diff options
Diffstat (limited to 'app/src')
-rw-r--r-- | app/src/main/java/com/zeapo/pwdstore/GitHandler.java | 50 | ||||
-rw-r--r-- | app/src/main/res/layout/activity_git_clone.xml | 51 |
2 files changed, 68 insertions, 33 deletions
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,24 +178,32 @@ 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. getMenuInflater().inflate(R.menu.git_clone, menu); 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 @@ -53,6 +53,31 @@ <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" + android:text="@string/server_user" + android:id="@+id/label_server_user" + android:layout_centerVertical="true" + android:layout_alignParentLeft="true" + android:layout_alignParentStart="true" /> + + <EditText + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:hint="@string/server_user_hint" + android:id="@+id/server_user" + android:layout_toEndOf="@+id/label_server_user" + android:layout_toRightOf="@+id/label_server_user" + android:layout_alignParentRight="true" + android:layout_alignParentEnd="true"/> + </RelativeLayout> + <RelativeLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="horizontal" + android:layout_gravity="center_vertical"> + + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" android:text="@string/server_url" android:id="@+id/label_server_url" android:layout_centerVertical="true" @@ -105,36 +130,12 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="@string/server_path_hint" + android:id="@+id/server_path" android:layout_toEndOf="@+id/label_server_path" android:layout_toRightOf="@+id/label_server_path" android:layout_alignParentRight="true" android:layout_alignParentEnd="true"/> </RelativeLayout> - <RelativeLayout - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:orientation="horizontal" - android:layout_gravity="center_vertical"> - - <TextView - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="@string/server_user" - android:id="@+id/label_server_user" - android:layout_centerVertical="true" - android:layout_alignParentLeft="true" - android:layout_alignParentStart="true" /> - - <EditText - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:hint="@string/server_user_hint" - android:id="@+id/editText" - android:layout_toEndOf="@+id/label_server_user" - android:layout_toRightOf="@+id/label_server_user" - android:layout_alignParentRight="true" - android:layout_alignParentEnd="true"/> - </RelativeLayout> <TextView |