diff options
author | Mohamed Zenadi <mohamed@zenadi.com> | 2015-08-11 19:12:21 +0200 |
---|---|---|
committer | Mohamed Zenadi <mohamed@zenadi.com> | 2015-08-11 19:13:38 +0200 |
commit | b1e37eaefbf7bbc509f8f1fdf001a8c28cc5c9e5 (patch) | |
tree | 3cbd98a0936518bccb2c51bc315130df5d3bdcc7 /app/src | |
parent | 33667d86e46dc4832dfec466055cf672baec6dc1 (diff) |
add a way to get the password repo dir without worktree
Diffstat (limited to 'app/src')
-rw-r--r-- | app/src/main/java/com/zeapo/pwdstore/PasswordStore.java | 4 | ||||
-rw-r--r-- | app/src/main/java/com/zeapo/pwdstore/utils/PasswordRepository.java | 18 |
2 files changed, 13 insertions, 9 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java index 4602cf59..97ac2d02 100644 --- a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java +++ b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java @@ -368,9 +368,9 @@ public class PasswordStore extends AppCompatActivity { adapter.remove(position); setResult(RESULT_CANCELED); - Git git = new Git(PasswordRepository.getRepository(new File(""))); + Repository repo = PasswordRepository.getRepository(PasswordRepository.getRepositoryDirectory(activity)); + Git git = new Git(repo); GitAsyncTask tasks = new GitAsyncTask(activity, false, true, CommitCommand.class); - System.out.println(tasks); tasks.execute( git.rm().addFilepattern(path.replace(PasswordRepository.getWorkTree() + "/", "")), git.commit().setMessage("[ANDROID PwdStore] Remove " + item + " from store.") diff --git a/app/src/main/java/com/zeapo/pwdstore/utils/PasswordRepository.java b/app/src/main/java/com/zeapo/pwdstore/utils/PasswordRepository.java index 8fa08f48..a2ca8824 100644 --- a/app/src/main/java/com/zeapo/pwdstore/utils/PasswordRepository.java +++ b/app/src/main/java/com/zeapo/pwdstore/utils/PasswordRepository.java @@ -114,18 +114,26 @@ public class PasswordRepository { repository = null; } - public static Repository initialize(Activity callingActivity) { + public static File getRepositoryDirectory(Activity callingActivity) { File dir = null; SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(callingActivity.getApplicationContext()); if (settings.getBoolean("git_external", false)) { - if (settings.getString("git_external_repo", null) != null) { - dir = new File(settings.getString("git_external_repo", null)); + String external_repo = settings.getString("git_external_repo", null); + if (external_repo != null) { + dir = new File(external_repo); } } else { dir = new File(callingActivity.getFilesDir() + "/store"); } + return dir; + } + + public static Repository initialize(Activity callingActivity) { + File dir = getRepositoryDirectory(callingActivity); + SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(callingActivity.getApplicationContext()); + if (dir == null) { return null; } @@ -143,10 +151,6 @@ public class PasswordRepository { return PasswordRepository.getRepository(new File(dir.getAbsolutePath() + "/.git")); } - public static ArrayList<File> getFilesList(){ - return getFilesList(repository.getWorkTree()); - } - /** * Gets the password items in the root directory * @return a list of passwords in the root direcotyr |