From 7ad91f5356a729e1ff013cb651bc8cfc6fca1412 Mon Sep 17 00:00:00 2001 From: knuthy Date: Thu, 2 Oct 2014 09:20:23 +0200 Subject: [PATCH] support non-physical keyboard for clone --- .../java/com/zeapo/pwdstore/GitHandler.java | 90 ++++- app/src/main/res/drawable/bottom_line.xml | 2 +- .../main/res/layout/activity_git_clone.xml | 328 +++++++++--------- 3 files changed, 241 insertions(+), 179 deletions(-) diff --git a/app/src/main/java/com/zeapo/pwdstore/GitHandler.java b/app/src/main/java/com/zeapo/pwdstore/GitHandler.java index 651b23d7..43bcfca8 100644 --- a/app/src/main/java/com/zeapo/pwdstore/GitHandler.java +++ b/app/src/main/java/com/zeapo/pwdstore/GitHandler.java @@ -8,7 +8,9 @@ import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; import android.preference.PreferenceManager; +import android.text.Editable; import android.text.InputType; +import android.text.TextWatcher; import android.util.Log; import android.view.KeyEvent; import android.view.Menu; @@ -149,17 +151,16 @@ 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)); + final EditText server_url = ((EditText) findViewById(R.id.server_url)); + final EditText server_port = ((EditText) findViewById(R.id.server_port)); + final EditText server_path = ((EditText) findViewById(R.id.server_path)); + final EditText server_user = ((EditText) findViewById(R.id.server_user)); final EditText server_uri = ((EditText)findViewById(R.id.clone_uri)); - View.OnKeyListener updateListener = new View.OnKeyListener() { + View.OnFocusChangeListener updateListener = new View.OnFocusChangeListener() { @Override - public boolean onKey(View view, int i, KeyEvent keyEvent) { + public void onFocusChange(View view, boolean b) { updateURI(); - return false; } }; @@ -168,16 +169,72 @@ public class GitHandler extends Activity { 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); - - server_uri.setOnKeyListener(new View.OnKeyListener() { + server_url.addTextChangedListener(new TextWatcher() { @Override - public boolean onKey(View view, int i, KeyEvent keyEvent) { - splitURI(); - return false; + public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) { } + + @Override + public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) { + if (server_url.isFocused()) + updateURI(); + } + + @Override + public void afterTextChanged(Editable editable) { } + }); + server_port.addTextChangedListener(new TextWatcher() { + @Override + public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) { } + + @Override + public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) { + if (server_port.isFocused()) + updateURI(); + } + + @Override + public void afterTextChanged(Editable editable) { } + }); + server_user.addTextChangedListener(new TextWatcher() { + @Override + public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) { } + + @Override + public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) { + if (server_user.isFocused()) + updateURI(); + } + + @Override + public void afterTextChanged(Editable editable) { } + }); + server_path.addTextChangedListener(new TextWatcher() { + @Override + public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) { } + + @Override + public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) { + if (server_path.isFocused()) + updateURI(); + } + + @Override + public void afterTextChanged(Editable editable) { } + }); + + server_uri.addTextChangedListener(new TextWatcher() { + @Override + public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) { + } + + @Override + public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) { + if (server_uri.isFocused()) + splitURI(); + } + + @Override + public void afterTextChanged(Editable editable) { } }); @@ -201,6 +258,7 @@ public class GitHandler extends Activity { 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)); + Log.i("GIT", "key entred"); if (uri != null) { String hostname = diff --git a/app/src/main/res/drawable/bottom_line.xml b/app/src/main/res/drawable/bottom_line.xml index c24a04df..fab0b04f 100644 --- a/app/src/main/res/drawable/bottom_line.xml +++ b/app/src/main/res/drawable/bottom_line.xml @@ -8,7 +8,7 @@ - + diff --git a/app/src/main/res/layout/activity_git_clone.xml b/app/src/main/res/layout/activity_git_clone.xml index a173f6f6..f1adcd6d 100644 --- a/app/src/main/res/layout/activity_git_clone.xml +++ b/app/src/main/res/layout/activity_git_clone.xml @@ -1,4 +1,4 @@ - - - - - + - + android:layout_height="match_parent" + android:orientation="vertical"> + android:text="@string/server_name" + android:textStyle="bold" + style="@android:style/TextAppearance.Large" + android:gravity="left" + android:paddingBottom="6dp" + android:textColor="@android:color/holo_orange_dark" + android:background="@drawable/bottom_line"/> - - + android:orientation="horizontal" + android:layout_gravity="center_vertical"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + android:text="@string/server_resulting_url" + android:textStyle="bold" + style="@android:style/TextAppearance.Large" + android:gravity="left" + android:paddingBottom="6dp" + android:textColor="@android:color/holo_orange_dark" + android:background="@drawable/bottom_line"/> - - + android:inputType="textWebEmailAddress"/> - - + android:background="@drawable/red_rectangle" + android:textColor="@android:color/white" + android:visibility="gone" + android:id="@+id/warn_url"/> - - - - - - - - - - - + android:orientation="horizontal" + android:layout_gravity="center_vertical"> - + - + + - - - - - - - - - + android:onClick="cloneRepository"/> + -