aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
authorHarsh Shandilya <msfjarvis@gmail.com>2020-07-07 19:18:24 +0530
committerGitHub <noreply@github.com>2020-07-07 19:18:24 +0530
commit5d170249cdd0050349f40d3a5852a8ba996663bc (patch)
treeb5c4b1654b8d44c7f0893b84cbc7072d0e35ad18 /app/src/main/java
parent035d3feaa4e81eadef69bb7799d3cedf7ff17d33 (diff)
Major UI overhaul and the introduction of a new icon (#920)
Co-authored-by: Fabian Henneke <fabian@henneke.me>
Diffstat (limited to 'app/src/main/java')
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/autofill/AutofillActivity.kt1
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/autofill/AutofillFragment.kt1
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/autofill/AutofillPreferenceActivity.kt1
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/autofill/AutofillRecyclerAdapter.kt1
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.kt1
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/crypto/PasswordCreationActivity.kt8
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/ui/adapters/PasswordItemRecyclerAdapter.kt6
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/ui/dialogs/XkPasswordGeneratorDialogFragment.kt75
8 files changed, 34 insertions, 60 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillActivity.kt b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillActivity.kt
index a64cdced..30766021 100644
--- a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillActivity.kt
+++ b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillActivity.kt
@@ -3,6 +3,7 @@
* SPDX-License-Identifier: GPL-3.0-only
*/
@file:Suppress("Deprecation")
+
package com.zeapo.pwdstore.autofill
import android.app.PendingIntent
diff --git a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillFragment.kt b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillFragment.kt
index 269e6624..5effb32f 100644
--- a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillFragment.kt
+++ b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillFragment.kt
@@ -3,6 +3,7 @@
* SPDX-License-Identifier: GPL-3.0-only
*/
@file:Suppress("Deprecation")
+
package com.zeapo.pwdstore.autofill
import android.annotation.SuppressLint
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 e8bf5537..1841aa06 100644
--- a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillPreferenceActivity.kt
+++ b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillPreferenceActivity.kt
@@ -3,6 +3,7 @@
* SPDX-License-Identifier: GPL-3.0-only
*/
@file:Suppress("Deprecation")
+
package com.zeapo.pwdstore.autofill
import android.content.Context
diff --git a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillRecyclerAdapter.kt b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillRecyclerAdapter.kt
index 5752b055..937c0e1a 100644
--- a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillRecyclerAdapter.kt
+++ b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillRecyclerAdapter.kt
@@ -3,6 +3,7 @@
* SPDX-License-Identifier: GPL-3.0-only
*/
@file:Suppress("Deprecation")
+
package com.zeapo.pwdstore.autofill
import android.content.Context
diff --git a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.kt b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.kt
index bfb1c5d0..da774882 100644
--- a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.kt
+++ b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.kt
@@ -3,6 +3,7 @@
* SPDX-License-Identifier: GPL-3.0-only
*/
@file:Suppress("Deprecation")
+
package com.zeapo.pwdstore.autofill
import android.accessibilityservice.AccessibilityService
diff --git a/app/src/main/java/com/zeapo/pwdstore/crypto/PasswordCreationActivity.kt b/app/src/main/java/com/zeapo/pwdstore/crypto/PasswordCreationActivity.kt
index 13f9add3..b98f20df 100644
--- a/app/src/main/java/com/zeapo/pwdstore/crypto/PasswordCreationActivity.kt
+++ b/app/src/main/java/com/zeapo/pwdstore/crypto/PasswordCreationActivity.kt
@@ -104,7 +104,11 @@ class PasswordCreationActivity : BasePgpActivity(), OpenPgpServiceConnection.OnB
oldCategory = path
}
}
- suggestedName?.let { filename.setText(it) }
+ if (suggestedName != null) {
+ filename.setText(suggestedName)
+ } else {
+ filename.requestFocus()
+ }
// Allow the user to quickly switch between storing the username as the filename or
// in the encrypted extras. This only makes sense if the directory structure is
// FileBased.
@@ -164,7 +168,7 @@ class PasswordCreationActivity : BasePgpActivity(), OpenPgpServiceConnection.OnB
override fun onOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) {
- android.R.id.home, R.id.cancel_password_add -> {
+ android.R.id.home -> {
setResult(RESULT_CANCELED)
finish()
}
diff --git a/app/src/main/java/com/zeapo/pwdstore/ui/adapters/PasswordItemRecyclerAdapter.kt b/app/src/main/java/com/zeapo/pwdstore/ui/adapters/PasswordItemRecyclerAdapter.kt
index fd96b7a8..fc63aec4 100644
--- a/app/src/main/java/com/zeapo/pwdstore/ui/adapters/PasswordItemRecyclerAdapter.kt
+++ b/app/src/main/java/com/zeapo/pwdstore/ui/adapters/PasswordItemRecyclerAdapter.kt
@@ -65,7 +65,11 @@ open class PasswordItemRecyclerAdapter :
} else {
typeImage.setImageResource(R.drawable.ic_action_secure_24dp)
val parentPath = item.fullPathToParent.replace("(^/)|(/$)".toRegex(), "")
- val source = "$parentPath\n$item"
+ val source = if (parentPath.isNotEmpty()) {
+ "$parentPath\n$item"
+ } else {
+ "$item"
+ }
val spannable = SpannableString(source)
spannable.setSpan(RelativeSizeSpan(0.7f), 0, parentPath.length, 0)
name.text = spannable
diff --git a/app/src/main/java/com/zeapo/pwdstore/ui/dialogs/XkPasswordGeneratorDialogFragment.kt b/app/src/main/java/com/zeapo/pwdstore/ui/dialogs/XkPasswordGeneratorDialogFragment.kt
index 206b0533..d9a4ba75 100644
--- a/app/src/main/java/com/zeapo/pwdstore/ui/dialogs/XkPasswordGeneratorDialogFragment.kt
+++ b/app/src/main/java/com/zeapo/pwdstore/ui/dialogs/XkPasswordGeneratorDialogFragment.kt
@@ -9,18 +9,16 @@ import android.content.Context
import android.content.SharedPreferences
import android.graphics.Typeface
import android.os.Bundle
-import android.widget.CheckBox
import android.widget.EditText
-import android.widget.Spinner
import android.widget.Toast
import androidx.appcompat.app.AlertDialog
-import androidx.appcompat.widget.AppCompatEditText
import androidx.appcompat.widget.AppCompatTextView
import androidx.core.content.edit
import androidx.fragment.app.DialogFragment
import com.github.ajalt.timberkt.Timber.tag
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.zeapo.pwdstore.R
+import com.zeapo.pwdstore.databinding.FragmentXkpwgenBinding
import com.zeapo.pwdstore.pwgen.PasswordGenerator
import com.zeapo.pwdstore.pwgenxkpwd.CapsType
import com.zeapo.pwdstore.pwgenxkpwd.PasswordBuilder
@@ -28,72 +26,45 @@ import com.zeapo.pwdstore.pwgenxkpwd.PasswordBuilder
/** A placeholder fragment containing a simple view. */
class XkPasswordGeneratorDialogFragment : DialogFragment() {
- private lateinit var editSeparator: AppCompatEditText
- private lateinit var editNumWords: AppCompatEditText
- private lateinit var cbSymbols: CheckBox
- private lateinit var spinnerCapsType: Spinner
- private lateinit var cbNumbers: CheckBox
private lateinit var prefs: SharedPreferences
- private lateinit var spinnerNumbersCount: Spinner
- private lateinit var spinnerSymbolsCount: Spinner
+ private lateinit var binding: FragmentXkpwgenBinding
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val builder = MaterialAlertDialogBuilder(requireContext())
val callingActivity = requireActivity()
val inflater = callingActivity.layoutInflater
- val view = inflater.inflate(R.layout.fragment_xkpwgen, null)
+ binding = FragmentXkpwgenBinding.inflate(inflater)
val monoTypeface = Typeface.createFromAsset(callingActivity.assets, "fonts/sourcecodepro.ttf")
- builder.setView(view)
+ builder.setView(binding.root)
prefs = callingActivity.getSharedPreferences("PasswordGenerator", Context.MODE_PRIVATE)
- cbNumbers = view.findViewById(R.id.xknumerals)
- cbNumbers.isChecked = prefs.getBoolean(PREF_KEY_USE_NUMERALS, false)
-
- spinnerNumbersCount = view.findViewById(R.id.xk_numbers_count)
-
- val storedNumbersCount = prefs.getInt(PREF_KEY_NUMBERS_COUNT, 0)
- spinnerNumbersCount.setSelection(storedNumbersCount)
-
- cbSymbols = view.findViewById(R.id.xksymbols)
- cbSymbols.isChecked = prefs.getBoolean(PREF_KEY_USE_SYMBOLS, false) != false
- spinnerSymbolsCount = view.findViewById(R.id.xk_symbols_count)
- val symbolsCount = prefs.getInt(PREF_KEY_SYMBOLS_COUNT, 0)
- spinnerSymbolsCount.setSelection(symbolsCount)
-
val previousStoredCapStyle: String = try {
prefs.getString(PREF_KEY_CAPITALS_STYLE, DEFAULT_CAPS_STYLE)!!
} catch (e: Exception) {
tag("xkpw").e(e)
DEFAULT_CAPS_STYLE
}
- spinnerCapsType = view.findViewById(R.id.xkCapType)
-
- val lastCapitalsStyleIndex: Int
- lastCapitalsStyleIndex = try {
+ val lastCapitalsStyleIndex: Int = try {
CapsType.valueOf(previousStoredCapStyle).ordinal
} catch (e: Exception) {
tag("xkpw").e(e)
DEFAULT_CAPS_INDEX
}
- spinnerCapsType.setSelection(lastCapitalsStyleIndex)
-
- editNumWords = view.findViewById(R.id.xk_num_words)
- editNumWords.setText(prefs.getString(PREF_KEY_NUM_WORDS, DEFAULT_NUMBER_OF_WORDS))
+ binding.xkCapType.setSelection(lastCapitalsStyleIndex)
+ binding.xkNumWords.setText(prefs.getString(PREF_KEY_NUM_WORDS, DEFAULT_NUMBER_OF_WORDS))
- editSeparator = view.findViewById(R.id.xk_separator)
- editSeparator.setText(prefs.getString(PREF_KEY_SEPARATOR, DEFAULT_WORD_SEPARATOR))
+ binding.xkSeparator.setText(prefs.getString(PREF_KEY_SEPARATOR, DEFAULT_WORD_SEPARATOR))
- val passwordText: AppCompatTextView = view.findViewById(R.id.xkPasswordText)
- passwordText.typeface = monoTypeface
+ binding.xkPasswordText.typeface = monoTypeface
builder.setPositiveButton(resources.getString(R.string.dialog_ok)) { _, _ ->
setPreferences()
val edit = callingActivity.findViewById<EditText>(R.id.password)
- edit.setText(passwordText.text)
+ edit.setText(binding.xkPasswordText.text)
}
// flip neutral and negative buttons
@@ -104,11 +75,11 @@ class XkPasswordGeneratorDialogFragment : DialogFragment() {
dialog.setOnShowListener {
setPreferences()
- makeAndSetPassword(passwordText)
+ makeAndSetPassword(binding.xkPasswordText)
dialog.getButton(AlertDialog.BUTTON_NEGATIVE).setOnClickListener {
setPreferences()
- makeAndSetPassword(passwordText)
+ makeAndSetPassword(binding.xkPasswordText)
}
}
return dialog
@@ -117,13 +88,11 @@ class XkPasswordGeneratorDialogFragment : DialogFragment() {
private fun makeAndSetPassword(passwordText: AppCompatTextView) {
try {
passwordText.text = PasswordBuilder(requireContext())
- .setNumberOfWords(Integer.valueOf(editNumWords.text.toString()))
+ .setNumberOfWords(Integer.valueOf(binding.xkNumWords.text.toString()))
.setMinimumWordLength(DEFAULT_MIN_WORD_LENGTH)
.setMaximumWordLength(DEFAULT_MAX_WORD_LENGTH)
- .setSeparator(editSeparator.text.toString())
- .appendNumbers(if (cbNumbers.isChecked) Integer.parseInt(spinnerNumbersCount.selectedItem as String) else 0)
- .appendSymbols(if (cbSymbols.isChecked) Integer.parseInt(spinnerSymbolsCount.selectedItem as String) else 0)
- .setCapitalization(CapsType.valueOf(spinnerCapsType.selectedItem.toString())).create()
+ .setSeparator(binding.xkSeparator.text.toString())
+ .setCapitalization(CapsType.valueOf(binding.xkCapType.selectedItem.toString())).create()
} catch (e: PasswordGenerator.PasswordGeneratorException) {
Toast.makeText(requireActivity(), e.message, Toast.LENGTH_SHORT).show()
tag("xkpw").e(e, "failure generating xkpasswd")
@@ -133,24 +102,16 @@ class XkPasswordGeneratorDialogFragment : DialogFragment() {
private fun setPreferences() {
prefs.edit {
- putBoolean(PREF_KEY_USE_NUMERALS, cbNumbers.isChecked)
- putBoolean(PREF_KEY_USE_SYMBOLS, cbSymbols.isChecked)
- putString(PREF_KEY_CAPITALS_STYLE, spinnerCapsType.selectedItem.toString())
- putString(PREF_KEY_NUM_WORDS, editNumWords.text.toString())
- putString(PREF_KEY_SEPARATOR, editSeparator.text.toString())
- putInt(PREF_KEY_NUMBERS_COUNT, Integer.parseInt(spinnerNumbersCount.selectedItem as String) - 1)
- putInt(PREF_KEY_SYMBOLS_COUNT, Integer.parseInt(spinnerSymbolsCount.selectedItem as String) - 1)
+ putString(PREF_KEY_CAPITALS_STYLE, binding.xkCapType.selectedItem.toString())
+ putString(PREF_KEY_NUM_WORDS, binding.xkNumWords.text.toString())
+ putString(PREF_KEY_SEPARATOR, binding.xkSeparator.text.toString())
}
}
companion object {
- const val PREF_KEY_USE_NUMERALS = "pref_key_use_numerals"
- const val PREF_KEY_USE_SYMBOLS = "pref_key_use_symbols"
const val PREF_KEY_CAPITALS_STYLE = "pref_key_capitals_style"
const val PREF_KEY_NUM_WORDS = "pref_key_num_words"
const val PREF_KEY_SEPARATOR = "pref_key_separator"
- const val PREF_KEY_NUMBERS_COUNT = "pref_key_xkpwgen_numbers_count"
- const val PREF_KEY_SYMBOLS_COUNT = "pref_key_symbols_count"
val DEFAULT_CAPS_STYLE = CapsType.Sentencecase.name
val DEFAULT_CAPS_INDEX = CapsType.Sentencecase.ordinal
const val DEFAULT_NUMBER_OF_WORDS = "3"