Allow selecting all media in overview
This commit is contained in:
parent
84c71fce16
commit
c82afd8944
4 changed files with 23 additions and 0 deletions
|
@ -4,4 +4,9 @@
|
|||
android:title="@string/delete"
|
||||
android:icon="@drawable/ic_delete_white_24dp"
|
||||
app:showAsAction="always"/>
|
||||
|
||||
<item android:id="@+id/select_all"
|
||||
android:title="@string/MediaOverviewActivity_Select_all"
|
||||
android:icon="?menu_selectall_icon"
|
||||
app:showAsAction="always"/>
|
||||
</menu>
|
||||
|
|
|
@ -394,6 +394,7 @@
|
|||
<string name="MediaOverviewActivity_Media_delete_progress_title">Deleting</string>
|
||||
<string name="MediaOverviewActivity_Media_delete_progress_message">Deleting messages...</string>
|
||||
<string name="MediaOverviewActivity_Documents">Documents</string>
|
||||
<string name="MediaOverviewActivity_Select_all">Select all</string>
|
||||
|
||||
<!--- NotificationBarManager -->
|
||||
<string name="NotificationBarManager_signal_call_in_progress">Signal call in progress</string>
|
||||
|
|
|
@ -154,6 +154,15 @@ class MediaGalleryAdapter extends StickyHeaderGridAdapter {
|
|||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
void selectAllMedia() {
|
||||
for (int section = 0; section < media.getSectionCount(); section++) {
|
||||
for (int item = 0; item < media.getSectionItemCount(section); item++) {
|
||||
selected.add(media.get(section, item));
|
||||
}
|
||||
}
|
||||
this.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
interface ItemClickListener {
|
||||
void onMediaClicked(@NonNull MediaRecord mediaRecord);
|
||||
void onMediaLongClicked(MediaRecord mediaRecord);
|
||||
|
|
|
@ -357,6 +357,11 @@ public class MediaOverviewActivity extends PassphraseRequiredActionBarActivity {
|
|||
builder.show();
|
||||
}
|
||||
|
||||
private void handleSelectAllMedia() {
|
||||
getListAdapter().selectAllMedia();
|
||||
actionMode.setTitle(String.valueOf(getListAdapter().getSelectedMediaCount()));
|
||||
}
|
||||
|
||||
private MediaGalleryAdapter getListAdapter() {
|
||||
return (MediaGalleryAdapter) recyclerView.getAdapter();
|
||||
}
|
||||
|
@ -401,6 +406,9 @@ public class MediaOverviewActivity extends PassphraseRequiredActionBarActivity {
|
|||
handleDeleteMedia(getListAdapter().getSelectedMedia());
|
||||
exitMultiSelect();
|
||||
return true;
|
||||
case R.id.select_all:
|
||||
handleSelectAllMedia();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue