From 21f940d767ee4ef3ec4e7b17a2b37bd493abb4cf Mon Sep 17 00:00:00 2001 From: Bradlee Speice Date: Mon, 22 Dec 2014 22:14:16 -0500 Subject: [PATCH] Bring in the new navigation menu API v8-compliant, sized correctly, all that good jazz. --- .../minimalbible/MinimalBibleDebug.java | 8 ++-- app/src/main/AndroidManifest.xml | 1 + .../minimalbible/activity/BaseActivity.java | 2 +- .../navigation/AbstractNavDrawerFragment.java | 2 + .../activity/viewer/BibleViewer.java | 23 ++++++----- .../minimalbible/activity/SystemBarUtil.kt | 18 +++++++++ .../minimalbible/activity/viewer/BibleMenu.kt | 39 ++++++++++++++----- .../main/res/layout/activity_bible_viewer.xml | 7 +--- .../main/res/layout/list_bible_menu_child.xml | 16 ++++++++ .../main/res/layout/list_bible_menu_group.xml | 16 ++++++++ app/src/main/res/layout/view_bible_menu.xml | 28 +++++++++++++ app/src/main/res/values-v19/styles.xml | 1 - app/src/main/res/values/dimens.xml | 3 +- app/src/main/res/values/styles.xml | 14 ++++--- 14 files changed, 140 insertions(+), 38 deletions(-) create mode 100644 app/src/main/kotlin/org/bspeice/minimalbible/activity/SystemBarUtil.kt create mode 100644 app/src/main/res/layout/list_bible_menu_child.xml create mode 100644 app/src/main/res/layout/list_bible_menu_group.xml create mode 100644 app/src/main/res/layout/view_bible_menu.xml diff --git a/app/src/debug/java/org/bspeice/minimalbible/MinimalBibleDebug.java b/app/src/debug/java/org/bspeice/minimalbible/MinimalBibleDebug.java index 01fee4f..358d061 100644 --- a/app/src/debug/java/org/bspeice/minimalbible/MinimalBibleDebug.java +++ b/app/src/debug/java/org/bspeice/minimalbible/MinimalBibleDebug.java @@ -1,22 +1,20 @@ package org.bspeice.minimalbible; -import org.acra.ACRA; -import org.acra.ReportingInteractionMode; -import org.acra.annotation.ReportsCrashes; - /** * Create a MinimalBible application that we can extend from the main release * Currently it's not doing much, but would allow for shenanigans during testing in the future */ +/* @ReportsCrashes(formKey = "", mailTo = "bspeice.nc@gmail.com", mode = ReportingInteractionMode.SILENT ) +*/ public class MinimalBibleDebug extends MinimalBible implements Injector { @Override public void onCreate() { super.onCreate(); - ACRA.init(this); +// ACRA.init(this); } } \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 1f5d14c..c8eee95 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -13,6 +13,7 @@ android:theme="@style/MinimalBible"> (this, android.R.layout.simple_list_item_1, - drawerStrings)); - - setInsets(this, drawerContent); + bibleMenu.setBible(mainBook); + setInsets(this, bibleMenu); } } diff --git a/app/src/main/kotlin/org/bspeice/minimalbible/activity/SystemBarUtil.kt b/app/src/main/kotlin/org/bspeice/minimalbible/activity/SystemBarUtil.kt new file mode 100644 index 0000000..335250e --- /dev/null +++ b/app/src/main/kotlin/org/bspeice/minimalbible/activity/SystemBarUtil.kt @@ -0,0 +1,18 @@ +package org.bspeice.minimalbible.activity + +import android.view.View +import android.os.Build +import com.readystatesoftware.systembartint.SystemBarTintManager +import android.app.Activity + +/** + * Created by bspeice on 12/22/14. + */ + +fun View.setInset(a: Activity) { + if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) { + val config = SystemBarTintManager(a).getConfig() + this.setPadding(0, config.getPixelInsetTop(false), + config.getPixelInsetRight(), config.getPixelInsetBottom()) + } +} diff --git a/app/src/main/kotlin/org/bspeice/minimalbible/activity/viewer/BibleMenu.kt b/app/src/main/kotlin/org/bspeice/minimalbible/activity/viewer/BibleMenu.kt index 7ce30a7..ad8468c 100644 --- a/app/src/main/kotlin/org/bspeice/minimalbible/activity/viewer/BibleMenu.kt +++ b/app/src/main/kotlin/org/bspeice/minimalbible/activity/viewer/BibleMenu.kt @@ -15,12 +15,29 @@ import android.content.res.Resources import android.support.annotation.IdRes import android.widget.ExpandableListView import rx.subjects.PublishSubject +import android.widget.LinearLayout +import android.app.Activity +import android.util.AttributeSet +import kotlin.properties.Delegates +import org.bspeice.minimalbible.activity.setInset +import android.support.annotation.LayoutRes -/** - * Created by bspeice on 10/24/14. - */ +class BibleMenu(val ctx: Context, val attrs: AttributeSet) : LinearLayout(ctx, attrs) { + var menuContent: ExpandableListView by Delegates.notNull(); -class BibleMenu(val b: Book) : BaseExpandableListAdapter() { + { + val inflater = ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater + inflater.inflate(R.layout.view_bible_menu, this, true) + + menuContent = findViewById(R.id.menu) as ExpandableListView + } + + fun setBible(b: Book) = menuContent.setAdapter(BibleAdapter(b)) + + fun placeInset(a: Activity) = setInset(a) +} + +class BibleAdapter(val b: Book) : BaseExpandableListAdapter() { // Map BibleBooks to the number of chapters they have val menuMappings = b.getVersification().getBooks().map { @@ -65,15 +82,16 @@ class BibleMenu(val b: Book) : BaseExpandableListAdapter() { override fun isChildSelectable(group: Int, child: Int): Boolean = true private fun doBinding(convertView: View?, parent: ViewGroup, - obj: Any, highlight: Boolean): View { + obj: Any, highlight: Boolean, + LayoutRes layout: Int): View { val finalView: View = convertView ?: (parent.getContext() .getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater) - .inflate(R.layout.list_navigation_drawer, parent, false) + .inflate(layout, parent, false) val holder: NavItemHolder = if (finalView.getTag() != null) finalView.getTag() as NavItemHolder - else NavItemHolder(finalView, R.id.navlist_content) + else NavItemHolder(finalView, R.id.content) holder.bind(obj, highlight) finalView setTag holder @@ -82,11 +100,14 @@ class BibleMenu(val b: Book) : BaseExpandableListAdapter() { override fun getGroupView(position: Int, expanded: Boolean, convertView: View?, parent: ViewGroup): View = - doBinding(convertView, parent, getGroup(position), position == groupHighlighted) + doBinding(convertView, parent, getGroup(position), + position == groupHighlighted, R.layout.list_bible_menu_group) override fun getChildView(group: Int, child: Int, isLast: Boolean, convertView: View?, parent: ViewGroup): View = - doBinding(convertView, parent, getChild(group, child), child == childHighlighted) + doBinding(convertView, parent, getChild(group, child), + group == groupHighlighted && child == childHighlighted, + R.layout.list_bible_menu_child) class NavItemHolder(val bindTo: View, IdRes resource: Int) { val content = bindTo.findViewById(resource) as TextView diff --git a/app/src/main/res/layout/activity_bible_viewer.xml b/app/src/main/res/layout/activity_bible_viewer.xml index 9a15ffe..98a4f30 100644 --- a/app/src/main/res/layout/activity_bible_viewer.xml +++ b/app/src/main/res/layout/activity_bible_viewer.xml @@ -25,17 +25,14 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Main Content" /> - - - + android:layout_gravity="start" /> diff --git a/app/src/main/res/layout/list_bible_menu_child.xml b/app/src/main/res/layout/list_bible_menu_child.xml new file mode 100644 index 0000000..b489adb --- /dev/null +++ b/app/src/main/res/layout/list_bible_menu_child.xml @@ -0,0 +1,16 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/list_bible_menu_group.xml b/app/src/main/res/layout/list_bible_menu_group.xml new file mode 100644 index 0000000..1141374 --- /dev/null +++ b/app/src/main/res/layout/list_bible_menu_group.xml @@ -0,0 +1,16 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/view_bible_menu.xml b/app/src/main/res/layout/view_bible_menu.xml new file mode 100644 index 0000000..ca11ec3 --- /dev/null +++ b/app/src/main/res/layout/view_bible_menu.xml @@ -0,0 +1,28 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values-v19/styles.xml b/app/src/main/res/values-v19/styles.xml index 3a432c3..e5030c6 100644 --- a/app/src/main/res/values-v19/styles.xml +++ b/app/src/main/res/values-v19/styles.xml @@ -10,5 +10,4 @@ - \ No newline at end of file diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index 75cee02..a319d0c 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -6,6 +6,7 @@ 240dp - 32dp + + 56dp diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index a2c60c4..ab19b40 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -5,13 +5,9 @@ @color/textColorPrimary - - - + +