diff options
42 files changed, 70 insertions, 1154 deletions
diff --git a/packages/SystemUI/plugin/src/com/android/systemui/plugins/qs/QSFactory.java b/packages/SystemUI/plugin/src/com/android/systemui/plugins/qs/QSFactory.java index cfe3be0acc00..3ac6422c0372 100644 --- a/packages/SystemUI/plugin/src/com/android/systemui/plugins/qs/QSFactory.java +++ b/packages/SystemUI/plugin/src/com/android/systemui/plugins/qs/QSFactory.java @@ -14,8 +14,6 @@ package com.android.systemui.plugins.qs; -import android.content.Context; - import com.android.systemui.plugins.Plugin; import com.android.systemui.plugins.annotations.DependsOn; import com.android.systemui.plugins.annotations.ProvidesInterface; @@ -30,18 +28,7 @@ import com.android.systemui.plugins.annotations.ProvidesInterface; public interface QSFactory extends Plugin { String ACTION = "com.android.systemui.action.PLUGIN_QS_FACTORY"; - int VERSION = 2; + int VERSION = 3; QSTile createTile(String tileSpec); - - /** - * Create a view for a tile. - * - * @param context a themed context for inflating the view - * @param tile the tile for which the view is created - * @param collapsedView {@code true} if the view will live in QQS and {@code false} otherwise. - * @return a view for the tile - */ - QSTileView createTileView(Context context, QSTile tile, boolean collapsedView); - } diff --git a/packages/SystemUI/plugin/src/com/android/systemui/plugins/qs/QSTile.java b/packages/SystemUI/plugin/src/com/android/systemui/plugins/qs/QSTile.java index 25f77ea4e6d5..06e9b10f6e7f 100644 --- a/packages/SystemUI/plugin/src/com/android/systemui/plugins/qs/QSTile.java +++ b/packages/SystemUI/plugin/src/com/android/systemui/plugins/qs/QSTile.java @@ -55,8 +55,6 @@ public interface QSTile { void removeCallback(Callback callback); void removeCallbacks(); - QSIconView createTileView(Context context); - /** * The tile was clicked. * @@ -170,7 +168,6 @@ public interface QSTile { public boolean dualTarget = false; public boolean isTransient = false; public String expandedAccessibilityClassName; - public SlashState slash; public boolean handlesLongClick = true; @Nullable public Drawable sideViewCustomDrawable; @@ -214,7 +211,6 @@ public interface QSTile { || !Objects.equals(other.state, state) || !Objects.equals(other.isTransient, isTransient) || !Objects.equals(other.dualTarget, dualTarget) - || !Objects.equals(other.slash, slash) || !Objects.equals(other.handlesLongClick, handlesLongClick) || !Objects.equals(other.sideViewCustomDrawable, sideViewCustomDrawable); other.spec = spec; @@ -230,7 +226,6 @@ public interface QSTile { other.state = state; other.dualTarget = dualTarget; other.isTransient = isTransient; - other.slash = slash != null ? slash.copy() : null; other.handlesLongClick = handlesLongClick; other.sideViewCustomDrawable = sideViewCustomDrawable; return changed; @@ -258,7 +253,6 @@ public interface QSTile { sb.append(",dualTarget=").append(dualTarget); sb.append(",isTransient=").append(isTransient); sb.append(",state=").append(state); - sb.append(",slash=\"").append(slash).append("\""); sb.append(",sideViewCustomDrawable=").append(sideViewCustomDrawable); return sb.append(']'); } @@ -302,73 +296,4 @@ public interface QSTile { return state; } } - - @ProvidesInterface(version = SignalState.VERSION) - public static final class SignalState extends BooleanState { - public static final int VERSION = 1; - public boolean activityIn; - public boolean activityOut; - public boolean isOverlayIconWide; - public int overlayIconId; - - @Override - public boolean copyTo(State other) { - final SignalState o = (SignalState) other; - final boolean changed = o.activityIn != activityIn - || o.activityOut != activityOut - || o.isOverlayIconWide != isOverlayIconWide - || o.overlayIconId != overlayIconId; - o.activityIn = activityIn; - o.activityOut = activityOut; - o.isOverlayIconWide = isOverlayIconWide; - o.overlayIconId = overlayIconId; - return super.copyTo(other) || changed; - } - - @Override - protected StringBuilder toStringBuilder() { - final StringBuilder rt = super.toStringBuilder(); - rt.insert(rt.length() - 1, ",activityIn=" + activityIn); - rt.insert(rt.length() - 1, ",activityOut=" + activityOut); - return rt; - } - - @Override - public State copy() { - SignalState state = new SignalState(); - copyTo(state); - return state; - } - } - - @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; - } - } } diff --git a/packages/SystemUI/res/drawable/ic_qs_signal_in.xml b/packages/SystemUI/res/drawable/ic_qs_signal_in.xml deleted file mode 100644 index 56223dbdb7c4..000000000000 --- a/packages/SystemUI/res/drawable/ic_qs_signal_in.xml +++ /dev/null @@ -1,25 +0,0 @@ -<!-- -Copyright (C) 2014 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. ---> -<vector xmlns:android="http://schemas.android.com/apk/res/android" - android:width="6.0dp" - android:height="32dp" - android:viewportWidth="6.0" - android:viewportHeight="24.0" - android:tint="?android:attr/colorAccent"> - <path - android:fillColor="#FFFFFFFF" - android:pathData="M6.000000,15.700000l-3.000000,5.599999 -3.000000,-5.599999z"/> -</vector> diff --git a/packages/SystemUI/res/drawable/ic_qs_signal_out.xml b/packages/SystemUI/res/drawable/ic_qs_signal_out.xml deleted file mode 100644 index 12c1a7a89e32..000000000000 --- a/packages/SystemUI/res/drawable/ic_qs_signal_out.xml +++ /dev/null @@ -1,25 +0,0 @@ -<!-- -Copyright (C) 2014 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. ---> -<vector xmlns:android="http://schemas.android.com/apk/res/android" - android:width="6.0dp" - android:height="32dp" - android:viewportWidth="6.0" - android:viewportHeight="24.0" - android:tint="?android:attr/colorAccent"> - <path - android:fillColor="#FFFFFFFF" - android:pathData="M0.000000,13.700000l3.000000,-5.700000 3.000000,5.700000z"/> -</vector> diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml index ae3138ef0c52..7e9d3f59369b 100644 --- a/packages/SystemUI/res/values/dimens.xml +++ b/packages/SystemUI/res/values/dimens.xml @@ -873,12 +873,6 @@ is displayed in the upper left corner. --> <dimen name="roaming_icon_start_padding">2sp</dimen> - <!-- Extra padding between the mobile data type icon and the strength indicator when the data - type icon is wide for the tile in quick settings. --> - <dimen name="wide_type_icon_start_padding_qs">3dp</dimen> - - <dimen name="signal_indicator_to_icon_frame_spacing">3dp</dimen> - <!-- Starting margin before the signal cluster --> <!-- Padding between signal cluster and battery icon --> diff --git a/packages/SystemUI/res/values/ids.xml b/packages/SystemUI/res/values/ids.xml index bd251bd78c38..21696fefb80f 100644 --- a/packages/SystemUI/res/values/ids.xml +++ b/packages/SystemUI/res/values/ids.xml @@ -50,7 +50,6 @@ <item type="id" name="x_animator_tag_start_value"/> <item type="id" name="y_animator_tag_start_value"/> <item type="id" name="qs_icon_tag"/> - <item type="id" name="qs_slash_tag"/> <item type="id" name="scrim"/> <item type="id" name="scrim_alpha_start"/> <item type="id" name="scrim_alpha_end"/> diff --git a/packages/SystemUI/src/com/android/systemui/qs/AlphaControlledSignalTileView.java b/packages/SystemUI/src/com/android/systemui/qs/AlphaControlledSignalTileView.java deleted file mode 100644 index e473dd22a09a..000000000000 --- a/packages/SystemUI/src/com/android/systemui/qs/AlphaControlledSignalTileView.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * 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.Nullable; -import android.content.Context; -import android.content.res.ColorStateList; -import android.graphics.drawable.Drawable; - -import com.android.systemui.qs.tileimpl.SlashImageView; - - -/** - * Creates AlphaControlledSlashImageView instead of SlashImageView - */ -public class AlphaControlledSignalTileView extends SignalTileView { - public AlphaControlledSignalTileView(Context context) { - super(context); - } - - @Override - protected SlashImageView createSlashImageView(Context context) { - return new AlphaControlledSlashImageView(context); - } - - /** - * Creates AlphaControlledSlashDrawable instead of regular SlashDrawables - */ - public static class AlphaControlledSlashImageView extends SlashImageView { - public AlphaControlledSlashImageView(Context context) { - super(context); - } - - public void setFinalImageTintList(ColorStateList tint) { - super.setImageTintList(tint); - final SlashDrawable slash = getSlash(); - if (slash != null) { - ((AlphaControlledSlashDrawable)slash).setFinalTintList(tint); - } - } - - @Override - protected void ensureSlashDrawable() { - if (getSlash() == null) { - final SlashDrawable slash = new AlphaControlledSlashDrawable(getDrawable()); - setSlash(slash); - slash.setAnimationEnabled(getAnimationEnabled()); - setImageViewDrawable(slash); - } - } - } - - /** - * SlashDrawable that disobeys orders to change its drawable's tint except when you tell - * it not to disobey. The slash still will animate its alpha. - */ - public static class AlphaControlledSlashDrawable extends SlashDrawable { - AlphaControlledSlashDrawable(Drawable d) { - super(d); - } - - @Override - protected void setDrawableTintList(@Nullable ColorStateList tint) { - } - - /** - * Set a target tint list instead of - */ - public void setFinalTintList(ColorStateList tint) { - super.setDrawableTintList(tint); - } - } -} - diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSHost.java b/packages/SystemUI/src/com/android/systemui/qs/QSHost.java index 856c64a52290..4e914a592304 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSHost.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QSHost.java @@ -21,9 +21,7 @@ import android.os.Build; import android.provider.Settings; import com.android.systemui.R; -import com.android.systemui.plugins.qs.QSFactory; import com.android.systemui.plugins.qs.QSTile; -import com.android.systemui.plugins.qs.QSTileView; import com.android.systemui.util.leak.GarbageMonitor; import java.util.ArrayList; @@ -63,12 +61,7 @@ public interface QSHost { void removeTiles(Collection<String> specs); List<String> getSpecs(); - /** - * Create a view for a tile, iterating over all possible {@link QSFactory}. - * - * @see QSFactory#createTileView - */ - QSTileView createTileView(Context themedContext, QSTile tile, boolean collapsedView); + /** Create a {@link QSTile} of a {@code tileSpec} type. * * This should only be called by classes that need to create one-off instances of tiles. diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSHostAdapter.kt b/packages/SystemUI/src/com/android/systemui/qs/QSHostAdapter.kt index cb87e3cc142a..2a36fdb21e18 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSHostAdapter.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/QSHostAdapter.kt @@ -23,7 +23,6 @@ import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Application import com.android.systemui.dump.DumpManager import com.android.systemui.plugins.qs.QSTile -import com.android.systemui.plugins.qs.QSTileView import com.android.systemui.qs.external.TileServiceRequestController import com.android.systemui.qs.pipeline.data.repository.TileSpecRepository.Companion.POSITION_AT_END import com.android.systemui.qs.pipeline.domain.interactor.CurrentTilesInteractor @@ -176,14 +175,6 @@ constructor( } } - override fun createTileView( - themedContext: Context?, - tile: QSTile?, - collapsedView: Boolean - ): QSTileView { - return qsTileHost.createTileView(themedContext, tile, collapsedView) - } - override fun createTile(tileSpec: String): QSTile? { return qsTileHost.createTile(tileSpec) } diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSPanelControllerBase.java b/packages/SystemUI/src/com/android/systemui/qs/QSPanelControllerBase.java index 81e3a2f68bfd..ef8167420f13 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSPanelControllerBase.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QSPanelControllerBase.java @@ -44,6 +44,9 @@ import com.android.systemui.statusbar.policy.SplitShadeStateController; import com.android.systemui.util.ViewController; import com.android.systemui.util.animation.DisappearParameters; +import kotlin.Unit; +import kotlin.jvm.functions.Function1; + import java.io.PrintWriter; import java.util.ArrayList; import java.util.Collection; @@ -53,9 +56,6 @@ import java.util.stream.Collectors; import javax.inject.Named; -import kotlin.Unit; -import kotlin.jvm.functions.Function1; - /** * Controller for QSPanel views. * @@ -250,8 +250,8 @@ public abstract class QSPanelControllerBase<T extends QSPanel> extends ViewContr } private void addTile(final QSTile tile, boolean collapsedView) { - final TileRecord r = - new TileRecord(tile, mHost.createTileView(getContext(), tile, collapsedView)); + final QSTileViewImpl tileView = new QSTileViewImpl(getContext(), collapsedView); + final TileRecord r = new TileRecord(tile, tileView); // TODO(b/250618218): Remove the QSLogger in QSTileViewImpl once we know the root cause of // b/250618218. try { @@ -490,7 +490,6 @@ public abstract class QSPanelControllerBase<T extends QSPanel> extends ViewContr public QSTile tile; public com.android.systemui.plugins.qs.QSTileView tileView; - public boolean scanState; @Nullable public QSTile.Callback callback; } diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSTileHost.java b/packages/SystemUI/src/com/android/systemui/qs/QSTileHost.java index e57db562b27a..4c292e70c111 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSTileHost.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QSTileHost.java @@ -39,7 +39,6 @@ import com.android.systemui.plugins.PluginListener; import com.android.systemui.plugins.PluginManager; import com.android.systemui.plugins.qs.QSFactory; import com.android.systemui.plugins.qs.QSTile; -import com.android.systemui.plugins.qs.QSTileView; import com.android.systemui.qs.external.CustomTile; import com.android.systemui.qs.external.CustomTileStatePersister; import com.android.systemui.qs.external.TileLifecycleManager; @@ -513,18 +512,6 @@ public class QSTileHost implements QSHost, Tunable, PluginListener<QSFactory>, P return null; } - @Override - public QSTileView createTileView(Context themedContext, QSTile tile, boolean collapsedView) { - for (int i = 0; i < mQsFactories.size(); i++) { - QSTileView view = mQsFactories.get(i) - .createTileView(themedContext, tile, collapsedView); - if (view != null) { - return view; - } - } - throw new RuntimeException("Default factory didn't create view for " + tile.getTileSpec()); - } - /** * Check if a particular {@link CustomTile} has been added for a user and has not been removed * since. diff --git a/packages/SystemUI/src/com/android/systemui/qs/QuickQSPanel.java b/packages/SystemUI/src/com/android/systemui/qs/QuickQSPanel.java index d8899796b336..150137910f91 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QuickQSPanel.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QuickQSPanel.java @@ -27,8 +27,6 @@ import com.android.internal.logging.UiEventLogger; import com.android.systemui.FontSizeUtils; import com.android.systemui.R; import com.android.systemui.plugins.qs.QSTile; -import com.android.systemui.plugins.qs.QSTile.SignalState; -import com.android.systemui.plugins.qs.QSTile.State; /** * Version of QSPanel that only shows N Quick Tiles in the QS Header. @@ -91,19 +89,6 @@ public class QuickQSPanel extends QSPanel { return !mExpanded; } - @Override - protected void drawTile(QSPanelControllerBase.TileRecord r, State state) { - if (state instanceof SignalState) { - SignalState copy = new SignalState(); - state.copyTo(copy); - // No activity shown in the quick panel. - copy.activityIn = false; - copy.activityOut = false; - state = copy; - } - super.drawTile(r, state); - } - public void setMaxTiles(int maxTiles) { mMaxTiles = maxTiles; } diff --git a/packages/SystemUI/src/com/android/systemui/qs/SignalTileView.java b/packages/SystemUI/src/com/android/systemui/qs/SignalTileView.java deleted file mode 100644 index b609df5e77fe..000000000000 --- a/packages/SystemUI/src/com/android/systemui/qs/SignalTileView.java +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Copyright (C) 2014 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.animation.ValueAnimator; -import android.content.Context; -import android.view.View; -import android.widget.FrameLayout; -import android.widget.ImageView; - -import com.android.systemui.R; -import com.android.systemui.plugins.qs.QSTile.SignalState; -import com.android.systemui.plugins.qs.QSTile.State; -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 { - private static final long DEFAULT_DURATION = new ValueAnimator().getDuration(); - private static final long SHORT_DURATION = DEFAULT_DURATION / 3; - - protected FrameLayout mIconFrame; - protected ImageView mSignal; - private ImageView mOverlay; - private ImageView mIn; - private ImageView mOut; - - private int mWideOverlayIconStartPadding; - private int mSignalIndicatorToIconFrameSpacing; - - public SignalTileView(Context context) { - super(context); - - mIn = addTrafficView(R.drawable.ic_qs_signal_in); - mOut = addTrafficView(R.drawable.ic_qs_signal_out); - - setClipChildren(false); - setClipToPadding(false); - - mWideOverlayIconStartPadding = context.getResources().getDimensionPixelSize( - R.dimen.wide_type_icon_start_padding_qs); - mSignalIndicatorToIconFrameSpacing = context.getResources().getDimensionPixelSize( - R.dimen.signal_indicator_to_icon_frame_spacing); - } - - private ImageView addTrafficView(int icon) { - final ImageView traffic = new ImageView(mContext); - traffic.setImageResource(icon); - traffic.setAlpha(0f); - addView(traffic); - return traffic; - } - - @Override - protected View createIcon() { - mIconFrame = new FrameLayout(mContext); - mSignal = createSlashImageView(mContext); - mIconFrame.addView(mSignal); - mOverlay = new ImageView(mContext); - mIconFrame.addView(mOverlay, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); - return mIconFrame; - } - - protected SlashImageView createSlashImageView(Context context) { - return new SlashImageView(context); - } - - @Override - protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - super.onMeasure(widthMeasureSpec, heightMeasureSpec); - int hs = MeasureSpec.makeMeasureSpec(mIconFrame.getMeasuredHeight(), MeasureSpec.EXACTLY); - int ws = MeasureSpec.makeMeasureSpec(mIconFrame.getMeasuredHeight(), MeasureSpec.AT_MOST); - mIn.measure(ws, hs); - mOut.measure(ws, hs); - } - - @Override - protected void onLayout(boolean changed, int l, int t, int r, int b) { - super.onLayout(changed, l, t, r, b); - layoutIndicator(mIn); - layoutIndicator(mOut); - } - - @Override - protected int getIconMeasureMode() { - return MeasureSpec.AT_MOST; - } - - private void layoutIndicator(View indicator) { - boolean isRtl = getLayoutDirection() == LAYOUT_DIRECTION_RTL; - int left, right; - if (isRtl) { - right = getLeft() - mSignalIndicatorToIconFrameSpacing; - left = right - indicator.getMeasuredWidth(); - } else { - left = getRight() + mSignalIndicatorToIconFrameSpacing; - right = left + indicator.getMeasuredWidth(); - } - indicator.layout( - left, - mIconFrame.getBottom() - indicator.getMeasuredHeight(), - right, - mIconFrame.getBottom()); - } - - @Override - public void setIcon(State state, boolean allowAnimations) { - final SignalState s = (SignalState) state; - setIcon(mSignal, s, allowAnimations); - - if (s.overlayIconId > 0) { - mOverlay.setVisibility(VISIBLE); - mOverlay.setImageResource(s.overlayIconId); - } else { - mOverlay.setVisibility(GONE); - } - if (s.overlayIconId > 0 && s.isOverlayIconWide) { - mSignal.setPaddingRelative(mWideOverlayIconStartPadding, 0, 0, 0); - } else { - mSignal.setPaddingRelative(0, 0, 0, 0); - } - final boolean shouldAnimate = allowAnimations && isShown(); - // Do not show activity indicators -// setVisibility(mIn, shouldAnimate, s.activityIn); -// setVisibility(mOut, shouldAnimate, s.activityOut); - } - - private void setVisibility(View view, boolean shown, boolean visible) { - final float newAlpha = shown && visible ? 1 : 0; - if (view.getAlpha() == newAlpha) return; - if (shown) { - view.animate() - .setDuration(visible ? SHORT_DURATION : DEFAULT_DURATION) - .alpha(newAlpha) - .start(); - } else { - view.setAlpha(newAlpha); - } - } -} diff --git a/packages/SystemUI/src/com/android/systemui/qs/SlashDrawable.java b/packages/SystemUI/src/com/android/systemui/qs/SlashDrawable.java deleted file mode 100644 index 90118539c912..000000000000 --- a/packages/SystemUI/src/com/android/systemui/qs/SlashDrawable.java +++ /dev/null @@ -1,234 +0,0 @@ -/* - * 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 static com.android.systemui.qs.tileimpl.QSIconViewImpl.QS_ANIM_LENGTH; - -import android.animation.ObjectAnimator; -import android.animation.ValueAnimator; -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.Path.Direction; -import android.graphics.PorterDuff.Mode; -import android.graphics.Rect; -import android.graphics.RectF; -import android.graphics.drawable.Drawable; -import android.util.FloatProperty; - -public class SlashDrawable extends Drawable { - - public static final float CORNER_RADIUS = 1f; - - private final Path mPath = new Path(); - private final Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); - - // These values are derived in un-rotated (vertical) orientation - private static final float SLASH_WIDTH = 1.8384776f; - private static final float SLASH_HEIGHT = 28f; - private static final float CENTER_X = 10.65f; - private static final float CENTER_Y = 11.869239f; - private static final float SCALE = 24f; - - // Bottom is derived during animation - private static final float LEFT = (CENTER_X - (SLASH_WIDTH / 2)) / SCALE; - private static final float TOP = (CENTER_Y - (SLASH_HEIGHT / 2)) / SCALE; - private static final float RIGHT = (CENTER_X + (SLASH_WIDTH / 2)) / SCALE; - // Draw the slash washington-monument style; rotate to no-u-turn style - private static final float DEFAULT_ROTATION = -45f; - - private Drawable mDrawable; - private final RectF mSlashRect = new RectF(0, 0, 0, 0); - private float mRotation; - private boolean mSlashed; - @Nullable - private Mode mTintMode; - @Nullable - private ColorStateList mTintList; - private boolean mAnimationEnabled = true; - - 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 setAnimationEnabled(boolean enabled) { - mAnimationEnabled = enabled; - } - - // Animate this value on change - private float mCurrentSlashLength; - private final FloatProperty mSlashLengthProp = new FloatProperty<SlashDrawable>("slashLength") { - @Override - public void setValue(SlashDrawable object, float value) { - object.mCurrentSlashLength = value; - } - - @Override - public Float get(SlashDrawable object) { - return object.mCurrentSlashLength; - } - }; - - public void setSlashed(boolean slashed) { - if (mSlashed == slashed) return; - - mSlashed = slashed; - - final float end = mSlashed ? SLASH_HEIGHT / SCALE : 0f; - final float start = mSlashed ? 0f : SLASH_HEIGHT / SCALE; - - if (mAnimationEnabled) { - ObjectAnimator anim = ObjectAnimator.ofFloat(this, mSlashLengthProp, start, end); - anim.addUpdateListener((ValueAnimator valueAnimator) -> invalidateSelf()); - anim.setDuration(QS_ANIM_LENGTH); - anim.start(); - } else { - mCurrentSlashLength = end; - invalidateSelf(); - } - } - - @Override - public void draw(@NonNull Canvas canvas) { - canvas.save(); - Matrix m = new Matrix(); - final int width = getBounds().width(); - final int height = getBounds().height(); - final float radiusX = scale(CORNER_RADIUS, width); - final float radiusY = scale(CORNER_RADIUS, height); - updateRect( - scale(LEFT, width), - scale(TOP, height), - scale(RIGHT, width), - scale(TOP + mCurrentSlashLength, height) - ); - - mPath.reset(); - // Draw the slash vertically - mPath.addRoundRect(mSlashRect, radiusX, radiusY, Direction.CW); - // Rotate -45 + desired rotation - m.setRotate(mRotation + DEFAULT_ROTATION, width / 2, height / 2); - mPath.transform(m); - canvas.drawPath(mPath, mPaint); - - // Rotate back to vertical - m.setRotate(-mRotation - DEFAULT_ROTATION, width / 2, height / 2); - mPath.transform(m); - - // Draw another rect right next to the first, for clipping - m.setTranslate(mSlashRect.width(), 0); - mPath.transform(m); - mPath.addRoundRect(mSlashRect, 1.0f * width, 1.0f * height, Direction.CW); - m.setRotate(mRotation + DEFAULT_ROTATION, 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; - } - - private void updateRect(float left, float top, float right, float bottom) { - mSlashRect.left = left; - mSlashRect.top = top; - mSlashRect.right = right; - mSlashRect.bottom = bottom; - } - - @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); - setDrawableTintList(tint); - mPaint.setColor(tint.getDefaultColor()); - invalidateSelf(); - } - - protected void setDrawableTintList(@Nullable ColorStateList tint) { - mDrawable.setTintList(tint); - } - - @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; - } -} diff --git a/packages/SystemUI/src/com/android/systemui/qs/customize/CustomizeTileView.kt b/packages/SystemUI/src/com/android/systemui/qs/customize/CustomizeTileView.kt index a316e6aa5f1b..edc16beebd3f 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/customize/CustomizeTileView.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/customize/CustomizeTileView.kt @@ -18,17 +18,11 @@ package com.android.systemui.qs.customize import android.content.Context import android.text.TextUtils -import com.android.systemui.plugins.qs.QSIconView import com.android.systemui.plugins.qs.QSTile import com.android.systemui.qs.tileimpl.QSTileViewImpl -/** - * Class for displaying tiles in [QSCustomizer] with the new design (labels on the side). - */ -class CustomizeTileView( - context: Context, - icon: QSIconView -) : QSTileViewImpl(context, icon, collapsed = false) { +/** Class for displaying tiles in [QSCustomizer] with the new design (labels on the side). */ +class CustomizeTileView(context: Context) : QSTileViewImpl(context, collapsed = false) { var showAppLabel = false set(value) { @@ -68,4 +62,4 @@ class CustomizeTileView( fun changeState(state: QSTile.State) { handleStateChanged(state) } -}
\ No newline at end of file +} diff --git a/packages/SystemUI/src/com/android/systemui/qs/customize/TileAdapter.java b/packages/SystemUI/src/com/android/systemui/qs/customize/TileAdapter.java index 596475eedb43..e8901701c3ac 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/customize/TileAdapter.java +++ b/packages/SystemUI/src/com/android/systemui/qs/customize/TileAdapter.java @@ -54,7 +54,6 @@ import com.android.systemui.qs.customize.TileQueryHelper.TileStateListener; import com.android.systemui.qs.dagger.QSScope; import com.android.systemui.qs.dagger.QSThemedContext; import com.android.systemui.qs.external.CustomTile; -import com.android.systemui.qs.tileimpl.QSIconViewImpl; import com.android.systemui.qs.tileimpl.QSTileViewImpl; import java.util.ArrayList; @@ -297,7 +296,7 @@ public class TileAdapter extends RecyclerView.Adapter<Holder> implements TileSta } FrameLayout frame = (FrameLayout) inflater.inflate(R.layout.qs_customize_tile_frame, parent, false); - View view = new CustomizeTileView(context, new QSIconViewImpl(context)); + View view = new CustomizeTileView(context); frame.addView(view); return new Holder(frame); } diff --git a/packages/SystemUI/src/com/android/systemui/qs/external/TileRequestDialog.kt b/packages/SystemUI/src/com/android/systemui/qs/external/TileRequestDialog.kt index 3432628e6d67..d2c51e50c60d 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/external/TileRequestDialog.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/external/TileRequestDialog.kt @@ -25,7 +25,6 @@ import android.widget.TextView import com.android.systemui.R import com.android.systemui.plugins.qs.QSTile import com.android.systemui.plugins.qs.QSTileView -import com.android.systemui.qs.tileimpl.QSIconViewImpl import com.android.systemui.qs.tileimpl.QSTileImpl import com.android.systemui.qs.tileimpl.QSTileImpl.ResourceIcon import com.android.systemui.qs.tileimpl.QSTileViewImpl @@ -68,7 +67,7 @@ class TileRequestDialog( private fun createTileView(tileData: TileData): QSTileView { val themedContext = ContextThemeWrapper(context, R.style.Theme_SystemUI_QuickSettings) - val tile = QSTileViewImpl(themedContext, QSIconViewImpl(themedContext), true) + val tile = QSTileViewImpl(themedContext, true) val state = QSTile.BooleanState().apply { label = tileData.label handlesLongClick = false diff --git a/packages/SystemUI/src/com/android/systemui/qs/logging/QSLogger.kt b/packages/SystemUI/src/com/android/systemui/qs/logging/QSLogger.kt index 39745c8cbeea..38e797228d4f 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/logging/QSLogger.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/logging/QSLogger.kt @@ -222,16 +222,8 @@ constructor( str2 = state.label?.toString() str3 = state.icon?.toString() int1 = state.state - if (state is QSTile.SignalState) { - bool1 = true - bool2 = state.activityIn - bool3 = state.activityOut - } }, - { - "[$str1] Tile updated. Label=$str2. State=$int1. Icon=$str3." + - if (bool1) " Activity in/out=$bool2/$bool3" else "" - } + { "[$str1] Tile updated. Label=$str2. State=$int1. Icon=$str3." } ) } diff --git a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSFactoryImpl.java b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSFactoryImpl.java index 6b23f5d77145..9c7a73412518 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSFactoryImpl.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSFactoryImpl.java @@ -14,7 +14,6 @@ package com.android.systemui.qs.tileimpl; -import android.content.Context; import android.os.Build; import android.util.Log; @@ -22,20 +21,18 @@ import androidx.annotation.Nullable; import com.android.systemui.dagger.SysUISingleton; import com.android.systemui.plugins.qs.QSFactory; -import com.android.systemui.plugins.qs.QSIconView; import com.android.systemui.plugins.qs.QSTile; -import com.android.systemui.plugins.qs.QSTileView; import com.android.systemui.qs.QSHost; import com.android.systemui.qs.external.CustomTile; import com.android.systemui.util.leak.GarbageMonitor; +import dagger.Lazy; + import java.util.Map; import javax.inject.Inject; import javax.inject.Provider; -import dagger.Lazy; - /** * A factory that creates Quick Settings tiles based on a tileSpec * @@ -96,10 +93,4 @@ public class QSFactoryImpl implements QSFactory { Log.w(TAG, "No stock tile spec: " + tileSpec); return null; } - - @Override - public QSTileView createTileView(Context context, QSTile tile, boolean collapsedView) { - QSIconView icon = tile.createTileView(context); - return new QSTileViewImpl(context, icon, collapsedView); - } } diff --git a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSIconViewImpl.java b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSIconViewImpl.java index 7e45491adc83..88c8e81bf1b5 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSIconViewImpl.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSIconViewImpl.java @@ -38,7 +38,6 @@ import com.android.systemui.R; import com.android.systemui.plugins.qs.QSIconView; import com.android.systemui.plugins.qs.QSTile; import com.android.systemui.plugins.qs.QSTile.State; -import com.android.systemui.qs.AlphaControlledSignalTileView.AlphaControlledSlashImageView; import java.util.Objects; @@ -114,8 +113,7 @@ public class QSIconViewImpl extends QSIconView { protected void updateIcon(ImageView iv, State state, boolean allowAnimations) { final QSTile.Icon icon = state.iconSupplier != null ? state.iconSupplier.get() : state.icon; - if (!Objects.equals(icon, iv.getTag(R.id.qs_icon_tag)) - || !Objects.equals(state.slash, iv.getTag(R.id.qs_slash_tag))) { + if (!Objects.equals(icon, iv.getTag(R.id.qs_icon_tag))) { boolean shouldAnimate = allowAnimations && shouldAnimate(iv); mLastIcon = icon; Drawable d = icon != null @@ -135,15 +133,9 @@ public class QSIconViewImpl extends QSIconView { ((Animatable2) lastDrawable).clearAnimationCallbacks(); } - if (iv instanceof SlashImageView) { - ((SlashImageView) iv).setAnimationEnabled(shouldAnimate); - ((SlashImageView) iv).setState(null, d); - } else { - iv.setImageDrawable(d); - } + iv.setImageDrawable(d); iv.setTag(R.id.qs_icon_tag, icon); - iv.setTag(R.id.qs_slash_tag, state.slash); iv.setPadding(0, padding, 0, padding); if (d instanceof Animatable2) { Animatable2 a = (Animatable2) d; @@ -177,12 +169,7 @@ public class QSIconViewImpl extends QSIconView { if (mTint != 0 && allowAnimations && shouldAnimate(iv)) { animateGrayScale(mTint, color, iv, () -> updateIcon(iv, state, allowAnimations)); } else { - if (iv instanceof AlphaControlledSlashImageView) { - ((AlphaControlledSlashImageView)iv) - .setFinalImageTintList(ColorStateList.valueOf(color)); - } else { - setTint(iv, color); - } + setTint(iv, color); updateIcon(iv, state, allowAnimations); } } else { @@ -195,11 +182,7 @@ public class QSIconViewImpl extends QSIconView { } private void animateGrayScale(int fromColor, int toColor, ImageView iv, - final Runnable endRunnable) { - if (iv instanceof AlphaControlledSlashImageView) { - ((AlphaControlledSlashImageView)iv) - .setFinalImageTintList(ColorStateList.valueOf(toColor)); - } + final Runnable endRunnable) { mColorAnimator.cancel(); if (mAnimationEnabled && ValueAnimator.areAnimatorsEnabled()) { PropertyValuesHolder values = PropertyValuesHolder.ofInt("color", fromColor, toColor); @@ -229,7 +212,7 @@ public class QSIconViewImpl extends QSIconView { } protected View createIcon() { - final ImageView icon = new SlashImageView(mContext); + final ImageView icon = new ImageView(mContext); icon.setId(android.R.id.icon); icon.setScaleType(ScaleType.FIT_CENTER); return icon; diff --git a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileImpl.java b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileImpl.java index 1ca2a961744b..70df09d0876b 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileImpl.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileImpl.java @@ -60,7 +60,6 @@ import com.android.systemui.Dumpable; import com.android.systemui.animation.ActivityLaunchAnimator; import com.android.systemui.plugins.ActivityStarter; import com.android.systemui.plugins.FalsingManager; -import com.android.systemui.plugins.qs.QSIconView; import com.android.systemui.plugins.qs.QSTile; import com.android.systemui.plugins.qs.QSTile.State; import com.android.systemui.plugins.statusbar.StatusBarStateController; @@ -262,16 +261,6 @@ public abstract class QSTileImpl<TState extends State> implements QSTile, Lifecy } /** - * Return the {@link QSIconView} to be used by this tile's view. - * - * @param context view context for the view - * @return icon view for this tile - */ - public QSIconView createTileView(Context context) { - return new QSIconViewImpl(context); - } - - /** * Is a startup check whether this device currently supports this tile. * Should not be used to conditionally hide tiles. Only checked on tile * creation or whether should be shown in edit screen. diff --git a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewImpl.kt b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewImpl.kt index 764ef681106b..966d94161f91 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewImpl.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewImpl.kt @@ -58,7 +58,6 @@ import java.util.Objects private const val TAG = "QSTileViewImpl" open class QSTileViewImpl @JvmOverloads constructor( context: Context, - private val _icon: QSIconView, private val collapsed: Boolean = false ) : QSTileView(context), HeightOverrideable, LaunchableView { @@ -73,10 +72,11 @@ open class QSTileViewImpl @JvmOverloads constructor( internal const val TILE_STATE_RES_PREFIX = "tile_states_" } - private var _position: Int = INVALID + private val icon: QSIconViewImpl = QSIconViewImpl(context) + private var position: Int = INVALID override fun setPosition(position: Int) { - _position = position + this.position = position } override var heightOverride: Int = HeightOverrideable.NO_OVERRIDE @@ -173,7 +173,7 @@ open class QSTileViewImpl @JvmOverloads constructor( setPaddingRelative(startPadding, padding, padding, padding) val iconSize = resources.getDimensionPixelSize(R.dimen.qs_icon_size) - addView(_icon, LayoutParams(iconSize, iconSize)) + addView(icon, LayoutParams(iconSize, iconSize)) createAndAddLabels() createAndAddSideView() @@ -204,7 +204,7 @@ open class QSTileViewImpl @JvmOverloads constructor( FontSizeUtils.updateFontSize(secondaryLabel, R.dimen.qs_tile_text_size) val iconSize = context.resources.getDimensionPixelSize(R.dimen.qs_icon_size) - _icon.layoutParams.apply { + icon.layoutParams.apply { height = iconSize width = iconSize } @@ -291,7 +291,7 @@ open class QSTileViewImpl @JvmOverloads constructor( } override fun getIcon(): QSIconView { - return _icon + return icon } override fun getIconWithBackground(): View { @@ -425,16 +425,16 @@ open class QSTileViewImpl @JvmOverloads constructor( } } } - if (_position != INVALID) { + if (position != INVALID) { info.collectionItemInfo = - AccessibilityNodeInfo.CollectionItemInfo(_position, 1, 0, 1, false) + AccessibilityNodeInfo.CollectionItemInfo(position, 1, 0, 1, false) } } override fun toString(): String { val sb = StringBuilder(javaClass.simpleName).append('[') sb.append("locInScreen=(${locInScreen[0]}, ${locInScreen[1]})") - sb.append(", iconView=$_icon") + sb.append(", iconView=$icon") sb.append(", tileState=$tileState") sb.append("]") return sb.toString() diff --git a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/SlashImageView.java b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/SlashImageView.java deleted file mode 100644 index f1e82b6a18a4..000000000000 --- a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/SlashImageView.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * 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.annotation.Nullable; -import android.content.Context; -import android.graphics.drawable.Drawable; -import android.widget.ImageView; - -import androidx.annotation.NonNull; - -import com.android.internal.annotations.VisibleForTesting; -import com.android.systemui.plugins.qs.QSTile.SlashState; -import com.android.systemui.qs.SlashDrawable; - -public class SlashImageView extends ImageView { - - @Nullable - @VisibleForTesting - protected SlashDrawable mSlash; - private boolean mAnimationEnabled = true; - - public SlashImageView(Context context) { - super(context); - } - - @Nullable - protected SlashDrawable getSlash() { - return mSlash; - } - - protected void setSlash(SlashDrawable slash) { - mSlash = slash; - } - - protected void ensureSlashDrawable() { - if (mSlash == null) { - mSlash = new SlashDrawable(getDrawable()); - mSlash.setAnimationEnabled(mAnimationEnabled); - super.setImageDrawable(mSlash); - } - } - - @Override - public void setImageDrawable(@Nullable Drawable drawable) { - if (drawable == null) { - mSlash = null; - super.setImageDrawable(null); - } else if (mSlash == null) { - setImageLevel(drawable.getLevel()); - super.setImageDrawable(drawable); - } else { - mSlash.setAnimationEnabled(mAnimationEnabled); - mSlash.setDrawable(drawable); - } - } - - protected void setImageViewDrawable(SlashDrawable slash) { - super.setImageDrawable(slash); - } - - public void setAnimationEnabled(boolean enabled) { - mAnimationEnabled = enabled; - } - - public boolean getAnimationEnabled() { - return mAnimationEnabled; - } - - private void setSlashState(@NonNull SlashState slashState) { - ensureSlashDrawable(); - mSlash.setRotation(slashState.rotation); - mSlash.setSlashed(slashState.isSlashed); - } - - public void setState(@Nullable SlashState state, @Nullable Drawable drawable) { - if (state != null) { - setImageDrawable(drawable); - setSlashState(state); - } else { - mSlash = null; - setImageDrawable(drawable); - } - } -} 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 26912f82b3a3..83b09bebee69 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/BluetoothTile.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/BluetoothTile.java @@ -151,10 +151,6 @@ public class BluetoothTile extends QSTileImpl<BooleanState> { } state.dualTarget = true; state.value = enabled; - if (state.slash == null) { - state.slash = new SlashState(); - } - state.slash.isSlashed = !enabled; state.label = mContext.getString(R.string.quick_settings_bluetooth_label); state.secondaryLabel = TextUtils.emptyIfNull( getSecondaryLabel(enabled, connecting, connected, state.isTransient)); diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/InternetTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/InternetTile.java index ffe5489d656f..fb2f2ced1d3a 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/InternetTile.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/InternetTile.java @@ -46,10 +46,8 @@ import com.android.systemui.dagger.qualifiers.Background; import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.plugins.ActivityStarter; import com.android.systemui.plugins.FalsingManager; -import com.android.systemui.plugins.qs.QSIconView; -import com.android.systemui.plugins.qs.QSTile.SignalState; +import com.android.systemui.plugins.qs.QSTile; import com.android.systemui.plugins.statusbar.StatusBarStateController; -import com.android.systemui.qs.AlphaControlledSignalTileView; import com.android.systemui.qs.QSHost; import com.android.systemui.qs.QsEventLogger; import com.android.systemui.qs.logging.QSLogger; @@ -68,7 +66,7 @@ import java.io.PrintWriter; import javax.inject.Inject; /** Quick settings tile: Internet **/ -public class InternetTile extends QSTileImpl<SignalState> { +public class InternetTile extends QSTileImpl<QSTile.BooleanState> { public static final String TILE_SPEC = "internet"; @@ -114,18 +112,13 @@ public class InternetTile extends QSTileImpl<SignalState> { } @Override - public SignalState newTileState() { - SignalState s = new SignalState(); + public BooleanState newTileState() { + BooleanState s = new BooleanState(); s.forceExpandIcon = true; return s; } @Override - public QSIconView createTileView(Context context) { - return new AlphaControlledSignalTileView(context); - } - - @Override public Intent getLongClickIntent() { return WIFI_SETTINGS; } @@ -453,7 +446,7 @@ public class InternetTile extends QSTileImpl<SignalState> { } @Override - protected void handleUpdateState(SignalState state, Object arg) { + protected void handleUpdateState(BooleanState state, Object arg) { mQSLogger.logInternetTileUpdate( getTileSpec(), mLastTileState, arg == null ? "null" : arg.toString()); if (arg instanceof CellularCallbackInfo) { @@ -506,18 +499,13 @@ public class InternetTile extends QSTileImpl<SignalState> { } } - private void handleUpdateWifiState(SignalState state, Object arg) { + private void handleUpdateWifiState(BooleanState state, Object arg) { WifiCallbackInfo cb = (WifiCallbackInfo) arg; if (DEBUG) { Log.d(TAG, "handleUpdateWifiState: " + "WifiCallbackInfo = " + cb.toString()); } boolean wifiConnected = cb.mEnabled && (cb.mWifiSignalIconId > 0) && (cb.mSsid != null); boolean wifiNotConnected = (cb.mWifiSignalIconId > 0) && (cb.mSsid == null); - if (state.slash == null) { - state.slash = new SlashState(); - state.slash.rotation = 6; - } - state.slash.isSlashed = false; state.secondaryLabel = getSecondaryLabel(cb.mIsTransient, removeDoubleQuotes(cb.mSsid)); state.state = Tile.STATE_ACTIVE; state.dualTarget = true; @@ -555,7 +543,6 @@ public class InternetTile extends QSTileImpl<SignalState> { state.icon = ResourceIcon.get( com.android.internal.R.drawable.ic_signal_wifi_transient_animation); } else if (!state.value) { - state.slash.isSlashed = true; state.state = Tile.STATE_INACTIVE; state.icon = ResourceIcon.get(WifiIcons.QS_WIFI_DISABLED); } else if (wifiConnected) { @@ -580,11 +567,11 @@ public class InternetTile extends QSTileImpl<SignalState> { R.string.accessibility_quick_settings_open_settings, getTileLabel()); state.expandedAccessibilityClassName = Switch.class.getName(); if (DEBUG) { - Log.d(TAG, "handleUpdateWifiState: " + "SignalState = " + state.toString()); + Log.d(TAG, "handleUpdateWifiState: " + "BooleanState = " + state.toString()); } } - private void handleUpdateCellularState(SignalState state, Object arg) { + private void handleUpdateCellularState(BooleanState state, Object arg) { CellularCallbackInfo cb = (CellularCallbackInfo) arg; if (DEBUG) { Log.d(TAG, "handleUpdateCellularState: " + "CellularCallbackInfo = " + cb.toString()); @@ -623,11 +610,11 @@ public class InternetTile extends QSTileImpl<SignalState> { state.stateDescription = state.secondaryLabel; } if (DEBUG) { - Log.d(TAG, "handleUpdateCellularState: " + "SignalState = " + state.toString()); + Log.d(TAG, "handleUpdateCellularState: " + "BooleanState = " + state.toString()); } } - private void handleUpdateEthernetState(SignalState state, Object arg) { + private void handleUpdateEthernetState(BooleanState state, Object arg) { EthernetCallbackInfo cb = (EthernetCallbackInfo) arg; if (DEBUG) { Log.d(TAG, "handleUpdateEthernetState: " + "EthernetCallbackInfo = " + cb.toString()); @@ -641,7 +628,7 @@ public class InternetTile extends QSTileImpl<SignalState> { state.icon = ResourceIcon.get(cb.mEthernetSignalIconId); state.secondaryLabel = cb.mEthernetContentDescription; if (DEBUG) { - Log.d(TAG, "handleUpdateEthernetState: " + "SignalState = " + state.toString()); + Log.d(TAG, "handleUpdateEthernetState: " + "BooleanState = " + state.toString()); } } diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/InternetTileNewImpl.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/InternetTileNewImpl.kt index 3b2f8b772d60..956e7ab6d7ab 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/InternetTileNewImpl.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/InternetTileNewImpl.kt @@ -16,7 +16,6 @@ package com.android.systemui.qs.tiles -import android.content.Context import android.content.Intent import android.os.Handler import android.os.Looper @@ -28,10 +27,8 @@ import com.android.systemui.dagger.qualifiers.Background import com.android.systemui.dagger.qualifiers.Main import com.android.systemui.plugins.ActivityStarter import com.android.systemui.plugins.FalsingManager -import com.android.systemui.plugins.qs.QSIconView import com.android.systemui.plugins.qs.QSTile import com.android.systemui.plugins.statusbar.StatusBarStateController -import com.android.systemui.qs.AlphaControlledSignalTileView import com.android.systemui.qs.QSHost import com.android.systemui.qs.QsEventLogger import com.android.systemui.qs.logging.QSLogger @@ -59,7 +56,7 @@ constructor( private val internetDialogFactory: InternetDialogFactory, private val accessPointController: AccessPointController, ) : - QSTileImpl<QSTile.SignalState>( + QSTileImpl<QSTile.BooleanState>( host, uiEventLogger, backgroundLooper, @@ -79,14 +76,11 @@ constructor( } } - override fun createTileView(context: Context): QSIconView = - AlphaControlledSignalTileView(context) - override fun getTileLabel(): CharSequence = mContext.getString(R.string.quick_settings_internet_label) - override fun newTileState(): QSTile.SignalState { - return QSTile.SignalState().also { it.forceExpandIcon = true } + override fun newTileState(): QSTile.BooleanState { + return QSTile.BooleanState().also { it.forceExpandIcon = true } } override fun handleClick(view: View?) { @@ -100,7 +94,7 @@ constructor( } } - override fun handleUpdateState(state: QSTile.SignalState, arg: Any?) { + override fun handleUpdateState(state: QSTile.BooleanState, arg: Any?) { state.label = mContext.resources.getString(R.string.quick_settings_internet_label) model.applyTo(state, mContext) diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/LocationTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/LocationTile.java index 83c568878c94..8b69f614dedd 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/LocationTile.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/LocationTile.java @@ -112,9 +112,6 @@ 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 diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/OneHandedModeTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/OneHandedModeTile.java index 1eb317aaeae8..5b0237f87153 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/OneHandedModeTile.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/OneHandedModeTile.java @@ -130,10 +130,6 @@ public class OneHandedModeTile extends QSTileImpl<BooleanState> { state.value = enabled; state.label = mContext.getString(R.string.quick_settings_onehanded_label); state.icon = mIcon; - if (state.slash == null) { - state.slash = new SlashState(); - } - state.slash.isSlashed = !state.value; state.state = state.value ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE; state.contentDescription = state.label; state.expandedAccessibilityClassName = Switch.class.getName(); diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/WorkModeTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/WorkModeTile.java index 21da59679909..c8c3c30a7302 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/WorkModeTile.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/WorkModeTile.java @@ -122,10 +122,6 @@ public class WorkModeTile extends QSTileImpl<BooleanState> implements onManagedProfileRemoved(); } - if (state.slash == null) { - state.slash = new SlashState(); - } - if (arg instanceof Boolean) { state.value = (Boolean) arg; } else { @@ -133,11 +129,6 @@ public class WorkModeTile extends QSTileImpl<BooleanState> implements } state.icon = mIcon; - if (state.value) { - state.slash.isSlashed = false; - } else { - state.slash.isSlashed = true; - } state.label = getTileLabel(); state.contentDescription = state.label; state.expandedAccessibilityClassName = Switch.class.getName(); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/ui/model/InternetTileModel.kt b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/ui/model/InternetTileModel.kt index 327dd8d442e8..1f076ed30f8a 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/ui/model/InternetTileModel.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/ui/model/InternetTileModel.kt @@ -32,17 +32,13 @@ sealed interface InternetTileModel { val iconId: Int? val icon: QSTile.Icon? - fun applyTo(state: QSTile.SignalState, context: Context) { + fun applyTo(state: QSTile.BooleanState, context: Context) { if (secondaryLabel != null) { state.secondaryLabel = secondaryLabel.loadText(context) } else { state.secondaryLabel = secondaryTitle } - // inout indicators are unused - state.activityIn = false - state.activityOut = false - // To support both SignalDrawable and other icons, give priority to icons over IDs if (icon != null) { state.icon = icon diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/AlphaControlledSignalTileViewTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/AlphaControlledSignalTileViewTest.java deleted file mode 100644 index 3e677c01fd57..000000000000 --- a/packages/SystemUI/tests/src/com/android/systemui/qs/AlphaControlledSignalTileViewTest.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * 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 static org.junit.Assert.assertTrue; - -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.atLeastOnce; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; - -import android.content.Context; -import android.content.res.ColorStateList; -import android.graphics.drawable.Drawable; -import android.test.suitebuilder.annotation.SmallTest; -import com.android.systemui.SysuiTestCase; -import com.android.systemui.qs.AlphaControlledSignalTileView.AlphaControlledSlashDrawable; -import com.android.systemui.qs.AlphaControlledSignalTileView.AlphaControlledSlashImageView; -import org.junit.Test; - -@SmallTest -public class AlphaControlledSignalTileViewTest extends SysuiTestCase { - - private AlphaControlledSignalTileView mTileView; - - @Test - public void testTileView_createsAlphaControlledSlashImageView() { - mTileView = new AlphaControlledSignalTileView(mContext); - - assertTrue(mTileView.createSlashImageView(mContext) - instanceof AlphaControlledSlashImageView); - } - - /// AlphaControlledSlashImageView tests - @Test - public void testSlashImageView_createsAlphaControlledSlashDrawable() { - TestableSlashImageView iv = new TestableSlashImageView(mContext); - - iv.ensureSlashDrawable(); - assertTrue(iv.getSlashDrawable() instanceof AlphaControlledSlashDrawable); - } - - /// AlphaControlledSlashDrawable tests - @Test - public void testSlashDrawable_doesNotSetTintList() { - Drawable mockDrawable = mock(Drawable.class); - AlphaControlledSlashDrawable drawable = new AlphaControlledSlashDrawable(mockDrawable); - ColorStateList list = ColorStateList.valueOf(0xffffff); - drawable.setTintList(list); - verify(mockDrawable, never()).setTintList(any()); - } - - @Test - public void testSlashDrawable_setsFinalTintList() { - Drawable mockDrawable = mock(Drawable.class); - AlphaControlledSlashDrawable drawable = new AlphaControlledSlashDrawable(mockDrawable); - ColorStateList list = ColorStateList.valueOf(0xffffff); - drawable.setFinalTintList(list); - verify(mockDrawable, atLeastOnce()).setTintList(list); - } - - // Expose getSlashDrawable - private static class TestableSlashImageView extends AlphaControlledSlashImageView { - TestableSlashImageView(Context c) { - super(c); - } - - private SlashDrawable getSlashDrawable() { - return mSlash; - } - - @Override - protected void setSlash(SlashDrawable slash) { - super.setSlash(slash); - } - } -} diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/QSPanelControllerBaseTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/QSPanelControllerBaseTest.java index 2ac220c1975d..24cd3e7de5b5 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/qs/QSPanelControllerBaseTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/qs/QSPanelControllerBaseTest.java @@ -34,6 +34,7 @@ import android.content.res.Configuration; import android.content.res.Resources; import android.testing.AndroidTestingRunner; import android.testing.TestableLooper.RunWithLooper; +import android.view.ContextThemeWrapper; import androidx.test.filters.SmallTest; @@ -46,7 +47,6 @@ import com.android.systemui.SysuiTestCase; import com.android.systemui.dump.DumpManager; import com.android.systemui.media.controls.ui.MediaHost; import com.android.systemui.plugins.qs.QSTile; -import com.android.systemui.plugins.qs.QSTileView; import com.android.systemui.qs.customize.QSCustomizerController; import com.android.systemui.qs.logging.QSLogger; import com.android.systemui.qs.tileimpl.QSTileImpl; @@ -92,8 +92,6 @@ public class QSPanelControllerBaseTest extends SysuiTestCase { @Mock QSTile mOtherTile; @Mock - QSTileView mQSTileView; - @Mock PagedTileLayout mPagedTileLayout; @Mock Resources mResources; @@ -132,11 +130,12 @@ public class QSPanelControllerBaseTest extends SysuiTestCase { when(mQSPanel.getTileLayout()).thenReturn(mPagedTileLayout); when(mQSTile.getTileSpec()).thenReturn("dnd"); when(mQSHost.getTiles()).thenReturn(Collections.singleton(mQSTile)); - when(mQSHost.createTileView(any(), eq(mQSTile), anyBoolean())).thenReturn(mQSTileView); when(mQSTileRevealControllerFactory.create(any(), any())) .thenReturn(mQSTileRevealController); when(mMediaHost.getDisappearParameters()).thenReturn(new DisappearParameters()); when(mQSPanel.getResources()).thenReturn(mResources); + when(mQSPanel.getContext()).thenReturn( + new ContextThemeWrapper(getContext(), R.style.Theme_SystemUI_QuickSettings)); when(mResources.getConfiguration()).thenReturn(mConfiguration); doAnswer(invocation -> { when(mQSPanel.isListening()).thenReturn(invocation.getArgument(0)); @@ -209,14 +208,15 @@ public class QSPanelControllerBaseTest extends SysuiTestCase { @Test public void testDump() { - String mockTileViewString = "Mock Tile View"; + String mockTileViewString = "QSTileViewImpl[locInScreen=(0, 0), " + + "iconView=QSIconViewImpl[state=-1, tint=0], " + + "tileState=false]"; String mockTileString = "Mock Tile"; doAnswer(invocation -> { PrintWriter pw = invocation.getArgument(0); pw.println(mockTileString); return null; }).when(mQSTile).dump(any(PrintWriter.class), any(String[].class)); - when(mQSTileView.toString()).thenReturn(mockTileViewString); StringWriter w = new StringWriter(); PrintWriter pw = new PrintWriter(w); diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/QSPanelControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/QSPanelControllerTest.kt index 8a530dd7206c..4cb194443112 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/qs/QSPanelControllerTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/qs/QSPanelControllerTest.kt @@ -4,6 +4,7 @@ import android.content.res.Configuration import android.test.suitebuilder.annotation.SmallTest import android.testing.AndroidTestingRunner import android.testing.TestableResources +import android.view.ContextThemeWrapper import com.android.internal.logging.MetricsLogger import com.android.internal.logging.UiEventLogger import com.android.systemui.R @@ -71,6 +72,8 @@ class QSPanelControllerTest : SysuiTestCase() { whenever(brightnessControllerFactory.create(any())).thenReturn(brightnessController) setShouldUseSplitShade(false) whenever(qsPanel.resources).thenReturn(testableResources.resources) + whenever(qsPanel.context) + .thenReturn( ContextThemeWrapper(context, R.style.Theme_SystemUI_QuickSettings)) whenever(qsPanel.getOrCreateTileLayout()).thenReturn(pagedTileLayout) whenever(statusBarKeyguardViewManager.isPrimaryBouncerInTransit()).thenReturn(false) whenever(qsPanel.setListening(anyBoolean())).then { diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/QSPanelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/QSPanelTest.kt index fe6c9b3fe7b1..1df504a668f4 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/qs/QSPanelTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/qs/QSPanelTest.kt @@ -32,7 +32,6 @@ import com.android.systemui.plugins.qs.QSTile import com.android.systemui.plugins.qs.QSTileView import com.android.systemui.qs.QSPanelControllerBase.TileRecord import com.android.systemui.qs.logging.QSLogger -import com.android.systemui.qs.tileimpl.QSIconViewImpl import com.android.systemui.qs.tileimpl.QSTileViewImpl import com.google.common.truth.Truth.assertThat import org.junit.After @@ -112,7 +111,7 @@ class QSPanelTest : SysuiTestCase() { qsPanel.tileLayout?.addTile( QSPanelControllerBase.TileRecord( mock(QSTile::class.java), - QSTileViewImpl(themedContext, QSIconViewImpl(themedContext)) + QSTileViewImpl(themedContext) ) ) @@ -142,7 +141,7 @@ class QSPanelTest : SysuiTestCase() { qsPanel.tileLayout?.addTile( QSPanelControllerBase.TileRecord( mock(QSTile::class.java), - QSTileViewImpl(themedContext, QSIconViewImpl(themedContext)) + QSTileViewImpl(themedContext) ) ) diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/QuickQSPanelControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/QuickQSPanelControllerTest.kt index f188b4e19a2b..9bd3b7979946 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/qs/QuickQSPanelControllerTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/qs/QuickQSPanelControllerTest.kt @@ -18,15 +18,16 @@ package com.android.systemui.qs import android.content.res.Configuration import android.testing.AndroidTestingRunner +import android.view.ContextThemeWrapper import androidx.test.filters.SmallTest import com.android.internal.logging.MetricsLogger import com.android.internal.logging.testing.UiEventLoggerFake +import com.android.systemui.R import com.android.systemui.SysuiTestCase import com.android.systemui.dump.DumpManager import com.android.systemui.media.controls.ui.MediaHost import com.android.systemui.media.controls.ui.MediaHostState import com.android.systemui.plugins.qs.QSTile -import com.android.systemui.plugins.qs.QSTileView import com.android.systemui.qs.customize.QSCustomizerController import com.android.systemui.qs.logging.QSLogger import com.android.systemui.statusbar.policy.ResourcesSplitShadeStateController @@ -36,15 +37,14 @@ import org.junit.Before import org.junit.Test import org.junit.runner.RunWith import org.mockito.ArgumentCaptor -import org.mockito.ArgumentMatchers.anyBoolean import org.mockito.Captor import org.mockito.Mock import org.mockito.Mockito.any import org.mockito.Mockito.reset import org.mockito.Mockito.times import org.mockito.Mockito.verify -import org.mockito.Mockito.`when` as whenever import org.mockito.MockitoAnnotations +import org.mockito.Mockito.`when` as whenever @SmallTest @RunWith(AndroidTestingRunner::class) @@ -58,7 +58,6 @@ class QuickQSPanelControllerTest : SysuiTestCase() { @Mock private lateinit var qsLogger: QSLogger @Mock private lateinit var tile: QSTile @Mock private lateinit var tileLayout: TileLayout - @Mock private lateinit var tileView: QSTileView @Captor private lateinit var captor: ArgumentCaptor<QSPanel.OnConfigurationChangedListener> private val uiEventLogger = UiEventLoggerFake() @@ -76,7 +75,8 @@ class QuickQSPanelControllerTest : SysuiTestCase() { whenever(quickQSPanel.isAttachedToWindow).thenReturn(true) whenever(quickQSPanel.dumpableTag).thenReturn("") whenever(quickQSPanel.resources).thenReturn(mContext.resources) - whenever(qsHost.createTileView(any(), any(), anyBoolean())).thenReturn(tileView) + whenever(quickQSPanel.context) + .thenReturn(ContextThemeWrapper(context, R.style.Theme_SystemUI_QuickSettings)) controller = TestQuickQSPanelController( @@ -89,7 +89,8 @@ class QuickQSPanelControllerTest : SysuiTestCase() { metricsLogger, uiEventLogger, qsLogger, - dumpManager) + dumpManager + ) controller.init() } @@ -169,7 +170,8 @@ class QuickQSPanelControllerTest : SysuiTestCase() { uiEventLogger, qsLogger, dumpManager, - ResourcesSplitShadeStateController()) { + ResourcesSplitShadeStateController() + ) { private var rotation = RotationUtils.ROTATION_NONE diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/SlashImageViewTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/SlashImageViewTest.java deleted file mode 100644 index ea8c64ac53bb..000000000000 --- a/packages/SystemUI/tests/src/com/android/systemui/qs/SlashImageViewTest.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * 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 static org.junit.Assert.assertTrue; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import android.content.Context; -import android.graphics.drawable.Drawable; -import android.testing.AndroidTestingRunner; -import android.testing.TestableLooper.RunWithLooper; - -import androidx.test.filters.SmallTest; - -import com.android.systemui.SysuiTestCase; -import com.android.systemui.plugins.qs.QSTile.SlashState; -import com.android.systemui.qs.tileimpl.SlashImageView; - -import org.junit.Test; -import org.junit.runner.RunWith; - -@SmallTest -@RunWith(AndroidTestingRunner.class) -@RunWithLooper -public class SlashImageViewTest extends SysuiTestCase { - private TestableSlashImageView mSlashView; - - @Test - public void testSetNonNullSlashStateCreatesSlashDrawable() { - SlashState mockState = mock(SlashState.class); - Drawable mockDrawable = mock(Drawable.class); - mSlashView = new TestableSlashImageView(mContext); - assertTrue(mSlashView.getSlashDrawable() == null); - - mSlashView.setState(mockState, mockDrawable); - - assertTrue(mSlashView.getSlashDrawable() != null); - } - - @Test - public void testSetNullSlashStateRemovesSlashDrawable() { - SlashState mockState = mock(SlashState.class); - Drawable mockDrawable = mock(Drawable.class); - mSlashView = new TestableSlashImageView(mContext); - mSlashView.setState(mockState, mockDrawable); - - assertTrue(mSlashView.getSlashDrawable() != null); - - mSlashView.setState(null, mockDrawable); - - assertTrue(mSlashView.getSlashDrawable() == null); - } - - @Test - public void testSetNullDrawableRemovesSlashDrawable() { - SlashState mockState = mock(SlashState.class); - Drawable mockDrawable = mock(Drawable.class); - - mSlashView = new TestableSlashImageView(mContext); - mSlashView.setImageDrawable(mockDrawable); - mSlashView.setState(mockState, mockDrawable); - mSlashView.setImageDrawable(null); - - assertTrue(mSlashView.getSlashDrawable() == null); - } - - @Test - public void testSetImageDrawableUsesDrawableLevel() { - SlashImageView iv = new SlashImageView(mContext); - Drawable mockDrawable = mock(Drawable.class); - when(mockDrawable.getLevel()).thenReturn(2); - - iv.setImageDrawable(mockDrawable); - - // Make sure setting the drawable didn't reset its level to 0 - verify(mockDrawable).setLevel(eq(2)); - } - - // Expose getSlashDrawable - private static class TestableSlashImageView extends SlashImageView { - TestableSlashImageView(Context c) { - super(c); - } - - private SlashDrawable getSlashDrawable() { - return mSlash; - } - } -} diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/TileLayoutTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/TileLayoutTest.java index f55ef65a8fc1..4a15d746eb32 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/qs/TileLayoutTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/qs/TileLayoutTest.java @@ -42,7 +42,6 @@ import androidx.test.runner.AndroidJUnit4; import com.android.systemui.R; import com.android.systemui.SysuiTestCase; import com.android.systemui.plugins.qs.QSTile; -import com.android.systemui.qs.tileimpl.QSIconViewImpl; import com.android.systemui.qs.tileimpl.QSTileViewImpl; import org.junit.Before; @@ -78,7 +77,7 @@ public class TileLayoutTest extends SysuiTestCase { private QSPanelControllerBase.TileRecord createTileRecord() { return new QSPanelControllerBase.TileRecord( mock(QSTile.class), - spy(new QSTileViewImpl(mSpyContext, new QSIconViewImpl(mSpyContext)))); + spy(new QSTileViewImpl(mSpyContext))); } @Test @@ -272,7 +271,7 @@ public class TileLayoutTest extends SysuiTestCase { private static class FakeTileView extends QSTileViewImpl { FakeTileView(Context context) { - super(context, new QSIconViewImpl(context), /* collapsed= */ false); + super(context, /* collapsed= */ false); } void changeState(QSTile.State state) { diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/customize/TileQueryHelperTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/customize/TileQueryHelperTest.java index 78a02584c40a..2eed38fcb767 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/qs/customize/TileQueryHelperTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/qs/customize/TileQueryHelperTest.java @@ -34,7 +34,6 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import android.Manifest; -import android.content.Context; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; @@ -53,7 +52,6 @@ import androidx.test.filters.SmallTest; import com.android.internal.logging.InstanceId; import com.android.systemui.R; import com.android.systemui.SysuiTestCase; -import com.android.systemui.plugins.qs.QSIconView; import com.android.systemui.plugins.qs.QSTile; import com.android.systemui.qs.QSHost; import com.android.systemui.settings.UserTracker; @@ -393,11 +391,6 @@ public class TileQueryHelperTest extends SysuiTestCase { } @Override - public QSIconView createTileView(Context context) { - return null; - } - - @Override public void click(@Nullable View view) {} @Override diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/pipeline/domain/interactor/FakeQSTile.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/pipeline/domain/interactor/FakeQSTile.kt index 013c925df51e..7e0e7d1f46e8 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/qs/pipeline/domain/interactor/FakeQSTile.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/qs/pipeline/domain/interactor/FakeQSTile.kt @@ -16,10 +16,8 @@ package com.android.systemui.qs.pipeline.domain.interactor -import android.content.Context import android.view.View import com.android.internal.logging.InstanceId -import com.android.systemui.plugins.qs.QSIconView import com.android.systemui.plugins.qs.QSTile class FakeQSTile( @@ -58,10 +56,6 @@ class FakeQSTile( callbacks.clear() } - override fun createTileView(context: Context?): QSIconView? { - return null - } - override fun click(view: View?) {} override fun secondaryClick(view: View?) {} diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/QSIconViewImplTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/QSIconViewImplTest.java index 180fed904d01..81a960419555 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/QSIconViewImplTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/QSIconViewImplTest.java @@ -49,7 +49,6 @@ import org.mockito.Mockito; public class QSIconViewImplTest extends SysuiTestCase { private QSIconViewImpl mIconView; - private static int RES_ID = 1; @Before public void setup() { @@ -79,7 +78,7 @@ public class QSIconViewImplTest extends SysuiTestCase { @Test public void testMutateIconDrawable() { - SlashImageView iv = mock(SlashImageView.class); + ImageView iv = mock(ImageView.class); Drawable originalDrawable = mock(Drawable.class); Drawable otherDrawable = mock(Drawable.class); State s = new State(); @@ -92,7 +91,7 @@ public class QSIconViewImplTest extends SysuiTestCase { mIconView.updateIcon(iv, s, /* allowAnimations= */true); - verify(iv).setState(any(), eq(otherDrawable)); + verify(iv).setImageDrawable(eq(otherDrawable)); } @Test diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/QSTileViewImplTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/QSTileViewImplTest.kt index 3c667725c78a..780c56cf7c52 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/QSTileViewImplTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/QSTileViewImplTest.kt @@ -29,7 +29,6 @@ import android.widget.TextView import androidx.test.filters.SmallTest import com.android.systemui.R import com.android.systemui.SysuiTestCase -import com.android.systemui.plugins.qs.QSIconView import com.android.systemui.plugins.qs.QSTile import com.google.common.truth.Truth.assertThat import org.junit.Before @@ -44,8 +43,6 @@ import org.mockito.MockitoAnnotations class QSTileViewImplTest : SysuiTestCase() { @Mock - private lateinit var iconView: QSIconView - @Mock private lateinit var customDrawable: Drawable private lateinit var tileView: FakeTileView @@ -57,7 +54,7 @@ class QSTileViewImplTest : SysuiTestCase() { MockitoAnnotations.initMocks(this) context.ensureTestableResources() - tileView = FakeTileView(context, iconView, false) + tileView = FakeTileView(context, false) customDrawableView = tileView.requireViewById(R.id.customDrawable) chevronView = tileView.requireViewById(R.id.chevron) } @@ -385,11 +382,9 @@ class QSTileViewImplTest : SysuiTestCase() { class FakeTileView( context: Context, - icon: QSIconView, collapsed: Boolean ) : QSTileViewImpl( ContextThemeWrapper(context, R.style.Theme_SystemUI_QuickSettings), - icon, collapsed ) { fun changeState(state: QSTile.State) { diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/qs/FakeQSFactory.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/qs/FakeQSFactory.kt index 9383a0a68844..bf26e719433d 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/qs/FakeQSFactory.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/qs/FakeQSFactory.kt @@ -16,21 +16,11 @@ package com.android.systemui.qs -import android.content.Context import com.android.systemui.plugins.qs.QSFactory import com.android.systemui.plugins.qs.QSTile -import com.android.systemui.plugins.qs.QSTileView class FakeQSFactory(private val tileCreator: (String) -> QSTile?) : QSFactory { override fun createTile(tileSpec: String): QSTile? { return tileCreator(tileSpec) } - - override fun createTileView( - context: Context?, - tile: QSTile?, - collapsedView: Boolean - ): QSTileView { - throw NotImplementedError("Not implemented") - } } |