Skip to content

Commit ef09a88

Browse files
committed
1.0.1: Add importing from Google passwords
1 parent 9648782 commit ef09a88

File tree

9 files changed

+347
-198
lines changed

9 files changed

+347
-198
lines changed

app/src/main/java/com/mikhailgrigorev/simple_password/ui/main_activity/adapters/PasswordAdapter.kt

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -38,45 +38,48 @@ class PasswordAdapter(
3838
@SuppressLint("SetTextI18n", "ClickableViewAccessibility")
3939
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
4040
val password = passwordCards[position]
41-
holder.passwordName.text = password.name
4241

42+
holder.passwordName.text = password.name
4343
holder.passwordGroup.removeAllViews()
44+
holder.passwordDescription.text = password.description
4445

4546
if (password.use_2fa) {
4647
val chip = Chip(
4748
holder.passwordGroup.context,
4849
null,
4950
R.style.Widget_MaterialComponents_Chip_Choice
5051
)
52+
5153
chip.text = "2FA"
5254
chip.isClickable = false
5355
chip.isChecked = false
5456
chip.alpha = 0.7f
5557
chip.textSize = 12F
58+
5659
holder.passwordGroup.addView(chip)
5760
}
58-
if (password.description != "")
59-
holder.passwordDescription.visibility = View.VISIBLE
60-
holder.passwordDescription.text = password.description
61-
if (password.favorite) {
62-
holder.favoriteButton.visibility = View.VISIBLE
63-
}
61+
62+
if (password.description != "") holder.passwordDescription.visibility = View.VISIBLE
63+
64+
if (password.favorite) { holder.favoriteButton.visibility = View.VISIBLE }
65+
6466
if (password.tags != "")
6567
password.tags.split("\\s".toRegex()).forEach { item ->
6668
val chip = Chip(
67-
holder.passwordGroup.context,
68-
null,
69-
R.style.Widget_MaterialComponents_Chip_Choice
69+
holder.passwordGroup.context,
70+
null,
71+
R.style.Widget_MaterialComponents_Chip_Choice
7072
)
71-
chip.text = item
73+
74+
chip.text = item.trim()
7275
chip.isClickable = true
7376
chip.isChecked = false
7477
chip.textSize = 12F
75-
chip.setOnClickListener {
76-
tagsClickListener(item)
77-
}
78+
chip.setOnClickListener { tagsClickListener(item) }
79+
7880
holder.passwordGroup.addView(chip)
7981
}
82+
8083
when {
8184
password.encrypted -> {
8285
holder.lockIcon.visibility = View.VISIBLE
@@ -108,16 +111,17 @@ class PasswordAdapter(
108111
holder.passwordCard.setOnClickListener {
109112
clickListener(position)
110113
}
114+
111115
holder.passwordCard.setOnLongClickListener {
112116
longClickListener(position, it)
113117
return@setOnLongClickListener (true)
114118
}
115119

116-
if (!Utils.toggleManager.analyzeToggle.isEnabled()) {
117-
holder.qualityMarker.visibility = View.GONE
118-
holder.creditCard.visibility = View.GONE
119-
holder.creditCardNeg.visibility = View.GONE
120-
}
120+
if (!Utils.toggleManager.analyzeToggle.isEnabled()) {
121+
holder.qualityMarker.visibility = View.GONE
122+
holder.creditCard.visibility = View.GONE
123+
holder.creditCardNeg.visibility = View.GONE
124+
}
121125
}
122126
}
123127

app/src/main/java/com/mikhailgrigorev/simple_password/ui/password/PasswordFragment.kt

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -911,44 +911,30 @@ class PasswordFragment: Fragment() {
911911
val folder = folderCards[position]
912912
changeFolderPopUp.dismiss()
913913

914-
val customAlertDialogView = LayoutInflater.from(requireContext())
915-
.inflate(R.layout.dialog_add_folder, null, false)
914+
val customAlertDialogView = LayoutInflater.from(requireContext()).inflate(R.layout.dialog_add_folder, null, false)
915+
916916
val materialAlertDialogBuilder = MaterialAlertDialogBuilder(requireContext())
917+
917918
customAlertDialogView.findViewById<SpectrumPalette>(R.id.spPalette)
918919
.setOnColorSelectedListener { color ->
919920
globalColor = "#${Integer.toHexString(color).uppercase(Locale.getDefault())}"
920921
}
922+
921923
materialAlertDialogBuilder.setView(customAlertDialogView)
922-
customAlertDialogView.findViewById<TextInputEditText>(
923-
R.id.etFolderName
924-
)
925-
.setText(
926-
folder.name
927-
)
928-
customAlertDialogView.findViewById<TextInputEditText>(
929-
R.id.etFolderDesc
930-
)
931-
.setText(
932-
folder.description
933-
)
924+
925+
customAlertDialogView.findViewById<TextInputEditText>(R.id.etFolderName).setText(folder.name)
926+
customAlertDialogView.findViewById<TextInputEditText>(R.id.etFolderDesc).setText(folder.description)
927+
934928
materialAlertDialogBuilder
935929
.setView(customAlertDialogView)
936930
.setTitle("Folder editor")
937931
.setMessage("Current configuration details")
938932
.setPositiveButton("Ok") { dialog, _ ->
939-
folder.name =
940-
customAlertDialogView.findViewById<TextInputEditText>(
941-
R.id.etFolderName
942-
).text.toString()
943-
folder.description =
944-
customAlertDialogView.findViewById<TextInputEditText>(
945-
R.id.etFolderDesc
946-
).text.toString()
947-
lifecycleScope.launch(Dispatchers.IO) {
948-
viewModel.updateCard(
949-
folder
950-
)
951-
}
933+
folder.name = customAlertDialogView.findViewById<TextInputEditText>(R.id.etFolderName).text.toString()
934+
folder.description = customAlertDialogView.findViewById<TextInputEditText>(R.id.etFolderDesc).text.toString()
935+
folder.colorTag = globalColor
936+
937+
lifecycleScope.launch(Dispatchers.IO) { viewModel.updateCard(folder) }
952938

953939
dialog.dismiss()
954940

app/src/main/java/com/mikhailgrigorev/simple_password/ui/profile/view/ProfileFragment.kt

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ class ProfileFragment : Fragment() {
5151
val view = binding.root
5252

5353
DaggerApplicationComponent.builder()
54-
.roomModule(Utils.getApplication()?.let { RoomModule(it) })
55-
.build().inject(this)
54+
.roomModule(Utils.getApplication()?.let { RoomModule(it) })
55+
.build().inject(this)
5656

5757
checkAnalyze()
5858
initViewModel()
@@ -181,14 +181,11 @@ class ProfileFragment : Fragment() {
181181

182182
private fun setListeners() {
183183
binding.ivAboutApp.setOnClickListener {
184-
findNavController().navigate(
185-
ProfileFragmentDirections.actionProfileFragmentToAboutFragment()
186-
)
184+
findNavController().navigate(ProfileFragmentDirections.actionProfileFragmentToAboutFragment())
187185
}
188186

189187
binding.cvEditAccount.setOnClickListener {
190-
findNavController().navigate(
191-
ProfileFragmentDirections.actionProfileFragmentToProfileEditFragment())
188+
findNavController().navigate(ProfileFragmentDirections.actionProfileFragmentToProfileEditFragment())
192189
}
193190

194191
binding.ivDeleteAccount.setOnClickListener {
@@ -225,9 +222,7 @@ class ProfileFragment : Fragment() {
225222

226223
val shortcutManager: ShortcutManager
227224
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
228-
shortcutManager =
229-
requireContext().getSystemService(ShortcutManager::class.java)!!
230-
225+
shortcutManager = requireContext().getSystemService(ShortcutManager::class.java)!!
231226
shortcutManager.dynamicShortcuts = shortcutList
232227
}
233228

0 commit comments

Comments
 (0)