Browse Source

Covert reader folder into git PDFReaderReaderModule submodule

Wayne 5 years ago
parent
commit
92e9a746f8
100 changed files with 6 additions and 7632 deletions
  1. 3 0
      .gitmodules
  2. 1 0
      PDFReaderReaderModule
  3. 2 2
      app/build.gradle
  4. 0 1
      reader/.gitignore
  5. 0 50
      reader/build.gradle
  6. BIN
      reader/libs/kmpdfkit-1.0.8.1 2019-01-11.aar
  7. 0 21
      reader/proguard-rules.pro
  8. 0 26
      reader/src/androidTest/java/com/kdanmobile/reader/ExampleInstrumentedTest.java
  9. 0 20
      reader/src/main/AndroidManifest.xml
  10. 0 15
      reader/src/main/java/com/kdanmobile/reader/Config.kt
  11. 0 827
      reader/src/main/java/com/kdanmobile/reader/ReaderActivity.kt
  12. 0 578
      reader/src/main/java/com/kdanmobile/reader/ReaderViewModel.kt
  13. 0 11
      reader/src/main/java/com/kdanmobile/reader/ReaderViewModelFactory.kt
  14. 0 81
      reader/src/main/java/com/kdanmobile/reader/Utils.kt
  15. 0 5
      reader/src/main/java/com/kdanmobile/reader/annotationattribute/AnnotationAttribute.kt
  16. 0 16
      reader/src/main/java/com/kdanmobile/reader/annotationattribute/AnnotationColor.kt
  17. 0 6
      reader/src/main/java/com/kdanmobile/reader/annotationattribute/Brush.kt
  18. 0 9
      reader/src/main/java/com/kdanmobile/reader/annotationattribute/InkAttribute.kt
  19. 0 115
      reader/src/main/java/com/kdanmobile/reader/screen/adapter/BookmarkAdapter.kt
  20. 0 59
      reader/src/main/java/com/kdanmobile/reader/screen/adapter/OutlineAdapter.kt
  21. 0 83
      reader/src/main/java/com/kdanmobile/reader/screen/adapter/SearchAdapter.kt
  22. 0 138
      reader/src/main/java/com/kdanmobile/reader/screen/adapter/ThumbnailAdapter.kt
  23. 0 8
      reader/src/main/java/com/kdanmobile/reader/screen/contextmenu/TextBoxContextMenuActionListener.kt
  24. 0 5
      reader/src/main/java/com/kdanmobile/reader/screen/data/ShapeAttribute.kt
  25. 0 3
      reader/src/main/java/com/kdanmobile/reader/screen/data/SignatureAttribute.kt
  26. 0 11
      reader/src/main/java/com/kdanmobile/reader/screen/data/StampAttribute.kt
  27. 0 3
      reader/src/main/java/com/kdanmobile/reader/screen/data/TextBoxAttribute.kt
  28. 0 83
      reader/src/main/java/com/kdanmobile/reader/screen/data/ViewerSettingSharePrefs.kt
  29. 0 8
      reader/src/main/java/com/kdanmobile/reader/screen/handler/BookmarkHandler.kt
  30. 0 9
      reader/src/main/java/com/kdanmobile/reader/screen/handler/OperateHandler.kt
  31. 0 8
      reader/src/main/java/com/kdanmobile/reader/screen/handler/OutlineHandler.kt
  32. 0 5
      reader/src/main/java/com/kdanmobile/reader/screen/handler/PasswordHandler.kt
  33. 0 16
      reader/src/main/java/com/kdanmobile/reader/screen/handler/PdfInfoHandler.kt
  34. 0 14
      reader/src/main/java/com/kdanmobile/reader/screen/handler/SearchHandler.kt
  35. 0 17
      reader/src/main/java/com/kdanmobile/reader/screen/handler/ThumbnailHandler.kt
  36. 0 33
      reader/src/main/java/com/kdanmobile/reader/screen/model/SearchResultInfo.kt
  37. 0 103
      reader/src/main/java/com/kdanmobile/reader/screen/model/SharePrefsModel.kt
  38. 0 26
      reader/src/main/java/com/kdanmobile/reader/screen/model/SimpleTextWatcher.kt
  39. 0 57
      reader/src/main/java/com/kdanmobile/reader/screen/reader/mediabox/MediaBoxTabView.kt
  40. 0 304
      reader/src/main/java/com/kdanmobile/reader/screen/reader/mediabox/MediaBoxView.kt
  41. 0 51
      reader/src/main/java/com/kdanmobile/reader/screen/reader/mediabox/common/MediaBoxHeader.kt
  42. 0 90
      reader/src/main/java/com/kdanmobile/reader/screen/reader/mediabox/common/MediaBoxSeekBar.kt
  43. 0 140
      reader/src/main/java/com/kdanmobile/reader/screen/reader/mediabox/shape/ShapeTabView.kt
  44. 0 5
      reader/src/main/java/com/kdanmobile/reader/screen/reader/mediabox/signature/OnSignatureAddListener.kt
  45. 0 5
      reader/src/main/java/com/kdanmobile/reader/screen/reader/mediabox/signature/OnSignatureClickListener.kt
  46. 0 5
      reader/src/main/java/com/kdanmobile/reader/screen/reader/mediabox/signature/OnSignatureRemoveListener.kt
  47. 0 126
      reader/src/main/java/com/kdanmobile/reader/screen/reader/mediabox/signature/SignatureAdapter.kt
  48. 0 22
      reader/src/main/java/com/kdanmobile/reader/screen/reader/mediabox/signature/SignatureRecyclerViewItemDecoration.kt
  49. 0 107
      reader/src/main/java/com/kdanmobile/reader/screen/reader/mediabox/signature/SignatureTabView.kt
  50. 0 66
      reader/src/main/java/com/kdanmobile/reader/screen/reader/mediabox/stamp/CustomStampAdapter.kt
  51. 0 19
      reader/src/main/java/com/kdanmobile/reader/screen/reader/mediabox/stamp/CustomStampType.kt
  52. 0 5
      reader/src/main/java/com/kdanmobile/reader/screen/reader/mediabox/stamp/OnStampClickListener.kt
  53. 0 148
      reader/src/main/java/com/kdanmobile/reader/screen/reader/mediabox/stamp/StampTabView.kt
  54. 0 55
      reader/src/main/java/com/kdanmobile/reader/screen/reader/mediabox/stamp/StandardStampAdapter.kt
  55. 0 104
      reader/src/main/java/com/kdanmobile/reader/screen/reader/mediabox/textbox/TextAttrView.kt
  56. 0 71
      reader/src/main/java/com/kdanmobile/reader/screen/reader/mediabox/textbox/TextBoxStyleView.kt
  57. 0 95
      reader/src/main/java/com/kdanmobile/reader/screen/reader/mediabox/textbox/TextBoxTabView.kt
  58. 0 145
      reader/src/main/java/com/kdanmobile/reader/screen/signature/SignatureActivity.kt
  59. 0 102
      reader/src/main/java/com/kdanmobile/reader/screen/signature/SignatureDrawView.kt
  60. 0 82
      reader/src/main/java/com/kdanmobile/reader/screen/view/BookmarkView.kt
  61. 0 62
      reader/src/main/java/com/kdanmobile/reader/screen/view/ColorOvalView.kt
  62. 0 108
      reader/src/main/java/com/kdanmobile/reader/screen/view/ColorSelectView.kt
  63. 0 71
      reader/src/main/java/com/kdanmobile/reader/screen/view/OutlineView.kt
  64. 0 97
      reader/src/main/java/com/kdanmobile/reader/screen/view/ReadingModeSelectView.kt
  65. 0 51
      reader/src/main/java/com/kdanmobile/reader/screen/view/RowSwitchView.kt
  66. 0 39
      reader/src/main/java/com/kdanmobile/reader/screen/view/ScreenSettingView.kt
  67. 0 374
      reader/src/main/java/com/kdanmobile/reader/screen/view/SearchView.kt
  68. 0 73
      reader/src/main/java/com/kdanmobile/reader/screen/view/ThumbnailView.kt
  69. 0 51
      reader/src/main/java/com/kdanmobile/reader/screen/view/ToolbarSettingView.kt
  70. 0 66
      reader/src/main/java/com/kdanmobile/reader/screen/view/TurnPageModeSelectView.kt
  71. 0 143
      reader/src/main/java/com/kdanmobile/reader/setting/ReaderSettingActivity.kt
  72. 0 65
      reader/src/main/java/com/kdanmobile/reader/setting/ReaderSettingViewModel.kt
  73. 0 11
      reader/src/main/java/com/kdanmobile/reader/setting/ReaderSettingViewModelFactory.kt
  74. 0 108
      reader/src/main/java/com/kdanmobile/reader/thumb/FileUtil.kt
  75. 0 12
      reader/src/main/java/com/kdanmobile/reader/thumb/ItemMoveSwipeListener.kt
  76. 0 34
      reader/src/main/java/com/kdanmobile/reader/thumb/ItemTouchHelpCallback.kt
  77. 0 309
      reader/src/main/java/com/kdanmobile/reader/thumb/PdfThumbActivity.kt
  78. 0 121
      reader/src/main/java/com/kdanmobile/reader/thumb/PdfThumbAdapter.kt
  79. 0 246
      reader/src/main/java/com/kdanmobile/reader/thumb/PdfThumbViewModel.kt
  80. 0 10
      reader/src/main/java/com/kdanmobile/reader/thumb/PdfThumbViewModelFactory.kt
  81. 0 23
      reader/src/main/java/com/kdanmobile/reader/thumb/ScreenUtil.kt
  82. 0 15
      reader/src/main/java/com/kdanmobile/reader/thumb/ThumbData.kt
  83. 0 23
      reader/src/main/java/com/kdanmobile/reader/thumb/mode/EditMode.kt
  84. 0 11
      reader/src/main/java/com/kdanmobile/reader/thumb/mode/Mode.kt
  85. 0 24
      reader/src/main/java/com/kdanmobile/reader/thumb/mode/NormalMode.kt
  86. 0 395
      reader/src/main/java/com/kdanmobile/reader/utils/AnimationUtil.kt
  87. 0 46
      reader/src/main/java/com/kdanmobile/reader/utils/DensityUtil.kt
  88. 0 274
      reader/src/main/java/com/kdanmobile/reader/view/AnnotationAttributeView.kt
  89. 0 22
      reader/src/main/java/com/kdanmobile/reader/view/AnnotationAttributeWindow.kt
  90. 0 32
      reader/src/main/java/com/kdanmobile/reader/view/ColorOpacityDisplayerView.kt
  91. 0 330
      reader/src/main/java/com/kdanmobile/reader/view/HorizontalView.java
  92. 0 20
      reader/src/main/java/com/kdanmobile/reader/view/NonSwipeableViewPage.kt
  93. 0 82
      reader/src/main/java/com/kdanmobile/reader/view/WaveLineView.java
  94. 0 55
      reader/src/main/java/com/kdanmobile/reader/widget/drag/OnRecyclerItemClickListener.kt
  95. 0 5
      reader/src/main/res/color/selector_annotation_attribute_seek_bar.xml
  96. 0 5
      reader/src/main/res/color/selector_annotation_attribute_seek_bar_background.xml
  97. BIN
      reader/src/main/res/drawable-hdpi/ic_arrowback_black_24dp.png
  98. BIN
      reader/src/main/res/drawable-hdpi/ic_arrowback_blue_24dp.png
  99. BIN
      reader/src/main/res/drawable-hdpi/ic_checkbox_off_blue_24dp.png
  100. 0 0
      reader/src/main/res/drawable-hdpi/ic_checkbox_on_blue_24dp.png

+ 3 - 0
.gitmodules

@@ -0,0 +1,3 @@
+[submodule "PDFReaderReaderModule"]
+	path = PDFReaderReaderModule
+	url = https://bitbucket.org/kdanandroid/pdfreaderreadermodule.git

+ 1 - 0
PDFReaderReaderModule

@@ -0,0 +1 @@
+Subproject commit 8c3d769dacba38c5a1ddb10f5b09c73613827bf3

+ 2 - 2
app/build.gradle

@@ -37,11 +37,11 @@ dependencies {
     androidTestImplementation 'com.android.support.test:runner:1.0.2'
     androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
 
-    implementation project(':reader')
+    implementation project(':PDFReaderReaderModule')
 }
 
 repositories {
     flatDir {
-        dirs 'libs', '../reader/libs'
+        dirs 'libs', '../PDFReaderReaderModule/libs'
     }
 }

+ 0 - 1
reader/.gitignore

@@ -1 +0,0 @@
-/build

+ 0 - 50
reader/build.gradle

@@ -1,50 +0,0 @@
-apply plugin: 'com.android.library'
-apply plugin: 'kotlin-android'
-apply plugin: 'kotlin-android-extensions'
-
-android {
-    compileSdkVersion 28
-
-    defaultConfig {
-        minSdkVersion 15
-        targetSdkVersion 28
-        versionCode 1
-        versionName "1.0"
-
-        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
-
-    }
-
-    buildTypes {
-        release {
-            minifyEnabled false
-            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
-        }
-    }
-
-}
-
-ext {
-    daggerVersion = 2.12
-    lifecycleVersion = "1.1.0"
-}
-
-dependencies {
-    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
-
-    implementation 'com.android.support:appcompat-v7:28.0.0'
-    implementation 'com.android.support:design:28.0.0'
-    implementation 'com.android.support:cardview-v7:28.0.0'
-    implementation 'com.android.support:recyclerview-v7:28.0.0'
-    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
-    implementation "android.arch.lifecycle:extensions:$lifecycleVersion"
-    implementation "android.arch.lifecycle:common-java8:$lifecycleVersion"
-    androidTestImplementation 'com.android.support.test:runner:1.0.2'
-    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
-    api 'io.reactivex.rxjava2:rxandroid:2.1.0'
-    api 'io.reactivex.rxjava2:rxjava:2.2.2'
-
-    testImplementation 'junit:junit:4.12'
-
-    api(name: 'kmpdfkit-1.0.8.1 2019-01-11', ext: 'aar')
-}

BIN
reader/libs/kmpdfkit-1.0.8.1 2019-01-11.aar


+ 0 - 21
reader/proguard-rules.pro

@@ -1,21 +0,0 @@
-# Add project specific ProGuard rules here.
-# You can control the set of applied configuration files using the
-# proguardFiles setting in build.gradle.
-#
-# For more details, see
-#   http://developer.android.com/guide/developing/tools/proguard.html
-
-# If your project uses WebView with JS, uncomment the following
-# and specify the fully qualified class name to the JavaScript interface
-# class:
-#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
-#   public *;
-#}
-
-# Uncomment this to preserve the line number information for
-# debugging stack traces.
-#-keepattributes SourceFile,LineNumberTable
-
-# If you keep the line number information, uncomment this to
-# hide the original source file name.
-#-renamesourcefileattribute SourceFile

+ 0 - 26
reader/src/androidTest/java/com/kdanmobile/reader/ExampleInstrumentedTest.java

@@ -1,26 +0,0 @@
-package com.kdanmobile.reader;
-
-import android.content.Context;
-import android.support.test.InstrumentationRegistry;
-import android.support.test.runner.AndroidJUnit4;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import static org.junit.Assert.*;
-
-/**
- * Instrumented test, which will execute on an Android device.
- *
- * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
- */
-@RunWith(AndroidJUnit4.class)
-public class ExampleInstrumentedTest {
-    @Test
-    public void useAppContext() {
-        // Context of the app under test.
-        Context appContext = InstrumentationRegistry.getTargetContext();
-
-        assertEquals("com.kdanmobile.reader.test", appContext.getPackageName());
-    }
-}

+ 0 - 20
reader/src/main/AndroidManifest.xml

@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
-    package="com.kdanmobile.reader">
-    <application>
-        <activity
-            android:name=".ReaderActivity"
-            android:theme="@style/ReaderActivityNoActionBarNoTitle" />
-        <activity
-            android:name=".setting.ReaderSettingActivity"
-            android:theme="@style/ReaderActivityNoActionBarNoTitle" />
-        <activity
-            android:name=".screen.signature.SignatureActivity"
-            android:screenOrientation="userLandscape"
-            android:theme="@style/ReaderActivityNoActionBarNoTitle" />
-        <activity
-            android:name=".thumb.PdfThumbActivity"
-            android:theme="@style/ReaderActivityNoActionBarNoTitle" />
-    </application>
-
-</manifest>

+ 0 - 15
reader/src/main/java/com/kdanmobile/reader/Config.kt

@@ -1,15 +0,0 @@
-package com.kdanmobile.reader
-
-import android.content.Context
-import java.io.File
-
-object Config {
-    var PDF_SDK_LICENSE = ""
-    var PDF_SDK_RSA_MSG = ""
-
-    const val SIGNATURE_FOLDER = "Signature"
-
-    fun getSignatureDirectoryPath(context: Context) : String {
-        return "${context.filesDir.absolutePath}${File.separator}$SIGNATURE_FOLDER"
-    }
-}

+ 0 - 827
reader/src/main/java/com/kdanmobile/reader/ReaderActivity.kt

@@ -1,827 +0,0 @@
-package com.kdanmobile.reader
-
-import android.annotation.SuppressLint
-import android.app.Activity
-import android.arch.lifecycle.Observer
-import android.arch.lifecycle.ViewModelProviders
-import android.content.Intent
-import android.net.Uri
-import android.os.Build
-import android.os.Bundle
-import android.support.constraint.ConstraintLayout
-import android.support.constraint.ConstraintSet
-import android.support.design.widget.Snackbar
-import android.support.v4.content.ContextCompat
-import android.support.v7.app.AlertDialog
-import android.support.v7.app.AppCompatActivity
-import android.util.DisplayMetrics
-import android.view.Menu
-import android.view.MenuItem
-import android.view.MotionEvent
-import android.view.View
-import android.widget.EditText
-import android.widget.LinearLayout
-import android.widget.TextView
-import android.widget.Toast
-import com.kdanmobile.kmpdfkit.globaldata.KMPDFAnnotEditMode
-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.contextmenu.TextBoxContextMenuActionListener
-import com.kdanmobile.reader.screen.reader.mediabox.MediaBoxView
-import com.kdanmobile.reader.screen.reader.mediabox.shape.ShapeTabView
-import com.kdanmobile.reader.screen.reader.mediabox.signature.SignatureTabView
-import com.kdanmobile.reader.screen.reader.mediabox.stamp.StampTabView
-import com.kdanmobile.reader.screen.reader.mediabox.textbox.TextBoxTabView
-import com.kdanmobile.reader.screen.view.BookmarkView
-import com.kdanmobile.reader.screen.view.OutlineView
-import com.kdanmobile.reader.screen.view.SearchView
-import com.kdanmobile.reader.screen.view.ThumbnailView
-import com.kdanmobile.reader.setting.ReaderSettingActivity
-import com.kdanmobile.reader.utils.AnimationUtil
-import com.kdanmobile.reader.utils.DensityUtil
-import com.kdanmobile.reader.view.AnnotationAttributeView
-import com.kdanmobile.reader.view.AnnotationAttributeWindow
-import com.kdanmobile.reader.thumb.PdfThumbActivity
-import kotlinx.android.synthetic.main.activity_reader.*
-
-abstract class ReaderActivity : AppCompatActivity() {
-
-    abstract fun onClickShare()
-    abstract fun onClickTextReflow()
-    abstract fun onClickFileInfo()
-    abstract fun onClickPrint()
-    abstract fun onClickUserGuide()
-    abstract fun transferThumbIntent(): Intent
-
-    companion object {
-        const val KEY_FILE_ABSOLUTE = "file_absolutepath"
-        const val THUMB = 221
-    }
-
-    private lateinit var viewModel: ReaderViewModel
-
-    // For hide/show toolbars
-    private var isHideToolbar = false
-    private lateinit var originConstraintSet: ConstraintSet
-
-    private var menuItemBookmark: MenuItem? = null
-
-    private val UI_ANIMATION_DURATION = 300L
-
-    private var w_318: Int = 0
-    private var w_240: Int = 0
-    private var w_left: Int = 0
-
-    private var oldLeftToolbarType = ReaderViewModel.LeftToolbarType.NONE
-
-    private var snackbarMediaBox: Snackbar? = null
-
-    override fun onCreate(savedInstanceState: Bundle?) {
-        super.onCreate(savedInstanceState)
-        setContentView(R.layout.activity_reader)
-        setSupportActionBar(toolbar_readerActivity)
-
-        val displayMetrics = DisplayMetrics()
-        windowManager.defaultDisplay.getMetrics(displayMetrics)
-        val width = Math.min(DensityUtil.getScreenWidthPx(baseContext), DensityUtil.getScreenHeightPx(baseContext))
-        w_318 = 318 * width / 800
-        w_240 = 240 * width / 800
-        w_left = resources.getDimension(R.dimen.reader_left_right_toolbar_icon_width).toInt()
-
-        cloneOriginConstraintSet()
-        setupToolbar()
-        setupLeftToolbar()
-        setupRightSideToolbar()
-        setupBottomToolbar()
-        setupMediaBoxView()
-
-        val factory = ReaderViewModelFactory()
-        viewModel = ViewModelProviders.of(this, factory).get(ReaderViewModel::class.java)
-        viewModel.isOpenedFileLiveData.observe(this, Observer(this::onIsOpenedFileUpdate))
-        viewModel.fileNameLiveData.observe(this, Observer { tv_readerActivity_title.text = it })
-        viewModel.annotationModeLiveData.observe(this, Observer(this::onAnnotationModeUpdate))
-        viewModel.annotationEitModeLiveData.observe(this, Observer(this::onAnnotationEditModeUpdate))
-        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 ->
-            if (isOpened) return@also
-            val filePath = intent.getStringExtra(KEY_FILE_ABSOLUTE)
-            val uri = Uri.parse(filePath)
-            viewModel.openPdfFile(this, uri, intent.type)
-        }
-        setupRightToolbar()
-        viewModel.pageIndexLiveData.observe(this, Observer(this::onPageIndexChanged))
-        viewModel.isPageInBookmarksLiveData.observe(this, Observer(this::onIsPageInBookmarksChanged))
-        viewModel.isLeftToolbarOpenLiveData.observe(this, Observer(this::onLeftToolbarOpenStateChanged))
-        viewModel.leftToolbarTypeLiveData.observe(this, Observer(this::onLeftToolbarTypeChanged))
-    }
-
-    override fun onBackPressed() {
-        when {
-            mediaBoxView.isShown -> mediaBoxView.dismiss()
-            else -> super.onBackPressed()
-        }
-    }
-
-    override fun onCreateOptionsMenu(menu: Menu?): Boolean {
-        menuInflater.inflate(R.menu.reader_more, menu)
-        menuItemBookmark = menu?.findItem(R.id.item_reader_bookmark)
-        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
-            menu?.findItem(R.id.item_reader_more_print)?.isVisible = false
-        }
-        // TODO: Check is pdf file or epub file, these action support only pdf file
-        val isPdf = true
-        if (!isPdf) {
-            menu?.apply {
-                findItem(R.id.item_reader_more_text_reflow)?.isVisible = false
-                findItem(R.id.item_reader_more_file_info)?.isVisible = false
-                findItem(R.id.item_reader_more_print)?.isVisible = false
-            }
-        }
-        return true
-    }
-
-    @SuppressLint("RestrictedApi")
-    override fun onPrepareOptionsPanel(view: View?, menu: Menu?): Boolean {
-        /** Force show action menu item icon **/
-        menu?.also {
-            if ("MenuBuilder" != it::javaClass.get().simpleName) return@also
-            try {
-                val method = it.javaClass.getDeclaredMethod("setOptionalIconsVisible", java.lang.Boolean.TYPE)
-                method.isAccessible = true
-                method.invoke(it, true)
-            } catch (e: Exception) {
-                // Do nothing
-            }
-        }
-        return super.onPrepareOptionsPanel(view, menu)
-    }
-
-    private fun cloneOriginConstraintSet() {
-        if (!isBelowKitkat()) {
-            originConstraintSet = ConstraintSet().apply {
-                clone(constrainLayout_readerActivity_root)
-            }
-        }
-    }
-
-    private fun onIsCopyModeUpdate(isCopyMode: Boolean?) {
-        if (isCopyMode == null) return
-        when (isCopyMode) {
-            true -> hideTopLeftBottomToolbars()
-            false -> 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_reader_right_toolbar_ink_color1
-                    AnnotationColor.Color2 -> R.drawable.ic_reader_right_toolbar_ink_color2
-                    AnnotationColor.Color3 -> R.drawable.ic_reader_right_toolbar_ink_color3
-                    AnnotationColor.Color4 -> R.drawable.ic_reader_right_toolbar_ink_color4
-                    AnnotationColor.Color5 -> R.drawable.ic_reader_right_toolbar_ink_color5
-                    AnnotationColor.Color6 -> R.drawable.ic_reader_right_toolbar_ink_color6
-                    AnnotationColor.Color7 -> R.drawable.ic_reader_right_toolbar_ink_color7
-                    AnnotationColor.Color8 -> R.drawable.ic_reader_right_toolbar_ink_color8
-                    AnnotationColor.Color9 -> R.drawable.ic_reader_right_toolbar_ink_color9
-                    AnnotationColor.Color10 -> R.drawable.ic_reader_right_toolbar_ink_color10
-                }
-                iv_readerActivity_ink.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 onAnnotationEditModeUpdate(mode: KMPDFAnnotEditMode.Mode?) {
-        when (mode) {
-            KMPDFAnnotEditMode.Mode.NULL -> {
-                showAllToolbars()
-                isHideToolbar = false
-                snackbarMediaBox?.dismiss()
-                snackbarMediaBox = null
-            }
-            KMPDFAnnotEditMode.Mode.SIGN_MODIFY -> {
-                hideAllToolbars()
-                isHideToolbar = true
-            }
-            KMPDFAnnotEditMode.Mode.FREETEXT_MODIFY, KMPDFAnnotEditMode.Mode.STAMP_MODIFY, KMPDFAnnotEditMode.Mode.SHAPE_MODIFY -> {
-                hideAllToolbars()
-                isHideToolbar = true
-                snackbarMediaBox?.dismiss()
-                snackbarMediaBox = null
-            }
-            else -> {}
-        }
-    }
-
-    private fun onIsOpenedFileUpdate(isOpened: Boolean?) {
-        if (isOpened == null) return
-        val container = viewGroup_readerActivity_container
-        container.removeAllViews()
-        if (!isOpened) return
-        val context = this
-        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() {
-                super.onTapMainDocArea()
-                when (isHideToolbar) {
-                    true -> showAllToolbars()
-                    false -> hideAllToolbars()
-                }
-                isHideToolbar = !isHideToolbar
-            }
-
-            override fun onMoveToChild(pageIndex: Int) {
-                super.onMoveToChild(pageIndex)
-                viewModel.setPageIndex(pageIndex)
-                updateThumbnailViewSelectedPage()
-            }
-
-            override fun onScroll(e1: MotionEvent?, e2: MotionEvent?, distanceX: Float, distanceY: Float): Boolean {
-                val isEditMode = viewModel.annotationModeLiveData.value != ReaderViewModel.AnnotationMode.None
-                val isCopyMode = viewModel.isCopyModeLiveData.value != false
-
-                if (!isEditMode && !isCopyMode && !isHideToolbar) {
-                    hideAllToolbars()
-                    isHideToolbar = true
-                }
-                return super.onScroll(e1, e2, distanceX, distanceY)
-            }
-        }
-        viewModel.setReaderView(readerView)
-        viewModel.pdfInfoHandler.setCurrentPage(viewModel.pageIndexLiveData.value ?: 0)
-        initTextBoxContextMenuActions()
-        container.addView(readerView)
-    }
-
-    private fun initTextBoxContextMenuActions() {
-        viewModel.setTextBoxContextMenuActions(object : TextBoxContextMenuActionListener {
-            override fun onDelete(): Boolean {
-                viewModel.deleteSelectedTextBox()
-                return true
-            }
-
-            override fun onEditStyle(): Boolean {
-                mediaBoxView.showTextBoxStyleView()
-                viewModel.editSelectedTextBoxStyle()
-                return true
-            }
-
-            override fun onEditText(): Boolean {
-                hideAllToolbars()
-                isHideToolbar = true
-                viewModel.editSelectedTextBoxText()
-                return true
-            }
-
-            override fun onCopy(): Boolean {
-                viewModel.copySelectedTextBox()
-                return true
-            }
-        })
-    }
-
-    override fun onDestroy() {
-        viewModel.saveModifyingAnnotationBeforeDestroy()
-        super.onDestroy()
-    }
-
-    private fun onPageIndexChanged(pageIndex: Int?) {
-        pageIndex?.let {
-            viewModel.setBookmarkDisplay(pageIndex)
-        }
-    }
-
-    private fun onIsPageInBookmarksChanged(isPageInBookmarks: Boolean?) {
-        isPageInBookmarks?.let {
-            if (it) {
-                menuItemBookmark?.icon = ContextCompat.getDrawable(this, R.drawable.ic_bookmark_fill)
-            } else {
-                menuItemBookmark?.icon = ContextCompat.getDrawable(this, R.drawable.ic_bookmark_border)
-            }
-        }
-    }
-
-    private fun isBelowKitkat(): Boolean {
-        return true
-//        return Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT
-    }
-
-    private fun showAllToolbars() {
-        if (isBelowKitkat()) {
-            val duration = ((1 - toolbar_readerActivity.alpha) * UI_ANIMATION_DURATION).toLong()
-            AnimationUtil.showViewFromTopToBottom(toolbar_readerActivity, duration)
-            AnimationUtil.showViewFromBottomToTop(viewGroup_readerActivity_bottomToolbar, duration)
-            AnimationUtil.showViewFromLeftToRight(viewGroup_readerActivity_leftToolbar, duration)
-            AnimationUtil.showViewFromRightToLeft(viewGroup_readerActivity_rightToolbar, duration)
-        } else {
-            constrainLayout_readerActivity_root.applyConstraintSet(originConstraintSet, UI_ANIMATION_DURATION)
-        }
-    }
-
-    private fun hideAllToolbars() {
-        if (isBelowKitkat()) {
-            val duration = (toolbar_readerActivity.alpha * UI_ANIMATION_DURATION).toLong()
-            AnimationUtil.hideViewFromBottomToTop(toolbar_readerActivity, duration)
-            AnimationUtil.hideViewFromTopToBottom(viewGroup_readerActivity_bottomToolbar, duration)
-            AnimationUtil.hideViewFromRightToLeft(viewGroup_readerActivity_leftToolbar, duration)
-            AnimationUtil.hideViewFromLeftToRight(viewGroup_readerActivity_rightToolbar, duration)
-            hideSearchViewSoftKeyboard()
-        } else {
-            constrainLayout_readerActivity_root.applyConstraintSet(this, R.layout.activity_reader_hide_all, UI_ANIMATION_DURATION)
-        }
-    }
-
-    private fun hideTopLeftBottomToolbars() {
-        if (isBelowKitkat()) {
-            val duration = (toolbar_readerActivity.alpha * UI_ANIMATION_DURATION).toLong()
-            AnimationUtil.hideViewFromBottomToTop(toolbar_readerActivity, duration)
-            AnimationUtil.hideViewFromTopToBottom(viewGroup_readerActivity_bottomToolbar, duration)
-            AnimationUtil.hideViewFromRightToLeft(viewGroup_readerActivity_leftToolbar, duration)
-            hideSearchViewSoftKeyboard()
-        } else {
-            constrainLayout_readerActivity_root.applyConstraintSet(this, R.layout.activity_reader_hide_top_left_bottom, UI_ANIMATION_DURATION)
-        }
-    }
-
-    private fun updateThumbnailViewSelectedPage() {
-        val view = linearLayout_readerActivity_leftToolbarContainer.getChildAt(0)
-        if (view is ThumbnailView) {
-            val currentPage = viewModel.pdfInfoHandler.getCurrentPage()
-            view.onScrollToPosition(currentPage, true)
-        }
-    }
-
-    private fun updateBookmarkView() {
-        val view = linearLayout_readerActivity_leftToolbarContainer.getChildAt(0)
-        if (view is BookmarkView) {
-            view.updateBookmark()
-        }
-    }
-
-    private fun setupToolbar() {
-        toolbar_readerActivity.setOnMenuItemClickListener {
-            when (it.itemId) {
-                R.id.item_reader_bookmark -> onClickBookmark()
-                R.id.item_reader_more_text_reflow -> onClickTextReflow()
-                R.id.item_reader_more_file_info -> onClickFileInfo()
-                R.id.item_reader_more_print -> onClickPrint()
-                R.id.item_reader_more_user_guide -> onClickUserGuide()
-            }
-            return@setOnMenuItemClickListener true
-        }
-    }
-
-    private fun onClickBookmark() {
-        viewModel.isPageInBookmarksLiveData.value?.let {
-            if (!it) {
-                showAddBookmarkDialog()
-            } else {
-                showDeleteBookmarkDialog()
-            }
-        }
-    }
-
-    private fun showAddBookmarkDialog() {
-        val alertDialogBuilder = AlertDialog.Builder(this)
-        val editText = EditText(this)
-        val layoutParams =
-                LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT)
-
-        editText.layoutParams = layoutParams
-        val defaultTitle = getString(R.string.dialogAddBookmark_page) + " " + (viewModel.pdfInfoHandler.getCurrentPage() + 1)
-        editText.setText(defaultTitle, TextView.BufferType.EDITABLE)
-        editText.setSelection(0, defaultTitle.length)
-
-        alertDialogBuilder.setTitle(getString(R.string.reader_alert_dialog_title_add_bookmark))
-        alertDialogBuilder.setView(editText)
-        alertDialogBuilder.setPositiveButton(getString(R.string.reader_alert_dialog_button_confirm)) { dialog, which ->
-            viewModel.addBookmark(editText.text.toString())
-            updateBookmarkView()
-        }
-        alertDialogBuilder.setNegativeButton(getString(R.string.reader_alert_dialog_button_cancel)) { dialog, which ->
-        }
-        alertDialogBuilder.create().show()
-        editText.requestFocus()
-    }
-
-    private fun getBookmarkTitle(page: Int): String {
-        val bookmarks = viewModel.bookmarkHandler.getBookmarks()
-        for (bookmark in bookmarks) {
-            if (bookmark.pageNum == page) {
-                return bookmark.title
-            }
-        }
-        return ""
-    }
-
-    private fun showDeleteBookmarkDialog() {
-        val alertDialogBuilder = AlertDialog.Builder(this)
-        alertDialogBuilder.setTitle(getString(R.string.reader_alert_dialog_title_delete_bookmark))
-        val bookmarkTitle = getBookmarkTitle(viewModel.pdfInfoHandler.getCurrentPage())
-        val message = String.format(getString(R.string.reader_alert_dialog_message_delete_bookmark), bookmarkTitle)
-        alertDialogBuilder.setMessage(message)
-        alertDialogBuilder.setPositiveButton(getString(R.string.reader_alert_dialog_button_confirm)) { dialog, which ->
-            viewModel.deleteBookmark()
-            updateBookmarkView()
-        }
-        alertDialogBuilder.setNegativeButton(getString(R.string.reader_alert_dialog_button_cancel)) { dialog, which ->
-        }
-        alertDialogBuilder.create().show()
-    }
-
-    private fun hideSearchViewSoftKeyboard() {
-        val view = linearLayout_readerActivity_leftToolbarContainer.getChildAt(0)
-        if (view is SearchView) {
-            view.hideSoftKeyboard()
-        }
-    }
-
-    private fun setupLeftToolbar() {
-        viewGroup_readerActivity_leftToolbar.setScroll(false)
-        setLeftToolbarWidth(w_240)
-        viewGroup_readerActivity_leftToolbar.smoothScrollTo(w_240, 0, 0)
-        val child = layoutInflater.inflate(R.layout.view_thumbnail, null)
-        linearLayout_readerActivity_leftToolbarContainer.addView(child)
-
-        fun onClickLeftToolbarItem(leftToolbarType: ReaderViewModel.LeftToolbarType) {
-            viewModel.setLeftToolbarType(leftToolbarType)
-            updateLeftToolbarOpenState(leftToolbarType)
-        }
-
-        iv_readerActivity_thumbnail.setOnClickListener { onClickLeftToolbarItem(ReaderViewModel.LeftToolbarType.THUMBNAIL) }
-        iv_readerActivity_bookmark.setOnClickListener { onClickLeftToolbarItem(ReaderViewModel.LeftToolbarType.BOOKMARK) }
-        iv_readerActivity_outline.setOnClickListener { onClickLeftToolbarItem(ReaderViewModel.LeftToolbarType.OUTLINE) }
-        iv_readerActivity_search.setOnClickListener { onClickLeftToolbarItem(ReaderViewModel.LeftToolbarType.SEARCH) }
-    }
-
-    private fun setupRightSideToolbar() {
-        iv_readerActivity_setting.setOnClickListener {
-            startActivity(Intent(this, ReaderSettingActivity::class.java))
-        }
-    }
-
-    private fun setupBottomToolbar() {
-        ib_readerActivity_bottomToolbarMediaBox.setOnClickListener { mediaBoxView.show() }
-        ib_readerActivity_bottomToolbarViewAll.setOnClickListener {
-            onClickBottomThumb1()
-            viewModel.transferKmpdfCore()
-        }
-    }
-
-    private fun setupMediaBoxView() {
-
-        fun showSnackbar(title: String, btnText: String) {
-            snackbarMediaBox = Snackbar.make(mediaBoxView, title, Snackbar.LENGTH_INDEFINITE)
-                    .setAction(btnText) {
-                        viewModel.clearSelection()
-                        mediaBoxView.post {
-                            mediaBoxView.show()
-                            snackbarMediaBox?.dismiss()
-                            snackbarMediaBox = null
-                        }
-                    }
-            snackbarMediaBox?.setActionTextColor(ContextCompat.getColor(this, R.color.bright_blue))
-            snackbarMediaBox?.show()
-        }
-
-        mediaBoxView.apply {
-            onShowListener = Runnable {
-                onMediaBoxShown()
-                snackbarMediaBox?.dismiss()
-                snackbarMediaBox = null
-            }
-            onDismissListener = Runnable {
-                onMediaBoxDismissed()
-                snackbarMediaBox?.dismiss()
-                snackbarMediaBox = null
-            }
-            onClickAddButtonListener = object : MediaBoxView.OnClickHeaderButtonListener {
-                override fun onClickTextBoxAddButton(textBoxTabView: TextBoxTabView) {
-                    dismiss(false)
-                    viewModel.setTextBoxAttribute(textBoxTabView.getTextBoxAttribute())
-                    showSnackbar(resources.getString(R.string.reader_mediaBox_snakebar_textBox), resources.getString(R.string.reader_mediaBox_snakebar_undo))
-                }
-
-                override fun onClickTextBoxStyleApplyButton(textBoxTabView: TextBoxTabView) {
-                    dismiss(false)
-                    viewModel.setTextBoxAttribute(textBoxTabView.getTextBoxAttribute(), true)
-                }
-
-                override fun onClickSignatureAddButton(signatureTabView: SignatureTabView) {
-                    dismiss(false)
-                    viewModel.setSignatureAttribute(signatureTabView.getSignatureAttribute())
-                    showSnackbar(resources.getString(R.string.reader_mediaBox_snakebar_signature), resources.getString(R.string.reader_mediaBox_snakebar_undo))
-                }
-
-                override fun onClickStampAddButton(stampTabView: StampTabView) {
-                    dismiss(false)
-                    viewModel.setStampAttribute(stampTabView.getStampAttribute())
-                    showSnackbar(resources.getString(R.string.reader_mediaBox_snakebar_stamp), resources.getString(R.string.reader_mediaBox_snakebar_undo))
-                }
-
-                override fun onClickShapeAddButton(shapeTabView: ShapeTabView) {
-                    dismiss(false)
-                    viewModel.setShapeAttribute(shapeTabView.getShapeAttribute())
-                    showSnackbar(resources.getString(R.string.reader_mediaBox_snakebar_shape), resources.getString(R.string.reader_mediaBox_snakebar_undo))
-                }
-            }
-        }
-    }
-
-    private fun setupRightToolbar() {
-        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) {
-        var params = viewGroup_readerActivity_leftToolbar.layoutParams as ConstraintLayout.LayoutParams
-        params.width = width + w_left
-        params.height = 0
-        viewGroup_readerActivity_leftToolbar.layoutParams = params
-
-        params = linearLayout_readerActivity_leftToolbarContainer.layoutParams as ConstraintLayout.LayoutParams
-        params.width = width
-        linearLayout_readerActivity_leftToolbarContainer.layoutParams = params
-    }
-
-    private fun updateLeftToolbarOpenState(type: ReaderViewModel.LeftToolbarType) {
-        val isLeftToolbarOpen = viewModel.isLeftToolbarOpenLiveData.value ?: false
-        viewModel.setIsLeftToolbarOpen(!isLeftToolbarOpen || oldLeftToolbarType != type)
-        cloneOriginConstraintSet()
-    }
-
-    private fun onMediaBoxShown() {
-        hideAllToolbars()
-        isHideToolbar = true
-    }
-
-    private fun onMediaBoxDismissed() {
-        showAllToolbars()
-        isHideToolbar = false
-        viewModel.clearSelection()
-    }
-
-    private fun setLeftToolbarContentView(leftToolbarType: ReaderViewModel.LeftToolbarType) {
-        if (oldLeftToolbarType != leftToolbarType) {
-            linearLayout_readerActivity_leftToolbarContainer.removeAllViews()
-            val view = when (leftToolbarType) {
-                ReaderViewModel.LeftToolbarType.NONE,
-                ReaderViewModel.LeftToolbarType.THUMBNAIL -> {
-                    val thumbnailView = ThumbnailView(this)
-                    thumbnailView.setHandlers(viewModel.pdfInfoHandler, viewModel.thumbnailHandler)
-                    thumbnailView
-                }
-                ReaderViewModel.LeftToolbarType.BOOKMARK -> {
-                    val bookmarkView = BookmarkView(this)
-                    bookmarkView.setHandlers(viewModel.pdfInfoHandler, viewModel.thumbnailHandler, viewModel.bookmarkHandler)
-                    bookmarkView
-                }
-                ReaderViewModel.LeftToolbarType.OUTLINE -> {
-                    val outlineView = OutlineView(this)
-                    outlineView.setHandlers(viewModel.pdfInfoHandler, viewModel.outlineHandler)
-                    outlineView
-                }
-                ReaderViewModel.LeftToolbarType.SEARCH -> {
-                    val searchView = SearchView(this)
-                    searchView.setHandlers(viewModel.pdfInfoHandler, viewModel.searchHandler)
-                    searchView
-                }
-            }
-            linearLayout_readerActivity_leftToolbarContainer.addView(view)
-            oldLeftToolbarType = leftToolbarType
-        }
-    }
-
-    private fun getLeftToolbarContentWidth(): Int {
-        return when (viewModel.leftToolbarTypeLiveData.value == ReaderViewModel.LeftToolbarType.THUMBNAIL) {
-            true -> w_240
-            false -> w_318
-        }
-    }
-
-    private fun onLeftToolbarTypeChanged(leftToolbarType: ReaderViewModel.LeftToolbarType?) {
-        updateLeftToolbarIcons()
-        setLeftToolbarWidth(getLeftToolbarContentWidth())
-        cloneOriginConstraintSet()
-
-        if (leftToolbarType != null) {
-            setLeftToolbarContentView(leftToolbarType)
-        }
-    }
-
-    private fun onLeftToolbarOpenStateChanged(open: Boolean?) {
-        updateLeftToolbarIcons()
-
-        when (open == true) {
-            true -> viewGroup_readerActivity_leftToolbar.smoothScrollTo(0, 0, UI_ANIMATION_DURATION.toInt())
-            false -> viewGroup_readerActivity_leftToolbar.smoothScrollTo(getLeftToolbarContentWidth(), 0, UI_ANIMATION_DURATION.toInt())
-        }
-    }
-
-
-    private fun updateLeftToolbarIcons() {
-        iv_readerActivity_thumbnail.setImageResource(R.drawable.ic_left_toolbar_thumbnails)
-        iv_readerActivity_bookmark.setImageResource(R.drawable.ic_left_toolbar_bookmarks)
-        iv_readerActivity_outline.setImageResource(R.drawable.ic_left_toolbar_outline)
-        iv_readerActivity_search.setImageResource(R.drawable.ic_left_toolbar_search)
-        if (viewModel.isLeftToolbarOpenLiveData.value == true) {
-            when (viewModel.leftToolbarTypeLiveData.value) {
-                ReaderViewModel.LeftToolbarType.NONE -> {}
-                ReaderViewModel.LeftToolbarType.THUMBNAIL -> iv_readerActivity_thumbnail.setImageResource(R.drawable.ic_left_toolbar_thumbnails_selected)
-                ReaderViewModel.LeftToolbarType.BOOKMARK -> iv_readerActivity_bookmark.setImageResource(R.drawable.ic_left_toolbar_bookmarks_selected)
-                ReaderViewModel.LeftToolbarType.OUTLINE -> iv_readerActivity_outline.setImageResource(R.drawable.ic_left_toolbar_outline_selected)
-                ReaderViewModel.LeftToolbarType.SEARCH -> iv_readerActivity_search.setImageResource(R.drawable.ic_left_toolbar_search_selected)
-            }
-        }
-    }
-
-    private fun onClickBottomThumb1() {
-        var intent = transferThumbIntent()
-        startActivityForResult(intent,THUMB)
-    }
-
-    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
-        super.onActivityResult(requestCode, resultCode, data)
-        if (resultCode == Activity.RESULT_OK){
-            when (requestCode){
-                THUMB -> {
-                    val mode = data?.getIntExtra("operate", -1)
-                    when (mode) {
-                        PdfThumbActivity.THUMB_NORMAL -> {
-                            val pageIndex = data.getIntExtra("result", 0)
-                            viewModel.pdfInfoHandler.setCurrentPage(pageIndex)
-                        }
-                    }
-                }
-            }
-        }
-    }
-
-
-}

