Link priority setting to message channel setting on Oreo+

When using notification channels, us setting priority actually has
no effect. So instead of having a non-functional setting, we've
routed the notification priority setting to go to the system
notification channel settings page for our Messages channel.
This commit is contained in:
Greyson Parrelli
2018-08-15 12:11:10 -07:00
parent 10a790df88
commit a6473bc922
6 changed files with 47 additions and 6 deletions

View File

@@ -30,8 +30,11 @@ public class MultipleRecipientNotificationBuilder extends AbstractNotificationBu
setContentTitle(context.getString(R.string.app_name));
setContentIntent(PendingIntent.getActivity(context, 0, new Intent(context, ConversationListActivity.class), 0));
setCategory(NotificationCompat.CATEGORY_MESSAGE);
setPriority(TextSecurePreferences.getNotificationPriority(context));
setGroupSummary(true);
if (!NotificationChannels.supported()) {
setPriority(TextSecurePreferences.getNotificationPriority(context));
}
}
public void setMessageCount(int messageCount, int threadCount) {

View File

@@ -26,7 +26,7 @@ public class NotificationChannels {
* ignored for API < 26.
*/
public static void create(@NonNull Context context) {
if (Build.VERSION.SDK_INT < 26) {
if (!supported()) {
return;
}
@@ -47,4 +47,8 @@ public class NotificationChannels {
notificationManager.deleteNotificationChannel(APP_UPDATES);
}
}
public static boolean supported() {
return Build.VERSION.SDK_INT >= 26;
}
}

View File

@@ -21,7 +21,6 @@ public class PendingMessageNotificationBuilder extends AbstractNotificationBuild
setSmallIcon(R.drawable.icon_notification);
setColor(context.getResources().getColor(R.color.textsecure_primary));
setPriority(TextSecurePreferences.getNotificationPriority(context));
setCategory(NotificationCompat.CATEGORY_MESSAGE);
setContentTitle(context.getString(R.string.MessageNotifier_pending_signal_messages));
@@ -31,5 +30,9 @@ public class PendingMessageNotificationBuilder extends AbstractNotificationBuild
setContentIntent(PendingIntent.getActivity(context, 0, intent, 0));
setAutoCancel(true);
setAlarms(null, RecipientDatabase.VibrateState.DEFAULT);
if (!NotificationChannels.supported()) {
setPriority(TextSecurePreferences.getNotificationPriority(context));
}
}
}

View File

@@ -52,8 +52,11 @@ public class SingleRecipientNotificationBuilder extends AbstractNotificationBuil
setSmallIcon(R.drawable.icon_notification);
setColor(context.getResources().getColor(R.color.textsecure_primary));
setPriority(TextSecurePreferences.getNotificationPriority(context));
setCategory(NotificationCompat.CATEGORY_MESSAGE);
if (!NotificationChannels.supported()) {
setPriority(TextSecurePreferences.getNotificationPriority(context));
}
}
public void setThread(@NonNull Recipient recipient) {