From 5ce28f976b6e59392741ca139f9ce89f7894feae Mon Sep 17 00:00:00 2001 From: Harris Date: Wed, 16 Jun 2021 16:05:08 +1000 Subject: [PATCH 1/3] feat: extracting QR related strings and other github mentioned strings --- .../securesms/loki/activities/LinkDeviceActivity.kt | 10 +++++----- .../securesms/loki/activities/PathActivity.kt | 8 ++++---- app/src/main/res/values/strings.xml | 3 +++ app/src/main/res/xml/preferences_notifications.xml | 4 ++-- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/loki/activities/LinkDeviceActivity.kt b/app/src/main/java/org/thoughtcrime/securesms/loki/activities/LinkDeviceActivity.kt index 20f8fcf795..19f195b009 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/loki/activities/LinkDeviceActivity.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/loki/activities/LinkDeviceActivity.kt @@ -22,17 +22,17 @@ import kotlinx.coroutines.flow.collect import kotlinx.coroutines.flow.filter import kotlinx.coroutines.launch import network.loki.messenger.R +import org.session.libsession.utilities.KeyPairUtilities import org.session.libsession.utilities.TextSecurePreferences -import org.session.libsignal.utilities.KeyHelper import org.session.libsignal.crypto.MnemonicCodec -import org.session.libsignal.utilities.hexEncodedPublicKey import org.session.libsignal.utilities.Hex +import org.session.libsignal.utilities.KeyHelper import org.session.libsignal.utilities.Log +import org.session.libsignal.utilities.hexEncodedPublicKey import org.thoughtcrime.securesms.ApplicationContext import org.thoughtcrime.securesms.BaseActionBarActivity import org.thoughtcrime.securesms.loki.fragments.ScanQRCodeWrapperFragment import org.thoughtcrime.securesms.loki.fragments.ScanQRCodeWrapperFragmentDelegate -import org.session.libsession.utilities.KeyPairUtilities import org.thoughtcrime.securesms.loki.utilities.MnemonicUtilities import org.thoughtcrime.securesms.loki.utilities.push import org.thoughtcrime.securesms.loki.utilities.setUpActionBarSessionLogo @@ -166,8 +166,8 @@ private class LinkDeviceActivityAdapter(private val activity: LinkDeviceActivity override fun getPageTitle(index: Int): CharSequence { return when (index) { - 0 -> "Recovery Phrase" - 1 -> "Scan QR Code" + 0 -> activity.getString(R.string.fragment_recovery_phrase_title) + 1 -> activity.getString(R.string.activity_qr_code_view_scan_qr_code_tab_title) else -> throw IllegalStateException() } } diff --git a/app/src/main/java/org/thoughtcrime/securesms/loki/activities/PathActivity.kt b/app/src/main/java/org/thoughtcrime/securesms/loki/activities/PathActivity.kt index f7e91da108..2a06562bdf 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/loki/activities/PathActivity.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/loki/activities/PathActivity.kt @@ -7,7 +7,6 @@ import android.content.IntentFilter import android.net.Uri import android.os.Bundle import android.os.Handler -import androidx.localbroadcastmanager.content.LocalBroadcastManager import android.util.AttributeSet import android.util.TypedValue import android.view.Gravity @@ -17,14 +16,15 @@ import android.widget.RelativeLayout import android.widget.TextView import android.widget.Toast import androidx.annotation.ColorRes +import androidx.localbroadcastmanager.content.LocalBroadcastManager import kotlinx.android.synthetic.main.activity_path.* import network.loki.messenger.R import org.session.libsession.snode.OnionRequestAPI +import org.session.libsignal.utilities.Snode import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity import org.thoughtcrime.securesms.loki.utilities.* import org.thoughtcrime.securesms.loki.views.GlowViewUtilities import org.thoughtcrime.securesms.loki.views.PathDotView -import org.session.libsignal.utilities.Snode class PathActivity : PassphraseRequiredActionBarActivity() { private val broadcastReceivers = mutableListOf() @@ -148,9 +148,9 @@ class PathActivity : PassphraseRequiredActionBarActivity() { private fun getPathRow(snode: Snode, location: LineView.Location, dotAnimationStartDelay: Long, dotAnimationRepeatInterval: Long, isGuardSnode: Boolean): LinearLayout { val title = if (isGuardSnode) resources.getString(R.string.activity_path_guard_node_row_title) else resources.getString(R.string.activity_path_service_node_row_title) val subtitle = if (IP2Country.isInitialized) { - IP2Country.shared.countryNamesCache[snode.ip] ?: "Resolving..." + IP2Country.shared.countryNamesCache[snode.ip] ?: resources.getString(R.string.activity_path_resolving_progress) } else { - "Resolving..." + resources.getString(R.string.activity_path_resolving_progress) } return getPathRow(title, subtitle, location, dotAnimationStartDelay, dotAnimationRepeatInterval) } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index b8d6c578d4..70c46a95a9 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -713,6 +713,7 @@ Service Node Destination Learn More + Resolving… New Session Enter Session ID @@ -765,6 +766,8 @@ Chats Notification Strategy + Use Fast Mode + You’ll be notified of new messages reliably and immediately using Google’s notification servers. Change name Unlink device diff --git a/app/src/main/res/xml/preferences_notifications.xml b/app/src/main/res/xml/preferences_notifications.xml index 76fff3f6d6..d2a299d9a7 100644 --- a/app/src/main/res/xml/preferences_notifications.xml +++ b/app/src/main/res/xml/preferences_notifications.xml @@ -26,8 +26,8 @@ From b0dab208d23bcb921f23eb6f1a0262a7a63e4786 Mon Sep 17 00:00:00 2001 From: Harris Date: Wed, 16 Jun 2021 16:14:06 +1000 Subject: [PATCH 2/3] feat: extracting more strings, replacing link device strings using existing activities in case they change in future --- .../securesms/loki/activities/LinkDeviceActivity.kt | 6 +++--- app/src/main/res/values/strings.xml | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/loki/activities/LinkDeviceActivity.kt b/app/src/main/java/org/thoughtcrime/securesms/loki/activities/LinkDeviceActivity.kt index 19f195b009..ec2a76e760 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/loki/activities/LinkDeviceActivity.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/loki/activities/LinkDeviceActivity.kt @@ -157,7 +157,7 @@ private class LinkDeviceActivityAdapter(private val activity: LinkDeviceActivity 1 -> { val result = ScanQRCodeWrapperFragment() result.delegate = activity - result.message = "Navigate to Settings → Recovery Phrase on your other device to show your QR code." + result.message = activity.getString(R.string.activity_link_device_qr_message) result } else -> throw IllegalStateException() @@ -166,8 +166,8 @@ private class LinkDeviceActivityAdapter(private val activity: LinkDeviceActivity override fun getPageTitle(index: Int): CharSequence { return when (index) { - 0 -> activity.getString(R.string.fragment_recovery_phrase_title) - 1 -> activity.getString(R.string.activity_qr_code_view_scan_qr_code_tab_title) + 0 -> activity.getString(R.string.activity_link_device_recovery_phrase) + 1 -> activity.getString(R.string.activity_link_device_scan_qr_code) else -> throw IllegalStateException() } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 70c46a95a9..940ea443d8 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -831,6 +831,9 @@ This is taking a while, would you like to skip? Link a Device + Recovery Phrase + Scan QR Code + Navigate to Settings → Recovery Phrase on your other device to show your QR code. Or join one of these… Message Notifications From 9af804ec2101344950ff3b162d4cde358cf95859 Mon Sep 17 00:00:00 2001 From: Brice-W Date: Wed, 16 Jun 2021 16:43:33 +1000 Subject: [PATCH 3/3] don't close the cursor if it's the same that is in the parameters --- .../securesms/mediapreview/MediaPreviewViewModel.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/mediapreview/MediaPreviewViewModel.java b/app/src/main/java/org/thoughtcrime/securesms/mediapreview/MediaPreviewViewModel.java index 259579a59c..91dad13848 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/mediapreview/MediaPreviewViewModel.java +++ b/app/src/main/java/org/thoughtcrime/securesms/mediapreview/MediaPreviewViewModel.java @@ -28,7 +28,7 @@ public class MediaPreviewViewModel extends ViewModel { public void setCursor(@NonNull Context context, @Nullable Cursor cursor, boolean leftIsRecent) { boolean firstLoad = (this.cursor == null) && (cursor != null); - if (this.cursor != null) { + if (this.cursor != null && !this.cursor.equals(cursor)) { this.cursor.close(); } this.cursor = cursor;