Kaynağa Gözat

Add encrypt / decrypt in menu

cooperku_kdanmobile 4 yıl önce
ebeveyn
işleme
d3393d9ae2

+ 12 - 0
src/main/java/com/kdanmobile/reader/ReaderActivity.kt

@@ -69,6 +69,8 @@ abstract class ReaderActivity :
     abstract fun onClickFileInfo()
     abstract fun onClickIBonPrint()
     abstract fun onClickPrint()
+    abstract fun onClickEncrypt()
+    abstract fun onClickDecrypt()
     abstract fun onClickUserGuide()
     abstract fun provideReaderSettingDialogFragment(): ReaderSettingDialogFragment
     abstract fun providePdfThumbDialogFragment(): PdfThumbDialogFragment
@@ -307,6 +309,14 @@ abstract class ReaderActivity :
             }
             menuItemBookmark?.isVisible = false
         }
+        if (isPdf()) {
+            menu?.apply {
+                when (password.isEmpty()) {
+                    true -> findItem(R.id.item_reader_more_decrypt)
+                    false -> findItem(R.id.item_reader_more_encrypt)
+                }?.isVisible = false
+            }
+        }
         if (!isIBonPrintEnabled()) {
             menu?.findItem(R.id.item_ibon_print)?.isVisible = false
         }
@@ -723,6 +733,8 @@ abstract class ReaderActivity :
                 R.id.item_reader_more_file_info -> onClickFileInfo()
                 R.id.item_ibon_print -> onClickIBonPrint()
                 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_clear_signature -> onClickClearSignature()
             }

+ 12 - 0
src/main/res/menu/reader_more.xml

@@ -37,6 +37,18 @@
         android:title="@string/reader_more_menu_print"
         app:showAsAction="withText">
     </item>
+    <item
+        android:id="@+id/item_reader_more_encrypt"
+        android:icon="@drawable/ic_encrypt"
+        android:title="@string/reader_more_menu_encrypt"
+        app:showAsAction="withText">
+    </item>
+    <item
+        android:id="@+id/item_reader_more_decrypt"
+        android:icon="@drawable/ic_decrypt"
+        android:title="@string/reader_more_menu_decrypt"
+        app:showAsAction="withText">
+    </item>
     <item
         android:id="@+id/item_reader_more_user_guide"
         android:icon="@drawable/ic_help_black_op60_24dp"

+ 2 - 0
src/main/res/values/strings.xml

@@ -7,6 +7,8 @@
     <string name="reader_more_menu_print">Print</string>
     <string name="reader_more_menu_file_info">File Info</string>
     <string name="reader_more_menu_clear_signature">"Clear Signature "</string>
+    <string name="reader_more_menu_encrypt">Encrypt</string>
+    <string name="reader_more_menu_decrypt">Remove Password</string>
     <string name="reader_more_menu_user_guide">User Guide</string>
     <string name="reader_more_menu_ibon">Print from ibon</string>
     <string name="reader_copy_text_success">The selected text has been saved to the clipboard!</string>