From e57ef1c7aafc013735f04ee4e9f2b3dc128462e5 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 22 Sep 2018 18:54:26 +0200 Subject: [PATCH] fix #908, reduce image quality even more on some devices --- .../gallery/fragments/PhotoFragment.kt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt index e8e57efb3..19097ef23 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt @@ -11,6 +11,7 @@ import android.graphics.drawable.ColorDrawable import android.graphics.drawable.PictureDrawable import android.media.ExifInterface.* import android.net.Uri +import android.os.Build import android.os.Bundle import android.os.Handler import android.util.DisplayMetrics @@ -47,11 +48,18 @@ import org.apache.sanselan.formats.jpeg.JpegImageParser import pl.droidsonroids.gif.GifDrawable import java.io.File import java.io.FileOutputStream +import java.util.* class PhotoFragment : ViewPagerFragment() { private val DEFAULT_DOUBLE_TAP_ZOOM = 2f private val ZOOMABLE_VIEW_LOAD_DELAY = 300L + // devices with good displays, but the rest of the hardware not good enough for them + private val WEIRD_DEVICES = arrayListOf( + "motorola xt1685", + "google nexus 5x" + ) + private var isFragmentVisible = false private var isFullscreen = false private var wasInit = false @@ -408,7 +416,9 @@ class PhotoFragment : ViewPagerFragment() { private fun getMinTileDpi(): Int { val metrics = resources.displayMetrics val averageDpi = (metrics.xdpi + metrics.ydpi) / 2 + val device = "${Build.BRAND} ${Build.MODEL}".toLowerCase() return when { + WEIRD_DEVICES.contains(device) -> 240 averageDpi > 400 -> 280 averageDpi > 300 -> 220 else -> 160