enable silent per recipient ringtone preference

Closes #4957
// FREEBIE
This commit is contained in:
Christian Ascheberg 2015-12-24 15:27:10 +01:00 committed by Moxie Marlinspike
parent 143fb1fe21
commit 1aa2d546d2
2 changed files with 13 additions and 8 deletions

View File

@ -14,7 +14,7 @@
android:key="pref_key_recipient_ringtone"
android:title="@string/recipient_preferences__notification_sound"
android:ringtoneType="notification"
android:showSilent="false"
android:showSilent="true"
android:showDefault="true"
android:persistent="false"/>

View File

@ -21,7 +21,6 @@ import android.support.v4.app.Fragment;
import android.support.v4.preference.PreferenceFragment;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.Toolbar;
import android.text.TextUtils;
import android.view.MenuItem;
import android.view.View;
import android.widget.TextView;
@ -264,15 +263,21 @@ public class RecipientPreferenceActivity extends PassphraseRequiredActionBarActi
mutePreference.setChecked(recipients.isMuted());
if (recipients.getRingtone() != null) {
Ringtone tone = RingtoneManager.getRingtone(getActivity(), recipients.getRingtone());
final Uri toneUri = recipients.getRingtone();
if (toneUri == null) {
ringtonePreference.setSummary(R.string.preferences__default);
ringtonePreference.setCurrentRingtone(Settings.System.DEFAULT_NOTIFICATION_URI);
} else if (toneUri.toString().isEmpty()) {
ringtonePreference.setSummary(R.string.preferences__silent);
ringtonePreference.setCurrentRingtone(null);
} else {
Ringtone tone = RingtoneManager.getRingtone(getActivity(), toneUri);
if (tone != null) {
ringtonePreference.setSummary(tone.getTitle(getActivity()));
ringtonePreference.setCurrentRingtone(recipients.getRingtone());
ringtonePreference.setCurrentRingtone(toneUri);
}
} else {
ringtonePreference.setSummary(R.string.preferences__default);
}
if (recipients.getVibrate() == VibrateState.DEFAULT) {
@ -336,7 +341,7 @@ public class RecipientPreferenceActivity extends PassphraseRequiredActionBarActi
final Uri uri;
if (TextUtils.isEmpty(value) || Settings.System.DEFAULT_NOTIFICATION_URI.toString().equals(value)) {
if (Settings.System.DEFAULT_NOTIFICATION_URI.toString().equals(value)) {
uri = null;
} else {
uri = Uri.parse(value);