Updates for msg apps that don't use shortcuts

- Notice on app specific page
- No individual conversation bubble controls

Test: manual
Bug: 154814754
Change-Id: I74c291890ba6203e6a3a162fc0c0335ed5eba3d4
This commit is contained in:
Julia Reynolds
2020-04-26 19:14:31 -04:00
parent da9e2099de
commit 8fe4b28312
5 changed files with 37 additions and 2 deletions

View File

@@ -8464,6 +8464,8 @@
<!-- [CHAR LIMIT=150] Notification Importance title: important conversation level summary --> <!-- [CHAR LIMIT=150] Notification Importance title: important conversation level summary -->
<string name="notification_channel_summary_priority">Shows at top of conversation section and appears as a bubble.</string> <string name="notification_channel_summary_priority">Shows at top of conversation section and appears as a bubble.</string>
<string name="convo_not_supported_summary"><xliff:g id="app_name" example="Android Services">%1$s</xliff:g> does not support conversation-specific settings.</string>
<!-- Channel summaries for the app notification page --> <!-- Channel summaries for the app notification page -->
<!-- [CHAR LIMIT=150] Notification Importance title: min importance level summary --> <!-- [CHAR LIMIT=150] Notification Importance title: min importance level summary -->

View File

@@ -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 * Returns all notification channels associated with the package and uid that will bypass DND
*/ */

View File

@@ -44,6 +44,7 @@ public class AppConversationListPreferenceController extends NotificationPrefere
private List<ConversationChannelWrapper> mConversations; private List<ConversationChannelWrapper> mConversations;
private PreferenceCategory mPreference; private PreferenceCategory mPreference;
private boolean mHasSentMsg;
public AppConversationListPreferenceController(Context context, NotificationBackend backend) { public AppConversationListPreferenceController(Context context, NotificationBackend backend) {
super(context, backend); super(context, backend);
@@ -78,6 +79,7 @@ public class AppConversationListPreferenceController extends NotificationPrefere
new AsyncTask<Void, Void, Void>() { new AsyncTask<Void, Void, Void>() {
@Override @Override
protected Void doInBackground(Void... unused) { protected Void doInBackground(Void... unused) {
mHasSentMsg = mBackend.hasSentMessage(mAppRow.pkg, mAppRow.uid);
mConversations = mBackend.getConversations(mAppRow.pkg, mAppRow.uid).getList(); mConversations = mBackend.getConversations(mAppRow.pkg, mAppRow.uid).getList();
Collections.sort(mConversations, mConversationComparator); Collections.sort(mConversations, mConversationComparator);
return null; return null;
@@ -99,7 +101,15 @@ public class AppConversationListPreferenceController extends NotificationPrefere
mPreference.setTitle(R.string.conversations_category_title); mPreference.setTitle(R.string.conversations_category_title);
if (mConversations.isEmpty()) { 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 { } else {
mPreference.setVisible(true); mPreference.setVisible(true);
populateConversations(); populateConversations();

View File

@@ -52,6 +52,8 @@ public class BubblePreference extends Preference implements View.OnClickListener
private ButtonViewHolder mBubbleSelectedButton; private ButtonViewHolder mBubbleSelectedButton;
private ButtonViewHolder mBubbleNoneButton; private ButtonViewHolder mBubbleNoneButton;
private boolean mSelectedVisible;
public BubblePreference(Context context) { public BubblePreference(Context context) {
this(context, null); this(context, null);
} }
@@ -89,6 +91,11 @@ public class BubblePreference extends Preference implements View.OnClickListener
} }
} }
public void setSelectedVisibility(boolean visible) {
mSelectedVisible = visible;
notifyChanged();
}
@Override @Override
public void onBindViewHolder(final PreferenceViewHolder holder) { public void onBindViewHolder(final PreferenceViewHolder holder) {
super.onBindViewHolder(holder); super.onBindViewHolder(holder);
@@ -122,7 +129,8 @@ public class BubblePreference extends Preference implements View.OnClickListener
mSelectedPreference == BUBBLE_PREFERENCE_SELECTED); mSelectedPreference == BUBBLE_PREFERENCE_SELECTED);
bubbleSelected.setTag(BUBBLE_PREFERENCE_SELECTED); bubbleSelected.setTag(BUBBLE_PREFERENCE_SELECTED);
bubbleSelected.setOnClickListener(this); 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); View bubbleNone = holder.findViewById(R.id.bubble_none);
ImageView bubbleNoneImage = (ImageView) holder.findViewById(R.id.bubble_none_icon); ImageView bubbleNoneImage = (ImageView) holder.findViewById(R.id.bubble_none_icon);

View File

@@ -47,6 +47,8 @@ public class BubblePreferenceController extends NotificationPreferenceController
private FragmentManager mFragmentManager; private FragmentManager mFragmentManager;
private boolean mIsAppPage; private boolean mIsAppPage;
private boolean mHasSentInvalidMsg;
private int mNumConversations;
public BubblePreferenceController(Context context, @Nullable FragmentManager fragmentManager, public BubblePreferenceController(Context context, @Nullable FragmentManager fragmentManager,
NotificationBackend backend, boolean isAppPage) { NotificationBackend backend, boolean isAppPage) {
@@ -81,10 +83,14 @@ public class BubblePreferenceController extends NotificationPreferenceController
@Override @Override
public void updateState(Preference preference) { public void updateState(Preference preference) {
if (mIsAppPage && mAppRow != null) { 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 // We're on the app specific bubble page which displays a tri-state
int backEndPref = mAppRow.bubblePreference; int backEndPref = mAppRow.bubblePreference;
BubblePreference pref = (BubblePreference) preference; BubblePreference pref = (BubblePreference) preference;
pref.setDisabledByAdmin(mAdmin); pref.setDisabledByAdmin(mAdmin);
pref.setSelectedVisibility(!mHasSentInvalidMsg || mNumConversations > 0);
if (!isGloballyEnabled()) { if (!isGloballyEnabled()) {
pref.setSelectedPreference(BUBBLE_PREFERENCE_NONE); pref.setSelectedPreference(BUBBLE_PREFERENCE_NONE);
} else { } else {