From b8d4842fd5c31aae6161dd8c2eac1af66b14c9b4 Mon Sep 17 00:00:00 2001 From: Yuichiro Kinoshita Date: Mon, 26 Jun 2023 12:32:19 +0900 Subject: [PATCH] fix --- app/proguard-rules.pro | 15 ++++++++++++++- .../image/ImageCacheRepositoryImpl.kt | 6 ++++++ .../reaction/choices/EmojiListItemsAdapter.kt | 1 + .../emoji/cache/CacheCustomEmojiImageWorker.kt | 9 +++++++-- 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index 009914c849..e431da56cf 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -94,4 +94,17 @@ # databinding -dontwarn androidx.databinding.** -keep class androidx.databinding.** { *; } --keep class * extends androidx.databinding.DataBinderMapper \ No newline at end of file +-keep class * extends androidx.databinding.DataBinderMapper + +# glide +-keep public class * implements com.bumptech.glide.module.GlideModule +-keep class * extends com.bumptech.glide.module.AppGlideModule { + (...); +} +-keep public enum com.bumptech.glide.load.ImageHeaderParser$** { + **[] $VALUES; + public *; +} +-keep class com.bumptech.glide.load.data.ParcelFileDescriptorRewinder$InternalRewinder { + *** rewind(); +} diff --git a/modules/data/src/main/java/net/pantasystem/milktea/data/infrastructure/image/ImageCacheRepositoryImpl.kt b/modules/data/src/main/java/net/pantasystem/milktea/data/infrastructure/image/ImageCacheRepositoryImpl.kt index 17ae88484e..18424e3140 100644 --- a/modules/data/src/main/java/net/pantasystem/milktea/data/infrastructure/image/ImageCacheRepositoryImpl.kt +++ b/modules/data/src/main/java/net/pantasystem/milktea/data/infrastructure/image/ImageCacheRepositoryImpl.kt @@ -1,7 +1,9 @@ package net.pantasystem.milktea.data.infrastructure.image import android.content.Context +import android.content.Intent import android.graphics.BitmapFactory +import android.net.Uri import dagger.hilt.android.qualifiers.ApplicationContext import io.objectbox.BoxStore import io.objectbox.kotlin.awaitCallInTx @@ -58,6 +60,10 @@ class ImageCacheRepositoryImpl @Inject constructor( } }.resolve(fileName) + context.contentResolver.takePersistableUriPermission( + Uri.fromFile(file), + Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION + ) downloadAndSaveFile(url, file) val cache = ImageCache( diff --git a/modules/features/note/src/main/java/net/pantasystem/milktea/note/reaction/choices/EmojiListItemsAdapter.kt b/modules/features/note/src/main/java/net/pantasystem/milktea/note/reaction/choices/EmojiListItemsAdapter.kt index 5b8d44d06a..d4a2aa28c3 100644 --- a/modules/features/note/src/main/java/net/pantasystem/milktea/note/reaction/choices/EmojiListItemsAdapter.kt +++ b/modules/features/note/src/main/java/net/pantasystem/milktea/note/reaction/choices/EmojiListItemsAdapter.kt @@ -85,6 +85,7 @@ class EmojiListItemsAdapter( binding.root.context ) ) + .into(binding.reactionImagePreview) binding.reactionStringPreview.setMemoVisibility(View.GONE) diff --git a/modules/worker/src/main/java/net/pantasystem/milktea/worker/emoji/cache/CacheCustomEmojiImageWorker.kt b/modules/worker/src/main/java/net/pantasystem/milktea/worker/emoji/cache/CacheCustomEmojiImageWorker.kt index 5d0221f591..5767e4c6db 100644 --- a/modules/worker/src/main/java/net/pantasystem/milktea/worker/emoji/cache/CacheCustomEmojiImageWorker.kt +++ b/modules/worker/src/main/java/net/pantasystem/milktea/worker/emoji/cache/CacheCustomEmojiImageWorker.kt @@ -2,7 +2,12 @@ package net.pantasystem.milktea.worker.emoji.cache import android.content.Context import androidx.hilt.work.HiltWorker -import androidx.work.* +import androidx.work.Constraints +import androidx.work.CoroutineWorker +import androidx.work.NetworkType +import androidx.work.PeriodicWorkRequest +import androidx.work.PeriodicWorkRequestBuilder +import androidx.work.WorkerParameters import dagger.assisted.Assisted import dagger.assisted.AssistedInject import kotlinx.coroutines.coroutineScope @@ -31,7 +36,7 @@ class CacheCustomEmojiImageWorker @AssistedInject constructor( .setRequiredNetworkType(NetworkType.UNMETERED) // Wi-Fi (or Ethernet etc) required .build() - return PeriodicWorkRequestBuilder(3, TimeUnit.DAYS) + return PeriodicWorkRequestBuilder(1, TimeUnit.DAYS) .setConstraints(constraints) .build() }