estou a fazer o Esqueci_a_palavra_passe ainda
|
|
@ -52,6 +52,7 @@ dependencies {
|
|||
implementation(libs.credentials.play.services.auth)
|
||||
implementation(libs.googleid)
|
||||
implementation(libs.mediarouter)
|
||||
implementation(libs.recyclerview)
|
||||
testImplementation(libs.junit)
|
||||
androidTestImplementation(libs.ext.junit)
|
||||
androidTestImplementation(libs.espresso.core)
|
||||
|
|
|
|||
|
|
@ -1,26 +1,108 @@
|
|||
package com.example.cuida.ui.Inicial;
|
||||
|
||||
import android.content.Intent; // Importação necessária para o Intent
|
||||
import android.os.Bundle;
|
||||
import android.util.Patterns;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.activity.EdgeToEdge;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.graphics.Insets;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.view.WindowInsetsCompat;
|
||||
|
||||
import com.example.cuida.R;
|
||||
import com.google.android.gms.tasks.OnCompleteListener;
|
||||
import com.google.android.gms.tasks.Task;
|
||||
import com.google.firebase.auth.FirebaseAuth;
|
||||
|
||||
public class Esqueci_a_palavra_passe extends AppCompatActivity {
|
||||
private TextView tpTextView;
|
||||
private TextView tsTextView;
|
||||
private EditText emailEditText;
|
||||
private Button enviarButton;
|
||||
// Removi as variáveis não usadas 'voltarButton'
|
||||
private Button voltarParaOLoginButton;
|
||||
|
||||
private FirebaseAuth mAuth;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
EdgeToEdge.enable(this);
|
||||
setContentView(R.layout.activity_esqueci_apalavra_passe);
|
||||
|
||||
mAuth = FirebaseAuth.getInstance();
|
||||
|
||||
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
|
||||
Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
|
||||
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
|
||||
return insets;
|
||||
});
|
||||
|
||||
// Inicialização dos componentes
|
||||
tpTextView = findViewById(R.id.tPTextView);
|
||||
voltarParaOLoginButton = findViewById(R.id.voltarParaOLoginButton);
|
||||
tsTextView = findViewById(R.id.tSTextView);
|
||||
emailEditText = findViewById(R.id.emailTextEdit);
|
||||
enviarButton = findViewById(R.id.enviarButton);
|
||||
|
||||
// Lógica para o botão de enviar e-mail
|
||||
enviarButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
recuperarSenha();
|
||||
}
|
||||
});
|
||||
|
||||
// --- CÓDIGO ADICIONADO AQUI ---
|
||||
// Lógica para o botão "Voltar para o Login"
|
||||
voltarParaOLoginButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// Cria um Intent para ir da tela atual para a tela de login
|
||||
Intent intent = new Intent(Esqueci_a_palavra_passe.this, iniciar_sessao.class);
|
||||
startActivity(intent);
|
||||
finish(); // Fecha a tela atual para que o usuário não volte para ela ao clicar "Voltar"
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void recuperarSenha() {
|
||||
String email = emailEditText.getText().toString().trim();
|
||||
|
||||
if (email.isEmpty()) {
|
||||
emailEditText.setError("O campo de e-mail é obrigatório.");
|
||||
emailEditText.requestFocus();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Patterns.EMAIL_ADDRESS.matcher(email).matches()) {
|
||||
emailEditText.setError("Por favor, insira um e-mail válido.");
|
||||
emailEditText.requestFocus();
|
||||
return;
|
||||
}
|
||||
|
||||
mAuth.sendPasswordResetEmail(email)
|
||||
.addOnCompleteListener(new OnCompleteListener<Void>() {
|
||||
@Override
|
||||
public void onComplete(@NonNull Task<Void> task) {
|
||||
if (task.isSuccessful()) {
|
||||
Toast.makeText(Esqueci_a_palavra_passe.this,
|
||||
"E-mail de redefinição de senha enviado. Verifique a sua caixa de entrada.",
|
||||
Toast.LENGTH_LONG).show();
|
||||
// Após enviar o e-mail, também podemos fechar a tela
|
||||
finish();
|
||||
} else {
|
||||
Toast.makeText(Esqueci_a_palavra_passe.this,
|
||||
"Falha ao enviar e-mail. Verifique se o e-mail está correto e registado.",
|
||||
Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -21,8 +21,8 @@
|
|||
|
||||
<EditText
|
||||
android:id="@+id/nomeApelidoEditText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="250dp"
|
||||
android:layout_height="50dp"
|
||||
android:layout_marginTop="50dp"
|
||||
android:ems="10"
|
||||
android:hint="Nome e Apelido"
|
||||
|
|
@ -33,8 +33,8 @@
|
|||
|
||||
<EditText
|
||||
android:id="@+id/gmailEditText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="250dp"
|
||||
android:layout_height="50dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:ems="10"
|
||||
android:hint="Gmail"
|
||||
|
|
@ -45,8 +45,8 @@
|
|||
|
||||
<EditText
|
||||
android:id="@+id/telemovelEditText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="250dp"
|
||||
android:layout_height="50dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:ems="10"
|
||||
android:hint="Nº de telemovel"
|
||||
|
|
@ -57,8 +57,8 @@
|
|||
|
||||
<EditText
|
||||
android:id="@+id/confirmarPalavraPasseEditText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="250dp"
|
||||
android:layout_height="50dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:ems="10"
|
||||
android:hint="Confirmar Palavra-Passe"
|
||||
|
|
@ -70,8 +70,8 @@
|
|||
|
||||
<EditText
|
||||
android:id="@+id/palavraPasseEditText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="250dp"
|
||||
android:layout_height="50dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:ems="10"
|
||||
android:hint="Palavra-Passe"
|
||||
|
|
@ -82,8 +82,8 @@
|
|||
|
||||
<EditText
|
||||
android:id="@+id/moradaEditText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="250dp"
|
||||
android:layout_height="50dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:ems="10"
|
||||
android:hint="morada"
|
||||
|
|
@ -92,20 +92,22 @@
|
|||
app:layout_constraintStart_toStartOf="@+id/telemovelEditText"
|
||||
app:layout_constraintTop_toBottomOf="@+id/telemovelEditText" />
|
||||
|
||||
<Button
|
||||
<androidx.appcompat.widget.AppCompatButton
|
||||
android:id="@+id/CriarContaButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="50dp"
|
||||
android:layout_marginTop="50dp"
|
||||
android:background="@color/blue"
|
||||
android:text="Criar Conta"
|
||||
android:textColor="@color/white"
|
||||
app:layout_constraintEnd_toEndOf="@+id/confirmarPalavraPasseEditText"
|
||||
app:layout_constraintStart_toStartOf="@+id/confirmarPalavraPasseEditText"
|
||||
app:layout_constraintTop_toBottomOf="@+id/confirmarPalavraPasseEditText" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/dataEditText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="250dp"
|
||||
android:layout_height="50dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:ems="10"
|
||||
android:hint="Data de nascimento"
|
||||
|
|
|
|||
|
|
@ -7,50 +7,64 @@
|
|||
android:layout_height="match_parent"
|
||||
tools:context=".ui.Inicial.Esqueci_a_palavra_passe">
|
||||
|
||||
<Button
|
||||
android:id="@+id/button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="120dp"
|
||||
android:text="Button"
|
||||
app:layout_constraintEnd_toEndOf="@+id/editTextTextEmailAddress"
|
||||
app:layout_constraintHorizontal_bias="0.504"
|
||||
app:layout_constraintStart_toStartOf="@+id/editTextTextEmailAddress"
|
||||
app:layout_constraintTop_toBottomOf="@+id/editTextTextEmailAddress" />
|
||||
<androidx.appcompat.widget.AppCompatButton
|
||||
android:id="@+id/enviarButton"
|
||||
android:layout_width="196dp"
|
||||
android:layout_height="47dp"
|
||||
android:layout_marginTop="28dp"
|
||||
android:background="@color/blue"
|
||||
android:text="Enviar"
|
||||
android:textColor="#F2EFEF"
|
||||
app:layout_constraintEnd_toEndOf="@+id/emailTextEdit"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintStart_toStartOf="@+id/emailTextEdit"
|
||||
app:layout_constraintTop_toBottomOf="@+id/emailTextEdit" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView2"
|
||||
android:id="@+id/tPTextView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="108dp"
|
||||
android:layout_marginTop="260dp"
|
||||
android:text="Esqueci a palavra passe"
|
||||
android:textSize="34sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.489"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView3"
|
||||
android:id="@+id/tSTextView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="48dp"
|
||||
android:layout_marginTop="4dp"
|
||||
android:text="usa o email para recuperar a sua palavra-passe"
|
||||
android:textSize="16sp"
|
||||
app:layout_constraintEnd_toEndOf="@+id/textView2"
|
||||
app:layout_constraintStart_toStartOf="@+id/textView2"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textView2" />
|
||||
app:layout_constraintEnd_toEndOf="@+id/tPTextView"
|
||||
app:layout_constraintHorizontal_bias="0.785"
|
||||
app:layout_constraintStart_toStartOf="@+id/tPTextView"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tPTextView" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/editTextTextEmailAddress"
|
||||
android:id="@+id/emailTextEdit"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="64dp"
|
||||
android:layout_marginTop="32dp"
|
||||
android:ems="10"
|
||||
android:hint=" "
|
||||
android:hint="Email"
|
||||
android:inputType="textEmailAddress"
|
||||
app:layout_constraintEnd_toEndOf="@+id/textView3"
|
||||
app:layout_constraintHorizontal_bias="0.493"
|
||||
app:layout_constraintStart_toStartOf="@+id/textView3"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textView3" />
|
||||
app:layout_constraintEnd_toEndOf="@+id/tSTextView"
|
||||
app:layout_constraintStart_toStartOf="@+id/tSTextView"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tSTextView" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/voltarParaOLoginButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="voltar para o login"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="16sp"
|
||||
app:layout_constraintEnd_toEndOf="@+id/enviarButton"
|
||||
app:layout_constraintStart_toStartOf="@+id/enviarButton"
|
||||
app:layout_constraintTop_toBottomOf="@+id/enviarButton" />
|
||||
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
|
@ -39,7 +39,7 @@
|
|||
android:layout_marginTop="12dp"
|
||||
android:layout_marginEnd="100dp"
|
||||
android:background="#2196F3"
|
||||
android:backgroundTint="#000000"
|
||||
android:backgroundTint="@color/black"
|
||||
android:shadowColor="#03A9F4"
|
||||
android:text="Entrar"
|
||||
android:textColor="#FFFFFF"
|
||||
|
|
|
|||
|
|
@ -1,5 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@color/img_cuida_background"/>
|
||||
<foreground android:drawable="@mipmap/img_cuida_foreground"/>
|
||||
</adaptive-icon>
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@color/img_cuida_background"/>
|
||||
<foreground android:drawable="@mipmap/img_cuida_foreground"/>
|
||||
</adaptive-icon>
|
||||
|
Before Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 5.7 KiB |
|
Before Width: | Height: | Size: 3.8 KiB |
|
Before Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 3.1 KiB |
|
Before Width: | Height: | Size: 8.4 KiB |
|
Before Width: | Height: | Size: 5.6 KiB |
|
Before Width: | Height: | Size: 5.5 KiB |
|
Before Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 9.9 KiB |
|
Before Width: | Height: | Size: 8.3 KiB |
|
Before Width: | Height: | Size: 31 KiB |
|
Before Width: | Height: | Size: 14 KiB |
|
|
@ -5,6 +5,11 @@
|
|||
<color name="purple_700">#FF3700B3</color>
|
||||
<color name="teal_200">#FF03DAC5</color>
|
||||
<color name="teal_700">#FF018786</color>
|
||||
<color name="black">#FF000000</color>
|
||||
<color name="white">#FFFFFFFF</color>
|
||||
|
||||
<color name="black">#FF000000</color> <!-- Em vez de "preto" -->
|
||||
<color name="white">#FFFFFFFF</color> <!-- Em vez de "branco" -->
|
||||
<color name="blue">#FF2196F3</color>
|
||||
|
||||
<!-- LINHA A ADICIONAR PARA CORRIGIR O ERRO -->
|
||||
<color name="img_cuida_background">#FFFFFFFF</color>
|
||||
</resources>
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="img_cuida_background">#FFFFFF</color>
|
||||
</resources>
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
[versions]
|
||||
agp = "8.13.1"
|
||||
agp = "8.13.2"
|
||||
junit = "4.13.2"
|
||||
junitVersion = "1.3.0"
|
||||
espressoCore = "3.7.0"
|
||||
|
|
@ -19,6 +19,7 @@ credentials = "1.5.0"
|
|||
credentialsPlayServicesAuth = "1.5.0"
|
||||
googleid = "1.1.1"
|
||||
mediarouter = "1.8.1"
|
||||
recyclerview = "1.4.0"
|
||||
|
||||
[libraries]
|
||||
junit = { group = "junit", name = "junit", version.ref = "junit" }
|
||||
|
|
@ -39,6 +40,7 @@ credentials = { group = "androidx.credentials", name = "credentials", version.re
|
|||
credentials-play-services-auth = { group = "androidx.credentials", name = "credentials-play-services-auth", version.ref = "credentialsPlayServicesAuth" }
|
||||
googleid = { group = "com.google.android.libraries.identity.googleid", name = "googleid", version.ref = "googleid" }
|
||||
mediarouter = { group = "androidx.mediarouter", name = "mediarouter", version.ref = "mediarouter" }
|
||||
recyclerview = { group = "androidx.recyclerview", name = "recyclerview", version.ref = "recyclerview" }
|
||||
|
||||
[plugins]
|
||||
android-application = { id = "com.android.application", version.ref = "agp" }
|
||||
|
|
|
|||