+ 0 - 578
reader/src/main/java/com/kdanmobile/reader/ReaderViewModel.kt

@@ -1,578 +0,0 @@
-package com.kdanmobile.reader
-
-import android.arch.lifecycle.LiveData
-import android.arch.lifecycle.MutableLiveData
-import android.arch.lifecycle.ViewModel
-import android.content.Context
-import android.graphics.Bitmap
-import android.graphics.Color
-import android.graphics.RectF
-import android.net.Uri
-import com.kdanmobile.kmpdfkit.annotation.Annotation
-import com.kdanmobile.kmpdfkit.annotation.bean.*
-import com.kdanmobile.kmpdfkit.contextmenu.KMPDFMenuItem
-import com.kdanmobile.kmpdfkit.contextmenu.MenuItemCallback
-import com.kdanmobile.kmpdfkit.globaldata.AnnotConfig
-import com.kdanmobile.kmpdfkit.globaldata.Config
-import com.kdanmobile.kmpdfkit.globaldata.KMPDFAnnotEditMode
-import com.kdanmobile.kmpdfkit.manager.KMPDFFactory
-import com.kdanmobile.kmpdfkit.manager.controller.KMPDFDocumentController
-import com.kdanmobile.kmpdfkit.manager.controller.KMPDFFreeTextController
-import com.kdanmobile.kmpdfkit.manager.controller.KMPDFLongPressCreateAnnotController
-import com.kdanmobile.kmpdfkit.manager.controller.KMPDFSignatureController
-import com.kdanmobile.kmpdfkit.manager.listener.KMPDFAddAnnotCallback
-import com.kdanmobile.kmpdfkit.manager.listener.KMPDFAnnotEditModeChangeListener
-import com.kdanmobile.kmpdfkit.pdfcommon.Bookmark
-import com.kdanmobile.kmpdfkit.pdfcommon.KMPDFReaderView
-import com.kdanmobile.kmpdfkit.pdfcommon.OutlineItem
-import com.kdanmobile.kmpdfkit.pdfcommon.TextWord
-import com.kdanmobile.reader.annotationattribute.AnnotationAttribute
-import com.kdanmobile.reader.annotationattribute.Brush
-import com.kdanmobile.reader.annotationattribute.InkAttribute
-import com.kdanmobile.reader.screen.contextmenu.TextBoxContextMenuActionListener
-import com.kdanmobile.reader.screen.data.ShapeAttribute
-import com.kdanmobile.reader.screen.data.SignatureAttribute
-import com.kdanmobile.reader.screen.data.StampAttribute
-import com.kdanmobile.reader.screen.data.TextBoxAttribute
-import com.kdanmobile.reader.screen.handler.*
-import com.kdanmobile.reader.thumb.PdfThumbViewModel
-
-class ReaderViewModel(private val pdfSdkLicense: String, private val pdfSdkRsaMsg: String) : ViewModel() {
-
-    enum class ViewDirection(val mode: Config.PDFViewMode) {
-        VerticalSinglePageContinues(Config.PDFViewMode.VERTICAL_SINGLE_PAGE_CONTINUES),
-        VerticalSinglePage(Config.PDFViewMode.VERTICAL_SINGLE_PAGE),
-        HorizontalSinglePage(Config.PDFViewMode.HORIZONTAL_SINGLE_PAGE)
-    }
-
-    enum class AnnotationMode {
-        None,
-        Highlight,
-        Strike,
-        Underline,
-        Ink,
-    }
-
-    companion object {
-        val DEFAULT_HIGHLIGHT_ATTR = AnnotationAttribute(Color.parseColor("#ffdc1b"), 127)
-        val DEFAULT_STRIKE_ATTR = AnnotationAttribute(Color.parseColor("#57d214"), 255)
-        val DEFAULT_UNDERLINE_ATTR = AnnotationAttribute(Color.parseColor("#296dd2"), 255)
-        val DEFAULT_INK_ATTR = InkAttribute(Color.parseColor("#dd0202"), 255, 1f, Brush.Fountain)
-    }
-
-    var viewDirection = ViewDirection.VerticalSinglePageContinues
-        set(value) {
-            field = value
-            updateViewDirection()
-        }
-    var isCrop = false
-        set(value) {
-            field = value
-            updateCrop()
-        }
-    val highLightAttributeLiveData = MutableLiveData<AnnotationAttribute>().apply { value = DEFAULT_HIGHLIGHT_ATTR }
-    val strikeAttributeLiveData = MutableLiveData<AnnotationAttribute>().apply { value = DEFAULT_STRIKE_ATTR }
-    var underLineAttributeLiveData = MutableLiveData<AnnotationAttribute>().apply { value = DEFAULT_UNDERLINE_ATTR }
-    var inkAttributeLiveData = MutableLiveData<InkAttribute>().apply { value = DEFAULT_INK_ATTR }
-
-    private var isVerified = false
-
-    private var kmpdfFactory: KMPDFFactory? = null
-    private var kmpdfDocumentController: KMPDFDocumentController? = null
-    val isOpenedFileLiveData = MutableLiveData<Boolean>().apply { value = false }
-    val fileNameLiveData = MutableLiveData<String>()
-    val annotationModeLiveData = MutableLiveData<AnnotationMode>().apply { value = AnnotationMode.None }
-    val annotationEitModeLiveData = MutableLiveData<KMPDFAnnotEditMode.Mode>().apply { value = KMPDFAnnotEditMode.Mode.NULL }
-    var isCopyModeLiveData = MutableLiveData<Boolean>().apply { value = false }
-
-    val pageIndexLiveData: LiveData<Int>
-        get() = mPageIndexLiveData
-    val isPageInBookmarksLiveData: LiveData<Boolean>
-        get() = mIsPageInBookmarksLiveData
-
-    private val mPageIndexLiveData = MutableLiveData<Int>().apply { value = 0 }
-    private val mIsPageInBookmarksLiveData = MutableLiveData<Boolean>().apply { value = false }
-
-    enum class LeftToolbarType {
-        NONE, THUMBNAIL, BOOKMARK, OUTLINE, SEARCH
-    }
-
-    val leftToolbarTypeLiveData: LiveData<LeftToolbarType>
-        get() = mLeftToolbarTypeLiveData
-    private val mLeftToolbarTypeLiveData = MutableLiveData<LeftToolbarType>().apply { value = LeftToolbarType.NONE }
-
-    val isLeftToolbarOpenLiveData: LiveData<Boolean>
-        get() = mIsLeftToolbarOpenLiveData
-    private val mIsLeftToolbarOpenLiveData = MutableLiveData<Boolean>().apply { value = false }
-
-    fun setLeftToolbarType(leftToolbarType: LeftToolbarType) {
-        mLeftToolbarTypeLiveData.postValue(leftToolbarType)
-    }
-
-    fun setIsLeftToolbarOpen(open: Boolean) {
-        mIsLeftToolbarOpenLiveData.postValue(open)
-    }
-
-    @JvmOverloads
-    fun openPdfFile(context: Context, uri: Uri, type: String? = null): Boolean {
-        if (!isVerified) {
-            if (!verifyLicense(context)) {
-                return false
-            }
-        }
-        return openPdfFIleImp(context, uri, type).apply{
-            isOpenedFileLiveData.postValue(this)
-        }
-    }
-
-    private fun openPdfFIleImp(context: Context, uri: Uri, type: String?): Boolean {
-        val factory = KMPDFFactory.open(context, uri, type) ?: return false
-        kmpdfFactory = factory
-        kmpdfFactory?.also {
-            fileNameLiveData.postValue(it.fileName)
-            return when {
-                it.needPassWord() -> {
-                    false
-                }
-                it.init() -> {
-                    true
-                }
-                else -> {
-                    false
-                }
-            }
-        }
-        return false
-    }
-
-    fun copySelection(): Boolean {
-        return kmpdfDocumentController?.copySelection() ?: false
-    }
-
-    fun onClickCopyBtn() {
-        if (annotationModeLiveData.value != AnnotationMode.None) stopAnnotationMode()
-        if (isCopyModeLiveData.value == true) {
-            stopCopyTextMode()
-        } else {
-            startCopyTextMode()
-        }
-    }
-
-    fun onClickHighlightBtn() {
-        if (isCopyModeLiveData.value == true) stopCopyTextMode()
-        if (annotationModeLiveData.value == AnnotationMode.Highlight) {
-            stopAnnotationMode()
-        } else {
-            startHighLightEditMode()
-        }
-    }
-
-    fun onLongClickHighlightBtn() {
-        if (isCopyModeLiveData.value == true) stopCopyTextMode()
-        startHighLightEditMode()
-    }
-
-    fun onClickStrikeBtn() {
-        if (isCopyModeLiveData.value == true) stopCopyTextMode()
-        if (annotationModeLiveData.value == AnnotationMode.Strike) {
-            stopAnnotationMode()
-        } else {
-            startStrikeOutEditMode()
-        }
-    }
-
-    fun onLongClickStrikeBtn() {
-        if (isCopyModeLiveData.value == true) stopCopyTextMode()
-        startStrikeOutEditMode()
-    }
-
-    fun onClickUnderlineBtn() {
-        if (isCopyModeLiveData.value == true) stopCopyTextMode()
-        if (annotationModeLiveData.value == AnnotationMode.Underline) {
-            stopAnnotationMode()
-        } else {
-            startUnderLineEditMode()
-        }
-    }
-
-    fun onLongClickUnderlineBtn() {
-        if (isCopyModeLiveData.value == true) stopCopyTextMode()
-        startUnderLineEditMode()
-    }
-
-    fun onClickInkBtn() {
-        if (isCopyModeLiveData.value == true) stopCopyTextMode()
-        if (annotationModeLiveData.value == AnnotationMode.Ink) {
-            stopAnnotationMode()
-        } else {
-            startInkEditMode()
-        }
-    }
-
-    fun onLongClickInkBtn() {
-        if (isCopyModeLiveData.value == true) stopCopyTextMode()
-        startInkEditMode()
-    }
-
-    private fun startCopyTextMode() {
-        kmpdfDocumentController?.startCopyText()
-        isCopyModeLiveData.postValue(true)
-    }
-
-    private fun stopCopyTextMode() {
-        kmpdfDocumentController?.stopCopyText()
-        isCopyModeLiveData.postValue(false)
-    }
-
-    fun setHighLightAttributes(annotationAttribute: AnnotationAttribute) {
-        highLightAttributeLiveData.postValue(annotationAttribute)
-        setHighLightAttributesImp(annotationAttribute)
-    }
-
-    private fun setHighLightAttributesImp(annotationAttribute: AnnotationAttribute) {
-        kmpdfFactory?.setAnnotationAttribute(KMPDFHighlightAnnotationBean("", annotationAttribute.color, annotationAttribute.alpha))
-        kmpdfFactory?.annotConfig?.apply {
-            markerPenColor_hightlight = annotationAttribute.color
-            markerPenAlpha_hightlight = annotationAttribute.alpha
-        }
-    }
-
-    private fun startHighLightEditMode() {
-        kmpdfFactory?.setAnnotationEditMode(KMPDFAnnotationBean.AnnotationType.HIGH_LIGHT)
-        annotationModeLiveData.postValue(AnnotationMode.Highlight)
-    }
-
-    fun setStrikeOutAttributes(annotationAttribute: AnnotationAttribute) {
-        strikeAttributeLiveData.postValue(annotationAttribute)
-        setStrikeOutAttributesImp(annotationAttribute)
-    }
-
-    private fun setStrikeOutAttributesImp(annotationAttribute: AnnotationAttribute) {
-        kmpdfFactory?.setAnnotationAttribute(KMPDFStrikeoutAnnotationBean("",annotationAttribute.color, annotationAttribute.alpha))
-        kmpdfFactory?.annotConfig?.apply {
-            markerPenColor_strikeout = annotationAttribute.color
-            markerPenAlpha_strikeout = annotationAttribute.alpha
-        }
-    }
-
-    private fun startStrikeOutEditMode() {
-        kmpdfFactory?.setAnnotationEditMode(KMPDFAnnotationBean.AnnotationType.STRIKE_OUT)
-        annotationModeLiveData.postValue(AnnotationMode.Strike)
-    }
-
-    fun setUnderLineAttributes(annotationAttribute: AnnotationAttribute) {
-        underLineAttributeLiveData.postValue(annotationAttribute)
-        setUnderLineAttributesImp(annotationAttribute)
-    }
-
-    private fun setUnderLineAttributesImp(annotationAttribute: AnnotationAttribute) {
-        kmpdfFactory?.setAnnotationAttribute(KMPDFUnderlineAnnotationBean("", annotationAttribute.color, annotationAttribute.alpha))
-        kmpdfFactory?.annotConfig?.apply {
-            markerPenColor_underline = annotationAttribute.color
-            markerPenAlpha_underline = annotationAttribute.alpha
-        }
-    }
-
-    private fun startUnderLineEditMode() {
-        kmpdfFactory?.setAnnotationEditMode(KMPDFAnnotationBean.AnnotationType.UNDER_LINE)
-        annotationModeLiveData.postValue(AnnotationMode.Underline)
-    }
-
-    fun setInkAttributes(inkAttribute: InkAttribute) {
-        inkAttributeLiveData.postValue(inkAttribute)
-        setInkAttributesImp(inkAttribute)
-    }
-
-    fun setInkAttributesImp(inkAttribute: InkAttribute) {
-        kmpdfFactory?.apply {
-            setAnnotationAttribute(KMPDFInkAnnotationBean("", inkAttribute.color, inkAttribute.width, inkAttribute.alpha))
-            annotConfig?.apply {
-                markerPenColor_ink = inkAttribute.color
-                markerPenAlpha_ink = inkAttribute.alpha
-                markerPenSize_ink = inkAttribute.width
-            }
-        }
-    }
-
-    private fun startInkEditMode() {
-        kmpdfFactory?.setAnnotationEditMode(KMPDFAnnotationBean.AnnotationType.INK)
-        annotationModeLiveData.postValue(AnnotationMode.Ink)
-    }
-
-    private fun stopAnnotationMode() {
-        kmpdfFactory?.setAnnotationEditMode(KMPDFAnnotationBean.AnnotationType.NULL)
-        annotationModeLiveData.postValue(AnnotationMode.None)
-    }
-
-    fun setReaderView(readerView: KMPDFReaderView) {
-        val isFirst = kmpdfFactory?.readerView == null
-        kmpdfFactory?.readerView = readerView
-        kmpdfDocumentController = kmpdfFactory?.getController(KMPDFFactory.ControllerType.DOCUMENT) as KMPDFDocumentController
-
-        /** init annotation color **/
-        highLightAttributeLiveData.value?.also { setHighLightAttributesImp(it) }
-        strikeAttributeLiveData.value?.also { setStrikeOutAttributesImp(it) }
-        underLineAttributeLiveData.value?.also { setUnderLineAttributesImp(it) }
-        inkAttributeLiveData.value?.also { setInkAttributesImp(it) }
-
-        updateViewDirection()
-
-        kmpdfFactory?.kmpdfAddAnnotCallback = object : KMPDFAddAnnotCallback {
-
-            override fun onSaveAnnotFinished(type: Annotation.Type, result: Boolean, message: String) {
-                println("KMPDFAddAnnotCallback::onSaveAnnotFinished")
-            }
-
-            override fun onAttachAnnotWidgetFinished(type: Annotation.Type) {
-                println("KMPDFAddAnnotCallback::onAttachAnnotWidgetFinished")
-                val mode = when (type) {
-                    Annotation.Type.FREETEXT -> KMPDFAnnotEditMode.Mode.FREETEXT_MODIFY
-                    Annotation.Type.STAMP -> KMPDFAnnotEditMode.Mode.STAMP_MODIFY
-                    Annotation.Type.CIRCLE, Annotation.Type.SQUARE, Annotation.Type.LINE -> KMPDFAnnotEditMode.Mode.SHAPE_MODIFY
-                    else -> KMPDFAnnotEditMode.Mode.NULL
-                }
-                if (mode != KMPDFAnnotEditMode.Mode.NULL) {
-                    kmpdfFactory?.kmpdfAnnotEditMode?.pdfAnnotEditMode = mode
-                }
-            }
-        }
-
-        kmpdfFactory?.kmpdfAnnotEditModeChangeListener = KMPDFAnnotEditModeChangeListener {
-            annotationEitModeLiveData.postValue(it)
-        }
-
-        setLongPressContextMenuActions()
-
-        if (!isFirst) {
-            restoreStateBeforeDestroy()
-        }
-    }
-
-    private fun setLongPressContextMenuActions() {
-        val item = KMPDFMenuItem()
-        item.annotType = KMPDFMenuItem.AnnotType.LONG_PRESS
-        item.menu_resId = R.menu.context_menu_longpress
-        item.menuCallbacks.add(MenuItemCallback { view, annotType ->
-            (kmpdfFactory?.getController(KMPDFFactory.ControllerType.LONGCLICK) as KMPDFLongPressCreateAnnotController).longPress_Paste()
-            annotationEitModeLiveData.postValue(KMPDFAnnotEditMode.Mode.FREETEXT_MODIFY)
-
-            return@MenuItemCallback true
-        })
-        kmpdfFactory?.setAnnotationContextMenu(item)
-    }
-
-    fun setTextBoxContextMenuActions(listener: TextBoxContextMenuActionListener) {
-        val item = KMPDFMenuItem()
-        item.annotType = KMPDFMenuItem.AnnotType.FREETEXT
-        item.menu_resId = R.menu.context_menu_textbox
-        item.menuCallbacks.add(MenuItemCallback { view, annotType ->
-            return@MenuItemCallback listener.onDelete()
-        })
-        item.menuCallbacks.add(MenuItemCallback { view, annotType ->
-            return@MenuItemCallback listener.onEditStyle()
-        })
-        item.menuCallbacks.add(MenuItemCallback { view, annotType ->
-            return@MenuItemCallback listener.onEditText()
-        })
-        item.menuCallbacks.add(MenuItemCallback { view, annotType ->
-            return@MenuItemCallback listener.onCopy()
-        })
-        kmpdfFactory?.setAnnotationContextMenu(item)
-    }
-
-    private fun restoreStateBeforeDestroy() {
-        if (isCopyModeLiveData.value == true) {
-            startCopyTextMode()
-        } else {
-            val annotationEditMode = when (annotationModeLiveData.value) {
-                AnnotationMode.None, null -> KMPDFAnnotationBean.AnnotationType.NULL
-                AnnotationMode.Highlight -> KMPDFAnnotationBean.AnnotationType.HIGH_LIGHT
-                AnnotationMode.Strike -> KMPDFAnnotationBean.AnnotationType.STRIKE_OUT
-                AnnotationMode.Underline -> KMPDFAnnotationBean.AnnotationType.UNDER_LINE
-                AnnotationMode.Ink -> KMPDFAnnotationBean.AnnotationType.INK
-            }
-            kmpdfFactory?.setAnnotationEditMode(annotationEditMode)
-            kmpdfFactory?.kmpdfAnnotEditMode?.pdfAnnotEditMode = KMPDFAnnotEditMode.Mode.NULL
-            annotationEitModeLiveData.postValue(KMPDFAnnotEditMode.Mode.NULL)
-        }
-    }
-
-    fun saveModifyingAnnotationBeforeDestroy() {
-        kmpdfFactory?.setAnnotationEditMode(KMPDFAnnotationBean.AnnotationType.NULL)
-    }
-
-    fun clearSelection() {
-        kmpdfFactory?.setAnnotationEditMode(KMPDFAnnotationBean.AnnotationType.NULL)
-        kmpdfFactory?.kmpdfAnnotEditMode?.pdfAnnotEditMode = KMPDFAnnotEditMode.Mode.NULL
-        annotationEitModeLiveData.postValue(KMPDFAnnotEditMode.Mode.NULL)
-    }
-
-    fun deleteSelectedTextBox() {
-        (kmpdfFactory?.getController(KMPDFFactory.ControllerType.FREETEXT) as KMPDFFreeTextController).deleteFreeTextAnnotView()
-    }
-
-    fun editSelectedTextBoxStyle() {
-        (kmpdfFactory?.getController(KMPDFFactory.ControllerType.FREETEXT) as KMPDFFreeTextController).setCurrentFreeTextViewEditMode(0)
-    }
-
-    fun editSelectedTextBoxText() {
-        (kmpdfFactory?.getController(KMPDFFactory.ControllerType.FREETEXT) as KMPDFFreeTextController).setCurrentFreeTextViewEditMode(1)
-    }
-
-    fun copySelectedTextBox() {
-        (kmpdfFactory?.getController(KMPDFFactory.ControllerType.FREETEXT) as KMPDFFreeTextController).copyFreeTextContent()
-    }
-
-    fun setPageIndex(pageIndex: Int){
-        mPageIndexLiveData.value = pageIndex
-    }
-
-    fun addBookmark(title: String) {
-        pageIndexLiveData.value?.let {
-            kmpdfDocumentController?.addBookmark(title, it)
-            setBookmarkDisplay(it)
-        }
-    }
-
-    fun deleteBookmark() {
-        pageIndexLiveData.value?.let {
-            kmpdfDocumentController?.deleteBookmarks(it)
-            setBookmarkDisplay(it)
-        }
-    }
-
-    fun setBookmarkDisplay(pageIndex: Int) {
-        kmpdfDocumentController?.let {
-            var isPageInBookmarks = false
-            it.bookmarks?.let {
-                for (bookmark in it) {
-                    if (bookmark.pageNum == pageIndex) {
-                        isPageInBookmarks = true
-                        break
-                    }
-                }
-            }
-            mIsPageInBookmarksLiveData.value = isPageInBookmarks
-        }
-    }
-
-    fun transferKmpdfCore(){
-        PdfThumbViewModel.tempKmpdfFactory = kmpdfFactory
-        PdfThumbViewModel.tempkmpdfDocumentController = kmpdfDocumentController
-    }
-
-    private fun verifyLicense(context: Context): Boolean {
-        val errorCode = KMPDFFactory.verifyLicense(context, pdfSdkLicense, pdfSdkRsaMsg)
-        return errorCode == 0
-    }
-
-    private fun updateViewDirection() {
-        kmpdfDocumentController?.pdfViewMode = viewDirection.mode
-        kmpdfDocumentController?.refresh(false)
-    }
-
-    private fun updateCrop() {
-        kmpdfDocumentController?.apply {
-            cropMode = isCrop
-            refresh(false)
-        }
-    }
-
-    fun setTextBoxAttribute(attr: TextBoxAttribute, modify: Boolean = false) {
-
-        val kmpdfFreetextAnnotationBean = KMPDFFreetextAnnotationBean("", attr.textColor, attr.textSize, 255, "Courier", attr.isBold, attr.isItalic)
-        kmpdfFactory?.setAnnotationAttribute(kmpdfFreetextAnnotationBean)
-        if (!modify) {
-            kmpdfFactory?.setAnnotationEditMode(KMPDFAnnotationBean.AnnotationType.FREETEXT)
-        }
-    }
-
-    fun setSignatureAttribute(attr: SignatureAttribute) {
-
-        val kmpdfSignatureAnnotationBean = KMPDFSignatureAnnotationBean("", attr.path, KMPDFSignatureController.OnSignImageCreateListener {
-            println("onSignImageCreated")
-        })
-        kmpdfFactory?.setAnnotationAttribute(kmpdfSignatureAnnotationBean)
-        kmpdfFactory?.setAnnotationEditMode(KMPDFAnnotationBean.AnnotationType.SIGNATURE)
-    }
-
-    fun setStampAttribute(attr: StampAttribute) {
-
-        val kmpdfStampAnnotationBean = when (attr.isStandardStamp()) {
-            true -> KMPDFStampAnnotationBean("", KMPDFStampAnnotationBean.StampType.STANDARD, KMPDFStampAnnotationBean.StandardStamp(attr.resId))
-            false -> KMPDFStampAnnotationBean("", KMPDFStampAnnotationBean.StampType.TEXT, KMPDFStampAnnotationBean.TextStamp(attr.rect, attr.config))
-        }
-        kmpdfFactory?.setAnnotationAttribute(kmpdfStampAnnotationBean)
-        kmpdfFactory?.setAnnotationEditMode(KMPDFAnnotationBean.AnnotationType.STAMP)
-    }
-
-    fun setShapeAttribute(attr: ShapeAttribute) {
-
-        val kmpdfShapeAnnotationBean = when (attr.shapeType) {
-            AnnotConfig.ShapeAnnotationType.LINE -> KMPDFLineAnnotationBean("", attr.lineColor, attr.lineWidth, attr.lineAlpha)
-            AnnotConfig.ShapeAnnotationType.ARROW -> KMPDFArrowAnnotationBean("", attr.lineColor, attr.lineWidth, attr.lineAlpha)
-            AnnotConfig.ShapeAnnotationType.CIRCLE -> KMPDFCircleAnnotationBean("", attr.lineColor, attr.lineWidth, attr.lineAlpha, attr.fillColor, attr.fillAlpha)
-            AnnotConfig.ShapeAnnotationType.SQUARE -> KMPDFSquareAnnotationBean("", attr.lineColor, attr.lineWidth, attr.lineAlpha, attr.fillColor, attr.fillAlpha)
-        }
-        kmpdfFactory?.setAnnotationAttribute(kmpdfShapeAnnotationBean)
-        kmpdfFactory?.setAnnotationEditMode(kmpdfShapeAnnotationBean.type)
-    }
-
-    val pdfInfoHandler = object : PdfInfoHandler {
-        override fun getOpenPdfFilename(): String {
-            return kmpdfFactory?.fileName ?: ""
-        }
-
-        override fun getPdfPageCount(): Int {
-            return kmpdfDocumentController?.getDocumentPageCount(false) ?: 0
-        }
-
-        override fun getCurrentPage(): Int {
-            return kmpdfDocumentController?.currentPageNum ?: 0
-        }
-
-        override fun setCurrentPage(page: Int): Boolean {
-            return kmpdfDocumentController?.gotoPage(page) ?: false
-        }
-
-        override fun textLines(page: Int): Array<Array<TextWord>> {
-            return kmpdfDocumentController?.textLines(page) ?: arrayOf()
-        }
-    }
-
-    val thumbnailHandler = object : ThumbnailHandler {
-        override fun getPdfBitmap(position: Int, picWidth: Int, mode: Int, isDrawAnnot: Boolean): Bitmap {
-            return kmpdfDocumentController?.covertPDFToBitmap(position, picWidth, mode, isDrawAnnot) ?: Bitmap.createBitmap(0, 0, Bitmap.Config.ARGB_4444)
-        }
-    }
-
-    val bookmarkHandler = object : BookmarkHandler {
-        override fun getBookmarks(): Array<Bookmark> {
-            return kmpdfDocumentController?.bookmarks ?: arrayOf()
-        }
-    }
-
-    val outlineHandler = object : OutlineHandler {
-        override fun getOutline(): Array<OutlineItem> {
-            return kmpdfDocumentController?.outline ?: arrayOf()
-        }
-    }
-
-    val searchHandler = object : SearchHandler {
-        override fun searchPage(page: Int, keyword: String): Array<RectF> {
-            return kmpdfDocumentController?.searchPage(page, keyword) ?: arrayOf()
-        }
-
-        override fun cleanPreviousSearchResults(keyword: String): Boolean {
-            return kmpdfDocumentController?.cleanPreviousSearchResults(keyword) ?: false
-        }
-
-        override fun setSearchResult(page: Int, keyword: String, rectArray: Array<RectF>): Boolean {
-            return kmpdfDocumentController?.setSearchResult(keyword, page, rectArray) ?: false
-        }
-
-        override fun stopSearchKeyWord(): Boolean {
-            return kmpdfDocumentController?.stopSearchKeyWord() ?: false
-        }
-    }
-}

+ 0 - 11
reader/src/main/java/com/kdanmobile/reader/ReaderViewModelFactory.kt

@@ -1,11 +0,0 @@
-package com.kdanmobile.reader
-
-import android.arch.lifecycle.ViewModel
-import android.arch.lifecycle.ViewModelProvider
-
-class ReaderViewModelFactory : ViewModelProvider.Factory {
-
-    override fun <T : ViewModel?> create(modelClass: Class<T>): T {
-        return ReaderViewModel(Config.PDF_SDK_LICENSE, Config.PDF_SDK_RSA_MSG) as T
-    }
-}

+ 0 - 81
reader/src/main/java/com/kdanmobile/reader/Utils.kt

