o login esta a dar erro
This commit is contained in:
@@ -4,6 +4,8 @@ import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import com.example.cuida.MainActivity;
|
||||
import com.example.cuida.data.model.User;
|
||||
@@ -41,11 +43,12 @@ public class LoginActivity extends AppCompatActivity {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// Sign out to prevent ghost sessions if they didn't want to be remembered
|
||||
// Se não for para lembrar a sessão, garantimos que o estado de login é falso
|
||||
// mas NÃO limpamos as credenciais guardadas para a biometria.
|
||||
if (mAuth.getCurrentUser() != null) {
|
||||
mAuth.signOut();
|
||||
}
|
||||
prefs.edit().clear().apply();
|
||||
prefs.edit().putBoolean("is_logged_in", false).apply();
|
||||
}
|
||||
|
||||
binding = ActivityLoginBinding.inflate(getLayoutInflater());
|
||||
@@ -73,8 +76,8 @@ public class LoginActivity extends AppCompatActivity {
|
||||
String savedPass = prefs.getString("saved_pass", null);
|
||||
|
||||
if (canAuthenticate == BiometricManager.BIOMETRIC_SUCCESS && savedEmail != null && savedPass != null) {
|
||||
binding.biometric_button.setVisibility(android.view.View.VISIBLE);
|
||||
binding.biometric_button.setOnClickListener(v -> showBiometricPrompt(savedEmail, savedPass));
|
||||
binding.biometricButton.setVisibility(android.view.View.VISIBLE);
|
||||
binding.biometricButton.setOnClickListener(v -> showBiometricPrompt(savedEmail, savedPass));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,11 +179,9 @@ public class LoginActivity extends AppCompatActivity {
|
||||
prefs.edit().putBoolean("is_logged_in", true).apply();
|
||||
prefs.edit().putBoolean("remember_me", rememberMe).apply();
|
||||
|
||||
// Save for biometrics if remember me is on
|
||||
if (rememberMe) {
|
||||
prefs.edit().putString("saved_email", email).apply();
|
||||
prefs.edit().putString("saved_pass", password).apply();
|
||||
}
|
||||
// Guardar sempre para biometria após login manual com sucesso
|
||||
prefs.edit().putString("saved_email", email).apply();
|
||||
prefs.edit().putString("saved_pass", password).apply();
|
||||
|
||||
if (fetchTask.isSuccessful() && fetchTask.getResult() != null
|
||||
&& fetchTask.getResult().exists()) {
|
||||
|
||||
@@ -5,68 +5,71 @@
|
||||
android:orientation="vertical"
|
||||
android:padding="24dp">
|
||||
|
||||
<FrameLayout
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/layout_med_name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
|
||||
android:hint="Nome do Medicamento"
|
||||
android:layout_marginBottom="8dp">
|
||||
|
||||
<LinearLayout
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/edit_med_name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
android:inputType="textCapWords" />
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/layout_med_name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
|
||||
android:hint="Nome do Medicamento"
|
||||
android:layout_marginBottom="8dp">
|
||||
<!-- Search Results RecyclerView -->
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recycler_search_results"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="-8dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:visibility="gone"
|
||||
android:background="#FFFFFF"
|
||||
android:elevation="4dp" />
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/edit_med_name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="textCapWords" />
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center_vertical"
|
||||
android:layout_marginBottom="4dp">
|
||||
|
||||
<TextView
|
||||
android:text="Horários"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="14sp"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center_vertical"
|
||||
android:layout_marginBottom="4dp">
|
||||
|
||||
<TextView
|
||||
android:text="Horários"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:textSize="14sp"/>
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/btn_add_time"
|
||||
style="@style/Widget.MaterialComponents.Button.TextButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Adicionar"
|
||||
android:padding="0dp"
|
||||
android:minWidth="0dp"
|
||||
android:minHeight="0dp"/>
|
||||
</LinearLayout>
|
||||
|
||||
<com.google.android.material.chip.ChipGroup
|
||||
android:id="@+id/chip_group_times"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:padding="4dp"/>
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/btn_add_time"
|
||||
style="@style/Widget.MaterialComponents.Button.TextButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Adicionar"
|
||||
android:padding="0dp"
|
||||
android:minWidth="0dp"
|
||||
android:minHeight="0dp"/>
|
||||
</LinearLayout>
|
||||
|
||||
<com.google.android.material.chip.ChipGroup
|
||||
android:id="@+id/chip_group_times"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:padding="4dp"/>
|
||||
|
||||
<TextView
|
||||
android:text="Via de Administração"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="14sp"
|
||||
android:textColor="@color/black"
|
||||
android:layout_marginBottom="4dp"/>
|
||||
|
||||
<RadioGroup
|
||||
@@ -91,12 +94,13 @@
|
||||
android:id="@+id/radio_inhalatory"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Via Inalatória (Pelo nariz/boca)" />
|
||||
android:text="Via Inalatória (Pela nariz/boca)" />
|
||||
</RadioGroup>
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
|
||||
android:hint="Notas (Opcional)"
|
||||
android:layout_marginBottom="16dp">
|
||||
|
||||
|
||||
Reference in New Issue
Block a user