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
e73b5f11
Commit
e73b5f11
authored
Sep 30, 2024
by
wanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
...
parent
23d3e3d9
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
304 additions
and
267 deletions
+304
-267
MainActivity.kt
...va/com/base/pdfviewerscannerwhite/ui/main/MainActivity.kt
+23
-3
MainPresenter.kt
...a/com/base/pdfviewerscannerwhite/ui/main/MainPresenter.kt
+15
-0
activity_main2.xml
app/src/main/res/layout/activity_main2.xml
+11
-0
strings.xml
app/src/main/res/values/strings.xml
+5
-10
ChoosePDFActivity.java
...rc/main/java/com/artifex/mupdfdemo/ChoosePDFActivity.java
+198
-199
strings.xml
pdflibrary/src/main/res/values-zh/strings.xml
+52
-53
strings.xml
pdflibrary/src/main/res/values/strings.xml
+0
-2
No files found.
app/src/main/java/com/base/pdfviewerscannerwhite/ui/main/MainActivity.kt
View file @
e73b5f11
...
@@ -21,15 +21,18 @@ import com.base.pdfviewerscannerwhite.ui.document.pdf.PdfActivity
...
@@ -21,15 +21,18 @@ import com.base.pdfviewerscannerwhite.ui.document.pdf.PdfActivity
import
com.base.pdfviewerscannerwhite.ui.document.ppt.PptActivity
import
com.base.pdfviewerscannerwhite.ui.document.ppt.PptActivity
import
com.base.pdfviewerscannerwhite.ui.document.word.WordActivity
import
com.base.pdfviewerscannerwhite.ui.document.word.WordActivity
import
com.base.pdfviewerscannerwhite.ui.view.DialogView.showDeleteDialog
import
com.base.pdfviewerscannerwhite.ui.view.DialogView.showDeleteDialog
import
com.base.pdfviewerscannerwhite.ui.view.DialogView.showDocumentRenameDialog
import
com.base.pdfviewerscannerwhite.ui.view.DialogView.showStoragePermission
import
com.base.pdfviewerscannerwhite.ui.view.DialogView.showStoragePermission
import
com.base.pdfviewerscannerwhite.ui.view.PdfDialog.showPdfPwdDialog
import
com.base.pdfviewerscannerwhite.ui.view.PdfDialog.showPdfPwdDialog
import
com.base.pdfviewerscannerwhite.utils.IntentShareUtils.shareMutDocuments
import
com.base.pdfviewerscannerwhite.utils.IntentShareUtils.shareMutDocuments
import
com.base.pdfviewerscannerwhite.utils.LogEx
import
com.base.pdfviewerscannerwhite.utils.LogEx
import
com.base.pdfviewerscannerwhite.utils.PermissionUtils.checkStorePermission
import
com.base.pdfviewerscannerwhite.utils.PermissionUtils.checkStorePermission
import
com.base.pdfviewerscannerwhite.utils.updateMediaStore
import
java.io.File
class
MainActivity
:
BaseActivity
<
ActivityMain2Binding
>(),
MainView
{
class
MainActivity
:
BaseActivity
<
ActivityMain2Binding
>(),
MainView
{
private
val
TAG
=
"MainActivity"
private
val
TAG
=
"MainActivity"
lateinit
var
mainPresenter
:
MainPresenter
lateinit
var
mainPresenter
:
MainPresenter
override
val
binding
:
ActivityMain2Binding
by
lazy
{
override
val
binding
:
ActivityMain2Binding
by
lazy
{
ActivityMain2Binding
.
inflate
(
layoutInflater
)
ActivityMain2Binding
.
inflate
(
layoutInflater
)
...
@@ -49,8 +52,10 @@ class MainActivity : BaseActivity<ActivityMain2Binding>(), MainView {
...
@@ -49,8 +52,10 @@ class MainActivity : BaseActivity<ActivityMain2Binding>(), MainView {
private
var
currentFragment
:
Fragment
=
documentFragment
private
var
currentFragment
:
Fragment
=
documentFragment
override
fun
initView
()
{
override
fun
initView
()
{
LogEx
.
logDebug
(
TAG
,
"initView"
)
LogEx
.
logDebug
(
TAG
,
"initView"
)
mainPresenter
=
MainPresenter
(
this
,
this
,
lifecycleScope
)
mainPresenter
=
MainPresenter
(
this
,
this
,
lifecycleScope
)
mainPresenter
.
initScannerLauncher
(
this
)
}
}
...
@@ -67,7 +72,7 @@ class MainActivity : BaseActivity<ActivityMain2Binding>(), MainView {
...
@@ -67,7 +72,7 @@ class MainActivity : BaseActivity<ActivityMain2Binding>(), MainView {
override
fun
onSaveInstanceState
(
outState
:
Bundle
)
{
override
fun
onSaveInstanceState
(
outState
:
Bundle
)
{
super
.
onSaveInstanceState
(
outState
)
super
.
onSaveInstanceState
(
outState
)
LogEx
.
logDebug
(
TAG
,
"onSaveInstanceState"
)
LogEx
.
logDebug
(
TAG
,
"onSaveInstanceState"
)
}
}
var
isDocumentAdd
:
Boolean
=
false
var
isDocumentAdd
:
Boolean
=
false
...
@@ -175,6 +180,9 @@ class MainActivity : BaseActivity<ActivityMain2Binding>(), MainView {
...
@@ -175,6 +180,9 @@ class MainActivity : BaseActivity<ActivityMain2Binding>(), MainView {
binding
.
llShare
.
setOnClickListener
{
binding
.
llShare
.
setOnClickListener
{
shareDocument
()
shareDocument
()
}
}
binding
.
ivScan
.
setOnClickListener
{
mainPresenter
.
starGmsScan
(
this
)
}
}
}
...
@@ -222,6 +230,18 @@ class MainActivity : BaseActivity<ActivityMain2Binding>(), MainView {
...
@@ -222,6 +230,18 @@ class MainActivity : BaseActivity<ActivityMain2Binding>(), MainView {
override
fun
handleActivityGmsScanResult
(
imageUri
:
Uri
,
pdfUri
:
Uri
)
{
override
fun
handleActivityGmsScanResult
(
imageUri
:
Uri
,
pdfUri
:
Uri
)
{
// LogEx.logDebug(TAG, "imageUri=$imageUri")
LogEx
.
logDebug
(
TAG
,
"pdfUri=$pdfUri"
)
val
file
=
File
(
pdfUri
.
toString
().
replace
(
"file://"
,
""
))
if
(
file
.
exists
())
{
// binding.tvTest.text = "imageUri=$imageUri\n\n\n\npdfUri=$pdfUri"
showDocumentRenameDialog
(
file
.
name
)
{
val
newFile
=
File
(
mainPresenter
.
getDocumentAppDir
(),
"$it.pdf"
)
mainPresenter
.
copyFile
(
file
,
newFile
)
this
.
updateMediaStore
()
refreshPageList
()
}
}
}
}
...
...
app/src/main/java/com/base/pdfviewerscannerwhite/ui/main/MainPresenter.kt
View file @
e73b5f11
...
@@ -4,11 +4,13 @@ import android.app.Activity
...
@@ -4,11 +4,13 @@ import android.app.Activity
import
android.content.Context
import
android.content.Context
import
android.content.IntentSender
import
android.content.IntentSender
import
android.net.Uri
import
android.net.Uri
import
android.os.Environment
import
androidx.activity.result.ActivityResultLauncher
import
androidx.activity.result.ActivityResultLauncher
import
androidx.activity.result.IntentSenderRequest
import
androidx.activity.result.IntentSenderRequest
import
androidx.activity.result.contract.ActivityResultContracts
import
androidx.activity.result.contract.ActivityResultContracts
import
androidx.appcompat.app.AppCompatActivity
import
androidx.appcompat.app.AppCompatActivity
import
androidx.lifecycle.LifecycleCoroutineScope
import
androidx.lifecycle.LifecycleCoroutineScope
import
com.base.pdfviewerscannerwhite.R
import
com.base.pdfviewerscannerwhite.bean.ConstObject
import
com.base.pdfviewerscannerwhite.bean.ConstObject
import
com.base.pdfviewerscannerwhite.bean.ConstObject.BOOKMARK_DATA_TYPE
import
com.base.pdfviewerscannerwhite.bean.ConstObject.BOOKMARK_DATA_TYPE
import
com.base.pdfviewerscannerwhite.bean.ConstObject.DOCUMENT_DATA_TYPE
import
com.base.pdfviewerscannerwhite.bean.ConstObject.DOCUMENT_DATA_TYPE
...
@@ -39,6 +41,13 @@ class MainPresenter(
...
@@ -39,6 +41,13 @@ class MainPresenter(
val
lifecycleScope
:
LifecycleCoroutineScope
val
lifecycleScope
:
LifecycleCoroutineScope
)
{
)
{
fun
getDocumentAppDir
():
File
{
val
appDir
=
File
(
Environment
.
getExternalStoragePublicDirectory
(
Environment
.
DIRECTORY_DOCUMENTS
),
context
.
packageName
)
if
(!
appDir
.
exists
())
appDir
.
exists
()
return
appDir
}
//所有fragment的数据,都从这里取
//所有fragment的数据,都从这里取
val
pdfDocuments
=
arrayListOf
<
DocumentBean
>()
val
pdfDocuments
=
arrayListOf
<
DocumentBean
>()
val
wordDocuments
=
arrayListOf
<
DocumentBean
>()
val
wordDocuments
=
arrayListOf
<
DocumentBean
>()
...
@@ -372,4 +381,10 @@ class MainPresenter(
...
@@ -372,4 +381,10 @@ class MainPresenter(
}
}
}
}
fun
copyFile
(
file
:
File
,
newFile
:
File
)
{
runCatching
{
file
.
copyTo
(
newFile
,
true
)
}
}
}
}
\ No newline at end of file
app/src/main/res/layout/activity_main2.xml
View file @
e73b5f11
...
@@ -243,5 +243,16 @@
...
@@ -243,5 +243,16 @@
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
<TextView
android:visibility=
"gone"
android:id=
"@+id/tv_test"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginHorizontal=
"20dp"
android:background=
"@color/white"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
app/src/main/res/values/strings.xml
View file @
e73b5f11
<resources>
<resources
xmlns:tools=
"http://schemas.android.com/tools"
>
<string
name=
"app_name"
>
PDF Viewer
&
Scanner
</string>
<string
name=
"app_name"
tools:ignore=
"MissingTranslation"
>
PDF Viewer
&
Scanner
</string>
<!-- TODO: Remove or change this placeholder text -->
<string
name=
"next"
tools:ignore=
"MissingTranslation"
>
Next
</string>
<string
name=
"hello_blank_fragment"
>
Hello blank fragment
</string>
<string
name=
"previous"
tools:ignore=
"MissingTranslation"
>
Previous
</string>
<!-- Strings used for fragments for navigation -->
<string
name=
"first_fragment_label"
>
First Fragment
</string>
<string
name=
"second_fragment_label"
>
Second Fragment
</string>
<string
name=
"next"
>
Next
</string>
<string
name=
"previous"
>
Previous
</string>
<string
name=
"lorem_ipsum"
>
<string
name=
"lorem_ipsum"
tools:ignore=
"MissingTranslation"
>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam in scelerisque sem. Mauris volutpat, dolor id interdum
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam in scelerisque sem. Mauris volutpat, dolor id interdum
ullamcorper, risus dolor egestas lectus, sit amet mattis purus dui nec risus. Maecenas non sodales nisi, vel dictum dolor.
ullamcorper, risus dolor egestas lectus, sit amet mattis purus dui nec risus. Maecenas non sodales nisi, vel dictum dolor.
Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Suspendisse blandit eleifend diam,
Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Suspendisse blandit eleifend diam,
...
...
pdflibrary/src/main/java/com/artifex/mupdfdemo/ChoosePDFActivity.java
View file @
e73b5f11
...
@@ -24,206 +24,205 @@ import android.widget.ListView;
...
@@ -24,206 +24,205 @@ import android.widget.ListView;
import
com.lonelypluto.pdfviewerlibrary.R
;
import
com.lonelypluto.pdfviewerlibrary.R
;
enum
Purpose
{
enum
Purpose
{
PickPDF
,
PickPDF
,
PickKeyFile
PickKeyFile
}
}
public
class
ChoosePDFActivity
extends
ListActivity
{
public
class
ChoosePDFActivity
extends
ListActivity
{
static
public
final
String
PICK_KEY_FILE
=
"com.artifex.mupdfdemo.PICK_KEY_FILE"
;
static
public
final
String
PICK_KEY_FILE
=
"com.artifex.mupdfdemo.PICK_KEY_FILE"
;
static
private
File
mDirectory
;
static
private
File
mDirectory
;
static
private
Map
<
String
,
Integer
>
mPositions
=
new
HashMap
<
String
,
Integer
>();
static
private
Map
<
String
,
Integer
>
mPositions
=
new
HashMap
<
String
,
Integer
>();
private
File
mParent
;
private
File
mParent
;
private
File
[]
mDirs
;
private
File
[]
mDirs
;
private
File
[]
mFiles
;
private
File
[]
mFiles
;
private
Handler
mHandler
;
private
Handler
mHandler
;
private
Runnable
mUpdateFiles
;
private
Runnable
mUpdateFiles
;
private
ChoosePDFAdapter
adapter
;
private
ChoosePDFAdapter
adapter
;
private
Purpose
mPurpose
;
private
Purpose
mPurpose
;
@Override
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
super
.
onCreate
(
savedInstanceState
);
mPurpose
=
PICK_KEY_FILE
.
equals
(
getIntent
().
getAction
())
?
Purpose
.
PickKeyFile
:
Purpose
.
PickPDF
;
mPurpose
=
PICK_KEY_FILE
.
equals
(
getIntent
().
getAction
())
?
Purpose
.
PickKeyFile
:
Purpose
.
PickPDF
;
String
storageState
=
Environment
.
getExternalStorageState
();
String
storageState
=
Environment
.
getExternalStorageState
();
if
(!
Environment
.
MEDIA_MOUNTED
.
equals
(
storageState
)
if
(!
Environment
.
MEDIA_MOUNTED
.
equals
(
storageState
)
&&
!
Environment
.
MEDIA_MOUNTED_READ_ONLY
.
equals
(
storageState
))
&&
!
Environment
.
MEDIA_MOUNTED_READ_ONLY
.
equals
(
storageState
))
{
{
AlertDialog
.
Builder
builder
=
new
AlertDialog
.
Builder
(
this
);
AlertDialog
.
Builder
builder
=
new
AlertDialog
.
Builder
(
this
);
builder
.
setTitle
(
R
.
string
.
no_media_warning
);
builder
.
setTitle
(
R
.
string
.
no_media_warning
);
builder
.
setMessage
(
R
.
string
.
no_media_hint
);
builder
.
setMessage
(
R
.
string
.
no_media_hint
);
AlertDialog
alert
=
builder
.
create
();
AlertDialog
alert
=
builder
.
create
();
alert
.
setButton
(
AlertDialog
.
BUTTON_POSITIVE
,
getString
(
R
.
string
.
dismiss
),
alert
.
setButton
(
AlertDialog
.
BUTTON_POSITIVE
,
getString
(
R
.
string
.
dismiss
),
new
OnClickListener
()
{
new
OnClickListener
()
{
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
finish
();
finish
();
}
}
});
});
alert
.
show
();
alert
.
show
();
return
;
return
;
}
}
if
(
mDirectory
==
null
)
if
(
mDirectory
==
null
)
mDirectory
=
Environment
.
getExternalStoragePublicDirectory
(
Environment
.
DIRECTORY_DOWNLOADS
);
mDirectory
=
Environment
.
getExternalStoragePublicDirectory
(
Environment
.
DIRECTORY_DOWNLOADS
);
// Create a list adapter...
// Create a list adapter...
adapter
=
new
ChoosePDFAdapter
(
getLayoutInflater
());
adapter
=
new
ChoosePDFAdapter
(
getLayoutInflater
());
setListAdapter
(
adapter
);
setListAdapter
(
adapter
);
// ...that is updated dynamically when files are scanned
// ...that is updated dynamically when files are scanned
mHandler
=
new
Handler
();
mHandler
=
new
Handler
();
mUpdateFiles
=
new
Runnable
()
{
mUpdateFiles
=
new
Runnable
()
{
public
void
run
()
{
public
void
run
()
{
Resources
res
=
getResources
();
Resources
res
=
getResources
();
String
appName
=
"app_name"
;
String
appName
=
res
.
getString
(
R
.
string
.
app_name
);
String
version
=
"1.0"
;
String
version
=
res
.
getString
(
R
.
string
.
version
);
String
title
=
res
.
getString
(
R
.
string
.
picker_title_App_Ver_Dir
);
String
title
=
res
.
getString
(
R
.
string
.
picker_title_App_Ver_Dir
);
setTitle
(
String
.
format
(
title
,
appName
,
version
,
mDirectory
));
setTitle
(
String
.
format
(
title
,
appName
,
version
,
mDirectory
));
mParent
=
mDirectory
.
getParentFile
();
mParent
=
mDirectory
.
getParentFile
();
mDirs
=
mDirectory
.
listFiles
(
new
FileFilter
()
{
mDirs
=
mDirectory
.
listFiles
(
new
FileFilter
()
{
public
boolean
accept
(
File
file
)
{
public
boolean
accept
(
File
file
)
{
return
file
.
isDirectory
();
return
file
.
isDirectory
();
}
}
});
});
if
(
mDirs
==
null
)
if
(
mDirs
==
null
)
mDirs
=
new
File
[
0
];
mDirs
=
new
File
[
0
];
mFiles
=
mDirectory
.
listFiles
(
new
FileFilter
()
{
mFiles
=
mDirectory
.
listFiles
(
new
FileFilter
()
{
public
boolean
accept
(
File
file
)
{
public
boolean
accept
(
File
file
)
{
if
(
file
.
isDirectory
())
if
(
file
.
isDirectory
())
return
false
;
return
false
;
String
fname
=
file
.
getName
().
toLowerCase
();
String
fname
=
file
.
getName
().
toLowerCase
();
switch
(
mPurpose
)
{
switch
(
mPurpose
)
{
case
PickPDF:
case
PickPDF:
if
(
fname
.
endsWith
(
".pdf"
))
if
(
fname
.
endsWith
(
".pdf"
))
return
true
;
return
true
;
if
(
fname
.
endsWith
(
".xps"
))
if
(
fname
.
endsWith
(
".xps"
))
return
true
;
return
true
;
if
(
fname
.
endsWith
(
".cbz"
))
if
(
fname
.
endsWith
(
".cbz"
))
return
true
;
return
true
;
if
(
fname
.
endsWith
(
".epub"
))
if
(
fname
.
endsWith
(
".epub"
))
return
true
;
return
true
;
if
(
fname
.
endsWith
(
".png"
))
if
(
fname
.
endsWith
(
".png"
))
return
true
;
return
true
;
if
(
fname
.
endsWith
(
".jpe"
))
if
(
fname
.
endsWith
(
".jpe"
))
return
true
;
return
true
;
if
(
fname
.
endsWith
(
".jpeg"
))
if
(
fname
.
endsWith
(
".jpeg"
))
return
true
;
return
true
;
if
(
fname
.
endsWith
(
".jpg"
))
if
(
fname
.
endsWith
(
".jpg"
))
return
true
;
return
true
;
if
(
fname
.
endsWith
(
".jfif"
))
if
(
fname
.
endsWith
(
".jfif"
))
return
true
;
return
true
;
if
(
fname
.
endsWith
(
".jfif-tbnl"
))
if
(
fname
.
endsWith
(
".jfif-tbnl"
))
return
true
;
return
true
;
if
(
fname
.
endsWith
(
".tif"
))
if
(
fname
.
endsWith
(
".tif"
))
return
true
;
return
true
;
if
(
fname
.
endsWith
(
".tiff"
))
if
(
fname
.
endsWith
(
".tiff"
))
return
true
;
return
true
;
return
false
;
return
false
;
case
PickKeyFile:
case
PickKeyFile:
if
(
fname
.
endsWith
(
".pfx"
))
if
(
fname
.
endsWith
(
".pfx"
))
return
true
;
return
true
;
return
false
;
return
false
;
default
:
default
:
return
false
;
return
false
;
}
}
}
}
});
});
if
(
mFiles
==
null
)
if
(
mFiles
==
null
)
mFiles
=
new
File
[
0
];
mFiles
=
new
File
[
0
];
Arrays
.
sort
(
mFiles
,
new
Comparator
<
File
>()
{
Arrays
.
sort
(
mFiles
,
new
Comparator
<
File
>()
{
public
int
compare
(
File
arg0
,
File
arg1
)
{
public
int
compare
(
File
arg0
,
File
arg1
)
{
return
arg0
.
getName
().
compareToIgnoreCase
(
arg1
.
getName
());
return
arg0
.
getName
().
compareToIgnoreCase
(
arg1
.
getName
());
}
}
});
});
Arrays
.
sort
(
mDirs
,
new
Comparator
<
File
>()
{
Arrays
.
sort
(
mDirs
,
new
Comparator
<
File
>()
{
public
int
compare
(
File
arg0
,
File
arg1
)
{
public
int
compare
(
File
arg0
,
File
arg1
)
{
return
arg0
.
getName
().
compareToIgnoreCase
(
arg1
.
getName
());
return
arg0
.
getName
().
compareToIgnoreCase
(
arg1
.
getName
());
}
}
});
});
adapter
.
clear
();
adapter
.
clear
();
if
(
mParent
!=
null
)
if
(
mParent
!=
null
)
adapter
.
add
(
new
ChoosePDFItem
(
ChoosePDFItem
.
Type
.
PARENT
,
getString
(
R
.
string
.
parent_directory
)));
adapter
.
add
(
new
ChoosePDFItem
(
ChoosePDFItem
.
Type
.
PARENT
,
getString
(
R
.
string
.
parent_directory
)));
for
(
File
f
:
mDirs
)
for
(
File
f
:
mDirs
)
adapter
.
add
(
new
ChoosePDFItem
(
ChoosePDFItem
.
Type
.
DIR
,
f
.
getName
()));
adapter
.
add
(
new
ChoosePDFItem
(
ChoosePDFItem
.
Type
.
DIR
,
f
.
getName
()));
for
(
File
f
:
mFiles
)
for
(
File
f
:
mFiles
)
adapter
.
add
(
new
ChoosePDFItem
(
ChoosePDFItem
.
Type
.
DOC
,
f
.
getName
()));
adapter
.
add
(
new
ChoosePDFItem
(
ChoosePDFItem
.
Type
.
DOC
,
f
.
getName
()));
lastPosition
();
lastPosition
();
}
}
};
};
// Start initial file scan...
// Start initial file scan...
mHandler
.
post
(
mUpdateFiles
);
mHandler
.
post
(
mUpdateFiles
);
// ...and observe the directory and scan files upon changes.
// ...and observe the directory and scan files upon changes.
FileObserver
observer
=
new
FileObserver
(
mDirectory
.
getPath
(),
FileObserver
.
CREATE
|
FileObserver
.
DELETE
)
{
FileObserver
observer
=
new
FileObserver
(
mDirectory
.
getPath
(),
FileObserver
.
CREATE
|
FileObserver
.
DELETE
)
{
public
void
onEvent
(
int
event
,
String
path
)
{
public
void
onEvent
(
int
event
,
String
path
)
{
mHandler
.
post
(
mUpdateFiles
);
mHandler
.
post
(
mUpdateFiles
);
}
}
};
};
observer
.
startWatching
();
observer
.
startWatching
();
}
}
private
void
lastPosition
()
{
private
void
lastPosition
()
{
String
p
=
mDirectory
.
getAbsolutePath
();
String
p
=
mDirectory
.
getAbsolutePath
();
if
(
mPositions
.
containsKey
(
p
))
if
(
mPositions
.
containsKey
(
p
))
getListView
().
setSelection
(
mPositions
.
get
(
p
));
getListView
().
setSelection
(
mPositions
.
get
(
p
));
}
}
@Override
@Override
protected
void
onListItemClick
(
ListView
l
,
View
v
,
int
position
,
long
id
)
{
protected
void
onListItemClick
(
ListView
l
,
View
v
,
int
position
,
long
id
)
{
super
.
onListItemClick
(
l
,
v
,
position
,
id
);
super
.
onListItemClick
(
l
,
v
,
position
,
id
);
mPositions
.
put
(
mDirectory
.
getAbsolutePath
(),
getListView
().
getFirstVisiblePosition
());
mPositions
.
put
(
mDirectory
.
getAbsolutePath
(),
getListView
().
getFirstVisiblePosition
());
if
(
position
<
(
mParent
==
null
?
0
:
1
))
{
if
(
position
<
(
mParent
==
null
?
0
:
1
))
{
mDirectory
=
mParent
;
mDirectory
=
mParent
;
mHandler
.
post
(
mUpdateFiles
);
mHandler
.
post
(
mUpdateFiles
);
return
;
return
;
}
}
position
-=
(
mParent
==
null
?
0
:
1
);
position
-=
(
mParent
==
null
?
0
:
1
);
if
(
position
<
mDirs
.
length
)
{
if
(
position
<
mDirs
.
length
)
{
mDirectory
=
mDirs
[
position
];
mDirectory
=
mDirs
[
position
];
mHandler
.
post
(
mUpdateFiles
);
mHandler
.
post
(
mUpdateFiles
);
return
;
return
;
}
}
position
-=
mDirs
.
length
;
position
-=
mDirs
.
length
;
Uri
uri
=
Uri
.
fromFile
(
mFiles
[
position
]);
Uri
uri
=
Uri
.
fromFile
(
mFiles
[
position
]);
Intent
intent
=
new
Intent
(
this
,
MuPDFActivity
.
class
);
Intent
intent
=
new
Intent
(
this
,
MuPDFActivity
.
class
);
intent
.
setAction
(
Intent
.
ACTION_VIEW
);
intent
.
setAction
(
Intent
.
ACTION_VIEW
);
intent
.
setData
(
uri
);
intent
.
setData
(
uri
);
switch
(
mPurpose
)
{
switch
(
mPurpose
)
{
case
PickPDF:
case
PickPDF:
// Start an activity to display the PDF file
// Start an activity to display the PDF file
startActivity
(
intent
);
startActivity
(
intent
);
break
;
break
;
case
PickKeyFile:
case
PickKeyFile:
// Return the uri to the caller
// Return the uri to the caller
setResult
(
RESULT_OK
,
intent
);
setResult
(
RESULT_OK
,
intent
);
finish
();
finish
();
break
;
break
;
}
}
}
}
@Override
@Override
protected
void
onPause
()
{
protected
void
onPause
()
{
super
.
onPause
();
super
.
onPause
();
if
(
mDirectory
!=
null
)
if
(
mDirectory
!=
null
)
mPositions
.
put
(
mDirectory
.
getAbsolutePath
(),
getListView
().
getFirstVisiblePosition
());
mPositions
.
put
(
mDirectory
.
getAbsolutePath
(),
getListView
().
getFirstVisiblePosition
());
}
}
}
}
pdflibrary/src/main/res/values-zh/strings.xml
View file @
e73b5f11
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<resources>
<string
name=
"accept"
>
接受
</string>
<string
name=
"accept"
>
接受
</string>
<string
name=
"app_name"
>
MuPDF
</string>
<string
name=
"cancel"
>
取消
</string>
<string
name=
"cancel"
>
取消
</string>
<string
name=
"cannot_open_buffer"
>
无法打开缓冲器
</string>
<string
name=
"cannot_open_buffer"
>
无法打开缓冲器
</string>
<string
name=
"cannot_open_document"
>
无法打开文档
</string>
<string
name=
"cannot_open_document"
>
无法打开文档
</string>
<string
name=
"cannot_open_document_Reason"
>
无法打开文档: %1$s
</string>
<string
name=
"cannot_open_document_Reason"
>
无法打开文档: %1$s
</string>
<string
name=
"cannot_open_file_Path"
>
无法打开文件:%1$s
</string>
<string
name=
"cannot_open_file_Path"
>
无法打开文件:%1$s
</string>
<string
name=
"choose_value"
>
选择值
</string>
<string
name=
"choose_value"
>
选择值
</string>
<string
name=
"copied_to_clipboard"
>
已复制到剪贴板
</string>
<string
name=
"copied_to_clipboard"
>
已复制到剪贴板
</string>
<string
name=
"copy"
>
复制
</string>
<string
name=
"copy"
>
复制
</string>
<string
name=
"copy_text"
>
复制文本
</string>
<string
name=
"copy_text"
>
复制文本
</string>
<string
name=
"copy_text_to_the_clipboard"
>
将文本复制到剪贴板
</string>
<string
name=
"copy_text_to_the_clipboard"
>
将文本复制到剪贴板
</string>
<string
name=
"delete"
>
删除
</string>
<string
name=
"delete"
>
删除
</string>
<string
name=
"dismiss"
>
解除
</string>
<string
name=
"dismiss"
>
解除
</string>
<string
name=
"document_has_changes_save_them_"
>
文档已变更,保存变更吗?
</string>
<string
name=
"document_has_changes_save_them_"
>
文档已变更,保存变更吗?
</string>
<string
name=
"draw_annotation"
>
作批注
</string>
<string
name=
"draw_annotation"
>
作批注
</string>
<string
name=
"edit_annotations"
>
编辑批注
</string>
<string
name=
"edit_annotations"
>
编辑批注
</string>
<string
name=
"enter_password"
>
输入密码
</string>
<string
name=
"enter_password"
>
输入密码
</string>
<string
name=
"entering_reflow_mode"
>
输入重排模式
</string>
<string
name=
"entering_reflow_mode"
>
输入重排模式
</string>
<string
name=
"fill_out_text_field"
>
填充文本字段
</string>
<string
name=
"fill_out_text_field"
>
填充文本字段
</string>
<string
name=
"format_currently_not_supported"
>
当前不支持此格式
</string>
<string
name=
"format_currently_not_supported"
>
当前不支持此格式
</string>
<string
name=
"highlight"
>
高亮
</string>
<string
name=
"highlight"
>
高亮
</string>
<string
name=
"ink"
>
墨迹
</string>
<string
name=
"ink"
>
墨迹
</string>
<string
name=
"leaving_reflow_mode"
>
正在离开重排模式
</string>
<string
name=
"leaving_reflow_mode"
>
正在离开重排模式
</string>
<string
name=
"more"
>
更多
</string>
<string
name=
"more"
>
更多
</string>
<string
name=
"no"
>
否
</string>
<string
name=
"no"
>
否
</string>
<string
name=
"no_further_occurrences_found"
>
未发现更多实例。
</string>
<string
name=
"no_further_occurrences_found"
>
未发现更多实例。
</string>
<string
name=
"no_media_hint"
>
存储介质在设备和 PC 上共同使用,会导致该存储介质在设备上无法被访问
</string>
<string
name=
"no_media_hint"
>
存储介质在设备和 PC 上共同使用,会导致该存储介质在设备上无法被访问
</string>
<string
name=
"no_media_warning"
>
没有存储介质
</string>
<string
name=
"no_media_warning"
>
没有存储介质
</string>
<string
name=
"no_text_selected"
>
未选择文本
</string>
<string
name=
"no_text_selected"
>
未选择文本
</string>
<string
name=
"not_supported"
>
不被支持
</string>
<string
name=
"not_supported"
>
不被支持
</string>
<string
name=
"nothing_to_save"
>
没有要保存的内容
</string>
<string
name=
"nothing_to_save"
>
没有要保存的内容
</string>
<string
name=
"okay"
>
确定
</string>
<string
name=
"okay"
>
确定
</string>
<string
name=
"outline_title"
>
目录
</string>
<string
name=
"outline_title"
>
目录
</string>
<string
name=
"parent_directory"
>
[向上一级]
</string>
<string
name=
"parent_directory"
>
[向上一级]
</string>
<string
name=
"picker_title_App_Ver_Dir"
>
%1$s%2$s:%3$s
</string>
<string
name=
"picker_title_App_Ver_Dir"
>
%1$s%2$s:%3$s
</string>
<string
name=
"print"
>
打印
</string>
<string
name=
"print"
>
打印
</string>
<string
name=
"print_failed"
>
未能打印
</string>
<string
name=
"print_failed"
>
未能打印
</string>
<string
name=
"save"
>
保存
</string>
<string
name=
"save"
>
保存
</string>
<string
name=
"search"
>
搜索
</string>
<string
name=
"search"
>
搜索
</string>
<string
name=
"search_backwards"
>
向后搜索
</string>
<string
name=
"search_backwards"
>
向后搜索
</string>
<string
name=
"search_document"
>
搜索文档
</string>
<string
name=
"search_document"
>
搜索文档
</string>
<string
name=
"search_forwards"
>
向前搜索
</string>
<string
name=
"search_forwards"
>
向前搜索
</string>
<string
name=
"searching_"
>
正在搜索…
</string>
<string
name=
"searching_"
>
正在搜索…
</string>
<string
name=
"select"
>
选择
</string>
<string
name=
"select"
>
选择
</string>
<string
name=
"select_text"
>
选择文本
</string>
<string
name=
"select_text"
>
选择文本
</string>
<string
name=
"strike_out"
>
删除线
</string>
<string
name=
"strike_out"
>
删除线
</string>
<string
name=
"text_not_found"
>
未发现文本
</string>
<string
name=
"text_not_found"
>
未发现文本
</string>
<string
name=
"toggle_links"
>
高亮并启用墨迹
</string>
<string
name=
"toggle_links"
>
高亮并启用墨迹
</string>
<string
name=
"underline"
>
下划线
</string>
<string
name=
"underline"
>
下划线
</string>
<string
name=
"yes"
>
是
</string>
<string
name=
"yes"
>
是
</string>
<string
name=
"select_certificate_and_sign"
>
选择证书并签名?
</string>
<string
name=
"select_certificate_and_sign"
>
选择证书并签名?
</string>
<string
name=
"signature_checked"
>
签名已检查
</string>
<string
name=
"signature_checked"
>
签名已检查
</string>
</resources>
</resources>
pdflibrary/src/main/res/values/strings.xml
View file @
e73b5f11
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<resources>
<string
name=
"app_name"
>
MuPDF
</string>
<string
name=
"version"
>
1.9 (git build)
</string>
<string
name=
"no_media_warning"
>
Storage media not present
</string>
<string
name=
"no_media_warning"
>
Storage media not present
</string>
<string
name=
"no_media_hint"
>
Sharing the storage media with a PC can make it inaccessible
</string>
<string
name=
"no_media_hint"
>
Sharing the storage media with a PC can make it inaccessible
</string>
<string
name=
"cancel"
>
Cancel
</string>
<string
name=
"cancel"
>
Cancel
</string>
...
...
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