aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/com
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/com')
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/PasswordFragment.kt10
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/PasswordStore.kt27
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/SelectFolderFragment.kt31
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/ToCloneOrNot.kt4
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/sshkeygen/SshKeyGenFragment.kt4
5 files changed, 21 insertions, 55 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.kt b/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.kt
index 2f3a3a7b..140c71bb 100644
--- a/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.kt
+++ b/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.kt
@@ -9,11 +9,9 @@ import android.content.Intent
import android.content.SharedPreferences
import android.os.Bundle
import android.os.Parcelable
-import android.view.LayoutInflater
import android.view.Menu
import android.view.MenuItem
import android.view.View
-import android.view.ViewGroup
import android.view.animation.Animation
import android.view.animation.AnimationUtils
import androidx.appcompat.view.ActionMode
@@ -51,11 +49,8 @@ class PasswordFragment : Fragment() {
private fun requireStore() = requireActivity() as PasswordStore
- override fun onCreateView(
- inflater: LayoutInflater,
- container: ViewGroup?,
- savedInstanceState: Bundle?
- ): View? {
+ override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
+ super.onViewCreated(view, savedInstanceState)
settings = PreferenceManager.getDefaultSharedPreferences(requireContext())
initializePasswordList()
binding.fab.setOnClickListener {
@@ -63,7 +58,6 @@ class PasswordFragment : Fragment() {
setTargetFragment(this@PasswordFragment, 1000)
}.show(parentFragmentManager, "BOTTOM_SHEET")
}
- return binding.root
}
private fun initializePasswordList() {
diff --git a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.kt b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.kt
index 2b3c1c59..5857af74 100644
--- a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.kt
+++ b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.kt
@@ -32,6 +32,7 @@ import androidx.core.content.ContextCompat
import androidx.core.content.edit
import androidx.core.content.getSystemService
import androidx.fragment.app.FragmentManager
+import androidx.fragment.app.commit
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.observe
import androidx.preference.PreferenceManager
@@ -64,9 +65,6 @@ import com.zeapo.pwdstore.utils.PasswordRepository.Companion.getRepositoryDirect
import com.zeapo.pwdstore.utils.PasswordRepository.Companion.initialize
import com.zeapo.pwdstore.utils.PasswordRepository.Companion.isInitialized
import com.zeapo.pwdstore.utils.PasswordRepository.PasswordSortOrder.Companion.getSortOrder
-import kotlinx.android.synthetic.main.fragment_to_clone_or_not.clone_from_server_button
-import kotlinx.android.synthetic.main.fragment_to_clone_or_not.local_directory_button
-import kotlinx.android.synthetic.main.fragment_to_clone_or_not.settings_button
import org.apache.commons.io.FileUtils
import org.apache.commons.io.FilenameUtils
import org.eclipse.jgit.api.Git
@@ -128,10 +126,6 @@ class PasswordStore : AppCompatActivity() {
super.onCreate(savedInstance)
setContentView(R.layout.activity_pwdstore)
- settings_button.setOnClickListener { startActivity(Intent(this, UserPreference::class.java)) }
- local_directory_button.setOnClickListener { initRepository(NEW_REPO_BUTTON) }
- clone_from_server_button.setOnClickListener { initRepository(CLONE_REPO_BUTTON) }
-
// If user is eligible for Oreo autofill, prompt them to switch.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O &&
!settings.getBoolean(PREFERENCE_SEEN_AUTOFILL_ONBOARDING, false)) {
@@ -429,12 +423,10 @@ class PasswordStore : AppCompatActivity() {
}
private fun checkLocalRepository(localDir: File?) {
- val fragmentManager = supportFragmentManager
- val fragmentTransaction = fragmentManager.beginTransaction()
if (localDir != null && settings.getBoolean("repository_initialized", false)) {
tag(TAG).d { "Check, dir: ${localDir.absolutePath}" }
// do not push the fragment if we already have it
- if (fragmentManager.findFragmentByTag("PasswordsList") == null ||
+ if (supportFragmentManager.findFragmentByTag("PasswordsList") == null ||
settings.getBoolean("repo_changed", false)) {
settings.edit { putBoolean("repo_changed", false) }
plist = PasswordFragment()
@@ -449,16 +441,17 @@ class PasswordStore : AppCompatActivity() {
plist!!.arguments = args
supportActionBar!!.show()
supportActionBar!!.setDisplayHomeAsUpEnabled(false)
- fragmentManager.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE)
- fragmentTransaction.replace(R.id.main_layout, plist!!, "PasswordsList")
- fragmentTransaction.commit()
+ supportFragmentManager.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE)
+ supportFragmentManager.commit {
+ replace(R.id.main_layout, plist!!, "PasswordsList")
+ }
}
} else {
supportActionBar!!.hide()
- fragmentManager.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE)
- val cloneFrag = ToCloneOrNot()
- fragmentTransaction.replace(R.id.main_layout, cloneFrag, "ToCloneOrNot")
- fragmentTransaction.commit()
+ supportFragmentManager.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE)
+ supportFragmentManager.commit {
+ replace(R.id.main_layout, ToCloneOrNot())
+ }
}
}
diff --git a/app/src/main/java/com/zeapo/pwdstore/SelectFolderFragment.kt b/app/src/main/java/com/zeapo/pwdstore/SelectFolderFragment.kt
index a17e6862..41c9443b 100644
--- a/app/src/main/java/com/zeapo/pwdstore/SelectFolderFragment.kt
+++ b/app/src/main/java/com/zeapo/pwdstore/SelectFolderFragment.kt
@@ -6,54 +6,41 @@ package com.zeapo.pwdstore
import android.content.Context
import android.os.Bundle
-import android.view.LayoutInflater
import android.view.View
-import android.view.ViewGroup
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels
import androidx.lifecycle.observe
import androidx.recyclerview.widget.LinearLayoutManager
-import androidx.recyclerview.widget.RecyclerView
-import com.google.android.material.floatingactionbutton.FloatingActionButton
+import com.zeapo.pwdstore.databinding.PasswordRecyclerViewBinding
import com.zeapo.pwdstore.ui.adapters.PasswordItemRecyclerAdapter
import com.zeapo.pwdstore.utils.PasswordItem
+import com.zeapo.pwdstore.utils.viewBinding
import me.zhanghai.android.fastscroll.FastScrollerBuilder
import java.io.File
class SelectFolderFragment : Fragment() {
+ private val binding by viewBinding(PasswordRecyclerViewBinding::bind)
private lateinit var recyclerAdapter: PasswordItemRecyclerAdapter
- private lateinit var recyclerView: RecyclerView
private lateinit var listener: OnFragmentInteractionListener
private val model: SearchableRepositoryViewModel by activityViewModels()
- override fun onCreateView(
- inflater: LayoutInflater,
- container: ViewGroup?,
- savedInstanceState: Bundle?
- ): View? {
- val view = inflater.inflate(R.layout.password_recycler_view, container, false)
- initializePasswordList(view)
- val fab: FloatingActionButton = view.findViewById(R.id.fab)
- fab.hide()
- return view
- }
-
- private fun initializePasswordList(rootView: View) {
+ override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
+ super.onViewCreated(view, savedInstanceState)
+ binding.fab.hide()
recyclerAdapter = PasswordItemRecyclerAdapter()
.onItemClicked { _, item ->
listener.onFragmentInteraction(item)
}
- recyclerView = rootView.findViewById(R.id.pass_recycler)
- recyclerView.apply {
+ binding.passRecycler.apply {
layoutManager = LinearLayoutManager(requireContext())
itemAnimator = null
adapter = recyclerAdapter
}
- FastScrollerBuilder(recyclerView).build()
- registerForContextMenu(recyclerView)
+ FastScrollerBuilder(binding.passRecycler).build()
+ registerForContextMenu(binding.passRecycler)
val path = requireNotNull(requireArguments().getString(PasswordStore.REQUEST_ARG_PATH))
model.navigateTo(File(path), listMode = ListMode.DirectoriesOnly, pushPreviousLocation = false)
diff --git a/app/src/main/java/com/zeapo/pwdstore/ToCloneOrNot.kt b/app/src/main/java/com/zeapo/pwdstore/ToCloneOrNot.kt
index 49a680cf..f235fe46 100644
--- a/app/src/main/java/com/zeapo/pwdstore/ToCloneOrNot.kt
+++ b/app/src/main/java/com/zeapo/pwdstore/ToCloneOrNot.kt
@@ -6,9 +6,7 @@ package com.zeapo.pwdstore
import android.content.Intent
import android.os.Bundle
-import android.view.LayoutInflater
import android.view.View
-import android.view.ViewGroup
import androidx.fragment.app.Fragment
import com.zeapo.pwdstore.databinding.FragmentToCloneOrNotBinding
import com.zeapo.pwdstore.utils.viewBinding
@@ -17,8 +15,6 @@ class ToCloneOrNot : Fragment() {
private val binding by viewBinding(FragmentToCloneOrNotBinding::bind)
- override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? = binding.root
-
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding.settingsButton.setOnClickListener { startActivity(Intent(requireContext(), UserPreference::class.java)) }
diff --git a/app/src/main/java/com/zeapo/pwdstore/sshkeygen/SshKeyGenFragment.kt b/app/src/main/java/com/zeapo/pwdstore/sshkeygen/SshKeyGenFragment.kt
index 510f5ce2..34806e0e 100644
--- a/app/src/main/java/com/zeapo/pwdstore/sshkeygen/SshKeyGenFragment.kt
+++ b/app/src/main/java/com/zeapo/pwdstore/sshkeygen/SshKeyGenFragment.kt
@@ -5,9 +5,7 @@
package com.zeapo.pwdstore.sshkeygen
import android.os.Bundle
-import android.view.LayoutInflater
import android.view.View
-import android.view.ViewGroup
import android.view.inputmethod.InputMethodManager
import androidx.core.content.edit
import androidx.core.content.getSystemService
@@ -31,8 +29,6 @@ class SshKeyGenFragment : Fragment() {
private var keyLength = 4096
private val binding by viewBinding(FragmentSshKeygenBinding::bind)
- override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?) = binding.root
-
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
with(binding) {