Merge "QuickSettings: fix text alignment."
diff --git a/packages/SystemUI/res/layout/qs_zen_mode_detail.xml b/packages/SystemUI/res/layout/qs_zen_mode_detail.xml
index b73874a..85b294d 100644
--- a/packages/SystemUI/res/layout/qs_zen_mode_detail.xml
+++ b/packages/SystemUI/res/layout/qs_zen_mode_detail.xml
@@ -25,7 +25,7 @@
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_alignParentStart="true"
- android:padding="@dimen/quick_settings_panel_padding" />
+ android:padding="@dimen/qs_panel_padding" />
<Switch
android:id="@android:id/checkbox"
@@ -33,7 +33,7 @@
android:layout_height="64dp"
android:layout_alignParentEnd="true"
android:gravity="center"
- android:padding="@dimen/quick_settings_panel_padding" />
+ android:padding="@dimen/qs_panel_padding" />
<TextView
android:id="@android:id/title"
@@ -43,7 +43,7 @@
android:layout_toStartOf="@android:id/checkbox"
android:textAppearance="@style/TextAppearance.StatusBar.Expanded.Clock"
android:gravity="center_vertical"
- android:paddingStart="@dimen/quick_settings_panel_padding"
+ android:paddingStart="@dimen/qs_panel_padding"
android:text="@string/zen_mode_title" />
<View
@@ -70,7 +70,7 @@
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:textAppearance="@style/TextAppearance.StatusBar.Expanded.Clock"
- android:padding="@dimen/quick_settings_panel_padding"
+ android:padding="@dimen/qs_panel_padding"
android:text="@string/quick_settings_more_settings"
android:textAllCaps="true" />
diff --git a/packages/SystemUI/res/layout/qs_zen_mode_detail_condition.xml b/packages/SystemUI/res/layout/qs_zen_mode_detail_condition.xml
index 7e02bee..59b1caf 100644
--- a/packages/SystemUI/res/layout/qs_zen_mode_detail_condition.xml
+++ b/packages/SystemUI/res/layout/qs_zen_mode_detail_condition.xml
@@ -23,7 +23,7 @@
android:layout_width="32dp"
android:layout_height="64dp"
android:layout_alignParentStart="true"
- android:layout_marginStart="@dimen/quick_settings_panel_padding"
+ android:layout_marginStart="@dimen/qs_panel_padding"
android:gravity="center" />
<TextView
@@ -45,7 +45,7 @@
android:layout_height="64dp"
android:layout_alignParentEnd="true"
android:layout_marginEnd="48dp"
- android:padding="@dimen/quick_settings_panel_padding"
+ android:padding="@dimen/qs_panel_padding"
android:paddingRight="0px" />
<ImageView
@@ -54,6 +54,6 @@
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_alignParentEnd="true"
- android:padding="@dimen/quick_settings_panel_padding" />
+ android:padding="@dimen/qs_panel_padding" />
</RelativeLayout>
\ No newline at end of file
diff --git a/packages/SystemUI/res/values-land/dimens.xml b/packages/SystemUI/res/values-land/dimens.xml
index 76e7784..39ce0a2 100644
--- a/packages/SystemUI/res/values-land/dimens.xml
+++ b/packages/SystemUI/res/values-land/dimens.xml
@@ -38,9 +38,6 @@
<dimen name="status_bar_recents_app_icon_left_margin">8dp</dimen>
<dimen name="status_bar_recents_app_icon_top_margin">8dp</dimen>
- <!-- The fixed height of each tile -->
- <dimen name="quick_settings_cell_height">100dp</dimen>
-
<!-- Width of the zen mode interstitial dialog. -->
<dimen name="zen_mode_dialog_width">384dp</dimen>
</resources>
diff --git a/packages/SystemUI/res/values-sw380dp/dimens.xml b/packages/SystemUI/res/values-sw380dp/dimens.xml
deleted file mode 100644
index b39e94c..0000000
--- a/packages/SystemUI/res/values-sw380dp/dimens.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- * Copyright (c) 2012, 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.
-*/
--->
-<resources>
- <!-- The fixed height of each tile -->
- <dimen name="quick_settings_cell_height">124dp</dimen>
-</resources>
diff --git a/packages/SystemUI/res/values/colors.xml b/packages/SystemUI/res/values/colors.xml
index 77b4843..e5ed3d6 100644
--- a/packages/SystemUI/res/values/colors.xml
+++ b/packages/SystemUI/res/values/colors.xml
@@ -41,18 +41,12 @@
<color name="system_secondary_color">#ff384248</color>
<color name="system_accent_color">#ff7fcac3</color>
<color name="system_error_color">#fff0592b</color>
- <color name="quick_settings_tile_divider">#ff888888</color>
- <color name="quick_settings_tile_text">#FFFFFFFF</color>
+ <color name="qs_tile_divider">#29ffffff</color><!-- 16% white -->
+ <color name="qs_tile_text">#FFFFFFFF</color>
<color name="status_bar_clock_color">#FFFFFFFF</color>
<drawable name="notification_item_background_color">#ff111111</drawable>
<drawable name="notification_item_background_color_pressed">#ff454545</drawable>
- <!-- Tint color for inactive Quick Settings icons. -->
- <color name="ic_qs_off">#ff404040</color>
-
- <!-- Tint color for active Quick Settings icons. -->
- <color name="ic_qs_on">#ffffffff</color>
-
<!-- Tint color for the content on the notification overflow card. -->
<color name="keyguard_overflow_content_color">#ff666666</color>
diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml
index 29955dd..44b9d38 100644
--- a/packages/SystemUI/res/values/dimens.xml
+++ b/packages/SystemUI/res/values/dimens.xml
@@ -174,12 +174,6 @@
<!-- The distance you can pull a notification before it pops open -->
<dimen name="one_finger_pop_limit">0dp</dimen>
- <!-- The fixed height of each tile -->
- <dimen name="quick_settings_cell_height">110dp</dimen>
-
- <!-- The padding between each tile within the QuickSettings layout -->
- <dimen name="quick_settings_cell_gap">4dp</dimen>
-
<!-- Minimum fraction of the screen that should be taken up by the notification panel.
Not used at this screen size. -->
<item type="dimen" name="notification_panel_min_height_frac">0%</item>
@@ -193,14 +187,14 @@
<!-- For phones, this is close_handle_height + header_height -->
<dimen name="peek_height">84dp</dimen>
- <!-- Quick Settings tile geometry: top interior margin, above icon -->
- <dimen name="qs_tile_margin_above_icon">27dp</dimen>
- <!-- Quick Settings tile geometry: gap between icon and text -->
- <dimen name="qs_tile_margin_below_icon">17dp</dimen>
- <!-- Quick Settings tile geometry: icon size -->
- <dimen name="qs_tile_icon_size">32dp</dimen>
- <!-- Quick Settings CA Cert Warning tile geometry: gap between icon and text -->
- <dimen name="qs_cawarn_tile_margin_below_icon">3dp</dimen>
+ <dimen name="qs_tile_height">84dp</dimen>
+ <dimen name="qs_tile_padding">8dp</dimen>
+ <dimen name="qs_tile_icon_size">28dp</dimen>
+ <dimen name="qs_tile_text_size">12sp</dimen>
+ <dimen name="qs_tile_divider_height">1dp</dimen>
+ <dimen name="qs_panel_padding">16dp</dimen>
+ <dimen name="qs_dual_tile_height">109dp</dimen>
+ <dimen name="qs_dual_tile_padding">12dp</dimen>
<!-- used by DessertCase -->
<dimen name="dessert_case_cell_size">192dp</dimen>
@@ -281,12 +275,6 @@
<!-- Lockscreen affordance drag distance for camera and phone. -->
<dimen name="affordance_drag_distance">100dp</dimen>
- <dimen name="quick_settings_tmp_scrim_stroke_width">8dp</dimen>
- <dimen name="quick_settings_tmp_scrim_text_size">30dp</dimen>
- <dimen name="quick_settings_panel_padding">16dp</dimen>
- <dimen name="quick_settings_tile_text_size">12sp</dimen>
- <dimen name="quick_settings_tile_divider_height">1dp</dimen>
-
<dimen name="notifications_top_padding">8dp</dimen>
<!-- Minimum distance the user has to drag down to go to the full shade. -->
diff --git a/packages/SystemUI/src/com/android/systemui/qs/CircularClipper.java b/packages/SystemUI/src/com/android/systemui/qs/CircularClipper.java
index 16ee3b0..ff904b3 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/CircularClipper.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/CircularClipper.java
@@ -27,12 +27,17 @@
private final View mTarget;
+ private Utils mUtils;
private ValueAnimator mAnimator;
public CircularClipper(View target) {
mTarget = target;
}
+ public void setUtils(Utils utils) {
+ mUtils = utils;
+ }
+
public void animateCircularClip(int x, int y, boolean in, AnimatorListener listener) {
if (mAnimator != null) {
mAnimator.cancel();
@@ -44,7 +49,14 @@
r = (int) Math.max(r, Math.ceil(Math.sqrt(w * w + h * h)));
r = (int) Math.max(r, Math.ceil(Math.sqrt(x * x + h * h)));
- mAnimator = mTarget.createRevealAnimator(x, y, 0, r);
+ if (mUtils == null) {
+ mTarget.setVisibility(in ? View.VISIBLE : View.GONE);
+ if (listener != null) {
+ listener.onAnimationEnd(null);
+ }
+ return;
+ }
+ mAnimator = mUtils.createRevealAnimator(mTarget, x, y, 0, r);
mAnimator.removeAllListeners();
if (listener != null) {
mAnimator.addListener(listener);
@@ -71,4 +83,9 @@
mTarget.setVisibility(View.GONE);
};
};
+
+ public interface Utils {
+ ValueAnimator createRevealAnimator(View v, int centerX, int centerY,
+ float startRadius, float endRadius);
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java b/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java
index 6176eb6..bdac7a0 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java
@@ -20,6 +20,7 @@
import android.animation.Animator.AnimatorListener;
import android.animation.AnimatorListenerAdapter;
import android.content.Context;
+import android.content.res.Resources;
import android.os.Handler;
import android.os.Message;
import android.util.AttributeSet;
@@ -33,8 +34,7 @@
/** View that represents the quick settings tile panel. **/
public class QSPanel extends ViewGroup {
- private static final float TILE_ASPECT = 1.4f;
- private static final float LARGE_TILE_FACTOR = 1.1f;
+ private static final float TILE_ASPECT = 1.2f;
private final Context mContext;
private final ArrayList<TileRecord> mRecords = new ArrayList<TileRecord>();
@@ -67,14 +67,22 @@
}
public void updateResources() {
- final int columns = Math.max(1,
- mContext.getResources().getInteger(R.integer.quick_settings_num_columns));
+ final Resources res = mContext.getResources();
+ final int columns = Math.max(1, res.getInteger(R.integer.quick_settings_num_columns));
+ mCellHeight = res.getDimensionPixelSize(R.dimen.qs_tile_height);
+ mCellWidth = (int)(mCellHeight * TILE_ASPECT);
+ mLargeCellHeight = res.getDimensionPixelSize(R.dimen.qs_dual_tile_height);
+ mLargeCellWidth = (int)(mLargeCellHeight * TILE_ASPECT);
if (mColumns != columns) {
mColumns = columns;
postInvalidate();
}
}
+ public void setUtils(CircularClipper.Utils utils) {
+ mClipper.setUtils(utils);
+ }
+
public void setExpanded(boolean expanded) {
if (!expanded) {
showDetail(false /*show*/, mDetailRecord);
@@ -156,10 +164,6 @@
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
final int width = MeasureSpec.getSize(widthMeasureSpec);
- mCellWidth = width / mColumns;
- mCellHeight = (int)(mCellWidth / TILE_ASPECT);
- mLargeCellWidth = (int)(mCellWidth * LARGE_TILE_FACTOR);
- mLargeCellHeight = (int)(mCellHeight * LARGE_TILE_FACTOR);
int r = -1;
int c = -1;
int rows = 0;
@@ -198,7 +202,7 @@
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
- final int w = mCellWidth * mColumns;
+ final int w = getWidth();
for (TileRecord record : mRecords) {
if (record.tileView.getVisibility() == GONE) continue;
final int cols = getColumnCount(record.row);
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSTileView.java b/packages/SystemUI/src/com/android/systemui/qs/QSTileView.java
index 4cfb636..5eecc20 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSTileView.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSTileView.java
@@ -21,6 +21,7 @@
import android.content.res.TypedArray;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
+import android.graphics.drawable.RippleDrawable;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
@@ -40,23 +41,26 @@
public class QSTileView extends ViewGroup {
private static final Typeface CONDENSED = Typeface.create("sans-serif-condensed",
Typeface.NORMAL);
- private static final int VERTICAL_PADDING_FACTOR = 8; // internal padding 1/8 the cell height
protected final Context mContext;
private final View mIcon;
private final View mDivider;
private final H mHandler = new H();
+ private final int mIconSizePx;
+ private int mTilePaddingPx;
private TextView mLabel;
private boolean mDual;
private OnClickListener mClickPrimary;
private OnClickListener mClickSecondary;
+ private RippleDrawable mRipple;
public QSTileView(Context context) {
super(context);
mContext = context;
final Resources res = context.getResources();
+ mIconSizePx = res.getDimensionPixelSize(R.dimen.qs_tile_icon_size);
recreateLabel();
setClipChildren(false);
@@ -64,13 +68,13 @@
addView(mIcon);
mDivider = new View(mContext);
- mDivider.setBackgroundColor(res.getColor(R.color.quick_settings_tile_divider));
- final int dh = res.getDimensionPixelSize(R.dimen.quick_settings_tile_divider_height);
+ mDivider.setBackgroundColor(res.getColor(R.color.qs_tile_divider));
+ final int dh = res.getDimensionPixelSize(R.dimen.qs_tile_divider_height);
mDivider.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, dh));
addView(mDivider);
setClickable(true);
- setBackground(getSelectableBackground());
+ setBackground(getTileBackground());
}
private void recreateLabel() {
@@ -83,11 +87,16 @@
mLabel = new TextView(mDual ? new ContextThemeWrapper(mContext, R.style.QSBorderless_Tiny)
: mContext);
mLabel.setId(android.R.id.title);
- mLabel.setTextColor(res.getColor(R.color.quick_settings_tile_text));
- mLabel.setGravity(Gravity.CENTER);
+ mLabel.setTextColor(res.getColor(R.color.qs_tile_text));
+ mLabel.setGravity(Gravity.CENTER_HORIZONTAL);
+ mLabel.setMinLines(2);
+ mTilePaddingPx = res.getDimensionPixelSize(
+ mDual ? R.dimen.qs_dual_tile_padding : R.dimen.qs_tile_padding);
+ final int bottomPadding = mDual ? 0 : mTilePaddingPx;
+ mLabel.setPadding(mTilePaddingPx, mTilePaddingPx, mTilePaddingPx, bottomPadding);
mLabel.setTypeface(CONDENSED);
mLabel.setTextSize(TypedValue.COMPLEX_UNIT_PX,
- res.getDimensionPixelSize(R.dimen.quick_settings_tile_text_size));
+ res.getDimensionPixelSize(R.dimen.qs_tile_text_size));
if (labelText != null) {
mLabel.setText(labelText);
}
@@ -124,11 +133,14 @@
return icon;
}
- private Drawable getSelectableBackground() {
+ private Drawable getTileBackground() {
final int[] attrs = new int[] { android.R.attr.selectableItemBackground};
final TypedArray ta = mContext.obtainStyledAttributes(attrs);
final Drawable d = ta.getDrawable(0);
ta.recycle();
+ if (d instanceof RippleDrawable) {
+ mRipple = (RippleDrawable) d;
+ }
return d;
}
@@ -136,14 +148,11 @@
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
final int w = MeasureSpec.getSize(widthMeasureSpec);
final int h = MeasureSpec.getSize(heightMeasureSpec);
- final int p = h / VERTICAL_PADDING_FACTOR;
- final int iconSpec = exactly((int)mLabel.getTextSize() * 2);
+ final int iconSpec = exactly(mIconSizePx);
mIcon.measure(iconSpec, iconSpec);
mLabel.measure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(h, MeasureSpec.AT_MOST));
if (mDual) {
mDivider.measure(widthMeasureSpec, exactly(mDivider.getLayoutParams().height));
- } else {
- mLabel.measure(widthMeasureSpec, exactly(mLabel.getMeasuredHeight() + p * 2));
}
setMeasuredDimension(w, h);
}
@@ -156,16 +165,25 @@
protected void onLayout(boolean changed, int l, int t, int r, int b) {
final int w = getMeasuredWidth();
final int h = getMeasuredHeight();
- final int p = h / VERTICAL_PADDING_FACTOR;
- final int contentHeight = p + mIcon.getMeasuredHeight() + mLabel.getMeasuredHeight()
- + (mDual ? (p + mDivider.getMeasuredHeight()) : 0);
- int top = (h - contentHeight) / 2 + p;
+ final int contentHeight = mTilePaddingPx + mIcon.getMeasuredHeight()
+ + mLabel.getMeasuredHeight()
+ + (mDual ? (mTilePaddingPx + mDivider.getMeasuredHeight()) : 0);
+
+ int top = Math.max(0, (h - contentHeight) / 2);
+ top += mTilePaddingPx;
final int iconLeft = (w - mIcon.getMeasuredWidth()) / 2;
layout(mIcon, iconLeft, top);
+ if (mRipple != null) {
+ // center the touch feedback on the center of the icon, and dial it down a bit
+ final int cx = w / 2;
+ final int cy = mIcon.getTop() + mIcon.getHeight() / 2;
+ final int rad = (int)(mIcon.getHeight() * 1.5);
+ mRipple.setHotspotBounds(cx - rad, cy - rad, cx + rad, cy + rad);
+ }
top = mIcon.getBottom();
if (mDual) {
- top += p;
+ top += mTilePaddingPx;
layout(mDivider, 0, top);
top = mDivider.getBottom();
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/LocationTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/LocationTile.java
index c5ad9e6..e496468 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/LocationTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/LocationTile.java
@@ -16,6 +16,7 @@
package com.android.systemui.qs.tiles;
+import android.content.res.Resources;
import android.graphics.drawable.AnimationDrawable;
import com.android.systemui.R;
@@ -64,7 +65,8 @@
state.visible = true;
if (state.value != locationEnabled) {
state.value = locationEnabled;
- final AnimationDrawable d = (AnimationDrawable) mContext.getDrawable(locationEnabled
+ final Resources res = mContext.getResources();
+ final AnimationDrawable d = (AnimationDrawable) res.getDrawable(locationEnabled
? R.drawable.ic_qs_location_on
: R.drawable.ic_qs_location_off);
state.icon = d;
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/RotationLockTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/RotationLockTile.java
index 1b0967b..3be97cc 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/RotationLockTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/RotationLockTile.java
@@ -17,8 +17,8 @@
package com.android.systemui.qs.tiles;
import android.content.res.Configuration;
+import android.content.res.Resources;
import android.graphics.drawable.AnimationDrawable;
-import android.graphics.drawable.Drawable;
import com.android.systemui.R;
import com.android.systemui.qs.QSTile;
@@ -60,9 +60,10 @@
if (mController == null) return;
final boolean rotationLocked = mController.isRotationLocked();
state.visible = mController.isRotationLockAffordanceVisible();
+ final Resources res = mContext.getResources();
if (state.value != rotationLocked) {
state.value = rotationLocked;
- final AnimationDrawable d = (AnimationDrawable) mContext.getDrawable(rotationLocked
+ final AnimationDrawable d = (AnimationDrawable) res.getDrawable(rotationLocked
? R.drawable.ic_qs_rotation_locked
: R.drawable.ic_qs_rotation_unlocked);
state.icon = d;
@@ -82,12 +83,12 @@
: R.string.quick_settings_rotation_locked_label;
state.label = mContext.getString(label);
if (state.icon == null) {
- state.icon = mContext.getDrawable(R.drawable.ic_qs_rotation_15);
+ state.icon = res.getDrawable(R.drawable.ic_qs_rotation_15);
}
} else {
state.label = mContext.getString(R.string.quick_settings_rotation_unlocked_label);
if (state.icon == null) {
- state.icon = mContext.getDrawable(R.drawable.ic_qs_rotation_01);
+ state.icon = res.getDrawable(R.drawable.ic_qs_rotation_01);
}
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
index 1072e49..54af2c5 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -31,6 +31,7 @@
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.TimeInterpolator;
+import android.animation.ValueAnimator;
import android.app.ActivityManager;
import android.app.ActivityManagerNative;
import android.app.Notification;
@@ -94,6 +95,7 @@
import com.android.systemui.EventLogTags;
import com.android.systemui.R;
import com.android.systemui.keyguard.KeyguardViewMediator;
+import com.android.systemui.qs.CircularClipper;
import com.android.systemui.qs.QSPanel;
import com.android.systemui.qs.QSTile;
import com.android.systemui.statusbar.BaseStatusBar;
@@ -730,6 +732,13 @@
// Set up the quick settings tile panel
mQSPanel = (QSPanel) mStatusBarWindow.findViewById(R.id.quick_settings_panel);
if (mQSPanel != null) {
+ mQSPanel.setUtils(new CircularClipper.Utils() {
+ @Override
+ public ValueAnimator createRevealAnimator(View v, int centerX, int centerY,
+ float startRadius, float endRadius) {
+ return v.createRevealAnimator(centerX, centerY, startRadius, endRadius);
+ }
+ });
final QSTileHost qsh = new QSTileHost(mContext, this,
mBluetoothController, mLocationController, mRotationLockController,
mNetworkController, mZenModeController, null /*tethering*/,