no confirmation/no deletion when using sd-card directory

This commit is contained in:
Mohamed Zenadi 2016-04-27 23:59:34 +02:00
parent 5a532cbc11
commit c866596d13
2 changed files with 4 additions and 23 deletions

View file

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

View file

@ -15,7 +15,7 @@
android:title="@string/pref_ssh_see_key_title" />
<Preference
android:key="git_delete_repo"
android:summary="Deletes local repository"
android:summary="Deletes local (hidden) repository"
android:title="@string/pref_git_delete_repo" />
<CheckBoxPreference
android:key="git_external"
@ -25,11 +25,6 @@
android:dependency="git_external"
android:key="pref_select_external"
android:title="Select external repository" />
<CheckBoxPreference
android:enabled="false"
android:key="git_enabled"
android:summary="Enable Git"
android:title="Enable git" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/pref_crypto_title">