Improve the ComputerCreationActivity.

* Allow using IP address as a name.
* Provide proper keyboards for typing name and address.

Change-Id: I86ca58282c81eb0705d6bc82b98b2aab94fbf676
This commit is contained in:
Artur Dryomov 2013-07-21 03:37:09 +03:00 committed by Michael Meeks
parent ac546de39e
commit 001552cc8a
4 changed files with 15 additions and 12 deletions

View File

@ -8,7 +8,7 @@
<EditText
android:id="@+id/edit_ip_address"
android:singleLine="true"
android:inputType="text"
android:inputType="phone"
android:hint="@string/hint_ip_address"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
@ -16,10 +16,18 @@
<EditText
android:id="@+id/edit_name"
android:singleLine="true"
android:inputType="text"
android:inputType="text|textCapSentences"
android:hint="@string/hint_name"
android:paddingTop="@dimen/padding_vertical_edit"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView
style="?textAppearanceSmall"
android:text="@string/message_name_notice"
android:gravity="center_horizontal"
android:paddingTop="@dimen/padding_vertical_notice"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>

View File

@ -15,6 +15,7 @@
<dimen name="padding_vertical_pin">10dp</dimen>
<dimen name="padding_vertical_error_message">10dp</dimen>
<dimen name="padding_vertical_edit">8dp</dimen>
<dimen name="padding_vertical_notice">16dp</dimen>
<dimen name="margin_vertical_action_bar_divider">12dp</dimen>
<dimen name="margin_slide">8dp</dimen>

View File

@ -27,7 +27,7 @@
<string name="message_impress_wifi_enabling">You should enable experimental features at “Tools → Options → LibreOffice → Advanced” as well.</string>
<string name="message_impress_pairing_check">If you have Bluetooth pairing issues check instructions related to your desktop OS.</string>
<string name="message_ip_address_validation">You should type a valid IP address.</string>
<string name="message_name_validation">Name should not be empty.</string>
<string name="message_name_notice">Name is optional — IP address would be used instead if you wish.</string>
<string name="hint_ip_address">IP address</string>
<string name="hint_name">Name</string>

View File

@ -68,11 +68,9 @@ public class ComputerCreationActivity extends SherlockFragmentActivity implement
public void onClick(View aView) {
if (aView.equals(getCancelButton())) {
cancelCreation();
return;
}
if (aView.equals(getSaveButton())) {
saveServer();
}
@ -88,13 +86,13 @@ public class ComputerCreationActivity extends SherlockFragmentActivity implement
if (!isIpAddressValid(aIpAddress)) {
getIpAddressEdit().setError(getText(R.string.message_ip_address_validation));
return;
}
if (TextUtils.isEmpty(aName)) {
getNameEdit().setError(getText(R.string.message_name_validation));
finish(aIpAddress, aIpAddress);
}
if (isServerInformationValid(aIpAddress, aName)) {
else {
finish(aIpAddress, aName);
}
}
@ -111,10 +109,6 @@ public class ComputerCreationActivity extends SherlockFragmentActivity implement
return (EditText) findViewById(R.id.edit_name);
}
private boolean isServerInformationValid(String aIpAddress, String aName) {
return isIpAddressValid(aIpAddress) && !TextUtils.isEmpty(aName);
}
private boolean isIpAddressValid(String aIpAddress) {
return Patterns.IP_ADDRESS.matcher(aIpAddress).matches();
}