From c8a90ced1988630ff50f23a9abdf0437adb14576 Mon Sep 17 00:00:00 2001 From: Niels Andriesse Date: Mon, 7 Oct 2019 16:22:13 +1100 Subject: [PATCH] Add missing event --- res/values/strings.xml | 2 +- .../thoughtcrime/securesms/ApplicationContext.java | 1 - .../securesms/ApplicationPreferencesActivity.java | 4 +--- .../securesms/components/TypingStatusSender.java | 14 ++++++-------- .../securesms/loki/DatabaseUtilities.kt | 6 +++--- .../thoughtcrime/securesms/loki/SeedActivity.kt | 1 + 6 files changed, 12 insertions(+), 16 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index f0dfd8f41a..8810bc8536 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -1568,7 +1568,7 @@ Register Restore Link - Other Device Pub Key + Your Public Key Looks like you don\'t have any conversations yet. Get started by messaging a friend. diff --git a/src/org/thoughtcrime/securesms/ApplicationContext.java b/src/org/thoughtcrime/securesms/ApplicationContext.java index 963daa56ad..e2bde579ab 100644 --- a/src/org/thoughtcrime/securesms/ApplicationContext.java +++ b/src/org/thoughtcrime/securesms/ApplicationContext.java @@ -147,7 +147,6 @@ public class ApplicationContext extends MultiDexApplication implements Dependenc @Override public void onCreate() { super.onCreate(); -// LokiStorageAPI.Companion.setDebugMode(BuildConfig.DEBUG); LokiGroupChatAPI.Companion.setDebugMode(BuildConfig.DEBUG); // Loki - Set debug mode if needed startKovenant(); Log.i(TAG, "onCreate()"); diff --git a/src/org/thoughtcrime/securesms/ApplicationPreferencesActivity.java b/src/org/thoughtcrime/securesms/ApplicationPreferencesActivity.java index e49a66a13e..24086768df 100644 --- a/src/org/thoughtcrime/securesms/ApplicationPreferencesActivity.java +++ b/src/org/thoughtcrime/securesms/ApplicationPreferencesActivity.java @@ -182,12 +182,10 @@ public class ApplicationPreferencesActivity extends PassphraseRequiredActionBarA .setOnPreferenceClickListener(new CategoryClickListener(PREFERENCE_CATEGORY_PUBLIC_KEY)); this.findPreference(PREFERENCE_CATEGORY_QR_CODE) .setOnPreferenceClickListener(new CategoryClickListener(PREFERENCE_CATEGORY_QR_CODE)); - Preference linkDevicePreference = this.findPreference(PREFERENCE_CATEGORY_LINK_DEVICE); - // Hide if we're already a secondary device + // Hide if this is a slave device linkDevicePreference.setVisible(!TextSecurePreferences.isSecondaryDevice(getContext())); linkDevicePreference.setOnPreferenceClickListener(new CategoryClickListener(PREFERENCE_CATEGORY_LINK_DEVICE)); - this.findPreference(PREFERENCE_CATEGORY_SEED) .setOnPreferenceClickListener(new CategoryClickListener((PREFERENCE_CATEGORY_SEED))); diff --git a/src/org/thoughtcrime/securesms/components/TypingStatusSender.java b/src/org/thoughtcrime/securesms/components/TypingStatusSender.java index be1ff84bc4..4aec2e803b 100644 --- a/src/org/thoughtcrime/securesms/components/TypingStatusSender.java +++ b/src/org/thoughtcrime/securesms/components/TypingStatusSender.java @@ -86,21 +86,19 @@ public class TypingStatusSender { ThreadDatabase threadDatabase = DatabaseFactory.getThreadDatabase(context); Recipient originalRecipient = threadDatabase.getRecipientForThreadId(threadId); - // Send normal message if storage api wasn't found - if (storageAPI == null || originalRecipient == null) { + if (originalRecipient == null) { ApplicationContext.getInstance(context).getJobManager().add(new TypingSendJob(threadId, typingStarted)); return; } - MultiDeviceUtilKt.getAllDevices(context, originalRecipient.getAddress().serialize(), storageAPI, (devicePubKey, isFriend, friendCount) -> { - Recipient device = Recipient.from(context, Address.fromSerialized(devicePubKey), false); - long deviceThreadId = threadDatabase.getThreadIdIfExistsFor(device); - if (deviceThreadId > -1) { - ApplicationContext.getInstance(context).getJobManager().add(new TypingSendJob(deviceThreadId, typingStarted)); + MultiDeviceUtilKt.getAllDevices(context, originalRecipient.getAddress().serialize(), storageAPI, (devicePublicKey, isFriend, friendCount) -> { + Recipient device = Recipient.from(context, Address.fromSerialized(devicePublicKey), false); + long deviceThreadID = threadDatabase.getThreadIdIfExistsFor(device); + if (deviceThreadID > -1) { + ApplicationContext.getInstance(context).getJobManager().add(new TypingSendJob(deviceThreadID, typingStarted)); } return Unit.INSTANCE; }); - } private class StartRunnable implements Runnable { diff --git a/src/org/thoughtcrime/securesms/loki/DatabaseUtilities.kt b/src/org/thoughtcrime/securesms/loki/DatabaseUtilities.kt index 32edff8401..41613af87c 100644 --- a/src/org/thoughtcrime/securesms/loki/DatabaseUtilities.kt +++ b/src/org/thoughtcrime/securesms/loki/DatabaseUtilities.kt @@ -19,14 +19,14 @@ fun SQLiteDatabase.get(table: String, query: String, arguments: Array SQLiteDatabase.getAll(table: String, query: String, arguments: Array, get: (Cursor) -> T): List { - var list = mutableListOf() + val result = mutableListOf() var cursor: Cursor? = null try { cursor = query(table, null, query, arguments, null, null, null) while (cursor != null && cursor.moveToNext()) { - list.add(get(cursor)) + result.add(get(cursor)) } - return list + return result } catch (e: Exception) { // Do nothing } finally { diff --git a/src/org/thoughtcrime/securesms/loki/SeedActivity.kt b/src/org/thoughtcrime/securesms/loki/SeedActivity.kt index a51083562e..c2ff7532f2 100644 --- a/src/org/thoughtcrime/securesms/loki/SeedActivity.kt +++ b/src/org/thoughtcrime/securesms/loki/SeedActivity.kt @@ -221,6 +221,7 @@ class SeedActivity : BaseActionBarActivity() { // Show the dialog val dialog = DeviceLinkingDialog.show(this, DeviceLinkingView.Mode.Slave, object: DeviceLinkingDialogDelegate { override fun handleDeviceLinkAuthorized() { + Analytics.shared.track("Device Linked Successfully") showAccountDetailsView() }