Skip to content

Commit

Permalink
Merge pull request #2463 from vector-im/feature/ons/change_pin
Browse files Browse the repository at this point in the history
Change PIN
  • Loading branch information
bmarty authored Nov 30, 2020
2 parents d759636 + 694397e commit 396dd5e
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Features ✨:
-

Improvements 🙌:
-
- Add Setting Item to Change PIN (#2462)

Bugfix 🐛:
- Double bottomsheet effect after verify with passphrase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down
3 changes: 2 additions & 1 deletion vector/src/main/java/im/vector/app/features/pin/PinMode.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ package im.vector.app.features.pin

enum class PinMode {
CREATE,
AUTH
AUTH,
MODIFY
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -41,6 +42,10 @@ class VectorSettingsPinFragment @Inject constructor(
findPreference<SwitchPreference>(VectorPreferences.SETTINGS_SECURITY_USE_PIN_CODE_FLAG)!!
}

private val changePinCodePref by lazy {
findPreference<VectorPreference>(VectorPreferences.SETTINGS_SECURITY_CHANGE_PIN_CODE_FLAG)!!
}

private val useCompleteNotificationPref by lazy {
findPreference<SwitchPreference>(VectorPreferences.SETTINGS_SECURITY_USE_COMPLETE_NOTIFICATIONS_FLAG)!!
}
Expand Down Expand Up @@ -74,6 +79,17 @@ class VectorSettingsPinFragment @Inject constructor(
}
true
}

changePinCodePref.onPreferenceClickListener = Preference.OnPreferenceClickListener {
if (hasPinCode) {
navigator.openPinCode(
requireContext(),
pinActivityResultLauncher,
PinMode.MODIFY
)
}
true
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions vector/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2686,6 +2686,8 @@
<string name="settings_security_pin_code_grace_period_title">Require PIN after 2 minutes</string>
<string name="settings_security_pin_code_grace_period_summary_on">PIN code is required after 2 minutes of not using Element.</string>
<string name="settings_security_pin_code_grace_period_summary_off">PIN code is required every time you open Element.</string>
<string name="settings_security_pin_code_change_pin_title">Change PIN</string>
<string name="settings_security_pin_code_change_pin_summary">Change your current PIN</string>
<string name="auth_pin_confirm_to_disable_title">Confirm PIN to disable PIN</string>
<string name="error_opening_banned_room">Can\'t open a room where you are banned from.</string>
<string name="room_error_not_found">Can\'t find this room. Make sure it exists.</string>
Expand Down
6 changes: 6 additions & 0 deletions vector/src/main/res/xml/vector_settings_pin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
android:summary="@string/settings_security_pin_code_summary"
android:title="@string/settings_security_pin_code_title" />

<im.vector.app.core.preference.VectorPreference
android:dependency="SETTINGS_SECURITY_USE_PIN_CODE_FLAG"
android:key="SETTINGS_SECURITY_CHANGE_PIN_CODE_FLAG"
android:summary="@string/settings_security_pin_code_change_pin_summary"
android:title="@string/settings_security_pin_code_change_pin_title" />

<im.vector.app.core.preference.VectorSwitchPreference
android:defaultValue="true"
android:dependency="SETTINGS_SECURITY_USE_PIN_CODE_FLAG"
Expand Down

0 comments on commit 396dd5e

Please sign in to comment.