From 5cba6c62d7b4628dfaf482dd883e333f93d323d4 Mon Sep 17 00:00:00 2001 From: Felix Bechstein Date: Sat, 22 Jul 2017 12:09:34 +0200 Subject: Parse username from password entry, refs #192 (#318) This is a first step of letting APS handle usernames from password entries. It shows the username in PgpHandler and allows to copy it to the clipboard. --- app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.java') diff --git a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.java b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.java index 447f39f3..004a0bbd 100644 --- a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.java +++ b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.java @@ -23,6 +23,7 @@ import android.view.accessibility.AccessibilityNodeInfo; import android.view.accessibility.AccessibilityWindowInfo; import android.widget.Toast; +import com.zeapo.pwdstore.PasswordEntry; import com.zeapo.pwdstore.R; import com.zeapo.pwdstore.utils.PasswordRepository; @@ -492,7 +493,7 @@ public class AutofillService extends AccessibilityService { switch (result.getIntExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR)) { case OpenPgpApi.RESULT_CODE_SUCCESS: { try { - String[] passContent = os.toString("UTF-8").split("\n"); + final PasswordEntry entry = new PasswordEntry(os); // if the user focused on something else, take focus back // but this will open another dialog...hack to ignore this @@ -501,11 +502,11 @@ public class AutofillService extends AccessibilityService { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Bundle args = new Bundle(); args.putCharSequence(AccessibilityNodeInfo.ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE, - passContent[0]); + entry.getPassword()); info.performAction(AccessibilityNodeInfo.ACTION_SET_TEXT, args); } else { ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); - ClipData clip = ClipData.newPlainText("autofill_pm", passContent[0]); + ClipData clip = ClipData.newPlainText("autofill_pm", entry.getPassword()); clipboard.setPrimaryClip(clip); info.performAction(AccessibilityNodeInfo.ACTION_PASTE); -- cgit v1.2.3