From f466f9b017853d5b3dd46b972f1104b7a0bb57c1 Mon Sep 17 00:00:00 2001 From: Bradlee Speice Date: Thu, 25 Dec 2014 15:06:00 -0500 Subject: [PATCH] Settings activity styled correctly --- .../minimalbible/activity/BaseActivity.java | 32 ++++++++++++------- .../activity/settings/MinimalBibleSettings.kt | 9 +++++- app/src/main/res/layout/activity_settings.xml | 24 ++++++++++++++ .../fragment_expandable_navigation_drawer.xml | 12 ------- .../main/res/layout/fragment_viewer_main.xml | 13 -------- app/src/main/res/values/strings.xml | 1 - app/src/main/res/values/styles.xml | 4 +-- 7 files changed, 55 insertions(+), 40 deletions(-) create mode 100644 app/src/main/res/layout/activity_settings.xml delete mode 100644 app/src/main/res/layout/fragment_expandable_navigation_drawer.xml delete mode 100644 app/src/main/res/layout/fragment_viewer_main.xml diff --git a/app/src/main/java/org/bspeice/minimalbible/activity/BaseActivity.java b/app/src/main/java/org/bspeice/minimalbible/activity/BaseActivity.java index 76eb2dc..dfcbf7e 100644 --- a/app/src/main/java/org/bspeice/minimalbible/activity/BaseActivity.java +++ b/app/src/main/java/org/bspeice/minimalbible/activity/BaseActivity.java @@ -16,6 +16,25 @@ import org.bspeice.minimalbible.R; */ public class BaseActivity extends ActionBarActivity { + // TODO: Refactor these methods to a utility class + public static void setupStatusBar(Activity activity) { + // Only set the tint if the device is running KitKat or above + // TODO: Can this be set as part of styles.xml? + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { + SystemBarTintManager tintManager = new SystemBarTintManager(activity); + tintManager.setStatusBarTintEnabled(true); + tintManager.setStatusBarTintColor(activity.getResources() + .getColor(R.color.colorPrimary)); + } + } + + public static void setupInsets(Activity context, View view) { + if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) { + SystemBarTintManager.SystemBarConfig config = getConfig(context); + view.setPadding(0, config.getPixelInsetTop(false), config.getPixelInsetRight(), config.getPixelInsetBottom()); + } + } + protected static SystemBarTintManager.SystemBarConfig getConfig(Activity context) { return new SystemBarTintManager(context).getConfig(); } @@ -28,9 +47,7 @@ public class BaseActivity extends ActionBarActivity { */ @SuppressWarnings("unused") protected static void setInsets(Activity context, View view) { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) return; - SystemBarTintManager.SystemBarConfig config = getConfig(context); - view.setPadding(0, config.getPixelInsetTop(false), config.getPixelInsetRight(), config.getPixelInsetBottom()); + setupInsets(context, view); } @SuppressWarnings("unused") @@ -47,13 +64,6 @@ public class BaseActivity extends ActionBarActivity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - // Only set the tint if the device is running KitKat or above - // TODO: Can this be set as part of styles.xml? - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { - SystemBarTintManager tintManager = new SystemBarTintManager(this); - tintManager.setStatusBarTintEnabled(true); - tintManager.setStatusBarTintColor(getResources().getColor( - R.color.colorPrimary)); - } + setupStatusBar(this); } } diff --git a/app/src/main/kotlin/org/bspeice/minimalbible/activity/settings/MinimalBibleSettings.kt b/app/src/main/kotlin/org/bspeice/minimalbible/activity/settings/MinimalBibleSettings.kt index 9c37681..6638143 100644 --- a/app/src/main/kotlin/org/bspeice/minimalbible/activity/settings/MinimalBibleSettings.kt +++ b/app/src/main/kotlin/org/bspeice/minimalbible/activity/settings/MinimalBibleSettings.kt @@ -3,15 +3,22 @@ package org.bspeice.minimalbible.activity.settings import android.preference.PreferenceActivity import android.os.Bundle import org.bspeice.minimalbible.R +import android.support.v7.widget.Toolbar +import org.bspeice.minimalbible.activity.BaseActivity /** * Created by bspeice on 12/1/14. */ -// TODO: Fix the status bar color/transparency, and lack of toolbar class MinimalBibleSettings() : PreferenceActivity() { + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) addPreferencesFromResource(R.xml.preferences) + setContentView(R.layout.activity_settings) + BaseActivity.setupStatusBar(this) + + val toolbar = findViewById(R.id.toolbar) as Toolbar + toolbar.setTitle(R.string.action_settings) } } \ No newline at end of file diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml new file mode 100644 index 0000000..e1d0163 --- /dev/null +++ b/app/src/main/res/layout/activity_settings.xml @@ -0,0 +1,24 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_expandable_navigation_drawer.xml b/app/src/main/res/layout/fragment_expandable_navigation_drawer.xml deleted file mode 100644 index 35da2a2..0000000 --- a/app/src/main/res/layout/fragment_expandable_navigation_drawer.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_viewer_main.xml b/app/src/main/res/layout/fragment_viewer_main.xml deleted file mode 100644 index 37d52b8..0000000 --- a/app/src/main/res/layout/fragment_viewer_main.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index e13a246..283a221 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -7,7 +7,6 @@ Section 3 Open navigation drawer Close navigation drawer - Example action Settings Downloads diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 238381f..39e3ae3 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -26,8 +26,8 @@ 8dp -