From 221eddd9956c513cda3e9c3d063cbda38a1356ba Mon Sep 17 00:00:00 2001 From: Onuray Sahin Date: Fri, 27 Nov 2020 15:02:08 +0300 Subject: [PATCH 1/4] Add changelog. --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index 761d8a4634..9b57903455 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -15,6 +15,7 @@ Improvements 🙌: - Room creation form: add advanced section to disable federation (#1314) - Move "Enable Encryption" from room setting screen to room profile screen (#2394) - Improve Invite user screen (seamless search for matrix ID) + - Add Setting Item to Change PIN (#2462) Bugfix 🐛: - Fix crash on AttachmentViewer (#2365) From 89e7e28bfae672a4ea92d0ceb0677ddf7007381c Mon Sep 17 00:00:00 2001 From: Onuray Sahin Date: Fri, 27 Nov 2020 15:22:31 +0300 Subject: [PATCH 2/4] Add settings item to change pin. --- vector/src/main/res/values/strings.xml | 2 ++ vector/src/main/res/xml/vector_settings_pin.xml | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/vector/src/main/res/values/strings.xml b/vector/src/main/res/values/strings.xml index f82e7f6fe7..1641617fb1 100644 --- a/vector/src/main/res/values/strings.xml +++ b/vector/src/main/res/values/strings.xml @@ -2686,6 +2686,8 @@ Require PIN after 2 minutes PIN code is required after 2 minutes of not using Element. PIN code is required every time you open Element. + Change PIN + Change the current PIN, you will have to validate your current PIN first. Confirm PIN to disable PIN Can\'t open a room where you are banned from. Can\'t find this room. Make sure it exists. diff --git a/vector/src/main/res/xml/vector_settings_pin.xml b/vector/src/main/res/xml/vector_settings_pin.xml index 27eb275b09..20e240ee35 100644 --- a/vector/src/main/res/xml/vector_settings_pin.xml +++ b/vector/src/main/res/xml/vector_settings_pin.xml @@ -7,6 +7,12 @@ android:summary="@string/settings_security_pin_code_summary" android:title="@string/settings_security_pin_code_title" /> + + Date: Fri, 27 Nov 2020 17:17:24 +0300 Subject: [PATCH 3/4] Create a new pin when tap on change pin item. --- .../app/features/settings/VectorPreferences.kt | 1 + .../settings/VectorSettingsPinFragment.kt | 16 ++++++++++++++++ vector/src/main/res/values/strings.xml | 2 +- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt b/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt index 5872c1fa1c..9d6ed0246c 100755 --- a/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt +++ b/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt @@ -165,6 +165,7 @@ class VectorPreferences @Inject constructor(private val context: Context) { // Security const val SETTINGS_SECURITY_USE_FLAG_SECURE = "SETTINGS_SECURITY_USE_FLAG_SECURE" const val SETTINGS_SECURITY_USE_PIN_CODE_FLAG = "SETTINGS_SECURITY_USE_PIN_CODE_FLAG" + const val SETTINGS_SECURITY_CHANGE_PIN_CODE_FLAG = "SETTINGS_SECURITY_CHANGE_PIN_CODE_FLAG" private const val SETTINGS_SECURITY_USE_BIOMETRICS_FLAG = "SETTINGS_SECURITY_USE_BIOMETRICS_FLAG" private const val SETTINGS_SECURITY_USE_GRACE_PERIOD_FLAG = "SETTINGS_SECURITY_USE_GRACE_PERIOD_FLAG" const val SETTINGS_SECURITY_USE_COMPLETE_NOTIFICATIONS_FLAG = "SETTINGS_SECURITY_USE_COMPLETE_NOTIFICATIONS_FLAG" diff --git a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsPinFragment.kt b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsPinFragment.kt index 37465258f6..94328dc44a 100644 --- a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsPinFragment.kt +++ b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsPinFragment.kt @@ -21,6 +21,7 @@ import androidx.preference.Preference import androidx.preference.SwitchPreference import im.vector.app.R import im.vector.app.core.extensions.registerStartForActivityResult +import im.vector.app.core.preference.VectorPreference import im.vector.app.features.navigation.Navigator import im.vector.app.features.notifications.NotificationDrawerManager import im.vector.app.features.pin.PinCodeStore @@ -41,6 +42,10 @@ class VectorSettingsPinFragment @Inject constructor( findPreference(VectorPreferences.SETTINGS_SECURITY_USE_PIN_CODE_FLAG)!! } + private val changePinCodePref by lazy { + findPreference(VectorPreferences.SETTINGS_SECURITY_CHANGE_PIN_CODE_FLAG)!! + } + private val useCompleteNotificationPref by lazy { findPreference(VectorPreferences.SETTINGS_SECURITY_USE_COMPLETE_NOTIFICATIONS_FLAG)!! } @@ -74,6 +79,17 @@ class VectorSettingsPinFragment @Inject constructor( } true } + + changePinCodePref.onPreferenceClickListener = Preference.OnPreferenceClickListener { + if (hasPinCode) { + navigator.openPinCode( + requireContext(), + pinActivityResultLauncher, + PinMode.CREATE + ) + } + true + } } } diff --git a/vector/src/main/res/values/strings.xml b/vector/src/main/res/values/strings.xml index 1641617fb1..bbb09e8df8 100644 --- a/vector/src/main/res/values/strings.xml +++ b/vector/src/main/res/values/strings.xml @@ -2687,7 +2687,7 @@ PIN code is required after 2 minutes of not using Element. PIN code is required every time you open Element. Change PIN - Change the current PIN, you will have to validate your current PIN first. + Change your current PIN Confirm PIN to disable PIN Can\'t open a room where you are banned from. Can\'t find this room. Make sure it exists. From 694397efc18eaf38118328db25cc7329d70209d5 Mon Sep 17 00:00:00 2001 From: Onuray Sahin Date: Mon, 30 Nov 2020 13:51:40 +0300 Subject: [PATCH 4/4] Create a new pin mode for changing pin code. --- vector/src/main/java/im/vector/app/features/pin/PinFragment.kt | 1 + vector/src/main/java/im/vector/app/features/pin/PinMode.kt | 3 ++- .../vector/app/features/settings/VectorSettingsPinFragment.kt | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/pin/PinFragment.kt b/vector/src/main/java/im/vector/app/features/pin/PinFragment.kt index b6e238c2dc..378c7b853d 100644 --- a/vector/src/main/java/im/vector/app/features/pin/PinFragment.kt +++ b/vector/src/main/java/im/vector/app/features/pin/PinFragment.kt @@ -56,6 +56,7 @@ class PinFragment @Inject constructor( when (fragmentArgs.pinMode) { PinMode.CREATE -> showCreateFragment() PinMode.AUTH -> showAuthFragment() + PinMode.MODIFY -> showCreateFragment() // No need to create another function for now because texts are generic } } diff --git a/vector/src/main/java/im/vector/app/features/pin/PinMode.kt b/vector/src/main/java/im/vector/app/features/pin/PinMode.kt index c24ac5adf2..9801912bd6 100644 --- a/vector/src/main/java/im/vector/app/features/pin/PinMode.kt +++ b/vector/src/main/java/im/vector/app/features/pin/PinMode.kt @@ -18,5 +18,6 @@ package im.vector.app.features.pin enum class PinMode { CREATE, - AUTH + AUTH, + MODIFY } diff --git a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsPinFragment.kt b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsPinFragment.kt index 94328dc44a..1a04dab950 100644 --- a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsPinFragment.kt +++ b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsPinFragment.kt @@ -85,7 +85,7 @@ class VectorSettingsPinFragment @Inject constructor( navigator.openPinCode( requireContext(), pinActivityResultLauncher, - PinMode.CREATE + PinMode.MODIFY ) } true