summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorZeapo <mohamed@zenadi.com>2014-08-09 00:44:45 +0100
committerZeapo <mohamed@zenadi.com>2014-08-09 00:44:45 +0100
commitbac44808d3ed284ab3853e95003ea7e7a56c5596 (patch)
treedb99893190851322d8e7242dbfae18f508359a0c /app
parent4002791b150d47d4dc173cc11deaffcb8a0e0c9d (diff)
corrected a small issue with commit and added push to origin
Diffstat (limited to 'app')
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/GitHandler.java11
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/PasswordStore.java14
2 files changed, 21 insertions, 4 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/GitHandler.java b/app/src/main/java/com/zeapo/pwdstore/GitHandler.java
index 155f47d2..977a45ba 100644
--- a/app/src/main/java/com/zeapo/pwdstore/GitHandler.java
+++ b/app/src/main/java/com/zeapo/pwdstore/GitHandler.java
@@ -151,6 +151,10 @@ public class GitHandler extends Activity {
case REQUEST_PULL:
authenticateAndRun("pullOperation");
break;
+
+ case REQUEST_PUSH:
+ authenticateAndRun("pushOperation");
+ break;
}
@@ -400,6 +404,13 @@ public class GitHandler extends Activity {
.setCredentialsProvider(provider));
}
+
+ public void pushOperation(UsernamePasswordCredentialsProvider provider) {
+ new GitAsyncTask(activity, true).execute(new Git(PasswordRepository.getRepository(new File("")))
+ .push()
+ .setCredentialsProvider(provider));
+ }
+
/** Finds the method and provides it with authentication paramters via invokeWithAuthentication */
private void authenticateAndRun(String operation) {
try {
diff --git a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java
index 4868c9a5..9d0944e3 100644
--- a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java
+++ b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java
@@ -78,10 +78,12 @@ public class PasswordStore extends Activity implements ToCloneOrNot.OnFragmentI
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
+ Intent intent;
+
switch (id) {
case R.id.user_pref:
try {
- Intent intent = new Intent(this, UserPreference.class);
+ intent = new Intent(this, UserPreference.class);
startActivity(intent);
} catch (Exception e) {
System.out.println("Exception caught :(");
@@ -98,10 +100,14 @@ public class PasswordStore extends Activity implements ToCloneOrNot.OnFragmentI
// break;
case R.id.git_push:
- break;
+ intent = new Intent(this, GitHandler.class);
+ intent.putExtra("Operation", GitHandler.REQUEST_PUSH);
+ startActivity(intent);
+ this.leftActivity = true;
+ return true;
case R.id.git_pull:
- Intent intent = new Intent(this, GitHandler.class);
+ intent = new Intent(this, GitHandler.class);
intent.putExtra("Operation", GitHandler.REQUEST_PULL);
startActivity(intent);
this.leftActivity = true;
@@ -255,7 +261,7 @@ public class PasswordStore extends Activity implements ToCloneOrNot.OnFragmentI
Git git = new Git(PasswordRepository.getRepository(new File("")));
GitAsyncTask tasks = new GitAsyncTask(this, false);
tasks.execute(
- git.add().addFilepattern(data.getExtras().getString("CREATED_FILE")),
+ git.add().addFilepattern("."),
git.commit().setMessage("Added " + data.getExtras().getString("NAME"))
);
break;