kopia lustrzana https://github.com/ryukoposting/Signal-Android
Merge pull request #446 from veeti/settings
Show LED and ringtone setting values in their summariesfork-5.53.8
commit
bba49fcb76
|
@ -440,12 +440,8 @@
|
|||
<string name="preferences__manage_configured_identity_keys">Manage configured identity keys</string>
|
||||
<string name="preferences__notifications">Notifications</string>
|
||||
<string name="preferences__display_message_notifications_in_status_bar">Display message notifications in status bar</string>
|
||||
<string name="preferences__led_color">LED Color</string>
|
||||
<string name="preferences__change_notification_led_color">Change notification LED color</string>
|
||||
<string name="preferences__pref_led_blink_title">LED Blink Pattern</string>
|
||||
<string name="preferences__change_notification_blink_pattern">Change notification LED blink pattern</string>
|
||||
<string name="preferences__pref_led_blink_dialogtitle">Select LED Blink Pattern</string>
|
||||
<string name="preferences__select_led_color">Select LED Color</string>
|
||||
<string name="preferences__led_color">LED color</string>
|
||||
<string name="preferences__pref_led_blink_title">LED blink pattern</string>
|
||||
<string name="preferences__sound">Sound</string>
|
||||
<string name="preferences__change_notification_sound">Change notification sound</string>
|
||||
<string name="preferences__inthread_notifications">In-thread notifications</string>
|
||||
|
|
|
@ -32,20 +32,16 @@
|
|||
android:defaultValue="green"
|
||||
android:title="@string/preferences__led_color"
|
||||
android:dependency="pref_key_enable_notifications"
|
||||
android:summary="@string/preferences__change_notification_led_color"
|
||||
android:entries="@array/pref_led_color_entries"
|
||||
android:entryValues="@array/pref_led_color_values"
|
||||
android:dialogTitle="@string/preferences__select_led_color" />
|
||||
android:entryValues="@array/pref_led_color_values" />
|
||||
|
||||
<org.thoughtcrime.securesms.preferences.LedBlinkPatternListPreference
|
||||
android:key="pref_led_blink"
|
||||
android:defaultValue="500,2000"
|
||||
android:title="@string/preferences__pref_led_blink_title"
|
||||
android:dependency="pref_key_enable_notifications"
|
||||
android:summary="@string/preferences__change_notification_blink_pattern"
|
||||
android:entries="@array/pref_led_blink_pattern_entries"
|
||||
android:entryValues="@array/pref_led_blink_pattern_values"
|
||||
android:dialogTitle="@string/preferences__pref_led_blink_dialogtitle" />
|
||||
android:entryValues="@array/pref_led_blink_pattern_values" />
|
||||
|
||||
|
||||
<RingtonePreference android:layout="?android:attr/preferenceLayoutChild"
|
||||
|
|
|
@ -21,17 +21,22 @@ import android.app.AlertDialog;
|
|||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.media.Ringtone;
|
||||
import android.media.RingtoneManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.preference.CheckBoxPreference;
|
||||
import android.preference.EditTextPreference;
|
||||
import android.preference.ListPreference;
|
||||
import android.preference.Preference;
|
||||
import android.preference.PreferenceGroup;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.preference.PreferenceScreen;
|
||||
import android.preference.RingtonePreference;
|
||||
import android.provider.ContactsContract;
|
||||
import android.provider.Telephony;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
@ -128,6 +133,16 @@ public class ApplicationPreferencesActivity extends PassphraseRequiredSherlockPr
|
|||
.setOnPreferenceChangeListener(new DisablePassphraseClickListener());
|
||||
this.findPreference(MMS_PREF)
|
||||
.setOnPreferenceClickListener(new ApnPreferencesClickListener());
|
||||
this.findPreference(LED_COLOR_PREF)
|
||||
.setOnPreferenceChangeListener(new ListSummaryListener());
|
||||
this.findPreference(LED_BLINK_PREF)
|
||||
.setOnPreferenceChangeListener(new ListSummaryListener());
|
||||
this.findPreference(RINGTONE_PREF)
|
||||
.setOnPreferenceChangeListener(new RingtoneSummaryListener());
|
||||
|
||||
initializeListSummary((ListPreference) findPreference(LED_COLOR_PREF));
|
||||
initializeListSummary((ListPreference) findPreference(LED_BLINK_PREF));
|
||||
initializeRingtoneSummary((RingtonePreference) findPreference(RINGTONE_PREF));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -225,6 +240,18 @@ public class ApplicationPreferencesActivity extends PassphraseRequiredSherlockPr
|
|||
}
|
||||
}
|
||||
|
||||
private void initializeListSummary(ListPreference pref) {
|
||||
pref.setSummary(pref.getEntry());
|
||||
}
|
||||
|
||||
private void initializeRingtoneSummary(RingtonePreference pref) {
|
||||
RingtoneSummaryListener listener =
|
||||
(RingtoneSummaryListener) pref.getOnPreferenceChangeListener();
|
||||
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
|
||||
listener.onPreferenceChange(pref, sharedPreferences.getString(pref.getKey(), ""));
|
||||
}
|
||||
|
||||
private void handleIdentitySelection(Intent data) {
|
||||
Uri contactUri = data.getData();
|
||||
|
||||
|
@ -380,6 +407,42 @@ public class ApplicationPreferencesActivity extends PassphraseRequiredSherlockPr
|
|||
}
|
||||
}
|
||||
|
||||
private class ListSummaryListener implements Preference.OnPreferenceChangeListener {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object value) {
|
||||
ListPreference asList = (ListPreference) preference;
|
||||
|
||||
int index = 0;
|
||||
for (; index < asList.getEntryValues().length; index++) {
|
||||
if (value.equals(asList.getEntryValues()[index])) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
asList.setSummary(asList.getEntries()[index]);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private class RingtoneSummaryListener implements Preference.OnPreferenceChangeListener {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
String value = (String) newValue;
|
||||
|
||||
if (TextUtils.isEmpty(value)) {
|
||||
preference.setSummary(R.string.preferences__default);
|
||||
} else {
|
||||
Ringtone tone = RingtoneManager.getRingtone(ApplicationPreferencesActivity.this,
|
||||
Uri.parse(value));
|
||||
if (tone != null) {
|
||||
preference.setSummary(tone.getTitle(ApplicationPreferencesActivity.this));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/* http://code.google.com/p/android/issues/detail?id=4611#c35 */
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
|
|
Ładowanie…
Reference in New Issue