From f889b61b9c354e1a888ea30f0236911a080f4f7b Mon Sep 17 00:00:00 2001 From: Bradlee Speice Date: Thu, 25 Dec 2014 16:50:59 -0500 Subject: [PATCH] Lots of styling cleanup Download activity last thing before another release --- .../minimalbible/activity/BaseActivity.java | 47 ++++++++++++++----- .../activity/viewer/BibleViewer.java | 7 ++- .../activity/settings/MinimalBibleSettings.kt | 4 ++ .../main/res/layout/activity_bible_viewer.xml | 5 +- app/src/main/res/layout/activity_settings.xml | 2 +- app/src/main/res/layout/view_bible_menu.xml | 3 +- app/src/main/res/values/styles.xml | 9 ++-- 7 files changed, 54 insertions(+), 23 deletions(-) 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 dfcbf7e..4c739c8 100644 --- a/app/src/main/java/org/bspeice/minimalbible/activity/BaseActivity.java +++ b/app/src/main/java/org/bspeice/minimalbible/activity/BaseActivity.java @@ -4,6 +4,7 @@ import android.app.Activity; import android.os.Build; import android.os.Bundle; import android.support.v7.app.ActionBarActivity; +import android.support.v7.widget.Toolbar; import android.view.View; import com.readystatesoftware.systembartint.SystemBarTintManager; @@ -29,9 +30,26 @@ public class BaseActivity extends ActionBarActivity { } public static void setupInsets(Activity context, View view) { - if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { SystemBarTintManager.SystemBarConfig config = getConfig(context); - view.setPadding(0, config.getPixelInsetTop(false), config.getPixelInsetRight(), config.getPixelInsetBottom()); + view.setPadding(0, config.getPixelInsetTop(false), + config.getPixelInsetRight(), config.getPixelInsetBottom()); + } + } + + /** + * Calculate the offset needed for a Toolbar + * The reason we need a separate method is because we don't want + * the SystemBarTintManager calculating an offset for the navigation bar + * + * @param context + * @param view + */ + public static void setupToolbar(Activity context, Toolbar view) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { + SystemBarTintManager.SystemBarConfig config = getConfig(context); + view.setPadding(0, config.getPixelInsetTop(false), + config.getPixelInsetRight(), 0); } } @@ -39,17 +57,6 @@ public class BaseActivity extends ActionBarActivity { return new SystemBarTintManager(context).getConfig(); } - /** - * Calculate the offset we need to display properly if the System bar is translucent - * - * @param context The {@link android.app.Activity} we are displaying in - * @param view The {@link android.view.View} we need to calculate the offset for. - */ - @SuppressWarnings("unused") - protected static void setInsets(Activity context, View view) { - setupInsets(context, view); - } - @SuppressWarnings("unused") protected static void setInsetsSpinner(Activity context, View view) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) return; @@ -60,6 +67,20 @@ public class BaseActivity extends ActionBarActivity { marginTopBottom); } + /** + * Calculate the offset we need to display properly if the System bar is translucent + * + * @param view The {@link android.view.View} we need to calculate the offset for. + */ + @SuppressWarnings("unused") + protected void setInsets(View view) { + setupInsets(this, view); + } + + protected void setInsetToolbar(Toolbar toolbar) { + setupToolbar(this, toolbar); + } + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); diff --git a/app/src/main/java/org/bspeice/minimalbible/activity/viewer/BibleViewer.java b/app/src/main/java/org/bspeice/minimalbible/activity/viewer/BibleViewer.java index 9a88517..935f894 100644 --- a/app/src/main/java/org/bspeice/minimalbible/activity/viewer/BibleViewer.java +++ b/app/src/main/java/org/bspeice/minimalbible/activity/viewer/BibleViewer.java @@ -2,6 +2,7 @@ package org.bspeice.minimalbible.activity.viewer; import android.content.Intent; import android.os.Bundle; +import android.support.v4.widget.DrawerLayout; import android.support.v7.widget.Toolbar; import android.view.Menu; import android.view.MenuItem; @@ -40,6 +41,9 @@ public class BibleViewer extends BaseActivity implements Injector { @InjectView(R.id.toolbar) Toolbar toolbar; + @InjectView(R.id.drawer_layout) + DrawerLayout drawerLayout; + private ObjectGraph bvObjectGraph; /** @@ -85,9 +89,8 @@ public class BibleViewer extends BaseActivity implements Injector { ButterKnife.inject(this); setSupportActionBar(toolbar); + setInsetToolbar(toolbar); bibleMenu.setBible(mainBook); - setInsets(this, bibleMenu); - bibleContent.setBook(mainBook, prefs); } 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 6638143..0e08847 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 @@ -5,6 +5,7 @@ import android.os.Bundle import org.bspeice.minimalbible.R import android.support.v7.widget.Toolbar import org.bspeice.minimalbible.activity.BaseActivity +import android.widget.LinearLayout /** * Created by bspeice on 12/1/14. @@ -20,5 +21,8 @@ class MinimalBibleSettings() : PreferenceActivity() { val toolbar = findViewById(R.id.toolbar) as Toolbar toolbar.setTitle(R.string.action_settings) + + val root = findViewById(R.id.container) as LinearLayout + BaseActivity.setupInsets(this, root) } } \ No newline at end of file diff --git a/app/src/main/res/layout/activity_bible_viewer.xml b/app/src/main/res/layout/activity_bible_viewer.xml index 2b9448a..660fbdd 100644 --- a/app/src/main/res/layout/activity_bible_viewer.xml +++ b/app/src/main/res/layout/activity_bible_viewer.xml @@ -6,12 +6,13 @@ android:layout_height="match_parent" tools:context="org.bspeice.minimalbible.activities.viewer.BibleViewer"> - + diff --git a/app/src/main/res/layout/view_bible_menu.xml b/app/src/main/res/layout/view_bible_menu.xml index ca11ec3..84c8015 100644 --- a/app/src/main/res/layout/view_bible_menu.xml +++ b/app/src/main/res/layout/view_bible_menu.xml @@ -17,7 +17,8 @@ android:paddingLeft="16dp" android:paddingRight="16dp" android:text="@string/app_name" - android:textAppearance="@style/TextAppearance.AppCompat.Title" /> + android:textAppearance="@style/TextAppearance.AppCompat.Title" + android:textColor="?android:textColorPrimary" /> - +