Forráskód Böngészése

Feature: Shape tab UI

cooperku_kdanmobile 5 éve
szülő
commit
72b2ebbe43
25 módosított fájl, 321 hozzáadás és 14 törlés
  1. 11 14
      reader/src/main/java/com/kdanmobile/reader/screen/view/ViewerEditView.kt
  2. 131 0
      reader/src/main/java/com/kdanmobile/reader/screen/view/edit/ShapeTabView.kt
  3. BIN
      reader/src/main/res/drawable-hdpi/rectangle_pic_arrow.webp
  4. BIN
      reader/src/main/res/drawable-hdpi/rectangle_pic_circular.webp
  5. BIN
      reader/src/main/res/drawable-hdpi/rectangle_pic_line.webp
  6. BIN
      reader/src/main/res/drawable-hdpi/rectangle_pic_rectangle.webp
  7. BIN
      reader/src/main/res/drawable-mdpi/rectangle_pic_arrow.webp
  8. BIN
      reader/src/main/res/drawable-mdpi/rectangle_pic_circular.webp
  9. BIN
      reader/src/main/res/drawable-mdpi/rectangle_pic_line.webp
  10. BIN
      reader/src/main/res/drawable-mdpi/rectangle_pic_rectangle.webp
  11. BIN
      reader/src/main/res/drawable-xhdpi/rectangle_pic_arrow.webp
  12. BIN
      reader/src/main/res/drawable-xhdpi/rectangle_pic_circular.webp
  13. BIN
      reader/src/main/res/drawable-xhdpi/rectangle_pic_line.webp
  14. BIN
      reader/src/main/res/drawable-xhdpi/rectangle_pic_rectangle.webp
  15. BIN
      reader/src/main/res/drawable-xxhdpi/rectangle_pic_arrow.webp
  16. BIN
      reader/src/main/res/drawable-xxhdpi/rectangle_pic_circular.webp
  17. BIN
      reader/src/main/res/drawable-xxhdpi/rectangle_pic_line.webp
  18. BIN
      reader/src/main/res/drawable-xxhdpi/rectangle_pic_rectangle.webp
  19. BIN
      reader/src/main/res/drawable-xxxhdpi/rectangle_pic_arrow.webp
  20. BIN
      reader/src/main/res/drawable-xxxhdpi/rectangle_pic_circular.webp
  21. BIN
      reader/src/main/res/drawable-xxxhdpi/rectangle_pic_line.webp
  22. BIN
      reader/src/main/res/drawable-xxxhdpi/rectangle_pic_rectangle.webp
  23. 46 0
      reader/src/main/res/layout/view_viewer_edit_item_shape_border.xml
  24. 32 0
      reader/src/main/res/layout/view_viewer_edit_item_shape_fill.xml
  25. 101 0
      reader/src/main/res/layout/view_viewer_edit_tab_shape.xml

+ 11 - 14
reader/src/main/java/com/kdanmobile/reader/screen/view/ViewerEditView.kt

@@ -8,6 +8,7 @@ import android.view.LayoutInflater
 import android.view.View
 import android.widget.ImageButton
 import com.kdanmobile.reader.R
+import com.kdanmobile.reader.screen.view.edit.ShapeTabView
 import com.kdanmobile.reader.screen.view.edit.TextBoxTabView
 import kotlinx.android.synthetic.main.view_viewer_edit.view.*
 
