Commit c5ed0484 authored by wanglei's avatar wanglei

...

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