From ff3c3f94d1066b568921c8879076b0348d8410e9 Mon Sep 17 00:00:00 2001 From: knuthy Date: Wed, 1 Oct 2014 11:47:23 +0200 Subject: improves the clone screen --- app/app-debug.apk | Bin 1722187 -> 1722591 bytes app/app-release.apk | Bin 1722048 -> 1722615 bytes .../main/java/com/zeapo/pwdstore/GitHandler.java | 50 ++++++++++++++++---- app/src/main/res/layout/activity_git_clone.xml | 51 +++++++++++---------- 4 files changed, 68 insertions(+), 33 deletions(-) (limited to 'app') diff --git a/app/app-debug.apk b/app/app-debug.apk index bfc43cd3..f861a20a 100644 Binary files a/app/app-debug.apk and b/app/app-debug.apk differ diff --git a/app/app-release.apk b/app/app-release.apk index 8bc3a101..8d12a019 100644 Binary files a/app/app-release.apk and b/app/app-release.apk differ diff --git a/app/src/main/java/com/zeapo/pwdstore/GitHandler.java b/app/src/main/java/com/zeapo/pwdstore/GitHandler.java index c487ce0f..e0fa9755 100644 --- a/app/src/main/java/com/zeapo/pwdstore/GitHandler.java +++ b/app/src/main/java/com/zeapo/pwdstore/GitHandler.java @@ -9,6 +9,7 @@ import android.content.SharedPreferences; import android.os.Bundle; import android.preference.PreferenceManager; import android.text.InputType; +import android.view.KeyEvent; import android.view.Menu; import android.view.MenuItem; import android.view.View; @@ -32,6 +33,7 @@ import org.apache.commons.io.FileUtils; import org.eclipse.jgit.api.GitCommand; import org.eclipse.jgit.api.PullCommand; import org.eclipse.jgit.api.PushCommand; +import org.eclipse.jgit.diff.Edit; import org.eclipse.jgit.errors.UnsupportedCredentialItem; import org.eclipse.jgit.transport.CredentialItem; import org.eclipse.jgit.transport.CredentialsProvider; @@ -80,7 +82,7 @@ public class GitHandler extends Activity { settings = PreferenceManager.getDefaultSharedPreferences(this.context); protocol = settings.getString("git_remote_protocol", "ssh://"); - connectionMode = settings.getString("git_remote_auth", "username/password"); + connectionMode = settings.getString("git_remote_auth", "ssh-key"); switch (getIntent().getExtras().getInt("Operation")) { case REQUEST_CLONE: @@ -139,6 +141,30 @@ public class GitHandler extends Activity { } }); + + // init the server information + EditText server_url = ((EditText) findViewById(R.id.server_url)); + EditText server_port = ((EditText) findViewById(R.id.server_port)); + EditText server_path = ((EditText) findViewById(R.id.server_path)); + EditText server_user = ((EditText) findViewById(R.id.server_user)); + + View.OnKeyListener updateListener = new View.OnKeyListener() { + @Override + public boolean onKey(View view, int i, KeyEvent keyEvent) { + updateURI(); + return false; + } + }; + + server_url.setText(settings.getString("git_remote_server", "")); + server_port.setText("" + settings.getInt("git_remote_server_port", 22)); + server_user.setText(settings.getString("git_remote_username", "")); + server_path.setText(settings.getString("git_remote_location", "")); + + server_url.setOnKeyListener(updateListener); + server_port.setOnKeyListener(updateListener); + server_user.setOnKeyListener(updateListener); + server_path.setOnKeyListener(updateListener); break; case REQUEST_PULL: authenticateAndRun("pullOperation"); @@ -152,23 +178,31 @@ public class GitHandler extends Activity { } - @Override - public void onResume() { - super.onResume(); - + public void updateURI() { EditText uri = (EditText) findViewById(R.id.clone_uri); + EditText server_url = ((EditText) findViewById(R.id.server_url)); + EditText server_port = ((EditText) findViewById(R.id.server_port)); + EditText server_path = ((EditText) findViewById(R.id.server_path)); + EditText server_user = ((EditText) findViewById(R.id.server_user)); + if (uri != null) { String hostname = - settings.getString("git_remote_username", "") + server_user.getText() + "@" + - settings.getString("git_remote_server", "").trim() + server_url.getText().toString().trim() + ":" + - settings.getString("git_remote_location", ""); + server_path.getText(); if (!hostname.equals("@:")) uri.setText(hostname); } } + @Override + public void onResume() { + super.onResume(); + updateURI(); + } + @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. diff --git a/app/src/main/res/layout/activity_git_clone.xml b/app/src/main/res/layout/activity_git_clone.xml index 7aa9eea9..721980cb 100644 --- a/app/src/main/res/layout/activity_git_clone.xml +++ b/app/src/main/res/layout/activity_git_clone.xml @@ -44,6 +44,31 @@ android:layout_toRightOf="@+id/label_server_protocol" /> + + + + + + - - - - - -