diff --git a/res/layout/notif_importance_preference.xml b/res/layout/notif_importance_preference.xml
index b2a02d14240..614856c6d9c 100644
--- a/res/layout/notif_importance_preference.xml
+++ b/res/layout/notif_importance_preference.xml
@@ -21,8 +21,8 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
- android:layout_marginStart="24dp"
- android:layout_marginEnd="16dp"
+ android:paddingStart="?android:attr/listPreferredItemPaddingStart"
+ android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
android:paddingTop="@dimen/notification_importance_toggle_marginTop"
android:paddingBottom="@dimen/notification_importance_toggle_marginTop"
android:orientation="vertical">
diff --git a/res/layout/notif_priority_conversation_preference.xml b/res/layout/notif_priority_conversation_preference.xml
index 4601c008563..326c52a5407 100644
--- a/res/layout/notif_priority_conversation_preference.xml
+++ b/res/layout/notif_priority_conversation_preference.xml
@@ -21,8 +21,8 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
- android:layout_marginStart="24dp"
- android:layout_marginEnd="16dp"
+ android:paddingStart="?android:attr/listPreferredItemPaddingStart"
+ android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
android:paddingTop="@dimen/notification_importance_toggle_marginTop"
android:paddingBottom="@dimen/notification_importance_toggle_marginTop"
android:orientation="vertical">
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 69ff0f10a6a..61bcb6efffb 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -8999,9 +8999,12 @@
Conversation section
-
+
Allow app to use conversation section
+
+ Allow app to use conversation section, although conversation features like prioritization and bubbles are not supported by this app.
+
"%1$s • %2$s"
@@ -9394,8 +9397,11 @@
This app does not send notifications
+
+ App settings
+
- Categories
+ Notification categories
Other
diff --git a/res/xml/app_notification_settings.xml b/res/xml/app_notification_settings.xml
index 06d74f608fa..b91aea9a618 100644
--- a/res/xml/app_notification_settings.xml
+++ b/res/xml/app_notification_settings.xml
@@ -30,49 +30,21 @@
-
-
-
-
-
-
-
-
-
+ android:visibility="gone"
+ android:layout="@layout/empty_view" >
-
-
-
-
-
-
+ android:visibility="gone"
+ android:layout="@layout/empty_view" />
+
-
+
-
-
+
+
-
-
+
+
+
-
-
+
-
-
+
+
-
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/res/xml/channel_notification_settings.xml b/res/xml/channel_notification_settings.xml
index a3895e38c5e..a8b536b717d 100644
--- a/res/xml/channel_notification_settings.xml
+++ b/res/xml/channel_notification_settings.xml
@@ -111,16 +111,18 @@
android:title="@string/app_notification_override_dnd_title"
android:summary="@string/app_notification_override_dnd_summary" />
-
-
+ android:order="110"/>
+
+
+
+
diff --git a/res/xml/modes_calls_settings.xml b/res/xml/modes_calls_settings.xml
index b564020cf71..e3a6fca643d 100644
--- a/res/xml/modes_calls_settings.xml
+++ b/res/xml/modes_calls_settings.xml
@@ -32,9 +32,11 @@
android:layout_height="16dp"/>
-
+
+
+
= IMPORTANCE_DEFAULT
|| mChannel.getImportance() == IMPORTANCE_UNSPECIFIED);
+ if (preference.getParent() != null) {
+ preference.getParent().setVisible(true);
+ }
} else { Log.i(TAG, "tried to updatestate on a null channel?!"); }
}
diff --git a/src/com/android/settings/notification/app/AppLinkPreferenceController.java b/src/com/android/settings/notification/app/AppLinkPreferenceController.java
index 043ae698f54..4b397d02ce9 100644
--- a/src/com/android/settings/notification/app/AppLinkPreferenceController.java
+++ b/src/com/android/settings/notification/app/AppLinkPreferenceController.java
@@ -54,6 +54,9 @@ public class AppLinkPreferenceController extends NotificationPreferenceControlle
}
public void updateState(Preference preference) {
+ if (preference.getParent() != null) {
+ preference.getParent().setVisible(true);
+ }
if (mAppRow != null) {
preference.setIntent(mAppRow.settingsIntent);
}
diff --git a/src/com/android/settings/notification/app/BadgePreferenceController.java b/src/com/android/settings/notification/app/BadgePreferenceController.java
index 9d55fa322b8..b5e65fca401 100644
--- a/src/com/android/settings/notification/app/BadgePreferenceController.java
+++ b/src/com/android/settings/notification/app/BadgePreferenceController.java
@@ -82,6 +82,9 @@ public class BadgePreferenceController extends NotificationPreferenceController
public void updateState(Preference preference) {
if (mAppRow != null) {
+ if (preference.getParent() != null) {
+ preference.getParent().setVisible(true);
+ }
RestrictedSwitchPreference pref = (RestrictedSwitchPreference) preference;
pref.setDisabledByAdmin(mAdmin);
if (mChannel != null) {
diff --git a/src/com/android/settings/notification/app/BubbleSummaryPreferenceController.java b/src/com/android/settings/notification/app/BubbleSummaryPreferenceController.java
index 8c22f926e9b..e82fe0b31a4 100644
--- a/src/com/android/settings/notification/app/BubbleSummaryPreferenceController.java
+++ b/src/com/android/settings/notification/app/BubbleSummaryPreferenceController.java
@@ -82,6 +82,9 @@ public class BubbleSummaryPreferenceController extends NotificationPreferenceCon
intent.putExtra(Settings.EXTRA_APP_UID, mAppRow.uid);
preference.setIntent(intent);
}
+ if (preference.getParent() != null) {
+ preference.getParent().setVisible(true);
+ }
}
@Override
diff --git a/src/com/android/settings/notification/app/ChannelListPreferenceController.java b/src/com/android/settings/notification/app/ChannelListPreferenceController.java
index b8dfb6a7069..66094a02f5f 100644
--- a/src/com/android/settings/notification/app/ChannelListPreferenceController.java
+++ b/src/com/android/settings/notification/app/ChannelListPreferenceController.java
@@ -58,6 +58,7 @@ public class ChannelListPreferenceController extends NotificationPreferenceContr
private List mChannelGroupList;
private PreferenceCategory mPreference;
+ int mChannelCount;
public ChannelListPreferenceController(Context context, NotificationBackend backend) {
super(context, backend);
@@ -107,6 +108,7 @@ public class ChannelListPreferenceController extends NotificationPreferenceContr
} else {
mChannelGroupList = mBackend.getGroups(mAppRow.pkg, mAppRow.uid).getList();
}
+ mChannelCount = mBackend.getChannelCount(mAppRow.pkg, mAppRow.uid);
Collections.sort(mChannelGroupList, CHANNEL_GROUP_COMPARATOR);
return null;
}
@@ -116,6 +118,7 @@ public class ChannelListPreferenceController extends NotificationPreferenceContr
if (mContext == null) {
return;
}
+
updateFullList(mPreference, mChannelGroupList);
}
}.execute();
@@ -129,25 +132,30 @@ public class ChannelListPreferenceController extends NotificationPreferenceContr
void updateFullList(@NonNull PreferenceCategory groupPrefsList,
@NonNull List channelGroups) {
if (channelGroups.isEmpty()) {
- if (groupPrefsList.getPreferenceCount() == 1
- && KEY_ZERO_CATEGORIES.equals(groupPrefsList.getPreference(0).getKey())) {
- // Ensure the titles are correct for the current language, but otherwise leave alone
- PreferenceGroup groupCategory = (PreferenceGroup) groupPrefsList.getPreference(0);
- groupCategory.setTitle(R.string.notification_channels);
- groupCategory.getPreference(0).setTitle(R.string.no_channels);
- } else {
- // Clear any contents and create the 'zero-categories' group.
+ if (mChannelCount > 0) {
groupPrefsList.removeAll();
+ } else {
+ if (groupPrefsList.getPreferenceCount() == 1
+ && KEY_ZERO_CATEGORIES.equals(groupPrefsList.getPreference(0).getKey())) {
+ // Ensure the titles are correct for the current language, but otherwise leave alone
+ PreferenceGroup groupCategory = (PreferenceGroup) groupPrefsList.getPreference(
+ 0);
+ groupCategory.setTitle(R.string.notification_channels);
+ groupCategory.getPreference(0).setTitle(R.string.no_channels);
+ } else {
+ // Clear any contents and create the 'zero-categories' group.
+ groupPrefsList.removeAll();
- PreferenceCategory groupCategory = new PreferenceCategory(mContext);
- groupCategory.setTitle(R.string.notification_channels);
- groupCategory.setKey(KEY_ZERO_CATEGORIES);
- groupPrefsList.addPreference(groupCategory);
+ PreferenceCategory groupCategory = new PreferenceCategory(mContext);
+ groupCategory.setTitle(R.string.notification_channels);
+ groupCategory.setKey(KEY_ZERO_CATEGORIES);
+ groupPrefsList.addPreference(groupCategory);
- Preference empty = new Preference(mContext);
- empty.setTitle(R.string.no_channels);
- empty.setEnabled(false);
- groupCategory.addPreference(empty);
+ Preference empty = new Preference(mContext);
+ empty.setTitle(R.string.no_channels);
+ empty.setEnabled(false);
+ groupCategory.addPreference(empty);
+ }
}
} else {
updateGroupList(groupPrefsList, channelGroups);
@@ -211,6 +219,11 @@ public class ChannelListPreferenceController extends NotificationPreferenceContr
groupPrefsList.addPreference(group);
}
}
+ Preference otherGroup = groupPrefsList.findPreference(KEY_GENERAL_CATEGORY);
+ if (otherGroup != null) {
+ otherGroup.setTitle(numFinalGroups == 1
+ ? R.string.notification_channels : R.string.notification_channels_other);
+ }
}
/**
@@ -248,8 +261,7 @@ public class ChannelListPreferenceController extends NotificationPreferenceContr
List finalOrderedPrefs = new ArrayList<>();
Preference appDefinedGroupToggle;
if (group.getId() == null) {
- // For the 'null' group, set the "Other" title.
- groupPrefGroup.setTitle(R.string.notification_channels_other);
+ groupPrefGroup.setTitle(R.string.notification_channels);
appDefinedGroupToggle = null;
} else {
// For an app-defined group, set their name and create a row to toggle 'isBlocked'.
diff --git a/src/com/android/settings/notification/app/DeletedChannelsPreferenceController.java b/src/com/android/settings/notification/app/DeletedChannelsPreferenceController.java
index 07b7fdab01d..004afe295b9 100644
--- a/src/com/android/settings/notification/app/DeletedChannelsPreferenceController.java
+++ b/src/com/android/settings/notification/app/DeletedChannelsPreferenceController.java
@@ -63,6 +63,9 @@ public class DeletedChannelsPreferenceController extends NotificationPreferenceC
}
public void updateState(Preference preference) {
+ if (preference.getParent() != null) {
+ preference.getParent().setVisible(true);
+ }
if (mAppRow != null) {
int deletedChannelCount = mBackend.getDeletedChannelCount(mAppRow.pkg, mAppRow.uid);
preference.setTitle(StringUtil.getIcuPluralsString(mContext, deletedChannelCount,
diff --git a/src/com/android/settings/notification/app/DndPreferenceController.java b/src/com/android/settings/notification/app/DndPreferenceController.java
index b65928aa915..25337879253 100644
--- a/src/com/android/settings/notification/app/DndPreferenceController.java
+++ b/src/com/android/settings/notification/app/DndPreferenceController.java
@@ -54,6 +54,9 @@ public class DndPreferenceController extends NotificationPreferenceController
public void updateState(Preference preference) {
if (mChannel != null) {
+ if (preference.getParent() != null) {
+ preference.getParent().setVisible(true);
+ }
RestrictedSwitchPreference pref = (RestrictedSwitchPreference) preference;
pref.setDisabledByAdmin(mAdmin);
pref.setEnabled(!pref.isDisabledByAdmin());
diff --git a/src/com/android/settings/notification/app/FullScreenIntentPermissionPreferenceController.kt b/src/com/android/settings/notification/app/FullScreenIntentPermissionPreferenceController.kt
index 4349b4c9f4e..6977a99a6c1 100644
--- a/src/com/android/settings/notification/app/FullScreenIntentPermissionPreferenceController.kt
+++ b/src/com/android/settings/notification/app/FullScreenIntentPermissionPreferenceController.kt
@@ -21,9 +21,9 @@ import android.app.AppOpsManager
import android.app.AppOpsManager.OP_USE_FULL_SCREEN_INTENT
import android.content.AttributionSource
import android.content.Context
-import android.content.pm.PackageManager.NameNotFoundException
import android.content.pm.PackageManager.FLAG_PERMISSION_USER_SET
import android.content.pm.PackageManager.GET_PERMISSIONS
+import android.content.pm.PackageManager.NameNotFoundException
import android.os.UserHandle
import android.permission.PermissionManager
import android.util.Log
@@ -65,6 +65,7 @@ class FullScreenIntentPermissionPreferenceController(
preference.setDisabledByAdmin(mAdmin)
preference.isEnabled = !preference.isDisabledByAdmin
preference.isChecked = isPermissionGranted()
+ preference.parent?.isVisible = true
}
override fun onPreferenceChange(preference: Preference, value: Any): Boolean {
diff --git a/src/com/android/settings/notification/app/HeaderPreferenceController.java b/src/com/android/settings/notification/app/HeaderPreferenceController.java
index 220e7b555f1..91abe815794 100644
--- a/src/com/android/settings/notification/app/HeaderPreferenceController.java
+++ b/src/com/android/settings/notification/app/HeaderPreferenceController.java
@@ -81,9 +81,8 @@ public class HeaderPreferenceController extends NotificationPreferenceController
mHeaderController = EntityHeaderController.newInstance(
activity, mFragment, pref.findViewById(R.id.entity_header));
pref = mHeaderController.setIcon(mAppRow.icon)
- .setLabel(getLabel())
- .setSummary(getSummary())
- .setSecondSummary(getSecondSummary())
+ .setLabel(getSummary())
+ .setSummary(getSecondSummary())
.setPackageName(mAppRow.pkg)
.setUid(mAppRow.uid)
.setButtonActions(EntityHeaderController.ActionType.ACTION_NOTIF_PREFERENCE,
@@ -95,14 +94,6 @@ public class HeaderPreferenceController extends NotificationPreferenceController
}
}
- public CharSequence getLabel() {
- if (mChannel != null && !isDefaultChannel()) {
- return mChannel.getName();
- } else {
- return mAppRow.label;
- }
- }
-
@OnLifecycleEvent(Lifecycle.Event.ON_START)
public void onStart() {
mStarted = true;
@@ -113,15 +104,7 @@ public class HeaderPreferenceController extends NotificationPreferenceController
if (mChannel != null) {
if (mChannelGroup != null
&& !TextUtils.isEmpty(mChannelGroup.getName())) {
- final SpannableStringBuilder summary = new SpannableStringBuilder();
- BidiFormatter bidi = BidiFormatter.getInstance();
- summary.append(bidi.unicodeWrap(mAppRow.label));
- summary.append(bidi.unicodeWrap(mContext.getText(
- R.string.notification_header_divider_symbol_with_spaces)));
- summary.append(bidi.unicodeWrap(mChannelGroup.getName().toString()));
- return summary.toString();
- } else {
- return mAppRow.label.toString();
+ return mChannelGroup.getName().toString();
}
}
return "";
diff --git a/src/com/android/settings/notification/app/InvalidConversationInfoPreferenceController.java b/src/com/android/settings/notification/app/InvalidConversationInfoPreferenceController.java
index 478607b193e..219457944d1 100644
--- a/src/com/android/settings/notification/app/InvalidConversationInfoPreferenceController.java
+++ b/src/com/android/settings/notification/app/InvalidConversationInfoPreferenceController.java
@@ -23,6 +23,7 @@ import androidx.preference.Preference;
import com.android.settings.R;
import com.android.settings.notification.NotificationBackend;
+import com.android.settingslib.widget.SettingsThemeHelper;
public class InvalidConversationInfoPreferenceController extends NotificationPreferenceController {
@@ -49,6 +50,9 @@ public class InvalidConversationInfoPreferenceController extends NotificationPre
if (mPreferenceFilter != null && !isIncludedInFilter()) {
return false;
}
+ if (SettingsThemeHelper.isExpressiveTheme(mContext)) {
+ return false;
+ }
return mBackend.isInInvalidMsgState(mAppRow.pkg, mAppRow.uid);
}
diff --git a/src/com/android/settings/notification/app/InvalidConversationPreferenceController.java b/src/com/android/settings/notification/app/InvalidConversationPreferenceController.java
index 5c502dccbe0..57eaad9d01e 100644
--- a/src/com/android/settings/notification/app/InvalidConversationPreferenceController.java
+++ b/src/com/android/settings/notification/app/InvalidConversationPreferenceController.java
@@ -24,6 +24,7 @@ import androidx.preference.Preference;
import com.android.settings.R;
import com.android.settings.notification.NotificationBackend;
import com.android.settingslib.RestrictedSwitchPreference;
+import com.android.settingslib.widget.SettingsThemeHelper;
public class InvalidConversationPreferenceController extends NotificationPreferenceController
implements Preference.OnPreferenceChangeListener {
@@ -67,7 +68,15 @@ public class InvalidConversationPreferenceController extends NotificationPrefere
pref.setDisabledByAdmin(mAdmin);
pref.setEnabled(!pref.isDisabledByAdmin());
pref.setChecked(!mBackend.hasUserDemotedInvalidMsgApp(mAppRow.pkg, mAppRow.uid));
- preference.setSummary(mContext.getString(R.string.conversation_section_switch_summary));
+ if (SettingsThemeHelper.isExpressiveTheme(mContext)) {
+ if (preference.getParent() != null) {
+ preference.getParent().setVisible(true);
+ }
+ preference.setSummary(mContext.getString(
+ R.string.conversation_section_switch_complete_summary));
+ } else {
+ preference.setSummary(mContext.getString(R.string.conversation_section_switch_summary));
+ }
}
@Override
diff --git a/src/com/android/settings/notification/app/PriorityConversationsPreferenceController.java b/src/com/android/settings/notification/app/PriorityConversationsPreferenceController.java
index 18fc9178510..55b50df280a 100644
--- a/src/com/android/settings/notification/app/PriorityConversationsPreferenceController.java
+++ b/src/com/android/settings/notification/app/PriorityConversationsPreferenceController.java
@@ -23,6 +23,7 @@ import androidx.preference.Preference;
import com.android.settings.R;
import com.android.settings.notification.NotificationBackend;
+import com.android.settingslib.widget.TopIntroPreference;
public class PriorityConversationsPreferenceController extends
ConversationListPreferenceController {
@@ -40,9 +41,9 @@ public class PriorityConversationsPreferenceController extends
@Override
Preference getSummaryPreference() {
- Preference pref = new Preference(mContext);
+ Preference pref = new TopIntroPreference(mContext);
pref.setOrder(1);
- pref.setSummary(R.string.important_conversations_summary_bubbles);
+ pref.setTitle(R.string.important_conversations_summary_bubbles);
pref.setSelectable(false);
return pref;
}
diff --git a/src/com/android/settings/notification/app/PromotedNotificationsPreferenceController.java b/src/com/android/settings/notification/app/PromotedNotificationsPreferenceController.java
index 13417b2ccf1..bd8229e4d48 100644
--- a/src/com/android/settings/notification/app/PromotedNotificationsPreferenceController.java
+++ b/src/com/android/settings/notification/app/PromotedNotificationsPreferenceController.java
@@ -20,14 +20,12 @@ import android.content.Context;
import androidx.annotation.NonNull;
import androidx.preference.Preference;
-import androidx.preference.PreferenceCategory;
import com.android.settings.notification.NotificationBackend;
import com.android.settingslib.RestrictedSwitchPreference;
public class PromotedNotificationsPreferenceController extends
NotificationPreferenceController implements Preference.OnPreferenceChangeListener {
- private static final String KEY_PROMOTED_CATEGORY = "promoted_category";
protected static final String KEY_PROMOTED_SWITCH = "promoted_switch";
public PromotedNotificationsPreferenceController(@NonNull Context context,
@@ -38,7 +36,7 @@ public class PromotedNotificationsPreferenceController extends
@Override
@NonNull
public String getPreferenceKey() {
- return KEY_PROMOTED_CATEGORY;
+ return KEY_PROMOTED_SWITCH;
}
@Override
@@ -56,12 +54,13 @@ public class PromotedNotificationsPreferenceController extends
}
/**
- * Updates the state of the promoted notifications switch. Because this controller governs
- * the full PreferenceCategory, we must find the switch preference within the category first.
+ * Updates the state of the promoted notifications switch.
*/
public void updateState(@NonNull Preference preference) {
- PreferenceCategory category = (PreferenceCategory) preference;
- RestrictedSwitchPreference pref = category.findPreference(KEY_PROMOTED_SWITCH);
+ RestrictedSwitchPreference pref = (RestrictedSwitchPreference) preference;
+ if (pref.getParent() != null) {
+ pref.getParent().setVisible(true);
+ }
if (pref != null && mAppRow != null) {
pref.setDisabledByAdmin(mAdmin);
diff --git a/src/com/android/settings/notification/app/RecentConversationsPreferenceController.java b/src/com/android/settings/notification/app/RecentConversationsPreferenceController.java
index f5f2e97090b..4fe0a875334 100644
--- a/src/com/android/settings/notification/app/RecentConversationsPreferenceController.java
+++ b/src/com/android/settings/notification/app/RecentConversationsPreferenceController.java
@@ -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) {
diff --git a/src/com/android/settings/notification/app/ShowMorePreferenceController.java b/src/com/android/settings/notification/app/ShowMorePreferenceController.java
index dbc279a6c8b..f44a0c8518e 100644
--- a/src/com/android/settings/notification/app/ShowMorePreferenceController.java
+++ b/src/com/android/settings/notification/app/ShowMorePreferenceController.java
@@ -56,6 +56,9 @@ public class ShowMorePreferenceController extends NotificationPreferenceControll
if (mAppRow.banned || mAppRow.showAllChannels) {
return false;
}
+ if (mBackend.getChannelCount(mAppRow.pkg, mAppRow.uid) == 0) {
+ return false;
+ }
return true;
}
diff --git a/src/com/android/settings/notification/app/VisibilityPreferenceController.java b/src/com/android/settings/notification/app/VisibilityPreferenceController.java
index a2a1d76b71c..0cec7e2a4d6 100644
--- a/src/com/android/settings/notification/app/VisibilityPreferenceController.java
+++ b/src/com/android/settings/notification/app/VisibilityPreferenceController.java
@@ -75,6 +75,10 @@ public class VisibilityPreferenceController extends NotificationPreferenceContro
public void updateState(Preference preference) {
if (mChannel != null && mAppRow != null) {
+ if (preference.getParent() != null) {
+ preference.getParent().setVisible(true);
+ }
+
RestrictedListPreference pref = (RestrictedListPreference) preference;
ArrayList entries = new ArrayList<>();
ArrayList values = new ArrayList<>();
diff --git a/tests/robotests/src/com/android/settings/notification/app/AllowSoundPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/AllowSoundPreferenceControllerTest.java
index 5260ff64c1d..86a3fe4a02a 100644
--- a/tests/robotests/src/com/android/settings/notification/app/AllowSoundPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/AllowSoundPreferenceControllerTest.java
@@ -38,6 +38,8 @@ import android.content.Context;
import android.os.UserManager;
import androidx.preference.Preference;
+import androidx.preference.PreferenceCategory;
+import androidx.preference.PreferenceManager;
import androidx.preference.PreferenceScreen;
import com.android.settings.notification.NotificationBackend;
@@ -68,7 +70,6 @@ public class AllowSoundPreferenceControllerTest {
private NotificationManager mNm;
@Mock
private UserManager mUm;
- @Mock(answer = Answers.RETURNS_DEEP_STUBS)
private PreferenceScreen mScreen;
@Mock
@@ -83,6 +84,7 @@ public class AllowSoundPreferenceControllerTest {
shadowApplication.setSystemService(Context.NOTIFICATION_SERVICE, mNm);
shadowApplication.setSystemService(Context.USER_SERVICE, mUm);
mContext = RuntimeEnvironment.application;
+ mScreen = new PreferenceManager(mContext).createPreferenceScreen(mContext);
mController =
spy(new AllowSoundPreferenceController(mContext, mDependentFieldListener, mBackend));
}
@@ -160,6 +162,7 @@ public class AllowSoundPreferenceControllerTest {
RestrictedLockUtils.EnforcedAdmin.class), null);
Preference pref = new RestrictedSwitchPreference(mContext);
+ mScreen.addPreference(pref);
mController.updateState(pref);
assertFalse(pref.isEnabled());
@@ -173,6 +176,7 @@ public class AllowSoundPreferenceControllerTest {
mController.onResume(appRow, channel, null, null, null, null, null);
Preference pref = new RestrictedSwitchPreference(mContext);
+ mScreen.addPreference(pref);
mController.updateState(pref);
assertTrue(pref.isEnabled());
@@ -186,6 +190,7 @@ public class AllowSoundPreferenceControllerTest {
null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
+ mScreen.addPreference(pref);
mController.updateState(pref);
assertTrue(pref.isChecked());
}
@@ -198,6 +203,7 @@ public class AllowSoundPreferenceControllerTest {
null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
+ mScreen.addPreference(pref);
mController.updateState(pref);
assertTrue(pref.isChecked());
}
@@ -210,6 +216,7 @@ public class AllowSoundPreferenceControllerTest {
null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
+ mScreen.addPreference(pref);
mController.updateState(pref);
assertFalse(pref.isChecked());
}
@@ -222,7 +229,7 @@ public class AllowSoundPreferenceControllerTest {
null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
- when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(pref);
+ mScreen.addPreference(pref);
mController.displayPreference(mScreen);
mController.updateState(pref);
pref.setChecked(true);
@@ -240,7 +247,7 @@ public class AllowSoundPreferenceControllerTest {
null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
- when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(pref);
+ mScreen.addPreference(pref);
mController.displayPreference(mScreen);
mController.updateState(pref);
diff --git a/tests/robotests/src/com/android/settings/notification/app/FullScreenIntentPermissionPreferenceControllerTest.kt b/tests/robotests/src/com/android/settings/notification/app/FullScreenIntentPermissionPreferenceControllerTest.kt
index 89e33eef509..a9abf8b582b 100644
--- a/tests/robotests/src/com/android/settings/notification/app/FullScreenIntentPermissionPreferenceControllerTest.kt
+++ b/tests/robotests/src/com/android/settings/notification/app/FullScreenIntentPermissionPreferenceControllerTest.kt
@@ -37,6 +37,7 @@ import android.permission.PermissionManager.PERMISSION_HARD_DENIED
import android.permission.PermissionManager.PERMISSION_SOFT_DENIED
import android.permission.PermissionManager.PermissionResult
import androidx.preference.Preference
+import androidx.preference.PreferenceManager
import androidx.preference.PreferenceScreen
import androidx.test.core.app.ApplicationProvider
import com.android.settings.notification.NotificationBackend
@@ -80,7 +81,6 @@ class FullScreenIntentPermissionPreferenceControllerTest {
private lateinit var preference: RestrictedSwitchPreference
- @Mock(answer = Answers.RETURNS_DEEP_STUBS)
private lateinit var screen: PreferenceScreen
private lateinit var controller: FullScreenIntentPermissionPreferenceController
@@ -94,7 +94,8 @@ class FullScreenIntentPermissionPreferenceControllerTest {
preference = RestrictedSwitchPreference(context).apply { key = KEY_FSI_PERMISSION }
- whenever(screen.findPreference(KEY_FSI_PERMISSION)).thenReturn(preference)
+ screen = PreferenceManager(context).createPreferenceScreen(context)
+ screen.addPreference(preference)
controller = FullScreenIntentPermissionPreferenceController(
context,
diff --git a/tests/robotests/src/com/android/settings/notification/app/HeaderPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/HeaderPreferenceControllerTest.java
index 05a41a63a53..b5190dd19a7 100644
--- a/tests/robotests/src/com/android/settings/notification/app/HeaderPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/HeaderPreferenceControllerTest.java
@@ -113,27 +113,6 @@ public class HeaderPreferenceControllerTest {
assertTrue(mController.isAvailable());
}
- @Test
- public void testGetLabel() {
- NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
- appRow.label = "bananas";
- mController.onResume(appRow, null, null, null, null, null, null);
- assertEquals(appRow.label, mController.getLabel());
-
- NotificationChannelGroup group = new NotificationChannelGroup("id", "name");
- mController.onResume(appRow, null, group, null, null, null, null);
- assertEquals(appRow.label, mController.getLabel());
-
- NotificationChannel channel = new NotificationChannel("cid", "cname", IMPORTANCE_NONE);
- mController.onResume(appRow, channel, group, null, null, null, null);
- assertEquals(channel.getName(), mController.getLabel());
-
- NotificationChannel defaultChannel = new NotificationChannel(
- NotificationChannel.DEFAULT_CHANNEL_ID, "", IMPORTANCE_NONE);
- mController.onResume(appRow, defaultChannel, null, null, null, null, null);
- assertEquals(appRow.label, mController.getLabel());
- }
-
@Test
public void testGetSummary() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
@@ -146,16 +125,14 @@ public class HeaderPreferenceControllerTest {
NotificationChannel channel = new NotificationChannel("cid", "cname", IMPORTANCE_NONE);
mController.onResume(appRow, channel, group, null, null, null, null);
assertTrue(mController.getSummary().toString().contains(group.getName()));
- assertTrue(mController.getSummary().toString().contains(appRow.label));
mController.onResume(appRow, channel, null, null, null, null, null);
assertFalse(mController.getSummary().toString().contains(group.getName()));
- assertTrue(mController.getSummary().toString().contains(appRow.label));
NotificationChannel defaultChannel = new NotificationChannel(
NotificationChannel.DEFAULT_CHANNEL_ID, "", IMPORTANCE_NONE);
mController.onResume(appRow, defaultChannel, null, null, null, null, null);
- assertEquals(appRow.label, mController.getSummary());
+ assertEquals("", mController.getSummary());
}
@Test
diff --git a/tests/robotests/src/com/android/settings/notification/app/InvalidConversationInfoPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/InvalidConversationInfoPreferenceControllerTest.java
index eb8046567b2..dcc9daf552e 100644
--- a/tests/robotests/src/com/android/settings/notification/app/InvalidConversationInfoPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/InvalidConversationInfoPreferenceControllerTest.java
@@ -34,6 +34,7 @@ import androidx.preference.PreferenceScreen;
import com.android.settings.notification.NotificationBackend;
import com.android.settings.testutils.shadow.SettingsShadowResources;
+import com.android.settingslib.widget.SettingsThemeHelper;
import com.google.common.collect.ImmutableList;
@@ -88,6 +89,18 @@ public class InvalidConversationInfoPreferenceControllerTest {
mController.updateState(mock(Preference.class));
}
+ @Test
+ public void testIsAvailable_notIfExpressiveTheme() {
+ if (SettingsThemeHelper.isExpressiveTheme(mContext)) {
+ when(mBackend.isInInvalidMsgState(anyString(), anyInt())).thenReturn(true);
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ appRow.pkg = "hi";
+ appRow.uid = 0;
+ mController.onResume(appRow, null, null, null, null, null, null);
+ assertFalse(mController.isAvailable());
+ }
+ }
+
@Test
public void testIsAvailable_notIfAppBlocked() {
when(mBackend.isInInvalidMsgState(anyString(), anyInt())).thenReturn(true);
@@ -111,6 +124,9 @@ public class InvalidConversationInfoPreferenceControllerTest {
@Test
public void testIsAvailable() {
+ if (SettingsThemeHelper.isExpressiveTheme(mContext)) {
+ return;
+ }
when(mBackend.isInInvalidMsgState(anyString(), anyInt())).thenReturn(true);
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.pkg = "hi";
diff --git a/tests/robotests/src/com/android/settings/notification/app/PromotedNotificationsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/PromotedNotificationsPreferenceControllerTest.java
index 917d4694ca3..8e0ab965443 100644
--- a/tests/robotests/src/com/android/settings/notification/app/PromotedNotificationsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/PromotedNotificationsPreferenceControllerTest.java
@@ -18,13 +18,12 @@ package com.android.settings.notification.app;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyBoolean;
+import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
import android.app.Flags;
import android.content.Context;
@@ -32,7 +31,7 @@ import android.platform.test.annotations.DisableFlags;
import android.platform.test.annotations.EnableFlags;
import android.platform.test.flag.junit.SetFlagsRule;
-import androidx.preference.PreferenceCategory;
+import androidx.preference.PreferenceManager;
import androidx.test.core.app.ApplicationProvider;
import com.android.settings.notification.NotificationBackend;
@@ -55,8 +54,6 @@ public class PromotedNotificationsPreferenceControllerTest {
private NotificationBackend.AppRow mAppRow;
@Mock
private NotificationBackend mBackend;
- @Mock
- private PreferenceCategory mPrefCategory;
private RestrictedSwitchPreference mSwitch;
private PromotedNotificationsPreferenceController mPrefController;
@@ -66,7 +63,7 @@ public class PromotedNotificationsPreferenceControllerTest {
MockitoAnnotations.initMocks(this);
mContext = ApplicationProvider.getApplicationContext();
mSwitch = new RestrictedSwitchPreference(mContext);
- when(mPrefCategory.findPreference("promoted_switch")).thenReturn(mSwitch);
+ new PreferenceManager(mContext).createPreferenceScreen(mContext).addPreference(mSwitch);
mPrefController = new PromotedNotificationsPreferenceController(mContext, mBackend);
mAppRow = new NotificationBackend.AppRow();
@@ -93,12 +90,12 @@ public class PromotedNotificationsPreferenceControllerTest {
mAppRow.canBePromoted = true;
mPrefController.onResume(mAppRow, null, null, null, null, null, null);
- mPrefController.updateState(mPrefCategory);
+ mPrefController.updateState(mSwitch);
assertThat(mSwitch.isChecked()).isTrue();
mAppRow.canBePromoted = false;
mPrefController.onResume(mAppRow, null, null, null, null, null, null);
- mPrefController.updateState(mPrefCategory);
+ mPrefController.updateState(mSwitch);
assertThat(mSwitch.isChecked()).isFalse();
}
diff --git a/tests/robotests/src/com/android/settings/notification/app/RecentConversationsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/RecentConversationsPreferenceControllerTest.java
index 3c0a0f33349..538859105ed 100644
--- a/tests/robotests/src/com/android/settings/notification/app/RecentConversationsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/RecentConversationsPreferenceControllerTest.java
@@ -50,6 +50,7 @@ import androidx.test.core.app.ApplicationProvider;
import com.android.settings.R;
import com.android.settings.applications.AppInfoBase;
import com.android.settings.notification.NotificationBackend;
+import com.android.settingslib.widget.ButtonPreference;
import com.android.settingslib.widget.LayoutPreference;
import com.google.common.collect.ImmutableList;
@@ -232,14 +233,16 @@ public class RecentConversationsPreferenceControllerTest {
new NotificationChannelGroup("hi", "group"), 7,
false);
- RecentConversationPreference pref = mController.createConversationPref(ccw);
+ Preference pref = mController.createConversationPref(ccw);
final View view = View.inflate(mContext, pref.getLayoutResource(), null);
PreferenceViewHolder holder = spy(PreferenceViewHolder.createInstanceForTests(view));
- View delete = View.inflate(mContext, pref.getSecondTargetResId(), null);
- when(holder.findViewById(pref.getClearId())).thenReturn(delete);
+ View delete = View.inflate(mContext, ((RecentConversationPreference) pref)
+ .getSecondTargetResId(), null);
+ when(holder.findViewById(((RecentConversationPreference) pref).getClearId()))
+ .thenReturn(delete);
pref.onBindViewHolder(holder);
- pref.getClearView().performClick();
+ ((RecentConversationPreference) pref).getClearView().performClick();
verify(mPs).removeRecentConversation(
si.getPackage(), UserHandle.getUserId(ccw.getUid()), si.getId());
@@ -260,24 +263,24 @@ public class RecentConversationsPreferenceControllerTest {
new NotificationChannelGroup("hi", "group"), 7,
true);
- RecentConversationPreference pref = mController.createConversationPref(ccw);
+ Preference pref = mController.createConversationPref(ccw);
final View view = View.inflate(mContext, pref.getLayoutResource(), null);
PreferenceViewHolder holder = spy(PreferenceViewHolder.createInstanceForTests(view));
- View delete = View.inflate(mContext, pref.getSecondTargetResId(), null);
- when(holder.findViewById(pref.getClearId())).thenReturn(delete);
+ View delete = View.inflate(mContext, ((RecentConversationPreference) pref).
+ getSecondTargetResId(), null);
+ when(holder.findViewById(((RecentConversationPreference) pref).getClearId()))
+ .thenReturn(delete);
mPreferenceGroup.addPreference(pref);
- RecentConversationPreference pref2 = mController.createConversationPref(ccw2);
- final View view2 = View.inflate(mContext, pref2.getLayoutResource(), null);
- PreferenceViewHolder holder2 = spy(PreferenceViewHolder.createInstanceForTests(view2));
- View delete2 = View.inflate(mContext, pref2.getSecondTargetResId(), null);
- when(holder2.findViewById(pref.getClearId())).thenReturn(delete2);
+ Preference pref2 = mController.createConversationPref(ccw2);
mPreferenceGroup.addPreference(pref2);
- LayoutPreference clearAll = mController.getClearAll(mPreferenceGroup);
+ ButtonPreference clearAll = mController.getClearAll(mPreferenceGroup);
+ final View rootView = View.inflate(mContext, clearAll.getLayoutResource(), null);
+ clearAll.onBindViewHolder(PreferenceViewHolder.createInstanceForTests(rootView));
mPreferenceGroup.addPreference(clearAll);
- clearAll.findViewById(R.id.conversation_settings_clear_recents).performClick();
+ clearAll.getButton().performClick();
verify(mPs).removeAllRecentConversations();
assertThat((Preference) mPreferenceGroup.findPreference("hi:person")).isNull();
@@ -294,9 +297,9 @@ public class RecentConversationsPreferenceControllerTest {
new NotificationChannelGroup("hi", "group"), 7,
true);
- RecentConversationPreference pref = mController.createConversationPref(ccw);
+ Preference pref = mController.createConversationPref(ccw);
- assertThat(pref.hasClearListener()).isFalse();
+ assertThat(pref instanceof RecentConversationPreference).isFalse();
}
@Test
diff --git a/tests/unit/src/com/android/settings/notification/app/ChannelListPreferenceControllerTest.java b/tests/unit/src/com/android/settings/notification/app/ChannelListPreferenceControllerTest.java
index daa2afb71ab..f68ba05b43b 100644
--- a/tests/unit/src/com/android/settings/notification/app/ChannelListPreferenceControllerTest.java
+++ b/tests/unit/src/com/android/settings/notification/app/ChannelListPreferenceControllerTest.java
@@ -91,6 +91,14 @@ public class ChannelListPreferenceControllerTest {
assertEquals("zeroCategories", mGroupList.getPreference(0).getKey());
}
+ // Test the case with no groups but hidden channels
+ inGroups = new ArrayList<>();
+ mController.mChannelCount = 1;
+ mController.updateFullList(mGroupList, inGroups);
+ {
+ assertEquals(0, mGroupList.getPreferenceCount());
+ }
+
// Test that adding a group clears the zero category and adds everything
NotificationChannelGroup inGroup1 = new NotificationChannelGroup("group1", "Group 1");
inGroup1.addChannel(new NotificationChannel("ch1a", "Channel 1A", IMPORTANCE_DEFAULT));
@@ -250,6 +258,7 @@ public class ChannelListPreferenceControllerTest {
}
// Test that we go back to the empty state when clearing all groups and channels.
+ mController.mChannelCount = 0;
inGroups.clear();
mController.updateFullList(mGroupList, inGroups);
{