2
0
mirror of https://github.com/KDE/kdeconnect-android synced 2025-08-30 13:47:41 +00:00

Revert "Make linter happy: use try-with-resources"

Those require higher API levels. Added comment.

This reverts commit 84e78e4bda.
This commit is contained in:
Albert Vaca Cintora
2023-03-17 19:30:06 +01:00
parent ff3239f876
commit 772eae7a4c
2 changed files with 15 additions and 12 deletions

View File

@@ -658,14 +658,17 @@ public class SMSHelper {
attachments.add(new Attachment(partID, contentType, encodedThumbnail, fileName)); attachments.add(new Attachment(partID, contentType, encodedThumbnail, fileName));
} else if (MimeType.isTypeVideo(contentType)) { } else if (MimeType.isTypeVideo(contentType)) {
String fileName = data.substring(data.lastIndexOf('/') + 1); String fileName = data.substring(data.lastIndexOf('/') + 1);
try (MediaMetadataRetriever retriever = new MediaMetadataRetriever()) {
retriever.setDataSource(context, ContentUris.withAppendedId(getMMSPartUri(), partID)); // Can't use try-with-resources since MediaMetadataRetriever's close method was only added in API 29
Bitmap videoThumbnail = retriever.getFrameAtTime(); MediaMetadataRetriever retriever = new MediaMetadataRetriever();
String encodedThumbnail = SmsMmsUtils.bitMapToBase64( retriever.setDataSource(context, ContentUris.withAppendedId(getMMSPartUri(), partID));
Bitmap.createScaledBitmap(videoThumbnail, THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, true) Bitmap videoThumbnail = retriever.getFrameAtTime();
);
attachments.add(new Attachment(partID, contentType, encodedThumbnail, fileName)); 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)) { } else if (MimeType.isTypeAudio(contentType)) {
String fileName = data.substring(data.lastIndexOf('/') + 1); String fileName = data.substring(data.lastIndexOf('/') + 1);

View File

@@ -89,10 +89,10 @@ public class SftpSettingsFragment
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
super.onCreatePreferences(savedInstanceState, rootKey); super.onCreatePreferences(savedInstanceState, rootKey);
int colorAccent; // Can't use try-with-resources since TypedArray's close method was only added in API 31
try (TypedArray ta = requireContext().obtainStyledAttributes(new int[]{R.attr.colorAccent})) { TypedArray ta = requireContext().obtainStyledAttributes(new int[]{R.attr.colorAccent});
colorAccent = ta.getColor(0, 0); int colorAccent = ta.getColor(0, 0);
} ta.recycle();
storageInfoList = getStorageInfoList(requireContext(), plugin); storageInfoList = getStorageInfoList(requireContext(), plugin);