summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Viverette <alanv@google.com>2014-08-15 19:58:04 -0700
committerAlan Viverette <alanv@google.com>2014-08-15 19:58:04 -0700
commite8311ac850374c5362e8c1e48b81eb4b0211c70b (patch)
treef2d99cd3d8ba376fd0a6f90b44e50afe6ba52549
parenta2897ea9d8d6eb7c1c0aace695ed835da96bb39c (diff)
downloadframeworks_base-e8311ac850374c5362e8c1e48b81eb4b0211c70b.zip
frameworks_base-e8311ac850374c5362e8c1e48b81eb4b0211c70b.tar.gz
frameworks_base-e8311ac850374c5362e8c1e48b81eb4b0211c70b.tar.bz2
Update fast scroller preview for Material
BUG: 16374061 Change-Id: Iefbbc4f3e8eccb89072bd0885cc337f9e0470d81
-rw-r--r--core/java/android/widget/FastScroller.java30
-rw-r--r--core/res/res/drawable/fastscroll_label_left_material.xml27
-rw-r--r--core/res/res/drawable/fastscroll_label_right_material.xml27
-rw-r--r--core/res/res/values/attrs.xml3
-rw-r--r--core/res/res/values/styles_material.xml4
-rw-r--r--core/res/res/values/themes_material.xml12
6 files changed, 90 insertions, 13 deletions
diff --git a/core/java/android/widget/FastScroller.java b/core/java/android/widget/FastScroller.java
index c0961fd..06b7a93 100644
--- a/core/java/android/widget/FastScroller.java
+++ b/core/java/android/widget/FastScroller.java
@@ -79,6 +79,7 @@ class FastScroller {
// Positions for preview image and text.
private static final int OVERLAY_FLOATING = 0;
private static final int OVERLAY_AT_THUMB = 1;
+ private static final int OVERLAY_ABOVE_THUMB = 2;
// Indices for mPreviewResId.
private static final int PREVIEW_LEFT = 0;
@@ -189,8 +190,9 @@ class FastScroller {
/**
* Position for the preview image and text. One of:
* <ul>
- * <li>{@link #OVERLAY_AT_THUMB}
* <li>{@link #OVERLAY_FLOATING}
+ * <li>{@link #OVERLAY_AT_THUMB}
+ * <li>{@link #OVERLAY_ABOVE_THUMB}
* </ul>
*/
private int mOverlayPosition;
@@ -310,8 +312,10 @@ class FastScroller {
final int textMinSize = Math.max(0, mPreviewMinHeight);
mPrimaryText.setMinimumWidth(textMinSize);
mPrimaryText.setMinimumHeight(textMinSize);
+ mPrimaryText.setIncludeFontPadding(false);
mSecondaryText.setMinimumWidth(textMinSize);
mSecondaryText.setMinimumHeight(textMinSize);
+ mSecondaryText.setIncludeFontPadding(false);
refreshDrawablePressedState();
}
@@ -595,10 +599,10 @@ class FastScroller {
margins.right = mPreviewImage.getPaddingRight();
margins.bottom = mPreviewImage.getPaddingBottom();
- if (mOverlayPosition == OVERLAY_AT_THUMB) {
- measureViewToSide(v, mThumbImage, margins, out);
- } else {
+ if (mOverlayPosition == OVERLAY_FLOATING) {
measureFloating(v, margins, out);
+ } else {
+ measureViewToSide(v, mThumbImage, margins, out);
}
}
@@ -1147,11 +1151,23 @@ class FastScroller {
final float thumbMiddle = position * range + offset;
thumbImage.setTranslationY(thumbMiddle - thumbImage.getHeight() / 2);
- final float previewPos = mOverlayPosition == OVERLAY_AT_THUMB ? thumbMiddle : 0;
-
- // Center the preview on the thumb, constrained to the list bounds.
final View previewImage = mPreviewImage;
final float previewHalfHeight = previewImage.getHeight() / 2f;
+ final float previewPos;
+ switch (mOverlayPosition) {
+ case OVERLAY_AT_THUMB:
+ previewPos = thumbMiddle;
+ break;
+ case OVERLAY_ABOVE_THUMB:
+ previewPos = thumbMiddle - previewHalfHeight;
+ break;
+ case OVERLAY_FLOATING:
+ default:
+ previewPos = 0;
+ break;
+ }
+
+ // Center the preview on the thumb, constrained to the list bounds.
final float minP = top + previewHalfHeight;
final float maxP = bottom - previewHalfHeight;
final float previewMiddle = MathUtils.constrain(previewPos, minP, maxP);
diff --git a/core/res/res/drawable/fastscroll_label_left_material.xml b/core/res/res/drawable/fastscroll_label_left_material.xml
new file mode 100644
index 0000000..430d1b0
--- /dev/null
+++ b/core/res/res/drawable/fastscroll_label_left_material.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 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.
+-->
+
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+ android:shape="rectangle">
+ <corners
+ android:topLeftRadius="44dp"
+ android:topRightRadius="44dp"
+ android:bottomRightRadius="44dp" />
+ <padding
+ android:paddingLeft="22dp"
+ android:paddingRight="22dp" />
+ <solid android:color="?attr/colorControlActivated" />
+</shape>
diff --git a/core/res/res/drawable/fastscroll_label_right_material.xml b/core/res/res/drawable/fastscroll_label_right_material.xml
new file mode 100644
index 0000000..6e61397
--- /dev/null
+++ b/core/res/res/drawable/fastscroll_label_right_material.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 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.
+-->
+
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+ android:shape="rectangle">
+ <corners
+ android:topLeftRadius="44dp"
+ android:topRightRadius="44dp"
+ android:bottomLeftRadius="44dp" />
+ <padding
+ android:paddingLeft="22dp"
+ android:paddingRight="22dp" />
+ <solid android:color="?attr/colorControlActivated" />
+</shape>
diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml
index 89bda82..f9ea5d8 100644
--- a/core/res/res/values/attrs.xml
+++ b/core/res/res/values/attrs.xml
@@ -733,6 +733,7 @@
<attr name="fastScrollOverlayPosition">
<enum name="floating" value="0" />
<enum name="atThumb" value="1" />
+ <enum name="aboveThumb" value="2" />
</attr>
<!-- Text color for the fast scroll index overlay. Make sure it
plays nicely with fastScrollPreviewBackground[Left|Right]. -->
@@ -3196,6 +3197,8 @@
<enum name="floating" value="0" />
<!-- Pinned alongside the thumb. -->
<enum name="atThumb" value="1" />
+ <!-- Pinned above the thumb. -->
+ <enum name="aboveThumb" value="2" />
</attr>
<attr name="textAppearance" />
<attr name="textColor" />
diff --git a/core/res/res/values/styles_material.xml b/core/res/res/values/styles_material.xml
index f028222..2e1b6c2 100644
--- a/core/res/res/values/styles_material.xml
+++ b/core/res/res/values/styles_material.xml
@@ -866,6 +866,10 @@ please see styles_device_defaults.xml.
<style name="Widget.Material.FastScroll" parent="Widget.FastScroll">
<item name="thumbMinWidth">0dp</item>
<item name="thumbMinHeight">0dp</item>
+ <item name="minWidth">88dp</item>
+ <item name="minHeight">88dp</item>
+ <item name="padding">0dp</item>
+ <item name="textSize">45sp</item>
</style>
<style name="Widget.Material.PreferenceFrameLayout">
diff --git a/core/res/res/values/themes_material.xml b/core/res/res/values/themes_material.xml
index 1376dfa..6a394c7 100644
--- a/core/res/res/values/themes_material.xml
+++ b/core/res/res/values/themes_material.xml
@@ -364,10 +364,10 @@ please see themes_device_defaults.xml.
<!-- TODO: This belongs in a FastScroll style -->
<item name="fastScrollThumbDrawable">@drawable/fastscroll_thumb_material</item>
- <item name="fastScrollPreviewBackgroundLeft">@drawable/fastscroll_label_left_holo_dark</item>
- <item name="fastScrollPreviewBackgroundRight">@drawable/fastscroll_label_right_holo_dark</item>
+ <item name="fastScrollPreviewBackgroundLeft">@drawable/fastscroll_label_left_material</item>
+ <item name="fastScrollPreviewBackgroundRight">@drawable/fastscroll_label_right_material</item>
<item name="fastScrollTrackDrawable">@drawable/fastscroll_track_material</item>
- <item name="fastScrollOverlayPosition">atThumb</item>
+ <item name="fastScrollOverlayPosition">aboveThumb</item>
<!-- Color palette -->
<item name="colorPrimaryDark">@color/material_blue_grey_900</item>
@@ -706,10 +706,10 @@ please see themes_device_defaults.xml.
<item name="datePickerDialogTheme">?attr/alertDialogTheme</item>
<item name="fastScrollThumbDrawable">@drawable/fastscroll_thumb_material</item>
- <item name="fastScrollPreviewBackgroundLeft">@drawable/fastscroll_label_left_holo_light</item>
- <item name="fastScrollPreviewBackgroundRight">@drawable/fastscroll_label_right_holo_light</item>
+ <item name="fastScrollPreviewBackgroundLeft">@drawable/fastscroll_label_left_material</item>
+ <item name="fastScrollPreviewBackgroundRight">@drawable/fastscroll_label_right_material</item>
<item name="fastScrollTrackDrawable">@drawable/fastscroll_track_material</item>
- <item name="fastScrollOverlayPosition">atThumb</item>
+ <item name="fastScrollOverlayPosition">aboveThumb</item>
<!-- Color palette -->
<item name="colorPrimaryDark">@color/material_blue_grey_100</item>