correçao de pequenos erros e bugs , mudei opção de navegação e alterações no login
This commit is contained in:
@@ -83,10 +83,7 @@ public class CriarContaActivity extends AppCompatActivity {
|
|||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
String errorMessage = "Erro ao criar conta!";
|
String errorMessage = com.example.vdcscore.utils.FirebaseErrorUtils.getErrorMessagePt(task.getException());
|
||||||
if (task.getException() != null && task.getException().getMessage() != null) {
|
|
||||||
errorMessage = "Erro: " + task.getException().getMessage();
|
|
||||||
}
|
|
||||||
Toast.makeText(CriarContaActivity.this, errorMessage, Toast.LENGTH_LONG).show();
|
Toast.makeText(CriarContaActivity.this, errorMessage, Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -124,10 +124,7 @@ public class LoginActivity extends AppCompatActivity {
|
|||||||
finish();
|
finish();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
String errorMessage = "Erro ao fazer login!";
|
String errorMessage = com.example.vdcscore.utils.FirebaseErrorUtils.getErrorMessagePt(task.getException());
|
||||||
if (task.getException() != null && task.getException().getMessage() != null) {
|
|
||||||
errorMessage = "Erro: " + task.getException().getMessage();
|
|
||||||
}
|
|
||||||
Toast.makeText(this, errorMessage, Toast.LENGTH_LONG).show();
|
Toast.makeText(this, errorMessage, Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -59,10 +59,7 @@ public class RecuperarPasswordActivity extends AppCompatActivity {
|
|||||||
Toast.LENGTH_LONG).show();
|
Toast.LENGTH_LONG).show();
|
||||||
voltarLogin();
|
voltarLogin();
|
||||||
} else {
|
} else {
|
||||||
String errorMessage = "Erro ao enviar email de recuperação!";
|
String errorMessage = com.example.vdcscore.utils.FirebaseErrorUtils.getErrorMessagePt(task.getException());
|
||||||
if (task.getException() != null && task.getException().getMessage() != null) {
|
|
||||||
errorMessage = "Erro: " + task.getException().getMessage();
|
|
||||||
}
|
|
||||||
Toast.makeText(this, errorMessage, Toast.LENGTH_LONG).show();
|
Toast.makeText(this, errorMessage, Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -134,21 +134,12 @@ public class ContaActivity extends AppCompatActivity {
|
|||||||
if (result.getResultCode() == RESULT_OK && result.getData() != null) {
|
if (result.getResultCode() == RESULT_OK && result.getData() != null) {
|
||||||
selectedImageUri = result.getData().getData();
|
selectedImageUri = result.getData().getData();
|
||||||
if (selectedImageUri != null) {
|
if (selectedImageUri != null) {
|
||||||
try {
|
if (imageProfile != null) {
|
||||||
InputStream inputStream = getContentResolver().openInputStream(selectedImageUri);
|
imageProfile.setImageTintList(null);
|
||||||
if (inputStream != null) {
|
Glide.with(this)
|
||||||
Bitmap bitmap = BitmapFactory.decodeStream(inputStream);
|
.load(selectedImageUri)
|
||||||
inputStream.close();
|
.circleCrop()
|
||||||
if (bitmap != null) {
|
.into(imageProfile);
|
||||||
imageProfile.setImageBitmap(bitmap);
|
|
||||||
// Não fazemos upload até clicar em Gravar
|
|
||||||
} else {
|
|
||||||
Toast.makeText(this, "Erro ao carregar imagem", Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
Toast.makeText(this, "Erro ao carregar imagem: " + e.getMessage(), Toast.LENGTH_SHORT)
|
|
||||||
.show();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -195,6 +186,7 @@ public class ContaActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
private void loadProfileImage(String imageUrl) {
|
private void loadProfileImage(String imageUrl) {
|
||||||
if (imageUrl == null || imageProfile == null) return;
|
if (imageUrl == null || imageProfile == null) return;
|
||||||
|
imageProfile.setImageTintList(null);
|
||||||
Glide.with(this)
|
Glide.with(this)
|
||||||
.load(imageUrl)
|
.load(imageUrl)
|
||||||
.placeholder(R.mipmap.ic_launcher_round)
|
.placeholder(R.mipmap.ic_launcher_round)
|
||||||
@@ -227,7 +219,7 @@ public class ContaActivity extends AppCompatActivity {
|
|||||||
btnSaveAll.setOnClickListener(v -> saveAllChanges());
|
btnSaveAll.setOnClickListener(v -> saveAllChanges());
|
||||||
}
|
}
|
||||||
if (btnChangeEmail != null) {
|
if (btnChangeEmail != null) {
|
||||||
btnChangeEmail.setOnClickListener(v -> sendEmailVerificationForEmailChange());
|
btnChangeEmail.setOnClickListener(v -> showChangeEmailDialog());
|
||||||
}
|
}
|
||||||
if (btnChangePassword != null) {
|
if (btnChangePassword != null) {
|
||||||
btnChangePassword.setOnClickListener(v -> sendPasswordResetEmail());
|
btnChangePassword.setOnClickListener(v -> sendPasswordResetEmail());
|
||||||
@@ -295,9 +287,8 @@ public class ContaActivity extends AppCompatActivity {
|
|||||||
if (task.isSuccessful()) {
|
if (task.isSuccessful()) {
|
||||||
Toast.makeText(this, "Alterações guardadas com sucesso!", Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, "Alterações guardadas com sucesso!", Toast.LENGTH_SHORT).show();
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(this, "Erro ao guardar alterações: " +
|
String error = com.example.vdcscore.utils.FirebaseErrorUtils.getErrorMessagePt(task.getException());
|
||||||
(task.getException() != null ? task.getException().getMessage() : "Erro desconhecido"),
|
Toast.makeText(this, "Erro ao guardar alterações: " + error, Toast.LENGTH_SHORT).show();
|
||||||
Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -394,51 +385,86 @@ public class ContaActivity extends AppCompatActivity {
|
|||||||
"Email de alteração de password enviado! Verifique a sua caixa de entrada.",
|
"Email de alteração de password enviado! Verifique a sua caixa de entrada.",
|
||||||
Toast.LENGTH_LONG).show();
|
Toast.LENGTH_LONG).show();
|
||||||
} else {
|
} else {
|
||||||
String errorMessage = "Erro ao enviar email!";
|
String errorMessage = com.example.vdcscore.utils.FirebaseErrorUtils.getErrorMessagePt(task.getException());
|
||||||
if (task.getException() != null && task.getException().getMessage() != null) {
|
|
||||||
errorMessage = "Erro: " + task.getException().getMessage();
|
|
||||||
}
|
|
||||||
Toast.makeText(this, errorMessage, Toast.LENGTH_LONG).show();
|
Toast.makeText(this, errorMessage, Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendEmailVerificationForEmailChange() {
|
private void showChangeEmailDialog() {
|
||||||
FirebaseUser user = mAuth.getCurrentUser();
|
FirebaseUser user = mAuth.getCurrentUser();
|
||||||
if (user == null || user.getEmail() == null) {
|
if (user == null) {
|
||||||
Toast.makeText(this, "Utilizador não autenticado", Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, "Utilizador não autenticado", Toast.LENGTH_SHORT).show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
progressDialog.show();
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||||
|
builder.setTitle("Alterar Email");
|
||||||
|
|
||||||
// Enviar email de verificação para alterar email
|
final TextInputEditText input = new TextInputEditText(this);
|
||||||
user.sendEmailVerification()
|
input.setInputType(android.text.InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
|
||||||
|
input.setHint("Novo email");
|
||||||
|
if (user.getEmail() != null) {
|
||||||
|
input.setText(user.getEmail());
|
||||||
|
}
|
||||||
|
|
||||||
|
android.widget.FrameLayout container = new android.widget.FrameLayout(this);
|
||||||
|
android.widget.FrameLayout.LayoutParams params = new android.widget.FrameLayout.LayoutParams(
|
||||||
|
android.view.ViewGroup.LayoutParams.MATCH_PARENT,
|
||||||
|
android.view.ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||||
|
int marginPx = (int) (20 * getResources().getDisplayMetrics().density);
|
||||||
|
params.leftMargin = marginPx;
|
||||||
|
params.rightMargin = marginPx;
|
||||||
|
params.topMargin = marginPx;
|
||||||
|
params.bottomMargin = marginPx;
|
||||||
|
input.setLayoutParams(params);
|
||||||
|
container.addView(input);
|
||||||
|
builder.setView(container);
|
||||||
|
|
||||||
|
builder.setPositiveButton("Alterar", (dialog, which) -> {
|
||||||
|
String newEmail = input.getText().toString().trim();
|
||||||
|
if (newEmail.isEmpty()) {
|
||||||
|
Toast.makeText(this, "O email não pode estar vazio", Toast.LENGTH_SHORT).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!android.util.Patterns.EMAIL_ADDRESS.matcher(newEmail).matches()) {
|
||||||
|
Toast.makeText(this, "Email inválido", Toast.LENGTH_SHORT).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (newEmail.equalsIgnoreCase(user.getEmail())) {
|
||||||
|
Toast.makeText(this, "O novo email é igual ao atual", Toast.LENGTH_SHORT).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
performEmailChange(newEmail);
|
||||||
|
});
|
||||||
|
builder.setNegativeButton("Cancelar", (dialog, which) -> dialog.cancel());
|
||||||
|
builder.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void performEmailChange(String newEmail) {
|
||||||
|
FirebaseUser user = mAuth.getCurrentUser();
|
||||||
|
if (user == null) return;
|
||||||
|
|
||||||
|
progressDialog.show();
|
||||||
|
user.verifyBeforeUpdateEmail(newEmail)
|
||||||
.addOnCompleteListener(task -> {
|
.addOnCompleteListener(task -> {
|
||||||
progressDialog.dismiss();
|
progressDialog.dismiss();
|
||||||
if (task.isSuccessful()) {
|
if (task.isSuccessful()) {
|
||||||
Toast.makeText(this,
|
Toast.makeText(this,
|
||||||
"Email de verificação enviado! Verifique a sua caixa de entrada para alterar o email.",
|
"Email de verificação enviado para o novo endereço! Por favor verifique.",
|
||||||
Toast.LENGTH_LONG).show();
|
Toast.LENGTH_LONG).show();
|
||||||
|
if (textEmail != null) {
|
||||||
|
textEmail.setText(newEmail);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Se não conseguir enviar email de verificação, enviar email de reset de
|
if (task.getException() instanceof com.google.firebase.auth.FirebaseAuthRecentLoginRequiredException) {
|
||||||
// password
|
Toast.makeText(this,
|
||||||
// que pode ser usado para alterar o email através do Firebase Console
|
"Por segurança, precisa de terminar sessão e voltar a entrar antes de mudar o email.",
|
||||||
mAuth.sendPasswordResetEmail(user.getEmail())
|
Toast.LENGTH_LONG).show();
|
||||||
.addOnCompleteListener(resetTask -> {
|
} else {
|
||||||
if (resetTask.isSuccessful()) {
|
String error = com.example.vdcscore.utils.FirebaseErrorUtils.getErrorMessagePt(task.getException());
|
||||||
Toast.makeText(this,
|
Toast.makeText(this, "Erro ao alterar email: " + error, Toast.LENGTH_LONG).show();
|
||||||
"Email enviado! Verifique a sua caixa de entrada para instruções de alteração.",
|
}
|
||||||
Toast.LENGTH_LONG).show();
|
|
||||||
} else {
|
|
||||||
String errorMessage = "Erro ao enviar email!";
|
|
||||||
if (resetTask.getException() != null
|
|
||||||
&& resetTask.getException().getMessage() != null) {
|
|
||||||
errorMessage = "Erro: " + resetTask.getException().getMessage();
|
|
||||||
}
|
|
||||||
Toast.makeText(this, errorMessage, Toast.LENGTH_LONG).show();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,12 +22,27 @@
|
|||||||
android:id="@+id/logoImage"
|
android:id="@+id/logoImage"
|
||||||
android:layout_width="64dp"
|
android:layout_width="64dp"
|
||||||
android:layout_height="64dp"
|
android:layout_height="64dp"
|
||||||
android:layout_marginTop="50dp"
|
android:layout_marginTop="40dp"
|
||||||
android:background="@drawable/brand_icon_bg"
|
android:background="@drawable/brand_icon_bg"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
<!-- App Name Title -->
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/textAppName"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
android:text="VdcScore"
|
||||||
|
android:textColor="@color/text_1"
|
||||||
|
android:fontFamily="@font/font_bebas_neue"
|
||||||
|
android:textSize="26sp"
|
||||||
|
android:letterSpacing="0.06"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/logoImage"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent" />
|
||||||
|
|
||||||
<!-- Login Form Container -->
|
<!-- Login Form Container -->
|
||||||
<ScrollView
|
<ScrollView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|||||||
@@ -94,7 +94,8 @@
|
|||||||
android:layout_width="36dp"
|
android:layout_width="36dp"
|
||||||
android:layout_height="36dp"
|
android:layout_height="36dp"
|
||||||
android:background="@drawable/bg_circle_light_gray"
|
android:background="@drawable/bg_circle_light_gray"
|
||||||
android:src="@android:drawable/ic_media_previous"
|
android:foreground="?attr/selectableItemBackgroundBorderless"
|
||||||
|
android:src="@drawable/ic_arrow_back"
|
||||||
android:contentDescription="Anterior"
|
android:contentDescription="Anterior"
|
||||||
app:tint="@color/text_2" />
|
app:tint="@color/text_2" />
|
||||||
|
|
||||||
@@ -115,7 +116,8 @@
|
|||||||
android:layout_width="36dp"
|
android:layout_width="36dp"
|
||||||
android:layout_height="36dp"
|
android:layout_height="36dp"
|
||||||
android:background="@drawable/bg_circle_light_gray"
|
android:background="@drawable/bg_circle_light_gray"
|
||||||
android:src="@android:drawable/ic_media_next"
|
android:foreground="?attr/selectableItemBackgroundBorderless"
|
||||||
|
android:src="@drawable/ic_arrow_forward"
|
||||||
android:contentDescription="Próxima"
|
android:contentDescription="Próxima"
|
||||||
app:tint="@color/text_2" />
|
app:tint="@color/text_2" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|||||||
@@ -94,7 +94,8 @@
|
|||||||
android:layout_width="36dp"
|
android:layout_width="36dp"
|
||||||
android:layout_height="36dp"
|
android:layout_height="36dp"
|
||||||
android:background="@drawable/bg_circle_light_gray"
|
android:background="@drawable/bg_circle_light_gray"
|
||||||
android:src="@android:drawable/ic_media_previous"
|
android:foreground="?attr/selectableItemBackgroundBorderless"
|
||||||
|
android:src="@drawable/ic_arrow_back"
|
||||||
android:contentDescription="Anterior"
|
android:contentDescription="Anterior"
|
||||||
app:tint="@color/text_2" />
|
app:tint="@color/text_2" />
|
||||||
|
|
||||||
@@ -115,7 +116,8 @@
|
|||||||
android:layout_width="36dp"
|
android:layout_width="36dp"
|
||||||
android:layout_height="36dp"
|
android:layout_height="36dp"
|
||||||
android:background="@drawable/bg_circle_light_gray"
|
android:background="@drawable/bg_circle_light_gray"
|
||||||
android:src="@android:drawable/ic_media_next"
|
android:foreground="?attr/selectableItemBackgroundBorderless"
|
||||||
|
android:src="@drawable/ic_arrow_forward"
|
||||||
android:contentDescription="Próxima"
|
android:contentDescription="Próxima"
|
||||||
app:tint="@color/text_2" />
|
app:tint="@color/text_2" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|||||||
@@ -122,7 +122,7 @@
|
|||||||
android:fontFamily="@font/font_ibm_plex_sans"
|
android:fontFamily="@font/font_ibm_plex_sans"
|
||||||
android:text="Anterior"
|
android:text="Anterior"
|
||||||
android:textColor="@color/brand"
|
android:textColor="@color/brand"
|
||||||
app:icon="@android:drawable/ic_media_previous"
|
app:icon="@drawable/ic_arrow_back"
|
||||||
app:iconTint="@color/brand" />
|
app:iconTint="@color/brand" />
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
<com.google.android.material.button.MaterialButton
|
||||||
@@ -134,7 +134,7 @@
|
|||||||
android:fontFamily="@font/font_ibm_plex_sans"
|
android:fontFamily="@font/font_ibm_plex_sans"
|
||||||
android:text="Próxima"
|
android:text="Próxima"
|
||||||
android:textColor="@color/brand"
|
android:textColor="@color/brand"
|
||||||
app:icon="@android:drawable/ic_media_next"
|
app:icon="@drawable/ic_arrow_forward"
|
||||||
app:iconTint="@color/brand"
|
app:iconTint="@color/brand"
|
||||||
app:iconGravity="end" />
|
app:iconGravity="end" />
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user