From 2dceef50b7e59ecafb8bcb59eda4a44c22a240ae Mon Sep 17 00:00:00 2001 From: Moxie Marlinspike Date: Fri, 21 Apr 2017 22:50:49 -0700 Subject: [PATCH] Slim down some preference screens // FREEBIE --- .../preference_right_summary_widget.xml | 15 +++++ res/values/strings.xml | 2 + res/xml/preferences_app_protection.xml | 11 ++-- res/xml/preferences_appearance.xml | 24 +++---- res/xml/preferences_chats.xml | 13 ++-- res/xml/preferences_notifications.xml | 34 +++++----- .../LedBlinkPatternListPreference.java | 2 +- .../preferences/SignalListPreference.java | 65 +++++++++++++++++++ .../preferences/SignalRingtonePreference.java | 63 ++++++++++++++++++ 9 files changed, 188 insertions(+), 41 deletions(-) create mode 100644 res/layout/preference_right_summary_widget.xml create mode 100644 src/org/thoughtcrime/securesms/preferences/SignalListPreference.java create mode 100644 src/org/thoughtcrime/securesms/preferences/SignalRingtonePreference.java diff --git a/res/layout/preference_right_summary_widget.xml b/res/layout/preference_right_summary_widget.xml new file mode 100644 index 0000000000..56a908e79c --- /dev/null +++ b/res/layout/preference_right_summary_widget.xml @@ -0,0 +1,15 @@ + + + + + + \ No newline at end of file diff --git a/res/values/strings.xml b/res/values/strings.xml index 31c3090b54..03fbc6b51e 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -1199,6 +1199,8 @@ Chats Message notifications Events + In-chat sounds + Show Show invitation prompts Display invitation prompts for contacts without Signal Message font size diff --git a/res/xml/preferences_app_protection.xml b/res/xml/preferences_app_protection.xml index 5f1a3b04cf..30f6fc4409 100644 --- a/res/xml/preferences_app_protection.xml +++ b/res/xml/preferences_app_protection.xml @@ -13,11 +13,12 @@ android:summary="@string/preferences__change_your_passphrase" android:dependency="pref_enable_passphrase_temporary"/> - + - - + + - + diff --git a/res/xml/preferences_chats.xml b/res/xml/preferences_chats.xml index 3fb31a699c..23c9a2705b 100644 --- a/res/xml/preferences_chats.xml +++ b/res/xml/preferences_chats.xml @@ -30,12 +30,13 @@ - - + + - + + android:title="@string/preferences__vibrate"/> - - + @@ -68,7 +67,6 @@ diff --git a/src/org/thoughtcrime/securesms/preferences/LedBlinkPatternListPreference.java b/src/org/thoughtcrime/securesms/preferences/LedBlinkPatternListPreference.java index 5a8b4c22a2..529274aabd 100644 --- a/src/org/thoughtcrime/securesms/preferences/LedBlinkPatternListPreference.java +++ b/src/org/thoughtcrime/securesms/preferences/LedBlinkPatternListPreference.java @@ -38,7 +38,7 @@ import org.thoughtcrime.securesms.util.TextSecurePreferences; * @author Moxie Marlinspike */ -public class LedBlinkPatternListPreference extends ListPreference implements OnSeekBarChangeListener { +public class LedBlinkPatternListPreference extends SignalListPreference implements OnSeekBarChangeListener { private Context context; private SeekBar seekBarOn; diff --git a/src/org/thoughtcrime/securesms/preferences/SignalListPreference.java b/src/org/thoughtcrime/securesms/preferences/SignalListPreference.java new file mode 100644 index 0000000000..179589ff8c --- /dev/null +++ b/src/org/thoughtcrime/securesms/preferences/SignalListPreference.java @@ -0,0 +1,65 @@ +package org.thoughtcrime.securesms.preferences; + + +import android.content.Context; +import android.os.Build; +import android.preference.ListPreference; +import android.support.annotation.RequiresApi; +import android.util.AttributeSet; +import android.util.TypedValue; +import android.view.View; +import android.widget.TextView; + +import org.thoughtcrime.securesms.R; +import org.thoughtcrime.securesms.util.ViewUtil; + +public class SignalListPreference extends ListPreference { + + private TextView rightSummary; + private CharSequence summary; + + @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) + public SignalListPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { + super(context, attrs, defStyleAttr, defStyleRes); + initialize(); + } + + @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) + public SignalListPreference(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + initialize(); + } + + public SignalListPreference(Context context, AttributeSet attrs) { + super(context, attrs); + initialize(); + } + + public SignalListPreference(Context context) { + super(context); + initialize(); + } + + private void initialize() { + setWidgetLayoutResource(R.layout.preference_right_summary_widget); + } + + @Override + protected void onBindView(View view) { + super.onBindView(view); + + this.rightSummary = (TextView)view.findViewById(R.id.right_summary); + setSummary(this.summary); + } + + @Override + public void setSummary(CharSequence summary) { + super.setSummary(null); + + this.summary = summary; + + if (this.rightSummary != null) { + this.rightSummary.setText(summary); + } + } +} diff --git a/src/org/thoughtcrime/securesms/preferences/SignalRingtonePreference.java b/src/org/thoughtcrime/securesms/preferences/SignalRingtonePreference.java new file mode 100644 index 0000000000..1cfa2fb178 --- /dev/null +++ b/src/org/thoughtcrime/securesms/preferences/SignalRingtonePreference.java @@ -0,0 +1,63 @@ +package org.thoughtcrime.securesms.preferences; + + +import android.content.Context; +import android.os.Build; +import android.preference.RingtonePreference; +import android.support.annotation.RequiresApi; +import android.util.AttributeSet; +import android.view.View; +import android.widget.TextView; + +import org.thoughtcrime.securesms.R; + +public class SignalRingtonePreference extends RingtonePreference { + + private TextView rightSummary; + private CharSequence summary; + + @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) + public SignalRingtonePreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { + super(context, attrs, defStyleAttr, defStyleRes); + initialize(); + } + + public SignalRingtonePreference(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + initialize(); + } + + public SignalRingtonePreference(Context context, AttributeSet attrs) { + super(context, attrs); + initialize(); + } + + public SignalRingtonePreference(Context context) { + super(context); + initialize(); + } + + private void initialize() { + setWidgetLayoutResource(R.layout.preference_right_summary_widget); + } + + @Override + protected void onBindView(View view) { + super.onBindView(view); + + this.rightSummary = (TextView)view.findViewById(R.id.right_summary); + setSummary(summary); + } + + @Override + public void setSummary(CharSequence summary) { + this.summary = summary; + + super.setSummary(null); + + if (rightSummary != null) { + rightSummary.setText(summary); + } + } + +}