From a6c59bbc10164412f76be5c509c03e9aa6b20e7d Mon Sep 17 00:00:00 2001 From: inorichi Date: Fri, 2 Oct 2015 18:27:25 +0200 Subject: [PATCH] Item selection --- .../ui/fragment/LibraryFragment.java | 33 ++++++++++++++++++ .../res/drawable-hdpi/ic_action_delete.png | Bin 0 -> 161 bytes .../res/drawable-mdpi/ic_action_delete.png | Bin 0 -> 115 bytes .../res/drawable-xhdpi/ic_action_delete.png | Bin 0 -> 156 bytes .../res/drawable-xxhdpi/ic_action_delete.png | Bin 0 -> 200 bytes .../res/drawable-xxxhdpi/ic_action_delete.png | Bin 0 -> 243 bytes .../res/drawable/library_item_background.xml | 9 +++++ app/src/main/res/layout/fragment_library.xml | 1 + app/src/main/res/layout/item_library.xml | 3 +- app/src/main/res/menu/library_selection.xml | 12 +++++++ app/src/main/res/values/colors.xml | 1 + app/src/main/res/values/strings.xml | 2 ++ app/src/main/res/values/styles.xml | 7 +++- 13 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 app/src/main/res/drawable-hdpi/ic_action_delete.png create mode 100644 app/src/main/res/drawable-mdpi/ic_action_delete.png create mode 100644 app/src/main/res/drawable-xhdpi/ic_action_delete.png create mode 100644 app/src/main/res/drawable-xxhdpi/ic_action_delete.png create mode 100644 app/src/main/res/drawable-xxxhdpi/ic_action_delete.png create mode 100644 app/src/main/res/drawable/library_item_background.xml create mode 100644 app/src/main/res/menu/library_selection.xml diff --git a/app/src/main/java/eu/kanade/mangafeed/ui/fragment/LibraryFragment.java b/app/src/main/java/eu/kanade/mangafeed/ui/fragment/LibraryFragment.java index 38a60a1937..425f72f422 100644 --- a/app/src/main/java/eu/kanade/mangafeed/ui/fragment/LibraryFragment.java +++ b/app/src/main/java/eu/kanade/mangafeed/ui/fragment/LibraryFragment.java @@ -2,9 +2,11 @@ package eu.kanade.mangafeed.ui.fragment; import android.os.Bundle; import android.support.v7.widget.SearchView; +import android.view.ActionMode; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; +import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.widget.GridView; @@ -93,6 +95,37 @@ public class LibraryFragment extends BaseFragment implements LibraryView { (parent, view, position, id) -> presenter.onMangaClick(position) ); + grid.setMultiChoiceModeListener(new GridView.MultiChoiceModeListener() { + @Override + public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) { + mode.setTitle(getResources().getString(R.string.library_selection_title) + + ": " + grid.getCheckedItemCount()); + + + } + + @Override + public boolean onCreateActionMode(ActionMode mode, Menu menu) { + MenuInflater inflater = mode.getMenuInflater(); + inflater.inflate(R.menu.library_selection, menu); + return true; + } + + @Override + public boolean onPrepareActionMode(ActionMode mode, Menu menu) { + return false; + } + + @Override + public boolean onActionItemClicked(ActionMode mode, MenuItem item) { + return false; + } + + @Override + public void onDestroyActionMode(ActionMode mode) { + + } + }); } } diff --git a/app/src/main/res/drawable-hdpi/ic_action_delete.png b/app/src/main/res/drawable-hdpi/ic_action_delete.png new file mode 100644 index 0000000000000000000000000000000000000000..484ed5656b72d14d9ee11c9dd17f4a231f37b0b9 GIT binary patch literal 161 zcmeAS@N?(olHy`uVBq!ia0vp^Dj>|k0wldT1B8K8hNp{TNX4z>1PNA=hW|4Ewf~tb z9PIip^F(s-FKmRW+J}dc&f#K)gg?bl4l$?QfGI+ZB KxvX_7CM{eR+v zgY~R6ULP4=Whfl~yJVLAs>BdxJ>K;jR@FB~H~;@Xea5N(zxh7d@H058Pdd2NT8Iy5 O3WKMspUXO@geCwh`YDtE literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xhdpi/ic_action_delete.png b/app/src/main/res/drawable-xhdpi/ic_action_delete.png new file mode 100644 index 0000000000000000000000000000000000000000..b3aa07e6695172500004bd21352b5a712330ee06 GIT binary patch literal 156 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA0wn)(8}b0DWKS2zkcwMxuN~w(pdjE9xSDfX zru!rjF{WpBW&$0%JDWb$Gk#9^n84xU9CRso<@-P4PUjf@F^g6H-g}-Is2>CjxC>@~ z>z1|faoENj82tFn4mU`AYCaEXRs#?a;~)y>Xhe!9jo}(0^8Q zoKJv>pQwxS4GppUT((6y+I6dxDtMTgC#Sl&Jn`7t^o?uP{3AQ3mvj`1dWy4f2q^qI z^t9^MHwGpU+o6Gh5sC34cEQz0opu*87{A&Dq%)e@1uRsZX{=dZw@UkL=bTG_ZS=2X m1=#FA_3CQGa%Yz>>&q|G5dQ4KuY+ck{{`y~aU3Uxr^X+awlIm)m zLim6tF)Yw+SYp*L31Z?03ltA1m;Rr_zhgPmvYG>yq8FYs_ibEqHvUn-r*1=DgDFx+ z?bd02*59bTR4g&(=Y(kztIpQ%Z4JJY^zZNE9?f4`+x0ysZP__5=_$iXi`hvQAj>>m L{an^LB{Ts5t^ZVx literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable/library_item_background.xml b/app/src/main/res/drawable/library_item_background.xml new file mode 100644 index 0000000000..7ad2c6c8b0 --- /dev/null +++ b/app/src/main/res/drawable/library_item_background.xml @@ -0,0 +1,9 @@ + +> + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_library.xml b/app/src/main/res/layout/fragment_library.xml index 15a186c991..75e938b5df 100644 --- a/app/src/main/res/layout/fragment_library.xml +++ b/app/src/main/res/layout/fragment_library.xml @@ -16,6 +16,7 @@ android:numColumns="auto_fit" android:stretchMode="columnWidth" android:fastScrollEnabled="true" + android:choiceMode="multipleChoiceModal" tools:listitem="@layout/item_library" /> diff --git a/app/src/main/res/layout/item_library.xml b/app/src/main/res/layout/item_library.xml index 3fcaa31f26..bfd4f0e779 100644 --- a/app/src/main/res/layout/item_library.xml +++ b/app/src/main/res/layout/item_library.xml @@ -6,6 +6,7 @@ android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" + android:background="@drawable/library_item_background" > + > + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 9af6059c6d..503bec0f0b 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -14,4 +14,5 @@ #D4D4D4 #E9E9E9 #DD000000 + #E8E8E8 \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index b4090eed2c..e3d145ae8d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -33,5 +33,7 @@ Search Refresh Title or author... + Delete + Selected diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 54d2e38dd6..71b087af54 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -9,6 +9,8 @@ @color/black_87pc @color/black_87pc @color/white + true + @style/Widget.ActionMode - + +