|
@@ -4,7 +4,6 @@ import android.content.Context
|
|
import android.support.v4.graphics.ColorUtils
|
|
import android.support.v4.graphics.ColorUtils
|
|
import android.util.AttributeSet
|
|
import android.util.AttributeSet
|
|
import android.view.View
|
|
import android.view.View
|
|
-import android.widget.ImageView
|
|
|
|
import android.widget.LinearLayout
|
|
import android.widget.LinearLayout
|
|
import android.widget.SeekBar
|
|
import android.widget.SeekBar
|
|
import com.kdanmobile.reader.R
|
|
import com.kdanmobile.reader.R
|
|
@@ -12,6 +11,7 @@ import com.kdanmobile.reader.annotationattribute.AnnotationAttribute
|
|
import com.kdanmobile.reader.annotationattribute.AnnotationColor
|
|
import com.kdanmobile.reader.annotationattribute.AnnotationColor
|
|
import com.kdanmobile.reader.annotationattribute.Brush
|
|
import com.kdanmobile.reader.annotationattribute.Brush
|
|
import com.kdanmobile.reader.annotationattribute.InkAttribute
|
|
import com.kdanmobile.reader.annotationattribute.InkAttribute
|
|
|
|
+import com.kdanmobile.reader.screen.view.ColorSelectView
|
|
import kotlinx.android.synthetic.main.view_reader_annotation_property.view.*
|
|
import kotlinx.android.synthetic.main.view_reader_annotation_property.view.*
|
|
|
|
|
|
class AnnotationAttributeView @JvmOverloads constructor(
|
|
class AnnotationAttributeView @JvmOverloads constructor(
|
|
@@ -53,18 +53,6 @@ class AnnotationAttributeView @JvmOverloads constructor(
|
|
update()
|
|
update()
|
|
}
|
|
}
|
|
var onChangeListener: OnChangeListener? = null
|
|
var onChangeListener: OnChangeListener? = null
|
|
- private val colorBtnMap = HashMap<AnnotationColor, ImageView>().apply {
|
|
|
|
- put(AnnotationColor.Color1, iv_readerAnnotationProperty_color1)
|
|
|
|
- put(AnnotationColor.Color2, iv_readerAnnotationProperty_color2)
|
|
|
|
- put(AnnotationColor.Color3, iv_readerAnnotationProperty_color3)
|
|
|
|
- put(AnnotationColor.Color4, iv_readerAnnotationProperty_color4)
|
|
|
|
- put(AnnotationColor.Color5, iv_readerAnnotationProperty_color5)
|
|
|
|
- put(AnnotationColor.Color6, iv_readerAnnotationProperty_color6)
|
|
|
|
- put(AnnotationColor.Color7, iv_readerAnnotationProperty_color7)
|
|
|
|
- put(AnnotationColor.Color8, iv_readerAnnotationProperty_color8)
|
|
|
|
- put(AnnotationColor.Color9, iv_readerAnnotationProperty_color9)
|
|
|
|
- put(AnnotationColor.Color10, iv_readerAnnotationProperty_color10)
|
|
|
|
- }
|
|
|
|
private var thickness: Int = DEFAULT_THICKNESS
|
|
private var thickness: Int = DEFAULT_THICKNESS
|
|
set(value) {
|
|
set(value) {
|
|
field = value
|
|
field = value
|
|
@@ -100,6 +88,7 @@ class AnnotationAttributeView @JvmOverloads constructor(
|
|
}
|
|
}
|
|
private var colorEnum: AnnotationColor = AnnotationColor.Color1
|
|
private var colorEnum: AnnotationColor = AnnotationColor.Color1
|
|
set(value) {
|
|
set(value) {
|
|
|
|
+ if (field == value) return
|
|
field = value
|
|
field = value
|
|
updateColor()
|
|
updateColor()
|
|
updateColorButtons()
|
|
updateColorButtons()
|
|
@@ -154,8 +143,15 @@ class AnnotationAttributeView @JvmOverloads constructor(
|
|
}
|
|
}
|
|
|
|
|
|
private fun setupColorButtons() {
|
|
private fun setupColorButtons() {
|
|
- colorBtnMap.values.forEach {
|
|
|
|
- it.setOnClickListener(this::onClickColorBtn)
|
|
|
|
|
|
+ viewGroup_readerAnnotationProperty_color.onColorSelectedListener = object : ColorSelectView.OnColorSelectedListener {
|
|
|
|
+ override fun onColorSelected(color: Int) {
|
|
|
|
+ AnnotationColor.values().forEach { annotationColor ->
|
|
|
|
+ val c = resources.getColor(annotationColor.colorResId)
|
|
|
|
+ if (c == color) {
|
|
|
|
+ colorEnum = annotationColor
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -221,15 +217,6 @@ class AnnotationAttributeView @JvmOverloads constructor(
|
|
})
|
|
})
|
|
}
|
|
}
|
|
|
|
|
|
- private fun onClickColorBtn(view: View) {
|
|
|
|
- colorBtnMap.entries.forEach {
|
|
|
|
- if (it.value == view) {
|
|
|
|
- colorEnum = it.key
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
private fun update() {
|
|
private fun update() {
|
|
updateOpacity()
|
|
updateOpacity()
|
|
updateThickness()
|
|
updateThickness()
|
|
@@ -277,13 +264,8 @@ class AnnotationAttributeView @JvmOverloads constructor(
|
|
}
|
|
}
|
|
|
|
|
|
private fun updateColorButtons() {
|
|
private fun updateColorButtons() {
|
|
- colorBtnMap.entries.forEach {
|
|
|
|
- if (it.key == colorEnum) {
|
|
|
|
- it.value.setImageResource(R.drawable.reader_annotation_property_color_border_select)
|
|
|
|
- } else {
|
|
|
|
- it.value.setImageResource(R.drawable.reader_annotation_property_color_border)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ val c = resources.getColor(colorEnum.colorResId)
|
|
|
|
+ viewGroup_readerAnnotationProperty_color.setSelectedColor(c)
|
|
}
|
|
}
|
|
|
|
|
|
interface OnChangeListener {
|
|
interface OnChangeListener {
|