From c866596d135937f768b060c24c6e7b17e49d03ee Mon Sep 17 00:00:00 2001 From: Mohamed Zenadi Date: Wed, 27 Apr 2016 23:59:34 +0200 Subject: no confirmation/no deletion when using sd-card directory --- .../main/java/com/zeapo/pwdstore/UserPreference.java | 20 +++----------------- app/src/main/res/xml/preference.xml | 7 +------ 2 files changed, 4 insertions(+), 23 deletions(-) (limited to 'app/src') diff --git a/app/src/main/java/com/zeapo/pwdstore/UserPreference.java b/app/src/main/java/com/zeapo/pwdstore/UserPreference.java index 5fb710cf..57919624 100644 --- a/app/src/main/java/com/zeapo/pwdstore/UserPreference.java +++ b/app/src/main/java/com/zeapo/pwdstore/UserPreference.java @@ -183,6 +183,7 @@ public class UserPreference extends AppCompatActivity { Preference.OnPreferenceChangeListener resetRepo = new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object o) { + findPreference("git_delete_repo").setEnabled(!(Boolean) o); PasswordRepository.closeRepository(); getPreferenceManager().getSharedPreferences().edit().putBoolean("repo_changed", true).apply(); return true; @@ -233,6 +234,7 @@ public class UserPreference extends AppCompatActivity { final SharedPreferences sharedPreferences = getPreferenceManager().getSharedPreferences(); findPreference("pref_select_external").setSummary(getPreferenceManager().getSharedPreferences().getString("git_external_repo", "No external repository selected")); findPreference("ssh_see_key").setEnabled(sharedPreferences.getBoolean("use_generated_key", false)); + findPreference("git_delete_repo").setEnabled(!sharedPreferences.getBoolean("git_external", false)); // see if the autofill service is enabled and check the preference accordingly ((CheckBoxPreference) findPreference("autofill_enable")) @@ -408,23 +410,7 @@ public class UserPreference extends AppCompatActivity { setTitle("SD-Card root selected"). setMessage("You have selected the root of your sdcard for the store. " + "This is extremely dangerous and you will lose your data " + - "as its content will be deleted"). - setPositiveButton("Remove everything", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - PreferenceManager.getDefaultSharedPreferences(getApplicationContext()) - .edit() - .putString("git_external_repo", uri.getPath()) - .apply(); - } - }). - setNegativeButton(R.string.dialog_cancel, null).show(); - } else if (new File(uri.getPath()).listFiles().length != 0) { - new AlertDialog.Builder(this). - setTitle("Directory not empty"). - setMessage("You have selected a non-empty directory for the store. " + - "This is extremely dangerous and you will lose your data " + - "as its content will be deleted"). + "as its content will, eventually, be deleted"). setPositiveButton("Remove everything", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { diff --git a/app/src/main/res/xml/preference.xml b/app/src/main/res/xml/preference.xml index f8397bc3..ae07b296 100644 --- a/app/src/main/res/xml/preference.xml +++ b/app/src/main/res/xml/preference.xml @@ -15,7 +15,7 @@ android:title="@string/pref_ssh_see_key_title" /> - -- cgit v1.2.3