diff --git a/MinimalBible/res/layout/fragment_download.xml b/MinimalBible/res/layout/fragment_download.xml index e1b9542..5076ad1 100644 --- a/MinimalBible/res/layout/fragment_download.xml +++ b/MinimalBible/res/layout/fragment_download.xml @@ -2,10 +2,6 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - android:paddingBottom="@dimen/activity_vertical_margin" - android:paddingLeft="@dimen/activity_horizontal_margin" - android:paddingRight="@dimen/activity_horizontal_margin" - android:paddingTop="@dimen/activity_vertical_margin" tools:context="org.bspeice.minimalbible.DownloadActivity$PlaceholderFragment" > + android:padding="8dp" > + + \ No newline at end of file diff --git a/MinimalBible/src/org/bspeice/minimalbible/activities/ActivityModules.java b/MinimalBible/src/org/bspeice/minimalbible/activities/ActivityModules.java index de3a0d9..80e56fa 100644 --- a/MinimalBible/src/org/bspeice/minimalbible/activities/ActivityModules.java +++ b/MinimalBible/src/org/bspeice/minimalbible/activities/ActivityModules.java @@ -1,6 +1,6 @@ package org.bspeice.minimalbible.activities; -import org.bspeice.minimalbible.activities.downloader.ActivityDownloaderModule; +import org.bspeice.minimalbible.activities.downloader.manager.ActivityDownloaderModule; import dagger.Module; diff --git a/MinimalBible/src/org/bspeice/minimalbible/activities/downloader/BookListAdapter.java b/MinimalBible/src/org/bspeice/minimalbible/activities/downloader/BookListAdapter.java index bc1b0af..0f4ff14 100644 --- a/MinimalBible/src/org/bspeice/minimalbible/activities/downloader/BookListAdapter.java +++ b/MinimalBible/src/org/bspeice/minimalbible/activities/downloader/BookListAdapter.java @@ -61,6 +61,7 @@ public class BookListAdapter extends BaseAdapter { public class BookItemView extends RelativeLayout { @InjectView(R.id.img_download_icon) ImageView downloadIcon; + @InjectView(R.id.download_txt_item_acronym) TextView acronym; @InjectView(R.id.txt_download_item_name) TextView itemName; @InjectView(R.id.img_download_index_downloaded) ImageView isIndexedDownloaded; @InjectView(R.id.img_download_item_downloaded) ImageView isDownloaded; @@ -72,6 +73,7 @@ public class BookListAdapter extends BaseAdapter { } public void bind(Book b) { + acronym.setText(b.getInitials()); itemName.setText(b.getName()); } } diff --git a/MinimalBible/src/org/bspeice/minimalbible/activities/downloader/BookListFragment.java b/MinimalBible/src/org/bspeice/minimalbible/activities/downloader/BookListFragment.java index 97a8d7f..d9ba9f3 100644 --- a/MinimalBible/src/org/bspeice/minimalbible/activities/downloader/BookListFragment.java +++ b/MinimalBible/src/org/bspeice/minimalbible/activities/downloader/BookListFragment.java @@ -21,6 +21,8 @@ import com.readystatesoftware.systembartint.SystemBarTintManager; import org.bspeice.minimalbible.MinimalBible; import org.bspeice.minimalbible.MinimalBibleConstants; import org.bspeice.minimalbible.R; +import org.bspeice.minimalbible.activities.downloader.manager.DownloadManager; +import org.bspeice.minimalbible.activities.downloader.manager.EventBookList; import org.crosswire.jsword.book.Book; import org.crosswire.jsword.book.BookCategory; import org.crosswire.jsword.book.BookFilter; diff --git a/MinimalBible/src/org/bspeice/minimalbible/activities/downloader/DownloadActivity.java b/MinimalBible/src/org/bspeice/minimalbible/activities/downloader/DownloadActivity.java index 8789b59..c9ad587 100644 --- a/MinimalBible/src/org/bspeice/minimalbible/activities/downloader/DownloadActivity.java +++ b/MinimalBible/src/org/bspeice/minimalbible/activities/downloader/DownloadActivity.java @@ -3,6 +3,7 @@ package org.bspeice.minimalbible.activities.downloader; import org.bspeice.minimalbible.R; import org.bspeice.minimalbible.activities.BaseActivity; import org.bspeice.minimalbible.activities.BaseNavigationDrawerFragment; +import org.bspeice.minimalbible.activities.downloader.manager.DownloadManager; import android.os.Bundle; import android.support.v4.app.FragmentManager; diff --git a/MinimalBible/src/org/bspeice/minimalbible/activities/downloader/DownloadNavDrawerFragment.java b/MinimalBible/src/org/bspeice/minimalbible/activities/downloader/DownloadNavDrawerFragment.java index 5aace3e..a742ae1 100644 --- a/MinimalBible/src/org/bspeice/minimalbible/activities/downloader/DownloadNavDrawerFragment.java +++ b/MinimalBible/src/org/bspeice/minimalbible/activities/downloader/DownloadNavDrawerFragment.java @@ -2,6 +2,7 @@ package org.bspeice.minimalbible.activities.downloader; import org.bspeice.minimalbible.R; import org.bspeice.minimalbible.activities.BaseNavigationDrawerFragment; +import org.bspeice.minimalbible.activities.downloader.manager.DownloadManager; import android.os.Bundle; import android.view.LayoutInflater; diff --git a/MinimalBible/src/org/bspeice/minimalbible/activities/downloader/ActivityDownloaderModule.java b/MinimalBible/src/org/bspeice/minimalbible/activities/downloader/manager/ActivityDownloaderModule.java similarity index 58% rename from MinimalBible/src/org/bspeice/minimalbible/activities/downloader/ActivityDownloaderModule.java rename to MinimalBible/src/org/bspeice/minimalbible/activities/downloader/manager/ActivityDownloaderModule.java index 0411bd2..7f420f1 100644 --- a/MinimalBible/src/org/bspeice/minimalbible/activities/downloader/ActivityDownloaderModule.java +++ b/MinimalBible/src/org/bspeice/minimalbible/activities/downloader/manager/ActivityDownloaderModule.java @@ -1,4 +1,6 @@ -package org.bspeice.minimalbible.activities.downloader; +package org.bspeice.minimalbible.activities.downloader.manager; + +import org.bspeice.minimalbible.activities.downloader.BookListFragment; import javax.inject.Singleton; @@ -17,6 +19,12 @@ import de.greenrobot.event.EventBus; ) public class ActivityDownloaderModule { + /** + * Provide a Singleton DownloadManager for injection + * Note that we need to annotate Singleton here, only annotating on the + * DownloadManager itself is not enough. + * @return global DownloadManager instance + */ @Provides @Singleton DownloadManager provideDownloadManager() { return new DownloadManager(); diff --git a/MinimalBible/src/org/bspeice/minimalbible/activities/downloader/BookRefreshTask.java b/MinimalBible/src/org/bspeice/minimalbible/activities/downloader/manager/BookRefreshTask.java similarity index 94% rename from MinimalBible/src/org/bspeice/minimalbible/activities/downloader/BookRefreshTask.java rename to MinimalBible/src/org/bspeice/minimalbible/activities/downloader/manager/BookRefreshTask.java index eae1564..b1cb78a 100644 --- a/MinimalBible/src/org/bspeice/minimalbible/activities/downloader/BookRefreshTask.java +++ b/MinimalBible/src/org/bspeice/minimalbible/activities/downloader/manager/BookRefreshTask.java @@ -1,77 +1,77 @@ -package org.bspeice.minimalbible.activities.downloader; - -import java.util.LinkedList; -import java.util.List; - -import org.bspeice.minimalbible.MinimalBible; -import org.bspeice.minimalbible.MinimalBibleConstants; -import org.crosswire.jsword.book.Book; -import org.crosswire.jsword.book.BookFilter; -import org.crosswire.jsword.book.install.InstallException; -import org.crosswire.jsword.book.install.Installer; - -import de.greenrobot.event.EventBus; - -import android.content.Context; -import android.content.SharedPreferences; -import android.os.AsyncTask; -import android.util.Log; - -public class BookRefreshTask extends AsyncTask> { - private static final String TAG = "EventBookRefreshTask"; - - private EventBus downloadBus; - private BookFilter filter; - - public BookRefreshTask(EventBus downloadBus) { - this.downloadBus = downloadBus; - } - - public BookRefreshTask(EventBus downloadBus, BookFilter f) { - this.downloadBus = downloadBus; - this.filter = f; - } - - @Override - protected List doInBackground(Installer... params) { - List books = new LinkedList(); - - int index = 0; - for (Installer i : params) { - if (doRefresh()) { - try { - i.reloadBookList(); - } catch (InstallException e) { - Log.e(TAG, - "Error downloading books from installer: " - + i.toString(), e); - } - } - - if (filter != null) { - books.addAll(i.getBooks(filter)); - } else { - books.addAll(i.getBooks()); - } - publishProgress(++index, params.length); - } - - downloadBus.postSticky(new EventBookList(books)); - return books; - } - - private boolean doRefresh() { - // Check if we should refresh over the internet, or use the local copy - // TODO: Discover if we need to refresh over Internet, or use a cached - // copy - likely something time-based, also check network state. - // Fun fact - jSword handles the caching for us. - - SharedPreferences prefs = MinimalBible.getAppContext() - .getSharedPreferences( - MinimalBibleConstants.DOWNLOAD_PREFS_FILE, - Context.MODE_PRIVATE); - - // Refresh if download enabled - return prefs.getBoolean(MinimalBibleConstants.KEY_DOWNLOAD_ENABLED, false); - } -} +package org.bspeice.minimalbible.activities.downloader.manager; + +import java.util.LinkedList; +import java.util.List; + +import org.bspeice.minimalbible.MinimalBible; +import org.bspeice.minimalbible.MinimalBibleConstants; +import org.crosswire.jsword.book.Book; +import org.crosswire.jsword.book.BookFilter; +import org.crosswire.jsword.book.install.InstallException; +import org.crosswire.jsword.book.install.Installer; + +import de.greenrobot.event.EventBus; + +import android.content.Context; +import android.content.SharedPreferences; +import android.os.AsyncTask; +import android.util.Log; + +public class BookRefreshTask extends AsyncTask> { + private static final String TAG = "EventBookRefreshTask"; + + private EventBus downloadBus; + private BookFilter filter; + + public BookRefreshTask(EventBus downloadBus) { + this.downloadBus = downloadBus; + } + + public BookRefreshTask(EventBus downloadBus, BookFilter f) { + this.downloadBus = downloadBus; + this.filter = f; + } + + @Override + protected List doInBackground(Installer... params) { + List books = new LinkedList(); + + int index = 0; + for (Installer i : params) { + if (doRefresh()) { + try { + i.reloadBookList(); + } catch (InstallException e) { + Log.e(TAG, + "Error downloading books from installer: " + + i.toString(), e); + } + } + + if (filter != null) { + books.addAll(i.getBooks(filter)); + } else { + books.addAll(i.getBooks()); + } + publishProgress(++index, params.length); + } + + downloadBus.postSticky(new EventBookList(books)); + return books; + } + + private boolean doRefresh() { + // Check if we should refresh over the internet, or use the local copy + // TODO: Discover if we need to refresh over Internet, or use a cached + // copy - likely something time-based, also check network state. + // Fun fact - jSword handles the caching for us. + + SharedPreferences prefs = MinimalBible.getAppContext() + .getSharedPreferences( + MinimalBibleConstants.DOWNLOAD_PREFS_FILE, + Context.MODE_PRIVATE); + + // Refresh if download enabled + return prefs.getBoolean(MinimalBibleConstants.KEY_DOWNLOAD_ENABLED, false); + } +} diff --git a/MinimalBible/src/org/bspeice/minimalbible/activities/downloader/DownloadManager.java b/MinimalBible/src/org/bspeice/minimalbible/activities/downloader/manager/DownloadManager.java similarity index 95% rename from MinimalBible/src/org/bspeice/minimalbible/activities/downloader/DownloadManager.java rename to MinimalBible/src/org/bspeice/minimalbible/activities/downloader/manager/DownloadManager.java index 2b27183..ed6a881 100644 --- a/MinimalBible/src/org/bspeice/minimalbible/activities/downloader/DownloadManager.java +++ b/MinimalBible/src/org/bspeice/minimalbible/activities/downloader/manager/DownloadManager.java @@ -1,4 +1,4 @@ -package org.bspeice.minimalbible.activities.downloader; +package org.bspeice.minimalbible.activities.downloader.manager; import android.util.Log; diff --git a/MinimalBible/src/org/bspeice/minimalbible/activities/downloader/EventBookList.java b/MinimalBible/src/org/bspeice/minimalbible/activities/downloader/manager/EventBookList.java similarity index 78% rename from MinimalBible/src/org/bspeice/minimalbible/activities/downloader/EventBookList.java rename to MinimalBible/src/org/bspeice/minimalbible/activities/downloader/manager/EventBookList.java index 10e0f1b..a2b561b 100644 --- a/MinimalBible/src/org/bspeice/minimalbible/activities/downloader/EventBookList.java +++ b/MinimalBible/src/org/bspeice/minimalbible/activities/downloader/manager/EventBookList.java @@ -1,18 +1,18 @@ -package org.bspeice.minimalbible.activities.downloader; - -import java.util.List; - -import org.crosswire.jsword.book.Book; - -public class EventBookList { - - private List bookList; - - public EventBookList(List bookList) { - this.bookList = bookList; - } - - public List getBookList() { - return bookList; - } -} +package org.bspeice.minimalbible.activities.downloader.manager; + +import java.util.List; + +import org.crosswire.jsword.book.Book; + +public class EventBookList { + + private List bookList; + + public EventBookList(List bookList) { + this.bookList = bookList; + } + + public List getBookList() { + return bookList; + } +}