@@ -1,81 +0,0 @@
-package com.kdanmobile.reader
-
-import android.content.Context
-import android.content.res.ColorStateList
-import android.graphics.drawable.StateListDrawable
-import android.os.Build
-import android.support.annotation.LayoutRes
-import android.support.annotation.RequiresApi
-import android.support.constraint.ConstraintLayout
-import android.support.constraint.ConstraintSet
-import android.support.v4.content.ContextCompat
-import android.support.v4.graphics.drawable.DrawableCompat
-import android.support.v7.widget.AppCompatImageButton
-import android.support.v7.widget.AppCompatImageView
-import android.transition.AutoTransition
-import android.transition.TransitionManager
-import android.view.View
-import android.view.ViewGroup
-import android.widget.ImageView
-
-object Utils {
-    /**
-     * @param:
-     * @author: luozhipeng
-     * @Decreption:通过tint实现图片selector
-     * @create at: 8/8/16 16:17
-     **/
-    fun setTintDrawableList(context: Context, view: View, srcResourceId: Int, colorResId: Int, colorPressedResId: Int) {
-        var drawable = ContextCompat.getDrawable(context, srcResourceId)
-        val colors = intArrayOf(ContextCompat.getColor(context, colorPressedResId), ContextCompat.getColor(context, colorPressedResId), ContextCompat.getColor(context, colorResId))
-        val states = arrayOfNulls<IntArray>(3)
-        states[0] = intArrayOf(android.R.attr.state_pressed)
-        states[1] = intArrayOf(android.R.attr.state_selected)
-        states[2] = intArrayOf()
-        val colorList = ColorStateList(states, colors)
-        val stateListDrawable = StateListDrawable()
-        stateListDrawable.addState(states[0], drawable)//注意顺序
-        stateListDrawable.addState(states[1], drawable)
-        stateListDrawable.addState(states[2], drawable)
-        val state = stateListDrawable.constantState
-        drawable = DrawableCompat.wrap(if (state == null) stateListDrawable else state.newDrawable()).mutate()
-        DrawableCompat.setTintList(drawable!!, colorList)
-        drawable.setBounds(0, 0, drawable.minimumWidth, drawable.minimumHeight)
-
-        if (view is AppCompatImageView) {
-            view.setImageDrawable(drawable)
-        }
-
-        if (view is ImageView) {
-            view.setImageDrawable(drawable)
-        }
-
-        if (view is AppCompatImageButton) {
-            view.setImageDrawable(drawable)
-        }
-    }
-
-    @RequiresApi(Build.VERSION_CODES.KITKAT)
-    fun ConstraintLayout.applyConstraintSet(constraintSet: ConstraintSet, duration: Long = 300) {
-        val transition = AutoTransition()
-        transition.duration = duration
-        TransitionManager.beginDelayedTransition(this, transition)
-        constraintSet.applyTo(this)
-    }
-
-    @RequiresApi(Build.VERSION_CODES.KITKAT)
-    fun ConstraintLayout.applyConstraintSet(context: Context, @LayoutRes layoutResId: Int, duration: Long = 300) {
-        val constraintSet = ConstraintSet()
-        constraintSet.clone(context, layoutResId)
-        this.applyConstraintSet(constraintSet, duration)
-    }
-
-    fun makeDropDownMeasureSpec(measureSpec: Int): Int {
-        val mode = if (measureSpec == ViewGroup.LayoutParams.WRAP_CONTENT) {
-            View.MeasureSpec.UNSPECIFIED
-        } else {
-            View.MeasureSpec.EXACTLY
-        }
-        return View.MeasureSpec.makeMeasureSpec(View.MeasureSpec.getSize(measureSpec), mode)
-    }
-}

+ 0 - 5
reader/src/main/java/com/kdanmobile/reader/annotationattribute/AnnotationAttribute.kt

@@ -1,5 +0,0 @@
-package com.kdanmobile.reader.annotationattribute
-
-import android.support.annotation.IntRange
-
-open class AnnotationAttribute(open var color: Int, @IntRange(from = 0, to = 255) open var alpha: Int)

+ 0 - 16
reader/src/main/java/com/kdanmobile/reader/annotationattribute/AnnotationColor.kt

@@ -1,16 +0,0 @@
-package com.kdanmobile.reader.annotationattribute
-
-import com.kdanmobile.reader.R
-
-enum class AnnotationColor(val colorResId: Int) {
-    Color1(R.color.reader_color_selector_color_1),
-    Color2(R.color.reader_color_selector_color_2),
-    Color3(R.color.reader_color_selector_color_3),
-    Color4(R.color.reader_color_selector_color_4),
-    Color5(R.color.reader_color_selector_color_5),
-    Color6(R.color.reader_color_selector_color_6),
-    Color7(R.color.reader_color_selector_color_7),
-    Color8(R.color.reader_color_selector_color_8),
-    Color9(R.color.reader_color_selector_color_9),
-    Color10(R.color.reader_color_selector_color_10),
-}

+ 0 - 6
reader/src/main/java/com/kdanmobile/reader/annotationattribute/Brush.kt

@@ -1,6 +0,0 @@
-package com.kdanmobile.reader.annotationattribute
-
-enum class Brush(val maxSize: Int) {
-    Fountain(9),
-    Marker(16),
-}

+ 0 - 9
reader/src/main/java/com/kdanmobile/reader/annotationattribute/InkAttribute.kt

@@ -1,9 +0,0 @@
-package com.kdanmobile.reader.annotationattribute
-
-import android.support.annotation.IntRange
-
-data class InkAttribute(
-        override var color: Int,
-        @IntRange(from = 0, to = 255) override var alpha: Int,
-        var width: Float,
-        var brush: Brush) : AnnotationAttribute(color, alpha)

+ 0 - 115
reader/src/main/java/com/kdanmobile/reader/screen/adapter/BookmarkAdapter.kt

@@ -1,115 +0,0 @@
-package com.kdanmobile.reader.screen.adapter
-
-import android.graphics.Bitmap
-import android.support.v4.util.LruCache
-import android.support.v7.widget.RecyclerView
-import android.support.v7.widget.RecyclerView.ViewHolder
-import android.view.View
-import android.view.ViewGroup
-import android.widget.ImageView
-import android.widget.LinearLayout
-import android.widget.RelativeLayout
-import android.widget.TextView
-import com.kdanmobile.kmpdfkit.pdfcommon.Bookmark
-import com.kdanmobile.reader.R
-import com.kdanmobile.reader.screen.handler.ThumbnailHandler
-import io.reactivex.Observable
-import io.reactivex.android.schedulers.AndroidSchedulers
-import io.reactivex.disposables.Disposable
-import io.reactivex.schedulers.Schedulers
-
-class BookmarkAdapter(private val thumbnailHandler: ThumbnailHandler, private var bookmarkItems: Array<Bookmark>): RecyclerView.Adapter<BookmarkAdapter.BookmarkViewHolder>() {
-
-    companion object {
-        val maxMemory = Runtime.getRuntime().maxMemory() / 16
-
-        val mMemoryCache: LruCache<String, Bitmap> = object: LruCache<String, Bitmap>(maxMemory.toInt()) {
-            override fun sizeOf(key: String, value: Bitmap): Int {
-                return value.byteCount
-            }
-        }
-    }
-
-    fun setOutlineItems(bookmarkItems: Array<Bookmark>) {
-        this.bookmarkItems = bookmarkItems
-        notifyDataSetChanged()
-    }
-
-    override fun getItemCount(): Int {
-        return bookmarkItems.size
-    }
-
-    fun getItem(position: Int): Bookmark? {
-        return if (position >= 0 && position < bookmarkItems.size) bookmarkItems[position] else null
-    }
-
-    override fun onBindViewHolder(holder: BookmarkViewHolder, position: Int) {
-        val bookmark = bookmarkItems[holder.adapterPosition]
-        holder.msg.text = bookmark.title
-        holder.page.text = (bookmark.pageNum + 1).toString()
-        holder.loadThumbSync(bookmark.title + bookmark.pageNum + bookmark.createTime, bookmark.pageNum)
-    }
-
-    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BookmarkViewHolder {
-        val view = View.inflate(parent.context, R.layout.item_bookmark, null)
-        return BookmarkViewHolder(parent, view)
-    }
-
-    override fun onViewRecycled(holder: BookmarkViewHolder) {
-        super.onViewRecycled(holder)
-        holder.stopLoadThumbSync()
-    }
-
-    inner class BookmarkViewHolder(parent: ViewGroup, itemView: View): ViewHolder(itemView) {
-        private val thumb: ImageView
-        internal val page: TextView
-        internal val msg: TextView
-        private var disposable: Disposable? = null
-
-        init {
-            val idReaderBookmarkFl = itemView.findViewById<View>(R.id.tv_fragmentPdfReaderBookmarkLvItem_rl) as RelativeLayout
-            val params = LinearLayout.LayoutParams((parent.measuredWidth - 20) / 2, (parent.measuredWidth - 20) * 9 / 14)
-            params.setMargins(10, 5, 10, 5)
-            idReaderBookmarkFl.layoutParams = params
-
-            thumb = itemView.findViewById<View>(R.id.iv_fragmentPdfReaderBookmarkLvItem_) as ImageView
-            page = itemView.findViewById<View>(R.id.tv_fragmentPdfReaderBookmarkLvItem_page) as TextView
-            msg = itemView.findViewById<View>(R.id.tv_fragmentPdfReaderBookmarkLvItem_name) as TextView
-        }
-
-        internal fun loadThumbSync(filename: String, page: Int) {
-            stopLoadThumbSync()
-
-            disposable = Observable.create<Bitmap> { emitter ->
-                val pageNameTag = filename + page
-                val bitmap: Bitmap
-                val value = mMemoryCache[pageNameTag]
-                if (null != value) {
-                    bitmap = value
-                } else {
-                    bitmap = thumbnailHandler.getPdfBitmap(page, 180, ThumbnailHandler.MODE_DAY, true)
-                    mMemoryCache.put(pageNameTag, bitmap)
-                }
-                emitter.onNext(bitmap)
-                emitter.onComplete()
-            }
-                    .subscribeOn(Schedulers.io())
-                    .observeOn(AndroidSchedulers.mainThread())
-                    .subscribe({
-                        thumb.setImageBitmap(it)
-                        thumb.invalidate()
-                    }, {
-                        it.printStackTrace()
-                    })
-        }
-
-        internal fun stopLoadThumbSync() {
-            if (null != disposable && !disposable!!.isDisposed) {
-                disposable?.dispose()
-                disposable = null
-                thumb.setImageBitmap(null)
-                thumb.invalidate()
-            }
-        }
-    }
-}

+ 0 - 59
reader/src/main/java/com/kdanmobile/reader/screen/adapter/OutlineAdapter.kt

@@ -1,59 +0,0 @@
-package com.kdanmobile.reader.screen.adapter
-
-import android.view.LayoutInflater
-import android.view.View
-import android.view.ViewGroup
-import android.widget.BaseAdapter
-import android.widget.TextView
-import com.kdanmobile.kmpdfkit.pdfcommon.OutlineItem
-import com.kdanmobile.reader.R
-
-class OutlineAdapter(private val outlineListItems: List<OutlineItem>): BaseAdapter() {
-
-    override fun getCount(): Int {
-        return outlineListItems.size
-    }
-
-    override fun getItem(position: Int): OutlineItem? {
-        return if (position >= 0 && position < outlineListItems.size) outlineListItems[position] else null
-    }
-
-    override fun getItemId(position: Int): Long {
-        return position.toLong()
-    }
-
-    override fun getView(position: Int, view: View?, parent: ViewGroup): View {
-        var view1 = view
-        val holderView: HolderView
-        if (view1 == null) {
-            view1 = LayoutInflater.from(parent.context).inflate(R.layout.outline_entry, null) as View
-            holderView = HolderView(view1)
-            view1.tag = holderView
-        } else {
-            holderView = view1.tag as HolderView
-        }
-
-        val item = getItem(position)
-        /****** 大纲层次缩进  */
-        var space = ""
-        val null_str = parent.context.getString(R.string.null_str)
-        for (i in 1 .. item!!.level) {
-            space += null_str + null_str
-        }
-
-        holderView.tv_name.text = space + item.title
-        holderView.tv_name.textSize = (15 - item.level * 1.2f)
-        holderView.tv_page.text = (item.page + 1).toString()
-        return view1
-    }
-
-    private class HolderView(view: View) {
-        var tv_name: TextView
-        var tv_page: TextView
-
-        init {
-            tv_name = view.findViewById<View>(R.id.tv_outlineEntry_title) as TextView
-            tv_page = view.findViewById<View>(R.id.tv_outlineEntry_page) as TextView
-        }
-    }
-}

+ 0 - 83
reader/src/main/java/com/kdanmobile/reader/screen/adapter/SearchAdapter.kt

@@ -1,83 +0,0 @@
-package com.kdanmobile.reader.screen.adapter
-
-import android.text.Html
-import android.view.LayoutInflater
-import android.view.View
-import android.view.ViewGroup
-import android.widget.BaseAdapter
-import android.widget.LinearLayout
-import android.widget.RelativeLayout
-import android.widget.TextView
-import com.kdanmobile.reader.R
-import com.kdanmobile.reader.screen.model.SearchResultInfo
-import java.util.ArrayList
-
-class SearchAdapter(private var width: Int): BaseAdapter() {
-    private var list: MutableList<SearchResultInfo> = ArrayList()
-    private var selected = -1
-
-    fun clear() {
-        list.clear()
-    }
-
-    fun add(list: List<SearchResultInfo>) {
-        this.list.addAll(list)
-    }
-
-    override fun getCount(): Int {
-        return list.size
-    }
-
-    override fun getItem(position: Int): Any {
-        return list[position]
-    }
-
-    override fun getItemId(position: Int): Long {
-        return position.toLong()
-    }
-
-    fun setSelected(position: Int) {
-        this.selected = position
-        notifyDataSetChanged()
-    }
-
-    override fun getView(position: Int, view: View?, parent: ViewGroup): View {
-        var view1 = view
-        val item = list[position]
-        val holderView: HolderView
-        if (view1 == null) {
-            view1 = LayoutInflater.from(parent.context).inflate(R.layout.item_search, null) as View
-            holderView = HolderView()
-            holderView.tv_result = view1.findViewById<View>(R.id.tv_fragmentPdfReaderSearchLvItem_result) as TextView
-            holderView.tv_page = view1.findViewById<View>(R.id.tv_fragmentPdfReaderSearchLvItem_page) as TextView
-            holderView.view = view1.findViewById(R.id.view_fragmentPdfReaderSearchLvItem_selected)
-            holderView.rl = view1 .findViewById<View>(R.id.rl_fragmentPdfReaderSearchLvItem_) as RelativeLayout
-            val params = LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)
-            params.leftMargin = 21 * width / 800
-            params.rightMargin = 21 * width / 800
-            params.topMargin = 8 * width / 800
-            holderView.rl.layoutParams = params
-            view1.tag = holderView
-        } else {
-            holderView = view1.tag as HolderView
-        }
-
-        if (selected == position) {
-            holderView.view.setBackgroundResource(R.drawable.rectangle_6633b5e5)
-        } else {
-            holderView.view.setBackgroundResource(R.drawable.rectangle_0000)
-        }
-
-        holderView.tv_result.text = Html.fromHtml(item.result)
-        holderView.tv_page.text = (item.page + 1).toString()
-
-        return view1
-    }
-
-    private inner class HolderView {
-        lateinit var rl: RelativeLayout
-        lateinit var tv_result: TextView
-        lateinit var tv_page: TextView
-        lateinit var view: View
-    }
-}

+ 0 - 138
reader/src/main/java/com/kdanmobile/reader/screen/adapter/ThumbnailAdapter.kt

@@ -1,138 +0,0 @@
-package com.kdanmobile.reader.screen.adapter
-
-import android.graphics.Bitmap
-import android.support.v4.util.LruCache
-import android.support.v7.widget.RecyclerView
-import android.support.v7.widget.RecyclerView.ViewHolder
-import android.view.View
-import android.view.ViewGroup
-import android.widget.FrameLayout
-import android.widget.ImageView
-import android.widget.TextView
-import com.kdanmobile.reader.R
-import com.kdanmobile.reader.screen.handler.ThumbnailHandler
-import com.kdanmobile.reader.screen.adapter.ThumbnailAdapter.ThumbnailViewHolder
-import com.kdanmobile.reader.screen.handler.PdfInfoHandler
-import io.reactivex.Observable
-import io.reactivex.android.schedulers.AndroidSchedulers
-import io.reactivex.disposables.Disposable
-import io.reactivex.schedulers.Schedulers
-
-class ThumbnailAdapter(private val pdfInfoHandler: PdfInfoHandler, private val thumbnailHandler: ThumbnailHandler, private val filename: String = pdfInfoHandler.getOpenPdfFilename()): RecyclerView.Adapter<ThumbnailViewHolder>() {
-
-    companion object {
-        val maxMemory = Runtime.getRuntime().maxMemory() / 16
-
-        val mMemoryCache: LruCache<String, Bitmap> = object: LruCache<String, Bitmap>(maxMemory.toInt()) {
-            override fun sizeOf(key: String, value: Bitmap): Int {
-                return value.byteCount
-            }
-        }
-    }
-    private var currentPage = 0
-
-    init {
-        this.currentPage = pdfInfoHandler.getCurrentPage()
-    }
-
-    fun setCurrentPage(currentPage: Int) {
-        val oldCurrentPage = this.currentPage
-        this.currentPage = currentPage
-        notifyItemChanged(oldCurrentPage, false)
-        notifyItemChanged(currentPage, true)
-    }
-
-    fun clearMapSoftNotify() {
-        mMemoryCache.evictAll()
-        notifyDataSetChanged()
-    }
-
-    override fun getItemCount(): Int {
-        return pdfInfoHandler.getPdfPageCount()
-    }
-
-    override fun onBindViewHolder(holder: ThumbnailViewHolder, position: Int) {
-        holder.page.text = (holder.adapterPosition + 1).toString()
-        holder.onShowBorder(currentPage == holder.adapterPosition)
-        holder.loadThumbSync()
-    }
-
-    override fun onBindViewHolder(holder: ThumbnailViewHolder, position: Int, payloads: List<Any>) {
-        if (payloads.isEmpty()) {
-            onBindViewHolder(holder, position)
-        } else {
-            for (obj in payloads) {
-                if (obj is Boolean) {
-                    holder.onShowBorder(obj)
-                }
-            }
-        }
-    }
-
-    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ThumbnailViewHolder {
-        val view = View.inflate(parent.context, R.layout.item_thumbnail, null)
-        return ThumbnailViewHolder(parent, view)
-    }
-
-    override fun onViewRecycled(holder: ThumbnailViewHolder) {
-        super.onViewRecycled(holder)
-        holder.stopLoadThumbSync()
-    }
-
-    inner class ThumbnailViewHolder(parent: ViewGroup, itemView: View): ViewHolder(itemView) {
-        private val thumb: ImageView
-        internal val page: TextView
-        private val border: View
-        private var disposable: Disposable? = null
-
-        init {
-            val idReaderThumbFl = itemView.findViewById<View>(R.id.id_reader_thumb_fl) as FrameLayout
-            val params = RecyclerView.LayoutParams(parent.measuredWidth - 20, (parent.measuredWidth - 20) * 9 / 7)
-            params.setMargins(10, 5, 10, 5)
-            idReaderThumbFl.layoutParams = params
-
-            thumb = itemView.findViewById<View>(R.id.iv_fragmentPdfReaderThumbLvItem_) as ImageView
-            page = itemView.findViewById<View>(R.id.tv_fragmentPdfReaderThumbLvItem_page) as TextView
-            border = itemView.findViewById(R.id.v_pdfThumbGvItem_)
-        }
-
-        internal fun onShowBorder(isShow: Boolean) {
-            border.visibility = if (isShow) View.VISIBLE else View.GONE
-        }
-
-        internal fun loadThumbSync() {
-            stopLoadThumbSync()
-
-            disposable = Observable.create<Bitmap> { emitter ->
-                val pageNameTag = filename + adapterPosition
-                val bitmap: Bitmap
-                val value = mMemoryCache[pageNameTag]
-                if (null != value) {
-                    bitmap = value
-                } else {
-                    bitmap = thumbnailHandler.getPdfBitmap(adapterPosition, 180, ThumbnailHandler.MODE_DAY, true)
-                    mMemoryCache.put(pageNameTag, bitmap)
-                }
-                emitter.onNext(bitmap)
-                emitter.onComplete()
-            }
-                    .subscribeOn(Schedulers.io())
-                    .observeOn(AndroidSchedulers.mainThread())
-                    .subscribe({
-                        thumb.setImageBitmap(it)
-                        thumb.invalidate()
-                    }, {
-                        it.printStackTrace()
-                    })
-        }
-
-        internal fun stopLoadThumbSync() {
-            if (null != disposable && !disposable!!.isDisposed) {
-                disposable?.dispose()
-                disposable = null
-                thumb.setImageBitmap(null)
-                thumb.invalidate()
-            }
-        }
-    }
-}

+ 0 - 8
reader/src/main/java/com/kdanmobile/reader/screen/contextmenu/TextBoxContextMenuActionListener.kt

@@ -1,8 +0,0 @@
-package com.kdanmobile.reader.screen.contextmenu
-
-interface TextBoxContextMenuActionListener {
-    fun onDelete(): Boolean
-    fun onEditStyle(): Boolean
-    fun onEditText(): Boolean
-    fun onCopy(): Boolean
-}

+ 0 - 5
reader/src/main/java/com/kdanmobile/reader/screen/data/ShapeAttribute.kt

@@ -1,5 +0,0 @@
-package com.kdanmobile.reader.screen.data
-
-import com.kdanmobile.kmpdfkit.globaldata.AnnotConfig
-
-data class ShapeAttribute(val shapeType: AnnotConfig.ShapeAnnotationType, val lineColor: Int, val lineWidth: Float, val lineAlpha: Int, val fillColor: Int, val fillAlpha: Int)

+ 0 - 3
reader/src/main/java/com/kdanmobile/reader/screen/data/SignatureAttribute.kt

@@ -1,3 +0,0 @@
-package com.kdanmobile.reader.screen.data
-
-data class SignatureAttribute(val path: String)

+ 0 - 11
reader/src/main/java/com/kdanmobile/reader/screen/data/StampAttribute.kt

@@ -1,11 +0,0 @@
-package com.kdanmobile.reader.screen.data
-
-import android.graphics.Rect
-import com.kdanmobile.kmpdfkit.annotation.stamp.StampConfig
-import com.kdanmobile.kmpdfkit.annotation.stamp.TextStampConfig
-
-data class StampAttribute(val resId: StampConfig.STANDARD_STAMP_RES? = null, val rect: Rect? = null, val config: TextStampConfig? = null) {
-    fun isStandardStamp(): Boolean {
-        return null != resId
-    }
-}

+ 0 - 3
reader/src/main/java/com/kdanmobile/reader/screen/data/TextBoxAttribute.kt

@@ -1,3 +0,0 @@
-package com.kdanmobile.reader.screen.data
-
-data class TextBoxAttribute(val isBold: Boolean, val isItalic: Boolean, val textAlignment: Int, val textColor: Int, val textSize: Int)

+ 0 - 83
reader/src/main/java/com/kdanmobile/reader/screen/data/ViewerSettingSharePrefs.kt

@@ -1,83 +0,0 @@
-package com.kdanmobile.reader.screen.data
-
-import android.content.Context
-import android.content.SharedPreferences
-
-class ViewerSettingSharePrefs(val context: Context, sharedPrefsFileName: String) {
-    companion object {
-        const val readMode = "READ_MODE"
-        const val cropMode = "CROP_MODE"
-        const val stateBar = "STATE_BAR"
-        const val turnPageDirection = "TURN_PAGE_DIRECTION"
-        const val turnPageBtn = "TURN_PAGE_BUTTON"
-        const val screenSleep = "SCREEN_SLEEP"
-        const val commentTool = "COMMENT_TOOL"
-        const val botaTool = "BOTA_TOOL"
-    }
-
-    private var sharedPreferences: SharedPreferences = context.getSharedPreferences(sharedPrefsFileName, Context.MODE_PRIVATE)
-
-    fun getReadMode(): Int {
-        return sharedPreferences.getInt(readMode, 0)
-    }
-
-    fun setReadMode(showMode: Int) {
-        sharedPreferences.edit().putInt(readMode, showMode).apply()
-    }
-
-    fun isCropModeEnable(): Boolean {
-        return sharedPreferences.getBoolean(cropMode, false)
-    }
-
-    fun setCropModeEnable(enable: Boolean) {
-        sharedPreferences.edit().putBoolean(cropMode, enable).apply()
-    }
-
-    fun isShowStateBarEnable(): Boolean {
-        return sharedPreferences.getBoolean(stateBar, false)
-    }
-
-    fun setShowStateBarEnable(enable: Boolean) {
-        sharedPreferences.edit().putBoolean(stateBar, enable).apply()
-    }
-
-    fun getTurnPageDirection(): Int {
-        return sharedPreferences.getInt(turnPageDirection, 0)
-    }
-
-    fun setTurnPageDirection(direction: Int) {
-        sharedPreferences.edit().putInt(turnPageDirection, direction).apply()
-    }
-
-    fun isShowTurnPageButtonEnable(): Boolean {
-        return sharedPreferences.getBoolean(turnPageBtn, false)
-    }
-
-    fun setShowTurnPageButtonEnable(enable: Boolean) {
-        sharedPreferences.edit().putBoolean(turnPageBtn, enable).apply()
-    }
-
-    fun isLockScreenSleepEnable(): Boolean {
-        return sharedPreferences.getBoolean(screenSleep, false)
-    }
-
-    fun setLockScreenSleepEnable(enable: Boolean) {
-        sharedPreferences.edit().putBoolean(screenSleep, enable).apply()
-    }
-
-    fun isShowCommentToolEnable(): Boolean {
-        return sharedPreferences.getBoolean(commentTool, false)
-    }
-
-    fun setShowCommentToolEnable(enable: Boolean) {
-        sharedPreferences.edit().putBoolean(commentTool, enable).apply()
-    }
-
-    fun isShowBOTAToolEnable(): Boolean {
-        return sharedPreferences.getBoolean(botaTool, false)
-    }
-
-    fun setShowBOTAToolEnable(enable: Boolean) {
-        sharedPreferences.edit().putBoolean(botaTool, enable).apply()
-    }
-}

+ 0 - 8
reader/src/main/java/com/kdanmobile/reader/screen/handler/BookmarkHandler.kt

@@ -1,8 +0,0 @@
-package com.kdanmobile.reader.screen.handler
-
-import com.kdanmobile.kmpdfkit.pdfcommon.Bookmark
-
-interface BookmarkHandler {
-
-    fun getBookmarks(): Array<Bookmark>
-}

+ 0 - 9
reader/src/main/java/com/kdanmobile/reader/screen/handler/OperateHandler.kt

@@ -1,9 +0,0 @@
-package com.kdanmobile.reader.screen.handler
-
-interface OperateHandler {
-
-    fun save(): Boolean
-    fun deletePages(pages: IntArray): Boolean
-    fun reorderPage(fromPage: Int, toPage: Int): Boolean
-    fun splitPDFWithPages(path: String, selectPage: IntArray): Boolean
-}

+ 0 - 8
reader/src/main/java/com/kdanmobile/reader/screen/handler/OutlineHandler.kt

@@ -1,8 +0,0 @@
-package com.kdanmobile.reader.screen.handler
-
-import com.kdanmobile.kmpdfkit.pdfcommon.OutlineItem
-
-interface OutlineHandler {
-
-    fun getOutline(): Array<OutlineItem>
-}

+ 0 - 5
reader/src/main/java/com/kdanmobile/reader/screen/handler/PasswordHandler.kt

@@ -1,5 +0,0 @@
-package com.kdanmobile.reader.screen.handler
-
-interface PasswordHandler {
-    fun isNeedPassword(): Boolean
-}

+ 0 - 16
reader/src/main/java/com/kdanmobile/reader/screen/handler/PdfInfoHandler.kt

@@ -1,16 +0,0 @@
-package com.kdanmobile.reader.screen.handler
-
-import com.kdanmobile.kmpdfkit.pdfcommon.TextWord
-
-interface PdfInfoHandler {
-
-    fun getOpenPdfFilename(): String
-
-    fun getPdfPageCount(): Int
-
-    fun getCurrentPage(): Int
-
-    fun setCurrentPage(page: Int): Boolean
-
-    fun textLines(page: Int): Array<Array<TextWord>>
-}

+ 0 - 14
reader/src/main/java/com/kdanmobile/reader/screen/handler/SearchHandler.kt

@@ -1,14 +0,0 @@
-package com.kdanmobile.reader.screen.handler
-
-import android.graphics.RectF
-
-interface SearchHandler {
-
-    fun searchPage(page: Int, keyword: String): Array<RectF>
-
-    fun cleanPreviousSearchResults(keyword: String): Boolean
-
-    fun setSearchResult(page: Int, keyword: String, rectArray: Array<RectF>): Boolean
-
-    fun stopSearchKeyWord(): Boolean
-}

+ 0 - 17
reader/src/main/java/com/kdanmobile/reader/screen/handler/ThumbnailHandler.kt

@@ -1,17 +0,0 @@
-package com.kdanmobile.reader.screen.handler
-
-import android.graphics.Bitmap
-
-interface ThumbnailHandler {
-
-    companion object {
-        val MODE_DAY = 0
-        val MODE_NIGHT = 1
-        val MODE_SEFIA = 2
-        val MODE_ETON_BLUE = 3
-        val MODE_CHROME_WHITE = 4
-        val MODE_WHITE_LILAC = 5
-    }
-
-    fun getPdfBitmap(position: Int, picWidth: Int, mode: Int = MODE_DAY, isDrawAnnot: Boolean = true): Bitmap
-}

+ 0 - 33
reader/src/main/java/com/kdanmobile/reader/screen/model/SearchResultInfo.kt

@@ -1,33 +0,0 @@
-package com.kdanmobile.reader.screen.model
-
-import android.graphics.RectF
-import com.kdanmobile.kmpdfkit.pdfcommon.TextWord
-
-class SearchResultInfo(var page: Int, var keyword: String, var rect: RectF, lines: Array<TextWord>) {
-    var result: String = ""
-
-    init {
-        for (line in lines) {
-            result = result + line.w + " "
-        }
-
-        val sb = StringBuilder()
-        var src = result.toLowerCase()
-        val key = keyword.toLowerCase()
-        var index = src.indexOf(key)
-        while (index >= 0) {
-            sb.append(src.subSequence(0, index))
-            sb.append("<font color=\"#ff0000\">")
-            result = result.substring(index)
-            sb.append(result.substring(0, keyword.length))
-            sb.append("</font>")
-            result = result.substring(keyword.length)
-            src = src.substring(index + keyword.length)
-            index = src.indexOf(key)
-        }
-
-        sb.append(result)
-
-        result = sb.toString()
-    }
-}

+ 0 - 103
reader/src/main/java/com/kdanmobile/reader/screen/model/SharePrefsModel.kt

@@ -1,103 +0,0 @@
-package com.kdanmobile.reader.screen.model
-
-import android.arch.lifecycle.LiveData
-import android.arch.lifecycle.MutableLiveData
-import android.content.Context
-import com.kdanmobile.reader.screen.data.ViewerSettingSharePrefs
-
-class SharePrefsModel(context: Context) {
-    companion object {
-        const val viewerSettingFileName = "viewer_setting"
-    }
-
-    val readMode: LiveData<Int>
-        get() = mReadMode
-
-    val isCropModeEnable: LiveData<Boolean>
-        get() = mIsCropModeEnable
-
-    val isShowStateBarEnable: LiveData<Boolean>
-        get() = mIsShowStateBarEnable
-
-    val turnPageDirection: LiveData<Int>
-        get() = mTurnPageDirection
-
-    val isShowTurnPageBtnEnable: LiveData<Boolean>
-        get() = mIsShowTurnPageBtnEnable
-
-    val isLockScreenSleepEnable: LiveData<Boolean>
-        get() = mIsLockScreenSleepEnable
-
-    val isShowCommentToolEnable: LiveData<Boolean>
-        get() = mIsShowCommentToolEnable
-
-    val isShowBOTAToolEnable: LiveData<Boolean>
-        get() = mIsShowBOTAToolEnable
-
-    private var mReadMode = MutableLiveData<Int>()
-
-    private var mIsCropModeEnable = MutableLiveData<Boolean>()
-
-    private var mIsShowStateBarEnable = MutableLiveData<Boolean>()
-
-    private var mTurnPageDirection = MutableLiveData<Int>()
-
-    private var mIsShowTurnPageBtnEnable = MutableLiveData<Boolean>()
-
-    private var mIsLockScreenSleepEnable = MutableLiveData<Boolean>()
-
-    private var mIsShowCommentToolEnable = MutableLiveData<Boolean>()
-
-    private var mIsShowBOTAToolEnable = MutableLiveData<Boolean>()
-
-    private val viewSettingSharePrefs = ViewerSettingSharePrefs(context, viewerSettingFileName).apply {
-        mReadMode.value = this.getReadMode()
-        mIsCropModeEnable.value = this.isCropModeEnable()
-        mIsShowStateBarEnable.value = this.isShowStateBarEnable()
-        mTurnPageDirection.value = this.getTurnPageDirection()
-        mIsShowTurnPageBtnEnable.value = this.isShowTurnPageButtonEnable()
-        mIsLockScreenSleepEnable.value = this.isLockScreenSleepEnable()
-        mIsShowCommentToolEnable.value = this.isShowCommentToolEnable()
-        mIsShowBOTAToolEnable.value = this.isShowBOTAToolEnable()
-    }
-
-    fun setReadMode(readMode: Int) {
-        viewSettingSharePrefs.setReadMode(readMode)
-        mReadMode.value = readMode
-    }
-
-    fun setCropModeEnable(enable: Boolean) {
-        viewSettingSharePrefs.setCropModeEnable(enable)
-        mIsCropModeEnable.value = enable
-    }
-
-    fun setShowStateBarEnable(enable: Boolean) {
-        viewSettingSharePrefs.setShowStateBarEnable(enable)
-        mIsShowStateBarEnable.value = enable
-    }
-
-    fun setTurnPageDirection(direction: Int) {
-        viewSettingSharePrefs.setTurnPageDirection(direction)
-        mTurnPageDirection.value = direction
-    }
-
-    fun setTurnPageButtonEnable(enable: Boolean) {
-        viewSettingSharePrefs.setShowTurnPageButtonEnable(enable)
-        mIsShowTurnPageBtnEnable.value = enable
-    }
-
-    fun setLockScreenSleepEnable(enable: Boolean) {
-        viewSettingSharePrefs.setLockScreenSleepEnable(enable)
-        mIsLockScreenSleepEnable.value = enable
-    }
-
-    fun setShowCommentToolEnable(enable: Boolean) {
-        viewSettingSharePrefs.setShowCommentToolEnable(enable)
-        mIsShowCommentToolEnable.value = enable
-    }
-
-    fun setShowBOTAToolEnable(enable: Boolean) {
-        viewSettingSharePrefs.setShowBOTAToolEnable(enable)
-        mIsShowBOTAToolEnable.value = enable
-    }
-}

+ 0 - 26
reader/src/main/java/com/kdanmobile/reader/screen/model/SimpleTextWatcher.kt

@@ -1,26 +0,0 @@
-package com.kdanmobile.reader.screen.model
-
-import android.text.Editable
-import android.text.TextWatcher
-
-/**
- * @类名:SimpleTextWatcher
- * @类描述:重写TextWatcher
- * @作者:luozhipeng
- * @创建时间:2015年7月7日-下午4:14:58
- * @修改人:
- * @修改时间:
- * @修改备注:
- * @版本:
- * @Copyright:(c)-2015kdanmobile
- */
-open class SimpleTextWatcher : TextWatcher {
-    override fun beforeTextChanged(sequence: CharSequence, start: Int, count: Int, after: Int) {
-    }
-
-    override fun onTextChanged(sequence: CharSequence, start: Int, before: Int, count: Int) {
-    }
-
-    override fun afterTextChanged(editable: Editable) {
-    }
-}

+ 0 - 57
reader/src/main/java/com/kdanmobile/reader/screen/reader/mediabox/MediaBoxTabView.kt

@@ -1,57 +0,0 @@
-package com.kdanmobile.reader.screen.reader.mediabox
-
-import android.content.Context
-import android.support.constraint.ConstraintLayout
-import android.util.AttributeSet
-import android.view.LayoutInflater
-import com.kdanmobile.reader.R
-import kotlinx.android.synthetic.main.view_media_box_tab.view.*
-
-class MediaBoxTabView : ConstraintLayout {
-
-    var onClickListenerTabTextBox: OnClickListener? = null
-        set(value) {
-            field = value
-            ib_mediaBoxTab_textBox?.setOnClickListener(value)
-        }
-
-    var onClickListenerTabSignature: OnClickListener? = null
-        set(value) {
-            field = value
-            ib_mediaBoxTab_signature?.setOnClickListener(value)
-        }
-
-    var onClickListenerTabStamp: OnClickListener? = null
-        set(value) {
-            field = value
-            ib_mediaBoxTab_stamp?.setOnClickListener(value)
-        }
-
-    var onClickListenerTabShape: OnClickListener? = null
-        set(value) {
-            field = value
-            ib_mediaBoxTab_shape?.setOnClickListener(value)
-        }
-
-    var onClickListenerTabForm: OnClickListener? = null
-        set(value) {
-            field = value
-            ib_mediaBoxTab_form?.setOnClickListener(value)
-        }
-
-    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_media_box_tab, this)
-    }
-}

+ 0 - 304
reader/src/main/java/com/kdanmobile/reader/screen/reader/mediabox/MediaBoxView.kt

