fix #908, reduce image quality even more on some devices

This commit is contained in:
tibbi 2018-09-22 18:54:26 +02:00
parent 09c4a68fd4
commit e57ef1c7aa

View file

@ -11,6 +11,7 @@ import android.graphics.drawable.ColorDrawable
import android.graphics.drawable.PictureDrawable import android.graphics.drawable.PictureDrawable
import android.media.ExifInterface.* import android.media.ExifInterface.*
import android.net.Uri import android.net.Uri
import android.os.Build
import android.os.Bundle import android.os.Bundle
import android.os.Handler import android.os.Handler
import android.util.DisplayMetrics import android.util.DisplayMetrics
@ -47,11 +48,18 @@ import org.apache.sanselan.formats.jpeg.JpegImageParser
import pl.droidsonroids.gif.GifDrawable import pl.droidsonroids.gif.GifDrawable
import java.io.File import java.io.File
import java.io.FileOutputStream import java.io.FileOutputStream
import java.util.*
class PhotoFragment : ViewPagerFragment() { class PhotoFragment : ViewPagerFragment() {
private val DEFAULT_DOUBLE_TAP_ZOOM = 2f private val DEFAULT_DOUBLE_TAP_ZOOM = 2f
private val ZOOMABLE_VIEW_LOAD_DELAY = 300L 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 isFragmentVisible = false
private var isFullscreen = false private var isFullscreen = false
private var wasInit = false private var wasInit = false
@ -408,7 +416,9 @@ class PhotoFragment : ViewPagerFragment() {
private fun getMinTileDpi(): Int { private fun getMinTileDpi(): Int {
val metrics = resources.displayMetrics val metrics = resources.displayMetrics
val averageDpi = (metrics.xdpi + metrics.ydpi) / 2 val averageDpi = (metrics.xdpi + metrics.ydpi) / 2
val device = "${Build.BRAND} ${Build.MODEL}".toLowerCase()
return when { return when {
WEIRD_DEVICES.contains(device) -> 240
averageDpi > 400 -> 280 averageDpi > 400 -> 280
averageDpi > 300 -> 220 averageDpi > 300 -> 220
else -> 160 else -> 160