summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Amin Shaikh <ashaikh@google.com> 2018-02-27 16:52:53 -0500
committer Amin Shaikh <ashaikh@google.com> 2018-02-27 23:47:30 +0000
commitd620def5f409e2649d1926a4e589aa7ccf6e4a9f (patch)
treec6f3893cd6b3a609c2f744ceadb0a77a6137dcdc
parent8a771ee9f47bb6456a6410c6403a1d1ed345e7fe (diff)
Implement QS spec.
- Update padding between QS tiles - Add margins in the QS header for larger width devices - Update carrier text length in QS footer and fix animation overlap - Fix TouchAnimator to linearly interpolate more than 2 keyframe values Bug: 73312177 Test: visual Change-Id: I8da031437fc78ef1fb86797237711ac92a860616
-rw-r--r--packages/SystemUI/res/layout/qs_footer_impl.xml47
-rw-r--r--packages/SystemUI/res/layout/quick_status_bar_expanded_header.xml2
-rw-r--r--packages/SystemUI/res/values-sw372dp/dimens.xml1
-rw-r--r--packages/SystemUI/res/values/dimens.xml4
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/QSFooterImpl.java4
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/TileLayout.java16
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/TouchAnimator.java6
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/qs/TileLayoutTest.java2
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/qs/TouchAnimatorTest.java22
9 files changed, 61 insertions, 43 deletions
diff --git a/packages/SystemUI/res/layout/qs_footer_impl.xml b/packages/SystemUI/res/layout/qs_footer_impl.xml
index f635b180a68d..3c248452cece 100644
--- a/packages/SystemUI/res/layout/qs_footer_impl.xml
+++ b/packages/SystemUI/res/layout/qs_footer_impl.xml
@@ -43,40 +43,24 @@
android:layout_gravity="center_vertical"
android:gravity="end" >
- <LinearLayout
+ <com.android.keyguard.CarrierText
+ android:id="@+id/qs_carrier_text"
android:layout_width="0dp"
android:layout_height="match_parent"
- android:layout_weight="1" >
- <!-- Add an extra 8dp margin before carrier text without shifting it right -->
- <android.widget.Space
- android:layout_width="8dp"
- android:layout_height="match_parent" />
-
- <com.android.keyguard.CarrierText
- android:id="@+id/qs_carrier_text"
- android:layout_width="0dp"
- android:layout_height="match_parent"
- android:layout_weight="1"
- android:gravity="center_vertical|start"
- android:ellipsize="marquee"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:textColor="?android:attr/textColorPrimary"
- android:textDirection="locale"
- android:singleLine="true" />
- </LinearLayout>
-
- <View
- android:id="@+id/qs_drag_handle_view"
- android:layout_width="24dp"
- android:layout_height="4dp"
- android:layout_gravity="center"
- android:background="@drawable/qs_footer_drag_handle" />
+ android:layout_weight="1"
+ android:layout_marginStart="8dp"
+ android:layout_marginEnd="32dp"
+ android:gravity="center_vertical|start"
+ android:ellipsize="marquee"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:textColor="?android:attr/textColorPrimary"
+ android:textDirection="locale"
+ android:singleLine="true" />
<com.android.keyguard.AlphaOptimizedLinearLayout
android:id="@+id/qs_footer_actions_container"
- android:layout_width="0dp"
+ android:layout_width="wrap_content"
android:layout_height="match_parent"
- android:layout_weight="1"
android:gravity="center_vertical|end" >
<com.android.systemui.statusbar.phone.MultiUserSwitch
android:id="@+id/multi_user_switch"
@@ -139,4 +123,11 @@
</com.android.keyguard.AlphaOptimizedLinearLayout>
</LinearLayout>
+ <View
+ android:id="@+id/qs_drag_handle_view"
+ android:layout_width="24dp"
+ android:layout_height="4dp"
+ android:layout_gravity="center"
+ android:background="@drawable/qs_footer_drag_handle" />
+
</com.android.systemui.qs.QSFooterImpl>
diff --git a/packages/SystemUI/res/layout/quick_status_bar_expanded_header.xml b/packages/SystemUI/res/layout/quick_status_bar_expanded_header.xml
index 959247ee76e7..ca8fcba017b1 100644
--- a/packages/SystemUI/res/layout/quick_status_bar_expanded_header.xml
+++ b/packages/SystemUI/res/layout/quick_status_bar_expanded_header.xml
@@ -44,6 +44,8 @@
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_below="@id/quick_qs_status_icons"
+ android:layout_marginStart="@dimen/qs_header_tile_margin_horizontal"
+ android:layout_marginEnd="@dimen/qs_header_tile_margin_horizontal"
android:accessibilityTraversalAfter="@+id/date_time_group"
android:accessibilityTraversalBefore="@id/expand_indicator"
android:clipChildren="false"
diff --git a/packages/SystemUI/res/values-sw372dp/dimens.xml b/packages/SystemUI/res/values-sw372dp/dimens.xml
index 635185d7f2ad..3a7442a6ecd6 100644
--- a/packages/SystemUI/res/values-sw372dp/dimens.xml
+++ b/packages/SystemUI/res/values-sw372dp/dimens.xml
@@ -18,4 +18,5 @@
<resources>
<dimen name="nav_content_padding">8dp</dimen>
<dimen name="rounded_corner_content_padding">8dp</dimen>
+ <dimen name="qs_header_tile_margin_horizontal">5dp</dimen>
</resources>
diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml
index dc230d497fc2..ca4ea9e1578c 100644
--- a/packages/SystemUI/res/values/dimens.xml
+++ b/packages/SystemUI/res/values/dimens.xml
@@ -301,11 +301,13 @@
<dimen name="pull_span_min">25dp</dimen>
<dimen name="qs_tile_height">106dp</dimen>
- <dimen name="qs_tile_margin">19dp</dimen>
+ <dimen name="qs_tile_margin_horizontal">18dp</dimen>
+ <dimen name="qs_tile_margin_vertical">24dp</dimen>
<dimen name="qs_tile_margin_top">18dp</dimen>
<dimen name="qs_quick_tile_size">48dp</dimen>
<dimen name="qs_quick_tile_padding">12dp</dimen>
<dimen name="qs_header_gear_translation">16dp</dimen>
+ <dimen name="qs_header_tile_margin_horizontal">0dp</dimen>
<dimen name="qs_page_indicator_width">16dp</dimen>
<dimen name="qs_page_indicator_height">8dp</dimen>
<dimen name="qs_tile_icon_size">24dp</dimen>
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSFooterImpl.java b/packages/SystemUI/src/com/android/systemui/qs/QSFooterImpl.java
index 993df7596249..7b48e021b715 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSFooterImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSFooterImpl.java
@@ -169,10 +169,10 @@ public class QSFooterImpl extends FrameLayout implements QSFooter,
private TouchAnimator createFooterAnimator() {
return new TouchAnimator.Builder()
.addFloat(mDivider, "alpha", 0, 1)
- .addFloat(mCarrierText, "alpha", 0, 1)
+ .addFloat(mCarrierText, "alpha", 0, 0, 1)
.addFloat(mActionsContainer, "alpha", 0, 1)
.addFloat(mDragHandle, "translationY", mDragHandleExpandOffset, 0)
- .addFloat(mDragHandle, "alpha", 1, 0)
+ .addFloat(mDragHandle, "alpha", 1, 0, 0)
.setStartDelay(0.15f)
.build();
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/TileLayout.java b/packages/SystemUI/src/com/android/systemui/qs/TileLayout.java
index 23faa559793e..66823ca135cb 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/TileLayout.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/TileLayout.java
@@ -21,7 +21,8 @@ public class TileLayout extends ViewGroup implements QSTileLayout {
protected int mColumns;
protected int mCellWidth;
protected int mCellHeight;
- protected int mCellMargin;
+ protected int mCellMarginHorizontal;
+ protected int mCellMarginVertical;
protected final ArrayList<TileRecord> mRecords = new ArrayList<>();
private int mCellMarginTop;
@@ -76,7 +77,8 @@ public class TileLayout extends ViewGroup implements QSTileLayout {
final Resources res = mContext.getResources();
final int columns = Math.max(1, res.getInteger(R.integer.quick_settings_num_columns));
mCellHeight = mContext.getResources().getDimensionPixelSize(R.dimen.qs_tile_height);
- mCellMargin = res.getDimensionPixelSize(R.dimen.qs_tile_margin);
+ mCellMarginHorizontal = res.getDimensionPixelSize(R.dimen.qs_tile_margin_horizontal);
+ mCellMarginVertical= res.getDimensionPixelSize(R.dimen.qs_tile_margin_vertical);
mCellMarginTop = res.getDimensionPixelSize(R.dimen.qs_tile_margin_top);
if (mColumns != columns) {
mColumns = columns;
@@ -91,7 +93,7 @@ public class TileLayout extends ViewGroup implements QSTileLayout {
final int numTiles = mRecords.size();
final int width = MeasureSpec.getSize(widthMeasureSpec);
final int rows = (numTiles + mColumns - 1) / mColumns;
- mCellWidth = (width - (mCellMargin * (mColumns + 1))) / mColumns;
+ mCellWidth = (width - (mCellMarginHorizontal * (mColumns + 1))) / mColumns;
View previousView = this;
for (TileRecord record : mRecords) {
@@ -102,8 +104,8 @@ public class TileLayout extends ViewGroup implements QSTileLayout {
// Only include the top margin in our measurement if we have more than 1 row to show.
// Otherwise, don't add the extra margin buffer at top.
- int height = (mCellHeight + mCellMargin) * rows +
- (rows != 0 ? (mCellMarginTop - mCellMargin) : 0);
+ int height = (mCellHeight + mCellMarginVertical) * rows +
+ (rows != 0 ? (mCellMarginTop - mCellMarginVertical) : 0);
if (height < 0) height = 0;
setMeasuredDimension(width, height);
}
@@ -143,10 +145,10 @@ public class TileLayout extends ViewGroup implements QSTileLayout {
}
private int getRowTop(int row) {
- return row * (mCellHeight + mCellMargin) + mCellMarginTop;
+ return row * (mCellHeight + mCellMarginVertical) + mCellMarginTop;
}
private int getColumnStart(int column) {
- return column * (mCellWidth + mCellMargin) + mCellMargin;
+ return column * (mCellWidth + mCellMarginHorizontal) + mCellMarginHorizontal;
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/TouchAnimator.java b/packages/SystemUI/src/com/android/systemui/qs/TouchAnimator.java
index 6263efa2c711..f673364c7e17 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/TouchAnimator.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/TouchAnimator.java
@@ -200,7 +200,6 @@ public class TouchAnimator {
}
private static abstract class KeyframeSet {
-
private final float mFrameWidth;
private final int mSize;
@@ -210,9 +209,8 @@ public class TouchAnimator {
}
void setValue(float fraction, Object target) {
- int i;
- for (i = 1; i < mSize - 1 && fraction > mFrameWidth; i++);
- float amount = fraction / mFrameWidth;
+ int i = MathUtils.constrain((int) Math.ceil(fraction / mFrameWidth), 1, mSize - 1);
+ float amount = (fraction - mFrameWidth * (i - 1)) / mFrameWidth;
interpolate(i, amount, target);
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/TileLayoutTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/TileLayoutTest.java
index 11491a75c655..2040e7578910 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/TileLayoutTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/TileLayoutTest.java
@@ -54,7 +54,7 @@ public class TileLayoutTest extends SysuiTestCase {
// Layout needs to leave space for the tile margins. Three times the margin size is
// sufficient for any number of columns.
mLayoutSizeForOneTile =
- mContext.getResources().getDimensionPixelSize(R.dimen.qs_tile_margin) * 3;
+ mContext.getResources().getDimensionPixelSize(R.dimen.qs_tile_margin_horizontal) * 3;
}
private QSPanel.TileRecord createTileRecord() {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/TouchAnimatorTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/TouchAnimatorTest.java
index 641cdc761765..4cc0e20dd964 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/TouchAnimatorTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/TouchAnimatorTest.java
@@ -56,6 +56,28 @@ public class TouchAnimatorTest extends SysuiTestCase {
}
@Test
+ public void testSetValueFloat_threeValues() {
+ TouchAnimator animator = new TouchAnimator.Builder()
+ .addFloat(mTestView, "x", 0, 20, 50)
+ .build();
+
+ animator.setPosition(0);
+ assertEquals(0f, mTestView.getX());
+
+ animator.setPosition(.25f);
+ assertEquals(10f, mTestView.getX());
+
+ animator.setPosition(.5f);
+ assertEquals(20f, mTestView.getX());
+
+ animator.setPosition(.75f);
+ assertEquals(35f, mTestView.getX());
+
+ animator.setPosition(1);
+ assertEquals(50f, mTestView.getX());
+ }
+
+ @Test
public void testSetValueInt() {
TouchAnimator animator = new TouchAnimator.Builder()
.addInt(mTestView, "top", 0, 50)