Search in sources :

Example 21 with NonNull

use of android.support.annotation.NonNull in project Signal-Android by WhisperSystems.

the class IdentityKeyUtil method getIdentityKeyPair.

@NonNull
public static IdentityKeyPair getIdentityKeyPair(@NonNull Context context) {
    if (!hasIdentityKey(context))
        throw new AssertionError("There isn't one!");
    try {
        IdentityKey publicKey = getIdentityKey(context);
        ECPrivateKey privateKey = Curve.decodePrivatePoint(Base64.decode(retrieve(context, IDENTITY_PRIVATE_KEY_PREF)));
        return new IdentityKeyPair(publicKey, privateKey);
    } catch (IOException e) {
        throw new AssertionError(e);
    }
}
Also used : ECPrivateKey(org.whispersystems.libsignal.ecc.ECPrivateKey) IdentityKey(org.whispersystems.libsignal.IdentityKey) IOException(java.io.IOException) IdentityKeyPair(org.whispersystems.libsignal.IdentityKeyPair) NonNull(android.support.annotation.NonNull)

Example 22 with NonNull

use of android.support.annotation.NonNull in project Signal-Android by WhisperSystems.

the class AttachmentDatabase method getPendingAttachments.

@NonNull
public List<DatabaseAttachment> getPendingAttachments() {
    final SQLiteDatabase database = databaseHelper.getReadableDatabase();
    final List<DatabaseAttachment> attachments = new LinkedList<>();
    Cursor cursor = null;
    try {
        cursor = database.query(TABLE_NAME, PROJECTION, TRANSFER_STATE + " = ?", new String[] { String.valueOf(TRANSFER_PROGRESS_STARTED) }, null, null, null);
        while (cursor != null && cursor.moveToNext()) {
            attachments.add(getAttachment(cursor));
        }
    } finally {
        if (cursor != null)
            cursor.close();
    }
    return attachments;
}
Also used : SQLiteDatabase(android.database.sqlite.SQLiteDatabase) DatabaseAttachment(org.thoughtcrime.securesms.attachments.DatabaseAttachment) Cursor(android.database.Cursor) LinkedList(java.util.LinkedList) NonNull(android.support.annotation.NonNull)

Example 23 with NonNull

use of android.support.annotation.NonNull in project Signal-Android by WhisperSystems.

the class AttachmentDatabase method getAttachmentsForMessage.

@NonNull
public List<DatabaseAttachment> getAttachmentsForMessage(long mmsId) {
    SQLiteDatabase database = databaseHelper.getReadableDatabase();
    List<DatabaseAttachment> results = new LinkedList<>();
    Cursor cursor = null;
    try {
        cursor = database.query(TABLE_NAME, PROJECTION, MMS_ID + " = ?", new String[] { mmsId + "" }, null, null, null);
        while (cursor != null && cursor.moveToNext()) {
            results.add(getAttachment(cursor));
        }
        return results;
    } finally {
        if (cursor != null)
            cursor.close();
    }
}
Also used : SQLiteDatabase(android.database.sqlite.SQLiteDatabase) DatabaseAttachment(org.thoughtcrime.securesms.attachments.DatabaseAttachment) Cursor(android.database.Cursor) LinkedList(java.util.LinkedList) NonNull(android.support.annotation.NonNull)

Example 24 with NonNull

use of android.support.annotation.NonNull in project Signal-Android by WhisperSystems.

the class AttachmentDatabase method setAttachmentData.

@NonNull
private Pair<File, Long> setAttachmentData(@NonNull MasterSecret masterSecret, @NonNull InputStream in) throws MmsException {
    try {
        File partsDirectory = context.getDir("parts", Context.MODE_PRIVATE);
        File dataFile = File.createTempFile("part", ".mms", partsDirectory);
        return new Pair<>(dataFile, setAttachmentData(masterSecret, dataFile, in));
    } catch (IOException e) {
        throw new MmsException(e);
    }
}
Also used : MmsException(ws.com.google.android.mms.MmsException) IOException(java.io.IOException) File(java.io.File) Pair(android.util.Pair) NonNull(android.support.annotation.NonNull)

Example 25 with NonNull

use of android.support.annotation.NonNull in project Signal-Android by WhisperSystems.

the class SmsDatabase method insertCallLog.

@NonNull
private Pair<Long, Long> insertCallLog(@NonNull String number, long type, boolean unread) {
    Recipients recipients = RecipientFactory.getRecipientsFromString(context, number, true);
    long threadId = DatabaseFactory.getThreadDatabase(context).getThreadIdFor(recipients);
    ContentValues values = new ContentValues(6);
    values.put(ADDRESS, number);
    values.put(ADDRESS_DEVICE_ID, 1);
    values.put(DATE_RECEIVED, System.currentTimeMillis());
    values.put(DATE_SENT, System.currentTimeMillis());
    values.put(READ, unread ? 0 : 1);
    values.put(TYPE, type);
    values.put(THREAD_ID, threadId);
    SQLiteDatabase db = databaseHelper.getWritableDatabase();
    long messageId = db.insert(TABLE_NAME, null, values);
    DatabaseFactory.getThreadDatabase(context).update(threadId, true);
    notifyConversationListeners(threadId);
    jobManager.add(new TrimThreadJob(context, threadId));
    if (unread) {
        DatabaseFactory.getThreadDatabase(context).setUnread(threadId);
    }
    return new Pair<>(messageId, threadId);
}
Also used : ContentValues(android.content.ContentValues) TrimThreadJob(org.thoughtcrime.securesms.jobs.TrimThreadJob) Recipients(org.thoughtcrime.securesms.recipients.Recipients) SQLiteDatabase(android.database.sqlite.SQLiteDatabase) Pair(android.util.Pair) NonNull(android.support.annotation.NonNull)

Aggregations

NonNull (android.support.annotation.NonNull)610 TextView (android.widget.TextView)65 View (android.view.View)64 ArrayList (java.util.ArrayList)57 Test (org.junit.Test)45 Intent (android.content.Intent)38 Cursor (android.database.Cursor)35 ContentValues (android.content.ContentValues)32 Bundle (android.os.Bundle)32 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)29 IOException (java.io.IOException)27 DialogAction (com.afollestad.materialdialogs.DialogAction)25 AlertDialog (android.support.v7.app.AlertDialog)24 Override (java.lang.Override)24 DialogInterface (android.content.DialogInterface)22 File (java.io.File)21 WorkerThread (android.support.annotation.WorkerThread)19 RecyclerView (android.support.v7.widget.RecyclerView)19 ImageView (android.widget.ImageView)19 HashMap (java.util.HashMap)19