diff options
author | Matthew Wong <wongma@protonmail.ch> | 2015-08-12 21:17:15 -0400 |
---|---|---|
committer | Matthew Wong <wongma@protonmail.ch> | 2015-08-14 17:36:52 -0400 |
commit | 29b92f4a6d1dacac3e0a1154972e2659b3a536be (patch) | |
tree | 3e5156a51704cffdaa0cc84c43a51dc92f9d8f71 | |
parent | 04192a88a5181f34503caf402c329e092b7331c8 (diff) |
Make service compatible with latest PasswordRepository changes
-rw-r--r-- | app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.java | 42 |
1 files changed, 4 insertions, 38 deletions
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 2a80a449..bb3b17f2 100644 --- a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.java +++ b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.java @@ -22,7 +22,6 @@ import android.view.accessibility.AccessibilityWindowInfo; import android.widget.Toast; import com.zeapo.pwdstore.R; -import com.zeapo.pwdstore.UserPreference; import com.zeapo.pwdstore.utils.PasswordItem; import com.zeapo.pwdstore.utils.PasswordRepository; @@ -139,7 +138,7 @@ public class AutofillService extends AccessibilityService { String path = PasswordRepository.getWorkTree() + "/" + preference + ".gpg"; File file = new File(path); items = new ArrayList<>(); - items.add(PasswordItem.newPassword(file.getName(), file)); + items.add(PasswordItem.newPassword(file.getName(), file, PasswordRepository.getRepositoryDirectory(this))); } if (items.isEmpty()) { return; @@ -178,11 +177,11 @@ public class AutofillService extends AccessibilityService { private ArrayList<PasswordItem> recursiveFilter(String filter, File dir) { ArrayList<PasswordItem> items = new ArrayList<>(); if (!PasswordRepository.isInitialized()) { - initialize(); + PasswordRepository.initialize(this); } ArrayList<PasswordItem> passwordItems = dir == null ? - PasswordRepository.getPasswords() : - PasswordRepository.getPasswords(dir); + PasswordRepository.getPasswords(PasswordRepository.getRepositoryDirectory(this)) : + PasswordRepository.getPasswords(dir, PasswordRepository.getRepositoryDirectory(this)); for (PasswordItem item : passwordItems) { if (item.getType() == PasswordItem.TYPE_CATEGORY) { items.addAll(recursiveFilter(filter, item.getFile())); @@ -194,39 +193,6 @@ public class AutofillService extends AccessibilityService { return items; } - // just like PasswordRepository.initialize(). - private void initialize() { - File dir = null; - SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); - - if (settings.getBoolean("git_external", false)) { - if (settings.getString("git_external_repo", null) != null) { - dir = new File(settings.getString("git_external_repo", null)); - } - } else { - dir = new File(getFilesDir() + "/store"); - } - // temp for debug - if (dir == null) { - Intent intent = new Intent(this, UserPreference.class); - intent.putExtra("operation", "git_external"); - startActivity(intent); - return; - } - - // uninitialize the repo if the dir does not exist or is absolutely empty - if (!dir.exists() || !dir.isDirectory() || FileUtils.listFiles(dir, null, false).isEmpty()) { - settings.edit().putBoolean("repository_initialized", false).apply(); - } - - if (!PasswordRepository.getPasswords(dir).isEmpty()) { - settings.edit().putBoolean("repository_initialized", true).apply(); - } - - // create the repository static variable in PasswordRepository - PasswordRepository.getRepository(new File(dir.getAbsolutePath() + "/.git")); - } - @Override public void onInterrupt() { |