Start drawing QS slashes rather than using AVDS
These need a bit more work like length control and animations, etc. but this is a decent start. Test: visual Change-Id: I750d777b2b4a19f8c586066712f5a3f7e79befd6
This commit is contained in:
@@ -112,6 +112,7 @@ public interface QSTile {
|
||||
public boolean dualTarget = false;
|
||||
public boolean isTransient = false;
|
||||
public String expandedAccessibilityClassName;
|
||||
public SlashState slash;
|
||||
|
||||
public boolean copyTo(State other) {
|
||||
if (other == null) throw new IllegalArgumentException();
|
||||
@@ -126,7 +127,8 @@ public interface QSTile {
|
||||
|| !Objects.equals(other.disabledByPolicy, disabledByPolicy)
|
||||
|| !Objects.equals(other.state, state)
|
||||
|| !Objects.equals(other.isTransient, isTransient)
|
||||
|| !Objects.equals(other.dualTarget, dualTarget);
|
||||
|| !Objects.equals(other.dualTarget, dualTarget)
|
||||
|| !Objects.equals(other.slash, slash);
|
||||
other.icon = icon;
|
||||
other.label = label;
|
||||
other.contentDescription = contentDescription;
|
||||
@@ -136,6 +138,7 @@ public interface QSTile {
|
||||
other.state = state;
|
||||
other.dualTarget = dualTarget;
|
||||
other.isTransient = isTransient;
|
||||
other.slash = slash != null ? slash.copy() : null;
|
||||
return changed;
|
||||
}
|
||||
|
||||
@@ -155,6 +158,7 @@ public interface QSTile {
|
||||
sb.append(",dualTarget=").append(dualTarget);
|
||||
sb.append(",isTransient=").append(isTransient);
|
||||
sb.append(",state=").append(state);
|
||||
sb.append(",slash=\"").append(slash).append("\"");
|
||||
return sb.append(']');
|
||||
}
|
||||
|
||||
@@ -246,4 +250,34 @@ public interface QSTile {
|
||||
}
|
||||
}
|
||||
|
||||
@ProvidesInterface(version = SlashState.VERSION)
|
||||
public static class SlashState {
|
||||
public static final int VERSION = 2;
|
||||
|
||||
public boolean isSlashed;
|
||||
public float rotation;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "isSlashed=" + isSlashed + ",rotation=" + rotation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o == null) return false;
|
||||
try {
|
||||
return (((SlashState) o).rotation == rotation)
|
||||
&& (((SlashState) o).isSlashed == isSlashed);
|
||||
} catch (ClassCastException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public SlashState copy() {
|
||||
SlashState state = new SlashState();
|
||||
state.rotation = rotation;
|
||||
state.isSlashed = isSlashed;
|
||||
return state;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,16 +14,14 @@ Copyright (C) 2014 The Android Open Source Project
|
||||
limitations under the License.
|
||||
-->
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="32.0dp"
|
||||
android:height="29.5dp"
|
||||
android:viewportWidth="26.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#FFFFFFFF"
|
||||
android:pathData="M17.500000,16.500000L5.800000,3.400000c0.000000,0.000000 0.000000,0.000000 0.000000,0.000000l-2.700000,-3.000000L1.600000,1.800000l2.200000,2.500000c-2.000000,1.000000 -3.200000,2.000000 -3.400000,2.200000L13.000000,22.000000l0.000000,0.000000l0.000000,0.000000l0.000000,0.000000l0.000000,0.000000l3.200000,-3.900000l2.400000,2.700000l1.500000,-1.400000L17.500000,16.500000L17.500000,16.500000z"
|
||||
android:fillAlpha=".3"/>
|
||||
<path
|
||||
android:fillColor="#FFFFFFFF"
|
||||
android:pathData="M25.600000,6.500000C25.100000,6.100000 20.299999,2.100000 13.000000,2.100000c-1.900000,0.000000 -3.600000,0.300000 -5.200000,0.700000L18.700001,15.000000L25.600000,6.500000z"
|
||||
android:fillAlpha=".3"/>
|
||||
android:width="32.0dp"
|
||||
android:height="29.5dp"
|
||||
android:viewportWidth="26.0"
|
||||
android:viewportHeight="24.0">
|
||||
<group
|
||||
android:translateY="2">
|
||||
<path
|
||||
android:fillColor="#FFFFFFFF"
|
||||
android:pathData="M13.000000,22.000000L25.600000,6.500000C25.100000,6.100000 20.299999,2.100000 13.000000,2.100000S0.900000,6.100000 0.400000,6.500000L13.000000,22.000000L13.000000,22.000000L13.000000,22.000000L13.000000,22.000000L13.000000,22.000000z"/>
|
||||
</group>
|
||||
</vector>
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
<group
|
||||
android:name="plane"
|
||||
android:translateX="23.481"
|
||||
android:translateY="18.71151" >
|
||||
android:translateY="15.71151" >
|
||||
<path
|
||||
android:name="plane_1"
|
||||
android:pathData="M 18.9439849854,7.98849487305 c 0.0,0.0 0.0,-4.0 0.0,-4.0 c 0.0,0.0 -16.0,-10.0 -16.0,-10.0 c 0.0,0.0 0.0,-11.0 0.0,-11.0 c 0.0,-1.70001220703 -1.30000305176,-3.0 -3.0,-3.0 c -1.69999694824,0.0 -3.0,1.29998779297 -3.0,3.0 c 0.0,0.0 0.0,11.0 0.0,11.0 c 0.0,0.0 -16.0,10.0 -16.0,10.0 c 0.0,0.0 0.0,4.0 0.0,4.0 c 0.0,0.0 16.0,-5.0 16.0,-5.0 c 0.0,0.0 0.0,11.0 0.0,11.0 c 0.0,0.0 -4.0,3.0 -4.0,3.0 c 0.0,0.0 0.0,3.0 0.0,3.0 c 0.0,0.0 7.0,-2.0 7.0,-2.0 c 0.0,0.0 7.0,2.0 7.0,2.0 c 0.0,0.0 0.0,-3.0 0.0,-3.0 c 0.0,0.0 -4.0,-3.0 -4.0,-3.0 c 0.0,0.0 0.0,-11.0 0.0,-11.0 c 0.0,0.0 16.0,5.0 16.0,5.0 Z"
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
<item type="id" name="shadow_alpha_animator_start_value_tag"/>
|
||||
<item type="id" name="doze_saved_filter_tag"/>
|
||||
<item type="id" name="qs_icon_tag"/>
|
||||
<item type="id" name="qs_slash_tag"/>
|
||||
<item type="id" name="scrim"/>
|
||||
<item type="id" name="scrim_target"/>
|
||||
<item type="id" name="scrim_alpha_start"/>
|
||||
|
||||
@@ -27,6 +27,7 @@ import com.android.systemui.R;
|
||||
import com.android.systemui.plugins.qs.QSTile;
|
||||
import com.android.systemui.plugins.qs.QSTile.SignalState;
|
||||
import com.android.systemui.qs.tileimpl.QSIconViewImpl;
|
||||
import com.android.systemui.qs.tileimpl.SlashImageView;
|
||||
|
||||
/** View that represents a custom quick settings tile for displaying signal info (wifi/cell). **/
|
||||
public class SignalTileView extends QSIconViewImpl {
|
||||
@@ -61,7 +62,7 @@ public class SignalTileView extends QSIconViewImpl {
|
||||
@Override
|
||||
protected View createIcon() {
|
||||
mIconFrame = new FrameLayout(mContext);
|
||||
mSignal = new ImageView(mContext);
|
||||
mSignal = new SlashImageView(mContext);
|
||||
mIconFrame.addView(mSignal);
|
||||
return mIconFrame;
|
||||
}
|
||||
|
||||
178
packages/SystemUI/src/com/android/systemui/qs/SlashDrawable.java
Normal file
178
packages/SystemUI/src/com/android/systemui/qs/SlashDrawable.java
Normal file
@@ -0,0 +1,178 @@
|
||||
/*
|
||||
* Copyright (C) 2017 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.annotation.ColorInt;
|
||||
import android.annotation.IntRange;
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.ColorFilter;
|
||||
import android.graphics.Matrix;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Path;
|
||||
import android.graphics.PorterDuff.Mode;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.Log;
|
||||
|
||||
public class SlashDrawable extends Drawable {
|
||||
|
||||
private final Path mPath = new Path();
|
||||
private final Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
|
||||
private static float[] OFFSET = {
|
||||
1.3f / 24f,-1.3f / 24f
|
||||
};
|
||||
private static float[][] PATH = {
|
||||
{21.9f / 24f, 21.9f / 24f},
|
||||
{2.1f / 24f, 2.1f / 24f},
|
||||
{0.8f / 24f, 3.4f / 24f},
|
||||
{20.6f / 24f, 23.2f / 24f},
|
||||
};
|
||||
private Drawable mDrawable;
|
||||
private float mRotation;
|
||||
private boolean mSlashed;
|
||||
private Mode mTintMode;
|
||||
private ColorStateList mTintList;
|
||||
|
||||
public SlashDrawable(Drawable d) {
|
||||
mDrawable = d;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIntrinsicHeight() {
|
||||
return mDrawable != null ? mDrawable.getIntrinsicHeight(): 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIntrinsicWidth() {
|
||||
return mDrawable != null ? mDrawable.getIntrinsicWidth(): 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onBoundsChange(Rect bounds) {
|
||||
super.onBoundsChange(bounds);
|
||||
mDrawable.setBounds(bounds);
|
||||
}
|
||||
|
||||
public void setDrawable(Drawable d) {
|
||||
mDrawable = d;
|
||||
mDrawable.setCallback(getCallback());
|
||||
mDrawable.setBounds(getBounds());
|
||||
if (mTintMode != null) mDrawable.setTintMode(mTintMode);
|
||||
if (mTintList != null) mDrawable.setTintList(mTintList);
|
||||
invalidateSelf();
|
||||
}
|
||||
|
||||
public void setRotation(float rotation) {
|
||||
if (mRotation == rotation) return;
|
||||
mRotation = rotation;
|
||||
invalidateSelf();
|
||||
}
|
||||
|
||||
public void setSlashed(boolean slashed) {
|
||||
Log.d("TestTest", "setSlashed " + slashed);
|
||||
if (mSlashed == slashed) return;
|
||||
// TODO: Animate.
|
||||
mSlashed = slashed;
|
||||
invalidateSelf();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(@NonNull Canvas canvas) {
|
||||
canvas.save();
|
||||
Log.d("TestTest", "draw " + mSlashed);
|
||||
if (mSlashed) {
|
||||
Matrix m = new Matrix();
|
||||
int width = getBounds().width();
|
||||
int height = getBounds().height();
|
||||
mPath.reset();
|
||||
mPath.moveTo(scale(PATH[0][0], width), scale(PATH[0][1], height));
|
||||
mPath.lineTo(scale(PATH[1][0], width), scale(PATH[1][1], height));
|
||||
mPath.lineTo(scale(PATH[2][0], width), scale(PATH[2][1], height));
|
||||
mPath.lineTo(scale(PATH[3][0], width), scale(PATH[3][1], height));
|
||||
mPath.close();
|
||||
m = new Matrix();
|
||||
m.setRotate(mRotation, width / 2, height / 2);
|
||||
mPath.transform(m);
|
||||
canvas.drawPath(mPath, mPaint);
|
||||
m = new Matrix();
|
||||
m.setRotate(-mRotation, width / 2, height / 2);
|
||||
mPath.transform(m);
|
||||
|
||||
m = new Matrix();
|
||||
m.setTranslate(scale(OFFSET[0], width), scale(OFFSET[1], height));
|
||||
mPath.transform(m);
|
||||
mPath.moveTo(scale(PATH[0][0], width), scale(PATH[0][1], height));
|
||||
mPath.lineTo(scale(PATH[1][0], width), scale(PATH[1][1], height));
|
||||
mPath.lineTo(scale(PATH[2][0], width), scale(PATH[2][1], height));
|
||||
mPath.lineTo(scale(PATH[3][0], width), scale(PATH[3][1], height));
|
||||
mPath.close();
|
||||
m = new Matrix();
|
||||
m.setRotate(mRotation, width / 2, height / 2);
|
||||
mPath.transform(m);
|
||||
canvas.clipOutPath(mPath);
|
||||
}
|
||||
|
||||
mDrawable.draw(canvas);
|
||||
canvas.restore();
|
||||
}
|
||||
|
||||
private float scale(float frac, int width) {
|
||||
return frac * width;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTint(@ColorInt int tintColor) {
|
||||
super.setTint(tintColor);
|
||||
mDrawable.setTint(tintColor);
|
||||
mPaint.setColor(tintColor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTintList(@Nullable ColorStateList tint) {
|
||||
mTintList = tint;
|
||||
super.setTintList(tint);
|
||||
mDrawable.setTintList(tint);
|
||||
mPaint.setColor(tint.getDefaultColor());
|
||||
invalidateSelf();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTintMode(@NonNull Mode tintMode) {
|
||||
mTintMode = tintMode;
|
||||
super.setTintMode(tintMode);
|
||||
mDrawable.setTintMode(tintMode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAlpha(@IntRange(from = 0, to = 255) int alpha) {
|
||||
mDrawable.setAlpha(alpha);
|
||||
mPaint.setAlpha(alpha);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColorFilter(@Nullable ColorFilter colorFilter) {
|
||||
mDrawable.setColorFilter(colorFilter);
|
||||
mPaint.setColorFilter(colorFilter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOpacity() {
|
||||
return 255;
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,6 @@ import android.content.Context;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.Animatable;
|
||||
import android.graphics.drawable.Animatable2;
|
||||
import android.graphics.drawable.Animatable2.AnimationCallback;
|
||||
import android.graphics.drawable.Drawable;
|
||||
@@ -85,7 +84,8 @@ public class QSIconViewImpl extends QSIconView {
|
||||
}
|
||||
|
||||
protected void updateIcon(ImageView iv, State state) {
|
||||
if (!Objects.equals(state.icon, iv.getTag(R.id.qs_icon_tag))) {
|
||||
if (!Objects.equals(state.icon, iv.getTag(R.id.qs_icon_tag))
|
||||
|| !Objects.equals(state.slash, iv.getTag(R.id.qs_slash_tag))) {
|
||||
boolean shouldAnimate = iv.isShown() && mAnimationEnabled
|
||||
&& iv.getDrawable() != null;
|
||||
Drawable d = state.icon != null
|
||||
@@ -96,7 +96,11 @@ public class QSIconViewImpl extends QSIconView {
|
||||
d.setAutoMirrored(false);
|
||||
}
|
||||
iv.setImageDrawable(d);
|
||||
if (state.slash != null && iv instanceof SlashImageView) {
|
||||
((SlashImageView) iv).setState(state.slash);
|
||||
}
|
||||
iv.setTag(R.id.qs_icon_tag, state.icon);
|
||||
iv.setTag(R.id.qs_slash_tag, state.slash);
|
||||
iv.setPadding(0, padding, 0, padding);
|
||||
if (d instanceof Animatable2) {
|
||||
Animatable2 a = (Animatable2) d;
|
||||
@@ -166,7 +170,7 @@ public class QSIconViewImpl extends QSIconView {
|
||||
}
|
||||
|
||||
protected View createIcon() {
|
||||
final ImageView icon = new ImageView(mContext);
|
||||
final ImageView icon = new SlashImageView(mContext);
|
||||
icon.setId(android.R.id.icon);
|
||||
icon.setScaleType(ScaleType.FIT_CENTER);
|
||||
return icon;
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (C) 2017 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.tileimpl;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.android.systemui.plugins.qs.QSTile.SlashState;
|
||||
import com.android.systemui.qs.SlashDrawable;
|
||||
|
||||
public class SlashImageView extends ImageView {
|
||||
|
||||
private SlashDrawable mSlash;
|
||||
|
||||
public SlashImageView(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
private void ensureSlashDrawable() {
|
||||
if (mSlash == null) {
|
||||
mSlash = new SlashDrawable(getDrawable());
|
||||
super.setImageDrawable(mSlash);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setImageDrawable(Drawable drawable) {
|
||||
if (mSlash != null) {
|
||||
mSlash.setDrawable(drawable);
|
||||
} else {
|
||||
super.setImageDrawable(drawable);
|
||||
}
|
||||
}
|
||||
|
||||
public void setState(SlashState slashState) {
|
||||
ensureSlashDrawable();
|
||||
mSlash.setRotation(slashState.rotation);
|
||||
mSlash.setSlashed(slashState.isSlashed);
|
||||
}
|
||||
}
|
||||
@@ -29,19 +29,15 @@ import android.widget.Switch;
|
||||
import com.android.internal.logging.MetricsLogger;
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.plugins.qs.QSTile.BooleanState;
|
||||
import com.android.systemui.qs.GlobalSetting;
|
||||
import com.android.systemui.qs.QSHost;
|
||||
import com.android.systemui.plugins.qs.QSTile.BooleanState;
|
||||
import com.android.systemui.qs.tileimpl.QSTileImpl;
|
||||
|
||||
/** Quick settings tile: Airplane mode **/
|
||||
public class AirplaneModeTile extends QSTileImpl<BooleanState> {
|
||||
private final AnimationIcon mEnable =
|
||||
new AnimationIcon(R.drawable.ic_signal_airplane_enable_animation,
|
||||
R.drawable.ic_signal_airplane_disable);
|
||||
private final AnimationIcon mDisable =
|
||||
new AnimationIcon(R.drawable.ic_signal_airplane_disable_animation,
|
||||
R.drawable.ic_signal_airplane_enable);
|
||||
private final Icon mIcon =
|
||||
ResourceIcon.get(R.drawable.ic_signal_airplane_disable);
|
||||
private final GlobalSetting mSetting;
|
||||
|
||||
private boolean mListening;
|
||||
@@ -90,11 +86,11 @@ public class AirplaneModeTile extends QSTileImpl<BooleanState> {
|
||||
final boolean airplaneMode = value != 0;
|
||||
state.value = airplaneMode;
|
||||
state.label = mContext.getString(R.string.airplane_mode);
|
||||
if (airplaneMode) {
|
||||
state.icon = mEnable;
|
||||
} else {
|
||||
state.icon = mDisable;
|
||||
state.icon = mIcon;
|
||||
if (state.slash == null) {
|
||||
state.slash = new SlashState();
|
||||
}
|
||||
state.slash.isSlashed = !airplaneMode;
|
||||
state.state = airplaneMode ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE;
|
||||
state.contentDescription = state.label;
|
||||
state.expandedAccessibilityClassName = Switch.class.getName();
|
||||
|
||||
@@ -114,6 +114,10 @@ public class BluetoothTile extends QSTileImpl<BooleanState> {
|
||||
|| mController.getBluetoothState() == BluetoothAdapter.STATE_TURNING_ON;
|
||||
state.dualTarget = true;
|
||||
state.value = enabled;
|
||||
if (state.slash == null) {
|
||||
state.slash = new SlashState();
|
||||
}
|
||||
state.slash.isSlashed = !enabled;
|
||||
if (enabled) {
|
||||
state.label = null;
|
||||
if (connected) {
|
||||
@@ -137,7 +141,7 @@ public class BluetoothTile extends QSTileImpl<BooleanState> {
|
||||
}
|
||||
state.state = Tile.STATE_ACTIVE;
|
||||
} else {
|
||||
state.icon = ResourceIcon.get(R.drawable.ic_qs_bluetooth_off);
|
||||
state.icon = ResourceIcon.get(R.drawable.ic_qs_bluetooth_on);
|
||||
state.label = mContext.getString(R.string.quick_settings_bluetooth_label);
|
||||
state.contentDescription = mContext.getString(
|
||||
R.string.accessibility_quick_settings_bluetooth_off);
|
||||
|
||||
@@ -127,13 +127,16 @@ public class CellularTile extends QSTileImpl<SignalState> {
|
||||
state.expandedAccessibilityClassName = Switch.class.getName();
|
||||
state.value = mDataController.isMobileDataSupported()
|
||||
&& mDataController.isMobileDataEnabled();
|
||||
state.icon = ResourceIcon.get(R.drawable.ic_data_unavailable);
|
||||
state.state = cb.airplaneModeEnabled || !cb.enabled ? Tile.STATE_UNAVAILABLE
|
||||
: state.value ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE;
|
||||
if (state.slash == null) {
|
||||
state.slash = new SlashState();
|
||||
}
|
||||
state.slash.isSlashed = (state.state == Tile.STATE_INACTIVE);
|
||||
if (state.state == Tile.STATE_ACTIVE) {
|
||||
state.icon = ResourceIcon.get(R.drawable.ic_data_on);
|
||||
} else if (state.state == Tile.STATE_INACTIVE) {
|
||||
state.icon = ResourceIcon.get(R.drawable.ic_data_off);
|
||||
state.icon = ResourceIcon.get(R.drawable.ic_data_on);
|
||||
} else {
|
||||
state.icon = ResourceIcon.get(R.drawable.ic_data_unavailable);
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import android.widget.Switch;
|
||||
import com.android.internal.logging.MetricsLogger;
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.R.drawable;
|
||||
import com.android.systemui.qs.QSHost;
|
||||
import com.android.systemui.plugins.qs.QSTile.BooleanState;
|
||||
import com.android.systemui.qs.tileimpl.QSTileImpl;
|
||||
@@ -33,12 +34,7 @@ import com.android.systemui.qs.SecureSetting;
|
||||
/** Quick settings tile: Invert colors **/
|
||||
public class ColorInversionTile extends QSTileImpl<BooleanState> {
|
||||
|
||||
private final AnimationIcon mEnable
|
||||
= new AnimationIcon(R.drawable.ic_invert_colors_enable_animation,
|
||||
R.drawable.ic_invert_colors_disable);
|
||||
private final AnimationIcon mDisable
|
||||
= new AnimationIcon(R.drawable.ic_invert_colors_disable_animation,
|
||||
R.drawable.ic_invert_colors_enable);
|
||||
private final Icon mIcon = ResourceIcon.get(drawable.ic_invert_colors_disable);
|
||||
private final SecureSetting mSetting;
|
||||
|
||||
private boolean mListening;
|
||||
@@ -96,10 +92,14 @@ public class ColorInversionTile extends QSTileImpl<BooleanState> {
|
||||
protected void handleUpdateState(BooleanState state, Object arg) {
|
||||
final int value = arg instanceof Integer ? (Integer) arg : mSetting.getValue();
|
||||
final boolean enabled = value != 0;
|
||||
if (state.slash == null) {
|
||||
state.slash = new SlashState();
|
||||
}
|
||||
state.value = enabled;
|
||||
state.slash.isSlashed = !state.value;
|
||||
state.state = state.value ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE;
|
||||
state.label = mContext.getString(R.string.quick_settings_inversion_label);
|
||||
state.icon = enabled ? mEnable : mDisable;
|
||||
state.icon = mIcon;
|
||||
state.expandedAccessibilityClassName = Switch.class.getName();
|
||||
state.contentDescription = state.label;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ import android.content.SharedPreferences;
|
||||
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
import android.os.UserManager;
|
||||
import android.provider.Settings;
|
||||
import android.provider.Settings.Global;
|
||||
@@ -72,12 +71,7 @@ public class DndTile extends QSTileImpl<BooleanState> {
|
||||
private static final QSTile.Icon TOTAL_SILENCE =
|
||||
ResourceIcon.get(R.drawable.ic_qs_dnd_on_total_silence);
|
||||
|
||||
private final AnimationIcon mDisable =
|
||||
new AnimationIcon(R.drawable.ic_dnd_disable_animation,
|
||||
R.drawable.ic_qs_dnd_off);
|
||||
private final AnimationIcon mDisableTotalSilence =
|
||||
new AnimationIcon(R.drawable.ic_dnd_total_silence_disable_animation,
|
||||
R.drawable.ic_qs_dnd_off);
|
||||
private final Icon mDisable = ResourceIcon.get(R.drawable.ic_qs_dnd_off);
|
||||
|
||||
private final ZenModeController mController;
|
||||
private final DndDetailAdapter mDetailAdapter;
|
||||
@@ -167,9 +161,11 @@ public class DndTile extends QSTileImpl<BooleanState> {
|
||||
final int zen = arg instanceof Integer ? (Integer) arg : mController.getZen();
|
||||
final boolean newValue = zen != ZEN_MODE_OFF;
|
||||
final boolean valueChanged = state.value != newValue;
|
||||
if (state.slash == null) state.slash = new SlashState();
|
||||
state.dualTarget = true;
|
||||
state.value = newValue;
|
||||
state.state = state.value ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE;
|
||||
state.slash.isSlashed = !state.value;
|
||||
checkIfRestrictionEnforcedByAdminOnly(state, UserManager.DISALLOW_ADJUST_VOLUME);
|
||||
switch (zen) {
|
||||
case Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS:
|
||||
@@ -191,7 +187,7 @@ public class DndTile extends QSTileImpl<BooleanState> {
|
||||
R.string.accessibility_quick_settings_dnd_alarms_on);
|
||||
break;
|
||||
default:
|
||||
state.icon = TOTAL_SILENCE.equals(state.icon) ? mDisableTotalSilence : mDisable;
|
||||
state.icon = mDisable;
|
||||
state.label = mContext.getString(R.string.quick_settings_dnd_label);
|
||||
state.contentDescription = mContext.getString(
|
||||
R.string.accessibility_quick_settings_dnd);
|
||||
|
||||
@@ -23,12 +23,11 @@ import android.provider.MediaStore;
|
||||
import android.service.quicksettings.Tile;
|
||||
import android.widget.Switch;
|
||||
|
||||
import com.android.internal.logging.MetricsLogger;
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.systemui.Dependency;
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.qs.QSHost;
|
||||
import com.android.systemui.plugins.qs.QSTile.BooleanState;
|
||||
import com.android.systemui.qs.QSHost;
|
||||
import com.android.systemui.qs.tileimpl.QSTileImpl;
|
||||
import com.android.systemui.statusbar.policy.FlashlightController;
|
||||
|
||||
@@ -36,12 +35,7 @@ import com.android.systemui.statusbar.policy.FlashlightController;
|
||||
public class FlashlightTile extends QSTileImpl<BooleanState> implements
|
||||
FlashlightController.FlashlightListener {
|
||||
|
||||
private final AnimationIcon mEnable
|
||||
= new AnimationIcon(R.drawable.ic_signal_flashlight_enable_animation,
|
||||
R.drawable.ic_signal_flashlight_disable);
|
||||
private final AnimationIcon mDisable
|
||||
= new AnimationIcon(R.drawable.ic_signal_flashlight_disable_animation,
|
||||
R.drawable.ic_signal_flashlight_enable);
|
||||
private final Icon mIcon = ResourceIcon.get(R.drawable.ic_signal_flashlight_disable);
|
||||
private final FlashlightController mFlashlightController;
|
||||
|
||||
public FlashlightTile(QSHost host) {
|
||||
@@ -104,6 +98,9 @@ public class FlashlightTile extends QSTileImpl<BooleanState> implements
|
||||
|
||||
@Override
|
||||
protected void handleUpdateState(BooleanState state, Object arg) {
|
||||
if (state.slash == null) {
|
||||
state.slash = new SlashState();
|
||||
}
|
||||
state.label = mHost.getContext().getString(R.string.quick_settings_flashlight_label);
|
||||
if (!mFlashlightController.isAvailable()) {
|
||||
Drawable icon = mHost.getContext().getDrawable(R.drawable.ic_signal_flashlight_enable)
|
||||
@@ -123,8 +120,8 @@ public class FlashlightTile extends QSTileImpl<BooleanState> implements
|
||||
} else {
|
||||
state.value = mFlashlightController.isEnabled();
|
||||
}
|
||||
final AnimationIcon icon = state.value ? mEnable : mDisable;
|
||||
state.icon = icon;
|
||||
state.icon = mIcon;
|
||||
state.slash.isSlashed = !state.value;
|
||||
state.contentDescription = mContext.getString(R.string.quick_settings_flashlight_label);
|
||||
state.expandedAccessibilityClassName = Switch.class.getName();
|
||||
state.state = state.value ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE;
|
||||
|
||||
@@ -39,14 +39,7 @@ public class HotspotTile extends QSTileImpl<AirplaneBooleanState> {
|
||||
static final Intent TETHER_SETTINGS = new Intent().setComponent(new ComponentName(
|
||||
"com.android.settings", "com.android.settings.TetherSettings"));
|
||||
|
||||
private final AnimationIcon mEnable =
|
||||
new AnimationIcon(R.drawable.ic_hotspot_enable_animation,
|
||||
R.drawable.ic_hotspot_disable);
|
||||
private final Icon mEnabledStatic = ResourceIcon.get(R.drawable.ic_hotspot_disable);
|
||||
private final AnimationIcon mDisable =
|
||||
new AnimationIcon(R.drawable.ic_hotspot_disable_animation,
|
||||
R.drawable.ic_hotspot_enable);
|
||||
private final Icon mDisableNoAnimation = ResourceIcon.get(R.drawable.ic_hotspot_enable);
|
||||
private final Icon mUnavailable = ResourceIcon.get(R.drawable.ic_hotspot_unavailable);
|
||||
|
||||
private final HotspotController mController;
|
||||
@@ -116,6 +109,9 @@ public class HotspotTile extends QSTileImpl<AirplaneBooleanState> {
|
||||
|
||||
@Override
|
||||
protected void handleUpdateState(AirplaneBooleanState state, Object arg) {
|
||||
if (state.slash == null) {
|
||||
state.slash = new SlashState();
|
||||
}
|
||||
state.label = mContext.getString(R.string.quick_settings_hotspot_label);
|
||||
|
||||
checkIfRestrictionEnforcedByAdminOnly(state, UserManager.DISALLOW_CONFIG_TETHERING);
|
||||
@@ -124,18 +120,12 @@ public class HotspotTile extends QSTileImpl<AirplaneBooleanState> {
|
||||
} else {
|
||||
state.value = mController.isHotspotEnabled();
|
||||
}
|
||||
state.icon = !state.value ? mDisable
|
||||
: state.isTransient ? mEnabledStatic
|
||||
: mEnable;
|
||||
boolean wasAirplane = state.isAirplaneMode;
|
||||
state.icon = mEnabledStatic;
|
||||
state.isAirplaneMode = mAirplaneMode.getValue() != 0;
|
||||
state.isTransient = mController.isHotspotTransient();
|
||||
state.slash.isSlashed = !state.value && !state.isTransient;
|
||||
if (state.isTransient) {
|
||||
state.icon = ResourceIcon.get(R.drawable.ic_hotspot_transient_animation);
|
||||
} else if (state.isAirplaneMode) {
|
||||
state.icon = mUnavailable;
|
||||
} else if (wasAirplane) {
|
||||
state.icon = mDisableNoAnimation;
|
||||
}
|
||||
state.expandedAccessibilityClassName = Switch.class.getName();
|
||||
state.contentDescription = state.label;
|
||||
|
||||
@@ -25,6 +25,7 @@ import android.widget.Switch;
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.systemui.Dependency;
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.R.drawable;
|
||||
import com.android.systemui.plugins.ActivityStarter;
|
||||
import com.android.systemui.qs.QSHost;
|
||||
import com.android.systemui.plugins.qs.QSTile.BooleanState;
|
||||
@@ -36,12 +37,7 @@ import com.android.systemui.statusbar.policy.LocationController.LocationChangeCa
|
||||
/** Quick settings tile: Location **/
|
||||
public class LocationTile extends QSTileImpl<BooleanState> {
|
||||
|
||||
private final AnimationIcon mEnable =
|
||||
new AnimationIcon(R.drawable.ic_signal_location_enable_animation,
|
||||
R.drawable.ic_signal_location_disable);
|
||||
private final AnimationIcon mDisable =
|
||||
new AnimationIcon(R.drawable.ic_signal_location_disable_animation,
|
||||
R.drawable.ic_signal_location_enable);
|
||||
private final Icon mIcon = ResourceIcon.get(drawable.ic_signal_location_disable);
|
||||
|
||||
private final LocationController mController;
|
||||
private final KeyguardMonitor mKeyguard;
|
||||
@@ -95,6 +91,9 @@ public class LocationTile extends QSTileImpl<BooleanState> {
|
||||
|
||||
@Override
|
||||
protected void handleUpdateState(BooleanState state, Object arg) {
|
||||
if (state.slash == null) {
|
||||
state.slash = new SlashState();
|
||||
}
|
||||
final boolean locationEnabled = mController.isLocationEnabled();
|
||||
|
||||
// Work around for bug 15916487: don't show location tile on top of lock screen. After the
|
||||
@@ -102,13 +101,13 @@ public class LocationTile extends QSTileImpl<BooleanState> {
|
||||
// state.visible = !(mKeyguard.isSecure() && mKeyguard.isShowing());
|
||||
state.value = locationEnabled;
|
||||
checkIfRestrictionEnforcedByAdminOnly(state, UserManager.DISALLOW_SHARE_LOCATION);
|
||||
state.icon = mIcon;
|
||||
state.slash.isSlashed = !state.value;
|
||||
if (locationEnabled) {
|
||||
state.icon = mEnable;
|
||||
state.label = mContext.getString(R.string.quick_settings_location_label);
|
||||
state.contentDescription = mContext.getString(
|
||||
R.string.accessibility_quick_settings_location_on);
|
||||
} else {
|
||||
state.icon = mDisable;
|
||||
state.label = mContext.getString(R.string.quick_settings_location_label);
|
||||
state.contentDescription = mContext.getString(
|
||||
R.string.accessibility_quick_settings_location_off);
|
||||
|
||||
@@ -150,6 +150,12 @@ public class WifiTile extends QSTileImpl<SignalState> {
|
||||
mDetailAdapter.setItemsVisible(cb.enabled);
|
||||
fireToggleStateChanged(cb.enabled);
|
||||
}
|
||||
if (state.slash == null) {
|
||||
state.slash = new SlashState();
|
||||
state.slash.rotation = 8;
|
||||
}
|
||||
state.slash.isSlashed = false;
|
||||
state.state = Tile.STATE_ACTIVE;
|
||||
state.dualTarget = true;
|
||||
state.value = cb.enabled;
|
||||
state.activityIn = cb.enabled && cb.activityIn;
|
||||
@@ -160,6 +166,8 @@ public class WifiTile extends QSTileImpl<SignalState> {
|
||||
state.icon = ResourceIcon.get(R.drawable.ic_signal_wifi_transient_animation);
|
||||
state.label = r.getString(R.string.quick_settings_wifi_label);
|
||||
} else if (!state.value) {
|
||||
state.slash.isSlashed = true;
|
||||
state.state = Tile.STATE_INACTIVE;
|
||||
state.icon = ResourceIcon.get(R.drawable.ic_qs_wifi_disabled);
|
||||
state.label = r.getString(R.string.quick_settings_wifi_label);
|
||||
} else if (wifiConnected) {
|
||||
@@ -184,7 +192,6 @@ public class WifiTile extends QSTileImpl<SignalState> {
|
||||
state.dualLabelContentDescription = r.getString(
|
||||
R.string.accessibility_quick_settings_open_settings, getTileLabel());
|
||||
state.expandedAccessibilityClassName = Switch.class.getName();
|
||||
state.state = Tile.STATE_ACTIVE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user