diff options
author | Matthew Wong <wongma@protonmail.ch> | 2015-08-14 14:12:02 -0400 |
---|---|---|
committer | Matthew Wong <wongma@protonmail.ch> | 2015-08-14 17:38:17 -0400 |
commit | b1807197f85c4d6ceccc3ca23654bb184f9caa13 (patch) | |
tree | 82226ce09fc4970664c250146ec850463a3a97b3 /app/src/main | |
parent | 8388d8530a63d1484607aa83faa27a99adb40f8e (diff) |
Fix crash on first start & use documentLaunchMode for nicer openkeychain-api behaviour (5+ only)
Diffstat (limited to 'app/src/main')
-rw-r--r-- | app/src/main/AndroidManifest.xml | 4 | ||||
-rw-r--r-- | app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.java | 12 |
2 files changed, 10 insertions, 6 deletions
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index ecd106cd..0789fd33 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -55,7 +55,9 @@ </service> <activity android:name=".autofill.AutofillActivity" - android:parentActivityName=".PasswordStore"> + android:parentActivityName=".PasswordStore" + android:documentLaunchMode="intoExisting" + android:excludeFromRecents="true"> <meta-data android:name="android.support.PARENT_ACTIVITY" android:value="com.zeapo.pwdstore.PasswordStore" /> 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 688e22fc..1e64e8c8 100644 --- a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.java +++ b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.java @@ -130,11 +130,17 @@ public class AutofillService extends AccessibilityService { String preference = prefs.getString(event.getPackageName().toString(), defValue); switch (preference) { case "first": + if (!PasswordRepository.isInitialized()) { + PasswordRepository.initialize(this); + } items = recursiveFilter(appName, null); break; case "never": return; default: + if (!PasswordRepository.isInitialized()) { + PasswordRepository.initialize(this); + } String path = PasswordRepository.getWorkTree() + "/" + preference + ".gpg"; File file = new File(path); items = new ArrayList<>(); @@ -177,9 +183,6 @@ public class AutofillService extends AccessibilityService { private ArrayList<PasswordItem> recursiveFilter(String filter, File dir) { ArrayList<PasswordItem> items = new ArrayList<>(); - if (!PasswordRepository.isInitialized()) { - PasswordRepository.initialize(this); - } ArrayList<PasswordItem> passwordItems = dir == null ? PasswordRepository.getPasswords(PasswordRepository.getRepositoryDirectory(this)) : PasswordRepository.getPasswords(dir, PasswordRepository.getRepositoryDirectory(this)); @@ -252,8 +255,7 @@ public class AutofillService extends AccessibilityService { PendingIntent pi = result.getParcelableExtra(OpenPgpApi.RESULT_INTENT); // need to start a blank activity to call startIntentSenderForResult Intent intent = new Intent(AutofillService.this, AutofillActivity.class); - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK - | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); intent.putExtra("pending_intent", pi); startActivity(intent); break; |