From 52b1adaf588f65a0f6016b93a8f1677c74f753b7 Mon Sep 17 00:00:00 2001 From: Ryan ZHAO Date: Mon, 9 Nov 2020 14:02:21 +1100 Subject: [PATCH 1/2] modify the database version number tags --- .../securesms/DatabaseUpgradeActivity.java | 60 +++++++++---------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/src/org/thoughtcrime/securesms/DatabaseUpgradeActivity.java b/src/org/thoughtcrime/securesms/DatabaseUpgradeActivity.java index 176ca5b84a..d2d1e5dd30 100644 --- a/src/org/thoughtcrime/securesms/DatabaseUpgradeActivity.java +++ b/src/org/thoughtcrime/securesms/DatabaseUpgradeActivity.java @@ -61,36 +61,36 @@ import network.loki.messenger.R; public class DatabaseUpgradeActivity extends BaseActivity { private static final String TAG = DatabaseUpgradeActivity.class.getSimpleName(); - public static final int NO_MORE_KEY_EXCHANGE_PREFIX_VERSION = 46; - public static final int MMS_BODY_VERSION = 46; - public static final int TOFU_IDENTITIES_VERSION = 50; - public static final int CURVE25519_VERSION = 63; - public static final int ASYMMETRIC_MASTER_SECRET_FIX_VERSION = 73; - public static final int NO_V1_VERSION = 83; - public static final int SIGNED_PREKEY_VERSION = 83; - public static final int NO_DECRYPT_QUEUE_VERSION = 113; - public static final int PUSH_DECRYPT_SERIAL_ID_VERSION = 131; - public static final int MIGRATE_SESSION_PLAINTEXT = 136; - public static final int CONTACTS_ACCOUNT_VERSION = 136; - public static final int MEDIA_DOWNLOAD_CONTROLS_VERSION = 151; - public static final int REDPHONE_SUPPORT_VERSION = 157; - public static final int NO_MORE_CANONICAL_DB_VERSION = 276; - public static final int PROFILES = 289; - public static final int SCREENSHOTS = 300; - public static final int PERSISTENT_BLOBS = 317; - public static final int INTERNALIZE_CONTACTS = 317; - public static final int SQLCIPHER = 334; - public static final int SQLCIPHER_COMPLETE = 352; - public static final int REMOVE_JOURNAL = 353; - public static final int REMOVE_CACHE = 354; - public static final int FULL_TEXT_SEARCH = 358; - public static final int BAD_IMPORT_CLEANUP = 373; - public static final int IMAGE_CACHE_CLEANUP = 406; - public static final int WORKMANAGER_MIGRATION = 408; - public static final int COLOR_MIGRATION = 412; - public static final int UNIDENTIFIED_DELIVERY = 422; - public static final int SIGNALING_KEY_DEPRECATION = 447; - public static final int CONVERSATION_SEARCH = 455; + public static final int NO_MORE_KEY_EXCHANGE_PREFIX_VERSION = 0; // 46 + public static final int MMS_BODY_VERSION = 0; // 46 + public static final int TOFU_IDENTITIES_VERSION = 1; // 50 + public static final int CURVE25519_VERSION = 2; // 63 + public static final int ASYMMETRIC_MASTER_SECRET_FIX_VERSION = 3; // 73 + public static final int NO_V1_VERSION = 4; // 83 + public static final int SIGNED_PREKEY_VERSION = 4; // 83 + public static final int NO_DECRYPT_QUEUE_VERSION = 5; // 113 + public static final int PUSH_DECRYPT_SERIAL_ID_VERSION = 6; // 131 + public static final int MIGRATE_SESSION_PLAINTEXT = 7; // 136 + public static final int CONTACTS_ACCOUNT_VERSION = 7; // 136 + public static final int MEDIA_DOWNLOAD_CONTROLS_VERSION = 8; // 151 + public static final int REDPHONE_SUPPORT_VERSION = 9; // 157 + public static final int NO_MORE_CANONICAL_DB_VERSION = 10; // 276 + public static final int PROFILES = 11; // 289 + public static final int SCREENSHOTS = 12; // 300 + public static final int PERSISTENT_BLOBS = 13; // 317 + public static final int INTERNALIZE_CONTACTS = 13; // 317 + public static final int SQLCIPHER = 14; // 334 + public static final int SQLCIPHER_COMPLETE = 15; // 352 + public static final int REMOVE_JOURNAL = 16; // 353 + public static final int REMOVE_CACHE = 17; // 354 + public static final int FULL_TEXT_SEARCH = 18; // 358 + public static final int BAD_IMPORT_CLEANUP = 19; // 373 + public static final int IMAGE_CACHE_CLEANUP = 20; // 406 + public static final int WORKMANAGER_MIGRATION = 21; // 408 + public static final int COLOR_MIGRATION = 22; // 412 + public static final int UNIDENTIFIED_DELIVERY = 23; // 422 + public static final int SIGNALING_KEY_DEPRECATION = 24; // 447 + public static final int CONVERSATION_SEARCH = 25; // 455 private static final SortedSet UPGRADE_VERSIONS = new TreeSet() {{ add(NO_MORE_KEY_EXCHANGE_PREFIX_VERSION); From 96f0f3abc9abe9f8097b788e6906a2fec9bc5ba5 Mon Sep 17 00:00:00 2001 From: Ryan ZHAO Date: Mon, 9 Nov 2020 14:07:35 +1100 Subject: [PATCH 2/2] complete the logic of push notification service --- .../loki/api/PushNotificationService.kt | 27 ++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/src/org/thoughtcrime/securesms/loki/api/PushNotificationService.kt b/src/org/thoughtcrime/securesms/loki/api/PushNotificationService.kt index 4e3ef4a700..340152d857 100644 --- a/src/org/thoughtcrime/securesms/loki/api/PushNotificationService.kt +++ b/src/org/thoughtcrime/securesms/loki/api/PushNotificationService.kt @@ -1,14 +1,11 @@ package org.thoughtcrime.securesms.loki.api -import android.R -import android.app.NotificationManager -import android.app.PendingIntent -import android.content.Intent -import android.graphics.Color -import android.media.RingtoneManager +import androidx.core.app.NotificationCompat +import androidx.core.app.NotificationManagerCompat import com.google.firebase.messaging.FirebaseMessagingService import com.google.firebase.messaging.RemoteMessage import org.thoughtcrime.securesms.jobs.PushContentReceiveJob +import org.thoughtcrime.securesms.notifications.NotificationChannels import org.thoughtcrime.securesms.util.TextSecurePreferences import org.whispersystems.libsignal.logging.Log import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope @@ -37,6 +34,24 @@ class PushNotificationService : FirebaseMessagingService() { } } else { Log.d("Loki", "Failed to decode data for message.") + val builder = NotificationCompat.Builder(this, NotificationChannels.OTHER) + .setSmallIcon(network.loki.messenger.R.drawable.ic_notification) + .setColor(this.getResources().getColor(network.loki.messenger.R.color.textsecure_primary)) + .setContentTitle("Session") + .setContentText("You've got a new message.") + .setPriority(NotificationCompat.PRIORITY_DEFAULT) + .setAutoCancel(true) + with(NotificationManagerCompat.from(this)) { + notify(11111, builder.build()) + } } } + + override fun onDeletedMessages() { + org.thoughtcrime.securesms.logging.Log.d("Loki", "Called onDeletedMessages.") + super.onDeletedMessages() + val token = TextSecurePreferences.getFCMToken(this) + val userPublicKey = TextSecurePreferences.getLocalNumber(this) ?: return + LokiPushNotificationManager.register(token, userPublicKey, this, true) + } } \ No newline at end of file