From bb68512502d91d9e765c29cddafcf020c9b3d056 Mon Sep 17 00:00:00 2001 From: Thomas Date: Thu, 12 Jan 2023 17:11:27 +0100 Subject: [PATCH] Fix media cannot be downloaded --- .../java/app/fedilab/android/helper/MediaHelper.java | 11 ++++++++--- .../fastlane/metadata/android/en/changelogs/464.txt | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/app/fedilab/android/helper/MediaHelper.java b/app/src/main/java/app/fedilab/android/helper/MediaHelper.java index b6f65f7c..1a60e74a 100644 --- a/app/src/main/java/app/fedilab/android/helper/MediaHelper.java +++ b/app/src/main/java/app/fedilab/android/helper/MediaHelper.java @@ -100,7 +100,10 @@ public class MediaHelper { } try { String mime = getMimeType(url); - final String fileName = URLUtil.guessFileName(url, null, null); + String fileName = URLUtil.guessFileName(url, null, null); + if (fileName.endsWith(".bin")) { + fileName = fileName.replace(".bin", ".mp4"); + } request.allowScanningByMediaScanner(); if (mime.toLowerCase().startsWith("video")) { request.setDestinationInExternalPublicDir(Environment.DIRECTORY_MOVIES, context.getString(R.string.app_name) + "/" + fileName); @@ -134,9 +137,11 @@ public class MediaHelper { .into(new CustomTarget() { @Override public void onResourceReady(@NotNull File file, Transition transition) { - final String fileName = URLUtil.guessFileName(url, null, null); - + String fileName = URLUtil.guessFileName(url, null, null); + if (fileName.endsWith(".bin")) { + fileName = fileName.replace(".bin", ".jpg"); + } File path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES); File targeted_folder = new File(path, context.getString(R.string.app_name)); if (!targeted_folder.exists()) { diff --git a/src/fdroid/fastlane/metadata/android/en/changelogs/464.txt b/src/fdroid/fastlane/metadata/android/en/changelogs/464.txt index 38f2a668..38199488 100644 --- a/src/fdroid/fastlane/metadata/android/en/changelogs/464.txt +++ b/src/fdroid/fastlane/metadata/android/en/changelogs/464.txt @@ -7,4 +7,5 @@ Changed: Fixed: - Fix a crash with Art timelines +- Friendica: media cannot be downloaded/shared - Fix a crash with pinned timelines \ No newline at end of file