Remove "reset" from the preferences page.

Currently, removing the cache does the job much better. The only thing
clearing the cache doesn't do which "reset" did is removing the databases. But
we don't want to do that anyway.

If someone wants to do that, they can just deactivate or remove a repo, and it
will get wiped from the database.
This commit is contained in:
Daniel Martí 2013-07-23 17:02:35 +02:00
parent 4de47bd810
commit 0c1b854b69
3 changed files with 10 additions and 53 deletions

View File

@ -63,8 +63,6 @@
android:key="ignoreTouchscreen" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/maintenance">
<Preference android:title="@string/reset" android:summary="@string/clear_all_cached_data"
android:key="reset" />
<CheckBoxPreference android:title="@string/expert"
android:defaultValue="false" android:summary="@string/expert_mode"
android:key="expert" />

View File

@ -231,8 +231,7 @@ public class FDroid extends FragmentActivity {
// unschedule) the service accordingly. It's cheap, so no need to
// check if the particular setting has actually been changed.
UpdateService.schedule(getBaseContext());
if (data != null
&& (data.hasExtra("reset") || data.hasExtra("update"))) {
if (data != null && data.hasExtra("update")) {
updateRepos();
} else {
repopulateViews();

View File

@ -37,63 +37,23 @@ public class Preferences extends PreferenceActivity implements
super.onCreate(savedInstanceState);
ActionBarCompat.create(this).setDisplayHomeAsUpEnabled(true);
addPreferencesFromResource(R.xml.preferences);
for (String prefkey : new String[] { "reset", "ignoreTouchscreen",
for (String prefkey : new String[] { "ignoreTouchscreen",
"showIncompatible" }) {
Preference pref = findPreference(prefkey);
pref.setOnPreferenceClickListener(this);
}
}
private void deleteAll(File dir) {
if (dir.isDirectory()) {
String[] children = dir.list();
for (int i = 0; i < children.length; i++) {
deleteAll(new File(dir, children[i]));
}
}
dir.delete();
}
@Override
public boolean onPreferenceClick(Preference preference) {
String key = preference.getKey();
if (key.equals("ignoreTouchscreen") || key.equals("showIncompatible")) {
Intent ret = new Intent();
ret.putExtra("update", true);
setResult(RESULT_OK, ret);
return true;
} else if (key.equals("reset")) {
// TODO: Progress dialog + thread is needed, it can take a
// while to delete all the icons and cached apks in a long
// standing install!
// TODO: This is going to cause problems if there is background
// update in progress at the time!
try {
DB db = DB.getDB();
db.reset();
} finally {
DB.releaseDB();
}
((FDroidApp) getApplication()).invalidateAllApps();
File dp = DB.getDataPath(this);
deleteAll(dp);
dp.mkdir();
DB.getIconsPath(this).mkdir();
Toast.makeText(getBaseContext(),
"Local cached data has been cleared", Toast.LENGTH_LONG)
.show();
Intent ret = new Intent();
ret.putExtra("reset", true);
setResult(RESULT_OK, ret);
finish();
return true;
}
return false;
// Currently only one action is returned.
//String key = preference.getKey();
//if (key.equals("ignoreTouchscreen") || key.equals("showIncompatible")) {
Intent ret = new Intent();
ret.putExtra("update", true);
setResult(RESULT_OK, ret);
return true;
//}
}
}