Browse Source

Change color selector color

Wayne 5 năm trước cách đây
mục cha
commit
bcec93fb0e

+ 10 - 10
reader/src/main/java/com/kdanmobile/reader/annotationattribute/AnnotationColor.kt

@@ -3,14 +3,14 @@ package com.kdanmobile.reader.annotationattribute
 import com.kdanmobile.reader.R
 
 enum class AnnotationColor(val colorResId: Int) {
-    Color1(R.color.reader_annotation_color_1),
-    Color2(R.color.reader_annotation_color_2),
-    Color3(R.color.reader_annotation_color_3),
-    Color4(R.color.reader_annotation_color_4),
-    Color5(R.color.reader_annotation_color_5),
-    Color6(R.color.reader_annotation_color_6),
-    Color7(R.color.reader_annotation_color_7),
-    Color8(R.color.reader_annotation_color_8),
-    Color9(R.color.reader_annotation_color_9),
-    Color10(R.color.reader_annotation_color_10),
+    Color1(R.color.reader_color_selector_color_1),
+    Color2(R.color.reader_color_selector_color_2),
+    Color3(R.color.reader_color_selector_color_3),
+    Color4(R.color.reader_color_selector_color_4),
+    Color5(R.color.reader_color_selector_color_5),
+    Color6(R.color.reader_color_selector_color_6),
+    Color7(R.color.reader_color_selector_color_7),
+    Color8(R.color.reader_color_selector_color_8),
+    Color9(R.color.reader_color_selector_color_9),
+    Color10(R.color.reader_color_selector_color_10),
 }

+ 21 - 4
reader/src/main/java/com/kdanmobile/reader/screen/view/ColorSelectView.kt

@@ -1,14 +1,14 @@
 package com.kdanmobile.reader.screen.view
 
 import android.content.Context
-import android.support.constraint.ConstraintLayout
 import android.util.AttributeSet
 import android.view.LayoutInflater
 import android.view.View
+import android.widget.HorizontalScrollView
 import com.kdanmobile.reader.R
 import kotlinx.android.synthetic.main.view_color_select.view.*
 
