Skip to content
This repository was archived by the owner on Oct 15, 2024. It is now read-only.

Commit b6f5421

Browse files
committed
remove all mentions of getWorkTree
1 parent 0f7c933 commit b6f5421

File tree

9 files changed

+17
-29
lines changed

9 files changed

+17
-29
lines changed

app/src/main/java/com/zeapo/pwdstore/PasswordFragment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ public void popBack() {
221221
*/
222222
public File getCurrentDir() {
223223
if (pathStack.isEmpty())
224-
return PasswordRepository.getWorkTree();
224+
return PasswordRepository.getRepositoryDirectory(getActivity().getApplicationContext());
225225
else
226226
return pathStack.peek();
227227
}

app/src/main/java/com/zeapo/pwdstore/PasswordStore.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ private void createRepository() {
272272
PasswordRepository.initialize(this);
273273
}
274274

275-
File localDir = PasswordRepository.getWorkTree();
275+
File localDir = PasswordRepository.getRepositoryDirectory(getApplicationContext());
276276

277277
localDir.mkdir();
278278
try {
@@ -329,7 +329,7 @@ private void checkLocalRepository() {
329329
intent.putExtra("operation", "git_external");
330330
startActivityForResult(intent, HOME);
331331
} else {
332-
checkLocalRepository(PasswordRepository.getWorkTree());
332+
checkLocalRepository(PasswordRepository.getRepositoryDirectory(getApplicationContext()));
333333
}
334334
}
335335

@@ -344,7 +344,7 @@ private void checkLocalRepository(File localDir) {
344344

345345
plist = new PasswordFragment();
346346
Bundle args = new Bundle();
347-
args.putString("Path", PasswordRepository.getWorkTree().getAbsolutePath());
347+
args.putString("Path", PasswordRepository.getRepositoryDirectory(getApplicationContext()).getAbsolutePath());
348348

349349
// if the activity was started from the autofill settings, the
350350
// intent is to match a clicked pwd with app. pass this to fragment
@@ -510,7 +510,7 @@ private File getCurrentDir() {
510510
if ((null != plist)) {
511511
return plist.getCurrentDir();
512512
}
513-
return PasswordRepository.getWorkTree();
513+
return PasswordRepository.getRepositoryDirectory(getApplicationContext());
514514
}
515515

516516
private void commit(final String message) {
@@ -604,9 +604,9 @@ protected void onActivityResult(int requestCode, int resultCode,
604604
Log.e("Moving", "Something went wrong while moving.");
605605
} else {
606606
commit("[ANDROID PwdStore] Moved "
607-
+ string.replace(PasswordRepository.getWorkTree() + "/", "")
607+
+ string.replace(PasswordRepository.getRepositoryDirectory(getApplicationContext()) + "/", "")
608608
+ " to "
609-
+ target.getAbsolutePath().replace(PasswordRepository.getWorkTree() + "/", "")
609+
+ target.getAbsolutePath().replace(PasswordRepository.getRepositoryDirectory(getApplicationContext()) + "/", "")
610610
+ target.getAbsolutePath() + "/" + source.getName() + ".");
611611
}
612612
}
@@ -685,7 +685,7 @@ public void onClick(DialogInterface dialog, int which) {
685685

686686
public void matchPasswordWithApp(PasswordItem item) {
687687
String path = item.getFile().getAbsolutePath();
688-
path = path.replace(PasswordRepository.getWorkTree() + "/", "").replace(".gpg", "");
688+
path = path.replace(PasswordRepository.getRepositoryDirectory(getApplicationContext()) + "/", "").replace(".gpg", "");
689689
Intent data = new Intent();
690690
data.putExtra("path", path);
691691
setResult(RESULT_OK, data);

app/src/main/java/com/zeapo/pwdstore/SelectFolderFragment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ public void popBack() {
216216
*/
217217
public File getCurrentDir() {
218218
if (pathStack.isEmpty())
219-
return PasswordRepository.getWorkTree();
219+
return PasswordRepository.getRepositoryDirectory(getActivity().getApplicationContext());
220220
else
221221
return pathStack.peek();
222222
}

app/src/main/java/com/zeapo/pwdstore/UserPreference.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,13 @@ public boolean onPreferenceClick(Preference preference) {
118118
new AlertDialog.Builder(callingActivity).
119119
setTitle(R.string.pref_dialog_delete_title).
120120
setMessage(getResources().getString(R.string.dialog_delete_msg)
121-
+ " \n" + PasswordRepository.getWorkTree().toString()).
121+
+ " \n" + PasswordRepository.getRepositoryDirectory(callingActivity.getApplicationContext()).toString()).
122122
setCancelable(false).
123123
setPositiveButton(R.string.dialog_delete, new DialogInterface.OnClickListener() {
124124
@Override
125125
public void onClick(DialogInterface dialogInterface, int i) {
126126
try {
127-
FileUtils.cleanDirectory(PasswordRepository.getWorkTree());
127+
FileUtils.cleanDirectory(PasswordRepository.getRepositoryDirectory(callingActivity.getApplicationContext()));
128128
PasswordRepository.closeRepository();
129129
} catch (Exception e) {
130130
//TODO Handle the diffent cases of exceptions

app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public static AutofillService getInstance() {
6969
public void setResultData(Intent data) { resultData = data; }
7070

7171
public void setPickedPassword(String path) {
72-
items.add(new File(PasswordRepository.getWorkTree() + "/" + path + ".gpg"));
72+
items.add(new File(PasswordRepository.getRepositoryDirectory(getApplicationContext()) + "/" + path + ".gpg"));
7373
bindDecryptAndVerify();
7474
}
7575

@@ -334,7 +334,7 @@ private void getPreferredPasswords(String preference) {
334334
String preferredPasswords[] = preference.split("\n");
335335
items = new ArrayList<>();
336336
for (String password : preferredPasswords) {
337-
String path = PasswordRepository.getWorkTree() + "/" + password + ".gpg";
337+
String path = PasswordRepository.getRepositoryDirectory(getApplicationContext()) + "/" + password + ".gpg";
338338
if (new File(path).exists()) {
339339
items.add(new File(path));
340340
}

app/src/main/java/com/zeapo/pwdstore/crypto/PgpHandler.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ private void selectFolder(Intent data) {
457457

458458
passwordList = new SelectFolderFragment();
459459
Bundle args = new Bundle();
460-
args.putString("Path", PasswordRepository.getWorkTree().getAbsolutePath());
460+
args.putString("Path", PasswordRepository.getRepositoryDirectory(getApplicationContext()).getAbsolutePath());
461461

462462
passwordList.setArguments(args);
463463

@@ -751,7 +751,7 @@ public void onBound(IOpenPgpService2 service) {
751751
((EditText) findViewById(R.id.crypto_password_edit)).setTypeface(monoTypeface);
752752
((EditText) findViewById(R.id.crypto_extra_edit)).setTypeface(monoTypeface);
753753
String cat = extra.getString("FILE_PATH");
754-
cat = cat.replace(PasswordRepository.getWorkTree().getAbsolutePath(), "");
754+
cat = cat.replace(PasswordRepository.getRepositoryDirectory(getApplicationContext()).getAbsolutePath(), "");
755755
cat = cat + "/";
756756
((TextView) findViewById(R.id.crypto_password_category)).setText(cat);
757757
} else if (operation.equals("GET_KEY_ID")) {
@@ -765,7 +765,7 @@ public void onBound(IOpenPgpService2 service) {
765765
} else if (operation.equals("EDIT")) {
766766
setContentView(R.layout.decrypt_layout);
767767
((TextView) findViewById(R.id.crypto_password_file)).setText(extra.getString("NAME"));
768-
String cat = new File(extra.getString("FILE_PATH").replace(PasswordRepository.getWorkTree().getAbsolutePath(), ""))
768+
String cat = new File(extra.getString("FILE_PATH").replace(PasswordRepository.getRepositoryDirectory(getApplicationContext()).getAbsolutePath(), ""))
769769
.getParentFile().getName();
770770

771771
((TextView) findViewById(R.id.crypto_password_category)).setText(cat + "/");

app/src/main/java/com/zeapo/pwdstore/git/CloneOperation.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
import android.content.DialogInterface;
66

77
import com.zeapo.pwdstore.R;
8-
import com.zeapo.pwdstore.utils.PasswordRepository;
98

10-
import org.apache.commons.io.FileUtils;
119
import org.eclipse.jgit.api.CloneCommand;
1210
import org.eclipse.jgit.api.Git;
1311

@@ -86,12 +84,6 @@ public void onTaskEnded(String result) {
8684
setPositiveButton(callingActivity.getResources().getString(R.string.dialog_ok), new DialogInterface.OnClickListener() {
8785
@Override
8886
public void onClick(DialogInterface dialogInterface, int i) {
89-
// if we were unable to finish the job
90-
try {
91-
FileUtils.deleteDirectory(PasswordRepository.getWorkTree());
92-
} catch (Exception e) {
93-
e.printStackTrace();
94-
}
9587
}
9688
}).show();
9789
}

app/src/main/java/com/zeapo/pwdstore/git/GitActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ public void cloneRepository(View view) {
470470
if (PasswordRepository.getRepository(null) == null) {
471471
PasswordRepository.initialize(this);
472472
}
473-
localDir = PasswordRepository.getWorkTree();
473+
localDir = PasswordRepository.getRepositoryDirectory(context);
474474

475475
if (!saveConfiguration())
476476
return;

app/src/main/java/com/zeapo/pwdstore/utils/PasswordRepository.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,6 @@ public static ArrayList<PasswordItem> getPasswords(File rootDir) {
159159
return getPasswords(rootDir, rootDir);
160160
}
161161

162-
public static File getWorkTree() {
163-
return repository.getWorkTree();
164-
}
165-
166162
/**
167163
* Gets the .gpg files in a directory
168164
* @param path the directory path

0 commit comments

Comments
 (0)