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:
committed by
Michael Meeks
parent
ac546de39e
commit
001552cc8a
@@ -8,7 +8,7 @@
|
|||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/edit_ip_address"
|
android:id="@+id/edit_ip_address"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:inputType="text"
|
android:inputType="phone"
|
||||||
android:hint="@string/hint_ip_address"
|
android:hint="@string/hint_ip_address"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"/>
|
android:layout_height="wrap_content"/>
|
||||||
@@ -16,10 +16,18 @@
|
|||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/edit_name"
|
android:id="@+id/edit_name"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:inputType="text"
|
android:inputType="text|textCapSentences"
|
||||||
android:hint="@string/hint_name"
|
android:hint="@string/hint_name"
|
||||||
android:paddingTop="@dimen/padding_vertical_edit"
|
android:paddingTop="@dimen/padding_vertical_edit"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"/>
|
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>
|
</LinearLayout>
|
@@ -15,6 +15,7 @@
|
|||||||
<dimen name="padding_vertical_pin">10dp</dimen>
|
<dimen name="padding_vertical_pin">10dp</dimen>
|
||||||
<dimen name="padding_vertical_error_message">10dp</dimen>
|
<dimen name="padding_vertical_error_message">10dp</dimen>
|
||||||
<dimen name="padding_vertical_edit">8dp</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_vertical_action_bar_divider">12dp</dimen>
|
||||||
<dimen name="margin_slide">8dp</dimen>
|
<dimen name="margin_slide">8dp</dimen>
|
||||||
|
@@ -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_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_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_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_ip_address">IP address</string>
|
||||||
<string name="hint_name">Name</string>
|
<string name="hint_name">Name</string>
|
||||||
|
@@ -68,11 +68,9 @@ public class ComputerCreationActivity extends SherlockFragmentActivity implement
|
|||||||
public void onClick(View aView) {
|
public void onClick(View aView) {
|
||||||
if (aView.equals(getCancelButton())) {
|
if (aView.equals(getCancelButton())) {
|
||||||
cancelCreation();
|
cancelCreation();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (aView.equals(getSaveButton())) {
|
if (aView.equals(getSaveButton())) {
|
||||||
saveServer();
|
saveServer();
|
||||||
}
|
}
|
||||||
@@ -88,13 +86,13 @@ public class ComputerCreationActivity extends SherlockFragmentActivity implement
|
|||||||
|
|
||||||
if (!isIpAddressValid(aIpAddress)) {
|
if (!isIpAddressValid(aIpAddress)) {
|
||||||
getIpAddressEdit().setError(getText(R.string.message_ip_address_validation));
|
getIpAddressEdit().setError(getText(R.string.message_ip_address_validation));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TextUtils.isEmpty(aName)) {
|
if (TextUtils.isEmpty(aName)) {
|
||||||
getNameEdit().setError(getText(R.string.message_name_validation));
|
finish(aIpAddress, aIpAddress);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
if (isServerInformationValid(aIpAddress, aName)) {
|
|
||||||
finish(aIpAddress, aName);
|
finish(aIpAddress, aName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -111,10 +109,6 @@ public class ComputerCreationActivity extends SherlockFragmentActivity implement
|
|||||||
return (EditText) findViewById(R.id.edit_name);
|
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) {
|
private boolean isIpAddressValid(String aIpAddress) {
|
||||||
return Patterns.IP_ADDRESS.matcher(aIpAddress).matches();
|
return Patterns.IP_ADDRESS.matcher(aIpAddress).matches();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user