@@ -20,8 +21,6 @@ class ViewerEditView : ConstraintLayout {
     private var tabType = ViewerEditTabType.NONE
     private var selected: ImageButton? = null
 
-//    private val selectedColor = ContextCompat.getColor(context, R.color.reader_viewer_edit_tab_color_selected)
-
     constructor(context: Context) : super(context) {
         initView()
     }
@@ -49,17 +48,17 @@ class ViewerEditView : ConstraintLayout {
     }
 
     private fun getButtonDrawable(tabType: ViewerEditTabType, isSelected: Boolean): Int {
-        when (tabType) {
+        return when (tabType) {
             ViewerEditTabType.NONE, ViewerEditTabType.TEXT_BOX ->
-                return if (isSelected) R.drawable.ic_textbox_selected else R.drawable.ic_textbox
+                if (isSelected) R.drawable.ic_textbox_selected else R.drawable.ic_textbox
             ViewerEditTabType.SIGNATURE ->
-                return if (isSelected) R.drawable.ic_signature_selected else R.drawable.ic_signature
+                if (isSelected) R.drawable.ic_signature_selected else R.drawable.ic_signature
             ViewerEditTabType.STAMP ->
-                return if (isSelected) R.drawable.ic_stamp_selected else R.drawable.ic_stamp
+                if (isSelected) R.drawable.ic_stamp_selected else R.drawable.ic_stamp
             ViewerEditTabType.SHAPE ->
-                return if (isSelected) R.drawable.ic_shape_selected else R.drawable.ic_shape
+                if (isSelected) R.drawable.ic_shape_selected else R.drawable.ic_shape
             ViewerEditTabType.FORM ->
-                return if (isSelected) R.drawable.ic_form_selected else R.drawable.ic_form
+                if (isSelected) R.drawable.ic_form_selected else R.drawable.ic_form
         }
     }
 
@@ -68,12 +67,8 @@ class ViewerEditView : ConstraintLayout {
         if (this.tabType != tabType) {
             selected?.setImageDrawable(ContextCompat.getDrawable(context, getButtonDrawable(this.tabType, false)))
             this.tabType = tabType
-//            selected?.clearColorFilter()
             selected = button
             button.setImageDrawable(ContextCompat.getDrawable(context, getButtonDrawable(this.tabType, true)))
-//            button.drawable.setColorFilter(selectedColor, PorterDuff.Mode.SRC_IN)
-//            button.setColorFilter(selectedColor, PorterDuff.Mode.SRC_IN)
-//            button.setColorFilter(Color.BLACK, PorterDuff.Mode.SCREEN)
 
             viewEdit_layout_tab_content.removeAllViews()
             changed = true
@@ -111,12 +106,14 @@ class ViewerEditView : ConstraintLayout {
         //TODO implements tab view and add to viewEdit_layout_tab_content
         val changed = setupContent(view as ImageButton, ViewerEditTabType.SHAPE)
         if (changed) {
-            LayoutInflater.from(context).inflate(R.layout.view_viewer_edit_tab, viewEdit_layout_tab_content)
+            val shapeTabView = ShapeTabView(context)
+            val params = ConstraintLayout.LayoutParams(ConstraintLayout.LayoutParams.MATCH_PARENT, ConstraintLayout.LayoutParams.MATCH_PARENT)
+            viewEdit_layout_tab_content.addView(shapeTabView, params)
         }
     }
 
     private fun setupFormView(view: View) {
-//TODO implements tab view and add to viewEdit_layout_tab_content
+        //TODO implements tab view and add to viewEdit_layout_tab_content
         val changed = setupContent(view as ImageButton, ViewerEditTabType.FORM)
         if (changed) {
             LayoutInflater.from(context).inflate(R.layout.view_viewer_edit_tab, viewEdit_layout_tab_content)

+ 131 - 0
reader/src/main/java/com/kdanmobile/reader/screen/view/edit/ShapeTabView.kt

@@ -0,0 +1,131 @@
+package com.kdanmobile.reader.screen.view.edit
+
+import android.content.Context
+import android.graphics.Color
+import android.graphics.PorterDuff
+import android.support.constraint.ConstraintLayout
+import android.support.v4.view.PagerAdapter
+import android.util.AttributeSet
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import com.kdanmobile.kmpdfkit.annotation.bean.KMPDFArrowAnnotationBean
+import com.kdanmobile.kmpdfkit.annotation.bean.KMPDFCircleAnnotationBean
+import com.kdanmobile.kmpdfkit.annotation.bean.KMPDFLineAnnotationBean
+import com.kdanmobile.kmpdfkit.annotation.bean.KMPDFSquareAnnotationBean
+import com.kdanmobile.kmpdfkit.globaldata.AnnotConfig
+import com.kdanmobile.reader.R
+import kotlinx.android.synthetic.main.view_viewer_edit_tab_shape.view.*
+
+class ShapeTabView : ConstraintLayout {
+
+    var shapeType = AnnotConfig.ShapeAnnotationType.CIRCLE
+        set(value) {
+            field = value
+
+            btn_circle?.clearColorFilter()
+            btn_square?.clearColorFilter()
+            btn_line?.clearColorFilter()
+            btn_arrow?.clearColorFilter()
+            when (shapeType) {
+                AnnotConfig.ShapeAnnotationType.CIRCLE -> {
+                    btn_circle?.setColorFilter(Color.BLUE, PorterDuff.Mode.SRC_IN)
+                }
+                AnnotConfig.ShapeAnnotationType.SQUARE -> {
+                    btn_square?.setColorFilter(Color.BLUE, PorterDuff.Mode.SRC_IN)
+                }
+                AnnotConfig.ShapeAnnotationType.LINE -> {
+                    btn_line?.setColorFilter(Color.BLUE, PorterDuff.Mode.SRC_IN)
+                }
+                AnnotConfig.ShapeAnnotationType.ARROW -> {
+                    btn_arrow?.setColorFilter(Color.BLUE, PorterDuff.Mode.SRC_IN)
+                }
+            }
+            println(value.toString())
+        }
+
+    constructor(context: Context) : super(context) {
+        initView()
+    }
+
+    constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
+        initView()
+    }
+
+    constructor(context: Context, attrs: AttributeSet, defStyle: Int) : super(context, attrs, defStyle) {
+        initView()
+    }
+
+    private fun initView() {
+        LayoutInflater.from(context).inflate(R.layout.view_viewer_edit_tab_shape, this)
+
+        titleButton_shape.onButtonClickListener = OnClickListener { _ ->
+            println("onButtonClick")
+
+            when (shapeType) {
+                AnnotConfig.ShapeAnnotationType.CIRCLE -> {
+
+                }
+                AnnotConfig.ShapeAnnotationType.SQUARE -> {
+
+                }
+                AnnotConfig.ShapeAnnotationType.LINE -> {
+
+                }
+                AnnotConfig.ShapeAnnotationType.ARROW -> {
+
+                }
+            }
+        }
+
+        btn_circle.setOnClickListener { _ ->
+            shapeType = AnnotConfig.ShapeAnnotationType.CIRCLE
+        }
+
+        btn_square.setOnClickListener { _ ->
+            shapeType = AnnotConfig.ShapeAnnotationType.SQUARE
+        }
+
+        btn_line.setOnClickListener { _ ->
+            shapeType = AnnotConfig.ShapeAnnotationType.LINE
+        }
+
+        btn_arrow.setOnClickListener { _ ->
+            shapeType = AnnotConfig.ShapeAnnotationType.ARROW
+        }
+        shapeType = AnnotConfig.ShapeAnnotationType.CIRCLE
+
+        viewPager.adapter = ViewPagerAdapter(context, arrayListOf("Border", "Fill"))
+        tabLayout.setupWithViewPager(viewPager)
+    }
+
+    private class ViewPagerAdapter(context: Context, private val tabs: ArrayList<String>) : PagerAdapter() {
+        private val layoutInflater = LayoutInflater.from(context)
+
+        override fun instantiateItem(container: ViewGroup, position: Int): Any {
+            val resourceId = when (position) {
+                0 -> R.layout.view_viewer_edit_item_shape_border
+                else -> R.layout.view_viewer_edit_item_shape_fill
+            }
+            val view = layoutInflater.inflate(resourceId, container, false)
+            container.addView(view)
+            return view
+        }
+
+        override fun destroyItem(container: ViewGroup, position: Int, obj: Any) {
+            container.removeView(obj as View)
+        }
+
+        override fun getCount(): Int {
+            return tabs.size
+        }
+
+        override fun isViewFromObject(view: View, obj: Any): Boolean {
+            return view == obj
+        }
+
+        override fun getPageTitle(position: Int): CharSequence? {
+            return tabs[position]
+        }
+    }
+}

BIN
reader/src/main/res/drawable-hdpi/rectangle_pic_arrow.webp


BIN
reader/src/main/res/drawable-hdpi/rectangle_pic_circular.webp


BIN
reader/src/main/res/drawable-hdpi/rectangle_pic_line.webp


BIN
reader/src/main/res/drawable-hdpi/rectangle_pic_rectangle.webp


BIN
reader/src/main/res/drawable-mdpi/rectangle_pic_arrow.webp


BIN
reader/src/main/res/drawable-mdpi/rectangle_pic_circular.webp


BIN
reader/src/main/res/drawable-mdpi/rectangle_pic_line.webp


BIN
reader/src/main/res/drawable-mdpi/rectangle_pic_rectangle.webp


BIN
reader/src/main/res/drawable-xhdpi/rectangle_pic_arrow.webp


BIN
reader/src/main/res/drawable-xhdpi/rectangle_pic_circular.webp


BIN
reader/src/main/res/drawable-xhdpi/rectangle_pic_line.webp


BIN
reader/src/main/res/drawable-xhdpi/rectangle_pic_rectangle.webp


BIN
reader/src/main/res/drawable-xxhdpi/rectangle_pic_arrow.webp


BIN
reader/src/main/res/drawable-xxhdpi/rectangle_pic_circular.webp


BIN
reader/src/main/res/drawable-xxhdpi/rectangle_pic_line.webp


BIN
reader/src/main/res/drawable-xxhdpi/rectangle_pic_rectangle.webp


BIN
reader/src/main/res/drawable-xxxhdpi/rectangle_pic_arrow.webp


BIN
reader/src/main/res/drawable-xxxhdpi/rectangle_pic_circular.webp


BIN
reader/src/main/res/drawable-xxxhdpi/rectangle_pic_line.webp


BIN
reader/src/main/res/drawable-xxxhdpi/rectangle_pic_rectangle.webp


+ 46 - 0
reader/src/main/res/layout/view_viewer_edit_item_shape_border.xml

@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="utf-8"?>
+<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent">
+
+    <TextView
+        android:id="@+id/colorChooser_shapeBorder"
+        android:layout_width="match_parent"
+        android:layout_height="50dp"
+        android:text="Color Chooser"
+        android:gravity="center"
+        android:background="#00ff00"
+        app:layout_constraintLeft_toLeftOf="parent"
+        app:layout_constraintRight_toRightOf="parent"
+        app:layout_constraintTop_toTopOf="parent"
+        app:layout_constraintBottom_toTopOf="@+id/seekBar_shapeBorder_opacity" />
+
+    <com.kdanmobile.reader.screen.view.edit.TextSeekBar
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:id="@+id/seekBar_shapeBorder_opacity"
+        android:layout_marginTop="8dp"
+        app:title="Opacity"
+        app:unit="%"
+        app:maxValue="100"
+        app:minValue="0"
+        app:initValue="100"
+        app:layout_constraintLeft_toLeftOf="parent"
+        app:layout_constraintRight_toRightOf="parent"
+        app:layout_constraintTop_toBottomOf="@+id/colorChooser_shapeBorder"
+        app:layout_constraintBottom_toTopOf="@+id/seekBar_shapeBorder_thickness" />
+
+    <com.kdanmobile.reader.screen.view.edit.TextSeekBar
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:id="@+id/seekBar_shapeBorder_thickness"
+        app:title="Thickness"
+        app:unit="px"
+        app:maxValue="10"
+        app:minValue="0"
+        app:initValue="3"
+        app:layout_constraintLeft_toLeftOf="parent"
+        app:layout_constraintRight_toRightOf="parent"
+        app:layout_constraintTop_toBottomOf="@+id/seekBar_shapeBorder_opacity" />
+</android.support.constraint.ConstraintLayout>

+ 32 - 0
reader/src/main/res/layout/view_viewer_edit_item_shape_fill.xml

@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent">
+
+    <TextView
+        android:id="@+id/colorChooser_shapeFill"
+        android:layout_width="match_parent"
+        android:layout_height="50dp"
+        android:text="Color Chooser"
+        android:gravity="center"
+        android:background="#00ff00"
+        app:layout_constraintLeft_toLeftOf="parent"
+        app:layout_constraintRight_toRightOf="parent"
+        app:layout_constraintTop_toTopOf="parent"
+        app:layout_constraintBottom_toTopOf="@+id/seekBar_shapeFill_opacity" />
+
+    <com.kdanmobile.reader.screen.view.edit.TextSeekBar
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:id="@+id/seekBar_shapeFill_opacity"
+        android:layout_marginTop="8dp"
+        app:title="Opacity"
+        app:unit="%"
+        app:maxValue="100"
+        app:minValue="0"
+        app:initValue="100"
+        app:layout_constraintLeft_toLeftOf="parent"
+        app:layout_constraintRight_toRightOf="parent"
+        app:layout_constraintTop_toBottomOf="@+id/colorChooser_shapeFill" />
+</android.support.constraint.ConstraintLayout>

+ 101 - 0
reader/src/main/res/layout/view_viewer_edit_tab_shape.xml

@@ -0,0 +1,101 @@
+<?xml version="1.0" encoding="utf-8"?>
+<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:clickable="true"
+    android:focusable="true"
+    android:background="#FFFFFFFF">
+
+    <com.kdanmobile.reader.screen.view.edit.TitleButton
+        android:layout_width="match_parent"
+        android:layout_height="56dp"
+        android:id="@+id/titleButton_shape"
+        app:title="Shape"
+        app:buttonText="ADD"
+        app:layout_constraintLeft_toLeftOf="parent"
+        app:layout_constraintRight_toRightOf="parent"
+        app:layout_constraintTop_toTopOf="parent"
+        app:layout_constraintBottom_toTopOf="@+id/layout_shapeSelect" />
+
+    <android.support.constraint.ConstraintLayout
+        android:id="@+id/layout_shapeSelect"
+        android:layout_width="match_parent"
+        android:layout_height="56dp"
+        android:orientation="vertical"
+        android:background="#14000000"
+        app:layout_constraintLeft_toLeftOf="parent"
+        app:layout_constraintRight_toRightOf="parent"
+        app:layout_constraintTop_toBottomOf="@+id/titleButton_shape"
+        app:layout_constraintBottom_toTopOf="@+id/tabLayout" >
+
+        <ImageButton
+            android:id="@+id/btn_circle"
+            android:layout_width="48dp"
+            android:layout_height="48dp"
+            android:padding="6dp"
+            android:background="@null"
+            android:src="@drawable/rectangle_pic_circular"
+            app:layout_constraintTop_toTopOf="parent"
+            app:layout_constraintBottom_toBottomOf="parent"
+            app:layout_constraintLeft_toLeftOf="parent"
+            app:layout_constraintRight_toLeftOf="@+id/btn_square" />
+        <ImageButton
+            android:id="@+id/btn_square"
+            android:layout_width="48dp"
+            android:layout_height="48dp"
+            android:padding="6dp"
+            android:background="@null"
+            android:src="@drawable/rectangle_pic_rectangle"
+            app:layout_constraintTop_toTopOf="parent"
+            app:layout_constraintBottom_toBottomOf="parent"
+            app:layout_constraintLeft_toRightOf="@+id/btn_circle"
+            app:layout_constraintRight_toLeftOf="@+id/btn_line" />
+        <ImageButton
+            android:id="@+id/btn_line"
+            android:layout_width="48dp"
+            android:layout_height="48dp"
+            android:padding="6dp"
+            android:background="@null"
+            android:src="@drawable/rectangle_pic_line"
+            app:layout_constraintTop_toTopOf="parent"
+            app:layout_constraintBottom_toBottomOf="parent"
+            app:layout_constraintLeft_toRightOf="@+id/btn_square"
+            app:layout_constraintRight_toLeftOf="@+id/btn_arrow" />
+        <ImageButton
+            android:id="@+id/btn_arrow"
+            android:layout_width="48dp"
+            android:layout_height="48dp"
+            android:padding="6dp"
+            android:background="@null"
+            android:src="@drawable/rectangle_pic_arrow"
+            app:layout_constraintTop_toTopOf="parent"
+            app:layout_constraintBottom_toBottomOf="parent"
+            app:layout_constraintLeft_toRightOf="@+id/btn_line"
+            app:layout_constraintRight_toRightOf="parent" />
+
+    </android.support.constraint.ConstraintLayout>
+
+    <android.support.design.widget.TabLayout
+        android:id="@+id/tabLayout"
+        android:layout_width="match_parent"
+        android:layout_height="48dp"
+        app:tabIndicatorHeight="2dp"
+        app:tabIndicatorColor="#0077fd"
+        app:tabSelectedTextColor="#0077fd"
+        app:tabTextColor="#99000000"
+        app:layout_constraintLeft_toLeftOf="parent"
+        app:layout_constraintRight_toRightOf="parent"
+        app:layout_constraintTop_toBottomOf="@+id/layout_shapeSelect"
+        app:layout_constraintBottom_toTopOf="@+id/viewPager" />
+
+    <android.support.v4.view.ViewPager
+        android:id="@+id/viewPager"
+        android:layout_width="match_parent"
+        android:layout_height="0dp"
+        app:layout_constraintLeft_toLeftOf="parent"
+        app:layout_constraintRight_toRightOf="parent"
+        app:layout_constraintTop_toBottomOf="@+id/tabLayout"
+        app:layout_constraintBottom_toBottomOf="parent" />
+
+</android.support.constraint.ConstraintLayout>