Changes to icon picker for reusability in "add mode" flow

* Don't finish the fragment from the controller (ugh!) instead just report the selected icon via a listener.
* Highlight the selected icon in the list.
* Cache the icon drawables (since we're using selectors for the colors, we don't need to swap them, one per icon resource id is enough).
* Improved the tests a bit too.

Bug: 333901673
Bug: 326442408
Test: ates
Flag: android.app.modes_ui
Change-Id: Ib2ec7a7e3ed99b13f9264aa6f7c209ee3f6967a0
This commit is contained in:
Matías Hernández
2024-06-25 20:29:14 +02:00
parent 67d977b72e
commit c2d2de085d
9 changed files with 190 additions and 67 deletions

View File

@@ -18,13 +18,14 @@ package com.android.settings.notification.modes;
import android.app.AlertDialog;
import android.app.Application;
import android.app.AutomaticZenRule;
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import androidx.annotation.NonNull;
import com.android.settings.R;
import com.android.settingslib.applications.ApplicationsState;
import com.android.settingslib.core.AbstractPreferenceController;
@@ -72,11 +73,9 @@ public class ZenModeFragment extends ZenModeFragmentBase {
// Set title for the entire screen
ZenMode mode = getMode();
AutomaticZenRule azr = getAZR();
if (mode == null || azr == null) {
return;
if (mode != null) {
requireActivity().setTitle(mode.getName());
}
getActivity().setTitle(azr.getName());
}
@Override
@@ -92,7 +91,7 @@ public class ZenModeFragment extends ZenModeFragmentBase {
}
@Override
protected boolean onOptionsItemSelected(MenuItem item, ZenMode zenMode) {
protected boolean onOptionsItemSelected(MenuItem item, @NonNull ZenMode zenMode) {
switch (item.getItemId()) {
case DELETE_MODE:
new AlertDialog.Builder(mContext)