From a6f31c60bdb9b3890e51ec6ffe6e8670d9185a18 Mon Sep 17 00:00:00 2001 From: Greyson Parrelli Date: Wed, 16 Jan 2019 14:31:59 -0800 Subject: [PATCH] Show a toast when you've gone over the max media selection. --- res/values/strings.xml | 4 ++++ .../securesms/mediasend/MediaPickerItemAdapter.java | 3 +++ .../securesms/mediasend/MediaPickerItemFragment.java | 6 ++++++ 3 files changed, 13 insertions(+) diff --git a/res/values/strings.xml b/res/values/strings.xml index 346616d71b..2f548bdc8b 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -440,6 +440,10 @@ Tap to select + + You can\'t share more than %d item. + You can\'t share more than %d items. + Add a caption... diff --git a/src/org/thoughtcrime/securesms/mediasend/MediaPickerItemAdapter.java b/src/org/thoughtcrime/securesms/mediasend/MediaPickerItemAdapter.java index 03a3d47407..651c8c4874 100644 --- a/src/org/thoughtcrime/securesms/mediasend/MediaPickerItemAdapter.java +++ b/src/org/thoughtcrime/securesms/mediasend/MediaPickerItemAdapter.java @@ -134,6 +134,8 @@ public class MediaPickerItemAdapter extends RecyclerView.Adapter(selected)); + } else { + eventListener.onMediaSelectionOverflow(maxSelection); } }); } @@ -147,5 +149,6 @@ public class MediaPickerItemAdapter extends RecyclerView.Adapter media); + void onMediaSelectionOverflow(int maxSelection); } } diff --git a/src/org/thoughtcrime/securesms/mediasend/MediaPickerItemFragment.java b/src/org/thoughtcrime/securesms/mediasend/MediaPickerItemFragment.java index 3018b93352..5af64e20e2 100644 --- a/src/org/thoughtcrime/securesms/mediasend/MediaPickerItemFragment.java +++ b/src/org/thoughtcrime/securesms/mediasend/MediaPickerItemFragment.java @@ -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);