Merge "Update scrollbars to match Material spec" into lmp-mr1-dev

This commit is contained in:
Alan Viverette
2014-11-21 02:12:09 +00:00
committed by Android (Google) Code Review
21 changed files with 48 additions and 13 deletions

View File

@@ -106,6 +106,9 @@ class FastScroller {
*/
private final int[] mPreviewResId = new int[2];
/** The minimum touch target size in pixels. */
private final int mMinimumTouchTarget;
/**
* Padding in pixels around the preview text. Applied as layout margins to
* the preview text and padding to the preview image.
@@ -254,6 +257,9 @@ class FastScroller {
mPrimaryText = createPreviewTextView(context);
mSecondaryText = createPreviewTextView(context);
mMinimumTouchTarget = listView.getResources().getDimensionPixelSize(
com.android.internal.R.dimen.fast_scroller_minimum_touch_target);
setStyle(styleResId);
final ViewGroupOverlay overlay = listView.getOverlay();
@@ -1474,10 +1480,18 @@ class FastScroller {
}
private boolean isPointInsideX(float x) {
final float offset = mThumbImage.getTranslationX();
final float left = mThumbImage.getLeft() + offset;
final float right = mThumbImage.getRight() + offset;
// Apply the minimum touch target size.
final float targetSizeDiff = mMinimumTouchTarget - (right - left);
final float adjust = targetSizeDiff > 0 ? targetSizeDiff : 0;
if (mLayoutFromRight) {
return x >= mThumbImage.getLeft();
return x >= mThumbImage.getLeft() - adjust;
} else {
return x <= mThumbImage.getRight();
return x <= mThumbImage.getRight() + adjust;
}
}
@@ -1485,7 +1499,12 @@ class FastScroller {
final float offset = mThumbImage.getTranslationY();
final float top = mThumbImage.getTop() + offset;
final float bottom = mThumbImage.getBottom() + offset;
return y >= top && y <= bottom;
// Apply the minimum touch target size.
final float targetSizeDiff = mMinimumTouchTarget - (bottom - top);
final float adjust = targetSizeDiff > 0 ? targetSizeDiff / 2 : 0;
return y >= (top - adjust) && y <= (bottom + adjust);
}
/**

Binary file not shown.

Before

Width:  |  Height:  |  Size: 167 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 84 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 114 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 123 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 82 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 108 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 129 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 87 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 120 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 220 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 89 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 128 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 279 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 148 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 181 B

View File

@@ -16,11 +16,17 @@
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<bitmap android:src="@drawable/fastscroll_thumb_mtrl_alpha"
android:tint="?attr/colorControlActivated" />
<shape android:tint="?attr/colorControlActivated"
android:shape="rectangle">
<solid android:color="@color/white" />
<size android:width="8dp" android:height="48dp" />
</shape>
</item>
<item>
<bitmap android:src="@drawable/fastscroll_thumb_mtrl_alpha"
android:tint="?attr/colorControlNormal" />
<shape android:tint="?attr/colorControlNormal"
android:shape="rectangle">
<solid android:color="@color/white" />
<size android:width="8dp" android:height="48dp" />
</shape>
</item>
</selector>

View File

@@ -14,6 +14,9 @@
limitations under the License.
-->
<nine-patch xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/fastscroll_track_mtrl_alpha"
android:tint="?attr/colorControlNormal" />
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:tint="?attr/colorControlNormal"
android:shape="rectangle">
<solid android:color="#21ffffff" />
<size android:width="8dp" />
</shape>

View File

@@ -14,6 +14,9 @@
limitations under the License.
-->
<nine-patch xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/scrollbar_handle_mtrl_alpha"
android:tint="?attr/colorControlNormal" />
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:tint="?attr/colorControlNormal"
android:shape="rectangle">
<solid android:color="#42ffffff" />
<size android:width="4dp" />
</shape>

View File

@@ -397,6 +397,9 @@
<dimen name="datepicker_header_height">30dp</dimen>
<dimen name="datepicker_header_text_size">14dp</dimen>
<!-- Minimum size of the fast scroller thumb's touch target. -->
<dimen name="fast_scroller_minimum_touch_target">48dp</dimen>
<!-- width of ImmersiveModeConfirmation (-1 for match_parent) -->
<dimen name="immersive_mode_cling_width">-1px</dimen>

View File

@@ -2126,5 +2126,6 @@
<java-symbol type="string" name="android_system_label" />
<java-symbol type="string" name="system_error_wipe_data" />
<java-symbol type="string" name="system_error_manufacturer" />
<java-symbol type="dimen" name="fast_scroller_minimum_touch_target" />
</resources>