Loading src/com/android/settings/notification/modes/CircularIconsPreference.java +31 −0 Original line number Diff line number Diff line Loading @@ -51,6 +51,8 @@ import java.util.concurrent.Executor; public class CircularIconsPreference extends RestrictedPreference { private static final float DISABLED_ITEM_ALPHA = 0.3f; private Executor mUiExecutor; @Nullable private LinearLayout mIconContainer; Loading Loading @@ -98,6 +100,14 @@ public class CircularIconsPreference extends RestrictedPreference { displayIconsIfPending(); } @Override public void setEnabled(boolean enabled) { super.setEnabled(enabled); if (mIconContainer != null) { applyEnabledToIcons(mIconContainer, enabled); } } private void displayIconsIfPending() { CircularIconSet<?> pendingIconSet = mPendingDisplayIconSet; if (pendingIconSet != null) { Loading Loading @@ -211,6 +221,8 @@ public class CircularIconsPreference extends RestrictedPreference { textView.setText(getContext().getString(R.string.zen_mode_plus_n_items, extraItems)); } applyEnabledToIcons(mIconContainer, isEnabled()); // Display icons when all are ready (more consistent than randomly loading). mPendingLoadIconsFuture = Futures.allAsList(iconFutures); FutureUtil.whenDone( Loading @@ -224,6 +236,13 @@ public class CircularIconsPreference extends RestrictedPreference { mUiExecutor); } private void applyEnabledToIcons(ViewGroup container, boolean enabled) { for (int i = 0; i < container.getChildCount(); i++) { View child = container.getChildAt(i); child.setAlpha(enabled ? 1.0f : DISABLED_ITEM_ALPHA); } } private static Drawable getPlaceholderImage(Context context) { ShapeDrawable placeholder = new ShapeDrawable(new OvalShape()); placeholder.setTintList(Utils.getColorAttr(context, Loading @@ -249,6 +268,18 @@ public class CircularIconsPreference extends RestrictedPreference { return parent.getChildAt(parent.getChildCount() - 1); } @VisibleForTesting(otherwise = VisibleForTesting.NONE) List<View> getViews() { if (mIconContainer == null) { return List.of(); } ArrayList<View> views = new ArrayList<>(); for (int i = 0; i < mIconContainer.getChildCount(); i++) { views.add(mIconContainer.getChildAt(i)); } return views; } @VisibleForTesting(otherwise = VisibleForTesting.NONE) List<Drawable> getIcons() { if (mIconContainer == null) { Loading src/com/android/settings/notification/modes/InterruptionFilterPreferenceController.java +1 −0 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ class InterruptionFilterPreferenceController extends AbstractZenModePreferenceCo @Override public void updateState(Preference preference, @NonNull ZenMode zenMode) { preference.setEnabled(zenMode.isEnabled()); boolean filteringNotifications = zenMode.getRule().getInterruptionFilter() != INTERRUPTION_FILTER_ALL; ((TwoStatePreference) preference).setChecked(filteringNotifications); Loading src/com/android/settings/notification/modes/ZenModeAppsLinkPreferenceController.java +5 −6 Original line number Diff line number Diff line Loading @@ -34,7 +34,6 @@ import androidx.preference.Preference; import com.android.settings.R; import com.android.settings.Utils; import com.android.settings.core.SubSettingLauncher; import com.android.settingslib.applications.ApplicationsState; import com.android.settingslib.applications.ApplicationsState.AppEntry; import com.android.settingslib.notification.modes.ZenMode; Loading Loading @@ -95,11 +94,11 @@ class ZenModeAppsLinkPreferenceController extends AbstractZenModePreferenceContr Bundle bundle = new Bundle(); bundle.putString(EXTRA_AUTOMATIC_ZEN_RULE_ID, zenMode.getId()); // TODO(b/332937635): Update metrics category preference.setIntent(new SubSettingLauncher(mContext) .setDestination(ZenModeAppsFragment.class.getName()) .setSourceMetricsCategory(0) .setArguments(bundle) .toIntent()); preference.setIntent( ZenSubSettingLauncher.forModeFragment(mContext, ZenModeAppsFragment.class, zenMode.getId(), 0).toIntent()); preference.setEnabled(zenMode.isEnabled()); mZenMode = zenMode; mPreference = (CircularIconsPreference) preference; Loading src/com/android/settings/notification/modes/ZenModeDisplayLinkPreferenceController.java +4 −6 Original line number Diff line number Diff line Loading @@ -24,7 +24,6 @@ import android.os.Bundle; import androidx.annotation.NonNull; import androidx.preference.Preference; import com.android.settings.core.SubSettingLauncher; import com.android.settingslib.notification.modes.ZenMode; import com.android.settingslib.notification.modes.ZenModesBackend; Loading @@ -43,11 +42,10 @@ class ZenModeDisplayLinkPreferenceController extends AbstractZenModePreferenceCo Bundle bundle = new Bundle(); bundle.putString(EXTRA_AUTOMATIC_ZEN_RULE_ID, zenMode.getId()); // TODO(b/332937635): Update metrics category preference.setIntent(new SubSettingLauncher(mContext) .setDestination(ZenModeDisplayFragment.class.getName()) .setSourceMetricsCategory(0) .setArguments(bundle) .toIntent()); preference.setIntent( ZenSubSettingLauncher.forModeFragment(mContext, ZenModeDisplayFragment.class, zenMode.getId(), 0).toIntent()); preference.setEnabled(zenMode.isEnabled()); } @Override Loading src/com/android/settings/notification/modes/ZenModeFragment.java +3 −0 Original line number Diff line number Diff line Loading @@ -53,12 +53,15 @@ public class ZenModeFragment extends ZenModeFragmentBase { prefControllers.add(new ZenModeHeaderController(context, "header", this)); prefControllers.add( new ZenModeButtonPreferenceController(context, "activate", this, mBackend)); prefControllers.add(new ZenModePreferenceCategoryController(context, "modes_filters")); prefControllers.add(new ZenModePeopleLinkPreferenceController( context, "zen_mode_people", mHelperBackend)); prefControllers.add(new ZenModeAppsLinkPreferenceController( context, "zen_mode_apps", this, mBackend, mHelperBackend)); prefControllers.add(new ZenModeOtherLinkPreferenceController( context, "zen_other_settings", mHelperBackend)); prefControllers.add( new ZenModePreferenceCategoryController(context, "modes_additional_actions")); prefControllers.add(new ZenModeDisplayLinkPreferenceController( context, "mode_display_settings", mBackend, mHelperBackend)); prefControllers.add(new ZenModeSetTriggerLinkPreferenceController(context, Loading Loading
src/com/android/settings/notification/modes/CircularIconsPreference.java +31 −0 Original line number Diff line number Diff line Loading @@ -51,6 +51,8 @@ import java.util.concurrent.Executor; public class CircularIconsPreference extends RestrictedPreference { private static final float DISABLED_ITEM_ALPHA = 0.3f; private Executor mUiExecutor; @Nullable private LinearLayout mIconContainer; Loading Loading @@ -98,6 +100,14 @@ public class CircularIconsPreference extends RestrictedPreference { displayIconsIfPending(); } @Override public void setEnabled(boolean enabled) { super.setEnabled(enabled); if (mIconContainer != null) { applyEnabledToIcons(mIconContainer, enabled); } } private void displayIconsIfPending() { CircularIconSet<?> pendingIconSet = mPendingDisplayIconSet; if (pendingIconSet != null) { Loading Loading @@ -211,6 +221,8 @@ public class CircularIconsPreference extends RestrictedPreference { textView.setText(getContext().getString(R.string.zen_mode_plus_n_items, extraItems)); } applyEnabledToIcons(mIconContainer, isEnabled()); // Display icons when all are ready (more consistent than randomly loading). mPendingLoadIconsFuture = Futures.allAsList(iconFutures); FutureUtil.whenDone( Loading @@ -224,6 +236,13 @@ public class CircularIconsPreference extends RestrictedPreference { mUiExecutor); } private void applyEnabledToIcons(ViewGroup container, boolean enabled) { for (int i = 0; i < container.getChildCount(); i++) { View child = container.getChildAt(i); child.setAlpha(enabled ? 1.0f : DISABLED_ITEM_ALPHA); } } private static Drawable getPlaceholderImage(Context context) { ShapeDrawable placeholder = new ShapeDrawable(new OvalShape()); placeholder.setTintList(Utils.getColorAttr(context, Loading @@ -249,6 +268,18 @@ public class CircularIconsPreference extends RestrictedPreference { return parent.getChildAt(parent.getChildCount() - 1); } @VisibleForTesting(otherwise = VisibleForTesting.NONE) List<View> getViews() { if (mIconContainer == null) { return List.of(); } ArrayList<View> views = new ArrayList<>(); for (int i = 0; i < mIconContainer.getChildCount(); i++) { views.add(mIconContainer.getChildAt(i)); } return views; } @VisibleForTesting(otherwise = VisibleForTesting.NONE) List<Drawable> getIcons() { if (mIconContainer == null) { Loading
src/com/android/settings/notification/modes/InterruptionFilterPreferenceController.java +1 −0 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ class InterruptionFilterPreferenceController extends AbstractZenModePreferenceCo @Override public void updateState(Preference preference, @NonNull ZenMode zenMode) { preference.setEnabled(zenMode.isEnabled()); boolean filteringNotifications = zenMode.getRule().getInterruptionFilter() != INTERRUPTION_FILTER_ALL; ((TwoStatePreference) preference).setChecked(filteringNotifications); Loading
src/com/android/settings/notification/modes/ZenModeAppsLinkPreferenceController.java +5 −6 Original line number Diff line number Diff line Loading @@ -34,7 +34,6 @@ import androidx.preference.Preference; import com.android.settings.R; import com.android.settings.Utils; import com.android.settings.core.SubSettingLauncher; import com.android.settingslib.applications.ApplicationsState; import com.android.settingslib.applications.ApplicationsState.AppEntry; import com.android.settingslib.notification.modes.ZenMode; Loading Loading @@ -95,11 +94,11 @@ class ZenModeAppsLinkPreferenceController extends AbstractZenModePreferenceContr Bundle bundle = new Bundle(); bundle.putString(EXTRA_AUTOMATIC_ZEN_RULE_ID, zenMode.getId()); // TODO(b/332937635): Update metrics category preference.setIntent(new SubSettingLauncher(mContext) .setDestination(ZenModeAppsFragment.class.getName()) .setSourceMetricsCategory(0) .setArguments(bundle) .toIntent()); preference.setIntent( ZenSubSettingLauncher.forModeFragment(mContext, ZenModeAppsFragment.class, zenMode.getId(), 0).toIntent()); preference.setEnabled(zenMode.isEnabled()); mZenMode = zenMode; mPreference = (CircularIconsPreference) preference; Loading
src/com/android/settings/notification/modes/ZenModeDisplayLinkPreferenceController.java +4 −6 Original line number Diff line number Diff line Loading @@ -24,7 +24,6 @@ import android.os.Bundle; import androidx.annotation.NonNull; import androidx.preference.Preference; import com.android.settings.core.SubSettingLauncher; import com.android.settingslib.notification.modes.ZenMode; import com.android.settingslib.notification.modes.ZenModesBackend; Loading @@ -43,11 +42,10 @@ class ZenModeDisplayLinkPreferenceController extends AbstractZenModePreferenceCo Bundle bundle = new Bundle(); bundle.putString(EXTRA_AUTOMATIC_ZEN_RULE_ID, zenMode.getId()); // TODO(b/332937635): Update metrics category preference.setIntent(new SubSettingLauncher(mContext) .setDestination(ZenModeDisplayFragment.class.getName()) .setSourceMetricsCategory(0) .setArguments(bundle) .toIntent()); preference.setIntent( ZenSubSettingLauncher.forModeFragment(mContext, ZenModeDisplayFragment.class, zenMode.getId(), 0).toIntent()); preference.setEnabled(zenMode.isEnabled()); } @Override Loading
src/com/android/settings/notification/modes/ZenModeFragment.java +3 −0 Original line number Diff line number Diff line Loading @@ -53,12 +53,15 @@ public class ZenModeFragment extends ZenModeFragmentBase { prefControllers.add(new ZenModeHeaderController(context, "header", this)); prefControllers.add( new ZenModeButtonPreferenceController(context, "activate", this, mBackend)); prefControllers.add(new ZenModePreferenceCategoryController(context, "modes_filters")); prefControllers.add(new ZenModePeopleLinkPreferenceController( context, "zen_mode_people", mHelperBackend)); prefControllers.add(new ZenModeAppsLinkPreferenceController( context, "zen_mode_apps", this, mBackend, mHelperBackend)); prefControllers.add(new ZenModeOtherLinkPreferenceController( context, "zen_other_settings", mHelperBackend)); prefControllers.add( new ZenModePreferenceCategoryController(context, "modes_additional_actions")); prefControllers.add(new ZenModeDisplayLinkPreferenceController( context, "mode_display_settings", mBackend, mHelperBackend)); prefControllers.add(new ZenModeSetTriggerLinkPreferenceController(context, Loading