@@ -1,304 +0,0 @@
-package com.kdanmobile.reader.screen.reader.mediabox
-
-import android.animation.*
-import android.content.Context
-import android.graphics.Color
-import android.support.constraint.ConstraintLayout
-import android.support.v4.content.ContextCompat
-import android.util.AttributeSet
-import android.view.LayoutInflater
-import android.view.View
-import android.view.View.OnClickListener
-import android.view.animation.AccelerateDecelerateInterpolator
-import android.widget.ImageButton
-import com.kdanmobile.reader.R
-import com.kdanmobile.reader.screen.reader.mediabox.common.MediaBoxHeader
-import com.kdanmobile.reader.screen.reader.mediabox.shape.ShapeTabView
-import com.kdanmobile.reader.screen.reader.mediabox.signature.SignatureTabView
-import com.kdanmobile.reader.screen.reader.mediabox.stamp.StampTabView
-import com.kdanmobile.reader.screen.reader.mediabox.textbox.TextBoxStyleView
-import com.kdanmobile.reader.screen.reader.mediabox.textbox.TextBoxTabView
-import kotlinx.android.synthetic.main.view_media_box.view.*
-import kotlinx.android.synthetic.main.view_media_box_tab.view.*
-
-class MediaBoxView @JvmOverloads constructor(
-        context: Context,
-        attrs: AttributeSet? = null,
-        defStyleAttr: Int = 0
-): ConstraintLayout(context, attrs, defStyleAttr) {
-
-    private companion object {
-        const val COLOR_DISMISS = Color.TRANSPARENT
-        val COLOR_SHOW = Color.parseColor("#42000000")
-        const val DEFAULT_DURATION_ANIMATION = 300L
-    }
-
-    enum class MediaBoxTabType {
-        NONE, TEXT_BOX, SIGNATURE, STAMP, SHAPE, FORM, TEXT_BOX_STYLE
-    }
-
-    var onShowListener: Runnable? = null
-    var onDismissListener: Runnable? = null
-    var animationDuration = DEFAULT_DURATION_ANIMATION
-
-    private var mediaBoxAnimator: ObjectAnimator? = null
-    private var maskAnimator: ValueAnimator? = null
-    private var cacheView: View? = null
-    private var tabType = MediaBoxTabType.NONE
-    private var selected: ImageButton? = null
-    var onClickAddButtonListener: OnClickHeaderButtonListener? = null
-
-    init {
-        LayoutInflater.from(context).inflate(R.layout.view_media_box, this)
-        visibility = View.INVISIBLE
-        setupTabView()
-
-        /** Set empty listener to prevent dismissing by clicking box **/
-        view_mediaBox_dialog.setOnClickListener {}
-
-        /** Move media box view to bottom of parent(hide it) **/
-        val size = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED)
-        val v = view_mediaBox_dialog
-        v.measure(size, size)
-        v.y = v.top + v.measuredHeight.toFloat()
-    }
-
-    fun showTextBoxStyleView() {
-        if (viewGroup_mediaBox_pageContainer.childCount > 0) {
-            cacheView = viewGroup_mediaBox_pageContainer.getChildAt(0)
-            viewGroup_mediaBox_pageContainer.removeAllViews()
-        }
-        val textBoxStyleView = TextBoxStyleView(context)
-        val params = ConstraintLayout.LayoutParams(ConstraintLayout.LayoutParams.MATCH_PARENT, ConstraintLayout.LayoutParams.MATCH_PARENT)
-        viewGroup_mediaBox_pageContainer.addView(textBoxStyleView, params)
-        textBoxStyleView.onMediaBoxHeaderClickListener = object: MediaBoxHeader.OnTitleButtonClickListener {
-            override fun onTitleButtonClick() {
-                onClickAddButtonListener?.onClickTextBoxStyleApplyButton(textBoxStyleView)
-            }
-        }
-        show()
-    }
-
-    private fun showLeftSideTabView() {
-        mediaBoxTabView_mediaBox_tab.visibility = View.VISIBLE
-    }
-
-    private fun hideLeftSideTabView() {
-        mediaBoxTabView_mediaBox_tab.visibility = View.GONE
-    }
-
-    fun show() {
-        visibility = View.VISIBLE
-        setOnClickListener { dismiss(true) }
-        post {
-            showMaskWithAnimation()
-            showMediaBoxWithAnimation()
-        }
-        onShowListener?.run()
-    }
-
-    fun dismiss(fromUser: Boolean = true) {
-        setOnClickListener(null)
-        hideMaskWithAnimation()
-        hideMediaBoxWithAnimation()
-        if (fromUser) {
-            onDismissListener?.run()
-        }
-    }
-
-    private fun showMaskWithAnimation() {
-        maskAnimator?.cancel()
-        val from = maskAnimator?.animatedValue ?: COLOR_DISMISS
-        val to = COLOR_SHOW
-        maskAnimator = ValueAnimator.ofObject(ArgbEvaluator(), from, to).apply {
-            duration = DEFAULT_DURATION_ANIMATION
-            interpolator = AccelerateDecelerateInterpolator()
-            addUpdateListener {
-                setBackgroundColor(it.animatedValue as Int)
-            }
-            start()
-        }
-    }
-
-    private fun hideMaskWithAnimation() {
-        maskAnimator?.cancel()
-        val from = maskAnimator?.animatedValue ?: COLOR_SHOW
-        val to = COLOR_DISMISS
-        maskAnimator = ValueAnimator.ofObject(ArgbEvaluator(), from, to).apply {
-            duration = DEFAULT_DURATION_ANIMATION
-            interpolator = AccelerateDecelerateInterpolator()
-            addUpdateListener {
-                setBackgroundColor(it.animatedValue as Int)
-            }
-            start()
-        }
-    }
-
-    private fun showMediaBoxWithAnimation() {
-        mediaBoxAnimator?.cancel()
-        val v = view_mediaBox_dialog
-        v.visibility = View.VISIBLE
-        val from = v.y
-        val to = v.top.toFloat()
-        val holder = PropertyValuesHolder.ofFloat("Y", from, to)
-        mediaBoxAnimator = ObjectAnimator.ofPropertyValuesHolder(v, holder).apply {
-            interpolator = AccelerateDecelerateInterpolator()
-            duration = animationDuration
-            addListener(object : AnimatorListenerAdapter() {
-                override fun onAnimationStart(animation: Animator?) {
-                    super.onAnimationStart(animation)
-                    if (null != cacheView) {
-                        hideLeftSideTabView()
-                    }
-                }
-
-                override fun onAnimationEnd(animation: Animator?) {
-                    super.onAnimationEnd(animation)
-                    removeListener(this)
-                }
-            })
-            start()
-        }
-    }
-
-    private fun hideMediaBoxWithAnimation() {
-        mediaBoxAnimator?.cancel()
-        val v = view_mediaBox_dialog
-        val from = v.y
-        val to = v.top.toFloat() + v.height
-        val holder = PropertyValuesHolder.ofFloat("Y", from, to)
-        mediaBoxAnimator = ObjectAnimator.ofPropertyValuesHolder(v, holder).apply {
-            interpolator = AccelerateDecelerateInterpolator()
-            duration = animationDuration
-            addListener(object : AnimatorListenerAdapter() {
-                override fun onAnimationEnd(animation: Animator?) {
-                    super.onAnimationEnd(animation)
-                    removeListener(this)
-                    v.visibility = View.INVISIBLE
-                    this@MediaBoxView.visibility = View.GONE
-
-                    if (null != cacheView) {
-                        viewGroup_mediaBox_pageContainer.removeAllViews()
-                        viewGroup_mediaBox_pageContainer.addView(cacheView)
-                        cacheView = null
-                        showLeftSideTabView()
-                    }
-                }
-            })
-            start()
-        }
-    }
-
-    private fun setupTabView() {
-        mediaBoxTabView_mediaBox_tab.onClickListenerTabTextBox = OnClickListener(this::setupTextBoxView)
-        mediaBoxTabView_mediaBox_tab.onClickListenerTabSignature = OnClickListener(this::setupSignatureView)
-        mediaBoxTabView_mediaBox_tab.onClickListenerTabStamp = OnClickListener(this::setupStampView)
-        mediaBoxTabView_mediaBox_tab.onClickListenerTabShape = OnClickListener(this::setupShapeView)
-        mediaBoxTabView_mediaBox_tab.onClickListenerTabForm = OnClickListener(this::setupFormView)
-
-        setupTextBoxView(ib_mediaBoxTab_textBox)
-    }
-
-    private fun getButtonDrawable(tabType: MediaBoxTabType, isSelected: Boolean): Int {
-        return when (tabType) {
-            MediaBoxTabType.NONE, MediaBoxTabType.TEXT_BOX, MediaBoxTabType.TEXT_BOX_STYLE ->
-                if (isSelected) R.drawable.ic_textbox_selected else R.drawable.ic_textbox
-            MediaBoxTabType.SIGNATURE ->
-                if (isSelected) R.drawable.ic_signature_selected else R.drawable.ic_signature
-            MediaBoxTabType.STAMP ->
-                if (isSelected) R.drawable.ic_stamp_selected else R.drawable.ic_stamp
-            MediaBoxTabType.SHAPE ->
-                if (isSelected) R.drawable.ic_shape_selected else R.drawable.ic_shape
-            MediaBoxTabType.FORM ->
-                if (isSelected) R.drawable.ic_form_selected else R.drawable.ic_form
-        }
-    }
-
-    private fun setupContent(button: ImageButton, tabType: MediaBoxTabType): Boolean {
-        var changed = false
-        if (this.tabType != tabType) {
-            selected?.setImageDrawable(ContextCompat.getDrawable(context, getButtonDrawable(this.tabType, false)))
-            this.tabType = tabType
-            selected = button
-            button.setImageDrawable(ContextCompat.getDrawable(context, getButtonDrawable(this.tabType, true)))
-
-            viewGroup_mediaBox_pageContainer.removeAllViews()
-            changed = true
-        }
-        return changed
-    }
-
-    private fun setupTextBoxView(view: View) {
-        val changed = setupContent(view as ImageButton, MediaBoxTabType.TEXT_BOX)
-        if (changed) {
-            val textBoxTabView = TextBoxTabView(context)
-            val params = ConstraintLayout.LayoutParams(ConstraintLayout.LayoutParams.MATCH_PARENT, ConstraintLayout.LayoutParams.MATCH_PARENT)
-            viewGroup_mediaBox_pageContainer.addView(textBoxTabView, params)
-            textBoxTabView.onMediaBoxHeaderClickListener = object: MediaBoxHeader.OnTitleButtonClickListener {
-                override fun onTitleButtonClick() {
-                    onClickAddButtonListener?.onClickTextBoxAddButton(textBoxTabView)
-                }
-            }
-        }
-    }
-
-    private fun setupSignatureView(view: View) {
-        val changed = setupContent(view as ImageButton, MediaBoxTabType.SIGNATURE)
-        if (changed) {
-            val signatureTabView = SignatureTabView(context)
-            val params = ConstraintLayout.LayoutParams(ConstraintLayout.LayoutParams.MATCH_PARENT, ConstraintLayout.LayoutParams.MATCH_PARENT)
-            viewGroup_mediaBox_pageContainer.addView(signatureTabView, params)
-            signatureTabView.onMediaBoxHeaderClickListener = object: MediaBoxHeader.OnTitleButtonClickListener {
-                override fun onTitleButtonClick() {
-                    onClickAddButtonListener?.onClickSignatureAddButton(signatureTabView)
-                }
-            }
-        }
-    }
-
-    private fun setupStampView(view: View) {
-        val changed = setupContent(view as ImageButton, MediaBoxTabType.STAMP)
-        if (changed) {
-            val stampTabView = StampTabView(context)
-            val params = ConstraintLayout.LayoutParams(ConstraintLayout.LayoutParams.MATCH_PARENT, ConstraintLayout.LayoutParams.MATCH_PARENT)
-            viewGroup_mediaBox_pageContainer.addView(stampTabView, params)
-            stampTabView.onMediaBoxHeaderClickListener = object: MediaBoxHeader.OnTitleButtonClickListener {
-                override fun onTitleButtonClick() {
-                    onClickAddButtonListener?.onClickStampAddButton(stampTabView)
-                }
-            }
-        }
-    }
-
-    private fun setupShapeView(view: View) {
-        val changed = setupContent(view as ImageButton, MediaBoxTabType.SHAPE)
-        if (changed) {
-            val shapeTabView = ShapeTabView(context)
-            val params = ConstraintLayout.LayoutParams(ConstraintLayout.LayoutParams.MATCH_PARENT, ConstraintLayout.LayoutParams.MATCH_PARENT)
-            viewGroup_mediaBox_pageContainer.addView(shapeTabView, params)
-            shapeTabView.onMediaBoxHeaderClickListener = object: MediaBoxHeader.OnTitleButtonClickListener {
-                override fun onTitleButtonClick() {
-                    onClickAddButtonListener?.onClickShapeAddButton(shapeTabView)
-                }
-            }
-        }
-    }
-
-    private fun setupFormView(view: View) {
-        //TODO implements tab view and add to viewEdit_layout_tab_content
-        val changed = setupContent(view as ImageButton, MediaBoxTabType.FORM)
-        if (changed) {
-            LayoutInflater.from(context).inflate(R.layout.view_media_box_tab, viewGroup_mediaBox_pageContainer)
-            mediaBoxTabView_mediaBox_tab.visibility = View.VISIBLE
-            invalidate()
-        }
-    }
-
-    interface OnClickHeaderButtonListener {
-        fun onClickTextBoxAddButton(textBoxTabView: TextBoxTabView)
-        fun onClickTextBoxStyleApplyButton(textBoxTabView: TextBoxTabView)
-        fun onClickSignatureAddButton(signatureTabView: SignatureTabView)
-        fun onClickStampAddButton(stampTabView: StampTabView)
-        fun onClickShapeAddButton(shapeTabView: ShapeTabView)
-    }
-}

+ 0 - 51
reader/src/main/java/com/kdanmobile/reader/screen/reader/mediabox/common/MediaBoxHeader.kt

@@ -1,51 +0,0 @@
-package com.kdanmobile.reader.screen.reader.mediabox.common
-
-import android.content.Context
-import android.support.constraint.ConstraintLayout
-import android.util.AttributeSet
-import android.view.LayoutInflater
-import com.kdanmobile.reader.R
-import kotlinx.android.synthetic.main.view_media_box_header.view.*
-
-class MediaBoxHeader : ConstraintLayout {
-
-    private var title = ""
-    private var buttonText = ""
-
-    var onTitleButtonClickListener: OnTitleButtonClickListener? = null
-        set(value) {
-            field = value
-            btn_mediaBoxHeader_add?.setOnClickListener{field?.onTitleButtonClick()}
-        }
-
-    constructor(context: Context) : super(context) {
-        initView()
-    }
-
-    constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
-        initAttr(attrs)
-        initView()
-    }
-
-    constructor(context: Context, attrs: AttributeSet, defStyle: Int) : super(context, attrs, defStyle) {
-        initAttr(attrs)
-        initView()
-    }
-
-    private fun initAttr(attributeSet: AttributeSet) {
-        val typedArray = context.theme.obtainStyledAttributes(attributeSet, R.styleable.MediaBoxHeader, 0, 0)
-        title = typedArray.getString(R.styleable.MediaBoxHeader_title) ?: ""
-        buttonText = typedArray.getString(R.styleable.MediaBoxHeader_buttonText) ?: ""
-    }
-
-    private fun initView() {
-        LayoutInflater.from(context).inflate(R.layout.view_media_box_header, this)
-
-        tv_mediaBoxHeader_title.text = title
-        btn_mediaBoxHeader_add.text = buttonText
-    }
-
-    interface OnTitleButtonClickListener {
-        fun onTitleButtonClick()
-    }
-}

+ 0 - 90
reader/src/main/java/com/kdanmobile/reader/screen/reader/mediabox/common/MediaBoxSeekBar.kt

@@ -1,90 +0,0 @@
-package com.kdanmobile.reader.screen.reader.mediabox.common
-
-import android.content.Context
-import android.support.constraint.ConstraintLayout
-import android.util.AttributeSet
-import android.view.LayoutInflater
-import android.widget.SeekBar
-import com.kdanmobile.reader.R
-import kotlinx.android.synthetic.main.view_media_box_seekbar.view.*
-
-class MediaBoxSeekBar : ConstraintLayout {
-
-    private var title = ""
-    private var unit = ""
-    private var maxValue = 100
-    private var minValue = 0
-    private var initValue = 0
-
-    private val defaultFormatter = object : SeekBarFormatter {
-        override fun format(value: Int): String {
-            return value.toString()
-        }
-    }
-
-    var formatter = defaultFormatter
-        set(value) {
-            field = value
-            tv_mediaBoxSeekBar_value?.text = "${formatter.format(currentValue)}$unit"
-        }
-
-    interface SeekBarFormatter {
-        fun format(value: Int): String
-    }
-
-    var currentValue = 0
-        set(value) {
-            field = Math.max(Math.min(value, maxValue), minValue)
-            tv_mediaBoxSeekBar_value?.text = "${formatter.format(currentValue)}$unit"
-            seekBar_mediaBoxSeekBar?.progress = field - minValue
-        }
-    var onSeekBarChangeListener: SeekBar.OnSeekBarChangeListener? = null
-
-    constructor(context: Context) : super(context) {
-        initView()
-    }
-
-    constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
-        initAttr(attrs)
-        initView()
-    }
-
-    constructor(context: Context, attrs: AttributeSet, defStyle: Int) : super(context, attrs, defStyle) {
-        initAttr(attrs)
-        initView()
-    }
-
-    private fun initAttr(attributeSet: AttributeSet) {
-        val typedArray = context.theme.obtainStyledAttributes(attributeSet, R.styleable.MediaBoxSeekBar, 0, 0)
-        title = typedArray.getString(R.styleable.MediaBoxSeekBar_title) ?: ""
-        unit = typedArray.getString(R.styleable.MediaBoxSeekBar_unit) ?: ""
-        maxValue = typedArray.getInteger(R.styleable.MediaBoxSeekBar_maxValue, 100)
-        minValue = typedArray.getInteger(R.styleable.MediaBoxSeekBar_minValue, 0)
-        if (maxValue < minValue)
-            maxValue = minValue
-        initValue = typedArray.getInteger(R.styleable.MediaBoxSeekBar_initValue, 0)
-        initValue = Math.max(Math.min(initValue, maxValue), minValue)
-    }
-
-    private fun initView() {
-        LayoutInflater.from(context).inflate(R.layout.view_media_box_seekbar, this)
-
-        tv_mediaBoxSeekBar_title.text = title
-        seekBar_mediaBoxSeekBar.max = maxValue - minValue
-        seekBar_mediaBoxSeekBar.setOnSeekBarChangeListener(object: SeekBar.OnSeekBarChangeListener {
-            override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
-                currentValue = progress + minValue
-                onSeekBarChangeListener?.onProgressChanged(seekBar, currentValue, fromUser)
-            }
-
-            override fun onStartTrackingTouch(seekBar: SeekBar) {
-                onSeekBarChangeListener?.onStartTrackingTouch(seekBar)
-            }
-
-            override fun onStopTrackingTouch(seekBar: SeekBar) {
-                onSeekBarChangeListener?.onStopTrackingTouch(seekBar)
-            }
-        })
-        currentValue = initValue
-    }
-}

+ 0 - 140
reader/src/main/java/com/kdanmobile/reader/screen/reader/mediabox/shape/ShapeTabView.kt

@@ -1,140 +0,0 @@
-package com.kdanmobile.reader.screen.reader.mediabox.shape
-
-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.globaldata.AnnotConfig
-import com.kdanmobile.reader.R
-import com.kdanmobile.reader.screen.data.ShapeAttribute
-import com.kdanmobile.reader.screen.reader.mediabox.common.MediaBoxHeader
-import com.kdanmobile.reader.screen.reader.mediabox.common.MediaBoxSeekBar
-import kotlinx.android.synthetic.main.view_media_box_item_shape_border.view.*
-import kotlinx.android.synthetic.main.view_media_box_item_shape_fill.view.*
-import kotlinx.android.synthetic.main.view_media_box_tab_shape.view.*
-
-class ShapeTabView : ConstraintLayout {
-
-    var onMediaBoxHeaderClickListener: MediaBoxHeader.OnTitleButtonClickListener? = null
-        set(value) {
-            field = value
-            titleButton_shape?.onTitleButtonClickListener = field
-        }
-
-    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)
-                }
-            }
-        }
-
-    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_media_box_tab_shape, this)
-
-        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(resources.getString(R.string.reader_mediaBox_shape_tabBorder), resources.getString(R.string.reader_mediaBox_shape_tabFill)))
-        tabLayout.setupWithViewPager(viewPager)
-    }
-
-    fun getShapeAttribute() : ShapeAttribute {
-        val lineColor = colorChooser_shapeBorder.getSelectedColor()
-        val lineWidth = seekBar_shapeBorder_thickness.currentValue.toFloat()
-        val lineAlpha = seekBar_shapeBorder_opacity.currentValue
-        val fillColor = colorChooser_shapeFill.getSelectedColor()
-        val fillAlpha = seekBar_shapeFill_opacity.currentValue
-        return ShapeAttribute(shapeType, lineColor, lineWidth, lineAlpha, fillColor, fillAlpha)
-    }
-
-    private inner 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) {
-                true -> R.layout.view_media_box_item_shape_border
-                false -> R.layout.view_media_box_item_shape_fill
-            }
-            val view = layoutInflater.inflate(resourceId, container, false)
-            if (position == 0) {
-                view.seekBar_shapeBorder_opacity.formatter = object : MediaBoxSeekBar.SeekBarFormatter {
-                    override fun format(value: Int): String {
-                        return Math.round(value / 2.55).toInt().toString()
-                    }
-                }
-            } else {
-                view.seekBar_shapeFill_opacity.formatter = object : MediaBoxSeekBar.SeekBarFormatter {
-                    override fun format(value: Int): String {
-                        return Math.round(value / 2.55).toInt().toString()
-                    }
-                }
-            }
-            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]
-        }
-    }
-}

+ 0 - 5
reader/src/main/java/com/kdanmobile/reader/screen/reader/mediabox/signature/OnSignatureAddListener.kt

@@ -1,5 +0,0 @@
-package com.kdanmobile.reader.screen.reader.mediabox.signature
-
-interface OnSignatureAddListener {
-    fun onSignatureAdd(path: String)
-}

+ 0 - 5
reader/src/main/java/com/kdanmobile/reader/screen/reader/mediabox/signature/OnSignatureClickListener.kt

@@ -1,5 +0,0 @@
-package com.kdanmobile.reader.screen.reader.mediabox.signature
-
-interface OnSignatureClickListener {
-    fun onSignatureClick(path: String)
-}

+ 0 - 5
reader/src/main/java/com/kdanmobile/reader/screen/reader/mediabox/signature/OnSignatureRemoveListener.kt

@@ -1,5 +0,0 @@
-package com.kdanmobile.reader.screen.reader.mediabox.signature
-
-interface OnSignatureRemoveListener {
-    fun onSignatureRemove(path: String)
-}

+ 0 - 126
reader/src/main/java/com/kdanmobile/reader/screen/reader/mediabox/signature/SignatureAdapter.kt

@@ -1,126 +0,0 @@
-package com.kdanmobile.reader.screen.reader.mediabox.signature
-
-import android.content.Context
-import android.graphics.Bitmap
-import android.graphics.BitmapFactory
-import android.graphics.Matrix
-import android.support.v4.util.LruCache
-import android.support.v7.widget.RecyclerView
-import android.view.LayoutInflater
-import android.view.View
-import android.view.ViewGroup
-import android.widget.ImageView
-import com.kdanmobile.reader.R
-import io.reactivex.Observable
-import io.reactivex.android.schedulers.AndroidSchedulers
-import io.reactivex.disposables.Disposable
-import io.reactivex.schedulers.Schedulers
-import kotlinx.android.synthetic.main.view_media_box_item_signature.view.*
-
-class SignatureAdapter(private val context: Context, private var signaturePaths: ArrayList<String>): RecyclerView.Adapter<SignatureViewHolder>() {
-
-    companion object {
-        val maxMemory = Runtime.getRuntime().maxMemory() / 16
-
-        val mMemoryCache: LruCache<String, Bitmap> = object: LruCache<String, Bitmap>(maxMemory.toInt()) {
-            override fun sizeOf(key: String, value: Bitmap): Int {
-                return value.byteCount
-            }
-        }
-    }
-
-    private var onSignatureClickListener: OnSignatureClickListener? = null
-    private var onSignatureRemoveListener: OnSignatureRemoveListener? = null
-
-    override fun onBindViewHolder(holder: SignatureViewHolder, position: Int) {
-        holder.filename = signaturePaths[position]
-        holder.loadThumbSync()
-        holder.ivSignature.setOnClickListener {
-            onSignatureClickListener?.onSignatureClick(holder.filename)
-        }
-        holder.btnClose.setOnClickListener {
-            onSignatureRemoveListener?.onSignatureRemove(signaturePaths[holder.adapterPosition])
-        }
-    }
-
-    override fun getItemCount(): Int {
-        return signaturePaths.size
-    }
-
-    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): SignatureViewHolder {
-        val view = LayoutInflater.from(context).inflate(R.layout.view_media_box_item_signature, null)
-        return SignatureViewHolder(view)
-    }
-
-    override fun onViewRecycled(holder: SignatureViewHolder) {
-        super.onViewRecycled(holder)
-        holder.stopLoadThumbSync()
-    }
-
-    fun setOnSignatureClickListener(onSignatureClickListener: OnSignatureClickListener?) {
-        this.onSignatureClickListener = onSignatureClickListener
-    }
-
-    fun setOnSignatureRemoveListener(onSignatureRemoveListener: OnSignatureRemoveListener?) {
-        this.onSignatureRemoveListener = onSignatureRemoveListener
-    }
-}
-
-class SignatureViewHolder(view: View): RecyclerView.ViewHolder(view) {
-    val ivSignature: ImageView = view.iv_signature
-    val btnClose: View = view.btn_close
-    var filename: String = ""
-    private var disposable: Disposable? = null
-
-    fun loadThumbSync() {
-        stopLoadThumbSync()
-
-        disposable = Observable.create<Bitmap> { emitter ->
-            val bitmap: Bitmap
-            val value = SignatureAdapter.mMemoryCache[filename]
-            if (null != value) {
-                bitmap = value
-            } else {
-                bitmap = BitmapFactory.decodeFile(filename)
-                SignatureAdapter.mMemoryCache.put(filename, bitmap)
-            }
-            emitter.onNext(bitmap)
-            emitter.onComplete()
-        }
-                .subscribeOn(Schedulers.io())
-                .observeOn(AndroidSchedulers.mainThread())
-                .subscribe({
-                    ivSignature.setImageBitmap(it)
-                    ivSignature.invalidate()
-                    setScaleTypeFixLeft(ivSignature)
-                }, {
-                    it.printStackTrace()
-                })
-    }
-
-    private fun setScaleTypeFixLeft(imageView: ImageView) {
-
-        val drawableWidth = imageView.drawable.intrinsicWidth
-        val drawableHeight = imageView.drawable.intrinsicHeight
-        if (drawableWidth != 0 && drawableHeight != 0) {
-            val matrix = Matrix()
-            val viewWidth = imageView.width - imageView.paddingLeft - imageView.paddingRight
-            val viewHeight = imageView.height - imageView.paddingTop - imageView.paddingBottom
-            val scaleRatioX = viewWidth.toFloat() / drawableWidth
-            val scaleRatioY = viewHeight.toFloat() / drawableHeight
-            val scaleFactor = Math.min(scaleRatioX, scaleRatioY)
-            matrix.setScale(scaleFactor, scaleFactor)
-            matrix.postTranslate(0f, (viewHeight - drawableHeight * scaleFactor) * 0.5f)
-            imageView.imageMatrix = matrix
-        }
-    }
-
-    internal fun stopLoadThumbSync() {
-        if (null != disposable && !disposable!!.isDisposed) {
-            disposable?.dispose()
-            disposable = null
-            ivSignature.setImageBitmap(null)
-            ivSignature.invalidate()
-        }
-    }
-}

+ 0 - 22
reader/src/main/java/com/kdanmobile/reader/screen/reader/mediabox/signature/SignatureRecyclerViewItemDecoration.kt

@@ -1,22 +0,0 @@
-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
-
-
-class SignatureRecyclerViewItemDecoration(private val space: Int, private val additionalPadding: Int) : RecyclerView.ItemDecoration() {
-
-    override fun getItemOffsets(outRect: Rect, view: View, parent: RecyclerView, state: RecyclerView.State) {
-        val position = parent.getChildAdapterPosition(view)
-        val childCount = parent.adapter?.itemCount ?: 0
-        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
-        }
-    }
-}

+ 0 - 107
reader/src/main/java/com/kdanmobile/reader/screen/reader/mediabox/signature/SignatureTabView.kt

@@ -1,107 +0,0 @@
-package com.kdanmobile.reader.screen.reader.mediabox.signature
-
-import android.content.Context
-import android.content.Intent
-import android.support.constraint.ConstraintLayout
-import android.support.v7.widget.GridLayoutManager
-import android.util.AttributeSet
-import android.view.LayoutInflater
-import android.view.View
-import com.kdanmobile.reader.Config
-import com.kdanmobile.reader.R
-import com.kdanmobile.reader.screen.data.SignatureAttribute
-import com.kdanmobile.reader.screen.reader.mediabox.common.MediaBoxHeader
-import com.kdanmobile.reader.screen.signature.SignatureActivity
-import com.kdanmobile.reader.utils.DensityUtil
-import kotlinx.android.synthetic.main.view_media_box_tab_signature.view.*
-import java.io.File
-import java.util.*
-
-
-class SignatureTabView : ConstraintLayout {
-
-    var onMediaBoxHeaderClickListener: MediaBoxHeader.OnTitleButtonClickListener? = null
-
-    private lateinit var signaturePaths: ArrayList<String>
-    private lateinit var selectedSignaturePath: String
-
-    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_media_box_tab_signature, this)
-
-        updateSignaturePaths()
-        updateSignatureMessage()
-
-        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) {
-                selectedSignaturePath = path
-                onMediaBoxHeaderClickListener?.onTitleButtonClick()
-            }
-        })
-        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()
-                updateSignatureMessage()
-            }
-        })
-        btn_add_signature.setOnClickListener {
-            SignatureActivity.signatureAddNotifyManager = object : OnSignatureAddListener {
-                override fun onSignatureAdd(path: String) {
-                    signaturePaths.add(path)
-                    adapter.notifyDataSetChanged()
-                    recyclerView_signature.smoothScrollToPosition(signaturePaths.size - 1)
-                    updateSignatureMessage()
-                }
-            }
-            context.startActivity(Intent(context, SignatureActivity::class.java))
-        }
-        recyclerView_signature.adapter = adapter
-        recyclerView_signature.setHasFixedSize(true)
-
-        recyclerView_signature.addItemDecoration(SignatureRecyclerViewItemDecoration(DensityUtil.dp2px(context, 8f), DensityUtil.dp2px(context, 88f)))
-    }
-
-    fun getSignatureAttribute() : SignatureAttribute {
-        return SignatureAttribute(selectedSignaturePath)
-    }
-
-    private fun updateSignaturePaths() {
-        val path = Config.getSignatureDirectoryPath(context)
-        val array = File(path).list { _, name -> name.toLowerCase(Locale.US).endsWith(".png") }
-        signaturePaths = when (null != array) {
-            true -> array.toCollection(ArrayList())
-            false -> arrayListOf()
-        }
-        signaturePaths.sort()
-        for (i in 0 until signaturePaths.size) {
-            signaturePaths[i] = "$path${File.separator}${signaturePaths[i]}"
-        }
-    }
-
-    private fun updateSignatureMessage() {
-        tv_noSignature.visibility = if (signaturePaths.size == 0) View.VISIBLE else View.INVISIBLE
-        recyclerView_signature.visibility = if (signaturePaths.size == 0) View.INVISIBLE else View.VISIBLE
-    }
-}

+ 0 - 66
reader/src/main/java/com/kdanmobile/reader/screen/reader/mediabox/stamp/CustomStampAdapter.kt

@@ -1,66 +0,0 @@
-package com.kdanmobile.reader.screen.reader.mediabox.stamp
-
-import android.content.Context
-import android.support.v7.widget.RecyclerView
-import android.view.LayoutInflater
-import android.view.View
-import android.view.ViewGroup
-import android.widget.ImageView
-import com.kdanmobile.reader.R
-import kotlinx.android.synthetic.main.view_media_box_item_stamp_custom_viewholder.view.*
-
-class CustomStampAdapter(private val context: Context, private val stampTypes: Array<CustomStampType>): RecyclerView.Adapter<CustomStampViewHolder>() {
-
-    private var selectedIndex = 0
-    private var onStampClickListener: OnStampClickListener? = null
-
-    override fun onBindViewHolder(holder: CustomStampViewHolder, position: Int) {
-        val stampType = stampTypes[position]
-//            val stampTextView = holder.kmpdfStampTextView
-//            stampTextView.content = "a"
-//            stampTextView.shape = stampType.shape
-//            stampTextView.bgColor = stampType.backgroundColor
-//            stampTextView.textColor = stampType.textColor
-//            stampTextView.lineColor = stampType.lineColor
-//            stampTextView.lineWidth = 2f
-        holder.view.setOnClickListener {
-            if (position != selectedIndex) {
-                val oldSelectedIndex = selectedIndex
-                selectedIndex = position
-                notifyItemChanged(selectedIndex)
-                notifyItemChanged(oldSelectedIndex)
-                onStampClickListener?.onStampClick(selectedIndex)
-            }
-        }
-        holder.ivStamp.setImageResource(stampType.resourceId)
-        holder.ivSelectedBorder.visibility = when (position == selectedIndex) {
-            true -> View.VISIBLE
-            false -> View.INVISIBLE
-        }
-        holder.ivSelectedArrow.visibility = when (position == selectedIndex) {
-            true -> View.VISIBLE
-            false -> View.INVISIBLE
-        }
-    }
-
-    override fun getItemCount(): Int {
-        return stampTypes.size
-    }
-
-    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CustomStampViewHolder {
-        val view = LayoutInflater.from(context).inflate(R.layout.view_media_box_item_stamp_custom_viewholder, null)
-//            val view = ImageView(context)
-        return CustomStampViewHolder(view)
-    }
-
-    fun setOnStampClickListener(onStampClickListener: OnStampClickListener?) {
-        this.onStampClickListener = onStampClickListener
-    }
-}
-
-class CustomStampViewHolder(val view: View): RecyclerView.ViewHolder(view) {
-//        val kmpdfStampTextView: KMPDFStampTextView = view.findViewById(R.id.kmpdfStampTextView)
-    val ivStamp: ImageView = view.iv_stamp
-    val ivSelectedBorder: View = view.iv_selectedBorder
-    val ivSelectedArrow: ImageView = view.iv_selectedArrow
-}

+ 0 - 19
reader/src/main/java/com/kdanmobile/reader/screen/reader/mediabox/stamp/CustomStampType.kt

@@ -1,19 +0,0 @@
-package com.kdanmobile.reader.screen.reader.mediabox.stamp
-
-import com.kdanmobile.kmpdfkit.annotation.stamp.StampConfig
-import com.kdanmobile.kmpdfkit.annotation.stamp.view.KMPDFStampTextView
-import com.kdanmobile.reader.R
-
-enum class CustomStampType(val shape: KMPDFStampTextView.Shape, val backgroundColor: Int, val textColor: Int, val lineColor: Int, val resourceId: Int) {
-//        GREEN_LEFT_ARROW    (Shape.LEFT_RECT,   Color.parseColor("#ff0000"), StandardColor.text_green,   StandardColor.line_green),
-    GREEN_LEFT_ARROW    (KMPDFStampTextView.Shape.LEFT_RECT,   StampConfig.StandardColor.bg_green, StampConfig.StandardColor.text_green,   StampConfig.StandardColor.line_green,   R.drawable.stamp_green_left_arrow),
-    GREEN_RECTANGLE     (KMPDFStampTextView.Shape.RECT,        StampConfig.StandardColor.bg_green, StampConfig.StandardColor.text_green,   StampConfig.StandardColor.line_green,   R.drawable.stamp_green_rect),
-    GREEN_RIGHT_ARROW   (KMPDFStampTextView.Shape.RIGHT_RECT,  StampConfig.StandardColor.bg_green, StampConfig.StandardColor.text_green,   StampConfig.StandardColor.line_green,   R.drawable.stamp_green_right_arrow),
-    BLUE_LEFT_ARROW     (KMPDFStampTextView.Shape.LEFT_RECT,   StampConfig.StandardColor.bg_blue,  StampConfig.StandardColor.text_blue,    StampConfig.StandardColor.line_blue,    R.drawable.stamp_blue_left_arrow),
-    BLUE_RECTANGLE      (KMPDFStampTextView.Shape.RECT,        StampConfig.StandardColor.bg_blue,  StampConfig.StandardColor.text_blue,    StampConfig.StandardColor.line_blue,    R.drawable.stamp_blue_rect),
-    BLUE_RIGHT_ARROW    (KMPDFStampTextView.Shape.RIGHT_RECT,  StampConfig.StandardColor.bg_blue,  StampConfig.StandardColor.text_blue,    StampConfig.StandardColor.line_blue,    R.drawable.stamp_blue_right_arrow),
-    RED_LEFT_ARROW      (KMPDFStampTextView.Shape.LEFT_RECT,   StampConfig.StandardColor.bg_red,   StampConfig.StandardColor.text_red,     StampConfig.StandardColor.line_red,     R.drawable.stamp_red_left_arrow),
-    RED_RECTANGLE       (KMPDFStampTextView.Shape.RECT,        StampConfig.StandardColor.bg_red,   StampConfig.StandardColor.text_red,     StampConfig.StandardColor.line_red,     R.drawable.stamp_red_rect),
-    RED_RIGHT_ARROW     (KMPDFStampTextView.Shape.RIGHT_RECT,  StampConfig.StandardColor.bg_red,   StampConfig.StandardColor.text_red,     StampConfig.StandardColor.line_red,     R.drawable.stamp_red_right_arrow),
-//        NO_BORDER           (Shape.RECT,        StandardColor.bg_white, StandardColor.text_black,   StandardColor.line_white)
-}

+ 0 - 5
reader/src/main/java/com/kdanmobile/reader/screen/reader/mediabox/stamp/OnStampClickListener.kt

@@ -1,5 +0,0 @@
-package com.kdanmobile.reader.screen.reader.mediabox.stamp
-
-interface OnStampClickListener {
-    fun onStampClick(index: Int)
-}

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

