summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZeapo <mohamed@zenadi.com>2014-08-09 01:08:17 +0100
committerZeapo <mohamed@zenadi.com>2014-08-09 01:08:17 +0100
commit79fd5586f937f50764cc6fc5c8cec1e4783877e4 (patch)
treea7fc8ecf3d24826648f5626b451b6dad0ce952a6
parentbac44808d3ed284ab3853e95003ea7e7a56c5596 (diff)
add and remove are now committing files to git
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/GitAsyncTask.java13
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/PasswordStore.java2
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/crypto/PgpHandler.java11
3 files changed, 25 insertions, 1 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/GitAsyncTask.java b/app/src/main/java/com/zeapo/pwdstore/GitAsyncTask.java
index cc8938fb..085798ce 100644
--- a/app/src/main/java/com/zeapo/pwdstore/GitAsyncTask.java
+++ b/app/src/main/java/com/zeapo/pwdstore/GitAsyncTask.java
@@ -1,6 +1,7 @@
package com.zeapo.pwdstore;
import android.app.Activity;
+import android.app.ProgressDialog;
import android.os.AsyncTask;
import android.util.Log;
@@ -15,10 +16,21 @@ import org.eclipse.jgit.api.errors.TransportException;
public class GitAsyncTask extends AsyncTask<GitCommand, Integer, Integer> {
private Activity activity;
private boolean finishOnEnd;
+ private ProgressDialog dialog;
+
public GitAsyncTask(Activity activity, boolean finishOnEnd) {
this.activity = activity;
this.finishOnEnd = finishOnEnd;
+
+ dialog = new ProgressDialog(this.activity);
}
+
+ protected void onPreExecute() {
+ this.dialog.setMessage("Running command...");
+ this.dialog.setCancelable(false);
+ this.dialog.show();
+ }
+
@Override
protected Integer doInBackground(GitCommand... cmd) {
int count = cmd.length;
@@ -45,6 +57,7 @@ public class GitAsyncTask extends AsyncTask<GitCommand, Integer, Integer> {
protected void onPostExecute(Integer result) {
Log.i("GIT_ASYNC", result + "");
+ this.dialog.dismiss();
if (finishOnEnd) {
this.activity.finish();
}
diff --git a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java
index 9d0944e3..0ff75c3b 100644
--- a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java
+++ b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java
@@ -262,7 +262,7 @@ public class PasswordStore extends Activity implements ToCloneOrNot.OnFragmentI
GitAsyncTask tasks = new GitAsyncTask(this, false);
tasks.execute(
git.add().addFilepattern("."),
- git.commit().setMessage("Added " + data.getExtras().getString("NAME"))
+ git.commit().setMessage("[ANDROID PwdStore] Add " + data.getExtras().getString("NAME") + " from store.")
);
break;
}
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 a89451b8..93aee0fa 100644
--- a/app/src/main/java/com/zeapo/pwdstore/crypto/PgpHandler.java
+++ b/app/src/main/java/com/zeapo/pwdstore/crypto/PgpHandler.java
@@ -25,11 +25,13 @@ import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
+import com.zeapo.pwdstore.GitAsyncTask;
import com.zeapo.pwdstore.R;
import com.zeapo.pwdstore.UserPreference;
import com.zeapo.pwdstore.utils.PasswordRepository;
import org.apache.commons.io.FileUtils;
+import org.eclipse.jgit.api.Git;
import org.openintents.openpgp.OpenPgpError;
import org.openintents.openpgp.OpenPgpSignatureResult;
import org.openintents.openpgp.util.OpenPgpApi;
@@ -50,6 +52,7 @@ public class PgpHandler extends Activity {
private String keyIDs = "";
private String accountName = "";
SharedPreferences settings;
+ private Activity activity;
public static final int REQUEST_CODE_SIGN = 9910;
public static final int REQUEST_CODE_ENCRYPT = 9911;
@@ -68,6 +71,7 @@ public class PgpHandler extends Activity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ activity = this;
// some persistance
settings = PreferenceManager.getDefaultSharedPreferences(this);
@@ -441,6 +445,13 @@ public class PgpHandler extends Activity {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
(new File(getIntent().getExtras().getString("FILE_PATH"))).delete();
+
+ Git git = new Git(PasswordRepository.getRepository(new File("")));
+ GitAsyncTask tasks = new GitAsyncTask(activity, false);
+ tasks.execute(
+ git.rm().addFilepattern(getIntent().getExtras().getString("FILE_PATH").replace(PasswordRepository.getWorkTree() + "/", "")),
+ git.commit().setMessage("[ANDROID PwdStore] Remove " + getIntent().getExtras().getString("FILE_PATH") + " from store.")
+ );
setResult(RESULT_OK);
finish();
}