Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

android: show local files on older devices #1122

Merged
merged 1 commit into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
android:supportsRtl="true"
android:theme="@style/Theme.Memories"
android:usesCleartextTraffic="true"
android:requestLegacyExternalStorage="true"
tools:targetApi="31">
<activity
android:name=".MainActivity"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import android.graphics.ImageDecoder
import android.os.Build
import android.provider.MediaStore
import androidx.media3.common.util.UnstableApi
import gallery.memories.mapper.SystemImage
import java.io.ByteArrayOutputStream

@UnstableApi class ImageService(private val mCtx: Context, private val query: TimelineQuery) {
Expand All @@ -19,11 +20,15 @@ import java.io.ByteArrayOutputStream
fun getPreview(id: Long): ByteArray {
val bitmap =
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
val sysImgs = SystemImage.getByIds(mCtx, listOf(id))
if (sysImgs.isEmpty()) {
throw Exception("Image not found")
}

val uri = sysImgs[0].uri

mCtx.contentResolver.loadThumbnail(
ContentUris.withAppendedId(
MediaStore.Files.getContentUri(MediaStore.VOLUME_EXTERNAL),
id
),
uri,
android.util.Size(2048, 2048),
null
)
Expand Down