diff --git a/mifosng-android/src/main/java/com/mifos/mifosxdroid/LoginActivity.java b/mifosng-android/src/main/java/com/mifos/mifosxdroid/LoginActivity.java index e1dc7a76eee..d0d850cb72d 100644 --- a/mifosng-android/src/main/java/com/mifos/mifosxdroid/LoginActivity.java +++ b/mifosng-android/src/main/java/com/mifos/mifosxdroid/LoginActivity.java @@ -62,6 +62,7 @@ public class LoginActivity extends ActionBarActivity implements Callback{ @InjectView(R.id.bt_login) Button bt_login; @InjectView(R.id.tv_constructed_instance_url) TextView tv_constructed_instance_url; @InjectView(R.id.et_tenantIdentifier) EditText et_tenantIdentifier; + @InjectView(R.id.et_instancePort) EditText et_port; private String username; private String instanceURL; private String password; @@ -73,8 +74,7 @@ public class LoginActivity extends ActionBarActivity implements Callback{ private Matcher domainNameMatcher; private Pattern ipAddressPattern; private Matcher ipAddressMatcher; - private String tenantIdentifier; - + private int port = 80; @Override public void onCreate(Bundle savedInstanceState) { @@ -87,8 +87,6 @@ public void onCreate(Bundle savedInstanceState) { String previouslyEnteredUrl = sharedPreferences.getString(Constants.INSTANCE_URL_KEY, getString(R.string.default_instance_url)); - tenantIdentifier = sharedPreferences.getString(Constants.TENANT_IDENTIFIER_KEY, - "default"); authenticationToken = sharedPreferences.getString(User.AUTHENTICATION_KEY, "NA"); ButterKnife.inject(this); @@ -125,7 +123,15 @@ public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) { @Override public void afterTextChanged(Editable editable) { - String textUnderConstruction = constructInstanceUrl(editable.toString()); + String textUnderConstruction; + + if(!et_port.getEditableText().toString().isEmpty()) { + port = Integer.valueOf(et_port.getEditableText().toString().trim()); + textUnderConstruction = constructInstanceUrlWithPort(editable.toString(), port); + } else { + textUnderConstruction = constructInstanceUrl(editable.toString()); + } + tv_constructed_instance_url.setText(textUnderConstruction); if(!validateURL(editable.toString())) { @@ -182,6 +188,7 @@ public boolean validateUserInputs() throws ShortOfLengthException { if (!et_tenantIdentifier.getEditableText().toString().isEmpty()) { API.setTenantIdentifier(et_tenantIdentifier.getEditableText().toString().trim()); } + return true; } @@ -189,6 +196,10 @@ public String constructInstanceUrl(String validDomain) { return PROTOCOL_HTTPS + validDomain + API_PATH; } + public String constructInstanceUrlWithPort(String validDomain, int port) { + return PROTOCOL_HTTPS + validDomain + ":" + port + API_PATH; + } + @Override public void success(User user, Response response) { progressDialog.dismiss();