Fix missing photos in gallery.

This commit is contained in:
Michelle Tang
2024-09-03 12:20:38 -07:00
committed by GitHub
parent ab7bdc3c03
commit 2c7668253e
3 changed files with 16 additions and 14 deletions

View File

@@ -118,13 +118,7 @@ public class AttachmentKeyboard extends FrameLayout implements InputAwareLayout.
}
public void onMediaChanged(@NonNull List<Media> media) {
if (StorageUtil.canReadAllFromMediaStore()) {
mediaList.setVisibility(VISIBLE);
mediaAdapter.setMedia(media, false);
permissionButton.setVisibility(GONE);
permissionText.setVisibility(GONE);
manageButton.setVisibility(GONE);
} else if (StorageUtil.canOnlyReadSelectedMediaStore() && media.isEmpty()) {
if (StorageUtil.canOnlyReadSelectedMediaStore() && media.isEmpty()) {
mediaList.setVisibility(GONE);
manageButton.setVisibility(GONE);
permissionText.setVisibility(VISIBLE);
@@ -142,6 +136,12 @@ public class AttachmentKeyboard extends FrameLayout implements InputAwareLayout.
manageButton.setVisibility(VISIBLE);
permissionText.setVisibility(GONE);
permissionButton.setVisibility(GONE);
} else if (StorageUtil.canReadAnyFromMediaStore()) {
mediaList.setVisibility(VISIBLE);
mediaAdapter.setMedia(media, false);
permissionButton.setVisibility(GONE);
permissionText.setVisibility(GONE);
manageButton.setVisibility(GONE);
} else {
mediaList.setVisibility(GONE);
manageButton.setVisibility(GONE);

View File

@@ -181,12 +181,7 @@ class MediaGalleryFragment : Fragment(R.layout.v2_media_gallery_fragment) {
}
galleryItemsWithSelection.observe(viewLifecycleOwner) {
if (StorageUtil.canReadAllFromMediaStore()) {
binding.mediaGalleryMissingPermissions.visible = false
binding.mediaGalleryManageContainer.visible = false
shouldEnableScrolling = true
galleryAdapter.submitList(it)
} else if (StorageUtil.canOnlyReadSelectedMediaStore() && it.isEmpty()) {
if (StorageUtil.canOnlyReadSelectedMediaStore() && it.isEmpty()) {
binding.mediaGalleryMissingPermissions.visible = true
binding.mediaGalleryManageContainer.visible = false
binding.mediaGalleryPermissionText.text = getString(R.string.MediaGalleryFragment__no_photos_found)
@@ -200,6 +195,11 @@ class MediaGalleryFragment : Fragment(R.layout.v2_media_gallery_fragment) {
binding.mediaGalleryManageButton.setOnClickListener { v -> showManageContextMenu(v, v.rootView as ViewGroup, false, false) }
shouldEnableScrolling = true
galleryAdapter.submitList(it)
} else if (StorageUtil.canReadAnyFromMediaStore()) {
binding.mediaGalleryMissingPermissions.visible = false
binding.mediaGalleryManageContainer.visible = false
shouldEnableScrolling = true
galleryAdapter.submitList(it)
} else {
binding.mediaGalleryMissingPermissions.visible = true
binding.mediaGalleryManageContainer.visible = false

View File

@@ -145,7 +145,9 @@ public class StorageUtil {
}
public static boolean canOnlyReadSelectedMediaStore() {
return Build.VERSION.SDK_INT >= 34 && Permissions.hasAll(AppDependencies.getApplication(), Manifest.permission.READ_MEDIA_VISUAL_USER_SELECTED);
return Build.VERSION.SDK_INT >= 34 &&
Permissions.hasAll(AppDependencies.getApplication(), Manifest.permission.READ_MEDIA_VISUAL_USER_SELECTED) &&
!Permissions.hasAny(AppDependencies.getApplication(), Manifest.permission.READ_MEDIA_IMAGES, Manifest.permission.READ_MEDIA_VIDEO);
}
public static boolean canReadAllFromMediaStore() {