show the proper icon by default at the app icon color picker

This commit is contained in:
tibbi 2018-04-27 21:16:22 +02:00
parent 252422f0b1
commit 77be7edca9
4 changed files with 13 additions and 11 deletions

View file

@ -7,7 +7,7 @@ buildscript {
propMinSdkVersion = 16
propTargetSdkVersion = propCompileSdkVersion
propVersionCode = 1
propVersionName = '3.19.23'
propVersionName = '3.19.24'
kotlin_version = '1.2.40'
support_libs = '27.1.1'
}

View file

@ -20,10 +20,10 @@ class LineColorPickerDialog(val activity: BaseSimpleActivity, val color: Int, va
private var wasDimmedBackgroundRemoved = false
private var dialog: AlertDialog? = null
private var view: View
private var view: View = activity.layoutInflater.inflate(R.layout.dialog_line_color_picker, null)
init {
view = activity.layoutInflater.inflate(R.layout.dialog_line_color_picker, null).apply {
view.apply {
hex_code.text = color.toHex()
hex_code.setOnLongClickListener {
activity.copyToClipboard(hex_code.value.substring(1))
@ -33,7 +33,9 @@ class LineColorPickerDialog(val activity: BaseSimpleActivity, val color: Int, va
line_color_picker_icon.beGoneIf(isPrimaryColorPicker)
val indexes = getColorIndexes(color)
primary_line_color_picker.updateColors(getColors(primaryColors), indexes.first)
val primaryColorIndex = indexes.first
primaryColorChanged(primaryColorIndex)
primary_line_color_picker.updateColors(getColors(primaryColors), primaryColorIndex)
primary_line_color_picker.listener = object : LineColorPickerListener {
override fun colorChanged(index: Int, color: Int) {
val secondaryColors = getColorsForIndex(index)
@ -49,7 +51,7 @@ class LineColorPickerDialog(val activity: BaseSimpleActivity, val color: Int, va
}
secondary_line_color_picker.beVisibleIf(isPrimaryColorPicker)
secondary_line_color_picker.updateColors(getColorsForIndex(indexes.first), indexes.second)
secondary_line_color_picker.updateColors(getColorsForIndex(primaryColorIndex), indexes.second)
secondary_line_color_picker.listener = object : LineColorPickerListener {
override fun colorChanged(index: Int, color: Int) {
colorUpdated(color)
@ -87,10 +89,11 @@ class LineColorPickerDialog(val activity: BaseSimpleActivity, val color: Int, va
}
for (i in 0 until PRIMARY_COLORS_COUNT) {
val colors = getColorsForIndex(i)
val size = colors.size
(0 until size).filter { color == colors[it] }
.forEach { return Pair(i, it) }
getColorsForIndex(i).indexOfFirst { color == it }.apply {
if (this != -1) {
return Pair(i, this)
}
}
}
return getDefaultColorPair()

View file

@ -169,7 +169,7 @@
android:id="@+id/apply_to_all_holder"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/customization_primary_color_holder"
android:layout_below="@+id/customization_app_icon_color_holder"
android:layout_centerHorizontal="true"
android:layout_marginTop="@dimen/activity_margin"
android:background="?attr/selectableItemBackground">

View file

@ -13,7 +13,6 @@
android:layout_height="@dimen/line_color_picker_app_icon_size"
android:layout_centerHorizontal="true"
android:layout_marginBottom="@dimen/normal_margin"
android:src="@drawable/ic_bell"
android:visibility="gone"/>
<com.simplemobiletools.commons.views.LineColorPicker