@@ -1,148 +0,0 @@
-package com.kdanmobile.reader.screen.reader.mediabox.stamp
-
-import android.content.Context
-import android.graphics.Rect
-import android.support.constraint.ConstraintLayout
-import android.support.v4.view.PagerAdapter
-import android.support.v7.widget.GridLayoutManager
-import android.support.v7.widget.LinearLayoutManager
-import android.util.AttributeSet
-import android.view.LayoutInflater
-import android.view.View
-import android.view.ViewGroup
-import com.kdanmobile.kmpdfkit.annotation.stamp.StampConfig.STANDARD_STAMP_RES
-import com.kdanmobile.kmpdfkit.annotation.stamp.TextStampConfig
-import com.kdanmobile.kmpdfkit.annotation.stamp.view.KMPDFStampTextView
-import com.kdanmobile.reader.R
-import com.kdanmobile.reader.screen.data.StampAttribute
-import com.kdanmobile.reader.screen.reader.mediabox.common.MediaBoxHeader
-import kotlinx.android.synthetic.main.view_media_box_item_stamp_custom.view.*
-import kotlinx.android.synthetic.main.view_media_box_item_stamp_standard.view.*
-import kotlinx.android.synthetic.main.view_media_box_tab_stamp.view.*
-import java.text.SimpleDateFormat
-import java.util.*
-
-class StampTabView : ConstraintLayout {
-
-    private var selectedCustomStampIndex = 0
-    private var selectedStandardStampIndex = 0
-
-    var onMediaBoxHeaderClickListener: MediaBoxHeader.OnTitleButtonClickListener? = null
-        set(value) {
-            field = value
-            titleButton_stamp?.onTitleButtonClickListener = field
-        }
-
-    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_media_box_tab_stamp, this)
-
-        viewPager.adapter = StampViewPagerAdapter(arrayListOf(resources.getString(R.string.reader_mediaBox_stamp_tabCustom), resources.getString(R.string.reader_mediaBox_stamp_tabStandard)))
-        tabLayout.setupWithViewPager(viewPager)
-    }
-
-    fun getStampAttribute() : StampAttribute {
-        return when (viewPager.currentItem == 0) {
-            true -> {
-                val stampType = CustomStampType.values()[selectedCustomStampIndex]
-                //  not work?
-                val rect = Rect(0, 0, 100, 100)
-//                val timeText = "${cb_date.text}${if (cb_date.text.isNotEmpty()) " " else ""}${cb_time.text}"
-                val timeText: String
-                //  not work?
-                val timeType = if (cb_time.isChecked) {
-                    if (cb_date.isChecked) {
-                        timeText = "${cb_date.text} ${cb_time.text}"
-                        KMPDFStampTextView.TimeType.TIME_AND_DATE
-                    } else {
-                        timeText = "${cb_time.text}"
-                        KMPDFStampTextView.TimeType.TIME
-                    }
-                } else {
-                    if (cb_date.isChecked) {
-                        timeText = "${cb_date.text}"
-                        KMPDFStampTextView.TimeType.DATE
-                    } else {
-                        timeText = ""
-                        KMPDFStampTextView.TimeType.NULL
-                    }
-                }
-                StampAttribute(rect = rect, config = TextStampConfig(stampType.lineColor, stampType.backgroundColor, stampType.textColor, et_mediaBoxItemStampCustom_text.text.toString(), timeText, stampType.shape, timeType))
-            }
-            false -> {
-                StampAttribute(STANDARD_STAMP_RES.values()[selectedStandardStampIndex])
-            }
-        }
-    }
-
-    private inner class StampViewPagerAdapter(private val tabs: ArrayList<String>): PagerAdapter() {
-        private val layoutInflater = LayoutInflater.from(context)
-
-        override fun instantiateItem(container: ViewGroup, position: Int): Any {
-            val view = when (position) {
-                0 -> {
-                    val customStampView = layoutInflater.inflate(R.layout.view_media_box_item_stamp_custom, container, false)
-
-                    val date = Date()
-                    customStampView.cb_date.text = SimpleDateFormat("yyyy/MM/dd").format(date)
-                    customStampView.cb_time.text = SimpleDateFormat("hh:mm:ss a").format(date).toLowerCase(Locale.US)
-
-                    val recyclerView = customStampView.recyclerView_shapeCustom
-                    recyclerView.layoutManager = LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false)
-                    val adapter = CustomStampAdapter(context, CustomStampType.values())
-                    adapter.setOnStampClickListener(object : OnStampClickListener {
-                        override fun onStampClick(index: Int) {
-                            selectedCustomStampIndex = index
-                        }
-                    })
-                    recyclerView.adapter = adapter
-                    recyclerView.setHasFixedSize(true)
-                    customStampView
-                }
-                else -> {
-                    val standardStampView = layoutInflater.inflate(R.layout.view_media_box_item_stamp_standard, container, false)
-                    val recyclerView = standardStampView.recyclerView_shapeStandard
-                    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) {
-                            selectedStandardStampIndex = index
-                        }
-                    })
-                    recyclerView.adapter = adapter
-                    recyclerView.setHasFixedSize(true)
-                    standardStampView
-                }
-            }
-            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]
-        }
-    }
-}

+ 0 - 55
reader/src/main/java/com/kdanmobile/reader/screen/reader/mediabox/stamp/StandardStampAdapter.kt

@@ -1,55 +0,0 @@
-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>() {
-
-    private var selectedIndex = 0
-    private var onStampClickListener: OnStampClickListener? = null
-
-    override fun onBindViewHolder(holder: StandardStampViewHolder, position: Int) {
-
-        holder.imageView.setOnClickListener {
-            if (position != selectedIndex) {
-                val oldSelectedIndex = selectedIndex
-                selectedIndex = position
-                notifyItemChanged(selectedIndex)
-                notifyItemChanged(oldSelectedIndex)
-                onStampClickListener?.onStampClick(selectedIndex)
-            }
-        }
-        holder.imageView.setImageResource(resourceIds[position].resId)
-        holder.imageView.setBackgroundColor(when (position == selectedIndex) {
-            true -> ContextCompat.getColor(context, R.color.mediaBox_standardStamp_selected)
-            false -> ContextCompat.getColor(context, R.color.mediaBox_standardStamp_normal)
-        })
-    }
-
-    override fun getItemCount(): Int {
-        return resourceIds.size
-    }
-
-    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): StandardStampViewHolder {
-        val view = ImageView(context)
-        return StandardStampViewHolder(view)
-    }
-
-    fun setOnStampClickListener(onStampClickListener: OnStampClickListener?) {
-        this.onStampClickListener = onStampClickListener
-    }
-}
-
-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
-    }
-}

+ 0 - 104
reader/src/main/java/com/kdanmobile/reader/screen/reader/mediabox/textbox/TextAttrView.kt

@@ -1,104 +0,0 @@
-package com.kdanmobile.reader.screen.reader.mediabox.textbox
-
-import android.content.Context
-import android.graphics.PorterDuff
-import android.support.constraint.ConstraintLayout
-import android.support.v4.content.ContextCompat
-import android.util.AttributeSet
-import android.view.Gravity
-import android.view.LayoutInflater
-import com.kdanmobile.reader.R
-import kotlinx.android.synthetic.main.view_media_box_item_text_attr.view.*
-
-class TextAttrView : ConstraintLayout {
-
-    interface OnTextAttrClickListener {
-        fun onBoldClick(isSelected: Boolean)
-
-        fun onItalicClick(isSelected: Boolean)
-
-        fun onAlignmentClick(gravity: Int)
-    }
-    var onTextAttrClickListener: OnTextAttrClickListener? = null
-
-    var isTextBold = false
-        set(value) {
-            field = value
-            when (value) {
-                true -> btn_text_bold?.setColorFilter(selectedColor, PorterDuff.Mode.SRC_IN)
-                false -> btn_text_bold?.clearColorFilter()
-            }
-        }
-    var isTextItalic = false
-        set(value) {
-            field = value
-            when (value) {
-                true -> btn_text_italic?.setColorFilter(selectedColor, PorterDuff.Mode.SRC_IN)
-                false -> btn_text_italic?.clearColorFilter()
-            }
-        }
-    var alignment = Gravity.LEFT
-        set(value) {
-            field = value
-            when (value) {
-                Gravity.LEFT -> {
-                    btn_text_align_left.setColorFilter(selectedColor, PorterDuff.Mode.SRC_IN)
-                    btn_text_align_center.clearColorFilter()
-                    btn_text_align_right.clearColorFilter()
-                }
-                Gravity.CENTER -> {
-                    btn_text_align_left.clearColorFilter()
-                    btn_text_align_center.setColorFilter(selectedColor, PorterDuff.Mode.SRC_IN)
-                    btn_text_align_right.clearColorFilter()
-                }
-                Gravity.RIGHT -> {
-                    btn_text_align_left.clearColorFilter()
-                    btn_text_align_center.clearColorFilter()
-                    btn_text_align_right.setColorFilter(selectedColor, PorterDuff.Mode.SRC_IN)
-                }
-            }
-        }
-    private val selectedColor = ContextCompat.getColor(context, R.color.reader_viewer_edit_tab_color_selected)
-
-    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_media_box_item_text_attr, this)
-
-        btn_text_bold.setOnClickListener {
-            isTextBold = !isTextBold
-            onTextAttrClickListener?.onBoldClick(isTextBold)
-        }
-        btn_text_italic.setOnClickListener {
-            isTextItalic = !isTextItalic
-            onTextAttrClickListener?.onItalicClick(isTextItalic)
-        }
-
-        btn_text_align_left.setOnClickListener {
-            alignment = Gravity.LEFT
-            onTextAttrClickListener?.onAlignmentClick(alignment)
-        }
-        btn_text_align_center.setOnClickListener {
-            alignment = Gravity.CENTER
-            onTextAttrClickListener?.onAlignmentClick(alignment)
-        }
-        btn_text_align_right.setOnClickListener {
-            alignment = Gravity.RIGHT
-            onTextAttrClickListener?.onAlignmentClick(alignment)
-        }
-
-        isTextBold = false
-        isTextItalic = false
-        alignment = Gravity.LEFT
-    }
-}

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

@@ -1,71 +0,0 @@
-package com.kdanmobile.reader.screen.reader.mediabox.textbox
-
-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.*
-
-class TextBoxStyleView : TextBoxTabView {
-
-    constructor(context: Context) : super(context)
-
-    constructor(context: Context, attrs: AttributeSet) : super(context, attrs)
-
-    constructor(context: Context, attrs: AttributeSet, defStyle: Int) : super(context, attrs, defStyle)
-
-    override fun initView() {
-        LayoutInflater.from(context).inflate(R.layout.view_media_box_tab_text_box_style, this)
-
-        textAttrView_textBox.onTextAttrClickListener = object : TextAttrView.OnTextAttrClickListener {
-
-            private fun getTypeface(): Int {
-                return when (textAttrView_textBox.isTextBold) {
-                    true -> when (textAttrView_textBox.isTextItalic) {
-                        true -> Typeface.BOLD_ITALIC
-                        false -> Typeface.BOLD
-                    }
-                    false -> when (textAttrView_textBox.isTextItalic) {
-                        true -> Typeface.ITALIC
-                        false -> Typeface.NORMAL
-                    }
-                }
-            }
-
-            override fun onBoldClick(isSelected: Boolean) {
-                tv_preview.setTypeface(null, getTypeface())
-            }
-
-            override fun onItalicClick(isSelected: Boolean) {
-                tv_preview.setTypeface(null, getTypeface())
-            }
-
-            override fun onAlignmentClick(gravity: Int) {
-                tv_preview.gravity = gravity
-            }
-        }
-
-        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)
-            }
-        }
-
-        tv_preview.setTextColor(colorChooser_textBox.getSelectedColor())
-    }
-}

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

@@ -1,95 +0,0 @@
-package com.kdanmobile.reader.screen.reader.mediabox.textbox
-
-import android.content.Context
-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
-import com.kdanmobile.reader.screen.view.ColorSelectView
-import kotlinx.android.synthetic.main.view_media_box_tab_text_box.view.*
-
-open class TextBoxTabView : ConstraintLayout {
-
-    var onMediaBoxHeaderClickListener: MediaBoxHeader.OnTitleButtonClickListener? = null
-        set(value) {
-            field = value
-            titleButton_textBox?.onTitleButtonClickListener = field
-        }
-
-    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()
-    }
-
-    protected open fun initView() {
-        LayoutInflater.from(context).inflate(R.layout.view_media_box_tab_text_box, this)
-
-        textAttrView_textBox.onTextAttrClickListener = object : TextAttrView.OnTextAttrClickListener {
-
-            private fun getTypeface(): Int {
-                return when (textAttrView_textBox.isTextBold) {
-                    true -> when (textAttrView_textBox.isTextItalic) {
-                        true -> Typeface.BOLD_ITALIC
-                        false -> Typeface.BOLD
-                    }
-                    false -> when (textAttrView_textBox.isTextItalic) {
-                        true -> Typeface.ITALIC
-                        false -> Typeface.NORMAL
-                    }
-                }
-            }
-
-            override fun onBoldClick(isSelected: Boolean) {
-                tv_preview.setTypeface(null, getTypeface())
-            }
-
-            override fun onItalicClick(isSelected: Boolean) {
-                tv_preview.setTypeface(null, getTypeface())
-            }
-
-            override fun onAlignmentClick(gravity: Int) {
-                tv_preview.gravity = gravity
-            }
-        }
-
-        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)
-            }
-        }
-
-        tv_preview.setTextColor(colorChooser_textBox.getSelectedColor())
-    }
-
-    fun getTextBoxAttribute(): TextBoxAttribute {
-        val isBold = textAttrView_textBox.isTextBold
-        val isItalic = textAttrView_textBox.isTextItalic
-        val textAlignment = textAttrView_textBox.alignment
-        val textColor = tv_preview.currentTextColor
-        val textSize = seekBar_textBox_textSize.currentValue
-        return TextBoxAttribute(isBold, isItalic, textAlignment, textColor, textSize)
-    }
-}

+ 0 - 145
reader/src/main/java/com/kdanmobile/reader/screen/signature/SignatureActivity.kt

@@ -1,145 +0,0 @@
-package com.kdanmobile.reader.screen.signature
-
-import android.graphics.Bitmap
-import android.os.Bundle
-import android.support.v4.content.ContextCompat
-import android.support.v7.app.AppCompatActivity
-import android.view.MenuItem
-import android.view.View
-import android.widget.SeekBar
-import com.kdanmobile.reader.Config
-import com.kdanmobile.reader.R
-import com.kdanmobile.reader.screen.reader.mediabox.signature.OnSignatureAddListener
-import com.kdanmobile.reader.screen.view.ColorSelectView
-import kotlinx.android.synthetic.main.activity_view_signature_create.*
-import java.io.File
-import java.io.FileOutputStream
-import java.io.IOException
-
-class SignatureActivity : AppCompatActivity() {
-
-    companion object {
-        var signatureAddNotifyManager: OnSignatureAddListener? = null
-    }
-
-    private var onSignatureAddListener: OnSignatureAddListener? = null
-    private var noSignature = true
-        set(value) {
-            field = value
-            when (field) {
-                true -> {
-                    tv_writeHere.visibility = View.VISIBLE
-                    btn_save_signature.setTextColor(ContextCompat.getColor(baseContext, android.R.color.darker_gray))
-                    btn_save_signature.isClickable = false
-                }
-                false -> {
-                    tv_writeHere.visibility = View.INVISIBLE
-                    btn_save_signature.setTextColor(ContextCompat.getColor(baseContext, android.R.color.white))
-                    btn_save_signature.isClickable = true
-                }
-            }
-        }
-
-    override fun onCreate(savedInstanceState: Bundle?) {
-        super.onCreate(savedInstanceState)
-        setContentView(R.layout.activity_view_signature_create)
-
-        onSignatureAddListener = signatureAddNotifyManager
-        signatureAddNotifyManager = null
-
-        setupToolbar()
-
-        colorChooser_signature.onColorSelectedListener = object : ColorSelectView.OnColorSelectedListener {
-            override fun onColorSelected(color: Int) {
-                drawView.paintColor = color
-            }
-        }
-        drawView.paintColor = colorChooser_signature.getSelectedColor()
-
-        seekBar_signature.onSeekBarChangeListener = object : SeekBar.OnSeekBarChangeListener {
-            override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) {
-                drawView.strokeWidth = seekBar_signature.currentValue.toFloat()
-            }
-
-            override fun onStartTrackingTouch(seekBar: SeekBar?) {}
-
-            override fun onStopTrackingTouch(seekBar: SeekBar?) {
-                drawView.strokeWidth = seekBar_signature.currentValue.toFloat()
-            }
-        }
-        drawView.strokeWidth = seekBar_signature.currentValue.toFloat()
-
-        btn_save_signature.setOnClickListener {
-            if (!noSignature) {
-                val bitmap = drawView.getBitmap()
-
-                val argb = IntArray(bitmap.width * bitmap.height)
-                bitmap.getPixels(argb, 0, bitmap.width, 0, 0, bitmap.width, bitmap.height)
-                var minX = bitmap.width
-                var maxX = 0
-                var minY = bitmap.height
-                var maxY = 0
-                var index = 0
-                for (y in 0 until bitmap.height) {
-                    for (x in 0 until bitmap.width) {
-                        val alpha = (argb[index] shr 24) and 0xff
-                        if (alpha > 10) {
-                            minX = Math.min(x, minX)
-                            maxX = Math.max(x, maxX)
-                            minY = Math.min(y, minY)
-                            maxY = Math.max(y, maxY)
-                        }
-                        index++
-                    }
-                }
-
-                val cropBitmap = Bitmap.createBitmap(bitmap, minX, minY, maxX - minX + 1, maxY - minY + 1)
-
-                val path = Config.getSignatureDirectoryPath(baseContext)
-                val dir = File(path)
-                if (!dir.exists() || !dir.isDirectory) {
-                    dir.mkdirs()
-                }
-                val filename = "$path${File.separator}Signature${System.currentTimeMillis()}.png"
-                try {
-                    val fileOutputStream = FileOutputStream(filename)
-                    cropBitmap.compress(Bitmap.CompressFormat.PNG, 100, fileOutputStream)
-                    fileOutputStream.close()
-                } catch (e: IOException) {
-                    e.printStackTrace()
-                }
-
-                onSignatureAddListener?.onSignatureAdd(filename)
-                finish()
-            }
-        }
-
-        btn_clear_signature.setOnClickListener {
-            drawView.clear()
-        }
-
-        drawView.onSignatureDrawListener = object : SignatureDrawView.OnSignatureDrawListener {
-            override fun onClearSignature() {
-                noSignature = true
-            }
-
-            override fun onStartSignature() {
-                noSignature = false
-            }
-        }
-        noSignature = true
-    }
-
-    private fun setupToolbar() {
-        setSupportActionBar(toolbar_signature)
-        supportActionBar?.setHomeAsUpIndicator(R.drawable.ic_close)
-        supportActionBar?.setDisplayHomeAsUpEnabled(true)
-    }
-
-    override fun onOptionsItemSelected(item: MenuItem?): Boolean {
-        when (item?.itemId) {
-            android.R.id.home -> finish()
-        }
-        return super.onOptionsItemSelected(item)
-    }
-}

+ 0 - 102
reader/src/main/java/com/kdanmobile/reader/screen/signature/SignatureDrawView.kt

@@ -1,102 +0,0 @@
-package com.kdanmobile.reader.screen.signature
-
-import android.content.Context
-import android.graphics.Bitmap
-import android.graphics.Canvas
-import android.graphics.Paint
-import android.graphics.Paint.Cap
-import android.graphics.Path
-import android.support.v4.content.ContextCompat
-import android.util.AttributeSet
-import android.view.MotionEvent
-import android.view.View
-
-
-class SignatureDrawView : View {
-
-    private lateinit var paint: Paint
-    private var currentPath: Path? = null
-    private val datas = ArrayList<SignaturePathData>()
-    var onSignatureDrawListener: OnSignatureDrawListener? = null
-
-    var paintColor: Int = android.R.color.black
-    var strokeWidth: Float = 10f
-
-    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() {
-        paint = Paint()
-        paint.isAntiAlias = true
-        paint.style = Paint.Style.STROKE
-        paint.strokeCap = Cap.ROUND
-        paint.color = ContextCompat.getColor(context, paintColor)
-        paint.strokeWidth = strokeWidth
-    }
-
-    fun clear() {
-        datas.clear()
-        invalidate()
-        onSignatureDrawListener?.onClearSignature()
-    }
-
-    fun getBitmap(): Bitmap {
-        val bitmap = Bitmap.createBitmap(measuredWidth, measuredHeight, Bitmap.Config.ARGB_8888)
-        draw(Canvas(bitmap))
-        return bitmap
-    }
-
-    override fun onDraw(canvas: Canvas?) {
-        super.onDraw(canvas)
-
-        for (data in datas) {
-            paint.color = data.color
-            paint.strokeWidth = data.strokeWidth
-            canvas?.drawPath(data.path, paint)
-        }
-    }
-
-    override fun onTouchEvent(event: MotionEvent?): Boolean {
-        if (null != event) {
-            val actionIndex = event.actionIndex
-            val pointerId = event.getPointerId(actionIndex)
-            if (pointerId == 0) {
-                val x = event.getX(actionIndex)
-                val y = event.getY(actionIndex)
-                when (event.action) {
-                    MotionEvent.ACTION_DOWN -> {
-                        currentPath = Path()
-                        datas.add(SignaturePathData(currentPath!!, paintColor, strokeWidth))
-                        currentPath?.moveTo(x, y)
-                        onSignatureDrawListener?.onStartSignature()
-                    }
-                    MotionEvent.ACTION_MOVE -> {
-                        currentPath?.lineTo(x, y)
-                    }
-                    MotionEvent.ACTION_UP -> {
-                    }
-                }
-                invalidate()
-            }
-        }
-
-        return true
-    }
-
-    interface OnSignatureDrawListener {
-        fun onClearSignature()
-
-        fun onStartSignature()
-    }
-
-    data class SignaturePathData(val path: Path, val color: Int, val strokeWidth: Float)
-}

+ 0 - 82
reader/src/main/java/com/kdanmobile/reader/screen/view/BookmarkView.kt

@@ -1,82 +0,0 @@
-package com.kdanmobile.reader.screen.view
-
-import android.content.Context
-import android.support.v7.widget.LinearLayoutManager
-import android.support.v7.widget.RecyclerView
-import android.util.AttributeSet
-import android.view.LayoutInflater
-import android.widget.RelativeLayout
-import com.kdanmobile.kmpdfkit.pdfcommon.Bookmark
-import com.kdanmobile.reader.R
-import com.kdanmobile.reader.screen.adapter.BookmarkAdapter
-import com.kdanmobile.reader.screen.handler.BookmarkHandler
-import com.kdanmobile.reader.screen.handler.PdfInfoHandler
-import com.kdanmobile.reader.screen.handler.ThumbnailHandler
-import com.kdanmobile.reader.widget.drag.OnRecyclerItemClickListener
-import kotlinx.android.synthetic.main.view_bookmark.view.*
-import java.util.*
-
-class BookmarkView: RelativeLayout {
-    private var adapter: BookmarkAdapter? = null
-    private var pdfInfoHandler: PdfInfoHandler? = null
-    private var bookmarkHandler: BookmarkHandler? = null
-
-    constructor(context: Context) : super(context) {
-        initView()
-    }
-
-    constructor(context: Context, attributeSet: AttributeSet) : super(context, attributeSet) {
-        initView()
-    }
-
-    constructor(context: Context, attributeSet: AttributeSet, defStyleAttr: Int) : super(context, attributeSet, defStyleAttr) {
-        initView()
-    }
-
-    private fun initView() {
-        LayoutInflater.from(context).inflate(R.layout.view_bookmark, this)
-        val layoutManager = LinearLayoutManager(context)
-        layoutManager.orientation = LinearLayoutManager.VERTICAL
-
-        id_km_bookmark_recycler.setHasFixedSize(true)
-        id_km_bookmark_recycler.layoutManager = layoutManager
-        id_km_bookmark_recycler.layoutManager = LinearLayoutManager(context)
-        id_km_bookmark_recycler.addOnItemTouchListener(object : OnRecyclerItemClickListener(id_km_bookmark_recycler) {
-            override fun onItemClick(viewHolder: RecyclerView.ViewHolder) {
-                val bookmark = adapter?.getItem(viewHolder.adapterPosition)
-                if (null != bookmark) {
-                    pdfInfoHandler?.setCurrentPage(bookmark.pageNum)
-                }
-            }
-
-            override fun onItemLongClick(viewHolder: RecyclerView.ViewHolder) {
-
-            }
-        })
-    }
-
-    fun setHandlers(pdfInfoHandler: PdfInfoHandler, thumbnailHandler: ThumbnailHandler, bookmarkHandler: BookmarkHandler) {
-        this.pdfInfoHandler = pdfInfoHandler
-        this.bookmarkHandler = bookmarkHandler
-        adapter = BookmarkAdapter(thumbnailHandler, arrayOf())
-        id_km_bookmark_recycler.adapter = adapter
-        updateBookmark()
-    }
-
-    fun updateBookmark() {
-        if (null != bookmarkHandler) {
-            onRefreshBookmarkData(bookmarkHandler!!.getBookmarks())
-        }
-    }
-
-    private fun onRefreshBookmarkData(bookmarkItems: Array<Bookmark>) {
-        try {
-            if (bookmarkItems.isNotEmpty()) {
-                Arrays.sort(bookmarkItems) { lhs, rhs -> if (lhs.pageNum > rhs.pageNum) 1 else -1 }
-            }
-            adapter?.setOutlineItems(bookmarkItems)
-        } catch (e: Exception) {
-            e.printStackTrace()
-        }
-    }
-}

+ 0 - 62
reader/src/main/java/com/kdanmobile/reader/screen/view/ColorOvalView.kt

@@ -1,62 +0,0 @@
-package com.kdanmobile.reader.screen.view
-
-import android.content.Context
-import android.graphics.drawable.GradientDrawable
-import android.graphics.drawable.LayerDrawable
-import android.graphics.drawable.StateListDrawable
-import android.support.constraint.ConstraintLayout
-import android.support.v4.content.ContextCompat
-import android.util.AttributeSet
-import android.view.LayoutInflater
-import com.kdanmobile.reader.R
-import kotlinx.android.synthetic.main.view_color_oval.view.*
-
-class ColorOvalView : ConstraintLayout {
-
-    var color: Int = android.R.color.black
-        set(value) {
-            field = value
-
-            initColor(value)
-        }
-
-    constructor(context: Context) : super(context) {
-        initView()
-    }
-
-    constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
-        initAttr(attrs)
-        initView()
-    }
-
-    constructor(context: Context, attrs: AttributeSet, defStyle: Int) : super(context, attrs, defStyle) {
-        initAttr(attrs)
-        initView()
-    }
-
-    private fun initAttr(attributeSet: AttributeSet) {
-        val typedArray = context.theme.obtainStyledAttributes(attributeSet, R.styleable.ColorOvalView, 0, 0)
-        color = typedArray.getColor(R.styleable.ColorOvalView_color, ContextCompat.getColor(context, android.R.color.black))
-    }
-
-    private fun initView() {
-        LayoutInflater.from(context).inflate(R.layout.view_color_oval, this)
-        initColor(color)
-    }
-
-    override fun setSelected(selected: Boolean) {
-        super.setSelected(selected)
-
-        colorOval.isSelected = selected
-        initColor(color)
-    }
-
-    private fun initColor(color: Int) {
-        colorOval?.apply {
-            val stateListDrawable = background.mutate() as StateListDrawable
-            val layerDrawable = stateListDrawable.current.mutate() as LayerDrawable
-            val gradientDrawable = layerDrawable.findDrawableByLayerId(R.id.ovalColor).mutate() as GradientDrawable
-            gradientDrawable.setColor(color)
-        }
-    }
-}

+ 0 - 108
reader/src/main/java/com/kdanmobile/reader/screen/view/ColorSelectView.kt

@@ -1,108 +0,0 @@
-package com.kdanmobile.reader.screen.view
-
-import android.content.Context
-import android.util.AttributeSet
-import android.view.LayoutInflater
-import android.view.View
-import android.widget.HorizontalScrollView
-import com.kdanmobile.reader.R
-import kotlinx.android.synthetic.main.view_color_select.view.*
-
-class ColorSelectView : HorizontalScrollView {
-
-    interface OnColorSelectedListener {
-        fun onColorSelected(color: Int)
-    }
-
-    var onColorSelectedListener: OnColorSelectedListener? = null
-
-    private var selectedColor: Int = android.R.color.black
-
-    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_color_select, this)
-
-        colorSelect_column1.setOnClickListener(this::setColorSelect)
-        colorSelect_column2.setOnClickListener(this::setColorSelect)
-        colorSelect_column3.setOnClickListener(this::setColorSelect)
-        colorSelect_column4.setOnClickListener(this::setColorSelect)
-        colorSelect_column5.setOnClickListener(this::setColorSelect)
-        colorSelect_column6.setOnClickListener(this::setColorSelect)
-        colorSelect_column7.setOnClickListener(this::setColorSelect)
-        colorSelect_column8.setOnClickListener(this::setColorSelect)
-        colorSelect_column9.setOnClickListener(this::setColorSelect)
-        colorSelect_column10.setOnClickListener(this::setColorSelect)
-
-        setColorSelect(colorSelect_column1)
-    }
-
-    private fun setColorSelect(view: View) {
-        val colorOvalView = view as ColorOvalView
-
-        colorSelect_column1.isSelected = (colorOvalView == colorSelect_column1)
-        colorSelect_column2.isSelected = (colorOvalView == colorSelect_column2)
-        colorSelect_column3.isSelected = (colorOvalView == colorSelect_column3)
-        colorSelect_column4.isSelected = (colorOvalView == colorSelect_column4)
-        colorSelect_column5.isSelected = (colorOvalView == colorSelect_column5)
-        colorSelect_column6.isSelected = (colorOvalView == colorSelect_column6)
-        colorSelect_column7.isSelected = (colorOvalView == colorSelect_column7)
-        colorSelect_column8.isSelected = (colorOvalView == colorSelect_column8)
-        colorSelect_column9.isSelected = (colorOvalView == colorSelect_column9)
-        colorSelect_column10.isSelected = (colorOvalView == colorSelect_column10)
-
-        onColorSelectedListener?.onColorSelected(colorOvalView.color)
-        selectedColor = colorOvalView.color
-    }
-
-    fun getSelectedColor() : Int {
-        return selectedColor
-    }
-
-    fun setSelectedColor(color: Int) : Boolean {
-        val columnArray = arrayOf(
-                colorSelect_column1,
-                colorSelect_column2,
-                colorSelect_column3,
-                colorSelect_column4,
-                colorSelect_column5,
-                colorSelect_column6,
-                colorSelect_column7,
-                colorSelect_column8,
-                colorSelect_column9,
-                colorSelect_column10
-        )
-        for (column in columnArray) {
-            if (column.color == color) {
-                setColorSelect(column)
-                return true
-            }
-        }
-        return false
-    }
-
-    fun getColor(index: Int) : Int {
-        return when (index) {
-            0 -> colorSelect_column1.color
-            1 -> colorSelect_column2.color
-            2 -> colorSelect_column3.color
-            3 -> colorSelect_column4.color
-            4 -> colorSelect_column5.color
-            5 -> colorSelect_column6.color
-            6 -> colorSelect_column7.color
-            7 -> colorSelect_column8.color
-            8 -> colorSelect_column9.color
-            else -> colorSelect_column10.color
-        }
-    }
-}

+ 0 - 71
reader/src/main/java/com/kdanmobile/reader/screen/view/OutlineView.kt

@@ -1,71 +0,0 @@
-package com.kdanmobile.reader.screen.view
-
-import android.content.Context
-import android.util.AttributeSet
-import android.view.LayoutInflater
-import android.widget.RelativeLayout
-import com.kdanmobile.reader.R
-import com.kdanmobile.reader.screen.adapter.OutlineAdapter
-import com.kdanmobile.reader.screen.handler.OutlineHandler
-import com.kdanmobile.reader.screen.handler.PdfInfoHandler
-import io.reactivex.Observable
-import io.reactivex.android.schedulers.AndroidSchedulers
-import io.reactivex.disposables.Disposable
-import io.reactivex.schedulers.Schedulers
-import kotlinx.android.synthetic.main.view_outline.view.*
-
-class OutlineView: RelativeLayout {
-    private var adapter: OutlineAdapter? = null
-    private var pdfInfoHandler: PdfInfoHandler? = null
-    private var disposable: Disposable? = null
-
-    constructor(context: Context) : super(context) {
-        initView()
-    }
-
-    constructor(context: Context, attributeSet: AttributeSet) : super(context, attributeSet) {
-        initView()
-    }
-
-    constructor(context: Context, attributeSet: AttributeSet, defStyleAttr: Int) : super(context, attributeSet, defStyleAttr) {
-        initView()
-    }
-
-    private fun initView() {
-        LayoutInflater.from(context).inflate(R.layout.view_outline, this)
-
-        lv_viewPdfReaderOutline_.setOnItemClickListener { _, _, position, _ ->
-            val item = adapter?.getItem(position)
-            if (null != item) {
-                pdfInfoHandler?.setCurrentPage(item.page)
-            }
-        }
-
-    }
-
-    override fun onDetachedFromWindow() {
-        super.onDetachedFromWindow()
-        if (null != disposable && !disposable!!.isDisposed) {
-            disposable?.dispose()
-            disposable = null
-        }
-    }
-
-    fun setHandlers(pdfInfoHandler: PdfInfoHandler, outlineHandler: OutlineHandler) {
-        this.pdfInfoHandler = pdfInfoHandler
-        disposable = Observable.create<OutlineAdapter> {
-            val outlineItems = outlineHandler.getOutline()
-            val copyList = outlineItems.toList()
-            it.onNext(OutlineAdapter(copyList))
-            it.onComplete()
-        }
-                .subscribeOn(Schedulers.io())
-                .observeOn(AndroidSchedulers.mainThread())
-                .subscribe({
-                    adapter = it
-                    lv_viewPdfReaderOutline_.adapter = adapter
-                }, {
-                    it.printStackTrace()
-                })
-    }
-}

+ 0 - 97
reader/src/main/java/com/kdanmobile/reader/screen/view/ReadingModeSelectView.kt

@@ -1,97 +0,0 @@
-package com.kdanmobile.reader.screen.view
-
-import android.content.Context
-import android.support.constraint.ConstraintLayout
-import android.util.AttributeSet
-import android.view.LayoutInflater
-import android.view.View
-import com.kdanmobile.reader.R
-import kotlinx.android.synthetic.main.view_reading_mode_select.view.*
-
-class ReadingModeSelectView : ConstraintLayout {
-    companion object {
-        const val modeDay = 0
-        const val modeNight = 1
-        const val modeSefia = 2
-        const val modeLilac = 5
-    }
-
-    interface OnReadModeSelectListener {
-        fun onReadModeSelect(readMode: Int)
-    }
-
-    var onReadModeSelectListener: OnReadModeSelectListener? = null
-
-    var currentReadMode: Int? = null
-        set(value) {
-            field = value
-            when (value) {
-                modeDay -> setReadModeBtnActivated(btn_readingMode_day)
-                modeNight -> setReadModeBtnActivated(btn_readingMode_night)
-                modeSefia -> setReadModeBtnActivated(btn_readingMode_sefia)
-                modeLilac -> setReadModeBtnActivated(btn_readingMode_lilac)
-            }
-        }
-
-    var isLock: Boolean = false
-        set(value) {
-            field = value
-            setReadModeBtnLockVisible(isLock)
-        }
-
-    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_reading_mode_select, this).apply {
-            btn_readingMode_day.setOnClickListener {
-                onReadModeSelectListener?.onReadModeSelect(modeDay)
-                setReadModeBtnActivated(it)
-            }
-            btn_readingMode_lilac.setOnClickListener {
-                onReadModeSelectListener?.onReadModeSelect(modeLilac)
-                setReadModeBtnActivated(it)
-            }
-            btn_readingMode_night.setOnClickListener {
-                if (!isLock) {
-                    onReadModeSelectListener?.onReadModeSelect(modeNight)
-                    setReadModeBtnActivated(it)
-                }
-            }
-            btn_readingMode_sefia.setOnClickListener {
-                if (!isLock) {
-                    onReadModeSelectListener?.onReadModeSelect(modeSefia)
-                    setReadModeBtnActivated(it)
-                }
-            }
-            setReadModeBtnLockVisible(isLock)
-        }
-    }
-
-    private fun setReadModeBtnActivated(view: View?) {
-        btn_readingMode_day?.isActivated = false
-        btn_readingMode_lilac?.isActivated = false
-        btn_readingMode_night?.isActivated = false
-        btn_readingMode_sefia?.isActivated = false
-        view?.isActivated = true
-    }
-
-    private fun setReadModeBtnLockVisible(isVisible: Boolean) {
-        if (isVisible) {
-            iv_readingMode_night_lock?.visibility = View.VISIBLE
-            iv_readingMode_sefia_lock?.visibility = View.VISIBLE
-        } else {
-            iv_readingMode_night_lock?.visibility = View.INVISIBLE
-            iv_readingMode_sefia_lock?.visibility = View.INVISIBLE
-        }
-    }
-}

+ 0 - 51
reader/src/main/java/com/kdanmobile/reader/screen/view/RowSwitchView.kt

@@ -1,51 +0,0 @@
-package com.kdanmobile.reader.screen.view
-
-import android.content.Context
-import android.support.constraint.ConstraintLayout
-import android.util.AttributeSet
-import android.view.LayoutInflater
-import android.widget.CompoundButton
-import com.kdanmobile.reader.R
-import kotlinx.android.synthetic.main.view_row_switch.view.*
-
-class RowSwitchView : ConstraintLayout {
-    var text = ""
-
-    var isChecked = false
-        set(value) {
-            field = value
-            rowSwitchView_switch?.isChecked = isChecked
-        }
-
-    var onCheckedChangeListener: CompoundButton.OnCheckedChangeListener? = null
-        set(value) {
-            field = value
-            rowSwitchView_switch?.setOnCheckedChangeListener(onCheckedChangeListener)
-        }
-
-    constructor(context: Context) : super(context) {
-        initView()
-    }
-
-    constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
-        initAttr(attrs)
-        initView()
-    }
-
-    constructor(context: Context, attrs: AttributeSet, defStyle: Int) : super(context, attrs, defStyle) {
-        initAttr(attrs)
-        initView()
-    }
-
-    private fun initAttr(attributeSet: AttributeSet) {
-        val typedArray = context.theme.obtainStyledAttributes(attributeSet, R.styleable.RowSwitchView, 0, 0)
-        text = typedArray.getString(R.styleable.RowSwitchView_text)
-        isChecked = typedArray.getBoolean(R.styleable.RowSwitchView_isChecked, false)
-    }
-
-    private fun initView() {
-        LayoutInflater.from(context).inflate(R.layout.view_row_switch, this)
-        rowSwitchView_text.text = text
-        rowSwitchView_switch.isChecked = isChecked
-    }
-}

