Use switch preference for enabling app lock

This commit is contained in:
12aw 2024-02-17 07:27:15 +01:00
parent 0544fe4620
commit fe8cb18c54
5 changed files with 9 additions and 20 deletions

View file

@ -708,7 +708,7 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio
@Override
protected void onCreate(final Bundle savedInstanceState) {
// Check if lock is set
if (getBooleanPreference("app_is_locked", R.bool.app_is_locked)) {
if (getBooleanPreference("app_lock_enabled", R.bool.app_lock_enabled)) {
Intent intent = new Intent(this, UnlockActivity.class);
startActivityForResult(intent, REQUEST_CODE_ULOCK);
}

View file

@ -948,19 +948,6 @@ public class SettingsActivity extends XmppActivity implements OnSharedPreference
});
}
final Preference appUnLockPreference = mSettingsFragment.findPreference("app_lock_disabled");
if (appUnLockPreference != null) {
appUnLockPreference.setOnPreferenceClickListener(preference -> {
try {
SharedPreferences preferences = this.getPreferences();
preferences.edit().putBoolean(APP_IS_LOCKED, false).apply();
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(this, R.string.can_not_remove_lock, Toast.LENGTH_LONG).show();
}
return true;
});
}
final Preference prefereXmppAvatarPreference = mSettingsFragment.findPreference(PREFER_XMPP_AVATAR);
if (prefereXmppAvatarPreference != null) {
prefereXmppAvatarPreference.setOnPreferenceClickListener(preference -> {

View file

@ -12,4 +12,5 @@
<bool name="hide_donation_snackbar">false</bool>
<bool name="send_link_previews">true</bool>
<bool name="app_is_locked">false</bool>
<bool name="app_lock_enabled">false</bool>
</resources>

View file

@ -1417,6 +1417,6 @@
<string name="pref_app_lock_summary">Lock the app with a pin or fingerprint. Monocles chat will be locked after closed and can only be opened with the right pin or fingerprint again</string>
<string name="can_not_create_lock">Can\'t create pin or fingerprint</string>
<string name="can_not_remove_lock">Can not remove lock</string>
<string name="pref_app_lock_disable_title">Disable app lock</string>
<string name="pref_app_lock_disable_summary">Disable the app lock</string>
<string name="pref_app_lock_enable_title">Enable app lock</string>
<string name="pref_app_lock_enable_summary">Enable the app lock. Be aware you can\'t open the app anymore when you forgot the PIN.</string>
</resources>

View file

@ -710,10 +710,11 @@
android:key="app_lock"
android:summary="@string/pref_app_lock_summary"
android:title="@string/pref_app_lock_title" />
<Preference
android:key="app_lock_disabled"
android:summary="@string/pref_app_lock_disable_summary"
android:title="@string/pref_app_lock_disable_title" />
<SwitchPreference
android:defaultValue="@bool/app_lock_enabled"
android:key="app_lock_enabled"
android:summary="@string/pref_app_lock_enable_summary"
android:title="@string/pref_app_lock_enable_title" />
</PreferenceCategory>
<PreferenceCategory
android:key="connection_options"