Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
  • Loading branch information
msfjarvis committed Jun 1, 2020
1 parent a5f2b0d commit b3090e0
Show file tree
Hide file tree
Showing 11 changed files with 33 additions and 40 deletions.
3 changes: 1 addition & 2 deletions app/src/main/java/com/zeapo/pwdstore/PasswordStore.kt
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ import java.io.File
import java.lang.Character.UnicodeBlock
import java.util.Stack

class PasswordStore : AppCompatActivity() {
class PasswordStore : AppCompatActivity(R.layout.activity_pwdstore) {

private lateinit var activity: PasswordStore
private lateinit var searchItem: MenuItem
Expand Down Expand Up @@ -126,7 +126,6 @@ class PasswordStore : AppCompatActivity() {
savedInstance = null
}
super.onCreate(savedInstance)
setContentView(R.layout.activity_pwdstore)

// If user is eligible for Oreo autofill, prompt them to switch.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O &&
Expand Down
18 changes: 7 additions & 11 deletions app/src/main/java/com/zeapo/pwdstore/SelectFolderActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,17 @@ import android.view.Menu
import android.view.MenuItem
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.commit
import com.zeapo.pwdstore.utils.PasswordRepository

// TODO more work needed, this is just an extraction from PgpHandler

class SelectFolderActivity : AppCompatActivity() {
class SelectFolderActivity : AppCompatActivity(R.layout.select_folder_layout) {
private lateinit var passwordList: SelectFolderFragment

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

setContentView(R.layout.select_folder_layout)

val fragmentManager = supportFragmentManager
val fragmentTransaction = fragmentManager.beginTransaction()

passwordList = SelectFolderFragment()
val args = Bundle()
args.putString(PasswordStore.REQUEST_ARG_PATH, PasswordRepository.getRepositoryDirectory(applicationContext).absolutePath)
Expand All @@ -33,10 +29,11 @@ class SelectFolderActivity : AppCompatActivity() {

supportActionBar?.show()

fragmentManager.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE)
supportFragmentManager.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE)

fragmentTransaction.replace(R.id.pgp_handler_linearlayout, passwordList, "PasswordsList")
fragmentTransaction.commit()
supportFragmentManager.commit {
replace(R.id.pgp_handler_linearlayout, passwordList, "PasswordsList")
}
}

override fun onCreateOptionsMenu(menu: Menu): Boolean {
Expand All @@ -45,8 +42,7 @@ class SelectFolderActivity : AppCompatActivity() {
}

override fun onOptionsItemSelected(item: MenuItem): Boolean {
val id = item.itemId
when (id) {
when (item.itemId) {
android.R.id.home -> {
setResult(Activity.RESULT_CANCELED)
finish()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,31 @@ 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() {
class AutofillPreferenceActivity : AppCompatActivity(R.layout.autofill_recycler_view) {

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)

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

Expand Down Expand Up @@ -105,7 +105,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 {
Expand Down Expand Up @@ -140,11 +140,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")!!))
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import com.zeapo.pwdstore.utils.PasswordItem
import com.zeapo.pwdstore.utils.viewBinding

@TargetApi(Build.VERSION_CODES.O)
class AutofillFilterView : AppCompatActivity() {
class AutofillFilterView : AppCompatActivity(R.layout.activity_oreo_autofill_filter) {

companion object {
private const val HEIGHT_PERCENTAGE = 0.9
Expand Down Expand Up @@ -81,7 +81,6 @@ class AutofillFilterView : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(binding.root)
setFinishOnTouchOutside(true)

val params = window.attributes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import com.zeapo.pwdstore.databinding.ActivityOreoAutofillPublisherChangedBindin
import com.zeapo.pwdstore.utils.viewBinding

@TargetApi(Build.VERSION_CODES.O)
class AutofillPublisherChangedActivity : AppCompatActivity() {
class AutofillPublisherChangedActivity : AppCompatActivity(R.layout.activity_oreo_autofill_publisher_changed) {

companion object {
private const val EXTRA_APP_PACKAGE =
Expand All @@ -50,7 +50,6 @@ class AutofillPublisherChangedActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(binding.root)
setFinishOnTouchOutside(true)

appPackage = intent.getStringExtra(EXTRA_APP_PACKAGE) ?: run {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import org.openintents.openpgp.IOpenPgpService2
import org.openintents.openpgp.OpenPgpError

@Suppress("Registered")
open class BasePgpActivity(@LayoutRes layoutRes: Int) : AppCompatActivity(layoutRes), OpenPgpServiceConnection.OnBound {
open class BasePgpActivity(@LayoutRes contentLayoutRes: Int) : AppCompatActivity(contentLayoutRes), OpenPgpServiceConnection.OnBound {

val repoPath: String by lazy { intent.getStringExtra("REPO_PATH") }
val fullPath: String by lazy { intent.getStringExtra("FILE_PATH") }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ class DecryptActivity : BasePgpActivity(R.layout.decrypt_layout), OpenPgpService
super.onCreate(savedInstanceState)
bindToOpenKeychain(this)
with(binding) {
setContentView(root)
passwordCategory.text = relativeParentPath
passwordFile.text = name
passwordFile.setOnLongClickListener {
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/com/zeapo/pwdstore/git/BaseGitActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import android.content.SharedPreferences
import android.os.Bundle
import android.view.MenuItem
import androidx.annotation.CallSuper
import androidx.annotation.LayoutRes
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.edit
import androidx.core.text.isDigitsOnly
Expand All @@ -30,7 +31,7 @@ import java.net.URI
* Abstract AppCompatActivity that holds some information that is commonly shared across git-related
* tasks and makes sense to be held here.
*/
abstract class BaseGitActivity : AppCompatActivity() {
abstract class BaseGitActivity(@LayoutRes contentLayoutRes: Int) : AppCompatActivity(contentLayoutRes) {

lateinit var protocol: Protocol
lateinit var connectionMode: ConnectionMode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@ import com.zeapo.pwdstore.utils.PasswordRepository
import com.zeapo.pwdstore.utils.viewBinding
import org.eclipse.jgit.lib.Constants

class GitConfigActivity : BaseGitActivity() {
class GitConfigActivity : BaseGitActivity(R.layout.activity_git_config) {

private val binding by viewBinding(ActivityGitConfigBinding::inflate)

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(binding.root)
supportActionBar?.setDisplayHomeAsUpEnabled(true)

if (username.isEmpty())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import com.zeapo.pwdstore.R
import com.zeapo.pwdstore.UserPreference
import com.zeapo.pwdstore.utils.PasswordRepository

open class GitOperationActivity : BaseGitActivity() {
open class GitOperationActivity : BaseGitActivity(0) {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
when (intent.extras?.getInt(REQUEST_ARG_OP)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import java.io.IOException
* Activity that encompasses both the initial clone as well as editing the server config for future
* changes.
*/
class GitServerConfigActivity : BaseGitActivity() {
class GitServerConfigActivity : BaseGitActivity(R.layout.activity_git_clone) {

private val binding by viewBinding(ActivityGitCloneBinding::inflate)

Expand All @@ -34,7 +34,6 @@ class GitServerConfigActivity : BaseGitActivity() {
if (isClone) {
binding.saveButton.text = getString(R.string.clone_button)
}
setContentView(binding.root)
supportActionBar?.setDisplayHomeAsUpEnabled(true)

binding.cloneProtocolGroup.check(when (protocol) {
Expand Down

0 comments on commit b3090e0

Please sign in to comment.