diff options
author | Mohamed Zenadi <mohamed@zenadi.com> | 2017-01-16 20:32:46 +0100 |
---|---|---|
committer | Mohamed Zenadi <mohamed@zenadi.com> | 2017-01-16 20:32:59 +0100 |
commit | b6f5421d674cea5f5a479080bbd9c4857712764d (patch) | |
tree | e6232f67c5f457bc87ea7bd639cb7727010f0486 | |
parent | 0f7c933565e05aeb00df97bfe32d4459f372ce60 (diff) |
remove all mentions of getWorkTree
9 files changed, 17 insertions, 29 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.java b/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.java index b08db439..49d57e30 100644 --- a/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.java +++ b/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.java @@ -221,7 +221,7 @@ public class PasswordFragment extends Fragment{ */ public File getCurrentDir() { if (pathStack.isEmpty()) - return PasswordRepository.getWorkTree(); + return PasswordRepository.getRepositoryDirectory(getActivity().getApplicationContext()); else return pathStack.peek(); } diff --git a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java index b2dafdb8..4d3b84e5 100644 --- a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java +++ b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java @@ -272,7 +272,7 @@ public class PasswordStore extends AppCompatActivity { PasswordRepository.initialize(this); } - File localDir = PasswordRepository.getWorkTree(); + File localDir = PasswordRepository.getRepositoryDirectory(getApplicationContext()); localDir.mkdir(); try { @@ -329,7 +329,7 @@ public class PasswordStore extends AppCompatActivity { intent.putExtra("operation", "git_external"); startActivityForResult(intent, HOME); } else { - checkLocalRepository(PasswordRepository.getWorkTree()); + checkLocalRepository(PasswordRepository.getRepositoryDirectory(getApplicationContext())); } } @@ -344,7 +344,7 @@ public class PasswordStore extends AppCompatActivity { plist = new PasswordFragment(); Bundle args = new Bundle(); - args.putString("Path", PasswordRepository.getWorkTree().getAbsolutePath()); + args.putString("Path", PasswordRepository.getRepositoryDirectory(getApplicationContext()).getAbsolutePath()); // if the activity was started from the autofill settings, the // intent is to match a clicked pwd with app. pass this to fragment @@ -510,7 +510,7 @@ public class PasswordStore extends AppCompatActivity { if ((null != plist)) { return plist.getCurrentDir(); } - return PasswordRepository.getWorkTree(); + return PasswordRepository.getRepositoryDirectory(getApplicationContext()); } private void commit(final String message) { @@ -604,9 +604,9 @@ public class PasswordStore extends AppCompatActivity { Log.e("Moving", "Something went wrong while moving."); } else { commit("[ANDROID PwdStore] Moved " - + string.replace(PasswordRepository.getWorkTree() + "/", "") + + string.replace(PasswordRepository.getRepositoryDirectory(getApplicationContext()) + "/", "") + " to " - + target.getAbsolutePath().replace(PasswordRepository.getWorkTree() + "/", "") + + target.getAbsolutePath().replace(PasswordRepository.getRepositoryDirectory(getApplicationContext()) + "/", "") + target.getAbsolutePath() + "/" + source.getName() + "."); } } @@ -685,7 +685,7 @@ public class PasswordStore extends AppCompatActivity { public void matchPasswordWithApp(PasswordItem item) { String path = item.getFile().getAbsolutePath(); - path = path.replace(PasswordRepository.getWorkTree() + "/", "").replace(".gpg", ""); + path = path.replace(PasswordRepository.getRepositoryDirectory(getApplicationContext()) + "/", "").replace(".gpg", ""); Intent data = new Intent(); data.putExtra("path", path); setResult(RESULT_OK, data); diff --git a/app/src/main/java/com/zeapo/pwdstore/SelectFolderFragment.java b/app/src/main/java/com/zeapo/pwdstore/SelectFolderFragment.java index c9bc3596..bf378153 100644 --- a/app/src/main/java/com/zeapo/pwdstore/SelectFolderFragment.java +++ b/app/src/main/java/com/zeapo/pwdstore/SelectFolderFragment.java @@ -216,7 +216,7 @@ public class SelectFolderFragment extends Fragment{ */ public File getCurrentDir() { if (pathStack.isEmpty()) - return PasswordRepository.getWorkTree(); + return PasswordRepository.getRepositoryDirectory(getActivity().getApplicationContext()); else return pathStack.peek(); } diff --git a/app/src/main/java/com/zeapo/pwdstore/UserPreference.java b/app/src/main/java/com/zeapo/pwdstore/UserPreference.java index 8c612771..1a618249 100644 --- a/app/src/main/java/com/zeapo/pwdstore/UserPreference.java +++ b/app/src/main/java/com/zeapo/pwdstore/UserPreference.java @@ -118,13 +118,13 @@ public class UserPreference extends AppCompatActivity { new AlertDialog.Builder(callingActivity). setTitle(R.string.pref_dialog_delete_title). setMessage(getResources().getString(R.string.dialog_delete_msg) - + " \n" + PasswordRepository.getWorkTree().toString()). + + " \n" + PasswordRepository.getRepositoryDirectory(callingActivity.getApplicationContext()).toString()). setCancelable(false). setPositiveButton(R.string.dialog_delete, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { try { - FileUtils.cleanDirectory(PasswordRepository.getWorkTree()); + FileUtils.cleanDirectory(PasswordRepository.getRepositoryDirectory(callingActivity.getApplicationContext())); PasswordRepository.closeRepository(); } catch (Exception e) { //TODO Handle the diffent cases of exceptions 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 2ea95d5e..2d19860f 100644 --- a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.java +++ b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.java @@ -69,7 +69,7 @@ public class AutofillService extends AccessibilityService { public void setResultData(Intent data) { resultData = data; } public void setPickedPassword(String path) { - items.add(new File(PasswordRepository.getWorkTree() + "/" + path + ".gpg")); + items.add(new File(PasswordRepository.getRepositoryDirectory(getApplicationContext()) + "/" + path + ".gpg")); bindDecryptAndVerify(); } @@ -334,7 +334,7 @@ public class AutofillService extends AccessibilityService { String preferredPasswords[] = preference.split("\n"); items = new ArrayList<>(); for (String password : preferredPasswords) { - String path = PasswordRepository.getWorkTree() + "/" + password + ".gpg"; + String path = PasswordRepository.getRepositoryDirectory(getApplicationContext()) + "/" + password + ".gpg"; if (new File(path).exists()) { items.add(new File(path)); } diff --git a/app/src/main/java/com/zeapo/pwdstore/crypto/PgpHandler.java b/app/src/main/java/com/zeapo/pwdstore/crypto/PgpHandler.java index da235c2e..e898d1bb 100644 --- a/app/src/main/java/com/zeapo/pwdstore/crypto/PgpHandler.java +++ b/app/src/main/java/com/zeapo/pwdstore/crypto/PgpHandler.java @@ -457,7 +457,7 @@ public class PgpHandler extends AppCompatActivity implements OpenPgpServiceConne passwordList = new SelectFolderFragment(); Bundle args = new Bundle(); - args.putString("Path", PasswordRepository.getWorkTree().getAbsolutePath()); + args.putString("Path", PasswordRepository.getRepositoryDirectory(getApplicationContext()).getAbsolutePath()); passwordList.setArguments(args); @@ -751,7 +751,7 @@ public class PgpHandler extends AppCompatActivity implements OpenPgpServiceConne ((EditText) findViewById(R.id.crypto_password_edit)).setTypeface(monoTypeface); ((EditText) findViewById(R.id.crypto_extra_edit)).setTypeface(monoTypeface); String cat = extra.getString("FILE_PATH"); - cat = cat.replace(PasswordRepository.getWorkTree().getAbsolutePath(), ""); + cat = cat.replace(PasswordRepository.getRepositoryDirectory(getApplicationContext()).getAbsolutePath(), ""); cat = cat + "/"; ((TextView) findViewById(R.id.crypto_password_category)).setText(cat); } else if (operation.equals("GET_KEY_ID")) { @@ -765,7 +765,7 @@ public class PgpHandler extends AppCompatActivity implements OpenPgpServiceConne } else if (operation.equals("EDIT")) { setContentView(R.layout.decrypt_layout); ((TextView) findViewById(R.id.crypto_password_file)).setText(extra.getString("NAME")); - String cat = new File(extra.getString("FILE_PATH").replace(PasswordRepository.getWorkTree().getAbsolutePath(), "")) + String cat = new File(extra.getString("FILE_PATH").replace(PasswordRepository.getRepositoryDirectory(getApplicationContext()).getAbsolutePath(), "")) .getParentFile().getName(); ((TextView) findViewById(R.id.crypto_password_category)).setText(cat + "/"); diff --git a/app/src/main/java/com/zeapo/pwdstore/git/CloneOperation.java b/app/src/main/java/com/zeapo/pwdstore/git/CloneOperation.java index d46513fd..25dba1fc 100644 --- a/app/src/main/java/com/zeapo/pwdstore/git/CloneOperation.java +++ b/app/src/main/java/com/zeapo/pwdstore/git/CloneOperation.java @@ -5,9 +5,7 @@ import android.app.AlertDialog; import android.content.DialogInterface; import com.zeapo.pwdstore.R; -import com.zeapo.pwdstore.utils.PasswordRepository; -import org.apache.commons.io.FileUtils; import org.eclipse.jgit.api.CloneCommand; import org.eclipse.jgit.api.Git; @@ -86,12 +84,6 @@ public class CloneOperation extends GitOperation { setPositiveButton(callingActivity.getResources().getString(R.string.dialog_ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { - // if we were unable to finish the job - try { - FileUtils.deleteDirectory(PasswordRepository.getWorkTree()); - } catch (Exception e) { - e.printStackTrace(); - } } }).show(); } diff --git a/app/src/main/java/com/zeapo/pwdstore/git/GitActivity.java b/app/src/main/java/com/zeapo/pwdstore/git/GitActivity.java index 14b6ac59..96104e67 100644 --- a/app/src/main/java/com/zeapo/pwdstore/git/GitActivity.java +++ b/app/src/main/java/com/zeapo/pwdstore/git/GitActivity.java @@ -470,7 +470,7 @@ public class GitActivity extends AppCompatActivity { if (PasswordRepository.getRepository(null) == null) { PasswordRepository.initialize(this); } - localDir = PasswordRepository.getWorkTree(); + localDir = PasswordRepository.getRepositoryDirectory(context); if (!saveConfiguration()) return; 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 6638d4cf..90cd5ed0 100644 --- a/app/src/main/java/com/zeapo/pwdstore/utils/PasswordRepository.java +++ b/app/src/main/java/com/zeapo/pwdstore/utils/PasswordRepository.java @@ -159,10 +159,6 @@ public class PasswordRepository { return getPasswords(rootDir, rootDir); } - public static File getWorkTree() { - return repository.getWorkTree(); - } - /** * Gets the .gpg files in a directory * @param path the directory path |