Change first run method

This commit is contained in:
misaochan 2016-08-13 16:59:03 +12:00
parent ab78d43b79
commit 3bd3f170f7
2 changed files with 16 additions and 13 deletions

View file

@ -8,6 +8,7 @@ import android.app.Activity;
import android.app.ProgressDialog; import android.app.ProgressDialog;
import android.content.ContentResolver; import android.content.ContentResolver;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri; import android.net.Uri;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Bundle; import android.os.Bundle;
@ -42,6 +43,8 @@ public class LoginActivity extends AccountAuthenticatorActivity {
private CommonsApplication app; private CommonsApplication app;
private SharedPreferences prefs = null;
Button loginButton; Button loginButton;
Button signupButton; Button signupButton;
EditText usernameEdit; EditText usernameEdit;
@ -151,6 +154,8 @@ public class LoginActivity extends AccountAuthenticatorActivity {
passwordEdit = (EditText) findViewById(R.id.loginPassword); passwordEdit = (EditText) findViewById(R.id.loginPassword);
final LoginActivity that = this; final LoginActivity that = this;
prefs = getSharedPreferences("fr.free.nrw.commons", MODE_PRIVATE);
TextWatcher loginEnabler = new TextWatcher() { TextWatcher loginEnabler = new TextWatcher() {
public void beforeTextChanged(CharSequence charSequence, int start, int count, int after) { } 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 @Override
// FIXME: This Bundle seems to clash with the Bundle at line 81. Logging in brings user to signup screen - why???? protected void onResume() {
if (extras == null || !extras.getBoolean("Redirected")) { super.onResume();
if (extras != null) {
Log.d("SignupActivity", "Redirected? " + Boolean.toString(extras.getBoolean("Redirected"))); if (prefs.getBoolean("firstrun", true)) {
} // Do first run stuff here then set 'firstrun' as false
Intent welcomeIntent = new Intent(this, WelcomeActivity.class); Intent welcomeIntent = new Intent(this, WelcomeActivity.class);
startActivity(welcomeIntent); startActivity(welcomeIntent);
} prefs.edit().putBoolean("firstrun", false).apply();
} }
} }

View file

@ -54,7 +54,6 @@ public class SignupActivity extends Activity {
toast.show(); toast.show();
Intent intent = new Intent(getApplicationContext(), LoginActivity.class); Intent intent = new Intent(getApplicationContext(), LoginActivity.class);
intent.putExtra("Redirected", true);
startActivity(intent); startActivity(intent);
return true; return true;
} else { } else {
@ -76,7 +75,6 @@ public class SignupActivity extends Activity {
else { else {
//If we are in signup page, back button should take us back to LoginActivity //If we are in signup page, back button should take us back to LoginActivity
Intent intent = new Intent(getApplicationContext(), LoginActivity.class); Intent intent = new Intent(getApplicationContext(), LoginActivity.class);
intent.putExtra("Redirected", true);
startActivity(intent); startActivity(intent);
} }
} }