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
1a74a546
Commit
1a74a546
authored
Sep 24, 2024
by
wanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
...
parent
bcb64c57
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
219 additions
and
20 deletions
+219
-20
build.gradle.kts
app/build.gradle.kts
+1
-0
DocumentBean.kt
.../java/com/base/pdfviewerscannerwhite/bean/DocumentBean.kt
+3
-0
DocumentAdapter.kt
.../base/pdfviewerscannerwhite/ui/adapter/DocumentAdapter.kt
+12
-0
DocumentFragment.kt
...om/base/pdfviewerscannerwhite/ui/main/DocumentFragment.kt
+0
-1
DocumentPresenter.kt
...m/base/pdfviewerscannerwhite/ui/main/DocumentPresenter.kt
+10
-0
MainActivity.kt
...va/com/base/pdfviewerscannerwhite/ui/main/MainActivity.kt
+84
-8
color_b4b9bd_0592ee.xml
app/src/main/res/color/color_b4b9bd_0592ee.xml
+5
-0
color_b4b9bd_159b56.xml
app/src/main/res/color/color_b4b9bd_159b56.xml
+5
-0
color_b4b9bd_f02f2b.xml
app/src/main/res/color/color_b4b9bd_f02f2b.xml
+5
-0
color_b4b9bd_ffa127.xml
app/src/main/res/color/color_b4b9bd_ffa127.xml
+5
-0
indicator_bottom_line.xml
app/src/main/res/drawable/indicator_bottom_line.xml
+9
-0
ripple_select.xml
app/src/main/res/drawable/ripple_select.xml
+2
-11
activity_main.xml
app/src/main/res/layout/activity_main.xml
+72
-0
h_exceliocn.png
app/src/main/res/mipmap-xxhdpi/h_exceliocn.png
+0
-0
h_pptfiocn.png
app/src/main/res/mipmap-xxhdpi/h_pptfiocn.png
+0
-0
h_wordfiocn.png
app/src/main/res/mipmap-xxhdpi/h_wordfiocn.png
+0
-0
colors.xml
app/src/main/res/values/colors.xml
+4
-0
dimens.xml
app/src/main/res/values/dimens.xml
+2
-0
No files found.
app/build.gradle.kts
View file @
1a74a546
...
...
@@ -59,6 +59,7 @@ dependencies {
//第三方UI
implementation
(
"io.github.cymchad:BaseRecyclerViewAdapterHelper4:4.1.4"
)
implementation
(
"com.h6ah4i.android.widget.verticalseekbar:verticalseekbar:1.0.0"
)
implementation
(
"com.github.angcyo.DslTablayout:TabLayout:3.5.5"
)
//mlkit
implementation
(
"com.google.android.gms:play-services-mlkit-document-scanner:16.0.0-beta1"
)
...
...
app/src/main/java/com/base/pdfviewerscannerwhite/bean/DocumentBean.kt
View file @
1a74a546
...
...
@@ -14,5 +14,8 @@ data class DocumentBean(
companion
object
{
const
val
TYPE_PDF
=
"type_pdf"
const
val
TYPE_WORD
=
"type_word"
const
val
TYPE_EXCEL
=
"type_excel"
const
val
TYPE_PPT
=
"type_ppt"
}
}
app/src/main/java/com/base/pdfviewerscannerwhite/ui/adapter/DocumentAdapter.kt
View file @
1a74a546
...
...
@@ -8,7 +8,10 @@ import android.widget.ImageView
import
androidx.recyclerview.widget.RecyclerView.ViewHolder
import
com.base.pdfviewerscannerwhite.R
import
com.base.pdfviewerscannerwhite.bean.DocumentBean
import
com.base.pdfviewerscannerwhite.bean.DocumentBean.Companion.TYPE_EXCEL
import
com.base.pdfviewerscannerwhite.bean.DocumentBean.Companion.TYPE_PDF
import
com.base.pdfviewerscannerwhite.bean.DocumentBean.Companion.TYPE_PPT
import
com.base.pdfviewerscannerwhite.bean.DocumentBean.Companion.TYPE_WORD
import
com.base.pdfviewerscannerwhite.databinding.ItemDocumentBinding
import
com.base.pdfviewerscannerwhite.ui.document.pdf.PdfBoxUtils
import
com.base.pdfviewerscannerwhite.utils.KotlinExt.toFormatSize
...
...
@@ -60,6 +63,15 @@ class DocumentAdapter : BaseQuickAdapter<DocumentBean, DocumentAdapter.DocumentV
binding
.
iv
.
setImageResource
(
res
)
}
}
if
(
item
.
type
==
TYPE_WORD
)
{
binding
.
iv
.
setImageResource
(
R
.
mipmap
.
h_wordfiocn
)
}
if
(
item
.
type
==
TYPE_EXCEL
)
{
binding
.
iv
.
setImageResource
(
R
.
mipmap
.
h_exceliocn
)
}
if
(
item
.
type
==
TYPE_PPT
)
{
binding
.
iv
.
setImageResource
(
R
.
mipmap
.
h_pptfiocn
)
}
val
file
=
File
(
item
.
path
)
binding
.
tvName
.
text
=
file
.
name
...
...
app/src/main/java/com/base/pdfviewerscannerwhite/ui/main/DocumentFragment.kt
View file @
1a74a546
...
...
@@ -36,7 +36,6 @@ class DocumentFragment() : BaseFragment<FragmentDocumentBinding>(), DocumentView
override
fun
setView
()
{
documentPresenter
=
DocumentPresenter
(
requireContext
(),
this
,
type
,
lifecycleScope
)
initAdapter
()
}
override
fun
onResume
()
{
...
...
app/src/main/java/com/base/pdfviewerscannerwhite/ui/main/DocumentPresenter.kt
View file @
1a74a546
...
...
@@ -23,6 +23,16 @@ class DocumentPresenter(
if
(
type
==
DocumentBean
.
TYPE_PDF
)
{
selectionArgs
=
arrayOf
(
ConstObject
.
MIME_TYPE_PDF
)
}
if
(
type
==
DocumentBean
.
TYPE_WORD
)
{
selectionArgs
=
arrayOf
(
ConstObject
.
MIME_TYPE_DOC
,
ConstObject
.
MIME_TYPE_DOCX
)
}
if
(
type
==
DocumentBean
.
TYPE_EXCEL
)
{
selectionArgs
=
arrayOf
(
ConstObject
.
MIME_TYPE_XLS
,
ConstObject
.
MIME_TYPE_XLSX
)
}
if
(
type
==
DocumentBean
.
TYPE_PPT
)
{
selectionArgs
=
arrayOf
(
ConstObject
.
MIME_TYPE_PPT
,
ConstObject
.
MIME_TYPE_PPTX
)
}
val
bookmarkList
=
SpStringUtils
.
getSpStringList
(
SpStringUtils
.
BOOKMARK_KEY
)
val
list
=
context
.
getMediaFile
(
selectionArgs
=
selectionArgs
)
...
...
app/src/main/java/com/base/pdfviewerscannerwhite/ui/main/MainActivity.kt
View file @
1a74a546
...
...
@@ -7,14 +7,17 @@ import androidx.core.content.ContextCompat
import
androidx.fragment.app.Fragment
import
androidx.viewpager2.adapter.FragmentStateAdapter
import
androidx.viewpager2.widget.ViewPager2
import
com.angcyo.tablayout.DslTabIndicator
import
com.base.pdfviewerscannerwhite.BuildConfig
import
com.base.pdfviewerscannerwhite.R
import
com.base.pdfviewerscannerwhite.bean.DocumentBean
import
com.base.pdfviewerscannerwhite.databinding.ActivityMainBinding
import
com.base.pdfviewerscannerwhite.helper.BaseActivity
import
com.base.pdfviewerscannerwhite.ui.view.DialogView.showDocumentRenameDialog
import
com.base.pdfviewerscannerwhite.ui.view.DialogView.showStoragePermission
import
com.base.pdfviewerscannerwhite.ui.view.RateDialog.showRateDialog
import
com.base.pdfviewerscannerwhite.utils.KotlinExt.toFormatTime2
import
com.base.pdfviewerscannerwhite.utils.LogEx
import
com.base.pdfviewerscannerwhite.utils.PermissionUtils.checkStorePermission
import
com.base.pdfviewerscannerwhite.utils.ToastUtils.toast
...
...
@@ -29,7 +32,16 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), MainView {
}
private
val
pdfFragment
:
DocumentFragment
by
lazy
{
DocumentFragment
()
DocumentFragment
(
DocumentBean
.
TYPE_PDF
)
}
private
val
wordFragment
:
DocumentFragment
by
lazy
{
DocumentFragment
(
DocumentBean
.
TYPE_WORD
)
}
private
val
excelFragment
:
DocumentFragment
by
lazy
{
DocumentFragment
(
DocumentBean
.
TYPE_EXCEL
)
}
private
val
pptFragment
:
DocumentFragment
by
lazy
{
DocumentFragment
(
DocumentBean
.
TYPE_PPT
)
}
private
val
toolFragment
:
ToolFragment
by
lazy
{
ToolFragment
()
...
...
@@ -37,16 +49,15 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), MainView {
private
var
currentFragment
:
Fragment
=
pdfFragment
private
val
fragments
by
lazy
{
mutableListOf
(
pdfFragment
,
toolFragment
)
mutableListOf
(
pdfFragment
,
wordFragment
,
excelFragment
,
pptFragment
,
toolFragment
)
}
override
fun
initView
()
{
mainPresenter
=
MainPresenter
(
this
)
mainPresenter
.
initScannerLauncher
(
this
)
binding
.
viewPager2
.
offscreenPageLimit
=
4
binding
.
viewPager2
.
run
{
isUserInputEnabled
=
false
adapter
=
object
:
FragmentStateAdapter
(
this
@MainActivity
)
{
...
...
@@ -66,11 +77,69 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), MainView {
}
})
initTabLayout
()
if
(!
checkStorePermission
())
{
showStoragePermission
(
launcher
)
}
}
private
fun
initTabLayout
()
{
val
colorPdf
=
ContextCompat
.
getColor
(
this
,
R
.
color
.
color_f02f2b
)
val
colorWord
=
ContextCompat
.
getColor
(
this
,
R
.
color
.
color_0592ee
)
val
colorExcel
=
ContextCompat
.
getColor
(
this
,
R
.
color
.
color_149b55
)
val
colorPpt
=
ContextCompat
.
getColor
(
this
,
R
.
color
.
color_ffa127
)
binding
.
tabLayoutDocument
.
apply
{
tabIndicator
.
indicatorWidth
=
this
.
resources
.
getDimensionPixelOffset
(
R
.
dimen
.
dp_50
)
tabIndicator
.
indicatorHeight
=
this
.
resources
.
getDimensionPixelOffset
(
R
.
dimen
.
dp_4
)
tabIndicator
.
indicatorStyle
=
DslTabIndicator
.
INDICATOR_STYLE_BOTTOM
configTabLayoutConfig
{
onSelectIndexChange
=
{
fromIndex
,
selectIndexList
,
reselect
,
fromUser
->
val
toIndex
=
selectIndexList
.
first
()
LogEx
.
logDebug
(
TAG
,
"toIndex=$toIndex fromIndex=$fromIndex selectIndexList=$selectIndexList reselect=$reselect fromUser=$fromUser"
)
when
(
toIndex
)
{
0
->
{
tabSelectColor
=
colorPdf
tabIndicator
.
indicatorColor
=
colorPdf
binding
.
viewPager2
.
currentItem
=
0
}
1
->
{
tabSelectColor
=
colorWord
tabIndicator
.
indicatorColor
=
colorWord
binding
.
viewPager2
.
currentItem
=
1
}
2
->
{
tabSelectColor
=
colorExcel
tabIndicator
.
indicatorColor
=
colorExcel
binding
.
viewPager2
.
currentItem
=
2
}
3
->
{
tabSelectColor
=
colorPpt
tabIndicator
.
indicatorColor
=
colorPpt
binding
.
viewPager2
.
currentItem
=
3
}
}
dslSelector
.
updateStyle
()
}
}
}
}
var
latViewPagerIndex
=
-
1
@SuppressLint
(
"ClickableViewAccessibility"
,
"SetTextI18n"
)
override
fun
initListener
()
{
...
...
@@ -79,32 +148,37 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), MainView {
binding
.
llDocument
.
setOnClickListener
{
binding
.
tvTittle
.
text
=
"Document"
binding
.
clTabLayout
.
visibility
=
View
.
VISIBLE
binding
.
viewPager2
.
setCurrentItem
(
latViewPagerIndex
,
false
)
changeTabSelect
(
it
)
binding
.
ivScan
.
visibility
=
View
.
VISIBLE
binding
.
clAction
.
visibility
=
View
.
VISIBLE
binding
.
ivPaixu
.
visibility
=
View
.
VISIBLE
binding
.
viewPager2
.
currentItem
=
0
if
(
currentFragment
is
DocumentFragment
)
{
(
currentFragment
as
DocumentFragment
).
setAllList
()
}
}
binding
.
llRecent
.
setOnClickListener
{
binding
.
tvTittle
.
text
=
"Document"
binding
.
clTabLayout
.
visibility
=
View
.
VISIBLE
binding
.
viewPager2
.
setCurrentItem
(
latViewPagerIndex
,
false
)
binding
.
ivScan
.
visibility
=
View
.
VISIBLE
binding
.
clAction
.
visibility
=
View
.
VISIBLE
binding
.
ivPaixu
.
visibility
=
View
.
GONE
changeTabSelect
(
it
)
binding
.
viewPager2
.
currentItem
=
0
if
(
currentFragment
is
DocumentFragment
)
{
(
currentFragment
as
DocumentFragment
).
setRecentList
()
}
}
binding
.
llBookmark
.
setOnClickListener
{
binding
.
tvTittle
.
text
=
"Document"
binding
.
clTabLayout
.
visibility
=
View
.
VISIBLE
binding
.
viewPager2
.
setCurrentItem
(
latViewPagerIndex
,
false
)
binding
.
ivScan
.
visibility
=
View
.
VISIBLE
binding
.
clAction
.
visibility
=
View
.
VISIBLE
changeTabSelect
(
it
)
binding
.
viewPager2
.
currentItem
=
0
if
(
currentFragment
is
DocumentFragment
)
{
(
currentFragment
as
DocumentFragment
).
setBookmarkList
()
}
...
...
@@ -112,8 +186,10 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), MainView {
binding
.
llTool
.
setOnClickListener
{
binding
.
tvTittle
.
text
=
"Tool"
binding
.
ivScan
.
visibility
=
View
.
GONE
binding
.
clTabLayout
.
visibility
=
View
.
GONE
changeTabSelect
(
it
)
binding
.
viewPager2
.
currentItem
=
1
latViewPagerIndex
=
binding
.
viewPager2
.
currentItem
binding
.
viewPager2
.
setCurrentItem
(
5
,
false
)
binding
.
clAction
.
visibility
=
View
.
GONE
}
...
...
app/src/main/res/color/color_b4b9bd_0592ee.xml
0 → 100644
View file @
1a74a546
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<item
android:color=
"#0592EE"
android:state_selected=
"true"
/>
<item
android:color=
"#B4B9BD"
android:state_selected=
"false"
/>
</selector>
\ No newline at end of file
app/src/main/res/color/color_b4b9bd_159b56.xml
0 → 100644
View file @
1a74a546
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<item
android:color=
"#159B56"
android:state_selected=
"true"
/>
<item
android:color=
"#B4B9BD"
android:state_selected=
"false"
/>
</selector>
\ No newline at end of file
app/src/main/res/color/color_b4b9bd_f02f2b.xml
0 → 100644
View file @
1a74a546
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<item
android:color=
"#F02F2B"
android:state_selected=
"true"
/>
<item
android:color=
"#B4B9BD"
android:state_selected=
"false"
/>
</selector>
\ No newline at end of file
app/src/main/res/color/color_b4b9bd_ffa127.xml
0 → 100644
View file @
1a74a546
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<item
android:color=
"#FFA127"
android:state_selected=
"true"
/>
<item
android:color=
"#B4B9BD"
android:state_selected=
"false"
/>
</selector>
\ No newline at end of file
app/src/main/res/drawable/indicator_bottom_line.xml
0 → 100644
View file @
1a74a546
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<corners
android:radius=
"2dp"
/>
<!-- <solid android:color="@color/colorPrimary" />-->
<gradient
android:endColor=
"#FAF8D1"
android:startColor=
"#FAD4E7"
android:type=
"linear"
/>
</shape>
\ No newline at end of file
app/src/main/res/drawable/ripple_select.xml
View file @
1a74a546
<?xml version="1.0" encoding="utf-8"?>
<ripple
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:color=
"#99FAAB85"
>
android:color=
"#20000000"
>
<item
android:id=
"@android:id/mask"
android:width=
"110dp"
android:height=
"110dp"
android:gravity=
"center"
>
<shape
android:shape=
"rectangle"
>
<solid
android:color=
"#99FAAB85"
/>
<corners
android:radius=
"110dp"
/>
</shape>
</item>
</ripple>
\ No newline at end of file
app/src/main/res/layout/activity_main.xml
View file @
1a74a546
...
...
@@ -94,6 +94,78 @@
app:layout_constraintBottom_toTopOf=
"@id/ll_bottom"
app:layout_constraintTop_toBottomOf=
"@id/cl_top"
>
<!-- 外层FrameLayout设置背景用来限定水波纹大小-->
<FrameLayout
android:id=
"@+id/cl_tabLayout"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:background=
"#00000000"
>
<com.angcyo.tablayout.DslTabLayout
android:id=
"@+id/tabLayout_document"
android:layout_width=
"match_parent"
android:layout_height=
"50dp"
app:tab_badge_gravity=
"center"
app:tab_badge_offset_x=
"20dp"
app:tab_draw_indicator=
"true"
app:tab_enable_text_color=
"true"
app:tab_indicator_drawable=
"@drawable/indicator_bottom_line"
app:tab_indicator_height=
"3dp"
app:tab_item_is_equ_width=
"true"
>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:background=
"@drawable/ripple_select"
android:clipChildren=
"false"
android:clipToPadding=
"false"
android:gravity=
"center"
android:text=
"PDF"
android:textSize=
"16sp"
android:textStyle=
"bold"
tools:ignore=
"HardcodedText"
/>
<TextView
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center"
android:background=
"@drawable/ripple_select"
android:clipChildren=
"false"
android:clipToPadding=
"false"
android:gravity=
"center"
android:paddingVertical=
"5dp"
android:text=
"Word"
android:textSize=
"16sp"
android:textStyle=
"bold"
tools:ignore=
"HardcodedText"
/>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:background=
"@drawable/ripple_select"
android:clipChildren=
"false"
android:clipToPadding=
"false"
android:gravity=
"center"
android:text=
"Excel"
android:textSize=
"16sp"
android:textStyle=
"bold"
tools:ignore=
"HardcodedText"
/>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:background=
"@drawable/ripple_select"
android:clipChildren=
"false"
android:clipToPadding=
"false"
android:gravity=
"center"
android:text=
"PPT"
android:textSize=
"16sp"
android:textStyle=
"bold"
tools:ignore=
"HardcodedText"
/>
</com.angcyo.tablayout.DslTabLayout>
</FrameLayout>
<androidx.viewpager2.widget.ViewPager2
android:id=
"@+id/viewPager2"
...
...
app/src/main/res/mipmap-xxhdpi/h_exceliocn.png
0 → 100644
View file @
1a74a546
6.07 KB
app/src/main/res/mipmap-xxhdpi/h_pptfiocn.png
0 → 100644
View file @
1a74a546
3.76 KB
app/src/main/res/mipmap-xxhdpi/h_wordfiocn.png
0 → 100644
View file @
1a74a546
6.04 KB
app/src/main/res/values/colors.xml
View file @
1a74a546
...
...
@@ -2,4 +2,8 @@
<resources>
<color
name=
"black"
>
#FF000000
</color>
<color
name=
"white"
>
#FFFFFFFF
</color>
<color
name=
"color_f02f2b"
>
#F02F2B
</color>
<color
name=
"color_0592ee"
>
#0592EE
</color>
<color
name=
"color_149b55"
>
#149B55
</color>
<color
name=
"color_ffa127"
>
#FFA127
</color>
</resources>
\ No newline at end of file
app/src/main/res/values/dimens.xml
View file @
1a74a546
<resources>
<dimen
name=
"fab_margin"
>
16dp
</dimen>
<dimen
name=
"dp_50"
>
50dp
</dimen>
<dimen
name=
"dp_4"
>
4dp
</dimen>
</resources>
\ 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