Switch the main activity to be the LoginActivity

This commit is contained in:
addshore 2017-05-15 16:34:54 +02:00
parent 364199dcb2
commit 367228d758
4 changed files with 24 additions and 14 deletions

View file

@ -31,6 +31,10 @@
<activity
android:name=".auth.LoginActivity"
>
<intent-filter>
<category android:name="android.intent.category.LAUNCHER"/>
<action android:name="android.intent.action.MAIN"/>
</intent-filter>
</activity>
<activity
android:name=".WelcomeActivity"
@ -66,10 +70,6 @@
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
>
<intent-filter>
<category android:name="android.intent.category.LAUNCHER"/>
<action android:name="android.intent.action.MAIN"/>
</intent-filter>
</activity>
<activity
android:name=".settings.SettingsActivity"

View file

@ -166,7 +166,10 @@ public class CommonsApplication extends Application {
public MWApi getApi() {
return api;
}
/**
* @return Accout|null
*/
public Account getCurrentAccount() {
if(currentAccount == null) {
AccountManager accountManager = AccountManager.get(this);

View file

@ -17,10 +17,8 @@ import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import fr.free.nrw.commons.BuildConfig;
import fr.free.nrw.commons.R;
import fr.free.nrw.commons.Utils;
import fr.free.nrw.commons.WelcomeActivity;
import fr.free.nrw.commons.*;
import fr.free.nrw.commons.contributions.ContributionsActivity;
import timber.log.Timber;
@ -36,10 +34,14 @@ public class LoginActivity extends AccountAuthenticatorActivity {
EditText twoFactorEdit;
ProgressDialog progressDialog;
private CommonsApplication app;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
app = (CommonsApplication) getApplicationContext();
setContentView(R.layout.activity_login);
final LoginActivity that = this;
@ -116,6 +118,9 @@ public class LoginActivity extends AccountAuthenticatorActivity {
this.startWelcomeIntent();
prefs.edit().putBoolean("firstrun", false).apply();
}
if (app.getCurrentAccount() != null) {
startMainActivity();
}
}
private void startWelcomeIntent() {
@ -208,4 +213,10 @@ public class LoginActivity extends AccountAuthenticatorActivity {
twoFactorEdit.setText("");
}
public void startMainActivity() {
Intent intent = new Intent(this, ContributionsActivity.class);
startActivity(intent);
finish();
}
}

View file

@ -9,7 +9,6 @@ import android.os.Bundle;
import fr.free.nrw.commons.CommonsApplication;
import fr.free.nrw.commons.EventLog;
import fr.free.nrw.commons.R;
import fr.free.nrw.commons.contributions.ContributionsActivity;
import timber.log.Timber;
import java.io.IOException;
@ -90,10 +89,7 @@ class LoginTask extends AsyncTask<String, String, String> {
}
AccountUtil.createAccount( response, username, password );
Intent intent = new Intent(loginActivity, ContributionsActivity.class);
loginActivity.startActivity(intent);
loginActivity.finish();
loginActivity.startMainActivity();
}
/**