Merge branch 'dev' of https://github.com/loki-project/session-android into link-preview-for-any-site

This commit is contained in:
Ryan ZHAO 2020-11-16 13:18:27 +11:00
commit 798d7e227f
4 changed files with 56 additions and 41 deletions

View File

@ -190,8 +190,8 @@ dependencies {
testImplementation 'org.robolectric:shadows-multidex:4.2'
}
def canonicalVersionCode = 118
def canonicalVersionName = "1.6.3"
def canonicalVersionCode = 121
def canonicalVersionName = "1.6.4"
def postFixSize = 10
def abiPostFix = ['armeabi-v7a' : 1,

View File

@ -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<Integer> UPGRADE_VERSIONS = new TreeSet<Integer>() {{
add(NO_MORE_KEY_EXCHANGE_PREFIX_VERSION);

View File

@ -41,7 +41,7 @@ object LokiPushNotificationManager {
val body = RequestBody.create(MediaType.get("application/json"), JsonUtil.toJson(parameters))
val request = Request.Builder().url(url).post(body)
retryIfNeeded(maxRetryCount) {
OnionRequestAPI.sendOnionRequest(request.build(), server, pnServerPublicKey).map { json ->
OnionRequestAPI.sendOnionRequest(request.build(), server, pnServerPublicKey, "/loki/v2/lsrpc").map { json ->
val code = json["code"] as? Int
if (code != null && code != 0) {
TextSecurePreferences.setIsUsingFCM(context, false)
@ -70,7 +70,7 @@ object LokiPushNotificationManager {
val body = RequestBody.create(MediaType.get("application/json"), JsonUtil.toJson(parameters))
val request = Request.Builder().url(url).post(body)
retryIfNeeded(maxRetryCount) {
OnionRequestAPI.sendOnionRequest(request.build(), server, pnServerPublicKey).map { json ->
OnionRequestAPI.sendOnionRequest(request.build(), server, pnServerPublicKey, "/loki/v2/lsrpc").map { json ->
val code = json["code"] as? Int
if (code != null && code != 0) {
TextSecurePreferences.setIsUsingFCM(context, true)
@ -98,7 +98,7 @@ object LokiPushNotificationManager {
val body = RequestBody.create(MediaType.get("application/json"), JsonUtil.toJson(parameters))
val request = Request.Builder().url(url).post(body)
retryIfNeeded(maxRetryCount) {
OnionRequestAPI.sendOnionRequest(request.build(), server, pnServerPublicKey).map { json ->
OnionRequestAPI.sendOnionRequest(request.build(), server, pnServerPublicKey, "/loki/v2/lsrpc").map { json ->
val code = json["code"] as? Int
if (code == null || code == 0) {
Log.d("Loki", "Couldn't subscribe/unsubscribe closed group: $closedGroupPublicKey due to error: ${json["message"] as? String ?: "null"}.")

View File

@ -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)
}
}