From 594df14a3191c7d4ba6f667cd3681c9c57a070b8 Mon Sep 17 00:00:00 2001 From: Bradlee Speice Date: Mon, 5 May 2014 04:07:58 -0400 Subject: [PATCH] Can now browse a list of documents! --- .../res/drawable-hdpi/ic_action_search.png | Bin 0 -> 702 bytes .../res/drawable-mdpi/ic_action_search.png | Bin 0 -> 479 bytes .../res/drawable-xhdpi/ic_action_search.png | Bin 0 -> 900 bytes .../res/drawable-xxhdpi/ic_action_search.png | Bin 0 -> 1153 bytes MinimalBible/res/layout/activity_download.xml | 16 +++--- MinimalBible/res/layout/fragment_download.xml | 13 +++-- .../res/layout/list_download_items.xml | 45 +++++++++++++++ MinimalBible/res/values/styles.xml | 11 ++++ .../activities/downloader/BookItemView.java | 28 +++++++++ .../downloader/BookListAdapter.java | 53 ++++++++++++++++++ .../downloader/BookListFragment.java | 22 ++++++-- 11 files changed, 169 insertions(+), 19 deletions(-) create mode 100644 MinimalBible/res/drawable-hdpi/ic_action_search.png create mode 100644 MinimalBible/res/drawable-mdpi/ic_action_search.png create mode 100644 MinimalBible/res/drawable-xhdpi/ic_action_search.png create mode 100644 MinimalBible/res/drawable-xxhdpi/ic_action_search.png create mode 100644 MinimalBible/res/layout/list_download_items.xml create mode 100644 MinimalBible/src/org/bspeice/minimalbible/activities/downloader/BookItemView.java create mode 100644 MinimalBible/src/org/bspeice/minimalbible/activities/downloader/BookListAdapter.java diff --git a/MinimalBible/res/drawable-hdpi/ic_action_search.png b/MinimalBible/res/drawable-hdpi/ic_action_search.png new file mode 100644 index 0000000000000000000000000000000000000000..f594b4e482c7db630737b6b68c8646726480d4af GIT binary patch literal 702 zcmV;v0zv(WP)`- zYT3@c^WFKbjfR7RgM&i_cse#237;HVvt20r{a~c`dF|yDzzbtGju@$VR-^F1ro_g2$1rRf{V;Sp=H5*BpHGX zIl@TxNvBIS72F1uKc^v7`UMpEELyYM?S4VFolfV2+^tRP`!N1)lmIC40FO(iJSaXv z1!dO4ydNTQMI_qr+e30X2%Jf}PM>p|nd(OO0+cEl=4CSp1uu)27NuV! z1lWi6MFFdTIrkpaPJn`!9rdQ_$0+--4Ae7m0=|$obs)>xyH*#n8vmX^DwGF0(B(>t zdI?aa8vUo}v{ap_y4yeUudhY*07*qoM6N<$f@EtW!Ti(^`#)-zx#^ji+0NFC1by}d3d=;zzAt%~TnHRcUe_h#B`??G9``=?>wDDq zu5A7U@b3X``UFK$6rgy3uiybcF5x+OmSyF+0J9#+A31rORqzi$9K->T{0YS!S1G{} zi8Qy-^8_AqJGH%v0azoa5$;XmhByLA;S2cN(3$W%*4%R?CqtV;@yyi?-d#wX0+amU zN?wCdJPY>{04uYu1Nt&kzm@<9cw~A&UzPptSb*xO+Ffcwf&Q;sS5&abY!=+lOQI=TT5ycC$M*WVo9~vrJCnnMl`|= zi%gT13}#{~E;YkcqW~DfDBQZX+m%^!#E^LHYM`AEGs!azh?j=PP6+8QBHbeEyS7V8 z8es2$NG}e+)7%De`zs%%4v0pLm|x<8DT?A0hT#`}F5xHmJHU?KU$p6u$pr8tzyP+N VjEWx1<;nm6002ovPDHLkV1lr>(e3~M literal 0 HcmV?d00001 diff --git a/MinimalBible/res/drawable-xhdpi/ic_action_search.png b/MinimalBible/res/drawable-xhdpi/ic_action_search.png new file mode 100644 index 0000000000000000000000000000000000000000..aad535e9781380fe111046fa0bbd14de899c7a39 GIT binary patch literal 900 zcmV-~1AF|5P)n&Xh zIyrLelkdCt-rak45RgbD5{X12k&aWLi%!Sm@c<4N&@S;5|NRDyLEA!GuU4z#-~hnD zM{t-x8#TC`gUF#R0LHr40AS!L9A?mB!!9yt&j5n;4gd^(3WuAT%L;@O*I2|8K*)Ll z0R8+9T3RuqycP1S!hH$eb5j9i4)-kk0N_sH>je&gwRD}%AcPjpp8N2^(2}MYJVkx) zVx(H~FfnF^wsqUZhRYOyocPRaCMyW^ zzm(W@iA)OsR&STmYB04l_< z`1wgVoxnNXe#8HN4b1*Cv~xMvfWDkph}#rJCkm4-^Z7+xDGQ_hZB4$v#7dEW0Cqqq zLFAa#F~ue))!0Wkg<#{wNZYqUVtUOgEF#1H6TI%xRK%(Frv|An zFRVUupNGCa;y^|5_;4nyJXdhti*CGeVgZV1UcMYnYw`;2BAIHPSCq)Bw&o9QEg^In zU@&2liy5rR-oE0^lXVDA0knkoRpAQOA)EyMD$%&^-gHauGk`)9mJx)=*U>|i=RxvH zi2ijtGg%$H1;7Wv2jdz-F4C`8~hq z*bxGPAP9mW2!bF8f*=TjAP9n-YsBeduCK3Cc^K2j@3NJ$<@CAu`1mLQz^=isJ zg&tq0gKV!7Lv0IW{*{F37I!4l}(nh^Jk^WZ#kVEj`t-^m~; zMvy}=vQxqfo387>@TJ0|1rr4gQ8WGLiKPh{+`QcxbadccK6<4-8nG#UTJ<&99* zV}g*%>syBI0SiN(e{gO5h7jhINreZ1djH%s;P!b#1Yv6kMaxhly;P<0oI6T$ zziLLEB{%@OlryuDYIe}3#kCF>0A)T&3j_4!1)0eULh}IKv_Qe6_}LjUq9h~$SB8Si zyC?*f4X=5y08*|1sIz^o001In4@d>% z6+j6S`UQ{=^uCKw0O)kd%-BiD0CYDpVK(iX1`B{5^Rccp4c8J>2+|c@Qw}#ro|tm3 z4V(dBGVgw)%iK6s>NWtF=6x0n?oT)M{25XjT8#s`9yRyr1@sVJmkhiI1%R|OOjF!? zjQzT2)CIRiT2=tiyt}R_ThOAZzO@qid8&W+2n(ika41_*5=_LfAuT*qL-Z80xpb~~D!5vfbuo)>ifqyuU5wX#a0|1mo&U53ioQ{Trm)q_5l|uzFpML&#Hc-bOv=5H3U8R7}C>j7mBF(@@J05&-ZEAqN0|5IQgPjlL4@2;mKdm_G=){N4rt{6MJw7nQJw zIw7Y5tOS65At-~t*$6uT&R1R* literal 0 HcmV?d00001 diff --git a/MinimalBible/res/layout/activity_download.xml b/MinimalBible/res/layout/activity_download.xml index a6fb5e3..fc52f60 100644 --- a/MinimalBible/res/layout/activity_download.xml +++ b/MinimalBible/res/layout/activity_download.xml @@ -7,26 +7,24 @@ tools:context="org.bspeice.minimalbible.activities.downloader.DownloadActivity" > + android:layout_height="match_parent" /> diff --git a/MinimalBible/res/layout/fragment_download.xml b/MinimalBible/res/layout/fragment_download.xml index 7dc1a6a..e1b9542 100644 --- a/MinimalBible/res/layout/fragment_download.xml +++ b/MinimalBible/res/layout/fragment_download.xml @@ -8,9 +8,12 @@ android:paddingTop="@dimen/activity_vertical_margin" tools:context="org.bspeice.minimalbible.DownloadActivity$PlaceholderFragment" > - - + diff --git a/MinimalBible/res/layout/list_download_items.xml b/MinimalBible/res/layout/list_download_items.xml new file mode 100644 index 0000000..501be4c --- /dev/null +++ b/MinimalBible/res/layout/list_download_items.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/MinimalBible/res/values/styles.xml b/MinimalBible/res/values/styles.xml index 845fb57..5255562 100644 --- a/MinimalBible/res/values/styles.xml +++ b/MinimalBible/res/values/styles.xml @@ -10,6 +10,8 @@ res/values-vXX/styles.xml, while customizations related to backward-compatibility can go here. --> + + @@ -17,4 +19,13 @@ + + + diff --git a/MinimalBible/src/org/bspeice/minimalbible/activities/downloader/BookItemView.java b/MinimalBible/src/org/bspeice/minimalbible/activities/downloader/BookItemView.java new file mode 100644 index 0000000..2bcde3e --- /dev/null +++ b/MinimalBible/src/org/bspeice/minimalbible/activities/downloader/BookItemView.java @@ -0,0 +1,28 @@ +package org.bspeice.minimalbible.activities.downloader; + +import android.content.Context; +import android.widget.ImageView; +import android.widget.RelativeLayout; +import android.widget.TextView; + +import org.androidannotations.annotations.EViewGroup; +import org.androidannotations.annotations.ViewById; +import org.bspeice.minimalbible.R; +import org.crosswire.jsword.book.Book; + +@EViewGroup(R.layout.list_download_items) +public class BookItemView extends RelativeLayout { + + @ViewById (R.id.img_download_icon) ImageView downloadIcon; + @ViewById(R.id.txt_download_item_name) TextView itemName; + @ViewById(R.id.img_download_index_downloaded) ImageView isIndexedDownloaded; + @ViewById(R.id.img_download_item_downloaded) ImageView isDownloaded; + + public BookItemView (Context ctx) { + super(ctx); + } + + public void bind(Book b) { + itemName.setText(b.getName()); + } +} diff --git a/MinimalBible/src/org/bspeice/minimalbible/activities/downloader/BookListAdapter.java b/MinimalBible/src/org/bspeice/minimalbible/activities/downloader/BookListAdapter.java new file mode 100644 index 0000000..edac3e1 --- /dev/null +++ b/MinimalBible/src/org/bspeice/minimalbible/activities/downloader/BookListAdapter.java @@ -0,0 +1,53 @@ +package org.bspeice.minimalbible.activities.downloader; + +import android.content.Context; +import android.view.View; +import android.view.ViewGroup; +import android.widget.BaseAdapter; + +import org.crosswire.jsword.book.Book; + +import java.util.List; + +/** + * Adapter to inflate list_download_items.xml + */ +public class BookListAdapter extends BaseAdapter { + private List bookList; + + private Context ctx; + + public BookListAdapter(Context context, List bookList) { + this.bookList = bookList; + this.ctx = context; + } + + @Override + public int getCount() { + return bookList.size(); + } + + @Override + public Book getItem(int position) { + return bookList.get(position); + } + + @Override + public long getItemId(int i) { + return i; + } + + @Override + public View getView(int position, View convertView, ViewGroup parent) { + BookItemView itemView; + if (convertView == null) { + itemView = BookItemView_.build(this.ctx); + + } else { + itemView = (BookItemView) convertView; + } + + itemView.bind(getItem(position)); + return itemView; + } +} diff --git a/MinimalBible/src/org/bspeice/minimalbible/activities/downloader/BookListFragment.java b/MinimalBible/src/org/bspeice/minimalbible/activities/downloader/BookListFragment.java index ca8f6b0..c422e9a 100644 --- a/MinimalBible/src/org/bspeice/minimalbible/activities/downloader/BookListFragment.java +++ b/MinimalBible/src/org/bspeice/minimalbible/activities/downloader/BookListFragment.java @@ -1,15 +1,20 @@ package org.bspeice.minimalbible.activities.downloader; +import android.app.Activity; import android.app.AlertDialog; import android.app.ProgressDialog; import android.content.Context; import android.content.DialogInterface; import android.content.SharedPreferences; +import android.os.Build; import android.support.v4.app.Fragment; import android.util.Log; -import android.widget.TextView; +import android.view.View; +import android.widget.ListView; import android.widget.Toast; +import com.readystatesoftware.systembartint.SystemBarTintManager; + import org.androidannotations.annotations.AfterViews; import org.androidannotations.annotations.EFragment; import org.androidannotations.annotations.FragmentArg; @@ -38,8 +43,8 @@ public class BookListFragment extends Fragment { @FragmentArg BookCategory bookCategory; - @ViewById(R.id.section_label) - protected TextView tv; + @ViewById(R.id.lst_download_available) + protected ListView downloadsAvailable; private ProgressDialog refreshDialog; @@ -47,7 +52,6 @@ public class BookListFragment extends Fragment { @AfterViews public void updateName() { ((DownloadActivity) getActivity()).onSectionAttached(bookCategory.toString()); - tv.setText(bookCategory.toString()); displayModules(); } @@ -97,11 +101,19 @@ public class BookListFragment extends Fragment { displayBooks(event.getBookList()); } + public static void setInsets(Activity context, View view) { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) return; + SystemBarTintManager tintManager = new SystemBarTintManager(context); + SystemBarTintManager.SystemBarConfig config = tintManager.getConfig(); + view.setPadding(0, config.getPixelInsetTop(true), config.getPixelInsetRight(), config.getPixelInsetBottom()); + } + public void displayBooks(List bookList) { try { BookFilter f = FilterUtil.filterFromCategory(bookCategory); List filteredBooks = FilterUtil.applyFilter(bookList, f); - tv.setText(filteredBooks.get(0).getName()); + downloadsAvailable.setAdapter(new BookListAdapter(this.getActivity(), filteredBooks)); + setInsets(getActivity(), downloadsAvailable); } catch (FilterUtil.InvalidFilterCategoryMappingException e) { // To be honest, there should be no reason you end up here. Log.e(TAG, e.getMessage());