Ver código fonte

Merge branch 'encryptCopyFile' into 137-encryptPdf

cooperku_kdanmobile 4 anos atrás
pai
commit
9d17dab765

+ 2 - 19
src/main/java/com/kdanmobile/reader/ReaderActivity.kt

@@ -93,7 +93,6 @@ abstract class ReaderActivity :
 
     companion object {
         const val KEY_FILE_ABSOLUTE = "file_absolutepath"
-        const val KEY_ENCRYPT_PASSWORD = "encryptPassword"
         const val KEY_IS_PASSWORD_ACTIVITY_SHOWING = "isShowPasswordActivity"
         const val REQUEST_PASSWORD = 222
     }
@@ -183,14 +182,7 @@ abstract class ReaderActivity :
         setSupportActionBar(toolbar_readerActivity)
         isShowPasswordActivity = savedInstanceState?.getBoolean(KEY_IS_PASSWORD_ACTIVITY_SHOWING) ?: false
         // Get file path to determine the opening file is pdf or not
-        var encryptPassword: String? = null
-        intent.apply {
-            filePath = getStringExtra(KEY_FILE_ABSOLUTE)
-
-            encryptPassword = getStringExtra(KEY_ENCRYPT_PASSWORD)?.also {
-                putExtra(KEY_ENCRYPT_PASSWORD, null as String?)
-            }
-        }
+        filePath = intent.getStringExtra(KEY_FILE_ABSOLUTE)
 
         val displayMetrics = DisplayMetrics()
         windowManager.defaultDisplay.getMetrics(displayMetrics)
@@ -223,11 +215,10 @@ abstract class ReaderActivity :
             } else {
                 val result = viewModel.openPdfFile(
                         this@ReaderActivity,
-                        encryptPassword ?: password,
+                        password,
                         Runnable { requestPassword() },
                         intent.type
                 )
-                encryptPassword = null
                 if (result == ReaderViewModel.OpenFileResult.FAILED) {
                     showFileCannotOpenDialog(getString(R.string.cannot_open_file_Path, filePath))
                 }
@@ -756,14 +747,6 @@ abstract class ReaderActivity :
         }
     }
 
