From 8a2ddf6cac8dcf12aa577d3a676bde6ba87ed960 Mon Sep 17 00:00:00 2001 From: M66B Date: Mon, 1 Feb 2016 17:42:18 +0100 Subject: [PATCH] Preference compat --- app/app.iml | 4 ++++ app/build.gradle | 2 ++ .../main/java/eu/faircode/netguard/ActivitySettings.java | 2 +- .../main/java/eu/faircode/netguard/FragmentSettings.java | 9 ++++++--- .../main/java/eu/faircode/netguard/SwitchPreference.java | 3 ++- app/src/main/res/values/styles.xml | 2 ++ app/src/main/res/xml/preferences.xml | 2 +- 7 files changed, 18 insertions(+), 6 deletions(-) diff --git a/app/app.iml b/app/app.iml index c8002dfb..c452ceed 100644 --- a/app/app.iml +++ b/app/app.iml @@ -91,8 +91,10 @@ + + @@ -112,6 +114,8 @@ + + \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index eeb343fe..0c990ba2 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -56,5 +56,7 @@ dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:23.1.+' compile 'com.android.support:recyclerview-v7:23.1.+' + compile 'com.android.support:preference-v7:23.1.+' + compile 'com.h6ah4i.android.compat:mulsellistprefcompat:1.0.0' // Google come on ... compile 'com.squareup.picasso:picasso:2.5.+' } diff --git a/app/src/main/java/eu/faircode/netguard/ActivitySettings.java b/app/src/main/java/eu/faircode/netguard/ActivitySettings.java index a3601777..69f31c64 100644 --- a/app/src/main/java/eu/faircode/netguard/ActivitySettings.java +++ b/app/src/main/java/eu/faircode/netguard/ActivitySettings.java @@ -101,7 +101,7 @@ public class ActivitySettings extends AppCompatActivity implements SharedPrefere protected void onCreate(Bundle savedInstanceState) { Util.setTheme(this); super.onCreate(savedInstanceState); - getFragmentManager().beginTransaction().replace(android.R.id.content, new FragmentSettings()).commit(); + getSupportFragmentManager().beginTransaction().replace(android.R.id.content, new FragmentSettings()).commit(); getSupportActionBar().setTitle(R.string.menu_settings); } diff --git a/app/src/main/java/eu/faircode/netguard/FragmentSettings.java b/app/src/main/java/eu/faircode/netguard/FragmentSettings.java index 354fcf83..e3b53954 100644 --- a/app/src/main/java/eu/faircode/netguard/FragmentSettings.java +++ b/app/src/main/java/eu/faircode/netguard/FragmentSettings.java @@ -20,13 +20,16 @@ package eu.faircode.netguard; */ import android.os.Bundle; -import android.preference.PreferenceFragment; - -public class FragmentSettings extends PreferenceFragment { +import android.support.v7.preference.PreferenceFragmentCompat; +public class FragmentSettings extends PreferenceFragmentCompat { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + } + + @Override + public void onCreatePreferences(Bundle bundle, String s) { addPreferencesFromResource(R.xml.preferences); } } diff --git a/app/src/main/java/eu/faircode/netguard/SwitchPreference.java b/app/src/main/java/eu/faircode/netguard/SwitchPreference.java index e37c2bfb..ab6de01d 100644 --- a/app/src/main/java/eu/faircode/netguard/SwitchPreference.java +++ b/app/src/main/java/eu/faircode/netguard/SwitchPreference.java @@ -20,11 +20,12 @@ package eu.faircode.netguard; */ import android.content.Context; +import android.support.v7.preference.SwitchPreferenceCompat; import android.util.AttributeSet; // https://code.google.com/p/android/issues/detail?id=26194 -public class SwitchPreference extends android.preference.SwitchPreference { +public class SwitchPreference extends SwitchPreferenceCompat { public SwitchPreference(Context context) { this(context, null); } diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index dcc201e1..573cf86f 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -5,10 +5,12 @@