defeated again by capitalisation
This commit is contained in:
@@ -45,9 +45,11 @@ public class HomeActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
TextView userGreeting = findViewById(R.id.userGreeting);
|
TextView userGreeting = findViewById(R.id.userGreeting);
|
||||||
SharedPreferences currentUserThings = getSharedPreferences("userData", MODE_PRIVATE);
|
SharedPreferences currentUserThings = getApplicationContext().getSharedPreferences("UserData", MODE_PRIVATE);
|
||||||
String user = currentUserThings.getString("username", "");
|
String user = currentUserThings.getString("username", "");
|
||||||
userGreeting.setText("Welcome " + user + "!");
|
if (user != null)
|
||||||
|
userGreeting.setText("Welcome " + user + "!");
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package com.example.myapp_1;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
@@ -36,52 +35,43 @@ public class LoginActivity extends AppCompatActivity {
|
|||||||
guestLogin= findViewById(R.id.guestButton);
|
guestLogin= findViewById(R.id.guestButton);
|
||||||
|
|
||||||
SharedPreferences.Editor editor = currentUserThings.edit();
|
SharedPreferences.Editor editor = currentUserThings.edit();
|
||||||
signup.setOnClickListener(new View.OnClickListener() {
|
signup.setOnClickListener(v -> {
|
||||||
@Override
|
Intent newScreen = new Intent(getApplicationContext(), SigninActivity.class);
|
||||||
public void onClick(View v) {
|
startActivity(newScreen);
|
||||||
Intent newScreen = new Intent(getApplicationContext(), SigninActivity.class);
|
|
||||||
startActivity(newScreen);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
guestLogin.setOnClickListener(new View.OnClickListener(){
|
guestLogin.setOnClickListener(v -> {
|
||||||
|
editor.putString("username", "Guest");
|
||||||
|
editor.apply();
|
||||||
@Override
|
Intent newScreen = new Intent(getApplicationContext(), HomeActivity.class);
|
||||||
public void onClick(View v) {
|
startActivity(newScreen);
|
||||||
editor.putString("username", "Guest");
|
|
||||||
Intent newScreen = new Intent(getApplicationContext(), HomeActivity.class);
|
|
||||||
startActivity(newScreen);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
login.setOnClickListener(new View.OnClickListener() {
|
login.setOnClickListener(v -> {
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
|
|
||||||
String username_data = username.getText().toString();
|
String username_data = username.getText().toString();
|
||||||
String password_data = password.getText().toString();
|
String password_data = password.getText().toString();
|
||||||
|
|
||||||
if(username_data.isEmpty() || password_data.isEmpty()){
|
if(username_data.isEmpty() || password_data.isEmpty()){
|
||||||
Toast.makeText(LoginActivity.this,"Please fill your data!", Toast.LENGTH_LONG).show();
|
Toast.makeText(LoginActivity.this,"Please fill your data!", Toast.LENGTH_LONG).show();
|
||||||
}else{
|
}else{
|
||||||
if (dbOperations.checkLoginCredentials(username_data, password_data)) {
|
if (dbOperations.checkLoginCredentials(username_data, password_data)) {
|
||||||
// Login successful
|
// Login successful
|
||||||
// Proceed to the next screen or perform other actions
|
// Proceed to the next screen or perform other actions
|
||||||
Toast.makeText(LoginActivity.this,"Welcome", Toast.LENGTH_LONG).show();
|
Toast.makeText(LoginActivity.this,"Welcome", Toast.LENGTH_LONG).show();
|
||||||
editor.putString("username", "Guest");
|
editor.putString("username", username_data);
|
||||||
Intent newScreen = new Intent(getApplicationContext(), HomeActivity.class);
|
editor.apply();
|
||||||
startActivity(newScreen);
|
Intent newScreen = new Intent(getApplicationContext(), HomeActivity.class);
|
||||||
|
startActivity(newScreen);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// Login failed
|
// Login failed
|
||||||
|
|
||||||
Toast.makeText(LoginActivity.this,"Invalid Iformation", Toast.LENGTH_LONG).show();
|
Toast.makeText(LoginActivity.this,"Invalid Iformation", Toast.LENGTH_LONG).show();
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user