diff --git a/res/layout/debug.xml b/res/layout/debug.xml
deleted file mode 100644
index f98f7ffdf..000000000
--- a/res/layout/debug.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-
-
-
-
diff --git a/res/menu/debug_option.xml b/res/menu/debug_option.xml
deleted file mode 100644
index 7c4358e45..000000000
--- a/res/menu/debug_option.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
diff --git a/res/values/strings.xml b/res/values/strings.xml
index a0a7643c0..a7281f8d0 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -175,8 +175,10 @@ Welcome to K-9 Mail setup. K-9 is an open source email client for Android based
Version: %s
- Enable extra debug logging?
- Enable sensitive information debug logging? (May show passwords in logs.)
+ Enable debug logging?
+ Log extra information for diagnostics
+ Log sensitive information(May show passwords in logs.)
+ May show passwords in logs.
K-9 for Android %s
@@ -530,5 +532,6 @@ Welcome to K-9 Mail setup. K-9 is an open source email client for Android based
Dark
Light
Display Preferences
+ Diagnostic Preferences
Theme
diff --git a/res/xml/global_preferences.xml b/res/xml/global_preferences.xml
index 908b4dbbd..b00b11443 100644
--- a/res/xml/global_preferences.xml
+++ b/res/xml/global_preferences.xml
@@ -24,8 +24,20 @@
android:entries="@array/settings_theme_entries"
android:entryValues="@array/settings_theme_values"
android:dialogTitle="@string/settings_theme_label" />
-
+
+
+
+
+
diff --git a/src/com/android/email/Email.java b/src/com/android/email/Email.java
index 6950a6505..04fab7166 100644
--- a/src/com/android/email/Email.java
+++ b/src/com/android/email/Email.java
@@ -7,6 +7,7 @@ import android.app.Application;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
+import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.util.Log;
@@ -24,6 +25,8 @@ public class Email extends Application {
public static File tempDirectory;
public static final String LOG_TAG = "k9";
+
+ private static int theme = android.R.style.Theme_Light;
/**
* Some log messages can be sent to a file, so that the logs
* can be read using unprivileged access (eg. Terminal Emulator)
@@ -233,14 +236,25 @@ public class Email extends Application {
MailService.actionReschedule(context);
}
}
+
+ public static void save(SharedPreferences preferences)
+ {
+ SharedPreferences.Editor editor = preferences.edit();
+ editor.putBoolean("enableDebugLogging", Email.DEBUG);
+ editor.putBoolean("enableSensitiveLogging", Email.DEBUG_SENSITIVE);
+ editor.putInt("theme", theme);
+ editor.commit();
+ }
@Override
public void onCreate() {
super.onCreate();
app = this;
Preferences prefs = Preferences.getPreferences(this);
- DEBUG = prefs.getEnableDebugLogging();
- DEBUG_SENSITIVE = prefs.getEnableSensitiveLogging();
+ SharedPreferences sprefs = prefs.getPreferences();
+ DEBUG = sprefs.getBoolean("enableDebugLogging", false);
+ DEBUG_SENSITIVE = sprefs.getBoolean("enableSensitiveLogging", false);
+ Email.setK9Theme(sprefs.getInt("theme", android.R.style.Theme_Light));
MessagingController.getInstance(this).resetVisibleLimits(prefs.getAccounts());
/*
@@ -280,6 +294,16 @@ public class Email extends Application {
MailService.appStarted(this);
}
+
+ public static int getK9Theme()
+ {
+ return theme;
+ }
+
+ public static void setK9Theme(int ntheme)
+ {
+ theme = ntheme;
+ }
}
diff --git a/src/com/android/email/K9Activity.java b/src/com/android/email/K9Activity.java
index 7a91b476f..44a9c5869 100644
--- a/src/com/android/email/K9Activity.java
+++ b/src/com/android/email/K9Activity.java
@@ -1,6 +1,5 @@
package com.android.email;
-import com.android.email.Preferences;
import android.app.Activity;
import android.os.Bundle;
@@ -9,7 +8,7 @@ import android.os.Bundle;
public class K9Activity extends Activity {
@Override
public void onCreate(Bundle icicle) {
- setTheme(Preferences.getPreferences(this).getTheme());
+ setTheme(Email.getK9Theme());
super.onCreate(icicle);
}
diff --git a/src/com/android/email/K9ListActivity.java b/src/com/android/email/K9ListActivity.java
index 9e44cd775..d00c0e401 100644
--- a/src/com/android/email/K9ListActivity.java
+++ b/src/com/android/email/K9ListActivity.java
@@ -1,7 +1,5 @@
package com.android.email;
-import com.android.email.Preferences;
-
import android.app.ListActivity;
import android.os.Bundle;
@@ -9,7 +7,7 @@ import android.os.Bundle;
public class K9ListActivity extends ListActivity {
@Override
public void onCreate(Bundle icicle) {
- setTheme(Preferences.getPreferences(this).getTheme());
+ setTheme(Email.getK9Theme());
super.onCreate(icicle);
}
diff --git a/src/com/android/email/K9PreferenceActivity.java b/src/com/android/email/K9PreferenceActivity.java
index 28f50e704..a0c45a425 100644
--- a/src/com/android/email/K9PreferenceActivity.java
+++ b/src/com/android/email/K9PreferenceActivity.java
@@ -1,7 +1,5 @@
package com.android.email;
-import com.android.email.Preferences;
-
import android.preference.PreferenceActivity;
import android.os.Bundle;
@@ -10,7 +8,7 @@ import android.os.Bundle;
public class K9PreferenceActivity extends PreferenceActivity {
@Override
public void onCreate(Bundle icicle) {
- setTheme(Preferences.getPreferences(this).getTheme());
+ setTheme(Email.getK9Theme());
super.onCreate(icicle);
}
diff --git a/src/com/android/email/Preferences.java b/src/com/android/email/Preferences.java
index 91409c4fe..86f5fff7e 100644
--- a/src/com/android/email/Preferences.java
+++ b/src/com/android/email/Preferences.java
@@ -1,8 +1,6 @@
package com.android.email;
-import java.util.Arrays;
-
import com.android.email.preferences.Editor;
import com.android.email.preferences.Storage;
@@ -101,30 +99,6 @@ public class Preferences {
getPreferences().edit().putString("defaultAccountUuid", account.getUuid()).commit();
}
- public void setEnableDebugLogging(boolean value) {
- getPreferences().edit().putBoolean("enableDebugLogging", value).commit();
- }
-
- public boolean getEnableDebugLogging() {
- return getPreferences().getBoolean("enableDebugLogging", false);
- }
-
- public void setTheme(int theme) {
- getPreferences().edit().putInt("theme", theme).commit();
- }
-
- public int getTheme() {
- return getPreferences().getInt("theme", android.R.style.Theme_Light);
- }
-
- public void setEnableSensitiveLogging(boolean value) {
- getPreferences().edit().putBoolean("enableSensitiveLogging", value).commit();
- }
-
- public boolean getEnableSensitiveLogging() {
- return getPreferences().getBoolean("enableSensitiveLogging", false);
- }
-
public void dump() {
if (Config.LOGV) {
for (String key : getPreferences().getAll().keySet()) {
diff --git a/src/com/android/email/activity/Accounts.java b/src/com/android/email/activity/Accounts.java
index e4b79aa69..65d0b42b9 100644
--- a/src/com/android/email/activity/Accounts.java
+++ b/src/com/android/email/activity/Accounts.java
@@ -57,15 +57,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
private ConcurrentHashMap unreadMessageCounts = new ConcurrentHashMap();
private ConcurrentHashMap pendingWork = new ConcurrentHashMap();
- /**
- * Key codes used to open a debug settings screen.
- */
- private static int[] secretKeyCodes = {
- KeyEvent.KEYCODE_D, KeyEvent.KEYCODE_E, KeyEvent.KEYCODE_B, KeyEvent.KEYCODE_U,
- KeyEvent.KEYCODE_G
- };
-
- private int mSecretKeyCodeIndex = 0;
+
private Account mSelectedContextAccount;
private AccountsHandler mHandler = new AccountsHandler();
@@ -581,15 +573,6 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
- if (event.getKeyCode() == secretKeyCodes[mSecretKeyCodeIndex]) {
- mSecretKeyCodeIndex++;
- if (mSecretKeyCodeIndex == secretKeyCodes.length) {
- mSecretKeyCodeIndex = 0;
- startActivity(new Intent(this, Debug.class));
- }
- } else {
- mSecretKeyCodeIndex = 0;
- }
return super.onKeyDown(keyCode, event);
}
diff --git a/src/com/android/email/activity/Debug.java b/src/com/android/email/activity/Debug.java
deleted file mode 100644
index 37eeeb9f1..000000000
--- a/src/com/android/email/activity/Debug.java
+++ /dev/null
@@ -1,91 +0,0 @@
-
-package com.android.email.activity;
-
-import com.android.email.K9Activity;
-import android.content.pm.PackageInfo;
-import android.content.pm.PackageManager;
-import android.os.Bundle;
-import android.util.Log;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.widget.CheckBox;
-import android.widget.CompoundButton;
-import android.widget.TextView;
-import android.widget.CompoundButton.OnCheckedChangeListener;
-
-import com.android.email.Email;
-import com.android.email.Preferences;
-import com.android.email.R;
-
-import java.lang.Integer;
-
-public class Debug extends K9Activity implements OnCheckedChangeListener {
- private TextView mVersionView;
- private CheckBox mEnableDebugLoggingView;
- private CheckBox mEnableSensitiveLoggingView;
-
- private Preferences mPreferences;
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- setContentView(R.layout.debug);
-
- mPreferences = Preferences.getPreferences(this);
-
- mVersionView = (TextView)findViewById(R.id.version);
- mEnableDebugLoggingView = (CheckBox)findViewById(R.id.debug_logging);
- mEnableSensitiveLoggingView = (CheckBox)findViewById(R.id.sensitive_logging);
-
- mEnableDebugLoggingView.setOnCheckedChangeListener(this);
- mEnableSensitiveLoggingView.setOnCheckedChangeListener(this);
-
- mVersionView.setText(String.format(getString(R.string.debug_version_fmt).toString(), getVersionNumber()));
-
- mEnableDebugLoggingView.setChecked(Email.DEBUG);
- mEnableSensitiveLoggingView.setChecked(Email.DEBUG_SENSITIVE);
- }
-
- public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
- if (buttonView.getId() == R.id.debug_logging) {
- Email.DEBUG = isChecked;
- mPreferences.setEnableDebugLogging(Email.DEBUG);
- } else if (buttonView.getId() == R.id.sensitive_logging) {
- Email.DEBUG_SENSITIVE = isChecked;
- mPreferences.setEnableSensitiveLogging(Email.DEBUG_SENSITIVE);
- }
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- int id = item.getItemId();
- if (id == R.id.dump_settings) {
- Preferences.getPreferences(this).dump();
- return true;
- }
- return super.onOptionsItemSelected(item);
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- super.onCreateOptionsMenu(menu);
- getMenuInflater().inflate(R.menu.debug_option, menu);
- return true;
- }
-
- private String getVersionNumber() {
- String version = "?";
- int vnum;
-
- try {
- PackageInfo pi =
- getPackageManager().getPackageInfo(getPackageName(), 0);
- version = Integer.toString(pi.versionCode);
-
- } catch (PackageManager.NameNotFoundException e){
- Log.e(Email.LOG_TAG, "Package name not found: " + e.getMessage());
- };
- return version;
- }
-}
diff --git a/src/com/android/email/activity/setup/Prefs.java b/src/com/android/email/activity/setup/Prefs.java
index f91eb4b01..66d1bba2e 100644
--- a/src/com/android/email/activity/setup/Prefs.java
+++ b/src/com/android/email/activity/setup/Prefs.java
@@ -8,6 +8,7 @@ import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
+import android.widget.CheckBox;
import android.preference.EditTextPreference;
import android.preference.ListPreference;
import android.preference.CheckBoxPreference;
@@ -26,8 +27,13 @@ public class Prefs extends K9PreferenceActivity {
private static final String PREFERENCE_TOP_CATERGORY = "preferences";
private static final String PREFERENCE_THEME = "theme";
+ private static final String PREFERENCE_DEBUG_LOGGING = "debug_logging";
+ private static final String PREFERENCE_SENSITIVE_LOGGING = "sensitive_logging";
private ListPreference mTheme;
+ private CheckBoxPreference mDebugLogging;
+ private CheckBoxPreference mSensitiveLogging;
+
public static void actionPrefs(Context context) {
Intent i = new Intent(context, Prefs.class);
@@ -41,11 +47,8 @@ public class Prefs extends K9PreferenceActivity {
addPreferencesFromResource(R.xml.global_preferences);
- Preference category = findPreference(PREFERENCE_TOP_CATERGORY);
-
-
mTheme = (ListPreference) findPreference(PREFERENCE_THEME);
- mTheme.setValue(String.valueOf(Preferences.getPreferences(this).getTheme() == android.R.style.Theme ? "dark" : "light"));
+ mTheme.setValue(String.valueOf(Email.getK9Theme() == android.R.style.Theme ? "dark" : "light"));
mTheme.setSummary(mTheme.getEntry());
mTheme.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
public boolean onPreferenceChange(Preference preference, Object newValue) {
@@ -57,6 +60,12 @@ public class Prefs extends K9PreferenceActivity {
}
});
+ mDebugLogging = (CheckBoxPreference)findPreference(PREFERENCE_DEBUG_LOGGING);
+ mSensitiveLogging = (CheckBoxPreference)findPreference(PREFERENCE_SENSITIVE_LOGGING);
+
+ mDebugLogging.setChecked(Email.DEBUG);
+ mSensitiveLogging.setChecked(Email.DEBUG_SENSITIVE);
+
}
@Override
@@ -65,7 +74,11 @@ public class Prefs extends K9PreferenceActivity {
}
private void saveSettings() {
- Preferences.getPreferences(this).setTheme(mTheme.getValue().equals("dark") ? android.R.style.Theme : android.R.style.Theme_Light);
+ SharedPreferences preferences = Preferences.getPreferences(this).getPreferences();
+ Email.setK9Theme(mTheme.getValue().equals("dark") ? android.R.style.Theme : android.R.style.Theme_Light);
+ Email.DEBUG = mDebugLogging.isChecked();
+ Email.DEBUG_SENSITIVE = mSensitiveLogging.isChecked();
+ Email.save(preferences);
}
@Override