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

Commit

Permalink
Merge branch 'develop' into bug/chrome_autofill_fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Harsh Shandilya authored Jul 7, 2020
2 parents 1ee176e + 5d17024 commit 064a076
Show file tree
Hide file tree
Showing 87 changed files with 338 additions and 376 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,19 @@ All notable changes to this project will be documented in this file.

## [Unreleased]

### Changed

- A brand new icon to go with our biggest update ever!
- Light theme is now a consistent white across the board with ample contrast
- XkPassword generator is now easier to use with less configuration options

### Fixed

- Folder names that were very long did not look right
- Error message for wrong SSH/HTTPS password now looks cleaner
- Fix authentication failure with usernames that contain the `@` character
- Text input boxes were illegible on dark theme
- Top-level password names had inconsistent top margin making them look askew
- Autofill can now be made more reliable in Chrome by enabling an accessibility service that works around known Chrome limitations

### Added
Expand Down
31 changes: 0 additions & 31 deletions app/src/debug/res/drawable/ic_launcher_foreground.xml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import android.content.IntentSender
import android.os.Build
import androidx.annotation.RequiresApi
import androidx.appcompat.app.AppCompatActivity
import com.zeapo.pwdstore.autofill.oreo.FormOrigin

@RequiresApi(Build.VERSION_CODES.O)
@Suppress("UNUSED_PARAMETER")
Expand Down
Binary file added app/src/main/ic_launcher-playstore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed app/src/main/ic_launcher-web.png
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* SPDX-License-Identifier: GPL-3.0-only
*/
@file:Suppress("Deprecation")

package com.zeapo.pwdstore.autofill

import android.app.PendingIntent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* SPDX-License-Identifier: GPL-3.0-only
*/
@file:Suppress("Deprecation")

package com.zeapo.pwdstore.autofill

import android.annotation.SuppressLint
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* SPDX-License-Identifier: GPL-3.0-only
*/
@file:Suppress("Deprecation")

package com.zeapo.pwdstore.autofill

import android.content.Context
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* SPDX-License-Identifier: GPL-3.0-only
*/
@file:Suppress("Deprecation")

package com.zeapo.pwdstore.autofill

import android.content.Context
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* SPDX-License-Identifier: GPL-3.0-only
*/
@file:Suppress("Deprecation")

package com.zeapo.pwdstore.autofill

import android.accessibilityservice.AccessibilityService
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,91 +9,62 @@ 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

/** 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
Expand All @@ -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
Expand All @@ -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")
Expand All @@ -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"
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/res/color/outlined_box_selector.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/secondary_color" android:state_focused="true" />
<item android:color="@color/secondary_color" android:state_hovered="true" />
<item android:color="@color/secondary_color" />
</selector>
Binary file removed app/src/main/res/drawable-nodpi/autofill_ins_1.png
Binary file not shown.
Binary file not shown.
Binary file removed app/src/main/res/drawable-nodpi/autofill_ins_2.png
Binary file not shown.
Binary file not shown.
Binary file removed app/src/main/res/drawable-nodpi/autofill_ins_3.png
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 064a076

Please sign in to comment.