summaryrefslogtreecommitdiffstats
path: root/packages/SystemUI/src
diff options
context:
space:
mode:
authorJohn Spurlock <jspurlock@google.com>2014-05-21 21:28:16 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-05-21 21:28:16 +0000
commit35453dd751e5d7041b27045943d60ca0e1b51e20 (patch)
tree64cb670e2af9ff7084ba99004844a3d6ce478a4e /packages/SystemUI/src
parentc670c3b1ab6c7349f616be34bfffe17d5337848d (diff)
parent4bf31983d247a76142937c01bc2800b7f98d0281 (diff)
downloadframeworks_base-35453dd751e5d7041b27045943d60ca0e1b51e20.zip
frameworks_base-35453dd751e5d7041b27045943d60ca0e1b51e20.tar.gz
frameworks_base-35453dd751e5d7041b27045943d60ca0e1b51e20.tar.bz2
Merge "QuickSettings: fix text alignment."
Diffstat (limited to 'packages/SystemUI/src')
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/CircularClipper.java19
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/QSPanel.java22
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/QSTileView.java52
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/tiles/LocationTile.java4
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/tiles/RotationLockTile.java9
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java9
6 files changed, 83 insertions, 32 deletions
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 @@ public class CircularClipper {
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 @@ public class CircularClipper {
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 @@ public class CircularClipper {
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;
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 @@ import java.util.ArrayList;
/** 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 class QSPanel extends ViewGroup {
}
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 @@ public class QSPanel extends ViewGroup {
@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 @@ public class QSPanel extends ViewGroup {
@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.Resources;
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 @@ import com.android.systemui.qs.QSTile.State;
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 @@ public class QSTileView extends ViewGroup {
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 @@ public class QSTileView extends ViewGroup {
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 @@ public class QSTileView extends ViewGroup {
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 @@ public class QSTileView extends ViewGroup {
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 @@ public class QSTileView extends ViewGroup {
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 @@ public class LocationTile extends QSTile<QSTile.BooleanState> {
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 @@ public class RotationLockTile extends QSTile<QSTile.BooleanState> {
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 @@ public class RotationLockTile extends QSTile<QSTile.BooleanState> {
: 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 static com.android.systemui.statusbar.phone.BarTransitions.MODE_TRANSPARE
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.DemoMode;
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 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
// 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*/,