support non-physical keyboard for clone

This commit is contained in:
knuthy
2014-10-02 09:20:23 +02:00
parent c11e6eab84
commit 7ad91f5356
3 changed files with 241 additions and 179 deletions

View File

@@ -8,7 +8,9 @@ import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.text.Editable;
import android.text.InputType; import android.text.InputType;
import android.text.TextWatcher;
import android.util.Log; import android.util.Log;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.Menu; import android.view.Menu;
@@ -149,17 +151,16 @@ public class GitHandler extends Activity {
}); });
// init the server information // init the server information
EditText server_url = ((EditText) findViewById(R.id.server_url)); final EditText server_url = ((EditText) findViewById(R.id.server_url));
EditText server_port = ((EditText) findViewById(R.id.server_port)); final EditText server_port = ((EditText) findViewById(R.id.server_port));
EditText server_path = ((EditText) findViewById(R.id.server_path)); final EditText server_path = ((EditText) findViewById(R.id.server_path));
EditText server_user = ((EditText) findViewById(R.id.server_user)); final EditText server_user = ((EditText) findViewById(R.id.server_user));
final EditText server_uri = ((EditText)findViewById(R.id.clone_uri)); final EditText server_uri = ((EditText)findViewById(R.id.clone_uri));
View.OnKeyListener updateListener = new View.OnKeyListener() { View.OnFocusChangeListener updateListener = new View.OnFocusChangeListener() {
@Override @Override
public boolean onKey(View view, int i, KeyEvent keyEvent) { public void onFocusChange(View view, boolean b) {
updateURI(); updateURI();
return false;
} }
}; };
@@ -168,16 +169,72 @@ public class GitHandler extends Activity {
server_user.setText(settings.getString("git_remote_username", "")); server_user.setText(settings.getString("git_remote_username", ""));
server_path.setText(settings.getString("git_remote_location", "")); server_path.setText(settings.getString("git_remote_location", ""));
server_url.setOnKeyListener(updateListener); server_url.addTextChangedListener(new TextWatcher() {
server_port.setOnKeyListener(updateListener);
server_user.setOnKeyListener(updateListener);
server_path.setOnKeyListener(updateListener);
server_uri.setOnKeyListener(new View.OnKeyListener() {
@Override @Override
public boolean onKey(View view, int i, KeyEvent keyEvent) { public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) { }
splitURI();
return false; @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_port = ((EditText) findViewById(R.id.server_port));
EditText server_path = ((EditText) findViewById(R.id.server_path)); EditText server_path = ((EditText) findViewById(R.id.server_path));
EditText server_user = ((EditText) findViewById(R.id.server_user)); EditText server_user = ((EditText) findViewById(R.id.server_user));
Log.i("GIT", "key entred");
if (uri != null) { if (uri != null) {
String hostname = String hostname =

View File

@@ -8,7 +8,7 @@
<item android:bottom="2dp"> <item android:bottom="2dp">
<shape android:shape="rectangle"> <shape android:shape="rectangle">
<solid android:color="#FFFFFF" /> <solid android:color="@android:color/white" />
</shape> </shape>
</item> </item>
</layer-list> </layer-list>

View File

@@ -1,4 +1,4 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
@@ -7,193 +7,197 @@
android:paddingTop="@dimen/activity_vertical_margin" android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" android:paddingBottom="@dimen/activity_vertical_margin"
tools:context="com.zeapo.pwdstore.GitHandler" tools:context="com.zeapo.pwdstore.GitHandler"
android:orientation="vertical"> android:background="@android:color/white">
<LinearLayout
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
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"/>
<RelativeLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:orientation="horizontal" android:orientation="vertical">
android:layout_gravity="center_vertical">
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/server_protocol" android:text="@string/server_name"
android:id="@+id/label_server_protocol" android:textStyle="bold"
android:layout_centerVertical="true" style="@android:style/TextAppearance.Large"
android:layout_alignParentLeft="true" android:gravity="left"
android:layout_alignParentStart="true" /> android:paddingBottom="6dp"
android:textColor="@android:color/holo_orange_dark"
android:background="@drawable/bottom_line"/>
<Spinner <RelativeLayout
android:id="@+id/clone_protocol"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_toEndOf="@+id/label_server_protocol" android:orientation="horizontal"
android:layout_toRightOf="@+id/label_server_protocol" /> android:layout_gravity="center_vertical">
</RelativeLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/server_protocol"
android:id="@+id/label_server_protocol"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<Spinner
android:id="@+id/clone_protocol"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toEndOf="@+id/label_server_protocol"
android:layout_toRightOf="@+id/label_server_protocol" />
</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/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"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/server_url_hint"
android:id="@+id/server_url"
android:layout_toEndOf="@+id/label_server_url"
android:layout_toRightOf="@+id/label_server_url"
android:layout_toLeftOf="@+id/label_server_port"
android:layout_toStartOf="@+id/label_server_port" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=":"
android:id="@+id/label_server_port"
android:layout_centerVertical="true"
android:layout_toLeftOf="@+id/server_port"
android:layout_toStartOf="@+id/server_port" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="@string/server_port_hint"
android:id="@+id/server_port"
android:layout_alignParentRight="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_path"
android:id="@+id/label_server_path"
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_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 <TextView
android:layout_width="wrap_content" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/server_user" android:text="@string/server_resulting_url"
android:id="@+id/label_server_user" android:textStyle="bold"
android:layout_centerVertical="true" style="@android:style/TextAppearance.Large"
android:layout_alignParentLeft="true" android:gravity="left"
android:layout_alignParentStart="true" /> android:paddingBottom="6dp"
android:textColor="@android:color/holo_orange_dark"
android:background="@drawable/bottom_line"/>
<EditText <EditText
android:hint="Repository URI"
android:id="@+id/clone_uri"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:hint="@string/server_user_hint" android:inputType="textWebEmailAddress"/>
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 <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"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<EditText
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:hint="@string/server_url_hint" android:background="@drawable/red_rectangle"
android:id="@+id/server_url" android:textColor="@android:color/white"
android:layout_toEndOf="@+id/label_server_url" android:visibility="gone"
android:layout_toRightOf="@+id/label_server_url" android:id="@+id/warn_url"/>
android:layout_toLeftOf="@+id/label_server_port"
android:layout_toStartOf="@+id/label_server_port" />
<TextView <RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=":"
android:id="@+id/label_server_port"
android:layout_centerVertical="true"
android:layout_toLeftOf="@+id/server_port"
android:layout_toStartOf="@+id/server_port" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="@string/server_port_hint"
android:id="@+id/server_port"
android:layout_alignParentRight="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_path"
android:id="@+id/label_server_path"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<EditText
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:hint="@string/server_path_hint" android:orientation="horizontal"
android:id="@+id/server_path" android:layout_gravity="center_vertical">
android:layout_toEndOf="@+id/label_server_path"
android:layout_toRightOf="@+id/label_server_path"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"/>
</RelativeLayout>
<TextView <TextView
android:layout_width="fill_parent" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/server_resulting_url" android:text="@string/connection_mode"
android:textStyle="bold" android:id="@+id/label_connection_mode"
style="@android:style/TextAppearance.Large" android:layout_centerVertical="true"
android:gravity="left" android:layout_alignParentLeft="true"
android:paddingBottom="6dp" android:layout_alignParentStart="true" />
android:textColor="@android:color/holo_orange_dark"
android:background="@drawable/bottom_line"/>
<EditText <Spinner
android:hint="Repository URI" android:layout_width="match_parent"
android:id="@+id/clone_uri" android:layout_height="wrap_content"
android:layout_width="match_parent" android:id="@+id/connection_mode"
android:layout_height="wrap_content" android:layout_toEndOf="@+id/label_connection_mode"
android:inputType="textWebEmailAddress"/> android:layout_toRightOf="@+id/label_connection_mode" />
</RelativeLayout>
<TextView <Button
android:layout_width="match_parent" android:id="@+id/clone_button"
android:layout_height="wrap_content" android:text="Clone!"
android:background="@drawable/red_rectangle"
android:textColor="@android:color/white"
android:visibility="gone"
android:id="@+id/warn_url"/>
<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/connection_mode"
android:id="@+id/label_connection_mode"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<Spinner
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:id="@+id/connection_mode" android:onClick="cloneRepository"/>
android:layout_toEndOf="@+id/label_connection_mode" </LinearLayout>
android:layout_toRightOf="@+id/label_connection_mode" />
</RelativeLayout>
<Button </ScrollView>
android:id="@+id/clone_button"
android:text="Clone!"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="cloneRepository"/>
</LinearLayout>