remove all mentions of getWorkTree

This commit is contained in:
Mohamed Zenadi 2017-01-16 20:32:46 +01:00
parent 0f7c933565
commit b6f5421d67
9 changed files with 17 additions and 29 deletions

View file

@ -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();
}

View file

@ -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);

View file

@ -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();
}

View file

@ -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

View file

@ -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));
}

View file

@ -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 + "/");

View file

@ -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();
}

View file

@ -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;

View file

@ -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