+ 0 - 39
reader/src/main/java/com/kdanmobile/reader/screen/view/ScreenSettingView.kt

@@ -1,39 +0,0 @@
-package com.kdanmobile.reader.screen.view
-
-import android.content.Context
-import android.support.constraint.ConstraintLayout
-import android.util.AttributeSet
-import android.view.LayoutInflater
-import android.widget.CompoundButton
-import com.kdanmobile.reader.R
-import kotlinx.android.synthetic.main.view_screen_setting.view.*
-
-class ScreenSettingView : ConstraintLayout {
-    var onCheckedChangeListener: CompoundButton.OnCheckedChangeListener? = null
-        set(value) {
-            field = value
-            rowSwitchView_lockScreenSleepEnable?.onCheckedChangeListener = value
-        }
-
-    var isLockScreenSleepEnable: Boolean = false
-        set(value) {
-            field = value
-            rowSwitchView_lockScreenSleepEnable?.isChecked = value
-        }
-
-    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_screen_setting, this)
-    }
-}

+ 0 - 374
reader/src/main/java/com/kdanmobile/reader/screen/view/SearchView.kt

@@ -1,374 +0,0 @@
-package com.kdanmobile.reader.screen.view
-
-import android.content.Context
-import android.content.Intent
-import android.graphics.RectF
-import android.os.Handler
-import android.os.Message
-import android.text.InputType
-import android.util.AttributeSet
-import android.view.Gravity
-import android.view.LayoutInflater
-import android.view.View
-import android.view.inputmethod.EditorInfo
-import android.view.inputmethod.InputMethodManager
-import android.widget.*
-import com.kdanmobile.kmpdfkit.pdfcommon.TextWord
-import com.kdanmobile.reader.R
-import com.kdanmobile.reader.screen.adapter.SearchAdapter
-import com.kdanmobile.reader.screen.handler.PdfInfoHandler
-import com.kdanmobile.reader.screen.handler.SearchHandler
-import com.kdanmobile.reader.screen.model.SearchResultInfo
-import com.kdanmobile.reader.screen.model.SimpleTextWatcher
-import com.kdanmobile.reader.thumb.PdfThumbActivity
-import com.kdanmobile.reader.utils.DensityUtil
-import io.reactivex.Completable
-import io.reactivex.android.schedulers.AndroidSchedulers
-import io.reactivex.disposables.Disposable
-import io.reactivex.schedulers.Schedulers
-import kotlinx.android.synthetic.main.view_search.view.*
-import java.lang.ref.WeakReference
-import java.util.*
-
-class SearchView: RelativeLayout, View.OnClickListener {
-    private var pdfInfoHandler: PdfInfoHandler? = null
-    private var searchHandler: SearchHandler? = null
-    private lateinit var linearLayout: LinearLayout
-    private lateinit var tv_page: TextView
-    private lateinit var tv_text:TextView
-    private lateinit var et_search: EditText
-    private lateinit var lv: ListView
-    private lateinit var tv_tishi: TextView
-    private lateinit var adapter: SearchAdapter
-    private val list = ArrayList<SearchResultInfo>()
-
-    // 判断搜索的是否是页码 true 是页码
-    private var isPage = false
-
-    private var msgHandler: Handler? = null
-
-    private val MAX_SEARCH_RESULT = 200
-
-    private var isDone = false
-    private var deviceWidth: Int = 0
-
-    private var disposable: Disposable? = null
-
-    constructor(context: Context) : super(context) {
-        initView()
-    }
-
-    constructor(context: Context, attributeSet: AttributeSet) : super(context, attributeSet) {
-        initView()
-    }
-
-    constructor(context: Context, attributeSet: AttributeSet, defStyleAttr: Int) : super(context, attributeSet, defStyleAttr) {
-        initView()
-    }
-
-    private fun initView() {
-        LayoutInflater.from(context).inflate(R.layout.view_search, this)
-
-        initHandler()
-
-        initLayout()
-
-        setListener()
-
-        postDelayed( { showSoftKeyboard() }, 200)
-    }
-
-    fun setHandlers(pdfInfoHandler: PdfInfoHandler, searchHandler: SearchHandler) {
-        this.pdfInfoHandler = pdfInfoHandler
-        this.searchHandler = searchHandler
-    }
-
-    private fun initHandler() {
-
-        class WeakReferenceHandler(view: SearchView) : Handler() {
-            private val mView: WeakReference<SearchView> = WeakReference(view)
-
-            override fun handleMessage(msg: Message) {
-                val view = mView.get()
-                if (view != null) {
-                    when (msg.what) {
-                        10 -> {
-                            if (msg.obj is List<*>) {
-                                view.lv.visibility = View.VISIBLE
-                                view.tv_tishi.visibility = View.GONE
-                                val item = (msg.obj as List<*>).filterIsInstance<SearchResultInfo>()
-                                view.list.addAll(item)
-                                view.adapter.add(item)
-                                view.adapter.notifyDataSetChanged()
-                            }
-                        }
-                        20 -> search()
-                        30 -> {
-                            val position = msg.arg1
-                            val info = view.list[position]
-                            view.searchHandler?.setSearchResult(info.page, info.keyword, arrayOf(info.rect))
-                            view.pdfInfoHandler?.setCurrentPage(view.list[position].page)
-                        }
-                    }
-                }
-            }
-        }
-        msgHandler = WeakReferenceHandler(this)
-    }
-
-    private fun initLayout() {
-
-        linearLayout = ll_fragmentPdfReaderSearch
-        tv_page = tv_fragmentPdfReaderSearch_page
-        tv_text = tv_fragmentPdfReaderSearch_text
-        et_search = et_fragmentPdfReaderSearch_
-
-        et_search.setHint(R.string.fragment_search_enter_text)
-        et_search.inputType = InputType.TYPE_CLASS_TEXT
-        et_search.isLongClickable = false
-        lv = lv_fragmentPdfReaderSearch_
-        tv_tishi = tv_fragmentPdfReaderSearch_tishi
-
-        var navigationHeight = 0
-        val resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android")
-        if (resourceId > 0) {
-            val rid = resources.getIdentifier("config_showNavigationBar", "bool", "android")
-            if (resources.getBoolean(rid)) {
-                navigationHeight = resources.getDimensionPixelSize(resourceId)
-            }
-        }
-        val screenWidth = DensityUtil.getScreenWidthPx(context)
-        val screenHeight = DensityUtil.getScreenHeightPx(context)
-        val density = DensityUtil.getDensity(context)
-        val xDp = (screenWidth / density).toInt()
-        val yDp = ((screenHeight + navigationHeight) / density).toInt()
-        val isPhone = when (xDp >= 550 && yDp >= 550) {
-            true -> false
-            false -> true
-        }
-        deviceWidth = Math.min(screenWidth, screenHeight)
-
-        linearLayout.layoutParams = LinearLayout.LayoutParams(318 * deviceWidth / 800, LinearLayout.LayoutParams.MATCH_PARENT)
-
-        val params = LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)
-        params.leftMargin = 21 * deviceWidth / 800
-        params.rightMargin = 21 * deviceWidth / 800
-        params.topMargin = 8 * deviceWidth / 800
-        params.bottomMargin = 8 * deviceWidth / 800
-        et_search.layoutParams = params
-        val pad = (density * 4).toInt()
-        et_search.setPadding(pad, pad, pad, pad)
-
-        if (isPhone) {
-            tv_tishi.textSize = 18f
-        } else {
-            val textSize = deviceWidth.toFloat() / 800f / density
-            tv_tishi.textSize = 24 * textSize
-        }
-
-        adapter = SearchAdapter(deviceWidth)
-        lv.adapter = adapter
-    }
-
-    private fun setListener() {
-
-        tv_page.setOnClickListener(this)
-        tv_text.setOnClickListener(this)
-
-        lv.onItemClickListener = AdapterView.OnItemClickListener { parent, view, position, id ->
-            adapter.setSelected(position)
-
-            msgHandler?.sendMessageDelayed(msgHandler?.obtainMessage(30, position, 0), 50)
-        }
-
-        et_search.setOnEditorActionListener { _, actionId, _ ->
-            if (actionId == EditorInfo.IME_ACTION_SEARCH) {
-                if (!isPage && et_search.text.toString().length < 3) {
-                    val la = IntArray(2)
-                    et_search.getLocationOnScreen(la)
-                    val y = la[1]
-                    val toast = Toast.makeText(context, R.string.fileManager_thishi_search, Toast.LENGTH_SHORT)
-                    toast.setGravity(Gravity.TOP or Gravity.LEFT, 11 * deviceWidth / 800, y + 30 * deviceWidth / 800)
-                    toast.show()
-                } else {
-                    isDone = true
-                    msgHandler?.sendEmptyMessageDelayed(20, 100)
-                    hideSoftKeyboard()
-                }
-            }
-            return@setOnEditorActionListener false
-        }
-
-        et_search.addTextChangedListener(object : SimpleTextWatcher() {
-            override fun onTextChanged(sequence: CharSequence, start: Int, before: Int, count: Int) {
-                super.onTextChanged(sequence, start, before, count)
-                try {
-                    if (isPage && sequence.isNotEmpty()) {
-                        val c = sequence[sequence.length - 1]
-                        val index = sequence[0]
-                        if (c < '0' || c > '9' || index == '0') {
-                            val text = sequence.subSequence(0, sequence.length - 1).toString()
-                            et_search.setText(text)
-                            et_search.setSelection(text.length)
-                        }
-                        val searchText = et_search.text.toString()
-                        if (searchText.isNotEmpty()) {
-                            val page = Integer.parseInt(searchText)
-                            val pageCount = pdfInfoHandler?.getPdfPageCount() ?: 0
-                            if (page > pageCount) {
-                                val text = searchText.subSequence(0, searchText.length - 1).toString()
-                                et_search.setText(text)
-                                et_search.setSelection(text.length)
-                            }
-                        }
-                    }
-                } catch (e: Exception) {
-                    e.printStackTrace()
-                    et_search.setText("")
-                }
-
-            }
-        })
-    }
-
-    override fun onClick(v: View) {
-
-        when (v.id) {
-            R.id.tv_fragmentPdfReaderSearch_page -> {
-                if (!isPage) {
-                    et_search.isLongClickable = false
-                    tv_page.setTextColor(resources.getColor(R.color.reader_search_title_selected))
-                    tv_text.setTextColor(resources.getColor(R.color.reader_search_title_normal))
-                    et_search.setText("")
-                    et_search.setHint(R.string.fragment_search_enter_page)
-                    et_search.inputType = InputType.TYPE_CLASS_NUMBER
-                    et_search.setSingleLine(true)
-
-                    lv.visibility = View.GONE
-                    tv_tishi.visibility = View.GONE
-
-                    showSoftKeyboard()
-                }
-
-                isPage = true
-            }
-            R.id.tv_fragmentPdfReaderSearch_text -> {
-                if (isPage) {
-                    et_search.isLongClickable = true
-                    tv_page.setTextColor(resources.getColor(R.color.reader_search_title_normal))
-                    tv_text.setTextColor(resources.getColor(R.color.reader_search_title_selected))
-                    et_search.setText("")
-                    et_search.setHint(R.string.fragment_search_enter_text)
-                    et_search.inputType = InputType.TYPE_CLASS_TEXT
-                    et_search.setSingleLine(true)
-
-                    lv.visibility = View.VISIBLE
-                    tv_tishi.visibility = View.GONE
-
-                    showSoftKeyboard()
-                }
-
-                isPage = false
-            }
-        }
-    }
-
-    private fun search() {
-        val searchText = et_search.text.toString()
-        if (searchText.isNotEmpty()) {
-            if (isPage) {
-                val page = Integer.parseInt(searchText)
-                if (page > 0) {
-                    pdfInfoHandler?.setCurrentPage(page - 1)
-                }
-            } else if (searchText.length >= 3) {
-                if (list.size > 0) {
-                    adapter.setSelected(-1)
-                    adapter.clear()
-                    list.clear()
-                    adapter.notifyDataSetChanged()
-                }
-
-                isDone = false
-                disposable = Completable.create {
-                    if (null != pdfInfoHandler && null != searchHandler) {
-                        val pageCount = pdfInfoHandler!!.getPdfPageCount()
-                        for (i in 0 until pageCount) {
-                            if (!isDone) {
-                                val results = searchHandler!!.searchPage(i, searchText)
-                                if (results.isNotEmpty()) {
-                                    val texts = pdfInfoHandler!!.textLines(i)
-                                    val list = dealData(texts, results, searchText, i)
-                                    msgHandler?.sendMessage(msgHandler?.obtainMessage(10, list))
-                                    if (this.list.size + list.size >= MAX_SEARCH_RESULT) {
-                                        isDone = true
-                                    }
-                                }
-                            }
-                        }
-                    }
-                    it.onComplete()
-                }
-                        .subscribeOn(Schedulers.io())
-                        .observeOn(AndroidSchedulers.mainThread())
-                        .subscribe({
-                            if (list.size < 1) {
-                                lv.visibility = View.GONE
-                                tv_tishi.visibility = View.VISIBLE
-                            }
-                        }, {
-                            it.printStackTrace()
-                        })
-            }
-        }
-    }
-
-    override fun onDetachedFromWindow() {
-        super.onDetachedFromWindow()
-        if (null != disposable && !disposable!!.isDisposed) {
-            disposable?.dispose()
-            disposable = null
-        }
-    }
-
-    private fun dealData(texts: Array<Array<TextWord>>?, results: Array<RectF>?, search: String, page: Int): List<SearchResultInfo> {
-        val list = ArrayList<SearchResultInfo>()
-        if (texts == null || results == null) {
-            return list
-        }
-        for (i in texts.indices) {
-            if (!isDone) {
-                val tw = texts[i]
-                for (j in tw.indices) {
-                    if (!isDone) {
-                        for (k in results.indices) {
-                            if (!isDone) {
-                                if (tw[j].contains(results[k])) {
-                                    list.add(SearchResultInfo(page, search, results[k], tw))
-                                    if (this.list.size + list.size >= MAX_SEARCH_RESULT) {
-                                        return list
-                                    }
-                                }
-                            }
-
-                        }
-                    }
-
-                }
-            }
-
-        }
-        return list
-    }
-
-    private fun showSoftKeyboard() {
-        val inputMethodManager = context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
-        et_search.requestFocus()
-        inputMethodManager.showSoftInput(et_search, InputMethodManager.RESULT_UNCHANGED_SHOWN)
-    }
-
-    fun hideSoftKeyboard() {
-        val inputMethodManager = context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
-        inputMethodManager.hideSoftInputFromWindow(et_search.windowToken, InputMethodManager.HIDE_NOT_ALWAYS)
-    }
-}

+ 0 - 73
reader/src/main/java/com/kdanmobile/reader/screen/view/ThumbnailView.kt

@@ -1,73 +0,0 @@
-package com.kdanmobile.reader.screen.view
-
-import android.content.Context
-import android.support.v7.widget.LinearLayoutManager
-import android.support.v7.widget.RecyclerView
-import android.util.AttributeSet
-import android.view.LayoutInflater
-import android.widget.RelativeLayout
-import com.kdanmobile.reader.R
-import com.kdanmobile.reader.screen.adapter.ThumbnailAdapter
-import com.kdanmobile.reader.screen.handler.PdfInfoHandler
-import com.kdanmobile.reader.screen.handler.ThumbnailHandler
-import com.kdanmobile.reader.widget.drag.OnRecyclerItemClickListener
-import kotlinx.android.synthetic.main.view_thumbnail.view.*
-
-class ThumbnailView: RelativeLayout {
-    private var adapter: ThumbnailAdapter? = null
-    private var currentPage = 0
-    private var pdfInfoHandler: PdfInfoHandler? = null
-
-    constructor(context: Context) : super(context) {
-        initView()
-    }
-
-    constructor(context: Context, attributeSet: AttributeSet) : super(context, attributeSet) {
-        initView()
-    }
-
-    constructor(context: Context, attributeSet: AttributeSet, defStyleAttr: Int) : super(context, attributeSet, defStyleAttr) {
-        initView()
-    }
-
-    private fun initView() {
-        LayoutInflater.from(context).inflate(R.layout.view_thumbnail, this)
-        val layoutManager = LinearLayoutManager(context)
-        layoutManager.orientation = LinearLayoutManager.VERTICAL
-
-        id_km_thumb_recycler.setHasFixedSize(true)
-        id_km_thumb_recycler.layoutManager = layoutManager
-        id_km_thumb_recycler.layoutManager = LinearLayoutManager(context)
-        id_km_thumb_recycler.addOnItemTouchListener(object : OnRecyclerItemClickListener(id_km_thumb_recycler) {
-            override fun onItemClick(viewHolder: RecyclerView.ViewHolder) {
-                onScrollToPosition(viewHolder.adapterPosition, true)
-                pdfInfoHandler?.setCurrentPage(viewHolder.adapterPosition)
-            }
-
-            override fun onItemLongClick(viewHolder: RecyclerView.ViewHolder) {
-
-            }
-        })
-    }
-
-    fun setHandlers(pdfInfoHandler: PdfInfoHandler, thumbnailHandler: ThumbnailHandler) {
-        this.pdfInfoHandler = pdfInfoHandler
-
-        adapter = ThumbnailAdapter(pdfInfoHandler, thumbnailHandler)
-        id_km_thumb_recycler.adapter = adapter
-        currentPage = pdfInfoHandler.getCurrentPage()
-        onScrollToPosition(currentPage, true)
-    }
-
-    fun onScrollToPosition(position: Int, notify: Boolean) {
-        currentPage = position
-
-        if (notify) {
-            adapter?.setCurrentPage(position)
-        }
-
-        if (null != id_km_thumb_recycler) {
-            id_km_thumb_recycler.scrollToPosition(position)
-        }
-    }
-}

+ 0 - 51
reader/src/main/java/com/kdanmobile/reader/screen/view/ToolbarSettingView.kt

@@ -1,51 +0,0 @@
-package com.kdanmobile.reader.screen.view
-
-import android.content.Context
-import android.support.constraint.ConstraintLayout
-import android.util.AttributeSet
-import android.view.LayoutInflater
-import android.widget.CompoundButton
-import com.kdanmobile.reader.R
-import kotlinx.android.synthetic.main.view_toolbar_setting.view.*
-
-class ToolbarSettingView : ConstraintLayout {
-    var onCheckedChangeListenerComment: CompoundButton.OnCheckedChangeListener? = null
-        set(value) {
-            field = value
-            rowSwitchView_show_commentTool?.onCheckedChangeListener = value
-        }
-
-    var onCheckedChangeListenerBOTA: CompoundButton.OnCheckedChangeListener? = null
-        set(value) {
-            field = value
-            rowSwitchView_show_BOTATool?.onCheckedChangeListener = value
-        }
-
-    var isShowCommentToolEnable: Boolean = false
-        set(value) {
-            field = value
-            rowSwitchView_show_commentTool?.isChecked = value
-        }
-
-    var isShowBOTAToolEnable: Boolean = false
-        set(value) {
-            field = value
-            rowSwitchView_show_BOTATool?.isChecked = value
-        }
-
-    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_toolbar_setting, this)
-    }
-}

+ 0 - 66
reader/src/main/java/com/kdanmobile/reader/screen/view/TurnPageModeSelectView.kt

@@ -1,66 +0,0 @@
-package com.kdanmobile.reader.screen.view
-
-import android.content.Context
-import android.support.constraint.ConstraintLayout
-import android.util.AttributeSet
-import android.view.LayoutInflater
-import android.widget.CompoundButton
-import com.kdanmobile.reader.R
-import kotlinx.android.synthetic.main.view_turn_page_mode_select.view.*
-
-class TurnPageModeSelectView : ConstraintLayout {
-    companion object {
-        const val vertical = 0
-        const val horizontal = 1
-    }
-
-    interface OnTurnPageModeChangedListener {
-        fun onTurnPageModeChanged(direction: Int)
-    }
-
-    var onTurnPageModeChangedListener: OnTurnPageModeChangedListener? = null
-
-    var onShowTurnPageBtnEnableChangedListener: CompoundButton.OnCheckedChangeListener? = null
-        set(value) {
-            field = value
-            rowSwitchView_showTurnPageBtn?.onCheckedChangeListener = value
-        }
-
-    var direction: Int? = null
-        set(value) {
-            field = value
-            when (value) {
-                vertical -> radioBtn_turnPageMode_vertically.isChecked = true
-                horizontal -> radioBtn_turnPageMode_horizontally.isChecked = true
-            }
-        }
-
-    var isTurnPageBtnEnable: Boolean = false
-        set(value) {
-            field = value
-            rowSwitchView_showTurnPageBtn?.isChecked = value
-        }
-
-    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_turn_page_mode_select, this)
-
-        radioGroup_turnPageMode.setOnCheckedChangeListener { _, checkedId ->
-            when (checkedId) {
-                R.id.radioBtn_turnPageMode_vertically -> onTurnPageModeChangedListener?.onTurnPageModeChanged(vertical)
-                R.id.radioBtn_turnPageMode_horizontally -> onTurnPageModeChangedListener?.onTurnPageModeChanged(horizontal)
-            }
-        }
-    }
-}

+ 0 - 143
reader/src/main/java/com/kdanmobile/reader/setting/ReaderSettingActivity.kt

@@ -1,143 +0,0 @@
-package com.kdanmobile.reader.setting
-
-import android.arch.lifecycle.Observer
-import android.arch.lifecycle.ViewModelProviders
-import android.os.Bundle
-import android.support.v7.app.AppCompatActivity
-import android.view.MenuItem
-import android.widget.CompoundButton
-import com.kdanmobile.reader.R
-import com.kdanmobile.reader.screen.model.SharePrefsModel
-import com.kdanmobile.reader.screen.view.ReadingModeSelectView
-import com.kdanmobile.reader.screen.view.TurnPageModeSelectView
-import kotlinx.android.synthetic.main.activity_reader_setting.*
-
-class ReaderSettingActivity : AppCompatActivity() {
-
-    private lateinit var viewModel: ReaderSettingViewModel
-
-    override fun onCreate(savedInstanceState: Bundle?) {
-        super.onCreate(savedInstanceState)
-        setContentView(R.layout.activity_reader_setting)
-
-        viewModel = ViewModelProviders.of(this, ReaderSettingViewModelFactory(SharePrefsModel(applicationContext)))
-                .get(ReaderSettingViewModel::class.java)
-
-        viewModel.readMode.observe(this, Observer(this::onReadModeChanged))
-        viewModel.isCropModeEnable.observe(this, Observer(this::onCropModeEnableChanged))
-        viewModel.isShowStateBarEnable.observe(this, Observer(this::onShowStateBarEnableChanged))
-        viewModel.turnPageDirection.observe(this, Observer(this::onTurnPageDirectionChanged))
-        viewModel.isShowTurnPageBtnEnable.observe(this, Observer(this::onShowTurnPageBtnEnableChange))
-        viewModel.isLockScreenSleepEnable.observe(this, Observer(this::onLockScreenSleepEnableChange))
-        viewModel.isShowCommentToolEnable.observe(this, Observer(this::onShowCommentToolEnableChange))
-        viewModel.isShowBOTAToolEnable.observe(this, Observer(this::onShowBOTAToolEnableChange))
-
-        setupToolbar()
-        setupReadingModeView()
-        setupTurnPageView()
-        setupScreenSettingView()
-        setupToolbarSettingView()
-
-        rowSwitchView_smartCrop.onCheckedChangeListener = CompoundButton.OnCheckedChangeListener { _, isChecked ->
-            viewModel.setCropModeEnable(isChecked)
-        }
-        rowSwitchView_showStateBar.onCheckedChangeListener = CompoundButton.OnCheckedChangeListener { _, isChecked ->
-            viewModel.setShowStateBarEnable(isChecked)
-        }
-    }
-
-    private fun setupToolbar() {
-        setSupportActionBar(toolbar_viewerSetting)
-        supportActionBar?.setDisplayShowTitleEnabled(false)
-    }
-
-    override fun onOptionsItemSelected(item: MenuItem?): Boolean {
-        when (item?.itemId) {
-            android.R.id.home -> finish()
-        }
-        return super.onOptionsItemSelected(item)
-    }
-
-    private fun setupReadingModeView() {
-        readingModeSelectView.isLock = true
-        readingModeSelectView.onReadModeSelectListener = object : ReadingModeSelectView.OnReadModeSelectListener {
-            override fun onReadModeSelect(readMode: Int) {
-                viewModel.setReadMode(readMode)
-            }
-        }
-    }
-
-    private fun setupTurnPageView() {
-        turnPageModeSelectView.onTurnPageModeChangedListener = object : TurnPageModeSelectView.OnTurnPageModeChangedListener {
-            override fun onTurnPageModeChanged(direction: Int) {
-                viewModel.setTurnPageDirection(direction)
-            }
-        }
-        turnPageModeSelectView.onShowTurnPageBtnEnableChangedListener = CompoundButton.OnCheckedChangeListener { _, isChecked ->
-            viewModel.setTurnPageButtonEnable(isChecked)
-        }
-    }
-
-    private fun setupScreenSettingView() {
-        screenSettingView.onCheckedChangeListener = CompoundButton.OnCheckedChangeListener { _, isChecked ->
-            viewModel.setLockScreenSleepEnable(isChecked)
-        }
-    }
-
-    private fun setupToolbarSettingView() {
-        toolbarSettingView.onCheckedChangeListenerComment = CompoundButton.OnCheckedChangeListener { _, isChecked ->
-            viewModel.setShowCommentToolEnable(isChecked)
-        }
-        toolbarSettingView.onCheckedChangeListenerBOTA = CompoundButton.OnCheckedChangeListener { _, isChecked ->
-            viewModel.setShowBOTAToolEnable(isChecked)
-        }
-    }
-
-    private fun onReadModeChanged(readMode: Int?) {
-        readMode?.let {
-            readingModeSelectView.currentReadMode = it
-        }
-    }
-
-    private fun onCropModeEnableChanged(enable: Boolean?) {
-        enable?.let {
-            rowSwitchView_smartCrop.isChecked = it
-        }
-    }
-
-    private fun onShowStateBarEnableChanged(enable: Boolean?) {
-        enable?.let {
-            rowSwitchView_showStateBar.isChecked = it
-        }
-    }
-
-    private fun onTurnPageDirectionChanged(direction: Int?) {
-        direction?.let {
-            turnPageModeSelectView.direction = it
-        }
-    }
-
-    private fun onShowTurnPageBtnEnableChange(enable: Boolean?) {
-        enable?.let {
-            turnPageModeSelectView.isTurnPageBtnEnable = it
-        }
-    }
-
-    private fun onLockScreenSleepEnableChange(enable: Boolean?) {
-        enable?.let {
-            screenSettingView.isLockScreenSleepEnable = it
-        }
-    }
-
-    private fun onShowCommentToolEnableChange(enable: Boolean?) {
-        enable?.let {
-            toolbarSettingView.isShowCommentToolEnable = it
-        }
-    }
-
-    private fun onShowBOTAToolEnableChange(enable: Boolean?) {
-        enable?.let {
-            toolbarSettingView.isShowBOTAToolEnable = it
-        }
-    }
-}

+ 0 - 65
reader/src/main/java/com/kdanmobile/reader/setting/ReaderSettingViewModel.kt

@@ -1,65 +0,0 @@
-package com.kdanmobile.reader.setting
-
-import android.arch.lifecycle.LiveData
-import android.arch.lifecycle.ViewModel
-import com.kdanmobile.reader.screen.model.SharePrefsModel
-
-class ReaderSettingViewModel(private val sharePrefsModel: SharePrefsModel) : ViewModel() {
-
-    val readMode: LiveData<Int>
-        get() = sharePrefsModel.readMode
-
-    val isCropModeEnable: LiveData<Boolean>
-        get() = sharePrefsModel.isCropModeEnable
-
-    val isShowStateBarEnable: LiveData<Boolean>
-        get() = sharePrefsModel.isShowStateBarEnable
-
-    val turnPageDirection: LiveData<Int>
-        get() = sharePrefsModel.turnPageDirection
-
-    val isShowTurnPageBtnEnable: LiveData<Boolean>
-        get() = sharePrefsModel.isShowTurnPageBtnEnable
-
-    val isLockScreenSleepEnable: LiveData<Boolean>
-        get() = sharePrefsModel.isLockScreenSleepEnable
-
-    val isShowCommentToolEnable: LiveData<Boolean>
-        get() = sharePrefsModel.isShowCommentToolEnable
-
-    val isShowBOTAToolEnable: LiveData<Boolean>
-        get() = sharePrefsModel.isShowBOTAToolEnable
-
-    fun setReadMode(readMode: Int) {
-        sharePrefsModel.setReadMode(readMode)
-    }
-
-    fun setCropModeEnable(enable: Boolean) {
-        sharePrefsModel.setCropModeEnable(enable)
-    }
-
-    fun setShowStateBarEnable(enable: Boolean) {
-        sharePrefsModel.setShowStateBarEnable(enable)
-    }
-
-    fun setTurnPageDirection(direction: Int) {
-        sharePrefsModel.setTurnPageDirection(direction)
-    }
-
-    fun setTurnPageButtonEnable(enable: Boolean) {
-        sharePrefsModel.setTurnPageButtonEnable(enable)
-    }
-
-    fun setLockScreenSleepEnable(enable: Boolean) {
-        sharePrefsModel.setLockScreenSleepEnable(enable)
-    }
-
-    fun setShowCommentToolEnable(enable: Boolean) {
-        sharePrefsModel.setShowCommentToolEnable(enable)
-    }
-
-    fun setShowBOTAToolEnable(enable: Boolean) {
-        sharePrefsModel.setShowBOTAToolEnable(enable)
-    }
-}
-

+ 0 - 11
reader/src/main/java/com/kdanmobile/reader/setting/ReaderSettingViewModelFactory.kt

@@ -1,11 +0,0 @@
-package com.kdanmobile.reader.setting
-
-import android.arch.lifecycle.ViewModel
-import android.arch.lifecycle.ViewModelProvider
-import com.kdanmobile.reader.screen.model.SharePrefsModel
-
-class ReaderSettingViewModelFactory(private val sharePrefsModel: SharePrefsModel) : ViewModelProvider.Factory {
-    override fun <T : ViewModel?> create(modelClass: Class<T>): T {
-        return ReaderSettingViewModel(sharePrefsModel) as T
-    }
-}

+ 0 - 108
reader/src/main/java/com/kdanmobile/reader/thumb/FileUtil.kt

@@ -1,108 +0,0 @@
-package com.kdanmobile.reader.thumb
-
-import android.os.Environment
-import java.io.File
-import kotlin.collections.ArrayList
-
-object FileUtil {
-    val myFolder = "KdanPDFReader"
-    val EXTENSION_SEPARATOR = '.'
-    private val UNIX_SEPARATOR = '/'
-    private val NOT_FOUND = -1
-    private val WINDOWS_SEPARATOR = '\\'
-
-    fun generateSelectedPagesString(selectPage: ArrayList<Int>): String {
-        val pages = StringBuffer()
-        for (n in selectPage) {
-            val position = n + 1
-            pages.append(position).append(",")
-        }
-        pages.deleteCharAt(pages.length - 1)
-        return pages.toString()
-    }
-
-    fun createExtractBlankFile(fileName: String, pages: String, folder: File?): File {
-        val ext = getExtension(fileName)
-        val name = removeExtension(fileName) + String.format("(page-%s)", pages)
-        var file = File(folder, String.format("%s.%s", name, ext))
-        var i = 2
-        while (file.exists()) {
-            file = File(folder, String.format("%s(%d).%s", name, i, ext))
-            i++
-        }
-        return file
-    }
-
-    @Synchronized
-    fun getMyFile(): File? {
-        var myFile: File? = null
-        if (myFile == null) {
-            myFile = File(getSdCardFile(), myFolder)
-        }
-        if (myFile.exists()) {
-            myFile.mkdirs()
-        }
-        return myFile
-    }
-
-    private fun getSdCardFile(): File? {
-        var sdcardFile: File? = null
-        if (sdcardFile == null) {
-            sdcardFile = Environment.getExternalStorageDirectory()
-        }
-        return sdcardFile
-    }
-
-    fun getExtension(filename: String?): String? {
-        if (filename == null) {
-            return null
-        }
-        val index = indexOfExtension(filename)
-        return if (index == NOT_FOUND) {
-            ""
-        } else {
-            filename.substring(index + 1)
-        }
-    }
-
-    fun indexOfExtension(filename: String?): Int {
-        if (filename == null) {
-            return NOT_FOUND
-        }
-        val extensionPos = filename.lastIndexOf(EXTENSION_SEPARATOR)
-        val lastSeparator = indexOfLastSeparator(filename)
-        return if (lastSeparator > extensionPos) NOT_FOUND else extensionPos
-    }
-
-    fun indexOfLastSeparator(filename: String?): Int {
-        if (filename == null) {
-            return NOT_FOUND
-        }
-        val lastUnixPos = filename.lastIndexOf(UNIX_SEPARATOR)
-        val lastWindowsPos = filename.lastIndexOf(WINDOWS_SEPARATOR)
-        return Math.max(lastUnixPos, lastWindowsPos)
-    }
-
-     private fun removeExtension(filename: String?): String? {
-        if (filename == null) {
-            return null
-        }
-        failIfNullBytePresent(filename)
-
-        val index = indexOfExtension(filename)
-        return if (index == NOT_FOUND) {
-            filename
-        } else {
-            filename.substring(0, index)
-        }
-    }
-
-    private fun failIfNullBytePresent(path: String) {
-        val len = path.length
-        for (i in 0 until len) {
-            if (path[i].toInt() == 0) {
-                throw IllegalArgumentException("Null byte present in file/path name. There are no " + "known legitimate use cases for such data, but several injection attacks may use it")
-            }
-        }
-    }
-}

+ 0 - 12
reader/src/main/java/com/kdanmobile/reader/thumb/ItemMoveSwipeListener.kt

@@ -1,12 +0,0 @@
-package com.kdanmobile.reader.thumb
-
-import android.support.v7.widget.RecyclerView
-
-interface ItemMoveSwipeListener {
-    fun getMovementFlags(recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder): Int
-    fun isLongPressDragEnabled(): Boolean
-    fun onItemMove(fromPosition: Int, toPosition: Int): Boolean
-    fun onItemSwipe(position: Int)
-    fun onSelectedChanged(viewHolder: RecyclerView.ViewHolder?, actionState: Int)
-    fun clearView(recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder)
-}

+ 0 - 34
reader/src/main/java/com/kdanmobile/reader/thumb/ItemTouchHelpCallback.kt

@@ -1,34 +0,0 @@
-package com.kdanmobile.reader.thumb
-
-import android.support.v7.widget.RecyclerView
-import android.support.v7.widget.helper.ItemTouchHelper
-
-
-class ItemTouchHelpCallback (private val itemMoveSwipeListener: ItemMoveSwipeListener) : ItemTouchHelper.Callback() {
-
-    override fun isLongPressDragEnabled(): Boolean {
-        return itemMoveSwipeListener.isLongPressDragEnabled()
-    }
-
-    override fun getMovementFlags(recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder): Int {
-        return itemMoveSwipeListener.getMovementFlags(recyclerView,viewHolder)
-    }
-
-    override fun onMove(recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder, target: RecyclerView.ViewHolder): Boolean {
-        return itemMoveSwipeListener.onItemMove(viewHolder.adapterPosition, target.adapterPosition)
-    }
-    override fun onSwiped(viewHolder: RecyclerView.ViewHolder, direction: Int) {
-        itemMoveSwipeListener.onItemSwipe(viewHolder.adapterPosition)
-    }
-
-    override fun clearView(recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder) {
-        itemMoveSwipeListener.clearView(recyclerView,viewHolder)
-        super.clearView(recyclerView, viewHolder)
-    }
-
-    override fun onSelectedChanged(viewHolder: RecyclerView.ViewHolder?, actionState: Int) {
-        itemMoveSwipeListener.onSelectedChanged(viewHolder, actionState)
-        super.onSelectedChanged(viewHolder, actionState)
-    }
-
-}

+ 0 - 309
reader/src/main/java/com/kdanmobile/reader/thumb/PdfThumbActivity.kt

