mirror of
https://github.com/MinimalBible/MinimalBible
synced 2024-11-22 07:58:20 -05:00
Bring in the new navigation menu
API v8-compliant, sized correctly, all that good jazz.
This commit is contained in:
parent
51783afc0b
commit
21f940d767
@ -1,22 +1,20 @@
|
|||||||
package org.bspeice.minimalbible;
|
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
|
* 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
|
* Currently it's not doing much, but would allow for shenanigans during testing in the future
|
||||||
*/
|
*/
|
||||||
|
/*
|
||||||
@ReportsCrashes(formKey = "",
|
@ReportsCrashes(formKey = "",
|
||||||
mailTo = "bspeice.nc@gmail.com",
|
mailTo = "bspeice.nc@gmail.com",
|
||||||
mode = ReportingInteractionMode.SILENT
|
mode = ReportingInteractionMode.SILENT
|
||||||
)
|
)
|
||||||
|
*/
|
||||||
public class MinimalBibleDebug extends MinimalBible implements Injector {
|
public class MinimalBibleDebug extends MinimalBible implements Injector {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
ACRA.init(this);
|
// ACRA.init(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -13,6 +13,7 @@
|
|||||||
android:theme="@style/MinimalBible">
|
android:theme="@style/MinimalBible">
|
||||||
<activity
|
<activity
|
||||||
android:name=".activity.downloader.DownloadActivity"
|
android:name=".activity.downloader.DownloadActivity"
|
||||||
|
android:exported="true"
|
||||||
android:label="@string/app_name" />
|
android:label="@string/app_name" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".activity.settings.MinimalBibleSettings"
|
android:name=".activity.settings.MinimalBibleSettings"
|
||||||
|
@ -30,7 +30,7 @@ public class BaseActivity extends ActionBarActivity {
|
|||||||
protected static void setInsets(Activity context, View view) {
|
protected static void setInsets(Activity context, View view) {
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) return;
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) return;
|
||||||
SystemBarTintManager.SystemBarConfig config = getConfig(context);
|
SystemBarTintManager.SystemBarConfig config = getConfig(context);
|
||||||
view.setPadding(0, config.getPixelInsetTop(true), config.getPixelInsetRight(), config.getPixelInsetBottom());
|
view.setPadding(0, config.getPixelInsetTop(false), config.getPixelInsetRight(), config.getPixelInsetBottom());
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
|
@ -99,9 +99,11 @@ public abstract class AbstractNavDrawerFragment extends Fragment {
|
|||||||
GravityCompat.START);
|
GravityCompat.START);
|
||||||
// set up the drawer's list view with items and click listener
|
// set up the drawer's list view with items and click listener
|
||||||
|
|
||||||
|
/* TODO: Switch to Toolbar
|
||||||
ActionBar actionBar = getActionBar();
|
ActionBar actionBar = getActionBar();
|
||||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||||
actionBar.setHomeButtonEnabled(true);
|
actionBar.setHomeButtonEnabled(true);
|
||||||
|
*/
|
||||||
|
|
||||||
// ActionBarDrawerToggle ties together the the proper interactions
|
// ActionBarDrawerToggle ties together the the proper interactions
|
||||||
// between the navigation drawer and the action bar app icon.
|
// between the navigation drawer and the action bar app icon.
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
package org.bspeice.minimalbible.activity.viewer;
|
package org.bspeice.minimalbible.activity.viewer;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.widget.Toolbar;
|
import android.support.v7.widget.Toolbar;
|
||||||
import android.widget.ArrayAdapter;
|
|
||||||
import android.widget.ListView;
|
|
||||||
|
|
||||||
import org.bspeice.minimalbible.Injector;
|
import org.bspeice.minimalbible.Injector;
|
||||||
import org.bspeice.minimalbible.MinimalBible;
|
import org.bspeice.minimalbible.MinimalBible;
|
||||||
import org.bspeice.minimalbible.OGHolder;
|
import org.bspeice.minimalbible.OGHolder;
|
||||||
import org.bspeice.minimalbible.R;
|
import org.bspeice.minimalbible.R;
|
||||||
import org.bspeice.minimalbible.activity.BaseActivity;
|
import org.bspeice.minimalbible.activity.BaseActivity;
|
||||||
|
import org.bspeice.minimalbible.activity.downloader.DownloadActivity;
|
||||||
import org.crosswire.jsword.book.Book;
|
import org.crosswire.jsword.book.Book;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
@ -26,7 +26,7 @@ public class BibleViewer extends BaseActivity implements Injector {
|
|||||||
Book mainBook;
|
Book mainBook;
|
||||||
|
|
||||||
@InjectView(R.id.navigation_drawer)
|
@InjectView(R.id.navigation_drawer)
|
||||||
ListView drawerContent;
|
BibleMenu bibleMenu;
|
||||||
|
|
||||||
@InjectView(R.id.toolbar)
|
@InjectView(R.id.toolbar)
|
||||||
Toolbar toolbar;
|
Toolbar toolbar;
|
||||||
@ -57,23 +57,26 @@ public class BibleViewer extends BaseActivity implements Injector {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set up the application
|
* Set up the application
|
||||||
|
*
|
||||||
* @param savedInstanceState Android's savedInstanceState
|
* @param savedInstanceState Android's savedInstanceState
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
this.inject(this);
|
this.inject(this);
|
||||||
|
|
||||||
|
// Check that we have a book installed
|
||||||
|
if (mainBook == null) {
|
||||||
|
// No books installed, start the downloader.
|
||||||
|
Intent i = new Intent(this, DownloadActivity.class);
|
||||||
|
startActivityForResult(i, 0);
|
||||||
|
}
|
||||||
|
|
||||||
setContentView(R.layout.activity_bible_viewer);
|
setContentView(R.layout.activity_bible_viewer);
|
||||||
ButterKnife.inject(this);
|
ButterKnife.inject(this);
|
||||||
|
|
||||||
setSupportActionBar(toolbar);
|
setSupportActionBar(toolbar);
|
||||||
|
bibleMenu.setBible(mainBook);
|
||||||
String[] drawerStrings = new String[]{"Content 1", "Content 2"};
|
setInsets(this, bibleMenu);
|
||||||
drawerContent.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_list_item_1,
|
|
||||||
drawerStrings));
|
|
||||||
|
|
||||||
setInsets(this, drawerContent);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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())
|
||||||
|
}
|
||||||
|
}
|
@ -15,12 +15,29 @@ import android.content.res.Resources
|
|||||||
import android.support.annotation.IdRes
|
import android.support.annotation.IdRes
|
||||||
import android.widget.ExpandableListView
|
import android.widget.ExpandableListView
|
||||||
import rx.subjects.PublishSubject
|
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
|
||||||
|
|
||||||
/**
|
class BibleMenu(val ctx: Context, val attrs: AttributeSet) : LinearLayout(ctx, attrs) {
|
||||||
* Created by bspeice on 10/24/14.
|
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
|
// Map BibleBooks to the number of chapters they have
|
||||||
val menuMappings = b.getVersification().getBooks().map {
|
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
|
override fun isChildSelectable(group: Int, child: Int): Boolean = true
|
||||||
|
|
||||||
private fun doBinding(convertView: View?, parent: ViewGroup,
|
private fun doBinding(convertView: View?, parent: ViewGroup,
|
||||||
obj: Any, highlight: Boolean): View {
|
obj: Any, highlight: Boolean,
|
||||||
|
LayoutRes layout: Int): View {
|
||||||
val finalView: View = convertView ?:
|
val finalView: View = convertView ?:
|
||||||
(parent.getContext()
|
(parent.getContext()
|
||||||
.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater)
|
.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater)
|
||||||
.inflate(R.layout.list_navigation_drawer, parent, false)
|
.inflate(layout, parent, false)
|
||||||
|
|
||||||
val holder: NavItemHolder =
|
val holder: NavItemHolder =
|
||||||
if (finalView.getTag() != null) finalView.getTag() as 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)
|
holder.bind(obj, highlight)
|
||||||
finalView setTag holder
|
finalView setTag holder
|
||||||
@ -82,11 +100,14 @@ class BibleMenu(val b: Book) : BaseExpandableListAdapter() {
|
|||||||
|
|
||||||
override fun getGroupView(position: Int, expanded: Boolean,
|
override fun getGroupView(position: Int, expanded: Boolean,
|
||||||
convertView: View?, parent: ViewGroup): View =
|
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,
|
override fun getChildView(group: Int, child: Int, isLast: Boolean,
|
||||||
convertView: View?, parent: ViewGroup): View =
|
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) {
|
class NavItemHolder(val bindTo: View, IdRes resource: Int) {
|
||||||
val content = bindTo.findViewById(resource) as TextView
|
val content = bindTo.findViewById(resource) as TextView
|
||||||
|
@ -25,17 +25,14 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Main Content" />
|
android:text="Main Content" />
|
||||||
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<!-- Navigation drawer - layout_gravity:start activates the magic. -->
|
<!-- Navigation drawer - layout_gravity:start activates the magic. -->
|
||||||
<ListView
|
<org.bspeice.minimalbible.activity.viewer.BibleMenu
|
||||||
android:id="@+id/navigation_drawer"
|
android:id="@+id/navigation_drawer"
|
||||||
style="@style/MinimalBible.NavigationDrawer"
|
style="@style/MinimalBible.NavigationDrawer"
|
||||||
android:layout_width="@dimen/navigation_drawer_width"
|
android:layout_width="@dimen/navigation_drawer_width"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_gravity="start"
|
android:layout_gravity="start" />
|
||||||
android:fitsSystemWindows="true" />
|
|
||||||
|
|
||||||
</android.support.v4.widget.DrawerLayout>
|
</android.support.v4.widget.DrawerLayout>
|
||||||
|
16
app/src/main/res/layout/list_bible_menu_child.xml
Normal file
16
app/src/main/res/layout/list_bible_menu_child.xml
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/content"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:minHeight="?android:attr/listPreferredItemHeight"
|
||||||
|
android:paddingLeft="?android:attr/expandableListPreferredChildPaddingLeft"
|
||||||
|
android:paddingRight="?android:attr/expandableListPreferredChildPaddingLeft"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
16
app/src/main/res/layout/list_bible_menu_group.xml
Normal file
16
app/src/main/res/layout/list_bible_menu_group.xml
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/content"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:minHeight="?android:attr/listPreferredItemHeight"
|
||||||
|
android:paddingLeft="?android:attr/expandableListPreferredChildPaddingLeft"
|
||||||
|
android:paddingRight="?android:attr/expandableListPreferredChildPaddingLeft"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||||
|
</LinearLayout>
|
28
app/src/main/res/layout/view_bible_menu.xml
Normal file
28
app/src/main/res/layout/view_bible_menu.xml
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:fitsSystemWindows="true"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<!-- Both paddingLeft and Right are given to support RtL
|
||||||
|
layouts without worrying about min API and paddingStart shenanigans -->
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/title"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@color/colorPrimary"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:minHeight="?attr/actionBarSize"
|
||||||
|
android:paddingLeft="16dp"
|
||||||
|
android:paddingRight="16dp"
|
||||||
|
android:text="@string/app_name"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat.Title" />
|
||||||
|
|
||||||
|
<ExpandableListView
|
||||||
|
android:id="@+id/menu"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
|
||||||
|
</LinearLayout>
|
@ -10,5 +10,4 @@
|
|||||||
<style name="ActionBar" parent="@style/Widget.AppCompat.ActionBar">
|
<style name="ActionBar" parent="@style/Widget.AppCompat.ActionBar">
|
||||||
<item name="android:background">@color/colorPrimary</item>
|
<item name="android:background">@color/colorPrimary</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
@ -6,6 +6,7 @@
|
|||||||
<!-- Per the design guidelines, navigation drawers should be between 240dp and 320dp:
|
<!-- Per the design guidelines, navigation drawers should be between 240dp and 320dp:
|
||||||
https://developer.android.com/design/patterns/navigation-drawer.html -->
|
https://developer.android.com/design/patterns/navigation-drawer.html -->
|
||||||
<dimen name="navigation_drawer_width">240dp</dimen>
|
<dimen name="navigation_drawer_width">240dp</dimen>
|
||||||
|
|
||||||
<dimen name="navigation_drawer_highlight_height">32dp</dimen>
|
<dimen name="navigation_drawer_highlight_height">32dp</dimen>
|
||||||
|
|
||||||
|
<dimen name="toolbar_height">56dp</dimen>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -5,10 +5,6 @@
|
|||||||
<item name="android:textColorPrimary">@color/textColorPrimary</item>
|
<item name="android:textColorPrimary">@color/textColorPrimary</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<!-- Actual application style. Allows selective over-riding while inheriting
|
|
||||||
from the parent -->
|
|
||||||
<style name="MinimalBible" parent="MinimalBibleBase" />
|
|
||||||
|
|
||||||
<!-- Almost re-use style from Widget.Holo.Button.Borderless -->
|
<!-- Almost re-use style from Widget.Holo.Button.Borderless -->
|
||||||
<style name="MinimalBibleBase.Borderless">
|
<style name="MinimalBibleBase.Borderless">
|
||||||
<item name="android:background">?android:attr/selectableItemBackground</item>
|
<item name="android:background">?android:attr/selectableItemBackground</item>
|
||||||
@ -20,8 +16,14 @@
|
|||||||
-->
|
-->
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="MinimalBible.NavigationDrawer">
|
<style name="MinimalBibleBase.NavigationDrawer">
|
||||||
<item name="android:background">@color/navigationBackground</item>
|
<item name="android:background">@color/navigationBackground</item>
|
||||||
|
<item name="android:paddingLeft">8dp</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<!-- Actual application style. Allows selective over-riding while inheriting
|
||||||
|
from the parent -->
|
||||||
|
<style name="MinimalBible" parent="MinimalBibleBase" />
|
||||||
|
|
||||||
|
<style name="MinimalBible.NavigationDrawer" parent="MinimalBibleBase.NavigationDrawer" />
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
Reference in New Issue
Block a user