diff options
author | Harsh Shandilya <msfjarvis@gmail.com> | 2020-10-23 10:59:42 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-23 07:29:42 +0200 |
commit | c513722a304bc5a1a5911a92e3ee44e69a8fc420 (patch) | |
tree | cea84d1f408b13d9a3b417cab68d6a4d27e3090d /app/src/main/java/com | |
parent | 4a9151870d8e5196248b2abc09df8fbb1593c265 (diff) |
Rollback automatic synchronization feature (#1165)
* Revert "Add option to automatically sync repository on app launch (#1137)"
Fixes #1163
This reverts commit 92f1aab25da12411aa256c3b763e0cb6182e9320.
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
* CHANGELOG: add entry for auto sync rollback
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
Diffstat (limited to 'app/src/main/java/com')
3 files changed, 12 insertions, 50 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/LaunchActivity.kt b/app/src/main/java/com/zeapo/pwdstore/LaunchActivity.kt index 1003167f..268698e7 100644 --- a/app/src/main/java/com/zeapo/pwdstore/LaunchActivity.kt +++ b/app/src/main/java/com/zeapo/pwdstore/LaunchActivity.kt @@ -4,34 +4,20 @@ */ package com.zeapo.pwdstore -import android.content.ComponentName import android.content.Intent import android.os.Bundle import android.os.Handler +import androidx.appcompat.app.AppCompatActivity import androidx.core.content.edit -import androidx.core.view.isVisible -import androidx.lifecycle.lifecycleScope -import com.github.michaelbull.result.fold import com.zeapo.pwdstore.crypto.DecryptActivity -import com.zeapo.pwdstore.databinding.ActivityLaunchBinding -import com.zeapo.pwdstore.git.BaseGitActivity -import com.zeapo.pwdstore.git.config.AuthMode -import com.zeapo.pwdstore.git.config.GitSettings import com.zeapo.pwdstore.utils.BiometricAuthenticator -import com.zeapo.pwdstore.utils.PasswordRepository import com.zeapo.pwdstore.utils.PreferenceKeys import com.zeapo.pwdstore.utils.sharedPrefs -import com.zeapo.pwdstore.utils.viewBinding -import kotlinx.coroutines.launch -class LaunchActivity : BaseGitActivity() { - - private val binding by viewBinding(ActivityLaunchBinding::inflate) +class LaunchActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - setContentView(binding.root) - supportActionBar?.hide() val prefs = sharedPrefs if (prefs.getBoolean(PreferenceKeys.BIOMETRIC_AUTH, false)) { BiometricAuthenticator.authenticate(this) { @@ -54,38 +40,18 @@ class LaunchActivity : BaseGitActivity() { } private fun startTargetActivity(noAuth: Boolean) { - if (intent.action == ACTION_DECRYPT_PASS) { - intent.component = ComponentName(this, DecryptActivity::class.java) - startPasswordStoreActivity(intent, noAuth) - } else { - val intent = Intent(this, PasswordStore::class.java) - val repo = PasswordRepository.initialize() - // if repo is null, let PasswordStore handle it. - if (repo != null && - !GitSettings.url.isNullOrEmpty() && - sharedPrefs.getBoolean(PreferenceKeys.SYNC_ON_LAUNCH, false)) { - binding.progressBar.isVisible = true - binding.sync.isVisible = true - runGitOperation { startPasswordStoreActivity(intent, noAuth) } - } else { - startPasswordStoreActivity(intent, noAuth) + val intentToStart = if (intent.action == ACTION_DECRYPT_PASS) + Intent(this, DecryptActivity::class.java).apply { + putExtra("NAME", intent.getStringExtra("NAME")) + putExtra("FILE_PATH", intent.getStringExtra("FILE_PATH")) + putExtra("REPO_PATH", intent.getStringExtra("REPO_PATH")) + putExtra("LAST_CHANGED_TIMESTAMP", intent.getLongExtra("LAST_CHANGED_TIMESTAMP", 0L)) } - } - } - - private fun startPasswordStoreActivity(intent: Intent, noAuth: Boolean) { - Handler().postDelayed({ - startActivity(intent) - finish() - }, if (noAuth) 500L else 0L) - } + else + Intent(this, PasswordStore::class.java) + startActivity(intentToStart) - private fun runGitOperation(onCompletion: () -> Unit) = lifecycleScope.launch { - val gitOp = if (GitSettings.authMode == AuthMode.None) GitOp.PULL else GitOp.SYNC - launchGitOperation(gitOp).fold( - success = { onCompletion.invoke() }, - failure = { promptOnErrorHandler(it) { onCompletion.invoke() } }, - ) + Handler().postDelayed({ finish() }, if (noAuth) 0L else 500L) } companion object { diff --git a/app/src/main/java/com/zeapo/pwdstore/UserPreference.kt b/app/src/main/java/com/zeapo/pwdstore/UserPreference.kt index 53a49653..66873426 100644 --- a/app/src/main/java/com/zeapo/pwdstore/UserPreference.kt +++ b/app/src/main/java/com/zeapo/pwdstore/UserPreference.kt @@ -44,7 +44,6 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.zeapo.pwdstore.crypto.BasePgpActivity import com.zeapo.pwdstore.git.GitConfigActivity import com.zeapo.pwdstore.git.GitServerConfigActivity -import com.zeapo.pwdstore.git.config.GitSettings import com.zeapo.pwdstore.git.sshj.SshKey import com.zeapo.pwdstore.pwgenxkpwd.XkpwdDictionary import com.zeapo.pwdstore.sshkeygen.ShowSshKeyFragment @@ -408,8 +407,6 @@ class UserPreference : AppCompatActivity() { true } - findPreference<CheckBoxPreference>(PreferenceKeys.SYNC_ON_LAUNCH)?.isVisible = !GitSettings.url.isNullOrEmpty() - val prefCustomXkpwdDictionary = findPreference<Preference>(PreferenceKeys.PREF_KEY_CUSTOM_DICT) prefCustomXkpwdDictionary?.onPreferenceClickListener = ClickListener { prefsActivity.storeCustomDictionaryPath() diff --git a/app/src/main/java/com/zeapo/pwdstore/utils/PreferenceKeys.kt b/app/src/main/java/com/zeapo/pwdstore/utils/PreferenceKeys.kt index 536a0c19..70818568 100644 --- a/app/src/main/java/com/zeapo/pwdstore/utils/PreferenceKeys.kt +++ b/app/src/main/java/com/zeapo/pwdstore/utils/PreferenceKeys.kt @@ -73,7 +73,6 @@ object PreferenceKeys { const val SSH_OPENKEYSTORE_CLEAR_KEY_ID = "ssh_openkeystore_clear_keyid" const val SSH_OPENKEYSTORE_KEYID = "ssh_openkeystore_keyid" const val SSH_SEE_KEY = "ssh_see_key" - const val SYNC_ON_LAUNCH = "sync_on_launch" @Deprecated("To be used only in Migrations.kt") const val USE_GENERATED_KEY = "use_generated_key" |