Commit c5ed0484 authored by wanglei's avatar wanglei

...

parent 2fa2ebf2
...@@ -4,6 +4,7 @@ import android.content.Context ...@@ -4,6 +4,7 @@ import android.content.Context
import android.media.MediaScannerConnection import android.media.MediaScannerConnection
import android.net.Uri import android.net.Uri
import android.os.Environment import android.os.Environment
import com.base.pdfoneread.R
import com.base.pdfoneread.ads.AdmobHelper import com.base.pdfoneread.ads.AdmobHelper
import com.base.pdfoneread.ui.MyApplication.Companion.appContext import com.base.pdfoneread.ui.MyApplication.Companion.appContext
import com.base.pdfoneread.bean.ConstObject import com.base.pdfoneread.bean.ConstObject
...@@ -27,10 +28,7 @@ import com.base.pdfoneread.utils.PdfBoxUtils.checkPdfEncryption ...@@ -27,10 +28,7 @@ import com.base.pdfoneread.utils.PdfBoxUtils.checkPdfEncryption
import com.base.pdfoneread.utils.SpStringUtils import com.base.pdfoneread.utils.SpStringUtils
import com.base.pdfoneread.utils.SpStringUtils.BOOKMARK_KEY import com.base.pdfoneread.utils.SpStringUtils.BOOKMARK_KEY
import com.base.pdfoneread.utils.getMediaFile import com.base.pdfoneread.utils.getMediaFile
import kotlinx.coroutines.DelicateCoroutinesApi
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import java.io.File import java.io.File
import java.io.FileOutputStream import java.io.FileOutputStream
...@@ -68,7 +66,6 @@ fun cleanGlobalData() { ...@@ -68,7 +66,6 @@ fun cleanGlobalData() {
GlobalPptList.clear() GlobalPptList.clear()
} }
fun Context.upDateDemoStore() { fun Context.upDateDemoStore() {
val demoFile = File(filesDir, "demo") val demoFile = File(filesDir, "demo")
MediaScannerConnection.scanFile( MediaScannerConnection.scanFile(
...@@ -77,15 +74,26 @@ fun Context.upDateDemoStore() { ...@@ -77,15 +74,26 @@ fun Context.upDateDemoStore() {
} }
fun getDocumentAppDir(): File { fun getDocumentAppDir(): File {
val appDir = File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS), appContext.packageName) val appDir = File(
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS),
appContext.resources.getString(R.string.app_name)
)
if (!appDir.exists()) if (!appDir.exists())
appDir.exists() appDir.exists()
return appDir return appDir
} }
fun getDemoDir(): File {
val demoFile = File(getDocumentAppDir(), "demo")
if (!demoFile.exists()) {
demoFile.mkdirs()
}
return demoFile
}
fun Context.saveAssetsFile() { fun Context.saveAssetsFile() {
val demoFile = File(filesDir, "demo") val demoFile = getDemoDir()
demoFile.mkdirs()
arrayOf( arrayOf(
"DEMO.pdf", "DEMO.pdf",
"DEMO.docx", "DEMO.docx",
...@@ -111,32 +119,32 @@ fun Context.saveAssetsFile() { ...@@ -111,32 +119,32 @@ fun Context.saveAssetsFile() {
fun getPdfDemo(context: Context): DocumentBean { fun getPdfDemo(context: Context): DocumentBean {
val demoDocumentBean = DocumentBean() val demoDocumentBean = DocumentBean()
demoDocumentBean.type = TYPE_PDF demoDocumentBean.type = TYPE_PDF
val demoFile = File(context.filesDir, "demo") val demoFile = getDemoDir()
demoDocumentBean.path = demoFile.listFiles()?.find { it.name.contains(".pdf") }?.absolutePath ?: "" demoDocumentBean.path = demoFile.listFiles()?.find { it.name.contains(".pdf") }?.absolutePath ?: ""
context.pdfCheck(demoDocumentBean) context.pdfCheck(demoDocumentBean)
return demoDocumentBean return demoDocumentBean
} }
fun getWordDemo(context: Context): DocumentBean { fun getWordDemo(): DocumentBean {
val demoDocumentBean = DocumentBean() val demoDocumentBean = DocumentBean()
demoDocumentBean.type = TYPE_WORD demoDocumentBean.type = TYPE_WORD
val demoFile = File(context.filesDir, "demo") val demoFile = getDemoDir()
demoDocumentBean.path = demoFile.listFiles()?.find { it.name.contains(".docx") }?.absolutePath ?: "" demoDocumentBean.path = demoFile.listFiles()?.find { it.name.contains(".docx") }?.absolutePath ?: ""
return demoDocumentBean return demoDocumentBean
} }
fun getExcelDemo(context: Context): DocumentBean { fun getExcelDemo(): DocumentBean {
val demoDocumentBean = DocumentBean() val demoDocumentBean = DocumentBean()
demoDocumentBean.type = TYPE_EXCEL demoDocumentBean.type = TYPE_EXCEL
val demoFile = File(context.filesDir, "demo") val demoFile = getDemoDir()
demoDocumentBean.path = demoFile.listFiles()?.find { it.name.contains(".xlsx") }?.absolutePath ?: "" demoDocumentBean.path = demoFile.listFiles()?.find { it.name.contains(".xlsx") }?.absolutePath ?: ""
return demoDocumentBean return demoDocumentBean
} }
fun getPPtDemo(context: Context): DocumentBean { fun getPPtDemo(): DocumentBean {
val demoDocumentBean = DocumentBean() val demoDocumentBean = DocumentBean()
demoDocumentBean.type = TYPE_PPT demoDocumentBean.type = TYPE_PPT
val demoFile = File(context.filesDir, "demo") val demoFile = getDemoDir()
demoDocumentBean.path = demoFile.listFiles()?.find { it.name.contains(".pptx") }?.absolutePath ?: "" demoDocumentBean.path = demoFile.listFiles()?.find { it.name.contains(".pptx") }?.absolutePath ?: ""
return demoDocumentBean return demoDocumentBean
} }
...@@ -193,20 +201,20 @@ fun getAllDocument(context: Context): MutableList<DocumentBean> { ...@@ -193,20 +201,20 @@ fun getAllDocument(context: Context): MutableList<DocumentBean> {
documentBean documentBean
} }
val new = documentList.toMutableList() val new = documentList.toMutableList()
val pptDemo = getPPtDemo(context) val pptDemo = getPPtDemo()
if (File(pptDemo.path).exists()) { if (File(pptDemo.path).exists()) {
new.add(0, pptDemo) new.add(0, pptDemo)
GlobalPptList.add(0, pptDemo) GlobalPptList.add(0, pptDemo)
} }
val excelDemo = getExcelDemo(context) val excelDemo = getExcelDemo()
if (File(excelDemo.path).exists()) { if (File(excelDemo.path).exists()) {
new.add(0, excelDemo) new.add(0, excelDemo)
GlobalExcelList.add(0, excelDemo) GlobalExcelList.add(0, excelDemo)
} }
val wordDemp = getWordDemo(context) val wordDemo = getWordDemo()
if (File(wordDemp.path).exists()) { if (File(wordDemo.path).exists()) {
new.add(0, wordDemp) new.add(0, wordDemo)
GlobalWordList.add(0, wordDemp) GlobalWordList.add(0, wordDemo)
} }
val pdfDemo = getPdfDemo(context) val pdfDemo = getPdfDemo(context)
if (File(pdfDemo.path).exists()) { if (File(pdfDemo.path).exists()) {
...@@ -272,7 +280,7 @@ fun getWordDocument(context: Context): MutableList<DocumentBean> { ...@@ -272,7 +280,7 @@ fun getWordDocument(context: Context): MutableList<DocumentBean> {
documentBean documentBean
} }
val new = documentList.toMutableList() val new = documentList.toMutableList()
val wordDemo = getWordDemo(context) val wordDemo = getWordDemo()
if (File(wordDemo.path).exists()) { if (File(wordDemo.path).exists()) {
new.add(0, wordDemo) new.add(0, wordDemo)
GlobalWordList.add(0, deepCopy(wordDemo)) GlobalWordList.add(0, deepCopy(wordDemo))
...@@ -304,7 +312,7 @@ fun getExcelDocument(context: Context): MutableList<DocumentBean> { ...@@ -304,7 +312,7 @@ fun getExcelDocument(context: Context): MutableList<DocumentBean> {
documentBean documentBean
} }
val new = documentList.toMutableList() val new = documentList.toMutableList()
val excelDemo = getExcelDemo(context) val excelDemo = getExcelDemo()
if (File(excelDemo.path).exists()) { if (File(excelDemo.path).exists()) {
new.add(0, excelDemo) new.add(0, excelDemo)
GlobalExcelList.add(0, deepCopy(excelDemo)) GlobalExcelList.add(0, deepCopy(excelDemo))
...@@ -335,7 +343,7 @@ fun getPptDocument(context: Context): MutableList<DocumentBean> { ...@@ -335,7 +343,7 @@ fun getPptDocument(context: Context): MutableList<DocumentBean> {
documentBean documentBean
} }
val new = documentList.toMutableList() val new = documentList.toMutableList()
val pptDemo = getPPtDemo(context) val pptDemo = getPPtDemo()
if (File(pptDemo.path).exists()) { if (File(pptDemo.path).exists()) {
new.add(0, pptDemo) new.add(0, pptDemo)
GlobalPptList.add(0, deepCopy(pptDemo)) GlobalPptList.add(0, deepCopy(pptDemo))
......
...@@ -17,7 +17,6 @@ import com.base.pdfoneread.utils.LogEx ...@@ -17,7 +17,6 @@ import com.base.pdfoneread.utils.LogEx
import com.base.pdfoneread.utils.PdfBoxUtils.checkPdfEncryption import com.base.pdfoneread.utils.PdfBoxUtils.checkPdfEncryption
import com.base.pdfoneread.utils.SafUtils.jumpOpenDocumentThenPersistable import com.base.pdfoneread.utils.SafUtils.jumpOpenDocumentThenPersistable
import com.base.pdfoneread.utils.UriUtils.getMimeTypeBySafUri import com.base.pdfoneread.utils.UriUtils.getMimeTypeBySafUri
import com.mbridge.msdk.widget.FeedBackButton
class SettingFragment : Fragment() { class SettingFragment : Fragment() {
......
...@@ -68,25 +68,25 @@ class PdfSelectActivity : BaseActivity<ActivityPdfSelectBinding>() { ...@@ -68,25 +68,25 @@ class PdfSelectActivity : BaseActivity<ActivityPdfSelectBinding>() {
when (doWhat) { when (doWhat) {
DO_SPLIT_PDF -> { DO_SPLIT_PDF -> {
binding.tvBtnNext.visibility = View.GONE binding.tvBtnNext.visibility = View.GONE
binding.tvSelectTip.text = getString(R.string.select_a_project) binding.tvSelectTip.text = getString(R.string.select_a_project_split)
getPdfData(2) getPdfData(2)
} }
DO_MERGE_PDF -> { DO_MERGE_PDF -> {
binding.tvSelectTip.text = getString(R.string.select_a_project) binding.tvSelectTip.text = getString(R.string.select_a_project_merge)
getPdfData(1) getPdfData(1)
} }
DO_LOCK_PDF -> { DO_LOCK_PDF -> {
binding.tvBtnNext.visibility = View.GONE binding.tvBtnNext.visibility = View.GONE
binding.tvSelectTip.text = getString(R.string.select_a_project) binding.tvSelectTip.text = getString(R.string.select_a_project_lock)
getPdfData(3) getPdfData(3)
} }
DO_UNLOCK_PDF -> { DO_UNLOCK_PDF -> {
binding.tvBtnNext.visibility = View.GONE binding.tvBtnNext.visibility = View.GONE
binding.tvSelectTip.text = getString(R.string.select_a_project) binding.tvSelectTip.text = getString(R.string.select_a_project_unlock)
getPdfData(3) getPdfData(3)
} }
......
...@@ -109,9 +109,9 @@ fun Context.getMediaFile(selectionArgs: Array<String>? = null): ArrayList<MediaB ...@@ -109,9 +109,9 @@ fun Context.getMediaFile(selectionArgs: Array<String>? = null): ArrayList<MediaB
// val size = cursor.getLong(cursor.getColumnIndexOrThrow(MediaStore.Files.FileColumns.SIZE)) // val size = cursor.getLong(cursor.getColumnIndexOrThrow(MediaStore.Files.FileColumns.SIZE))
LogEx.logDebug(TAG, "path=$path uri=$uri mimeType=$mimeType") LogEx.logDebug(TAG, "path=$path uri=$uri mimeType=$mimeType")
list.add( if (!Uri.EMPTY.equals(uri) || File(path).exists()) {
MediaBean(path = path, uri = uri, mimeType = mimeType) list.add(MediaBean(path = path, uri = uri, mimeType = mimeType))
) }
} }
} }
} }
......
...@@ -76,5 +76,9 @@ ...@@ -76,5 +76,9 @@
<string name="rate_tip">We are working hard for a better\nuser experience.\nWe\'d greatly appreciate if you\ncan rate us.</string> <string name="rate_tip">We are working hard for a better\nuser experience.\nWe\'d greatly appreciate if you\ncan rate us.</string>
<string name="send">Send</string> <string name="send">Send</string>
<string name="favorite">Favorite</string> <string name="favorite">Favorite</string>
<string name="select_a_project_split">Select a project for split</string>
<string name="select_a_project_merge">Select projects for merge</string>
<string name="select_a_project_lock">Select a project to lock</string>
<string name="select_a_project_unlock">Select a project to unlock</string>
</resources> </resources>
\ 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