1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-24 02:12:15 -05:00

Fix back button behavior

This commit is contained in:
cketti 2013-02-01 00:47:28 +01:00
parent af51eee9b1
commit c11e5ef76b

View File

@ -170,6 +170,13 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
private DisplayMode mDisplayMode; private DisplayMode mDisplayMode;
private MessageReference mMessageReference; private MessageReference mMessageReference;
/**
* {@code true} when the message list was displayed once. This is used in
* {@link #onBackPressed()} to decide whether to go from the message view to the message list or
* finish the activity.
*/
private boolean mMessageListWasDisplayed = false;
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
@ -314,6 +321,7 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
break; break;
} }
case SPLIT_VIEW: { case SPLIT_VIEW: {
mMessageListWasDisplayed = true;
findViewById(R.id.message_list_divider).setVisibility(View.VISIBLE); findViewById(R.id.message_list_divider).setVisibility(View.VISIBLE);
if (mMessageViewFragment == null) { if (mMessageViewFragment == null) {
showMessageViewPlaceHolder(); showMessageViewPlaceHolder();
@ -479,7 +487,7 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
@Override @Override
public void onBackPressed() { public void onBackPressed() {
if (mDisplayMode == DisplayMode.MESSAGE_VIEW) { if (mDisplayMode == DisplayMode.MESSAGE_VIEW && mMessageListWasDisplayed) {
showMessageList(); showMessageList();
} else { } else {
super.onBackPressed(); super.onBackPressed();
@ -1294,6 +1302,7 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
} }
private void showMessageList() { private void showMessageList() {
mMessageListWasDisplayed = true;
mDisplayMode = DisplayMode.MESSAGE_LIST; mDisplayMode = DisplayMode.MESSAGE_LIST;
mMessageViewContainer.setVisibility(View.GONE); mMessageViewContainer.setVisibility(View.GONE);