From cbed3f1ae1e72543f21bf96355a5d89d757ceaf8 Mon Sep 17 00:00:00 2001 From: Thomas Date: Sun, 5 Feb 2023 16:50:08 +0100 Subject: [PATCH] Fix media cannot be downloaded or shared (Android 10) --- .../app/fedilab/android/mastodon/activities/MediaActivity.java | 2 +- .../fedilab/android/mastodon/imageeditor/EditImageActivity.java | 2 +- .../app/fedilab/android/mastodon/ui/drawer/ComposeAdapter.java | 2 +- .../ui/fragment/settings/FragmentSettingsCategories.java | 2 +- .../main/java/app/fedilab/android/peertube/helper/Helper.java | 2 +- .../java/app/fedilab/android/ui/fragment/FragmentLoginMain.java | 2 +- src/fdroid/fastlane/metadata/android/en/changelogs/477.txt | 1 + 7 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/app/fedilab/android/mastodon/activities/MediaActivity.java b/app/src/main/java/app/fedilab/android/mastodon/activities/MediaActivity.java index 8ca29890..db986092 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/activities/MediaActivity.java +++ b/app/src/main/java/app/fedilab/android/mastodon/activities/MediaActivity.java @@ -250,7 +250,7 @@ public class MediaActivity extends BaseTransparentActivity implements OnDownload int position = binding.mediaViewpager.getCurrentItem(); Attachment attachment = attachments.get(position); if (Build.VERSION.SDK_INT >= 23) { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) { + if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.Q) { if (ContextCompat.checkSelfPermission(MediaActivity.this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED || ContextCompat.checkSelfPermission(MediaActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(MediaActivity.this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, Helper.EXTERNAL_STORAGE_REQUEST_CODE_MEDIA_SAVE); } else { diff --git a/app/src/main/java/app/fedilab/android/mastodon/imageeditor/EditImageActivity.java b/app/src/main/java/app/fedilab/android/mastodon/imageeditor/EditImageActivity.java index ea0bae52..eca3f114 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/imageeditor/EditImageActivity.java +++ b/app/src/main/java/app/fedilab/android/mastodon/imageeditor/EditImageActivity.java @@ -265,7 +265,7 @@ public class EditImageActivity extends BaseActivity implements OnPhotoEditorList .setClearViewsEnabled(true) .setTransparencyEnabled(true) .build(); - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) { + if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.Q) { if (ContextCompat.checkSelfPermission(EditImageActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(EditImageActivity.this, diff --git a/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/ComposeAdapter.java b/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/ComposeAdapter.java index d3076c01..c0e2c35a 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/ComposeAdapter.java +++ b/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/ComposeAdapter.java @@ -399,7 +399,7 @@ public class ComposeAdapter extends RecyclerView.Adapter { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) { + if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.Q) { permissionLauncher.launch(Manifest.permission.WRITE_EXTERNAL_STORAGE); } else { try { diff --git a/app/src/main/java/app/fedilab/android/peertube/helper/Helper.java b/app/src/main/java/app/fedilab/android/peertube/helper/Helper.java index 43b6e7e0..a1052253 100644 --- a/app/src/main/java/app/fedilab/android/peertube/helper/Helper.java +++ b/app/src/main/java/app/fedilab/android/peertube/helper/Helper.java @@ -821,7 +821,7 @@ public class Helper { public static void requestPermissionAndProceed(Activity activity, PermissionGranted permissionGranted) { if (Build.VERSION.SDK_INT >= 23) { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) { + if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.Q) { if (ContextCompat.checkSelfPermission(activity, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED || ContextCompat.checkSelfPermission(activity, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(activity, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, app.fedilab.android.mastodon.helper.Helper.EXTERNAL_STORAGE_REQUEST_CODE_MEDIA_SAVE); } else { diff --git a/app/src/main/java/app/fedilab/android/ui/fragment/FragmentLoginMain.java b/app/src/main/java/app/fedilab/android/ui/fragment/FragmentLoginMain.java index 32f542a4..8ef6a8f3 100644 --- a/app/src/main/java/app/fedilab/android/ui/fragment/FragmentLoginMain.java +++ b/app/src/main/java/app/fedilab/android/ui/fragment/FragmentLoginMain.java @@ -237,7 +237,7 @@ public class FragmentLoginMain extends Fragment { } }); } else if (itemId == R.id.action_import_data) { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) { + if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.Q) { permissionLauncher.launch(Manifest.permission.WRITE_EXTERNAL_STORAGE); } else { proceed(); diff --git a/src/fdroid/fastlane/metadata/android/en/changelogs/477.txt b/src/fdroid/fastlane/metadata/android/en/changelogs/477.txt index ee3ae0d2..28949e34 100644 --- a/src/fdroid/fastlane/metadata/android/en/changelogs/477.txt +++ b/src/fdroid/fastlane/metadata/android/en/changelogs/477.txt @@ -12,4 +12,5 @@ Fixed: - Fix a crash when replying - Fix button size not changed - Forward tags in replies +- Media cannot be downloaded or shared with Android 10 - Some crashes