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.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();
}
}

View file

@ -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);
}
}