From c89104932384bce297ef903f5024266ff6a36c77 Mon Sep 17 00:00:00 2001 From: EndureBlaze Date: Sun, 20 Mar 2022 16:57:17 +0800 Subject: [PATCH] :sparkles: Change the format of the uploaded image to PNG --- app/src/main/java/ren/imyan/app_tracker/net/AppTrackerRepo.kt | 2 +- app/src/main/java/ren/imyan/app_tracker/ui/MainViewModel.kt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/ren/imyan/app_tracker/net/AppTrackerRepo.kt b/app/src/main/java/ren/imyan/app_tracker/net/AppTrackerRepo.kt index 00a86e3..8e7ed4f 100644 --- a/app/src/main/java/ren/imyan/app_tracker/net/AppTrackerRepo.kt +++ b/app/src/main/java/ren/imyan/app_tracker/net/AppTrackerRepo.kt @@ -34,7 +34,7 @@ class AppTrackerRepo { suspend fun submitAppIcon(packageName: String, icon: File) = flow { - val iconFile = icon.asRequestBody("image/jpeg".toMediaTypeOrNull()); + val iconFile = icon.asRequestBody("image/png".toMediaTypeOrNull()); emit(api.submitAppIcon(packageName, iconFile)) }.flowOn(Dispatchers.IO) } \ No newline at end of file diff --git a/app/src/main/java/ren/imyan/app_tracker/ui/MainViewModel.kt b/app/src/main/java/ren/imyan/app_tracker/ui/MainViewModel.kt index 2b94a66..388271e 100644 --- a/app/src/main/java/ren/imyan/app_tracker/ui/MainViewModel.kt +++ b/app/src/main/java/ren/imyan/app_tracker/ui/MainViewModel.kt @@ -199,7 +199,7 @@ class MainViewModel : BaseViewModel() { iconList.toList().asFlow().catch { err -> err.printStackTrace() }.onEach { - val iconFile = it.second.setBackground().toSize(288f, 288f).toFile("${it.first}.jpg") + val iconFile = it.second.setBackground().toSize(288f, 288f).toFile("${it.first}.png", format = Bitmap.CompressFormat.PNG) if (iconFile != null) { repo.submitAppIcon(it.first, iconFile).catch { err -> err.printStackTrace() @@ -240,7 +240,7 @@ class MainViewModel : BaseViewModel() { err.printStackTrace() }.onEach { icons -> val iconFile = icons.second.setBackground().toSize(288f, 288f) - .toFile("${icons.first}.jpg") + .toFile("${icons.first}.png", format = Bitmap.CompressFormat.PNG) if (iconFile != null) { repo.submitAppIcon(icons.first, iconFile).catch { err -> err.printStackTrace()