lets use oval colorpicker instead of square ones

This commit is contained in:
tibbi 2021-11-04 16:34:28 +01:00
parent b828635a33
commit 593606ea0e
4 changed files with 20 additions and 23 deletions

View file

@ -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() }

View file

@ -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

View file

@ -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)
}
}
}

View file

@ -137,8 +137,8 @@
<ImageView
android:id="@+id/color_picker_old_color"
android:layout_width="@dimen/colorpicker_color_width"
android:layout_height="match_parent"
android:layout_width="@dimen/colorpicker_items_height"
android:layout_height="@dimen/colorpicker_items_height"
android:layout_toStartOf="@+id/color_picker_arrow"
android:background="@android:color/white" />
@ -154,8 +154,8 @@
<ImageView
android:id="@+id/color_picker_new_color"
android:layout_width="@dimen/colorpicker_color_width"
android:layout_height="match_parent"
android:layout_width="@dimen/colorpicker_items_height"
android:layout_height="@dimen/colorpicker_items_height"
android:layout_toEndOf="@+id/color_picker_arrow"
android:background="@android:color/white" />
</RelativeLayout>