mirror of
https://github.com/MinimalBible/MinimalBible-Legacy
synced 2024-11-13 19:48:38 -05:00
Can now browse a list of documents!
This commit is contained in:
parent
f228e8265e
commit
594df14a31
BIN
MinimalBible/res/drawable-hdpi/ic_action_search.png
Normal file
BIN
MinimalBible/res/drawable-hdpi/ic_action_search.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 702 B |
BIN
MinimalBible/res/drawable-mdpi/ic_action_search.png
Normal file
BIN
MinimalBible/res/drawable-mdpi/ic_action_search.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 479 B |
BIN
MinimalBible/res/drawable-xhdpi/ic_action_search.png
Normal file
BIN
MinimalBible/res/drawable-xhdpi/ic_action_search.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 900 B |
BIN
MinimalBible/res/drawable-xxhdpi/ic_action_search.png
Normal file
BIN
MinimalBible/res/drawable-xxhdpi/ic_action_search.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
@ -7,26 +7,24 @@
|
||||
tools:context="org.bspeice.minimalbible.activities.downloader.DownloadActivity" >
|
||||
|
||||
<!--
|
||||
As the main content view, the view below consumes the entire
|
||||
As the main content view, the view below consumes the entire
|
||||
space available using match_parent in both dimensions.
|
||||
-->
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true"
|
||||
android:clipToPadding="false" />
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
<!--
|
||||
android:layout_gravity="start" tells DrawerLayout to treat
|
||||
this as a sliding drawer on the left side for left-to-right
|
||||
languages and on the right side for right-to-left languages.
|
||||
If you're not building against API 17 or higher, use
|
||||
android:layout_gravity="start" tells DrawerLayout to treat
|
||||
this as a sliding drawer on the left side for left-to-right
|
||||
languages and on the right side for right-to-left languages.
|
||||
If you're not building against API 17 or higher, use
|
||||
android:layout_gravity="left" instead.
|
||||
-->
|
||||
<!--
|
||||
The drawer is given a fixed width in dp and extends the full height of
|
||||
The drawer is given a fixed width in dp and extends the full height of
|
||||
the container.
|
||||
-->
|
||||
|
||||
|
@ -8,9 +8,12 @@
|
||||
android:paddingTop="@dimen/activity_vertical_margin"
|
||||
tools:context="org.bspeice.minimalbible.DownloadActivity$PlaceholderFragment" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/section_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<ListView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/lst_download_available"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:clipToPadding="false" />
|
||||
</RelativeLayout>
|
||||
|
45
MinimalBible/res/layout/list_download_items.xml
Normal file
45
MinimalBible/res/layout/list_download_items.xml
Normal file
@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:padding="2dip">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/img_download_icon"
|
||||
android:layout_weight="1"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_marginLeft="0dp"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_marginTop="0dp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/txt_download_item_name"
|
||||
android:layout_weight="1"
|
||||
android:layout_toRightOf="@+id/img_download_icon"
|
||||
android:layout_toLeftOf="@+id/img_download_index_downloaded" />
|
||||
|
||||
<ImageButton
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/img_download_index_downloaded"
|
||||
android:src="@drawable/ic_action_search"
|
||||
style="@style/AppBaseTheme.Borderless"
|
||||
android:layout_weight="1"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_toLeftOf="@+id/img_download_item_downloaded" />
|
||||
|
||||
<ImageButton
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/img_download_item_downloaded"
|
||||
android:layout_weight="1"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentRight="true"
|
||||
style="@style/AppBaseTheme.Borderless" />
|
||||
|
||||
</RelativeLayout>
|
@ -10,6 +10,8 @@
|
||||
res/values-vXX/styles.xml, while customizations related to
|
||||
backward-compatibility can go here.
|
||||
-->
|
||||
|
||||
|
||||
</style>
|
||||
|
||||
<!-- Application theme. -->
|
||||
@ -17,4 +19,13 @@
|
||||
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
|
||||
</style>
|
||||
|
||||
<!-- Almost re-use style from Widget.Holo.Button.Borderless -->
|
||||
<style name="AppBaseTheme.Borderless">
|
||||
<item name="android:background">?android:attr/selectableItemBackground</item>
|
||||
<!-- Requires API 17
|
||||
<item name="android:paddingStart">4dip</item>
|
||||
<item name="android:paddingEnd">4dip</item>
|
||||
-->
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
@ -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<Book> bookList;
|
||||
|
||||
private Context ctx;
|
||||
|
||||
public BookListAdapter(Context context, List<Book> 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;
|
||||
}
|
||||
}
|
@ -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<Book> bookList) {
|
||||
try {
|
||||
BookFilter f = FilterUtil.filterFromCategory(bookCategory);
|
||||
List<Book> 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());
|
||||
|
Loading…
Reference in New Issue
Block a user