Working towards a better QS
Some work (mostly on the new QS only) to make things more like they
will be.
- Remove Quick Tiles
- Remove Dual Tiles
- All tiles are the same, with slightly different UI in the header
- QS tiles in the header match the beginning of QS
- handleClick is a click from QS, handleSecondaryClick is a click
from the header, but defaults to normal behavior.
- Opening a detail panel from the header opens QS and the detail
selected
- Fix onStartListening bug in CustomTile
- UI updates towards how QS will look
Change-Id: Id820586ccdaa258a5bcb72cadbeb14941fc5f935
diff --git a/packages/SystemUI/res/drawable/quick_header_bg.xml b/packages/SystemUI/res/drawable/quick_header_bg.xml
new file mode 100644
index 0000000..d45d673
--- /dev/null
+++ b/packages/SystemUI/res/drawable/quick_header_bg.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2015 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
+ -->
+
+<ripple xmlns:android="http://schemas.android.com/apk/res/android"
+ android:color="?android:attr/colorControlHighlight" >
+ <item android:drawable="@color/system_primary_color"/>
+</ripple>
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 cc35c51c..8124eb7 100644
--- a/packages/SystemUI/res/layout/quick_status_bar_expanded_header.xml
+++ b/packages/SystemUI/res/layout/quick_status_bar_expanded_header.xml
@@ -25,9 +25,10 @@
android:layout_gravity="@integer/notification_panel_layout_gravity"
android:paddingStart="@dimen/notification_side_padding"
android:paddingEnd="@dimen/notification_side_padding"
+ android:clipChildren="false"
+ android:clipToPadding="false"
android:baselineAligned="false"
- android:elevation="4dp"
- android:background="@drawable/notification_header_bg"
+ android:background="@drawable/quick_header_bg"
android:clickable="true"
android:focusable="true"
>
@@ -35,9 +36,11 @@
<com.android.systemui.qs.QuickQSPanel
android:id="@+id/quick_qs_panel"
android:background="#0000"
- android:layout_width="144dp"
+ android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentEnd="true"
+ android:clipChildren="false"
+ android:clipToPadding="false"
android:layout_marginEnd="12dp" />
<LinearLayout
@@ -49,7 +52,7 @@
android:clipToPadding="false"
android:orientation="horizontal"
android:layout_alignParentEnd="true"
- android:layout_marginEnd="10dp">
+ android:layout_marginEnd="12dp">
<com.android.systemui.statusbar.AlphaOptimizedFrameLayout
android:id="@+id/settings_button_container"
diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml
index 086e9f4..25ff6b1 100644
--- a/packages/SystemUI/res/values/dimens.xml
+++ b/packages/SystemUI/res/values/dimens.xml
@@ -173,7 +173,7 @@
<dimen name="borderless_button_radius">2dp</dimen>
<!-- How far the expanded QS panel peeks from the header in collapsed state. -->
- <dimen name="qs_peek_height">8dp</dimen>
+ <dimen name="qs_peek_height">0dp</dimen>
<!-- Zen mode panel: condition item button padding -->
<dimen name="zen_mode_condition_detail_button_padding">8dp</dimen>
diff --git a/packages/SystemUI/src/com/android/systemui/QSQuickTileView.java b/packages/SystemUI/src/com/android/systemui/QSQuickTileView.java
deleted file mode 100644
index 3362650..0000000
--- a/packages/SystemUI/src/com/android/systemui/QSQuickTileView.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (C) 2015 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.
- */
-
-package com.android.systemui;
-
-import android.content.Context;
-import android.view.View;
-import android.widget.ImageView;
-import com.android.systemui.qs.QSTile;
-import com.android.systemui.qs.QSTileBaseView;
-
-public class QSQuickTileView extends QSTileBaseView {
-
- private final int mPadding;
- private final ImageView mIcon;
-
- public QSQuickTileView(Context context) {
- super(context);
- mPadding = context.getResources().getDimensionPixelSize(R.dimen.qs_quick_tile_padding);
- mIcon = createIcon();
- addView(mIcon);
- }
-
- protected ImageView createIcon() {
- final ImageView icon = new ImageView(mContext);
- icon.setId(android.R.id.icon);
- icon.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
- return icon;
- }
-
- @Override
- public void init(OnClickListener click, OnClickListener clickSecondary,
- OnLongClickListener longClick) {
- setClickable(true);
- setOnClickListener(click);
- }
-
- @Override
- protected void handleStateChanged(QSTile.State state) {
- mIcon.setImageDrawable(state.icon.getDrawable(getContext()));
- setContentDescription(state.contentDescription);
- }
-
- @Override
- public boolean setType(int type) {
- return false;
- }
-
- @Override
- public View updateAccessibilityOrder(View previousView) {
- return this;
- }
-
- @Override
- protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- super.onMeasure(widthMeasureSpec, heightMeasureSpec);
- mIcon.measure(exactly(getMeasuredWidth() - 2 * mPadding),
- exactly(getMeasuredHeight() - 2 * mPadding));
- }
-
- @Override
- protected void onLayout(boolean changed, int l, int t, int r, int b) {
- layout(mIcon, mPadding, mPadding);
- }
-}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/PagedTileLayout.java b/packages/SystemUI/src/com/android/systemui/qs/PagedTileLayout.java
index 0e4a4e5..61b1b8e 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/PagedTileLayout.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/PagedTileLayout.java
@@ -101,10 +101,6 @@
final int NT = mTiles.size();
for (int i = 0; i < NT; i++) {
TileRecord tile = mTiles.get(i);
- if (tile.tile.getTileType() == QSTileView.QS_TYPE_QUICK) {
- // Don't show any quick tiles for now.
- continue;
- }
if (mPages.get(index).isFull()) {
if (++index == mPages.size()) {
if (DEBUG) Log.d(TAG, "Adding page for " + tile.tile.getClass().getSimpleName());
@@ -178,7 +174,6 @@
public TilePage(Context context, AttributeSet attrs) {
super(context, attrs);
- mAllowDual = false;
updateResources();
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSIconView.java b/packages/SystemUI/src/com/android/systemui/qs/QSIconView.java
new file mode 100644
index 0000000..b56ad76
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSIconView.java
@@ -0,0 +1,104 @@
+/*
+ * Copyright (C) 2015 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.
+ */
+
+package com.android.systemui.qs;
+
+import android.content.Context;
+import android.content.res.Resources;
+import android.graphics.drawable.Animatable;
+import android.graphics.drawable.Drawable;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ImageView;
+import com.android.systemui.R;
+
+import java.util.Objects;
+
+public class QSIconView extends ViewGroup {
+
+ private final View mIcon;
+ private final int mIconSizePx;
+ private final int mTilePaddingBelowIconPx;
+
+ public QSIconView(Context context) {
+ super(context);
+
+ final Resources res = context.getResources();
+ mIconSizePx = res.getDimensionPixelSize(R.dimen.qs_tile_icon_size);
+ mTilePaddingBelowIconPx = res.getDimensionPixelSize(R.dimen.qs_tile_padding_below_icon);
+
+ mIcon = createIcon();
+ addView(mIcon);
+ }
+
+ @Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ final int w = MeasureSpec.getSize(widthMeasureSpec);
+ final int iconSpec = exactly(mIconSizePx);
+ mIcon.measure(MeasureSpec.makeMeasureSpec(w, getIconMeasureMode()), iconSpec);
+ setMeasuredDimension(w, mIcon.getMeasuredHeight() + mTilePaddingBelowIconPx);
+ }
+
+ @Override
+ protected void onLayout(boolean changed, int l, int t, int r, int b) {
+ final int w = getMeasuredWidth();
+ final int h = getMeasuredHeight();
+ int top = 0;
+ final int iconLeft = (w - mIcon.getMeasuredWidth()) / 2;
+ layout(mIcon, iconLeft, top);
+ }
+
+ public void setIcon(QSTile.State state) {
+ setIcon((ImageView) mIcon, state);
+ }
+
+ protected void setIcon(ImageView iv, QSTile.State state) {
+ if (!Objects.equals(state.icon, iv.getTag(R.id.qs_icon_tag))) {
+ Drawable d = state.icon != null ? state.icon.getDrawable(mContext) : null;
+ if (d != null && state.autoMirrorDrawable) {
+ d.setAutoMirrored(true);
+ }
+ iv.setImageDrawable(d);
+ iv.setTag(R.id.qs_icon_tag, state.icon);
+ if (d instanceof Animatable) {
+ Animatable a = (Animatable) d;
+ if (state.icon instanceof QSTile.AnimationIcon && !iv.isShown()) {
+ a.stop(); // skip directly to end state
+ }
+ }
+ }
+
+ }
+
+ protected int getIconMeasureMode() {
+ return MeasureSpec.EXACTLY;
+ }
+
+ protected View createIcon() {
+ final ImageView icon = new ImageView(mContext);
+ icon.setId(android.R.id.icon);
+ icon.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
+ return icon;
+ }
+
+ protected static int exactly(int size) {
+ return MeasureSpec.makeMeasureSpec(size, MeasureSpec.EXACTLY);
+ }
+
+ protected static void layout(View child, int left, int top) {
+ child.layout(left, top, left + child.getMeasuredWidth(), top + child.getMeasuredHeight());
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java b/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java
index bb2b8fc..cf1ffe3 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java
@@ -298,7 +298,7 @@
showDetail(show, r);
}
- private void showDetail(boolean show, Record r) {
+ protected void showDetail(boolean show, Record r) {
mHandler.obtainMessage(H.SHOW_DETAIL, show ? 1 : 0, 0, r).sendToTarget();
}
@@ -330,10 +330,14 @@
r.tileView.onStateChanged(state);
}
+ protected QSTileBaseView createTileView(QSTile<?> tile) {
+ return new QSTileView(mContext, tile.createTileView(mContext));
+ }
+
protected void addTile(final QSTile<?> tile) {
final TileRecord r = new TileRecord();
r.tile = tile;
- r.tileView = tile.createTileView(mContext);
+ r.tileView = createTileView(tile);
r.tileView.setVisibility(View.GONE);
final QSTile.Callback callback = new QSTile.Callback() {
@Override
@@ -369,13 +373,7 @@
final View.OnClickListener click = new View.OnClickListener() {
@Override
public void onClick(View v) {
- r.tile.click();
- }
- };
- final View.OnClickListener clickSecondary = new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- r.tile.secondaryClick();
+ onTileClick(r.tile);
}
};
final View.OnLongClickListener longClick = new View.OnLongClickListener() {
@@ -396,7 +394,7 @@
return true;
}
};
- r.tileView.init(click, clickSecondary, longClick);
+ r.tileView.init(click, longClick);
r.tile.setListening(mListening);
callback.onStateChanged(r.tile.getState());
r.tile.refreshState();
@@ -407,6 +405,10 @@
}
}
+ protected void onTileClick(QSTile<?> tile) {
+ tile.click();
+ }
+
public boolean isShowingDetail() {
return mDetailRecord != null
|| (mCustomizePanel != null && mCustomizePanel.isCustomizing());
@@ -429,7 +431,7 @@
return mQsContainer.getMeasuredHeight();
}
- private void handleShowDetail(Record r, boolean show) {
+ protected void handleShowDetail(Record r, boolean show) {
if (r instanceof TileRecord) {
handleShowDetailTile((TileRecord) r, show);
} else {
@@ -560,7 +562,7 @@
}
}
- private static class Record {
+ protected static class Record {
View detailView;
DetailAdapter detailAdapter;
int x;
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSTile.java b/packages/SystemUI/src/com/android/systemui/qs/QSTile.java
index 7f45545..7f74a12 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSTile.java
@@ -86,20 +86,12 @@
mTileSpec = tileSpec;
}
- public int getTileType() {
- return QSTileView.QS_TYPE_NORMAL;
- }
-
- public final boolean supportsDualTargets() {
- return getTileType() == QSTileView.QS_TYPE_DUAL;
- }
-
public Host getHost() {
return mHost;
}
- public QSTileBaseView createTileView(Context context) {
- return new QSTileView(context);
+ public QSIconView createTileView(Context context) {
+ return new QSIconView(context);
}
public DetailAdapter getDetailAdapter() {
@@ -181,7 +173,8 @@
}
protected void handleSecondaryClick() {
- // optional
+ // Default to normal click.
+ handleClick();
}
protected void handleLongClick() {
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSTileBaseView.java b/packages/SystemUI/src/com/android/systemui/qs/QSTileBaseView.java
index 72fc88d..68461f5 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSTileBaseView.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSTileBaseView.java
@@ -1,57 +1,112 @@
/*
* Copyright (C) 2015 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
+ * 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.
+ * 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.
*/
-
package com.android.systemui.qs;
import android.content.Context;
+import android.content.res.TypedArray;
+import android.graphics.drawable.Drawable;
+import android.graphics.drawable.RippleDrawable;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
-import android.util.AttributeSet;
import android.view.View;
-import android.view.ViewGroup;
+import android.widget.LinearLayout;
+import com.android.systemui.R;
-public abstract class QSTileBaseView extends ViewGroup {
-
- public static final int QS_TYPE_NORMAL = 0;
- public static final int QS_TYPE_DUAL = 1;
- public static final int QS_TYPE_QUICK = 2;
+public class QSTileBaseView extends LinearLayout {
private final H mHandler = new H();
+ private QSIconView mIcon;
+ private RippleDrawable mRipple;
+ private Drawable mTileBackground;
- public QSTileBaseView(Context context) {
+ public QSTileBaseView(Context context, QSIconView icon) {
super(context);
+ mIcon = icon;
+ addView(mIcon);
+
+ mTileBackground = newTileBackground();
+ if (mTileBackground instanceof RippleDrawable) {
+ setRipple((RippleDrawable) mTileBackground);
+ }
+ setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES);
+ setBackground(mTileBackground);
+
+ // Default to Quick Tile padding, and QSTileView will specify its own padding.
+ int padding = context.getResources().getDimensionPixelSize(R.dimen.qs_quick_tile_padding);
+ setPadding(padding, padding, padding, padding);
}
- public QSTileBaseView(Context context, AttributeSet attrs) {
- super(context, attrs);
+ private Drawable newTileBackground() {
+ final int[] attrs = new int[] { android.R.attr.selectableItemBackgroundBorderless };
+ final TypedArray ta = mContext.obtainStyledAttributes(attrs);
+ final Drawable d = ta.getDrawable(0);
+ ta.recycle();
+ return d;
}
+ private void setRipple(RippleDrawable tileBackground) {
+ mRipple = tileBackground;
+ if (getWidth() != 0) {
+ updateRippleSize(getWidth(), getHeight());
+ }
+ }
+
+ 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 rad = (int)(mIcon.getHeight() * .85f);
+ mRipple.setHotspotBounds(cx - rad, cy - rad, cx + rad, cy + rad);
+ }
+
+ public void init(OnClickListener click, OnLongClickListener longClick) {
+ setClickable(true);
+ setOnClickListener(click);
+ }
+
+ @Override
+ protected void onLayout(boolean changed, int l, int t, int r, int b) {
+ super.onLayout(changed, l, t, r, b);
+ final int w = getMeasuredWidth();
+ final int h = getMeasuredHeight();
+
+ if (mRipple != null) {
+ updateRippleSize(w, h);
+ }
+ }
+
+ /**
+ * Update the accessibility order for this view.
+ *
+ * @param previousView the view which should be before this one
+ * @return the last view in this view which is accessible
+ */
+ public View updateAccessibilityOrder(View previousView) {
+ setAccessibilityTraversalAfter(previousView.getId());
+ return this;
+ }
public void onStateChanged(QSTile.State state) {
mHandler.obtainMessage(H.STATE_CHANGED, state).sendToTarget();
}
- public abstract void init(OnClickListener click, OnClickListener clickSecondary,
- OnLongClickListener longClick);
- public abstract View updateAccessibilityOrder(View previousView);
- public abstract boolean setType(int type);
-
- protected abstract void handleStateChanged(QSTile.State state);
-
- protected static int exactly(int size) {
- return MeasureSpec.makeMeasureSpec(size, MeasureSpec.EXACTLY);
- }
-
- protected static void layout(View child, int left, int top) {
- child.layout(left, top, left + child.getMeasuredWidth(), top + child.getMeasuredHeight());
+ protected void handleStateChanged(QSTile.State state) {
+ mIcon.setIcon(state);
+ setContentDescription(state.contentDescription);
}
private class H extends Handler {
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSTileView.java b/packages/SystemUI/src/com/android/systemui/qs/QSTileView.java
index 4cc2b8d..41ac4d9 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSTileView.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSTileView.java
@@ -17,26 +17,16 @@
package com.android.systemui.qs;
import android.content.Context;
-import android.content.res.ColorStateList;
import android.content.res.Configuration;
import android.content.res.Resources;
-import android.content.res.TypedArray;
import android.graphics.Typeface;
-import android.graphics.drawable.Animatable;
-import android.graphics.drawable.Drawable;
-import android.graphics.drawable.RippleDrawable;
import android.util.MathUtils;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.View;
-import android.widget.ImageView;
-import android.widget.ImageView.ScaleType;
import android.widget.TextView;
import com.android.systemui.FontSizeUtils;
import com.android.systemui.R;
-import com.android.systemui.qs.QSTile.AnimationIcon;
-
-import java.util.Objects;
/** View that represents a standard quick settings tile. **/
public class QSTileView extends QSTileBaseView {
@@ -44,59 +34,25 @@
Typeface.NORMAL);
protected final Context mContext;
- private final View mIcon;
- private final View mDivider;
- private final int mIconSizePx;
private final int mTileSpacingPx;
private int mTilePaddingTopPx;
- private final int mTilePaddingBelowIconPx;
- private final int mDualTileVerticalPaddingPx;
- private final View mTopBackgroundView;
private TextView mLabel;
- private QSDualTileLabel mDualLabel;
- private int mType;
- private OnClickListener mClickPrimary;
- private OnClickListener mClickSecondary;
- private OnLongClickListener mLongClick;
- private Drawable mTileBackground;
- private RippleDrawable mRipple;
- private View mCircle;
-
- public QSTileView(Context context) {
- super(context);
+ public QSTileView(Context context, QSIconView icon) {
+ super(context, icon);
mContext = context;
final Resources res = context.getResources();
- mIconSizePx = res.getDimensionPixelSize(R.dimen.qs_tile_icon_size);
mTileSpacingPx = res.getDimensionPixelSize(R.dimen.qs_tile_spacing);
- mTilePaddingBelowIconPx = res.getDimensionPixelSize(R.dimen.qs_tile_padding_below_icon);
- mDualTileVerticalPaddingPx =
- res.getDimensionPixelSize(R.dimen.qs_dual_tile_padding_vertical);
- mTileBackground = newTileBackground();
- recreateLabel();
setClipChildren(false);
- mTopBackgroundView = new View(context);
- mTopBackgroundView.setId(View.generateViewId());
- addView(mTopBackgroundView);
-
- mIcon = createIcon();
- addView(mIcon);
-
- mCircle = createCircleIcon();
- addView(mCircle);
-
- mDivider = new View(mContext);
- mDivider.setBackgroundColor(context.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);
updateTopPadding();
setId(View.generateViewId());
+ createLabel();
+ setOrientation(VERTICAL);
+ setGravity(Gravity.CENTER);
}
private void updateTopPadding() {
@@ -106,6 +62,8 @@
float largeFactor = (MathUtils.constrain(getResources().getConfiguration().fontScale,
1.0f, FontSizeUtils.LARGE_TEXT_SCALE) - 1f) / (FontSizeUtils.LARGE_TEXT_SCALE - 1f);
mTilePaddingTopPx = Math.round((1 - largeFactor) * padding + largeFactor * largePadding);
+ setPadding(mTileSpacingPx, mTilePaddingTopPx + mTileSpacingPx, mTileSpacingPx,
+ mTileSpacingPx);
requestLayout();
}
@@ -114,260 +72,29 @@
super.onConfigurationChanged(newConfig);
updateTopPadding();
FontSizeUtils.updateFontSize(mLabel, R.dimen.qs_tile_text_size);
- if (mDualLabel != null) {
- mDualLabel.setTextSize(TypedValue.COMPLEX_UNIT_PX,
- getResources().getDimensionPixelSize(R.dimen.qs_tile_text_size));
- }
}
- private void recreateLabel() {
- CharSequence labelText = null;
- CharSequence labelDescription = null;
- if (mLabel != null) {
- labelText = mLabel.getText();
- removeView(mLabel);
- mLabel = null;
- }
- if (mDualLabel != null) {
- labelText = mDualLabel.getText();
- labelDescription = mLabel != null ? mLabel.getContentDescription() : null;
- removeView(mDualLabel);
- mDualLabel = null;
- }
+ private void createLabel() {
final Resources res = mContext.getResources();
- if (mType == QS_TYPE_DUAL) {
- mDualLabel = new QSDualTileLabel(mContext);
- mDualLabel.setId(View.generateViewId());
- mDualLabel.setBackgroundResource(R.drawable.btn_borderless_rect);
- mDualLabel.setFirstLineCaret(mContext.getDrawable(R.drawable.qs_dual_tile_caret));
- mDualLabel.setTextColor(mContext.getColor(R.color.qs_tile_text));
- mDualLabel.setPadding(0, mDualTileVerticalPaddingPx, 0, mDualTileVerticalPaddingPx);
- mDualLabel.setTypeface(CONDENSED);
- mDualLabel.setTextSize(TypedValue.COMPLEX_UNIT_PX,
- res.getDimensionPixelSize(R.dimen.qs_tile_text_size));
- mDualLabel.setClickable(true);
- mDualLabel.setOnClickListener(mClickSecondary);
- mDualLabel.setFocusable(true);
- if (labelText != null) {
- mDualLabel.setText(labelText);
- }
- if (labelDescription != null) {
- mDualLabel.setContentDescription(labelDescription);
- }
- addView(mDualLabel);
- mDualLabel.setAccessibilityTraversalAfter(mTopBackgroundView.getId());
- } else if (mType == QS_TYPE_NORMAL) {
- mLabel = new TextView(mContext);
- mLabel.setTextColor(mContext.getColor(R.color.qs_tile_text));
- mLabel.setGravity(Gravity.CENTER_HORIZONTAL);
- mLabel.setMinLines(2);
- mLabel.setPadding(0, 0, 0, 0);
- mLabel.setTypeface(CONDENSED);
- mLabel.setTextSize(TypedValue.COMPLEX_UNIT_PX,
- res.getDimensionPixelSize(R.dimen.qs_tile_text_size));
- mLabel.setClickable(false);
- if (labelText != null) {
- mLabel.setText(labelText);
- }
- addView(mLabel);
- }
+ mLabel = new TextView(mContext);
+ mLabel.setTextColor(mContext.getColor(R.color.qs_tile_text));
+ mLabel.setGravity(Gravity.CENTER_HORIZONTAL);
+ mLabel.setMinLines(2);
+ mLabel.setPadding(0, 0, 0, 0);
+ mLabel.setTypeface(CONDENSED);
+ mLabel.setTextSize(TypedValue.COMPLEX_UNIT_PX,
+ res.getDimensionPixelSize(R.dimen.qs_tile_text_size));
+ mLabel.setClickable(false);
+ addView(mLabel);
}
- public boolean setType(int type) {
- final boolean changed = mType != type;
- mType = type;
- if (changed) {
- recreateLabel();
- }
- if (mTileBackground instanceof RippleDrawable) {
- setRipple((RippleDrawable) mTileBackground);
- }
- if (mType == QS_TYPE_DUAL) {
- mTopBackgroundView.setOnClickListener(mClickPrimary);
- setOnClickListener(null);
- setClickable(false);
- setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
- mTopBackgroundView.setBackground(mTileBackground);
- } else {
- mTopBackgroundView.setOnClickListener(null);
- mTopBackgroundView.setClickable(false);
- setOnClickListener(mClickPrimary);
- setOnLongClickListener(mLongClick);
- setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES);
- setBackground(mTileBackground);
- }
- mTopBackgroundView.setFocusable(mType == QS_TYPE_DUAL);
- setFocusable(mType != QS_TYPE_DUAL);
- mDivider.setVisibility(mType == QS_TYPE_DUAL ? VISIBLE : GONE);
- mCircle.setVisibility(mType == QS_TYPE_QUICK ? VISIBLE : GONE);
- postInvalidate();
- return changed;
- }
-
- private void setRipple(RippleDrawable tileBackground) {
- mRipple = tileBackground;
- if (getWidth() != 0) {
- updateRippleSize(getWidth(), getHeight());
- }
- }
-
- public void init(OnClickListener clickPrimary, OnClickListener clickSecondary,
- OnLongClickListener longClick) {
- mClickPrimary = clickPrimary;
- mClickSecondary = clickSecondary;
- mLongClick = longClick;
- }
-
- protected View createIcon() {
- final ImageView icon = new ImageView(mContext);
- icon.setId(android.R.id.icon);
- icon.setScaleType(ScaleType.CENTER_INSIDE);
- return icon;
- }
-
- protected View createCircleIcon() {
- final ImageView icon = new ImageView(mContext);
- icon.setImageResource(R.drawable.ic_qs_circle);
- // TODO: Not this.
- icon.setPadding(20, 20, 20, 20);
- return icon;
- }
-
- protected View createCircle() {
- final ImageView icon = new ImageView(mContext);
- icon.setId(android.R.id.icon);
- icon.setScaleType(ScaleType.CENTER_INSIDE);
- return icon;
- }
-
- private Drawable newTileBackground() {
- final int[] attrs = new int[] { android.R.attr.selectableItemBackgroundBorderless };
- final TypedArray ta = mContext.obtainStyledAttributes(attrs);
- final Drawable d = ta.getDrawable(0);
- ta.recycle();
- return d;
- }
-
- private View labelView() {
- return mType == QS_TYPE_DUAL ? mDualLabel : mLabel;
- }
-
- @Override
- protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- final int w = MeasureSpec.getSize(widthMeasureSpec);
- final int h = MeasureSpec.getSize(heightMeasureSpec);
- final int iconSpec = exactly(mIconSizePx);
- mIcon.measure(MeasureSpec.makeMeasureSpec(w, getIconMeasureMode()), iconSpec);
- switch (mType) {
- case QS_TYPE_QUICK:
- mCircle.measure(
- MeasureSpec.makeMeasureSpec(w, MeasureSpec.EXACTLY),
- MeasureSpec.makeMeasureSpec(h, MeasureSpec.EXACTLY));
- break;
- case QS_TYPE_DUAL:
- mDivider.measure(widthMeasureSpec, exactly(mDivider.getLayoutParams().height));
- default:
- labelView().measure(widthMeasureSpec,
- MeasureSpec.makeMeasureSpec(h, MeasureSpec.AT_MOST));
- break;
- }
- int heightSpec = exactly(
- mIconSizePx + mTilePaddingBelowIconPx + mTilePaddingTopPx);
- mTopBackgroundView.measure(widthMeasureSpec, heightSpec);
- setMeasuredDimension(w, h);
- }
-
- protected int getIconMeasureMode() {
- return MeasureSpec.EXACTLY;
- }
-
- @Override
- protected void onLayout(boolean changed, int l, int t, int r, int b) {
- final int w = getMeasuredWidth();
- final int h = getMeasuredHeight();
-
- layout(mTopBackgroundView, 0, mTileSpacingPx);
-
- int top = 0;
- top += mTileSpacingPx;
- top += mTilePaddingTopPx;
- final int iconLeft = (w - mIcon.getMeasuredWidth()) / 2;
- if (mType == QS_TYPE_QUICK) {
- top = (h - mIcon.getMeasuredHeight()) / 2;
- layout(mCircle, 0, 0);
- }
- layout(mIcon, iconLeft, top);
- if (mRipple != null) {
- updateRippleSize(w, h);
-
- }
- top = mIcon.getBottom();
- top += mTilePaddingBelowIconPx;
- if (mType == QS_TYPE_DUAL) {
- layout(mDivider, 0, top);
- top = mDivider.getBottom();
- }
- if (mType != QS_TYPE_QUICK) {
- layout(labelView(), 0, top);
- }
- }
-
- 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 = mType == QS_TYPE_DUAL ? mIcon.getTop() + mIcon.getHeight() / 2 : height / 2;
- final int rad = (int)(mIcon.getHeight() * 1.25f);
- mRipple.setHotspotBounds(cx - rad, cy - rad, cx + rad, cy + rad);
+ public void init(OnClickListener clickPrimary, OnLongClickListener longClick) {
+ setOnClickListener(clickPrimary);
+ setOnLongClickListener(longClick);
}
protected void handleStateChanged(QSTile.State state) {
- if (mIcon instanceof ImageView) {
- setIcon((ImageView) mIcon, state);
- }
- if (mType == QS_TYPE_DUAL) {
- mDualLabel.setText(state.label);
- mDualLabel.setContentDescription(state.dualLabelContentDescription);
- mTopBackgroundView.setContentDescription(state.contentDescription);
- } else if (mType == QS_TYPE_NORMAL) {
- mLabel.setText(state.label);
- setContentDescription(state.contentDescription);
- }
- }
-
- protected void setIcon(ImageView iv, QSTile.State state) {
- if (!Objects.equals(state.icon, iv.getTag(R.id.qs_icon_tag))) {
- Drawable d = state.icon != null ? state.icon.getDrawable(mContext) : null;
- if (d != null && state.autoMirrorDrawable) {
- d.setAutoMirrored(true);
- }
- iv.setImageDrawable(d);
- iv.setTag(R.id.qs_icon_tag, state.icon);
- if (d instanceof Animatable) {
- Animatable a = (Animatable) d;
- if (state.icon instanceof AnimationIcon && !iv.isShown()) {
- a.stop(); // skip directly to end state
- }
- }
- }
- }
-
- /**
- * Update the accessibility order for this view.
- *
- * @param previousView the view which should be before this one
- * @return the last view in this view which is accessible
- */
- public View updateAccessibilityOrder(View previousView) {
- View firstView;
- View lastView;
- if (mType == QS_TYPE_DUAL) {
- lastView = mDualLabel;
- firstView = mTopBackgroundView;
- } else {
- firstView = this;
- lastView = this;
- }
- firstView.setAccessibilityTraversalAfter(previousView.getId());
- return lastView;
+ super.handleStateChanged(state);
+ mLabel.setText(state.label);
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QuickQSPanel.java b/packages/SystemUI/src/com/android/systemui/qs/QuickQSPanel.java
index 6a053be..a5c8d91 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QuickQSPanel.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QuickQSPanel.java
@@ -19,7 +19,6 @@
import android.content.Context;
import android.content.res.ColorStateList;
import android.util.AttributeSet;
-import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.widget.ImageView;
@@ -30,10 +29,14 @@
import java.util.Collection;
/**
- * Version of QSPanel that only shows 4 Quick Tiles in the QS Header.
+ * Version of QSPanel that only shows N Quick Tiles in the QS Header.
*/
public class QuickQSPanel extends QSPanel {
+ private int mMaxTiles;
+ private QSPanel mFullPanel;
+ private View mHeader;
+
public QuickQSPanel(Context context, AttributeSet attrs) {
super(context, attrs);
if (mTileLayout != null) {
@@ -46,6 +49,36 @@
mQsContainer.addView((View) mTileLayout, 1 /* Between brightness and footer */);
}
+ public void setQSPanelAndHeader(QSPanel fullPanel, View header) {
+ mFullPanel = fullPanel;
+ mHeader = header;
+ }
+
+ @Override
+ protected void handleShowDetail(QSPanel.Record r, boolean show) {
+ if (show) {
+ mHeader.performClick();
+ mFullPanel.showDetail(show, r);
+ } else {
+ // Not sure how we would end up here...
+ super.handleShowDetail(r, show);
+ }
+ }
+
+ @Override
+ protected QSTileBaseView createTileView(QSTile<?> tile) {
+ return new QSTileBaseView(mContext, tile.createTileView(mContext));
+ }
+
+ public void setMaxTiles(int maxTiles) {
+ mMaxTiles = maxTiles;
+ }
+
+ @Override
+ protected void onTileClick(QSTile<?> tile) {
+ tile.secondaryClick();
+ }
+
@Override
public void onTuningChanged(String key, String newValue) {
// No tunings for you.
@@ -59,11 +92,8 @@
public void setTiles(Collection<QSTile<?>> tiles) {
ArrayList<QSTile<?>> quickTiles = new ArrayList<>();
for (QSTile<?> tile : tiles) {
- if (tile.getTileType() == QSTileView.QS_TYPE_QUICK) {
- Log.d("QSPanel", "Adding " + tile.getTileSpec());
- quickTiles.add(tile);
- }
- if (quickTiles.size() == 2) {
+ quickTiles.add(tile);
+ if (quickTiles.size() == mMaxTiles) {
break;
}
}
@@ -74,6 +104,8 @@
public HeaderTileLayout(Context context) {
super(context);
+ setClipChildren(false);
+ setClipToPadding(false);
setGravity(Gravity.CENTER_VERTICAL);
setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
@@ -92,17 +124,13 @@
@Override
public void addTile(TileRecord tile) {
tile.tileView.setLayoutParams(generateLayoutParams());
- // These shouldn't be normal tiles, but they will be for now so that the circles don't
- // show up.
- tile.tileView.setType(QSTileView.QS_TYPE_NORMAL);
addView(tile.tileView, getChildCount() - 1 /* Leave icon at end */);
}
private LayoutParams generateLayoutParams() {
int size =
mContext.getResources().getDimensionPixelSize(R.dimen.qs_quick_tile_size);
- LayoutParams lp = new LayoutParams(0, size);
- lp.weight = 1;
+ LayoutParams lp = new LayoutParams(size, size);
return lp;
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/SignalTileView.java b/packages/SystemUI/src/com/android/systemui/qs/SignalTileView.java
index a2e1296..b2bfa06 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/SignalTileView.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/SignalTileView.java
@@ -27,7 +27,7 @@
import com.android.systemui.qs.QSTile.SignalState;
/** View that represents a custom quick settings tile for displaying signal info (wifi/cell). **/
-public final class SignalTileView extends QSTileView {
+public final class SignalTileView extends QSIconView {
private static final long DEFAULT_DURATION = new ValueAnimator().getDuration();
private static final long SHORT_DURATION = DEFAULT_DURATION / 3;
@@ -106,8 +106,7 @@
}
@Override
- protected void handleStateChanged(QSTile.State state) {
- super.handleStateChanged(state);
+ public void setIcon(QSTile.State state) {
final SignalState s = (SignalState) state;
setIcon(mSignal, s);
if (s.overlayIconId > 0) {
diff --git a/packages/SystemUI/src/com/android/systemui/qs/TileLayout.java b/packages/SystemUI/src/com/android/systemui/qs/TileLayout.java
index 1336eec..e82396e 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/TileLayout.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/TileLayout.java
@@ -18,14 +18,9 @@
private static final String TAG = "TileLayout";
- private int mDualTileUnderlap;
protected int mColumns;
private int mCellWidth;
private int mCellHeight;
- private int mLargeCellWidth;
- private int mLargeCellHeight;
-
- protected boolean mAllowDual = true;
protected final ArrayList<TileRecord> mRecords = new ArrayList<>();
@@ -69,11 +64,6 @@
final int columns = Math.max(1, res.getInteger(R.integer.quick_settings_num_columns));
mCellHeight = getCellHeight();
mCellWidth = (int) (mCellHeight * TILE_ASPECT);
- mLargeCellHeight = mAllowDual ? res.getDimensionPixelSize(R.dimen.qs_dual_tile_height)
- : mCellHeight;
- mLargeCellWidth = mAllowDual ? (int) (mLargeCellHeight * TILE_ASPECT) : mCellWidth;
- mDualTileUnderlap = mAllowDual
- ? res.getDimensionPixelSize(R.dimen.qs_dual_tile_padding_vertical) : 0;
if (mColumns != columns) {
mColumns = columns;
postInvalidate();
@@ -90,16 +80,13 @@
int r = -1;
int c = -1;
int rows = 0;
- boolean rowIsDual = false;
for (TileRecord record : mRecords) {
if (record.tileView.getVisibility() == GONE) continue;
// wrap to next column if we've reached the max # of columns
// also don't allow dual + single tiles on the same row
- if (r == -1 || c == (mColumns - 1)
- || rowIsDual != (mAllowDual && record.tile.supportsDualTargets())) {
+ if (r == -1 || c == (mColumns - 1)) {
r++;
c = 0;
- rowIsDual = mAllowDual && record.tile.supportsDualTargets();
} else {
c++;
}
@@ -110,13 +97,9 @@
View previousView = this;
for (TileRecord record : mRecords) {
- if (record.tileView.setType(mAllowDual ? record.tile.getTileType()
- : QSTileView.QS_TYPE_NORMAL)) {
- record.tileView.handleStateChanged(record.tile.getState());
- }
if (record.tileView.getVisibility() == GONE) continue;
- final int cw = record.row == 0 ? mLargeCellWidth : mCellWidth;
- final int ch = record.row == 0 ? mLargeCellHeight : mCellHeight;
+ final int cw = mCellWidth;
+ final int ch = mCellHeight;
record.tileView.measure(exactly(cw), exactly(ch));
previousView = record.tileView.updateAccessibilityOrder(previousView);
}
@@ -135,7 +118,7 @@
for (TileRecord record : mRecords) {
if (record.tileView.getVisibility() == GONE) continue;
final int cols = getColumnCount(record.row);
- final int cw = record.row == 0 ? mLargeCellWidth : mCellWidth;
+ final int cw = mCellWidth;
final int extra = (w - cw * cols) / (cols + 1);
int left = record.col * cw + (record.col + 1) * extra;
final int top = getRowTop(record.row);
@@ -153,7 +136,7 @@
private int getRowTop(int row) {
if (row <= 0) return 0;
- return mLargeCellHeight - mDualTileUnderlap + (row - 1) * mCellHeight;
+ return row * mCellHeight;
}
private int getColumnCount(int row) {
diff --git a/packages/SystemUI/src/com/android/systemui/qs/customize/NonPagedTileLayout.java b/packages/SystemUI/src/com/android/systemui/qs/customize/NonPagedTileLayout.java
index d0d5b54..f2b5d1c 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/customize/NonPagedTileLayout.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/customize/NonPagedTileLayout.java
@@ -25,14 +25,12 @@
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.LinearLayout;
-
import com.android.systemui.R;
import com.android.systemui.qs.PagedTileLayout;
import com.android.systemui.qs.PagedTileLayout.TilePage;
import com.android.systemui.qs.QSPanel.QSTileLayout;
import com.android.systemui.qs.QSPanel.TileRecord;
import com.android.systemui.qs.QSTile;
-import com.android.systemui.qs.QSTileView;
import com.android.systemui.qs.QuickTileLayout;
import java.util.ArrayList;
@@ -75,13 +73,12 @@
public void addTile(TileRecord record) {
mTiles.add(record);
distributeTiles();
- if (record.tile.getTileType() == QSTileView.QS_TYPE_QUICK
- || record.tileView.getTag() == record.tile) {
+ if (record.tileView.getTag() == record.tile) {
return;
}
record.tileView.setTag(record.tile);
record.tileView.setVisibility(View.VISIBLE);
- record.tileView.init(null, null, null);
+ record.tileView.init(null, null);
record.tileView.setOnTouchListener(this);
if (mCurrentClip != null && mCurrentClip.getItemAt(0)
.getText().toString().equals(record.tile.getTileSpec())) {
@@ -107,10 +104,6 @@
final int NT = mTiles.size();
for (int i = 0; i < NT; i++) {
TileRecord tile = mTiles.get(i);
- if (tile.tile.getTileType() == QSTileView.QS_TYPE_QUICK) {
- // Ignore quick tiles for now.
- continue;
- }
mPages.get(index).addTile(tile);
// Keep everything in one layout for now.
if (false && mPages.get(index).isFull()) {
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/BluetoothTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/BluetoothTile.java
index 7f07ddc..ae10051 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/BluetoothTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/BluetoothTile.java
@@ -24,18 +24,15 @@
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
-
import com.android.internal.logging.MetricsLogger;
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
import com.android.systemui.R;
import com.android.systemui.qs.QSDetailItems;
import com.android.systemui.qs.QSDetailItems.Item;
import com.android.systemui.qs.QSTile;
-import com.android.systemui.qs.QSTileView;
import com.android.systemui.statusbar.policy.BluetoothController;
import java.util.Collection;
-import java.util.Set;
/** Quick settings tile: Bluetooth **/
public class BluetoothTile extends QSTile<QSTile.BooleanState> {
@@ -44,21 +41,13 @@
private final BluetoothController mController;
private final BluetoothDetailAdapter mDetailAdapter;
- private final boolean mAlwaysDetail;
-
- public BluetoothTile(Host host, boolean alwaysDetail) {
+ public BluetoothTile(Host host) {
super(host);
- mAlwaysDetail = alwaysDetail;
mController = host.getBluetoothController();
mDetailAdapter = new BluetoothDetailAdapter();
}
@Override
- public int getTileType() {
- return QSTileView.QS_TYPE_DUAL;
- }
-
- @Override
public DetailAdapter getDetailAdapter() {
return mDetailAdapter;
}
@@ -78,18 +67,15 @@
}
@Override
- protected void handleClick() {
- if (mAlwaysDetail) {
- handleSecondaryClick();
- return;
- }
+ protected void handleSecondaryClick() {
+ // Secondary clicks are header clicks, just toggle.
final boolean isEnabled = (Boolean)mState.value;
MetricsLogger.action(mContext, getMetricsCategory(), !isEnabled);
mController.setBluetoothEnabled(!isEnabled);
}
@Override
- protected void handleSecondaryClick() {
+ protected void handleClick() {
if (!mState.value) {
mState.value = true;
mController.setBluetoothEnabled(true);
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/CellularTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/CellularTile.java
index a0bbbe3..959ccf0 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/CellularTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/CellularTile.java
@@ -26,8 +26,8 @@
import com.android.internal.logging.MetricsLogger;
import com.android.settingslib.net.MobileDataController;
import com.android.systemui.R;
+import com.android.systemui.qs.QSIconView;
import com.android.systemui.qs.QSTile;
-import com.android.systemui.qs.QSTileBaseView;
import com.android.systemui.qs.SignalTileView;
import com.android.systemui.statusbar.policy.NetworkController;
import com.android.systemui.statusbar.policy.NetworkController.IconState;
@@ -71,7 +71,7 @@
}
@Override
- public QSTileBaseView createTileView(Context context) {
+ public QSIconView createTileView(Context context) {
return new SignalTileView(context);
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/CustomTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/CustomTile.java
index 04006eb..b63cdec 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/CustomTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/CustomTile.java
@@ -104,9 +104,15 @@
mServiceConnection, Service.BIND_AUTO_CREATE,
new UserHandle(ActivityManager.getCurrentUser()));
mBound = true;
+ } else {
+ if (mService != null) {
+ mService.onStartListening();
+ } else {
+ Log.d(TAG, "Can't start service listening");
+ }
}
} else {
- if (mService!= null) {
+ if (mService != null) {
mService.onStopListening();
}
if (mIsTokenGranted && !mIsShowingDialog) {
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/QAirplaneTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/QAirplaneTile.java
deleted file mode 100644
index b77191e..0000000
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/QAirplaneTile.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2015 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.
- */
-
-package com.android.systemui.qs.tiles;
-
-import android.content.Context;
-import com.android.systemui.QSQuickTileView;
-import com.android.systemui.qs.QSTileBaseView;
-import com.android.systemui.qs.QSTileView;
-
-/** Quick settings tile: Airplane mode **/
-public class QAirplaneTile extends AirplaneModeTile {
-
- public QAirplaneTile(Host host) {
- super(host);
- }
-
- @Override
- public QSTileBaseView createTileView(Context context) {
- return new QSQuickTileView(context);
- }
-
- @Override
- public int getTileType() {
- return QSTileView.QS_TYPE_QUICK;
- }
-}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/QBluetoothTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/QBluetoothTile.java
deleted file mode 100644
index 4fe7e45..0000000
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/QBluetoothTile.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2015 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.
- */
-
-package com.android.systemui.qs.tiles;
-
-import android.content.Context;
-import com.android.systemui.QSQuickTileView;
-import com.android.systemui.qs.QSTileBaseView;
-import com.android.systemui.qs.QSTileView;
-
-/** Quick settings tile: Bluetooth **/
-public class QBluetoothTile extends BluetoothTile {
-
- public QBluetoothTile(Host host) {
- super(host, false);
- }
-
- @Override
- public QSTileBaseView createTileView(Context context) {
- return new QSQuickTileView(context);
- }
-
- @Override
- public int getTileType() {
- return QSTileView.QS_TYPE_QUICK;
- }
-}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/QFlashlightTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/QFlashlightTile.java
deleted file mode 100644
index e115755e..0000000
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/QFlashlightTile.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2015 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.
- */
-
-package com.android.systemui.qs.tiles;
-
-import android.content.Context;
-import com.android.systemui.QSQuickTileView;
-import com.android.systemui.qs.QSTileBaseView;
-import com.android.systemui.qs.QSTileView;
-
-/** Quick settings tile: Flashlight **/
-public class QFlashlightTile extends FlashlightTile {
-
- public QFlashlightTile(Host host) {
- super(host);
- }
-
- @Override
- public QSTileBaseView createTileView(Context context) {
- return new QSQuickTileView(context);
- }
-
- @Override
- public int getTileType() {
- return QSTileView.QS_TYPE_QUICK;
- }
-}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/QLockTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/QLockTile.java
deleted file mode 100644
index 8b3013a..0000000
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/QLockTile.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright (C) 2015 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.
- */
-package com.android.systemui.qs.tiles;
-
-import android.content.Context;
-import com.android.internal.logging.MetricsLogger;
-import com.android.systemui.QSQuickTileView;
-import com.android.systemui.R;
-import com.android.systemui.qs.QSTile;
-import com.android.systemui.qs.QSTileBaseView;
-import com.android.systemui.qs.QSTileView;
-import com.android.systemui.statusbar.policy.KeyguardMonitor;
-
-public class QLockTile extends QSTile<QSTile.State> implements KeyguardMonitor.Callback {
-
- private final KeyguardMonitor mKeyguard;
-
- public QLockTile(Host host) {
- super(host);
- mKeyguard = host.getKeyguardMonitor();
- }
-
- @Override
- public QSTileBaseView createTileView(Context context) {
- return new QSQuickTileView(context);
- }
-
- @Override
- public int getTileType() {
- return QSTileView.QS_TYPE_QUICK;
- }
-
- @Override
- protected State newTileState() {
- return new State();
- }
-
- @Override
- public void setListening(boolean listening) {
- if (listening) {
- mKeyguard.addCallback(this);
- } else {
- mKeyguard.removeCallback(this);
- }
- }
-
- @Override
- public int getMetricsCategory() {
- return MetricsLogger.QS_LOCK_TILE;
- }
-
- @Override
- public void onKeyguardChanged() {
- refreshState();
- }
-
- @Override
- protected void handleClick() {
- if (mKeyguard.isShowing()) {
- mKeyguard.unlock();
- } else {
- mKeyguard.lock();
- }
- }
-
- @Override
- protected void handleUpdateState(State state, Object arg) {
- // TOD: Content description.
- state.visible = true;
- if (mKeyguard.isShowing()) {
- state.icon = ResourceIcon.get(R.drawable.ic_qs_lock);
- } else {
- state.icon = ResourceIcon.get(R.drawable.ic_qs_lock_open);
- }
- }
-}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/QRotationLockTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/QRotationLockTile.java
deleted file mode 100644
index 5f5cab5..0000000
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/QRotationLockTile.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2015 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.
- */
-
-package com.android.systemui.qs.tiles;
-
-import android.content.Context;
-import com.android.systemui.QSQuickTileView;
-import com.android.systemui.qs.QSTileBaseView;
-import com.android.systemui.qs.QSTileView;
-
-/** Quick settings tile: Rotation **/
-public class QRotationLockTile extends RotationLockTile {
-
- public QRotationLockTile(Host host) {
- super(host);
- }
-
- @Override
- public QSTileBaseView createTileView(Context context) {
- return new QSQuickTileView(context);
- }
-
- @Override
- public int getTileType() {
- return QSTileView.QS_TYPE_QUICK;
- }
-}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/QWifiTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/QWifiTile.java
deleted file mode 100644
index f0fe87d..0000000
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/QWifiTile.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (C) 2015 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.
- */
-
-package com.android.systemui.qs.tiles;
-
-import android.content.Context;
-import com.android.systemui.QSQuickTileView;
-import com.android.systemui.qs.QSTileBaseView;
-import com.android.systemui.qs.QSTileView;
-import com.android.systemui.statusbar.policy.WifiIcons;
-
-/** Quick settings tile: Wifi **/
-public class QWifiTile extends WifiTile {
-
- public QWifiTile(Host host) {
- super(host, false);
- }
-
- @Override
- public QSTileBaseView createTileView(Context context) {
- return new QSQuickTileView(context);
- }
-
- @Override
- public int getTileType() {
- return QSTileView.QS_TYPE_QUICK;
- }
-
- @Override
- protected void handleUpdateState(SignalState state, Object arg) {
- super.handleUpdateState(state, arg);
-
- CallbackInfo cb = (CallbackInfo) arg;
- if (cb == null) {
- cb = mSignalCallback.mInfo;
- }
- boolean wifiConnected = cb.enabled && (cb.wifiSignalIconId > 0) && (cb.enabledDesc != null);
-
- if (state.enabled && wifiConnected) {
- // Only show full signal here.
- state.icon = ResourceIcon.get(WifiIcons.QS_WIFI_SIGNAL_STRENGTH[1][4]);
- }
- // No activity in the quick toggle.
- state.activityIn = false;
- state.activityOut = false;
- }
-}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/WifiTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/WifiTile.java
index 7f4442a..5228081 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/WifiTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/WifiTile.java
@@ -23,15 +23,13 @@
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
-
import com.android.internal.logging.MetricsLogger;
import com.android.settingslib.wifi.AccessPoint;
import com.android.systemui.R;
import com.android.systemui.qs.QSDetailItems;
import com.android.systemui.qs.QSDetailItems.Item;
+import com.android.systemui.qs.QSIconView;
import com.android.systemui.qs.QSTile;
-import com.android.systemui.qs.QSTileBaseView;
-import com.android.systemui.qs.QSTileView;
import com.android.systemui.qs.SignalTileView;
import com.android.systemui.statusbar.policy.NetworkController;
import com.android.systemui.statusbar.policy.NetworkController.AccessPointController;
@@ -51,22 +49,14 @@
protected final WifiSignalCallback mSignalCallback = new WifiSignalCallback();
- private final boolean mAlwaysDetail;
-
- public WifiTile(Host host, boolean alwaysDetail) {
+ public WifiTile(Host host) {
super(host);
- mAlwaysDetail = alwaysDetail;
mController = host.getNetworkController();
mWifiController = mController.getAccessPointController();
mDetailAdapter = new WifiDetailAdapter();
}
@Override
- public int getTileType() {
- return QSTileView.QS_TYPE_DUAL;
- }
-
- @Override
protected SignalState newTileState() {
return new SignalState();
}
@@ -95,23 +85,20 @@
}
@Override
- public QSTileBaseView createTileView(Context context) {
+ public QSIconView createTileView(Context context) {
return new SignalTileView(context);
}
@Override
- protected void handleClick() {
- if (mAlwaysDetail) {
- handleSecondaryClick();
- return;
- }
+ protected void handleSecondaryClick() {
+ // Secondary clicks are header clicks, just toggle.
mState.copyTo(mStateBeforeClick);
MetricsLogger.action(mContext, getMetricsCategory(), !mState.enabled);
mController.setWifiEnabled(!mState.enabled);
}
@Override
- protected void handleSecondaryClick() {
+ protected void handleClick() {
if (!mWifiController.canConfigWifi()) {
mHost.startActivityDismissingKeyguard(new Intent(Settings.ACTION_WIFI_SETTINGS));
return;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QSTileHost.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QSTileHost.java
index 327b81e..9427f22 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QSTileHost.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QSTileHost.java
@@ -45,12 +45,6 @@
import com.android.systemui.qs.tiles.HotspotTile;
import com.android.systemui.qs.tiles.IntentTile;
import com.android.systemui.qs.tiles.LocationTile;
-import com.android.systemui.qs.tiles.QAirplaneTile;
-import com.android.systemui.qs.tiles.QBluetoothTile;
-import com.android.systemui.qs.tiles.QFlashlightTile;
-import com.android.systemui.qs.tiles.QLockTile;
-import com.android.systemui.qs.tiles.QRotationLockTile;
-import com.android.systemui.qs.tiles.QWifiTile;
import com.android.systemui.qs.tiles.RotationLockTile;
import com.android.systemui.qs.tiles.UserTile;
import com.android.systemui.qs.tiles.WifiTile;
@@ -334,8 +328,8 @@
}
public QSTile<?> createTile(String tileSpec) {
- if (tileSpec.equals("wifi")) return new WifiTile(this, false);
- else if (tileSpec.equals("bt")) return new BluetoothTile(this, false);
+ if (tileSpec.equals("wifi")) return new WifiTile(this);
+ else if (tileSpec.equals("bt")) return new BluetoothTile(this);
else if (tileSpec.equals("inversion")) return new ColorInversionTile(this);
else if (tileSpec.equals("cell")) return new CellularTile(this);
else if (tileSpec.equals("airplane")) return new AirplaneModeTile(this);
@@ -348,16 +342,6 @@
else if (tileSpec.equals("hotspot")) return new HotspotTile(this);
else if (tileSpec.equals("user")) return new UserTile(this);
else if (tileSpec.equals("battery")) return new BatteryTile(this);
- // Detail only versions of wifi and bluetooth.
- else if (tileSpec.equals("dwifi")) return new WifiTile(this, true);
- else if (tileSpec.equals("dbt")) return new BluetoothTile(this, true);
- // Quick tiles, no text.
- else if (tileSpec.equals("qwifi")) return new QWifiTile(this);
- else if (tileSpec.equals("qbt")) return new QBluetoothTile(this);
- else if (tileSpec.equals("qairplane")) return new QAirplaneTile(this);
- else if (tileSpec.equals("qrotation")) return new QRotationLockTile(this);
- else if (tileSpec.equals("qflashlight")) return new QFlashlightTile(this);
- else if (tileSpec.equals("qlock")) return new QLockTile(this);
// Intent tiles.
else if (tileSpec.startsWith(IntentTile.PREFIX)) return IntentTile.create(this,tileSpec);
else if (tileSpec.startsWith(CustomTile.PREFIX)) return CustomTile.create(this,tileSpec);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickStatusBarHeader.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickStatusBarHeader.java
index cc9f5c7..26ff97a 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickStatusBarHeader.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickStatusBarHeader.java
@@ -30,10 +30,10 @@
import android.widget.Switch;
import android.widget.TextView;
import android.widget.Toast;
-
import com.android.systemui.R;
import com.android.systemui.qs.QSPanel;
import com.android.systemui.qs.QSTile;
+import com.android.systemui.qs.QuickQSPanel;
import com.android.systemui.statusbar.policy.BatteryController;
import com.android.systemui.statusbar.policy.NextAlarmController;
import com.android.systemui.statusbar.policy.UserInfoController;
@@ -63,7 +63,7 @@
private boolean mListening;
private AlarmManager.AlarmClockInfo mNextAlarm;
- private QSPanel mHeaderQsPanel;
+ private QuickQSPanel mHeaderQsPanel;
public QuickStatusBarHeader(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -75,7 +75,7 @@
mExpandedGroup = (ViewGroup) findViewById(R.id.expanded_group);
- mHeaderQsPanel = (QSPanel) findViewById(R.id.quick_qs_panel);
+ mHeaderQsPanel = (QuickQSPanel) findViewById(R.id.quick_qs_panel);
mSettingsButton = (SettingsButton) findViewById(R.id.settings_button);
mSettingsContainer = findViewById(R.id.settings_button_container);
@@ -133,9 +133,10 @@
@Override
public void setExpansion(float headerExpansionFraction) {
- float offset = getHeight() * headerExpansionFraction;
- mExpandedGroup.setTranslationY(offset - getHeight());
- mHeaderQsPanel.setTranslationY(offset);
+ mExpandedGroup.setAlpha(headerExpansionFraction);
+ mExpandedGroup.setVisibility(headerExpansionFraction > 0 ? View.VISIBLE : View.INVISIBLE);
+ mHeaderQsPanel.setAlpha(1 - headerExpansionFraction);
+ mHeaderQsPanel.setVisibility(headerExpansionFraction < 1 ? View.VISIBLE : View.INVISIBLE);
}
public void setListening(boolean listening) {
@@ -190,7 +191,9 @@
host.getUserSwitcherController(), host.getUserInfoController(),
host.getKeyguardMonitor(), host.getSecurityController(),
host.getBatteryController());
+ mHeaderQsPanel.setQSPanelAndHeader(mQsPanel, this);
mHeaderQsPanel.setHost(myHost);
+ mHeaderQsPanel.setMaxTiles(3);
mHeaderQsPanel.setTiles(myHost.getTiles());
myHost.addCallback(new QSTile.Host.Callback() {
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/tuner/QSPagingSwitch.java b/packages/SystemUI/src/com/android/systemui/tuner/QSPagingSwitch.java
index 04a51f0..d19a825 100644
--- a/packages/SystemUI/src/com/android/systemui/tuner/QSPagingSwitch.java
+++ b/packages/SystemUI/src/com/android/systemui/tuner/QSPagingSwitch.java
@@ -9,8 +9,8 @@
public class QSPagingSwitch extends TunerSwitch {
public static final String QS_PAGE_TILES =
- "dwifi,dbt,dnd,cell,battery,user,rotation,flashlight,location,"
- + "hotspot,qwifi,qbt,qlock,qflashlight,qairplane,inversion,cast";
+ "dnd,cell,battery,user,rotation,flashlight,location,"
+ + "hotspot,inversion,cast";
public QSPagingSwitch(Context context, AttributeSet attrs) {
super(context, attrs);