mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-27 20:15:21 +00:00
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:
parent
10a790df88
commit
a6473bc922
@ -30,8 +30,11 @@ public class MultipleRecipientNotificationBuilder extends AbstractNotificationBu
|
|||||||
setContentTitle(context.getString(R.string.app_name));
|
setContentTitle(context.getString(R.string.app_name));
|
||||||
setContentIntent(PendingIntent.getActivity(context, 0, new Intent(context, ConversationListActivity.class), 0));
|
setContentIntent(PendingIntent.getActivity(context, 0, new Intent(context, ConversationListActivity.class), 0));
|
||||||
setCategory(NotificationCompat.CATEGORY_MESSAGE);
|
setCategory(NotificationCompat.CATEGORY_MESSAGE);
|
||||||
setPriority(TextSecurePreferences.getNotificationPriority(context));
|
|
||||||
setGroupSummary(true);
|
setGroupSummary(true);
|
||||||
|
|
||||||
|
if (!NotificationChannels.supported()) {
|
||||||
|
setPriority(TextSecurePreferences.getNotificationPriority(context));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMessageCount(int messageCount, int threadCount) {
|
public void setMessageCount(int messageCount, int threadCount) {
|
||||||
|
@ -26,7 +26,7 @@ public class NotificationChannels {
|
|||||||
* ignored for API < 26.
|
* ignored for API < 26.
|
||||||
*/
|
*/
|
||||||
public static void create(@NonNull Context context) {
|
public static void create(@NonNull Context context) {
|
||||||
if (Build.VERSION.SDK_INT < 26) {
|
if (!supported()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,4 +47,8 @@ public class NotificationChannels {
|
|||||||
notificationManager.deleteNotificationChannel(APP_UPDATES);
|
notificationManager.deleteNotificationChannel(APP_UPDATES);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean supported() {
|
||||||
|
return Build.VERSION.SDK_INT >= 26;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,6 @@ public class PendingMessageNotificationBuilder extends AbstractNotificationBuild
|
|||||||
|
|
||||||
setSmallIcon(R.drawable.icon_notification);
|
setSmallIcon(R.drawable.icon_notification);
|
||||||
setColor(context.getResources().getColor(R.color.textsecure_primary));
|
setColor(context.getResources().getColor(R.color.textsecure_primary));
|
||||||
setPriority(TextSecurePreferences.getNotificationPriority(context));
|
|
||||||
setCategory(NotificationCompat.CATEGORY_MESSAGE);
|
setCategory(NotificationCompat.CATEGORY_MESSAGE);
|
||||||
|
|
||||||
setContentTitle(context.getString(R.string.MessageNotifier_pending_signal_messages));
|
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));
|
setContentIntent(PendingIntent.getActivity(context, 0, intent, 0));
|
||||||
setAutoCancel(true);
|
setAutoCancel(true);
|
||||||
setAlarms(null, RecipientDatabase.VibrateState.DEFAULT);
|
setAlarms(null, RecipientDatabase.VibrateState.DEFAULT);
|
||||||
|
|
||||||
|
if (!NotificationChannels.supported()) {
|
||||||
|
setPriority(TextSecurePreferences.getNotificationPriority(context));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,8 +52,11 @@ public class SingleRecipientNotificationBuilder extends AbstractNotificationBuil
|
|||||||
|
|
||||||
setSmallIcon(R.drawable.icon_notification);
|
setSmallIcon(R.drawable.icon_notification);
|
||||||
setColor(context.getResources().getColor(R.color.textsecure_primary));
|
setColor(context.getResources().getColor(R.color.textsecure_primary));
|
||||||
setPriority(TextSecurePreferences.getNotificationPriority(context));
|
|
||||||
setCategory(NotificationCompat.CATEGORY_MESSAGE);
|
setCategory(NotificationCompat.CATEGORY_MESSAGE);
|
||||||
|
|
||||||
|
if (!NotificationChannels.supported()) {
|
||||||
|
setPriority(TextSecurePreferences.getNotificationPriority(context));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setThread(@NonNull Recipient recipient) {
|
public void setThread(@NonNull Recipient recipient) {
|
||||||
|
@ -18,6 +18,8 @@ import org.thoughtcrime.securesms.ApplicationPreferencesActivity;
|
|||||||
import org.thoughtcrime.securesms.R;
|
import org.thoughtcrime.securesms.R;
|
||||||
import org.thoughtcrime.securesms.components.SwitchPreferenceCompat;
|
import org.thoughtcrime.securesms.components.SwitchPreferenceCompat;
|
||||||
import org.thoughtcrime.securesms.notifications.MessageNotifier;
|
import org.thoughtcrime.securesms.notifications.MessageNotifier;
|
||||||
|
import org.thoughtcrime.securesms.notifications.NotificationChannels;
|
||||||
|
import org.thoughtcrime.securesms.preferences.widgets.SignalListPreference;
|
||||||
import org.thoughtcrime.securesms.preferences.widgets.SignalPreference;
|
import org.thoughtcrime.securesms.preferences.widgets.SignalPreference;
|
||||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||||
import org.w3c.dom.Text;
|
import org.w3c.dom.Text;
|
||||||
@ -84,7 +86,21 @@ public class NotificationsPreferenceFragment extends ListSummaryPreferenceFragme
|
|||||||
initializeListSummary((ListPreference) findPreference(TextSecurePreferences.LED_BLINK_PREF));
|
initializeListSummary((ListPreference) findPreference(TextSecurePreferences.LED_BLINK_PREF));
|
||||||
initializeListSummary((ListPreference) findPreference(TextSecurePreferences.REPEAT_ALERTS_PREF));
|
initializeListSummary((ListPreference) findPreference(TextSecurePreferences.REPEAT_ALERTS_PREF));
|
||||||
initializeListSummary((ListPreference) findPreference(TextSecurePreferences.NOTIFICATION_PRIVACY_PREF));
|
initializeListSummary((ListPreference) findPreference(TextSecurePreferences.NOTIFICATION_PRIVACY_PREF));
|
||||||
|
|
||||||
|
if (NotificationChannels.supported()) {
|
||||||
|
((SignalListPreference) this.findPreference(TextSecurePreferences.NOTIFICATION_PRIORITY_PREF)).disableDialog();
|
||||||
|
|
||||||
|
this.findPreference(TextSecurePreferences.NOTIFICATION_PRIORITY_PREF)
|
||||||
|
.setOnPreferenceClickListener(preference -> {
|
||||||
|
Intent intent = new Intent(Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS);
|
||||||
|
intent.putExtra(Settings.EXTRA_CHANNEL_ID, NotificationChannels.MESSAGES);
|
||||||
|
intent.putExtra(Settings.EXTRA_APP_PACKAGE, getContext().getPackageName());
|
||||||
|
startActivity(intent);
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
} else {
|
||||||
initializeListSummary((ListPreference) findPreference(TextSecurePreferences.NOTIFICATION_PRIORITY_PREF));
|
initializeListSummary((ListPreference) findPreference(TextSecurePreferences.NOTIFICATION_PRIORITY_PREF));
|
||||||
|
}
|
||||||
|
|
||||||
initializeRingtoneSummary(findPreference(TextSecurePreferences.RINGTONE_PREF));
|
initializeRingtoneSummary(findPreference(TextSecurePreferences.RINGTONE_PREF));
|
||||||
initializeCallRingtoneSummary(findPreference(TextSecurePreferences.CALL_RINGTONE_PREF));
|
initializeCallRingtoneSummary(findPreference(TextSecurePreferences.CALL_RINGTONE_PREF));
|
||||||
|
@ -18,6 +18,7 @@ public class SignalListPreference extends ListPreference {
|
|||||||
|
|
||||||
private TextView rightSummary;
|
private TextView rightSummary;
|
||||||
private CharSequence summary;
|
private CharSequence summary;
|
||||||
|
private boolean dialogDisabled;
|
||||||
|
|
||||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||||
public SignalListPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
public SignalListPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||||
@ -63,4 +64,15 @@ public class SignalListPreference extends ListPreference {
|
|||||||
this.rightSummary.setText(summary);
|
this.rightSummary.setText(summary);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void disableDialog() {
|
||||||
|
dialogDisabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onClick() {
|
||||||
|
if (!dialogDisabled) {
|
||||||
|
super.onClick();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user