Commit 7096a17f authored by wanglei's avatar wanglei

...

parent c7a1e38b
......@@ -60,6 +60,7 @@ dependencies {
implementation("io.github.cymchad:BaseRecyclerViewAdapterHelper4:4.1.4")
implementation("com.h6ah4i.android.widget.verticalseekbar:verticalseekbar:1.0.0")
implementation("com.github.angcyo.DslTablayout:TabLayout:3.5.5")
implementation("com.github.angcyo.DslTablayout:ViewPager2Delegate:3.5.5")
//mlkit
implementation("com.google.android.gms:play-services-mlkit-document-scanner:16.0.0-beta1")
......
package com.base.pdfviewerscannerwhite.ui.document.excel
import android.annotation.SuppressLint
import android.app.Activity
import android.content.Intent
import android.content.pm.ActivityInfo
import android.view.View
import android.view.animation.Animation
import android.view.animation.TranslateAnimation
import androidx.activity.addCallback
import com.base.pdfviewerscannerwhite.bean.DocumentBean
import com.base.pdfviewerscannerwhite.databinding.ActivityExcelBinding
import com.base.pdfviewerscannerwhite.helper.BaseActivity
import com.base.pdfviewerscannerwhite.ui.view.DialogView.showDocumentMore
import com.base.pdfviewerscannerwhite.utils.KeyBoardUtils.hideKeyboard
import com.base.pdfviewerscannerwhite.utils.LogEx
import com.cherry.lib.doc.bean.DocEngine
import com.cherry.lib.doc.util.Constant
import java.io.File
class ExcelActivity : BaseActivity<ActivityExcelBinding>() {
......@@ -20,13 +30,13 @@ class ExcelActivity : BaseActivity<ActivityExcelBinding>() {
fun launchDocViewer(
activity: Activity,
docSourceType: Int,
path: String?,
pathOrUri: String?,
fileType: Int? = null,
engine: Int? = null
) {
val intent = Intent(activity, ExcelActivity::class.java)
intent.putExtra(Constant.INTENT_SOURCE_KEY, docSourceType)
intent.putExtra(Constant.INTENT_DATA_KEY, path)
intent.putExtra(Constant.INTENT_DATA_KEY, pathOrUri)
intent.putExtra(Constant.INTENT_TYPE_KEY, fileType)
intent.putExtra(Constant.INTENT_ENGINE_KEY, engine)
activity.startActivity(intent)
......@@ -34,21 +44,100 @@ class ExcelActivity : BaseActivity<ActivityExcelBinding>() {
}
override fun initView() {
initData(intent)
initSpData(intent)
val file = File(pathOrUri ?: "")
if (file.exists()) {
binding.tvName.text = file.name
}
}
@SuppressLint("ClickableViewAccessibility")
override fun initListener() {
super.initListener()
onBackPressedDispatcher.addCallback {
finishToMain()
}
binding.flFanhui.setOnClickListener {
onBackPressedDispatcher.onBackPressed()
}
binding.ivXuanzhuan.setOnClickListener {
switchOrientation()
}
binding.ivMore.setOnClickListener {
showDocumentMore(DocumentBean.TYPE_EXCEL)
}
binding.mDocView.singleTapAction = {
LogEx.logDebug(TAG, "actionDownCallBack")
if (isShowTopLayout) {
LogEx.logDebug(TAG, "hide")
hideTopLayout()
} else {
showTopLayout()
LogEx.logDebug(TAG, "show")
}
}
}
private fun switchOrientation() {
requestedOrientation = if (requestedOrientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) {
ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
} else {
ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
}
}
private var isShowTopLayout = true
private fun showTopLayout() {
if (!isShowTopLayout) {
isShowTopLayout = true
val topAnim: Animation = TranslateAnimation(0f, 0f, -binding.vAnimatorTop.height.toFloat(), 0f)
topAnim.setDuration(200)
topAnim.setAnimationListener(object : Animation.AnimationListener {
override fun onAnimationStart(animation: Animation) {
binding.vAnimatorTop.visibility = View.VISIBLE
}
override fun onAnimationRepeat(animation: Animation) {}
override fun onAnimationEnd(animation: Animation) {
}
})
binding.vAnimatorTop.startAnimation(topAnim)
}
}
private fun hideTopLayout() {
if (isShowTopLayout) {
isShowTopLayout = false
hideKeyboard(binding.editSearch)
val topAnim: Animation = TranslateAnimation(0f, 0f, 0f, -binding.vAnimatorTop.height.toFloat())
topAnim.setDuration(200)
topAnim.setAnimationListener(object : Animation.AnimationListener {
override fun onAnimationStart(animation: Animation) {}
override fun onAnimationRepeat(animation: Animation) {}
override fun onAnimationEnd(animation: Animation) {
binding.vAnimatorTop.visibility = View.GONE
}
})
binding.vAnimatorTop.startAnimation(topAnim)
}
}
private var docSourceType = 0
private var fileType = -1
private var engine: Int = DocEngine.INTERNAL.value
private var docUrl: String? = null// 文件地址
fun initData(intent: Intent?) {
docUrl = intent?.getStringExtra(Constant.INTENT_DATA_KEY)
private var pathOrUri: String? = null// 文件地址
private fun initSpData(intent: Intent?) {
pathOrUri = intent?.getStringExtra(Constant.INTENT_DATA_KEY)
docSourceType = intent?.getIntExtra(Constant.INTENT_SOURCE_KEY, 0) ?: 0
fileType = intent?.getIntExtra(Constant.INTENT_TYPE_KEY, -1) ?: -1
engine = intent?.getIntExtra(Constant.INTENT_ENGINE_KEY, DocEngine.INTERNAL.value) ?: DocEngine.INTERNAL.value
binding.mDocView.openDoc(this, docUrl, docSourceType, fileType, false, DocEngine.values().first { it.value == engine })
LogEx.logDebug(TAG, "initData-docUrl = $docUrl")
binding.mDocView.openDoc(this, pathOrUri, docSourceType, fileType, false, DocEngine.values().first { it.value == engine })
LogEx.logDebug(TAG, "initData-pathOrUri = $pathOrUri")
LogEx.logDebug(TAG, "initData-docSourceType = $docSourceType")
LogEx.logDebug(TAG, "initData-fileType = $fileType")
LogEx.logDebug(TAG, "initData-engine = $engine")
......
package com.base.pdfviewerscannerwhite.ui.document.ppt
import android.annotation.SuppressLint
import android.app.Activity
import android.content.Intent
import android.view.View
import android.view.animation.Animation
import android.view.animation.TranslateAnimation
import androidx.activity.addCallback
import androidx.core.view.isVisible
import com.base.pdfviewerscannerwhite.databinding.ActivityPptBinding
import com.base.pdfviewerscannerwhite.helper.BaseActivity
import com.base.pdfviewerscannerwhite.utils.KeyBoardUtils.hideKeyboard
import com.base.pdfviewerscannerwhite.utils.LogEx
import com.cherry.lib.doc.bean.DocEngine
import com.cherry.lib.doc.util.Constant
......@@ -31,18 +38,45 @@ class PptActivity : BaseActivity<ActivityPptBinding>() {
intent.putExtra(Constant.INTENT_ENGINE_KEY, engine)
activity.startActivity(intent)
}
}
@SuppressLint("SetTextI18n")
override fun initView() {
initData(intent)
binding.mDocView
initSpData(intent)
binding.mDocView.getPageNumberAction = { current, total ->
if (!binding.tvPageCount.isVisible) {
binding.tvPageCount.isVisible = true
}
binding.tvPageCount.text = "$current/$total"
}
binding.mDocView.singleTapAction = {
LogEx.logDebug(TAG, "actionDownCallBack")
if (isShowTopLayout) {
LogEx.logDebug(TAG, "hide")
hideTopLayout()
} else {
showTopLayout()
LogEx.logDebug(TAG, "show")
}
}
}
override fun initListener() {
super.initListener()
onBackPressedDispatcher.addCallback {
finishToMain()
}
binding.flFanhui.setOnClickListener {
onBackPressedDispatcher.onBackPressed()
}
}
private var docSourceType = 0
private var fileType = -1
private var engine: Int = DocEngine.INTERNAL.value
private var docUrl: String? = null// 文件地址
fun initData(intent: Intent?) {
private fun initSpData(intent: Intent?) {
docUrl = intent?.getStringExtra(Constant.INTENT_DATA_KEY)
docSourceType = intent?.getIntExtra(Constant.INTENT_SOURCE_KEY, 0) ?: 0
fileType = intent?.getIntExtra(Constant.INTENT_TYPE_KEY, -1) ?: -1
......@@ -54,4 +88,42 @@ class PptActivity : BaseActivity<ActivityPptBinding>() {
LogEx.logDebug(TAG, "initData-fileType = $fileType")
LogEx.logDebug(TAG, "initData-engine = $engine")
}
private fun showTopLayout() {
if (!isShowTopLayout) {
isShowTopLayout = true
val topAnim: Animation = TranslateAnimation(0f, 0f, -binding.vAnimatorTop.height.toFloat(), 0f)
topAnim.setDuration(200)
topAnim.setAnimationListener(object : Animation.AnimationListener {
override fun onAnimationStart(animation: Animation) {
binding.vAnimatorTop.visibility = View.VISIBLE
}
override fun onAnimationRepeat(animation: Animation) {}
override fun onAnimationEnd(animation: Animation) {
}
})
binding.vAnimatorTop.startAnimation(topAnim)
}
}
private var isShowTopLayout = true
private fun hideTopLayout() {
if (isShowTopLayout) {
isShowTopLayout = false
hideKeyboard(binding.editSearch)
val topAnim: Animation = TranslateAnimation(0f, 0f, 0f, -binding.vAnimatorTop.height.toFloat())
topAnim.setDuration(200)
topAnim.setAnimationListener(object : Animation.AnimationListener {
override fun onAnimationStart(animation: Animation) {}
override fun onAnimationRepeat(animation: Animation) {}
override fun onAnimationEnd(animation: Animation) {
binding.vAnimatorTop.visibility = View.GONE
}
})
binding.vAnimatorTop.startAnimation(topAnim)
}
}
}
\ No newline at end of file
......@@ -61,7 +61,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), MainView {
binding.viewPager2.offscreenPageLimit = 4
binding.viewPager2.run {
isUserInputEnabled = false
isUserInputEnabled = true
adapter = object : FragmentStateAdapter(this@MainActivity) {
override fun getItemCount(): Int {
return fragments.size
......
......@@ -12,9 +12,11 @@ import androidx.core.content.FileProvider
import androidx.core.widget.addTextChangedListener
import com.base.pdfviewerscannerwhite.R
import com.base.pdfviewerscannerwhite.bean.DocumentBean
import com.base.pdfviewerscannerwhite.bean.DocumentBean.Companion.TYPE_EXCEL
import com.base.pdfviewerscannerwhite.databinding.DialogCommonTipBinding
import com.base.pdfviewerscannerwhite.databinding.DialogDeleteBinding
import com.base.pdfviewerscannerwhite.databinding.DialogDocumentDetailBinding
import com.base.pdfviewerscannerwhite.databinding.DialogDocumentMoreBinding
import com.base.pdfviewerscannerwhite.databinding.DialogDocumentRenameBinding
import com.base.pdfviewerscannerwhite.databinding.DialogPageNumberBinding
import com.base.pdfviewerscannerwhite.databinding.DialogPdfDetailBinding
......@@ -25,6 +27,7 @@ import com.base.pdfviewerscannerwhite.ui.adapter.DocumentAdapter
import com.base.pdfviewerscannerwhite.ui.document.pdf.PdfBoxUtils
import com.base.pdfviewerscannerwhite.ui.main.DocumentView
import com.base.pdfviewerscannerwhite.ui.document.pdf.PdfView
import com.base.pdfviewerscannerwhite.ui.view.DialogView.showPdfMoreDialog
import com.base.pdfviewerscannerwhite.utils.ActivityLauncher
import com.base.pdfviewerscannerwhite.utils.IntentShareUtils.sharePdfIntent
import com.base.pdfviewerscannerwhite.utils.IntentShareUtils.sharePdfPrintIntent
......@@ -228,6 +231,24 @@ object DialogView {
}
fun Activity.showDocumentMore(type: String) {
val dialog = BottomSheetDialog(this, R.style.BottomSheetDialog)
val binding = DialogDocumentMoreBinding.inflate(LayoutInflater.from(this))
dialog.setContentView(binding.root)
dialog.setCanceledOnTouchOutside(false)
dialog.show()
val parentView = binding.root.parent as View
val behavior = BottomSheetBehavior.from(parentView)
//展开
behavior.state = BottomSheetBehavior.STATE_EXPANDED
if (type == TYPE_EXCEL) {
binding.llJump.visibility = View.GONE
}
}
@SuppressLint("SetTextI18n")
fun Context.showPdfPwdDialog(
......
......@@ -7,16 +7,119 @@
android:layout_height="match_parent"
tools:context=".ui.document.excel.ExcelActivity">
<ViewAnimator
android:id="@+id/v_animator_top"
android:layout_width="match_parent"
android:layout_height="60dp"
android:background="@color/white"
app:layout_constraintTop_toTopOf="parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/cl_top"
android:layout_width="match_parent"
android:layout_height="60dp"
app:layout_constraintTop_toTopOf="parent">
<FrameLayout
android:id="@+id/fl_fanhui"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/tv_name"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:padding="15dp"
android:src="@mipmap/fanhui_b"
tools:ignore="ContentDescription" />
</FrameLayout>
<TextView
android:id="@+id/tv_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:ellipsize="end"
android:singleLine="true"
android:textColor="@color/black"
android:textSize="19sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/iv_xuanzhuan"
app:layout_constraintStart_toEndOf="@id/fl_fanhui"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="HardcodedText"
tools:text="DEMO.xlsx" />
<ImageView
android:id="@+id/iv_xuanzhuan"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:src="@mipmap/hengping"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/iv_search"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="ContentDescription" />
<ImageView
android:id="@+id/iv_search"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:src="@mipmap/h_sousuo"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/iv_more"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="ContentDescription" />
<ImageView
android:id="@+id/iv_more"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:src="@mipmap/x_genduo"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="ContentDescription" />
<EditText
android:id="@+id/edit_search"
android:layout_width="0dp"
android:layout_height="40dp"
android:layout_marginStart="5dp"
android:layout_marginEnd="20dp"
android:background="@drawable/bg_f8f9fe_10"
android:hint="input..."
android:paddingHorizontal="18dp"
android:singleLine="true"
android:textColor="@color/black"
android:textColorHint="#B8B9BD"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/iv_search"
app:layout_constraintStart_toEndOf="@id/fl_fanhui"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="Autofill,HardcodedText,TextFields" />
</androidx.constraintlayout.widget.ConstraintLayout>
</ViewAnimator>
<com.cherry.lib.doc.widget.DocView
android:id="@+id/mDocView"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:dv_engine="internal"
android:layout_height="0dp"
app:dv_moving_orientation="vertical"
app:dv_page_pb_color="@color/yellow"
app:dv_page_pb_height="2dp"
app:dv_quality="normal"
app:dv_show_page_num="false" />
app:dv_show_page_num="false"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@id/v_animator_top" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
......@@ -166,7 +166,6 @@
</com.angcyo.tablayout.DslTabLayout>
</FrameLayout>
<androidx.viewpager2.widget.ViewPager2
android:id="@+id/viewPager2"
android:layout_width="match_parent"
......
......@@ -7,15 +7,138 @@
android:layout_height="match_parent"
tools:context=".ui.document.ppt.PptActivity">
<ViewAnimator
android:id="@+id/v_animator_top"
android:layout_width="match_parent"
android:layout_height="60dp"
android:background="@color/white"
app:layout_constraintTop_toTopOf="parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/cl_top"
android:layout_width="match_parent"
android:layout_height="60dp"
app:layout_constraintTop_toTopOf="parent">
<FrameLayout
android:id="@+id/fl_fanhui"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/tv_name"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:padding="15dp"
android:src="@mipmap/fanhui_b"
tools:ignore="ContentDescription" />
</FrameLayout>
<TextView
android:id="@+id/tv_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:ellipsize="end"
android:singleLine="true"
android:textColor="@color/black"
android:textSize="19sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/iv_xuanzhuan"
app:layout_constraintStart_toEndOf="@id/fl_fanhui"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="HardcodedText"
tools:text="DEMO.ppt" />
<ImageView
android:id="@+id/iv_xuanzhuan"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:src="@mipmap/hengping"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/iv_search"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="ContentDescription" />
<ImageView
android:id="@+id/iv_search"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:src="@mipmap/h_sousuo"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/iv_more"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="ContentDescription" />
<ImageView
android:id="@+id/iv_more"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:src="@mipmap/x_genduo"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="ContentDescription" />
<EditText
android:id="@+id/edit_search"
android:layout_width="0dp"
android:layout_height="40dp"
android:layout_marginStart="5dp"
android:layout_marginEnd="20dp"
android:background="@drawable/bg_f8f9fe_10"
android:hint="input..."
android:paddingHorizontal="18dp"
android:singleLine="true"
android:textColor="@color/black"
android:textColorHint="#B8B9BD"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/iv_search"
app:layout_constraintStart_toEndOf="@id/fl_fanhui"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="Autofill,HardcodedText,TextFields" />
</androidx.constraintlayout.widget.ConstraintLayout>
</ViewAnimator>
<com.cherry.lib.doc.widget.DocView
android:id="@+id/mDocView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="0dp"
app:dv_engine="internal"
app:dv_moving_orientation="vertical"
app:dv_page_pb_color="@color/yellow"
app:dv_page_pb_height="2dp"
app:dv_quality="normal"
app:dv_show_page_num="false" />
app:dv_show_page_num="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@id/v_animator_top" />
<TextView
android:visibility="gone"
android:id="@+id/tv_pageCount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="28dp"
android:layout_marginTop="28dp"
android:background="@drawable/bg_54585b_5"
android:includeFontPadding="false"
android:paddingHorizontal="2dp"
android:paddingVertical="2dp"
android:textColor="@color/white"
android:textSize="12sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/v_animator_top"
tools:text="1/3" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/bg_f1f1f1_tlr25"
android:orientation="vertical">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/cl"
android:layout_width="match_parent"
android:layout_height="65dp"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="15dp"
android:text="More"
android:textColor="#333333"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="HardcodedText" />
<ImageView
android:id="@+id/iv_bookmark"
android:layout_width="24dp"
android:layout_height="32dp"
android:layout_marginEnd="27dp"
android:src="@mipmap/h_soucang_n"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="ContentDescription" />
</androidx.constraintlayout.widget.ConstraintLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@id/cl">
<LinearLayout
android:id="@+id/ll_jump"
android:layout_width="match_parent"
android:layout_height="60dp"
android:background="?android:selectableItemBackground"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="13dp"
android:src="@mipmap/jump"
tools:ignore="ContentDescription" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginHorizontal="13dp"
android:layout_weight="1"
android:ellipsize="end"
android:includeFontPadding="false"
android:singleLine="true"
android:text="Jump to the specified page"
android:textColor="#333333"
android:textSize="16sp"
tools:ignore="HardcodedText" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginEnd="20dp"
android:src="@mipmap/jianotou"
tools:ignore="ContentDescription" />
</LinearLayout>
<LinearLayout
android:id="@+id/ll_detail"
android:layout_width="match_parent"
android:layout_height="60dp"
android:background="?android:selectableItemBackground"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="13dp"
android:src="@mipmap/particulars"
tools:ignore="ContentDescription" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginHorizontal="13dp"
android:layout_weight="1"
android:ellipsize="end"
android:includeFontPadding="false"
android:singleLine="true"
android:text="Detail"
android:textColor="#333333"
android:textSize="16sp"
tools:ignore="HardcodedText" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginEnd="20dp"
android:src="@mipmap/jianotou"
tools:ignore="ContentDescription" />
</LinearLayout>
<LinearLayout
android:id="@+id/ll_share"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_marginBottom="20dp"
android:background="?android:selectableItemBackground"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="13dp"
android:src="@mipmap/share"
tools:ignore="ContentDescription" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginHorizontal="13dp"
android:layout_weight="1"
android:ellipsize="end"
android:includeFontPadding="false"
android:singleLine="true"
android:text="Share"
android:textColor="#333333"
android:textSize="16sp"
tools:ignore="HardcodedText" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginEnd="20dp"
android:src="@mipmap/jianotou"
tools:ignore="ContentDescription" />
</LinearLayout>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
......@@ -3,8 +3,10 @@ package com.cherry.lib.doc.office;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import com.blankj.utilcode.util.AppUtils;
import com.cherry.lib.doc.office.common.IOfficeToPicture;
import com.cherry.lib.doc.office.constant.EventConstant;
......@@ -12,6 +14,7 @@ import com.cherry.lib.doc.office.constant.wp.WPViewConstant;
import com.cherry.lib.doc.office.res.ResKit;
import com.cherry.lib.doc.office.system.IMainFrame;
import com.cherry.lib.doc.office.system.MainControl;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
......@@ -22,6 +25,7 @@ import java.util.List;
*/
public abstract class IOffice implements IMainFrame {
private String TAG = "IOffice";
private MainControl control;
private boolean writeLog = true;
//view background
......@@ -148,6 +152,7 @@ public abstract class IOffice implements IMainFrame {
* @return True if the listener has consumed the event, false otherwise.
*/
public boolean doActionEvent(int actionID, Object obj) {
Log.e(TAG, "doActionEvent actionID" + actionID);
try {
switch (actionID) {
case EventConstant.SYS_UPDATE_TOOLSBAR_BUTTON_STATUS: //update toolsbar state
......@@ -192,8 +197,7 @@ public abstract class IOffice implements IMainFrame {
return 0;
}
public boolean onEventMethod(View v, MotionEvent e1, MotionEvent e2, float xValue,
float yValue, byte eventMethodType) {
public boolean onEventMethod(View v, MotionEvent e1, MotionEvent e2, float xValue, float yValue, byte eventMethodType) {
return false;
}
......
......@@ -39,7 +39,6 @@ public interface TouchEventListener
* @param e2 MotionEvent instance
* @param velocityX x axis velocity
* @param velocityY y axis velocity
* @param eventNethodType event method
* @see TouchEventListener#EVENT_CLICK
* @see TouchEventListener#EVENT_DOUBLE_TAP
* @see TouchEventListener#EVENT_DOUBLE_TAP_EVENT
......
......@@ -9,8 +9,6 @@ package com.cherry.lib.doc.office.pg.control;
import com.cherry.lib.doc.office.common.ISlideShow;
import com.cherry.lib.doc.office.system.IControl;
import com.cherry.lib.doc.office.system.beans.AEventManage;
import com.cherry.lib.doc.office.system.beans.ATimer;
import android.graphics.Rect;
import android.view.MotionEvent;
import android.view.View;
......
......@@ -38,7 +38,7 @@ import com.cherry.lib.doc.office.common.ISlideShow
*
*
*/
abstract class AbstractControl : IControl {
abstract class AbstractControl : IControl {
override fun layoutView(x: Int, y: Int, w: Int, h: Int) {}
override fun actionEvent(actionID: Int, obj: Any?) {}
override fun getActionValue(actionID: Int, obj: Any?): Any? {
......
/*
* 文件名称: IActivity.java
*
*
* 编译器: android2.2
* 时间: 下午5:24:10
*/
......@@ -25,12 +25,11 @@ import android.view.View;
* <p>
* 负责人: ljj8494
* <p>
* 负责小组:
* 负责小组:
* <p>
* <p>
*/
public interface IMainFrame
{
public interface IMainFrame {
// onTouch
public final static byte ON_TOUCH = 0;
// onDown
......@@ -56,280 +55,281 @@ public interface IMainFrame
/**
* get activity instance
*
* @return activity instance
*/
public Activity getActivity();
/**
* do action
* do action
*
* @param actionID action ID
*
* @param obj acValue
*
* @return True if the listener has consumed the event, false otherwise.
* @param actionID action ID
* @param obj acValue
* @return True if the listener has consumed the event, false otherwise.
*/
public boolean doActionEvent(int actionID, Object obj);
/**
* reader file finish call this method
*/
public void openFileFinish();
public void openFileFailed();
/**
* update tool bar status
*/
*/
public void updateToolsbarStatus();
/**
* set the find back button and find forward button state
*
*
* @param state
*/
public void setFindBackForwardState(boolean state);
/**
* get bottom bar height
*
* @return bottom bar height
*/
public int getBottomBarHeight();
/**
* get top bar height
*
* @return top bar height
*/
public int getTopBarHeight();
/**
* get application name;
*
* @return application name
*/
public String getAppName();
/**
*
* @return
*/
public File getTemporaryDirectory();
/**
* event method, office engine dispatch
*
* @param v event source
* @param e1 MotionEvent instance
* @param e2 MotionEvent instance
* @param xValue eventNethodType is ON_SCROLL, this is value distanceX
* eventNethodType is ON_FLING, this is value velocityY
* eventNethodType is other type, this is value -1
*
* @param yValue eventNethodType is ON_SCROLL, this is value distanceY
* eventNethodType is ON_FLING, this is value velocityY
* eventNethodType is other type, this is value -1
* @param eventNethodType event method
* @see IMainFrame#ON_CLICK
* @see IMainFrame#ON_DOUBLE_TAP
* @see IMainFrame#ON_DOUBLE_TAP_EVENT
* @see IMainFrame#ON_DOWN
* @see IMainFrame#ON_FLING
* @see IMainFrame#ON_LONG_PRESS
* @see IMainFrame#ON_SCROLL
* @see IMainFrame#ON_SHOW_PRESS
* @see IMainFrame#ON_SINGLE_TAP_CONFIRMED
* @see IMainFrame#ON_SINGLE_TAP_UP
* @see IMainFrame#ON_TOUCH
/**
* event method, office engine dispatch
*
* @param v event source
* @param e1 MotionEvent instance
* @param e2 MotionEvent instance
* @param xValue eventNethodType is ON_SCROLL, this is value distanceX
* eventNethodType is ON_FLING, this is value velocityY
* eventNethodType is other type, this is value -1
* @param yValue eventNethodType is ON_SCROLL, this is value distanceY
* eventNethodType is ON_FLING, this is value velocityY
* eventNethodType is other type, this is value -1
* @see IMainFrame#ON_CLICK
* @see IMainFrame#ON_DOUBLE_TAP
* @see IMainFrame#ON_DOUBLE_TAP_EVENT
* @see IMainFrame#ON_DOWN
* @see IMainFrame#ON_FLING
* @see IMainFrame#ON_LONG_PRESS
* @see IMainFrame#ON_SCROLL
* @see IMainFrame#ON_SHOW_PRESS
* @see IMainFrame#ON_SINGLE_TAP_CONFIRMED
* @see IMainFrame#ON_SINGLE_TAP_UP
* @see IMainFrame#ON_TOUCH
*/
public boolean onEventMethod(View v, MotionEvent e1, MotionEvent e2, float xValue, float yValue, byte eventMethodType);
//单次点击
public void singleTap();
//获取页码
public void getPageNumber(int current, int total);
/**
* is support draw page number
* @return true draw page number
* false don’t draw page number
*
* @return true draw page number
* false don’t draw page number
*/
public boolean isDrawPageNumber();
/**
* true: show message when zooming
* false: not show message when zooming
*
* @return
*/
public boolean isShowZoomingMsg();
/**
* true: pop up dialog when throw err
* false: not pop up dialog when throw err
*
* @return
*/
public boolean isPopUpErrorDlg();
/**
* show password dialog when parse file with password
*
* @return
*/
public boolean isShowPasswordDlg();
public boolean isShowPasswordDlg();
/**
* show progress bar or not when parsing document
*
* @return
*/
public boolean isShowProgressBar();
/**
*
*
*/
public boolean isShowFindDlg();
/**
* show txt encode dialog when parse txt file
*
* @return
*/
public boolean isShowTXTEncodeDlg();
/**
* get txt default encode when not showing txt encode dialog
*
* @return null if showing txt encode dialog
*/
public String getTXTDefaultEncode();
/**
* is support zoom in / zoom out
*
* @return true touch zoom
* false don’t touch zoom
*
* @return true touch zoom
* false don’t touch zoom
*/
public boolean isTouchZoom();
/**
* normal view, changed after zoom bend, you need to re-layout
*
* @return true re-layout
* false don't re-layout
*
* @return true re-layout
* false don't re-layout
*/
public boolean isZoomAfterLayoutForWord();
/**
* Word application default view (Normal or Page)
*
*
* @return 0, page view
* 1,normal view;
*
* 1,normal view;
*/
public byte getWordDefaultView();
/**
* get Internationalization resource
*
*
* @param resName Internationalization resource name
*/
public String getLocalString(String resName);
/**
* callback this method after zoom change
*/
public void changeZoom();
/**
*
*
*/
public void changePage();
/**
*
*
*/
public void completeLayout();
/**
* when engine error occurred callback this method
*/
public void error(int errorCode);
/**
* full screen, not show top tool bar
*/
public void fullScreen(boolean fullscreen);
/**
*
* @param visible
*/
public void showProgressBar(boolean visible);
/**
*
* @param viewList
*/
public void updateViewImages(List<Integer> viewList);
public void updateViewImages(List<Integer> viewList);
/**
* set change page flag, Only when effectively the PageSize greater than ViewSize.
* (for PPT, word print mode, PDF)
*
* @param b = true, change page
* = false, don't change page
* set change page flag, Only when effectively the PageSize greater than ViewSize.
* (for PPT, word print mode, PDF)
*/
public boolean isChangePage();
/**
* when need destroy office engine instance callback this method
*/
//public void destroyEngine();
/**
*
* @param saveLog
*/
public void setWriteLog(boolean saveLog);
/**
*
* @return
*/
public boolean isWriteLog();
/**
*
* @param isThumbnail
*/
public void setThumbnail(boolean isThumbnail);
/**
*
* @return
*/
public boolean isThumbnail();
/**
* get view backgrouond
*
* @return
*/
public Object getViewBackground();
/**
* set flag whether fitzoom can be larger than 100% but smaller than the max zoom
*
* @param ignoreOriginalSize
*/
public void setIgnoreOriginalSize(boolean ignoreOriginalSize);
/**
*
* @return
* true fitzoom may be larger than 100% but smaller than the max zoom
* @return true fitzoom may be larger than 100% but smaller than the max zoom
* false fitzoom can not larger than 100%
*/
public boolean isIgnoreOriginalSize();
/**
* page list view moving position
* @param position horizontal or vertical
*/
public int getPageListViewMovingPosition();
/**
*
*
*/
public void dispose();
}
......@@ -140,7 +140,7 @@ public class MainControl extends AbstractControl {
*/
public void dismissProgressDialog() {
if (progressDialog != null) {
if(progressDialog.getWindow() != null){
if (progressDialog.getWindow() != null) {
progressDialog.dismiss();
}
progressDialog = null;
......@@ -316,6 +316,7 @@ public class MainControl extends AbstractControl {
* @param obj 动作ID的Value
*/
public void actionEvent(int actionID, final Object obj) {
Log.e("MainControl", "actionEvent " + actionID);
if (actionID == EventConstant.SYS_READER_FINSH_ID) {
if (reader != null) {
if (appControl != null) {
......
......@@ -17,6 +17,7 @@ import android.graphics.Rect;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
import android.widget.LinearLayout;
......@@ -569,6 +570,7 @@ public class Word extends LinearLayout implements IWord {
* @param zoom
*/
private void drawPageNubmer(Canvas canvas, float zoom) {
Log.e("Word", "drawPageNubmer");
int currentNumber = getCurrentPageNumber();
if (control.getMainFrame().isDrawPageNumber() && pageRoot != null) {
Rect rect = canvas.getClipBounds();
......
......@@ -9,6 +9,7 @@ import android.graphics.Rect
import android.graphics.drawable.Drawable
import android.util.AttributeSet
import android.util.Log
import android.view.MotionEvent
import android.view.View
import android.view.ViewGroup
import android.widget.FrameLayout
......@@ -52,27 +53,19 @@ class DocView : FrameLayout {
private val TAG = "DocView"
var mActivity: Activity? = null
var lifecycleScope: LifecycleCoroutineScope = (context as AppCompatActivity).lifecycleScope
private var mPoiViewer: PoiViewer? = null
private var mMovingOrientation = DocMovingOrientation.HORIZONTAL
private var engine = DocEngine.INTERNAL
private var showDivider = true
private var showPageNum = true
private var divider: Drawable? = null
private var runnable = Runnable {}
var enableLoadingForPages: Boolean = true
var pbDefaultHeight = 2
var pbHeight: Int = pbDefaultHeight
var pbDefaultColor = Color.RED
var pbColor: Int = pbDefaultColor
private var pdfRendererCoreInitialised = false
var pageMargin: Rect = Rect(0, 0, 0, 0)
var totalPageCount = 0
var mOnDocPageChangeListener: OnDocPageChangeListener? = null
var sourceFilePath: String? = null
var mViewPdfInPage: Boolean = true
......@@ -87,9 +80,6 @@ class DocView : FrameLayout {
fun initView(attrs: AttributeSet?, defStyle: Int) {
inflate(context, R.layout.doc_view, this)
binding = DocViewBinding.bind(this)
binding.mIvPdf.setOnClickListener {
binding.mLlBigPdfImage.hide()
}
val typedArray =
context.obtainStyledAttributes(attrs, R.styleable.DocView, defStyle, 0)
......@@ -114,7 +104,6 @@ class DocView : FrameLayout {
bottom = typedArray.getDimensionPixelSize(R.styleable.DocView_dv_page_marginBottom, bottom)
}
binding.mPdfPageNo.isVisible = showPageNum
val layoutParams = binding.mPlLoadProgress.layoutParams
layoutParams.height = pbHeight
......@@ -125,7 +114,6 @@ class DocView : FrameLayout {
typedArray.recycle()
}
fun openDoc(
activity: Activity, docUrl: String?, docSourceType: Int,
engine: DocEngine = this.engine
......@@ -136,8 +124,10 @@ class DocView : FrameLayout {
@SuppressLint("ObsoleteSdkInt")
fun openDoc(
activity: Activity?, docUrl: String?,
docSourceType: Int, fileType: Int,
activity: Activity?,
docUrl: String?,
docSourceType: Int,
fileType: Int,
viewPdfInPage: Boolean = false,
engine: DocEngine = this.engine
) {
......@@ -180,7 +170,6 @@ class DocView : FrameLayout {
when (type) {
FileType.PDF -> {
Log.e(TAG, "openDoc()......PDF")
// binding.mDocWeb.hide()
binding.mFlDocContainer.hide()
binding.mIvImage.hide()
......@@ -191,7 +180,6 @@ class DocView : FrameLayout {
showPageNum = false
}
Log.e(TAG, "openDoc()......")
// binding.mDocWeb.hide()
binding.mFlDocContainer.hide()
binding.mIvImage.show()
if (docSourceType == DocSourceType.PATH) {
......@@ -218,9 +206,33 @@ class DocView : FrameLayout {
}
}
var singleTapAction: (() -> Unit)? = null
var getPageNumberAction: ((current: Int, total: Int) -> Unit)? = null
fun showDoc(activity: Activity, mDocContainer: ViewGroup?, url: String?, docSourceType: Int, fileType: Int) {
Log.e(TAG, "showDoc()......")
val iOffice: IOffice = object : IOffice() {
override fun onEventMethod(
v: View?,
e1: MotionEvent?,
e2: MotionEvent?,
xValue: Float,
yValue: Float,
eventMethodType: Byte
): Boolean {
Log.e(TAG, "onEventMethod ${e1?.action} ${MotionEvent.ACTION_DOWN}")
return super.onEventMethod(v, e1, e2, xValue, yValue, eventMethodType)
}
override fun singleTap() {
Log.e(TAG, "singleTap")
singleTapAction?.invoke()
}
override fun getPageNumber(current: Int, total: Int) {
getPageNumberAction?.invoke(current, total)
}
override fun getActivity(): Activity {
return activity
}
......@@ -269,52 +281,10 @@ class DocView : FrameLayout {
}
}
//是否绘制页码
iOffice.isDrawPageNumber
iOffice.openFile(url, docSourceType, fileType.toString())
}
private val scrollListener = object : RecyclerView.OnScrollListener() {
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
super.onScrolled(recyclerView, dx, dy)
(recyclerView.layoutManager as LinearLayoutManager).run {
var foundPosition: Int = findLastCompletelyVisibleItemPosition()
if (foundPosition != RecyclerView.NO_POSITION)
binding.mPdfPageNo.text = context.getString(R.string.pdfView_page_no, foundPosition + 1, totalPageCount)
if (showPageNum) {
binding.mPdfPageNo.visibility = View.VISIBLE
}
if (foundPosition == 0 && !mViewPdfInPage)
binding.mPdfPageNo.postDelayed({
binding.mPdfPageNo.visibility = GONE
}, 3000)
if (foundPosition != RecyclerView.NO_POSITION) {
mOnDocPageChangeListener?.OnPageChanged(foundPosition, totalPageCount)
return@run
}
foundPosition = findFirstVisibleItemPosition()
if (foundPosition != RecyclerView.NO_POSITION) {
mOnDocPageChangeListener?.OnPageChanged(foundPosition, totalPageCount)
return@run
}
}
}
override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) {
super.onScrollStateChanged(recyclerView, newState)
if (newState == RecyclerView.SCROLL_STATE_IDLE && !mViewPdfInPage) {
binding.mPdfPageNo.postDelayed(runnable, 3000)
} else {
binding.mPdfPageNo.removeCallbacks(runnable)
}
}
}
override fun onDetachedFromWindow() {
super.onDetachedFromWindow()
onDestroy()
......
......@@ -4,38 +4,6 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:id="@+id/mLlBigPdfImage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:visibility="gone">
<com.cherry.lib.doc.widget.PinchImageView
android:id="@+id/mIvPdf"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<ProgressBar
android:id="@+id/mPbBigLoading"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_gravity="center"
android:visibility="gone"
tools:visibility="visible" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:layout_marginTop="50dp"
android:layout_marginEnd="30dp"
android:scaleType="fitCenter"
android:src="@mipmap/ic_big_close"
tools:ignore="ContentDescription" />
</FrameLayout>
<FrameLayout
android:id="@+id/mFlDocContainer"
android:layout_width="match_parent"
......@@ -55,17 +23,5 @@
android:progressDrawable="@drawable/pb_webview_layer"
android:visibility="visible" />
<TextView
android:id="@+id/mPdfPageNo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="18dp"
android:background="@drawable/page_counter"
android:paddingStart="12dp"
android:paddingTop="4dp"
android:paddingEnd="12dp"
android:paddingBottom="4dp"
android:textColor="#A19D9D"
android:textSize="16sp" />
</FrameLayout>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment