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
......
......@@ -39,6 +39,8 @@ import android.view.View;
import org.jetbrains.annotations.Nullable;
/**
* ppt 控制器
* <p>
* 文件注释
* <p>
* <p>
......@@ -54,52 +56,45 @@ import org.jetbrains.annotations.Nullable;
* <p>
* <p>
*/
public class PGControl extends AbstractControl
{
public class PGControl extends AbstractControl {
/**
*
*/
public PGControl(IControl mainControl, PGModel pgModel, String filePath)
{
public PGControl(IControl mainControl, PGModel pgModel, String filePath) {
this.mainControl = mainControl;
pgView = new Presentation(getMainFrame().getActivity(), pgModel, this);
}
/**
* 布局视图
*
* @param x
* @param y
* @param w
* @param h
*/
public void layoutView(int x, int y, int w, int h)
{
public void layoutView(int x, int y, int w, int h) {
}
/**
* action派发
*
* @param actionID 动作ID
* @param obj 动作ID的Value
*/
public void actionEvent(int actionID, final @Nullable Object obj)
{
switch (actionID)
{
public void actionEvent(int actionID, final @Nullable Object obj) {
switch (actionID) {
case EventConstant.SYS_SET_PROGRESS_BAR_ID:
if (pgView.getParent() != null)
{
pgView.post(new Runnable()
{
if (pgView.getParent() != null) {
pgView.post(new Runnable() {
/**
*
*/
public void run()
{
if (!isDispose)
{
public void run() {
if (!isDispose) {
//getActivity().setProgressBarIndeterminateVisibility((Boolean)obj);
mainControl.getMainFrame().showProgressBar((Boolean)obj);
mainControl.getMainFrame().showProgressBar((Boolean) obj);
}
}
});
......@@ -107,34 +102,25 @@ public class PGControl extends AbstractControl
break;
case EventConstant.SYS_VECTORGRAPH_PROGRESS:
if (pgView.getParent() != null)
{
pgView.post(new Runnable()
{
if (pgView.getParent() != null) {
pgView.post(new Runnable() {
/**
*
*/
public void run()
{
if (!isDispose)
{
mainControl.getMainFrame().updateViewImages((List<Integer>)obj);
public void run() {
if (!isDispose) {
mainControl.getMainFrame().updateViewImages((List<Integer>) obj);
}
}
});
}
else
{
new Thread()
{
} else {
new Thread() {
/**
*
*/
public void run()
{
if (!isDispose)
{
mainControl.getMainFrame().updateViewImages((List<Integer>)obj);
public void run() {
if (!isDispose) {
mainControl.getMainFrame().updateViewImages((List<Integer>) obj);
}
}
}.start();
......@@ -151,15 +137,11 @@ public class PGControl extends AbstractControl
break;
case EventConstant.SYS_UPDATE_TOOLSBAR_BUTTON_STATUS: // 更新toolsbar button状态
pgView.post(new Runnable()
{
@ Override
public void run()
{
if (!isDispose)
{
if (getMainFrame() != null)
{
pgView.post(new Runnable() {
@Override
public void run() {
if (!isDispose) {
if (getMainFrame() != null) {
getMainFrame().updateToolsbarStatus();
}
}
......@@ -168,52 +150,39 @@ public class PGControl extends AbstractControl
break;
case EventConstant.APP_PAGE_UP_ID:
if(pgView.isSlideShow())
{
if (pgView.isSlideShow()) {
pgView.slideShow(ISlideShow.SlideShow_PreviousSlide);
}
else
{
if (pgView.getCurrentIndex() > 0)
{
} else {
if (pgView.getCurrentIndex() > 0) {
pgView.showSlide(pgView.getCurrentIndex() - 1, false);
}
}
break;
case EventConstant.APP_PAGE_DOWN_ID:
if(pgView.isSlideShow())
{
if (pgView.isSlideShow()) {
pgView.slideShow(ISlideShow.SlideShow_NextSlide);
}
else
{
if (pgView.getCurrentIndex() < pgView.getRealSlideCount() - 1)
{
} else {
if (pgView.getCurrentIndex() < pgView.getRealSlideCount() - 1) {
pgView.showSlide(pgView.getCurrentIndex() + 1, false);
}
}
break;
case EventConstant.PG_SHOW_SLIDE_ID:
if(!pgView.isSlideShow())
{
showSlide((Integer)obj);
if (!pgView.isSlideShow()) {
showSlide((Integer) obj);
}
break;
case EventConstant.APP_ZOOM_ID:
if(!pgView.isSlideShow())
{
int[] params = (int[])obj;
pgView.setZoom(params[0] / (float)MainConstant.STANDARD_RATE, params[1], params[2]);
pgView.post(new Runnable()
{
@ Override
public void run()
{
if (!isDispose)
{
if (!pgView.isSlideShow()) {
int[] params = (int[]) obj;
pgView.setZoom(params[0] / (float) MainConstant.STANDARD_RATE, params[1], params[2]);
pgView.post(new Runnable() {
@Override
public void run() {
if (!isDispose) {
getMainFrame().changeZoom();
}
}
......@@ -230,55 +199,47 @@ public class PGControl extends AbstractControl
break;
case EventConstant.FILE_COPY_ID: //copy
ClipboardManager clip = (ClipboardManager)getMainFrame().getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
ClipboardManager clip = (ClipboardManager) getMainFrame().getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
clip.setText(pgView.getSelectedText());
break;
case EventConstant.APP_HYPERLINK: //hyperlink
String addr = ((Hyperlink)obj).getAddress();
if(addr != null)
{
try
{
String addr = ((Hyperlink) obj).getAddress();
if (addr != null) {
try {
Intent hyIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(addr));
getMainFrame().getActivity().startActivity(hyIntent);
}
catch(Exception e)
{
} catch (Exception e) {
}
}
break;
case EventConstant.SYS_AUTO_TEST_FINISH_ID: // 布局完成
if (isAutoTest())
{
if (isAutoTest()) {
getMainFrame().getActivity().onBackPressed();
}
break;
case EventConstant.APP_GENERATED_PICTURE_ID:
pgView.post(new Runnable()
{
@ Override
public void run()
{
if (!isDispose)
{
pgView.post(new Runnable() {
@Override
public void run() {
if (!isDispose) {
pgView.createPicture();
}
}
});
break;
case EventConstant.PG_SLIDESHOW_DURATION:
pgView.setAnimationDuration((Integer)obj);
pgView.setAnimationDuration((Integer) obj);
break;
case EventConstant.PG_SLIDESHOW_GEGIN:
//first, it'll throw an event of onSizeChanged
getMainFrame().fullScreen(true);
//then
this.pgView.beginSlideShow(obj == null ? pgView.getCurrentIndex() + 1 : (Integer)obj);
this.pgView.beginSlideShow(obj == null ? pgView.getCurrentIndex() + 1 : (Integer) obj);
break;
case EventConstant.PG_SLIDESHOW_END:
pgView.endSlideShow();
......@@ -297,7 +258,7 @@ public class PGControl extends AbstractControl
break;
case EventConstant.APP_SET_FIT_SIZE_ID:
pgView.setFitSize((Integer)obj);
pgView.setFitSize((Integer) obj);
break;
case EventConstant.APP_INIT_CALLOUTVIEW_ID:
......@@ -309,32 +270,23 @@ public class PGControl extends AbstractControl
}
}
private void pagesCountChanged()
{
if(isShowingProgressDlg && pgView.showLoadingSlide())
{
private void pagesCountChanged() {
if (isShowingProgressDlg && pgView.showLoadingSlide()) {
isShowingProgressDlg = false;
pgView.post(new Runnable()
{
pgView.post(new Runnable() {
/**
*
*/
public void run()
{
if(getMainFrame().isShowProgressBar())
{
if (progressDialog != null)
{
public void run() {
if (getMainFrame().isShowProgressBar()) {
if (progressDialog != null) {
progressDialog.dismiss();
progressDialog = null;
}
}
else
{
} else {
ICustomDialog dlgListener = mainControl.getCustomDialog();
if(dlgListener != null)
{
if (dlgListener != null) {
dlgListener.dismissDialog(ICustomDialog.DIALOGTYPE_LOADING);
}
}
......@@ -347,20 +299,16 @@ public class PGControl extends AbstractControl
/**
*
*/
private void showSlide(final int slideIndex)
{
if (slideIndex < 0 || slideIndex >= pgView.getSlideCount())
{
private void showSlide(final int slideIndex) {
if (slideIndex < 0 || slideIndex >= pgView.getSlideCount()) {
return;
}
isShowingProgressDlg = false;
if (slideIndex >= pgView.getRealSlideCount())
{
if (slideIndex >= pgView.getRealSlideCount()) {
isShowingProgressDlg = true;
if(Objects.requireNonNull(getMainFrame()).isShowProgressBar())
{
if (Objects.requireNonNull(getMainFrame()).isShowProgressBar()) {
final PGControl own = this;
pgView.postDelayed(() -> {
if (isShowingProgressDlg) {
......@@ -370,12 +318,9 @@ public class PGControl extends AbstractControl
progressDialog.show();
}
}, 200);
}
else
{
} else {
ICustomDialog dlgListener = mainControl.getCustomDialog();
if(dlgListener != null)
{
if (dlgListener != null) {
dlgListener.showDialog(ICustomDialog.DIALOGTYPE_LOADING);
}
}
......@@ -391,10 +336,8 @@ public class PGControl extends AbstractControl
*
* @return obj
*/
public @Nullable Object getActionValue(int actionID, @Nullable Object obj)
{
switch (actionID)
{
public @Nullable Object getActionValue(int actionID, @Nullable Object obj) {
switch (actionID) {
case EventConstant.APP_ZOOM_ID:
return pgView.getZoom();
......@@ -411,30 +354,27 @@ public class PGControl extends AbstractControl
return pgView.getFitZoom();
case EventConstant.PG_SLIDE_TO_IMAGE:
return pgView.slideToImage((Integer)obj);
return pgView.slideToImage((Integer) obj);
case EventConstant.APP_PAGEAREA_TO_IMAGE:
if(obj instanceof int[])
{
int[] paraArr = (int[])obj;
if(paraArr != null && paraArr.length == 7)
{
if (obj instanceof int[]) {
int[] paraArr = (int[]) obj;
if (paraArr != null && paraArr.length == 7) {
return pgView.slideAreaToImage(paraArr[0], paraArr[1], paraArr[2], paraArr[3], paraArr[4], paraArr[5], paraArr[6]);
}
}
break;
case EventConstant.PG_GET_SLIDE_NOTE:
return pgView.getSldieNote((Integer)obj);
return pgView.getSldieNote((Integer) obj);
case EventConstant.PG_GET_SLIDE_SIZE:
int index = (Integer)obj;
if (index <= 0 || index > pgView.getSlideCount())
{
int index = (Integer) obj;
if (index <= 0 || index > pgView.getSlideCount()) {
return null;
}
Dimension d = pgView.getPageSize();
return new Rectangle(0, 0, (int)d.width, (int)d.height);
return new Rectangle(0, 0, (int) d.width, (int) d.height);
case EventConstant.PG_SLIDESHOW:
return pgView.isSlideShow();
......@@ -452,29 +392,25 @@ public class PGControl extends AbstractControl
return pgView.hasNextAction_Slideshow();
case EventConstant.APP_THUMBNAIL_ID:
if(obj instanceof int[])
{
int[] a = (int[])obj;
if (a.length < 2 || a[1] <= 0)
{
if (obj instanceof int[]) {
int[] a = (int[]) obj;
if (a.length < 2 || a[1] <= 0) {
return null;
}
return pgView.getThumbnail(a[0], a[1] / (float)MainConstant.STANDARD_RATE);
return pgView.getThumbnail(a[0], a[1] / (float) MainConstant.STANDARD_RATE);
}
break;
case EventConstant.PG_SLIDESHOW_SLIDEEXIST:
return ((Integer)obj).intValue() <= pgView.getRealSlideCount();
return ((Integer) obj).intValue() <= pgView.getRealSlideCount();
case EventConstant.PG_SLIDESHOW_ANIMATIONSTEPS:
return pgView.getSlideAnimationSteps((Integer)obj);
return pgView.getSlideAnimationSteps((Integer) obj);
case EventConstant.PG_SLIDESHOW_SLIDESHOWTOIMAGE:
if(obj instanceof int[])
{
int[] a = (int[])obj;
if (a.length < 2 || a[1] <= 0)
{
if (obj instanceof int[]) {
int[] a = (int[]) obj;
if (a.length < 2 || a[1] <= 0) {
return null;
}
return pgView.getSlideshowToImage(a[0], a[1]);
......@@ -482,16 +418,14 @@ public class PGControl extends AbstractControl
break;
case EventConstant.APP_GET_FIT_SIZE_STATE_ID:
if (pgView != null)
{
if (pgView != null) {
return pgView.getFitSizeState();
}
break;
case EventConstant.APP_GET_SNAPSHOT_ID:
if (pgView != null)
{
return pgView.getSnapshot((Bitmap)obj);
if (pgView != null) {
return pgView.getSnapshot((Bitmap) obj);
}
break;
......@@ -503,124 +437,104 @@ public class PGControl extends AbstractControl
/**
* current view index
*
* @return
*/
public int getCurrentViewIndex()
{
public int getCurrentViewIndex() {
return pgView.getCurrentIndex() + 1;
}
/**
*
*
*/
public View getView()
{
public View getView() {
return pgView;
}
/**
*
*/
public Dialog getDialog(Activity activity, int id)
{
public Dialog getDialog(Activity activity, int id) {
return null;
}
/**
*
*/
public IMainFrame getMainFrame()
{
public IMainFrame getMainFrame() {
return mainControl.getMainFrame();
}
/**
* (non-Javadoc)
*
*(non-Javadoc)
* @see com.cherry.lib.doc.office.system.AbstractControl#getActivity()
*
*/
public Activity getActivity()
{
public Activity getActivity() {
return mainControl.getMainFrame().getActivity();
}
/**
*
*/
public IFind getFind()
{
public IFind getFind() {
return pgView.getFind();
}
/**
*
*/
public boolean isAutoTest()
{
public boolean isAutoTest() {
return mainControl.isAutoTest();
}
/**
*
*
*/
public IOfficeToPicture getOfficeToPicture()
{
public IOfficeToPicture getOfficeToPicture() {
return mainControl.getOfficeToPicture();
}
/**
*
*/
public ICustomDialog getCustomDialog()
{
public ICustomDialog getCustomDialog() {
return mainControl.getCustomDialog();
}
/**
*
*/
public boolean isSlideShow()
{
public boolean isSlideShow() {
return pgView.isSlideShow();
}
/**
*
* @return
*/
public ISlideShow getSlideShow()
{
public ISlideShow getSlideShow() {
return mainControl.getSlideShow();
}
/**
*
*
*/
public int getApplicationType()
{
public int getApplicationType() {
return MainConstant.APPLICATION_TYPE_PPT;
}
/**
*
*
*/
public SysKit getSysKit()
{
public SysKit getSysKit() {
return mainControl.getSysKit();
}
/**
*
*
*/
public void dispose()
{
public void dispose() {
isDispose = true;
pgView.dispose();
pgView = null;
......
......@@ -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;
......
......@@ -29,6 +29,7 @@ import com.cherry.lib.doc.office.system.SysKit;
import com.cherry.lib.doc.office.system.beans.pagelist.APageListItem;
import com.cherry.lib.doc.office.system.beans.pagelist.APageListView;
import com.cherry.lib.doc.office.system.beans.pagelist.IPageListViewListener;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
......@@ -37,6 +38,7 @@ import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
......@@ -58,23 +60,18 @@ import android.widget.FrameLayout;
* <p>
* <p>
*/
public class PGPrintMode extends FrameLayout implements IPageListViewListener
{
public class PGPrintMode extends FrameLayout implements IPageListViewListener {
/**
*
* @param context
*/
public PGPrintMode(Context context)
{
public PGPrintMode(Context context) {
super(context);
}
/**
*
*
*/
public PGPrintMode(Context context, IControl control, PGModel pgModel, PGEditor editor)
{
public PGPrintMode(Context context, IControl control, PGModel pgModel, PGEditor editor) {
super(context);
this.control = control;
this.pgModel = pgModel;
......@@ -90,52 +87,41 @@ public class PGPrintMode extends FrameLayout implements IPageListViewListener
paint.setTextSize(36);
}
public void setVisible(boolean visible)
{
if(visible)
{
public void setVisible(boolean visible) {
if (visible) {
listView.setVisibility(View.VISIBLE);
}
else
{
} else {
listView.setVisibility(View.GONE);
}
}
/**
*
*/
public void setBackgroundColor(int color)
{
public void setBackgroundColor(int color) {
super.setBackgroundColor(color);
if (listView != null)
{
if (listView != null) {
listView.setBackgroundColor(color);
}
}
/**
*
*
*/
public void setBackgroundResource(int resid)
{
public void setBackgroundResource(int resid) {
super.setBackgroundResource(resid);
if (listView != null)
{
if (listView != null) {
listView.setBackgroundResource(resid);
}
}
/**
*
*
*/
public void setBackgroundDrawable(Drawable d)
{
public void setBackgroundDrawable(Drawable d) {
super.setBackgroundDrawable(d);
if (listView != null)
{
if (listView != null) {
listView.setBackgroundDrawable(d);
}
}
......@@ -143,46 +129,38 @@ public class PGPrintMode extends FrameLayout implements IPageListViewListener
/**
*
*/
public void setVisibility(int visibility)
{
public void setVisibility(int visibility) {
super.setVisibility(visibility);
if (visibility == VISIBLE);
if (visibility == VISIBLE) ;
{
exportImage(listView.getCurrentPageView(), null);
}
}
/**
* (non-Javadoc)
*
*(non-Javadoc)
* @see android.view.ViewGroup#dispatchDraw(android.graphics.Canvas)
*
*/
protected void dispatchDraw(Canvas canvas)
{
protected void dispatchDraw(Canvas canvas) {
super.dispatchDraw(canvas);
drawPageNubmer(canvas);
}
/**
*
*
*/
public void init()
{
public void init() {
//view.setBackgroundColor(color)
if ((int)(getZoom() * 100) == 100)
{
if ((int) (getZoom() * 100) == 100) {
setZoom(getFitZoom(), Integer.MIN_VALUE, Integer.MIN_VALUE);
}
}
/**
*
*
*/
public void setZoom(float zoom, int pointX, int pointY)
{
public void setZoom(float zoom, int pointX, int pointY) {
listView.setZoom(zoom, pointX, pointY);
}
......@@ -194,8 +172,7 @@ public class PGPrintMode extends FrameLayout implements IPageListViewListener
* = 1, fit size of pageWidth
* = 2, fit size of PageHeight
*/
public void setFitSize(int value)
{
public void setFitSize(int value) {
listView.setFitSize(value);
}
......@@ -208,24 +185,21 @@ public class PGPrintMode extends FrameLayout implements IPageListViewListener
* = 2, left/right alignment
* = 3, left/right and top/bottom alignment
*/
public int getFitSizeState()
{
public int getFitSizeState() {
return listView.getFitSizeState();
}
/**
*
*/
public float getZoom()
{
public float getZoom() {
return listView.getZoom();
}
/**
*
*/
public float getFitZoom()
{
public float getFitZoom() {
return listView.getFitZoom();
}
......@@ -234,32 +208,28 @@ public class PGPrintMode extends FrameLayout implements IPageListViewListener
*
* @return page number (base 1)
*/
public int getCurrentPageNumber()
{
public int getCurrentPageNumber() {
return listView.getCurrentPageNumber();
}
/**
*
*/
public APageListView getListView()
{
public APageListView getListView() {
return this.listView;
}
/**
*
*/
public void nextPageView()
{
public void nextPageView() {
listView.nextPageView();
}
/**
*
*/
public void previousPageview()
{
public void previousPageview() {
listView.previousPageview();
}
......@@ -268,49 +238,45 @@ public class PGPrintMode extends FrameLayout implements IPageListViewListener
*
* @param index
*/
public void showSlideForIndex(int index)
{
public void showSlideForIndex(int index) {
listView.showPDFPageForIndex(index);
}
/**
* /
public long viewToModel(int x, int y, boolean isBack)
{
int pageIndex = listView.getCurrentPageNumber() - 1;
if (pageIndex < 0 || pageIndex >= getPageCount())
{
return 0;
}
return pageRoot.viewToModel(x, y, isBack);
}
/**
*
* public long viewToModel(int x, int y, boolean isBack)
* {
* int pageIndex = listView.getCurrentPageNumber() - 1;
* if (pageIndex < 0 || pageIndex >= getPageCount())
* {
* return 0;
* }
* return pageRoot.viewToModel(x, y, isBack);
* }
* <p>
* /**
* <p>
* /
public Rectangle modelToView(long offset, Rectangle rect, boolean isBack)
{
int pageIndex = listView.getCurrentPageNumber() - 1;
if (pageIndex < 0 || pageIndex >= getPageCount())
{
return rect;
}
return pageRoot.modelToView(offset, rect, isBack);
}
/**
*
* public Rectangle modelToView(long offset, Rectangle rect, boolean isBack)
* {
* int pageIndex = listView.getCurrentPageNumber() - 1;
* if (pageIndex < 0 || pageIndex >= getPageCount())
* {
* return rect;
* }
* return pageRoot.modelToView(offset, rect, isBack);
* }
* <p>
* /**
*/
public int getPageCount()
{
public int getPageCount() {
return Math.max(pgModel.getSlideCount(), 1);
}
/**
*
*/
public APageListItem getPageListItem(int position, View convertView, ViewGroup parent)
{
public APageListItem getPageListItem(int position, View convertView, ViewGroup parent) {
Rect rect = getPageSize(position);
return new PGPageListItem(listView, control, editor, rect.width(), rect.height());
}
......@@ -329,51 +295,39 @@ public class PGPrintMode extends FrameLayout implements IPageListViewListener
}
/**
*
*
*/
public void exportImage(final APageListItem pageItem, final Bitmap srcBitmap)
{
if (getControl() == null || !(getParent() instanceof Presentation))
{
public void exportImage(final APageListItem pageItem, final Bitmap srcBitmap) {
if (getControl() == null || !(getParent() instanceof Presentation)) {
return;
}
PGFind find = (PGFind)control.getFind();
if (find.isSetPointToVisible())
{
PGFind find = (PGFind) control.getFind();
if (find.isSetPointToVisible()) {
find.setSetPointToVisible(false);
Rectangle rect = editor.modelToView(editor.getHighlight().getSelectStart(), new Rectangle(), false);
if (!listView.isPointVisibleOnScreen(rect.x, rect.y))
{
if (!listView.isPointVisibleOnScreen(rect.x, rect.y)) {
listView.setItemPointVisibleOnScreen(rect.x, rect.y);
return;
}
}
post(new Runnable()
{
@ Override
public void run()
{
try
{
post(new Runnable() {
@Override
public void run() {
try {
PGSlide slide = pgModel.getSlide(pageItem.getPageIndex());
if (slide != null)
{
if (slide != null) {
IOfficeToPicture otp = getControl().getOfficeToPicture();
if (otp != null && otp.getModeType() == IOfficeToPicture.VIEW_CHANGE_END)
{
if (otp != null && otp.getModeType() == IOfficeToPicture.VIEW_CHANGE_END) {
int rW = Math.min(getWidth(), pageItem.getWidth());
int rH = Math.min(getHeight(), pageItem.getHeight());
Bitmap dstBitmap = otp.getBitmap(rW, rH);
if (dstBitmap == null)
{
if (dstBitmap == null) {
return;
}
//editor.getHighlight().setPaintHighlight(false);
// don't zoom
if (dstBitmap.getWidth() == rW && dstBitmap.getHeight() == rH)
{
if (dstBitmap.getWidth() == rW && dstBitmap.getHeight() == rH) {
Canvas canvas = new Canvas(dstBitmap);
canvas.drawColor(Color.WHITE);
float zoom = listView.getZoom();
......@@ -384,12 +338,11 @@ public class PGPrintMode extends FrameLayout implements IPageListViewListener
control.getSysKit().getCalloutManager().drawPath(canvas, pageItem.getPageIndex(), zoom);
}
// zoom
else
{
float paintZoom = Math.min(dstBitmap.getWidth() / (float)rW, dstBitmap.getHeight() / (float)rH);
else {
float paintZoom = Math.min(dstBitmap.getWidth() / (float) rW, dstBitmap.getHeight() / (float) rH);
float zoom = listView.getZoom() * paintZoom;
int left = (int)(pageItem.getLeft() * paintZoom);
int top = (int)(pageItem.getTop() * paintZoom);
int left = (int) (pageItem.getLeft() * paintZoom);
int top = (int) (pageItem.getTop() * paintZoom);
Canvas canvas = new Canvas(dstBitmap);
canvas.drawColor(Color.WHITE);
canvas.translate(-(Math.max(left, 0) - left), -(Math.max(top, 0) - top));
......@@ -400,9 +353,7 @@ public class PGPrintMode extends FrameLayout implements IPageListViewListener
otp.callBack(dstBitmap);
}
}
}
catch (Exception e)
{
} catch (Exception e) {
}
}
});
......@@ -410,31 +361,27 @@ public class PGPrintMode extends FrameLayout implements IPageListViewListener
/**
* get snap shot
*
* @param dstBitmap
* @return
*/
public Bitmap getSnapshot(final Bitmap dstBitmap)
{
if (getControl() == null || !(getParent() instanceof Presentation))
{
public Bitmap getSnapshot(final Bitmap dstBitmap) {
if (getControl() == null || !(getParent() instanceof Presentation)) {
return null;
}
PGPageListItem pageItem = (PGPageListItem)getListView().getCurrentPageView();
if (pageItem == null)
{
PGPageListItem pageItem = (PGPageListItem) getListView().getCurrentPageView();
if (pageItem == null) {
return null;
}
PGSlide slide = pgModel.getSlide(pageItem.getPageIndex());
if (slide != null)
{
if (slide != null) {
int rW = Math.min(getWidth(), pageItem.getWidth());
int rH = Math.min(getHeight(), pageItem.getHeight());
// don't zoom
if (dstBitmap.getWidth() == rW && dstBitmap.getHeight() == rH)
{
if (dstBitmap.getWidth() == rW && dstBitmap.getHeight() == rH) {
Canvas canvas = new Canvas(dstBitmap);
canvas.drawColor(Color.WHITE);
float zoom = listView.getZoom();
......@@ -444,12 +391,11 @@ public class PGPrintMode extends FrameLayout implements IPageListViewListener
SlideDrawKit.instance().drawSlide(canvas, pgModel, editor, slide, zoom);
}
// zoom
else
{
float paintZoom = Math.min(dstBitmap.getWidth() / (float)rW, dstBitmap.getHeight() / (float)rH);
else {
float paintZoom = Math.min(dstBitmap.getWidth() / (float) rW, dstBitmap.getHeight() / (float) rH);
float zoom = listView.getZoom() * paintZoom;
int left = (int)(pageItem.getLeft() * paintZoom);
int top = (int)(pageItem.getTop() * paintZoom);
int left = (int) (pageItem.getLeft() * paintZoom);
int top = (int) (pageItem.getTop() * paintZoom);
Canvas canvas = new Canvas(dstBitmap);
canvas.drawColor(Color.WHITE);
canvas.translate(-(Math.max(left, 0) - left), -(Math.max(top, 0) - top));
......@@ -459,47 +405,40 @@ public class PGPrintMode extends FrameLayout implements IPageListViewListener
return dstBitmap;
}
/**
*
*
*/
public boolean isInit()
{
public boolean isInit() {
return true;
}
/**
*
* @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()
{
public boolean isIgnoreOriginalSize() {
return control.getMainFrame().isIgnoreOriginalSize();
}
/**
* page list view moving position
*/
public int getPageListViewMovingPosition()
{
public int getPageListViewMovingPosition() {
return control.getMainFrame().getPageListViewMovingPosition();
}
/**
*
*/
public Object getModel()
{
public Object getModel() {
return pgModel;
}
/**
*
*/
public IControl getControl()
{
public IControl getControl() {
return this.control;
}
......@@ -523,40 +462,30 @@ public class PGPrintMode extends FrameLayout implements IPageListViewListener
* @see IMainFrame#ON_SINGLE_TAP_UP
* @see IMainFrame#ON_TOUCH
*/
public boolean onEventMethod(View v, MotionEvent e1, MotionEvent e2, float velocityX, float velocityY, byte eventMethodType)
{
public boolean onEventMethod(View v, MotionEvent e1, MotionEvent e2, float velocityX, float velocityY, byte eventMethodType) {
if (eventMethodType == ON_SINGLE_TAP_UP && e1 != null
&& e1.getAction() == MotionEvent.ACTION_UP)
{
&& e1.getAction() == MotionEvent.ACTION_UP) {
APageListItem item = listView.getCurrentPageView();
if (item != null)
{
if (item != null) {
float zoom = listView.getZoom();
int x = (int)((e1.getX() - item.getLeft()) / zoom);
int y = (int)((e1.getY() - item.getTop()) / zoom);
int x = (int) ((e1.getX() - item.getLeft()) / zoom);
int y = (int) ((e1.getY() - item.getTop()) / zoom);
IShape shape = pgModel.getSlide(item.getPageIndex()).getTextboxShape(x, y);
if (shape != null && shape.getType() == AbstractShape.SHAPE_TEXTBOX)
{
TextBox textBox = (TextBox)shape;
if (shape != null && shape.getType() == AbstractShape.SHAPE_TEXTBOX) {
TextBox textBox = (TextBox) shape;
STRoot root = textBox.getRootView();
if (root != null)
{
if (root != null) {
long offset = root.viewToModel(x - shape.getBounds().x, y - shape.getBounds().y, false);
if (offset >= 0)
{
ParagraphElement paraElem = (ParagraphElement)textBox.getElement().getElement(offset);
if (paraElem != null)
{
if (offset >= 0) {
ParagraphElement paraElem = (ParagraphElement) textBox.getElement().getElement(offset);
if (paraElem != null) {
IElement leaf = paraElem.getLeaf(offset);
if (leaf != null)
{
if (leaf != null) {
int hyID = AttrManage.instance().getHperlinkID(leaf.getAttribute());
if (hyID >= 0)
{
if (hyID >= 0) {
Hyperlink hylink = control.getSysKit().getHyperlinkManage().getHyperlink(hyID);
if (hylink != null)
{
if (hylink != null) {
control.actionEvent(EventConstant.APP_HYPERLINK, hylink);
return true;
}
......@@ -572,25 +501,19 @@ public class PGPrintMode extends FrameLayout implements IPageListViewListener
}
/**
*
*
*/
public void updateStutus(Object obj)
{
public void updateStutus(Object obj) {
control.actionEvent(EventConstant.SYS_UPDATE_TOOLSBAR_BUTTON_STATUS, obj);
}
/**
*
*
*/
public void resetSearchResult(APageListItem pageItem)
{
if (getParent() instanceof Presentation)
{
Presentation pg = (Presentation)getParent();
if (pg.getFind().getPageIndex() != pageItem.getPageIndex())
{
public void resetSearchResult(APageListItem pageItem) {
if (getParent() instanceof Presentation) {
Presentation pg = (Presentation) getParent();
if (pg.getFind().getPageIndex() != pageItem.getPageIndex()) {
pg.getEditor().getHighlight().removeHighlight();
}
}
......@@ -599,76 +522,69 @@ public class PGPrintMode extends FrameLayout implements IPageListViewListener
/**
*
*/
public boolean isTouchZoom()
{
public boolean isTouchZoom() {
return control.getMainFrame().isTouchZoom();
}
/**
*
*/
public boolean isShowZoomingMsg()
{
public boolean isShowZoomingMsg() {
return control.getMainFrame().isShowZoomingMsg();
}
/**
*
*/
public void changeZoom()
{
public void changeZoom() {
control.getMainFrame().changeZoom();
}
/**
* @param isDrawPictrue The isDrawPictrue to set.
*/
public void setDrawPictrue(boolean isDrawPictrue)
{
public void setDrawPictrue(boolean isDrawPictrue) {
PictureKit.instance().setDrawPictrue(isDrawPictrue);
}
/**
*
* @return
*/
public PGSlide getCurrentPGSlide()
{
public PGSlide getCurrentPGSlide() {
APageListItem item = listView.getCurrentPageView();
if (item != null)
{
if (item != null) {
return pgModel.getSlide(item.getPageIndex());
}
else
{
} else {
return pgModel.getSlide(0);
}
}
/**
* 绘制页信息
*
* @param canvas
*/
private void drawPageNubmer(Canvas canvas)
{
if (control.getMainFrame().isDrawPageNumber())
{
private void drawPageNubmer(Canvas canvas) {
Log.e("PGPrintMode", "drawPageNubmer");
control.getMainFrame().getPageNumber(listView.getCurrentPageNumber(), pgModel.getSlideCount());
if (control.getMainFrame().isDrawPageNumber()) {
String pn = String.valueOf((listView.getCurrentPageNumber()) + " / " + pgModel.getSlideCount());
int w = (int)paint.measureText(pn);
int h = (int)(paint.descent() - paint.ascent());
int x = (int)((getWidth() - w) / 2);
int y = (int)((getHeight() - h) - 50);
int w = (int) paint.measureText(pn);
int h = (int) (paint.descent() - paint.ascent());
int x = (int) ((getWidth() - w) / 2);
int y = (int) ((getHeight() - h) - 50);
Drawable drawable = SysKit.getPageNubmerDrawable();
drawable.setBounds((int)(x - 20), y - 10, x + w + 20, y + h + 10);
drawable.setBounds((int) (x - 20), y - 10, x + w + 20, y + h + 10);
drawable.draw(canvas);
y -= paint.ascent();
canvas.drawText(pn, x, y, paint);
}
if (preShowPageIndex != listView.getCurrentPageNumber())
{
if (preShowPageIndex != listView.getCurrentPageNumber()) {
changePage();
preShowPageIndex = listView.getCurrentPageNumber();
}
......@@ -677,29 +593,24 @@ public class PGPrintMode extends FrameLayout implements IPageListViewListener
/**
*
*/
public void changePage()
{
public void changePage() {
control.getMainFrame().changePage();
}
/**
* set change page flag, Only when effectively the PageSize greater than ViewSize.
* (for PPT, word print mode, PDF)
*
*/
public boolean isChangePage()
{
public boolean isChangePage() {
return control.getMainFrame().isChangePage();
}
/**
*
*/
public void dispose()
{
public void dispose() {
control = null;
if (listView != null)
{
if (listView != null) {
listView.dispose();
}
pgModel = null;
......
......@@ -29,8 +29,7 @@ import android.view.View;
* <p>
* <p>
*/
public interface IMainFrame
{
public interface IMainFrame {
// onTouch
public final static byte ON_TOUCH = 0;
// onDown
......@@ -56,6 +55,7 @@ public interface IMainFrame
/**
* get activity instance
*
* @return activity instance
*/
public Activity getActivity();
......@@ -64,9 +64,7 @@ public interface IMainFrame
* do action
*
* @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);
......@@ -92,24 +90,26 @@ public interface IMainFrame
/**
* 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();
......@@ -123,11 +123,9 @@ public interface IMainFrame
* @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
......@@ -142,8 +140,15 @@ public interface IMainFrame
*/
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
*/
......@@ -153,6 +158,7 @@ public interface IMainFrame
/**
* true: show message when zooming
* false: not show message when zooming
*
* @return
*/
public boolean isShowZoomingMsg();
......@@ -160,18 +166,21 @@ public interface IMainFrame
/**
* 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();
/**
* show progress bar or not when parsing document
*
* @return
*/
public boolean isShowProgressBar();
......@@ -183,12 +192,14 @@ public interface IMainFrame
/**
* 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();
......@@ -215,7 +226,6 @@ public interface IMainFrame
*
* @return 0, page view
* 1,normal view;
*
*/
public byte getWordDefaultView();
......@@ -252,13 +262,11 @@ public interface IMainFrame
public void fullScreen(boolean fullscreen);
/**
*
* @param visible
*/
public void showProgressBar(boolean visible);
/**
*
* @param viewList
*/
public void updateViewImages(List<Integer> viewList);
......@@ -267,9 +275,6 @@ public interface IMainFrame
/**
* 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
*/
public boolean isChangePage();
......@@ -279,52 +284,47 @@ public interface IMainFrame
//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();
......
......@@ -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) {
......
......@@ -8,12 +8,10 @@ package com.cherry.lib.doc.office.system.beans;
import com.cherry.lib.doc.office.constant.EventConstant;
import com.cherry.lib.doc.office.constant.MainConstant;
import com.cherry.lib.doc.office.system.ErrorUtil;
import com.cherry.lib.doc.office.system.IControl;
import com.cherry.lib.doc.office.system.IMainFrame;
import com.cherry.lib.doc.office.system.MainControl;
import android.content.Context;
import android.util.Log;
import android.view.GestureDetector;
import android.view.GestureDetector.OnDoubleTapListener;
import android.view.GestureDetector.OnGestureListener;
......@@ -43,13 +41,11 @@ import android.widget.Toast;
* <p>
*/
public abstract class AEventManage implements OnTouchListener,
OnGestureListener, OnDoubleTapListener, OnClickListener
{
OnGestureListener, OnDoubleTapListener, OnClickListener {
/**
*
*/
public AEventManage(Context context, IControl control)
{
public AEventManage(Context context, IControl control) {
this.control = control;
gesture = new GestureDetector(context, this, null, true);
mScroller = new Scroller(context);
......@@ -61,34 +57,28 @@ public abstract class AEventManage implements OnTouchListener,
/**
* 触摸事件
*
*/
public boolean onTouch(View v, MotionEvent event)
{
public boolean onTouch(View v, MotionEvent event) {
Log.e("AEventManage", "onTouch " + event.getAction());
boolean ret = false;
try
{
if (gesture == null)
{
try {
if (gesture == null) {
return false;
}
control.getMainFrame().onEventMethod(v, event, null, -1.0f, -1.0f, IMainFrame.ON_TOUCH);
if(event.getPointerCount() == 2)
{
if (event.getPointerCount() == 2) {
//view zoom
return zoom(event);
}
// 交给手型处理
gesture.onTouchEvent(event);
if (mVelocityTracker == null)
{
if (mVelocityTracker == null) {
mVelocityTracker = VelocityTracker.obtain();
}
mVelocityTracker.addMovement(event);
int action = event.getAction();
switch (action)
{
switch (action) {
case MotionEvent.ACTION_DOWN:
stopFling();
mActivePointerId = event.getPointerId(0);
......@@ -98,22 +88,18 @@ public abstract class AEventManage implements OnTouchListener,
break;
case MotionEvent.ACTION_UP:
if(!singleTabup)
{
if (!singleTabup) {
final VelocityTracker velocityTracker = mVelocityTracker;
velocityTracker.computeCurrentVelocity(1000, mMaximumVelocity);
int initialYVelocity = (int)velocityTracker.getYVelocity(mActivePointerId);
int initialXVelocity = (int)velocityTracker.getXVelocity(mActivePointerId);
int initialYVelocity = (int) velocityTracker.getYVelocity(mActivePointerId);
int initialXVelocity = (int) velocityTracker.getXVelocity(mActivePointerId);
if (Math.abs(initialYVelocity) > mMinimumVelocity
|| Math.abs(initialXVelocity) > mMinimumVelocity)
{
if(!isScroll)
{
|| Math.abs(initialXVelocity) > mMinimumVelocity) {
if (!isScroll) {
isScroll = control.getApplicationType() == MainConstant.APPLICATION_TYPE_PPT;
}
if (!zoomChange)
{
if (!zoomChange) {
fling(-initialXVelocity, -initialYVelocity);
}
ret = true;
......@@ -121,41 +107,34 @@ public abstract class AEventManage implements OnTouchListener,
midXDoublePoint = -1;
midYDoublePoint = -1;
mActivePointerId = -1;
if (mVelocityTracker != null)
{
if (mVelocityTracker != null) {
mVelocityTracker.recycle();
mVelocityTracker = null;
}
toast.cancel();
if (isScroll)
{
if (isScroll) {
isScroll = false;
if (control.getApplicationType() == MainConstant.APPLICATION_TYPE_WP && zoomChange)
{
if (!control.getMainFrame().isZoomAfterLayoutForWord())
{
if (control.getApplicationType() == MainConstant.APPLICATION_TYPE_WP && zoomChange) {
if (!control.getMainFrame().isZoomAfterLayoutForWord()) {
control.actionEvent(EventConstant.APP_GENERATED_PICTURE_ID, null);
}
}
if (control.getApplicationType() == MainConstant.APPLICATION_TYPE_PPT)
{
if (!control.isSlideShow())
{
if (control.getApplicationType() == MainConstant.APPLICATION_TYPE_PPT) {
if (!control.isSlideShow()) {
control.actionEvent(EventConstant.APP_GENERATED_PICTURE_ID, null);
}
}
else
{
} else {
control.actionEvent(EventConstant.APP_GENERATED_PICTURE_ID, null);
}
control.actionEvent(EventConstant.SYS_UPDATE_TOOLSBAR_BUTTON_STATUS, null);
}
if (control.getApplicationType() != MainConstant.APPLICATION_TYPE_WP)
{
if (control.getApplicationType() != MainConstant.APPLICATION_TYPE_WP) {
zoomChange = false;
}
} else {
control.getMainFrame().singleTap();
}
singleTabup = false;
......@@ -163,17 +142,14 @@ public abstract class AEventManage implements OnTouchListener,
break;
case MotionEvent.ACTION_CANCEL:
mActivePointerId = -1;
if (mVelocityTracker != null)
{
if (mVelocityTracker != null) {
mVelocityTracker.recycle();
mVelocityTracker = null;
}
default:
break;
}
}
catch (Exception e)
{
} catch (Exception e) {
control.getSysKit().getErrorKit().writerLog(e);
}
return ret;
......@@ -181,35 +157,33 @@ public abstract class AEventManage implements OnTouchListener,
/**
* action when zooming
*
* @param event
* @return
*/
protected boolean zoom(MotionEvent event)
{
if (!control.getMainFrame().isTouchZoom())
{
protected boolean zoom(MotionEvent event) {
if (!control.getMainFrame().isTouchZoom()) {
return true;
}
float zoom = ((Float)control.getActionValue(EventConstant.APP_ZOOM_ID, null)).floatValue();
float fitZoom = ((Float)control.getActionValue(EventConstant.APP_FIT_ZOOM_ID, null)).floatValue();
boolean isMinZoom = (int)(zoom * MainConstant.STANDARD_RATE) == (int)(fitZoom * MainConstant.STANDARD_RATE);
float zoom = ((Float) control.getActionValue(EventConstant.APP_ZOOM_ID, null)).floatValue();
float fitZoom = ((Float) control.getActionValue(EventConstant.APP_FIT_ZOOM_ID, null)).floatValue();
boolean isMinZoom = (int) (zoom * MainConstant.STANDARD_RATE) == (int) (fitZoom * MainConstant.STANDARD_RATE);
boolean zoomRateChanged = false;
float dist = distance;
int action = event.getActionMasked();
switch(action)
{
switch (action) {
case MotionEvent.ACTION_POINTER_1_DOWN:
float x1 = event.getX(0);
float y1= event.getY(0);
float y1 = event.getY(0);
float x2 = event.getX(1);
float y2= event.getY(1);
float y2 = event.getY(1);
float min = Math.min(x1, x2);
midXDoublePoint = (int)(min + Math.abs(x1 - x2) / 2);
midXDoublePoint = (int) (min + Math.abs(x1 - x2) / 2);
min = Math.min(y1, y2);
midYDoublePoint = (int)(min + Math.abs(y1 - y2) / 2);
midYDoublePoint = (int) (min + Math.abs(y1 - y2) / 2);
distance = (float)(Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)) / 2);
distance = (float) (Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)) / 2);
break;
case MotionEvent.ACTION_POINTER_1_UP:
//zoomRateChanged = true;
......@@ -254,22 +228,19 @@ public abstract class AEventManage implements OnTouchListener,
}
//zoom rate changed, update view
if(zoomRateChanged)
{
if (zoomRateChanged) {
isScroll = true;
zoomChange = true;
control.actionEvent(EventConstant.APP_ZOOM_ID, new int[]{(int)(zoom * MainConstant.STANDARD_RATE), midXDoublePoint, midYDoublePoint});
control.actionEvent(EventConstant.APP_ZOOM_ID, new int[]{(int) (zoom * MainConstant.STANDARD_RATE), midXDoublePoint, midYDoublePoint});
control.getView().postInvalidate();
// 提示
if(control.getMainFrame().isShowZoomingMsg())
{
if(control.getApplicationType() == MainConstant.APPLICATION_TYPE_PPT
&& control.isSlideShow())
{
if (control.getMainFrame().isShowZoomingMsg()) {
if (control.getApplicationType() == MainConstant.APPLICATION_TYPE_PPT
&& control.isSlideShow()) {
return true;
}
toast.setText((int)Math.round(zoom * 100) + "%");
toast.setText((int) Math.round(zoom * 100) + "%");
toast.show();
}
}
......@@ -279,106 +250,85 @@ public abstract class AEventManage implements OnTouchListener,
/**
*
*/
public boolean onDown(MotionEvent e)
{
public boolean onDown(MotionEvent e) {
Log.e("AEventManage", "onDown");
return control.getMainFrame().onEventMethod(control.getView(), e, null, -1.0f, -1.0f, IMainFrame.ON_DOWN);
}
/**
*
*
*/
public void onShowPress(MotionEvent e)
{
public void onShowPress(MotionEvent e) {
control.getMainFrame().onEventMethod(control.getView(), e, null, -1.0f, -1.0f, IMainFrame.ON_SHOW_PRESS);
}
/**
*
*
*/
public boolean onSingleTapUp(MotionEvent e)
{
if(!isScroll)
{
public boolean onSingleTapUp(MotionEvent e) {
if (!isScroll) {
singleTabup = true;
}
return control.getMainFrame().onEventMethod(control.getView(), e, null, -1.0f, -1.0f, IMainFrame.ON_SINGLE_TAP_UP);
}
/**
*
*
*/
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY)
{
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
isScroll = true;
return control.getMainFrame().onEventMethod(control.getView(), e1, e2, distanceX, distanceY, IMainFrame.ON_SCROLL);
}
/**
*
*
*/
public void onLongPress(MotionEvent e)
{
public void onLongPress(MotionEvent e) {
control.getMainFrame().onEventMethod(control.getView(), e, null, -1.0f, -1.0f, IMainFrame.ON_LONG_PRESS);
}
/**
*
*
*/
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY)
{
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
return control.getMainFrame().onEventMethod(control.getView(), e1, e2, velocityX, velocityY, IMainFrame.ON_FLING);
}
/**
*
*
*/
public boolean onSingleTapConfirmed(MotionEvent e)
{
public boolean onSingleTapConfirmed(MotionEvent e) {
return control.getMainFrame().onEventMethod(control.getView(), e, null, -1.0f, -1.0f, IMainFrame.ON_SINGLE_TAP_CONFIRMED);
}
/**
*
*
*/
public boolean onDoubleTap(MotionEvent e)
{
public boolean onDoubleTap(MotionEvent e) {
return control.getMainFrame().onEventMethod(control.getView(), e, null, -1.0f, -1.0f, IMainFrame.ON_DOUBLE_TAP);
}
/**
*
*
*/
public boolean onDoubleTapEvent(MotionEvent e)
{
public boolean onDoubleTapEvent(MotionEvent e) {
return control.getMainFrame().onEventMethod(control.getView(), e, null, -1.0f, -1.0f, IMainFrame.ON_DOUBLE_TAP_EVENT);
}
/**
*
*
*/
public void onClick(View v)
{
public void onClick(View v) {
Log.e("AEventManage", "onClick");
control.getMainFrame().onEventMethod(control.getView(), null, null, -1.0f, -1.0f, IMainFrame.ON_CLICK);
}
/**
*
*
*/
public void computeScroll()
{
if (isFling && mScroller.isFinished())
{
public void computeScroll() {
if (isFling && mScroller.isFinished()) {
isFling = false;
control.actionEvent(EventConstant.APP_GENERATED_PICTURE_ID, null);
control.actionEvent(EventConstant.SYS_UPDATE_TOOLSBAR_BUTTON_STATUS, null);
......@@ -391,17 +341,14 @@ public abstract class AEventManage implements OnTouchListener,
* @param velocityX X方向速率
* @param velocityY Y方向速率
*/
public void fling(int velocityX, int velocityY)
{
public void fling(int velocityX, int velocityY) {
}
/**
*
*/
public void stopFling()
{
if (mScroller != null && !mScroller.isFinished())
{
public void stopFling() {
if (mScroller != null && !mScroller.isFinished()) {
isFling = true;
mScroller.abortAnimation();
}
......@@ -410,30 +357,26 @@ public abstract class AEventManage implements OnTouchListener,
/**
* get middle X axis of double point
*/
public int getMiddleXOfDoublePoint()
{
public int getMiddleXOfDoublePoint() {
return this.midXDoublePoint;
}
/**
* get middle Y axis of double point
*/
public int getMiddleYOfDoublePoint()
{
public int getMiddleYOfDoublePoint() {
return this.midYDoublePoint;
}
/**
*
*/
public void dispose()
{
public void dispose() {
control = null;
gesture = null;
mVelocityTracker = null;
toast = null;
if (mScroller != null && !mScroller.isFinished())
{
if (mScroller != null && !mScroller.isFinished()) {
mScroller.abortAnimation();
}
mScroller = null;
......
......@@ -32,6 +32,7 @@ import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
......@@ -53,23 +54,18 @@ import android.widget.FrameLayout;
* <p>
* <p>
*/
public class PrintWord extends FrameLayout implements IPageListViewListener
{
public class PrintWord extends FrameLayout implements IPageListViewListener {
/**
*
* @param context
*/
public PrintWord(Context context)
{
public PrintWord(Context context) {
super(context);
}
/**
*
*
*/
public PrintWord(Context context, IControl control, PageRoot pageRoot)
{
public PrintWord(Context context, IControl control, PageRoot pageRoot) {
super(context);
this.control = control;
this.pageRoot = pageRoot;
......@@ -86,37 +82,29 @@ public class PrintWord extends FrameLayout implements IPageListViewListener
/**
*
*/
public void setBackgroundColor(int color)
{
public void setBackgroundColor(int color) {
super.setBackgroundColor(color);
if (listView != null)
{
if (listView != null) {
listView.setBackgroundColor(color);
}
}
/**
*
*
*/
public void setBackgroundResource(int resid)
{
public void setBackgroundResource(int resid) {
super.setBackgroundResource(resid);
if (listView != null)
{
if (listView != null) {
listView.setBackgroundResource(resid);
}
}
/**
*
*
*/
public void setBackgroundDrawable(Drawable d)
{
public void setBackgroundDrawable(Drawable d) {
super.setBackgroundDrawable(d);
if (listView != null)
{
if (listView != null) {
listView.setBackgroundDrawable(d);
}
}
......@@ -124,41 +112,35 @@ public class PrintWord extends FrameLayout implements IPageListViewListener
/**
*
*/
public void setVisibility(int visibility)
{
public void setVisibility(int visibility) {
super.setVisibility(visibility);
if (visibility == VISIBLE);
if (visibility == VISIBLE) ;
{
exportImage(listView.getCurrentPageView(), null);
}
}
/**
* (non-Javadoc)
*
*(non-Javadoc)
* @see android.view.ViewGroup#dispatchDraw(android.graphics.Canvas)
*
*/
protected void dispatchDraw(Canvas canvas)
{
protected void dispatchDraw(Canvas canvas) {
super.dispatchDraw(canvas);
drawPageNubmer(canvas);
}
/**
*
*
*/
public void init()
{
public void init() {
}
/**
*
*
*/
public void setZoom(float zoom, int pointX, int pointY)
{
public void setZoom(float zoom, int pointX, int pointY) {
listView.setZoom(zoom, pointX, pointY);
}
......@@ -170,8 +152,7 @@ public class PrintWord extends FrameLayout implements IPageListViewListener
* = 1, fit size of pageWidth
* = 2, fit size of PageHeight
*/
public void setFitSize(int value)
{
public void setFitSize(int value) {
listView.setFitSize(value);
}
......@@ -184,24 +165,21 @@ public class PrintWord extends FrameLayout implements IPageListViewListener
* = 2, left/right alignment
* = 3, left/right and top/bottom alignment
*/
public int getFitSizeState()
{
public int getFitSizeState() {
return listView.getFitSizeState();
}
/**
*
*/
public float getZoom()
{
public float getZoom() {
return listView.getZoom();
}
/**
*
*/
public float getFitZoom()
{
public float getFitZoom() {
return listView.getFitZoom();
}
......@@ -210,32 +188,28 @@ public class PrintWord extends FrameLayout implements IPageListViewListener
*
* @return page number (base 1)
*/
public int getCurrentPageNumber()
{
public int getCurrentPageNumber() {
return listView.getCurrentPageNumber();
}
/**
*
*/
public APageListView getListView()
{
public APageListView getListView() {
return this.listView;
}
/**
*
*/
public void nextPageView()
{
public void nextPageView() {
listView.nextPageView();
}
/**
*
*/
public void previousPageview()
{
public void previousPageview() {
listView.previousPageview();
}
......@@ -244,8 +218,7 @@ public class PrintWord extends FrameLayout implements IPageListViewListener
*
* @param index
*/
public void showPDFPageForIndex(int index)
{
public void showPDFPageForIndex(int index) {
listView.showPDFPageForIndex(index);
}
......@@ -253,11 +226,9 @@ public class PrintWord extends FrameLayout implements IPageListViewListener
* @param x 为100%的值
* @param y 为100%的值
*/
public long viewToModel(int x, int y, boolean isBack)
{
public long viewToModel(int x, int y, boolean isBack) {
int pageIndex = listView.getCurrentPageNumber() - 1;
if (pageIndex < 0 || pageIndex >= getPageCount())
{
if (pageIndex < 0 || pageIndex >= getPageCount()) {
return 0;
}
return pageRoot.viewToModel(x, y, isBack);
......@@ -266,11 +237,9 @@ public class PrintWord extends FrameLayout implements IPageListViewListener
/**
*
*/
public Rectangle modelToView(long offset, Rectangle rect, boolean isBack)
{
public Rectangle modelToView(long offset, Rectangle rect, boolean isBack) {
int pageIndex = listView.getCurrentPageNumber() - 1;
if (pageIndex < 0 || pageIndex >= getPageCount())
{
if (pageIndex < 0 || pageIndex >= getPageCount()) {
return rect;
}
return pageRoot.modelToView(offset, rect, isBack);
......@@ -279,16 +248,14 @@ public class PrintWord extends FrameLayout implements IPageListViewListener
/**
*
*/
public int getPageCount()
{
public int getPageCount() {
return Math.max(pageRoot.getChildCount(), 1);
}
/**
*
*/
public APageListItem getPageListItem(int position, View convertView, ViewGroup parent)
{
public APageListItem getPageListItem(int position, View convertView, ViewGroup parent) {
Rect rect = getPageSize(position);
return new WPPageListItem(listView, control, rect.width(), rect.height());
}
......@@ -296,87 +263,69 @@ public class PrintWord extends FrameLayout implements IPageListViewListener
/**
*
*/
public Rect getPageSize(int pageIndex)
{
public Rect getPageSize(int pageIndex) {
PageView view = pageRoot.getPageView(pageIndex);
if (view != null)
{
if (view != null) {
pageSize.set(0, 0, view.getWidth(), view.getHeight());
}
else
{
} else {
IAttributeSet attr = pageRoot.getDocument().getSection(0).getAttribute();
int pageWidth = (int)(AttrManage.instance().getPageWidth(attr) * MainConstant.TWIPS_TO_PIXEL);
int pageHeight = (int)(AttrManage.instance().getPageHeight(attr) * MainConstant.TWIPS_TO_PIXEL);
int pageWidth = (int) (AttrManage.instance().getPageWidth(attr) * MainConstant.TWIPS_TO_PIXEL);
int pageHeight = (int) (AttrManage.instance().getPageHeight(attr) * MainConstant.TWIPS_TO_PIXEL);
pageSize.set(0, 0, pageWidth, pageHeight);
}
return pageSize;
}
/**
*
*
*/
public void exportImage(final APageListItem pageItem, final Bitmap srcBitmap)
{
if (getControl() == null || !(getParent() instanceof Word))
{
public void exportImage(final APageListItem pageItem, final Bitmap srcBitmap) {
if (getControl() == null || !(getParent() instanceof Word)) {
return;
}
WPFind find = (WPFind)control.getFind();
if (find.isSetPointToVisible())
{
WPFind find = (WPFind) control.getFind();
if (find.isSetPointToVisible()) {
find.setSetPointToVisible(false);
PageView pv = pageRoot.getPageView(pageItem.getPageIndex());
if (pv == null)
{
if (pv == null) {
return;
}
Rectangle rect = modelToView(((Word)getParent()).getHighlight().getSelectStart(), new Rectangle(), false);
Rectangle rect = modelToView(((Word) getParent()).getHighlight().getSelectStart(), new Rectangle(), false);
rect.x -= pv.getX();
rect.y -= pv.getY();
if (!listView.isPointVisibleOnScreen(rect.x, rect.y))
{
if (!listView.isPointVisibleOnScreen(rect.x, rect.y)) {
listView.setItemPointVisibleOnScreen(rect.x, rect.y);
return;
}
}
post(new Runnable()
{
@ Override
public void run()
{
try
{
post(new Runnable() {
@Override
public void run() {
try {
IOfficeToPicture otp = getControl().getOfficeToPicture();
if (otp != null && otp.getModeType() == IOfficeToPicture.VIEW_CHANGE_END)
{
if (otp != null && otp.getModeType() == IOfficeToPicture.VIEW_CHANGE_END) {
int rW = Math.min(getWidth(), pageItem.getWidth());
int rH = Math.min(getHeight(), pageItem.getHeight());
Bitmap dstBitmap = otp.getBitmap(rW, rH);
if (dstBitmap == null)
{
if (dstBitmap == null) {
return;
}
if (getParent() instanceof Word)
{
((Word)getParent()).getHighlight().setPaintHighlight(false);
if (getParent() instanceof Word) {
((Word) getParent()).getHighlight().setPaintHighlight(false);
}
// don't zoom
if (dstBitmap.getWidth() == rW && dstBitmap.getHeight() == rH)
{
if (dstBitmap.getWidth() == rW && dstBitmap.getHeight() == rH) {
Canvas canvas = new Canvas(dstBitmap);
canvas.drawColor(Color.WHITE);
float zoom = listView.getZoom();
PageView pv = pageRoot.getPageView(pageItem.getPageIndex());
if (pv != null)
{
if (pv != null) {
canvas.save();
canvas.translate(-pv.getX() * zoom, -pv.getY() * zoom);
int left = (int)(pageItem.getLeft());
int top = (int)(pageItem.getTop());
int left = (int) (pageItem.getLeft());
int top = (int) (pageItem.getTop());
pv.drawForPrintMode(canvas, -(Math.max(left, 0) - left), -(Math.max(top, 0) - top), zoom);
canvas.restore();
canvas.translate(-(Math.max(left, 0) - left), -(Math.max(top, 0) - top));
......@@ -384,15 +333,13 @@ public class PrintWord extends FrameLayout implements IPageListViewListener
}
}
// zoom
else
{
else {
PageView pv = pageRoot.getPageView(pageItem.getPageIndex());
if (pv != null)
{
float paintZoom = Math.min(dstBitmap.getWidth() / (float)rW, dstBitmap.getHeight() / (float)rH);
if (pv != null) {
float paintZoom = Math.min(dstBitmap.getWidth() / (float) rW, dstBitmap.getHeight() / (float) rH);
float zoom = listView.getZoom() * paintZoom;
int left = (int)(pageItem.getLeft() * paintZoom);
int top = (int)(pageItem.getTop() * paintZoom);
int left = (int) (pageItem.getLeft() * paintZoom);
int top = (int) (pageItem.getTop() * paintZoom);
Canvas canvas = new Canvas(dstBitmap);
canvas.save();
canvas.drawColor(Color.WHITE);
......@@ -403,15 +350,12 @@ public class PrintWord extends FrameLayout implements IPageListViewListener
control.getSysKit().getCalloutManager().drawPath(canvas, pageItem.getPageIndex(), zoom);
}
}
if (getParent() instanceof Word)
{
((Word)getParent()).getHighlight().setPaintHighlight(true);
if (getParent() instanceof Word) {
((Word) getParent()).getHighlight().setPaintHighlight(true);
}
otp.callBack(dstBitmap);
}
}
catch (Exception e)
{
} catch (Exception e) {
}
}
});
......@@ -419,58 +363,49 @@ public class PrintWord extends FrameLayout implements IPageListViewListener
}
/**
*
* @param dstBitmap
* @return
*/
public Bitmap getSnapshot(Bitmap dstBitmap)
{
public Bitmap getSnapshot(Bitmap dstBitmap) {
APageListItem pageItem = getListView().getCurrentPageView();
if(pageItem == null)
{
if (pageItem == null) {
return null;
}
int rW = Math.min(getWidth(), pageItem.getWidth());
int rH = Math.min(getHeight(), pageItem.getHeight());
if (getParent() instanceof Word)
{
((Word)getParent()).getHighlight().setPaintHighlight(false);
if (getParent() instanceof Word) {
((Word) getParent()).getHighlight().setPaintHighlight(false);
}
// don't zoom
if (dstBitmap.getWidth() == rW && dstBitmap.getHeight() == rH)
{
if (dstBitmap.getWidth() == rW && dstBitmap.getHeight() == rH) {
Canvas canvas = new Canvas(dstBitmap);
canvas.drawColor(Color.WHITE);
float zoom = listView.getZoom();
PageView pv = pageRoot.getPageView(pageItem.getPageIndex());
if (pv != null)
{
if (pv != null) {
canvas.translate(-pv.getX() * zoom, -pv.getY() * zoom);
int left = (int)(pageItem.getLeft());
int top = (int)(pageItem.getTop());
int left = (int) (pageItem.getLeft());
int top = (int) (pageItem.getTop());
pv.drawForPrintMode(canvas, -(Math.max(left, 0) - left), -(Math.max(top, 0) - top), zoom);
}
}
// zoom
else
{
else {
PageView pv = pageRoot.getPageView(pageItem.getPageIndex());
if (pv != null)
{
float paintZoom = Math.min(dstBitmap.getWidth() / (float)rW, dstBitmap.getHeight() / (float)rH);
if (pv != null) {
float paintZoom = Math.min(dstBitmap.getWidth() / (float) rW, dstBitmap.getHeight() / (float) rH);
float zoom = listView.getZoom() * paintZoom;
int left = (int)(pageItem.getLeft() * paintZoom);
int top = (int)(pageItem.getTop() * paintZoom);
int left = (int) (pageItem.getLeft() * paintZoom);
int top = (int) (pageItem.getTop() * paintZoom);
Canvas canvas = new Canvas(dstBitmap);
canvas.drawColor(Color.WHITE);
canvas.translate(-pv.getX() * zoom, -pv.getY() * zoom);
pv.drawForPrintMode(canvas, -(Math.max(left, 0) - left), -(Math.max(top, 0) - top), zoom);
}
}
if (getParent() instanceof Word)
{
((Word)getParent()).getHighlight().setPaintHighlight(true);
if (getParent() instanceof Word) {
((Word) getParent()).getHighlight().setPaintHighlight(true);
}
return dstBitmap;
......@@ -478,47 +413,38 @@ public class PrintWord extends FrameLayout implements IPageListViewListener
/**
*
*
*/
public boolean isInit()
{
public boolean isInit() {
return true;
}
/**
*
* @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()
{
public boolean isIgnoreOriginalSize() {
return control.getMainFrame().isIgnoreOriginalSize();
}
/**
* page list view moving position
* @param position horizontal or vertical
*/
public int getPageListViewMovingPosition()
{
public int getPageListViewMovingPosition() {
return control.getMainFrame().getPageListViewMovingPosition();
}
/**
*
*/
public Object getModel()
{
public Object getModel() {
return pageRoot;
}
/**
*
*/
public IControl getControl()
{
public IControl getControl() {
return this.control;
}
......@@ -530,7 +456,6 @@ public class PrintWord extends FrameLayout implements IPageListViewListener
* @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
......@@ -543,32 +468,24 @@ public class PrintWord extends FrameLayout implements IPageListViewListener
* @see TouchEventListener#EVENT_SINGLE_TAP_UP
* @see TouchEventListener#EVENT_TOUCH
*/
public boolean onEventMethod(View v, MotionEvent e1, MotionEvent e2, float velocityX, float velocityY, byte eventMethodType)
{
public boolean onEventMethod(View v, MotionEvent e1, MotionEvent e2, float velocityX, float velocityY, byte eventMethodType) {
if (eventMethodType == ON_SINGLE_TAP_UP && e1 != null
&& e1.getAction() == MotionEvent.ACTION_UP)
{
&& e1.getAction() == MotionEvent.ACTION_UP) {
APageListItem item = listView.getCurrentPageView();
if (item != null)
{
if (item != null) {
PageView pv = pageRoot.getPageView(item.getPageIndex());
if (pv != null)
{
if (pv != null) {
float zoom = listView.getZoom();
int x = (int)((e1.getX() - item.getLeft()) / zoom) + pv.getX();
int y = (int)((e1.getY() - item.getTop()) / zoom) + pv.getY();
int x = (int) ((e1.getX() - item.getLeft()) / zoom) + pv.getX();
int y = (int) ((e1.getY() - item.getTop()) / zoom) + pv.getY();
long offset = pv.viewToModel(x, y, false);
if (offset >= 0)
{
if (offset >= 0) {
IElement leaf = pv.getDocument().getLeaf(offset);
if (leaf != null)
{
if (leaf != null) {
int hyID = AttrManage.instance().getHperlinkID(leaf.getAttribute());
if (hyID >= 0)
{
if (hyID >= 0) {
Hyperlink hylink = control.getSysKit().getHyperlinkManage().getHyperlink(hyID);
if (hylink != null)
{
if (hylink != null) {
control.actionEvent(EventConstant.APP_HYPERLINK, hylink);
}
}
......@@ -581,25 +498,19 @@ public class PrintWord extends FrameLayout implements IPageListViewListener
}
/**
*
*
*/
public void updateStutus(Object obj)
{
public void updateStutus(Object obj) {
control.actionEvent(EventConstant.SYS_UPDATE_TOOLSBAR_BUTTON_STATUS, obj);
}
/**
*
*
*/
public void resetSearchResult(APageListItem pageItem)
{
if (getParent() instanceof Word)
{
Word word = (Word)getParent();
if (word.getFind().getPageIndex() != pageItem.getPageIndex())
{
public void resetSearchResult(APageListItem pageItem) {
if (getParent() instanceof Word) {
Word word = (Word) getParent();
if (word.getFind().getPageIndex() != pageItem.getPageIndex()) {
word.getHighlight().removeHighlight();
}
}
......@@ -608,44 +519,37 @@ public class PrintWord extends FrameLayout implements IPageListViewListener
/**
*
*/
public boolean isTouchZoom()
{
public boolean isTouchZoom() {
return control.getMainFrame().isTouchZoom();
}
/**
*
*/
public boolean isShowZoomingMsg()
{
public boolean isShowZoomingMsg() {
return control.getMainFrame().isShowZoomingMsg();
}
/**
*
*/
public void changeZoom()
{
public void changeZoom() {
control.getMainFrame().changeZoom();
}
/**
* @param isDrawPictrue The isDrawPictrue to set.
*/
public void setDrawPictrue(boolean isDrawPictrue)
{
public void setDrawPictrue(boolean isDrawPictrue) {
PictureKit.instance().setDrawPictrue(isDrawPictrue);
}
/**
*
* @return
*/
public PageView getCurrentPageView()
{
public PageView getCurrentPageView() {
APageListItem item = listView.getCurrentPageView();
if (item != null)
{
if (item != null) {
return pageRoot.getPageView(item.getPageIndex());
}
return null;
......@@ -653,21 +557,22 @@ public class PrintWord extends FrameLayout implements IPageListViewListener
/**
* 绘制页信息
*
* @param canvas
* @param zoom
*/
private void drawPageNubmer(Canvas canvas)
{
if (control.getMainFrame().isDrawPageNumber())
{
private void drawPageNubmer(Canvas canvas) {
Log.e("PrintWord", "drawPageNubmer");
if (control.getMainFrame().isDrawPageNumber()) {
String pn = String.valueOf((listView.getCurrentPageNumber()) + " / " + pageRoot.getChildCount());
int w = (int)paint.measureText(pn);
int h = (int)(paint.descent() - paint.ascent());
int x = (int)((getWidth() - w) / 2);
int y = (int)((getHeight() - h) - 50);
int w = (int) paint.measureText(pn);
int h = (int) (paint.descent() - paint.ascent());
int x = (int) ((getWidth() - w) / 2);
int y = (int) ((getHeight() - h) - 50);
Drawable drawable = SysKit.getPageNubmerDrawable();
drawable.setBounds((int)(x - 20), y - 10, x + w + 20, y + h + 10);
drawable.setBounds((int) (x - 20), y - 10, x + w + 20, y + h + 10);
drawable.draw(canvas);
y -= paint.ascent();
......@@ -675,8 +580,7 @@ public class PrintWord extends FrameLayout implements IPageListViewListener
}
if (preShowPageIndex != listView.getCurrentPageNumber()
|| prePageCount != getPageCount())
{
|| prePageCount != getPageCount()) {
changePage();
preShowPageIndex = listView.getCurrentPageNumber();
prePageCount = getPageCount();
......@@ -686,31 +590,24 @@ public class PrintWord extends FrameLayout implements IPageListViewListener
/**
*
*/
public void changePage()
{
public void changePage() {
control.getMainFrame().changePage();
}
/**
* 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
*/
public boolean isChangePage()
{
public boolean isChangePage() {
return control.getMainFrame().isChangePage();
}
/**
*
*/
public void dispose()
{
public void dispose() {
control = null;
if (listView != null)
{
if (listView != null) {
listView.dispose();
}
pageRoot = 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