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);
+ }
+}