Fix actionbar for message view
- shows the title of the message in the action bar (visuals not final - need to extend the width and hide the account name) - ensures that tapping up/back from a message view from a search result list doesn't exit search - ensures that tapping "app up" from a collapsible tablet view doesn't exist the search unless the left pane is uncollapsed Change-Id: I2b21a430d12148cf72237060c05312c7a23e2b3b
This commit is contained in:
parent
8de5bda815
commit
698aa92e6f
|
@ -100,6 +100,9 @@ public class ActionBarController {
|
|||
/** Either {@link #MODE_NORMAL} or {@link #MODE_SEARCH}. */
|
||||
private int mSearchMode = MODE_NORMAL;
|
||||
|
||||
/** The current title mode, which should be one of {@code Callback TITLE_MODE_*} */
|
||||
private int mTitleMode;
|
||||
|
||||
public final Callback mCallback;
|
||||
|
||||
public interface SearchContext {
|
||||
|
@ -127,8 +130,6 @@ public class ActionBarController {
|
|||
* {@link #getMessageSubject()}.
|
||||
*
|
||||
* The account spinner will be disabled in this mode.
|
||||
*
|
||||
* NOT IMPLEMENTED YET
|
||||
*/
|
||||
public static final int TITLE_MODE_MESSAGE_SUBJECT = 3;
|
||||
|
||||
|
@ -278,6 +279,14 @@ public class ActionBarController {
|
|||
return mSearchMode == MODE_SEARCH;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Whether or not the search bar should be shown. This is a function of whether or not a
|
||||
* search is active, and if the current layout supports it.
|
||||
*/
|
||||
private boolean shouldShowSearchBar() {
|
||||
return isInSearchMode() && (mTitleMode != Callback.TITLE_MODE_MESSAGE_SUBJECT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the search box.
|
||||
*
|
||||
|
@ -320,7 +329,7 @@ public class ActionBarController {
|
|||
* <code>false</code> if it's caused by the "home" icon click on the action bar.
|
||||
*/
|
||||
public boolean onBackPressed(boolean isSystemBackKey) {
|
||||
if (isInSearchMode()) {
|
||||
if (shouldShowSearchBar()) {
|
||||
exitSearchMode();
|
||||
return true;
|
||||
}
|
||||
|
@ -415,28 +424,28 @@ public class ActionBarController {
|
|||
return;
|
||||
}
|
||||
|
||||
if (mSearchMode == MODE_SEARCH) {
|
||||
// In search mode, so we don't care about the account list - it'll get updated when
|
||||
// it goes visible again.
|
||||
mTitleMode = mCallback.getTitleMode();
|
||||
|
||||
if (shouldShowSearchBar()) {
|
||||
// In search mode, the search box is a replacement of the account spinner, so ignore
|
||||
// the work needed to update that. It will get updated when it goes visible again.
|
||||
mAccountSpinner.setVisibility(View.GONE);
|
||||
mSearchContainer.setVisibility(View.VISIBLE);
|
||||
return;
|
||||
}
|
||||
|
||||
final int titleMode = mCallback.getTitleMode();
|
||||
|
||||
// TODO Handle TITLE_MODE_MESSAGE_SUBJECT
|
||||
|
||||
// Account spinner visible.
|
||||
mAccountSpinner.setVisibility(View.VISIBLE);
|
||||
mSearchContainer.setVisibility(View.GONE);
|
||||
|
||||
// Get mailbox name
|
||||
final String mailboxName;
|
||||
if (titleMode == Callback.TITLE_MODE_ACCOUNT_WITH_ALL_FOLDERS_LABEL) {
|
||||
if (mTitleMode == Callback.TITLE_MODE_ACCOUNT_WITH_ALL_FOLDERS_LABEL) {
|
||||
mailboxName = mAllFoldersLabel;
|
||||
} else if (titleMode == Callback.TITLE_MODE_ACCOUNT_WITH_MAILBOX) {
|
||||
} else if (mTitleMode == Callback.TITLE_MODE_ACCOUNT_WITH_MAILBOX) {
|
||||
mailboxName = mCursor.getMailboxDisplayName();
|
||||
} else if (mTitleMode == Callback.TITLE_MODE_MESSAGE_SUBJECT) {
|
||||
mailboxName = mCallback.getMessageSubject();
|
||||
} else {
|
||||
mailboxName = null;
|
||||
}
|
||||
|
@ -455,7 +464,7 @@ public class ActionBarController {
|
|||
mContext, mCursor.getMailboxMessageCount(), true));
|
||||
|
||||
boolean spinnerEnabled =
|
||||
((titleMode & TITLE_MODE_SPINNER_ENABLED) != 0)
|
||||
((mTitleMode & TITLE_MODE_SPINNER_ENABLED) != 0)
|
||||
&& (mCursor.getAccountCount() + mCursor.getRecentMailboxCount()) > 1;
|
||||
|
||||
if (spinnerEnabled) {
|
||||
|
|
|
@ -469,7 +469,7 @@ public abstract class MessageViewFragmentBase extends Fragment implements View.O
|
|||
return mCallback;
|
||||
}
|
||||
|
||||
protected final Message getMessage() {
|
||||
public final Message getMessage() {
|
||||
return mMessage;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,9 +16,6 @@
|
|||
|
||||
package com.android.email.activity;
|
||||
|
||||
import com.android.email.R;
|
||||
import com.android.emailcommon.Logging;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.animation.PropertyValuesHolder;
|
||||
|
@ -34,6 +31,9 @@ import android.view.ViewGroup;
|
|||
import android.view.animation.DecelerateInterpolator;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import com.android.email.R;
|
||||
import com.android.emailcommon.Logging;
|
||||
|
||||
/**
|
||||
* The "three pane" layout used on tablet.
|
||||
*
|
||||
|
@ -229,7 +229,7 @@ public class ThreePaneLayout extends LinearLayout implements View.OnClickListene
|
|||
/**
|
||||
* Return whether or not the left pane should be collapsible.
|
||||
*/
|
||||
private boolean isPaneCollapsible() {
|
||||
public boolean isPaneCollapsible() {
|
||||
return mFoggedGlass != null;
|
||||
}
|
||||
|
||||
|
@ -276,39 +276,24 @@ public class ThreePaneLayout extends LinearLayout implements View.OnClickListene
|
|||
/**
|
||||
* Handles the back event.
|
||||
*
|
||||
* @param isSystemBackKey set true if the system back key is pressed, rather than the home
|
||||
* icon on action bar.
|
||||
* @return true if the event is handled.
|
||||
*/
|
||||
public boolean onBackPressed(boolean isSystemBackKey) {
|
||||
public boolean uncollapsePane() {
|
||||
if (!isPaneCollapsible()) {
|
||||
switch (mPaneState) {
|
||||
case STATE_RIGHT_VISIBLE:
|
||||
changePaneState(STATE_LEFT_VISIBLE, true); // Close the right pane
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
switch (mPaneState) {
|
||||
case STATE_RIGHT_VISIBLE:
|
||||
if (isSystemBackKey) {
|
||||
changePaneState(STATE_LEFT_VISIBLE, true);
|
||||
} else {
|
||||
changePaneState(STATE_MIDDLE_EXPANDED, true);
|
||||
}
|
||||
return true;
|
||||
case STATE_MIDDLE_EXPANDED:
|
||||
changePaneState(STATE_LEFT_VISIBLE, true);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mPaneState == STATE_RIGHT_VISIBLE) {
|
||||
return changePaneState(STATE_MIDDLE_EXPANDED, true);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the left most pane. (i.e. mailbox list)
|
||||
*/
|
||||
public void showLeftPane() {
|
||||
changePaneState(STATE_LEFT_VISIBLE, true);
|
||||
public boolean showLeftPane() {
|
||||
return changePaneState(STATE_LEFT_VISIBLE, true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -327,11 +312,11 @@ public class ThreePaneLayout extends LinearLayout implements View.OnClickListene
|
|||
/**
|
||||
* Show the right most pane. (i.e. message view)
|
||||
*/
|
||||
public void showRightPane() {
|
||||
changePaneState(STATE_RIGHT_VISIBLE, true);
|
||||
public boolean showRightPane() {
|
||||
return changePaneState(STATE_RIGHT_VISIBLE, true);
|
||||
}
|
||||
|
||||
private void changePaneState(int newState, boolean animate) {
|
||||
private boolean changePaneState(int newState, boolean animate) {
|
||||
if (!isPaneCollapsible() && (newState == STATE_MIDDLE_EXPANDED)) {
|
||||
newState = STATE_RIGHT_VISIBLE;
|
||||
}
|
||||
|
@ -340,10 +325,10 @@ public class ThreePaneLayout extends LinearLayout implements View.OnClickListene
|
|||
// layout properly.
|
||||
// Just remember the new state and return.
|
||||
mInitialPaneState = newState;
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
if (newState == mPaneState) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
// Just make sure the first transition doesn't animate.
|
||||
if (mPaneState == STATE_UNINITIALIZED) {
|
||||
|
@ -425,6 +410,7 @@ public class ThreePaneLayout extends LinearLayout implements View.OnClickListene
|
|||
PropertyValuesHolder.ofInt(PROP_MESSAGE_LIST_WIDTH,
|
||||
getCurrentMessageListWidth(), expectedMessageListWidth)
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -578,18 +578,10 @@ abstract class UIControllerBase implements MailboxListFragment.Callback,
|
|||
/**
|
||||
* Performs the back action.
|
||||
*
|
||||
* NOTE The method in the base class has precedence. Subclasses overriding this method MUST
|
||||
* call super's method first.
|
||||
*
|
||||
* @param isSystemBackKey <code>true</code> if the system back key was pressed.
|
||||
* <code>false</code> if it's caused by the "home" icon click on the action bar.
|
||||
*/
|
||||
public boolean onBackPressed(boolean isSystemBackKey) {
|
||||
if (mActionBarController.onBackPressed(isSystemBackKey)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public abstract boolean onBackPressed(boolean isSystemBackKey);
|
||||
|
||||
/**
|
||||
* Must be called from {@link Activity#onSearchRequested()}.
|
||||
|
|
|
@ -16,14 +16,6 @@
|
|||
|
||||
package com.android.email.activity;
|
||||
|
||||
import com.android.email.Email;
|
||||
import com.android.email.MessageListContext;
|
||||
import com.android.email.R;
|
||||
import com.android.emailcommon.Logging;
|
||||
import com.android.emailcommon.provider.Account;
|
||||
import com.android.emailcommon.provider.EmailContent.Message;
|
||||
import com.android.emailcommon.provider.Mailbox;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Fragment;
|
||||
import android.app.FragmentTransaction;
|
||||
|
@ -33,6 +25,14 @@ import android.view.Menu;
|
|||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import com.android.email.Email;
|
||||
import com.android.email.MessageListContext;
|
||||
import com.android.email.R;
|
||||
import com.android.emailcommon.Logging;
|
||||
import com.android.emailcommon.provider.Account;
|
||||
import com.android.emailcommon.provider.EmailContent.Message;
|
||||
import com.android.emailcommon.provider.Mailbox;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
|
@ -180,13 +180,15 @@ class UIControllerOnePane extends UIControllerBase {
|
|||
if (isMailboxListInstalled()) {
|
||||
return TITLE_MODE_ACCOUNT_WITH_ALL_FOLDERS_LABEL;
|
||||
}
|
||||
// TODO Return TITLE_MODE_MESSAGE_SUBJECT if isMessageViewInstalled()
|
||||
if (isMessageViewInstalled()) {
|
||||
return TITLE_MODE_MESSAGE_SUBJECT;
|
||||
}
|
||||
return TITLE_MODE_ACCOUNT_WITH_MAILBOX;
|
||||
}
|
||||
|
||||
public String getMessageSubject() {
|
||||
if (isMessageViewInstalled()) {
|
||||
return "TODO: Return current message subject here";
|
||||
if (isMessageViewInstalled() && getMessageViewFragment().isMessageOpen()) {
|
||||
return getMessageViewFragment().getMessage().mSubject;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
@ -314,8 +316,8 @@ class UIControllerOnePane extends UIControllerBase {
|
|||
// This is VERY important -- no check for DEBUG_LIFECYCLE
|
||||
Log.d(Logging.LOG_TAG, this + " onBackPressed: " + isSystemBackKey);
|
||||
}
|
||||
// Super's method has precedence. Must call it first.
|
||||
if (super.onBackPressed(isSystemBackKey)) {
|
||||
// The action bar controller has precedence. Must call it first.
|
||||
if (mActionBarController.onBackPressed(isSystemBackKey)) {
|
||||
return true;
|
||||
}
|
||||
// If the mailbox list is shown and showing a nested mailbox, let it navigate up first.
|
||||
|
|
|
@ -516,13 +516,29 @@ class UIControllerTwoPane extends UIControllerBase implements
|
|||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public boolean onBackPressed(boolean isSystemBackKey) {
|
||||
// Super's method has precedence. Must call it first.
|
||||
if (super.onBackPressed(isSystemBackKey)) {
|
||||
return true;
|
||||
}
|
||||
if (mThreePane.onBackPressed(isSystemBackKey)) {
|
||||
return true;
|
||||
if (!mThreePane.isPaneCollapsible()) {
|
||||
if (mActionBarController.onBackPressed(isSystemBackKey)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (mThreePane.showLeftPane()) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
// If it's not the system back key, always attempt to uncollapse the left pane first.
|
||||
if (!isSystemBackKey && mThreePane.uncollapsePane()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (mActionBarController.onBackPressed(isSystemBackKey)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (mThreePane.showLeftPane()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (isMailboxListInstalled() && getMailboxListFragment().navigateUp()) {
|
||||
return true;
|
||||
}
|
||||
|
@ -689,24 +705,15 @@ class UIControllerTwoPane extends UIControllerBase implements
|
|||
if ((mThreePane.getVisiblePanes() & ThreePaneLayout.PANE_LEFT) != 0) {
|
||||
// Mailbox list visible
|
||||
return TITLE_MODE_ACCOUNT_NAME_ONLY;
|
||||
}
|
||||
if ((mThreePane.getVisiblePanes() & ThreePaneLayout.PANE_MIDDLE) != 0) {
|
||||
// Message list + message view
|
||||
} else {
|
||||
// Mailbox list hidden
|
||||
return TITLE_MODE_ACCOUNT_WITH_MAILBOX;
|
||||
}
|
||||
if ((mThreePane.getVisiblePanes() & ThreePaneLayout.PANE_RIGHT) != 0) {
|
||||
// Message view only (message list collapsed)
|
||||
// TODO return TITLE_MODE_MESSAGE_SUBJECT
|
||||
return TITLE_MODE_ACCOUNT_WITH_MAILBOX;
|
||||
}
|
||||
|
||||
// Shouldn't happen, but just in case
|
||||
return TITLE_MODE_ACCOUNT_NAME_ONLY;
|
||||
}
|
||||
|
||||
public String getMessageSubject() {
|
||||
if (isMessageViewInstalled()) {
|
||||
return "TODO: Return current message subject here";
|
||||
if (isMessageViewInstalled() && getMessageViewFragment().isMessageOpen()) {
|
||||
return getMessageViewFragment().getMessage().mSubject;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue