Преглед на файлове

Remove ReaderViewModel::encrypt(String)

cooperku_kdanmobile преди 4 години
родител
ревизия
e056903107
променени са 2 файла, в които са добавени 2 реда и са изтрити 25 реда
  1. 2 19
      src/main/java/com/kdanmobile/reader/ReaderActivity.kt
  2. 0 6
      src/main/java/com/kdanmobile/reader/ReaderViewModel.kt

+ 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()