Skip to content

Commit

Permalink
#45 On initial start, deactivate connect button initially
Browse files Browse the repository at this point in the history
  • Loading branch information
stefan-niedermann committed Jan 21, 2016
1 parent f57a877 commit 33e6df4
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
2 changes: 2 additions & 0 deletions app/app.iml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/23.0.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/cardview-v7/23.0.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/design/23.0.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/gridlayout-v7/23.0.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/recyclerview-v7/23.0.1/jars" />
Expand All @@ -91,6 +92,7 @@
<orderEntry type="library" exported="" name="recyclerview-v7-23.0.1" level="project" />
<orderEntry type="library" exported="" name="gridlayout-v7-23.0.1" level="project" />
<orderEntry type="library" exported="" name="bypasses-1.0.1" level="project" />
<orderEntry type="library" exported="" name="cardview-v7-23.0.1" level="project" />
<orderEntry type="library" exported="" name="support-v4-23.0.1" level="project" />
<orderEntry type="library" exported="" name="design-23.0.1" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-23.0.1" level="project" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void beforeTextChanged(CharSequence s, int start, int count, int after) {

@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
String url = ((EditText) findViewById(R.id.settings_url)).getText().toString();
String url = field_url.getText().toString();

if (!url.endsWith("/")) {
url += "/";
Expand All @@ -81,13 +81,32 @@ public void onTextChanged(CharSequence s, int start, int before, int count) {
} else {
findViewById(R.id.settings_url_warn_http).setVisibility(View.GONE);
}

handleSubmitButtonEnabled(field_url.getText(), field_username.getText());
}

@Override
public void afterTextChanged(Editable s) {
}
});

field_username.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {

}

@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
handleSubmitButtonEnabled(field_url.getText(), field_username.getText());
}

@Override
public void afterTextChanged(Editable s) {

}
});

// Load current Preferences
field_url.setText(preferences.getString(SETTINGS_URL, DEFAULT_SETTINGS));
field_username.setText(preferences.getString(SETTINGS_USERNAME, DEFAULT_SETTINGS));
Expand All @@ -101,6 +120,7 @@ public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
}
});

btn_submit.setEnabled(false);
btn_submit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Expand Down Expand Up @@ -133,6 +153,14 @@ private void login() {
new LoginValidatorAsyncTask().execute(url, username, password);
}

private void handleSubmitButtonEnabled(Editable url, Editable username) {
if (field_username.getText().length() > 0 && field_url.getText().length() > 0) {
btn_submit.setEnabled(true);
} else {
btn_submit.setEnabled(false);
}
}

/************************************ Async Tasks ************************************/

/**
Expand Down

0 comments on commit 33e6df4

Please sign in to comment.