mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-23 18:15:22 +00:00
Address bugs in notification channel backup restore.
This commit is contained in:
parent
ad036b0d6a
commit
70eecb754e
@ -364,7 +364,7 @@ public class RecipientPreferenceActivity extends PassphraseRequiredActionBarActi
|
||||
|
||||
mutePreference.setChecked(recipient.isMuted());
|
||||
|
||||
ringtoneMessagePreference.setSummary(ringtoneMessagePreference.isEnabled() ? getRingtoneSummary(getContext(), recipient.getMessageRingtone(getContext())) : "");
|
||||
ringtoneMessagePreference.setSummary(ringtoneMessagePreference.isEnabled() ? getRingtoneSummary(getContext(), recipient.getMessageRingtone()) : "");
|
||||
ringtoneCallPreference.setSummary(getRingtoneSummary(getContext(), recipient.getCallRingtone()));
|
||||
|
||||
Pair<String, Integer> vibrateMessageSummary = getVibrateSummary(getContext(), recipient.getMessageVibrate());
|
||||
@ -512,7 +512,7 @@ public class RecipientPreferenceActivity extends PassphraseRequiredActionBarActi
|
||||
current = recipient.getCallRingtone();
|
||||
defaultUri = TextSecurePreferences.getCallNotificationRingtone(getContext());
|
||||
} else {
|
||||
current = recipient.getMessageRingtone(getContext());
|
||||
current = recipient.getMessageRingtone();
|
||||
defaultUri = TextSecurePreferences.getNotificationRingtone(getContext());
|
||||
}
|
||||
|
||||
@ -754,17 +754,5 @@ public class RecipientPreferenceActivity extends PassphraseRequiredActionBarActi
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private class NotificationSettingsClickedListener implements Preference.OnPreferenceClickListener {
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
String channel = recipient.getNotificationChannel();
|
||||
if (channel != null) {
|
||||
NotificationChannels.openChannelSettings(getActivity(), channel);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -381,7 +381,10 @@ public class MessageNotifier {
|
||||
return;
|
||||
}
|
||||
|
||||
Uri uri = recipient != null ? recipient.resolve().getMessageRingtone(context) : null;
|
||||
Uri uri = null;
|
||||
if (recipient != null) {
|
||||
uri = NotificationChannels.supported() ? NotificationChannels.getMessageRingtone(context, recipient) : recipient.getMessageRingtone();
|
||||
}
|
||||
|
||||
if (uri == null) {
|
||||
uri = NotificationChannels.supported() ? NotificationChannels.getMessageRingtone(context) : TextSecurePreferences.getNotificationRingtone(context);
|
||||
|
@ -82,7 +82,11 @@ public class NotificationChannels {
|
||||
try (RecipientDatabase.RecipientReader reader = db.getRecipientsWithNotificationChannels()) {
|
||||
Recipient recipient;
|
||||
while ((recipient = reader.getNext()) != null) {
|
||||
NotificationChannels.createChannelFor(context, recipient);
|
||||
NotificationManager notificationManager = getNotificationManager(context);
|
||||
if (!channelExists(notificationManager.getNotificationChannel(recipient.getNotificationChannel()))) {
|
||||
String id = createChannelFor(context, recipient);
|
||||
db.setNotificationChannel(recipient, id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -123,7 +127,7 @@ public class NotificationChannels {
|
||||
public static String createChannelFor(@NonNull Context context, @NonNull Recipient recipient) {
|
||||
VibrateState vibrateState = recipient.getMessageVibrate();
|
||||
boolean vibrationEnabled = vibrateState == VibrateState.DEFAULT ? TextSecurePreferences.isNotificationVibrateEnabled(context) : vibrateState == VibrateState.ENABLED;
|
||||
Uri messageRingtone = recipient.getMessageRingtone(context) != null ? recipient.getMessageRingtone(context) : getMessageRingtone(context);
|
||||
Uri messageRingtone = recipient.getMessageRingtone() != null ? recipient.getMessageRingtone() : getMessageRingtone(context);
|
||||
String displayName = getChannelDisplayNameFor(context, recipient.getName(), recipient.getProfileName(), recipient.getAddress());
|
||||
|
||||
return createChannelFor(context, recipient.getAddress(), displayName, messageRingtone, vibrationEnabled);
|
||||
|
@ -50,7 +50,8 @@ public class NotificationState {
|
||||
Recipient recipient = notifications.getFirst().getRecipient();
|
||||
|
||||
if (recipient != null) {
|
||||
return recipient.resolve().getMessageRingtone(context);
|
||||
return NotificationChannels.supported() ? NotificationChannels.getMessageRingtone(context, recipient)
|
||||
: recipient.resolve().getMessageRingtone();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -463,15 +463,11 @@ public class Recipient implements RecipientModifiedListener {
|
||||
if (notify) notifyListeners();
|
||||
}
|
||||
|
||||
public synchronized @Nullable Uri getMessageRingtone(@NonNull Context context) {
|
||||
public synchronized @Nullable Uri getMessageRingtone() {
|
||||
if (messageRingtone != null && messageRingtone.getScheme() != null && messageRingtone.getScheme().startsWith("file")) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (NotificationChannels.supported()) {
|
||||
return NotificationChannels.getMessageRingtone(context, this);
|
||||
}
|
||||
|
||||
return messageRingtone;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user