Item selection

This commit is contained in:
inorichi 2015-10-02 18:27:25 +02:00
parent 7fe40525f2
commit a6c59bbc10
13 changed files with 66 additions and 2 deletions

View File

@ -2,9 +2,11 @@ package eu.kanade.mangafeed.ui.fragment;
import android.os.Bundle; import android.os.Bundle;
import android.support.v7.widget.SearchView; import android.support.v7.widget.SearchView;
import android.view.ActionMode;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
import android.view.MenuInflater; import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.GridView; import android.widget.GridView;
@ -93,6 +95,37 @@ public class LibraryFragment extends BaseFragment implements LibraryView {
(parent, view, position, id) -> (parent, view, position, id) ->
presenter.onMangaClick(position) 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) {
}
});
} }
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 161 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 115 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 156 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 200 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 243 B

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android"
android:exitFadeDuration="@android:integer/config_shortAnimTime">>
<item android:drawable="@color/line_grey" android:state_pressed="true"/>
<item android:drawable="@color/line_grey" android:state_selected="true"/>
<item android:drawable="@color/line_grey" android:state_activated="true"/>
<item android:drawable="@color/library_text_background"/>
</selector>

View File

@ -16,6 +16,7 @@
android:numColumns="auto_fit" android:numColumns="auto_fit"
android:stretchMode="columnWidth" android:stretchMode="columnWidth"
android:fastScrollEnabled="true" android:fastScrollEnabled="true"
android:choiceMode="multipleChoiceModal"
tools:listitem="@layout/item_library" /> tools:listitem="@layout/item_library" />
</FrameLayout> </FrameLayout>

View File

@ -6,6 +6,7 @@
android:orientation="vertical" android:orientation="vertical"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@drawable/library_item_background"
> >
<FrameLayout <FrameLayout
@ -42,7 +43,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="36dp" android:layout_height="36dp"
android:id="@+id/footerLinearLayout" android:id="@+id/footerLinearLayout"
android:background="@color/md_grey_300"> >
<eu.kanade.mangafeed.widget.PTSansTextView <eu.kanade.mangafeed.widget.PTSansTextView
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item android:id="@+id/action_delete"
android:title="@string/action_delete"
android:icon="@drawable/ic_action_delete"
android:orderInCategory="1"
app:showAsAction="always"/>
</menu>

View File

@ -14,4 +14,5 @@
<color name="light_grey">#D4D4D4</color> <color name="light_grey">#D4D4D4</color>
<color name="bg_light_grey">#E9E9E9</color> <color name="bg_light_grey">#E9E9E9</color>
<color name="black_87pc">#DD000000</color> <color name="black_87pc">#DD000000</color>
<color name="library_text_background">#E8E8E8</color>
</resources> </resources>

View File

@ -33,5 +33,7 @@
<string name="action_search">Search</string> <string name="action_search">Search</string>
<string name="action_refresh">Refresh</string> <string name="action_refresh">Refresh</string>
<string name="library_search_hint">Title or author...</string> <string name="library_search_hint">Title or author...</string>
<string name="action_delete">Delete</string>
<string name="library_selection_title">Selected</string>
</resources> </resources>

View File

@ -9,6 +9,8 @@
<item name="android:textColorPrimary">@color/black_87pc</item> <item name="android:textColorPrimary">@color/black_87pc</item>
<item name="android:textColor">@color/black_87pc</item> <item name="android:textColor">@color/black_87pc</item>
<item name="colorControlNormal">@color/white</item> <item name="colorControlNormal">@color/white</item>
<item name="windowActionModeOverlay">true</item>
<item name="actionModeStyle">@style/Widget.ActionMode</item>
</style> </style>
<style name="AppTheme.NoActionBar" parent="AppTheme"> <style name="AppTheme.NoActionBar" parent="AppTheme">
@ -22,6 +24,9 @@
<item name="android:itemTextAppearance">@style/OptionsMenuTextColor</item> <item name="android:itemTextAppearance">@style/OptionsMenuTextColor</item>
</style> </style>
<style name="Widget.ActionMode" parent="@style/Widget.AppCompat.ActionMode">
<item name="background">@color/primary</item>
</style>
<style name="AlertDialogStyle" parent="Theme.AppCompat.Light.Dialog.Alert"> <style name="AlertDialogStyle" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="android:windowTitleStyle">@style/DialogTitleText</item> <item name="android:windowTitleStyle">@style/DialogTitleText</item>
<item name="colorAccent">@color/primary</item> <item name="colorAccent">@color/primary</item>