--- /dev/null
+<?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>
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"
>
<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
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"
<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>
+++ /dev/null
-/*
- * 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);
- }
-}
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());
public TilePage(Context context, AttributeSet attrs) {
super(context, attrs);
- mAllowDual = false;
updateResources();
}
--- /dev/null
+/*
+ * 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());
+ }
+}
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();
}
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
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() {
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();
}
}
+ protected void onTileClick(QSTile<?> tile) {
+ tile.click();
+ }
+
public boolean isShowingDetail() {
return mDetailRecord != null
|| (mCustomizePanel != null && mCustomizePanel.isCustomizing());
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 {
}
}
- private static class Record {
+ protected static class Record {
View detailView;
DetailAdapter detailAdapter;
int x;
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() {
}
protected void handleSecondaryClick() {
- // optional
+ // Default to normal click.
+ handleClick();
}
protected void handleLongClick() {
/*
* 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;
-
-public abstract class QSTileBaseView extends ViewGroup {
+import android.widget.LinearLayout;
+import com.android.systemui.R;
- 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());
+ }
+ }
- public void onStateChanged(QSTile.State state) {
- mHandler.obtainMessage(H.STATE_CHANGED, state).sendToTarget();
+ 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 abstract void init(OnClickListener click, OnClickListener clickSecondary,
- OnLongClickListener longClick);
- public abstract View updateAccessibilityOrder(View previousView);
- public abstract boolean setType(int type);
+ 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);
+ }
+ }
- protected abstract void handleStateChanged(QSTile.State 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) {
+ setAccessibilityTraversalAfter(previousView.getId());
+ return this;
+ }
- protected static int exactly(int size) {
- return MeasureSpec.makeMeasureSpec(size, MeasureSpec.EXACTLY);
+ public void onStateChanged(QSTile.State state) {
+ mHandler.obtainMessage(H.STATE_CHANGED, state).sendToTarget();
}
- 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 {
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 {
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() {
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();
}
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);
- }
- }
-
- 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());
- }
+ 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 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);
}
}
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;
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) {
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.
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;
}
}
public HeaderTileLayout(Context context) {
super(context);
+ setClipChildren(false);
+ setClipToPadding(false);
setGravity(Gravity.CENTER_VERTICAL);
setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
@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;
}
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;
}
@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) {
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<>();
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();
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++;
}
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);
}
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);
private int getRowTop(int row) {
if (row <= 0) return 0;
- return mLargeCellHeight - mDualTileUnderlap + (row - 1) * mCellHeight;
+ return row * mCellHeight;
}
private int getColumnCount(int row) {
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;
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())) {
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()) {
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> {
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;
}
}
@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);
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;
}
@Override
- public QSTileBaseView createTileView(Context context) {
+ public QSIconView createTileView(Context context) {
return new SignalTileView(context);
}
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) {
+++ /dev/null
-/*
- * 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;
- }
-}
+++ /dev/null
-/*
- * 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;
- }
-}
+++ /dev/null
-/*
- * 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;
- }
-}
+++ /dev/null
-/*
- * 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);
- }
- }
-}
+++ /dev/null
-/*
- * 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;
- }
-}
+++ /dev/null
-/*
- * 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;
- }
-}
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;
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();
}
}
@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;
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;
}
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);
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);
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;
private boolean mListening;
private AlarmManager.AlarmClockInfo mNextAlarm;
- private QSPanel mHeaderQsPanel;
+ private QuickQSPanel mHeaderQsPanel;
public QuickStatusBarHeader(Context context, AttributeSet attrs) {
super(context, attrs);
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);
@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) {
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
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);