From 3dc67f31188637285d73d991e51c5b51daf8d2f4 Mon Sep 17 00:00:00 2001 From: Corbin Champion Date: Thu, 7 Oct 2021 22:15:43 -0700 Subject: [PATCH 1/4] Correctly scale to full screen and first step towards custom scaling (#1442) Correctly scale to full screen and first step towards custom scaling --- app/build.gradle | 5 ++ app/src/main/java/tech/ula/MainActivity.kt | 2 +- .../java/tech/ula/utils/DeviceDimensions.kt | 69 ++++++++++++------- app/src/main/res/values-de/strings.xml | 3 + app/src/main/res/values/strings.xml | 3 + app/src/main/res/xml/preferences.xml | 13 ++++ .../tech/ula/utils/DeviceDimensionsTest.kt | 15 +++- 7 files changed, 80 insertions(+), 30 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 3cf81749f..84afd1e55 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -32,6 +32,11 @@ android { vectorDrawables.useSupportLibrary = true buildConfigField 'boolean', 'ENABLE_PLAY_SERVICES', 'true' + //these are used to help determine the resolution + buildConfigField 'boolean', 'FORCE_PORTRAIT_GEOMETRY', 'true' + buildConfigField 'int', "MAX_DIMENSION", "1280" + buildConfigField 'int', "MIN_DIMENSION", "360" + // Ignore Sentry packages that cause lint failure lintOptions { lintConfig file("$projectDir/src/main/resources/lint.xml") diff --git a/app/src/main/java/tech/ula/MainActivity.kt b/app/src/main/java/tech/ula/MainActivity.kt index ed225749d..ee2daa780 100644 --- a/app/src/main/java/tech/ula/MainActivity.kt +++ b/app/src/main/java/tech/ula/MainActivity.kt @@ -356,7 +356,7 @@ class MainActivity : AppCompatActivity(), SessionListFragment.SessionSelection, val windowManager = applicationContext.getSystemService(Context.WINDOW_SERVICE) as WindowManager val orientation = applicationContext.resources.configuration.orientation - deviceDimensions.saveDeviceDimensions(windowManager, DisplayMetrics(), orientation) + deviceDimensions.saveDeviceDimensions(windowManager, DisplayMetrics(), orientation, defaultSharedPreferences) session.geometry = deviceDimensions.getScreenResolution() } diff --git a/app/src/main/java/tech/ula/utils/DeviceDimensions.kt b/app/src/main/java/tech/ula/utils/DeviceDimensions.kt index fa3860327..acf5253b9 100644 --- a/app/src/main/java/tech/ula/utils/DeviceDimensions.kt +++ b/app/src/main/java/tech/ula/utils/DeviceDimensions.kt @@ -1,42 +1,59 @@ package tech.ula.utils -import android.content.res.Configuration -import android.graphics.Point +import android.content.SharedPreferences +import android.os.Build import android.util.DisplayMetrics import android.view.WindowManager +import tech.ula.BuildConfig class DeviceDimensions { - private var height = 720 - private var width = 1480 + private var height = 720f + private var width = 1480f + private var scaling = 1f - fun saveDeviceDimensions(windowManager: WindowManager, displayMetrics: DisplayMetrics, orientation: Int) { - val navBarSize = getNavigationBarSize(windowManager) + fun saveDeviceDimensions(windowManager: WindowManager, displayMetrics: DisplayMetrics, orientation: Int, sharedPreferences: SharedPreferences) { + var scalingMin = 1f + var scalingMax = 1f windowManager.defaultDisplay.getRealMetrics(displayMetrics) - height = displayMetrics.heightPixels - width = displayMetrics.widthPixels - windowManager.defaultDisplay.getMetrics(displayMetrics) + height = displayMetrics.heightPixels.toFloat() + width = displayMetrics.widthPixels.toFloat() - when (orientation) { - Configuration.ORIENTATION_PORTRAIT -> if (navBarSize.y > 0) height += navBarSize.y - Configuration.ORIENTATION_LANDSCAPE -> if (navBarSize.x > 0) width += navBarSize.x - else -> return + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { + val displayCutout = windowManager.defaultDisplay.cutout + if (displayCutout != null) { + height -= displayCutout.safeInsetBottom + displayCutout.safeInsetTop + width -= displayCutout.safeInsetLeft + displayCutout.safeInsetRight + } } - } - fun getScreenResolution(): String { - return when (height > width) { - true -> "${height}x$width" - false -> "${width}x$height" + if (sharedPreferences.getBoolean("pref_custom_scaling_enabled", false)) { + scaling = sharedPreferences.getString("pref_scaling", "1.0")!!.toFloat() + } else { + if (height > width) { + scalingMax = height / BuildConfig.MAX_DIMENSION + scalingMin = width / BuildConfig.MIN_DIMENSION + } else { + scalingMax = width / BuildConfig.MAX_DIMENSION + scalingMin = height / BuildConfig.MIN_DIMENSION + } + if (scalingMin < 1f) + scalingMin = 1f + if (scalingMax < 1f) + scalingMax = 1f + if (scalingMax < scalingMin) + scaling = scalingMax + else + scaling = scalingMin } - } - private fun getNavigationBarSize(windowManager: WindowManager): Point { - val display = windowManager.defaultDisplay - val appSize = Point() - val screenSize = Point() - display.getSize(appSize) - display.getRealSize(screenSize) + height = height / scaling + width = width / scaling + } - return Point(screenSize.x - appSize.x, screenSize.y - appSize.y) + fun getScreenResolution(): String { + return when ((height > width) && BuildConfig.FORCE_PORTRAIT_GEOMETRY) { + true -> "${height.toInt()}x${width.toInt()}" + false -> "${width.toInt()}x${height.toInt()}" + } } } \ No newline at end of file diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 72f79e296..386945e9c 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -281,5 +281,8 @@ Autostart Einstellungen löschen Keine App mehr automatisch starten, bis wieder aktiviert wird. Autostart aktivieren + Benuterdefinierten Skalierfaktor verwenden + Erlaubt das Einstellen eines benutzerdefinierten Skalierfaktors, um die Display Auflösung der VNC Sitzung zu verringern. + Skalierfaktor festlegen diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 8ec01a8f6..8465d9214 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -149,6 +149,9 @@ Select the page you would like to open the app with. Clear Auto Start Settings Stops any app from auto starting until enabled again. + Use Custom Graphical Scaling Factor + Allows specifying a custom scaling factor to decrease the resolution of the VNC session. + Set Custom Scaling Factor PRoot Preferences PRoot Debugging Logs Enabled Only necessary if having problems with the app. Log file stored at\n/mnt/sdcard/PRoot_Debug_Log diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index 064a91112..e63e6dfd4 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -18,6 +18,19 @@ android:title="@string/pref_clear_auto_start_title" android:summary="@string/pref_clear_auto_start_summary" app:iconSpaceReserved="false"/> + + Date: Fri, 8 Oct 2021 15:53:33 -0700 Subject: [PATCH 2/4] Update compile sdk version to 11 (#1443) * Update target SDK and library version * Fix setgroups on older devices --- app/build.gradle | 14 +++++++------- app/src/main/AndroidManifest.xml | 15 +++++++++++++++ .../main/java/tech/ula/utils/BillingManager.kt | 6 ++++-- build.gradle | 4 ++-- 4 files changed, 28 insertions(+), 11 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 84afd1e55..e11f65759 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -13,7 +13,7 @@ apply plugin: 'jacoco' apply plugin: 'de.undercouch.download' android { - compileSdkVersion 29 + compileSdkVersion 30 defaultConfig { // Version code is generated as time since June 1, 2019. These allows for constantly @@ -22,9 +22,9 @@ android { applicationId "tech.ula" minSdkVersion 21 - targetSdkVersion 29 + targetSdkVersion 30 versionCode vcode - versionName "2.8.2" + versionName "2.8.3" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunnerArguments clearPackageData: 'true' @@ -205,7 +205,7 @@ ext.architectures = ["armeabi-v7a", "arm64-v8a", "x86", "x86_64"] ext.libDir = "$project.projectDir/src/main/jniLibs" task downloadAssets(type: Download) { - def assetVersion = "v1.2.6" + def assetVersion = "v1.2.7" def baseUrl = "https://github.com/CypherpunkArmory/UserLAnd-Assets-Support/releases/download/$assetVersion" for (arch in architectures) { src "$baseUrl/$arch-assets.zip" @@ -245,12 +245,12 @@ preBuild.dependsOn checkIfAssetsMissing dependencies { def moshi_version = '1.8.0' - def okhttp_version = '3.13.1' + def okhttp_version = '3.14.7' def sentry_version = '1.7.22' def slf4j_version = '1.7.26' def kotlinx_coroutines_version = '1.0.0' - def kotlin_jdk_version = '1.3.31' + def kotlin_jdk_version = '1.3.61' // Androidx versions def room_version = '2.1.0-beta01' @@ -258,7 +258,7 @@ dependencies { def support_library_version = '1.1.0-alpha06' def preference_version = '1.1.0-alpha05' def ktx_version = '1.0.2' - def billing_version = '2.2.1' + def billing_version = '3.0.3' implementation project(':terminal-term') diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index a1e404b73..e9ee802a3 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -13,6 +13,21 @@ + + + + + + + + + + + + + + + Date: Sun, 10 Apr 2022 09:47:41 -0700 Subject: [PATCH 3/4] Update README.md --- README.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/README.md b/README.md index c7ec0b792..a32711f36 100644 --- a/README.md +++ b/README.md @@ -8,9 +8,6 @@ Features: * Install and uninstall like a regular app. * No root required. -[Get it on F-Droid](https://f-droid.org/packages/tech.ula) [Get it on Google Play](https://play.google.com/store/apps/details?id=tech.ula) From 17512ef4d8d50aeaeabb63623910cff790761bbf Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 7 Jun 2022 21:36:24 +0000 Subject: [PATCH 4/4] Bump jmespath from 1.4.0 to 1.6.1 Bumps [jmespath](https://github.com/trevorrowe/jmespath.rb) from 1.4.0 to 1.6.1. - [Release notes](https://github.com/trevorrowe/jmespath.rb/releases) - [Changelog](https://github.com/jmespath/jmespath.rb/blob/main/CHANGELOG.md) - [Commits](https://github.com/trevorrowe/jmespath.rb/compare/v1.4.0...v1.6.1) --- updated-dependencies: - dependency-name: jmespath dependency-type: indirect ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 3f1568caf..908f58845 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -123,7 +123,7 @@ GEM httpclient (2.8.3) i18n (1.8.10) concurrent-ruby (~> 1.0) - jmespath (1.4.0) + jmespath (1.6.1) json (2.3.0) jwt (2.1.0) memoist (0.16.2)