Merge pull request #2463 from vector-im/feature/ons/change_pin

Change PIN
This commit is contained in:
Benoit Marty 2020-11-30 13:45:09 +01:00 committed by GitHub
commit 396dd5e36e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 29 additions and 2 deletions

View file

@ -5,7 +5,7 @@ Features ✨:
-
Improvements 🙌:
-
- Add Setting Item to Change PIN (#2462)
Bugfix 🐛:
- Double bottomsheet effect after verify with passphrase

View file

@ -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
}
}

View file

@ -18,5 +18,6 @@ package im.vector.app.features.pin
enum class PinMode {
CREATE,
AUTH
AUTH,
MODIFY
}

View file

@ -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"

View file

@ -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<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)!!
}
@ -74,6 +79,17 @@ class VectorSettingsPinFragment @Inject constructor(
}
true
}
changePinCodePref.onPreferenceClickListener = Preference.OnPreferenceClickListener {
if (hasPinCode) {
navigator.openPinCode(
requireContext(),
pinActivityResultLauncher,
PinMode.MODIFY
)
}
true
}
}
}

View file

@ -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>

View file

@ -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"