From f9f994c540347062cf7f9de96531bde956cf97c0 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Mon, 20 Sep 2021 10:08:11 +0200 Subject: [PATCH] Intent.EXTRA_ALLOW_MULTIPLE is now supported by minSdk --- .../conversations/ui/ConversationFragment.java | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java index 9ad7caed5..bf9aa93d3 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java @@ -135,6 +135,8 @@ import static eu.siacs.conversations.utils.PermissionUtils.allGranted; import static eu.siacs.conversations.utils.PermissionUtils.getFirstDenied; import static eu.siacs.conversations.utils.PermissionUtils.writeGranted; +import org.jetbrains.annotations.NotNull; + public class ConversationFragment extends XmppFragment implements EditMessage.KeyboardListener, MessageAdapter.OnContactPictureLongClicked, MessageAdapter.OnContactPictureClicked { @@ -1692,7 +1694,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke this.activity.xmppConnectionService.updateConversation(conversation); this.activity.onConversationsListItemUpdated(); refresh(); - getActivity().invalidateOptionsMenu(); + requireActivity().invalidateOptionsMenu(); } @@ -1702,9 +1704,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke switch (attachmentChoice) { case ATTACHMENT_CHOICE_CHOOSE_IMAGE: intent.setAction(Intent.ACTION_GET_CONTENT); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { - intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true); - } + intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true); intent.setType("image/*"); chooser = true; break; @@ -1722,9 +1722,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke case ATTACHMENT_CHOICE_CHOOSE_FILE: chooser = true; intent.setType("*/*"); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { - intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true); - } + intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true); intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setAction(Intent.ACTION_GET_CONTENT); break; @@ -1807,7 +1805,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke } private void showErrorMessage(final Message message) { - AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); + AlertDialog.Builder builder = new AlertDialog.Builder(requireActivity()); builder.setTitle(R.string.error_message); final String errorMessage = message.getErrorMessage(); final String[] errorMessageParts = errorMessage == null ? new String[0] : errorMessage.split("\\u001f"); @@ -1828,7 +1826,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke private void deleteFile(final Message message) { - AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); + AlertDialog.Builder builder = new AlertDialog.Builder(requireActivity()); builder.setNegativeButton(R.string.cancel, null); builder.setTitle(R.string.delete_file_dialog); builder.setMessage(R.string.delete_file_dialog_msg); @@ -1962,7 +1960,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke } @Override - public void onSaveInstanceState(Bundle outState) { + public void onSaveInstanceState(@NotNull Bundle outState) { super.onSaveInstanceState(outState); if (conversation != null) { outState.putString(STATE_CONVERSATION_UUID, conversation.getUuid());