mirror of
https://github.com/android-password-store/Android-Password-Store
synced 2025-08-31 22:35:17 +00:00
add a way to get the password repo dir without worktree
This commit is contained in:
@@ -368,9 +368,9 @@ public class PasswordStore extends AppCompatActivity {
|
|||||||
adapter.remove(position);
|
adapter.remove(position);
|
||||||
|
|
||||||
setResult(RESULT_CANCELED);
|
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);
|
GitAsyncTask tasks = new GitAsyncTask(activity, false, true, CommitCommand.class);
|
||||||
System.out.println(tasks);
|
|
||||||
tasks.execute(
|
tasks.execute(
|
||||||
git.rm().addFilepattern(path.replace(PasswordRepository.getWorkTree() + "/", "")),
|
git.rm().addFilepattern(path.replace(PasswordRepository.getWorkTree() + "/", "")),
|
||||||
git.commit().setMessage("[ANDROID PwdStore] Remove " + item + " from store.")
|
git.commit().setMessage("[ANDROID PwdStore] Remove " + item + " from store.")
|
||||||
|
@@ -114,18 +114,26 @@ public class PasswordRepository {
|
|||||||
repository = null;
|
repository = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Repository initialize(Activity callingActivity) {
|
public static File getRepositoryDirectory(Activity callingActivity) {
|
||||||
File dir = null;
|
File dir = null;
|
||||||
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(callingActivity.getApplicationContext());
|
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(callingActivity.getApplicationContext());
|
||||||
|
|
||||||
if (settings.getBoolean("git_external", false)) {
|
if (settings.getBoolean("git_external", false)) {
|
||||||
if (settings.getString("git_external_repo", null) != null) {
|
String external_repo = settings.getString("git_external_repo", null);
|
||||||
dir = new File(settings.getString("git_external_repo", null));
|
if (external_repo != null) {
|
||||||
|
dir = new File(external_repo);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
dir = new File(callingActivity.getFilesDir() + "/store");
|
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) {
|
if (dir == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -143,10 +151,6 @@ public class PasswordRepository {
|
|||||||
return PasswordRepository.getRepository(new File(dir.getAbsolutePath() + "/.git"));
|
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
|
* Gets the password items in the root directory
|
||||||
* @return a list of passwords in the root direcotyr
|
* @return a list of passwords in the root direcotyr
|
||||||
|
Reference in New Issue
Block a user