From ded0370e8e376a9fecb349c517c0b99a54a68d06 Mon Sep 17 00:00:00 2001 From: Harris Date: Thu, 2 Sep 2021 10:19:43 +1000 Subject: [PATCH 1/3] feat: add gif metadata warning --- .../conversation/v2/ConversationActivityV2.kt | 23 +++++++++++++++---- .../utilities/TextSecurePreferences.kt | 10 ++++++++ 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt index c25d157bb3..ce06e86c1a 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt @@ -3,10 +3,7 @@ package org.thoughtcrime.securesms.conversation.v2 import android.Manifest import android.animation.FloatEvaluator import android.animation.ValueAnimator -import android.content.ClipData -import android.content.ClipboardManager -import android.content.Context -import android.content.Intent +import android.content.* import android.content.res.Resources import android.database.Cursor import android.graphics.Rect @@ -972,7 +969,23 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe } private fun showGIFPicker() { - AttachmentManager.selectGif(this, ConversationActivityV2.PICK_GIF) + val hasSeenGIFMetaDataWarning: Boolean = TextSecurePreferences.hasSeenGIFMetaDataWarning(this) + if (!hasSeenGIFMetaDataWarning) { + val builder = AlertDialog.Builder(this) + builder.setTitle("Search GIFs?") + builder.setMessage("You will not have full metadata protection when sending GIFs.") + builder.setPositiveButton("OK") { dialog: DialogInterface, which: Int -> + AttachmentManager.selectGif(this, ConversationActivityV2.PICK_GIF) + dialog.dismiss() + } + builder.setNegativeButton( + "Cancel" + ) { dialog: DialogInterface, which: Int -> dialog.dismiss() } + builder.create().show() + TextSecurePreferences.setHasSeenGIFMetaDataWarning(this) + } else { + AttachmentManager.selectGif(this, ConversationActivityV2.PICK_GIF) + } } private fun showDocumentPicker() { diff --git a/libsession/src/main/java/org/session/libsession/utilities/TextSecurePreferences.kt b/libsession/src/main/java/org/session/libsession/utilities/TextSecurePreferences.kt index 7ac0feae6d..ab9bdcc08f 100644 --- a/libsession/src/main/java/org/session/libsession/utilities/TextSecurePreferences.kt +++ b/libsession/src/main/java/org/session/libsession/utilities/TextSecurePreferences.kt @@ -285,6 +285,16 @@ object TextSecurePreferences { setBooleanPreference(context, LINK_PREVIEWS, enabled) } + @JvmStatic + fun hasSeenGIFMetaDataWarning(context: Context): Boolean { + return getBooleanPreference(context, "has_seen_gif_metadata_warning", false) + } + + @JvmStatic + fun setHasSeenGIFMetaDataWarning(context: Context) { + setBooleanPreference(context, "has_seen_gif_metadata_warning", true) + } + @JvmStatic fun isGifSearchInGridLayout(context: Context): Boolean { return getBooleanPreference(context, GIF_GRID_LAYOUT, false) From adeffbdc0718d7f8879baf54e84188a8b427f646 Mon Sep 17 00:00:00 2001 From: Harris Date: Thu, 2 Sep 2021 10:21:14 +1000 Subject: [PATCH 2/3] feat: replace hardcoded with const string --- .../session/libsession/utilities/TextSecurePreferences.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libsession/src/main/java/org/session/libsession/utilities/TextSecurePreferences.kt b/libsession/src/main/java/org/session/libsession/utilities/TextSecurePreferences.kt index ab9bdcc08f..8c67a36b80 100644 --- a/libsession/src/main/java/org/session/libsession/utilities/TextSecurePreferences.kt +++ b/libsession/src/main/java/org/session/libsession/utilities/TextSecurePreferences.kt @@ -80,6 +80,7 @@ object TextSecurePreferences { const val UNIVERSAL_UNIDENTIFIED_ACCESS = "pref_universal_unidentified_access" const val TYPING_INDICATORS = "pref_typing_indicators" const val LINK_PREVIEWS = "pref_link_previews" + private const val GIF_METADATA_WARNING = "has_seen_gif_metadata_warning" private const val GIF_GRID_LAYOUT = "pref_gif_grid_layout" const val IS_USING_FCM = "pref_is_using_fcm" private const val FCM_TOKEN = "pref_fcm_token" @@ -287,12 +288,12 @@ object TextSecurePreferences { @JvmStatic fun hasSeenGIFMetaDataWarning(context: Context): Boolean { - return getBooleanPreference(context, "has_seen_gif_metadata_warning", false) + return getBooleanPreference(context, GIF_METADATA_WARNING, false) } @JvmStatic fun setHasSeenGIFMetaDataWarning(context: Context) { - setBooleanPreference(context, "has_seen_gif_metadata_warning", true) + setBooleanPreference(context, GIF_METADATA_WARNING, true) } @JvmStatic From b1535940f9f9f258366db3707335913e6b751cee Mon Sep 17 00:00:00 2001 From: Harris Date: Fri, 3 Sep 2021 13:53:49 +1000 Subject: [PATCH 3/3] refactor: move the set has seen to positive button handler --- .../securesms/conversation/v2/ConversationActivityV2.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt index ce06e86c1a..c439862bac 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt @@ -975,6 +975,7 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe builder.setTitle("Search GIFs?") builder.setMessage("You will not have full metadata protection when sending GIFs.") builder.setPositiveButton("OK") { dialog: DialogInterface, which: Int -> + TextSecurePreferences.setHasSeenGIFMetaDataWarning(this) AttachmentManager.selectGif(this, ConversationActivityV2.PICK_GIF) dialog.dismiss() } @@ -982,7 +983,6 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe "Cancel" ) { dialog: DialogInterface, which: Int -> dialog.dismiss() } builder.create().show() - TextSecurePreferences.setHasSeenGIFMetaDataWarning(this) } else { AttachmentManager.selectGif(this, ConversationActivityV2.PICK_GIF) }