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:
@@ -8464,6 +8464,8 @@
|
||||
<!-- [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="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 -->
|
||||
|
||||
<!-- [CHAR LIMIT=150] Notification Importance title: min importance level summary -->
|
||||
|
@@ -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
|
||||
*/
|
||||
|
@@ -44,6 +44,7 @@ public class AppConversationListPreferenceController extends NotificationPrefere
|
||||
|
||||
private List<ConversationChannelWrapper> 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<Void, Void, Void>() {
|
||||
@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();
|
||||
|
@@ -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);
|
||||
|
@@ -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 {
|
||||
|
Reference in New Issue
Block a user