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();
|
isNetworkAvailable();
|
||||||
checkForMaintenance();
|
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() {
|
public void isNetworkAvailable() {
|
||||||
@@ -96,7 +104,7 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
|||||||
.setCancelable(false)
|
.setCancelable(false)
|
||||||
.setNeutralButton(android.R.string.yes, new DialogInterface.OnClickListener() {
|
.setNeutralButton(android.R.string.yes, new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
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)
|
.setIcon(android.R.drawable.ic_dialog_alert)
|
||||||
@@ -108,9 +116,9 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
|||||||
Intent intent = getIntent();
|
Intent intent = getIntent();
|
||||||
String msg_intent = intent.getStringExtra(AppConfig.EXTRA_MESSAGE);
|
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();
|
initLoginView();
|
||||||
}else if(msg_intent.equals(AppConfig.INTENT_REGISTER)){
|
}else if((msg_intent == null) || msg_intent.equals(AppConfig.INTENT_REGISTER)){
|
||||||
initRegisterView();
|
initRegisterView();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -128,6 +136,14 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
|||||||
input_password = (TextView) findViewById(R.id.input_register_password);
|
input_password = (TextView) findViewById(R.id.input_register_password);
|
||||||
TextView btn_requestPW = (TextView) findViewById(R.id.lbl_login_resendPW);
|
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);
|
Button btn_login = (Button) findViewById(R.id.btn_login);
|
||||||
btn_login.setOnClickListener(new View.OnClickListener() {
|
btn_login.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
@@ -178,6 +194,7 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
|||||||
input_email = (TextView) findViewById(R.id.input_register_email);
|
input_email = (TextView) findViewById(R.id.input_register_email);
|
||||||
input_password = (TextView) findViewById(R.id.input_register_password);
|
input_password = (TextView) findViewById(R.id.input_register_password);
|
||||||
Button btn_login = (Button) findViewById(R.id.btn_register);
|
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()) {
|
input_username.addTextChangedListener(new TextValidator(input_username, getApplicationContext()) {
|
||||||
@Override
|
@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() {
|
private void initSocialLoginButtons() {
|
||||||
FragmentManager fragmentManager = getSupportFragmentManager();
|
FragmentManager fragmentManager = getSupportFragmentManager();
|
||||||
//FacebookButtonFragment fragmentFB = new FacebookButtonFragment();
|
|
||||||
new FacebookButtonFragment();
|
new FacebookButtonFragment();
|
||||||
GooglePlusButtonFragment fragmentGP = new GooglePlusButtonFragment();
|
GooglePlusButtonFragment fragmentGP = new GooglePlusButtonFragment();
|
||||||
|
|
||||||
@@ -261,7 +284,6 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
|||||||
if (!error) {
|
if (!error) {
|
||||||
if(jObj.getBoolean("maintenancemode")){
|
if(jObj.getBoolean("maintenancemode")){
|
||||||
showMessage(jObj.getString("maintenancemsg"));
|
showMessage(jObj.getString("maintenancemsg"));
|
||||||
gotoStartActivity();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
@@ -285,10 +307,15 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private void gotoStartActivity() {
|
public void gotoLogin(View view) {
|
||||||
Intent intent = new Intent(
|
Intent intent = new Intent(this, LoginActivity.class);
|
||||||
LoginActivity.this,
|
intent.putExtra(AppConfig.EXTRA_MESSAGE, AppConfig.INTENT_LOGIN);
|
||||||
StartActivity.class);
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void gotoRegister(View view) {
|
||||||
|
Intent intent = new Intent(this, LoginActivity.class);
|
||||||
|
intent.putExtra(AppConfig.EXTRA_MESSAGE, AppConfig.INTENT_REGISTER);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1040,12 +1067,6 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
|||||||
pDialog.dismiss();
|
pDialog.dismiss();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onBackPressed() {
|
|
||||||
gotoStartActivity();
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
getMenuInflater().inflate(R.menu.menu_common, menu);
|
getMenuInflater().inflate(R.menu.menu_common, menu);
|
||||||
|
|||||||
Reference in New Issue
Block a user