Explorar o código

Change margins & selected color of Standard Stamp in MediaBox

cooperku_kdanmobile %!s(int64=5) %!d(string=hai) anos
pai
achega
a4cbb56ebc

+ 12 - 3
reader/src/main/java/com/kdanmobile/reader/screen/reader/mediabox/stamp/StandardStampAdapter.kt

@@ -1,10 +1,13 @@
 package com.kdanmobile.reader.screen.reader.mediabox.stamp
 
 import android.content.Context
+import android.support.v4.content.ContextCompat
 import android.support.v7.widget.RecyclerView
 import android.view.ViewGroup
 import android.widget.ImageView
 import com.kdanmobile.kmpdfkit.annotation.stamp.StampConfig
+import com.kdanmobile.reader.R
+import android.widget.LinearLayout
 
 class StandardStampAdapter(private val context: Context, private val resourceIds: Array<StampConfig.STANDARD_STAMP_RES>): RecyclerView.Adapter<StandardStampViewHolder>() {
 
@@ -24,8 +27,8 @@ class StandardStampAdapter(private val context: Context, private val resourceIds
         }
         holder.imageView.setImageResource(resourceIds[position].resId)
         holder.imageView.setBackgroundColor(when (position == selectedIndex) {
-            true -> 0xff80ffff.toInt()
-            false -> 0xffffffff.toInt()
+            true -> ContextCompat.getColor(context, R.color.mediaBox_standardStamp_selected)
+            false -> ContextCompat.getColor(context, R.color.mediaBox_standardStamp_normal)
         })
     }
 
@@ -43,4 +46,10 @@ class StandardStampAdapter(private val context: Context, private val resourceIds
     }
 }
 
-class StandardStampViewHolder(val imageView: ImageView): RecyclerView.ViewHolder(imageView)
+class StandardStampViewHolder(val imageView: ImageView): RecyclerView.ViewHolder(imageView) {
+    init {
+        val params = LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)
+        params.setMargins(8, 8, 8, 8)
+        imageView.layoutParams = params
+    }
+}

+ 3 - 0
reader/src/main/res/values/colors.xml

@@ -47,4 +47,7 @@
     <color name="reader_outline_background_selected">@color/bright_blue</color>
     <color name="reader_search_title_normal">#afafaf</color>
     <color name="reader_search_title_selected">@color/bright_blue</color>
+
+    <color name="mediaBox_standardStamp_normal">#ffffff</color>
+    <color name="mediaBox_standardStamp_selected">@color/reader_right_toolbar_selected_bg</color>
 </resources>