diff --git a/res/values/strings.xml b/res/values/strings.xml index 4c9e30156..f35192cb6 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -724,7 +724,11 @@ Welcome to K-9 Mail setup. K-9 is an open source mail client for Android origin Use gaudy visual effects Gestures Accept gesture control - + + Manage "Back" button + Make "Back" always go up a level + + Show account size Turn off for faster display diff --git a/res/xml/global_preferences.xml b/res/xml/global_preferences.xml index da9965245..bbde3928b 100644 --- a/res/xml/global_preferences.xml +++ b/res/xml/global_preferences.xml @@ -48,6 +48,12 @@ android:title="@string/gestures_title" android:summary="@string/gestures_summary" /> + + + diff --git a/src/com/fsck/k9/K9.java b/src/com/fsck/k9/K9.java index e87a3d1b2..0b4f3d99b 100644 --- a/src/com/fsck/k9/K9.java +++ b/src/com/fsck/k9/K9.java @@ -79,6 +79,7 @@ public class K9 extends Application private static boolean mMessageListCheckboxes = false; private static boolean mMessageListTouchable = false; private static boolean mGesturesEnabled = true; + private static boolean mManageBack = false; private static boolean mMeasureAccounts = true; private static boolean mCountSearchMessages = true; @@ -297,6 +298,7 @@ public class K9 extends Application editor.putString("backgroundOperations", K9.backgroundOps.toString()); editor.putBoolean("animations", mAnimations); editor.putBoolean("gesturesEnabled", mGesturesEnabled); + editor.putBoolean("manageBack", mManageBack); editor.putBoolean("measureAccounts", mMeasureAccounts); editor.putBoolean("countSearchMessages", mCountSearchMessages); editor.putBoolean("messageListStars",mMessageListStars); @@ -322,6 +324,7 @@ public class K9 extends Application DEBUG_SENSITIVE = sprefs.getBoolean("enableSensitiveLogging", false); mAnimations = sprefs.getBoolean("animations", true); mGesturesEnabled = sprefs.getBoolean("gesturesEnabled", true); + mManageBack = sprefs.getBoolean("manageBack", false); mMeasureAccounts = sprefs.getBoolean("measureAccounts", true); mCountSearchMessages = sprefs.getBoolean("countSearchMessages", true); mMessageListStars = sprefs.getBoolean("messageListStars",true); @@ -451,6 +454,17 @@ public class K9 extends Application mGesturesEnabled = gestures; } + + public static boolean manageBack() + { + return mManageBack; + } + + public static void setManageBack(boolean manageBack) + { + mManageBack = manageBack; + } + public static boolean isAnimations() { return mAnimations; diff --git a/src/com/fsck/k9/activity/FolderList.java b/src/com/fsck/k9/activity/FolderList.java index 930ec5444..e9285fed3 100644 --- a/src/com/fsck/k9/activity/FolderList.java +++ b/src/com/fsck/k9/activity/FolderList.java @@ -355,9 +355,36 @@ public class FolderList extends K9ListActivity } + public void onBackPressed() + { + // This will be called either automatically for you on 2.0 + // or later, or by the code above on earlier versions of the + // platform. + if (K9.manageBack() ) + { + onAccounts(); + } + } + @Override public boolean onKeyDown(int keyCode, KeyEvent event) { //Shortcuts that work no matter what is selected + + if ( + // TODO - when we move to android 2.0, uncomment this. + // android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.ECLAIR && + + keyCode == KeyEvent.KEYCODE_BACK + && event.getRepeatCount() == 0 + && K9.manageBack() ) + { + // Take care of calling this method on earlier versions of + // the platform where it doesn't exist. + onBackPressed(); + return true; + } + + switch (keyCode) { case KeyEvent.KEYCODE_Q: @@ -533,6 +560,7 @@ public class FolderList extends K9ListActivity private void onOpenFolder(String folder) { MessageList.actionHandleFolder(this, mAccount, folder); + finish(); } private void onCompact(Account account) diff --git a/src/com/fsck/k9/activity/MessageList.java b/src/com/fsck/k9/activity/MessageList.java index 7922330a4..7ae51c4b2 100644 --- a/src/com/fsck/k9/activity/MessageList.java +++ b/src/com/fsck/k9/activity/MessageList.java @@ -575,9 +575,35 @@ public class MessageList } + public void onBackPressed() + { + // This will be called either automatically for you on 2.0 + // or later, or by the code above on earlier versions of the + // platform. + if (K9.manageBack()) + { + onShowFolderList(); + } else { + finish(); + } + } + + @Override public boolean onKeyDown(int keyCode, KeyEvent event) { + if ( + // XXX TODO - when we go to android 2.0, uncomment this + // android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.ECLAIR && + keyCode == KeyEvent.KEYCODE_BACK + && event.getRepeatCount() == 0 + ) + { + // Take care of calling this method on earlier versions of + // the platform where it doesn't exist. + onBackPressed(); + return true; + } //Shortcuts that work no matter what is selected switch (keyCode) diff --git a/src/com/fsck/k9/activity/setup/Prefs.java b/src/com/fsck/k9/activity/setup/Prefs.java index 834e0fe3a..886c5f3a8 100644 --- a/src/com/fsck/k9/activity/setup/Prefs.java +++ b/src/com/fsck/k9/activity/setup/Prefs.java @@ -28,6 +28,7 @@ public class Prefs extends K9PreferenceActivity private static final String PREFERENCE_ANIMATIONS = "animations"; private static final String PREFERENCE_GESTURES = "gestures"; + private static final String PREFERENCE_MANAGE_BACK = "manage_back"; private static final String PREFERENCE_MESSAGELIST_STARS = "messagelist_stars"; private static final String PREFERENCE_MESSAGELIST_CHECKBOXES = "messagelist_checkboxes"; private static final String PREFERENCE_MESSAGELIST_TOUCHABLE = "messagelist_touchable"; @@ -41,6 +42,7 @@ public class Prefs extends K9PreferenceActivity private CheckBoxPreference mDebugLogging; private CheckBoxPreference mSensitiveLogging; private CheckBoxPreference mGestures; + private CheckBoxPreference mManageBack; private CheckBoxPreference mAnimations; private CheckBoxPreference mStars; private CheckBoxPreference mCheckboxes; @@ -146,6 +148,10 @@ public class Prefs extends K9PreferenceActivity mGestures = (CheckBoxPreference)findPreference(PREFERENCE_GESTURES); mGestures.setChecked(K9.gesturesEnabled()); + mManageBack = (CheckBoxPreference)findPreference(PREFERENCE_MANAGE_BACK); + mManageBack.setChecked(K9.manageBack()); + + mStars = (CheckBoxPreference)findPreference(PREFERENCE_MESSAGELIST_STARS); mStars.setChecked(K9.messageListStars()); @@ -181,6 +187,7 @@ public class Prefs extends K9PreferenceActivity K9.setAnimations(mAnimations.isChecked()); K9.setGesturesEnabled(mGestures.isChecked()); + K9.setManageBack(mManageBack.isChecked()); K9.setMessageListStars(mStars.isChecked()); K9.setMessageListCheckboxes(mCheckboxes.isChecked());