mirror of
https://github.com/MinimalBible/MinimalBible
synced 2024-11-04 15:18:22 -05:00
Download activity styling and new theme
Still some issues outstanding, but I need sleep.
This commit is contained in:
parent
f889b61b9c
commit
d49c5e593c
@ -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<Object> adapter = new ArrayAdapter<>(this.getActivity(),
|
||||
ArrayAdapter<Object> 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")
|
||||
|
@ -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<BookCategory> 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;
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,6 @@ import de.devland.esperandro.Esperandro;
|
||||
BookItemHolder.class,
|
||||
BookManager.class,
|
||||
RefreshManager.class,
|
||||
DownloadNavDrawerFragment.class,
|
||||
DownloadActivity.class
|
||||
},
|
||||
addsTo = MinimalBibleModules.class,
|
||||
|
@ -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<BookCategory> 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<BookCategory>(getActivity(),
|
||||
validCategories));
|
||||
mDrawerListView.setItemChecked(mCurrentSelectedPosition, true);
|
||||
return mDrawerListView;
|
||||
}
|
||||
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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<T> extends BaseAdapter {
|
||||
Context context;
|
||||
List<T> objects;
|
||||
int currentlyHighlighted;
|
||||
|
||||
public ListNavAdapter(Context context, List<T> 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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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 <a href=
|
||||
* "https://developer.android.com/design/patterns/navigation-drawer.html#Interaction"
|
||||
* > design guidelines</a> 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<String>) mDrawerListView.getAdapter()).setCurrentlyHighlighted(position);
|
||||
}
|
||||
if (mDrawerLayout != null) {
|
||||
mDrawerLayout.closeDrawer(mFragmentContainerView);
|
||||
}
|
||||
if (mCallbacks != null) {
|
||||
mCallbacks.onNavigationDrawerItemSelected(position);
|
||||
}
|
||||
}
|
||||
|
||||
public int getCurrentPosition() {
|
||||
return mCurrentSelectedPosition;
|
||||
}
|
||||
}
|
@ -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<Installer>,
|
||||
.map {
|
||||
if (doReload()) {
|
||||
it.reloadBookList() // TODO: Handle InstallException
|
||||
prefs.downloadRefreshedOn(Date().getTime())
|
||||
}
|
||||
mapOf(Pair(it, it.getBooks()))
|
||||
}
|
||||
|
@ -10,11 +10,26 @@
|
||||
As the main content view, the view below consumes the entire
|
||||
space available using match_parent in both dimensions.
|
||||
-->
|
||||
|
||||
<FrameLayout
|
||||
<LinearLayout
|
||||
android:id="@+id/container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true"
|
||||
android:orientation="vertical">
|
||||
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/colorPrimary"
|
||||
android:minHeight="?attr/actionBarSize" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<!--
|
||||
android:layout_gravity="start" tells DrawerLayout to treat
|
||||
@ -27,12 +42,24 @@
|
||||
The drawer is given a fixed width in dp and extends the full height of
|
||||
the container.
|
||||
-->
|
||||
|
||||
<fragment
|
||||
<LinearLayout
|
||||
android:id="@+id/navigation_drawer"
|
||||
android:name="org.bspeice.minimalbible.activity.downloader.DownloadNavDrawerFragment"
|
||||
style="@style/MinimalBible.NavigationDrawer"
|
||||
android:layout_width="@dimen/navigation_drawer_width"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="start" />
|
||||
android:layout_gravity="start"
|
||||
android:fitsSystemWindows="true"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
style="@style/MinimalBible.NavigationDrawer.Title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/action_download_title_categories" />
|
||||
|
||||
<ListView
|
||||
android:id="@+id/navigation_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
</LinearLayout>
|
||||
</android.support.v4.widget.DrawerLayout>
|
||||
|
@ -1,22 +1,20 @@
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
tools:context="org.bspeice.minimalbible.DownloadActivity$PlaceholderFragment" >
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/spn_available_languages"
|
||||
style="@style/MinimalBible.Spinner"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentTop="true" />
|
||||
android:minHeight="?attr/actionBarSize" />
|
||||
|
||||
<ListView
|
||||
android:id="@+id/lst_download_available"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_below="@+id/spn_available_languages" />
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
|
@ -1,11 +0,0 @@
|
||||
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/list_nav_drawer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#cccccc"
|
||||
android:choiceMode="singleChoice"
|
||||
android:divider="@android:color/transparent"
|
||||
android:dividerHeight="0dp"
|
||||
tools:context="org.bspeice.minimalbible.activities.BaseNavigationDrawerFragment" />
|
||||
|
@ -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" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/download_ibtn_download"
|
||||
style="@style/MinimalBibleBase.Borderless"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:src="@drawable/ic_action_download" />
|
||||
|
||||
<com.todddavies.components.progressbar.ProgressWheel
|
||||
android:id="@+id/download_prg_download"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:visibility="gone"
|
||||
app:barWidth="4dp"
|
||||
app:rimWidth="0dp" />
|
||||
|
@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="horizontal" android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<!-- Largely taken from simple_list_item_1.xml -->
|
||||
<TextView
|
||||
style="?android:attr/textAppearanceListItemSmall"
|
||||
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
|
||||
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
|
||||
android:minHeight="?android:attr/listPreferredItemHeightSmall"
|
||||
android:gravity="center_vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/navlist_content" />
|
||||
</LinearLayout>
|
@ -9,16 +9,10 @@
|
||||
layouts without worrying about min API and paddingStart shenanigans -->
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
style="@style/MinimalBible.NavigationDrawer.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"
|
||||
android:textColor="?android:textColorPrimary" />
|
||||
android:text="@string/app_name" />
|
||||
|
||||
<ExpandableListView
|
||||
android:id="@+id/menu"
|
||||
|
@ -6,10 +6,11 @@
|
||||
<color name="textColorAccent">#ffffff</color>
|
||||
|
||||
<color name="textColor">#000000</color>
|
||||
<color name="textColorSecondary">#9e9e9e</color>
|
||||
|
||||
<color name="navigationBackground">#cccccc</color>
|
||||
<color name="textNavigation">#000</color>
|
||||
|
||||
<color name="settingsTextColor">#000</color>
|
||||
<color name="settingsTextColorSecondary">#9e9e9e</color>
|
||||
<color name="settingsTextColor">@color/textColor</color>
|
||||
<color name="settingsTextColorSecondary">@color/textColorSecondary</color>
|
||||
</resources>
|
||||
|
@ -11,5 +11,6 @@
|
||||
<string name="activity_downloader">Downloads</string>
|
||||
|
||||
<string name="book_removal_failure">Could not remove book. Try restarting application?</string>
|
||||
<string name="action_download_title_categories">Categories</string>
|
||||
|
||||
</resources>
|
||||
|
@ -25,6 +25,16 @@
|
||||
<item name="android:background">@color/navigationBackground</item>
|
||||
</style>
|
||||
|
||||
<style name="MinimalBibleBase.NavigationDrawer.Title">
|
||||
<item name="android:textAppearance">@style/TextAppearance.AppCompat.Title</item>
|
||||
<item name="android:textColor">?android:attr/textColorPrimary</item>
|
||||
<item name="android:background">@color/colorPrimary</item>
|
||||
<item name="android:paddingLeft">16dp</item>
|
||||
<item name="android:paddingRight">16dp</item>
|
||||
<item name="android:minHeight">?attr/actionBarSize</item>
|
||||
<item name="android:gravity">center_vertical</item>
|
||||
</style>
|
||||
|
||||
<!-- Inherits from MinimalBible as a parent so that
|
||||
translucent statusbar is automatically applied -->
|
||||
<style name="MinimalBibleBase.Settings" parent="MinimalBible">
|
||||
@ -32,11 +42,27 @@
|
||||
<item name="android:textColorSecondary">@color/settingsTextColorSecondary</item>
|
||||
</style>
|
||||
|
||||
<!-- Clear the background (including the drop-down arrow) for spinners.
|
||||
Some quick documentation: The spinner is a 9-patch controlled by android:background.
|
||||
I have no idea why it's using the "dark" spinner drop-down, as everything points
|
||||
to it using the light spinner, being that the activity inherits the application theme,
|
||||
and the application theme is light by proxy of MinimalBible -> MinimalBibleBase.
|
||||
However, when I set the Download activity theme to Light.NoActionBar, the spinner color
|
||||
corrects itself (while messing up a couple other things).
|
||||
TODO: Why the heck is the spinner drop-down white? -->
|
||||
<style name="MinimalBibleBase.Spinner">
|
||||
<item name="android:background">@android:color/transparent</item>
|
||||
</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" />
|
||||
|
||||
<style name="MinimalBible.NavigationDrawer.Title" parent="MinimalBibleBase.NavigationDrawer.Title" />
|
||||
|
||||
<style name="MinimalBible.Spinner" parent="MinimalBibleBase.Spinner" />
|
||||
|
||||
<style name="MinimalBible.Settings" parent="MinimalBibleBase.Settings" />
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user