Commit 876ba615 authored by wanglei's avatar wanglei

...

parent c0a7d9d7
...@@ -7,14 +7,19 @@ import android.content.pm.ActivityInfo ...@@ -7,14 +7,19 @@ import android.content.pm.ActivityInfo
import android.view.View import android.view.View
import android.view.animation.Animation import android.view.animation.Animation
import android.view.animation.TranslateAnimation import android.view.animation.TranslateAnimation
import android.view.inputmethod.EditorInfo
import androidx.activity.addCallback import androidx.activity.addCallback
import androidx.core.widget.addTextChangedListener
import com.base.pdfviewerscannerwhite.bean.DocumentBean import com.base.pdfviewerscannerwhite.bean.DocumentBean
import com.base.pdfviewerscannerwhite.databinding.ActivityExcelBinding import com.base.pdfviewerscannerwhite.databinding.ActivityExcelBinding
import com.base.pdfviewerscannerwhite.helper.BaseActivity import com.base.pdfviewerscannerwhite.helper.BaseActivity
import com.base.pdfviewerscannerwhite.ui.view.DialogView.showDocumentMore import com.base.pdfviewerscannerwhite.ui.view.DialogView.showDocumentMore
import com.base.pdfviewerscannerwhite.utils.KeyBoardUtils.hideKeyboard import com.base.pdfviewerscannerwhite.utils.KeyBoardUtils.hideKeyboard
import com.base.pdfviewerscannerwhite.utils.KeyBoardUtils.showKeyBoard
import com.base.pdfviewerscannerwhite.utils.LogEx import com.base.pdfviewerscannerwhite.utils.LogEx
import com.cherry.lib.doc.bean.DocEngine import com.cherry.lib.doc.bean.DocEngine
import com.cherry.lib.doc.office.ss.control.SSControl
import com.cherry.lib.doc.office.ss.control.Spreadsheet
import com.cherry.lib.doc.util.Constant import com.cherry.lib.doc.util.Constant
import java.io.File import java.io.File
...@@ -27,7 +32,7 @@ class ExcelActivity : BaseActivity<ActivityExcelBinding>() { ...@@ -27,7 +32,7 @@ class ExcelActivity : BaseActivity<ActivityExcelBinding>() {
} }
companion object { companion object {
var excelDocumentBean:DocumentBean = DocumentBean() var excelDocumentBean: DocumentBean = DocumentBean()
fun launchDocViewer( fun launchDocViewer(
activity: Activity, activity: Activity,
docSourceType: Int, docSourceType: Int,
...@@ -57,6 +62,10 @@ class ExcelActivity : BaseActivity<ActivityExcelBinding>() { ...@@ -57,6 +62,10 @@ class ExcelActivity : BaseActivity<ActivityExcelBinding>() {
super.initListener() super.initListener()
onBackPressedDispatcher.addCallback { onBackPressedDispatcher.addCallback {
if (isSearchUI) {
cancelSearchUI()
return@addCallback
}
finishToMain() finishToMain()
} }
binding.flFanhui.setOnClickListener { binding.flFanhui.setOnClickListener {
...@@ -74,19 +83,63 @@ class ExcelActivity : BaseActivity<ActivityExcelBinding>() { ...@@ -74,19 +83,63 @@ class ExcelActivity : BaseActivity<ActivityExcelBinding>() {
if (isShowTopLayout) { if (isShowTopLayout) {
LogEx.logDebug(TAG, "hide") LogEx.logDebug(TAG, "hide")
hideTopLayout() hideTopLayout()
hideBottomLayout()
} else { } else {
showTopLayout() showTopLayout()
showBottomLayout()
LogEx.logDebug(TAG, "show") LogEx.logDebug(TAG, "show")
} }
} }
// lifecycleScope.launch { binding.ivSearch.setOnClickListener {
// delay(5000) showSearchUI()
// val ssControl = binding.mDocView.iOffice?.control?.appControl as SSControl }
// toast("转换") binding.editSearch.addTextChangedListener {
// binding.mDocView.iOffice?.control?.sysKit binding.mDocView.visibility = View.VISIBLE
// } haveSearchResult = false
hideBottomLayout()
getSpreadsheet().resetSearchResult()
}
binding.editSearch.setOnEditorActionListener { v, actionId, event ->
if (actionId == EditorInfo.IME_ACTION_DONE) {
// Perform your action here
searchExcel()
return@setOnEditorActionListener true
}
false
}
binding.flPre.setOnClickListener {
getSpreadsheet().findBackward()
}
binding.flNext.setOnClickListener {
getSpreadsheet().findForward()
}
}
private fun getSpreadsheet(): Spreadsheet {
val ssControl: SSControl = (binding.mDocView.iOffice?.control?.appControl as SSControl)
return (ssControl.find as Spreadsheet)
}
private fun searchExcel() {
val text = binding.editSearch.text
if (text.isNullOrEmpty()) {
return
}
val flag = getSpreadsheet().find(text.toString())
haveSearchResult = flag
if (flag) {
hideKeyboard(binding.editSearch)
showBottomLayout()
} else {
binding.mDocView.visibility = View.GONE
}
} }
private var haveSearchResult: Boolean = false
private fun switchOrientation() { private fun switchOrientation() {
requestedOrientation = if (requestedOrientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) { requestedOrientation = if (requestedOrientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) {
ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
...@@ -96,6 +149,7 @@ class ExcelActivity : BaseActivity<ActivityExcelBinding>() { ...@@ -96,6 +149,7 @@ class ExcelActivity : BaseActivity<ActivityExcelBinding>() {
} }
private var isShowTopLayout = true private var isShowTopLayout = true
private var isSearchUI: Boolean = false
private fun showTopLayout() { private fun showTopLayout() {
if (!isShowTopLayout) { if (!isShowTopLayout) {
isShowTopLayout = true isShowTopLayout = true
...@@ -115,6 +169,25 @@ class ExcelActivity : BaseActivity<ActivityExcelBinding>() { ...@@ -115,6 +169,25 @@ class ExcelActivity : BaseActivity<ActivityExcelBinding>() {
} }
} }
private fun showBottomLayout() {
if (isSearchUI && haveSearchResult) {
val bottomAnim: Animation = TranslateAnimation(0f, 0f, binding.vAnimatorBottom.height.toFloat(), 0f)
bottomAnim.duration = 200
bottomAnim.setAnimationListener(object : Animation.AnimationListener {
override fun onAnimationStart(animation: Animation) {
binding.vAnimatorBottom.visibility = View.VISIBLE
}
override fun onAnimationRepeat(animation: Animation) {}
override fun onAnimationEnd(animation: Animation) {
}
})
binding.vAnimatorBottom.startAnimation(bottomAnim)
}
}
private fun hideTopLayout() { private fun hideTopLayout() {
if (isShowTopLayout) { if (isShowTopLayout) {
isShowTopLayout = false isShowTopLayout = false
...@@ -133,6 +206,41 @@ class ExcelActivity : BaseActivity<ActivityExcelBinding>() { ...@@ -133,6 +206,41 @@ class ExcelActivity : BaseActivity<ActivityExcelBinding>() {
} }
} }
private fun hideBottomLayout() {
if (isSearchUI) {
val bottomAnim: Animation = TranslateAnimation(0f, 0f, 0f, binding.vAnimatorBottom.height.toFloat())
bottomAnim.duration = 200
bottomAnim.setAnimationListener(object : Animation.AnimationListener {
override fun onAnimationStart(animation: Animation) {}
override fun onAnimationRepeat(animation: Animation) {}
override fun onAnimationEnd(animation: Animation) {
binding.vAnimatorBottom.visibility = View.GONE
}
})
binding.vAnimatorBottom.startAnimation(bottomAnim)
}
}
private fun showSearchUI() {
isSearchUI = true
binding.ivXuanzhuan.visibility = View.GONE
binding.ivMore.visibility = View.GONE
binding.tvName.visibility = View.INVISIBLE
binding.editSearch.visibility = View.VISIBLE
showKeyBoard(binding.editSearch)
}
private fun cancelSearchUI() {
hideBottomLayout()
isSearchUI = false
binding.editSearch.visibility = View.GONE
binding.ivXuanzhuan.visibility = View.VISIBLE
binding.ivMore.visibility = View.VISIBLE
binding.tvName.visibility = View.VISIBLE
binding.mDocView.visibility = View.VISIBLE
hideKeyboard(binding.editSearch)
}
private var docSourceType = 0 private var docSourceType = 0
private var fileType = -1 private var fileType = -1
private var engine: Int = DocEngine.INTERNAL.value private var engine: Int = DocEngine.INTERNAL.value
......
...@@ -116,7 +116,6 @@ class WordActivity : BaseActivity<ActivityWordBinding>() { ...@@ -116,7 +116,6 @@ class WordActivity : BaseActivity<ActivityWordBinding>() {
binding.flPre.setOnClickListener { binding.flPre.setOnClickListener {
val wpControl: WPControl = (binding.mDocView.iOffice?.control?.appControl as WPControl) val wpControl: WPControl = (binding.mDocView.iOffice?.control?.appControl as WPControl)
(wpControl.find as WPFind).findBackward() (wpControl.find as WPFind).findBackward()
hideBottomLayout()
} }
binding.flNext.setOnClickListener { binding.flNext.setOnClickListener {
val wpControl: WPControl = (binding.mDocView.iOffice?.control?.appControl as WPControl) val wpControl: WPControl = (binding.mDocView.iOffice?.control?.appControl as WPControl)
...@@ -154,6 +153,7 @@ class WordActivity : BaseActivity<ActivityWordBinding>() { ...@@ -154,6 +153,7 @@ class WordActivity : BaseActivity<ActivityWordBinding>() {
} }
private fun cancelSearchUI() { private fun cancelSearchUI() {
hideBottomLayout()
isSearchUI = false isSearchUI = false
binding.editSearch.visibility = View.GONE binding.editSearch.visibility = View.GONE
binding.ivXuanzhuan.visibility = View.VISIBLE binding.ivXuanzhuan.visibility = View.VISIBLE
...@@ -161,6 +161,7 @@ class WordActivity : BaseActivity<ActivityWordBinding>() { ...@@ -161,6 +161,7 @@ class WordActivity : BaseActivity<ActivityWordBinding>() {
binding.tvName.visibility = View.VISIBLE binding.tvName.visibility = View.VISIBLE
binding.mDocView.visibility = View.VISIBLE binding.mDocView.visibility = View.VISIBLE
binding.tvPageCount.visibility = View.VISIBLE binding.tvPageCount.visibility = View.VISIBLE
hideKeyboard(binding.editSearch)
} }
private fun switchOrientation() { private fun switchOrientation() {
......
...@@ -85,7 +85,7 @@ class DocumentFragment() : BaseFragment<FragmentDocumentBinding>(), DocumentView ...@@ -85,7 +85,7 @@ class DocumentFragment() : BaseFragment<FragmentDocumentBinding>(), DocumentView
WordActivity.launchDocViewer(requireActivity(), 3, item.path, -1, 100) WordActivity.launchDocViewer(requireActivity(), 3, item.path, -1, 100)
} }
if (type == TYPE_EXCEL) { if (type == TYPE_EXCEL) {
ExcelActivity.excelDocumentBean ExcelActivity.excelDocumentBean=item
ExcelActivity.launchDocViewer(requireActivity(), 3, item.path, -1, 100) ExcelActivity.launchDocViewer(requireActivity(), 3, item.path, -1, 100)
} }
if (type == TYPE_PPT) { if (type == TYPE_PPT) {
......
...@@ -31,6 +31,7 @@ import com.base.pdfviewerscannerwhite.ui.document.pdf.PdfBoxUtils ...@@ -31,6 +31,7 @@ import com.base.pdfviewerscannerwhite.ui.document.pdf.PdfBoxUtils
import com.base.pdfviewerscannerwhite.ui.main.DocumentView import com.base.pdfviewerscannerwhite.ui.main.DocumentView
import com.base.pdfviewerscannerwhite.ui.document.pdf.PdfView import com.base.pdfviewerscannerwhite.ui.document.pdf.PdfView
import com.base.pdfviewerscannerwhite.utils.ActivityLauncher import com.base.pdfviewerscannerwhite.utils.ActivityLauncher
import com.base.pdfviewerscannerwhite.utils.IntentShareUtils.shareExcelIntent
import com.base.pdfviewerscannerwhite.utils.IntentShareUtils.sharePdfIntent import com.base.pdfviewerscannerwhite.utils.IntentShareUtils.sharePdfIntent
import com.base.pdfviewerscannerwhite.utils.IntentShareUtils.sharePdfPrintIntent import com.base.pdfviewerscannerwhite.utils.IntentShareUtils.sharePdfPrintIntent
import com.base.pdfviewerscannerwhite.utils.IntentShareUtils.sharePptIntent import com.base.pdfviewerscannerwhite.utils.IntentShareUtils.sharePptIntent
...@@ -306,6 +307,10 @@ object DialogView { ...@@ -306,6 +307,10 @@ object DialogView {
intent = shareWordIntent(uri) intent = shareWordIntent(uri)
desc = "Share Word" desc = "Share Word"
} }
if (documentBean.type == TYPE_EXCEL) {
intent = shareExcelIntent(uri)
desc = "Share Excel"
}
intent?.let { startActivity(Intent.createChooser(it, desc)) } intent?.let { startActivity(Intent.createChooser(it, desc)) }
} }
binding.llJump.setOnClickListener { binding.llJump.setOnClickListener {
......
...@@ -35,6 +35,17 @@ object IntentShareUtils { ...@@ -35,6 +35,17 @@ object IntentShareUtils {
return shareIntent return shareIntent
} }
fun shareExcelIntent(uri: Uri): Intent {
val shareIntent = Intent().apply {
action = Intent.ACTION_SEND
putExtra(Intent.EXTRA_STREAM, uri)
type = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION) // 授权临时权限
}
return shareIntent
}
fun sharePdfPrintIntent(uri: Uri): Intent { fun sharePdfPrintIntent(uri: Uri): Intent {
// 创建打印的 Intent // 创建打印的 Intent
val intent = Intent(Intent.ACTION_SEND) val intent = Intent(Intent.ACTION_SEND)
......
...@@ -122,4 +122,54 @@ ...@@ -122,4 +122,54 @@
app:layout_constraintTop_toBottomOf="@id/v_animator_top" /> app:layout_constraintTop_toBottomOf="@id/v_animator_top" />
<ViewAnimator
android:id="@+id/v_animator_bottom"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_50"
android:layout_alignParentBottom="true"
android:background="@color/white"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:ignore="UselessParent">
<FrameLayout
android:id="@+id/fl_pre"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|start"
android:layout_marginStart="20dp"
android:padding="10dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/left"
tools:ignore="ContentDescription" />
</FrameLayout>
<FrameLayout
android:id="@+id/fl_next"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|end"
android:layout_marginEnd="20dp"
android:padding="10dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/right"
tools:ignore="ContentDescription" />
</FrameLayout>
</FrameLayout>
</ViewAnimator>
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
...@@ -104,7 +104,6 @@ ...@@ -104,7 +104,6 @@
android:ellipsize="end" android:ellipsize="end"
android:includeFontPadding="false" android:includeFontPadding="false"
android:maxLines="2" android:maxLines="2"
android:singleLine="true"
android:textColor="#9A9A9A" android:textColor="#9A9A9A"
android:textSize="14sp" android:textSize="14sp"
tools:text="/data/user/0/com.pdfviewer.scanner/files/ demo/DEMO.pdf" /> tools:text="/data/user/0/com.pdfviewer.scanner/files/ demo/DEMO.pdf" />
......
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