add save-and-copy button (#537)
This commit is contained in:
parent
7062156b1a
commit
367e55de3c
4 changed files with 37 additions and 7 deletions
|
@ -168,6 +168,7 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound {
|
|||
R.id.share_password_as_plaintext -> shareAsPlaintext()
|
||||
R.id.edit_password -> editPassword()
|
||||
R.id.crypto_confirm_add -> encrypt()
|
||||
R.id.crypto_confirm_add_and_copy -> encrypt(true)
|
||||
R.id.crypto_cancel_add -> {
|
||||
if (passwordEntry?.hotpIsIncremented() == false) {
|
||||
setResult(RESULT_CANCELED)
|
||||
|
@ -408,7 +409,7 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound {
|
|||
/**
|
||||
* Encrypts the password and the extra content
|
||||
*/
|
||||
private fun encrypt() {
|
||||
private fun encrypt(copy: Boolean = false) {
|
||||
// if HOTP was incremented, we leave fields as is; they have already been set
|
||||
if (intent.getStringExtra("OPERATION") != "INCREMENT") {
|
||||
editName = crypto_password_file_edit.text.toString().trim()
|
||||
|
@ -426,6 +427,10 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound {
|
|||
return
|
||||
}
|
||||
|
||||
if (copy) {
|
||||
copyPasswordToClipBoard()
|
||||
}
|
||||
|
||||
val data = Intent()
|
||||
data.action = OpenPgpApi.ACTION_ENCRYPT
|
||||
|
||||
|
@ -635,10 +640,17 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound {
|
|||
}
|
||||
|
||||
private fun copyPasswordToClipBoard() {
|
||||
if (findViewById<TextView>(R.id.crypto_password_show) == null)
|
||||
return
|
||||
var pass = passwordEntry?.password
|
||||
|
||||
val clip = ClipData.newPlainText("pgp_handler_result_pm", passwordEntry?.password)
|
||||
if (findViewById<TextView>(R.id.crypto_password_show) == null) {
|
||||
if (editPass == null) {
|
||||
return
|
||||
} else {
|
||||
pass = editPass
|
||||
}
|
||||
}
|
||||
|
||||
val clip = ClipData.newPlainText("pgp_handler_result_pm", pass)
|
||||
clipboard.setPrimaryClip(clip)
|
||||
|
||||
var clearAfter = 45
|
||||
|
@ -738,12 +750,12 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound {
|
|||
}
|
||||
|
||||
val container = findViewById<LinearLayout>(R.id.crypto_container_decrypt)
|
||||
container.visibility = View.VISIBLE
|
||||
container?.visibility = View.VISIBLE
|
||||
|
||||
val extraText = findViewById<TextView>(R.id.crypto_extra_show)
|
||||
|
||||
if (extraText.text.isNotEmpty())
|
||||
findViewById<View>(R.id.crypto_extra_show_layout).visibility = View.VISIBLE
|
||||
if (extraText?.text?.isNotEmpty() ?: false)
|
||||
findViewById<View>(R.id.crypto_extra_show_layout)?.visibility = View.VISIBLE
|
||||
|
||||
if (showTime == 0) {
|
||||
// treat 0 as forever, and the user must exit and/or clear clipboard on their own
|
||||
|
|
12
app/src/main/res/drawable/ic_done_copy_white_24dp.xml
Normal file
12
app/src/main/res/drawable/ic_done_copy_white_24dp.xml
Normal file
|
@ -0,0 +1,12 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="#FFFFFFFF"
|
||||
android:pathData="M9,16.2L4.8,12l-1.4,1.4L9,19 21,7l-1.4,-1.4L9,16.2z"/>
|
||||
<path
|
||||
android:fillColor="#FFFFFFFF"
|
||||
android:pathData="m11.40827,8.88349l1.33314,0q-0.34816,2.91631 -3.13784,2.91631l0,0q-1.63503,0 -2.52526,-1.23315l0,0q-0.77565,-1.08101 -0.77565,-3.01721l0,0q0,-1.97624 0.86158,-3.13732l0,0q0.85056,-1.14186 2.43932,-1.14186l0,0q2.5495,0 3.0453,2.53836l0,0l-1.30229,0q-0.33274,-1.67195 -1.743,-1.67195l0,0q-1.93691,0 -1.93691,3.41277l0,0q0,3.38395 1.95234,3.38395l0,0q1.65045,0 1.78928,-2.04991l0,0z"/>
|
||||
</vector>
|
|
@ -12,4 +12,9 @@
|
|||
pwstore:showAsAction="ifRoom"
|
||||
android:id="@+id/crypto_confirm_add"
|
||||
/>
|
||||
<item android:title="@string/crypto_save_and_copy"
|
||||
android:icon="@drawable/ic_done_copy_white_24dp"
|
||||
pwstore:showAsAction="ifRoom"
|
||||
android:id="@+id/crypto_confirm_add_and_copy"
|
||||
/>
|
||||
</menu>
|
||||
|
|
|
@ -103,6 +103,7 @@
|
|||
<string name="crypto_select">Select</string>
|
||||
<string name="crypto_cancel">Cancel</string>
|
||||
<string name="crypto_save">Save</string>
|
||||
<string name="crypto_save_and_copy">Save and Copy</string>
|
||||
|
||||
<!-- DECRYPT Layout -->
|
||||
<string name="action_search">Search</string>
|
||||
|
|
Loading…
Reference in a new issue