diff --git a/res/values/strings.xml b/res/values/strings.xml
index e1eae680a2c..27188f441bd 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -8464,6 +8464,8 @@
Shows at top of conversation section and appears as a bubble.
+ %1$s does not support conversation-specific settings.
+
diff --git a/src/com/android/settings/notification/NotificationBackend.java b/src/com/android/settings/notification/NotificationBackend.java
index b172879b64e..6172268bd0b 100644
--- a/src/com/android/settings/notification/NotificationBackend.java
+++ b/src/com/android/settings/notification/NotificationBackend.java
@@ -268,6 +268,15 @@ public class NotificationBackend {
}
}
+ public boolean hasSentMessage(String pkg, int uid) {
+ try {
+ return sINM.hasSentMessage(pkg, uid);
+ } catch (Exception e) {
+ Log.w(TAG, "Error calling NoMan", e);
+ return false;
+ }
+ }
+
/**
* Returns all notification channels associated with the package and uid that will bypass DND
*/
diff --git a/src/com/android/settings/notification/app/AppConversationListPreferenceController.java b/src/com/android/settings/notification/app/AppConversationListPreferenceController.java
index 32278db907a..bea015709c2 100644
--- a/src/com/android/settings/notification/app/AppConversationListPreferenceController.java
+++ b/src/com/android/settings/notification/app/AppConversationListPreferenceController.java
@@ -44,6 +44,7 @@ public class AppConversationListPreferenceController extends NotificationPrefere
private List mConversations;
private PreferenceCategory mPreference;
+ private boolean mHasSentMsg;
public AppConversationListPreferenceController(Context context, NotificationBackend backend) {
super(context, backend);
@@ -78,6 +79,7 @@ public class AppConversationListPreferenceController extends NotificationPrefere
new AsyncTask() {
@Override
protected Void doInBackground(Void... unused) {
+ mHasSentMsg = mBackend.hasSentMessage(mAppRow.pkg, mAppRow.uid);
mConversations = mBackend.getConversations(mAppRow.pkg, mAppRow.uid).getList();
Collections.sort(mConversations, mConversationComparator);
return null;
@@ -99,7 +101,15 @@ public class AppConversationListPreferenceController extends NotificationPrefere
mPreference.setTitle(R.string.conversations_category_title);
if (mConversations.isEmpty()) {
- mPreference.setVisible(false);
+ if (mHasSentMsg) {
+ mPreference.setVisible(true);
+ Preference notSupportedPref = new Preference(mContext);
+ notSupportedPref.setSummary(mContext.getString(
+ R.string.convo_not_supported_summary, mAppRow.label));
+ mPreference.addPreference(notSupportedPref);
+ } else {
+ mPreference.setVisible(false);
+ }
} else {
mPreference.setVisible(true);
populateConversations();
diff --git a/src/com/android/settings/notification/app/BubblePreference.java b/src/com/android/settings/notification/app/BubblePreference.java
index 679b663c8dd..7e071ff938a 100644
--- a/src/com/android/settings/notification/app/BubblePreference.java
+++ b/src/com/android/settings/notification/app/BubblePreference.java
@@ -52,6 +52,8 @@ public class BubblePreference extends Preference implements View.OnClickListener
private ButtonViewHolder mBubbleSelectedButton;
private ButtonViewHolder mBubbleNoneButton;
+ private boolean mSelectedVisible;
+
public BubblePreference(Context context) {
this(context, null);
}
@@ -89,6 +91,11 @@ public class BubblePreference extends Preference implements View.OnClickListener
}
}
+ public void setSelectedVisibility(boolean visible) {
+ mSelectedVisible = visible;
+ notifyChanged();
+ }
+
@Override
public void onBindViewHolder(final PreferenceViewHolder holder) {
super.onBindViewHolder(holder);
@@ -122,7 +129,8 @@ public class BubblePreference extends Preference implements View.OnClickListener
mSelectedPreference == BUBBLE_PREFERENCE_SELECTED);
bubbleSelected.setTag(BUBBLE_PREFERENCE_SELECTED);
bubbleSelected.setOnClickListener(this);
- bubbleSelected.setVisibility(disabledByAdmin ? View.GONE : View.VISIBLE);
+ bubbleSelected.setVisibility((!mSelectedVisible || disabledByAdmin)
+ ? View.GONE : View.VISIBLE);
View bubbleNone = holder.findViewById(R.id.bubble_none);
ImageView bubbleNoneImage = (ImageView) holder.findViewById(R.id.bubble_none_icon);
diff --git a/src/com/android/settings/notification/app/BubblePreferenceController.java b/src/com/android/settings/notification/app/BubblePreferenceController.java
index 3255192a912..02d6d99e049 100644
--- a/src/com/android/settings/notification/app/BubblePreferenceController.java
+++ b/src/com/android/settings/notification/app/BubblePreferenceController.java
@@ -47,6 +47,8 @@ public class BubblePreferenceController extends NotificationPreferenceController
private FragmentManager mFragmentManager;
private boolean mIsAppPage;
+ private boolean mHasSentInvalidMsg;
+ private int mNumConversations;
public BubblePreferenceController(Context context, @Nullable FragmentManager fragmentManager,
NotificationBackend backend, boolean isAppPage) {
@@ -81,10 +83,14 @@ public class BubblePreferenceController extends NotificationPreferenceController
@Override
public void updateState(Preference preference) {
if (mIsAppPage && mAppRow != null) {
+ mHasSentInvalidMsg = mBackend.hasSentMessage(mAppRow.pkg, mAppRow.uid);
+ mNumConversations = mBackend.getConversations(
+ mAppRow.pkg, mAppRow.uid).getList().size();
// We're on the app specific bubble page which displays a tri-state
int backEndPref = mAppRow.bubblePreference;
BubblePreference pref = (BubblePreference) preference;
pref.setDisabledByAdmin(mAdmin);
+ pref.setSelectedVisibility(!mHasSentInvalidMsg || mNumConversations > 0);
if (!isGloballyEnabled()) {
pref.setSelectedPreference(BUBBLE_PREFERENCE_NONE);
} else {