Skip to content

Commit

Permalink
Handle Attachment Keyboard selection of a too large item.
Browse files Browse the repository at this point in the history
  • Loading branch information
alan-signal committed Jun 18, 2020
1 parent bc5be10 commit c4dc906
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,10 @@ private void initViewModel() {
case ITEM_TOO_LARGE:
Toast.makeText(this, R.string.MediaSendActivity_an_item_was_removed_because_it_exceeded_the_size_limit, Toast.LENGTH_LONG).show();
break;
case ONLY_ITEM_TOO_LARGE:
Toast.makeText(this, R.string.MediaSendActivity_an_item_was_removed_because_it_exceeded_the_size_limit, Toast.LENGTH_LONG).show();
onNoMediaAvailable();
break;
case TOO_MANY_ITEMS:
int maxSelection = viewModel.getMaxSelection();
Toast.makeText(this, getResources().getQuantityString(R.plurals.MediaSendActivity_cant_share_more_than_n_items, maxSelection, maxSelection), Toast.LENGTH_SHORT).show();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,11 @@ void onSelectedMediaChanged(@NonNull Context context, @NonNull List<Media> newMe
List<Media> filteredMedia = getFilteredMedia(context, populatedMedia, mediaConstraints);

if (filteredMedia.size() != newMedia.size()) {
error.setValue(Error.ITEM_TOO_LARGE);
if (filteredMedia.isEmpty() && newMedia.size() == 1 && page == Page.UNKNOWN) {
error.setValue(Error.ONLY_ITEM_TOO_LARGE);
} else {
error.setValue(Error.ITEM_TOO_LARGE);
}
}

if (filteredMedia.size() > maxSelection) {
Expand Down Expand Up @@ -670,7 +674,7 @@ protected void onCleared() {
}

enum Error {
ITEM_TOO_LARGE, TOO_MANY_ITEMS, NO_ITEMS
ITEM_TOO_LARGE, TOO_MANY_ITEMS, NO_ITEMS, ONLY_ITEM_TOO_LARGE
}

enum Event {
Expand Down

0 comments on commit c4dc906

Please sign in to comment.