diff --git a/proguard.flags b/proguard.flags index 4ead936ec..57e7b0704 100644 --- a/proguard.flags +++ b/proguard.flags @@ -215,3 +215,8 @@ *** toByteArray(java.io.Reader, java.lang.String); *** toByteArray(java.lang.String); } + +-keepclasseswithmembers class com.android.email.activity.ThreePaneLayout { + *** setMessageListWidthAnim(...); + *** setMailboxListLeftAnim(...); +} diff --git a/res/values-sw600dp-port/bools.xml b/res/values-sw600dp-port/bools.xml index 28e2b249b..5616f6d70 100644 --- a/res/values-sw600dp-port/bools.xml +++ b/res/values-sw600dp-port/bools.xml @@ -17,4 +17,6 @@ false + + false diff --git a/res/values-sw600dp-port/dimensions.xml b/res/values-sw600dp-port/dimensions.xml index 9fd281cab..edab08be4 100644 --- a/res/values-sw600dp-port/dimensions.xml +++ b/res/values-sw600dp-port/dimensions.xml @@ -38,6 +38,11 @@ 32dip 32dip +<<<<<<< HEAD 76dip 78dip +======= + + 1 +>>>>>>> Make search interaction match gmail. diff --git a/res/values-sw600dp/bools.xml b/res/values-sw600dp/bools.xml index 60275191d..81e44685c 100644 --- a/res/values-sw600dp/bools.xml +++ b/res/values-sw600dp/bools.xml @@ -19,4 +19,7 @@ true + + + true diff --git a/res/values-sw720dp-port/dimen.xml b/res/values-sw720dp-port/dimensions.xml similarity index 83% rename from res/values-sw720dp-port/dimen.xml rename to res/values-sw720dp-port/dimensions.xml index 371921dd1..adecda532 100644 --- a/res/values-sw720dp-port/dimen.xml +++ b/res/values-sw720dp-port/dimensions.xml @@ -20,5 +20,8 @@ 200dip 0dip + + + 0 diff --git a/res/values/bools.xml b/res/values/bools.xml index 10b261b22..84498d6b4 100644 --- a/res/values/bools.xml +++ b/res/values/bools.xml @@ -22,4 +22,7 @@ true + + + false diff --git a/res/values/dimensions.xml b/res/values/dimensions.xml index 888d2a8f8..6d2b84a95 100644 --- a/res/values/dimensions.xml +++ b/res/values/dimensions.xml @@ -78,4 +78,7 @@ 3sp 28sp 9sp + + + 1 diff --git a/src/com/android/email/activity/EmailActivity.java b/src/com/android/email/activity/EmailActivity.java index 50667cbff..a8ff8f93c 100644 --- a/src/com/android/email/activity/EmailActivity.java +++ b/src/com/android/email/activity/EmailActivity.java @@ -156,8 +156,17 @@ public class EmailActivity extends Activity implements View.OnClickListener, Fra * Initialize {@link #mUIController}. */ private void initUIController() { - mUIController = UiUtilities.useTwoPane(this) - ? new UIControllerTwoPane(this) : new UIControllerOnePane(this); + if (UiUtilities.useTwoPane(this)) { + if (getIntent().getAction() != null + && Intent.ACTION_SEARCH.equals(getIntent().getAction()) + && !UiUtilities.showTwoPaneSearchResults(this)) { + mUIController = new UIControllerSearchTwoPane(this); + } else { + mUIController = new UIControllerTwoPane(this); + } + } else { + mUIController = new UIControllerOnePane(this); + } } @Override diff --git a/src/com/android/email/activity/MessageListFragment.java b/src/com/android/email/activity/MessageListFragment.java index a62a2713b..c5dd00cc1 100644 --- a/src/com/android/email/activity/MessageListFragment.java +++ b/src/com/android/email/activity/MessageListFragment.java @@ -355,7 +355,7 @@ public class MessageListFragment extends ListFragment mController = Controller.getInstance(mActivity); mRefreshManager = RefreshManager.getInstance(mActivity); - mListAdapter = new MessagesAdapter(mActivity, this); + mListAdapter = new MessagesAdapter(mActivity, this, getListContext().isSearch()); mIsFirstLoad = true; } @@ -1326,7 +1326,8 @@ public class MessageListFragment extends ListFragment // If this is a search result, open the first message. if (UiUtilities.useTwoPane(getActivity()) && mIsFirstLoad && mListContext.isSearch() - && cursor.getCount() > 0) { + && cursor.getCount() > 0 + && UiUtilities.showTwoPaneSearchResults(getActivity())) { cursor.moveToFirst(); onMessageOpen(getMailboxId(), cursor.getLong(MessagesAdapter.COLUMN_ID)); } diff --git a/src/com/android/email/activity/MessageListItem.java b/src/com/android/email/activity/MessageListItem.java index 0d8c27dd0..d7dc21559 100644 --- a/src/com/android/email/activity/MessageListItem.java +++ b/src/com/android/email/activity/MessageListItem.java @@ -60,6 +60,7 @@ public class MessageListItem extends View { private MessagesAdapter mAdapter; private MessageListItemCoordinates mCoordinates; private Context mContext; + private boolean mIsSearchResult = false; private boolean mDownEvent; @@ -252,6 +253,7 @@ public class MessageListItem extends View { } long mTimeFormatted = 0; + public void setTimestamp(long timestamp) { if (mTimeFormatted != timestamp) { mFormattedDate = DateUtils.getRelativeTimeSpanString(mContext, timestamp).toString(); @@ -266,7 +268,7 @@ public class MessageListItem extends View { * @return The mode of the view */ private int getViewMode(int width) { - return MessageListItemCoordinates.getMode(mContext, width); + return MessageListItemCoordinates.getMode(mContext, width, mIsSearchResult); } private Drawable mCurentBackground = null; // Only used by updateBackground() @@ -413,7 +415,7 @@ public class MessageListItem extends View { protected void onLayout(boolean changed, int left, int top, int right, int bottom) { super.onLayout(changed, left, top, right, bottom); - mCoordinates = MessageListItemCoordinates.forWidth(mContext, mViewWidth); + mCoordinates = MessageListItemCoordinates.forWidth(mContext, mViewWidth, mIsSearchResult); calculateDrawingData(); } @@ -502,9 +504,11 @@ public class MessageListItem extends View { * @param layout If this is a three pane implementation, the * ThreePaneLayout. Otherwise, null. */ - public void bindViewInit(MessagesAdapter adapter, ThreePaneLayout layout) { + public void bindViewInit(MessagesAdapter adapter, ThreePaneLayout layout, + boolean isSearchResult) { mLayout = layout; mAdapter = adapter; + mIsSearchResult = isSearchResult; requestLayout(); } diff --git a/src/com/android/email/activity/MessageListItemCoordinates.java b/src/com/android/email/activity/MessageListItemCoordinates.java index 87e4d6c08..94fc9e226 100644 --- a/src/com/android/email/activity/MessageListItemCoordinates.java +++ b/src/com/android/email/activity/MessageListItemCoordinates.java @@ -109,8 +109,11 @@ public class MessageListItemCoordinates { * Returns the mode of the header view (Wide/Normal/Narrow) given the its * measured width. */ - public static int getMode(Context context, int width) { + public static int getMode(Context context, int width, boolean isSearch) { Resources res = context.getResources(); + if (isSearch) { + return res.getInteger(R.integer.message_search_list_header_mode); + } if (MINIMUM_WIDTH_WIDE_MODE <= 0) { MINIMUM_WIDTH_WIDE_MODE = res.getDimensionPixelSize(R.dimen.minimum_width_wide_mode); } @@ -239,7 +242,8 @@ public class MessageListItemCoordinates { * Returns coordinates for elements inside a conversation header view given * the view width. */ - public static MessageListItemCoordinates forWidth(Context context, int width) { + public static MessageListItemCoordinates forWidth(Context context, int width, + boolean isSearchResult) { MessageListItemCoordinates coordinates = mCache.get(width); if (coordinates == null) { coordinates = new MessageListItemCoordinates(); @@ -247,7 +251,7 @@ public class MessageListItemCoordinates { // TODO: make the field computation done inside of the constructor and mark fields final // Layout the appropriate view. - int mode = getMode(context, width); + int mode = getMode(context, width, isSearchResult); int height = getHeight(context, mode); View view = LayoutInflater.from(context).inflate(getLayoutId(mode), null); int widthSpec = MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY); diff --git a/src/com/android/email/activity/MessagesAdapter.java b/src/com/android/email/activity/MessagesAdapter.java index b9b2c2a39..4904ad8d1 100644 --- a/src/com/android/email/activity/MessagesAdapter.java +++ b/src/com/android/email/activity/MessagesAdapter.java @@ -100,6 +100,8 @@ import java.util.Set; private ThreePaneLayout mLayout; + private boolean mIsSearchResult = false; + /** * The actual return type from the loader. */ @@ -130,10 +132,11 @@ import java.util.Set; } } - public MessagesAdapter(Context context, Callback callback) { + public MessagesAdapter(Context context, Callback callback, boolean isSearchResult) { super(context.getApplicationContext(), null, 0 /* no auto requery */); mResourceHelper = ResourceHelper.getInstance(context); mCallback = callback; + mIsSearchResult = isSearchResult; } public void setLayout(ThreePaneLayout layout) { @@ -188,7 +191,7 @@ import java.util.Set; public void bindView(View view, Context context, Cursor cursor) { // Reset the view (in case it was recycled) and prepare for binding MessageListItem itemView = (MessageListItem) view; - itemView.bindViewInit(this, mLayout); + itemView.bindViewInit(this, mLayout, mIsSearchResult); // TODO: just move thise all to a MessageListItem.bindTo(cursor) so that the fields can // be private, and their inter-dependence when they change can be abstracted away. diff --git a/src/com/android/email/activity/ThreePaneLayout.java b/src/com/android/email/activity/ThreePaneLayout.java index cb7b2069b..04b48d53b 100644 --- a/src/com/android/email/activity/ThreePaneLayout.java +++ b/src/com/android/email/activity/ThreePaneLayout.java @@ -119,6 +119,8 @@ public class ThreePaneLayout extends LinearLayout { private Callback mCallback = EmptyCallback.INSTANCE; + private boolean mIsSearchResult = false; + public interface Callback { /** Called when {@link ThreePaneLayout#getVisiblePanes()} has changed. */ public void onVisiblePanesChanged(int previousVisiblePanes); @@ -162,7 +164,7 @@ public class ThreePaneLayout extends LinearLayout { mConvViewExpandList = getContext().getResources().getBoolean(R.bool.expand_middle_view); View[][] stateRightVisible = new View[][] { { - mMiddlePane, mMessageCommandButtons, mRightPane + mMiddlePane, mMessageCommandButtons, mRightPane }, // Visible { mLeftPane @@ -182,7 +184,7 @@ public class ThreePaneLayout extends LinearLayout { // STATE_LEFT_VISIBLE { { - mLeftPane, mMiddlePane + mLeftPane, mMiddlePane }, // Visible { mRightPane @@ -209,6 +211,13 @@ public class ThreePaneLayout extends LinearLayout { mMessageListWidth = getResources().getDimensionPixelSize(R.dimen.message_list_width); } + public void setIsSearch(boolean isSearch) { + mIsSearchResult = isSearch; + } + + private boolean shouldShowMailboxList() { + return !mIsSearchResult || UiUtilities.showTwoPaneSearchResults(getContext()); + } public void setCallback(Callback callback) { mCallback = (callback == null) ? EmptyCallback.INSTANCE : callback; @@ -225,21 +234,6 @@ public class ThreePaneLayout extends LinearLayout { return mMessageCommandButtons; } - @Override - protected Parcelable onSaveInstanceState() { - SavedState ss = new SavedState(super.onSaveInstanceState()); - ss.mPaneState = mPaneState; - return ss; - } - - @Override - protected void onRestoreInstanceState(Parcelable state) { - // Called after onFinishInflate() - SavedState ss = (SavedState) state; - super.onRestoreInstanceState(ss.getSuperState()); - mInitialPaneState = ss.mPaneState; - } - @Override protected void onSizeChanged(int w, int h, int oldw, int oldh) { super.onSizeChanged(w, h, oldw, oldh); @@ -298,6 +292,13 @@ public class ThreePaneLayout extends LinearLayout { return changePaneState(STATE_RIGHT_VISIBLE, true); } + private int getMailboxListWidth() { + if (!shouldShowMailboxList()) { + return 0; + } + return mMailboxListWidth; + } + private boolean changePaneState(int newState, boolean animate) { if (!isPaneCollapsible() && (newState == STATE_MIDDLE_EXPANDED)) { newState = STATE_RIGHT_VISIBLE; @@ -329,7 +330,7 @@ public class ThreePaneLayout extends LinearLayout { final String animatorLabel; // for debug purpose - setViewWidth(mLeftPane, mMailboxListWidth); + setViewWidth(mLeftPane, getMailboxListWidth()); setViewWidth(mRightPane, totalWidth - getMessageListWidth()); switch (mPaneState) { @@ -337,18 +338,18 @@ public class ThreePaneLayout extends LinearLayout { // mailbox + message list animatorLabel = "moving to [mailbox list + message list]"; expectedMailboxLeft = 0; - expectedMessageListWidth = totalWidth - mMailboxListWidth; + expectedMessageListWidth = totalWidth - getMailboxListWidth(); break; case STATE_RIGHT_VISIBLE: // message list + message view animatorLabel = "moving to [message list + message view]"; - expectedMailboxLeft = -mMailboxListWidth; + expectedMailboxLeft = -getMailboxListWidth(); expectedMessageListWidth = getMessageListWidth(); break; default: throw new IllegalStateException(); } - + setViewWidth(mMiddlePane, expectedMessageListWidth); final View[][] showHideViews = mShowHideViews[mPaneState]; final AnimatorListener listener = new AnimatorListener(animatorLabel, showHideViews[INDEX_VISIBLE], diff --git a/src/com/android/email/activity/UIControllerSearchTwoPane.java b/src/com/android/email/activity/UIControllerSearchTwoPane.java new file mode 100644 index 000000000..407dbeea4 --- /dev/null +++ b/src/com/android/email/activity/UIControllerSearchTwoPane.java @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.email.activity; + + +/** + * TwoPane controller for search results in portrait. + */ +public class UIControllerSearchTwoPane extends UIControllerTwoPane { + + public UIControllerSearchTwoPane(EmailActivity activity) { + super(activity); + } + + /** {@inheritDoc} */ + @Override + public boolean onBackPressed(boolean isSystemBackKey) { + if (isMessageViewInstalled() && mThreePane.showLeftPane()) { + return true; + } + return super.onBackPressed(isSystemBackKey); + } + + @Override + public void onActivityViewReady() { + super.onActivityViewReady(); + mThreePane.setIsSearch(true); + } + + @Override + public void onVisiblePanesChanged(int previousVisiblePanes) { + super.onVisiblePanesChanged(previousVisiblePanes); + mThreePane.requestLayout(); + } +} diff --git a/src/com/android/email/activity/UIControllerTwoPane.java b/src/com/android/email/activity/UIControllerTwoPane.java index 11df43f08..26223c26d 100644 --- a/src/com/android/email/activity/UIControllerTwoPane.java +++ b/src/com/android/email/activity/UIControllerTwoPane.java @@ -54,7 +54,7 @@ class UIControllerTwoPane extends UIControllerBase implements ThreePaneLayout.Ca static final int INBOX_AUTO_REFRESH_MIN_INTERVAL = 10 * 1000; // in milliseconds // Other UI elements - private ThreePaneLayout mThreePane; + protected ThreePaneLayout mThreePane; private MessageCommandButtonView mMessageCommandButtons; @@ -359,7 +359,7 @@ class UIControllerTwoPane extends UIControllerBase implements ThreePaneLayout.Ca if (messageId != Message.NO_MESSAGE) { updateMessageView(ft, messageId); mThreePane.showRightPane(); - } else if (mListContext.isSearch()) { + } else if (mListContext.isSearch() && UiUtilities.showTwoPaneSearchResults(mActivity)) { mThreePane.showRightPane(); } else { mThreePane.showLeftPane(); diff --git a/src/com/android/email/activity/UiUtilities.java b/src/com/android/email/activity/UiUtilities.java index a91806740..1dc3a25b5 100644 --- a/src/com/android/email/activity/UiUtilities.java +++ b/src/com/android/email/activity/UiUtilities.java @@ -173,4 +173,11 @@ public class UiUtilities { } return context.getResources().getBoolean(R.bool.use_two_pane); } + + /** + * Return whether to show search results in a split pane. + */ + public static boolean showTwoPaneSearchResults(Context context) { + return context.getResources().getBoolean(R.bool.show_two_pane_search_result); + } }