aboutsummaryrefslogtreecommitdiffstats
path: root/app/src/main/java/com/zeapo/pwdstore/autofill
diff options
context:
space:
mode:
authorHarsh Shandilya <msfjarvis@gmail.com>2020-06-12 14:58:15 +0000
committerGitHub <noreply@github.com>2020-06-12 20:28:15 +0530
commitd8231e112afb501c43041a6f839ab8285f400f77 (patch)
tree6785a8d0c6a70a3017ce5d62fe6b8234d5564f07 /app/src/main/java/com/zeapo/pwdstore/autofill
parentbf33fb2c88a208931340201e95a524b274d70b31 (diff)
downloadHardenedPass-d8231e112afb501c43041a6f839ab8285f400f77.tar.gz
HardenedPass-d8231e112afb501c43041a6f839ab8285f400f77.zip
Break down PGP Activity into focused sections (#776)
Diffstat (limited to 'app/src/main/java/com/zeapo/pwdstore/autofill')
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/autofill/AutofillPreferenceActivity.kt31
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/autofill/oreo/ui/AutofillSaveActivity.kt19
2 files changed, 26 insertions, 24 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillPreferenceActivity.kt b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillPreferenceActivity.kt
index 3553d431..860d8459 100644
--- a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillPreferenceActivity.kt
+++ b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillPreferenceActivity.kt
@@ -16,31 +16,32 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.widget.SearchView
import androidx.recyclerview.widget.DividerItemDecoration
import androidx.recyclerview.widget.LinearLayoutManager
-import androidx.recyclerview.widget.RecyclerView
import com.google.android.material.floatingactionbutton.FloatingActionButton
import com.zeapo.pwdstore.R
+import com.zeapo.pwdstore.databinding.AutofillRecyclerViewBinding
+import com.zeapo.pwdstore.utils.viewBinding
import me.zhanghai.android.fastscroll.FastScrollerBuilder
import java.lang.ref.WeakReference
import java.util.ArrayList
class AutofillPreferenceActivity : AppCompatActivity() {
+ private val binding by viewBinding(AutofillRecyclerViewBinding::inflate)
internal var recyclerAdapter: AutofillRecyclerAdapter? = null // let fragment have access
- private var recyclerView: RecyclerView? = null
private var pm: PackageManager? = null
private var recreate: Boolean = false // flag for action on up press; origin autofill dialog? different act
public override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
-
- setContentView(R.layout.autofill_recycler_view)
- recyclerView = findViewById(R.id.autofill_recycler)
+ setContentView(binding.root)
val layoutManager = LinearLayoutManager(this)
- recyclerView!!.layoutManager = layoutManager
- recyclerView!!.addItemDecoration(DividerItemDecoration(this, DividerItemDecoration.VERTICAL))
- FastScrollerBuilder(recyclerView!!).build()
+ with(binding) {
+ autofillRecycler.layoutManager = layoutManager
+ autofillRecycler.addItemDecoration(DividerItemDecoration(this@AutofillPreferenceActivity, DividerItemDecoration.VERTICAL))
+ FastScrollerBuilder(autofillRecycler).build()
+ }
pm = packageManager
@@ -105,7 +106,7 @@ class AutofillPreferenceActivity : AppCompatActivity() {
companion object {
private class PopulateTask(activity: AutofillPreferenceActivity) : AsyncTask<Void, Void, Void>() {
- val weakReference = WeakReference<AutofillPreferenceActivity>(activity)
+ val weakReference = WeakReference(activity)
override fun onPreExecute() {
weakReference.get()?.apply {
@@ -140,11 +141,13 @@ class AutofillPreferenceActivity : AppCompatActivity() {
override fun onPostExecute(ignored: Void?) {
weakReference.get()?.apply {
runOnUiThread {
- findViewById<View>(R.id.progress_bar).visibility = View.GONE
- recyclerView!!.adapter = recyclerAdapter
- val extras = intent.extras
- if (extras != null) {
- recyclerView!!.scrollToPosition(recyclerAdapter!!.getPosition(extras.getString("appName")!!))
+ with(binding) {
+ progressBar.visibility = View.GONE
+ autofillRecycler.adapter = recyclerAdapter
+ val extras = intent.extras
+ if (extras != null) {
+ autofillRecycler.scrollToPosition(recyclerAdapter!!.getPosition(extras.getString("appName")!!))
+ }
}
}
}
diff --git a/app/src/main/java/com/zeapo/pwdstore/autofill/oreo/ui/AutofillSaveActivity.kt b/app/src/main/java/com/zeapo/pwdstore/autofill/oreo/ui/AutofillSaveActivity.kt
index 209892a7..fad13ec8 100644
--- a/app/src/main/java/com/zeapo/pwdstore/autofill/oreo/ui/AutofillSaveActivity.kt
+++ b/app/src/main/java/com/zeapo/pwdstore/autofill/oreo/ui/AutofillSaveActivity.kt
@@ -23,8 +23,9 @@ import com.zeapo.pwdstore.autofill.oreo.AutofillPreferences
import com.zeapo.pwdstore.autofill.oreo.Credentials
import com.zeapo.pwdstore.autofill.oreo.FillableForm
import com.zeapo.pwdstore.autofill.oreo.FormOrigin
-import com.zeapo.pwdstore.crypto.PgpActivity
+import com.zeapo.pwdstore.crypto.PasswordCreationActivity
import com.zeapo.pwdstore.utils.PasswordRepository
+import com.zeapo.pwdstore.utils.commitChange
import java.io.File
@RequiresApi(Build.VERSION_CODES.O)
@@ -97,15 +98,14 @@ class AutofillSaveActivity : Activity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val repo = PasswordRepository.getRepositoryDirectory(applicationContext)
- val saveIntent = Intent(this, PgpActivity::class.java).apply {
+ val saveIntent = Intent(this, PasswordCreationActivity::class.java).apply {
putExtras(
bundleOf(
"REPO_PATH" to repo.absolutePath,
"FILE_PATH" to repo.resolve(intent.getStringExtra(EXTRA_FOLDER_NAME)!!).absolutePath,
- "OPERATION" to "ENCRYPT",
- "SUGGESTED_NAME" to intent.getStringExtra(EXTRA_NAME),
- "SUGGESTED_PASS" to intent.getStringExtra(EXTRA_PASSWORD),
- "GENERATE_PASSWORD" to intent.getBooleanExtra(EXTRA_GENERATE_PASSWORD, false)
+ PasswordCreationActivity.EXTRA_FILE_NAME to intent.getStringExtra(EXTRA_NAME),
+ PasswordCreationActivity.EXTRA_PASSWORD to intent.getStringExtra(EXTRA_PASSWORD),
+ PasswordCreationActivity.EXTRA_GENERATE_PASSWORD to intent.getBooleanExtra(EXTRA_GENERATE_PASSWORD, false)
)
)
}
@@ -144,10 +144,9 @@ class AutofillSaveActivity : Activity() {
// Password was extracted from a form, there is nothing to fill.
Intent()
}
- // PgpActivity delegates committing the added file to PasswordStore. Since PasswordStore
- // is not involved in an AutofillScenario, we have to commit the file ourselves.
- PasswordStore.commitChange(
- this,
+ // PasswordCreationActivity delegates committing the added file to PasswordStore. Since
+ // PasswordStore is not involved in an AutofillScenario, we have to commit the file ourselves.
+ commitChange(
getString(R.string.git_commit_add_text, longName),
finishWithResultOnEnd = result
)