From 593606ea0eada1b8dfdc90b03ceace4c9da0949b Mon Sep 17 00:00:00 2001 From: tibbi Date: Thu, 4 Nov 2021 16:34:28 +0100 Subject: [PATCH] lets use oval colorpicker instead of square ones --- .../commons/activities/CustomizationActivity.kt | 13 ++++++------- .../commons/dialogs/ColorPickerDialog.kt | 11 +++++------ .../commons/extensions/ImageView.kt | 11 +++++------ commons/src/main/res/layout/dialog_color_picker.xml | 8 ++++---- 4 files changed, 20 insertions(+), 23 deletions(-) diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/activities/CustomizationActivity.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/activities/CustomizationActivity.kt index a42a54e7e..00db4c1df 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/activities/CustomizationActivity.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/activities/CustomizationActivity.kt @@ -400,13 +400,12 @@ class CustomizationActivity : BaseSimpleActivity() { } private fun setupColorsPickers() { - val cornerRadius = getCornerRadius() - customization_text_color.setFillWithStroke(curTextColor, curBackgroundColor, cornerRadius) - customization_primary_color.setFillWithStroke(curPrimaryColor, curBackgroundColor, cornerRadius) - customization_accent_color.setFillWithStroke(curAccentColor, curBackgroundColor, cornerRadius) - customization_background_color.setFillWithStroke(curBackgroundColor, curBackgroundColor, cornerRadius) - customization_app_icon_color.setFillWithStroke(curAppIconColor, curBackgroundColor, cornerRadius) - customization_navigation_bar_color.setFillWithStroke(curNavigationBarColor, curBackgroundColor, cornerRadius) + customization_text_color.setFillWithStroke(curTextColor, curBackgroundColor) + customization_primary_color.setFillWithStroke(curPrimaryColor, curBackgroundColor) + customization_accent_color.setFillWithStroke(curAccentColor, curBackgroundColor) + customization_background_color.setFillWithStroke(curBackgroundColor, curBackgroundColor) + customization_app_icon_color.setFillWithStroke(curAppIconColor, curBackgroundColor) + customization_navigation_bar_color.setFillWithStroke(curNavigationBarColor, curBackgroundColor) customization_text_color_holder.setOnClickListener { pickTextColor() } customization_background_color_holder.setOnClickListener { pickBackgroundColor() } diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/ColorPickerDialog.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/ColorPickerDialog.kt index 70190a94e..945381cfc 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/ColorPickerDialog.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/ColorPickerDialog.kt @@ -37,7 +37,6 @@ class ColorPickerDialog( private val baseConfig = activity.baseConfig private val currentColorHsv = FloatArray(3) private val backgroundColor = baseConfig.backgroundColor - private val cornerRadius = activity.getCornerRadius() private var isHueBeingDragged = false private var wasDimmedBackgroundRemoved = false private var dialog: AlertDialog? = null @@ -57,8 +56,8 @@ class ColorPickerDialog( viewSatVal.setHue(getHue()) - viewNewColor.setFillWithStroke(getColor(), backgroundColor, cornerRadius) - color_picker_old_color.setFillWithStroke(color, backgroundColor, cornerRadius) + viewNewColor.setFillWithStroke(getColor(), backgroundColor) + color_picker_old_color.setFillWithStroke(color, backgroundColor) val hexCode = getHexCode(color) color_picker_old_hex.text = "#$hexCode" @@ -117,7 +116,7 @@ class ColorPickerDialog( currentColorHsv[2] = 1f - 1f / viewSatVal.measuredHeight * y moveColorPicker() - viewNewColor.setFillWithStroke(getColor(), backgroundColor, cornerRadius) + viewNewColor.setFillWithStroke(getColor(), backgroundColor) newHexField.setText(getHexCode(getColor())) return@OnTouchListener true } @@ -169,7 +168,7 @@ class ColorPickerDialog( val recentColorView = ImageView(context) recentColorView.id = View.generateViewId() recentColorView.layoutParams = ViewGroup.LayoutParams(squareSize, squareSize) - recentColorView.setFillWithStroke(recentColor, backgroundColor, cornerRadius) + recentColorView.setFillWithStroke(recentColor, backgroundColor) recentColorView.setOnClickListener { newHexField.setText(getHexCode(recentColor)) } recent_colors.addView(recentColorView) recent_colors_flow.addView(recentColorView) @@ -218,7 +217,7 @@ class ColorPickerDialog( private fun updateHue() { viewSatVal.setHue(getHue()) moveHuePicker() - viewNewColor.setFillWithStroke(getColor(), backgroundColor, cornerRadius) + viewNewColor.setFillWithStroke(getColor(), backgroundColor) if (removeDimmedBackground && !wasDimmedBackgroundRemoved) { dialog?.window?.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND) wasDimmedBackgroundRemoved = true diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/ImageView.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/ImageView.kt index b607568dc..ddc8aa66d 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/ImageView.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/ImageView.kt @@ -4,16 +4,15 @@ import android.graphics.PorterDuff import android.graphics.drawable.GradientDrawable import android.widget.ImageView -fun ImageView.setFillWithStroke(fillColor: Int, backgroundColor: Int, cornerRadiusSize: Float = 0f) { - val strokeColor = backgroundColor.getContrastColor() +fun ImageView.setFillWithStroke(fillColor: Int, backgroundColor: Int) { GradientDrawable().apply { - shape = GradientDrawable.RECTANGLE + shape = GradientDrawable.OVAL setColor(fillColor) - setStroke(2, strokeColor) background = this - if (cornerRadiusSize != 0f) { - cornerRadius = cornerRadiusSize + if (backgroundColor == fillColor) { + val strokeColor = backgroundColor.getContrastColor().adjustAlpha(0.5f) + setStroke(2, strokeColor) } } } diff --git a/commons/src/main/res/layout/dialog_color_picker.xml b/commons/src/main/res/layout/dialog_color_picker.xml index 287e8445e..a47890b7b 100644 --- a/commons/src/main/res/layout/dialog_color_picker.xml +++ b/commons/src/main/res/layout/dialog_color_picker.xml @@ -137,8 +137,8 @@ @@ -154,8 +154,8 @@