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
7096a17f
Commit
7096a17f
authored
Sep 25, 2024
by
wanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
...
parent
c7a1e38b
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
1575 additions
and
1399 deletions
+1575
-1399
build.gradle.kts
app/build.gradle.kts
+1
-0
ExcelActivity.kt
.../pdfviewerscannerwhite/ui/document/excel/ExcelActivity.kt
+97
-8
PptActivity.kt
...base/pdfviewerscannerwhite/ui/document/ppt/PptActivity.kt
+75
-3
MainActivity.kt
...va/com/base/pdfviewerscannerwhite/ui/main/MainActivity.kt
+1
-1
DialogView.kt
...java/com/base/pdfviewerscannerwhite/ui/view/DialogView.kt
+21
-0
activity_excel.xml
app/src/main/res/layout/activity_excel.xml
+109
-6
activity_main.xml
app/src/main/res/layout/activity_main.xml
+0
-1
activity_ppt.xml
app/src/main/res/layout/activity_ppt.xml
+126
-3
dialog_document_more.xml
app/src/main/res/layout/dialog_document_more.xml
+173
-0
IOffice.java
library/src/main/java/com/cherry/lib/doc/office/IOffice.java
+6
-2
TouchEventListener.java
...a/com/cherry/lib/doc/office/macro/TouchEventListener.java
+0
-1
PGControl.java
.../java/com/cherry/lib/doc/office/pg/control/PGControl.java
+215
-301
PGEventManage.java
...a/com/cherry/lib/doc/office/pg/control/PGEventManage.java
+0
-2
PGPrintMode.java
...ava/com/cherry/lib/doc/office/pg/control/PGPrintMode.java
+258
-347
AbstractControl.kt
.../java/com/cherry/lib/doc/office/system/AbstractControl.kt
+1
-1
IMainFrame.java
...ain/java/com/cherry/lib/doc/office/system/IMainFrame.java
+110
-110
MainControl.java
...in/java/com/cherry/lib/doc/office/system/MainControl.java
+2
-1
AEventManage.java
.../com/cherry/lib/doc/office/system/beans/AEventManage.java
+115
-172
PrintWord.java
.../java/com/cherry/lib/doc/office/wp/control/PrintWord.java
+234
-337
Word.java
.../main/java/com/cherry/lib/doc/office/wp/control/Word.java
+2
-0
DocView.kt
library/src/main/java/com/cherry/lib/doc/widget/DocView.kt
+29
-59
doc_view.xml
library/src/main/res/layout/doc_view.xml
+0
-44
No files found.
app/build.gradle.kts
View file @
7096a17f
...
...
@@ -60,6 +60,7 @@ dependencies {
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"
)
implementation
(
"com.github.angcyo.DslTablayout:ViewPager2Delegate: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/ui/document/excel/ExcelActivity.kt
View file @
7096a17f
package
com.base.pdfviewerscannerwhite.ui.document.excel
import
android.annotation.SuppressLint
import
android.app.Activity
import
android.content.Intent
import
android.content.pm.ActivityInfo
import
android.view.View
import
android.view.animation.Animation
import
android.view.animation.TranslateAnimation
import
androidx.activity.addCallback
import
com.base.pdfviewerscannerwhite.bean.DocumentBean
import
com.base.pdfviewerscannerwhite.databinding.ActivityExcelBinding
import
com.base.pdfviewerscannerwhite.helper.BaseActivity
import
com.base.pdfviewerscannerwhite.ui.view.DialogView.showDocumentMore
import
com.base.pdfviewerscannerwhite.utils.KeyBoardUtils.hideKeyboard
import
com.base.pdfviewerscannerwhite.utils.LogEx
import
com.cherry.lib.doc.bean.DocEngine
import
com.cherry.lib.doc.util.Constant
import
java.io.File
class
ExcelActivity
:
BaseActivity
<
ActivityExcelBinding
>()
{
...
...
@@ -20,13 +30,13 @@ class ExcelActivity : BaseActivity<ActivityExcelBinding>() {
fun
launchDocViewer
(
activity
:
Activity
,
docSourceType
:
Int
,
path
:
String
?,
path
OrUri
:
String
?,
fileType
:
Int
?
=
null
,
engine
:
Int
?
=
null
)
{
val
intent
=
Intent
(
activity
,
ExcelActivity
::
class
.
java
)
intent
.
putExtra
(
Constant
.
INTENT_SOURCE_KEY
,
docSourceType
)
intent
.
putExtra
(
Constant
.
INTENT_DATA_KEY
,
path
)
intent
.
putExtra
(
Constant
.
INTENT_DATA_KEY
,
path
OrUri
)
intent
.
putExtra
(
Constant
.
INTENT_TYPE_KEY
,
fileType
)
intent
.
putExtra
(
Constant
.
INTENT_ENGINE_KEY
,
engine
)
activity
.
startActivity
(
intent
)
...
...
@@ -34,21 +44,100 @@ class ExcelActivity : BaseActivity<ActivityExcelBinding>() {
}
override
fun
initView
()
{
initData
(
intent
)
initSpData
(
intent
)
val
file
=
File
(
pathOrUri
?:
""
)
if
(
file
.
exists
())
{
binding
.
tvName
.
text
=
file
.
name
}
}
@SuppressLint
(
"ClickableViewAccessibility"
)
override
fun
initListener
()
{
super
.
initListener
()
onBackPressedDispatcher
.
addCallback
{
finishToMain
()
}
binding
.
flFanhui
.
setOnClickListener
{
onBackPressedDispatcher
.
onBackPressed
()
}
binding
.
ivXuanzhuan
.
setOnClickListener
{
switchOrientation
()
}
binding
.
ivMore
.
setOnClickListener
{
showDocumentMore
(
DocumentBean
.
TYPE_EXCEL
)
}
binding
.
mDocView
.
singleTapAction
=
{
LogEx
.
logDebug
(
TAG
,
"actionDownCallBack"
)
if
(
isShowTopLayout
)
{
LogEx
.
logDebug
(
TAG
,
"hide"
)
hideTopLayout
()
}
else
{
showTopLayout
()
LogEx
.
logDebug
(
TAG
,
"show"
)
}
}
}
private
fun
switchOrientation
()
{
requestedOrientation
=
if
(
requestedOrientation
==
ActivityInfo
.
SCREEN_ORIENTATION_PORTRAIT
)
{
ActivityInfo
.
SCREEN_ORIENTATION_LANDSCAPE
}
else
{
ActivityInfo
.
SCREEN_ORIENTATION_PORTRAIT
}
}
private
var
isShowTopLayout
=
true
private
fun
showTopLayout
()
{
if
(!
isShowTopLayout
)
{
isShowTopLayout
=
true
val
topAnim
:
Animation
=
TranslateAnimation
(
0f
,
0f
,
-
binding
.
vAnimatorTop
.
height
.
toFloat
(),
0f
)
topAnim
.
setDuration
(
200
)
topAnim
.
setAnimationListener
(
object
:
Animation
.
AnimationListener
{
override
fun
onAnimationStart
(
animation
:
Animation
)
{
binding
.
vAnimatorTop
.
visibility
=
View
.
VISIBLE
}
override
fun
onAnimationRepeat
(
animation
:
Animation
)
{}
override
fun
onAnimationEnd
(
animation
:
Animation
)
{
}
})
binding
.
vAnimatorTop
.
startAnimation
(
topAnim
)
}
}
private
fun
hideTopLayout
()
{
if
(
isShowTopLayout
)
{
isShowTopLayout
=
false
hideKeyboard
(
binding
.
editSearch
)
val
topAnim
:
Animation
=
TranslateAnimation
(
0f
,
0f
,
0f
,
-
binding
.
vAnimatorTop
.
height
.
toFloat
())
topAnim
.
setDuration
(
200
)
topAnim
.
setAnimationListener
(
object
:
Animation
.
AnimationListener
{
override
fun
onAnimationStart
(
animation
:
Animation
)
{}
override
fun
onAnimationRepeat
(
animation
:
Animation
)
{}
override
fun
onAnimationEnd
(
animation
:
Animation
)
{
binding
.
vAnimatorTop
.
visibility
=
View
.
GONE
}
})
binding
.
vAnimatorTop
.
startAnimation
(
topAnim
)
}
}
private
var
docSourceType
=
0
private
var
fileType
=
-
1
private
var
engine
:
Int
=
DocEngine
.
INTERNAL
.
value
private
var
docUrl
:
String
?
=
null
// 文件地址
fun
init
Data
(
intent
:
Intent
?)
{
docUrl
=
intent
?.
getStringExtra
(
Constant
.
INTENT_DATA_KEY
)
private
var
pathOrUri
:
String
?
=
null
// 文件地址
private
fun
initSp
Data
(
intent
:
Intent
?)
{
pathOrUri
=
intent
?.
getStringExtra
(
Constant
.
INTENT_DATA_KEY
)
docSourceType
=
intent
?.
getIntExtra
(
Constant
.
INTENT_SOURCE_KEY
,
0
)
?:
0
fileType
=
intent
?.
getIntExtra
(
Constant
.
INTENT_TYPE_KEY
,
-
1
)
?:
-
1
engine
=
intent
?.
getIntExtra
(
Constant
.
INTENT_ENGINE_KEY
,
DocEngine
.
INTERNAL
.
value
)
?:
DocEngine
.
INTERNAL
.
value
binding
.
mDocView
.
openDoc
(
this
,
docUrl
,
docSourceType
,
fileType
,
false
,
DocEngine
.
values
().
first
{
it
.
value
==
engine
})
LogEx
.
logDebug
(
TAG
,
"initData-
docUrl = $docUrl
"
)
binding
.
mDocView
.
openDoc
(
this
,
pathOrUri
,
docSourceType
,
fileType
,
false
,
DocEngine
.
values
().
first
{
it
.
value
==
engine
})
LogEx
.
logDebug
(
TAG
,
"initData-
pathOrUri = $pathOrUri
"
)
LogEx
.
logDebug
(
TAG
,
"initData-docSourceType = $docSourceType"
)
LogEx
.
logDebug
(
TAG
,
"initData-fileType = $fileType"
)
LogEx
.
logDebug
(
TAG
,
"initData-engine = $engine"
)
...
...
app/src/main/java/com/base/pdfviewerscannerwhite/ui/document/ppt/PptActivity.kt
View file @
7096a17f
package
com.base.pdfviewerscannerwhite.ui.document.ppt
import
android.annotation.SuppressLint
import
android.app.Activity
import
android.content.Intent
import
android.view.View
import
android.view.animation.Animation
import
android.view.animation.TranslateAnimation
import
androidx.activity.addCallback
import
androidx.core.view.isVisible
import
com.base.pdfviewerscannerwhite.databinding.ActivityPptBinding
import
com.base.pdfviewerscannerwhite.helper.BaseActivity
import
com.base.pdfviewerscannerwhite.utils.KeyBoardUtils.hideKeyboard
import
com.base.pdfviewerscannerwhite.utils.LogEx
import
com.cherry.lib.doc.bean.DocEngine
import
com.cherry.lib.doc.util.Constant
...
...
@@ -31,18 +38,45 @@ class PptActivity : BaseActivity<ActivityPptBinding>() {
intent
.
putExtra
(
Constant
.
INTENT_ENGINE_KEY
,
engine
)
activity
.
startActivity
(
intent
)
}
}
@SuppressLint
(
"SetTextI18n"
)
override
fun
initView
()
{
initData
(
intent
)
binding
.
mDocView
initSpData
(
intent
)
binding
.
mDocView
.
getPageNumberAction
=
{
current
,
total
->
if
(!
binding
.
tvPageCount
.
isVisible
)
{
binding
.
tvPageCount
.
isVisible
=
true
}
binding
.
tvPageCount
.
text
=
"$current/$total"
}
binding
.
mDocView
.
singleTapAction
=
{
LogEx
.
logDebug
(
TAG
,
"actionDownCallBack"
)
if
(
isShowTopLayout
)
{
LogEx
.
logDebug
(
TAG
,
"hide"
)
hideTopLayout
()
}
else
{
showTopLayout
()
LogEx
.
logDebug
(
TAG
,
"show"
)
}
}
}
override
fun
initListener
()
{
super
.
initListener
()
onBackPressedDispatcher
.
addCallback
{
finishToMain
()
}
binding
.
flFanhui
.
setOnClickListener
{
onBackPressedDispatcher
.
onBackPressed
()
}
}
private
var
docSourceType
=
0
private
var
fileType
=
-
1
private
var
engine
:
Int
=
DocEngine
.
INTERNAL
.
value
private
var
docUrl
:
String
?
=
null
// 文件地址
fun
init
Data
(
intent
:
Intent
?)
{
private
fun
initSp
Data
(
intent
:
Intent
?)
{
docUrl
=
intent
?.
getStringExtra
(
Constant
.
INTENT_DATA_KEY
)
docSourceType
=
intent
?.
getIntExtra
(
Constant
.
INTENT_SOURCE_KEY
,
0
)
?:
0
fileType
=
intent
?.
getIntExtra
(
Constant
.
INTENT_TYPE_KEY
,
-
1
)
?:
-
1
...
...
@@ -54,4 +88,42 @@ class PptActivity : BaseActivity<ActivityPptBinding>() {
LogEx
.
logDebug
(
TAG
,
"initData-fileType = $fileType"
)
LogEx
.
logDebug
(
TAG
,
"initData-engine = $engine"
)
}
private
fun
showTopLayout
()
{
if
(!
isShowTopLayout
)
{
isShowTopLayout
=
true
val
topAnim
:
Animation
=
TranslateAnimation
(
0f
,
0f
,
-
binding
.
vAnimatorTop
.
height
.
toFloat
(),
0f
)
topAnim
.
setDuration
(
200
)
topAnim
.
setAnimationListener
(
object
:
Animation
.
AnimationListener
{
override
fun
onAnimationStart
(
animation
:
Animation
)
{
binding
.
vAnimatorTop
.
visibility
=
View
.
VISIBLE
}
override
fun
onAnimationRepeat
(
animation
:
Animation
)
{}
override
fun
onAnimationEnd
(
animation
:
Animation
)
{
}
})
binding
.
vAnimatorTop
.
startAnimation
(
topAnim
)
}
}
private
var
isShowTopLayout
=
true
private
fun
hideTopLayout
()
{
if
(
isShowTopLayout
)
{
isShowTopLayout
=
false
hideKeyboard
(
binding
.
editSearch
)
val
topAnim
:
Animation
=
TranslateAnimation
(
0f
,
0f
,
0f
,
-
binding
.
vAnimatorTop
.
height
.
toFloat
())
topAnim
.
setDuration
(
200
)
topAnim
.
setAnimationListener
(
object
:
Animation
.
AnimationListener
{
override
fun
onAnimationStart
(
animation
:
Animation
)
{}
override
fun
onAnimationRepeat
(
animation
:
Animation
)
{}
override
fun
onAnimationEnd
(
animation
:
Animation
)
{
binding
.
vAnimatorTop
.
visibility
=
View
.
GONE
}
})
binding
.
vAnimatorTop
.
startAnimation
(
topAnim
)
}
}
}
\ No newline at end of file
app/src/main/java/com/base/pdfviewerscannerwhite/ui/main/MainActivity.kt
View file @
7096a17f
...
...
@@ -61,7 +61,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), MainView {
binding
.
viewPager2
.
offscreenPageLimit
=
4
binding
.
viewPager2
.
run
{
isUserInputEnabled
=
fals
e
isUserInputEnabled
=
tru
e
adapter
=
object
:
FragmentStateAdapter
(
this
@MainActivity
)
{
override
fun
getItemCount
():
Int
{
return
fragments
.
size
...
...
app/src/main/java/com/base/pdfviewerscannerwhite/ui/view/DialogView.kt
View file @
7096a17f
...
...
@@ -12,9 +12,11 @@ import androidx.core.content.FileProvider
import
androidx.core.widget.addTextChangedListener
import
com.base.pdfviewerscannerwhite.R
import
com.base.pdfviewerscannerwhite.bean.DocumentBean
import
com.base.pdfviewerscannerwhite.bean.DocumentBean.Companion.TYPE_EXCEL
import
com.base.pdfviewerscannerwhite.databinding.DialogCommonTipBinding
import
com.base.pdfviewerscannerwhite.databinding.DialogDeleteBinding
import
com.base.pdfviewerscannerwhite.databinding.DialogDocumentDetailBinding
import
com.base.pdfviewerscannerwhite.databinding.DialogDocumentMoreBinding
import
com.base.pdfviewerscannerwhite.databinding.DialogDocumentRenameBinding
import
com.base.pdfviewerscannerwhite.databinding.DialogPageNumberBinding
import
com.base.pdfviewerscannerwhite.databinding.DialogPdfDetailBinding
...
...
@@ -25,6 +27,7 @@ import com.base.pdfviewerscannerwhite.ui.adapter.DocumentAdapter
import
com.base.pdfviewerscannerwhite.ui.document.pdf.PdfBoxUtils
import
com.base.pdfviewerscannerwhite.ui.main.DocumentView
import
com.base.pdfviewerscannerwhite.ui.document.pdf.PdfView
import
com.base.pdfviewerscannerwhite.ui.view.DialogView.showPdfMoreDialog
import
com.base.pdfviewerscannerwhite.utils.ActivityLauncher
import
com.base.pdfviewerscannerwhite.utils.IntentShareUtils.sharePdfIntent
import
com.base.pdfviewerscannerwhite.utils.IntentShareUtils.sharePdfPrintIntent
...
...
@@ -228,6 +231,24 @@ object DialogView {
}
fun
Activity
.
showDocumentMore
(
type
:
String
)
{
val
dialog
=
BottomSheetDialog
(
this
,
R
.
style
.
BottomSheetDialog
)
val
binding
=
DialogDocumentMoreBinding
.
inflate
(
LayoutInflater
.
from
(
this
))
dialog
.
setContentView
(
binding
.
root
)
dialog
.
setCanceledOnTouchOutside
(
false
)
dialog
.
show
()
val
parentView
=
binding
.
root
.
parent
as
View
val
behavior
=
BottomSheetBehavior
.
from
(
parentView
)
//展开
behavior
.
state
=
BottomSheetBehavior
.
STATE_EXPANDED
if
(
type
==
TYPE_EXCEL
)
{
binding
.
llJump
.
visibility
=
View
.
GONE
}
}
@SuppressLint
(
"SetTextI18n"
)
fun
Context
.
showPdfPwdDialog
(
...
...
app/src/main/res/layout/activity_excel.xml
View file @
7096a17f
...
...
@@ -7,16 +7,119 @@
android:layout_height=
"match_parent"
tools:context=
".ui.document.excel.ExcelActivity"
>
<ViewAnimator
android:id=
"@+id/v_animator_top"
android:layout_width=
"match_parent"
android:layout_height=
"60dp"
android:background=
"@color/white"
app:layout_constraintTop_toTopOf=
"parent"
>
<androidx.constraintlayout.widget.ConstraintLayout
android:id=
"@+id/cl_top"
android:layout_width=
"match_parent"
android:layout_height=
"60dp"
app:layout_constraintTop_toTopOf=
"parent"
>
<FrameLayout
android:id=
"@+id/fl_fanhui"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toStartOf=
"@id/tv_name"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
>
<ImageView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center"
android:padding=
"15dp"
android:src=
"@mipmap/fanhui_b"
tools:ignore=
"ContentDescription"
/>
</FrameLayout>
<TextView
android:id=
"@+id/tv_name"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:ellipsize=
"end"
android:singleLine=
"true"
android:textColor=
"@color/black"
android:textSize=
"19sp"
android:textStyle=
"bold"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toStartOf=
"@+id/iv_xuanzhuan"
app:layout_constraintStart_toEndOf=
"@id/fl_fanhui"
app:layout_constraintTop_toTopOf=
"parent"
tools:ignore=
"HardcodedText"
tools:text=
"DEMO.xlsx"
/>
<ImageView
android:id=
"@+id/iv_xuanzhuan"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginEnd=
"16dp"
android:src=
"@mipmap/hengping"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toStartOf=
"@id/iv_search"
app:layout_constraintTop_toTopOf=
"parent"
tools:ignore=
"ContentDescription"
/>
<ImageView
android:id=
"@+id/iv_search"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginEnd=
"16dp"
android:src=
"@mipmap/h_sousuo"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toStartOf=
"@id/iv_more"
app:layout_constraintTop_toTopOf=
"parent"
tools:ignore=
"ContentDescription"
/>
<ImageView
android:id=
"@+id/iv_more"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginEnd=
"16dp"
android:src=
"@mipmap/x_genduo"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
tools:ignore=
"ContentDescription"
/>
<EditText
android:id=
"@+id/edit_search"
android:layout_width=
"0dp"
android:layout_height=
"40dp"
android:layout_marginStart=
"5dp"
android:layout_marginEnd=
"20dp"
android:background=
"@drawable/bg_f8f9fe_10"
android:hint=
"input..."
android:paddingHorizontal=
"18dp"
android:singleLine=
"true"
android:textColor=
"@color/black"
android:textColorHint=
"#B8B9BD"
android:visibility=
"gone"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toStartOf=
"@id/iv_search"
app:layout_constraintStart_toEndOf=
"@id/fl_fanhui"
app:layout_constraintTop_toTopOf=
"parent"
tools:ignore=
"Autofill,HardcodedText,TextFields"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
</ViewAnimator>
<com.cherry.lib.doc.widget.DocView
android:id=
"@+id/mDocView"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
app:dv_engine=
"internal"
android:layout_height=
"0dp"
app:dv_moving_orientation=
"vertical"
app:dv_page_pb_color=
"@color/yellow"
app:dv_page_pb_height=
"2dp"
app:dv_quality=
"normal"
app:dv_show_page_num=
"false"
/>
app:dv_show_page_num=
"false"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@id/v_animator_top"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
app/src/main/res/layout/activity_main.xml
View file @
7096a17f
...
...
@@ -166,7 +166,6 @@
</com.angcyo.tablayout.DslTabLayout>
</FrameLayout>
<androidx.viewpager2.widget.ViewPager2
android:id=
"@+id/viewPager2"
android:layout_width=
"match_parent"
...
...
app/src/main/res/layout/activity_ppt.xml
View file @
7096a17f
...
...
@@ -7,15 +7,138 @@
android:layout_height=
"match_parent"
tools:context=
".ui.document.ppt.PptActivity"
>
<ViewAnimator
android:id=
"@+id/v_animator_top"
android:layout_width=
"match_parent"
android:layout_height=
"60dp"
android:background=
"@color/white"
app:layout_constraintTop_toTopOf=
"parent"
>
<androidx.constraintlayout.widget.ConstraintLayout
android:id=
"@+id/cl_top"
android:layout_width=
"match_parent"
android:layout_height=
"60dp"
app:layout_constraintTop_toTopOf=
"parent"
>
<FrameLayout
android:id=
"@+id/fl_fanhui"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toStartOf=
"@id/tv_name"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
>
<ImageView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center"
android:padding=
"15dp"
android:src=
"@mipmap/fanhui_b"
tools:ignore=
"ContentDescription"
/>
</FrameLayout>
<TextView
android:id=
"@+id/tv_name"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:ellipsize=
"end"
android:singleLine=
"true"
android:textColor=
"@color/black"
android:textSize=
"19sp"
android:textStyle=
"bold"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toStartOf=
"@+id/iv_xuanzhuan"
app:layout_constraintStart_toEndOf=
"@id/fl_fanhui"
app:layout_constraintTop_toTopOf=
"parent"
tools:ignore=
"HardcodedText"
tools:text=
"DEMO.ppt"
/>
<ImageView
android:id=
"@+id/iv_xuanzhuan"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginEnd=
"16dp"
android:src=
"@mipmap/hengping"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toStartOf=
"@id/iv_search"
app:layout_constraintTop_toTopOf=
"parent"
tools:ignore=
"ContentDescription"
/>
<ImageView
android:id=
"@+id/iv_search"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginEnd=
"16dp"
android:src=
"@mipmap/h_sousuo"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toStartOf=
"@id/iv_more"
app:layout_constraintTop_toTopOf=
"parent"
tools:ignore=
"ContentDescription"
/>
<ImageView
android:id=
"@+id/iv_more"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginEnd=
"16dp"
android:src=
"@mipmap/x_genduo"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
tools:ignore=
"ContentDescription"
/>
<EditText
android:id=
"@+id/edit_search"
android:layout_width=
"0dp"
android:layout_height=
"40dp"
android:layout_marginStart=
"5dp"
android:layout_marginEnd=
"20dp"
android:background=
"@drawable/bg_f8f9fe_10"
android:hint=
"input..."
android:paddingHorizontal=
"18dp"
android:singleLine=
"true"
android:textColor=
"@color/black"
android:textColorHint=
"#B8B9BD"
android:visibility=
"gone"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toStartOf=
"@id/iv_search"
app:layout_constraintStart_toEndOf=
"@id/fl_fanhui"
app:layout_constraintTop_toTopOf=
"parent"
tools:ignore=
"Autofill,HardcodedText,TextFields"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
</ViewAnimator>
<com.cherry.lib.doc.widget.DocView
android:id=
"@+id/mDocView"
android:layout_width=
"match_parent"
android:layout_height=
"
match_parent
"
android:layout_height=
"
0dp
"
app:dv_engine=
"internal"
app:dv_moving_orientation=
"vertical"
app:dv_page_pb_color=
"@color/yellow"
app:dv_page_pb_height=
"2dp"
app:dv_quality=
"normal"
app:dv_show_page_num=
"false"
/>
app:dv_show_page_num=
"true"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@id/v_animator_top"
/>
<TextView
android:visibility=
"gone"
android:id=
"@+id/tv_pageCount"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"28dp"
android:layout_marginTop=
"28dp"
android:background=
"@drawable/bg_54585b_5"
android:includeFontPadding=
"false"
android:paddingHorizontal=
"2dp"
android:paddingVertical=
"2dp"
android:textColor=
"@color/white"
android:textSize=
"12sp"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@id/v_animator_top"
tools:text=
"1/3"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
app/src/main/res/layout/dialog_document_more.xml
0 → 100644
View file @
7096a17f
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:background=
"@drawable/bg_f1f1f1_tlr25"
android:orientation=
"vertical"
>
<androidx.constraintlayout.widget.ConstraintLayout
android:id=
"@+id/cl"
android:layout_width=
"match_parent"
android:layout_height=
"65dp"
app:layout_constraintTop_toTopOf=
"parent"
>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"15dp"
android:text=
"More"
android:textColor=
"#333333"
android:textStyle=
"bold"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
tools:ignore=
"HardcodedText"
/>
<ImageView
android:id=
"@+id/iv_bookmark"
android:layout_width=
"24dp"
android:layout_height=
"32dp"
android:layout_marginEnd=
"27dp"
android:src=
"@mipmap/h_soucang_n"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
tools:ignore=
"ContentDescription"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:background=
"@color/white"
android:orientation=
"vertical"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@id/cl"
>
<LinearLayout
android:id=
"@+id/ll_jump"
android:layout_width=
"match_parent"
android:layout_height=
"60dp"
android:background=
"?android:selectableItemBackground"
android:orientation=
"horizontal"
>
<ImageView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_vertical"
android:layout_marginStart=
"13dp"
android:src=
"@mipmap/jump"
tools:ignore=
"ContentDescription"
/>
<TextView
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_vertical"
android:layout_marginHorizontal=
"13dp"
android:layout_weight=
"1"
android:ellipsize=
"end"
android:includeFontPadding=
"false"
android:singleLine=
"true"
android:text=
"Jump to the specified page"
android:textColor=
"#333333"
android:textSize=
"16sp"
tools:ignore=
"HardcodedText"
/>
<ImageView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_vertical"
android:layout_marginEnd=
"20dp"
android:src=
"@mipmap/jianotou"
tools:ignore=
"ContentDescription"
/>
</LinearLayout>
<LinearLayout
android:id=
"@+id/ll_detail"
android:layout_width=
"match_parent"
android:layout_height=
"60dp"
android:background=
"?android:selectableItemBackground"
android:orientation=
"horizontal"
>
<ImageView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_vertical"
android:layout_marginStart=
"13dp"
android:src=
"@mipmap/particulars"
tools:ignore=
"ContentDescription"
/>
<TextView
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_vertical"
android:layout_marginHorizontal=
"13dp"
android:layout_weight=
"1"
android:ellipsize=
"end"
android:includeFontPadding=
"false"
android:singleLine=
"true"
android:text=
"Detail"
android:textColor=
"#333333"
android:textSize=
"16sp"
tools:ignore=
"HardcodedText"
/>
<ImageView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_vertical"
android:layout_marginEnd=
"20dp"
android:src=
"@mipmap/jianotou"
tools:ignore=
"ContentDescription"
/>
</LinearLayout>
<LinearLayout
android:id=
"@+id/ll_share"
android:layout_width=
"match_parent"
android:layout_height=
"60dp"
android:layout_marginBottom=
"20dp"
android:background=
"?android:selectableItemBackground"
android:orientation=
"horizontal"
>
<ImageView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_vertical"
android:layout_marginStart=
"13dp"
android:src=
"@mipmap/share"
tools:ignore=
"ContentDescription"
/>
<TextView
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_vertical"
android:layout_marginHorizontal=
"13dp"
android:layout_weight=
"1"
android:ellipsize=
"end"
android:includeFontPadding=
"false"
android:singleLine=
"true"
android:text=
"Share"
android:textColor=
"#333333"
android:textSize=
"16sp"
tools:ignore=
"HardcodedText"
/>
<ImageView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_vertical"
android:layout_marginEnd=
"20dp"
android:src=
"@mipmap/jianotou"
tools:ignore=
"ContentDescription"
/>
</LinearLayout>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
library/src/main/java/com/cherry/lib/doc/office/IOffice.java
View file @
7096a17f
...
...
@@ -3,8 +3,10 @@ package com.cherry.lib.doc.office;
import
android.app.Activity
;
import
android.graphics.Bitmap
;
import
android.graphics.Color
;
import
android.util.Log
;
import
android.view.MotionEvent
;
import
android.view.View
;
import
com.blankj.utilcode.util.AppUtils
;
import
com.cherry.lib.doc.office.common.IOfficeToPicture
;
import
com.cherry.lib.doc.office.constant.EventConstant
;
...
...
@@ -12,6 +14,7 @@ import com.cherry.lib.doc.office.constant.wp.WPViewConstant;
import
com.cherry.lib.doc.office.res.ResKit
;
import
com.cherry.lib.doc.office.system.IMainFrame
;
import
com.cherry.lib.doc.office.system.MainControl
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
...
...
@@ -22,6 +25,7 @@ import java.util.List;
*/
public
abstract
class
IOffice
implements
IMainFrame
{
private
String
TAG
=
"IOffice"
;
private
MainControl
control
;
private
boolean
writeLog
=
true
;
//view background
...
...
@@ -148,6 +152,7 @@ public abstract class IOffice implements IMainFrame {
* @return True if the listener has consumed the event, false otherwise.
*/
public
boolean
doActionEvent
(
int
actionID
,
Object
obj
)
{
Log
.
e
(
TAG
,
"doActionEvent actionID"
+
actionID
);
try
{
switch
(
actionID
)
{
case
EventConstant
.
SYS_UPDATE_TOOLSBAR_BUTTON_STATUS
:
//update toolsbar state
...
...
@@ -192,8 +197,7 @@ public abstract class IOffice implements IMainFrame {
return
0
;
}
public
boolean
onEventMethod
(
View
v
,
MotionEvent
e1
,
MotionEvent
e2
,
float
xValue
,
float
yValue
,
byte
eventMethodType
)
{
public
boolean
onEventMethod
(
View
v
,
MotionEvent
e1
,
MotionEvent
e2
,
float
xValue
,
float
yValue
,
byte
eventMethodType
)
{
return
false
;
}
...
...
library/src/main/java/com/cherry/lib/doc/office/macro/TouchEventListener.java
View file @
7096a17f
...
...
@@ -39,7 +39,6 @@ public interface TouchEventListener
* @param e2 MotionEvent instance
* @param velocityX x axis velocity
* @param velocityY y axis velocity
* @param eventNethodType event method
* @see TouchEventListener#EVENT_CLICK
* @see TouchEventListener#EVENT_DOUBLE_TAP
* @see TouchEventListener#EVENT_DOUBLE_TAP_EVENT
...
...
library/src/main/java/com/cherry/lib/doc/office/pg/control/PGControl.java
View file @
7096a17f
This diff is collapsed.
Click to expand it.
library/src/main/java/com/cherry/lib/doc/office/pg/control/PGEventManage.java
View file @
7096a17f
...
...
@@ -9,8 +9,6 @@ package com.cherry.lib.doc.office.pg.control;
import
com.cherry.lib.doc.office.common.ISlideShow
;
import
com.cherry.lib.doc.office.system.IControl
;
import
com.cherry.lib.doc.office.system.beans.AEventManage
;
import
com.cherry.lib.doc.office.system.beans.ATimer
;
import
android.graphics.Rect
;
import
android.view.MotionEvent
;
import
android.view.View
;
...
...
library/src/main/java/com/cherry/lib/doc/office/pg/control/PGPrintMode.java
View file @
7096a17f
This diff is collapsed.
Click to expand it.
library/src/main/java/com/cherry/lib/doc/office/system/AbstractControl.kt
View file @
7096a17f
library/src/main/java/com/cherry/lib/doc/office/system/IMainFrame.java
View file @
7096a17f
...
...
@@ -29,8 +29,7 @@ import android.view.View;
* <p>
* <p>
*/
public
interface
IMainFrame
{
public
interface
IMainFrame
{
// onTouch
public
final
static
byte
ON_TOUCH
=
0
;
// onDown
...
...
@@ -56,6 +55,7 @@ public interface IMainFrame
/**
* get activity instance
*
* @return activity instance
*/
public
Activity
getActivity
();
...
...
@@ -64,9 +64,7 @@ public interface IMainFrame
* do action
*
* @param actionID action ID
*
* @param obj acValue
*
* @return True if the listener has consumed the event, false otherwise.
*/
public
boolean
doActionEvent
(
int
actionID
,
Object
obj
);
...
...
@@ -92,24 +90,26 @@ public interface IMainFrame
/**
* get bottom bar height
*
* @return bottom bar height
*/
public
int
getBottomBarHeight
();
/**
* get top bar height
*
* @return top bar height
*/
public
int
getTopBarHeight
();
/**
* get application name;
*
* @return application name
*/
public
String
getAppName
();
/**
*
* @return
*/
public
File
getTemporaryDirectory
();
...
...
@@ -123,11 +123,9 @@ public interface IMainFrame
* @param xValue eventNethodType is ON_SCROLL, this is value distanceX
* eventNethodType is ON_FLING, this is value velocityY
* eventNethodType is other type, this is value -1
*
* @param yValue eventNethodType is ON_SCROLL, this is value distanceY
* eventNethodType is ON_FLING, this is value velocityY
* eventNethodType is other type, this is value -1
* @param eventNethodType event method
* @see IMainFrame#ON_CLICK
* @see IMainFrame#ON_DOUBLE_TAP
* @see IMainFrame#ON_DOUBLE_TAP_EVENT
...
...
@@ -142,8 +140,15 @@ public interface IMainFrame
*/
public
boolean
onEventMethod
(
View
v
,
MotionEvent
e1
,
MotionEvent
e2
,
float
xValue
,
float
yValue
,
byte
eventMethodType
);
//单次点击
public
void
singleTap
();
//获取页码
public
void
getPageNumber
(
int
current
,
int
total
);
/**
* is support draw page number
*
* @return true draw page number
* false don’t draw page number
*/
...
...
@@ -153,6 +158,7 @@ public interface IMainFrame
/**
* true: show message when zooming
* false: not show message when zooming
*
* @return
*/
public
boolean
isShowZoomingMsg
();
...
...
@@ -160,18 +166,21 @@ public interface IMainFrame
/**
* true: pop up dialog when throw err
* false: not pop up dialog when throw err
*
* @return
*/
public
boolean
isPopUpErrorDlg
();
/**
* show password dialog when parse file with password
*
* @return
*/
public
boolean
isShowPasswordDlg
();
/**
* show progress bar or not when parsing document
*
* @return
*/
public
boolean
isShowProgressBar
();
...
...
@@ -183,12 +192,14 @@ public interface IMainFrame
/**
* show txt encode dialog when parse txt file
*
* @return
*/
public
boolean
isShowTXTEncodeDlg
();
/**
* get txt default encode when not showing txt encode dialog
*
* @return null if showing txt encode dialog
*/
public
String
getTXTDefaultEncode
();
...
...
@@ -215,7 +226,6 @@ public interface IMainFrame
*
* @return 0, page view
* 1,normal view;
*
*/
public
byte
getWordDefaultView
();
...
...
@@ -252,13 +262,11 @@ public interface IMainFrame
public
void
fullScreen
(
boolean
fullscreen
);
/**
*
* @param visible
*/
public
void
showProgressBar
(
boolean
visible
);
/**
*
* @param viewList
*/
public
void
updateViewImages
(
List
<
Integer
>
viewList
);
...
...
@@ -267,9 +275,6 @@ public interface IMainFrame
/**
* set change page flag, Only when effectively the PageSize greater than ViewSize.
* (for PPT, word print mode, PDF)
*
* @param b = true, change page
* = false, don't change page
*/
public
boolean
isChangePage
();
...
...
@@ -279,52 +284,47 @@ public interface IMainFrame
//public void destroyEngine();
/**
*
* @param saveLog
*/
public
void
setWriteLog
(
boolean
saveLog
);
/**
*
* @return
*/
public
boolean
isWriteLog
();
/**
*
* @param isThumbnail
*/
public
void
setThumbnail
(
boolean
isThumbnail
);
/**
*
* @return
*/
public
boolean
isThumbnail
();
/**
* get view backgrouond
*
* @return
*/
public
Object
getViewBackground
();
/**
* set flag whether fitzoom can be larger than 100% but smaller than the max zoom
*
* @param ignoreOriginalSize
*/
public
void
setIgnoreOriginalSize
(
boolean
ignoreOriginalSize
);
/**
*
* @return
* true fitzoom may be larger than 100% but smaller than the max zoom
* @return true fitzoom may be larger than 100% but smaller than the max zoom
* false fitzoom can not larger than 100%
*/
public
boolean
isIgnoreOriginalSize
();
/**
* page list view moving position
* @param position horizontal or vertical
*/
public
int
getPageListViewMovingPosition
();
...
...
library/src/main/java/com/cherry/lib/doc/office/system/MainControl.java
View file @
7096a17f
...
...
@@ -140,7 +140,7 @@ public class MainControl extends AbstractControl {
*/
public
void
dismissProgressDialog
()
{
if
(
progressDialog
!=
null
)
{
if
(
progressDialog
.
getWindow
()
!=
null
)
{
if
(
progressDialog
.
getWindow
()
!=
null
)
{
progressDialog
.
dismiss
();
}
progressDialog
=
null
;
...
...
@@ -316,6 +316,7 @@ public class MainControl extends AbstractControl {
* @param obj 动作ID的Value
*/
public
void
actionEvent
(
int
actionID
,
final
Object
obj
)
{
Log
.
e
(
"MainControl"
,
"actionEvent "
+
actionID
);
if
(
actionID
==
EventConstant
.
SYS_READER_FINSH_ID
)
{
if
(
reader
!=
null
)
{
if
(
appControl
!=
null
)
{
...
...
library/src/main/java/com/cherry/lib/doc/office/system/beans/AEventManage.java
View file @
7096a17f
This diff is collapsed.
Click to expand it.
library/src/main/java/com/cherry/lib/doc/office/wp/control/PrintWord.java
View file @
7096a17f
This diff is collapsed.
Click to expand it.
library/src/main/java/com/cherry/lib/doc/office/wp/control/Word.java
View file @
7096a17f
...
...
@@ -17,6 +17,7 @@ import android.graphics.Rect;
import
android.graphics.Typeface
;
import
android.graphics.drawable.Drawable
;
import
android.util.AttributeSet
;
import
android.util.Log
;
import
android.view.View
;
import
android.widget.LinearLayout
;
...
...
@@ -569,6 +570,7 @@ public class Word extends LinearLayout implements IWord {
* @param zoom
*/
private
void
drawPageNubmer
(
Canvas
canvas
,
float
zoom
)
{
Log
.
e
(
"Word"
,
"drawPageNubmer"
);
int
currentNumber
=
getCurrentPageNumber
();
if
(
control
.
getMainFrame
().
isDrawPageNumber
()
&&
pageRoot
!=
null
)
{
Rect
rect
=
canvas
.
getClipBounds
();
...
...
library/src/main/java/com/cherry/lib/doc/widget/DocView.kt
View file @
7096a17f
...
...
@@ -9,6 +9,7 @@ import android.graphics.Rect
import
android.graphics.drawable.Drawable
import
android.util.AttributeSet
import
android.util.Log
import
android.view.MotionEvent
import
android.view.View
import
android.view.ViewGroup
import
android.widget.FrameLayout
...
...
@@ -52,27 +53,19 @@ class DocView : FrameLayout {
private
val
TAG
=
"DocView"
var
mActivity
:
Activity
?
=
null
var
lifecycleScope
:
LifecycleCoroutineScope
=
(
context
as
AppCompatActivity
).
lifecycleScope
private
var
mPoiViewer
:
PoiViewer
?
=
null
private
var
mMovingOrientation
=
DocMovingOrientation
.
HORIZONTAL
private
var
engine
=
DocEngine
.
INTERNAL
private
var
showDivider
=
true
private
var
showPageNum
=
true
private
var
divider
:
Drawable
?
=
null
private
var
runnable
=
Runnable
{}
var
enableLoadingForPages
:
Boolean
=
true
var
pbDefaultHeight
=
2
var
pbHeight
:
Int
=
pbDefaultHeight
var
pbDefaultColor
=
Color
.
RED
var
pbColor
:
Int
=
pbDefaultColor
private
var
pdfRendererCoreInitialised
=
false
var
pageMargin
:
Rect
=
Rect
(
0
,
0
,
0
,
0
)
var
totalPageCount
=
0
var
mOnDocPageChangeListener
:
OnDocPageChangeListener
?
=
null
var
sourceFilePath
:
String
?
=
null
var
mViewPdfInPage
:
Boolean
=
true
...
...
@@ -87,9 +80,6 @@ class DocView : FrameLayout {
fun
initView
(
attrs
:
AttributeSet
?,
defStyle
:
Int
)
{
inflate
(
context
,
R
.
layout
.
doc_view
,
this
)
binding
=
DocViewBinding
.
bind
(
this
)
binding
.
mIvPdf
.
setOnClickListener
{
binding
.
mLlBigPdfImage
.
hide
()
}
val
typedArray
=
context
.
obtainStyledAttributes
(
attrs
,
R
.
styleable
.
DocView
,
defStyle
,
0
)
...
...
@@ -114,7 +104,6 @@ class DocView : FrameLayout {
bottom
=
typedArray
.
getDimensionPixelSize
(
R
.
styleable
.
DocView_dv_page_marginBottom
,
bottom
)
}
binding
.
mPdfPageNo
.
isVisible
=
showPageNum
val
layoutParams
=
binding
.
mPlLoadProgress
.
layoutParams
layoutParams
.
height
=
pbHeight
...
...
@@ -125,7 +114,6 @@ class DocView : FrameLayout {
typedArray
.
recycle
()
}
fun
openDoc
(
activity
:
Activity
,
docUrl
:
String
?,
docSourceType
:
Int
,
engine
:
DocEngine
=
this
.
engine
...
...
@@ -136,8 +124,10 @@ class DocView : FrameLayout {
@SuppressLint
(
"ObsoleteSdkInt"
)
fun
openDoc
(
activity
:
Activity
?,
docUrl
:
String
?,
docSourceType
:
Int
,
fileType
:
Int
,
activity
:
Activity
?,
docUrl
:
String
?,
docSourceType
:
Int
,
fileType
:
Int
,
viewPdfInPage
:
Boolean
=
false
,
engine
:
DocEngine
=
this
.
engine
)
{
...
...
@@ -180,7 +170,6 @@ class DocView : FrameLayout {
when
(
type
)
{
FileType
.
PDF
->
{
Log
.
e
(
TAG
,
"openDoc()......PDF"
)
// binding.mDocWeb.hide()
binding
.
mFlDocContainer
.
hide
()
binding
.
mIvImage
.
hide
()
...
...
@@ -191,7 +180,6 @@ class DocView : FrameLayout {
showPageNum
=
false
}
Log
.
e
(
TAG
,
"openDoc()......"
)
// binding.mDocWeb.hide()
binding
.
mFlDocContainer
.
hide
()
binding
.
mIvImage
.
show
()
if
(
docSourceType
==
DocSourceType
.
PATH
)
{
...
...
@@ -218,9 +206,33 @@ class DocView : FrameLayout {
}
}
var
singleTapAction
:
(()
->
Unit
)?
=
null
var
getPageNumberAction
:
((
current
:
Int
,
total
:
Int
)
->
Unit
)?
=
null
fun
showDoc
(
activity
:
Activity
,
mDocContainer
:
ViewGroup
?,
url
:
String
?,
docSourceType
:
Int
,
fileType
:
Int
)
{
Log
.
e
(
TAG
,
"showDoc()......"
)
val
iOffice
:
IOffice
=
object
:
IOffice
()
{
override
fun
onEventMethod
(
v
:
View
?,
e1
:
MotionEvent
?,
e2
:
MotionEvent
?,
xValue
:
Float
,
yValue
:
Float
,
eventMethodType
:
Byte
):
Boolean
{
Log
.
e
(
TAG
,
"onEventMethod ${e1?.action} ${MotionEvent.ACTION_DOWN}"
)
return
super
.
onEventMethod
(
v
,
e1
,
e2
,
xValue
,
yValue
,
eventMethodType
)
}
override
fun
singleTap
()
{
Log
.
e
(
TAG
,
"singleTap"
)
singleTapAction
?.
invoke
()
}
override
fun
getPageNumber
(
current
:
Int
,
total
:
Int
)
{
getPageNumberAction
?.
invoke
(
current
,
total
)
}
override
fun
getActivity
():
Activity
{
return
activity
}
...
...
@@ -269,52 +281,10 @@ class DocView : FrameLayout {
}
}
//是否绘制页码
iOffice
.
isDrawPageNumber
iOffice
.
openFile
(
url
,
docSourceType
,
fileType
.
toString
())
}
private
val
scrollListener
=
object
:
RecyclerView
.
OnScrollListener
()
{
override
fun
onScrolled
(
recyclerView
:
RecyclerView
,
dx
:
Int
,
dy
:
Int
)
{
super
.
onScrolled
(
recyclerView
,
dx
,
dy
)
(
recyclerView
.
layoutManager
as
LinearLayoutManager
).
run
{
var
foundPosition
:
Int
=
findLastCompletelyVisibleItemPosition
()
if
(
foundPosition
!=
RecyclerView
.
NO_POSITION
)
binding
.
mPdfPageNo
.
text
=
context
.
getString
(
R
.
string
.
pdfView_page_no
,
foundPosition
+
1
,
totalPageCount
)
if
(
showPageNum
)
{
binding
.
mPdfPageNo
.
visibility
=
View
.
VISIBLE
}
if
(
foundPosition
==
0
&&
!
mViewPdfInPage
)
binding
.
mPdfPageNo
.
postDelayed
({
binding
.
mPdfPageNo
.
visibility
=
GONE
},
3000
)
if
(
foundPosition
!=
RecyclerView
.
NO_POSITION
)
{
mOnDocPageChangeListener
?.
OnPageChanged
(
foundPosition
,
totalPageCount
)
return
@run
}
foundPosition
=
findFirstVisibleItemPosition
()
if
(
foundPosition
!=
RecyclerView
.
NO_POSITION
)
{
mOnDocPageChangeListener
?.
OnPageChanged
(
foundPosition
,
totalPageCount
)
return
@run
}
}
}
override
fun
onScrollStateChanged
(
recyclerView
:
RecyclerView
,
newState
:
Int
)
{
super
.
onScrollStateChanged
(
recyclerView
,
newState
)
if
(
newState
==
RecyclerView
.
SCROLL_STATE_IDLE
&&
!
mViewPdfInPage
)
{
binding
.
mPdfPageNo
.
postDelayed
(
runnable
,
3000
)
}
else
{
binding
.
mPdfPageNo
.
removeCallbacks
(
runnable
)
}
}
}
override
fun
onDetachedFromWindow
()
{
super
.
onDetachedFromWindow
()
onDestroy
()
...
...
library/src/main/res/layout/doc_view.xml
View file @
7096a17f
...
...
@@ -4,38 +4,6 @@
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<FrameLayout
android:id=
"@+id/mLlBigPdfImage"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:background=
"@color/white"
android:visibility=
"gone"
>
<com.cherry.lib.doc.widget.PinchImageView
android:id=
"@+id/mIvPdf"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
/>
<ProgressBar
android:id=
"@+id/mPbBigLoading"
android:layout_width=
"40dp"
android:layout_height=
"40dp"
android:layout_gravity=
"center"
android:visibility=
"gone"
tools:visibility=
"visible"
/>
<ImageView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"end"
android:layout_marginTop=
"50dp"
android:layout_marginEnd=
"30dp"
android:scaleType=
"fitCenter"
android:src=
"@mipmap/ic_big_close"
tools:ignore=
"ContentDescription"
/>
</FrameLayout>
<FrameLayout
android:id=
"@+id/mFlDocContainer"
android:layout_width=
"match_parent"
...
...
@@ -55,17 +23,5 @@
android:progressDrawable=
"@drawable/pb_webview_layer"
android:visibility=
"visible"
/>
<TextView
android:id=
"@+id/mPdfPageNo"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_margin=
"18dp"
android:background=
"@drawable/page_counter"
android:paddingStart=
"12dp"
android:paddingTop=
"4dp"
android:paddingEnd=
"12dp"
android:paddingBottom=
"4dp"
android:textColor=
"#A19D9D"
android:textSize=
"16sp"
/>
</FrameLayout>
\ 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