diff options
| author | Fabian Henneke <FabianHenneke@users.noreply.github.com> | 2020-09-03 10:48:14 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-09-03 14:18:14 +0530 |
| commit | 3840f43fa0026b06b15913379761c1bf6b6a1c68 (patch) | |
| tree | 41a5d47c3ed3ef06430d2d045876301d4db416ad /app/src/main/java/com/zeapo/pwdstore/git/GitOperationActivity.kt | |
| parent | 258ccc601605f3112d9310043b9a34bf6ca3c9e0 (diff) | |
| download | HardenedPass-3840f43fa0026b06b15913379761c1bf6b6a1c68.tar.gz HardenedPass-3840f43fa0026b06b15913379761c1bf6b6a1c68.zip | |
Refactor Git operations and auth (#1066)
Co-authored-by: Harsh Shandilya <me@msfjarvis.dev>
Diffstat (limited to 'app/src/main/java/com/zeapo/pwdstore/git/GitOperationActivity.kt')
| -rw-r--r-- | app/src/main/java/com/zeapo/pwdstore/git/GitOperationActivity.kt | 79 |
1 files changed, 0 insertions, 79 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/git/GitOperationActivity.kt b/app/src/main/java/com/zeapo/pwdstore/git/GitOperationActivity.kt deleted file mode 100644 index 8b772747..00000000 --- a/app/src/main/java/com/zeapo/pwdstore/git/GitOperationActivity.kt +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright © 2014-2020 The Android Password Store Authors. All Rights Reserved. - * SPDX-License-Identifier: GPL-3.0-only - */ -package com.zeapo.pwdstore.git - -import android.content.Intent -import android.os.Bundle -import android.view.Menu -import android.view.MenuItem -import androidx.lifecycle.lifecycleScope -import com.google.android.material.dialog.MaterialAlertDialogBuilder -import com.zeapo.pwdstore.R -import com.zeapo.pwdstore.UserPreference -import com.zeapo.pwdstore.git.config.GitSettings -import com.zeapo.pwdstore.utils.PasswordRepository -import kotlinx.coroutines.launch - -open class GitOperationActivity : BaseGitActivity() { - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - when (val reqCode = intent.extras?.getInt(REQUEST_ARG_OP)) { - REQUEST_PULL -> lifecycleScope.launch { syncRepository(REQUEST_PULL) } - REQUEST_PUSH -> lifecycleScope.launch { syncRepository(REQUEST_PUSH) } - REQUEST_SYNC -> lifecycleScope.launch { syncRepository(REQUEST_SYNC) } - else -> { - throw IllegalArgumentException("Invalid request code: $reqCode") - } - } - } - - override fun onCreateOptionsMenu(menu: Menu): Boolean { - // Inflate the menu; this adds items to the action bar if it is present. - menuInflater.inflate(R.menu.git_clone, menu) - return true - } - - override fun onOptionsItemSelected(item: MenuItem): Boolean { - return when (item.itemId) { - R.id.user_pref -> try { - val intent = Intent(this, UserPreference::class.java) - startActivity(intent) - true - } catch (e: Exception) { - println("Exception caught :(") - e.printStackTrace() - false - } - else -> super.onOptionsItemSelected(item) - } - } - - /** - * Syncs the local repository with the remote one (either pull or push) - * - * @param operation the operation to execute can be REQUEST_PULL or REQUEST_PUSH - */ - private suspend fun syncRepository(operation: Int) { - if (GitSettings.url.isNullOrEmpty()) - MaterialAlertDialogBuilder(this) - .setMessage(getString(R.string.set_information_dialog_text)) - .setPositiveButton(getString(R.string.dialog_positive)) { _, _ -> - val intent = Intent(this, UserPreference::class.java) - startActivityForResult(intent, REQUEST_PULL) - } - .setNegativeButton(getString(R.string.dialog_negative)) { _, _ -> - // do nothing :( - setResult(RESULT_OK) - finish() - } - .show() - else { - // check that the remote origin is here, else add it - PasswordRepository.addRemote("origin", GitSettings.url!!, true) - launchGitOperation(operation) - } - } -} |
