Make preferences look decent (material) on KitKat

I have no idea what I'm doing
This commit is contained in:
Alexander Bakker 2018-05-14 18:45:15 +02:00
parent f8891c0225
commit 972a1670eb
6 changed files with 20 additions and 16 deletions

View file

@ -32,6 +32,7 @@ dependencies {
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.takisoft.fix:preference-v7:27.1.1.1'
implementation 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
implementation 'me.dm7.barcodescanner:zxing:1.9'
implementation 'com.android.support:cardview-v7:27.1.1'

View file

@ -16,7 +16,7 @@ public class PreferencesActivity extends AegisActivity implements PasswordDialog
_fragment = new PreferencesFragment();
_fragment.setArguments(getIntent().getExtras());
getFragmentManager().beginTransaction().replace(android.R.id.content, _fragment).commit();
getSupportFragmentManager().beginTransaction().replace(android.R.id.content, _fragment).commit();
}
@Override

View file

@ -7,11 +7,11 @@ import android.content.Intent;
import android.media.MediaScannerConnection;
import android.net.Uri;
import android.os.Bundle;
import android.preference.EditTextPreference;
import android.preference.Preference;
import android.preference.PreferenceFragment;
import android.support.v7.preference.EditTextPreference;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.preference.Preference;
import com.takisoft.fix.support.v7.preference.PreferenceFragmentCompat;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Toast;
@ -42,7 +42,7 @@ import me.impy.aegis.ui.dialogs.PasswordDialogFragment;
import me.impy.aegis.ui.preferences.SwitchPreference;
import me.impy.aegis.util.ByteInputStream;
public class PreferencesFragment extends PreferenceFragment implements PasswordDialogFragment.Listener {
public class PreferencesFragment extends PreferenceFragmentCompat implements PasswordDialogFragment.Listener {
// activity request codes
private static final int CODE_IMPORT = 0;
private static final int CODE_IMPORT_DECRYPT = 1;
@ -64,8 +64,7 @@ public class PreferencesFragment extends PreferenceFragment implements PasswordD
private Preference _slotsPreference;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
public void onCreatePreferencesFix(Bundle savedInstanceState, String rootKey) {
addPreferencesFromResource(R.xml.preferences);
AegisApplication app = (AegisApplication) getActivity().getApplication();

View file

@ -3,10 +3,12 @@ package me.impy.aegis.ui.preferences;
import android.content.Context;
import android.os.Build;
import android.support.annotation.RequiresApi;
import android.support.v7.preference.Preference;
import android.support.v7.preference.SwitchPreferenceCompat;
import android.util.AttributeSet;
public class SwitchPreference extends android.preference.SwitchPreference {
private OnPreferenceChangeListener _listener;
public class SwitchPreference extends SwitchPreferenceCompat {
private Preference.OnPreferenceChangeListener _listener;
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public SwitchPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {

View file

@ -16,7 +16,7 @@
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar"/>
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light"/>
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<style name="AppTheme" parent="PreferenceFixTheme.Light.DarkActionBar">
<item name="primaryText">@color/primary_text</item>
<item name="secondaryText">@color/secondary_text</item>
<item name="cardBackground">@color/card_background</item>
@ -25,6 +25,7 @@
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="background">@color/background</item>
<item name="preferenceCategory_marginBottom">0dp</item>
<item name="swirl_ridgeColor">@color/colorSwirlPrimary</item>
<item name="swirl_errorColor">@color/colorSwirlError</item>
@ -45,7 +46,7 @@
<item name="android:windowFullscreen">true</item>
</style>
<style name="AppTheme.Dark" parent="Theme.AppCompat">
<style name="AppTheme.Dark" parent="@style/PreferenceFixTheme">
<item name="primaryText">@color/primary_text_dark</item>
<item name="secondaryText">@color/secondary_text_dark</item>
<item name="cardBackground">@color/card_background_dark</item>
@ -54,6 +55,7 @@
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="background">@color/background_dark</item>
<item name="preferenceCategory_marginBottom">0dp</item>
<item name="swirl_ridgeColor">@color/colorSwirlPrimaryDark</item>
<item name="swirl_errorColor">@color/colorSwirlErrorDark</item>

View file

@ -1,16 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
<android.support.v7.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/settings">
<PreferenceCategory
android:title="Appearance">
<SwitchPreference
<android.support.v7.preference.SwitchPreferenceCompat
android:defaultValue="false"
android:key="pref_dark_mode"
android:title="@string/pref_dark_mode_title"
android:summary="@string/pref_dark_mode_summary"/>
<SwitchPreference
<android.support.v7.preference.SwitchPreferenceCompat
android:defaultValue="false"
android:key="pref_issuer"
android:title="@string/pref_issuer_title"
@ -19,7 +19,7 @@
<PreferenceCategory
android:title="Security">
<SwitchPreference
<android.support.v7.preference.SwitchPreferenceCompat
android:defaultValue="true"
android:key="pref_secure_screen"
android:title="@string/pref_secure_screen_title"
@ -54,4 +54,4 @@
android:summary="@string/pref_export_summary"/>
</PreferenceCategory>
</PreferenceScreen>
</android.support.v7.preference.PreferenceScreen>