From 001552cc8a01ddc724856a905017937e735eee73 Mon Sep 17 00:00:00 2001 From: Artur Dryomov Date: Sun, 21 Jul 2013 03:37:09 +0300 Subject: [PATCH] Improve the ComputerCreationActivity. * Allow using IP address as a name. * Provide proper keyboards for typing name and address. Change-Id: I86ca58282c81eb0705d6bc82b98b2aab94fbf676 --- .../res/layout/activity_computer_creation.xml | 12 ++++++++++-- android/sdremote/res/values/dimens.xml | 1 + android/sdremote/res/values/strings.xml | 2 +- .../activity/ComputerCreationActivity.java | 12 +++--------- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/android/sdremote/res/layout/activity_computer_creation.xml b/android/sdremote/res/layout/activity_computer_creation.xml index be1f31395436..4ef3f86a269f 100644 --- a/android/sdremote/res/layout/activity_computer_creation.xml +++ b/android/sdremote/res/layout/activity_computer_creation.xml @@ -8,7 +8,7 @@ @@ -16,10 +16,18 @@ + + \ No newline at end of file diff --git a/android/sdremote/res/values/dimens.xml b/android/sdremote/res/values/dimens.xml index b73555f52401..d4c2e5b07b04 100644 --- a/android/sdremote/res/values/dimens.xml +++ b/android/sdremote/res/values/dimens.xml @@ -15,6 +15,7 @@ 10dp 10dp 8dp + 16dp 12dp 8dp diff --git a/android/sdremote/res/values/strings.xml b/android/sdremote/res/values/strings.xml index 38252bb9a05c..072c406ea223 100644 --- a/android/sdremote/res/values/strings.xml +++ b/android/sdremote/res/values/strings.xml @@ -27,7 +27,7 @@ You should enable experimental features at “Tools → Options → LibreOffice → Advanced” as well. If you have Bluetooth pairing issues check instructions related to your desktop OS. You should type a valid IP address. - Name should not be empty. + Name is optional — IP address would be used instead if you wish. IP address Name diff --git a/android/sdremote/src/org/libreoffice/impressremote/activity/ComputerCreationActivity.java b/android/sdremote/src/org/libreoffice/impressremote/activity/ComputerCreationActivity.java index 76f33c6e4ccb..372e49bdb947 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/activity/ComputerCreationActivity.java +++ b/android/sdremote/src/org/libreoffice/impressremote/activity/ComputerCreationActivity.java @@ -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(); }