Browse Source

Merge branch 'landscapeMediaBox'

cooperku_kdanmobile 5 years ago
parent
commit
e4b2d98144

+ 1 - 1
reader/src/main/AndroidManifest.xml

@@ -10,7 +10,7 @@
             android:theme="@style/ReaderActivityNoActionBarNoTitle" />
         <activity
             android:name=".screen.signature.SignatureActivity"
-            android:screenOrientation="landscape"
+            android:screenOrientation="userLandscape"
             android:theme="@style/ReaderActivityNoActionBarNoTitle" />
         <activity
             android:name=".thumb.PdfThumbActivity"

+ 5 - 1
reader/src/main/java/com/kdanmobile/reader/screen/reader/mediabox/signature/SignatureRecyclerViewItemDecoration.kt

@@ -1,6 +1,7 @@
 package com.kdanmobile.reader.screen.reader.mediabox.signature
 
 import android.graphics.Rect
+import android.support.v7.widget.GridLayoutManager
 import android.support.v7.widget.RecyclerView
 import android.view.View
 
@@ -10,7 +11,10 @@ class SignatureRecyclerViewItemDecoration(private val space: Int, private val ad
     override fun getItemOffsets(outRect: Rect, view: View, parent: RecyclerView, state: RecyclerView.State) {
         val position = parent.getChildAdapterPosition(view)
         val childCount = parent.adapter?.itemCount ?: 0
-        outRect.bottom = when (position == childCount - 1) {
+        val layoutManager = parent.layoutManager as GridLayoutManager
+        val currentRow = (position / layoutManager.spanCount)
+        val lastRow = ((childCount - 1) / layoutManager.spanCount)
+        outRect.bottom = when (currentRow == lastRow) {
             true -> space + additionalPadding
             false -> space
         }

+ 7 - 1
reader/src/main/java/com/kdanmobile/reader/screen/reader/mediabox/signature/SignatureTabView.kt

@@ -43,7 +43,7 @@ class SignatureTabView : ConstraintLayout {
         updateSignaturePaths()
         updateSignatureMessage()
 
-        recyclerView_signature.layoutManager = GridLayoutManager(context, 1)
+        recyclerView_signature.layoutManager = GridLayoutManager(context, resources.getInteger(R.integer.mediaBox_signature_columnCount))
         val adapter = SignatureAdapter(context, signaturePaths)
         adapter.setOnSignatureClickListener(object : OnSignatureClickListener {
             override fun onSignatureClick(path: String) {
@@ -54,6 +54,12 @@ class SignatureTabView : ConstraintLayout {
         adapter.setOnSignatureRemoveListener(object : OnSignatureRemoveListener {
             override fun onSignatureRemove(path: String) {
                 val position = signaturePaths.indexOf(path)
+
+                val layoutManager = recyclerView_signature.layoutManager as GridLayoutManager
+                val updateRow = (position - 1) / layoutManager.spanCount
+                val positionStart = updateRow * layoutManager.spanCount
+                adapter.notifyItemRangeChanged(positionStart, adapter.itemCount - positionStart)
+
                 signaturePaths.removeAt(position)
                 adapter.notifyItemRemoved(position)
                 File(path).delete()

+ 1 - 1
reader/src/main/java/com/kdanmobile/reader/screen/reader/mediabox/stamp/StampTabView.kt

@@ -113,7 +113,7 @@ class StampTabView : ConstraintLayout {
                 else -> {
                     val standardStampView = layoutInflater.inflate(R.layout.view_media_box_item_stamp_standard, container, false)
                     val recyclerView = standardStampView.recyclerView_shapeStandard
-                    recyclerView.layoutManager = GridLayoutManager(context, 3)
+                    recyclerView.layoutManager = GridLayoutManager(context, resources.getInteger(R.integer.mediaBox_standardStamp_columnCount))
                     val adapter = StandardStampAdapter(context, STANDARD_STAMP_RES.values())
                     adapter.setOnStampClickListener(object : OnStampClickListener {
                         override fun onStampClick(index: Int) {

+ 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
+    }
+}

+ 13 - 0
reader/src/main/java/com/kdanmobile/reader/screen/reader/mediabox/textbox/TextBoxStyleView.kt

@@ -4,6 +4,7 @@ import android.content.Context
 import android.graphics.Typeface
 import android.util.AttributeSet
 import android.view.LayoutInflater
+import android.widget.SeekBar
 import com.kdanmobile.reader.R
 import com.kdanmobile.reader.screen.view.ColorSelectView
 import kotlinx.android.synthetic.main.view_media_box_tab_text_box_style.view.*
@@ -47,6 +48,18 @@ class TextBoxStyleView : TextBoxTabView {
             }
         }
 
+        seekBar_textBox_textSize.onSeekBarChangeListener = object : SeekBar.OnSeekBarChangeListener {
+            override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
+                tv_preview.textSize = progress.toFloat()
+            }
+
+            override fun onStartTrackingTouch(seekBar: SeekBar) {
+            }
+
+            override fun onStopTrackingTouch(seekBar: SeekBar) {
+            }
+        }
+
         colorChooser_textBox.onColorSelectedListener = object : ColorSelectView.OnColorSelectedListener {
             override fun onColorSelected(color: Int) {
                 tv_preview.setTextColor(color)

+ 13 - 0
reader/src/main/java/com/kdanmobile/reader/screen/reader/mediabox/textbox/TextBoxTabView.kt

@@ -5,6 +5,7 @@ import android.graphics.Typeface
 import android.support.constraint.ConstraintLayout
 import android.util.AttributeSet
 import android.view.LayoutInflater
+import android.widget.SeekBar
 import com.kdanmobile.reader.R
 import com.kdanmobile.reader.screen.data.TextBoxAttribute
 import com.kdanmobile.reader.screen.reader.mediabox.common.MediaBoxHeader
@@ -62,6 +63,18 @@ open class TextBoxTabView : ConstraintLayout {
             }
         }
 
+        seekBar_textBox_textSize.onSeekBarChangeListener = object : SeekBar.OnSeekBarChangeListener {
+            override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
+                tv_preview.textSize = progress.toFloat()
+            }
+
+            override fun onStartTrackingTouch(seekBar: SeekBar) {
+            }
+
+            override fun onStopTrackingTouch(seekBar: SeekBar) {
+            }
+        }
+
         colorChooser_textBox.onColorSelectedListener = object : ColorSelectView.OnColorSelectedListener {
             override fun onColorSelected(color: Int) {
                 tv_preview.setTextColor(color)

+ 0 - 1
reader/src/main/res/layout/activity_view_signature_create.xml

@@ -83,7 +83,6 @@
         android:layout_marginRight="16dp"
         android:layout_marginEnd="16dp"
         android:gravity="center"
-        android:paddingTop="12dp"
         android:layout_marginBottom="8dp"
         app:layout_constraintBottom_toBottomOf="parent"
         app:layout_constraintLeft_toLeftOf="parent"

+ 3 - 2
reader/src/main/res/layout/view_media_box_item_shape_border.xml

@@ -7,9 +7,9 @@
     <com.kdanmobile.reader.screen.view.ColorSelectView
         android:id="@+id/colorChooser_shapeBorder"
         android:layout_width="0dp"
-        android:layout_height="50dp"
+        android:layout_height="48dp"
         android:gravity="center"
-        android:paddingTop="12dp"
+        android:layout_marginTop="8dp"
         app:layout_constraintLeft_toLeftOf="parent"
         app:layout_constraintRight_toRightOf="parent"
         app:layout_constraintTop_toTopOf="parent"
@@ -34,6 +34,7 @@
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:id="@+id/seekBar_shapeBorder_thickness"
+        android:layout_marginBottom="8dp"
         app:title="@string/reader_mediaBox_shape_titleSeekBarThickness"
         app:unit="@string/reader_mediaBox_shape_unitSeekBarThickness"
         app:maxValue="24"

+ 3 - 2
reader/src/main/res/layout/view_media_box_item_shape_fill.xml

@@ -7,9 +7,9 @@
     <com.kdanmobile.reader.screen.view.ColorSelectView
         android:id="@+id/colorChooser_shapeFill"
         android:layout_width="0dp"
-        android:layout_height="50dp"
+        android:layout_height="48dp"
         android:gravity="center"
-        android:paddingTop="12dp"
+        android:layout_marginTop="8dp"
         app:layout_constraintLeft_toLeftOf="parent"
         app:layout_constraintRight_toRightOf="parent"
         app:layout_constraintTop_toTopOf="parent"
@@ -20,6 +20,7 @@
         android:layout_height="wrap_content"
         android:id="@+id/seekBar_shapeFill_opacity"
         android:layout_marginTop="8dp"
+        android:layout_marginBottom="8dp"
         app:title="@string/reader_mediaBox_shape_titleSeekBarOpacity"
         app:unit="@string/reader_mediaBox_shape_unitSeekBarOpacity"
         app:maxValue="255"

+ 3 - 0
reader/src/main/res/layout/view_media_box_tab_shape.xml

@@ -84,6 +84,9 @@
         app:tabIndicatorColor="#0077fd"
         app:tabSelectedTextColor="#0077fd"
         app:tabTextColor="#99000000"
+        app:tabMaxWidth="0dp"
+        app:tabGravity="fill"
+        app:tabMode="fixed"
         app:layout_constraintLeft_toLeftOf="parent"
         app:layout_constraintRight_toRightOf="parent"
         app:layout_constraintTop_toBottomOf="@+id/layout_shapeSelect"

+ 3 - 0
reader/src/main/res/layout/view_media_box_tab_stamp.xml

@@ -26,6 +26,9 @@
         app:tabIndicatorColor="#0077fd"
         app:tabSelectedTextColor="#0077fd"
         app:tabTextColor="#99000000"
+        app:tabMaxWidth="0dp"
+        app:tabGravity="fill"
+        app:tabMode="fixed"
         app:layout_constraintLeft_toLeftOf="parent"
         app:layout_constraintRight_toRightOf="parent"
         app:layout_constraintTop_toBottomOf="@+id/titleButton_stamp"

+ 13 - 18
reader/src/main/res/layout/view_media_box_tab_text_box.xml

@@ -21,8 +21,7 @@
     <android.support.constraint.ConstraintLayout
         android:id="@+id/layout_textBox"
         android:layout_width="match_parent"
-        android:layout_height="64dp"
-        android:orientation="vertical"
+        android:layout_height="0dp"
         android:background="#14000000"
         android:layout_marginBottom="8dp"
         app:layout_constraintLeft_toLeftOf="parent"
@@ -34,17 +33,17 @@
             android:id="@+id/tv_preview"
             style="@style/Base.TextAppearance.Widget.AppCompat.Toolbar.Subtitle"
             android:layout_width="match_parent"
-            android:layout_height="wrap_content"
+            android:layout_height="match_parent"
             android:layout_marginLeft="16dp"
             android:layout_marginStart="16dp"
             android:layout_marginRight="16dp"
             android:layout_marginEnd="16dp"
-            android:gravity="start"
+            android:gravity="center_vertical"
+            android:singleLine="true"
+            android:ellipsize="none"
             android:textColor="#f5a623"
             android:textSize="24sp"
-            android:text="@string/reader_mediaBox_textBox_simpleText"
-            app:layout_constraintTop_toTopOf="parent"
-            app:layout_constraintBottom_toBottomOf="parent" />
+            android:text="@string/reader_mediaBox_textBox_simpleText" />
     </android.support.constraint.ConstraintLayout>
 
     <com.kdanmobile.reader.screen.reader.mediabox.textbox.TextAttrView
@@ -57,29 +56,25 @@
         app:layout_constraintBottom_toTopOf="@+id/colorChooser_textBox" />
 
     <com.kdanmobile.reader.screen.view.ColorSelectView
+        style="@style/MediaBoxTextBoxColorChooserStyle"
         android:id="@+id/colorChooser_textBox"
         android:layout_width="0dp"
         android:layout_height="48dp"
         android:gravity="center"
-        android:paddingTop="12dp"
         android:layout_marginTop="16dp"
         app:layout_constraintLeft_toLeftOf="parent"
-        app:layout_constraintRight_toRightOf="parent"
-        app:layout_constraintTop_toBottomOf="@+id/textAttrView_textBox"
-        app:layout_constraintBottom_toTopOf="@+id/seekBar_textBox_textSize" />
+        app:layout_constraintTop_toBottomOf="@+id/textAttrView_textBox" />
 
     <com.kdanmobile.reader.screen.reader.mediabox.common.MediaBoxSeekBar
-        android:layout_width="match_parent"
+        style="@style/MediaBoxTextBoxSeekBarStyle"
+        android:layout_width="0dp"
         android:layout_height="wrap_content"
         android:id="@+id/seekBar_textBox_textSize"
-        android:layout_marginTop="16dp"
         app:title="@string/reader_mediaBox_textBox_titleSeekBarSize"
         app:unit="@string/reader_mediaBox_textBox_unitSeekBarSize"
-        app:maxValue="96"
-        app:minValue="8"
+        app:maxValue="100"
+        app:minValue="2"
         app:initValue="24"
-        app:layout_constraintLeft_toLeftOf="parent"
-        app:layout_constraintRight_toRightOf="parent"
-        app:layout_constraintTop_toBottomOf="@+id/colorChooser_textBox" />
+        app:layout_constraintRight_toRightOf="parent" />
 
 </android.support.constraint.ConstraintLayout>

+ 13 - 17
reader/src/main/res/layout/view_media_box_tab_text_box_style.xml

@@ -21,8 +21,7 @@
     <android.support.constraint.ConstraintLayout
         android:id="@+id/layout_textBox"
         android:layout_width="match_parent"
-        android:layout_height="64dp"
-        android:orientation="vertical"
+        android:layout_height="0dp"
         android:background="#14000000"
         android:layout_marginBottom="8dp"
         app:layout_constraintLeft_toLeftOf="parent"
@@ -34,17 +33,17 @@
             android:id="@+id/tv_preview"
             style="@style/Base.TextAppearance.Widget.AppCompat.Toolbar.Subtitle"
             android:layout_width="match_parent"
-            android:layout_height="wrap_content"
+            android:layout_height="match_parent"
             android:layout_marginLeft="16dp"
             android:layout_marginStart="16dp"
             android:layout_marginRight="16dp"
             android:layout_marginEnd="16dp"
-            android:gravity="start"
+            android:gravity="center_vertical"
+            android:singleLine="true"
+            android:ellipsize="none"
             android:textColor="#f5a623"
             android:textSize="24sp"
-            android:text="@string/reader_mediaBox_textBox_simpleText"
-            app:layout_constraintTop_toTopOf="parent"
-            app:layout_constraintBottom_toBottomOf="parent" />
+            android:text="@string/reader_mediaBox_textBox_simpleText" />
     </android.support.constraint.ConstraintLayout>
 
     <com.kdanmobile.reader.screen.reader.mediabox.textbox.TextAttrView
@@ -57,6 +56,7 @@
         app:layout_constraintBottom_toTopOf="@+id/colorChooser_textBox" />
 
     <com.kdanmobile.reader.screen.view.ColorSelectView
+        style="@style/MediaBoxTextBoxColorChooserStyle"
         android:id="@+id/colorChooser_textBox"
         android:layout_width="0dp"
         android:layout_height="48dp"
@@ -64,22 +64,18 @@
         android:paddingTop="12dp"
         android:layout_marginTop="16dp"
         app:layout_constraintLeft_toLeftOf="parent"
-        app:layout_constraintRight_toRightOf="parent"
-        app:layout_constraintTop_toBottomOf="@+id/textAttrView_textBox"
-        app:layout_constraintBottom_toTopOf="@+id/seekBar_textBox_textSize" />
+        app:layout_constraintTop_toBottomOf="@+id/textAttrView_textBox" />
 
     <com.kdanmobile.reader.screen.reader.mediabox.common.MediaBoxSeekBar
-        android:layout_width="match_parent"
+        style="@style/MediaBoxTextBoxSeekBarStyle"
+        android:layout_width="0dp"
         android:layout_height="wrap_content"
         android:id="@+id/seekBar_textBox_textSize"
-        android:layout_marginTop="16dp"
         app:title="@string/reader_mediaBox_textBox_titleSeekBarSize"
         app:unit="@string/reader_mediaBox_textBox_unitSeekBarSize"
-        app:maxValue="96"
-        app:minValue="8"
+        app:maxValue="100"
+        app:minValue="2"
         app:initValue="24"
-        app:layout_constraintLeft_toLeftOf="parent"
-        app:layout_constraintRight_toRightOf="parent"
-        app:layout_constraintTop_toBottomOf="@+id/colorChooser_textBox" />
+        app:layout_constraintRight_toRightOf="parent" />
 
 </android.support.constraint.ConstraintLayout>

+ 4 - 0
reader/src/main/res/values-land/dimens.xml

@@ -1,3 +1,7 @@
 <resources>
     <dimen name="reader_media_box_height">0dp</dimen>
+
+    <integer name="mediaBox_signature_columnCount">2</integer>
+
+    <integer name="mediaBox_standardStamp_columnCount">3</integer>
 </resources>

+ 12 - 0
reader/src/main/res/values-land/styles_media_box.xml

@@ -4,4 +4,16 @@
         <item name="layout_constraintTop_toTopOf">parent</item>
         <item name="android:background">@color/reader_media_box_bg</item>
     </style>
+
+    <style name="MediaBoxTextBoxColorChooserStyle">
+        <item name="android:layout_marginBottom">16dp</item>
+        <item name="layout_constraintRight_toLeftOf">@+id/seekBar_textBox_textSize</item>
+        <item name="layout_constraintBottom_toBottomOf">parent</item>
+    </style>
+
+    <style name="MediaBoxTextBoxSeekBarStyle">
+        <item name="layout_constraintLeft_toRightOf">@+id/colorChooser_textBox</item>
+        <item name="layout_constraintTop_toTopOf">@+id/colorChooser_textBox</item>
+        <item name="layout_constraintBottom_toBottomOf">@+id/colorChooser_textBox</item>
+    </style>
 </resources>

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

@@ -53,4 +53,7 @@
     <color name="action_bar_btn_enable">#757575</color>
     <color name="action_bar_btn_disable">#BDBDBD</color>
     <color name="action_bar_btn_pressed">#2196f3</color>
+
+    <color name="mediaBox_standardStamp_normal">#ffffff</color>
+    <color name="mediaBox_standardStamp_selected">@color/reader_right_toolbar_selected_bg</color>
 </resources>

+ 4 - 0
reader/src/main/res/values/dimens.xml

@@ -9,4 +9,8 @@
     <dimen name="reader_left_right_toolbar_icon_width">48dp</dimen>
 
     <dimen name="reader_media_box_height">336dp</dimen>
+
+    <integer name="mediaBox_signature_columnCount">1</integer>
+
+    <integer name="mediaBox_standardStamp_columnCount">2</integer>
 </resources>

+ 13 - 0
reader/src/main/res/values/styles_media_box.xml

@@ -8,4 +8,17 @@
     <style name="MediaBoxStyle">
         <item name="android:background">@drawable/shape_rec_w_up_rcorner</item>
     </style>
+
+    <style name="MediaBoxTextBoxColorChooserStyle">
+        <item name="layout_constraintRight_toRightOf">parent</item>
+        <item name="layout_constraintBottom_toTopOf">@+id/seekBar_textBox_textSize</item>
+    </style>
+
+    <style name="MediaBoxTextBoxSeekBarStyle">
+        <item name="android:layout_marginTop">16dp</item>
+        <item name="android:layout_marginBottom">16dp</item>
+        <item name="layout_constraintLeft_toLeftOf">parent</item>
+        <item name="layout_constraintTop_toBottomOf">@+id/colorChooser_textBox</item>
+        <item name="layout_constraintBottom_toBottomOf">parent</item>
+    </style>
 </resources>