From 3bd3f170f775e9034a1747dd9e9d63482b8c4f34 Mon Sep 17 00:00:00 2001 From: misaochan Date: Sat, 13 Aug 2016 16:59:03 +1200 Subject: [PATCH] Change first run method --- .../free/nrw/commons/auth/LoginActivity.java | 27 +++++++++++-------- .../free/nrw/commons/auth/SignupActivity.java | 2 -- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/fr/free/nrw/commons/auth/LoginActivity.java b/app/src/main/java/fr/free/nrw/commons/auth/LoginActivity.java index 633f05510..51d7c9e24 100644 --- a/app/src/main/java/fr/free/nrw/commons/auth/LoginActivity.java +++ b/app/src/main/java/fr/free/nrw/commons/auth/LoginActivity.java @@ -8,6 +8,7 @@ import android.app.Activity; import android.app.ProgressDialog; import android.content.ContentResolver; import android.content.Intent; +import android.content.SharedPreferences; import android.net.Uri; import android.os.AsyncTask; import android.os.Bundle; @@ -42,6 +43,8 @@ public class LoginActivity extends AccountAuthenticatorActivity { private CommonsApplication app; + private SharedPreferences prefs = null; + Button loginButton; Button signupButton; EditText usernameEdit; @@ -151,6 +154,8 @@ public class LoginActivity extends AccountAuthenticatorActivity { passwordEdit = (EditText) findViewById(R.id.loginPassword); final LoginActivity that = this; + prefs = getSharedPreferences("fr.free.nrw.commons", MODE_PRIVATE); + TextWatcher loginEnabler = new TextWatcher() { public void beforeTextChanged(CharSequence charSequence, int start, int count, int after) { } @@ -188,17 +193,17 @@ public class LoginActivity extends AccountAuthenticatorActivity { } }); - if (savedInstanceState == null) { - Bundle extras = getIntent().getExtras(); - // Only load welcome screen if we weren't redirected from SignupActivity - // FIXME: This Bundle seems to clash with the Bundle at line 81. Logging in brings user to signup screen - why???? - if (extras == null || !extras.getBoolean("Redirected")) { - if (extras != null) { - Log.d("SignupActivity", "Redirected? " + Boolean.toString(extras.getBoolean("Redirected"))); - } - Intent welcomeIntent = new Intent(this, WelcomeActivity.class); - startActivity(welcomeIntent); - } + } + + @Override + protected void onResume() { + super.onResume(); + + if (prefs.getBoolean("firstrun", true)) { + // Do first run stuff here then set 'firstrun' as false + Intent welcomeIntent = new Intent(this, WelcomeActivity.class); + startActivity(welcomeIntent); + prefs.edit().putBoolean("firstrun", false).apply(); } } diff --git a/app/src/main/java/fr/free/nrw/commons/auth/SignupActivity.java b/app/src/main/java/fr/free/nrw/commons/auth/SignupActivity.java index 4d5fe939a..497a8c40b 100644 --- a/app/src/main/java/fr/free/nrw/commons/auth/SignupActivity.java +++ b/app/src/main/java/fr/free/nrw/commons/auth/SignupActivity.java @@ -54,7 +54,6 @@ public class SignupActivity extends Activity { toast.show(); Intent intent = new Intent(getApplicationContext(), LoginActivity.class); - intent.putExtra("Redirected", true); startActivity(intent); return true; } else { @@ -76,7 +75,6 @@ public class SignupActivity extends Activity { else { //If we are in signup page, back button should take us back to LoginActivity Intent intent = new Intent(getApplicationContext(), LoginActivity.class); - intent.putExtra("Redirected", true); startActivity(intent); } }