From 45f1e819d36043991c11d52fdcc551de777901fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C3=ADas=20Hern=C3=A1ndez?= Date: Mon, 1 Jul 2024 18:25:54 +0200 Subject: [PATCH] Icon picker: Styling improvements Instead of a the plain appearance of a EntityHeaderController, make the top icon bigger and use the same circled style as the choices in the list. Also highlight the current icon in the list as selected, even if it is the default for the mode type. Also cleaned up controllers that don't need a ZenModesBackend to not receive it. (Both of these changes also line up with the "new mode" fragment that is incoming). Bug: 333901673 Bug: 326442408 Test: atest com.android.settings.notification.modes Flag: android.app.modes_ui Change-Id: I0c9f3e34019a1a6c48658933dde545ad8d7399ae --- res/layout/modes_icon_list_item.xml | 4 +- res/values/dimens.xml | 6 +- .../AbstractZenModePreferenceController.java | 35 ++++++---- .../settings/notification/modes/IconUtil.java | 65 +++++++++++++------ .../ZenModeActionsPreferenceController.java | 7 +- .../ZenModeAppsPreferenceController.java | 3 +- .../ZenModeCallsLinkPreferenceController.java | 5 +- .../modes/ZenModeDisplayFragment.java | 2 +- .../notification/modes/ZenModeFragment.java | 8 +-- .../modes/ZenModeHeaderController.java | 7 +- .../modes/ZenModeIconPickerFragment.java | 5 +- ...odeIconPickerIconPreferenceController.java | 19 ++++-- ...odeIconPickerListPreferenceController.java | 23 +++++-- ...nModeMessagesLinkPreferenceController.java | 5 +- ...nModeNotifVisLinkPreferenceController.java | 5 +- .../ZenModeOtherLinkPreferenceController.java | 5 +- .../modes/ZenModePeopleFragment.java | 4 +- ...ZenModePeopleLinkPreferenceController.java | 5 +- ...ModeCallsLinkPreferenceControllerTest.java | 5 +- ...conPickerListPreferenceControllerTest.java | 4 +- ...eMessagesLinkPreferenceControllerTest.java | 5 +- ...eNotifVisLinkPreferenceControllerTest.java | 5 +- ...ModeOtherLinkPreferenceControllerTest.java | 5 +- ...odePeopleLinkPreferenceControllerTest.java | 6 +- 24 files changed, 135 insertions(+), 108 deletions(-) diff --git a/res/layout/modes_icon_list_item.xml b/res/layout/modes_icon_list_item.xml index aa45de33b72..72aef528889 100644 --- a/res/layout/modes_icon_list_item.xml +++ b/res/layout/modes_icon_list_item.xml @@ -24,8 +24,8 @@ diff --git a/res/values/dimens.xml b/res/values/dimens.xml index d34647449df..ce48720cf78 100755 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -502,7 +502,9 @@ 30dp + 90dp + 48dp 96dp - 56dp - 32dp + 56dp + 32dp diff --git a/src/com/android/settings/notification/modes/AbstractZenModePreferenceController.java b/src/com/android/settings/notification/modes/AbstractZenModePreferenceController.java index a4bd2aac5f6..c740847af0e 100644 --- a/src/com/android/settings/notification/modes/AbstractZenModePreferenceController.java +++ b/src/com/android/settings/notification/modes/AbstractZenModePreferenceController.java @@ -16,6 +16,8 @@ package com.android.settings.notification.modes; +import static com.google.common.base.Preconditions.checkState; + import android.app.Flags; import android.content.Context; import android.service.notification.ZenPolicy; @@ -30,8 +32,6 @@ import com.android.settingslib.core.AbstractPreferenceController; import com.android.settingslib.notification.modes.ZenMode; import com.android.settingslib.notification.modes.ZenModesBackend; -import com.google.common.base.Preconditions; - import java.util.function.Function; /** @@ -41,8 +41,8 @@ abstract class AbstractZenModePreferenceController extends AbstractPreferenceCon private static final String TAG = "AbstractZenModePreferenceController"; - @Nullable - protected ZenModesBackend mBackend; + @Nullable protected final ZenModesBackend mBackend; + @Nullable // only until setZenMode() is called private ZenMode mZenMode; @@ -50,14 +50,27 @@ abstract class AbstractZenModePreferenceController extends AbstractPreferenceCon @NonNull private final String mKey; - // ZenModesBackend should only be passed in if the preference controller may set the user's - // policy for this zen mode. Otherwise, if the preference controller is essentially read-only - // and leads to a further Settings screen, backend should be null. - AbstractZenModePreferenceController(@NonNull Context context, @NonNull String key, - @Nullable ZenModesBackend backend) { + /** + * Constructor suitable for "read-only" controllers (e.g. link to a different sub-screen. + * Controllers that call this constructor to initialize themselves cannot call + * {@link #saveMode} or {@link #savePolicy} later. + */ + AbstractZenModePreferenceController(@NonNull Context context, @NonNull String key) { super(context); - mBackend = backend; mKey = key; + mBackend = null; + } + + /** + * Constructor suitable for controllers that will update the associated {@link ZenMode}. + * Controllers that call this constructor to initialize themselves may call {@link #saveMode} or + * {@link #savePolicy} later. + */ + AbstractZenModePreferenceController(@NonNull Context context, @NonNull String key, + @NonNull ZenModesBackend backend) { + super(context); + mKey = key; + mBackend = backend; } @Override @@ -135,7 +148,7 @@ abstract class AbstractZenModePreferenceController extends AbstractPreferenceCon * instance is ok. */ protected final boolean saveMode(Function updater) { - Preconditions.checkState(mBackend != null); + checkState(mBackend != null); ZenMode mode = mZenMode; if (mode == null) { Log.wtf(TAG, "Cannot save mode, it hasn't been loaded (" + getClass() + ")"); diff --git a/src/com/android/settings/notification/modes/IconUtil.java b/src/com/android/settings/notification/modes/IconUtil.java index 56967c89d00..d07abf34b79 100644 --- a/src/com/android/settings/notification/modes/IconUtil.java +++ b/src/com/android/settings/notification/modes/IconUtil.java @@ -19,14 +19,17 @@ package com.android.settings.notification.modes; import static com.google.common.base.Preconditions.checkNotNull; import android.content.Context; +import android.content.res.ColorStateList; import android.graphics.drawable.Drawable; import android.graphics.drawable.LayerDrawable; import android.graphics.drawable.ShapeDrawable; import android.graphics.drawable.shapes.OvalShape; +import android.view.Gravity; import androidx.annotation.AttrRes; import androidx.annotation.DrawableRes; import androidx.annotation.NonNull; +import androidx.annotation.Px; import com.android.settings.R; import com.android.settingslib.Utils; @@ -49,32 +52,52 @@ class IconUtil { } /** - * Returns a variant of the supplied {@code icon} to be used in the icon picker. The inner icon - * is 36x36dp and it's contained into a circle of diameter 54dp. It's also set up so that - * selection and pressed states are represented in the color. + * Returns a variant of the supplied {@code icon} to be used as the header in the icon picker. + * The inner icon is 48x48dp and it's contained into a circle of diameter 90dp. */ - static Drawable makeIconCircle(@NonNull Context context, @NonNull Drawable icon) { + static Drawable makeBigIconCircle(@NonNull Context context, Drawable icon) { + return composeIconCircle( + Utils.getColorAttr(context, + com.android.internal.R.attr.materialColorSecondaryContainer), + context.getResources().getDimensionPixelSize( + R.dimen.zen_mode_icon_list_header_circle_diameter), + icon, + Utils.getColorAttr(context, + com.android.internal.R.attr.materialColorOnSecondaryContainer), + context.getResources().getDimensionPixelSize( + R.dimen.zen_mode_icon_list_header_icon_size)); + } + + /** + * Returns a variant of the supplied {@code icon} to be used as an option in the icon picker. + * The inner icon is 36x36dp and it's contained into a circle of diameter 54dp. It's also set up + * so that selection and pressed states are represented in the color. + */ + static Drawable makeSmallIconCircle(@NonNull Context context, @DrawableRes int iconResId) { + return composeIconCircle( + context.getColorStateList(R.color.modes_icon_picker_item_background), + context.getResources().getDimensionPixelSize( + R.dimen.zen_mode_icon_list_item_circle_diameter), + checkNotNull(context.getDrawable(iconResId)), + context.getColorStateList(R.color.modes_icon_picker_item_icon), + context.getResources().getDimensionPixelSize( + R.dimen.zen_mode_icon_list_item_icon_size)); + } + + private static Drawable composeIconCircle(ColorStateList circleColor, @Px int circleDiameterPx, + Drawable icon, ColorStateList iconColor, @Px int iconSizePx) { ShapeDrawable background = new ShapeDrawable(new OvalShape()); - background.setTintList( - context.getColorStateList(R.color.modes_icon_picker_item_background)); - icon = icon.mutate(); - icon.setTintList( - context.getColorStateList(R.color.modes_icon_picker_item_icon)); + background.setTintList(circleColor); + Drawable foreground = checkNotNull(icon.getConstantState()).newDrawable().mutate(); + foreground.setTintList(iconColor); - LayerDrawable layerDrawable = new LayerDrawable(new Drawable[] { background, icon }); + LayerDrawable layerDrawable = new LayerDrawable(new Drawable[] { background, foreground }); - int circleDiameter = context.getResources().getDimensionPixelSize( - R.dimen.zen_mode_icon_list_circle_diameter); - int iconSize = context.getResources().getDimensionPixelSize( - R.dimen.zen_mode_icon_list_icon_size); - int iconPadding = (circleDiameter - iconSize) / 2; - layerDrawable.setBounds(0, 0, circleDiameter, circleDiameter); - layerDrawable.setLayerInset(1, iconPadding, iconPadding, iconPadding, iconPadding); + layerDrawable.setBounds(0, 0, circleDiameterPx, circleDiameterPx); + layerDrawable.setLayerSize(0, circleDiameterPx, circleDiameterPx); + layerDrawable.setLayerGravity(1, Gravity.CENTER); + layerDrawable.setLayerSize(1, iconSizePx, iconSizePx); return layerDrawable; } - - static Drawable makeIconCircle(@NonNull Context context, @DrawableRes int iconResId) { - return makeIconCircle(context, checkNotNull(context.getDrawable(iconResId))); - } } diff --git a/src/com/android/settings/notification/modes/ZenModeActionsPreferenceController.java b/src/com/android/settings/notification/modes/ZenModeActionsPreferenceController.java index 914683fb86c..2561a7b630e 100644 --- a/src/com/android/settings/notification/modes/ZenModeActionsPreferenceController.java +++ b/src/com/android/settings/notification/modes/ZenModeActionsPreferenceController.java @@ -22,20 +22,17 @@ import android.content.Context; import android.os.Bundle; import androidx.annotation.NonNull; -import androidx.annotation.Nullable; import androidx.preference.Preference; import com.android.settings.R; import com.android.settings.core.SubSettingLauncher; import com.android.settingslib.notification.modes.ZenMode; -import com.android.settingslib.notification.modes.ZenModesBackend; import com.android.settingslib.widget.ActionButtonsPreference; class ZenModeActionsPreferenceController extends AbstractZenModePreferenceController { - ZenModeActionsPreferenceController(@NonNull Context context, @NonNull String key, - @Nullable ZenModesBackend backend) { - super(context, key, backend); + ZenModeActionsPreferenceController(@NonNull Context context, @NonNull String key) { + super(context, key); } @Override diff --git a/src/com/android/settings/notification/modes/ZenModeAppsPreferenceController.java b/src/com/android/settings/notification/modes/ZenModeAppsPreferenceController.java index 1d807ed47b4..522f191c37f 100644 --- a/src/com/android/settings/notification/modes/ZenModeAppsPreferenceController.java +++ b/src/com/android/settings/notification/modes/ZenModeAppsPreferenceController.java @@ -24,7 +24,6 @@ import android.os.Bundle; import android.service.notification.ZenPolicy; import androidx.annotation.NonNull; -import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; import androidx.preference.Preference; import androidx.preference.PreferenceScreen; @@ -44,7 +43,7 @@ public class ZenModeAppsPreferenceController extends String mModeId; public ZenModeAppsPreferenceController(@NonNull Context context, - @NonNull String key, @Nullable ZenModesBackend backend) { + @NonNull String key, @NonNull ZenModesBackend backend) { super(context, key, backend); } diff --git a/src/com/android/settings/notification/modes/ZenModeCallsLinkPreferenceController.java b/src/com/android/settings/notification/modes/ZenModeCallsLinkPreferenceController.java index e5c1e480ee6..d8850191762 100644 --- a/src/com/android/settings/notification/modes/ZenModeCallsLinkPreferenceController.java +++ b/src/com/android/settings/notification/modes/ZenModeCallsLinkPreferenceController.java @@ -26,15 +26,14 @@ import androidx.preference.Preference; import com.android.settings.core.SubSettingLauncher; import com.android.settingslib.notification.modes.ZenMode; -import com.android.settingslib.notification.modes.ZenModesBackend; class ZenModeCallsLinkPreferenceController extends AbstractZenModePreferenceController { private final ZenModeSummaryHelper mSummaryHelper; public ZenModeCallsLinkPreferenceController(Context context, String key, - ZenModesBackend backend, ZenHelperBackend helperBackend) { - super(context, key, backend); + ZenHelperBackend helperBackend) { + super(context, key); mSummaryHelper = new ZenModeSummaryHelper(context, helperBackend); } diff --git a/src/com/android/settings/notification/modes/ZenModeDisplayFragment.java b/src/com/android/settings/notification/modes/ZenModeDisplayFragment.java index 8c3b8261f74..38ac8f31072 100644 --- a/src/com/android/settings/notification/modes/ZenModeDisplayFragment.java +++ b/src/com/android/settings/notification/modes/ZenModeDisplayFragment.java @@ -35,7 +35,7 @@ public class ZenModeDisplayFragment extends ZenModeFragmentBase { protected List createPreferenceControllers(Context context) { List prefControllers = new ArrayList<>(); prefControllers.add(new ZenModeNotifVisLinkPreferenceController( - context, "notification_visibility", mBackend, mHelperBackend)); + context, "notification_visibility", mHelperBackend)); prefControllers.add(new ZenModeDisplayEffectPreferenceController( context, "effect_greyscale", mBackend)); prefControllers.add(new ZenModeDisplayEffectPreferenceController( diff --git a/src/com/android/settings/notification/modes/ZenModeFragment.java b/src/com/android/settings/notification/modes/ZenModeFragment.java index bb315d9cae0..5e3fc89610d 100644 --- a/src/com/android/settings/notification/modes/ZenModeFragment.java +++ b/src/com/android/settings/notification/modes/ZenModeFragment.java @@ -47,18 +47,18 @@ public class ZenModeFragment extends ZenModeFragmentBase { @Override protected List createPreferenceControllers(Context context) { List prefControllers = new ArrayList<>(); - prefControllers.add(new ZenModeHeaderController(context, "header", this, mBackend)); + prefControllers.add(new ZenModeHeaderController(context, "header", this)); prefControllers.add( new ZenModeButtonPreferenceController(context, "activate", this, mBackend)); - prefControllers.add(new ZenModeActionsPreferenceController(context, "actions", mBackend)); + prefControllers.add(new ZenModeActionsPreferenceController(context, "actions")); prefControllers.add(new ZenModePeopleLinkPreferenceController( - context, "zen_mode_people", mBackend, mHelperBackend)); + context, "zen_mode_people", mHelperBackend)); prefControllers.add(new ZenModeAppsLinkPreferenceController( context, "zen_mode_apps", this, ApplicationsState.getInstance((Application) context.getApplicationContext()), mBackend, mHelperBackend)); prefControllers.add(new ZenModeOtherLinkPreferenceController( - context, "zen_other_settings", mBackend, mHelperBackend)); + context, "zen_other_settings", mHelperBackend)); prefControllers.add(new ZenModeDisplayLinkPreferenceController( context, "mode_display_settings", mBackend, mHelperBackend)); prefControllers.add(new ZenModeSetTriggerLinkPreferenceController(context, diff --git a/src/com/android/settings/notification/modes/ZenModeHeaderController.java b/src/com/android/settings/notification/modes/ZenModeHeaderController.java index 1845ee8f190..545abffe2f1 100644 --- a/src/com/android/settings/notification/modes/ZenModeHeaderController.java +++ b/src/com/android/settings/notification/modes/ZenModeHeaderController.java @@ -19,7 +19,6 @@ import android.app.Flags; import android.content.Context; import androidx.annotation.NonNull; -import androidx.annotation.Nullable; import androidx.preference.Preference; import com.android.settings.R; @@ -27,7 +26,6 @@ import com.android.settings.dashboard.DashboardFragment; import com.android.settings.widget.EntityHeaderController; import com.android.settingslib.notification.modes.ZenIconLoader; import com.android.settingslib.notification.modes.ZenMode; -import com.android.settingslib.notification.modes.ZenModesBackend; import com.android.settingslib.widget.LayoutPreference; class ZenModeHeaderController extends AbstractZenModePreferenceController { @@ -38,9 +36,8 @@ class ZenModeHeaderController extends AbstractZenModePreferenceController { ZenModeHeaderController( @NonNull Context context, @NonNull String key, - @NonNull DashboardFragment fragment, - @Nullable ZenModesBackend backend) { - super(context, key, backend); + @NonNull DashboardFragment fragment) { + super(context, key); mFragment = fragment; } diff --git a/src/com/android/settings/notification/modes/ZenModeIconPickerFragment.java b/src/com/android/settings/notification/modes/ZenModeIconPickerFragment.java index 43d9dba1b54..f065af239c4 100644 --- a/src/com/android/settings/notification/modes/ZenModeIconPickerFragment.java +++ b/src/com/android/settings/notification/modes/ZenModeIconPickerFragment.java @@ -41,10 +41,9 @@ public class ZenModeIconPickerFragment extends ZenModeFragmentBase { @Override protected List createPreferenceControllers(Context context) { return ImmutableList.of( - new ZenModeIconPickerIconPreferenceController(context, "current_icon", this, - mBackend), + new ZenModeIconPickerIconPreferenceController(context, "current_icon", this), new ZenModeIconPickerListPreferenceController(context, "icon_list", - mIconPickerListener, new IconOptionsProviderImpl(mContext), mBackend)); + mIconPickerListener)); } private final ZenModeIconPickerListPreferenceController.IconPickerListener mIconPickerListener = diff --git a/src/com/android/settings/notification/modes/ZenModeIconPickerIconPreferenceController.java b/src/com/android/settings/notification/modes/ZenModeIconPickerIconPreferenceController.java index d1d53af9ddf..70df9b651ee 100644 --- a/src/com/android/settings/notification/modes/ZenModeIconPickerIconPreferenceController.java +++ b/src/com/android/settings/notification/modes/ZenModeIconPickerIconPreferenceController.java @@ -17,9 +17,10 @@ package com.android.settings.notification.modes; import android.content.Context; +import android.view.ViewGroup; +import android.widget.ImageView; import androidx.annotation.NonNull; -import androidx.annotation.Nullable; import androidx.preference.Preference; import com.android.settings.R; @@ -27,17 +28,17 @@ import com.android.settings.dashboard.DashboardFragment; import com.android.settings.widget.EntityHeaderController; import com.android.settingslib.notification.modes.ZenIconLoader; import com.android.settingslib.notification.modes.ZenMode; -import com.android.settingslib.notification.modes.ZenModesBackend; import com.android.settingslib.widget.LayoutPreference; +/** Controller used for displaying the currently-chosen icon at the top of the icon picker. */ class ZenModeIconPickerIconPreferenceController extends AbstractZenModePreferenceController { private final DashboardFragment mFragment; private EntityHeaderController mHeaderController; ZenModeIconPickerIconPreferenceController(@NonNull Context context, @NonNull String key, - @NonNull DashboardFragment fragment, @Nullable ZenModesBackend backend) { - super(context, key, backend); + @NonNull DashboardFragment fragment) { + super(context, key); mFragment = fragment; } @@ -51,11 +52,19 @@ class ZenModeIconPickerIconPreferenceController extends AbstractZenModePreferenc mFragment.getActivity(), mFragment, pref.findViewById(R.id.entity_header)); + + ImageView iconView = pref.findViewById(R.id.entity_header_icon); + ViewGroup.LayoutParams layoutParams = iconView.getLayoutParams(); + int imageSizePx = iconView.getContext().getResources().getDimensionPixelSize( + R.dimen.zen_mode_icon_list_header_circle_diameter); + layoutParams.width = imageSizePx; + layoutParams.height = imageSizePx; + iconView.setLayoutParams(layoutParams); } FutureUtil.whenDone( zenMode.getIcon(mContext, ZenIconLoader.getInstance()), - icon -> mHeaderController.setIcon(IconUtil.applyNormalTint(mContext, icon)) + icon -> mHeaderController.setIcon(IconUtil.makeBigIconCircle(mContext, icon)) .done(/* rebindActions= */ false), mContext.getMainExecutor()); } diff --git a/src/com/android/settings/notification/modes/ZenModeIconPickerListPreferenceController.java b/src/com/android/settings/notification/modes/ZenModeIconPickerListPreferenceController.java index e663354231e..512dabb4437 100644 --- a/src/com/android/settings/notification/modes/ZenModeIconPickerListPreferenceController.java +++ b/src/com/android/settings/notification/modes/ZenModeIconPickerListPreferenceController.java @@ -26,6 +26,7 @@ import android.widget.ImageView; import androidx.annotation.DrawableRes; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.annotation.VisibleForTesting; import androidx.preference.Preference; import androidx.preference.PreferenceScreen; import androidx.recyclerview.widget.GridLayoutManager; @@ -33,8 +34,8 @@ import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.SimpleItemAnimator; import com.android.settings.R; +import com.android.settingslib.notification.modes.ZenIconLoader; import com.android.settingslib.notification.modes.ZenMode; -import com.android.settingslib.notification.modes.ZenModesBackend; import com.android.settingslib.widget.LayoutPreference; import com.google.common.collect.ImmutableList; @@ -51,9 +52,15 @@ class ZenModeIconPickerListPreferenceController extends AbstractZenModePreferenc private @DrawableRes int mCurrentIconResId; ZenModeIconPickerListPreferenceController(@NonNull Context context, @NonNull String key, - @NonNull IconPickerListener listener, @NonNull IconOptionsProvider iconOptionsProvider, - @Nullable ZenModesBackend backend) { - super(context, key, backend); + @NonNull IconPickerListener listener) { + this(context, key, listener, new IconOptionsProviderImpl(context)); + } + + @VisibleForTesting + ZenModeIconPickerListPreferenceController(@NonNull Context context, @NonNull String key, + @NonNull IconPickerListener listener, + @NonNull IconOptionsProvider iconOptionsProvider) { + super(context, key); mListener = listener; mIconOptionsProvider = iconOptionsProvider; } @@ -80,7 +87,11 @@ class ZenModeIconPickerListPreferenceController extends AbstractZenModePreferenc @Override void updateState(Preference preference, @NonNull ZenMode zenMode) { - updateIconSelection(zenMode.getRule().getIconResId()); + @DrawableRes int iconResId = zenMode.getRule().getIconResId(); + if (iconResId == 0) { + iconResId = ZenIconLoader.getIconResourceIdFromType(zenMode.getType()); + } + updateIconSelection(iconResId); } private void updateIconSelection(@DrawableRes int iconResId) { @@ -145,7 +156,7 @@ class ZenModeIconPickerListPreferenceController extends AbstractZenModePreferenc public void onBindViewHolder(@NonNull IconHolder holder, int position) { IconOptionsProvider.IconInfo iconInfo = mIconResources.get(position); Drawable iconDrawable = mIconCache.computeIfAbsent(iconInfo, - info -> IconUtil.makeIconCircle(mContext, info.resId())); + info -> IconUtil.makeSmallIconCircle(mContext, info.resId())); holder.bindIcon(iconInfo, iconDrawable); } diff --git a/src/com/android/settings/notification/modes/ZenModeMessagesLinkPreferenceController.java b/src/com/android/settings/notification/modes/ZenModeMessagesLinkPreferenceController.java index 9b7c8a1b757..4c0b758e7cb 100644 --- a/src/com/android/settings/notification/modes/ZenModeMessagesLinkPreferenceController.java +++ b/src/com/android/settings/notification/modes/ZenModeMessagesLinkPreferenceController.java @@ -26,14 +26,13 @@ import androidx.preference.Preference; import com.android.settings.core.SubSettingLauncher; import com.android.settingslib.notification.modes.ZenMode; -import com.android.settingslib.notification.modes.ZenModesBackend; class ZenModeMessagesLinkPreferenceController extends AbstractZenModePreferenceController { private final ZenModeSummaryHelper mSummaryHelper; public ZenModeMessagesLinkPreferenceController(Context context, String key, - ZenModesBackend backend, ZenHelperBackend helperBackend) { - super(context, key, backend); + ZenHelperBackend helperBackend) { + super(context, key); mSummaryHelper = new ZenModeSummaryHelper(context, helperBackend); } diff --git a/src/com/android/settings/notification/modes/ZenModeNotifVisLinkPreferenceController.java b/src/com/android/settings/notification/modes/ZenModeNotifVisLinkPreferenceController.java index a2d941108ae..622c4a2db48 100644 --- a/src/com/android/settings/notification/modes/ZenModeNotifVisLinkPreferenceController.java +++ b/src/com/android/settings/notification/modes/ZenModeNotifVisLinkPreferenceController.java @@ -27,15 +27,14 @@ import androidx.preference.Preference; import com.android.settings.core.SubSettingLauncher; import com.android.settingslib.notification.modes.ZenMode; -import com.android.settingslib.notification.modes.ZenModesBackend; class ZenModeNotifVisLinkPreferenceController extends AbstractZenModePreferenceController { private final ZenModeSummaryHelper mSummaryBuilder; public ZenModeNotifVisLinkPreferenceController(Context context, String key, - ZenModesBackend backend, ZenHelperBackend helperBackend) { - super(context, key, backend); + ZenHelperBackend helperBackend) { + super(context, key); mSummaryBuilder = new ZenModeSummaryHelper(context, helperBackend); } diff --git a/src/com/android/settings/notification/modes/ZenModeOtherLinkPreferenceController.java b/src/com/android/settings/notification/modes/ZenModeOtherLinkPreferenceController.java index 99625ebc574..248ef1dd585 100644 --- a/src/com/android/settings/notification/modes/ZenModeOtherLinkPreferenceController.java +++ b/src/com/android/settings/notification/modes/ZenModeOtherLinkPreferenceController.java @@ -27,7 +27,6 @@ import androidx.preference.Preference; import com.android.settings.core.SubSettingLauncher; import com.android.settingslib.notification.modes.ZenMode; -import com.android.settingslib.notification.modes.ZenModesBackend; /** * Preference with a link and summary about what other sounds can break through the mode @@ -37,8 +36,8 @@ class ZenModeOtherLinkPreferenceController extends AbstractZenModePreferenceCont private final ZenModeSummaryHelper mSummaryHelper; public ZenModeOtherLinkPreferenceController(Context context, String key, - ZenModesBackend backend, ZenHelperBackend helperBackend) { - super(context, key, backend); + ZenHelperBackend helperBackend) { + super(context, key); mSummaryHelper = new ZenModeSummaryHelper(mContext, helperBackend); } diff --git a/src/com/android/settings/notification/modes/ZenModePeopleFragment.java b/src/com/android/settings/notification/modes/ZenModePeopleFragment.java index 448712ce0e8..f541d132010 100644 --- a/src/com/android/settings/notification/modes/ZenModePeopleFragment.java +++ b/src/com/android/settings/notification/modes/ZenModePeopleFragment.java @@ -35,9 +35,9 @@ public class ZenModePeopleFragment extends ZenModeFragmentBase { protected List createPreferenceControllers(Context context) { List prefControllers = new ArrayList<>(); prefControllers.add(new ZenModeCallsLinkPreferenceController( - context, "zen_mode_people_calls", mBackend, mHelperBackend)); + context, "zen_mode_people_calls", mHelperBackend)); prefControllers.add(new ZenModeMessagesLinkPreferenceController( - context, "zen_mode_people_messages", mBackend, mHelperBackend)); + context, "zen_mode_people_messages", mHelperBackend)); return prefControllers; } diff --git a/src/com/android/settings/notification/modes/ZenModePeopleLinkPreferenceController.java b/src/com/android/settings/notification/modes/ZenModePeopleLinkPreferenceController.java index 1613a010c35..936cea6ce5c 100644 --- a/src/com/android/settings/notification/modes/ZenModePeopleLinkPreferenceController.java +++ b/src/com/android/settings/notification/modes/ZenModePeopleLinkPreferenceController.java @@ -27,7 +27,6 @@ import androidx.preference.Preference; import com.android.settings.core.SubSettingLauncher; import com.android.settingslib.notification.modes.ZenMode; -import com.android.settingslib.notification.modes.ZenModesBackend; /** * Preference with a link and summary about what calls and messages can break through the mode @@ -37,8 +36,8 @@ class ZenModePeopleLinkPreferenceController extends AbstractZenModePreferenceCon private final ZenModeSummaryHelper mSummaryHelper; public ZenModePeopleLinkPreferenceController(Context context, String key, - ZenModesBackend backend, ZenHelperBackend helperBackend) { - super(context, key, backend); + ZenHelperBackend helperBackend) { + super(context, key); mSummaryHelper = new ZenModeSummaryHelper(mContext, helperBackend); } diff --git a/tests/robotests/src/com/android/settings/notification/modes/ZenModeCallsLinkPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/modes/ZenModeCallsLinkPreferenceControllerTest.java index 058b2d7d566..e50d2941fc3 100644 --- a/tests/robotests/src/com/android/settings/notification/modes/ZenModeCallsLinkPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/notification/modes/ZenModeCallsLinkPreferenceControllerTest.java @@ -27,8 +27,6 @@ import android.platform.test.flag.junit.SetFlagsRule; import androidx.preference.Preference; -import com.android.settingslib.notification.modes.ZenModesBackend; - import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -47,7 +45,6 @@ public final class ZenModeCallsLinkPreferenceControllerTest { public final SetFlagsRule mSetFlagsRule = new SetFlagsRule(); private Context mContext; - @Mock private ZenModesBackend mBackend; @Mock private ZenHelperBackend mHelperBackend; @Before @@ -57,7 +54,7 @@ public final class ZenModeCallsLinkPreferenceControllerTest { mContext = RuntimeEnvironment.application; mController = new ZenModeCallsLinkPreferenceController( - mContext, "something", mBackend, mHelperBackend); + mContext, "something", mHelperBackend); } @Test diff --git a/tests/robotests/src/com/android/settings/notification/modes/ZenModeIconPickerListPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/modes/ZenModeIconPickerListPreferenceControllerTest.java index e0ca306c71c..4d30ce95ee1 100644 --- a/tests/robotests/src/com/android/settings/notification/modes/ZenModeIconPickerListPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/notification/modes/ZenModeIconPickerListPreferenceControllerTest.java @@ -19,7 +19,6 @@ package com.android.settings.notification.modes; import static com.google.common.truth.Truth.assertThat; import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -34,7 +33,6 @@ import androidx.recyclerview.widget.RecyclerView; import com.android.settings.R; import com.android.settingslib.notification.modes.ZenMode; -import com.android.settingslib.notification.modes.ZenModesBackend; import com.android.settingslib.widget.LayoutPreference; import com.google.common.collect.ImmutableList; @@ -64,7 +62,7 @@ public class ZenModeIconPickerListPreferenceControllerTest { mController = new ZenModeIconPickerListPreferenceController( RuntimeEnvironment.getApplication(), "icon_list", mListener, - new TestIconOptionsProvider(), mock(ZenModesBackend.class)); + new TestIconOptionsProvider()); mRecyclerView = new RecyclerView(mContext); mRecyclerView.setId(R.id.icon_list); diff --git a/tests/robotests/src/com/android/settings/notification/modes/ZenModeMessagesLinkPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/modes/ZenModeMessagesLinkPreferenceControllerTest.java index 288359aeb57..dda58ae7482 100644 --- a/tests/robotests/src/com/android/settings/notification/modes/ZenModeMessagesLinkPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/notification/modes/ZenModeMessagesLinkPreferenceControllerTest.java @@ -27,8 +27,6 @@ import android.platform.test.flag.junit.SetFlagsRule; import androidx.preference.Preference; -import com.android.settingslib.notification.modes.ZenModesBackend; - import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -47,7 +45,6 @@ public final class ZenModeMessagesLinkPreferenceControllerTest { public final SetFlagsRule mSetFlagsRule = new SetFlagsRule(); private Context mContext; - @Mock private ZenModesBackend mBackend; @Mock private ZenHelperBackend mHelperBackend; @Before @@ -57,7 +54,7 @@ public final class ZenModeMessagesLinkPreferenceControllerTest { mContext = RuntimeEnvironment.application; mController = new ZenModeMessagesLinkPreferenceController( - mContext, "something", mBackend, mHelperBackend); + mContext, "something", mHelperBackend); } @Test diff --git a/tests/robotests/src/com/android/settings/notification/modes/ZenModeNotifVisLinkPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/modes/ZenModeNotifVisLinkPreferenceControllerTest.java index ee7340bd526..bfa99a0a927 100644 --- a/tests/robotests/src/com/android/settings/notification/modes/ZenModeNotifVisLinkPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/notification/modes/ZenModeNotifVisLinkPreferenceControllerTest.java @@ -27,8 +27,6 @@ import android.platform.test.flag.junit.SetFlagsRule; import androidx.preference.Preference; -import com.android.settingslib.notification.modes.ZenModesBackend; - import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -47,7 +45,6 @@ public final class ZenModeNotifVisLinkPreferenceControllerTest { public final SetFlagsRule mSetFlagsRule = new SetFlagsRule(); private Context mContext; - @Mock private ZenModesBackend mBackend; @Mock private ZenHelperBackend mHelperBackend; @Before @@ -57,7 +54,7 @@ public final class ZenModeNotifVisLinkPreferenceControllerTest { mContext = RuntimeEnvironment.application; mController = new ZenModeNotifVisLinkPreferenceController( - mContext, "something", mBackend, mHelperBackend); + mContext, "something", mHelperBackend); } @Test diff --git a/tests/robotests/src/com/android/settings/notification/modes/ZenModeOtherLinkPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/modes/ZenModeOtherLinkPreferenceControllerTest.java index c4d03fe3360..39ba9e8aa82 100644 --- a/tests/robotests/src/com/android/settings/notification/modes/ZenModeOtherLinkPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/notification/modes/ZenModeOtherLinkPreferenceControllerTest.java @@ -27,8 +27,6 @@ import android.platform.test.flag.junit.SetFlagsRule; import androidx.preference.Preference; -import com.android.settingslib.notification.modes.ZenModesBackend; - import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -48,7 +46,6 @@ public final class ZenModeOtherLinkPreferenceControllerTest { public final SetFlagsRule mSetFlagsRule = new SetFlagsRule(); private Context mContext; - @Mock private ZenModesBackend mBackend; @Mock private ZenHelperBackend mHelperBackend; @Before @@ -58,7 +55,7 @@ public final class ZenModeOtherLinkPreferenceControllerTest { mContext = RuntimeEnvironment.application; mController = new ZenModeOtherLinkPreferenceController( - mContext, "something", mBackend, mHelperBackend); + mContext, "something", mHelperBackend); } @Test diff --git a/tests/robotests/src/com/android/settings/notification/modes/ZenModePeopleLinkPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/modes/ZenModePeopleLinkPreferenceControllerTest.java index 6591b724c58..9d9dd9892a7 100644 --- a/tests/robotests/src/com/android/settings/notification/modes/ZenModePeopleLinkPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/notification/modes/ZenModePeopleLinkPreferenceControllerTest.java @@ -27,8 +27,6 @@ import android.platform.test.flag.junit.SetFlagsRule; import androidx.preference.Preference; -import com.android.settingslib.notification.modes.ZenModesBackend; - import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -48,8 +46,6 @@ public final class ZenModePeopleLinkPreferenceControllerTest { private Context mContext; @Mock - private ZenModesBackend mBackend; - @Mock private ZenHelperBackend mHelperBackend; @Before @@ -59,7 +55,7 @@ public final class ZenModePeopleLinkPreferenceControllerTest { mContext = RuntimeEnvironment.application; mController = new ZenModePeopleLinkPreferenceController( - mContext, "something", mBackend, mHelperBackend); + mContext, "something", mHelperBackend); } @Test