2
0
mirror of https://github.com/KDE/kdeconnect-android synced 2025-08-30 05:37:43 +00:00

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

Those require higher API levels. Added comment.

This reverts commit 84e78e4bdafb4a5d7b7fd4a4f36fb965e5ed4b45.
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));
} 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);

View File

@ -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);