Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
P
PDF Viewer Scanner White
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wanglei
PDF Viewer Scanner White
Commits
9a85ea42
Commit
9a85ea42
authored
Dec 04, 2024
by
wanglei
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of gitlab.huolea.com:koko/pdf-viewer-scanner-white
parents
010ca428
8030086e
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
80 additions
and
53 deletions
+80
-53
AndroidManifest.xml
app/src/main/AndroidManifest.xml
+1
-0
MainPresenter.kt
...a/com/base/pdfviewerscannerwhite/ui/main/MainPresenter.kt
+79
-53
No files found.
app/src/main/AndroidManifest.xml
View file @
9a85ea42
...
@@ -21,6 +21,7 @@
...
@@ -21,6 +21,7 @@
android:label=
"@string/app_name"
android:label=
"@string/app_name"
android:requestLegacyExternalStorage=
"true"
android:requestLegacyExternalStorage=
"true"
android:roundIcon=
"@mipmap/logo"
android:roundIcon=
"@mipmap/logo"
android:largeHeap=
"true"
android:supportsRtl=
"true"
android:supportsRtl=
"true"
android:theme=
"@style/Theme.PDFViewerScannerWhite"
android:theme=
"@style/Theme.PDFViewerScannerWhite"
android:usesCleartextTraffic=
"true"
android:usesCleartextTraffic=
"true"
...
...
app/src/main/java/com/base/pdfviewerscannerwhite/ui/main/MainPresenter.kt
View file @
9a85ea42
...
@@ -39,6 +39,7 @@ import com.google.mlkit.vision.documentscanner.GmsDocumentScanningResult
...
@@ -39,6 +39,7 @@ import com.google.mlkit.vision.documentscanner.GmsDocumentScanningResult
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.MainScope
import
kotlinx.coroutines.MainScope
import
kotlinx.coroutines.launch
import
kotlinx.coroutines.launch
import
kotlinx.coroutines.withContext
import
java.io.File
import
java.io.File
class
MainPresenter
(
class
MainPresenter
(
...
@@ -49,7 +50,10 @@ class MainPresenter(
...
@@ -49,7 +50,10 @@ class MainPresenter(
private
val
TAG
=
"MainPresenter"
private
val
TAG
=
"MainPresenter"
fun
getDocumentAppDir
():
File
{
fun
getDocumentAppDir
():
File
{
val
appDir
=
File
(
Environment
.
getExternalStoragePublicDirectory
(
Environment
.
DIRECTORY_DOCUMENTS
),
context
.
packageName
)
val
appDir
=
File
(
Environment
.
getExternalStoragePublicDirectory
(
Environment
.
DIRECTORY_DOCUMENTS
),
context
.
packageName
)
if
(!
appDir
.
exists
())
if
(!
appDir
.
exists
())
appDir
.
exists
()
appDir
.
exists
()
return
appDir
return
appDir
...
@@ -68,6 +72,7 @@ class MainPresenter(
...
@@ -68,6 +72,7 @@ class MainPresenter(
}
}
fun
initAllDocumentData
()
=
lifecycleScope
.
launch
(
Dispatchers
.
IO
)
{
fun
initAllDocumentData
()
=
lifecycleScope
.
launch
(
Dispatchers
.
IO
)
{
if
(!
mainRefreshData
)
{
mainRefreshData
=
true
mainRefreshData
=
true
val
start
=
System
.
currentTimeMillis
()
val
start
=
System
.
currentTimeMillis
()
Log
.
d
(
"glc"
,
"pdfs 清理前:"
+
pdfDocuments
.
size
)
Log
.
d
(
"glc"
,
"pdfs 清理前:"
+
pdfDocuments
.
size
)
...
@@ -89,13 +94,14 @@ class MainPresenter(
...
@@ -89,13 +94,14 @@ class MainPresenter(
excelDocuments
.
addAll
(
initAllExcelData
())
excelDocuments
.
addAll
(
initAllExcelData
())
pptDocuments
.
addAll
(
initAllPptData
())
pptDocuments
.
addAll
(
initAllPptData
())
mainRefreshData
=
false
mainRefreshData
=
false
lifecycleScope
.
launch
(
Dispatchers
.
Main
)
{
withContext
(
Dispatchers
.
Main
)
{
val
end
=
System
.
currentTimeMillis
()
val
end
=
System
.
currentTimeMillis
()
val
time
=
end
-
start
val
time
=
end
-
start
LogEx
.
logDebug
(
TAG
,
"time=$time"
)
LogEx
.
logDebug
(
TAG
,
"time=$time"
)
mainView
.
refreshPageList
()
mainView
.
refreshPageList
()
}
}
}
}
}
fun
getDataByType
(
documentType
:
String
,
dataType
:
String
):
List
<
DocumentBean
>
{
fun
getDataByType
(
documentType
:
String
,
dataType
:
String
):
List
<
DocumentBean
>
{
...
@@ -120,7 +126,8 @@ class MainPresenter(
...
@@ -120,7 +126,8 @@ class MainPresenter(
RECENT_DATA_TYPE
->
{
RECENT_DATA_TYPE
->
{
data
.
forEach
{
recentFilter
(
recentList
,
it
)
}
data
.
forEach
{
recentFilter
(
recentList
,
it
)
}
return
data
.
filter
{
it
.
lastViewTime
!=
0L
}.
sortedByDescending
{
it
.
lastViewTime
}
return
data
.
filter
{
it
.
lastViewTime
!=
0L
}
.
sortedByDescending
{
it
.
lastViewTime
}
}
}
BOOKMARK_DATA_TYPE
->
{
BOOKMARK_DATA_TYPE
->
{
...
@@ -145,7 +152,8 @@ class MainPresenter(
...
@@ -145,7 +152,8 @@ class MainPresenter(
RECENT_DATA_TYPE
->
{
RECENT_DATA_TYPE
->
{
data
.
forEach
{
recentFilter
(
recentList
,
it
)
}
data
.
forEach
{
recentFilter
(
recentList
,
it
)
}
return
data
.
filter
{
it
.
lastViewTime
!=
0L
}.
sortedByDescending
{
it
.
lastViewTime
}
return
data
.
filter
{
it
.
lastViewTime
!=
0L
}
.
sortedByDescending
{
it
.
lastViewTime
}
}
}
BOOKMARK_DATA_TYPE
->
{
BOOKMARK_DATA_TYPE
->
{
...
@@ -169,7 +177,8 @@ class MainPresenter(
...
@@ -169,7 +177,8 @@ class MainPresenter(
RECENT_DATA_TYPE
->
{
RECENT_DATA_TYPE
->
{
data
.
forEach
{
recentFilter
(
recentList
,
it
)
}
data
.
forEach
{
recentFilter
(
recentList
,
it
)
}
return
data
.
filter
{
it
.
lastViewTime
!=
0L
}.
sortedByDescending
{
it
.
lastViewTime
}
return
data
.
filter
{
it
.
lastViewTime
!=
0L
}
.
sortedByDescending
{
it
.
lastViewTime
}
}
}
BOOKMARK_DATA_TYPE
->
{
BOOKMARK_DATA_TYPE
->
{
...
@@ -193,7 +202,8 @@ class MainPresenter(
...
@@ -193,7 +202,8 @@ class MainPresenter(
RECENT_DATA_TYPE
->
{
RECENT_DATA_TYPE
->
{
data
.
forEach
{
recentFilter
(
recentList
,
it
)
}
data
.
forEach
{
recentFilter
(
recentList
,
it
)
}
return
data
.
filter
{
it
.
lastViewTime
!=
0L
}.
sortedByDescending
{
it
.
lastViewTime
}
return
data
.
filter
{
it
.
lastViewTime
!=
0L
}
.
sortedByDescending
{
it
.
lastViewTime
}
}
}
BOOKMARK_DATA_TYPE
->
{
BOOKMARK_DATA_TYPE
->
{
...
@@ -225,7 +235,8 @@ class MainPresenter(
...
@@ -225,7 +235,8 @@ class MainPresenter(
val
demoFile
=
File
(
context
.
filesDir
,
"demo"
)
val
demoFile
=
File
(
context
.
filesDir
,
"demo"
)
val
selectionArgs
=
arrayOf
(
ConstObject
.
MIME_TYPE_PDF
)
val
selectionArgs
=
arrayOf
(
ConstObject
.
MIME_TYPE_PDF
)
demoDocumentBean
.
path
=
demoFile
.
listFiles
()
?.
find
{
it
.
name
.
contains
(
".pdf"
)
}
?.
absolutePath
?:
""
demoDocumentBean
.
path
=
demoFile
.
listFiles
()
?.
find
{
it
.
name
.
contains
(
".pdf"
)
}
?.
absolutePath
?:
""
val
list
=
context
.
getMediaFile
(
selectionArgs
=
selectionArgs
)
val
list
=
context
.
getMediaFile
(
selectionArgs
=
selectionArgs
)
...
@@ -245,7 +256,8 @@ class MainPresenter(
...
@@ -245,7 +256,8 @@ class MainPresenter(
val
demoFile
=
File
(
context
.
filesDir
,
"demo"
)
val
demoFile
=
File
(
context
.
filesDir
,
"demo"
)
val
selectionArgs
=
arrayOf
(
ConstObject
.
MIME_TYPE_DOC
,
ConstObject
.
MIME_TYPE_DOCX
)
val
selectionArgs
=
arrayOf
(
ConstObject
.
MIME_TYPE_DOC
,
ConstObject
.
MIME_TYPE_DOCX
)
demoDocumentBean
.
path
=
demoFile
.
listFiles
()
?.
find
{
it
.
name
.
contains
(
".docx"
)
}
?.
absolutePath
?:
""
demoDocumentBean
.
path
=
demoFile
.
listFiles
()
?.
find
{
it
.
name
.
contains
(
".docx"
)
}
?.
absolutePath
?:
""
val
list
=
context
.
getMediaFile
(
selectionArgs
=
selectionArgs
)
val
list
=
context
.
getMediaFile
(
selectionArgs
=
selectionArgs
)
...
@@ -265,7 +277,8 @@ class MainPresenter(
...
@@ -265,7 +277,8 @@ class MainPresenter(
val
demoFile
=
File
(
context
.
filesDir
,
"demo"
)
val
demoFile
=
File
(
context
.
filesDir
,
"demo"
)
val
selectionArgs
=
arrayOf
(
ConstObject
.
MIME_TYPE_XLS
,
ConstObject
.
MIME_TYPE_XLSX
)
val
selectionArgs
=
arrayOf
(
ConstObject
.
MIME_TYPE_XLS
,
ConstObject
.
MIME_TYPE_XLSX
)
demoDocumentBean
.
path
=
demoFile
.
listFiles
()
?.
find
{
it
.
name
.
contains
(
".xlsx"
)
}
?.
absolutePath
?:
""
demoDocumentBean
.
path
=
demoFile
.
listFiles
()
?.
find
{
it
.
name
.
contains
(
".xlsx"
)
}
?.
absolutePath
?:
""
val
list
=
context
.
getMediaFile
(
selectionArgs
=
selectionArgs
)
val
list
=
context
.
getMediaFile
(
selectionArgs
=
selectionArgs
)
val
documentList
=
list
.
map
{
val
documentList
=
list
.
map
{
...
@@ -285,7 +298,8 @@ class MainPresenter(
...
@@ -285,7 +298,8 @@ class MainPresenter(
val
demoFile
=
File
(
context
.
filesDir
,
"demo"
)
val
demoFile
=
File
(
context
.
filesDir
,
"demo"
)
val
selectionArgs
=
arrayOf
(
ConstObject
.
MIME_TYPE_PPT
,
ConstObject
.
MIME_TYPE_PPTX
)
val
selectionArgs
=
arrayOf
(
ConstObject
.
MIME_TYPE_PPT
,
ConstObject
.
MIME_TYPE_PPTX
)
demoDocumentBean
.
path
=
demoFile
.
listFiles
()
?.
find
{
it
.
name
.
contains
(
".pptx"
)
}
?.
absolutePath
?:
""
demoDocumentBean
.
path
=
demoFile
.
listFiles
()
?.
find
{
it
.
name
.
contains
(
".pptx"
)
}
?.
absolutePath
?:
""
val
list
=
context
.
getMediaFile
(
selectionArgs
=
selectionArgs
)
val
list
=
context
.
getMediaFile
(
selectionArgs
=
selectionArgs
)
...
@@ -390,10 +404,17 @@ class MainPresenter(
...
@@ -390,10 +404,17 @@ class MainPresenter(
val
result
=
file
.
renameTo
(
newFile
)
val
result
=
file
.
renameTo
(
newFile
)
if
(
result
)
{
if
(
result
)
{
when
(
documentPageFragment
.
type
)
{
when
(
documentPageFragment
.
type
)
{
TYPE_PDF
->
pdfDocuments
.
find
{
it
.
path
==
file
.
absolutePath
}
?.
path
=
newFile
.
absolutePath
TYPE_PDF
->
pdfDocuments
.
find
{
it
.
path
==
file
.
absolutePath
}
?.
path
=
TYPE_WORD
->
wordDocuments
.
find
{
it
.
path
==
file
.
absolutePath
}
?.
path
=
newFile
.
absolutePath
newFile
.
absolutePath
TYPE_EXCEL
->
excelDocuments
.
find
{
it
.
path
==
file
.
absolutePath
}
?.
path
=
newFile
.
absolutePath
TYPE_PPT
->
pptDocuments
.
find
{
it
.
path
==
file
.
absolutePath
}
?.
path
=
newFile
.
absolutePath
TYPE_WORD
->
wordDocuments
.
find
{
it
.
path
==
file
.
absolutePath
}
?.
path
=
newFile
.
absolutePath
TYPE_EXCEL
->
excelDocuments
.
find
{
it
.
path
==
file
.
absolutePath
}
?.
path
=
newFile
.
absolutePath
TYPE_PPT
->
pptDocuments
.
find
{
it
.
path
==
file
.
absolutePath
}
?.
path
=
newFile
.
absolutePath
}
}
}
}
}
catch
(
e
:
Exception
)
{
}
catch
(
e
:
Exception
)
{
...
@@ -404,7 +425,8 @@ class MainPresenter(
...
@@ -404,7 +425,8 @@ class MainPresenter(
}
}
}
}
fun
deleteDocument
(
path
:
String
,
documentPageFragment
:
DocumentPageFragment
)
=
lifecycleScope
.
launch
(
Dispatchers
.
IO
)
{
fun
deleteDocument
(
path
:
String
,
documentPageFragment
:
DocumentPageFragment
)
=
lifecycleScope
.
launch
(
Dispatchers
.
IO
)
{
val
flag
=
File
(
path
).
delete
()
val
flag
=
File
(
path
).
delete
()
if
(
flag
)
{
if
(
flag
)
{
when
(
documentPageFragment
.
type
)
{
when
(
documentPageFragment
.
type
)
{
...
@@ -420,7 +442,11 @@ class MainPresenter(
...
@@ -420,7 +442,11 @@ class MainPresenter(
}
}
fun
changeBookmark
(
path
:
String
,
isBookmarked
:
Boolean
,
documentPageFragment
:
DocumentPageFragment
)
=
fun
changeBookmark
(
path
:
String
,
isBookmarked
:
Boolean
,
documentPageFragment
:
DocumentPageFragment
)
=
lifecycleScope
.
launch
(
Dispatchers
.
IO
)
{
lifecycleScope
.
launch
(
Dispatchers
.
IO
)
{
if
(
isBookmarked
)
{
if
(
isBookmarked
)
{
SpStringUtils
.
addSpString
(
BOOKMARK_KEY
,
path
)
SpStringUtils
.
addSpString
(
BOOKMARK_KEY
,
path
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment