diff options
author | Rohan Shah <shahrk@google.com> | 2014-09-11 08:41:43 -0700 |
---|---|---|
committer | Rohan Shah <shahrk@google.com> | 2014-09-19 22:25:27 +0000 |
commit | f9fd2cf057d845c7b081a3f17482dd0b886179d1 (patch) | |
tree | 751d674f84dc5d70a77352c6f5d1bd20f5d0d525 | |
parent | 3f784c879e564cb144d542b29c4e68e980d2c298 (diff) | |
download | android_packages_apps_UnifiedEmail-f9fd2cf057d845c7b081a3f17482dd0b886179d1.tar.gz android_packages_apps_UnifiedEmail-f9fd2cf057d845c7b081a3f17482dd0b886179d1.tar.bz2 android_packages_apps_UnifiedEmail-f9fd2cf057d845c7b081a3f17482dd0b886179d1.zip |
Update shadows for TL (Quantum) UnifiedEmail
NOTE: I'll fix FAB issues in a different CL
Add shadows assets on L & pre-L (RTL included)
for thread list sides. To avoid overdraw, the
backgrounds have been modified (The outermost
framelayout for TL now has a white background
instead of each of the conversation items).
For both L & pre-L, we're using two shadow assets
on either side of the TL, both of which are
set as backgrounds for the drawer and
the conversation view (conv pane). Elevation
didn't work out too well and will be revisited
while fixing overdraw issues (Need to move around
swipe/leave-behind item backgrounds and it
seems a bit risky to mess with it given the
timeline)
+ Also removed the background on the loading
item under conversations in the TL and used
the default conversation item background to
get rid of the ugly divider/slight line flicker
on folder change
Bug: 17461682
Change-Id: Id9e4504b6063f21a055ed492fc8de962e6e52462
34 files changed, 134 insertions, 168 deletions
diff --git a/res/drawable-hdpi/ic_vertical_shadow_end_4dp.9.png b/res/drawable-hdpi/ic_vertical_shadow_end_4dp.9.png Binary files differnew file mode 100644 index 000000000..88c72be2b --- /dev/null +++ b/res/drawable-hdpi/ic_vertical_shadow_end_4dp.9.png diff --git a/res/drawable-hdpi/ic_vertical_shadow_start_6dp.9.png b/res/drawable-hdpi/ic_vertical_shadow_start_6dp.9.png Binary files differnew file mode 100644 index 000000000..4d4f439b3 --- /dev/null +++ b/res/drawable-hdpi/ic_vertical_shadow_start_6dp.9.png diff --git a/res/drawable-ldrtl-hdpi/ic_vertical_shadow_end_4dp.9.png b/res/drawable-ldrtl-hdpi/ic_vertical_shadow_end_4dp.9.png Binary files differnew file mode 100644 index 000000000..e119bad72 --- /dev/null +++ b/res/drawable-ldrtl-hdpi/ic_vertical_shadow_end_4dp.9.png diff --git a/res/drawable-ldrtl-hdpi/ic_vertical_shadow_start_6dp.9.png b/res/drawable-ldrtl-hdpi/ic_vertical_shadow_start_6dp.9.png Binary files differnew file mode 100644 index 000000000..1a47ee287 --- /dev/null +++ b/res/drawable-ldrtl-hdpi/ic_vertical_shadow_start_6dp.9.png diff --git a/res/drawable-ldrtl-mdpi/ic_vertical_shadow_end_4dp.9.png b/res/drawable-ldrtl-mdpi/ic_vertical_shadow_end_4dp.9.png Binary files differnew file mode 100644 index 000000000..c8fc1b3c3 --- /dev/null +++ b/res/drawable-ldrtl-mdpi/ic_vertical_shadow_end_4dp.9.png diff --git a/res/drawable-ldrtl-mdpi/ic_vertical_shadow_start_6dp.9.png b/res/drawable-ldrtl-mdpi/ic_vertical_shadow_start_6dp.9.png Binary files differnew file mode 100644 index 000000000..b4728bb1f --- /dev/null +++ b/res/drawable-ldrtl-mdpi/ic_vertical_shadow_start_6dp.9.png diff --git a/res/drawable-ldrtl-xhdpi/ic_vertical_shadow_end_4dp.9.png b/res/drawable-ldrtl-xhdpi/ic_vertical_shadow_end_4dp.9.png Binary files differnew file mode 100644 index 000000000..9a7eb50c3 --- /dev/null +++ b/res/drawable-ldrtl-xhdpi/ic_vertical_shadow_end_4dp.9.png diff --git a/res/drawable-ldrtl-xhdpi/ic_vertical_shadow_start_6dp.9.png b/res/drawable-ldrtl-xhdpi/ic_vertical_shadow_start_6dp.9.png Binary files differnew file mode 100644 index 000000000..3e5cf4a3c --- /dev/null +++ b/res/drawable-ldrtl-xhdpi/ic_vertical_shadow_start_6dp.9.png diff --git a/res/drawable-ldrtl-xxhdpi/ic_vertical_shadow_end_4dp.9.png b/res/drawable-ldrtl-xxhdpi/ic_vertical_shadow_end_4dp.9.png Binary files differnew file mode 100644 index 000000000..b781e2d89 --- /dev/null +++ b/res/drawable-ldrtl-xxhdpi/ic_vertical_shadow_end_4dp.9.png diff --git a/res/drawable-ldrtl-xxhdpi/ic_vertical_shadow_start_6dp.9.png b/res/drawable-ldrtl-xxhdpi/ic_vertical_shadow_start_6dp.9.png Binary files differnew file mode 100644 index 000000000..1a8d69df5 --- /dev/null +++ b/res/drawable-ldrtl-xxhdpi/ic_vertical_shadow_start_6dp.9.png diff --git a/res/drawable-mdpi/ic_vertical_shadow_end_4dp.9.png b/res/drawable-mdpi/ic_vertical_shadow_end_4dp.9.png Binary files differnew file mode 100644 index 000000000..ec1555c21 --- /dev/null +++ b/res/drawable-mdpi/ic_vertical_shadow_end_4dp.9.png diff --git a/res/drawable-mdpi/ic_vertical_shadow_start_6dp.9.png b/res/drawable-mdpi/ic_vertical_shadow_start_6dp.9.png Binary files differnew file mode 100644 index 000000000..3239363d6 --- /dev/null +++ b/res/drawable-mdpi/ic_vertical_shadow_start_6dp.9.png diff --git a/res/drawable-v19/conversation_wide_unread_selector.xml b/res/drawable-v19/conversation_wide_unread_selector.xml deleted file mode 100644 index 39de4ac5c..000000000 --- a/res/drawable-v19/conversation_wide_unread_selector.xml +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - Copyright (C) 2011 Google Inc. - Licensed to 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. ---> -<selector xmlns:android="http://schemas.android.com/apk/res/android"> - <item android:state_focused="true" - android:drawable="@drawable/list_conversation_wide_unread_focused_holo" /> - <item android:state_pressed="true" - android:drawable="@drawable/list_conversation_wide_unread_pressed_holo" /> - <item android:state_activated="true" - android:drawable="@drawable/list_conversation_wide_unread_pressed_holo" /> - <item android:state_selected="true" - android:drawable="@drawable/list_conversation_wide_unread_selected_holo" /> - <item android:drawable="@drawable/list_conversation_wide_unread_normal_holo" /> -</selector> diff --git a/res/drawable-v21/conversation_item_background_ripple.xml b/res/drawable-v21/conversation_item_background_ripple.xml index 2b336f9f9..f474b14db 100644 --- a/res/drawable-v21/conversation_item_background_ripple.xml +++ b/res/drawable-v21/conversation_item_background_ripple.xml @@ -16,6 +16,8 @@ limitations under the License. --> <ripple xmlns:android="http://schemas.android.com/apk/res/android" - android:color="@color/conversation_item_blue_background"> + android:color="@color/conversation_item_blue_background"> + <item android:drawable="@android:color/white" /> + </ripple>
\ No newline at end of file diff --git a/res/drawable-xhdpi/ic_vertical_shadow_end_4dp.9.png b/res/drawable-xhdpi/ic_vertical_shadow_end_4dp.9.png Binary files differnew file mode 100644 index 000000000..2d100c0d4 --- /dev/null +++ b/res/drawable-xhdpi/ic_vertical_shadow_end_4dp.9.png diff --git a/res/drawable-xhdpi/ic_vertical_shadow_start_6dp.9.png b/res/drawable-xhdpi/ic_vertical_shadow_start_6dp.9.png Binary files differnew file mode 100644 index 000000000..0cff034f4 --- /dev/null +++ b/res/drawable-xhdpi/ic_vertical_shadow_start_6dp.9.png diff --git a/res/drawable-xxhdpi/ic_vertical_shadow_end_4dp.9.png b/res/drawable-xxhdpi/ic_vertical_shadow_end_4dp.9.png Binary files differnew file mode 100644 index 000000000..9edd16b55 --- /dev/null +++ b/res/drawable-xxhdpi/ic_vertical_shadow_end_4dp.9.png diff --git a/res/drawable-xxhdpi/ic_vertical_shadow_start_6dp.9.png b/res/drawable-xxhdpi/ic_vertical_shadow_start_6dp.9.png Binary files differnew file mode 100644 index 000000000..4aefadea9 --- /dev/null +++ b/res/drawable-xxhdpi/ic_vertical_shadow_start_6dp.9.png diff --git a/res/drawable-xxxhdpi/ic_vertical_shadow_end_4dp.9.png b/res/drawable-xxxhdpi/ic_vertical_shadow_end_4dp.9.png Binary files differnew file mode 100644 index 000000000..33c93ee87 --- /dev/null +++ b/res/drawable-xxxhdpi/ic_vertical_shadow_end_4dp.9.png diff --git a/res/drawable-xxxhdpi/ic_vertical_shadow_start_6dp.9.png b/res/drawable-xxxhdpi/ic_vertical_shadow_start_6dp.9.png Binary files differnew file mode 100644 index 000000000..f86d386f2 --- /dev/null +++ b/res/drawable-xxxhdpi/ic_vertical_shadow_start_6dp.9.png diff --git a/res/drawable/conversation_wide_unread_selector.xml b/res/drawable/conversation_wide_unread_selector.xml deleted file mode 100644 index 39de4ac5c..000000000 --- a/res/drawable/conversation_wide_unread_selector.xml +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - Copyright (C) 2011 Google Inc. - Licensed to 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. ---> -<selector xmlns:android="http://schemas.android.com/apk/res/android"> - <item android:state_focused="true" - android:drawable="@drawable/list_conversation_wide_unread_focused_holo" /> - <item android:state_pressed="true" - android:drawable="@drawable/list_conversation_wide_unread_pressed_holo" /> - <item android:state_activated="true" - android:drawable="@drawable/list_conversation_wide_unread_pressed_holo" /> - <item android:state_selected="true" - android:drawable="@drawable/list_conversation_wide_unread_selected_holo" /> - <item android:drawable="@drawable/list_conversation_wide_unread_normal_holo" /> -</selector> diff --git a/res/layout/conversation_list.xml b/res/layout/conversation_list.xml index a9eeb1823..70f9d1f94 100644 --- a/res/layout/conversation_list.xml +++ b/res/layout/conversation_list.xml @@ -19,7 +19,8 @@ <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/between_chrome" android:layout_width="match_parent" - android:layout_height="match_parent"> + android:layout_height="match_parent" + android:background="@color/conversation_list_background_color"> <com.android.mail.ui.MailSwipeRefreshLayout android:id="@+id/swipe_refresh_widget" diff --git a/res/layout/conversation_list_footer_view.xml b/res/layout/conversation_list_footer_view.xml index 2909cdb53..2238e13e2 100644 --- a/res/layout/conversation_list_footer_view.xml +++ b/res/layout/conversation_list_footer_view.xml @@ -22,7 +22,7 @@ android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="wrap_content" - android:background="@android:color/white"> + android:background="@drawable/conversation_item_background"> <LinearLayout android:id="@+id/network_error" android:layout_width="match_parent" diff --git a/res/layout/folder_teaser_item.xml b/res/layout/folder_teaser_item.xml index e23bacc56..382894eb7 100644 --- a/res/layout/folder_teaser_item.xml +++ b/res/layout/folder_teaser_item.xml @@ -19,6 +19,7 @@ android:orientation="vertical"> <LinearLayout + android:id="@+id/folder_teaser_row" android:layout_width="match_parent" android:layout_height="wrap_content" android:minHeight="@dimen/folder_teaser_item_height" diff --git a/res/layout/two_pane_activity.xml b/res/layout/two_pane_activity.xml index 3b9ef3389..a2ca3b6a8 100644 --- a/res/layout/two_pane_activity.xml +++ b/res/layout/two_pane_activity.xml @@ -52,14 +52,14 @@ android:id="@+id/conversation_list_pane" android:layout_width="0dp" android:layout_height="match_parent" - android:layout_gravity="left" - style="@style/TwoPaneConversationList" /> + android:layout_gravity="left" /> <com.android.mail.ui.ConversationViewFrame android:id="@+id/conversation_pane" android:layout_width="0dp" android:layout_height="match_parent" - android:layout_gravity="left"> + android:layout_gravity="left" + android:foreground="@drawable/ic_vertical_shadow_end_4dp" > <include layout="@layout/conversation_pager" android:layout_width="match_parent" @@ -71,7 +71,8 @@ android:id="@+id/miscellaneous_pane" android:layout_width="0dp" android:layout_height="match_parent" - android:layout_gravity="left" /> + android:layout_gravity="left" + android:foreground="@drawable/ic_vertical_shadow_end_4dp" /> <include layout="@layout/floating_actions" /> diff --git a/res/values-ldrtl-sw600dp-port/styles.xml b/res/values-ldrtl-sw600dp-port/styles.xml deleted file mode 100644 index 0a988d8f5..000000000 --- a/res/values-ldrtl-sw600dp-port/styles.xml +++ /dev/null @@ -1,23 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - Copyright (C) 2014 Google Inc. - Licensed to 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. ---> - -<resources> - <style name="TwoPaneConversationList"> - <item name="android:paddingEnd">@dimen/two_pane_tl_side</item> - </style> -</resources> diff --git a/res/values-sw600dp-port/styles.xml b/res/values-sw600dp-port/styles.xml deleted file mode 100644 index 29016fa8d..000000000 --- a/res/values-sw600dp-port/styles.xml +++ /dev/null @@ -1,30 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - Copyright (C) 2014 Google Inc. - Licensed to 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. ---> - -<resources> - <style name="TwoPaneConversationList"> - <item name="android:paddingRight">@dimen/two_pane_tl_side</item> - </style> - - <style name="ConversationListFade" parent="@style/ConversationListFadeBase"> - <item name="android:paddingTop">@dimen/two_pane_tl_top</item> - <item name="android:paddingBottom">@dimen/two_pane_tl_top</item> - <item name="android:clipToPadding">false</item> - <item name="android:divider">@null</item> - </style> -</resources> diff --git a/res/values-sw600dp/colors.xml b/res/values-sw600dp/colors.xml index 85bc9a9d6..cda7c4708 100644 --- a/res/values-sw600dp/colors.xml +++ b/res/values-sw600dp/colors.xml @@ -3,4 +3,6 @@ <color name="folder_list_divider_color">#b2b2b2</color> <color name="drawer_item_selected_background_color">#e4e4e4</color> <color name="mail_activity_status_bar_color">@color/primary_dark_color</color> + <color name="loading_messages_background_color">@android:color/white</color> + <color name="conversation_list_background_color">@android:color/white</color> </resources> diff --git a/res/values/colors.xml b/res/values/colors.xml index 1c32c7c0e..c79323734 100644 --- a/res/values/colors.xml +++ b/res/values/colors.xml @@ -174,4 +174,5 @@ <color name="snack_bar_action_text_color">#f4b400</color> <color name="conversation_item_blue_background">#ccf2f7</color> + <color name="conversation_list_background_color">@android:color/transparent</color> </resources> diff --git a/res/values/styles.xml b/res/values/styles.xml index 12a0d1805..4c4709f45 100644 --- a/res/values/styles.xml +++ b/res/values/styles.xml @@ -453,8 +453,6 @@ <style name="NotificationSecondaryText"> </style> - <style name="TwoPaneConversationList" /> - <style name="AttachmentButtonStyle"> <item name="android:clickable">true</item> <item name="android:layout_width">48dip</item> diff --git a/src/com/android/mail/browse/ConversationListFooterView.java b/src/com/android/mail/browse/ConversationListFooterView.java index 1113a2417..c0406409c 100644 --- a/src/com/android/mail/browse/ConversationListFooterView.java +++ b/src/com/android/mail/browse/ConversationListFooterView.java @@ -18,7 +18,6 @@ package com.android.mail.browse; import android.content.Context; -import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.Bundle; import android.util.AttributeSet; @@ -30,11 +29,9 @@ import android.widget.TextView; import com.android.mail.R; import com.android.mail.providers.Folder; import com.android.mail.providers.UIProvider; -import com.android.mail.ui.ViewMode; import com.android.mail.utils.Utils; -public final class ConversationListFooterView extends LinearLayout implements View.OnClickListener, - ViewMode.ModeChangeListener { +public final class ConversationListFooterView extends LinearLayout implements View.OnClickListener { public interface FooterViewClickListener { void onFooterViewErrorActionClick(Folder folder, int errorStatus); @@ -50,14 +47,9 @@ public final class ConversationListFooterView extends LinearLayout implements Vi private Uri mLoadMoreUri; private int mErrorStatus; private FooterViewClickListener mClickListener; - private final boolean mTabletDevice; - // Backgrounds for different states. - private static Drawable sWideBackground; - private static Drawable sNormalBackground; public ConversationListFooterView(Context context, AttributeSet attrs) { super(context, attrs); - mTabletDevice = Utils.useTabletUI(context.getResources()); } @Override @@ -176,36 +168,4 @@ public final class ConversationListFooterView extends LinearLayout implements Vi } return showFooter; } - - /** - * Update to the appropriate background when the view mode changes. - */ - @Override - public void onViewModeChanged(int newMode) { - final Drawable drawable; - if (mTabletDevice && newMode == ViewMode.CONVERSATION_LIST) { - drawable = getWideBackground(); - } else { - drawable = getNormalBackground(); - } - setBackgroundDrawable(drawable); - } - - private Drawable getWideBackground() { - if (sWideBackground == null) { - sWideBackground = getBackground(R.drawable.conversation_wide_unread_selector); - } - return sWideBackground; - } - - private Drawable getNormalBackground() { - if (sNormalBackground == null) { - sNormalBackground = getBackground(R.drawable.conversation_item_background); - } - return sNormalBackground; - } - - private Drawable getBackground(int resId) { - return getContext().getResources().getDrawable(resId); - } } diff --git a/src/com/android/mail/ui/ConversationListFragment.java b/src/com/android/mail/ui/ConversationListFragment.java index ed82494aa..ddeb3a55b 100644 --- a/src/com/android/mail/ui/ConversationListFragment.java +++ b/src/com/android/mail/ui/ConversationListFragment.java @@ -34,6 +34,7 @@ import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.AbsListView; import android.widget.AdapterView; import android.widget.AdapterView.OnItemLongClickListener; import android.widget.ListView; @@ -80,7 +81,8 @@ import static android.view.View.OnKeyListener; */ public final class ConversationListFragment extends Fragment implements OnItemLongClickListener, ModeChangeListener, ListItemSwipedListener, OnRefreshListener, - SwipeListener, OnKeyListener, AdapterView.OnItemClickListener, View.OnClickListener { + SwipeListener, OnKeyListener, AdapterView.OnItemClickListener, View.OnClickListener, + AbsListView.OnScrollListener { /** Key used to pass data to {@link ConversationListFragment}. */ private static final String CONVERSATION_LIST_KEY = "conversation-list"; /** Key used to keep track of the scroll state of the list. */ @@ -167,6 +169,9 @@ public final class ConversationListFragment extends Fragment implements // ACTION_UP). If not, the listview only receives ACTION_UP. private boolean mKeyInitiatedFromList; + // Default color id for what background should be while idle + private int mDefaultListBackgroundColor; + /** Duration, in milliseconds, of the CAB mode (peek icon) animation. */ private static long sSelectionModeAnimationDuration = -1; @@ -372,6 +377,13 @@ public final class ConversationListFragment extends Fragment implements mUpdater = mActivity.getConversationUpdater(); mUpdater.registerConversationListObserver(mConversationCursorObserver); mTabletDevice = Utils.useTabletUI(mActivity.getApplicationContext().getResources()); + + // Shadow mods to TL require background changes and scroll listening to avoid overdraw + mDefaultListBackgroundColor = + getResources().getColor(R.color.conversation_list_background_color); + getView().setBackgroundColor(mDefaultListBackgroundColor); + mListView.setOnScrollListener(this); + // The onViewModeChanged callback doesn't get called when the mode // object is created, so // force setting the mode manually this time around. @@ -479,7 +491,7 @@ public final class ConversationListFragment extends Fragment implements View rootView = inflater.inflate(R.layout.conversation_list, null); mEmptyView = (ConversationListEmptyView) rootView.findViewById(R.id.empty_view); mSecurityHoldView = rootView.findViewById(R.id.security_hold_view); - mSecurityHoldText = (TextView)rootView.findViewById(R.id.security_hold_text); + mSecurityHoldText = (TextView) rootView.findViewById(R.id.security_hold_text); mSecurityHoldButton = rootView.findViewById(R.id.security_hold_button); mSecurityHoldButton.setOnClickListener(this); mLoadingView = rootView.findViewById(R.id.background_view); @@ -754,9 +766,6 @@ public final class ConversationListFragment extends Fragment implements clearChoicesAndActivated(); } } - if (mFooterView != null) { - mFooterView.onViewModeChanged(newMode); - } } public boolean isAnimating() { @@ -1268,4 +1277,31 @@ public final class ConversationListFragment extends Fragment implements startActivity(intent); } } + + @Override + public final void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, + int totalItemCount) { + mListView.onScroll(view, firstVisibleItem, visibleItemCount, totalItemCount); + } + + /** + * Used with SwipeableListView to change conv_list backgrounds to work around shadow elevation + * issues causing and overdraw problems due to static backgrounds. + * + * @param view + * @param scrollState + */ + @Override + public void onScrollStateChanged(final AbsListView view, final int scrollState) { + mListView.onScrollStateChanged(view, scrollState); + + // If not scrolling, assign default background - white for tablet, transparent for phone + if (scrollState == AbsListView.OnScrollListener.SCROLL_STATE_IDLE) { + getView().setBackgroundColor(mDefaultListBackgroundColor); + + // Otherwise, list is scrolling, so remove background (corresponds to 0 input) + } else { + getView().setBackgroundResource(0); + } + } } diff --git a/src/com/android/mail/ui/SwipeableListView.java b/src/com/android/mail/ui/SwipeableListView.java index a3549c85e..fb5198ba1 100644 --- a/src/com/android/mail/ui/SwipeableListView.java +++ b/src/com/android/mail/ui/SwipeableListView.java @@ -84,11 +84,11 @@ public class SwipeableListView extends ListView implements Callback, OnScrollLis public SwipeableListView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); - setOnScrollListener(this); float densityScale = getResources().getDisplayMetrics().density; float pagingTouchSlop = ViewConfiguration.get(context).getScaledPagingTouchSlop(); mSwipeHelper = new SwipeHelper(context, SwipeHelper.X, this, densityScale, pagingTouchSlop); + mScrolling = false; } @Override diff --git a/src/com/android/mail/ui/TwoPaneLayout.java b/src/com/android/mail/ui/TwoPaneLayout.java index a5fa76dbb..6b19e0d6d 100644 --- a/src/com/android/mail/ui/TwoPaneLayout.java +++ b/src/com/android/mail/ui/TwoPaneLayout.java @@ -22,12 +22,16 @@ import java.util.List; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.TimeInterpolator; +import android.animation.ValueAnimator; import android.app.Activity; import android.content.Context; import android.content.res.Resources; +import android.graphics.Canvas; +import android.graphics.drawable.Drawable; import android.util.AttributeSet; import android.view.View; import android.view.ViewGroup; +import android.view.ViewPropertyAnimator; import android.view.animation.AnimationUtils; import android.widget.FrameLayout; @@ -103,6 +107,9 @@ final class TwoPaneLayout extends FrameLayout implements ModeChangeListener { private View mFoldersView; private View mListView; + private final Drawable mShadowDrawable; + private final int mShadowMinWidth; + private final List<Runnable> mTransitionCompleteJobs = Lists.newArrayList(); private final PaneAnimationListener mPaneAnimationListener = new PaneAnimationListener(); @@ -119,6 +126,26 @@ final class TwoPaneLayout extends FrameLayout implements ModeChangeListener { void onConversationListLayout(int xEnd, boolean drawerOpen); } + // Responsible for invalidating the shadow region only to minimize drawing overhead (and jank) + // Coordinated with ListView animation to ensure shadow and list slide together. + private final ValueAnimator.AnimatorUpdateListener mListViewAnimationListener = + new ValueAnimator.AnimatorUpdateListener() { + @Override + public void onAnimationUpdate(ValueAnimator valueAnimator) { + if (ViewUtils.isViewRtl(TwoPaneLayout.this)) { + // Get the right edge of list and use as left edge coord for shadow + final int leftEdgeCoord = (int) mListView.getX() + mListView.getWidth(); + invalidate(leftEdgeCoord, 0, leftEdgeCoord + mShadowMinWidth, + getBottom()); + } else { + // Get the left edge of list and use as right edge coord for shadow + final int rightEdgeCoord = (int) mListView.getX(); + invalidate(rightEdgeCoord - mShadowMinWidth, 0, rightEdgeCoord, + getBottom()); + } + } + }; + public TwoPaneLayout(Context context) { this(context, null); } @@ -143,6 +170,29 @@ final class TwoPaneLayout extends FrameLayout implements ModeChangeListener { final int convViewWeight = res.getInteger(R.integer.conversation_view_weight); mConversationListWeight = (double) convListWeight / (convListWeight + convViewWeight); + + mShadowDrawable = getResources().getDrawable(R.drawable.ic_vertical_shadow_start_6dp); + mShadowMinWidth = mShadowDrawable.getMinimumWidth(); + } + + @Override + protected void dispatchDraw(Canvas canvas) { + // Draw children/update the canvas first. + super.dispatchDraw(canvas); + + if (ViewUtils.isViewRtl(this)) { + // Get the right edge of list and use as left edge coord for shadow + final int leftEdgeCoord = (int) mListView.getX() + mListView.getWidth(); + mShadowDrawable.setBounds(leftEdgeCoord, 0, leftEdgeCoord + mShadowMinWidth, + mListView.getBottom()); + } else { + // Get the left edge of list and use as right edge coord for shadow + final int rightEdgeCoord = (int) mListView.getX(); + mShadowDrawable.setBounds(rightEdgeCoord - mShadowMinWidth, 0, rightEdgeCoord, + mListView.getBottom()); + } + + mShadowDrawable.draw(canvas); } @Override @@ -209,13 +259,12 @@ final class TwoPaneLayout extends FrameLayout implements ModeChangeListener { } /** - * Positions the three sliding panes at the correct X offset (using {@link View#setX(float)}). + * Positions the three sliding panes at the correct X offset (using {@link android.view.View#setX(float)}). * When switching from list->conversation mode or vice versa, animate the change in X. * * @param width */ private void positionPanes(int width) { - final boolean isRtl = ViewUtils.isViewRtl(this); final boolean isDrawerOpen = isDrawerOpen(); final int convX, listX, foldersX; @@ -223,7 +272,9 @@ final class TwoPaneLayout extends FrameLayout implements ModeChangeListener { final int foldersW = isDrawerOpen ? mDrawerWidthOpen : mDrawerWidthMini; final int listW = getPaneWidth(mListView); + final boolean isRtl = ViewUtils.isViewRtl(this); boolean cvOnScreen = true; + if (!mListCollapsible) { if (isRtl) { foldersX = width - mDrawerWidthOpen; @@ -306,7 +357,16 @@ final class TwoPaneLayout extends FrameLayout implements ModeChangeListener { } mFoldersView.animate().x(foldersX); - mListView.animate().x(listX).setListener(mPaneAnimationListener); + + final ViewPropertyAnimator listAnimation = mListView.animate() + .x(listX) + .setListener(mPaneAnimationListener); + + // If we're running K+, we can use the update listener to transition the list's left shadow + // and set different update listeners based on rtl to avoid doing a check on every frame + if (Utils.isRunningKitkatOrLater()) { + listAnimation.setUpdateListener(mListViewAnimationListener); + } configureAnimations(mConversationView, mFoldersView, mListView, mMiscellaneousView); } @@ -521,6 +581,19 @@ final class TwoPaneLayout extends FrameLayout implements ModeChangeListener { } @Override + public void onAnimationStart(Animator animation) { + // If we're running pre-K, we don't have ViewPropertyAnimator's setUpdateListener. + // This is a hack to get around it and uses a dummy ValueAnimator to allow us + // to create an animation for the shadow along with the list view. + if (!Utils.isRunningKitkatOrLater()) { + final ValueAnimator shadowAnimator = ValueAnimator.ofFloat(0, 1); + shadowAnimator.setDuration(SLIDE_DURATION_MS) + .addUpdateListener(mListViewAnimationListener); + shadowAnimator.start(); + } + } + + @Override public void onAnimationEnd(Animator animation) { onTransitionComplete(); } |