diff options
author | Tony Mantler <nicoya@google.com> | 2014-10-03 15:26:53 -0700 |
---|---|---|
committer | Tony Mantler <nicoya@google.com> | 2014-10-06 18:44:25 +0000 |
commit | e5f28abed41c8d32fc4b42adcb2ff6620fdda652 (patch) | |
tree | d9ca5008a26276cbe1fad6f438bf8f425e08a172 | |
parent | 93a03315d10eb749e634b7888a62645920aca982 (diff) | |
download | android_packages_apps_UnifiedEmail-e5f28abed41c8d32fc4b42adcb2ff6620fdda652.tar.gz android_packages_apps_UnifiedEmail-e5f28abed41c8d32fc4b42adcb2ff6620fdda652.tar.bz2 android_packages_apps_UnifiedEmail-e5f28abed41c8d32fc4b42adcb2ff6620fdda652.zip |
Give minidrawer items an activated state background
I'd prefer to use a layer-list or something but that doesn't
get along well with selectableItemBackground on pre-L.
b/17536955
Change-Id: I7dfd814205c5df43acfb3e7aea5050bc750807fd
-rw-r--r-- | res/drawable/folder_item.xml | 2 | ||||
-rw-r--r-- | res/drawable/mini_drawer_folder_background.xml | 26 | ||||
-rw-r--r-- | res/layout/mini_drawer_folder_item.xml | 12 | ||||
-rw-r--r-- | res/values-v21/colors.xml | 3 | ||||
-rw-r--r-- | res/values/colors.xml | 4 | ||||
-rw-r--r-- | src/com/android/mail/ui/MiniDrawerView.java | 8 |
6 files changed, 46 insertions, 9 deletions
diff --git a/res/drawable/folder_item.xml b/res/drawable/folder_item.xml index 98b158842..f63939604 100644 --- a/res/drawable/folder_item.xml +++ b/res/drawable/folder_item.xml @@ -17,6 +17,6 @@ --> <selector xmlns:android="http://schemas.android.com/apk/res/android"> - <item android:state_activated="true" android:drawable="@color/drawer_item_selected_background_color" /> + <item android:state_activated="true" android:drawable="@color/drawer_item_activated_background_color" /> <item android:drawable="@android:color/transparent" /> </selector> diff --git a/res/drawable/mini_drawer_folder_background.xml b/res/drawable/mini_drawer_folder_background.xml new file mode 100644 index 000000000..295643ff4 --- /dev/null +++ b/res/drawable/mini_drawer_folder_background.xml @@ -0,0 +1,26 @@ +<?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. +--> +<selector xmlns:android="http://schemas.android.com/apk/res/android"> + <item android:state_activated="true"> + <shape> + <corners android:radius="2dp" /> + <solid android:color="@color/mini_drawer_activated_background_color" /> + </shape> + </item> + <item android:drawable="@android:color/transparent" /> +</selector> diff --git a/res/layout/mini_drawer_folder_item.xml b/res/layout/mini_drawer_folder_item.xml index e8b9ae73a..fcfeacd12 100644 --- a/res/layout/mini_drawer_folder_item.xml +++ b/res/layout/mini_drawer_folder_item.xml @@ -15,6 +15,12 @@ See the License for the specific language governing permissions and limitations under the License. --> - -<ImageView xmlns:android="http://schemas.android.com/apk/res/android" - style="@style/MiniDrawerFolderStyle" /> +<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_height="wrap_content" + android:layout_width="wrap_content" + android:layout_gravity="center_horizontal" + android:background="@drawable/mini_drawer_folder_background"> + <ImageView + android:id="@+id/image_view" + style="@style/MiniDrawerFolderStyle" /> +</FrameLayout> diff --git a/res/values-v21/colors.xml b/res/values-v21/colors.xml index fe91d0f05..45fe3a583 100644 --- a/res/values-v21/colors.xml +++ b/res/values-v21/colors.xml @@ -16,6 +16,7 @@ limitations under the License. --> <resources> + <color name="mini_drawer_activated_background_color">#e4e4e4</color> <color name="text_color_undo_notification">@color/text_color_grey</color> <color name="text_color_undo_notification_description">@color/text_color_black</color> -</resources>
\ No newline at end of file +</resources> diff --git a/res/values/colors.xml b/res/values/colors.xml index 786923046..74cc016a4 100644 --- a/res/values/colors.xml +++ b/res/values/colors.xml @@ -53,7 +53,9 @@ <color name="account_item_selected_text_color">@color/mail_app_blue</color> <color name="folder_list_heading_text_color">@color/text_color_medium_grey</color> <color name="list_background_color">@android:color/white</color> - <color name="drawer_item_selected_background_color">#12000000</color> + <color name="drawer_item_activated_background_color">#12000000</color> + <color name="mini_drawer_activated_background_color">#d3d3d3</color> + <!-- overridden in sw600dp --> <color name="folder_list_divider_color">@color/divider_color</color> diff --git a/src/com/android/mail/ui/MiniDrawerView.java b/src/com/android/mail/ui/MiniDrawerView.java index 4ebe64196..4d815b832 100644 --- a/src/com/android/mail/ui/MiniDrawerView.java +++ b/src/com/android/mail/ui/MiniDrawerView.java @@ -22,6 +22,7 @@ import android.graphics.Rect; import android.util.AttributeSet; import android.view.LayoutInflater; import android.view.View; +import android.view.ViewGroup; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.ListAdapter; @@ -151,12 +152,13 @@ public class MiniDrawerView extends LinearLayout { while (folderCursor.moveToPosition(++pos)) { final Folder f = folderCursor.getModel(); if (f.isInbox()) { - final ImageView iv = (ImageView) mInflater.inflate( + final View view = mInflater.inflate( R.layout.mini_drawer_folder_item, this, false /* attachToRoot */); + final ImageView iv = (ImageView) view.findViewById(R.id.image_view); iv.setTag(new FolderItem(f, iv)); iv.setContentDescription(f.name); - iv.setActivated(mController.isSelectedFolder(f)); - addView(iv, 1 + numInboxes); + view.setActivated(mController.isSelectedFolder(f)); + addView(view, 1 + numInboxes); numInboxes++; } } |