mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-18 13:49:53 +01:00
Merge branch '1651-no-ringtone-picker' into 'master'
Check if ringtone picker is available before launching it Closes #1485 and #1651 See merge request briar/briar!1188
This commit is contained in:
@@ -347,8 +347,10 @@ class AndroidNotificationManagerImpl implements AndroidNotificationManager,
|
|||||||
if (currentTime - lastSound > SOUND_DELAY) {
|
if (currentTime - lastSound > SOUND_DELAY) {
|
||||||
boolean sound = settings.getBoolean(PREF_NOTIFY_SOUND, true);
|
boolean sound = settings.getBoolean(PREF_NOTIFY_SOUND, true);
|
||||||
String ringtoneUri = settings.get(PREF_NOTIFY_RINGTONE_URI);
|
String ringtoneUri = settings.get(PREF_NOTIFY_RINGTONE_URI);
|
||||||
if (sound && !StringUtils.isNullOrEmpty(ringtoneUri))
|
if (sound && !StringUtils.isNullOrEmpty(ringtoneUri)) {
|
||||||
b.setSound(Uri.parse(ringtoneUri));
|
Uri uri = Uri.parse(ringtoneUri);
|
||||||
|
if (!"file".equals(uri.getScheme())) b.setSound(uri);
|
||||||
|
}
|
||||||
b.setDefaults(getDefaults());
|
b.setDefaults(getDefaults());
|
||||||
lastSound = currentTime;
|
lastSound = currentTime;
|
||||||
}
|
}
|
||||||
@@ -359,7 +361,8 @@ class AndroidNotificationManagerImpl implements AndroidNotificationManager,
|
|||||||
int defaults = DEFAULT_LIGHTS;
|
int defaults = DEFAULT_LIGHTS;
|
||||||
boolean sound = settings.getBoolean(PREF_NOTIFY_SOUND, true);
|
boolean sound = settings.getBoolean(PREF_NOTIFY_SOUND, true);
|
||||||
String ringtoneUri = settings.get(PREF_NOTIFY_RINGTONE_URI);
|
String ringtoneUri = settings.get(PREF_NOTIFY_RINGTONE_URI);
|
||||||
if (sound && StringUtils.isNullOrEmpty(ringtoneUri))
|
if (sound && (StringUtils.isNullOrEmpty(ringtoneUri) ||
|
||||||
|
"file".equals(Uri.parse(ringtoneUri).getScheme())))
|
||||||
defaults |= DEFAULT_SOUND;
|
defaults |= DEFAULT_SOUND;
|
||||||
if (settings.getBoolean(PREF_NOTIFY_VIBRATION, true))
|
if (settings.getBoolean(PREF_NOTIFY_VIBRATION, true))
|
||||||
defaults |= DEFAULT_VIBRATE;
|
defaults |= DEFAULT_VIBRATE;
|
||||||
|
|||||||
@@ -511,7 +511,12 @@ public class SettingsFragment extends PreferenceFragmentCompat
|
|||||||
else uri = Uri.parse(ringtoneUri);
|
else uri = Uri.parse(ringtoneUri);
|
||||||
i.putExtra(EXTRA_RINGTONE_EXISTING_URI, uri);
|
i.putExtra(EXTRA_RINGTONE_EXISTING_URI, uri);
|
||||||
}
|
}
|
||||||
startActivityForResult(i, REQUEST_RINGTONE);
|
if (i.resolveActivity(requireActivity().getPackageManager()) != null) {
|
||||||
|
startActivityForResult(i, REQUEST_RINGTONE);
|
||||||
|
} else {
|
||||||
|
Toast.makeText(getContext(), R.string.cannot_load_ringtone,
|
||||||
|
LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -646,7 +651,7 @@ public class SettingsFragment extends PreferenceFragmentCompat
|
|||||||
} else {
|
} else {
|
||||||
// The user chose a ringtone other than the default
|
// The user chose a ringtone other than the default
|
||||||
Ringtone r = RingtoneManager.getRingtone(getContext(), uri);
|
Ringtone r = RingtoneManager.getRingtone(getContext(), uri);
|
||||||
if (r == null) {
|
if (r == null || "file".equals(uri.getScheme())) {
|
||||||
Toast.makeText(getContext(), R.string.cannot_load_ringtone,
|
Toast.makeText(getContext(), R.string.cannot_load_ringtone,
|
||||||
LENGTH_SHORT).show();
|
LENGTH_SHORT).show();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user