From 3e890e11d909476af496a70fbc01aa4e42318a11 Mon Sep 17 00:00:00 2001 From: agrajaghh Date: Sun, 17 May 2015 14:13:34 +0200 Subject: [PATCH] add SwitchCompat to preferences Closes #3137 --- res/layout/switch_compat_preference.xml | 9 +++++ res/xml/preferences_advanced.xml | 6 ++- res/xml/preferences_app_protection.xml | 6 ++- res/xml/preferences_notifications.xml | 3 +- res/xml/preferences_sms_mms.xml | 12 ++++-- res/xml/preferences_storage.xml | 3 +- .../components/SwitchPreferenceCompat.java | 37 +++++++++++++++++++ 7 files changed, 66 insertions(+), 10 deletions(-) create mode 100644 res/layout/switch_compat_preference.xml create mode 100644 src/org/thoughtcrime/securesms/components/SwitchPreferenceCompat.java diff --git a/res/layout/switch_compat_preference.xml b/res/layout/switch_compat_preference.xml new file mode 100644 index 0000000000..739a3c23b2 --- /dev/null +++ b/res/layout/switch_compat_preference.xml @@ -0,0 +1,9 @@ + + diff --git a/res/xml/preferences_advanced.xml b/res/xml/preferences_advanced.xml index 473d588e92..26b3515e64 100644 --- a/res/xml/preferences_advanced.xml +++ b/res/xml/preferences_advanced.xml @@ -1,12 +1,14 @@ - - diff --git a/res/xml/preferences_app_protection.xml b/res/xml/preferences_app_protection.xml index 93451d7fb2..7ec1cc40fd 100644 --- a/res/xml/preferences_app_protection.xml +++ b/res/xml/preferences_app_protection.xml @@ -1,7 +1,8 @@ - @@ -21,7 +22,8 @@ android:key="pref_timeout_interval" android:dependency="pref_timeout_passphrase"/> - diff --git a/res/xml/preferences_notifications.xml b/res/xml/preferences_notifications.xml index 68fdd49b30..5abc24ac93 100644 --- a/res/xml/preferences_notifications.xml +++ b/res/xml/preferences_notifications.xml @@ -1,7 +1,8 @@ - diff --git a/res/xml/preferences_sms_mms.xml b/res/xml/preferences_sms_mms.xml index a7083cb42e..8d8a33ea10 100644 --- a/res/xml/preferences_sms_mms.xml +++ b/res/xml/preferences_sms_mms.xml @@ -1,12 +1,14 @@ - - @@ -15,12 +17,14 @@ android:title="@string/ApplicationPreferencesActivity_sms_disabled" android:summary="@string/ApplicationPreferencesActivity_touch_to_make_textsecure_your_default_sms_app" /> - - diff --git a/res/xml/preferences_storage.xml b/res/xml/preferences_storage.xml index 00cd1f5d01..83a1d88cc9 100644 --- a/res/xml/preferences_storage.xml +++ b/res/xml/preferences_storage.xml @@ -1,7 +1,8 @@ - diff --git a/src/org/thoughtcrime/securesms/components/SwitchPreferenceCompat.java b/src/org/thoughtcrime/securesms/components/SwitchPreferenceCompat.java new file mode 100644 index 0000000000..26da2811b7 --- /dev/null +++ b/src/org/thoughtcrime/securesms/components/SwitchPreferenceCompat.java @@ -0,0 +1,37 @@ +package org.thoughtcrime.securesms.components; + +import android.annotation.TargetApi; +import android.content.Context; +import android.os.Build; +import android.preference.CheckBoxPreference; +import android.util.AttributeSet; + +import org.thoughtcrime.securesms.R; + +public class SwitchPreferenceCompat extends CheckBoxPreference { + + public SwitchPreferenceCompat(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + setLayoutRes(); + } + + @TargetApi(Build.VERSION_CODES.LOLLIPOP) + public SwitchPreferenceCompat(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { + super(context, attrs, defStyleAttr, defStyleRes); + setLayoutRes(); + } + + public SwitchPreferenceCompat(Context context, AttributeSet attrs) { + super(context, attrs); + setLayoutRes(); + } + + public SwitchPreferenceCompat(Context context) { + super(context); + setLayoutRes(); + } + + private void setLayoutRes() { + setWidgetLayoutResource(R.layout.switch_compat_preference); + } +}