Make the back button behaviour configurable. The default should remain
identical to the most recent behaviour. As an option, the user can force back to always go "up" a level like Jesse likes
This commit is contained in:
parent
49c4a4f97c
commit
6b5bcd2c4d
6 changed files with 86 additions and 1 deletions
|
@ -724,7 +724,11 @@ Welcome to K-9 Mail setup. K-9 is an open source mail client for Android origin
|
|||
<string name="animations_summary">Use gaudy visual effects</string>
|
||||
<string name="gestures_title">Gestures</string>
|
||||
<string name="gestures_summary">Accept gesture control</string>
|
||||
|
||||
|
||||
<string name="manage_back_title">Manage "Back" button</string>
|
||||
<string name="manage_back_summary">Make "Back" always go up a level</string>
|
||||
|
||||
|
||||
<string name="measure_accounts_title">Show account size</string>
|
||||
<string name="measure_accounts_summary">Turn off for faster display</string>
|
||||
|
||||
|
|
|
@ -48,6 +48,12 @@
|
|||
android:title="@string/gestures_title"
|
||||
android:summary="@string/gestures_summary" />
|
||||
|
||||
<CheckBoxPreference
|
||||
android:key="manage_back"
|
||||
android:title="@string/manage_back_title"
|
||||
android:summary="@string/manage_back_summary" />
|
||||
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory android:title="@string/accountlist_preferences" android:key="accountlist_preferences">
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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());
|
||||
|
||||
|
|
Loading…
Reference in a new issue