Show a toast when you've gone over the max media selection.

This commit is contained in:
Greyson Parrelli 2019-01-16 14:31:59 -08:00
parent 4643dea2ad
commit a6f31c60bd
3 changed files with 13 additions and 0 deletions

View File

@ -440,6 +440,10 @@
<!-- MediaPickerItemFragment -->
<string name="MediaPickerItemFragment_tap_to_select">Tap to select</string>
<plurals name="MediaPickerItemFragment_cant_share_more_than_n_items">
<item quantity="one">You can\'t share more than %d item.</item>
<item quantity="other">You can\'t share more than %d items.</item>
</plurals>
<!-- MediaSendActivity -->
<string name="MediaSendActivity_add_a_caption">Add a caption...</string>

View File

@ -134,6 +134,8 @@ public class MediaPickerItemAdapter extends RecyclerView.Adapter<MediaPickerItem
if (selected.size() < maxSelection) {
selected.add(media);
eventListener.onMediaSelectionChanged(new ArrayList<>(selected));
} else {
eventListener.onMediaSelectionOverflow(maxSelection);
}
});
}
@ -147,5 +149,6 @@ public class MediaPickerItemAdapter extends RecyclerView.Adapter<MediaPickerItem
interface EventListener {
void onMediaChosen(@NonNull Media media);
void onMediaSelectionChanged(@NonNull List<Media> media);
void onMediaSelectionOverflow(int maxSelection);
}
}

View File

@ -22,6 +22,7 @@ import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Toast;
import org.thoughtcrime.securesms.R;
import org.thoughtcrime.securesms.mms.GlideApp;
@ -167,6 +168,11 @@ public class MediaPickerItemFragment extends Fragment implements MediaPickerItem
viewModel.onSelectedMediaChanged(selected);
}
@Override
public void onMediaSelectionOverflow(int maxSelection) {
Toast.makeText(requireContext(), getResources().getQuantityString(R.plurals.MediaPickerItemFragment_cant_share_more_than_n_items, maxSelection, maxSelection), Toast.LENGTH_SHORT).show();
}
private void initToolbar(Toolbar toolbar) {
((AppCompatActivity) requireActivity()).setSupportActionBar(toolbar);
((AppCompatActivity) requireActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true);