From 5b6d469563bdef2d3d2d061c6e5a3cbddaa00047 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Tue, 6 Feb 2024 13:18:16 +0100 Subject: [PATCH] fix: reset option in image filter dialog doesn't reset all values --- .../ui/components/dialogs/ImageFilterDialog.kt | 10 +++++++--- .../java/com/bnyro/wallpaper/util/BitmapProcessor.kt | 8 ++++---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/com/bnyro/wallpaper/ui/components/dialogs/ImageFilterDialog.kt b/app/src/main/java/com/bnyro/wallpaper/ui/components/dialogs/ImageFilterDialog.kt index 1e46fda5..2c65e929 100644 --- a/app/src/main/java/com/bnyro/wallpaper/ui/components/dialogs/ImageFilterDialog.kt +++ b/app/src/main/java/com/bnyro/wallpaper/ui/components/dialogs/ImageFilterDialog.kt @@ -25,9 +25,13 @@ fun ImageFilterDialog( DialogButton( stringResource(R.string.reset) ) { - Preferences.edit { putFloat(Preferences.blurKey, 1f) } - Preferences.edit { putBoolean(Preferences.grayscaleKey, false) } - Preferences.edit { putString(Preferences.resizeMethodKey, ResizeMethod.NONE.name) } + Preferences.edit { + putFloat(Preferences.blurKey, 1f) + putFloat(Preferences.contrastKey, 1f) + putString(Preferences.resizeMethodKey, ResizeMethod.CROP.name) + putBoolean(Preferences.grayscaleKey, false) + putBoolean(Preferences.invertBitmapBySystemThemeKey, false) + } onChange.invoke() onDismissRequest.invoke() } diff --git a/app/src/main/java/com/bnyro/wallpaper/util/BitmapProcessor.kt b/app/src/main/java/com/bnyro/wallpaper/util/BitmapProcessor.kt index f915cd46..2135d9cf 100644 --- a/app/src/main/java/com/bnyro/wallpaper/util/BitmapProcessor.kt +++ b/app/src/main/java/com/bnyro/wallpaper/util/BitmapProcessor.kt @@ -25,11 +25,11 @@ object BitmapProcessor { val contrast = Preferences.getFloat(Preferences.contrastKey, 1f) val grayScale = Preferences.getBoolean(Preferences.grayscaleKey, false) - var bitmap = bitmap.blur(blurRadius) - bitmap = changeBitmapContrast(bitmap, contrast) - if (grayScale) bitmap = bitmap.grayScale() + var bm = bitmap.blur(blurRadius) + bm = changeBitmapContrast(bm, contrast) + if (grayScale) bm = bm.grayScale() - return bitmap + return bm } private fun changeBitmapContrast(bitmap: Bitmap, contrast: Float): Bitmap {