kopia lustrzana https://github.com/ryukoposting/Signal-Android
Use correct in-thread message tone on O+.
We manually play the ringtone when in-thread notifications are enabled, but we weren't using the sound specified by the channel in the system settings. This fixes that problem by reading the NotificationChannel setting.fork-5.53.8
rodzic
54715e9c43
commit
f1efe2b589
|
@ -356,7 +356,7 @@ public class RecipientPreferenceActivity extends PassphraseRequiredActionBarActi
|
|||
|
||||
mutePreference.setChecked(recipient.isMuted());
|
||||
|
||||
ringtoneMessagePreference.setSummary(getRingtoneSummary(getContext(), recipient.getMessageRingtone()));
|
||||
ringtoneMessagePreference.setSummary(getRingtoneSummary(getContext(), recipient.getMessageRingtone(getContext())));
|
||||
ringtoneCallPreference.setSummary(getRingtoneSummary(getContext(), recipient.getCallRingtone()));
|
||||
|
||||
Pair<String, Integer> vibrateMessageSummary = getVibrateSummary(getContext(), recipient.getMessageVibrate());
|
||||
|
@ -496,7 +496,7 @@ public class RecipientPreferenceActivity extends PassphraseRequiredActionBarActi
|
|||
current = recipient.getCallRingtone();
|
||||
defaultUri = TextSecurePreferences.getCallNotificationRingtone(getContext());
|
||||
} else {
|
||||
current = recipient.getMessageRingtone();
|
||||
current = recipient.getMessageRingtone(getContext());
|
||||
defaultUri = TextSecurePreferences.getNotificationRingtone(getContext());
|
||||
}
|
||||
|
||||
|
|
|
@ -325,7 +325,7 @@ public class MessageNotifier {
|
|||
}
|
||||
|
||||
if (signal) {
|
||||
builder.setAlarms(notificationState.getRingtone(), notificationState.getVibrate());
|
||||
builder.setAlarms(notificationState.getRingtone(context), notificationState.getVibrate());
|
||||
builder.setTicker(notifications.get(0).getIndividualRecipient(),
|
||||
notifications.get(0).getText());
|
||||
}
|
||||
|
@ -363,7 +363,7 @@ public class MessageNotifier {
|
|||
}
|
||||
|
||||
if (signal) {
|
||||
builder.setAlarms(notificationState.getRingtone(), notificationState.getVibrate());
|
||||
builder.setAlarms(notificationState.getRingtone(context), notificationState.getVibrate());
|
||||
builder.setTicker(notifications.get(0).getIndividualRecipient(),
|
||||
notifications.get(0).getText());
|
||||
}
|
||||
|
@ -378,7 +378,7 @@ public class MessageNotifier {
|
|||
return;
|
||||
}
|
||||
|
||||
Uri uri = recipient != null ? recipient.resolve().getMessageRingtone() : null;
|
||||
Uri uri = recipient != null ? recipient.resolve().getMessageRingtone(context) : null;
|
||||
|
||||
if (uri == null) {
|
||||
uri = TextSecurePreferences.getNotificationRingtone(context);
|
||||
|
|
|
@ -99,7 +99,7 @@ public class NotificationChannels {
|
|||
boolean vibrationEnabled = vibrateState == VibrateState.DEFAULT ? TextSecurePreferences.isNotificationVibrateEnabled(context) : vibrateState == VibrateState.ENABLED;
|
||||
String displayName = getChannelDisplayNameFor(recipient.getName(), recipient.getProfileName(), recipient.getAddress());
|
||||
|
||||
return createChannelFor(context, recipient.getAddress(), displayName, recipient.getMessageRingtone(), vibrationEnabled);
|
||||
return createChannelFor(context, recipient.getAddress(), displayName, recipient.getMessageRingtone(context), vibrationEnabled);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -219,6 +219,26 @@ public class NotificationChannels {
|
|||
notificationManager.createNotificationChannel(channel);
|
||||
}
|
||||
|
||||
public static @Nullable Uri getMessageRingtone(@NonNull Context context, @NonNull Recipient recipient) {
|
||||
if (!supported()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
NotificationManager notificationManager = context.getSystemService(NotificationManager.class);
|
||||
if (notificationManager == null) {
|
||||
Log.w(TAG, "Unable to retrieve notification manager. Cannot update channel name.");
|
||||
return null;
|
||||
}
|
||||
|
||||
NotificationChannel channel = notificationManager.getNotificationChannel(recipient.getNotificationChannel(context));
|
||||
if (channel == null) {
|
||||
Log.w(TAG, "Recipient had an invalid channel. Returning null.");
|
||||
return null;
|
||||
}
|
||||
|
||||
return channel.getSound();
|
||||
}
|
||||
|
||||
@TargetApi(26)
|
||||
private static void onCreate(@NonNull Context context, @NonNull NotificationManager notificationManager) {
|
||||
NotificationChannelGroup messagesGroup = new NotificationChannelGroup(CATEGORY_MESSAGES, context.getResources().getString(R.string.NotificationChannel_group_messages));
|
||||
|
|
|
@ -45,12 +45,12 @@ public class NotificationState {
|
|||
notificationCount++;
|
||||
}
|
||||
|
||||
public @Nullable Uri getRingtone() {
|
||||
public @Nullable Uri getRingtone(@NonNull Context context) {
|
||||
if (!notifications.isEmpty()) {
|
||||
Recipient recipient = notifications.getFirst().getRecipient();
|
||||
|
||||
if (recipient != null) {
|
||||
return recipient.resolve().getMessageRingtone();
|
||||
return recipient.resolve().getMessageRingtone(context);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -464,11 +464,15 @@ public class Recipient implements RecipientModifiedListener {
|
|||
if (notify) notifyListeners();
|
||||
}
|
||||
|
||||
public synchronized @Nullable Uri getMessageRingtone() {
|
||||
public synchronized @Nullable Uri getMessageRingtone(@NonNull Context context) {
|
||||
if (messageRingtone != null && messageRingtone.getScheme() != null && messageRingtone.getScheme().startsWith("file")) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (NotificationChannels.supported()) {
|
||||
return NotificationChannels.getMessageRingtone(context, this);
|
||||
}
|
||||
|
||||
return messageRingtone;
|
||||
}
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue