|
@@ -69,6 +69,8 @@ abstract class ReaderActivity :
|
|
abstract fun onClickFileInfo()
|
|
abstract fun onClickFileInfo()
|
|
abstract fun onClickIBonPrint()
|
|
abstract fun onClickIBonPrint()
|
|
abstract fun onClickPrint()
|
|
abstract fun onClickPrint()
|
|
|
|
+ abstract fun onClickEncrypt()
|
|
|
|
+ abstract fun onClickDecrypt()
|
|
abstract fun onClickUserGuide()
|
|
abstract fun onClickUserGuide()
|
|
abstract fun provideReaderSettingDialogFragment(): ReaderSettingDialogFragment
|
|
abstract fun provideReaderSettingDialogFragment(): ReaderSettingDialogFragment
|
|
abstract fun providePdfThumbDialogFragment(): PdfThumbDialogFragment
|
|
abstract fun providePdfThumbDialogFragment(): PdfThumbDialogFragment
|
|
@@ -273,11 +275,13 @@ abstract class ReaderActivity :
|
|
}
|
|
}
|
|
|
|
|
|
fun isPdf(): Boolean {
|
|
fun isPdf(): Boolean {
|
|
- var isPdf = filePath?.toLowerCase(Locale.US)?.endsWith(".pdf") ?: false
|
|
|
|
|
|
+ return filePath?.toLowerCase(Locale.US)?.endsWith(".pdf") ?: false
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ fun isNoPasswordProtectedPdf(): Boolean {
|
|
// TODO this workaround should be removed in the future
|
|
// TODO this workaround should be removed in the future
|
|
// workaround: password-protected pdf is not editable
|
|
// workaround: password-protected pdf is not editable
|
|
- isPdf = isPdf && !isPasswordProtected
|
|
|
|
- return isPdf
|
|
|
|
|
|
+ return isPdf() && !isPasswordProtected
|
|
}
|
|
}
|
|
|
|
|
|
final override fun onBackPressed() {
|
|
final override fun onBackPressed() {
|
|
@@ -295,7 +299,7 @@ abstract class ReaderActivity :
|
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
|
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
|
|
menu?.findItem(R.id.item_reader_more_print)?.isVisible = false
|
|
menu?.findItem(R.id.item_reader_more_print)?.isVisible = false
|
|
}
|
|
}
|
|
- if (!isPdf()) {
|
|
|
|
|
|
+ if (!isNoPasswordProtectedPdf()) {
|
|
menu?.apply {
|
|
menu?.apply {
|
|
findItem(R.id.item_reader_more_text_reflow)?.isVisible = false
|
|
findItem(R.id.item_reader_more_text_reflow)?.isVisible = false
|
|
findItem(R.id.item_reader_more_clear_signature)?.isVisible = false
|
|
findItem(R.id.item_reader_more_clear_signature)?.isVisible = false
|
|
@@ -305,6 +309,19 @@ abstract class ReaderActivity :
|
|
}
|
|
}
|
|
menuItemBookmark?.isVisible = false
|
|
menuItemBookmark?.isVisible = false
|
|
}
|
|
}
|
|
|
|
+ menu?.apply {
|
|
|
|
+ val isPdf = isPdf()
|
|
|
|
+ when (password.isEmpty()) {
|
|
|
|
+ true -> {
|
|
|
|
+ findItem(R.id.item_reader_more_encrypt)?.isVisible = isPdf
|
|
|
|
+ findItem(R.id.item_reader_more_decrypt)?.isVisible = false
|
|
|
|
+ }
|
|
|
|
+ false -> {
|
|
|
|
+ findItem(R.id.item_reader_more_encrypt)?.isVisible = false
|
|
|
|
+ findItem(R.id.item_reader_more_decrypt)?.isVisible = isPdf
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
if (!isIBonPrintEnabled()) {
|
|
if (!isIBonPrintEnabled()) {
|
|
menu?.findItem(R.id.item_ibon_print)?.isVisible = false
|
|
menu?.findItem(R.id.item_ibon_print)?.isVisible = false
|
|
}
|
|
}
|
|
@@ -628,6 +645,7 @@ abstract class ReaderActivity :
|
|
// return Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT
|
|
// return Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @SuppressLint("NewApi")
|
|
private fun showAllToolbars() {
|
|
private fun showAllToolbars() {
|
|
if (isBelowKitkat()) {
|
|
if (isBelowKitkat()) {
|
|
val duration = ((1 - toolbar_readerActivity.alpha) * UI_ANIMATION_DURATION).toLong()
|
|
val duration = ((1 - toolbar_readerActivity.alpha) * UI_ANIMATION_DURATION).toLong()
|
|
@@ -641,6 +659,7 @@ abstract class ReaderActivity :
|
|
isHidePdfPage = true
|
|
isHidePdfPage = true
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @SuppressLint("NewApi")
|
|
private fun hideAllToolbars() {
|
|
private fun hideAllToolbars() {
|
|
if (isBelowKitkat()) {
|
|
if (isBelowKitkat()) {
|
|
val duration = (toolbar_readerActivity.alpha * UI_ANIMATION_DURATION).toLong()
|
|
val duration = (toolbar_readerActivity.alpha * UI_ANIMATION_DURATION).toLong()
|
|
@@ -654,6 +673,7 @@ abstract class ReaderActivity :
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @SuppressLint("NewApi")
|
|
private fun hideTopLeftBottomToolbars() {
|
|
private fun hideTopLeftBottomToolbars() {
|
|
if (isBelowKitkat()) {
|
|
if (isBelowKitkat()) {
|
|
val duration = (toolbar_readerActivity.alpha * UI_ANIMATION_DURATION).toLong()
|
|
val duration = (toolbar_readerActivity.alpha * UI_ANIMATION_DURATION).toLong()
|
|
@@ -718,6 +738,8 @@ abstract class ReaderActivity :
|
|
R.id.item_reader_more_file_info -> onClickFileInfo()
|
|
R.id.item_reader_more_file_info -> onClickFileInfo()
|
|
R.id.item_ibon_print -> onClickIBonPrint()
|
|
R.id.item_ibon_print -> onClickIBonPrint()
|
|
R.id.item_reader_more_print -> onClickPrint()
|
|
R.id.item_reader_more_print -> onClickPrint()
|
|
|
|
+ R.id.item_reader_more_encrypt -> onClickEncrypt()
|
|
|
|
+ R.id.item_reader_more_decrypt -> onClickDecrypt()
|
|
R.id.item_reader_more_user_guide -> onClickUserGuide()
|
|
R.id.item_reader_more_user_guide -> onClickUserGuide()
|
|
R.id.item_reader_more_clear_signature -> onClickClearSignature()
|
|
R.id.item_reader_more_clear_signature -> onClickClearSignature()
|
|
}
|
|
}
|
|
@@ -816,7 +838,7 @@ abstract class ReaderActivity :
|
|
iv_readerActivity_outline.setOnClickListener { onClickLeftToolbarItem(ReaderViewModel.LeftToolbarType.OUTLINE) }
|
|
iv_readerActivity_outline.setOnClickListener { onClickLeftToolbarItem(ReaderViewModel.LeftToolbarType.OUTLINE) }
|
|
iv_readerActivity_search.setOnClickListener { onClickLeftToolbarItem(ReaderViewModel.LeftToolbarType.SEARCH) }
|
|
iv_readerActivity_search.setOnClickListener { onClickLeftToolbarItem(ReaderViewModel.LeftToolbarType.SEARCH) }
|
|
|
|
|
|
- if (!isPdf()) {
|
|
|
|
|
|
+ if (!isNoPasswordProtectedPdf()) {
|
|
iv_readerActivity_bookmark.visibility = View.GONE
|
|
iv_readerActivity_bookmark.visibility = View.GONE
|
|
if (!isPasswordProtected) iv_readerActivity_outline.visibility = View.GONE
|
|
if (!isPasswordProtected) iv_readerActivity_outline.visibility = View.GONE
|
|
}
|
|
}
|
|
@@ -955,7 +977,7 @@ abstract class ReaderActivity :
|
|
onClickShare()
|
|
onClickShare()
|
|
}
|
|
}
|
|
|
|
|
|
- if (!isPdf()) {
|
|
|
|
|
|
+ if (!isNoPasswordProtectedPdf()) {
|
|
ib_readerActivity_bottomToolbarMediaBox.visibility = View.GONE
|
|
ib_readerActivity_bottomToolbarMediaBox.visibility = View.GONE
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1161,7 +1183,7 @@ abstract class ReaderActivity :
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- if (!isPdf()) {
|
|
|
|
|
|
+ if (!isNoPasswordProtectedPdf()) {
|
|
iv_readerActivity_highLight.visibility = View.GONE
|
|
iv_readerActivity_highLight.visibility = View.GONE
|
|
iv_readerActivity_strike.visibility = View.GONE
|
|
iv_readerActivity_strike.visibility = View.GONE
|
|
iv_readerActivity_underline.visibility = View.GONE
|
|
iv_readerActivity_underline.visibility = View.GONE
|