-class ColorSelectView : ConstraintLayout {
+class ColorSelectView : HorizontalScrollView {
 
     interface OnColorSelectedListener {
         fun onColorSelected(color: Int)
@@ -41,6 +41,8 @@ class ColorSelectView : ConstraintLayout {
         colorSelect_column6.setOnClickListener(this::setColorSelect)
         colorSelect_column7.setOnClickListener(this::setColorSelect)
         colorSelect_column8.setOnClickListener(this::setColorSelect)
+        colorSelect_column9.setOnClickListener(this::setColorSelect)
+        colorSelect_column10.setOnClickListener(this::setColorSelect)
 
         setColorSelect(colorSelect_column1)
     }
@@ -56,6 +58,8 @@ class ColorSelectView : ConstraintLayout {
         colorSelect_column6.isSelected = (colorOvalView == colorSelect_column6)
         colorSelect_column7.isSelected = (colorOvalView == colorSelect_column7)
         colorSelect_column8.isSelected = (colorOvalView == colorSelect_column8)
+        colorSelect_column9.isSelected = (colorOvalView == colorSelect_column9)
+        colorSelect_column10.isSelected = (colorOvalView == colorSelect_column10)
 
         onColorSelectedListener?.onColorSelected(colorOvalView.color)
         selectedColor = colorOvalView.color
@@ -66,7 +70,18 @@ class ColorSelectView : ConstraintLayout {
     }
 
     fun setSelectedColor(color: Int) : Boolean {
-        val columnArray = arrayOf(colorSelect_column1, colorSelect_column2, colorSelect_column3, colorSelect_column4, colorSelect_column5, colorSelect_column6, colorSelect_column7, colorSelect_column8)
+        val columnArray = arrayOf(
+                colorSelect_column1,
+                colorSelect_column2,
+                colorSelect_column3,
+                colorSelect_column4,
+                colorSelect_column5,
+                colorSelect_column6,
+                colorSelect_column7,
+                colorSelect_column8,
+                colorSelect_column9,
+                colorSelect_column10
+        )
         for (column in columnArray) {
             if (column.color == color) {
                 setColorSelect(column)
@@ -85,7 +100,9 @@ class ColorSelectView : ConstraintLayout {
             4 -> colorSelect_column5.color
             5 -> colorSelect_column6.color
             6 -> colorSelect_column7.color
-            else -> colorSelect_column8.color
+            7 -> colorSelect_column8.color
+            8 -> colorSelect_column9.color
+            else -> colorSelect_column10.color
         }
     }
 }

+ 54 - 59
reader/src/main/res/layout/view_color_select.xml

@@ -1,70 +1,65 @@
 <?xml version="1.0" encoding="utf-8"?>
-<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<merge xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools"
+    tools:parentTag="android.widget.HorizontalScrollView"
     android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    android:background="@android:color/white">
+    android:layout_height="wrap_content">
 
-    <com.kdanmobile.reader.screen.view.ColorOvalView
-        android:id="@+id/colorSelect_column1"
-        android:layout_width="24dp"
-        android:layout_height="24dp"
-        app:color="#d0021b"
-        app:layout_constraintLeft_toLeftOf="parent"
-        app:layout_constraintRight_toLeftOf="@id/colorSelect_column2" />
+    <LinearLayout
+        android:orientation="horizontal"
+        android:gravity="center"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content">
 
-    <com.kdanmobile.reader.screen.view.ColorOvalView
-        android:id="@+id/colorSelect_column2"
-        android:layout_width="24dp"
-        android:layout_height="24dp"
-        app:color="#f5a623"
-        app:layout_constraintLeft_toRightOf="@id/colorSelect_column1"
-        app:layout_constraintRight_toLeftOf="@id/colorSelect_column3" />
+        <com.kdanmobile.reader.screen.view.ColorOvalView
+            android:id="@+id/colorSelect_column1"
+            style="@style/ReaderColorSelectorItemStyle"
+            app:color="@color/reader_color_selector_color_1" />
 
-    <com.kdanmobile.reader.screen.view.ColorOvalView
-        android:id="@+id/colorSelect_column3"
-        android:layout_width="24dp"
-        android:layout_height="24dp"
-        app:color="#f8e71c"
-        app:layout_constraintLeft_toRightOf="@id/colorSelect_column2"
-        app:layout_constraintRight_toLeftOf="@id/colorSelect_column4" />
+        <com.kdanmobile.reader.screen.view.ColorOvalView
+            android:id="@+id/colorSelect_column2"
+            style="@style/ReaderColorSelectorItemStyle"
+            app:color="@color/reader_color_selector_color_2" />
 
-    <com.kdanmobile.reader.screen.view.ColorOvalView
-        android:id="@+id/colorSelect_column4"
-        android:layout_width="24dp"
-        android:layout_height="24dp"
-        app:color="#8b572a"
-        app:layout_constraintLeft_toRightOf="@id/colorSelect_column3"
-        app:layout_constraintRight_toLeftOf="@id/colorSelect_column5" />
+        <com.kdanmobile.reader.screen.view.ColorOvalView
+            android:id="@+id/colorSelect_column3"
+            style="@style/ReaderColorSelectorItemStyle"
+            app:color="@color/reader_color_selector_color_3" />
 
-    <com.kdanmobile.reader.screen.view.ColorOvalView
-        android:id="@+id/colorSelect_column5"
-        android:layout_width="24dp"
-        android:layout_height="24dp"
-        app:color="#7ed321"
-        app:layout_constraintLeft_toRightOf="@id/colorSelect_column4"
-        app:layout_constraintRight_toLeftOf="@id/colorSelect_column6" />
+        <com.kdanmobile.reader.screen.view.ColorOvalView
+            android:id="@+id/colorSelect_column4"
+            style="@style/ReaderColorSelectorItemStyle"
+            app:color="@color/reader_color_selector_color_4" />
 
-    <com.kdanmobile.reader.screen.view.ColorOvalView
-        android:id="@+id/colorSelect_column6"
-        android:layout_width="24dp"
-        android:layout_height="24dp"
-        app:color="#417505"
-        app:layout_constraintLeft_toRightOf="@id/colorSelect_column5"
-        app:layout_constraintRight_toLeftOf="@id/colorSelect_column7" />
+        <com.kdanmobile.reader.screen.view.ColorOvalView
+            android:id="@+id/colorSelect_column5"
+            style="@style/ReaderColorSelectorItemStyle"
+            app:color="@color/reader_color_selector_color_5" />
 
-    <com.kdanmobile.reader.screen.view.ColorOvalView
-        android:id="@+id/colorSelect_column7"
-        android:layout_width="24dp"
-        android:layout_height="24dp"
-        app:color="#4a90e2"
-        app:layout_constraintLeft_toRightOf="@id/colorSelect_column6"
-        app:layout_constraintRight_toLeftOf="@id/colorSelect_column8" />
+        <com.kdanmobile.reader.screen.view.ColorOvalView
+            android:id="@+id/colorSelect_column6"
+            style="@style/ReaderColorSelectorItemStyle"
+            app:color="@color/reader_color_selector_color_6" />
 
-    <com.kdanmobile.reader.screen.view.ColorOvalView
-        android:id="@+id/colorSelect_column8"
-        android:layout_width="24dp"
-        android:layout_height="24dp"
-        app:layout_constraintLeft_toRightOf="@id/colorSelect_column7"
-        app:layout_constraintRight_toRightOf="parent"/>
-</android.support.constraint.ConstraintLayout>
+        <com.kdanmobile.reader.screen.view.ColorOvalView
+            android:id="@+id/colorSelect_column7"
+            style="@style/ReaderColorSelectorItemStyle"
+            app:color="@color/reader_color_selector_color_7" />
+
+        <com.kdanmobile.reader.screen.view.ColorOvalView
+            android:id="@+id/colorSelect_column8"
+            style="@style/ReaderColorSelectorItemStyle"
+            app:color="@color/reader_color_selector_color_8" />
+
+        <com.kdanmobile.reader.screen.view.ColorOvalView
+            android:id="@+id/colorSelect_column9"
+            style="@style/ReaderColorSelectorItemStyle"
+            app:color="@color/reader_color_selector_color_9" />
+
+        <com.kdanmobile.reader.screen.view.ColorOvalView
+            android:id="@+id/colorSelect_column10"
+            style="@style/ReaderColorSelectorItemStyle"
+            app:color="@color/reader_color_selector_color_10" />
+    </LinearLayout>
+</merge>

+ 10 - 10
reader/src/main/res/layout/view_reader_annotation_property.xml

@@ -142,52 +142,52 @@
             <ImageView
                 style="@style/AnnotationPropertyColorImageView"
                 android:id="@+id/iv_readerAnnotationProperty_color1"
-                android:background="@color/reader_annotation_color_1" />
+                android:background="@color/reader_color_selector_color_1" />
 
             <ImageView
                 style="@style/AnnotationPropertyColorImageView"
                 android:id="@+id/iv_readerAnnotationProperty_color2"
-                android:background="@color/reader_annotation_color_2" />
+                android:background="@color/reader_color_selector_color_2" />
 
             <ImageView
                 style="@style/AnnotationPropertyColorImageView"
                 android:id="@+id/iv_readerAnnotationProperty_color3"
-                android:background="@color/reader_annotation_color_3" />
+                android:background="@color/reader_color_selector_color_3" />
 
             <ImageView
                 style="@style/AnnotationPropertyColorImageView"
                 android:id="@+id/iv_readerAnnotationProperty_color4"
-                android:background="@color/reader_annotation_color_4" />
+                android:background="@color/reader_color_selector_color_4" />
 
             <ImageView
                 style="@style/AnnotationPropertyColorImageView"
                 android:id="@+id/iv_readerAnnotationProperty_color5"
-                android:background="@color/reader_annotation_color_5" />
+                android:background="@color/reader_color_selector_color_5" />
 
             <ImageView
                 style="@style/AnnotationPropertyColorImageView"
                 android:id="@+id/iv_readerAnnotationProperty_color6"
-                android:background="@color/reader_annotation_color_6" />
+                android:background="@color/reader_color_selector_color_6" />
 
             <ImageView
                 style="@style/AnnotationPropertyColorImageView"
                 android:id="@+id/iv_readerAnnotationProperty_color7"
-                android:background="@color/reader_annotation_color_7" />
+                android:background="@color/reader_color_selector_color_7" />
 
             <ImageView
                 style="@style/AnnotationPropertyColorImageView"
                 android:id="@+id/iv_readerAnnotationProperty_color8"
-                android:background="@color/reader_annotation_color_8" />
+                android:background="@color/reader_color_selector_color_8" />
 
             <ImageView
                 style="@style/AnnotationPropertyColorImageView"
                 android:id="@+id/iv_readerAnnotationProperty_color9"
-                android:background="@color/reader_annotation_color_9" />
+                android:background="@color/reader_color_selector_color_9" />
 
             <ImageView
                 style="@style/AnnotationPropertyColorImageView"
                 android:id="@+id/iv_readerAnnotationProperty_color10"
-                android:background="@color/reader_annotation_color_10" />
+                android:background="@color/reader_color_selector_color_10" />
         </LinearLayout>
     </HorizontalScrollView>
 

+ 10 - 10
reader/src/main/res/values/colors.xml

@@ -21,16 +21,16 @@
     <color name="reader_annotation_attribute_seek_bar_tint_disable">@color/black_38</color>
     <color name="reader_annotation_attribute_seek_bar_tint_background_enable">@color/bright_blue_38</color>
     <color name="reader_annotation_attribute_seek_bar_tint_background_disable">@color/black_38</color>
-    <color name="reader_annotation_color_1">#000000</color>
-    <color name="reader_annotation_color_2">#296dd2</color>
-    <color name="reader_annotation_color_3">#57d214</color>
-    <color name="reader_annotation_color_4">#ffdc1b</color>
-    <color name="reader_annotation_color_5">#ff7e00</color>
-    <color name="reader_annotation_color_6">#fe866a</color>
-    <color name="reader_annotation_color_7">#d11bff</color>
-    <color name="reader_annotation_color_8">#ff1b89</color>
-    <color name="reader_annotation_color_9">#dd0202</color>
-    <color name="reader_annotation_color_10">#ffffff</color>
+    <color name="reader_color_selector_color_1">#000000</color>
+    <color name="reader_color_selector_color_2">#296dd2</color>
+    <color name="reader_color_selector_color_3">#57d214</color>
+    <color name="reader_color_selector_color_4">#ffdc1b</color>
+    <color name="reader_color_selector_color_5">#ff7e00</color>
+    <color name="reader_color_selector_color_6">#fe866a</color>
+    <color name="reader_color_selector_color_7">#d11bff</color>
+    <color name="reader_color_selector_color_8">#ff1b89</color>
+    <color name="reader_color_selector_color_9">#dd0202</color>
+    <color name="reader_color_selector_color_10">#ffffff</color>
 
     <color name="highlight_default_color">#FFFF00</color>
     <color name="strike_default_color">#FF0000</color>

+ 5 - 0
reader/src/main/res/values/styles.xml

@@ -32,4 +32,9 @@
         <item name="android:layout_height">48dp</item>
         <item name="android:textColor">@color/reader_bota_title_color</item>
     </style>
+    <style name="ReaderColorSelectorItemStyle">
+        <item name="android:layout_width">48dp</item>
+        <item name="android:layout_height">48dp</item>
+        <item name="android:padding">6dp</item>
+    </style>
 </resources>