-    fun encryptPdf(password: String): Boolean {
-        return viewModel.encrypt(password)
-    }
-
-    fun decryptPdf(): Boolean {
-        return viewModel.encrypt("")
-    }
-
     private fun onClickBookmark() {
         onEvent(HookEvent.OnClickTopBookmarkBtn())
         viewModel.isPageInBookmarksLiveData.value?.let {

+ 0 - 6
src/main/java/com/kdanmobile/reader/ReaderViewModel.kt

@@ -253,12 +253,6 @@ class ReaderViewModel(
         return OpenFileResult.FAILED
     }
 
-    fun encrypt(password: String): Boolean {
-        val isSuccess = kmpdfDocumentController?.addPasswordForDocument(password) ?: false
-        kmpdfDocumentController?.save()
-        return isSuccess
-    }
-
     override fun onCleared() {
         readerModelManager.release(uri)
         super.onCleared()

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

@@ -108,4 +108,6 @@
     <string name="reader_clear_signature_dialog_msg">Sind Sie sicher, dass Sie alle Signaturen löschen möchten?</string>
     <string name="cannot_open_buffer">Datei kann nicht geöffnet werden</string>
     <string name="reader_more_menu_ibon">Drucken aus iBon</string>
+    <string name="reader_more_menu_encrypt">Verschlüsseln</string>
+    <string name="reader_more_menu_decrypt">Passwort entfernen</string>
 </resources>

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

@@ -107,4 +107,6 @@
     <string name="reader_clear_signature_dialog_msg">¿ Seguro que desea eliminar todas las firmas ?</string>
     <string name="cannot_open_buffer">No se puede abrir el archivo</string>
     <string name="reader_more_menu_ibon">Impresión desde ibon</string>
+    <string name="reader_more_menu_encrypt">Cifrar</string>
+    <string name="reader_more_menu_decrypt">Elimine contraseña</string>
 </resources>

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

@@ -107,4 +107,6 @@
     <string name="reader_clear_signature_dialog_msg">Etes-vous sûre de vouloir supprimer toutes les signatures?</string>
     <string name="cannot_open_buffer">Nous ne pouvons ouvrir le fichier</string>
     <string name="reader_more_menu_ibon">Impression d\'ibon</string>
+    <string name="reader_more_menu_encrypt">Crypter</string>
+    <string name="reader_more_menu_decrypt">Supprimer Le Mot De Passe</string>
 </resources>

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

@@ -107,4 +107,6 @@
     <string name="reader_clear_signature_dialog_msg">"Sei sicuro di voler cancellare tutte le firme ? "</string>
     <string name="cannot_open_buffer">Impossibile aprire il file</string>
     <string name="reader_more_menu_ibon">Stampa da iBon</string>
+    <string name="reader_more_menu_encrypt">Encrypt</string>
+    <string name="reader_more_menu_decrypt">Rimuovi password</string>
 </resources>

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

@@ -106,4 +106,6 @@
     <string name="reader_clear_signature_dialog_msg">PDFから署名を削除しますか?</string>
     <string name="cannot_open_buffer">ファイルを開くことができません</string>
     <string name="reader_more_menu_ibon">ibon印刷する</string>
+    <string name="reader_more_menu_encrypt">エンクリプション</string>
+    <string name="reader_more_menu_decrypt">パスワードの削除</string>
 </resources>

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

@@ -107,4 +107,6 @@
     <string name="reader_clear_signature_dialog_msg">모든 서명을 삭제하시겠습니까 ?</string>
     <string name="cannot_open_buffer">파일을 열 수 없습니다</string>
     <string name="reader_more_menu_ibon">ibon에서 인쇄</string>
+    <string name="reader_more_menu_encrypt">암호화</string>
+    <string name="reader_more_menu_decrypt">비밀번호 제거</string>
 </resources>

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

@@ -107,4 +107,6 @@
     <string name="reader_clear_signature_dialog_msg">Você deseja excluir todas as assinaturas?</string>
     <string name="cannot_open_buffer">Não conseguimos abrir o arquivo</string>
     <string name="reader_more_menu_ibon">Imprimir a partir do iBon</string>
+    <string name="reader_more_menu_encrypt">Criptografar</string>
+    <string name="reader_more_menu_decrypt">Remover Senha</string>
 </resources>

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

@@ -107,4 +107,6 @@
     <string name="reader_clear_signature_dialog_msg">Вы уверены , что хотите удалить все подписи ?</string>
     <string name="cannot_open_buffer">Не возможно открыть файл</string>
     <string name="reader_more_menu_ibon">Печать из ibon</string>
+    <string name="reader_more_menu_encrypt">Зашифровать</string>
+    <string name="reader_more_menu_decrypt">Удалить пароль</string>
 </resources>

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

@@ -107,4 +107,6 @@
     <string name="reader_clear_signature_dialog_msg">是否要移除文件內所有簽名?</string>
     <string name="cannot_open_buffer">無法打開檔案</string>
     <string name="reader_more_menu_ibon">ibon雲端列印</string>
+    <string name="reader_more_menu_encrypt">加密</string>
+    <string name="reader_more_menu_decrypt">移除密碼</string>
 </resources>

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

@@ -107,4 +107,6 @@
     <string name="reader_clear_signature_dialog_msg">是否要移除文件内所有签名?</string>
     <string name="cannot_open_buffer">无法打开文档</string>
     <string name="reader_more_menu_ibon">ibon云端列印</string>
+    <string name="reader_more_menu_encrypt">加密</string>
+    <string name="reader_more_menu_decrypt">移除密码</string>
 </resources>