Moved some functionality from old StartActivity to LoginActivity (goto registration, enter app if already logged in)
This commit is contained in:
@@ -84,6 +84,14 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
||||
isNetworkAvailable();
|
||||
checkForMaintenance();
|
||||
|
||||
SessionManager session = new SessionManager(getApplicationContext());
|
||||
if (session.isLoggedIn()) {
|
||||
Log.d(TAG,"User found in sharedPrefs and is therefore logged in. Continue to internal Area.");
|
||||
Intent intent = new Intent(LoginActivity.this, MainActivity.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void isNetworkAvailable() {
|
||||
@@ -96,7 +104,7 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
||||
.setCancelable(false)
|
||||
.setNeutralButton(android.R.string.yes, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
gotoStartActivity();
|
||||
//todo What to do when no internet connection is available?
|
||||
}
|
||||
})
|
||||
.setIcon(android.R.drawable.ic_dialog_alert)
|
||||
@@ -108,9 +116,9 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
||||
Intent intent = getIntent();
|
||||
String msg_intent = intent.getStringExtra(AppConfig.EXTRA_MESSAGE);
|
||||
|
||||
if(msg_intent.equals(AppConfig.INTENT_LOGIN)){
|
||||
if(msg_intent != null && msg_intent.equals(AppConfig.INTENT_LOGIN)){
|
||||
initLoginView();
|
||||
}else if(msg_intent.equals(AppConfig.INTENT_REGISTER)){
|
||||
}else if((msg_intent == null) || msg_intent.equals(AppConfig.INTENT_REGISTER)){
|
||||
initRegisterView();
|
||||
}
|
||||
}
|
||||
@@ -128,6 +136,14 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
||||
input_password = (TextView) findViewById(R.id.input_register_password);
|
||||
TextView btn_requestPW = (TextView) findViewById(R.id.lbl_login_resendPW);
|
||||
|
||||
Button btn_switchtoregistration = (Button) findViewById(R.id.btn_switchtoregistration);
|
||||
btn_switchtoregistration.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
gotoRegister(v);
|
||||
}
|
||||
});
|
||||
|
||||
Button btn_login = (Button) findViewById(R.id.btn_login);
|
||||
btn_login.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
@@ -178,6 +194,7 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
||||
input_email = (TextView) findViewById(R.id.input_register_email);
|
||||
input_password = (TextView) findViewById(R.id.input_register_password);
|
||||
Button btn_login = (Button) findViewById(R.id.btn_register);
|
||||
TextView btn_switchtologin = (TextView) findViewById(R.id.lbl_register_switchtologin);
|
||||
|
||||
input_username.addTextChangedListener(new TextValidator(input_username, getApplicationContext()) {
|
||||
@Override
|
||||
@@ -227,11 +244,17 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
btn_switchtologin.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
gotoLogin(v);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initSocialLoginButtons() {
|
||||
FragmentManager fragmentManager = getSupportFragmentManager();
|
||||
//FacebookButtonFragment fragmentFB = new FacebookButtonFragment();
|
||||
new FacebookButtonFragment();
|
||||
GooglePlusButtonFragment fragmentGP = new GooglePlusButtonFragment();
|
||||
|
||||
@@ -261,7 +284,6 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
||||
if (!error) {
|
||||
if(jObj.getBoolean("maintenancemode")){
|
||||
showMessage(jObj.getString("maintenancemsg"));
|
||||
gotoStartActivity();
|
||||
}
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
@@ -285,10 +307,15 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
||||
};
|
||||
}
|
||||
|
||||
private void gotoStartActivity() {
|
||||
Intent intent = new Intent(
|
||||
LoginActivity.this,
|
||||
StartActivity.class);
|
||||
public void gotoLogin(View view) {
|
||||
Intent intent = new Intent(this, LoginActivity.class);
|
||||
intent.putExtra(AppConfig.EXTRA_MESSAGE, AppConfig.INTENT_LOGIN);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
public void gotoRegister(View view) {
|
||||
Intent intent = new Intent(this, LoginActivity.class);
|
||||
intent.putExtra(AppConfig.EXTRA_MESSAGE, AppConfig.INTENT_REGISTER);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@@ -1040,12 +1067,6 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
||||
pDialog.dismiss();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
gotoStartActivity();
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.menu_common, menu);
|
||||
|
||||
Reference in New Issue
Block a user