corrected a small issue with commit and added push to origin

This commit is contained in:
Zeapo 2014-08-09 00:44:45 +01:00
parent 4002791b15
commit bac44808d3
2 changed files with 21 additions and 4 deletions

View file

@ -151,6 +151,10 @@ public class GitHandler extends Activity {
case REQUEST_PULL: case REQUEST_PULL:
authenticateAndRun("pullOperation"); authenticateAndRun("pullOperation");
break; break;
case REQUEST_PUSH:
authenticateAndRun("pushOperation");
break;
} }
@ -400,6 +404,13 @@ public class GitHandler extends Activity {
.setCredentialsProvider(provider)); .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 */ /** Finds the method and provides it with authentication paramters via invokeWithAuthentication */
private void authenticateAndRun(String operation) { private void authenticateAndRun(String operation) {
try { try {

View file

@ -78,10 +78,12 @@ public class PasswordStore extends Activity implements ToCloneOrNot.OnFragmentI
// automatically handle clicks on the Home/Up button, so long // automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml. // as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId(); int id = item.getItemId();
Intent intent;
switch (id) { switch (id) {
case R.id.user_pref: case R.id.user_pref:
try { try {
Intent intent = new Intent(this, UserPreference.class); intent = new Intent(this, UserPreference.class);
startActivity(intent); startActivity(intent);
} catch (Exception e) { } catch (Exception e) {
System.out.println("Exception caught :("); System.out.println("Exception caught :(");
@ -98,10 +100,14 @@ public class PasswordStore extends Activity implements ToCloneOrNot.OnFragmentI
// break; // break;
case R.id.git_push: 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: case R.id.git_pull:
Intent intent = new Intent(this, GitHandler.class); intent = new Intent(this, GitHandler.class);
intent.putExtra("Operation", GitHandler.REQUEST_PULL); intent.putExtra("Operation", GitHandler.REQUEST_PULL);
startActivity(intent); startActivity(intent);
this.leftActivity = true; this.leftActivity = true;
@ -255,7 +261,7 @@ public class PasswordStore extends Activity implements ToCloneOrNot.OnFragmentI
Git git = new Git(PasswordRepository.getRepository(new File(""))); Git git = new Git(PasswordRepository.getRepository(new File("")));
GitAsyncTask tasks = new GitAsyncTask(this, false); GitAsyncTask tasks = new GitAsyncTask(this, false);
tasks.execute( tasks.execute(
git.add().addFilepattern(data.getExtras().getString("CREATED_FILE")), git.add().addFilepattern("."),
git.commit().setMessage("Added " + data.getExtras().getString("NAME")) git.commit().setMessage("Added " + data.getExtras().getString("NAME"))
); );
break; break;