From 28299acb90b63cc643fe130e3e5203c8d017466c Mon Sep 17 00:00:00 2001 From: Snaggly Date: Wed, 22 Feb 2023 00:14:26 +0100 Subject: [PATCH] Update DensityUtil.kt --- .../ksw_toolkit/util/adb/DensityUtil.kt | 24 +++++-------------- 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/app/src/main/java/com/snaggly/ksw_toolkit/util/adb/DensityUtil.kt b/app/src/main/java/com/snaggly/ksw_toolkit/util/adb/DensityUtil.kt index f9ab48e..6f73eda 100644 --- a/app/src/main/java/com/snaggly/ksw_toolkit/util/adb/DensityUtil.kt +++ b/app/src/main/java/com/snaggly/ksw_toolkit/util/adb/DensityUtil.kt @@ -7,11 +7,7 @@ import com.snaggly.ksw_toolkit.util.commander.AppStarter import kotlin.math.min object DensityUtil { - private var tabletModeTurnedOn = false - fun turnOnTabletMode(context: Context) { - if (tabletModeTurnedOn) - return val displayMetrics = context.resources.displayMetrics val tabletDpi = Integer.max( (min( @@ -19,28 +15,20 @@ object DensityUtil { displayMetrics.heightPixels ) * 160) / Integer.max(600, 320), 120 ) - tabletModeTurnedOn = try { + try { AdbManager.sendCommand("wm density $tabletDpi", context) - true - } catch (e: Exception) { - false - } + } catch (_: Exception) { } } fun turnOffTabletMode(context: Context) { - if (!tabletModeTurnedOn) - return - val dpi = { + val dpi : Int = if (context.resources.displayMetrics.heightPixels > 480) 240 else 160 - } - tabletModeTurnedOn = try { + + try { AdbManager.sendCommand("wm density $dpi", context) - false - } catch (e: Exception) { - true - } + } catch (_: Exception) { } } } \ No newline at end of file