From f3eb312e5782b70428e1cbf65a3d3ac03f61ebca Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 3 May 2022 10:38:36 +0200 Subject: [PATCH] fix #1113, #2309, fixing some wallpaper setting related glitches --- .../gallery/pro/activities/SetWallpaperActivity.kt | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SetWallpaperActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SetWallpaperActivity.kt index 6273a193e..248fcf6ad 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SetWallpaperActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SetWallpaperActivity.kt @@ -34,6 +34,7 @@ class SetWallpaperActivity : SimpleActivity(), CropImageView.OnCropImageComplete override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_set_wallpaper) + setupBottomActions() if (checkAppSideloading()) { return @@ -48,7 +49,6 @@ class SetWallpaperActivity : SimpleActivity(), CropImageView.OnCropImageComplete } handleImage(intent) - setupBottomActions() } override fun onCreateOptionsMenu(menu: Menu): Boolean { @@ -93,10 +93,16 @@ class SetWallpaperActivity : SimpleActivity(), CropImageView.OnCropImageComplete } private fun setupAspectRatio() { + var widthToUse = wallpaperManager.desiredMinimumWidth + val heightToUse = wallpaperManager.desiredMinimumHeight + if (widthToUse == heightToUse) { + widthToUse /= 2 + } + when (aspectRatio) { - RATIO_LANDSCAPE -> crop_image_view.setAspectRatio(wallpaperManager.desiredMinimumWidth, wallpaperManager.desiredMinimumHeight / 2) - RATIO_PORTRAIT -> crop_image_view.setAspectRatio(wallpaperManager.desiredMinimumWidth / 2, wallpaperManager.desiredMinimumHeight) - else -> crop_image_view.setAspectRatio(wallpaperManager.desiredMinimumWidth, wallpaperManager.desiredMinimumWidth) + RATIO_PORTRAIT -> crop_image_view.setAspectRatio(heightToUse, widthToUse) + RATIO_LANDSCAPE -> crop_image_view.setAspectRatio(widthToUse, heightToUse) + else -> crop_image_view.setAspectRatio(widthToUse, widthToUse) } }