@@ -1,309 +0,0 @@
-package com.kdanmobile.reader.thumb
-
-import android.app.Activity
-import android.app.AlertDialog
-import android.arch.lifecycle.ViewModelProviders
-import android.content.Intent
-import android.content.res.Configuration
-import android.os.Bundle
-import android.support.v7.app.AppCompatActivity
-import android.support.v7.widget.GridLayoutManager
-import android.support.v7.widget.RecyclerView
-import android.support.v7.widget.helper.ItemTouchHelper
-import android.view.*
-import com.kdanmobile.reader.R
-import com.kdanmobile.reader.ReaderActivity
-import com.kdanmobile.reader.thumb.mode.EditMode
-import com.kdanmobile.reader.thumb.mode.NormalMode
-import com.kdanmobile.reader.widget.drag.OnRecyclerItemClickListener
-import kotlinx.android.synthetic.main.layout_toolbar.*
-import kotlinx.android.synthetic.main.pdf_thumb.*
-import java.io.File
-
-abstract class PdfThumbActivity: AppCompatActivity(), PdfThumbAdapter.PageMoveHandler {
-
-    abstract fun provideIntent():Intent
-    abstract fun canDelete(): Boolean
-    abstract fun canExtract() : Boolean
-    abstract fun canChangePage() : Boolean
-    abstract fun getTrialDays(): Long
-    abstract fun getSubscribeRunnable(): Runnable
-    abstract fun getHeight(): Int
-    abstract fun getWidth(): Int
-    abstract fun getPadding(): Int
-    abstract fun getColumns(): Int
-    abstract fun getCreateExtractBlankFile(pdfFilename: String, selectPage: String): File
-
-    companion object {
-        const val THUMB_NORMAL = 0
-    }
-    private lateinit var viewModel: PdfThumbViewModel
-    private lateinit var pdfThumbAdapter: PdfThumbAdapter
-    private lateinit var thumbData: ThumbData
-    private var editMode = EditMode()
-    private var normalMode = NormalMode()
-    private var columns = 0
-    private var height = 0
-    private var width = 0
-    private var padding = 0
-
-    override fun onCreate(savedInstanceState: Bundle?) {
-        super.onCreate(savedInstanceState)
-        window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
-        setContentView(R.layout.pdf_thumb)
-        setSupportActionBar(toolbar)
-        val factory = PdfThumbViewModelFactory()
-        viewModel = ViewModelProviders.of(this, factory).get(PdfThumbViewModel::class.java)
-        initView()
-        initToolBar()
-    }
-
-    private fun initView() {
-        id_recyclerview.setHasFixedSize(true)
-        setViewSize()
-        thumbData = ThumbData().apply {
-            this.viewHeight = height
-            this.viewWidth = width
-            this.viewPadding = padding
-            this.isEditMode = viewModel.isEditMode
-            this.currentPage = viewModel.pdfInfoHandler.getCurrentPage()
-            this.pageSelect = viewModel.mapSelect
-            this.pages = viewModel.getAllPdfBitmap()
-            this.hasBookMarks = viewModel.hasBookMark()
-        }
-        pdfThumbAdapter = PdfThumbAdapter(thumbData,this)
-        viewModel.kmpdfDocumentController?.currentPageNum
-        id_recyclerview.adapter = pdfThumbAdapter
-        id_recyclerview.layoutManager = GridLayoutManager(this, columns)
-        id_recyclerview.addOnItemTouchListener(object : OnRecyclerItemClickListener(id_recyclerview) {
-            override fun onItemClick(vh: RecyclerView.ViewHolder) {
-                viewModel.mode.onPageItemClick(this@PdfThumbActivity, vh.adapterPosition, THUMB_NORMAL, viewModel.mapSelect, pdfThumbAdapter)
-            }
-            override fun onItemLongClick(vh: RecyclerView.ViewHolder) {}
-        })
-        id_recyclerview.scrollToPosition(viewModel.pdfInfoHandler.getCurrentPage())
-        var itemTouchHelperCallBack = ItemTouchHelpCallback(pdfThumbAdapter)
-        var itemTouchHelper = ItemTouchHelper(itemTouchHelperCallBack)
-        itemTouchHelper.attachToRecyclerView(id_recyclerview)
-    }
-
-    private fun initToolBar(){
-        viewModel.isEditMode.let {
-            if (it){
-                toolbar.setNavigationIcon(R.drawable.selector_close_btn_navigation)
-                supportActionBar?.title = resources.getString(R.string.pdf_thumb_title_edit_mode)
-            } else {
-                toolbar.setNavigationIcon(R.drawable.selector_arrowback)
-                supportActionBar?.title = resources.getString(R.string.thumbnail)
-            }
-        }
-        toolbar.setNavigationOnClickListener(this::onClickToolBarNavigation)
-    }
-
-    private fun setViewSize() {
-        if (resources.configuration.orientation === Configuration.ORIENTATION_LANDSCAPE) {
-            if (ScreenUtil.getXDp(this) >= 720) {
-                columns = 6
-                width = (ScreenUtil.getScreenWidth(this) / 6.6).toInt()
-            } else {
-                columns = 5
-                width = (ScreenUtil.getScreenWidth(this) / 5.5).toInt()
-            }
-        } else {
-            if (ScreenUtil.getXDp(this) >= 720) {
-                columns = 4
-                width = (ScreenUtil.getScreenWidth(this) / 4.4).toInt()
-            } else {
-                columns = 3
-                width = (ScreenUtil.getScreenWidth(this) / 3.3).toInt()
-            }
-        }
-        padding = (ScreenUtil.getScreenWidth(this) - width * columns) / 2 * (columns + 1)
-        height = 234 * width / 180
-    }
-
-    override fun onCreateOptionsMenu(menu: Menu): Boolean {
-        if (!viewModel.passwordHandler.isNeedPassword()) menuInflater.inflate(R.menu.menu_thumb, menu)
-        return true
-    }
-
-    override fun onPrepareOptionsMenu(menu: Menu): Boolean {
-        if (!viewModel.passwordHandler.isNeedPassword()) {
-            when (viewModel.isEditMode) {
-                true -> {
-                    val isExtractEnable = viewModel.hasSelectItem()
-                    val isRotateEnable = viewModel.hasSelectItem()
-                    val isDeleteEnable = viewModel.hasSelectItem() && !viewModel.isAllItemSelect()
-                    val visible = viewModel.isPdf
-                    menu.findItem(R.id.item_action_edit_thumb).isVisible = false
-                    menu.findItem(R.id.item_action_select_all_thumb)
-                            .setVisible(visible)
-                            .setIcon(if (viewModel.isAllItemSelect()) R.drawable.selector_deselect_all_btn_action_bar else R.drawable.selector_select_all_btn_action_bar)
-                    menu.findItem(R.id.item_action_extract_thumb)
-                            .setVisible(visible).isEnabled = isExtractEnable
-                    menu.findItem(R.id.item_action_rorate_thumb)
-                            .setVisible(visible).isEnabled = isRotateEnable
-                    menu.findItem(R.id.item_action_delete_thumb)
-                            .setVisible(visible).isEnabled = isDeleteEnable
-                }
-                false -> {
-                    val visible = viewModel.isPdf
-                    menu.findItem(R.id.item_action_edit_thumb).isVisible = visible
-                    menu.findItem(R.id.item_action_select_all_thumb).isVisible = false
-                    menu.findItem(R.id.item_action_extract_thumb).isVisible = false
-                    menu.findItem(R.id.item_action_rorate_thumb).isVisible = false
-                    menu.findItem(R.id.item_action_delete_thumb).isVisible = false
-                }
-            }
-        }
-        return super.onPrepareOptionsMenu(menu)
-    }
-
-    override fun onOptionsItemSelected(item: MenuItem): Boolean {
-        when (item.itemId) {
-            R.id.item_action_edit_thumb -> switchToEditMode()
-            R.id.item_action_select_all_thumb -> onClickSelectAllBtn()
-            R.id.item_action_rorate_thumb -> onClickRotateBtn()
-            R.id.item_action_delete_thumb -> onClickDeleteBtn()
-            R.id.item_action_extract_thumb -> onClickExtractBtn()
-        }
-        return super.onOptionsItemSelected(item)
-    }
-
-    override fun onBackPressed() {
-        val data = Intent()
-        data.putExtra("result", viewModel.pdfInfoHandler.getCurrentPage())
-        data.putExtra("operate", THUMB_NORMAL)
-        setResult(Activity.RESULT_OK, data)
-        finish()
-        super.onBackPressed()
-    }
-
-    private fun onClickToolBarNavigation(v: View){
-        when(viewModel.isEditMode){
-            true -> {
-                switchToNormalMode()
-                invalidateOptionsMenu()
-                onModeSwitched()
-            }
-            false -> {
-                onBackPressed()
-            }
-        }
-    }
-    private fun switchToEditMode() {
-        viewModel.mode = editMode
-        viewModel.isEditMode = true
-        thumbData.isEditMode = true
-        pdfThumbAdapter.setThumbData(thumbData)
-        onModeSwitched()
-    }
-
-    private fun switchToNormalMode() {
-        viewModel.mode = normalMode
-        viewModel.isEditMode = false
-        thumbData.isEditMode = false
-        pdfThumbAdapter.setThumbData(thumbData)
-        onModeSwitched()
-    }
-
-    private fun onModeSwitched() {
-        updateToolbar()
-    }
-
-    fun updateToolbar() {
-        invalidateOptionsMenu()
-        when(viewModel.isEditMode){
-            true -> {
-                supportActionBar?.setTitle(R.string.pdf_thumb_title_edit_mode)
-                toolbar.setNavigationIcon(R.drawable.selector_close_btn_navigation)
-            }
-            false -> {
-                supportActionBar?.setTitle(R.string.thumbnail)
-                toolbar.setNavigationIcon(R.drawable.selector_arrowback)
-            }
-        }
-    }
-
-    private fun onClickSelectAllBtn() {
-        if (!viewModel.isAllItemSelect()) {
-            viewModel.setAllSelect()
-        } else {
-            viewModel.setAllUnSelect()
-        }
-        pdfThumbAdapter.notifyDataSetChanged()
-        updateToolbar()
-    }
-
-    private fun onClickRotateBtn() {
-        val runnable = Runnable {
-            thumbData.pages = viewModel.getAllPdfBitmap()
-            pdfThumbAdapter.notifyDataSetChanged()
-        }
-        viewModel.pageRotate(runnable)
-    }
-
-    private fun onClickExtractBtn(){
-        if (!canExtract()) {
-            getSubscribeRunnable().run()
-        } else {
-            val pagesForFile = FileUtil.generateSelectedPagesString(viewModel.getSelectPage())
-            val dst = FileUtil.createExtractBlankFile(viewModel.pdfInfoHandler.getOpenPdfFilename(), pagesForFile, FileUtil.getMyFile())
-            val runnable = Runnable {
-                val filePath = String.format("/%s/%s", dst.getParentFile().getName(), dst.getName())
-                val msg = getString(R.string.pdf_thumb_extract_page_suc_dialog_msg, filePath)
-                AlertDialog.Builder(this)
-                        .setTitle(R.string.pdf_thumb_extract_page_suc_dialog_title)
-                        .setMessage(msg)
-                        .setPositiveButton(R.string.pdf_thumb_extract_page_suc_dialog_positive_btn) { _, _ ->
-                            val intent = provideIntent()
-                            intent.putExtra(ReaderActivity.KEY_FILE_ABSOLUTE, dst.absolutePath)
-                            startActivity(intent)
-                        }
-                        .show()
-            }
-            val runnableForFail = Runnable {
-                AlertDialog.Builder(this)
-                        .setTitle(R.string.pdf_thumb_extract_page_failed_dialog_title)
-                        .setMessage(R.string.pdf_thumb_extract_page_failed_dialog_msg)
-                        .show()
-            }
-            viewModel.pageExtract(dst, runnable, runnableForFail)
-        }
-    }
-
-    private fun onClickDeleteBtn(){
-        if (!canDelete()) {
-            getSubscribeRunnable().run()
-        } else {
-            var builder = AlertDialog.Builder(this)
-            builder.setMessage(R.string.pdf_thumb_delete_check_dialog_msg)
-            builder.setNegativeButton(R.string.common_cancel) { dialog, _ -> dialog.dismiss() }
-            builder.setPositiveButton(R.string.common_okay) { _, _ ->
-                    viewModel.pageDelete(Runnable {
-                    viewModel.setAllUnSelect()
-                    thumbData.pages = viewModel.getAllPdfBitmap()
-                    pdfThumbAdapter.notifyDataSetChanged() }) }
-            builder.create().show()
-        }
-    }
-
-
-    override fun onPageMove(fromPage: Int, toPage: Int) {
-        if(!canChangePage()) {
-            getSubscribeRunnable().run()
-        } else {
-            val runnable = Runnable {
-                thumbData.hasBookMarks?.let { it ->
-                    it[fromPage] = it[toPage]
-                }
-                thumbData.pages?.let { it ->
-                    var tempPage = it[fromPage]
-                    it.removeAt(fromPage)
-                    it.add(toPage, tempPage)
-                }
-            }
-            viewModel.reorderPage(fromPage, toPage, runnable)
-        }
-    }
-}

+ 0 - 121
reader/src/main/java/com/kdanmobile/reader/thumb/PdfThumbAdapter.kt

@@ -1,121 +0,0 @@
-package com.kdanmobile.reader.thumb
-
-import android.graphics.Bitmap
-import android.support.v7.widget.RecyclerView
-import android.support.v7.widget.helper.ItemTouchHelper
-import android.support.v7.widget.helper.ItemTouchHelper.Callback.makeMovementFlags
-import android.view.LayoutInflater
-import android.view.View
-import android.view.ViewGroup
-import android.widget.LinearLayout
-import com.kdanmobile.reader.R
-import kotlinx.android.synthetic.main.pdf_thumb_gv_item.view.*
-
-class PdfThumbAdapter(thumbData: ThumbData, pageMoveHandler: PageMoveHandler): RecyclerView.Adapter<PdfThumbAdapter.ViewHolder>(), ItemMoveSwipeListener {
-    var data = thumbData
-    var handler = pageMoveHandler
-
-    override fun getItemCount(): Int {
-        var size = 0
-        data.pages?.let {
-            size = it.size
-        }
-        return size
-    }
-
-    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
-        holder.bind(data, position)
-    }
-
-    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
-        val v1 = LayoutInflater.from(parent.context).inflate(R.layout.pdf_thumb_gv_item, parent, false)
-        var holder = ViewHolder(v1)
-        holder?.setSize(data.viewWidth, data.viewHeight, data.viewPadding, ScreenUtil.getDensity(parent.context))
-        return ViewHolder(v1)
-    }
-
-    class ViewHolder (view : View) : RecyclerView.ViewHolder(view) {
-        fun bind(thumbData: ThumbData, position: Int) {
-            var pages = thumbData.pages as List<Bitmap>
-            itemView.iv_pdfThumbGvItem_.setImageBitmap(pages[position])
-            itemView.tv_pdfThumbGvItem_page.text = (position + 1).toString()
-            itemView.cb_pdfThumbGvItem_.isChecked = thumbData.pageSelect[position] as Boolean
-            thumbData.hasBookMarks?.let {
-                when (it[position]){
-                    true -> {
-                        itemView.iv_pdfThumbGvItem_bookmark.visibility = View.VISIBLE
-                    }
-                    false -> {
-                        itemView.iv_pdfThumbGvItem_bookmark.visibility = View.GONE
-                    }
-                }
-            }
-            when(thumbData.currentPage == position) {
-                true -> {
-                    itemView.view_pdfThumbGvItem_.visibility = View.VISIBLE
-                }
-                false -> {
-                    itemView.view_pdfThumbGvItem_.visibility = View.GONE
-                }
-            }
-            when(thumbData.isEditMode){
-                true -> {
-                    itemView.cb_pdfThumbGvItem_.visibility = View.VISIBLE
-                }
-                false -> {
-                    itemView.cb_pdfThumbGvItem_.visibility = View.GONE
-                }
-            }
-        }
-
-        fun setSize(width: Int, height: Int, padding: Int, density: Float) {
-            if (width != itemView.rl_pdfThumbGvItem_.getWidth()) {
-                val params = LinearLayout.LayoutParams(width, height)
-                params.topMargin = (density * 4).toInt()
-                params.leftMargin = padding
-                params.rightMargin = padding
-                itemView.rl_pdfThumbGvItem_.layoutParams = params
-                itemView.iv_pdfThumbGvItem_.setPadding(1, 1, 1, 1)
-            }
-        }
-    }
-
-    fun setThumbData(thumbData: ThumbData){
-        data = thumbData
-        notifyDataSetChanged()
-    }
-
-    override fun isLongPressDragEnabled(): Boolean {
-        return data.isEditMode
-    }
-    override fun getMovementFlags(recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder): Int {
-        val dragFlags = ItemTouchHelper.LEFT or ItemTouchHelper.RIGHT or ItemTouchHelper.UP or ItemTouchHelper.DOWN
-        val swipeFlags = 0
-        return makeMovementFlags(dragFlags, swipeFlags)
-    }
-    override fun onItemMove(fromPosition: Int, toPosition: Int): Boolean {
-        notifyItemMoved(fromPosition, toPosition)
-        handler.onPageMove(fromPosition,toPosition)
-        return true
-    }
-
-    override fun onItemSwipe(position: Int) {
-    }
-
-    override fun clearView(recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder) {
-        viewHolder.itemView.scaleX = 1.0f
-        viewHolder.itemView.scaleY = 1.0f
-        notifyDataSetChanged()
-    }
-
-    override fun onSelectedChanged(viewHolder: RecyclerView.ViewHolder?, actionState: Int) {
-        if (actionState != ItemTouchHelper.ACTION_STATE_IDLE && null != viewHolder) {
-            viewHolder.itemView.scaleX = 0.7f
-            viewHolder.itemView.scaleY = 0.7f
-        }
-    }
-
-    interface PageMoveHandler{
-        fun onPageMove(fromPage: Int, toPage: Int)
-    }
-}

+ 0 - 246
reader/src/main/java/com/kdanmobile/reader/thumb/PdfThumbViewModel.kt

@@ -1,246 +0,0 @@
-package com.kdanmobile.reader.thumb
-
-import android.app.AlertDialog
-import android.arch.lifecycle.ViewModel
-import android.graphics.Bitmap
-import com.kdanmobile.kmpdfkit.manager.KMPDFFactory
-import com.kdanmobile.kmpdfkit.manager.controller.KMPDFDocumentController
-import com.kdanmobile.kmpdfkit.pdfcommon.Bookmark
-import com.kdanmobile.kmpdfkit.pdfcommon.TextWord
-import com.kdanmobile.reader.R
-import com.kdanmobile.reader.ReaderActivity
-import com.kdanmobile.reader.screen.handler.*
-import com.kdanmobile.reader.thumb.mode.Mode
-import com.kdanmobile.reader.thumb.mode.NormalMode
-import io.reactivex.Observable
-import io.reactivex.android.schedulers.AndroidSchedulers
-import io.reactivex.disposables.Disposable
-import io.reactivex.schedulers.Schedulers
-import java.io.File
-import java.util.HashMap
-
-class PdfThumbViewModel: ViewModel() {
-    companion object {
-        var tempKmpdfFactory: KMPDFFactory? = null
-        var tempkmpdfDocumentController: KMPDFDocumentController? = null
-    }
-
-    private var pageCount = 0
-    private var normalMode = NormalMode()
-    private var disposable: Disposable? = null
-    var kmpdfFactory: KMPDFFactory? = null
-    var kmpdfDocumentController: KMPDFDocumentController? = null
-    val mapSelect: MutableMap<Int, Boolean> = HashMap()
-    var mode: Mode
-    var isEditMode = false
-    var isPdf = true
-
-    init {
-        kmpdfFactory = tempKmpdfFactory
-        kmpdfDocumentController = tempkmpdfDocumentController
-        tempKmpdfFactory = null
-        tempkmpdfDocumentController = null
-        pageCount = kmpdfDocumentController?.getDocumentPageCount(false) ?: 0
-        for (i in 0 until pageCount){
-            mapSelect[i] = false
-        }
-        mode = normalMode
-    }
-
-    val pdfInfoHandler = object : PdfInfoHandler {
-        override fun getOpenPdfFilename(): String {
-            return kmpdfFactory?.fileName ?: ""
-        }
-
-        override fun getPdfPageCount(): Int {
-            return kmpdfDocumentController?.getDocumentPageCount(false) ?: 0
-        }
-
-        override fun getCurrentPage(): Int {
-            return kmpdfDocumentController?.currentPageNum ?: 0
-        }
-
-        override fun setCurrentPage(page: Int): Boolean {
-            return kmpdfDocumentController?.gotoPage(page) ?: false
-        }
-
-        override fun textLines(page: Int): Array<Array<TextWord>> {
-            return kmpdfDocumentController?.textLines(page) ?: arrayOf()
-        }
-    }
-
-    private val thumbnailHandler = object : ThumbnailHandler {
-        override fun getPdfBitmap(position: Int, picWidth: Int, mode: Int, isDrawAnnot: Boolean): Bitmap {
-            return kmpdfDocumentController?.covertPDFToBitmap(position, picWidth, mode, isDrawAnnot) ?: Bitmap.createBitmap(0, 0, Bitmap.Config.ARGB_4444)
-        }
-    }
-
-    private val bookmarkHandler = object : BookmarkHandler {
-        override fun getBookmarks(): Array<Bookmark> {
-            return kmpdfDocumentController?.bookmarks ?: arrayOf()
-        }
-    }
-
-    val operateHandler = object : OperateHandler {
-        override fun deletePages(pages: IntArray): Boolean {
-            return kmpdfDocumentController?.deletePages(pages) ?: false
-        }
-        override fun save(): Boolean {
-            return kmpdfDocumentController?.save() ?: false
-        }
-
-        override fun reorderPage(fromPage: Int, toPage: Int): Boolean {
-            return kmpdfDocumentController?.reorderPages(fromPage,toPage) ?: false
-        }
-
-        override fun splitPDFWithPages(path: String, selectPage: IntArray): Boolean {
-            return kmpdfDocumentController?.splitPDFWithPages(path, selectPage) ?: false
-        }
-    }
-
-    val passwordHandler = object : PasswordHandler {
-        override fun isNeedPassword(): Boolean {
-            return tempKmpdfFactory?.needPassWord() ?: false
-        }
-    }
-
-    fun getAllPdfBitmap(): ArrayList<Bitmap>{
-        var pdfBitmaps = ArrayList<Bitmap>()
-        var pageCount: Int = kmpdfDocumentController?.getDocumentPageCount(true) ?: 0
-        for(i in 0 until pageCount) {
-            pdfBitmaps.add(thumbnailHandler.getPdfBitmap(i, 180, ThumbnailHandler.MODE_DAY, true))
-        }
-        return pdfBitmaps
-    }
-
-    fun isAllItemSelect(): Boolean{
-        var count = 0
-        for (i in 0 until pageCount){
-            mapSelect[i]?.let {
-                if(it) count ++
-            }
-        }
-        return (count == pageCount)
-    }
-
-    fun setAllSelect(){
-        for (i in 0 until pageCount) {
-            mapSelect.let {
-                it[i] = true
-            }
-        }
-    }
-
-    fun setAllUnSelect(){
-        for (i in 0 until pageCount) {
-            mapSelect.let {
-                it[i] = false
-            }
-        }
-    }
-
-    fun getSelectPage(): ArrayList<Int>{
-        var list = ArrayList<Int>()
-        for (i in 0 until pageCount){
-            mapSelect[i]?.let {
-                if(it) list.add(i)
-            }
-        }
-        return list
-    }
-
-    fun hasSelectItem(): Boolean{
-        var count = 0
-        for (i in 0 until pageCount){
-            mapSelect[i]?.let {
-                if(it) count ++
-            }
-        }
-        return (count > 0)
-    }
-
-    fun hasBookMark() : Array<Boolean>{
-        var hasBookMark = Array(pageCount) { false }
-        for (bookmark in bookmarkHandler.getBookmarks()){
-            hasBookMark[bookmark.pageNum] = true
-        }
-        return hasBookMark
-    }
-
-    fun pageRotate(runnable: Runnable){
-        val isRotate = kmpdfDocumentController?.rotatePages(getSelectPage().toIntArray(), KMPDFDocumentController.RotationalDirection.CLOCK_WISE)
-        when(isRotate){
-            true -> {
-                runnable.run()
-            }
-        }
-    }
-
-    fun pageDelete(runnable: Runnable){
-        disposable = Observable.create<Boolean> { emitter ->
-            val flag = operateHandler.deletePages(getSelectPage().toIntArray())
-            emitter.onNext(flag)
-            emitter.onComplete()
-        }
-                .subscribeOn(Schedulers.computation())
-                .observeOn(AndroidSchedulers.mainThread())
-                .subscribe({
-                    when(it){
-                        true -> {
-                            runnable.run()
-                        }
-                    }
-                }, {
-                    it.printStackTrace()
-                })
-    }
-
-    fun pageExtract(dst: File, runnableForSuc: Runnable, runnableForFail: Runnable) {
-        disposable = Observable.create<Boolean> { emitter ->
-            val b = operateHandler.splitPDFWithPages(dst.absolutePath, getSelectPage().toIntArray())
-            emitter.onNext(b)
-            emitter.onComplete()
-            }
-                .subscribeOn(Schedulers.io())
-                .observeOn(AndroidSchedulers.mainThread())
-                .subscribe({
-                    when (it) {
-                        true -> {
-                            runnableForSuc.run()
-                        }
-                        false -> {
-                            runnableForFail.run()
-                        }
-                    }
-                }, {
-                    it.printStackTrace()
-                })
-    }
-
-    fun reorderPage(fromPage: Int, toPage: Int, runnable: Runnable){
-        disposable = Observable.create<Boolean> { emitter ->
-            val flag = operateHandler.reorderPage(fromPage, toPage)
-            emitter.onNext(flag)
-            emitter.onComplete()
-        }
-                .subscribeOn(Schedulers.io())
-                .observeOn(AndroidSchedulers.mainThread())
-                .subscribe({
-                    when(it){
-                        true -> {
-                            runnable.run()
-                        }
-                    }
-                }, {
-                    it.printStackTrace()
-                })
-    }
-
-    override fun onCleared() {
-        if (null != disposable && !disposable!!.isDisposed) {
-            disposable?.dispose()
-            disposable = null
-        }
-        super.onCleared()
-    }
-}

+ 0 - 10
reader/src/main/java/com/kdanmobile/reader/thumb/PdfThumbViewModelFactory.kt

@@ -1,10 +0,0 @@
-package com.kdanmobile.reader.thumb
-
-import android.arch.lifecycle.ViewModel
-import android.arch.lifecycle.ViewModelProvider
-
-class PdfThumbViewModelFactory: ViewModelProvider.Factory {
-    override fun <T : ViewModel?> create(modelClass: Class<T>): T {
-        return PdfThumbViewModel() as T
-    }
-}

+ 0 - 23
reader/src/main/java/com/kdanmobile/reader/thumb/ScreenUtil.kt

@@ -1,23 +0,0 @@
-package com.kdanmobile.reader.thumb
-
-import android.content.Context
-import android.util.DisplayMetrics
-
-object ScreenUtil {
-
-    private fun getDisPlayMetrics(context: Context): DisplayMetrics {
-        return context.resources.displayMetrics
-    }
-
-    fun getScreenWidth(context: Context): Int {
-        return getDisPlayMetrics(context).widthPixels
-    }
-
-    fun getDensity(context: Context): Float {
-        return getDisPlayMetrics(context).density
-    }
-
-    fun getXDp(context: Context): Double {
-        return (getScreenWidth(context) / getDensity(context)).toDouble()
-    }
-}

+ 0 - 15
reader/src/main/java/com/kdanmobile/reader/thumb/ThumbData.kt

@@ -1,15 +0,0 @@
-package com.kdanmobile.reader.thumb
-
-import android.graphics.Bitmap
-import java.util.HashMap
-
-class ThumbData {
-    var viewHeight = 0
-    var viewWidth = 0
-    var viewPadding = 0
-    var currentPage = 0
-    var isEditMode = false
-    var pages: ArrayList<Bitmap>? = null
-    var pageSelect: MutableMap<Int, Boolean> = HashMap()
-    var hasBookMarks: Array<Boolean>? = null
-}

+ 0 - 23
reader/src/main/java/com/kdanmobile/reader/thumb/mode/EditMode.kt

@@ -1,23 +0,0 @@
-package com.kdanmobile.reader.thumb.mode
-
-import android.app.Activity
-import com.kdanmobile.reader.thumb.PdfThumbActivity
-import com.kdanmobile.reader.thumb.PdfThumbAdapter
-
-class EditMode: Mode() {
-    override fun onClickToolBarNavigation() {
-        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
-    }
-
-    override fun updateToolbar() {
-        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
-    }
-
-    override fun onPageItemClick(activity: Activity, integer: Int, operate: Int, selectMap: MutableMap<Int,Boolean>, pdfThumbAdapter: PdfThumbAdapter){
-        selectMap[integer]?.let {
-            selectMap[integer] = !it
-        }
-        pdfThumbAdapter.notifyDataSetChanged()
-        (activity as PdfThumbActivity).updateToolbar()
-    }
-}

+ 0 - 11
reader/src/main/java/com/kdanmobile/reader/thumb/mode/Mode.kt

@@ -1,11 +0,0 @@
-package com.kdanmobile.reader.thumb.mode
-
-import android.app.Activity
-import com.kdanmobile.reader.thumb.PdfThumbAdapter
-
-abstract class Mode {
-    abstract fun onPageItemClick(activity: Activity, integer: Int, operate: Int, selectMap: MutableMap<Int,Boolean>, pdfThumbAdapter: PdfThumbAdapter)
-    abstract fun onClickToolBarNavigation()
-    abstract fun updateToolbar()
-
-}

+ 0 - 24
reader/src/main/java/com/kdanmobile/reader/thumb/mode/NormalMode.kt

@@ -1,24 +0,0 @@
-package com.kdanmobile.reader.thumb.mode
-
-import android.app.Activity
-import android.app.Activity.RESULT_OK
-import android.content.Intent
-import com.kdanmobile.reader.thumb.PdfThumbAdapter
-
-class NormalMode: Mode() {
-    override fun onClickToolBarNavigation() {
-        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
-    }
-
-    override fun updateToolbar() {
-        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
-    }
-
-    override fun onPageItemClick(activity: Activity, integer: Int, operate: Int,selectMap: MutableMap<Int,Boolean>, pdfThumbAdapter: PdfThumbAdapter) {
-        val data = Intent()
-        data.putExtra("result", integer)
-        data.putExtra("operate", operate)
-        activity.setResult(RESULT_OK, data)
-        activity.finish()
-    }
-}

+ 0 - 395
reader/src/main/java/com/kdanmobile/reader/utils/AnimationUtil.kt

@@ -1,395 +0,0 @@
-package com.kdanmobile.reader.utils
-
-import android.animation.Animator
-import android.animation.AnimatorListenerAdapter
-import android.animation.AnimatorSet
-import android.animation.ObjectAnimator
-import android.animation.PropertyValuesHolder
-import android.animation.ValueAnimator
-import android.os.Handler
-import android.os.Looper
-import android.view.View
-import android.view.animation.AccelerateInterpolator
-import android.view.animation.Animation
-import android.view.animation.LinearInterpolator
-
-/**
- * @项目名称:PDFReader_android_for_as
- * @包名称:com.kdanmobile.pdf.tools
- * @文件名称:AnimationUtil
- * @创建时间:15/9/12 - 上午11:29 - 11
- * @创建人:luozhipeng
- * @修改记录:
- * @修改人: --------------------------------------
- * @Copyright (c)-2015kdanmobile
- */
-class AnimationUtil private constructor() {
-
-    init {
-        /* cannot be instantiated */
-        throw UnsupportedOperationException("cannot be instantiated")
-    }
-
-    companion object {
-        private var showTopToBottom: ObjectAnimator? = null
-        private var showBottomToTop: ObjectAnimator? = null
-        private var showRightToLeft: ObjectAnimator? = null
-        private var showLeftToRight: ObjectAnimator? = null
-
-        fun ViewScaleAnimation(view: View?, toScale: Float, duration: Long = 16000) {
-            if (view != null && view.animation != null) {
-                view.animation.start()
-                return
-            }
-            val anim1 = ObjectAnimator.ofFloat(view, "scaleX", 1.0f, toScale, 1.0f)
-            anim1.duration = duration
-            anim1.repeatMode = ValueAnimator.RESTART
-            anim1.repeatCount = Animation.INFINITE
-            val anim2 = ObjectAnimator.ofFloat(view, "scaleY", 1.0f, toScale, 1.0f)
-            anim2.duration = duration
-            anim2.repeatMode = ValueAnimator.RESTART
-            anim2.repeatCount = Animation.INFINITE
-            //        ObjectAnimator anim3 = ObjectAnimator.ofFloat(view, "alpha",
-            //                1.0f, 0.9f, 1.0f);
-            //        anim3.setDuration(16000);
-            //        anim3.setRepeatMode(Animation.RESTART);
-            //        anim3.setRepeatCount(Animation.INFINITE);
-            val animSet = AnimatorSet()
-            animSet.interpolator = LinearInterpolator()
-            animSet.playTogether(anim1, anim2)
-            animSet.start()
-        }
-
-        private fun ImageViewAnimation(view: View, duration: Long = 16000) {
-            val pvhX = PropertyValuesHolder.ofFloat("alpha", 1f, 0.4f, 1f)
-            val pvhY = PropertyValuesHolder.ofFloat("scaleX", 1f, 1.2f, 1f)
-            val pvhZ = PropertyValuesHolder.ofFloat("scaleY", 1f, 1.2f, 1f)
-            val anim = ObjectAnimator.ofPropertyValuesHolder(view, pvhX, pvhY, pvhZ)
-            anim.repeatCount = Animation.INFINITE//1->2->1的循环模式
-            anim.repeatMode = ValueAnimator.RESTART//无限模式
-            anim.interpolator = AccelerateInterpolator()
-            anim.setDuration(duration).start()
-        }
-
-        /**
-         * 显示buttons控件,从控件底部往控件顶部扩展显示
-         *
-         * @param view
-         */
-        fun showViewFromBottomToTop(view: View?, duration: Long = 300) {
-            if (showBottomToTop != null && showBottomToTop!!.isRunning) {
-                if (showBottomToTop?.target == view) {
-                    showBottomToTop?.cancel()
-                    showBottomToTop = null
-                } else {
-                    return
-                }
-            }
-
-            if (view != null) {
-                val pvhA = PropertyValuesHolder.ofFloat("alpha", view.alpha, 1.0f)
-                val pvhY = PropertyValuesHolder.ofFloat("Y", Math.max(view.y, view.top.toFloat() + view.height), view.top.toFloat())
-                showBottomToTop = ObjectAnimator.ofPropertyValuesHolder(view, pvhA, pvhY)
-                showBottomToTop?.apply {
-                    interpolator = AccelerateInterpolator()
-                    addListener(object : AnimatorListenerAdapter() {
-                        override fun onAnimationStart(animation: Animator) {
-                            super.onAnimationStart(animation)
-                            view.visibility = View.VISIBLE
-                        }
-
-                        override fun onAnimationCancel(animation: Animator?) {
-                            super.onAnimationCancel(animation)
-                            animation?.removeAllListeners()
-                        }
-                    })
-                    setDuration(duration).start()
-                }
-            }
-        }
-
-        /**
-         * 隐藏buttons控件,从控件顶部往底部回收隐藏
-         *
-         * @param view
-         */
-        fun hideViewFromTopToBottom(view: View?, duration: Long = 300) {
-            if (showBottomToTop != null && showBottomToTop!!.isRunning) {
-                if (showBottomToTop?.target == view) {
-                    showBottomToTop?.cancel()
-                    showBottomToTop = null
-                } else {
-                    return
-                }
-            }
-
-            if (view != null) {
-                val pvhA = PropertyValuesHolder.ofFloat("alpha", view.alpha, 0f)
-                val pvhY = PropertyValuesHolder.ofFloat("Y", Math.min(view.y, view.top.toFloat()), view.top.toFloat() + view.height)
-                showBottomToTop = ObjectAnimator.ofPropertyValuesHolder(view, pvhA, pvhY)
-                showBottomToTop = ObjectAnimator.ofPropertyValuesHolder(view, pvhA, pvhY)
-                showBottomToTop?.apply {
-                    interpolator = AccelerateInterpolator()
-                    addListener(object : AnimatorListenerAdapter() {
-                        override fun onAnimationEnd(animation: Animator) {
-                            super.onAnimationEnd(animation)
-                            view.visibility = View.INVISIBLE
-                        }
-
-                        override fun onAnimationCancel(animation: Animator?) {
-                            super.onAnimationCancel(animation)
-                            animation?.removeAllListeners()
-                        }
-                    })
-                    setDuration(duration).start()
-                }
-            }
-        }
-
-        fun showViewFromRightToLeft(view: View?, duration: Long = 300) {
-            if (showRightToLeft != null && showRightToLeft!!.isRunning) {
-                if (showRightToLeft?.target == view) {
-                    showRightToLeft?.cancel()
-                    showRightToLeft = null
-                } else {
-                    return
-                }
-            }
-
-            if (view != null) {
-                val pvhA = PropertyValuesHolder.ofFloat("alpha", view.alpha, 1.0f)
-                val pvhX = PropertyValuesHolder.ofFloat("X", Math.min(view.x, view.left.toFloat() + view.width), view.left.toFloat())
-                showRightToLeft = ObjectAnimator.ofPropertyValuesHolder(view, pvhA, pvhX)
-                showRightToLeft?.apply {
-                    interpolator = AccelerateInterpolator()
-                    addListener(object : AnimatorListenerAdapter() {
-                        override fun onAnimationStart(animation: Animator) {
-                            super.onAnimationStart(animation)
-                            view.visibility = View.VISIBLE
-                        }
-
-                        override fun onAnimationCancel(animation: Animator?) {
-                            super.onAnimationCancel(animation)
-                            animation?.removeAllListeners()
-                        }
-                    })
-                    setDuration(duration).start()
-                }
-            }
-        }
-
-        fun hideViewFromLeftToRight(view: View?, duration: Long = 300) {
-            if (showRightToLeft != null && showRightToLeft!!.isRunning) {
-                if (showRightToLeft?.target == view) {
-                    showRightToLeft?.cancel()
-                    showRightToLeft = null
-                } else {
-                    return
-                }
-            }
-
-            if (view != null) {
-                val pvhA = PropertyValuesHolder.ofFloat("alpha", view.alpha, 0f)
-                val pvhX = PropertyValuesHolder.ofFloat("X", Math.max(view.x, view.left.toFloat()), view.left.toFloat() + view.width)
-                showRightToLeft = ObjectAnimator.ofPropertyValuesHolder(view, pvhA, pvhX)
-                showRightToLeft?.apply {
-                    interpolator = AccelerateInterpolator()
-                    addListener(object : AnimatorListenerAdapter() {
-                        override fun onAnimationEnd(animation: Animator) {
-                            super.onAnimationEnd(animation)
-                            view.visibility = View.INVISIBLE
-                        }
-
-                        override fun onAnimationCancel(animation: Animator?) {
-                            super.onAnimationCancel(animation)
-                            animation?.removeAllListeners()
-                        }
-                    })
-                    setDuration(duration).start()
-                }
-            }
-        }
-
-        /**
-         * 显示buttons控件,从控件顶部往控件底部扩展显示
-         *
-         * @param view
-         */
-        fun showViewFromTopToBottom(view: View?, duration: Long = 300) {
-            if (showTopToBottom != null && showTopToBottom!!.isRunning) {
-                if (showTopToBottom?.target == view) {
-                    showTopToBottom?.cancel()
-                    showTopToBottom = null
-                } else {
-                    return
-                }
-            }
-
-            if (view != null) {
-                val pvhA = PropertyValuesHolder.ofFloat("alpha", view.alpha, 1.0f)
-                val pvhY = PropertyValuesHolder.ofFloat("Y", Math.min(view.y, view.top.toFloat() + view.height), view.top.toFloat())
-                showTopToBottom = ObjectAnimator.ofPropertyValuesHolder(view, pvhA, pvhY)
-                showTopToBottom?.apply {
-                    interpolator = AccelerateInterpolator()
-                    addListener(object : AnimatorListenerAdapter() {
-                        override fun onAnimationStart(animation: Animator) {
-                            super.onAnimationStart(animation)
-                            view.visibility = View.VISIBLE
-                        }
-
-                        override fun onAnimationCancel(animation: Animator?) {
-                            super.onAnimationCancel(animation)
-                            animation?.removeAllListeners()
-                        }
-                    })
-                    setDuration(duration).start()
-                }
-            }
-        }
-
-        /**
-         * 隐藏buttons控件,从控件底部往控件顶部收缩隐藏
-         *
-         * @param view
-         */
-        fun hideViewFromBottomToTop(view: View?, duration: Long = 300) {
-            if (showTopToBottom != null && showTopToBottom!!.isRunning) {
-                if (showTopToBottom?.target == view) {
-                    showTopToBottom?.cancel()
-                    showTopToBottom = null
-                } else {
-                    return
-                }
-            }
-
-            if (view != null) {
-                val pvhA = PropertyValuesHolder.ofFloat("alpha", view.alpha, 0f)
-                val pvhY = PropertyValuesHolder.ofFloat("Y", Math.max(view.y, view.top.toFloat()), view.top.toFloat() - view.height)
-                showTopToBottom = ObjectAnimator.ofPropertyValuesHolder(view, pvhA, pvhY)
-                showTopToBottom?.apply {
-                    interpolator = AccelerateInterpolator()
-                    addListener(object : AnimatorListenerAdapter() {
-                        override fun onAnimationEnd(animation: Animator) {
-                            super.onAnimationEnd(animation)
-                            view.visibility = View.INVISIBLE
-                        }
-
-                        override fun onAnimationCancel(animation: Animator?) {
-                            super.onAnimationCancel(animation)
-                            animation?.removeAllListeners()
-                        }
-                    })
-                    setDuration(duration).start()
-                }
-            }
-        }
-
-        fun showViewFromLeftToRight(view: View?, duration: Long = 300) {
-            if (showLeftToRight != null && showLeftToRight!!.isRunning) {
-                if (showLeftToRight?.target == view) {
-                    showLeftToRight?.cancel()
-                    showLeftToRight = null
-                } else {
-                    return
-                }
-            }
-
-            if (view != null) {
-                val pvhA = PropertyValuesHolder.ofFloat("alpha", view.alpha, 1.0f)
-                val pvhX = PropertyValuesHolder.ofFloat("X", Math.max(view.x, view.left.toFloat() - view.width), view.left.toFloat())
-                showLeftToRight = ObjectAnimator.ofPropertyValuesHolder(view, pvhA, pvhX)
-                showLeftToRight?.apply {
-                    interpolator = AccelerateInterpolator()
-                    addListener(object : AnimatorListenerAdapter() {
-                        override fun onAnimationStart(animation: Animator) {
-                            super.onAnimationStart(animation)
-                            view.visibility = View.VISIBLE
-                        }
-
-                        override fun onAnimationCancel(animation: Animator?) {
-                            super.onAnimationCancel(animation)
-                            animation?.removeAllListeners()
-                        }
-                    })
-                    setDuration(duration).start()
-                }
-            }
-        }
-
-        fun hideViewFromRightToLeft(view: View?, duration: Long = 300) {
-            if (showLeftToRight != null && showLeftToRight!!.isRunning) {
-                if (showLeftToRight?.target == view) {
-                    showLeftToRight?.cancel()
-                    showLeftToRight = null
-                } else {
-                    return
-                }
-            }
-
-            if (view != null) {
-                val pvhA = PropertyValuesHolder.ofFloat("alpha", view.alpha, 0f)
-                val pvhX = PropertyValuesHolder.ofFloat("X", Math.min(view.x, view.left.toFloat()), view.left.toFloat() - view.width)
-                showLeftToRight = ObjectAnimator.ofPropertyValuesHolder(view, pvhA, pvhX)
-                showLeftToRight?.apply {
-                    interpolator = AccelerateInterpolator()
-                    addListener(object : AnimatorListenerAdapter() {
-                        override fun onAnimationEnd(animation: Animator) {
-                            super.onAnimationEnd(animation)
-                            view.visibility = View.INVISIBLE
-                        }
-
-                        override fun onAnimationCancel(animation: Animator?) {
-                            super.onAnimationCancel(animation)
-                            animation?.removeAllListeners()
-                        }
-                    })
-                    setDuration(duration).start()
-                }
-            }
-        }
-
-        fun showViewAlpha(view: View?, duration: Long = 300) {
-            if (view != null && view.visibility != View.VISIBLE) {
-                val pvhA = PropertyValuesHolder.ofFloat("alpha", 0f, 1.0f)
-                val animAlpha = ObjectAnimator.ofPropertyValuesHolder(view, pvhA)
-                animAlpha.interpolator = AccelerateInterpolator()
-                animAlpha.addListener(object : AnimatorListenerAdapter() {
-                    override fun onAnimationStart(animation: Animator) {
-                        super.onAnimationStart(animation)
-                        view.visibility = View.VISIBLE
-                    }
-                })
-                animAlpha.setDuration(duration).start()
-            }
-        }
-
-        fun hideViewAlpha(view: View?, duration: Long = 300) {
-            if (view != null && view.visibility == View.VISIBLE) {
-                val pvhA = PropertyValuesHolder.ofFloat("alpha", 1.0f, 0f)
-                val animAlpha = ObjectAnimator.ofPropertyValuesHolder(view, pvhA)
-                animAlpha.interpolator = AccelerateInterpolator()
-                animAlpha.addListener(object : AnimatorListenerAdapter() {
-                    override fun onAnimationEnd(animation: Animator) {
-                        super.onAnimationEnd(animation)
-                        Handler(Looper.getMainLooper()).post { view.visibility = View.GONE }
-                    }
-                })
-                animAlpha.setDuration(duration).start()
-            }
-        }
-
-        /**
-         * 结束该动画
-         */
-        fun cancelAnimations() {
-            showTopToBottom?.cancel()
-            showBottomToTop?.cancel()
-            showLeftToRight?.cancel()
-            showRightToLeft?.cancel()
-            showTopToBottom = null
-            showBottomToTop = null
-            showRightToLeft = null
-            showLeftToRight = null
-        }
-    }
-}

