aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/org/connectbot/SettingsActivity.java28
1 files changed, 27 insertions, 1 deletions
diff --git a/src/org/connectbot/SettingsActivity.java b/src/org/connectbot/SettingsActivity.java
index 422e1df..1d4991f 100644
--- a/src/org/connectbot/SettingsActivity.java
+++ b/src/org/connectbot/SettingsActivity.java
@@ -18,15 +18,41 @@
package org.connectbot;
+import org.connectbot.util.PreferenceConstants;
+
+import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceActivity;
+import android.preference.PreferenceManager;
+import android.util.Log;
public class SettingsActivity extends PreferenceActivity {
+ private static final String TAG = "ConnectBot.Settings";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- addPreferencesFromResource(R.xml.preferences);
+ try {
+ addPreferencesFromResource(R.xml.preferences);
+ } catch (ClassCastException e) {
+ Log.e(TAG, "Shared preferences are corrupt! Resetting to default values.");
+
+ SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
+
+ // Blow away all the preferences
+ SharedPreferences.Editor editor = preferences.edit();
+ editor.clear();
+ editor.commit();
+
+ PreferenceManager.setDefaultValues(this, R.xml.preferences, true);
+
+ // Since they were able to get to the Settings activity, they already agreed to the EULA
+ editor = preferences.edit();
+ editor.putBoolean(PreferenceConstants.EULA, true);
+ editor.commit();
+
+ addPreferencesFromResource(R.xml.preferences);
+ }
// TODO: add parse checking here to make sure we have integer value for scrollback