Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
P
Pdf one Reader
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 one Reader
Commits
b32d8bd5
Commit
b32d8bd5
authored
Nov 13, 2024
by
wanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
...处理
parent
a4c385ca
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
483 additions
and
24 deletions
+483
-24
build.gradle.kts
app/build.gradle.kts
+2
-0
DocumentBean.kt
app/src/main/java/com/base/pdfoneread/bean/DocumentBean.kt
+1
-1
DocumentActivity.kt
.../java/com/base/pdfoneread/ui/document/DocumentActivity.kt
+105
-11
DocumentAdapter.kt
...n/java/com/base/pdfoneread/ui/document/DocumentAdapter.kt
+69
-7
DocumentEx.kt
...c/main/java/com/base/pdfoneread/ui/document/DocumentEx.kt
+1
-1
DocumentViewModel.kt
...java/com/base/pdfoneread/ui/document/DocumentViewModel.kt
+71
-0
HomeAdapter.kt
app/src/main/java/com/base/pdfoneread/ui/main/HomeAdapter.kt
+4
-0
HomeFragment.kt
...src/main/java/com/base/pdfoneread/ui/main/HomeFragment.kt
+24
-0
RecentFragment.kt
...c/main/java/com/base/pdfoneread/ui/main/RecentFragment.kt
+24
-4
activity_document.xml
app/src/main/res/layout/activity_document.xml
+132
-0
fragment_recent.xml
app/src/main/res/layout/fragment_recent.xml
+40
-0
item_document.xml
app/src/main/res/layout/item_document.xml
+3
-0
no_empty.png
app/src/main/res/mipmap-xxhdpi/no_empty.png
+0
-0
pdf_add.png
app/src/main/res/mipmap-xxhdpi/pdf_add.png
+0
-0
pdf_delete.png
app/src/main/res/mipmap-xxhdpi/pdf_delete.png
+0
-0
pdf_s.png
app/src/main/res/mipmap-xxhdpi/pdf_s.png
+0
-0
pdf_share.png
app/src/main/res/mipmap-xxhdpi/pdf_share.png
+0
-0
strings.xml
app/src/main/res/values/strings.xml
+4
-0
build.gradle.kts
build.gradle.kts
+3
-0
No files found.
app/build.gradle.kts
View file @
b32d8bd5
plugins
{
plugins
{
alias
(
libs
.
plugins
.
android
.
application
)
alias
(
libs
.
plugins
.
android
.
application
)
alias
(
libs
.
plugins
.
kotlin
.
android
)
alias
(
libs
.
plugins
.
kotlin
.
android
)
id
(
"com.google.gms.google-services"
)
id
(
"com.google.firebase.crashlytics"
)
}
}
android
{
android
{
...
...
app/src/main/java/com/base/pdfoneread/bean/DocumentBean.kt
View file @
b32d8bd5
...
@@ -8,7 +8,7 @@ data class DocumentBean(
...
@@ -8,7 +8,7 @@ data class DocumentBean(
var
type
:
String
=
""
,
var
type
:
String
=
""
,
var
isBookmarked
:
Boolean
=
false
,
var
isBookmarked
:
Boolean
=
false
,
)
{
)
{
var
uiType
:
Int
=
0
//0
首页
模式 1合并选择模式 2拆分模式 3解锁加锁模式 4搜索模式
var
uiType
:
Int
=
0
//0
浏览
模式 1合并选择模式 2拆分模式 3解锁加锁模式 4搜索模式
var
isSelect
:
Boolean
=
false
var
isSelect
:
Boolean
=
false
var
state
:
Int
=
-
1
//0正常状态 1 锁定
var
state
:
Int
=
-
1
//0正常状态 1 锁定
var
password
:
String
=
""
var
password
:
String
=
""
...
...
app/src/main/java/com/base/pdfoneread/ui/document/DocumentActivity.kt
View file @
b32d8bd5
package
com.base.pdfoneread.ui.document
package
com.base.pdfoneread.ui.document
import
android.annotation.SuppressLint
import
android.graphics.Color
import
android.graphics.Color
import
android.view.View
import
androidx.activity.addCallback
import
androidx.core.view.isVisible
import
androidx.core.view.updatePadding
import
androidx.core.view.updatePadding
import
androidx.lifecycle.ViewModelProvider
import
androidx.lifecycle.lifecycleScope
import
androidx.lifecycle.lifecycleScope
import
com.base.pdfoneread.R
import
com.base.pdfoneread.R
import
com.base.pdfoneread.bean.DocumentBean.Companion.TYPE_ALL
import
com.base.pdfoneread.bean.DocumentBean.Companion.TYPE_ALL
...
@@ -15,6 +20,7 @@ import com.base.pdfoneread.utils.BarUtils
...
@@ -15,6 +20,7 @@ import com.base.pdfoneread.utils.BarUtils
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.launch
import
kotlinx.coroutines.launch
class
DocumentActivity
:
BaseActivity
<
ActivityDocumentBinding
>()
{
class
DocumentActivity
:
BaseActivity
<
ActivityDocumentBinding
>()
{
var
type
:
String
=
""
var
type
:
String
=
""
...
@@ -23,6 +29,7 @@ class DocumentActivity : BaseActivity<ActivityDocumentBinding>() {
...
@@ -23,6 +29,7 @@ class DocumentActivity : BaseActivity<ActivityDocumentBinding>() {
ActivityDocumentBinding
.
inflate
(
layoutInflater
)
ActivityDocumentBinding
.
inflate
(
layoutInflater
)
}
}
private
var
adapter
:
DocumentAdapter
?
=
null
private
var
adapter
:
DocumentAdapter
?
=
null
private
lateinit
var
viewModel
:
DocumentViewModel
override
fun
initView
()
{
override
fun
initView
()
{
...
@@ -30,7 +37,28 @@ class DocumentActivity : BaseActivity<ActivityDocumentBinding>() {
...
@@ -30,7 +37,28 @@ class DocumentActivity : BaseActivity<ActivityDocumentBinding>() {
BarUtils
.
setStatusBarColor
(
this
,
Color
.
WHITE
)
BarUtils
.
setStatusBarColor
(
this
,
Color
.
WHITE
)
binding
.
root
.
updatePadding
(
top
=
BarUtils
.
getStatusBarHeight
())
binding
.
root
.
updatePadding
(
top
=
BarUtils
.
getStatusBarHeight
())
viewModel
=
ViewModelProvider
(
this
)[
DocumentViewModel
::
class
.
java
]
viewModel
.
handleActivityGmsScanResult
=
{
imageUri
,
pdfUri
->
}
type
=
intent
.
extras
?.
getString
(
"type"
)
?:
""
type
=
intent
.
extras
?.
getString
(
"type"
)
?:
""
changeTittle
()
initAdapter
()
}
@SuppressLint
(
"SetTextI18n"
)
private
fun
initAdapter
()
{
adapter
=
DocumentAdapter
(
this
)
adapter
?.
selectAction
=
{
size
->
binding
.
tvTittle
.
text
=
"$size Selected"
binding
.
ivAllSelector
.
isSelected
=
size
==
adapter
?.
items
?.
size
}
binding
.
rv
.
adapter
=
adapter
}
private
fun
changeTittle
()
{
when
(
type
)
{
when
(
type
)
{
TYPE_ALL
->
{
TYPE_ALL
->
{
binding
.
tvTittle
.
text
=
getString
(
R
.
string
.
all_files
)
binding
.
tvTittle
.
text
=
getString
(
R
.
string
.
all_files
)
...
@@ -52,41 +80,104 @@ class DocumentActivity : BaseActivity<ActivityDocumentBinding>() {
...
@@ -52,41 +80,104 @@ class DocumentActivity : BaseActivity<ActivityDocumentBinding>() {
binding
.
tvTittle
.
text
=
getString
(
R
.
string
.
ppt_files
)
binding
.
tvTittle
.
text
=
getString
(
R
.
string
.
ppt_files
)
}
}
}
}
adapter
=
DocumentAdapter
(
this
)
binding
.
rv
.
adapter
=
adapter
}
}
override
fun
initListener
()
{
override
fun
initListener
()
{
super
.
initListener
()
super
.
initListener
()
onBackPressedDispatcher
.
addCallback
{
if
(
binding
.
flSelector
.
isVisible
)
{
changeSelectUI
(
false
)
}
else
{
finishToMain
()
}
}
binding
.
flFanhui
.
setOnClickListener
{
onBackPressedDispatcher
.
onBackPressed
()
}
binding
.
ivScan
.
setOnClickListener
{
viewModel
.
starGmsScan
(
this
)
}
binding
.
flSelect
.
setOnClickListener
{
changeSelectUI
(
true
)
}
binding
.
flSelector
.
setOnClickListener
{
binding
.
ivAllSelector
.
isSelected
=
!
binding
.
ivAllSelector
.
isSelected
changeRvItemSelect
(
binding
.
ivAllSelector
.
isSelected
)
}
binding
.
llDelete
.
setOnClickListener
{
}
binding
.
llShare
.
setOnClickListener
{
}
binding
.
flPaixu
.
setOnClickListener
{
}
binding
.
flSearch
.
setOnClickListener
{
}
binding
.
swipeRefreshLayout
.
setOnRefreshListener
{
initData
()
}
initPreData
()
initPreData
()
}
}
@SuppressLint
(
"NotifyDataSetChanged"
)
private
fun
changeSelectUI
(
isSelect
:
Boolean
)
{
if
(
isSelect
)
{
binding
.
llTool
.
visibility
=
View
.
GONE
binding
.
ivScan
.
visibility
=
View
.
GONE
binding
.
flSelector
.
visibility
=
View
.
VISIBLE
binding
.
cardTool
.
visibility
=
View
.
VISIBLE
binding
.
tvTittle
.
text
=
getString
(
R
.
string
.
_0_selected
)
adapter
?.
items
?.
forEach
{
it
.
uiType
=
1
}
}
else
{
binding
.
llTool
.
visibility
=
View
.
VISIBLE
binding
.
ivScan
.
visibility
=
View
.
VISIBLE
binding
.
flSelector
.
visibility
=
View
.
GONE
binding
.
cardTool
.
visibility
=
View
.
GONE
changeTittle
()
adapter
?.
items
?.
forEach
{
it
.
uiType
=
0
}
}
adapter
?.
notifyDataSetChanged
()
}
@SuppressLint
(
"NotifyDataSetChanged"
)
fun
changeRvItemSelect
(
isSelect
:
Boolean
)
{
adapter
?.
items
?.
forEach
{
it
.
isSelect
=
isSelect
}
adapter
?.
notifyDataSetChanged
()
}
private
fun
initPreData
()
{
private
fun
initPreData
()
{
when
(
type
)
{
val
list
=
when
(
type
)
{
TYPE_ALL
->
{
adapter
?.
submitList
(
getGlobalAllList
())
}
TYPE_PDF
->
{
TYPE_PDF
->
{
adapter
?.
submitList
(
GlobalPdfList
)
GlobalPdfList
}
}
TYPE_WORD
->
{
TYPE_WORD
->
{
adapter
?.
submitList
(
GlobalWordList
)
GlobalWordList
}
}
TYPE_EXCEL
->
{
TYPE_EXCEL
->
{
adapter
?.
submitList
(
GlobalExcelList
)
GlobalExcelList
}
}
TYPE_PPT
->
{
TYPE_PPT
->
{
adapter
?.
submitList
(
GlobalPptList
)
GlobalPptList
}
}
else
->
getGlobalAllList
()
}
if
(
list
.
isEmpty
())
{
binding
.
swipeRefreshLayout
.
isRefreshing
=
true
initData
()
}
else
{
binding
.
llEmpty
.
visibility
=
View
.
GONE
adapter
?.
submitList
(
list
)
}
}
initData
()
}
}
...
@@ -102,10 +193,13 @@ class DocumentActivity : BaseActivity<ActivityDocumentBinding>() {
...
@@ -102,10 +193,13 @@ class DocumentActivity : BaseActivity<ActivityDocumentBinding>() {
}
}
launch
(
Dispatchers
.
Main
)
{
launch
(
Dispatchers
.
Main
)
{
if
(
list
.
isEmpty
())
{
if
(
list
.
isEmpty
())
{
binding
.
llEmpty
.
visibility
=
View
.
VISIBLE
adapter
?.
submitList
(
listOf
())
adapter
?.
submitList
(
listOf
())
}
else
{
}
else
{
binding
.
llEmpty
.
visibility
=
View
.
GONE
adapter
?.
submitList
(
list
)
adapter
?.
submitList
(
list
)
}
}
binding
.
swipeRefreshLayout
.
isRefreshing
=
false
}
}
}
}
...
...
app/src/main/java/com/base/pdfoneread/ui/document/DocumentAdapter.kt
View file @
b32d8bd5
...
@@ -30,7 +30,8 @@ class DocumentAdapter(
...
@@ -30,7 +30,8 @@ class DocumentAdapter(
inner
class
DocumentViewHolder
(
view
:
View
)
:
ViewHolder
(
view
)
inner
class
DocumentViewHolder
(
view
:
View
)
:
ViewHolder
(
view
)
var
moreAction
:
((
item
:
DocumentBean
)
->
Unit
)?
=
null
var
moreAction
:
((
item
:
DocumentBean
)
->
Unit
)?
=
null
var
itemClickAction
:
((
item
:
DocumentBean
)
->
Unit
)?
=
null
var
itemClick
:
((
item
:
DocumentBean
)
->
Unit
)?
=
null
var
selectAction
:
((
size
:
Int
)
->
Unit
)?
=
null
@SuppressLint
(
"SetTextI18n"
)
@SuppressLint
(
"SetTextI18n"
)
override
fun
onBindViewHolder
(
holder
:
DocumentViewHolder
,
position
:
Int
,
item
:
DocumentBean
?)
{
override
fun
onBindViewHolder
(
holder
:
DocumentViewHolder
,
position
:
Int
,
item
:
DocumentBean
?)
{
...
@@ -47,7 +48,7 @@ class DocumentAdapter(
...
@@ -47,7 +48,7 @@ class DocumentAdapter(
if
(
item
.
state
==
0
)
{
if
(
item
.
state
==
0
)
{
binding
.
ivIcon
.
setImageResource
(
R
.
mipmap
.
rv_pdf
)
binding
.
ivIcon
.
setImageResource
(
R
.
mipmap
.
rv_pdf
)
}
else
{
}
else
{
// binding.ivIcon.setImageResource(R.mipmap.rv_pdf_lock
)
binding
.
ivIcon
.
setImageResource
(
R
.
mipmap
.
pdf_s
)
}
}
}
}
...
@@ -66,17 +67,78 @@ class DocumentAdapter(
...
@@ -66,17 +67,78 @@ class DocumentAdapter(
val
file
=
File
(
item
.
path
)
val
file
=
File
(
item
.
path
)
binding
.
tvName
.
text
=
file
.
name
binding
.
tvName
.
text
=
file
.
name
binding
.
tvInfo
.
text
=
file
.
lastModified
().
toFormatTime5
()
+
" "
+
file
.
length
().
toFormatSize
()
binding
.
tvInfo
.
text
=
file
.
lastModified
().
toFormatTime5
()
+
" "
+
file
.
length
().
toFormatSize
()
//DocumentPdfAdapter
when
(
item
.
uiType
)
{
0
->
{
binding
.
flSelect
.
visibility
=
View
.
GONE
binding
.
flBookmark
.
visibility
=
View
.
VISIBLE
binding
.
flMore
.
visibility
=
View
.
VISIBLE
if
(
item
.
isBookmarked
)
{
binding
.
ivBookmark
.
setImageResource
(
R
.
mipmap
.
r_star_s
)
}
else
{
binding
.
ivBookmark
.
setImageResource
(
R
.
mipmap
.
star
)
}
binding
.
flBookmark
.
setOnClickListener
{
item
.
isBookmarked
=
!
item
.
isBookmarked
saveBookmarkChange
(
item
.
isBookmarked
,
item
.
path
)
notifyItemChanged
(
position
,
"aaaa"
)
}
binding
.
flMore
.
setOnClickListener
{
moreAction
?.
invoke
(
item
)
}
binding
.
root
.
setOnClickListener
{
itemClick
?.
invoke
(
item
)
}
}
1
->
{
binding
.
flSelect
.
visibility
=
View
.
VISIBLE
binding
.
flBookmark
.
visibility
=
View
.
GONE
binding
.
flMore
.
visibility
=
View
.
GONE
binding
.
ivSelector
.
isSelected
=
item
.
isSelect
binding
.
flSelect
.
setOnClickListener
{
item
.
isSelect
=
!
item
.
isSelect
notifyItemChanged
(
position
,
"aaa"
)
selectAction
?.
invoke
(
items
.
filter
{
it
.
isSelect
}.
size
)
}
}
2
->
{
//拆分选择
binding
.
flBookmark
.
visibility
=
View
.
GONE
binding
.
flMore
.
visibility
=
View
.
INVISIBLE
binding
.
root
.
setOnClickListener
{
itemClick
?.
invoke
(
item
)
}
}
3
->
{
//解锁模式选择
binding
.
flBookmark
.
visibility
=
View
.
GONE
binding
.
flMore
.
visibility
=
View
.
INVISIBLE
binding
.
root
.
setOnClickListener
{
itemClick
?.
invoke
(
item
)
}
}
4
->
{
//搜索选择
binding
.
flBookmark
.
visibility
=
View
.
GONE
binding
.
flMore
.
setOnClickListener
{
moreAction
?.
invoke
(
item
)
}
binding
.
root
.
setOnClickListener
{
itemClick
?.
invoke
(
item
)
}
}
binding
.
flMore
.
setOnClickListener
{
moreAction
?.
invoke
(
item
)
}
binding
.
root
.
setOnClickListener
{
itemClickAction
?.
invoke
(
item
)
}
}
}
}
}
}
override
fun
getItemViewType
(
position
:
Int
,
list
:
List
<
DocumentBean
>):
Int
{
override
fun
getItemViewType
(
position
:
Int
,
list
:
List
<
DocumentBean
>):
Int
{
val
item
=
list
[
position
]
val
item
=
list
[
position
]
return
if
(
item
.
isAd
)
1
else
0
return
if
(
item
.
isAd
)
1
else
0
...
...
app/src/main/java/com/base/pdfoneread/ui/document/DocumentEx.kt
View file @
b32d8bd5
...
@@ -28,6 +28,7 @@ import java.io.File
...
@@ -28,6 +28,7 @@ import java.io.File
import
java.io.FileOutputStream
import
java.io.FileOutputStream
import
java.io.IOException
import
java.io.IOException
/**
/**
* 全局数据数据
* 全局数据数据
*/
*/
...
@@ -310,7 +311,6 @@ fun getPptDocument(context: Context): MutableList<DocumentBean> {
...
@@ -310,7 +311,6 @@ fun getPptDocument(context: Context): MutableList<DocumentBean> {
return
new
return
new
}
}
fun
recentFilter
(
recentList
:
List
<
String
>,
documentBean
:
DocumentBean
)
{
fun
recentFilter
(
recentList
:
List
<
String
>,
documentBean
:
DocumentBean
)
{
val
findLastTime
=
recentList
.
filter
{
it
.
contains
(
documentBean
.
path
)
}.
map
{
val
findLastTime
=
recentList
.
filter
{
it
.
contains
(
documentBean
.
path
)
}.
map
{
it
.
split
(
"_/_"
)[
1
].
toLong
()
it
.
split
(
"_/_"
)[
1
].
toLong
()
...
...
app/src/main/java/com/base/pdfoneread/ui/document/DocumentViewModel.kt
0 → 100644
View file @
b32d8bd5
package
com.base.pdfoneread.ui.document
import
android.app.Activity
import
android.content.IntentSender
import
android.net.Uri
import
androidx.activity.result.ActivityResultLauncher
import
androidx.activity.result.IntentSenderRequest
import
androidx.activity.result.contract.ActivityResultContracts
import
androidx.appcompat.app.AppCompatActivity
import
androidx.lifecycle.ViewModel
import
com.google.mlkit.vision.documentscanner.GmsDocumentScannerOptions
import
com.google.mlkit.vision.documentscanner.GmsDocumentScanning
import
com.google.mlkit.vision.documentscanner.GmsDocumentScanningResult
class
DocumentViewModel
:
ViewModel
()
{
private
var
scannerLauncher
:
ActivityResultLauncher
<
IntentSenderRequest
>?
=
null
var
handleActivityGmsScanResult
:
((
imageUri
:
Uri
?,
pdfUri
:
Uri
?)
->
Unit
)?
=
null
private
var
scannerLauncherRegister
:
Boolean
=
false
fun
initScannerLauncher
(
appCompatActivity
:
AppCompatActivity
)
{
scannerLauncher
=
appCompatActivity
.
registerForActivityResult
(
ActivityResultContracts
.
StartIntentSenderForResult
())
{
activityResult
->
val
resultCode
=
activityResult
.
resultCode
val
result
=
GmsDocumentScanningResult
.
fromActivityResultIntent
(
activityResult
.
data
)
// appCompatActivity.toast("回调1")
if
(
resultCode
==
Activity
.
RESULT_OK
&&
result
!=
null
)
{
val
pages
=
result
.
pages
// appCompatActivity.toast("回调2 ${pages?.size}")
var
imageUri
=
Uri
.
EMPTY
if
(!
pages
.
isNullOrEmpty
())
{
// appCompatActivity.toast("回调3")
imageUri
=
pages
[
0
].
imageUri
}
val
pdfUri
=
result
.
pdf
?.
uri
?:
Uri
.
EMPTY
handleActivityGmsScanResult
?.
invoke
(
imageUri
,
pdfUri
)
}
else
{
handleActivityGmsScanResult
?.
invoke
(
null
,
null
)
}
}
scannerLauncherRegister
=
true
}
fun
starGmsScan
(
activity
:
Activity
)
{
runCatching
{
if
(
scannerLauncher
==
null
&&
!
scannerLauncherRegister
)
return
val
options
=
GmsDocumentScannerOptions
.
Builder
()
.
setScannerMode
(
GmsDocumentScannerOptions
.
SCANNER_MODE_BASE
)
.
setResultFormats
(
GmsDocumentScannerOptions
.
RESULT_FORMAT_PDF
)
.
setGalleryImportAllowed
(
true
)
options
.
setScannerMode
(
GmsDocumentScannerOptions
.
SCANNER_MODE_FULL
)
val
pageLimit
=
1
options
.
setPageLimit
(
pageLimit
)
GmsDocumentScanning
.
getClient
(
options
.
build
())
.
getStartScanIntent
(
activity
)
.
addOnSuccessListener
{
intentSender
:
IntentSender
->
scannerLauncher
?.
launch
(
IntentSenderRequest
.
Builder
(
intentSender
).
build
())
}
.
addOnFailureListener
{
e
:
Exception
->
}
}
}
}
\ No newline at end of file
app/src/main/java/com/base/pdfoneread/ui/main/HomeAdapter.kt
View file @
b32d8bd5
...
@@ -32,6 +32,8 @@ class HomeAdapter() : BaseQuickAdapter<HomeUIBean, HomeAdapter.HomeUIBeanViewHol
...
@@ -32,6 +32,8 @@ class HomeAdapter() : BaseQuickAdapter<HomeUIBean, HomeAdapter.HomeUIBeanViewHol
if
(
item
.
fileNumber
!=
-
1
)
{
if
(
item
.
fileNumber
!=
-
1
)
{
binding
.
tvFileNumber
.
visibility
=
View
.
VISIBLE
binding
.
tvFileNumber
.
visibility
=
View
.
VISIBLE
binding
.
tvFileNumber
.
text
=
"${item.fileNumber} files"
binding
.
tvFileNumber
.
text
=
"${item.fileNumber} files"
}
else
{
binding
.
tvFileNumber
.
text
=
""
}
}
binding
.
root
.
setOnClickListener
{
binding
.
root
.
setOnClickListener
{
itemClick
?.
invoke
(
item
)
itemClick
?.
invoke
(
item
)
...
@@ -45,6 +47,8 @@ class HomeAdapter() : BaseQuickAdapter<HomeUIBean, HomeAdapter.HomeUIBeanViewHol
...
@@ -45,6 +47,8 @@ class HomeAdapter() : BaseQuickAdapter<HomeUIBean, HomeAdapter.HomeUIBeanViewHol
if
(
item
.
fileNumber
!=
-
1
)
{
if
(
item
.
fileNumber
!=
-
1
)
{
binding
.
tvFileNumber
.
visibility
=
View
.
VISIBLE
binding
.
tvFileNumber
.
visibility
=
View
.
VISIBLE
binding
.
tvFileNumber
.
text
=
"${item.fileNumber} files"
binding
.
tvFileNumber
.
text
=
"${item.fileNumber} files"
}
else
{
binding
.
tvFileNumber
.
text
=
""
}
}
binding
.
root
.
setOnClickListener
{
binding
.
root
.
setOnClickListener
{
itemClick
?.
invoke
(
item
)
itemClick
?.
invoke
(
item
)
...
...
app/src/main/java/com/base/pdfoneread/ui/main/HomeFragment.kt
View file @
b32d8bd5
...
@@ -10,7 +10,10 @@ import androidx.lifecycle.lifecycleScope
...
@@ -10,7 +10,10 @@ import androidx.lifecycle.lifecycleScope
import
androidx.recyclerview.widget.GridLayoutManager
import
androidx.recyclerview.widget.GridLayoutManager
import
com.base.pdfoneread.R
import
com.base.pdfoneread.R
import
com.base.pdfoneread.bean.DocumentBean.Companion.TYPE_ALL
import
com.base.pdfoneread.bean.DocumentBean.Companion.TYPE_ALL
import
com.base.pdfoneread.bean.DocumentBean.Companion.TYPE_EXCEL
import
com.base.pdfoneread.bean.DocumentBean.Companion.TYPE_PDF
import
com.base.pdfoneread.bean.DocumentBean.Companion.TYPE_PDF
import
com.base.pdfoneread.bean.DocumentBean.Companion.TYPE_PPT
import
com.base.pdfoneread.bean.DocumentBean.Companion.TYPE_WORD
import
com.base.pdfoneread.databinding.FragmentHomeBinding
import
com.base.pdfoneread.databinding.FragmentHomeBinding
import
com.base.pdfoneread.bean.HomeUIBean
import
com.base.pdfoneread.bean.HomeUIBean
import
com.base.pdfoneread.bean.HomeUIBean.Companion.KEY_ALL
import
com.base.pdfoneread.bean.HomeUIBean.Companion.KEY_ALL
...
@@ -88,15 +91,36 @@ class HomeFragment() : Fragment() {
...
@@ -88,15 +91,36 @@ class HomeFragment() : Fragment() {
putExtra
(
"type"
,
TYPE_PDF
)
putExtra
(
"type"
,
TYPE_PDF
)
})
})
}
}
KEY_WORD
->
{
startActivity
(
Intent
(
requireContext
(),
DocumentActivity
::
class
.
java
).
apply
{
putExtra
(
"type"
,
TYPE_WORD
)
})
}
KEY_EXCEL
->
{
startActivity
(
Intent
(
requireContext
(),
DocumentActivity
::
class
.
java
).
apply
{
putExtra
(
"type"
,
TYPE_EXCEL
)
})
}
KEY_PPT
->
{
startActivity
(
Intent
(
requireContext
(),
DocumentActivity
::
class
.
java
).
apply
{
putExtra
(
"type"
,
TYPE_PPT
)
})
}
}
}
}
}
binding
.
swipeRefreshLayout
.
setOnRefreshListener
{
binding
.
swipeRefreshLayout
.
setOnRefreshListener
{
refreshData
()
refreshData
()
}
}
refreshData
()
refreshData
()
}
}
fun
refreshData
()
{
fun
refreshData
()
{
kotlin
.
runCatching
{
kotlin
.
runCatching
{
...
...
app/src/main/java/com/base/pdfoneread/ui/main/RecentFragment.kt
View file @
b32d8bd5
...
@@ -5,7 +5,12 @@ import androidx.fragment.app.Fragment
...
@@ -5,7 +5,12 @@ import androidx.fragment.app.Fragment
import
android.view.LayoutInflater
import
android.view.LayoutInflater
import
android.view.View
import
android.view.View
import
android.view.ViewGroup
import
android.view.ViewGroup
import
com.base.pdfoneread.R
import
androidx.lifecycle.lifecycleScope
import
com.base.pdfoneread.databinding.FragmentRecentBinding
import
com.base.pdfoneread.ui.document.DocumentAdapter
import
com.base.pdfoneread.ui.document.getGlobalAllList
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.launch
class
RecentFragment
()
:
Fragment
()
{
class
RecentFragment
()
:
Fragment
()
{
...
@@ -14,15 +19,30 @@ class RecentFragment() : Fragment() {
...
@@ -14,15 +19,30 @@ class RecentFragment() : Fragment() {
super
.
onCreate
(
savedInstanceState
)
super
.
onCreate
(
savedInstanceState
)
}
}
private
lateinit
var
binding
:
FragmentRecentBinding
private
var
adapter
:
DocumentAdapter
?
=
null
override
fun
onCreateView
(
override
fun
onCreateView
(
inflater
:
LayoutInflater
,
container
:
ViewGroup
?,
inflater
:
LayoutInflater
,
container
:
ViewGroup
?,
savedInstanceState
:
Bundle
?
savedInstanceState
:
Bundle
?
):
View
?
{
):
View
{
// Inflate the layout for this fragment
binding
=
FragmentRecentBinding
.
inflate
(
inflater
)
return
inflater
.
inflate
(
R
.
layout
.
fragment_recent
,
container
,
false
)
return
binding
.
root
}
override
fun
onViewCreated
(
view
:
View
,
savedInstanceState
:
Bundle
?)
{
super
.
onViewCreated
(
view
,
savedInstanceState
)
adapter
=
DocumentAdapter
(
requireActivity
())
initPreData
()
}
private
fun
initPreData
()
=
lifecycleScope
.
launch
(
Dispatchers
.
Main
)
{
adapter
?.
submitList
(
getGlobalAllList
())
}
}
companion
object
{
companion
object
{
}
}
}
}
\ No newline at end of file
app/src/main/res/layout/activity_document.xml
View file @
b32d8bd5
...
@@ -52,6 +52,7 @@
...
@@ -52,6 +52,7 @@
tools:text=
"All files"
/>
tools:text=
"All files"
/>
<LinearLayout
<LinearLayout
android:id=
"@+id/ll_tool"
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginEnd=
"8dp"
android:layout_marginEnd=
"8dp"
...
@@ -101,6 +102,25 @@
...
@@ -101,6 +102,25 @@
</LinearLayout>
</LinearLayout>
<FrameLayout
android:id=
"@+id/fl_selector"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginEnd=
"16dp"
android:padding=
"15dp"
android:visibility=
"gone"
app:layout_constraintBottom_toBottomOf=
"@id/fl_fanhui"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintTop_toTopOf=
"@id/fl_fanhui"
>
<ImageView
android:id=
"@+id/iv_all_selector"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:src=
"@drawable/selector_document"
tools:ignore=
"ContentDescription"
/>
</FrameLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
...
@@ -123,4 +143,116 @@
...
@@ -123,4 +143,116 @@
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
<LinearLayout
android:id=
"@+id/ll_empty"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:orientation=
"vertical"
android:visibility=
"gone"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@id/card"
app:layout_constraintVertical_bias=
"0.45"
tools:ignore=
"UseCompoundDrawables"
>
<ImageView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_horizontal"
android:src=
"@mipmap/no_empty"
tools:ignore=
"ContentDescription"
/>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_horizontal"
android:layout_marginTop=
"24dp"
android:text=
"@string/no_files_yet"
android:textColor=
"#010101"
android:textSize=
"20sp"
/>
</LinearLayout>
<ImageView
android:id=
"@+id/iv_scan"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginEnd=
"10dp"
android:layout_marginBottom=
"120dp"
android:src=
"@mipmap/pdf_add"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
tools:ignore=
"ContentDescription"
/>
<androidx.cardview.widget.CardView
android:id=
"@+id/card_tool"
android:layout_width=
"0dp"
android:layout_height=
"80dp"
android:layout_marginHorizontal=
"30dp"
android:layout_marginBottom=
"50dp"
app:cardCornerRadius=
"25dp"
app:cardElevation=
"5dp"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
>
<LinearLayout
android:id=
"@+id/ll_delete"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_vertical|start"
android:layout_marginStart=
"50dp"
android:layout_marginTop=
"5dp"
android:orientation=
"vertical"
tools:ignore=
"UseCompoundDrawables"
>
<ImageView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_horizontal"
android:src=
"@mipmap/pdf_delete"
tools:ignore=
"ContentDescription"
/>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_horizontal"
android:layout_marginTop=
"5dp"
android:text=
"@string/delete"
android:textColor=
"@color/black"
android:textSize=
"15sp"
tools:ignore=
"HardcodedText"
/>
</LinearLayout>
<LinearLayout
android:id=
"@+id/ll_share"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_vertical|end"
android:layout_marginTop=
"5dp"
android:layout_marginEnd=
"50dp"
android:orientation=
"vertical"
tools:ignore=
"UseCompoundDrawables"
>
<ImageView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_horizontal"
android:src=
"@mipmap/pdf_share"
tools:ignore=
"ContentDescription"
/>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_horizontal"
android:layout_marginTop=
"5dp"
android:text=
"@string/share"
android:textColor=
"@color/black"
android:textSize=
"15sp"
tools:ignore=
"HardcodedText"
/>
</LinearLayout>
</androidx.cardview.widget.CardView>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
app/src/main/res/layout/fragment_recent.xml
View file @
b32d8bd5
...
@@ -5,4 +5,44 @@
...
@@ -5,4 +5,44 @@
android:layout_height=
"match_parent"
android:layout_height=
"match_parent"
tools:context=
".ui.main.RecentFragment"
>
tools:context=
".ui.main.RecentFragment"
>
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id=
"@+id/swipeRefreshLayout"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<androidx.recyclerview.widget.RecyclerView
android:id=
"@+id/rv"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
tools:listitem=
"@layout/item_document"
/>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
<LinearLayout
android:id=
"@+id/ll_empty"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center"
android:orientation=
"vertical"
android:visibility=
"gone"
tools:ignore=
"UseCompoundDrawables"
>
<ImageView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_horizontal"
android:src=
"@mipmap/no_empty"
tools:ignore=
"ContentDescription"
/>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_horizontal"
android:layout_marginTop=
"24dp"
android:text=
"@string/no_files_yet"
android:textColor=
"#010101"
android:textSize=
"20sp"
/>
</LinearLayout>
</FrameLayout>
</FrameLayout>
\ No newline at end of file
app/src/main/res/layout/item_document.xml
View file @
b32d8bd5
...
@@ -56,6 +56,7 @@
...
@@ -56,6 +56,7 @@
app:layout_constraintTop_toTopOf=
"parent"
>
app:layout_constraintTop_toTopOf=
"parent"
>
<ImageView
<ImageView
android:id=
"@+id/iv_bookmark"
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:src=
"@mipmap/r_star_s"
android:src=
"@mipmap/r_star_s"
...
@@ -76,6 +77,7 @@
...
@@ -76,6 +77,7 @@
app:layout_constraintTop_toTopOf=
"parent"
>
app:layout_constraintTop_toTopOf=
"parent"
>
<ImageView
<ImageView
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:src=
"@mipmap/icon_more"
android:src=
"@mipmap/icon_more"
...
@@ -94,6 +96,7 @@
...
@@ -94,6 +96,7 @@
app:layout_constraintTop_toTopOf=
"parent"
>
app:layout_constraintTop_toTopOf=
"parent"
>
<ImageView
<ImageView
android:id=
"@+id/iv_selector"
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:src=
"@drawable/selector_document"
android:src=
"@drawable/selector_document"
...
...
app/src/main/res/mipmap-xxhdpi/no_empty.png
0 → 100644
View file @
b32d8bd5
48.5 KB
app/src/main/res/mipmap-xxhdpi/pdf_add.png
0 → 100644
View file @
b32d8bd5
10.3 KB
app/src/main/res/mipmap-xxhdpi/pdf_delete.png
0 → 100644
View file @
b32d8bd5
1.56 KB
app/src/main/res/mipmap-xxhdpi/pdf_s.png
0 → 100644
View file @
b32d8bd5
5.05 KB
app/src/main/res/mipmap-xxhdpi/pdf_share.png
0 → 100644
View file @
b32d8bd5
1.81 KB
app/src/main/res/values/strings.xml
View file @
b32d8bd5
...
@@ -20,5 +20,9 @@
...
@@ -20,5 +20,9 @@
<string
name=
"permission_required"
>
Permission Required
</string>
<string
name=
"permission_required"
>
Permission Required
</string>
<string
name=
"allow"
>
Allow
</string>
<string
name=
"allow"
>
Allow
</string>
<string
name=
"allow_access_to_manage_all_files"
>
Allow access to manage all files
</string>
<string
name=
"allow_access_to_manage_all_files"
>
Allow access to manage all files
</string>
<string
name=
"no_files_yet"
>
No files yet
</string>
<string
name=
"_0_selected"
>
0 Selected
</string>
<string
name=
"share"
>
Share
</string>
<string
name=
"delete"
>
Delete
</string>
</resources>
</resources>
\ No newline at end of file
build.gradle.kts
View file @
b32d8bd5
...
@@ -2,4 +2,7 @@
...
@@ -2,4 +2,7 @@
plugins
{
plugins
{
alias
(
libs
.
plugins
.
android
.
application
)
apply
false
alias
(
libs
.
plugins
.
android
.
application
)
apply
false
alias
(
libs
.
plugins
.
kotlin
.
android
)
apply
false
alias
(
libs
.
plugins
.
kotlin
.
android
)
apply
false
id
(
"com.google.gms.google-services"
)
version
"4.4.1"
apply
false
id
(
"com.google.firebase.crashlytics"
)
version
"3.0.2"
apply
false
}
}
\ No newline at end of file
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