diff --git a/src/org/kde/kdeconnect/Helpers/SMSHelper.java b/src/org/kde/kdeconnect/Helpers/SMSHelper.java index 19069028..f557f091 100644 --- a/src/org/kde/kdeconnect/Helpers/SMSHelper.java +++ b/src/org/kde/kdeconnect/Helpers/SMSHelper.java @@ -658,14 +658,17 @@ public class SMSHelper { attachments.add(new Attachment(partID, contentType, encodedThumbnail, fileName)); } else if (MimeType.isTypeVideo(contentType)) { String fileName = data.substring(data.lastIndexOf('/') + 1); - try (MediaMetadataRetriever retriever = new MediaMetadataRetriever()) { - retriever.setDataSource(context, ContentUris.withAppendedId(getMMSPartUri(), partID)); - Bitmap videoThumbnail = retriever.getFrameAtTime(); - String encodedThumbnail = SmsMmsUtils.bitMapToBase64( - Bitmap.createScaledBitmap(videoThumbnail, THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, true) - ); - attachments.add(new Attachment(partID, contentType, encodedThumbnail, fileName)); - }; + + // Can't use try-with-resources since MediaMetadataRetriever's close method was only added in API 29 + MediaMetadataRetriever retriever = new MediaMetadataRetriever(); + retriever.setDataSource(context, ContentUris.withAppendedId(getMMSPartUri(), partID)); + Bitmap videoThumbnail = retriever.getFrameAtTime(); + + String encodedThumbnail = SmsMmsUtils.bitMapToBase64( + Bitmap.createScaledBitmap(videoThumbnail, THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, true) + ); + + attachments.add(new Attachment(partID, contentType, encodedThumbnail, fileName)); } else if (MimeType.isTypeAudio(contentType)) { String fileName = data.substring(data.lastIndexOf('/') + 1); diff --git a/src/org/kde/kdeconnect/Plugins/SftpPlugin/SftpSettingsFragment.java b/src/org/kde/kdeconnect/Plugins/SftpPlugin/SftpSettingsFragment.java index 73e8482f..4b8570dd 100644 --- a/src/org/kde/kdeconnect/Plugins/SftpPlugin/SftpSettingsFragment.java +++ b/src/org/kde/kdeconnect/Plugins/SftpPlugin/SftpSettingsFragment.java @@ -89,10 +89,10 @@ public class SftpSettingsFragment public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { super.onCreatePreferences(savedInstanceState, rootKey); - int colorAccent; - try (TypedArray ta = requireContext().obtainStyledAttributes(new int[]{R.attr.colorAccent})) { - colorAccent = ta.getColor(0, 0); - } + // Can't use try-with-resources since TypedArray's close method was only added in API 31 + TypedArray ta = requireContext().obtainStyledAttributes(new int[]{R.attr.colorAccent}); + int colorAccent = ta.getColor(0, 0); + ta.recycle(); storageInfoList = getStorageInfoList(requireContext(), plugin);