Added the ability to share a password as plaintext using any app, including ones like BluetoothToPc. (#213)

This commit is contained in:
Daniël van den Berg 2016-08-27 15:21:21 +02:00 committed by Mohamed Zenadi
parent 4075fddd60
commit 86083f03f5
8 changed files with 33 additions and 1 deletions

View file

@ -147,6 +147,9 @@ public class PgpHandler extends AppCompatActivity implements OpenPgpServiceConne
case R.id.copy_password:
copyToClipBoard();
break;
case R.id.share_password_as_plaintext:
shareAsPlaintext();
break;
case R.id.edit_password:
editPassword();
break;
@ -200,12 +203,35 @@ public class PgpHandler extends AppCompatActivity implements OpenPgpServiceConne
invalidateOptionsMenu();
}
public void shareAsPlaintext() {
if (findViewById(R.id.share_password_as_plaintext) == null)
return;
final TextView cryptoPasswordShow = (TextView) findViewById(R.id.crypto_password_show);
if (cryptoPasswordShow == null) {
return;
}
final CharSequence text = cryptoPasswordShow.getText();
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, text);
sendIntent.setType("text/plain");
startActivity(Intent.createChooser(sendIntent, getResources().getText(R.string.send_plaintext_password_to)));//Always show a picker to give the user a chance to cancel
}
public void copyToClipBoard() {
if (findViewById(R.id.crypto_password_show) == null)
return;
ClipData clip = ClipData.newPlainText("pgp_handler_result_pm", ((TextView) findViewById(R.id.crypto_password_show)).getText());
final TextView cryptoPasswordShow = (TextView) findViewById(R.id.crypto_password_show);
if (cryptoPasswordShow == null) {
return;
}
ClipData clip = ClipData.newPlainText("pgp_handler_result_pm", cryptoPasswordShow.getText());
clipboard.setPrimaryClip(clip);
try {
showToast(this.getResources().getString(R.string.clipboard_beginning_toast_text)

Binary file not shown.

After

Width:  |  Height:  |  Size: 397 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 268 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 496 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 698 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 938 B

View file

@ -2,6 +2,11 @@
xmlns:tools="http://schemas.android.com/tools"
xmlns:pwstore="http://schemas.android.com/apk/res-auto"
tools:context="com.zeapo.pwdstore.crypto.PgpHandler" >
<item android:title="Share as plaintext"
android:icon="@drawable/ic_share_white_24dp"
pwstore:showAsAction="ifRoom"
android:id="@+id/share_password_as_plaintext"
/>
<item android:title="Copy password"
android:icon="@drawable/ic_content_copy_white_24dp"
pwstore:showAsAction="ifRoom"

View file

@ -181,4 +181,5 @@
<string name="settings">Settings</string>
<string name="no_repo_selected">No external repository selected</string>
<string name="no_repo_selected2">No external repository selected</string>
<string name="send_plaintext_password_to">Send password as plaintext using…</string>
</resources>