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

Hide/show toolbars when media box show/hide

Wayne 5 éve
szülő
commit
95390b861b

+ 15 - 2
reader/src/main/java/com/kdanmobile/reader/ReaderActivity.kt

@@ -224,7 +224,6 @@ abstract class ReaderActivity : AppCompatActivity() {
             AnimationUtil.hideViewFromTopToBottom(viewGroup_readerActivity_bottomToolbar, UI_ANIMATION_DURATION)
             AnimationUtil.hideViewFromRightToLeft(viewGroup_readerActivity_leftToolbar, UI_ANIMATION_DURATION)
             AnimationUtil.hideViewFromLeftToRight(viewGroup_readerActivity_rightToolbar, UI_ANIMATION_DURATION)
-            viewerEditView.visibility = View.GONE
             hideSearchViewSoftKeyboard()
         } else {
             constrainLayout_readerActivity_root.applyConstraintSet(this, R.layout.activity_reader_hide_all, UI_ANIMATION_DURATION)
@@ -329,6 +328,10 @@ abstract class ReaderActivity : AppCompatActivity() {
         alertDialogBuilder.create().show()
     }
 
+    private fun showMediaBox() {
+        viewerEditView.show()
+    }
+
     private fun hideSearchViewSoftKeyboard() {
         val view = linearLayout_readerActivity_leftToolbarContainer.getChildAt(0)
         if (view is SearchView) {
@@ -352,11 +355,13 @@ abstract class ReaderActivity : AppCompatActivity() {
     }
 
     private fun setupBottomToolbar() {
-        ib_readerActivity_bottomToolbarMediaBox.setOnClickListener { viewerEditView.visibility = View.VISIBLE }
+        ib_readerActivity_bottomToolbarMediaBox.setOnClickListener { showMediaBox() }
     }
 
     private fun setupViewerEditView() {
         viewerEditView.apply {
+            onShowListener = Runnable { onMediaBoxShown() }
+            onDismissListener = Runnable { onMediaBoxDismissed() }
             onViewerEditTabAddButtonClickListener = object : ViewerEditView.OnViewerEditTabAddButtonClickListener {
                 override fun onTabTextBoxAddButtonClick(textBoxTabView: TextBoxTabView) {
                     hideAllToolbars()
@@ -407,6 +412,14 @@ abstract class ReaderActivity : AppCompatActivity() {
         cloneOriginConstraintSet()
     }
 
+    private fun onMediaBoxShown() {
+        hideAllToolbars()
+    }
+
+    private fun onMediaBoxDismissed() {
+        showAllToolbars()
+    }
+
     private fun onThumbnailClick() {
         val type = LeftToolbarType.THUMBNAIL
         changeLeftToolbarType(type)

+ 15 - 1
reader/src/main/java/com/kdanmobile/reader/screen/view/ViewerEditView.kt

@@ -21,6 +21,9 @@ class ViewerEditView : ConstraintLayout {
         NONE, TEXT_BOX, SIGNATURE, STAMP, SHAPE, FORM
     }
 
+    var onShowListener: Runnable? = null
+    var onDismissListener: Runnable? = null
+
     private var tabType = ViewerEditTabType.NONE
     private var selected: ImageButton? = null
     var onViewerEditTabAddButtonClickListener: OnViewerEditTabAddButtonClickListener? = null
@@ -39,8 +42,19 @@ class ViewerEditView : ConstraintLayout {
 
     private fun initView() {
         LayoutInflater.from(context).inflate(R.layout.view_viewer_edit, this)
-
+        visibility = View.GONE
         setupTabView()
+        setOnClickListener { dismiss() }
+    }
+
+    fun show() {
+        visibility = View.VISIBLE
+        onShowListener?.run()
+    }
+
+    fun dismiss() {
+        visibility = View.GONE
+        onDismissListener?.run()
     }
 
     private fun setupTabView() {