+ 0 - 46
reader/src/main/java/com/kdanmobile/reader/utils/DensityUtil.kt

@@ -1,46 +0,0 @@
-package com.kdanmobile.reader.utils
-
-import android.content.Context
-
-
-class DensityUtil private constructor() {
-
-    init {
-        throw UnsupportedOperationException("cannot be instantiated")
-    }
-
-    companion object {
-
-        fun getDensityDpi(context: Context): Int {
-            return context.resources.displayMetrics.densityDpi
-        }
-
-        fun getDensity(context: Context): Float {
-            return context.resources.displayMetrics.density
-        }
-
-        fun getScreenWidthPx(context: Context): Int {
-            return context.resources.displayMetrics.widthPixels
-        }
-
-        fun getScreenHeightPx(context: Context): Int {
-            return context.resources.displayMetrics.heightPixels
-        }
-
-        fun dp2px(context: Context, dpVal: Float): Int {
-            return (dpVal * context.resources.displayMetrics.density + 0.5f).toInt()
-        }
-
-        fun sp2px(context: Context, spVal: Float): Int {
-            return (spVal * context.resources.displayMetrics.scaledDensity + 0.5f).toInt()
-        }
-
-        fun px2dp(context: Context, pxVal: Float): Float {
-            return pxVal / context.resources.displayMetrics.density
-        }
-
-        fun px2sp(context: Context, pxVal: Float): Float {
-            return pxVal / context.resources.displayMetrics.scaledDensity
-        }
-    }
-}

+ 0 - 274
reader/src/main/java/com/kdanmobile/reader/view/AnnotationAttributeView.kt

@@ -1,274 +0,0 @@
-package com.kdanmobile.reader.view
-
-import android.content.Context
-import android.support.v4.graphics.ColorUtils
-import android.util.AttributeSet
-import android.view.View
-import android.widget.LinearLayout
-import android.widget.SeekBar
-import com.kdanmobile.reader.R
-import com.kdanmobile.reader.annotationattribute.AnnotationAttribute
-import com.kdanmobile.reader.annotationattribute.AnnotationColor
-import com.kdanmobile.reader.annotationattribute.Brush
-import com.kdanmobile.reader.annotationattribute.InkAttribute
-import com.kdanmobile.reader.screen.view.ColorSelectView
-import kotlinx.android.synthetic.main.view_reader_annotation_property.view.*
-
-class AnnotationAttributeView @JvmOverloads constructor(
-        context: Context,
-        attrs: AttributeSet? = null,
-        defStyleAttr: Int = 0
-) : LinearLayout(context, attrs, defStyleAttr) {
-
-    companion object {
-        const val DEFAULT_OPACITY = 50
-        const val DEFAULT_THICKNESS = 5
-    }
-
-
-    init {
-        inflate(context, R.layout.view_reader_annotation_property, this)
-    }
-    var inkAttribute: InkAttribute
-        get() {
-            return InkAttribute(color, alpha, thickness.toFloat(), brush)
-        }
-        set(value) {
-            color = value.color
-            alpha = value.alpha
-            thickness = value.width.toInt()
-            brush = value.brush
-        }
-    var annotationAttribute: AnnotationAttribute
-        get() {
-            return AnnotationAttribute(color, alpha)
-        }
-        set(value) {
-            color = value.color
-            alpha = value.alpha
-        }
-    var isSimpleMode = true
-        set(value) {
-            field = value
-            update()
-        }
-    var onChangeListener: OnChangeListener? = null
-    private var thickness: Int = DEFAULT_THICKNESS
-        set(value) {
-            field = value
-            updateThickness()
-        }
-    /**
-     * 1~255
-     */
-    private var alpha: Int
-        get() {
-            return Math.round(opacity.toFloat() / 100 * 255)
-        }
-        set(value) {
-            val progress = Math.round(value.toFloat() / 255 * 100)
-            seekBar_readerAnnotationProperty_opacity.progress = progress
-        }
-    /**
-     * 1~100
-     */
-    private var opacity: Int = DEFAULT_OPACITY
-    private var color: Int
-        get() {
-            return context.resources.getColor(colorEnum.colorResId)
-        }
-        set(value) {
-            AnnotationColor.values().forEach {
-                val c = context.resources.getColor(it.colorResId)
-                if (c == value) {
-                    colorEnum = it
-                    return
-                }
-            }
-        }
-    private var colorEnum: AnnotationColor = AnnotationColor.Color1
-        set(value) {
-            if (field == value) return
-            field = value
-            updateColor()
-            updateColorButtons()
-            onChangeListener?.onChange(this)
-        }
-    private val colorWithAlpha: Int
-        get() {
-            return  ColorUtils.setAlphaComponent(color, alpha)
-        }
-    private var brush = Brush.Fountain
-        set(value) {
-            if (field == value) return
-            field = value
-            update()
-            when (value) {
-                Brush.Fountain -> if (thickness > brush.maxSize) thickness = brush.maxSize
-                Brush.Marker -> thickness = brush.maxSize
-            }
-            onChangeListener?.onChange(this)
-        }
-    init {
-        setupOpacitySeekBar()
-        setupThicknessSeekBar()
-        setupColorButtons()
-        setupBrushes()
-        update()
-    }
-
-    private fun setupBrushes() {
-        iv_readerAnnotationProperty_brush1.setOnClickListener {
-            brush = Brush.Fountain
-        }
-        iv_readerAnnotationProperty_brush2.setOnClickListener {
-            brush = Brush.Marker
-        }
-    }
-
-    private fun setupThicknessSeekBar() {
-        seekBar_readerAnnotationProperty_thickness.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener {
-            override fun onProgressChanged(p0: SeekBar?, progress: Int, p2: Boolean) {
-                thickness = progress
-                updateThickness()
-            }
-
-            override fun onStartTrackingTouch(p0: SeekBar?) {
-            }
-
-            override fun onStopTrackingTouch(p0: SeekBar?) {
-                onChangeListener?.onChange(this@AnnotationAttributeView)
-            }
-        })
-    }
-
-    private fun setupColorButtons() {
-        colorSelectView_readerAnnotationProperty.onColorSelectedListener = object : ColorSelectView.OnColorSelectedListener {
-            override fun onColorSelected(color: Int) {
-                AnnotationColor.values().forEach { annotationColor ->
-                    val c = resources.getColor(annotationColor.colorResId)
-                    if (c == color) {
-                        colorEnum = annotationColor
-                    }
-                }
-            }
-        }
-    }
-
-    private fun setupOpacitySeekBar() {
-        seekBar_readerAnnotationProperty_opacity.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener {
-            /** Hide display view now (1/5) **/
-            /*
-            val colorDisplayerView = ColorOpacityDisplayerView(context)
-            val windowW = ViewGroup.LayoutParams.WRAP_CONTENT
-            val windowH = ViewGroup.LayoutParams.WRAP_CONTENT
-            val window = PopupWindow(colorDisplayerView, windowW, windowH).apply {
-                animationStyle = android.R.style.Animation
-            }
-            val contentView = window.contentView.apply {
-                val w = Utils.makeDropDownMeasureSpec(window.width)
-                val h = Utils.makeDropDownMeasureSpec(window.height)
-                measure(w, h)
-            }
-            */
-
-            override fun onProgressChanged(seekBar: SeekBar, progress: Int, p2: Boolean) {
-                opacity = progress
-                updateOpacity()
-                /** Hide display view now (2/5) **/
-                /*
-                val x = calculateOffsetX(seekBar)
-                val y = calculateOffsetY(seekBar)
-                window.update(seekBar, x, y, window.width, window.height)
-                colorDisplayerView.color = colorWithAlpha
-                */
-            }
-
-            override fun onStartTrackingTouch(seekBar: SeekBar) {
-                /** Hide display view now (3/5) **/
-                /*
-                val x = calculateOffsetX(seekBar)
-                val y = calculateOffsetY(seekBar)
-                colorDisplayerView.color = colorWithAlpha
-                window.showAsDropDown(seekBar, x, y)
-                */
-            }
-
-            override fun onStopTrackingTouch(p0: SeekBar?) {
-                /** Hide display view now (4/5) **/
-                /*
-                window.dismiss()
-                */
-                onChangeListener?.onChange(this@AnnotationAttributeView)
-            }
-
-            /** Hide display view now (5/5) **/
-            /*
-            private fun calculateOffsetX(seekBar: SeekBar): Int {
-                val seekBarLineWidth = seekBar.width - seekBar.paddingLeft - seekBar.paddingRight
-                val progress = seekBar.progress.toFloat() / seekBar.max.toFloat()
-                return (seekBar.paddingLeft + seekBarLineWidth * progress - contentView.measuredWidth / 2).toInt()
-            }
-
-            private fun calculateOffsetY(seekBar: SeekBar): Int {
-                return -seekBar.height - contentView.measuredHeight
-            }
-            */
-        })
-    }
-
-    private fun update() {
-        updateOpacity()
-        updateThickness()
-        updateColor()
-        updateColorButtons()
-        group_readerAnnotationProperty_brushMode.visibility = if (isSimpleMode) View.GONE else View.VISIBLE
-        group_readerAnnotationProperty_brushMode.post {
-            when (brush) {
-                Brush.Fountain -> {
-                    iv_readerAnnotationProperty_triangle1.visibility = View.VISIBLE
-                    iv_readerAnnotationProperty_triangle2.visibility = View.INVISIBLE
-                }
-                Brush.Marker -> {
-                    iv_readerAnnotationProperty_triangle1.visibility = View.INVISIBLE
-                    iv_readerAnnotationProperty_triangle2.visibility = View.VISIBLE
-                }
-            }
-        }
-    }
-
-    private fun updateOpacity() {
-        seekBar_readerAnnotationProperty_opacity.progress = opacity
-        tv_readerAnnotationProperty_opacityValue.text = opacity.toString()
-        waveLineView_readerAnnotationProperty.setColor(colorWithAlpha)
-    }
-
-    private fun updateThickness() {
-        when (brush) {
-            Brush.Fountain -> {
-                seekBar_readerAnnotationProperty_thickness.max = brush.maxSize
-                seekBar_readerAnnotationProperty_thickness.isEnabled = true
-            }
-            Brush.Marker -> {
-                seekBar_readerAnnotationProperty_thickness.max = brush.maxSize
-                seekBar_readerAnnotationProperty_thickness.isEnabled = false
-            }
-        }
-        seekBar_readerAnnotationProperty_thickness.progress = thickness
-        tv_readerAnnotationProperty_thicknessValue.text = thickness.toString()
-        waveLineView_readerAnnotationProperty.setThickness(thickness.toFloat())
-    }
-
-    private fun updateColor() {
-        waveLineView_readerAnnotationProperty.setColor(colorWithAlpha)
-    }
-
-    private fun updateColorButtons() {
-        val c = resources.getColor(colorEnum.colorResId)
-        colorSelectView_readerAnnotationProperty.setSelectedColor(c)
-    }
-
-    interface OnChangeListener {
-        fun onChange(annotationAttributeView: AnnotationAttributeView)
-    }
-}

+ 0 - 22
reader/src/main/java/com/kdanmobile/reader/view/AnnotationAttributeWindow.kt

@@ -1,22 +0,0 @@
-package com.kdanmobile.reader.view
-
-import android.content.Context
-import android.os.Build
-import android.widget.PopupWindow
-import com.kdanmobile.reader.R
-
-class AnnotationAttributeWindow(context: Context, isSimpleMode: Boolean) : PopupWindow(context) {
-    val annotationAttributeView: AnnotationAttributeView
-
-    init {
-        isOutsideTouchable = true
-        isFocusable = true
-        if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {
-            elevation = context.resources.getDimension(R.dimen.reader_annotation_property_setting_window_elevation)
-        }
-        setBackgroundDrawable(context.resources.getDrawable(R.drawable.bg_annotation_property_setting_window))
-        annotationAttributeView = AnnotationAttributeView(context)
-        annotationAttributeView.isSimpleMode = isSimpleMode
-        contentView = annotationAttributeView
-    }
-}

+ 0 - 32
reader/src/main/java/com/kdanmobile/reader/view/ColorOpacityDisplayerView.kt

@@ -1,32 +0,0 @@
-package com.kdanmobile.reader.view
-
-import android.content.Context
-import android.graphics.Color
-import android.support.constraint.ConstraintLayout
-import android.util.AttributeSet
-import android.view.View
-import com.kdanmobile.reader.R
-import kotlinx.android.synthetic.main.view_color_opacity_displayer.view.*
-
-/**
- * 現在不顯示透明度的放大鏡,暫時不會用到這個 View,但請不要刪除它 QAQ
- */
-class ColorOpacityDisplayerView @JvmOverloads constructor(
-        context: Context,
-        attrs: AttributeSet? = null,
-        defStyleAttr: Int = 0
-) : ConstraintLayout(context, attrs, defStyleAttr) {
-    init {
-        View.inflate(context, R.layout.view_color_opacity_displayer, this)
-    }
-
-    var color = Color.BLACK
-        set(value) {
-            field = value
-            update()
-        }
-
-    private fun update() {
-        view_colorOpacityDisplayer_color.setBackgroundColor(color)
-    }
-}

+ 0 - 330
reader/src/main/java/com/kdanmobile/reader/view/HorizontalView.java

@@ -1,330 +0,0 @@
-package com.kdanmobile.reader.view;
-
-import android.app.Activity;
-import android.content.Context;
-import android.support.annotation.NonNull;
-import android.util.AttributeSet;
-import android.util.DisplayMetrics;
-import android.view.GestureDetector;
-import android.view.MotionEvent;
-import android.widget.LinearLayout;
-import android.widget.Scroller;
-
-/**
- * @类名:HorizontalView
- * @类描述:自定义线性布局,实现布局整个滑动功能
- * @作者:zhouguifang
- * @创建时间:2015-7-6-下午5:59:49
- * @修改人:
- * @修改时间:
- * @修改备注:
- * @版本:
- * @Copyright:(c)-2015kdan mobile
- */
-@SuppressWarnings("ALL")
-public class HorizontalView extends LinearLayout implements
-		GestureDetector.OnGestureListener {
-	// private static final String TAG = "Scroller";
-	private final GestureDetector mGestureDetector;
-
-	private Scroller mScroller;
-
-	private float last_position = 0;
-	private float start_position = 0;
-
-	private float x1, x2, y1, y2;
-	private boolean isFirst = true;
-	private boolean isResult = false;
-
-	private int moveDistance = 266;
-	public boolean isOpen = false;
-	private boolean isOk = false;
-	private boolean isScroll = true;
-
-	private boolean isFirstPager = true;
-
-	private static final int MOVING_DIAGONALLY = 0;
-	private static final int MOVING_LEFT = 1;
-	private static final int MOVING_RIGHT = 2;
-	private static final int MOVING_UP = 3;
-	private static final int MOVING_DOWN = 4;
-
-	public HorizontalView(Context context, AttributeSet attrs) {
-		super(context, attrs);
-		mScroller = new Scroller(context);
-		mGestureDetector = new GestureDetector(this);
-	}
-
-	public void setScroll(boolean isScroll) {
-		this.isScroll = isScroll;
-	}
-
-	public void setFirstPager(boolean isFirstPager) {
-		this.isFirstPager = isFirstPager;
-	}
-
-	@Override
-	public boolean dispatchTouchEvent(@NonNull MotionEvent ev) {
-		// Out.println("dispatchTouchEvent...");
-		switch (ev.getAction()) {
-		case MotionEvent.ACTION_DOWN:
-			// Out.println("ACTION_DOWN...");
-			x1 = ev.getX();
-			y1 = ev.getY();
-			break;
-		case MotionEvent.ACTION_MOVE:
-			// Out.println("ACTION_MOVE...");
-			if (isFirst) {
-				x2 = ev.getX();
-				y2 = ev.getY();
-				float x = Math.abs(x1 - x2);
-				float y = Math.abs(y1 - y2);
-				float distance = (x * x) + (y * y);
-				// Out.println("isFirst...dis:" + distance);
-				DisplayMetrics displayMetrics = new DisplayMetrics();
-                Activity activity = (Activity) getContext();
-                activity.getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
-                float density = displayMetrics.density;
-				if (distance > (density * 5)) {
-					isFirst = false;
-					if (x > y) {
-						// 第一页向右滑动||第一页向左滑动且控件是打开的
-						if ((((x1 - x2) < 0) && isFirstPager)
-                                || (((x1 - x2) > 0) && isFirstPager && isOpen)) {
-							isResult = true;
-							start_position = ev.getX();
-							last_position = ev.getX();
-						}
-					}
-				}
-			}
-			break;
-		case MotionEvent.ACTION_UP:
-			// LogUtil.print_i(HorizontalView.class,"ACTION_UP...");
-			isFirst = true;
-			isResult = false;
-			break;
-		}
-		return super.dispatchTouchEvent(ev);
-	}
-
-	@Override
-	public boolean onInterceptTouchEvent(MotionEvent ev) {
-        return isScroll && isResult || super.onInterceptTouchEvent(ev);
-    }
-
-	@Override
-	public boolean onTouchEvent(@NonNull MotionEvent event) {
-		mGestureDetector.onTouchEvent(event);
-		int action = event.getAction();
-		float x = event.getX();
-		switch (action) {
-		case MotionEvent.ACTION_DOWN:
-			start_position = event.getX();
-			last_position = event.getX();
-			break;
-		case MotionEvent.ACTION_MOVE:
-			// LogUtil.print_i(HorizontalView.class,"onTouchEvent...ACTION_MOVE");
-			float distant = x - start_position;
-			if (!isOpen) {
-				if (distant > moveDistance) {
-					distant = moveDistance;
-				}
-				if (distant < 0) {
-					distant = 0;
-				}
-				x = distant + start_position;
-			} else {
-				if (distant > 0) {
-					distant = 0;
-				}
-				if (distant < -moveDistance) {
-					distant = -moveDistance;
-				}
-			}
-			x = distant + start_position;
-			smoothScrollBy((int) (last_position - x), 0, 0);
-			last_position = x;
-			break;
-		case MotionEvent.ACTION_UP:
-			if (!isOk) {
-				if (isOpen) {
-					if ((mScroller.getFinalX() + ((moveDistance * 7) / 8)) > 0) {
-						smoothScrollTo(0, 0);
-						isOpen = false;
-					} else {
-						smoothScrollTo(0 - moveDistance, 0);
-						isOpen = true;
-					}
-				} else {
-					if ((mScroller.getFinalX() + ((moveDistance) / 8)) > 0) {
-						smoothScrollTo(0, 0);
-						isOpen = false;
-					} else {
-						smoothScrollTo(0 - moveDistance, 0);
-						isOpen = true;
-					}
-				}
-			}
-			isOk = false;
-			return false;
-		}
-		return super.onTouchEvent(event);
-	}
-
-	@Override
-	public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
-                           float velocityY) {
-		switch (directionOfTravel(velocityX, velocityY)) {
-		case MOVING_LEFT:
-			smoothScrollTo(0, 0);
-			isOpen = false;
-			break;
-		case MOVING_RIGHT:
-			smoothScrollTo(0 - moveDistance, 0);
-			isOpen = true;
-			break;
-		default:
-			// LogUtil.print_i(HorizontalView.class,"x:" + mScroller.getFinalX() + "  Y:"
-			// + mScroller.getFinalY());
-			if (isOpen) {
-				if ((mScroller.getFinalX() + ((moveDistance * 7) / 8)) > 0) {
-					smoothScrollTo(0, 0);
-					isOpen = false;
-				} else {
-					smoothScrollTo(0 - moveDistance, 0);
-					isOpen = true;
-				}
-			} else {
-				if ((mScroller.getFinalX() + ((moveDistance) / 8)) > 0) {
-					smoothScrollTo(0, 0);
-					isOpen = false;
-				} else {
-					smoothScrollTo(0 - moveDistance, 0);
-					isOpen = true;
-				}
-			}
-			break;
-		}
-		isOk = true;
-		return true;
-	}
-
-	public void animateToggle() {
-		if (isOpen) {
-			smoothScrollTo(0, 0);
-		} else {
-			smoothScrollTo(0 - moveDistance, 0);
-		}
-		isOpen = !isOpen;
-	}
-	
-	/**
-	 * @方法说明:计算移动方向
-	 * @方法名称:directionOfTravel
-	 * @param vx
-	 * @param vy
-	 * @return
-	 * @返回值:int
-	 */
-	private static int directionOfTravel(float vx, float vy) {
-		if (Math.abs(vx) > (2 * Math.abs(vy)))
-			return (vx > 0) ? MOVING_RIGHT : MOVING_LEFT;
-		else if (Math.abs(vy) > (2 * Math.abs(vx)))
-			return (vy > 0) ? MOVING_DOWN : MOVING_UP;
-		else
-			return MOVING_DIAGONALLY;
-	}
-
-	/**
-	 * @方法说明:调用此方法滚动到目标位置
-	 * @方法名称:smoothScrollTo
-	 * @param fx
-	 * @param fy
-	 * @返回值:void
-	 */
-	public void smoothScrollTo(int fx, int fy) {
-		int dx = fx - mScroller.getFinalX();
-		int dy = fy - mScroller.getFinalY();
-		smoothScrollBy(dx, dy);
-	}
-
-	/**
-	 * @方法说明:调用此方法滚动到目标位置
-	 * @方法名称:smoothScrollTo
-	 * @param fx
-	 * @param fy
-	 * @param drution
-	 * @返回值:void
-	 */
-	public void smoothScrollTo(int fx, int fy, int drution) {
-		int dx = fx - mScroller.getFinalX();
-		int dy = fy - mScroller.getFinalY();
-		mScroller.startScroll(mScroller.getFinalX(), mScroller.getFinalY(), dx,
-				dy, drution);
-		invalidate();
-	}
-
-	/**
-	 * @方法说明:调用此方法设置滚动的相对偏移
-	 * @方法名称:smoothScrollBy
-	 * @param dx
-	 * @param dy
-	 * @返回值:void
-	 */
-	public void smoothScrollBy(int dx, int dy) {
-		// 设置mScroller的滚动偏移量
-		mScroller.startScroll(mScroller.getFinalX(), mScroller.getFinalY(), dx,
-				dy, 500);
-		invalidate();// 这里必须调用invalidate()才能保证computeScroll()会被调用,否则不一定会刷新界面,看不到滚动效果
-	}
-
-	public void smoothScrollBy(int dx, int dy, int drution) {
-		// 设置mScroller的滚动偏移量
-		mScroller.startScroll(mScroller.getFinalX(), mScroller.getFinalY(), dx,
-				dy, drution);
-		invalidate();// 这里必须调用invalidate()才能保证computeScroll()会被调用,否则不一定会刷新界面,看不到滚动效果
-	}
-
-	@Override
-	public void computeScroll() {
-		// 先判断mScroller滚动是否完成
-		if (mScroller.computeScrollOffset()) {
-			// 这里调用View的scrollTo()完成实际的滚动
-			scrollTo(mScroller.getCurrX(), mScroller.getCurrY());
-
-			// 必须调用该方法,否则不一定能看到滚动效果
-			postInvalidate();
-		}
-		super.computeScroll();
-	}
-
-	public void setMoveDistance(int distance) {
-		moveDistance = distance;
-	}
-
-	@Override
-	public boolean onDown(MotionEvent e) {
-		return false;
-	}
-
-	@Override
-	public void onShowPress(MotionEvent e) {
-	}
-
-	@Override
-	public boolean onSingleTapUp(MotionEvent e) {
-		return false;
-	}
-
-	@Override
-	public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX,
-                            float distanceY) {
-		return false;
-	}
-
-	@Override
-	public void onLongPress(MotionEvent e) {
-
-	}
-}

+ 0 - 20
reader/src/main/java/com/kdanmobile/reader/view/NonSwipeableViewPage.kt

@@ -1,20 +0,0 @@
-package com.kdanmobile.reader.view
-
-import android.content.Context
-import android.support.v4.view.ViewPager
-import android.util.AttributeSet
-import android.view.MotionEvent
-
-class NonSwipeableViewPage @JvmOverloads constructor(
-        context: Context,
-        attrs: AttributeSet? = null
-) : ViewPager(context, attrs) {
-
-    override fun onInterceptTouchEvent(ev: MotionEvent?): Boolean {
-        return false
-    }
-
-    override fun onTouchEvent(ev: MotionEvent?): Boolean {
-        return false
-    }
-}

+ 0 - 82
reader/src/main/java/com/kdanmobile/reader/view/WaveLineView.java

@@ -1,82 +0,0 @@
-package com.kdanmobile.reader.view;
-
-import android.content.Context;
-import android.graphics.Canvas;
-import android.graphics.Paint;
-import android.graphics.Paint.Cap;
-import android.graphics.Paint.Style;
-import android.graphics.Path;
-import android.support.annotation.NonNull;
-import android.util.AttributeSet;
-import android.view.View;
-
-/**
- * @类名:WaveLineView
- * @类描述:自定义控件实现波浪线
- * @作者:zhouguifang
- * @创建时间:2015-7-7-上午11:35:01
- * @修改人:
- * @修改时间:
- * @修改备注:
- * @版本:
- * @Copyright:(c)-2015kdan mobile
- */
-public class WaveLineView extends View {
-	private Paint paint;
-	private Path path;
-	private int color = 0xffff0000;
-	private float thickness = 20;
-	private float bili = 1.f / 6;
-
-	public WaveLineView(Context context, AttributeSet attrs) {
-		super(context, attrs);
-		paint = new Paint();
-		paint.setColor(color);
-		paint.setAntiAlias(true);
-		paint.setStrokeCap(Cap.ROUND);
-		paint.setStyle(Style.STROKE);
-		paint.setStrokeWidth(20f);
-	}
-
-	public void setThickness(float thickness) {
-		this.thickness = thickness;
-		invalidate();
-	}
-
-	public void setColor(int color) {
-		this.color = color;
-		invalidate();
-	}
-
-	@Override
-	public void draw(@NonNull Canvas canvas) {
-		super.draw(canvas);
-		if (getWidth() > 0) {
-			if (path == null) {
-				int w = getWidth();
-				int h = getHeight();
-				path = new Path();
-				path.moveTo(0, h / 2f);
-				path.lineTo((w * 30) / 360, (h / 2) - (h * bili * 0.5f));
-				path.lineTo((w * 45) / 360, (h / 2) - (h * bili * 0.707f));
-				path.lineTo((w * 60) / 360, (h / 2) - (h * bili * 0.866f));
-				path.lineTo((w * 90) / 360, (h / 2) - (h * bili * 1.0f));
-				path.lineTo((w * 120) / 360, (h / 2) - (h * bili * 0.866f));
-				path.lineTo((w * 135) / 360, (h / 2) - (h * bili * 0.707f));
-				path.lineTo((w * 150) / 360, (h / 2) - (h * bili * 0.5f));
-				path.lineTo((w * 180) / 360, (h / 2) - (h * bili * 0.0f));
-				path.lineTo((w * 210) / 360, (h / 2) + (h * bili * 0.5f));
-				path.lineTo((w * 225) / 360, (h / 2) + (h * bili * 0.707f));
-				path.lineTo((w * 240) / 360, (h / 2) + (h * bili * 0.866f));
-				path.lineTo((w * 270) / 360, (h / 2) + (h * bili * 1.0f));
-				path.lineTo((w * 300) / 360, (h / 2) + (h * bili * 0.866f));
-				path.lineTo((w * 315) / 360, (h / 2) + (h * bili * 0.707f));
-				path.lineTo((w * 330) / 360, (h / 2) + (h * bili * 0.5f));
-				path.lineTo((w * 360) / 360, (h / 2) + (h * bili * 0.0f));
-			}
-			paint.setColor(color);
-			paint.setStrokeWidth(thickness);
-			canvas.drawPath(path, paint);
-		}
-	}
-}

+ 0 - 55
reader/src/main/java/com/kdanmobile/reader/widget/drag/OnRecyclerItemClickListener.kt

@@ -1,55 +0,0 @@
-package com.kdanmobile.reader.widget.drag
-
-import android.support.v4.view.GestureDetectorCompat
-import android.support.v7.widget.RecyclerView
-import android.view.GestureDetector
-import android.view.MotionEvent
-import android.view.View
-
-/**
- * @classname:OnRecyclerItemClickListener
- * @author:luozhipeng
- * @date:1/11/17 21:57
- * @description:监控RecyclerView的点击事件,单击,长按
- */
-abstract class OnRecyclerItemClickListener(private val recyclerView: RecyclerView) : RecyclerView.OnItemTouchListener {
-    private val mGestureDetector: GestureDetectorCompat
-
-    init {
-        mGestureDetector = GestureDetectorCompat(recyclerView.context, ItemTouchHelperGestureListener())
-    }
-
-    override fun onInterceptTouchEvent(recyclerView: RecyclerView, e: MotionEvent): Boolean {
-        mGestureDetector.onTouchEvent(e)
-        return false
-    }
-
-    override fun onTouchEvent(recyclerView: RecyclerView, e: MotionEvent) {
-        mGestureDetector.onTouchEvent(e)
-    }
-
-    override fun onRequestDisallowInterceptTouchEvent(disallowIntercept: Boolean) {}
-
-    private inner class ItemTouchHelperGestureListener : GestureDetector.SimpleOnGestureListener() {
-        override fun onSingleTapUp(e: MotionEvent): Boolean {
-            val child = recyclerView.findChildViewUnder(e.x, e.y)
-            if (child != null) {
-                val vh = recyclerView.getChildViewHolder(child)
-                onItemClick(vh)
-            }
-            return true
-        }
-
-        override fun onLongPress(e: MotionEvent) {
-            val child = recyclerView.findChildViewUnder(e.x, e.y)
-            if (child != null) {
-                val vh = recyclerView.getChildViewHolder(child)
-                onItemLongClick(vh)
-            }
-        }
-    }
-
-    abstract fun onItemClick(viewHolder: RecyclerView.ViewHolder)
-
-    abstract fun onItemLongClick(viewHolder: RecyclerView.ViewHolder)
-}

+ 0 - 5
reader/src/main/res/color/selector_annotation_attribute_seek_bar.xml

@@ -1,5 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<selector xmlns:android="http://schemas.android.com/apk/res/android">
-    <item android:state_enabled="false" android:color="@color/reader_annotation_attribute_seek_bar_tint_disable"/>
-    <item android:state_enabled="true" android:color="@color/reader_annotation_attribute_seek_bar_tint_enable"/>
-</selector>

+ 0 - 5
reader/src/main/res/color/selector_annotation_attribute_seek_bar_background.xml

@@ -1,5 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<selector xmlns:android="http://schemas.android.com/apk/res/android">
-    <item android:state_enabled="false" android:color="@color/reader_annotation_attribute_seek_bar_tint_background_disable"/>
-    <item android:state_enabled="true" android:color="@color/reader_annotation_attribute_seek_bar_tint_background_enable"/>
-</selector>

BIN
reader/src/main/res/drawable-hdpi/ic_arrowback_black_24dp.png


BIN
reader/src/main/res/drawable-hdpi/ic_arrowback_blue_24dp.png


BIN
reader/src/main/res/drawable-hdpi/ic_checkbox_off_blue_24dp.png


+ 0 - 0
reader/src/main/res/drawable-hdpi/ic_checkbox_on_blue_24dp.png


Some files were not shown because too many files changed in this diff