Commit e1d9ed3b authored by wanglei's avatar wanglei

...

parent 165acf40
...@@ -18,6 +18,7 @@ import com.base.pdfviewerscannerwhite.ui.view.DialogView.showDocumentMore ...@@ -18,6 +18,7 @@ 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.KeyBoardUtils.showKeyBoard
import com.base.pdfviewerscannerwhite.utils.LogEx import com.base.pdfviewerscannerwhite.utils.LogEx
import com.base.pdfviewerscannerwhite.utils.SpStringUtils
import com.cherry.lib.doc.bean.DocEngine import com.cherry.lib.doc.bean.DocEngine
import com.cherry.lib.doc.office.constant.EventConstant import com.cherry.lib.doc.office.constant.EventConstant
import com.cherry.lib.doc.office.ss.control.SSControl import com.cherry.lib.doc.office.ss.control.SSControl
...@@ -265,6 +266,8 @@ class ExcelActivity : BaseActivity<ActivityExcelBinding>() { ...@@ -265,6 +266,8 @@ class ExcelActivity : BaseActivity<ActivityExcelBinding>() {
LogEx.logDebug(TAG, "initData-pathOrUri = $pathOrUri") LogEx.logDebug(TAG, "initData-pathOrUri = $pathOrUri")
LogEx.logDebug(TAG, "initData-docSourceType = $docSourceType") LogEx.logDebug(TAG, "initData-docSourceType = $docSourceType")
LogEx.logDebug(TAG, "initData-fileType = $fileType") LogEx.logDebug(TAG, "initData-fileType = $fileType")
SpStringUtils.addSpString(SpStringUtils.LAST_VIEW_KEY, pathOrUri ?: "")
} }
......
...@@ -69,6 +69,7 @@ class PdfActivity : BaseActivity<ActivityPdfBinding>(), PdfView { ...@@ -69,6 +69,7 @@ class PdfActivity : BaseActivity<ActivityPdfBinding>(), PdfView {
assets = intent.extras?.getString("assets") ?: "" assets = intent.extras?.getString("assets") ?: ""
LogEx.logDebug(TAG, "path=$path") LogEx.logDebug(TAG, "path=$path")
LogEx.logDebug(TAG, "uri=$uri") LogEx.logDebug(TAG, "uri=$uri")
SpStringUtils.addSpString(LAST_VIEW_KEY, path)
val file = File(path) val file = File(path)
binding.tvPdfName.text = file.name binding.tvPdfName.text = file.name
...@@ -171,6 +172,7 @@ class PdfActivity : BaseActivity<ActivityPdfBinding>(), PdfView { ...@@ -171,6 +172,7 @@ class PdfActivity : BaseActivity<ActivityPdfBinding>(), PdfView {
} }
binding.ivWancheng.setOnClickListener { binding.ivWancheng.setOnClickListener {
changeEditSaveUI() changeEditSaveUI()
binding.mupdfReaderView.setMode(MuPDFReaderView.Mode.Viewing)
} }
binding.ivBianji.setOnClickListener { binding.ivBianji.setOnClickListener {
bianJiScaleXiao { bianJiScaleXiao {
...@@ -525,6 +527,7 @@ class PdfActivity : BaseActivity<ActivityPdfBinding>(), PdfView { ...@@ -525,6 +527,7 @@ class PdfActivity : BaseActivity<ActivityPdfBinding>(), PdfView {
binding.llGlideLine.setBackgroundColor(Color.TRANSPARENT) binding.llGlideLine.setBackgroundColor(Color.TRANSPARENT)
binding.llStrikethrough.setBackgroundColor(Color.TRANSPARENT) binding.llStrikethrough.setBackgroundColor(Color.TRANSPARENT)
binding.llPaintingBrush.setBackgroundColor(Color.TRANSPARENT) binding.llPaintingBrush.setBackgroundColor(Color.TRANSPARENT)
} }
override fun onPause() { override fun onPause() {
......
...@@ -14,6 +14,7 @@ import com.base.pdfviewerscannerwhite.databinding.ActivityPptBinding ...@@ -14,6 +14,7 @@ import com.base.pdfviewerscannerwhite.databinding.ActivityPptBinding
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.LogEx import com.base.pdfviewerscannerwhite.utils.LogEx
import com.base.pdfviewerscannerwhite.utils.SpStringUtils
import com.cherry.lib.doc.bean.DocEngine import com.cherry.lib.doc.bean.DocEngine
import com.cherry.lib.doc.office.pg.control.PGControl import com.cherry.lib.doc.office.pg.control.PGControl
import com.cherry.lib.doc.util.Constant import com.cherry.lib.doc.util.Constant
...@@ -111,6 +112,8 @@ class PptActivity : BaseActivity<ActivityPptBinding>() { ...@@ -111,6 +112,8 @@ class PptActivity : BaseActivity<ActivityPptBinding>() {
LogEx.logDebug(TAG, "initData-docUrl = $pathOrUri") LogEx.logDebug(TAG, "initData-docUrl = $pathOrUri")
LogEx.logDebug(TAG, "initData-docSourceType = $docSourceType") LogEx.logDebug(TAG, "initData-docSourceType = $docSourceType")
LogEx.logDebug(TAG, "initData-fileType = $fileType") LogEx.logDebug(TAG, "initData-fileType = $fileType")
SpStringUtils.addSpString(SpStringUtils.LAST_VIEW_KEY, pathOrUri ?: "")
} }
private fun showTopLayout() { private fun showTopLayout() {
......
...@@ -21,6 +21,7 @@ import com.base.pdfviewerscannerwhite.ui.view.DialogView.showDocumentMore ...@@ -21,6 +21,7 @@ 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.KeyBoardUtils.showKeyBoard
import com.base.pdfviewerscannerwhite.utils.LogEx import com.base.pdfviewerscannerwhite.utils.LogEx
import com.base.pdfviewerscannerwhite.utils.SpStringUtils
import com.cherry.lib.doc.bean.DocEngine import com.cherry.lib.doc.bean.DocEngine
import com.cherry.lib.doc.office.constant.EventConstant.APP_PAGE_DOWN_ID import com.cherry.lib.doc.office.constant.EventConstant.APP_PAGE_DOWN_ID
import com.cherry.lib.doc.office.constant.EventConstant.APP_PAGE_UP_ID import com.cherry.lib.doc.office.constant.EventConstant.APP_PAGE_UP_ID
...@@ -295,6 +296,7 @@ class WordActivity : BaseActivity<ActivityWordBinding>() { ...@@ -295,6 +296,7 @@ class WordActivity : BaseActivity<ActivityWordBinding>() {
LogEx.logDebug(TAG, "initData-docSourceType = $docSourceType") LogEx.logDebug(TAG, "initData-docSourceType = $docSourceType")
LogEx.logDebug(TAG, "initData-fileType = $fileType") LogEx.logDebug(TAG, "initData-fileType = $fileType")
LogEx.logDebug(TAG, "initData-engine = $engine") LogEx.logDebug(TAG, "initData-engine = $engine")
SpStringUtils.addSpString(SpStringUtils.LAST_VIEW_KEY, pathOrUri ?: "")
} }
companion object { companion object {
......
...@@ -57,19 +57,18 @@ class MainActivity : BaseActivity<ActivityMain2Binding>(), MainView { ...@@ -57,19 +57,18 @@ class MainActivity : BaseActivity<ActivityMain2Binding>(), MainView {
LogEx.logDebug(TAG, "initView") LogEx.logDebug(TAG, "initView")
mainPresenter = MainPresenter(this, this, lifecycleScope) mainPresenter = MainPresenter(this, this, lifecycleScope)
mainPresenter.initScannerLauncher(this) mainPresenter.initScannerLauncher(this)
showStoragePermission(launcher, allowAction = {
// mainPresenter.initAllDocumentData()
Log.d("glc","我被调用了B")
})
} }
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
if (checkStorePermission() && needRefresh) { if (checkStorePermission() && needRefresh) {
mainPresenter.initAllDocumentData() mainPresenter.initAllDocumentData()
Log.d("glc","我被调用了A") // Log.d("glc","我被调用了A")
} else { } else {
showStoragePermission(launcher, allowAction = {
// mainPresenter.initAllDocumentData()
// Log.d("glc","我被调用了B")
})
} }
} }
......
...@@ -24,6 +24,7 @@ import com.base.pdfviewerscannerwhite.ui.document.pdf.PdfBoxUtils ...@@ -24,6 +24,7 @@ import com.base.pdfviewerscannerwhite.ui.document.pdf.PdfBoxUtils
import com.base.pdfviewerscannerwhite.utils.AssetUtils.saveAssetsFile import com.base.pdfviewerscannerwhite.utils.AssetUtils.saveAssetsFile
import com.base.pdfviewerscannerwhite.utils.SpStringUtils import com.base.pdfviewerscannerwhite.utils.SpStringUtils
import com.base.pdfviewerscannerwhite.utils.SpStringUtils.BOOKMARK_KEY import com.base.pdfviewerscannerwhite.utils.SpStringUtils.BOOKMARK_KEY
import com.base.pdfviewerscannerwhite.utils.SpStringUtils.LAST_VIEW_KEY
import com.base.pdfviewerscannerwhite.utils.ToastUtils.toast import com.base.pdfviewerscannerwhite.utils.ToastUtils.toast
import com.base.pdfviewerscannerwhite.utils.getMediaFile import com.base.pdfviewerscannerwhite.utils.getMediaFile
import com.base.pdfviewerscannerwhite.utils.upDateDemoStore import com.base.pdfviewerscannerwhite.utils.upDateDemoStore
...@@ -58,7 +59,7 @@ class MainPresenter( ...@@ -58,7 +59,7 @@ class MainPresenter(
private lateinit var scannerLauncher: ActivityResultLauncher<IntentSenderRequest> private lateinit var scannerLauncher: ActivityResultLauncher<IntentSenderRequest>
fun initAllDocumentData() = lifecycleScope.launch(Dispatchers.IO) { fun initAllDocumentData() = lifecycleScope.launch(Dispatchers.IO) {
Log.d("glc","pdfs 清理前:"+pdfDocuments.size) Log.d("glc", "pdfs 清理前:" + pdfDocuments.size)
context.upDateDemoStore() context.upDateDemoStore()
if (!ConstObject.haveSaveDemo) { if (!ConstObject.haveSaveDemo) {
context.saveAssetsFile() context.saveAssetsFile()
...@@ -70,9 +71,9 @@ class MainPresenter( ...@@ -70,9 +71,9 @@ class MainPresenter(
wordDocuments.clear() wordDocuments.clear()
excelDocuments.clear() excelDocuments.clear()
pptDocuments.clear() pptDocuments.clear()
Log.d("glc","pdfs:"+pdfs.size) Log.d("glc", "pdfs:" + pdfs.size)
pdfDocuments.addAll(pdfs) pdfDocuments.addAll(pdfs)
Log.d("glc","添加了 pdfDocuments:"+pdfDocuments.size) Log.d("glc", "添加了 pdfDocuments:" + pdfDocuments.size)
wordDocuments.addAll(initAllWordData()) wordDocuments.addAll(initAllWordData())
excelDocuments.addAll(initAllExcelData()) excelDocuments.addAll(initAllExcelData())
pptDocuments.addAll(initAllPptData()) pptDocuments.addAll(initAllPptData())
...@@ -85,7 +86,9 @@ class MainPresenter( ...@@ -85,7 +86,9 @@ class MainPresenter(
fun getDataByType(documentType: String, dataType: String): List<DocumentBean> { fun getDataByType(documentType: String, dataType: String): List<DocumentBean> {
val bookmarkList = SpStringUtils.getSpStringList(SpStringUtils.BOOKMARK_KEY) val bookmarkList = SpStringUtils.getSpStringList(SpStringUtils.BOOKMARK_KEY)
Log.d("glc","pdfDocuments:"+pdfDocuments.size) Log.d("glc", "pdfDocuments:" + pdfDocuments.size)
val recentList = SpStringUtils.getSpStringList(LAST_VIEW_KEY)
when (documentType) { when (documentType) {
TYPE_PDF -> { TYPE_PDF -> {
pdfDocuments.forEach { pdfDocuments.forEach {
...@@ -97,7 +100,7 @@ class MainPresenter( ...@@ -97,7 +100,7 @@ class MainPresenter(
} }
RECENT_DATA_TYPE -> { RECENT_DATA_TYPE -> {
return pdfDocuments.filter { recentFilter(it) } return pdfDocuments.filter { recentFilter(recentList, it) }
} }
BOOKMARK_DATA_TYPE -> { BOOKMARK_DATA_TYPE -> {
...@@ -118,7 +121,7 @@ class MainPresenter( ...@@ -118,7 +121,7 @@ class MainPresenter(
} }
RECENT_DATA_TYPE -> { RECENT_DATA_TYPE -> {
return wordDocuments.filter { recentFilter(it) } return wordDocuments.filter { recentFilter(recentList, it) }
} }
BOOKMARK_DATA_TYPE -> { BOOKMARK_DATA_TYPE -> {
...@@ -139,7 +142,7 @@ class MainPresenter( ...@@ -139,7 +142,7 @@ class MainPresenter(
} }
RECENT_DATA_TYPE -> { RECENT_DATA_TYPE -> {
return excelDocuments.filter { recentFilter(it) } return excelDocuments.filter { recentFilter(recentList, it) }
} }
BOOKMARK_DATA_TYPE -> { BOOKMARK_DATA_TYPE -> {
...@@ -159,7 +162,7 @@ class MainPresenter( ...@@ -159,7 +162,7 @@ class MainPresenter(
} }
RECENT_DATA_TYPE -> { RECENT_DATA_TYPE -> {
return pptDocuments.filter { recentFilter(it) } return pptDocuments.filter { recentFilter(recentList, it) }
} }
BOOKMARK_DATA_TYPE -> { BOOKMARK_DATA_TYPE -> {
...@@ -172,8 +175,8 @@ class MainPresenter( ...@@ -172,8 +175,8 @@ class MainPresenter(
return listOf() return listOf()
} }
private fun recentFilter(documentBean: DocumentBean): Boolean { private fun recentFilter(recentList: List<String>, documentBean: DocumentBean): Boolean {
return (System.currentTimeMillis() - File(documentBean.path).lastModified()) < 300L * 24 * 60 * 60 * 1000 return recentList.contains(documentBean.path)
} }
......
...@@ -15,7 +15,9 @@ object SpStringUtils { ...@@ -15,7 +15,9 @@ object SpStringUtils {
fun addSpString(key: String, value: String) { fun addSpString(key: String, value: String) {
val list = getSpStringList(key).toMutableList() val list = getSpStringList(key).toMutableList()
if (!list.contains(value)) {
list.add(value) list.add(value)
}
val string = list.joinToString(separator = "|||") val string = list.joinToString(separator = "|||")
AppPreferences.getInstance().put(key, string) AppPreferences.getInstance().put(key, string)
} }
......
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