소스 검색

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