#21 hitting the back arrow on the top left causes a strange animation and all the fields to be deleted –> highly annoying

This commit is contained in:
Stefan Niedermann 2015-10-23 00:43:40 +02:00
parent 990d8f682c
commit 5283b7682f

View file

@ -37,6 +37,7 @@ public class SettingsActivity extends AppCompatActivity {
private EditText field_username = null; private EditText field_username = null;
private EditText field_password = null; private EditText field_password = null;
private Button btn_submit = null; private Button btn_submit = null;
private boolean first_run = false;
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
@ -46,6 +47,11 @@ public class SettingsActivity extends AppCompatActivity {
preferences = PreferenceManager preferences = PreferenceManager
.getDefaultSharedPreferences(getApplicationContext()); .getDefaultSharedPreferences(getApplicationContext());
if (preferences.getBoolean(SettingsActivity.SETTINGS_FIRST_RUN, true)) {
first_run = true;
getSupportActionBar().setDisplayHomeAsUpEnabled(false);
}
field_url = (EditText) findViewById(R.id.settings_url); field_url = (EditText) findViewById(R.id.settings_url);
field_username = (EditText) findViewById(R.id.settings_username); field_username = (EditText) findViewById(R.id.settings_username);
field_password = (EditText) findViewById(R.id.settings_password); field_password = (EditText) findViewById(R.id.settings_password);
@ -94,12 +100,21 @@ public class SettingsActivity extends AppCompatActivity {
if (!url.startsWith("http://") && !url.startsWith("https://")) { if (!url.startsWith("http://") && !url.startsWith("https://")) {
url = "https://" + url; url = "https://" + url;
} }
Log.v("Note", "URL: " + url);
new LoginValidatorAsyncTask().execute(url, username, password); new LoginValidatorAsyncTask().execute(url, username, password);
} }
}); });
} }
/**
* Prevent pressing back button on first run
*/
@Override
public void onBackPressed() {
if (!first_run) {
super.onBackPressed();
}
}
/************************************ Async Tasks ************************************/ /************************************ Async Tasks ************************************/
/** /**