Skip to content

Commit

Permalink
fix: reset option in image filter dialog doesn't reset all values
Browse files Browse the repository at this point in the history
  • Loading branch information
Bnyro committed Feb 6, 2024
1 parent ed2d91e commit 5b6d469
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/java/com/bnyro/wallpaper/util/BitmapProcessor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 5b6d469

Please sign in to comment.