mirror of
https://github.com/beemdevelopment/Aegis.git
synced 2025-05-14 05:52:52 +00:00
Apply a hack to detect programmatic changes to SwitchPreference
This commit is contained in:
parent
cd781d3236
commit
f8891c0225
3 changed files with 51 additions and 3 deletions
|
@ -10,7 +10,6 @@ import android.os.Bundle;
|
||||||
import android.preference.EditTextPreference;
|
import android.preference.EditTextPreference;
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
import android.preference.PreferenceFragment;
|
import android.preference.PreferenceFragment;
|
||||||
import android.preference.SwitchPreference;
|
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
|
@ -40,6 +39,7 @@ import me.impy.aegis.importers.AegisImporter;
|
||||||
import me.impy.aegis.importers.DatabaseImporter;
|
import me.impy.aegis.importers.DatabaseImporter;
|
||||||
import me.impy.aegis.importers.DatabaseImporterException;
|
import me.impy.aegis.importers.DatabaseImporterException;
|
||||||
import me.impy.aegis.ui.dialogs.PasswordDialogFragment;
|
import me.impy.aegis.ui.dialogs.PasswordDialogFragment;
|
||||||
|
import me.impy.aegis.ui.preferences.SwitchPreference;
|
||||||
import me.impy.aegis.util.ByteInputStream;
|
import me.impy.aegis.util.ByteInputStream;
|
||||||
|
|
||||||
public class PreferencesFragment extends PreferenceFragment implements PasswordDialogFragment.Listener {
|
public class PreferencesFragment extends PreferenceFragment implements PasswordDialogFragment.Listener {
|
||||||
|
@ -413,7 +413,7 @@ public class PreferencesFragment extends PreferenceFragment implements PasswordD
|
||||||
|
|
||||||
private void updateEncryptionPreference() {
|
private void updateEncryptionPreference() {
|
||||||
boolean encrypted = _db.getFile().isEncrypted();
|
boolean encrypted = _db.getFile().isEncrypted();
|
||||||
_encryptionPreference.setChecked(encrypted);
|
_encryptionPreference.setChecked(encrypted, true);
|
||||||
_slotsPreference.setEnabled(encrypted);
|
_slotsPreference.setEnabled(encrypted);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
package me.impy.aegis.ui.preferences;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.support.annotation.RequiresApi;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
|
||||||
|
public class SwitchPreference extends android.preference.SwitchPreference {
|
||||||
|
private OnPreferenceChangeListener _listener;
|
||||||
|
|
||||||
|
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||||
|
public SwitchPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||||
|
super(context, attrs, defStyleAttr, defStyleRes);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SwitchPreference(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||||
|
super(context, attrs, defStyleAttr);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SwitchPreference(Context context, AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SwitchPreference(Context context) {
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setOnPreferenceChangeListener(OnPreferenceChangeListener listener) {
|
||||||
|
super.setOnPreferenceChangeListener(listener);
|
||||||
|
_listener = listener;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setChecked(boolean checked) {
|
||||||
|
setChecked(true, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setChecked(boolean checked, boolean silent) {
|
||||||
|
if (silent) {
|
||||||
|
super.setOnPreferenceChangeListener(null);
|
||||||
|
}
|
||||||
|
super.setChecked(checked);
|
||||||
|
if (silent) {
|
||||||
|
super.setOnPreferenceChangeListener(_listener);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -31,7 +31,7 @@
|
||||||
android:inputType="number"
|
android:inputType="number"
|
||||||
android:defaultValue="30"
|
android:defaultValue="30"
|
||||||
android:dialogTitle="Set number of seconds of inactivity before Aegis locks the database"/>
|
android:dialogTitle="Set number of seconds of inactivity before Aegis locks the database"/>
|
||||||
<SwitchPreference
|
<me.impy.aegis.ui.preferences.SwitchPreference
|
||||||
android:key="pref_encryption"
|
android:key="pref_encryption"
|
||||||
android:title="@string/pref_encryption_title"
|
android:title="@string/pref_encryption_title"
|
||||||
android:summary="@string/pref_encryption_summary"
|
android:summary="@string/pref_encryption_summary"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue