Various QS fixes and cleanup

Test: runtest systemui
Change-Id: If87f58f2af00b23c5e1a8e38a63a6a63d903002c
This commit is contained in:
Jason Monk
2017-02-15 15:49:32 -05:00
parent 4211358c74
commit f13413e2f3
19 changed files with 70 additions and 98 deletions

View File

@@ -23,7 +23,7 @@
android:fillColor="#FFFFFFFF"
android:pathData="M12.0,19.0c-3.9,0.0 -7.0,-3.1 -7.0,-7.0c0.0,-3.5 2.6,-6.4 6.0,-6.9L11.0,2.0C5.9,2.5 2.0,6.8 2.0,12.0c0.0,5.5 4.5,10.0 10.0,10.0c3.3,0.0 6.2,-1.6 8.1,-4.1l-2.6,-1.5C16.2,18.0 14.2,19.0 12.0,19.0z"/>
<path
android:fillColor="#4DFFFFFF"
android:fillColor="#54FFFFFF"
android:pathData="M13.0,2.0l0.0,3.0c3.4,0.5 6.0,3.4 6.0,6.9c0.0,0.9 -0.2,1.8 -0.5,2.5l2.6,1.5c0.6,-1.2 0.9,-2.6 0.9,-4.1C22.0,6.8 18.0,2.6 13.0,2.0z"/>
<path
android:fillColor="#FFFFFFFF"

View File

@@ -20,9 +20,9 @@
android:viewportHeight="24.0"
android:tint="?android:attr/colorControlNormal">
<path
android:fillColor="#4DFFFFFF"
android:fillColor="#FFFFFFFF"
android:pathData="M12.0,19.0c-3.9,0.0 -7.0,-3.1 -7.0,-7.0c0.0,-3.5 2.6,-6.4 6.0,-6.9L11.0,2.0C5.9,2.5 2.0,6.8 2.0,12.0c0.0,5.5 4.5,10.0 10.0,10.0c3.3,0.0 6.2,-1.6 8.1,-4.1l-2.6,-1.5C16.2,18.0 14.2,19.0 12.0,19.0z"/>
<path
android:fillColor="#4DFFFFFF"
android:fillColor="#FFFFFFFF"
android:pathData="M13.0,2.0l0.0,3.0c3.4,0.5 6.0,3.4 6.0,6.9c0.0,0.9 -0.2,1.8 -0.5,2.5l2.6,1.5c0.6,-1.2 0.9,-2.6 0.9,-4.1C22.0,6.8 18.0,2.6 13.0,2.0z"/>
</vector>

View File

@@ -25,5 +25,5 @@
android:textAppearance="@style/TextAppearance.StatusBar.Expanded.Clock"
android:textColor="?android:attr/textColorPrimary"
android:gravity="center_vertical|start"
android:paddingEnd="4dp"
android:paddingStart="4dp"
/>

View File

@@ -16,5 +16,6 @@
<View xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="72dp"
android:layout_height="1dp"
android:layout_marginTop="8dp"
android:background="?android:attr/colorForeground"
android:alpha="?android:attr/disabledAlpha" />

View File

@@ -20,9 +20,8 @@
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_gravity="center"
android:layout_marginTop="40dp"
android:layout_marginBottom="24dp"
android:focusable="true"
android:gravity="center"
android:importantForAccessibility="yes"
android:visibility="gone"/>
android:visibility="gone"/>

View File

@@ -19,6 +19,7 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="24dp"
android:clipChildren="false"
android:clipToPadding="false">

View File

@@ -16,10 +16,12 @@
-->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingTop="16dp">
android:gravity="center_horizontal"
android:paddingTop="8dp"
android:paddingBottom="8dp">
<TextView android:id="@+id/tile_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"

View File

@@ -17,7 +17,6 @@
xmlns:systemui="http://schemas.android.com/apk/res-auto"
android:layout_height="48dp"
android:layout_width="match_parent"
android:layout_marginBottom="24dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
style="@style/BrightnessDialogContainer">

View File

@@ -85,16 +85,6 @@
<include layout="@layout/system_icons" />
</FrameLayout>
<TextView
android:id="@+id/battery_level"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="@dimen/header_battery_margin_expanded"
android:importantForAccessibility="noHideDescendants"
android:textColor="?android:attr/textColorPrimary"
android:textSize="@dimen/battery_level_text_size"/>
</LinearLayout>
<com.android.systemui.statusbar.AlphaOptimizedFrameLayout

View File

@@ -219,8 +219,8 @@
<!-- The size of the gesture span needed to activate the "pull" notification expansion -->
<dimen name="pull_span_min">25dp</dimen>
<dimen name="qs_tile_height">80dp</dimen>
<dimen name="qs_tile_margin">36dp</dimen>
<dimen name="qs_tile_height">88dp</dimen>
<dimen name="qs_tile_margin">28dp</dimen>
<dimen name="qs_tile_margin_top">16dp</dimen>
<dimen name="qs_quick_tile_size">48dp</dimen>
<dimen name="qs_quick_tile_padding">12dp</dimen>

View File

@@ -65,6 +65,7 @@ public class BatteryMeterView extends LinearLayout implements
private SettingObserver mSettingObserver;
private int mTextColor;
private int mLevel;
private boolean mForceShowPercent;
public BatteryMeterView(Context context) {
this(context, null, 0);
@@ -103,6 +104,11 @@ public class BatteryMeterView extends LinearLayout implements
updateShowPercent();
}
public void forceShowPercent() {
mForceShowPercent = true;
updateShowPercent();
}
// StatusBarIconController reaches in here and adjusts the layout parameters of the icon
public ImageView getBatteryIconView() {
return mBatteryIconView;
@@ -173,13 +179,12 @@ public class BatteryMeterView extends LinearLayout implements
private void updateShowPercent() {
final boolean showing = mBatteryPercentView != null;
if (0 != Settings.System.getInt(getContext().getContentResolver(),
BatteryMeterView.SHOW_PERCENT_SETTING, 0)) {
BatteryMeterView.SHOW_PERCENT_SETTING, 0) || mForceShowPercent) {
if (!showing) {
mBatteryPercentView = loadPercentView();
if (mTextColor != 0) mBatteryPercentView.setTextColor(mTextColor);
updatePercentText();
addView(mBatteryPercentView,
0,
new ViewGroup.LayoutParams(
LayoutParams.WRAP_CONTENT,
LayoutParams.MATCH_PARENT));

View File

@@ -242,7 +242,7 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout {
maxHeight = height;
}
}
setMeasuredDimension(getMeasuredWidth(), maxHeight);
setMeasuredDimension(getMeasuredWidth(), maxHeight + getPaddingBottom());
}
private final Runnable mDistribute = new Runnable() {

View File

@@ -160,7 +160,9 @@ public class QSAnimator implements Callback, PageListener, Listener, OnLayoutCha
mAllViews.clear();
mTopFiveQs.clear();
mAllViews.add((View) mQsPanel.getTileLayout());
QSTileLayout tileLayout = mQsPanel.getTileLayout();
mAllViews.add((View) tileLayout);
firstPageBuilder.addFloat(tileLayout, "translationY", mQsPanel.getHeight(), 0);
for (QSTile<?> tile : tiles) {
QSTileBaseView tileView = mQsPanel.getTileView(tile);
@@ -168,7 +170,6 @@ public class QSAnimator implements Callback, PageListener, Listener, OnLayoutCha
Log.e(TAG, "tileView is null " + tile.getTileSpec());
continue;
}
final TextView label = ((QSTileView) tileView).getLabel();
final View tileIcon = tileView.getIcon().getIconView();
View view = mQs.getView();
if (count < mNumQuickTiles && mAllowFancy) {
@@ -187,12 +188,12 @@ public class QSAnimator implements Callback, PageListener, Listener, OnLayoutCha
// Counteract the parent translation on the tile. So we have a static base to
// animate the label position off from.
firstPageBuilder.addFloat(tileView, "translationY", mQsPanel.getHeight(), 0);
//firstPageBuilder.addFloat(tileView, "translationY", mQsPanel.getHeight(), 0);
// Move the real tile's label from the quick tile position to its final
// Move the real tile from the quick tile position to its final
// location.
translationXBuilder.addFloat(label, "translationX", -xDiff, 0);
translationYBuilder.addFloat(label, "translationY", -yDiff, 0);
translationXBuilder.addFloat(tileView, "translationX", -xDiff, 0);
translationYBuilder.addFloat(tileView, "translationY", -yDiff, 0);
mTopFiveQs.add(tileView.getIcon());
mAllViews.add(tileView.getIcon());
@@ -209,22 +210,22 @@ public class QSAnimator implements Callback, PageListener, Listener, OnLayoutCha
firstPageBuilder.addFloat(tileView, "translationY", mQsPanel.getHeight(), 0);
translationXBuilder.addFloat(tileView, "translationX", -xDiff, 0);
translationYBuilder.addFloat(label, "translationY", -yDiff, 0);
translationYBuilder.addFloat(tileView, "translationY", -yDiff, 0);
translationYBuilder.addFloat(tileIcon, "translationY", -yDiff, 0);
mAllViews.add(tileIcon);
} else {
firstPageBuilder.addFloat(tileView, "alpha", 0, 1);
firstPageBuilder.addFloat(tileView, "translationY", -mQsPanel.getHeight(), 0);
}
mAllViews.add(tileView);
mAllViews.add(label);
count++;
}
if (mAllowFancy) {
// Make brightness appear static position and alpha in through second half.
View brightness = mQsPanel.getBrightnessView();
if (brightness != null) {
// firstPageBuilder.addFloat(brightness, "translationY", mQsPanel.getHeight(), 0);
firstPageBuilder.addFloat(brightness, "translationY", mQsPanel.getHeight(), 0);
mBrightnessAnimator = new TouchAnimator.Builder()
.addFloat(brightness, "alpha", 0, 1)
.addFloat(mQsPanel.getPageIndicator(), "alpha", 0, 1)
@@ -240,7 +241,7 @@ public class QSAnimator implements Callback, PageListener, Listener, OnLayoutCha
// Fade in the tiles/labels as we reach the final position.
mFirstPageDelayedAnimator = new TouchAnimator.Builder()
.setStartDelay(EXPANDED_TILE_DELAY)
.addFloat(mQsPanel.getTileLayout(), "alpha", 0, 1)
.addFloat(tileLayout, "alpha", 0, 1)
.addFloat(mQsPanel.getFooter().getView(), "alpha", 0, 1).build();
mAllViews.add(mQsPanel.getFooter().getView());
float px = 0;

View File

@@ -86,6 +86,10 @@ public class QSPanel extends LinearLayout implements Tunable, Callback {
setOrientation(VERTICAL);
mBrightnessView = LayoutInflater.from(context).inflate(
R.layout.quick_settings_brightness_dialog, this, false);
addView(mBrightnessView);
setupTileLayout();
mFooter = new QSFooter(this, context);
@@ -100,10 +104,6 @@ public class QSPanel extends LinearLayout implements Tunable, Callback {
updateResources();
mBrightnessView = LayoutInflater.from(context).inflate(
R.layout.quick_settings_brightness_dialog, this, false);
addView(mBrightnessView);
mBrightnessController = new BrightnessController(getContext(),
(ImageView) findViewById(R.id.brightness_icon),
(ToggleSliderView) findViewById(R.id.brightness_slider));
@@ -441,8 +441,15 @@ public class QSPanel extends LinearLayout implements Tunable, Callback {
}
r.tile.setDetailListening(show);
int x = r.tileView.getLeft() + r.tileView.getWidth() / 2;
int y = r.tileView.getTop() + mTileLayout.getOffsetTop(r) + r.tileView.getHeight() / 2
+ getTop();
int y;
if (r.tileView instanceof QSTileView) {
View labelContainer = (View) ((QSTileView) r.tileView).getLabel().getParent();
y = r.tileView.getTop() + mTileLayout.getOffsetTop(r) + getTop()
+ labelContainer.getTop() + labelContainer.getHeight() / 2;
} else {
y = r.tileView.getTop() + mTileLayout.getOffsetTop(r) + r.tileView.getHeight() / 2
+ getTop();
}
handleShowDetailImpl(r, show, x, y);
}

View File

@@ -15,38 +15,30 @@
*/
package com.android.systemui.qs;
import android.animation.ValueAnimator;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.RippleDrawable;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.service.quicksettings.Tile;
import android.text.TextUtils;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.ImageView.ScaleType;
import android.widget.LinearLayout;
import android.widget.Switch;
import com.android.settingslib.Utils;
import com.android.systemui.R;
public class QSTileBaseView extends LinearLayout {
private static final String TAG = "QSTileBaseView";
private final H mHandler = new H();
private final FrameLayout mIconFrame;
protected QSIconView mIcon;
protected RippleDrawable mRipple;
private Drawable mTileBackground;
@@ -63,15 +55,15 @@ public class QSTileBaseView extends LinearLayout {
// Default to Quick Tile padding, and QSTileView will specify its own padding.
int padding = context.getResources().getDimensionPixelSize(R.dimen.qs_quick_tile_padding);
FrameLayout frame = new FrameLayout(context);
frame.setForegroundGravity(Gravity.CENTER);
mIconFrame = new FrameLayout(context);
mIconFrame.setForegroundGravity(Gravity.CENTER);
int size = context.getResources().getDimensionPixelSize(R.dimen.qs_quick_tile_size);
addView(frame, new LayoutParams(size, size));
addView(mIconFrame, new LayoutParams(size, size));
mIcon = icon;
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
params.setMargins(0, padding, 0, padding);
frame.addView(mIcon, params);
mIconFrame.addView(mIcon, params);
mTileBackground = newTileBackground();
if (mTileBackground instanceof RippleDrawable) {
@@ -105,7 +97,7 @@ public class QSTileBaseView extends LinearLayout {
private void updateRippleSize(int width, int height) {
// center the touch feedback on the center of the icon, and dial it down a bit
final int cx = width / 2;
final int cy = height / 2;
final int cy = mIconFrame.getMeasuredHeight() / 2;
final int rad = (int) (mIcon.getHeight() * .85f);
mRipple.setHotspotBounds(cx - rad, cy - rad, cx + rad, cy + rad);
}

View File

@@ -20,6 +20,7 @@ import static com.android.systemui.qs.QSTile.getColorForState;
import android.content.Context;
import android.content.res.Configuration;
import android.graphics.drawable.RippleDrawable;
import android.service.quicksettings.Tile;
import android.text.SpannableStringBuilder;
import android.text.style.ForegroundColorSpan;
@@ -28,6 +29,7 @@ import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.ImageView;
import android.widget.TextView;
@@ -43,8 +45,7 @@ public class QSTileView extends QSTileBaseView {
protected TextView mLabel;
private ImageView mPadLock;
private int mState;
private OnClickListener mClick;
private OnClickListener mSecondaryClick;
private ViewGroup mLabelContainer;
public QSTileView(Context context, QSIconView icon) {
this(context, icon, false);
@@ -76,13 +77,15 @@ public class QSTileView extends QSTileBaseView {
}
protected void createLabel() {
ViewGroup view = (ViewGroup) LayoutInflater.from(getContext())
.inflate(R.layout.qs_tile_label, null);
view.setClipChildren(false);
view.setClipToPadding(false);
mLabel = (TextView) view.findViewById(R.id.tile_label);
mPadLock = (ImageView) view.findViewById(R.id.restricted_padlock);
addView(view);
mLabelContainer = (ViewGroup) LayoutInflater.from(getContext())
.inflate(R.layout.qs_tile_label, this, false);
mLabelContainer.setClipChildren(false);
mLabelContainer.setClipToPadding(false);
mLabel = (TextView) mLabelContainer.findViewById(R.id.tile_label);
mPadLock = (ImageView) mLabelContainer.findViewById(R.id.restricted_padlock);
mLabelContainer.setBackground(newTileBackground());
addView(mLabelContainer);
}
@Override
@@ -104,17 +107,10 @@ public class QSTileView extends QSTileBaseView {
}
@Override
public void init(OnClickListener click, OnClickListener secondaryClick, OnLongClickListener longClick) {
mClick = click;
mSecondaryClick = secondaryClick;
public void init(OnClickListener click, OnClickListener secondaryClick,
OnLongClickListener longClick) {
super.init(click, secondaryClick, longClick);
}
@Override
public boolean onTouchEvent(MotionEvent event) {
if (event.getActionMasked() == MotionEvent.ACTION_UP) {
setOnClickListener(event.getY() < (getMeasuredHeight() / 2) ? mClick : mSecondaryClick);
}
return super.onTouchEvent(event);
mLabelContainer.setClickable(true);
mLabelContainer.setOnClickListener(secondaryClick);
}
}

View File

@@ -103,11 +103,6 @@ public class BatteryTile extends QSTile<QSTile.State> implements BatteryControll
mBatteryController.setPowerSaveMode(!mPowerSave);
}
@Override
protected void handleSecondaryClick() {
showDetail(true);
}
@Override
public CharSequence getTileLabel() {
return mContext.getString(R.string.battery);
@@ -118,7 +113,6 @@ public class BatteryTile extends QSTile<QSTile.State> implements BatteryControll
int level = (arg != null) ? (Integer) arg : mLevel;
String percentage = NumberFormat.getPercentInstance().format((double) level / 100.0);
state.dualTarget = true;
state.state = mCharging ? Tile.STATE_UNAVAILABLE
: mPowerSave ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE;
state.icon = ResourceIcon.get(R.drawable.ic_qs_battery_saver);

View File

@@ -123,7 +123,6 @@ public class CastTile extends QSTile<QSTile.BooleanState> {
@Override
protected void handleUpdateState(BooleanState state, Object arg) {
state.dualTarget = true;
state.label = mContext.getString(R.string.quick_settings_cast_title);
state.contentDescription = state.label;
state.value = false;

View File

@@ -26,7 +26,6 @@ import android.graphics.Color;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.RippleDrawable;
import android.icu.text.NumberFormat;
import android.os.UserManager;
import android.support.annotation.Nullable;
import android.support.annotation.VisibleForTesting;
@@ -55,7 +54,6 @@ import com.android.systemui.qs.QuickQSPanel;
import com.android.systemui.qs.TouchAnimator;
import com.android.systemui.qs.TouchAnimator.Builder;
import com.android.systemui.statusbar.SignalClusterView;
import com.android.systemui.statusbar.policy.BatteryController.BatteryStateChangeCallback;
import com.android.systemui.statusbar.policy.NetworkController;
import com.android.systemui.statusbar.policy.NetworkController.EmergencyListener;
import com.android.systemui.statusbar.policy.NetworkController.IconState;
@@ -68,7 +66,7 @@ import com.android.systemui.tuner.TunerService;
public class QuickStatusBarHeader extends BaseStatusBarHeader implements
NextAlarmChangeCallback, OnClickListener, OnUserInfoChangedListener, EmergencyListener,
BatteryStateChangeCallback, SignalCallback {
SignalCallback {
private static final float EXPAND_INDICATOR_THRESHOLD = .93f;
private ActivityStarter mActivityStarter;
@@ -110,7 +108,6 @@ public class QuickStatusBarHeader extends BaseStatusBarHeader implements
private boolean mShowFullAlarm;
private float mDateTimeTranslation;
private TextView mBatteryLevel;
private SparseBooleanArray mRoamingsBySubId = new SparseBooleanArray();
private boolean mIsRoaming;
@@ -161,8 +158,6 @@ public class QuickStatusBarHeader extends BaseStatusBarHeader implements
mAlarmStatus = (TextView) findViewById(R.id.alarm_status);
mAlarmStatus.setOnClickListener(this);
mBatteryLevel = (TextView) findViewById(R.id.battery_level);
mMultiUserSwitch = (MultiUserSwitch) findViewById(R.id.multi_user_switch);
mMultiUserAvatar = (ImageView) mMultiUserSwitch.findViewById(R.id.multi_user_avatar);
mAlwaysShowMultiUserSwitch = res.getBoolean(R.bool.config_alwaysShowMultiUserSwitcher);
@@ -179,7 +174,9 @@ public class QuickStatusBarHeader extends BaseStatusBarHeader implements
int colorForeground = Utils.getColorAttr(getContext(), android.R.attr.colorForeground);
float intensity = colorForeground == Color.WHITE ? 0 : 1;
cluster.onDarkChanged(new Rect(0, 0, 0, 0), intensity, colorForeground);
BatteryMeterView battery = (BatteryMeterView) findViewById(R.id.battery);
battery.forceShowPercent();
int colorSecondary = Utils.getColorAttr(getContext(), android.R.attr.textColorSecondary);
battery.setRawColors(colorForeground, colorSecondary);
@@ -443,17 +440,6 @@ public class QuickStatusBarHeader extends BaseStatusBarHeader implements
}
}
@Override
public void onBatteryLevelChanged(int level, boolean pluggedIn, boolean charging) {
String percentage = NumberFormat.getPercentInstance().format((double) level / 100.0);
mBatteryLevel.setText(percentage);
}
@Override
public void onPowerSaveChanged(boolean isPowerSave) {
// Don't care.
}
public void setMobileDataIndicators(IconState statusIcon, IconState qsIcon, int statusType,
int qsType, boolean activityIn, boolean activityOut, String typeContentDescription,
String description, boolean isWide, int subId, boolean roaming) {