Auto logout process handled

This commit is contained in:
Sumit Mandal 2023-09-23 13:25:32 +05:30
parent bf299f8dfc
commit 0ede79cbe7
5 changed files with 28 additions and 25 deletions

View File

@ -157,6 +157,9 @@ public class CheckInActivity extends AppCompatActivity {
@Override
public void onClick(View view) {
SharedPreferences.Editor editor = shared.edit();
editor.putBoolean("IsUserLogin",false);
editor.commit();
Intent intent = new Intent(CheckInActivity.this, LoginActivityNew.class);
startActivity(intent);
@ -186,6 +189,10 @@ public class CheckInActivity extends AppCompatActivity {
popup_log_out.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
SharedPreferences.Editor editor = shared.edit();
editor.putBoolean("IsUserLogin",false);
editor.commit();
Intent intent = new Intent(CheckInActivity.this, LoginActivityNew.class);
startActivity(intent);
finish();

View File

@ -10,8 +10,10 @@ import android.os.Handler;
import android.view.WindowManager;
import cn.pedant.SweetAlert.SweetAlertDialog;
import ru.visionlab.femdemo.authentication.AuthSuccessActivity;
import ru.visionlab.femdemo.login.LoginActivity;
import ru.visionlab.femdemo.login.LoginActivityNew;
import ru.visionlab.femdemo.register.RegisterActivity;
public class Splashactivity extends AppCompatActivity {
@ -29,26 +31,20 @@ public class Splashactivity extends AppCompatActivity {
// creating a new intent
SharedPreferences sharedPreferences = getSharedPreferences("MyPrefs", Context.MODE_PRIVATE);
boolean loggedBefore = sharedPreferences.getBoolean("loggedBefore",false);
boolean IsUserLogin = sharedPreferences.getBoolean("IsUserLogin",false);
System.out.println("Value of loggedBefore "+ loggedBefore);
if(loggedBefore){
if(!IsUserLogin){
Intent i = new Intent(Splashactivity.this, LoginActivity.class);
startActivity(i);
}
else {
Intent i = new Intent(Splashactivity.this, LoginActivity.class); // on below line we are
// starting a new activity.
startActivity(i);
// on the below line we are finishing
// our current activity.
finish();
}
else {
final Intent intent = new Intent(Splashactivity.this, CheckInActivity.class);
intent.putExtra("FromRegister", true);
intent.putExtra("checkinButtonFromRegister", true);
startActivity(intent);
finish();
}
}
}, 2000);
}

View File

@ -106,6 +106,7 @@ public class LoginActivity extends BaseActivity {
public void onClick(View view) {
Intent intent = new Intent(LoginActivity.this,LoginActivityNew.class);
startActivity(intent);
finish();
}
});
reg_new = findViewById(R.id.reg_new);
@ -114,6 +115,7 @@ public class LoginActivity extends BaseActivity {
public void onClick(View view) {
Intent intent = new Intent(LoginActivity.this, RegisterActivityNew.class);
startActivity(intent);
finish();
}
});

View File

@ -557,7 +557,6 @@ public class LoginActivityNew extends AppCompatActivity {
if(statuscode.equals("200"))
{
// preferences.setUsername(username);
SharedPreferences.Editor editor = shared.edit();
editor.putString("RegisterUser",username);
editor.putString("Employeeid",_employeeid);

View File

@ -118,7 +118,7 @@ public class RegisterActivity extends ToolbarActivity implements RegisterFragmen
private boolean goingSomewhere = false;
String valueFromApiCheckIn;
SharedPreferences shared;
@SuppressLint("MissingInflatedId")
@ -131,9 +131,9 @@ public class RegisterActivity extends ToolbarActivity implements RegisterFragmen
//ButterKnife.bind(this);
setToolbar();
SharedPreferences sharedPreferences = getSharedPreferences("MyPrefs", Context.MODE_PRIVATE);
String login = sharedPreferences.getString("login","");
String Descriptor = sharedPreferences.getString("Descriptor","");
shared = getSharedPreferences("MyPrefs", Context.MODE_PRIVATE);
String login = shared.getString("login","");
String Descriptor = shared.getString("Descriptor","");
System.out.println("Value of login and Descriptor " + preferences.getUsername()+" ");
Intent intent = getIntent();
@ -584,12 +584,13 @@ public class RegisterActivity extends ToolbarActivity implements RegisterFragmen
}
private void showSuccess() {
SharedPreferences.Editor editor = shared.edit();
editor.putBoolean("IsUserLogin",true);
editor.commit();
final Intent intent = new Intent(RegisterActivity.this, CheckInActivity.class);
intent.putExtra(AuthSuccessActivity.LOGIN, login);
System.out.println("login value "+ login);
if (BuildConfig.IS_OFFLINE_VERSION) {
intent.putExtra(AuthSuccessActivity.TIME, (int) (((double) (verifEndTime - verifStartTime)) / 1e6));
intent.putExtra("FromRegister", true);
@ -597,9 +598,7 @@ public class RegisterActivity extends ToolbarActivity implements RegisterFragmen
intent.putExtra("valueFromApiCheckIn", valueFromApiCheckIn);
intent.putExtra("UserName", login);
}
startActivity(intent);
finish();
/*if (checkinButton) {