From 4d2f2483f6d9e2eb25d843d676981f4ebc9c79e5 Mon Sep 17 00:00:00 2001 From: Alan Viverette Date: Sun, 1 Jun 2014 15:58:04 -0700 Subject: Fixes hotspot list transitions, update to use a single hotspot Also updates background and button colors to match spec, removes dependency on bouncycastle Arrays. Vastly simplifies ripple drawing. Adds APIs for maximum ripple radius. Makes selectableItemBackground bounded by default and adds an unbounded version and theme attribute. BUG: 15315168 BUG: 15314684 BUG: 15314830 BUG: 15316768 BUG: 15333033 BUG: 15344050 Change-Id: Ib0619587ce78e43056b66571bae185e0f1613185 --- core/java/android/widget/AbsListView.java | 35 +++++++++++++------ core/res/res/color/btn_default_quantum_dark.xml | 4 +-- core/res/res/color/btn_default_quantum_light.xml | 4 +-- .../item_background_borderless_quantum.xml | 19 ++++++++++ core/res/res/drawable/item_background_quantum.xml | 7 ++-- core/res/res/drawable/list_selector_quantum.xml | 22 ------------ core/res/res/values/attrs.xml | 11 +++--- core/res/res/values/colors_quantum.xml | 10 ++++-- core/res/res/values/public.xml | 1 + core/res/res/values/styles_quantum.xml | 40 ++++++++-------------- core/res/res/values/themes.xml | 3 ++ core/res/res/values/themes_quantum.xml | 22 ++++++------ 12 files changed, 98 insertions(+), 80 deletions(-) create mode 100644 core/res/res/drawable/item_background_borderless_quantum.xml delete mode 100644 core/res/res/drawable/list_selector_quantum.xml (limited to 'core') diff --git a/core/java/android/widget/AbsListView.java b/core/java/android/widget/AbsListView.java index c9eb130..9a46052 100644 --- a/core/java/android/widget/AbsListView.java +++ b/core/java/android/widget/AbsListView.java @@ -2495,17 +2495,25 @@ public abstract class AbsListView extends AdapterView implements Te } /** - * Positions the selector in a way that mimics keyboard focus. If the - * selector drawable supports hotspots, this manages the focus hotspot. + * Positions the selector in a way that mimics keyboard focus. */ void positionSelectorLikeFocus(int position, View sel) { + // If we're changing position, update the visibility since the selector + // is technically being detached from the previous selection. + final Drawable selector = mSelector; + final boolean manageState = selector != null && mSelectorPosition != position + && position != INVALID_POSITION; + if (manageState) { + selector.setVisible(false, false); + } + positionSelector(position, sel); - final Drawable selector = mSelector; - if (selector != null && position != INVALID_POSITION) { + if (manageState) { final Rect bounds = mSelectorRect; final float x = bounds.exactCenterX(); final float y = bounds.exactCenterY(); + selector.setVisible(getVisibility() == VISIBLE, false); selector.setHotspot(x, y); } } @@ -2520,8 +2528,18 @@ public abstract class AbsListView extends AdapterView implements Te if (sel instanceof SelectionBoundsAdjuster) { ((SelectionBoundsAdjuster)sel).adjustListItemSelectionBounds(selectorRect); } - positionSelector(selectorRect.left, selectorRect.top, selectorRect.right, - selectorRect.bottom); + + // Adjust for selection padding. + selectorRect.left -= mSelectionLeftPadding; + selectorRect.top -= mSelectionTopPadding; + selectorRect.right += mSelectionRightPadding; + selectorRect.bottom += mSelectionBottomPadding; + + // Update the selector drawable. + final Drawable selector = mSelector; + if (selector != null) { + selector.setBounds(selectorRect); + } final boolean isChildViewEnabled = mIsChildViewEnabled; if (sel.isEnabled() != isChildViewEnabled) { @@ -2532,11 +2550,6 @@ public abstract class AbsListView extends AdapterView implements Te } } - private void positionSelector(int l, int t, int r, int b) { - mSelectorRect.set(l - mSelectionLeftPadding, t - mSelectionTopPadding, r - + mSelectionRightPadding, b + mSelectionBottomPadding); - } - @Override protected void dispatchDraw(Canvas canvas) { int saveCount = 0; diff --git a/core/res/res/color/btn_default_quantum_dark.xml b/core/res/res/color/btn_default_quantum_dark.xml index f2e772d..ec0f140 100644 --- a/core/res/res/color/btn_default_quantum_dark.xml +++ b/core/res/res/color/btn_default_quantum_dark.xml @@ -15,6 +15,6 @@ --> - - + + diff --git a/core/res/res/color/btn_default_quantum_light.xml b/core/res/res/color/btn_default_quantum_light.xml index de1bd2c..9536d24 100644 --- a/core/res/res/color/btn_default_quantum_light.xml +++ b/core/res/res/color/btn_default_quantum_light.xml @@ -15,6 +15,6 @@ --> - - + + diff --git a/core/res/res/drawable/item_background_borderless_quantum.xml b/core/res/res/drawable/item_background_borderless_quantum.xml new file mode 100644 index 0000000..c2a1c127 --- /dev/null +++ b/core/res/res/drawable/item_background_borderless_quantum.xml @@ -0,0 +1,19 @@ + + + + diff --git a/core/res/res/drawable/item_background_quantum.xml b/core/res/res/drawable/item_background_quantum.xml index c2a1c127..039ca51 100644 --- a/core/res/res/drawable/item_background_quantum.xml +++ b/core/res/res/drawable/item_background_quantum.xml @@ -15,5 +15,8 @@ --> + android:tint="?attr/colorControlHighlight"> + + + + \ No newline at end of file diff --git a/core/res/res/drawable/list_selector_quantum.xml b/core/res/res/drawable/list_selector_quantum.xml deleted file mode 100644 index 6cd59e5..0000000 --- a/core/res/res/drawable/list_selector_quantum.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml index 5fec907..c0286f1 100644 --- a/core/res/res/values/attrs.xml +++ b/core/res/res/values/attrs.xml @@ -890,9 +890,12 @@ with the appearance of a singel button broken into segments. --> - + + + + @@ -4658,11 +4661,11 @@ - + - + - + diff --git a/core/res/res/values/colors_quantum.xml b/core/res/res/values/colors_quantum.xml index 556463e..976930c 100644 --- a/core/res/res/values/colors_quantum.xml +++ b/core/res/res/values/colors_quantum.xml @@ -16,8 +16,14 @@ - #ff303030 - @color/white + #ff414042 + #fff1f2f2 + + #30ffffff + #30000000 + + #ff5a595b + #ffd6d7d7 @color/white @color/black diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml index 2d5477c..e9a2f9f 100644 --- a/core/res/res/values/public.xml +++ b/core/res/res/values/public.xml @@ -2178,6 +2178,7 @@ + diff --git a/core/res/res/values/styles_quantum.xml b/core/res/res/values/styles_quantum.xml index 6943533..b55edf8 100644 --- a/core/res/res/values/styles_quantum.xml +++ b/core/res/res/values/styles_quantum.xml @@ -405,7 +405,9 @@ please see styles_device_defaults.xml. ?attr/textColorPrimary 48dip 96dip - @anim/button_state_list_anim_quantum + + + @@ -434,7 +436,6 @@ please see styles_device_defaults.xml. @drawable/btn_toggle_quantum @string/capital_on @string/capital_off - ?attr/textAppearanceSmall 48dip @@ -468,34 +469,29 @@ please see styles_device_defaults.xml. 8dp - - + @@ -626,7 +622,7 @@ please see styles_device_defaults.xml. 16dip 16dip true - ?attr/selectableItemBackground + ?attr/selectableItemBackgroundBorderless - + @@ -446,6 +446,7 @@ please see themes_device_defaults.xml. @style/Widget.Quantum.Light.MediaRouteButton @drawable/item_background_quantum + @drawable/item_background_borderless_quantum @style/Widget.Quantum.Light.Button.Borderless @drawable/ic_ab_back_quantum @@ -470,8 +471,7 @@ please see themes_device_defaults.xml. @drawable/btn_radio_quantum_anim @drawable/btn_check_quantum_anim - @drawable/list_selector_quantum - + ?attr/selectableItemBackground @drawable/activated_background_quantum 40dip @@ -655,7 +655,7 @@ please see themes_device_defaults.xml. @style/Widget.Quantum.Light.PopupWindow.ActionMode @style/ThemeOverlay.Quantum.ActionBarWidget @null - @drawable/item_background_quantum + ?attr/selectableItemBackgroundBorderless @drawable/ic_menu_cut_quantum @drawable/ic_menu_copy_quantum @@ -721,8 +721,8 @@ please see themes_device_defaults.xml. ?attr/textColorSecondary ?attr/colorPrimary - #30000000 + @color/ripple_quantum_light @color/btn_default_quantum_light @@ -770,7 +770,8 @@ please see themes_device_defaults.xml. @drawable/fastscroll_label_left_holo_light @drawable/fastscroll_label_right_holo_light - @color/quantum_grey_100 + @color/ripple_quantum_light + @color/btn_default_quantum_light