Layout improvements for notification pages

Changes for upcoming theming changes in Settings:
- replacing some margins with padding
- merging some (switch pref + info pref) combos into a single preference.
I flagged the one that was already launched, but changed the other directly
- added some section headers (unflagged)
- moved all app wide notification settings to a single section (unflagged)
- changed two plain text prefs into TopIntroPreference, the dedicated pref
type for that sort of UI
- fixed some UI issues with 'Show more categories' appearing too often
- removed a duplicate notifcation channel label (unflagged)
- replaced a button layout preference with ButtonPreference (unflagged)

Test: manual review with is_expressive_design_enabled on and off
Test: atest com.android.settings.notification.app
Flag: EXEMPT this feature is not using aconfig for flagging
Bug: 349652992
Change-Id: I2acd7b2eb9dbcf6929143bfde99cd67163f1f95d
This commit is contained in:
Julia Reynolds
2024-11-20 10:32:59 -05:00
parent b7e1cc472e
commit 41896428ea
30 changed files with 261 additions and 215 deletions

View File

@@ -40,6 +40,7 @@ import com.android.settings.applications.AppInfoBase;
import com.android.settings.core.SubSettingLauncher;
import com.android.settings.notification.NotificationBackend;
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.widget.ButtonPreference;
import com.android.settingslib.widget.LayoutPreference;
import java.text.Collator;
@@ -75,14 +76,12 @@ public class RecentConversationsPreferenceController extends AbstractPreferenceC
return true;
}
//TODO(b/233325816): Use ButtonPreference instead.
LayoutPreference getClearAll(PreferenceGroup parent) {
LayoutPreference pref = new LayoutPreference(
mContext, R.layout.conversations_clear_recents);
ButtonPreference getClearAll(PreferenceGroup parent) {
ButtonPreference pref = new ButtonPreference(mContext);
pref.setTitle(R.string.conversation_settings_clear_recents);
pref.setKey(getPreferenceKey() + CLEAR_ALL_KEY_SUFFIX);
pref.setOrder(1);
Button button = pref.findViewById(R.id.conversation_settings_clear_recents);
button.setOnClickListener(v -> {
pref.setOnClickListener(v -> {
try {
mPs.removeAllRecentConversations();
// Removing recents is asynchronous, so we can't immediately reload the list from
@@ -97,7 +96,8 @@ public class RecentConversationsPreferenceController extends AbstractPreferenceC
}
}
}
button.announceForAccessibility(mContext.getString(R.string.recent_convos_removed));
pref.getButton().announceForAccessibility(
mContext.getString(R.string.recent_convos_removed));
} catch (RemoteException e) {
Slog.w(TAG, "Could not clear recents", e);
}
@@ -160,25 +160,27 @@ public class RecentConversationsPreferenceController extends AbstractPreferenceC
.forEachOrdered(pref -> {
pref.setOrder(order.getAndIncrement());
mPreferenceGroup.addPreference(pref);
if (pref.hasClearListener()) {
if (pref instanceof RecentConversationPreference
&& ((RecentConversationPreference) pref).hasClearListener()) {
hasClearable.set(true);
}
});
return hasClearable.get();
}
protected RecentConversationPreference createConversationPref(
protected Preference createConversationPref(
final ConversationChannel conversation) {
final String pkg = conversation.getShortcutInfo().getPackage();
final int uid = conversation.getUid();
final String conversationId = conversation.getShortcutInfo().getId();
RecentConversationPreference pref = new RecentConversationPreference(mContext);
Preference pref = conversation.hasActiveNotifications() ? new Preference(mContext)
: new RecentConversationPreference(mContext);
if (!conversation.hasActiveNotifications()) {
pref.setOnClearClickListener(() -> {
((RecentConversationPreference) pref).setOnClearClickListener(() -> {
try {
mPs.removeRecentConversation(pkg, UserHandle.getUserId(uid), conversationId);
pref.getClearView().announceForAccessibility(
((RecentConversationPreference) pref).getClearView().announceForAccessibility(
mContext.getString(R.string.recent_convo_removed));
mPreferenceGroup.removePreference(pref);
} catch (RemoteException e) {