From 5283b7682fa21377ec138b4fa95b5992de38192c Mon Sep 17 00:00:00 2001 From: Stefan Niedermann Date: Fri, 23 Oct 2015 00:43:40 +0200 Subject: [PATCH] =?UTF-8?q?#21=20hitting=20the=20back=20arrow=20on=20the?= =?UTF-8?q?=20top=20left=20causes=20a=20strange=20animation=20and=20all=20?= =?UTF-8?q?the=20fields=20to=20be=20deleted=20=E2=80=93>=20highly=20annoyi?= =?UTF-8?q?ng?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../android/activity/SettingsActivity.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/it/niedermann/owncloud/notes/android/activity/SettingsActivity.java b/app/src/main/java/it/niedermann/owncloud/notes/android/activity/SettingsActivity.java index fc2cebfe..e76a04e8 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/android/activity/SettingsActivity.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/android/activity/SettingsActivity.java @@ -37,6 +37,7 @@ public class SettingsActivity extends AppCompatActivity { private EditText field_username = null; private EditText field_password = null; private Button btn_submit = null; + private boolean first_run = false; @Override public void onCreate(Bundle savedInstanceState) { @@ -46,6 +47,11 @@ public class SettingsActivity extends AppCompatActivity { preferences = PreferenceManager .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_username = (EditText) findViewById(R.id.settings_username); field_password = (EditText) findViewById(R.id.settings_password); @@ -94,12 +100,21 @@ public class SettingsActivity extends AppCompatActivity { if (!url.startsWith("http://") && !url.startsWith("https://")) { url = "https://" + url; } - Log.v("Note", "URL: " + url); new LoginValidatorAsyncTask().execute(url, username, password); } }); } + /** + * Prevent pressing back button on first run + */ + @Override + public void onBackPressed() { + if (!first_run) { + super.onBackPressed(); + } + } + /************************************ Async Tasks ************************************/ /**