|
@@ -6,31 +6,41 @@ import android.arch.lifecycle.ViewModelProviders
|
|
import android.content.Intent
|
|
import android.content.Intent
|
|
import android.net.Uri
|
|
import android.net.Uri
|
|
import android.os.Build
|
|
import android.os.Build
|
|
-import android.support.v7.app.AppCompatActivity
|
|
|
|
import android.os.Bundle
|
|
import android.os.Bundle
|
|
import android.support.constraint.ConstraintLayout
|
|
import android.support.constraint.ConstraintLayout
|
|
import android.support.constraint.ConstraintSet
|
|
import android.support.constraint.ConstraintSet
|
|
|
|
+import android.widget.Toast
|
|
|
|
+import com.kdanmobile.kmpdfkit.pdfcommon.KMPDFReaderView
|
|
|
|
+import com.kdanmobile.reader.Utils.applyConstraintSet
|
|
|
|
+import com.kdanmobile.reader.view.AnnotationAttributeView
|
|
|
|
+import com.kdanmobile.reader.view.AnnotationAttributeWindow
|
|
import android.support.v4.content.ContextCompat
|
|
import android.support.v4.content.ContextCompat
|
|
import android.support.v7.app.AlertDialog
|
|
import android.support.v7.app.AlertDialog
|
|
|
|
+import android.support.v7.app.AppCompatActivity
|
|
|
|
+import android.util.DisplayMetrics
|
|
import android.view.Menu
|
|
import android.view.Menu
|
|
import android.view.MenuItem
|
|
import android.view.MenuItem
|
|
-import android.util.DisplayMetrics
|
|
|
|
import android.view.MotionEvent
|
|
import android.view.MotionEvent
|
|
import android.view.View
|
|
import android.view.View
|
|
import android.widget.EditText
|
|
import android.widget.EditText
|
|
import android.widget.LinearLayout
|
|
import android.widget.LinearLayout
|
|
import android.widget.TextView
|
|
import android.widget.TextView
|
|
-import com.kdanmobile.kmpdfkit.pdfcommon.KMPDFReaderView
|
|
|
|
-import com.kdanmobile.reader.Utils.applyConstraintSet
|
|
|
|
|
|
+import com.kdanmobile.reader.annotationattribute.AnnotationAttribute
|
|
|
|
+import com.kdanmobile.reader.annotationattribute.AnnotationColor
|
|
|
|
+import com.kdanmobile.reader.annotationattribute.InkAttribute
|
|
import com.kdanmobile.reader.screen.view.BookmarkView
|
|
import com.kdanmobile.reader.screen.view.BookmarkView
|
|
import com.kdanmobile.reader.screen.view.OutlineView
|
|
import com.kdanmobile.reader.screen.view.OutlineView
|
|
import com.kdanmobile.reader.screen.view.SearchView
|
|
import com.kdanmobile.reader.screen.view.SearchView
|
|
import com.kdanmobile.reader.screen.view.ThumbnailView
|
|
import com.kdanmobile.reader.screen.view.ThumbnailView
|
|
|
|
+import com.kdanmobile.reader.screen.ViewerSettingActivity
|
|
|
|
+import com.kdanmobile.reader.screen.view.*
|
|
|
|
+import com.kdanmobile.reader.screen.view.edit.ShapeTabView
|
|
|
|
+import com.kdanmobile.reader.screen.view.edit.SignatureTabView
|
|
|
|
+import com.kdanmobile.reader.screen.view.edit.StampTabView
|
|
|
|
+import com.kdanmobile.reader.screen.view.edit.TextBoxTabView
|
|
import com.kdanmobile.reader.utils.AnimationUtil
|
|
import com.kdanmobile.reader.utils.AnimationUtil
|
|
import com.kdanmobile.reader.utils.DensityUtil
|
|
import com.kdanmobile.reader.utils.DensityUtil
|
|
-import com.kdanmobile.reader.screen.ViewerSettingActivity
|
|
|
|
import kotlinx.android.synthetic.main.activity_reader.*
|
|
import kotlinx.android.synthetic.main.activity_reader.*
|
|
-import kotlin.Exception
|
|
|
|
|
|
|
|
abstract class ReaderActivity : AppCompatActivity() {
|
|
abstract class ReaderActivity : AppCompatActivity() {
|
|
|
|
|
|
@@ -82,21 +92,36 @@ abstract class ReaderActivity : AppCompatActivity() {
|
|
setupLeftToolbar()
|
|
setupLeftToolbar()
|
|
setupRightSideToolbar()
|
|
setupRightSideToolbar()
|
|
setupBottomToolbar()
|
|
setupBottomToolbar()
|
|
|
|
+ setupViewerEditView()
|
|
|
|
|
|
val factory = ReaderViewModelFactory()
|
|
val factory = ReaderViewModelFactory()
|
|
viewModel = ViewModelProviders.of(this, factory).get(ReaderViewModel::class.java)
|
|
viewModel = ViewModelProviders.of(this, factory).get(ReaderViewModel::class.java)
|
|
viewModel.isOpenedFileLiveData.observe(this, Observer(this::onIsOpenedFileUpdate))
|
|
viewModel.isOpenedFileLiveData.observe(this, Observer(this::onIsOpenedFileUpdate))
|
|
viewModel.fileNameLiveData.observe(this, Observer { tv_readerActivity_title.text = it })
|
|
viewModel.fileNameLiveData.observe(this, Observer { tv_readerActivity_title.text = it })
|
|
|
|
+ viewModel.annotationModeLiveData.observe(this, Observer(this::onAnnotationModeUpdate))
|
|
|
|
+ viewModel.isCopyModeLiveData.observe(this, Observer (this::onIsCopyModeUpdate))
|
|
|
|
+ viewModel.highLightAttributeLiveData.observe(this, Observer(this::onHighlightAttributeUpdate))
|
|
|
|
+ viewModel.strikeAttributeLiveData.observe(this, Observer(this::onStrikeAttributeUpdate))
|
|
|
|
+ viewModel.underLineAttributeLiveData.observe(this, Observer(this::onUnderlineAttributeUpdate))
|
|
|
|
+ viewModel.inkAttributeLiveData.observe(this, Observer(this::onInkAttributeUpdate))
|
|
viewModel.isOpenedFileLiveData.value?.also { isOpened ->
|
|
viewModel.isOpenedFileLiveData.value?.also { isOpened ->
|
|
if (isOpened) return@also
|
|
if (isOpened) return@also
|
|
val filePath = intent.getStringExtra(KEY_FILE_ABSOLUTE)
|
|
val filePath = intent.getStringExtra(KEY_FILE_ABSOLUTE)
|
|
val uri = Uri.parse(filePath)
|
|
val uri = Uri.parse(filePath)
|
|
viewModel.openPdfFile(this, uri, intent.type)
|
|
viewModel.openPdfFile(this, uri, intent.type)
|
|
}
|
|
}
|
|
|
|
+ setupRightToolbar()
|
|
viewModel.pageIndexLiveData.observe(this, Observer(this::onPageIndexChanged))
|
|
viewModel.pageIndexLiveData.observe(this, Observer(this::onPageIndexChanged))
|
|
viewModel.isPageInBookmarksLiveData.observe(this, Observer(this::onIsPageInBookmarksChanged))
|
|
viewModel.isPageInBookmarksLiveData.observe(this, Observer(this::onIsPageInBookmarksChanged))
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ override fun onBackPressed() {
|
|
|
|
+ when {
|
|
|
|
+ viewerEditView.isShown -> viewerEditView.dismiss()
|
|
|
|
+ else -> super.onBackPressed()
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
|
|
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
|
|
menuInflater.inflate(R.menu.reader_more, menu)
|
|
menuInflater.inflate(R.menu.reader_more, menu)
|
|
menuItemBookmark = menu?.findItem(R.id.item_reader_bookmark)
|
|
menuItemBookmark = menu?.findItem(R.id.item_reader_bookmark)
|
|
@@ -139,6 +164,81 @@ abstract class ReaderActivity : AppCompatActivity() {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private fun onIsCopyModeUpdate(isCopyMode: Boolean?) {
|
|
|
|
+ if (isCopyMode == null) return
|
|
|
|
+ when (isCopyMode) {
|
|
|
|
+ true -> {
|
|
|
|
+ val color = resources.getColor(R.color.reader_right_toolbar_selected_bg)
|
|
|
|
+ iv_readerActivity_copy.setBackgroundColor(color)
|
|
|
|
+ hideTopLeftBottomToolbars()
|
|
|
|
+ }
|
|
|
|
+ false -> {
|
|
|
|
+ iv_readerActivity_copy.setBackgroundDrawable(null)
|
|
|
|
+ showAllToolbars()
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private fun onHighlightAttributeUpdate(annotationAttribute: AnnotationAttribute?) {
|
|
|
|
+ if (annotationAttribute == null) return
|
|
|
|
+ view_readerActivity_highLightStroke.setBackgroundColor(annotationAttribute.color)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private fun onStrikeAttributeUpdate(annotationAttribute: AnnotationAttribute?) {
|
|
|
|
+ if (annotationAttribute == null) return
|
|
|
|
+ view_readerActivity_strikeStroke.setBackgroundColor(annotationAttribute.color)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private fun onUnderlineAttributeUpdate(annotationAttribute: AnnotationAttribute?) {
|
|
|
|
+ if (annotationAttribute == null) return
|
|
|
|
+ view_readerActivity_underlineStroke.setBackgroundColor(annotationAttribute.color)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private fun onInkAttributeUpdate(inkAttribute: InkAttribute?) {
|
|
|
|
+ if (inkAttribute == null) return
|
|
|
|
+ val color = inkAttribute.color
|
|
|
|
+ AnnotationColor.values().forEach {
|
|
|
|
+ if (resources.getColor(it.colorResId) == color) {
|
|
|
|
+ val drawableResId = when (it) {
|
|
|
|
+ AnnotationColor.Color1 -> R.drawable.ic_tool_freehand_s1
|
|
|
|
+ AnnotationColor.Color2 -> R.drawable.ic_tool_freehand_s2
|
|
|
|
+ AnnotationColor.Color3 -> R.drawable.ic_tool_freehand_s3
|
|
|
|
+ AnnotationColor.Color4 -> R.drawable.ic_tool_freehand_s4
|
|
|
|
+ AnnotationColor.Color5 -> R.drawable.ic_tool_freehand_s5
|
|
|
|
+ AnnotationColor.Color6 -> R.drawable.ic_tool_freehand_s6
|
|
|
|
+ AnnotationColor.Color7 -> R.drawable.ic_tool_freehand_s7
|
|
|
|
+ AnnotationColor.Color8 -> R.drawable.ic_tool_freehand_s8
|
|
|
|
+ AnnotationColor.Color9 -> R.drawable.ic_tool_freehand_s9
|
|
|
|
+ AnnotationColor.Color10 -> R.drawable.ic_tool_freehand_s10
|
|
|
|
+ }
|
|
|
|
+ iv_readerActivity_inkStroke.setImageResource(drawableResId)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private fun onAnnotationModeUpdate(annotationMode: ReaderViewModel.AnnotationMode?) {
|
|
|
|
+ if (annotationMode == null) return
|
|
|
|
+ val map = HashMap<ReaderViewModel.AnnotationMode, View>().apply {
|
|
|
|
+ put(ReaderViewModel.AnnotationMode.Highlight, iv_readerActivity_highLight)
|
|
|
|
+ put(ReaderViewModel.AnnotationMode.Strike, iv_readerActivity_strike)
|
|
|
|
+ put(ReaderViewModel.AnnotationMode.Underline, iv_readerActivity_underline)
|
|
|
|
+ put(ReaderViewModel.AnnotationMode.Ink, iv_readerActivity_ink)
|
|
|
|
+ }
|
|
|
|
+ map.forEach {
|
|
|
|
+ if (it.key == annotationMode) {
|
|
|
|
+ val color = resources.getColor(R.color.reader_right_toolbar_selected_bg)
|
|
|
|
+ it.value.setBackgroundColor(color)
|
|
|
|
+ } else {
|
|
|
|
+ it.value.setBackgroundDrawable(null)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ when (annotationMode == ReaderViewModel.AnnotationMode.None) {
|
|
|
|
+ true -> showAllToolbars()
|
|
|
|
+ false -> hideTopLeftBottomToolbars()
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
private fun onIsOpenedFileUpdate(isOpened: Boolean?) {
|
|
private fun onIsOpenedFileUpdate(isOpened: Boolean?) {
|
|
if (isOpened == null) return
|
|
if (isOpened == null) return
|
|
val container = viewGroup_readerActivity_container
|
|
val container = viewGroup_readerActivity_container
|
|
@@ -146,6 +246,19 @@ abstract class ReaderActivity : AppCompatActivity() {
|
|
if (!isOpened) return
|
|
if (!isOpened) return
|
|
val context = this
|
|
val context = this
|
|
val readerView = object : KMPDFReaderView(context) {
|
|
val readerView = object : KMPDFReaderView(context) {
|
|
|
|
+ @SuppressLint("ClickableViewAccessibility")
|
|
|
|
+ override fun onTouchEvent(motionEvent: MotionEvent): Boolean {
|
|
|
|
+ if (motionEvent.action == MotionEvent.ACTION_UP) {
|
|
|
|
+ if (viewModel.isCopyModeLiveData.value == true) {
|
|
|
|
+ if (viewModel.copySelection()) {
|
|
|
|
+ val context = this@ReaderActivity
|
|
|
|
+ Toast.makeText(context, R.string.reader_copy_text_success, Toast.LENGTH_SHORT).show()
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return super.onTouchEvent(motionEvent)
|
|
|
|
+ }
|
|
|
|
+
|
|
override fun onTapMainDocArea() {
|
|
override fun onTapMainDocArea() {
|
|
super.onTapMainDocArea()
|
|
super.onTapMainDocArea()
|
|
if (isBelowKitkat()) {
|
|
if (isBelowKitkat()) {
|
|
@@ -161,9 +274,9 @@ abstract class ReaderActivity : AppCompatActivity() {
|
|
isHideToolbar = !isHideToolbar
|
|
isHideToolbar = !isHideToolbar
|
|
}
|
|
}
|
|
|
|
|
|
- override fun onMoveToChild(p0: Int) {
|
|
|
|
- super.onMoveToChild(p0)
|
|
|
|
- viewModel.setPageIndex(p0)
|
|
|
|
|
|
+ override fun onMoveToChild(pageIndex: Int) {
|
|
|
|
+ super.onMoveToChild(pageIndex)
|
|
|
|
+ viewModel.setPageIndex(pageIndex)
|
|
updateThumbnailViewSelectedPage()
|
|
updateThumbnailViewSelectedPage()
|
|
}
|
|
}
|
|
|
|
|
|
@@ -350,17 +463,150 @@ abstract class ReaderActivity : AppCompatActivity() {
|
|
}
|
|
}
|
|
|
|
|
|
private fun setupBottomToolbar() {
|
|
private fun setupBottomToolbar() {
|
|
- val context = this
|
|
|
|
- /** Set buttons color **/
|
|
|
|
- val normalColor = R.color.reader_bottom_toolbar_bottom_color_normal
|
|
|
|
- val pressColor = R.color.reader_bottom_toolbar_bottom_color_press
|
|
|
|
- Utils.setTintDrawableList(context, ib_readerActivity_bottomToolbarPrevious, R.drawable.ic_chevron_left, normalColor, pressColor)
|
|
|
|
- Utils.setTintDrawableList(context, ib_readerActivity_bottomToolbarNext, R.drawable.ic_chevron_right, normalColor, pressColor)
|
|
|
|
- Utils.setTintDrawableList(context, ib_readerActivity_bottomToolbarBookmark, R.drawable.ic_bookmark_border, normalColor, pressColor)
|
|
|
|
- Utils.setTintDrawableList(context, ib_readerActivity_bottomToolbarViewAll, R.drawable.ic_view_all, normalColor, pressColor)
|
|
|
|
- Utils.setTintDrawableList(context, ib_readerActivity_bottomToolbarKdanCloud, R.drawable.ic_kdan_cloud, normalColor, pressColor)
|
|
|
|
|
|
+ ib_readerActivity_bottomToolbarMediaBox.setOnClickListener { viewerEditView.show() }
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private fun setupViewerEditView() {
|
|
|
|
+ viewerEditView.apply {
|
|
|
|
+ onShowListener = Runnable { onMediaBoxShown() }
|
|
|
|
+ onDismissListener = Runnable { onMediaBoxDismissed() }
|
|
|
|
+ onViewerEditTabAddButtonClickListener = object : ViewerEditView.OnViewerEditTabAddButtonClickListener {
|
|
|
|
+ override fun onTabTextBoxAddButtonClick(textBoxTabView: TextBoxTabView) {
|
|
|
|
+ hideAllToolbars()
|
|
|
|
+ viewModel.setTextBoxAttribute(textBoxTabView.getTextBoxAttribute())
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ override fun onTabSignatureAddButtonClick(signatureTabView: SignatureTabView) {
|
|
|
|
+ hideAllToolbars()
|
|
|
|
+ viewModel.setSignatureAttribute(signatureTabView.getSignatureAttribute())
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ override fun onTabStampAddButtonClick(stampTabView: StampTabView) {
|
|
|
|
+ hideAllToolbars()
|
|
|
|
+ viewModel.setStampAttribute(stampTabView.getStampAttribute())
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ override fun onTabShapeAddButtonClick(shapeTabView: ShapeTabView) {
|
|
|
|
+ hideAllToolbars()
|
|
|
|
+ viewModel.setShapeAttribute(shapeTabView.getShapeAttribute())
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private fun setupRightToolbar() {
|
|
|
|
+ iv_readerActivity_copy.setOnClickListener { viewModel.onClickCopyBtn() }
|
|
|
|
+ iv_readerActivity_highLight.apply {
|
|
|
|
+ setOnClickListener { viewModel.onClickHighlightBtn() }
|
|
|
|
+ setOnLongClickListener { btn ->
|
|
|
|
+ viewModel.onLongClickHighlightBtn()
|
|
|
|
+ val context = this@ReaderActivity
|
|
|
|
+ AnnotationAttributeWindow(context, true).also { window ->
|
|
|
|
+ viewModel.highLightAttributeLiveData.value?.let { attr ->
|
|
|
|
+ window.annotationAttributeView.annotationAttribute = attr
|
|
|
|
+ }
|
|
|
|
+ window.annotationAttributeView.onChangeListener = object : AnnotationAttributeView.OnChangeListener {
|
|
|
|
+ override fun onChange(annotationAttributeView: AnnotationAttributeView) {
|
|
|
|
+ viewModel.setHighLightAttributes(annotationAttributeView.annotationAttribute)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ val contentView = window.contentView.apply {
|
|
|
|
+ val w = Utils.makeDropDownMeasureSpec(window.width)
|
|
|
|
+ val y = Utils.makeDropDownMeasureSpec(window.height)
|
|
|
|
+ measure(w, y)
|
|
|
|
+ }
|
|
|
|
+ val space = resources.getDimension(R.dimen.reader_annotation_property_setting_window_right_toolbar_space)
|
|
|
|
+ val xOff = (-contentView.measuredWidth - space).toInt()
|
|
|
|
+ val yOff = -btn.height
|
|
|
|
+ window.showAsDropDown(btn, xOff, yOff)
|
|
|
|
+ }
|
|
|
|
+ return@setOnLongClickListener true
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ iv_readerActivity_strike.apply {
|
|
|
|
+ setOnClickListener { viewModel.onClickStrikeBtn() }
|
|
|
|
+ setOnLongClickListener { btn ->
|
|
|
|
+ viewModel.onLongClickStrikeBtn()
|
|
|
|
+ val context = this@ReaderActivity
|
|
|
|
+ AnnotationAttributeWindow(context, true).also { window ->
|
|
|
|
+ viewModel.strikeAttributeLiveData.value?.let { attr ->
|
|
|
|
+ window.annotationAttributeView.annotationAttribute = attr
|
|
|
|
+ }
|
|
|
|
+ window.annotationAttributeView.onChangeListener = object : AnnotationAttributeView.OnChangeListener {
|
|
|
|
+ override fun onChange(annotationAttributeView: AnnotationAttributeView) {
|
|
|
|
+ viewModel.setStrikeOutAttributes(annotationAttributeView.annotationAttribute)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ val contentView = window.contentView.apply {
|
|
|
|
+ val w = Utils.makeDropDownMeasureSpec(window.width)
|
|
|
|
+ val y = Utils.makeDropDownMeasureSpec(window.height)
|
|
|
|
+ measure(w, y)
|
|
|
|
+ }
|
|
|
|
+ val space = resources.getDimension(R.dimen.reader_annotation_property_setting_window_right_toolbar_space)
|
|
|
|
+ val xOff = (-contentView.measuredWidth - space).toInt()
|
|
|
|
+ val yOff = -btn.height
|
|
|
|
+ window.showAsDropDown(btn, xOff, yOff)
|
|
|
|
+ }
|
|
|
|
+ return@setOnLongClickListener true
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ iv_readerActivity_underline.apply {
|
|
|
|
+ setOnClickListener { viewModel.onClickUnderlineBtn() }
|
|
|
|
+ setOnLongClickListener { btn ->
|
|
|
|
+ viewModel.onLongClickUnderlineBtn()
|
|
|
|
+ val context = this@ReaderActivity
|
|
|
|
+ AnnotationAttributeWindow(context, true).also { window ->
|
|
|
|
+ viewModel.underLineAttributeLiveData.value?.let { attr ->
|
|
|
|
+ window.annotationAttributeView.annotationAttribute = attr
|
|
|
|
+ }
|
|
|
|
+ window.annotationAttributeView.onChangeListener = object : AnnotationAttributeView.OnChangeListener {
|
|
|
|
+ override fun onChange(annotationAttributeView: AnnotationAttributeView) {
|
|
|
|
+ viewModel.setUnderLineAttributes(annotationAttributeView.annotationAttribute)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ val contentView = window.contentView.apply {
|
|
|
|
+ val w = Utils.makeDropDownMeasureSpec(window.width)
|
|
|
|
+ val y = Utils.makeDropDownMeasureSpec(window.height)
|
|
|
|
+ measure(w, y)
|
|
|
|
+ }
|
|
|
|
+ val space = resources.getDimension(R.dimen.reader_annotation_property_setting_window_right_toolbar_space)
|
|
|
|
+ val xOff = (-contentView.measuredWidth - space).toInt()
|
|
|
|
+ val yOff = -btn.height
|
|
|
|
+ window.showAsDropDown(btn, xOff, yOff)
|
|
|
|
+ }
|
|
|
|
+ return@setOnLongClickListener true
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ iv_readerActivity_ink.apply {
|
|
|
|
+ setOnClickListener { viewModel.onClickInkBtn() }
|
|
|
|
+ setOnLongClickListener { btn ->
|
|
|
|
+ viewModel.onLongClickInkBtn()
|
|
|
|
+ val context = this@ReaderActivity
|
|
|
|
+ AnnotationAttributeWindow(context, false).also { window ->
|
|
|
|
+ viewModel.inkAttributeLiveData.value?.let { attr ->
|
|
|
|
+ window.annotationAttributeView.inkAttribute = attr
|
|
|
|
+ }
|
|
|
|
+ window.annotationAttributeView.onChangeListener = object : AnnotationAttributeView.OnChangeListener {
|
|
|
|
+ override fun onChange(annotationAttributeView: AnnotationAttributeView) {
|
|
|
|
+ viewModel.setInkAttributes(annotationAttributeView.inkAttribute)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ val contentView = window.contentView.apply {
|
|
|
|
+ val w = Utils.makeDropDownMeasureSpec(window.width)
|
|
|
|
+ val y = Utils.makeDropDownMeasureSpec(window.height)
|
|
|
|
+ measure(w, y)
|
|
|
|
+ }
|
|
|
|
+ val space = resources.getDimension(R.dimen.reader_annotation_property_setting_window_right_toolbar_space)
|
|
|
|
+ val xOff = (-contentView.measuredWidth - space).toInt()
|
|
|
|
+ val yOff = -contentView.measuredHeight
|
|
|
|
+ window.showAsDropDown(btn, xOff, yOff)
|
|
|
|
+ }
|
|
|
|
+ return@setOnLongClickListener true
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
private fun setLeftToolbarWidth(width: Int) {
|
|
private fun setLeftToolbarWidth(width: Int) {
|
|
var params = viewGroup_readerActivity_leftToolbar.layoutParams as ConstraintLayout.LayoutParams
|
|
var params = viewGroup_readerActivity_leftToolbar.layoutParams as ConstraintLayout.LayoutParams
|
|
params.width = width + w_left
|
|
params.width = width + w_left
|
|
@@ -392,6 +638,14 @@ abstract class ReaderActivity : AppCompatActivity() {
|
|
cloneOriginConstraintSet()
|
|
cloneOriginConstraintSet()
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private fun onMediaBoxShown() {
|
|
|
|
+ hideAllToolbars()
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private fun onMediaBoxDismissed() {
|
|
|
|
+ showAllToolbars()
|
|
|
|
+ }
|
|
|
|
+
|
|
private fun onThumbnailClick() {
|
|
private fun onThumbnailClick() {
|
|
val type = LeftToolbarType.THUMBNAIL
|
|
val type = LeftToolbarType.THUMBNAIL
|
|
changeLeftToolbarType(type)
|
|
changeLeftToolbarType(type)
|
|
@@ -461,8 +715,7 @@ abstract class ReaderActivity : AppCompatActivity() {
|
|
leftToolbarType = type
|
|
leftToolbarType = type
|
|
}
|
|
}
|
|
|
|
|
|
- fun onClick(view: View)
|
|
|
|
- {
|
|
|
|
|
|
+ fun onClick(view: View) {
|
|
when (view.id) {
|
|
when (view.id) {
|
|
R.id.iv_readerActivity_thumbnail -> {
|
|
R.id.iv_readerActivity_thumbnail -> {
|
|
onThumbnailClick()
|
|
onThumbnailClick()
|