From d49c5e593c5c8ecef3d575860b2341fd807b1fb1 Mon Sep 17 00:00:00 2001 From: Bradlee Speice Date: Fri, 26 Dec 2014 01:26:43 -0500 Subject: [PATCH] Download activity styling and new theme Still some issues outstanding, but I need sleep. --- .../activity/downloader/BookListFragment.java | 20 +- .../activity/downloader/DownloadActivity.java | 116 ++++---- .../downloader/DownloadActivityModules.java | 1 - .../downloader/DownloadNavDrawerFragment.java | 49 ---- .../navigation/AbstractNavDrawerFragment.java | 260 ------------------ .../activity/navigation/ListNavAdapter.java | 96 ------- .../navigation/NavDrawerFragment.java | 52 ---- .../downloader/manager/RefreshManager.kt | 8 +- app/src/main/res/layout/activity_download.xml | 43 ++- app/src/main/res/layout/fragment_download.xml | 14 +- .../res/layout/fragment_navigation_drawer.xml | 11 - .../main/res/layout/list_download_items.xml | 11 +- .../res/layout/list_navigation_drawer.xml | 17 -- app/src/main/res/layout/view_bible_menu.xml | 10 +- app/src/main/res/values/colors.xml | 5 +- app/src/main/res/values/strings.xml | 1 + app/src/main/res/values/styles.xml | 28 +- 17 files changed, 138 insertions(+), 604 deletions(-) delete mode 100644 app/src/main/java/org/bspeice/minimalbible/activity/downloader/DownloadNavDrawerFragment.java delete mode 100644 app/src/main/java/org/bspeice/minimalbible/activity/navigation/AbstractNavDrawerFragment.java delete mode 100644 app/src/main/java/org/bspeice/minimalbible/activity/navigation/ListNavAdapter.java delete mode 100644 app/src/main/java/org/bspeice/minimalbible/activity/navigation/NavDrawerFragment.java delete mode 100644 app/src/main/res/layout/fragment_navigation_drawer.xml delete mode 100644 app/src/main/res/layout/list_navigation_drawer.xml diff --git a/app/src/main/java/org/bspeice/minimalbible/activity/downloader/BookListFragment.java b/app/src/main/java/org/bspeice/minimalbible/activity/downloader/BookListFragment.java index 34a3c9f..1fb615b 100644 --- a/app/src/main/java/org/bspeice/minimalbible/activity/downloader/BookListFragment.java +++ b/app/src/main/java/org/bspeice/minimalbible/activity/downloader/BookListFragment.java @@ -1,9 +1,10 @@ package org.bspeice.minimalbible.activity.downloader; -import android.app.Activity; import android.app.AlertDialog; import android.content.DialogInterface; +import android.graphics.drawable.Drawable; import android.os.Bundle; +import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -96,13 +97,6 @@ public class BookListFragment extends BaseFragment { return rootView; } - @Override - public void onAttach(Activity activity) { - super.onAttach(activity); - ((DownloadActivity) activity).onSectionAttached(getArguments() - .getString(ARG_BOOK_CATEGORY)); - } - void displayModules() { displayModules(downloadPrefs.hasShownDownloadDialog()); } @@ -130,18 +124,14 @@ public class BookListFragment extends BaseFragment { } void displayLanguageSpinner() { - ArrayAdapter adapter = new ArrayAdapter<>(this.getActivity(), + ArrayAdapter adapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_spinner_item, availableLanguages.toArray() ); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); languagesSpinner.setAdapter(adapter); - - if (BookListFragment.this.getActivity() != null) { - // On a screen rotate, getActivity() will be null, but the activity - // will already have been set up. If not null, we need to set it up now. - setInsetsSpinner(BookListFragment.this.getActivity(), languagesSpinner); - } + Drawable d = languagesSpinner.getBackground(); + Log.d("Spinner", d.toString()); } @SuppressWarnings("unused") diff --git a/app/src/main/java/org/bspeice/minimalbible/activity/downloader/DownloadActivity.java b/app/src/main/java/org/bspeice/minimalbible/activity/downloader/DownloadActivity.java index ca05b54..d9fd899 100644 --- a/app/src/main/java/org/bspeice/minimalbible/activity/downloader/DownloadActivity.java +++ b/app/src/main/java/org/bspeice/minimalbible/activity/downloader/DownloadActivity.java @@ -3,48 +3,49 @@ package org.bspeice.minimalbible.activity.downloader; import android.content.Intent; import android.os.Bundle; import android.support.v4.app.FragmentManager; -import android.support.v4.widget.DrawerLayout; -import android.support.v7.app.ActionBar; -import android.util.Log; +import android.support.v7.widget.Toolbar; import android.view.Menu; import android.view.MenuItem; +import android.view.View; +import android.widget.AdapterView; +import android.widget.ArrayAdapter; +import android.widget.LinearLayout; +import android.widget.ListView; import org.bspeice.minimalbible.Injector; import org.bspeice.minimalbible.MinimalBible; import org.bspeice.minimalbible.OGHolder; import org.bspeice.minimalbible.R; import org.bspeice.minimalbible.activity.BaseActivity; -import org.bspeice.minimalbible.activity.navigation.NavDrawerFragment; import org.bspeice.minimalbible.activity.settings.MinimalBibleSettings; import org.crosswire.jsword.book.BookCategory; +import org.jetbrains.annotations.NotNull; import java.util.List; import javax.inject.Inject; import javax.inject.Named; +import butterknife.ButterKnife; +import butterknife.InjectView; import dagger.ObjectGraph; public class DownloadActivity extends BaseActivity implements - NavDrawerFragment.NavigationDrawerCallbacks, - Injector { - - private final String TAG = "DownloadActivity"; - private final String TAG_CURRENT_CATEGORY = "CurrentCategory"; + Injector, + AdapterView.OnItemClickListener { @Inject @Named("ValidCategories") List validCategories; - /** - * Fragment managing the behaviors, interactions and presentation of the - * navigation drawer. - */ - private DownloadNavDrawerFragment mNavigationDrawerFragment; - /** - * Used to store the last screen title. For use in - * {@link #restoreActionBar()}. - */ - private CharSequence mTitle; + + @InjectView(R.id.navigation_drawer) + LinearLayout navigationDrawer; + + @InjectView(R.id.navigation_content) + ListView navigationContent; + + @InjectView(R.id.toolbar) + Toolbar toolbar; private ObjectGraph daObjectGraph; @@ -56,7 +57,6 @@ public class DownloadActivity extends BaseActivity implements OGHolder holder = OGHolder.get(this); ObjectGraph holderGraph = holder.fetchGraph(); if (holderGraph == null) { - Log.i(TAG, "Rebuilding ObjectGraph..."); daObjectGraph = MinimalBible.get(this) .plus(new DownloadActivityModules(this)); holder.persistGraph(daObjectGraph); @@ -79,55 +79,19 @@ public class DownloadActivity extends BaseActivity implements inject(this); setContentView(R.layout.activity_download); + ButterKnife.inject(this); - mNavigationDrawerFragment = (DownloadNavDrawerFragment) getSupportFragmentManager() - .findFragmentById(R.id.navigation_drawer); - mTitle = getTitle(); - - // Set up the drawer. - mNavigationDrawerFragment.setUp(R.id.navigation_drawer, - (DrawerLayout) findViewById(R.id.drawer_layout)); - - // And select our first item - int itemToSelect = 0; - if (savedInstanceState != null) { - itemToSelect = savedInstanceState.getInt(TAG_CURRENT_CATEGORY); - } - mNavigationDrawerFragment.selectItem(itemToSelect); - } - - @Override - public void onNavigationDrawerItemSelected(int position) { - // update the main content by replacing fragments - //TODO: Switch to AutoFactory pattern, rather than newInstance() - FragmentManager fragmentManager = getSupportFragmentManager(); - fragmentManager - .beginTransaction() - .replace(R.id.container, - BookListFragment.newInstance(validCategories.get(position))).commit(); - } - - public void onSectionAttached(String category) { - mTitle = category; - } - - public void restoreActionBar() { - ActionBar actionBar = getSupportActionBar(); - actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); - actionBar.setDisplayShowTitleEnabled(true); - actionBar.setTitle(mTitle); + navigationContent.setAdapter( + new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, + validCategories)); + navigationContent.setOnItemClickListener(this); + setInsets(navigationDrawer); + handleSelect(0); } @Override public boolean onCreateOptionsMenu(Menu menu) { - if (!mNavigationDrawerFragment.isDrawerOpen()) { - // Only show items in the action bar relevant to this screen - // if the drawer is not showing. Otherwise, let the drawer - // decide what to show in the action bar. - getMenuInflater().inflate(R.menu.download, menu); - restoreActionBar(); - return true; - } + getMenuInflater().inflate(R.menu.download, menu); return super.onCreateOptionsMenu(menu); } @@ -145,9 +109,25 @@ public class DownloadActivity extends BaseActivity implements } @Override - protected void onSaveInstanceState(Bundle outState) { - super.onSaveInstanceState(outState); - outState.putInt(TAG_CURRENT_CATEGORY, - mNavigationDrawerFragment.getCurrentPosition()); + public void onItemClick(@NotNull AdapterView parent, + @NotNull View view, int position, long id) { + handleSelect(position); + } + + public void handleSelect(int position) { + // update the main content by replacing fragments + //TODO: Switch to AutoFactory pattern, rather than newInstance() + BookCategory category = validCategories.get(position); + setTitle(category.toString()); + FragmentManager fragmentManager = getSupportFragmentManager(); + fragmentManager + .beginTransaction() + .replace(R.id.content, + BookListFragment.newInstance(validCategories.get(position))) + .commit(); + } + + private void setTitle(String title) { + toolbar.setTitle(title); } } diff --git a/app/src/main/java/org/bspeice/minimalbible/activity/downloader/DownloadActivityModules.java b/app/src/main/java/org/bspeice/minimalbible/activity/downloader/DownloadActivityModules.java index 466469f..a07ac05 100644 --- a/app/src/main/java/org/bspeice/minimalbible/activity/downloader/DownloadActivityModules.java +++ b/app/src/main/java/org/bspeice/minimalbible/activity/downloader/DownloadActivityModules.java @@ -34,7 +34,6 @@ import de.devland.esperandro.Esperandro; BookItemHolder.class, BookManager.class, RefreshManager.class, - DownloadNavDrawerFragment.class, DownloadActivity.class }, addsTo = MinimalBibleModules.class, diff --git a/app/src/main/java/org/bspeice/minimalbible/activity/downloader/DownloadNavDrawerFragment.java b/app/src/main/java/org/bspeice/minimalbible/activity/downloader/DownloadNavDrawerFragment.java deleted file mode 100644 index e9171f0..0000000 --- a/app/src/main/java/org/bspeice/minimalbible/activity/downloader/DownloadNavDrawerFragment.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.bspeice.minimalbible.activity.downloader; - -import android.os.Bundle; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.AdapterView; -import android.widget.ListView; - -import org.bspeice.minimalbible.Injector; -import org.bspeice.minimalbible.R; -import org.bspeice.minimalbible.activity.navigation.ListNavAdapter; -import org.bspeice.minimalbible.activity.navigation.NavDrawerFragment; -import org.crosswire.jsword.book.BookCategory; - -import java.util.List; - -import javax.inject.Inject; -import javax.inject.Named; - -public class DownloadNavDrawerFragment extends NavDrawerFragment { - - @Inject - @Named("ValidCategories") - List validCategories; - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - ((Injector) getActivity()).inject(this); - - mDrawerListView = (ListView) inflater.inflate( - R.layout.fragment_navigation_drawer, container, false); - mDrawerListView - .setOnItemClickListener(new AdapterView.OnItemClickListener() { - @Override - public void onItemClick(AdapterView parent, View view, - int position, long id) { - selectItem(position); - } - }); - - mDrawerListView.setAdapter(new ListNavAdapter(getActivity(), - validCategories)); - mDrawerListView.setItemChecked(mCurrentSelectedPosition, true); - return mDrawerListView; - } - -} diff --git a/app/src/main/java/org/bspeice/minimalbible/activity/navigation/AbstractNavDrawerFragment.java b/app/src/main/java/org/bspeice/minimalbible/activity/navigation/AbstractNavDrawerFragment.java deleted file mode 100644 index 9e007c9..0000000 --- a/app/src/main/java/org/bspeice/minimalbible/activity/navigation/AbstractNavDrawerFragment.java +++ /dev/null @@ -1,260 +0,0 @@ -package org.bspeice.minimalbible.activity.navigation; - -import android.app.Activity; -import android.content.SharedPreferences; -import android.content.res.Configuration; -import android.os.Build; -import android.os.Bundle; -import android.preference.PreferenceManager; -import android.support.v4.app.ActionBarDrawerToggle; -import android.support.v4.app.Fragment; -import android.support.v4.view.GravityCompat; -import android.support.v4.widget.DrawerLayout; -import android.support.v7.app.ActionBar; -import android.support.v7.app.ActionBarActivity; -import android.view.Menu; -import android.view.MenuInflater; -import android.view.MenuItem; -import android.view.View; - -import com.readystatesoftware.systembartint.SystemBarTintManager; - -import org.bspeice.minimalbible.R; - -/** - * Abstract NavDrawer Fragment to build on top of. - * Likely needs some more methods refactored to truly support both List and ExandableList - */ -public abstract class AbstractNavDrawerFragment extends Fragment { - - /** - * Remember the position of the selected item. - */ - private static final String STATE_SELECTED_POSITION = "selected_navigation_drawer_position"; - - /** - * Per the design guidelines, you should show the drawer on launch until the - * user manually expands it. This shared preference tracks this. - */ - private static final String PREF_USER_LEARNED_DRAWER = "navigation_drawer_learned"; - protected int mCurrentSelectedPosition = 0; - /** - * A pointer to the current callbacks instance (the Activity). - */ - protected NavigationDrawerCallbacks mCallbacks; - protected DrawerLayout mDrawerLayout; - protected View mFragmentContainerView; - /** - * Helper component that ties the action bar to the navigation drawer. - */ - private ActionBarDrawerToggle mDrawerToggle; - private boolean mFromSavedInstanceState; - private boolean mUserLearnedDrawer; - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - // Read in the flag indicating whether or not the user has demonstrated - // awareness of the - // drawer. See PREF_USER_LEARNED_DRAWER for details. - SharedPreferences sp = PreferenceManager - .getDefaultSharedPreferences(getActivity()); - mUserLearnedDrawer = sp.getBoolean(PREF_USER_LEARNED_DRAWER, false); - - if (savedInstanceState != null) { - mCurrentSelectedPosition = savedInstanceState - .getInt(STATE_SELECTED_POSITION); - mFromSavedInstanceState = true; - } - } - - @Override - public void onActivityCreated(Bundle savedInstanceState) { - super.onActivityCreated(savedInstanceState); - // Indicate that this fragment would like to influence the set of - // actions in the action bar. - setHasOptionsMenu(true); - } - - public boolean isDrawerOpen() { - return mDrawerLayout != null - && mDrawerLayout.isDrawerOpen(mFragmentContainerView); - } - - /** - * Users of this fragment must call this method to set up the navigation - * drawer interactions. - * - * @param fragmentId The android:id of this fragment in its activity's layout. - * @param drawerLayout The DrawerLayout containing this fragment's UI. - */ - public void setUp(int fragmentId, DrawerLayout drawerLayout) { - mFragmentContainerView = getActivity().findViewById(fragmentId); - mDrawerLayout = drawerLayout; - - // set a custom shadow that overlays the main content when the drawer - // opens - mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, - GravityCompat.START); - // set up the drawer's list view with items and click listener - - /* TODO: Switch to Toolbar - ActionBar actionBar = getActionBar(); - actionBar.setDisplayHomeAsUpEnabled(true); - actionBar.setHomeButtonEnabled(true); - */ - - // ActionBarDrawerToggle ties together the the proper interactions - // between the navigation drawer and the action bar app icon. - mDrawerToggle = new ActionBarDrawerToggle(getActivity(), /* host Activity */ - mDrawerLayout, /* DrawerLayout object */ - R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */ - R.string.navigation_drawer_open, /* - * "open drawer" description for - * accessibility - */ - R.string.navigation_drawer_close /* - * "close drawer" description for - * accessibility - */ - ) { - @Override - public void onDrawerClosed(View drawerView) { - super.onDrawerClosed(drawerView); - if (!isAdded()) { - return; - } - - getActivity().supportInvalidateOptionsMenu(); // calls - // onPrepareOptionsMenu() - } - - @Override - public void onDrawerOpened(View drawerView) { - super.onDrawerOpened(drawerView); - if (!isAdded()) { - return; - } - - if (!mUserLearnedDrawer) { - // The user manually opened the drawer; store this flag to - // prevent auto-showing - // the navigation drawer automatically in the future. - mUserLearnedDrawer = true; - SharedPreferences sp = PreferenceManager - .getDefaultSharedPreferences(getActivity()); - sp.edit().putBoolean(PREF_USER_LEARNED_DRAWER, true) - .commit(); - } - - getActivity().supportInvalidateOptionsMenu(); // calls - // onPrepareOptionsMenu() - } - }; - - // If the user hasn't 'learned' about the drawer, open it to introduce - // them to the drawer, - // per the navigation drawer design guidelines. - if (!mUserLearnedDrawer && !mFromSavedInstanceState) { - mDrawerLayout.openDrawer(mFragmentContainerView); - } - - // Defer code dependent on restoration of previous instance state. - mDrawerLayout.post(new Runnable() { - @Override - public void run() { - mDrawerToggle.syncState(); - } - }); - - mDrawerLayout.setDrawerListener(mDrawerToggle); - } - - @Override - public void onAttach(Activity activity) { - super.onAttach(activity); - try { - mCallbacks = (NavigationDrawerCallbacks) activity; - } catch (ClassCastException e) { - throw new ClassCastException( - "Activity must implement NavigationDrawerCallbacks."); - } - } - - @Override - public void onDetach() { - super.onDetach(); - mCallbacks = null; - } - - @Override - public void onSaveInstanceState(Bundle outState) { - super.onSaveInstanceState(outState); - outState.putInt(STATE_SELECTED_POSITION, mCurrentSelectedPosition); - } - - @Override - public void onConfigurationChanged(Configuration newConfig) { - super.onConfigurationChanged(newConfig); - // Forward the new configuration the drawer toggle component. - mDrawerToggle.onConfigurationChanged(newConfig); - } - - @Override - public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { - // If the drawer is open, show the global app actions in the action bar. - // See also - // showGlobalContextActionBar, which controls the top-left area of the - // action bar. - if (mDrawerLayout != null && isDrawerOpen()) { - inflater.inflate(R.menu.global, menu); - showGlobalContextActionBar(); - } - super.onCreateOptionsMenu(menu, inflater); - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - if (mDrawerToggle.onOptionsItemSelected(item)) { - return true; - } - return super.onOptionsItemSelected(item); - } - - /** - * Per the navigation drawer design guidelines, updates the action bar to - * show the global app 'context', rather than just what's in the current - * screen. - */ - private void showGlobalContextActionBar() { - ActionBar actionBar = getActionBar(); - actionBar.setDisplayShowTitleEnabled(true); - actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); - // actionBar.setTitle(R.string.app_name); - } - - protected ActionBar getActionBar() { - return ((ActionBarActivity) getActivity()).getSupportActionBar(); - } - - public void setInsets(View view) { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) - return; - SystemBarTintManager tintManager = new SystemBarTintManager(getActivity()); - SystemBarTintManager.SystemBarConfig config = tintManager.getConfig(); - view.setPadding(0, config.getPixelInsetTop(true), - config.getPixelInsetRight(), config.getPixelInsetBottom()); - } - - /** - * Callbacks interface that all activities using this fragment must - * implement. - */ - public static interface NavigationDrawerCallbacks { - /** - * Called when an item in the navigation drawer is selected. - */ - void onNavigationDrawerItemSelected(int position); - } -} diff --git a/app/src/main/java/org/bspeice/minimalbible/activity/navigation/ListNavAdapter.java b/app/src/main/java/org/bspeice/minimalbible/activity/navigation/ListNavAdapter.java deleted file mode 100644 index a16c54b..0000000 --- a/app/src/main/java/org/bspeice/minimalbible/activity/navigation/ListNavAdapter.java +++ /dev/null @@ -1,96 +0,0 @@ -package org.bspeice.minimalbible.activity.navigation; - -import android.content.Context; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.BaseAdapter; -import android.widget.TextView; - -import org.bspeice.minimalbible.R; - -import java.util.List; - -import butterknife.ButterKnife; -import butterknife.InjectView; - -/** - * Helper for setting up a highlighting navbar - * This class (and its usage) needs some work refactoring, - * but the PoC is looking good! - */ -public class ListNavAdapter extends BaseAdapter { - Context context; - List objects; - int currentlyHighlighted; - - public ListNavAdapter(Context context, List objects) { - this.context = context; - this.objects = objects; - } - - public int getCurrentlyHighlighted() { - return this.currentlyHighlighted; - } - - public void setCurrentlyHighlighted(int currentlyHighlighted) { - this.currentlyHighlighted = currentlyHighlighted; - } - - @Override - public int getCount() { - return objects.size(); - } - - @Override - public Object getItem(int i) { - return objects.get(i); - } - - @Override - public long getItemId(int i) { - return i; - } - - @Override - public View getView(int i, View view, ViewGroup viewGroup) { - LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); - NavItemHolder holder; - if (view == null || view.getTag() == null) { - view = inflater.inflate(R.layout.list_navigation_drawer, viewGroup, false); - holder = new NavItemHolder(view, i == currentlyHighlighted, (T) getItem(i)); - } else { - holder = (NavItemHolder) view.getTag(); - } - - holder.bind(); - return view; - } - - /** - * Holder object for items in the Nav Drawer - */ - - protected class NavItemHolder { - @InjectView(R.id.navlist_content) - TextView content; - - boolean highlighted; - View v; - T object; - - public NavItemHolder(View v, boolean highlighted, T object) { - this.v = v; // Needed for resolving colors below - ButterKnife.inject(this, v); - this.highlighted = highlighted; - this.object = object; - } - - public void bind() { - content.setText(object.toString()); - if (highlighted) { - content.setTextColor(v.getResources().getColor(R.color.colorPrimary)); - } - } - } -} diff --git a/app/src/main/java/org/bspeice/minimalbible/activity/navigation/NavDrawerFragment.java b/app/src/main/java/org/bspeice/minimalbible/activity/navigation/NavDrawerFragment.java deleted file mode 100644 index b2cf122..0000000 --- a/app/src/main/java/org/bspeice/minimalbible/activity/navigation/NavDrawerFragment.java +++ /dev/null @@ -1,52 +0,0 @@ -package org.bspeice.minimalbible.activity.navigation; - -import android.os.Bundle; -import android.view.View; -import android.widget.ListView; - -import org.bspeice.minimalbible.R; - -/** - * Fragment used for managing interactions for and presentation of a navigation - * drawer. See the design guidelines for a complete explanation of the behaviors - * implemented here. - * TODO: Refactor to allow ExpandableListView - */ -public class NavDrawerFragment extends AbstractNavDrawerFragment { - - protected ListView mDrawerListView; - - @Override - public void onViewCreated(View view, Bundle savedInstanceState) { - super.onViewCreated(view, savedInstanceState); - - // This could also be a ScrollView - ListView list = (ListView) view.findViewById(R.id.list_nav_drawer); - // This could also be set in your layout, allows the list items to - // scroll through the bottom padded area (navigation bar) - list.setClipToPadding(false); - // Sets the padding to the insets (include action bar and navigation bar - // padding for the current device and orientation) - super.setInsets(list); - } - - public void selectItem(int position) { - mCurrentSelectedPosition = position; - if (mDrawerListView != null) { - mDrawerListView.setItemChecked(position, true); - ((ListNavAdapter) mDrawerListView.getAdapter()).setCurrentlyHighlighted(position); - } - if (mDrawerLayout != null) { - mDrawerLayout.closeDrawer(mFragmentContainerView); - } - if (mCallbacks != null) { - mCallbacks.onNavigationDrawerItemSelected(position); - } - } - - public int getCurrentPosition() { - return mCurrentSelectedPosition; - } -} diff --git a/app/src/main/kotlin/org/bspeice/minimalbible/activity/downloader/manager/RefreshManager.kt b/app/src/main/kotlin/org/bspeice/minimalbible/activity/downloader/manager/RefreshManager.kt index 94ea0ec..96e7b89 100644 --- a/app/src/main/kotlin/org/bspeice/minimalbible/activity/downloader/manager/RefreshManager.kt +++ b/app/src/main/kotlin/org/bspeice/minimalbible/activity/downloader/manager/RefreshManager.kt @@ -9,6 +9,7 @@ import java.util.Calendar import org.bspeice.minimalbible.activity.downloader.DownloadPrefs import android.net.ConnectivityManager import org.crosswire.jsword.book.BookComparators +import java.util.Date /** * Created by bspeice on 10/22/14. @@ -23,6 +24,7 @@ class RefreshManager(val installers: Collection, .map { if (doReload()) { it.reloadBookList() // TODO: Handle InstallException + prefs.downloadRefreshedOn(Date().getTime()) } mapOf(Pair(it, it.getBooks())) } @@ -31,9 +33,9 @@ class RefreshManager(val installers: Collection, val flatModules: Observable = availableModules - // Map -> Lists - .flatMap { Observable.from(it.values()) } - // Lists -> Single list + // Map -> Lists + .flatMap { Observable.from(it.values()) } + // Lists -> Single list .flatMap { Observable.from(it) } val flatModulesSorted = flatModules.toSortedList {(book1, book2) -> diff --git a/app/src/main/res/layout/activity_download.xml b/app/src/main/res/layout/activity_download.xml index ca79697..3e8612e 100644 --- a/app/src/main/res/layout/activity_download.xml +++ b/app/src/main/res/layout/activity_download.xml @@ -4,17 +4,32 @@ android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent" - tools:context="org.bspeice.minimalbible.activities.downloader.DownloadActivity" > + tools:context="org.bspeice.minimalbible.activities.downloader.DownloadActivity"> - - + android:layout_height="match_parent" + android:fitsSystemWindows="true" + android:orientation="vertical"> + + + + + + - - + android:layout_gravity="start" + android:fitsSystemWindows="true" + android:orientation="vertical"> + + + + diff --git a/app/src/main/res/layout/fragment_download.xml b/app/src/main/res/layout/fragment_download.xml index 6142dd1..57ceb79 100644 --- a/app/src/main/res/layout/fragment_download.xml +++ b/app/src/main/res/layout/fragment_download.xml @@ -1,22 +1,20 @@ - + android:minHeight="?attr/actionBarSize" /> + android:layout_height="wrap_content" /> - + diff --git a/app/src/main/res/layout/fragment_navigation_drawer.xml b/app/src/main/res/layout/fragment_navigation_drawer.xml deleted file mode 100644 index c7a1d25..0000000 --- a/app/src/main/res/layout/fragment_navigation_drawer.xml +++ /dev/null @@ -1,11 +0,0 @@ - - diff --git a/app/src/main/res/layout/list_download_items.xml b/app/src/main/res/layout/list_download_items.xml index a5f3eb6..adb6d25 100644 --- a/app/src/main/res/layout/list_download_items.xml +++ b/app/src/main/res/layout/list_download_items.xml @@ -10,7 +10,7 @@ android:id="@+id/txt_download_item_name" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_alignParentStart="true" + android:layout_alignParentLeft="true" android:layout_toLeftOf="@+id/download_ibtn_download" android:ellipsize="end" android:maxLines="1" @@ -20,24 +20,25 @@ android:id="@+id/download_txt_item_acronym" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_alignParentStart="true" + android:layout_alignParentLeft="true" android:layout_below="@+id/txt_download_item_name" android:paddingTop="4dp" - android:textAppearance="?android:attr/textAppearanceSmall" /> + android:textAppearance="?android:attr/textAppearanceSmall" + android:textColor="@color/textColorSecondary" /> diff --git a/app/src/main/res/layout/list_navigation_drawer.xml b/app/src/main/res/layout/list_navigation_drawer.xml deleted file mode 100644 index 704f8aa..0000000 --- a/app/src/main/res/layout/list_navigation_drawer.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - \ 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 index 84c8015..0203199 100644 --- a/app/src/main/res/layout/view_bible_menu.xml +++ b/app/src/main/res/layout/view_bible_menu.xml @@ -9,16 +9,10 @@ layouts without worrying about min API and paddingStart shenanigans --> + android:text="@string/app_name" /> #ffffff #000000 + #9e9e9e #cccccc #000 - #000 - #9e9e9e + @color/textColor + @color/textColorSecondary diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 283a221..17b3cd0 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -11,5 +11,6 @@ Downloads Could not remove book. Try restarting application? + Categories diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 9e86480..d1f31c6 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -22,7 +22,17 @@ + + + +