tenho de ver se marca as coisas
This commit is contained in:
@@ -72,4 +72,9 @@ dependencies {
|
|||||||
implementation 'com.google.firebase:firebase-auth'
|
implementation 'com.google.firebase:firebase-auth'
|
||||||
implementation 'com.google.firebase:firebase-firestore'
|
implementation 'com.google.firebase:firebase-firestore'
|
||||||
implementation 'com.google.firebase:firebase-database'
|
implementation 'com.google.firebase:firebase-database'
|
||||||
|
implementation 'com.google.firebase:firebase-storage'
|
||||||
|
|
||||||
|
// Glide
|
||||||
|
implementation 'com.github.bumptech.glide:glide:4.12.0'
|
||||||
|
annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,6 +59,18 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
if (navHostFragment != null) {
|
if (navHostFragment != null) {
|
||||||
NavController navController = navHostFragment.getNavController();
|
NavController navController = navHostFragment.getNavController();
|
||||||
NavigationUI.setupWithNavController(binding.navView, navController);
|
NavigationUI.setupWithNavController(binding.navView, navController);
|
||||||
|
|
||||||
|
// Força o clique no Perfil com Transação Manual (Infalível)
|
||||||
|
binding.navView.setOnItemSelectedListener(item -> {
|
||||||
|
if (item.getItemId() == R.id.navigation_profile) {
|
||||||
|
getSupportFragmentManager().beginTransaction()
|
||||||
|
.replace(R.id.nav_host_fragment, new com.example.cuida.ui.profile.ProfileFragment())
|
||||||
|
.addToBackStack(null)
|
||||||
|
.commit();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return NavigationUI.onNavDestinationSelected(item, navController);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import androidx.fragment.app.Fragment;
|
|||||||
import androidx.lifecycle.ViewModelProvider;
|
import androidx.lifecycle.ViewModelProvider;
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
|
|
||||||
|
import com.example.cuida.R;
|
||||||
import com.example.cuida.databinding.FragmentHomeBinding;
|
import com.example.cuida.databinding.FragmentHomeBinding;
|
||||||
import com.example.cuida.ui.medication.MedicationViewModel;
|
import com.example.cuida.ui.medication.MedicationViewModel;
|
||||||
import com.example.cuida.ui.medication.MedicationAdapter;
|
import com.example.cuida.ui.medication.MedicationAdapter;
|
||||||
@@ -16,7 +17,7 @@ import com.example.cuida.ui.appointments.AppointmentsViewModel;
|
|||||||
import com.example.cuida.ui.appointments.AppointmentAdapter;
|
import com.example.cuida.ui.appointments.AppointmentAdapter;
|
||||||
import com.example.cuida.data.model.Appointment;
|
import com.example.cuida.data.model.Appointment;
|
||||||
import com.example.cuida.data.model.Medication;
|
import com.example.cuida.data.model.Medication;
|
||||||
|
import com.bumptech.glide.Glide;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
||||||
public class HomeFragment extends Fragment {
|
public class HomeFragment extends Fragment {
|
||||||
@@ -45,27 +46,42 @@ public class HomeFragment extends Fragment {
|
|||||||
|
|
||||||
if (name != null && !name.isEmpty()) {
|
if (name != null && !name.isEmpty()) {
|
||||||
String firstName = name.split(" ")[0];
|
String firstName = name.split(" ")[0];
|
||||||
binding.textGreeting.setText("Olá, " + firstName + "!");
|
binding.textGreeting.setText("Olá, " + firstName);
|
||||||
} else {
|
} else {
|
||||||
binding.textGreeting.setText("Olá, Utilizador!");
|
binding.textGreeting.setText("Olá");
|
||||||
}
|
}
|
||||||
|
|
||||||
String profilePictureUri = documentSnapshot.getString("profilePictureUri");
|
String profilePictureUri = documentSnapshot.getString("profilePictureUri");
|
||||||
if (profilePictureUri != null && !profilePictureUri.isEmpty()) {
|
if (isAdded() && binding.imageProfileHome != null) {
|
||||||
try {
|
binding.imageProfileHome.setVisibility(View.VISIBLE);
|
||||||
binding.imageProfileHome.setImageURI(android.net.Uri.parse(profilePictureUri));
|
if (profilePictureUri != null && !profilePictureUri.isEmpty() && getContext() != null) {
|
||||||
} catch (Exception e) {
|
Glide.with(getContext())
|
||||||
android.util.Log.e("HomeFragment", "Error loading profile pic view: " + e.getMessage());
|
.load(profilePictureUri)
|
||||||
|
.placeholder(R.drawable.ic_user)
|
||||||
|
.circleCrop()
|
||||||
|
.into(binding.imageProfileHome);
|
||||||
|
} else {
|
||||||
|
binding.imageProfileHome.setImageResource(R.drawable.ic_user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Clique para entrar no perfil (Manual e Infalível)
|
||||||
|
binding.imageProfileHome.setOnClickListener(v -> {
|
||||||
|
if (getActivity() != null) {
|
||||||
|
getActivity().getSupportFragmentManager().beginTransaction()
|
||||||
|
.replace(R.id.nav_host_fragment, new com.example.cuida.ui.profile.ProfileFragment())
|
||||||
|
.addToBackStack(null)
|
||||||
|
.commit();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.addOnFailureListener(e -> {
|
.addOnFailureListener(e -> {
|
||||||
if (isAdded())
|
if (isAdded())
|
||||||
binding.textGreeting.setText("Olá, Utilizador!");
|
binding.textGreeting.setText("Olá");
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
binding.textGreeting.setText("Olá, Utilizador!");
|
binding.textGreeting.setText("Olá");
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- Setup Adapters ---
|
// --- Setup Adapters ---
|
||||||
|
|||||||
@@ -11,51 +11,63 @@ import android.view.View;
|
|||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import androidx.activity.result.ActivityResultLauncher;
|
||||||
|
import androidx.activity.result.contract.ActivityResultContracts;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
|
import com.bumptech.glide.Glide;
|
||||||
import com.example.cuida.R;
|
import com.example.cuida.R;
|
||||||
import com.example.cuida.data.model.User;
|
|
||||||
import com.example.cuida.databinding.FragmentProfileBinding;
|
import com.example.cuida.databinding.FragmentProfileBinding;
|
||||||
|
import com.example.cuida.data.model.User;
|
||||||
import com.example.cuida.ui.auth.LoginActivity;
|
import com.example.cuida.ui.auth.LoginActivity;
|
||||||
import com.google.firebase.auth.FirebaseAuth;
|
import com.google.firebase.auth.FirebaseAuth;
|
||||||
import com.google.firebase.firestore.FirebaseFirestore;
|
import com.google.firebase.firestore.FirebaseFirestore;
|
||||||
|
import com.google.firebase.storage.FirebaseStorage;
|
||||||
|
import com.google.firebase.storage.StorageReference;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class ProfileFragment extends Fragment {
|
public class ProfileFragment extends Fragment {
|
||||||
|
|
||||||
private FragmentProfileBinding binding;
|
private FragmentProfileBinding binding;
|
||||||
private User currentUser;
|
|
||||||
private FirebaseFirestore db;
|
|
||||||
private FirebaseAuth auth;
|
private FirebaseAuth auth;
|
||||||
private Uri tempProfileUri;
|
private FirebaseFirestore db;
|
||||||
private ImageView dialogImageView;
|
private FirebaseStorage storage;
|
||||||
|
private User currentUser;
|
||||||
|
private String userId;
|
||||||
|
|
||||||
private final androidx.activity.result.ActivityResultLauncher<String> pickMedia = registerForActivityResult(
|
private ImageView dialogImageView;
|
||||||
new androidx.activity.result.contract.ActivityResultContracts.GetContent(), uri -> {
|
private Uri tempProfileUri;
|
||||||
if (uri != null) {
|
|
||||||
|
private final ActivityResultLauncher<String> pickMedia = registerForActivityResult(
|
||||||
|
new ActivityResultContracts.GetContent(), uri -> {
|
||||||
|
if (uri != null && dialogImageView != null) {
|
||||||
tempProfileUri = uri;
|
tempProfileUri = uri;
|
||||||
try {
|
dialogImageView.setImageURI(uri);
|
||||||
requireContext().getContentResolver().takePersistableUriPermission(uri,
|
|
||||||
Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
|
||||||
} catch (Exception e) {
|
|
||||||
Log.e("ProfileFragment", "Permission error: " + e.getMessage());
|
|
||||||
}
|
|
||||||
if (dialogImageView != null) {
|
|
||||||
dialogImageView.setImageURI(uri);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
binding = FragmentProfileBinding.inflate(inflater, container, false);
|
try {
|
||||||
|
binding = FragmentProfileBinding.inflate(inflater, container, false);
|
||||||
|
View root = binding.getRoot();
|
||||||
|
|
||||||
db = FirebaseFirestore.getInstance();
|
|
||||||
auth = FirebaseAuth.getInstance();
|
auth = FirebaseAuth.getInstance();
|
||||||
loadUserData();
|
db = FirebaseFirestore.getInstance();
|
||||||
|
storage = FirebaseStorage.getInstance();
|
||||||
|
|
||||||
|
if (auth.getCurrentUser() != null) {
|
||||||
|
userId = auth.getCurrentUser().getUid();
|
||||||
|
loadUserData();
|
||||||
|
}
|
||||||
|
|
||||||
binding.buttonEditProfile.setOnClickListener(v -> showEditDialog());
|
binding.buttonEditProfile.setOnClickListener(v -> showEditDialog());
|
||||||
|
|
||||||
binding.buttonLogout.setOnClickListener(v -> {
|
binding.buttonLogout.setOnClickListener(v -> {
|
||||||
auth.signOut();
|
auth.signOut();
|
||||||
if (getContext() != null) {
|
if (getContext() != null) {
|
||||||
@@ -65,91 +77,100 @@ public class ProfileFragment extends Fragment {
|
|||||||
requireActivity().finish();
|
requireActivity().finish();
|
||||||
});
|
});
|
||||||
|
|
||||||
return binding.getRoot();
|
return root;
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.e("ProfileFragment", "Erro ao inflar perfil", e);
|
||||||
|
return inflater.inflate(R.layout.fragment_profile, container, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadUserData() {
|
private void loadUserData() {
|
||||||
if (auth.getCurrentUser() == null) return;
|
|
||||||
String userId = auth.getCurrentUser().getUid();
|
|
||||||
|
|
||||||
if (currentUser == null) {
|
|
||||||
currentUser = new User();
|
|
||||||
currentUser.id = userId;
|
|
||||||
currentUser.email = auth.getCurrentUser().getEmail();
|
|
||||||
currentUser.name = auth.getCurrentUser().getDisplayName();
|
|
||||||
}
|
|
||||||
|
|
||||||
db.collection("utilizadores").document(userId)
|
|
||||||
.addSnapshotListener((doc, error) -> {
|
|
||||||
if (error != null) {
|
|
||||||
Log.e("ProfileFragment", "Listen failed.", error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (doc != null && doc.exists() && isAdded()) {
|
|
||||||
currentUser.id = doc.getId();
|
|
||||||
String nome = doc.getString("nome_completo");
|
|
||||||
if (nome == null) nome = doc.getString("name");
|
|
||||||
currentUser.name = nome;
|
|
||||||
currentUser.email = doc.getString("email");
|
|
||||||
|
|
||||||
String utente = doc.getString("numero_utente");
|
|
||||||
if (utente == null) utente = doc.getString("utenteNumber");
|
|
||||||
currentUser.utenteNumber = utente;
|
|
||||||
|
|
||||||
currentUser.profilePictureUri = doc.getString("profilePictureUri");
|
|
||||||
|
|
||||||
Object ageObj = doc.get("idade");
|
|
||||||
if (ageObj == null) ageObj = doc.get("age");
|
|
||||||
if (ageObj instanceof Number) currentUser.age = ((Number) ageObj).intValue();
|
|
||||||
else if (ageObj instanceof String) {
|
|
||||||
try { currentUser.age = Integer.parseInt((String) ageObj); }
|
|
||||||
catch (Exception e) { currentUser.age = 0; }
|
|
||||||
}
|
|
||||||
|
|
||||||
updateUI();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateUI() {
|
|
||||||
if (!isAdded() || binding == null || currentUser == null) return;
|
|
||||||
binding.profileName.setText(currentUser.name != null ? currentUser.name : "N/D");
|
|
||||||
binding.profileEmail.setText(currentUser.email != null ? currentUser.email : "N/D");
|
|
||||||
binding.profileAge.setText(currentUser.age > 0 ? String.valueOf(currentUser.age) : "N/D");
|
|
||||||
binding.profileUtente.setText(currentUser.utenteNumber != null ? currentUser.utenteNumber : "N/D");
|
|
||||||
|
|
||||||
if (currentUser.profilePictureUri != null && !currentUser.profilePictureUri.isEmpty()) {
|
|
||||||
ImageView profileImage = binding.getRoot().findViewById(R.id.profile_image);
|
|
||||||
if (profileImage != null) loadSafeImage(profileImage, currentUser.profilePictureUri);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void loadSafeImage(ImageView view, String uriStr) {
|
|
||||||
if (view == null || uriStr == null) return;
|
|
||||||
try {
|
try {
|
||||||
Uri uri = Uri.parse(uriStr);
|
if (userId == null || !isAdded()) return;
|
||||||
if (uri.getScheme() != null && (uri.getScheme().equals("content") || uri.getScheme().equals("file"))) {
|
|
||||||
view.setImageURI(uri);
|
// Primeiro tenta na coleção geral 'utilizadores'
|
||||||
} else {
|
db.collection("utilizadores").document(userId).addSnapshotListener((doc, error) -> {
|
||||||
Log.d("ProfileFragment", "Skipping setImageURI for non-local scheme: " + uri.getScheme());
|
try {
|
||||||
}
|
if (doc != null && doc.exists()) {
|
||||||
|
updateUIFromDocument(doc);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Independentemente de encontrar em 'utilizadores', tenta TAMBÉM em 'Pacientes' para completar dados
|
||||||
|
db.collection("Pacientes").document(userId).get().addOnSuccessListener(docP -> {
|
||||||
|
if (docP.exists()) {
|
||||||
|
updateUIFromDocument(docP);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.e("ProfileFragment", "Erro no carregamento", e);
|
||||||
|
}
|
||||||
|
});
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e("ProfileFragment", "Image load error: " + e.getMessage());
|
Log.e("ProfileFragment", "Erro ao iniciar", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateUIFromDocument(com.google.firebase.firestore.DocumentSnapshot doc) {
|
||||||
|
if (!isAdded() || binding == null) return;
|
||||||
|
|
||||||
|
// Nome
|
||||||
|
String n = doc.getString("nome_completo");
|
||||||
|
if (n == null) n = doc.getString("name");
|
||||||
|
if (n == null) n = doc.getString("nome");
|
||||||
|
if (n != null && !n.isEmpty()) binding.profileName.setText(n);
|
||||||
|
|
||||||
|
// Email
|
||||||
|
String e = doc.getString("email");
|
||||||
|
if (e != null && !e.isEmpty()) binding.profileEmail.setText(e);
|
||||||
|
|
||||||
|
// Idade
|
||||||
|
Long i = doc.getLong("idade");
|
||||||
|
if (i != null) binding.profileAge.setText(String.valueOf(i));
|
||||||
|
|
||||||
|
// Nº Utente
|
||||||
|
String u = doc.getString("numero_utente");
|
||||||
|
if (u == null) u = doc.getString("utenteNumber");
|
||||||
|
if (u != null && !u.isEmpty()) binding.profileUtente.setText(u);
|
||||||
|
|
||||||
|
// Foto
|
||||||
|
String p = doc.getString("profilePictureUri");
|
||||||
|
if (p != null && !p.isEmpty()) {
|
||||||
|
loadSafeImage(binding.profileImage, p);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Atualiza objeto local para o EditDialog
|
||||||
|
if (currentUser == null) currentUser = new User();
|
||||||
|
if (n != null) currentUser.name = n;
|
||||||
|
if (e != null) currentUser.email = e;
|
||||||
|
if (i != null) currentUser.age = i.intValue();
|
||||||
|
if (u != null) currentUser.utenteNumber = u;
|
||||||
|
if (p != null) currentUser.profilePictureUri = p;
|
||||||
|
currentUser.id = doc.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadSafeImage(ImageView view, String url) {
|
||||||
|
try {
|
||||||
|
if (!isAdded() || view == null || getContext() == null) return;
|
||||||
|
Glide.with(getContext())
|
||||||
|
.load(url)
|
||||||
|
.placeholder(R.drawable.ic_user)
|
||||||
|
.circleCrop()
|
||||||
|
.into(view);
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.e("ProfileFragment", "Erro ao carregar imagem", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showEditDialog() {
|
private void showEditDialog() {
|
||||||
if (currentUser == null) {
|
if (!isAdded()) return;
|
||||||
Toast.makeText(getContext(), "Dados não carregados.", Toast.LENGTH_SHORT).show();
|
if (currentUser == null) currentUser = new User();
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
AlertDialog.Builder builder = new AlertDialog.Builder(requireContext(), R.style.CustomDialogTheme);
|
||||||
View dialogView = requireActivity().getLayoutInflater().inflate(R.layout.dialog_edit_profile, null);
|
View dialogView = requireActivity().getLayoutInflater().inflate(R.layout.dialog_edit_profile, null);
|
||||||
builder.setView(dialogView);
|
builder.setView(dialogView);
|
||||||
AlertDialog dialog = builder.create();
|
AlertDialog dialog = builder.create();
|
||||||
|
if (dialog.getWindow() != null) dialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
|
||||||
|
|
||||||
EditText editName = dialogView.findViewById(R.id.edit_name);
|
EditText editName = dialogView.findViewById(R.id.edit_name);
|
||||||
EditText editAge = dialogView.findViewById(R.id.edit_age);
|
EditText editAge = dialogView.findViewById(R.id.edit_age);
|
||||||
@@ -157,78 +178,91 @@ public class ProfileFragment extends Fragment {
|
|||||||
EditText editEmail = dialogView.findViewById(R.id.edit_email);
|
EditText editEmail = dialogView.findViewById(R.id.edit_email);
|
||||||
dialogImageView = dialogView.findViewById(R.id.edit_profile_image);
|
dialogImageView = dialogView.findViewById(R.id.edit_profile_image);
|
||||||
|
|
||||||
if (editName == null || dialogImageView == null) return;
|
// Preenchimento Seguro
|
||||||
|
if (editName != null) editName.setText(currentUser.name);
|
||||||
editName.setText(currentUser.name);
|
if (editAge != null) editAge.setText(String.valueOf(currentUser.age));
|
||||||
editAge.setText(String.valueOf(currentUser.age));
|
if (editUtente != null) editUtente.setText(currentUser.utenteNumber);
|
||||||
editUtente.setText(currentUser.utenteNumber);
|
if (editEmail != null) editEmail.setText(currentUser.email);
|
||||||
editEmail.setText(currentUser.email);
|
if (dialogImageView != null && currentUser.profilePictureUri != null) {
|
||||||
|
loadSafeImage(dialogImageView, currentUser.profilePictureUri);
|
||||||
if (currentUser.profilePictureUri != null) loadSafeImage(dialogImageView, currentUser.profilePictureUri);
|
|
||||||
|
|
||||||
dialogView.findViewById(R.id.button_change_photo).setOnClickListener(v -> pickMedia.launch("image/*"));
|
|
||||||
dialogImageView.setOnClickListener(v -> pickMedia.launch("image/*"));
|
|
||||||
dialogView.findViewById(R.id.button_change_password).setOnClickListener(v -> showChangePasswordDialog());
|
|
||||||
|
|
||||||
dialogView.findViewById(R.id.button_cancel).setOnClickListener(v -> dialog.dismiss());
|
|
||||||
dialogView.findViewById(R.id.button_save).setOnClickListener(v -> {
|
|
||||||
String newName = editName.getText().toString().trim();
|
|
||||||
String ageStr = editAge.getText().toString().trim();
|
|
||||||
String newUtente = editUtente.getText().toString().trim();
|
|
||||||
String newEmail = editEmail.getText().toString().trim();
|
|
||||||
|
|
||||||
if (newName.isEmpty() || ageStr.isEmpty() || newUtente.isEmpty() || newEmail.isEmpty()) {
|
|
||||||
Toast.makeText(getContext(), "Preencha todos os campos.", Toast.LENGTH_SHORT).show();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
currentUser.name = newName;
|
|
||||||
try { currentUser.age = Integer.parseInt(ageStr); } catch (Exception ignored) {}
|
|
||||||
currentUser.utenteNumber = newUtente;
|
|
||||||
|
|
||||||
if (tempProfileUri != null) currentUser.profilePictureUri = tempProfileUri.toString();
|
|
||||||
|
|
||||||
db.collection("utilizadores").document(currentUser.id).set(currentUser)
|
|
||||||
.addOnSuccessListener(aVoid -> {
|
|
||||||
Toast.makeText(getContext(), "Perfil atualizado!", Toast.LENGTH_SHORT).show();
|
|
||||||
loadUserData();
|
|
||||||
dialog.dismiss();
|
|
||||||
})
|
|
||||||
.addOnFailureListener(e -> Toast.makeText(getContext(), "Erro ao guardar.", Toast.LENGTH_SHORT).show());
|
|
||||||
});
|
|
||||||
|
|
||||||
dialog.show();
|
|
||||||
} catch (Exception e) {
|
|
||||||
Toast.makeText(getContext(), "Erro ao abrir edição.", Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void showChangePasswordDialog() {
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
|
||||||
View view = requireActivity().getLayoutInflater().inflate(R.layout.dialog_change_password, null);
|
|
||||||
builder.setView(view);
|
|
||||||
AlertDialog dialog = builder.create();
|
|
||||||
|
|
||||||
EditText editNewPassword = view.findViewById(R.id.new_password);
|
|
||||||
view.findViewById(R.id.button_save_password).setOnClickListener(v -> {
|
|
||||||
String newPass = editNewPassword.getText().toString();
|
|
||||||
if (newPass.length() < 6) {
|
|
||||||
Toast.makeText(getContext(), "Mínimo 6 caracteres.", Toast.LENGTH_SHORT).show();
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if (auth.getCurrentUser() != null) {
|
|
||||||
auth.getCurrentUser().updatePassword(newPass).addOnCompleteListener(task -> {
|
// Listeners
|
||||||
if (task.isSuccessful()) {
|
View btnPhoto = dialogView.findViewById(R.id.button_change_photo);
|
||||||
Toast.makeText(getContext(), "Sucesso!", Toast.LENGTH_SHORT).show();
|
if (btnPhoto != null) btnPhoto.setOnClickListener(v -> pickMedia.launch("image/*"));
|
||||||
dialog.dismiss();
|
if (dialogImageView != null) dialogImageView.setOnClickListener(v -> pickMedia.launch("image/*"));
|
||||||
|
|
||||||
|
View btnPass = dialogView.findViewById(R.id.button_change_password);
|
||||||
|
if (btnPass != null) btnPass.setOnClickListener(v -> showChangePasswordDialog());
|
||||||
|
|
||||||
|
View btnCancel = dialogView.findViewById(R.id.button_cancel);
|
||||||
|
if (btnCancel != null) btnCancel.setOnClickListener(v -> dialog.dismiss());
|
||||||
|
|
||||||
|
View btnSave = dialogView.findViewById(R.id.button_save);
|
||||||
|
if (btnSave != null) {
|
||||||
|
btnSave.setOnClickListener(v -> {
|
||||||
|
btnSave.setEnabled(false);
|
||||||
|
if (tempProfileUri != null) {
|
||||||
|
uploadPhotoAndSave(editName.getText().toString(), editAge.getText().toString(), editUtente.getText().toString(), editEmail.getText().toString(), dialog);
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(getContext(), "Erro: " + task.getException().getMessage(), Toast.LENGTH_LONG).show();
|
saveDataToFirestore(editName.getText().toString(), editAge.getText().toString(), editUtente.getText().toString(), editEmail.getText().toString(), currentUser.profilePictureUri, dialog);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
view.findViewById(R.id.button_cancel_password).setOnClickListener(v -> dialog.dismiss());
|
dialog.show();
|
||||||
dialog.show();
|
} catch (Throwable t) {
|
||||||
|
Toast.makeText(getContext(), "Erro: " + t.toString(), Toast.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void uploadPhotoAndSave(String n, String a, String u, String e, AlertDialog d) {
|
||||||
|
StorageReference ref = storage.getReference().child("perfil_pacientes/" + userId + ".jpg");
|
||||||
|
ref.putFile(tempProfileUri).addOnSuccessListener(task -> {
|
||||||
|
ref.getDownloadUrl().addOnSuccessListener(uri -> saveDataToFirestore(n, a, u, e, uri.toString(), d));
|
||||||
|
}).addOnFailureListener(err -> {
|
||||||
|
Toast.makeText(getContext(), "Erro foto", Toast.LENGTH_SHORT).show();
|
||||||
|
saveDataToFirestore(n, a, u, e, currentUser.profilePictureUri, d);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void saveDataToFirestore(String name, String age, String utente, String email, String photo, AlertDialog d) {
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
map.put("nome_completo", name);
|
||||||
|
map.put("email", email);
|
||||||
|
try { map.put("idade", Integer.parseInt(age)); } catch (Exception ignored) {
|
||||||
|
map.put("idade", 0);
|
||||||
|
}
|
||||||
|
map.put("numero_utente", utente);
|
||||||
|
map.put("tipo", "paciente");
|
||||||
|
if (photo != null) map.put("profilePictureUri", photo);
|
||||||
|
|
||||||
|
com.google.firebase.firestore.WriteBatch batch = db.batch();
|
||||||
|
batch.set(db.collection("utilizadores").document(userId), map, com.google.firebase.firestore.SetOptions.merge());
|
||||||
|
batch.set(db.collection("Pacientes").document(userId), map, com.google.firebase.firestore.SetOptions.merge());
|
||||||
|
|
||||||
|
batch.commit().addOnSuccessListener(aVoid -> {
|
||||||
|
if (isAdded()) {
|
||||||
|
Toast.makeText(getContext(), "Perfil Atualizado com Sucesso!", Toast.LENGTH_SHORT).show();
|
||||||
|
loadUserData();
|
||||||
|
d.dismiss();
|
||||||
|
tempProfileUri = null;
|
||||||
|
}
|
||||||
|
}).addOnFailureListener(e -> {
|
||||||
|
if (isAdded()) {
|
||||||
|
Toast.makeText(getContext(), "Erro ao guardar no Firebase", Toast.LENGTH_SHORT).show();
|
||||||
|
d.dismiss();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showChangePasswordDialog() {
|
||||||
|
Toast.makeText(getContext(), "Funcionalidade de Password em breve.", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroyView() {
|
||||||
|
super.onDestroyView();
|
||||||
|
binding = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,128 +1,194 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content"
|
||||||
|
app:cardCornerRadius="28dp"
|
||||||
|
app:cardElevation="0dp"
|
||||||
|
android:layout_margin="12dp">
|
||||||
|
|
||||||
<LinearLayout
|
<androidx.core.widget.NestedScrollView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content">
|
||||||
android:orientation="vertical"
|
|
||||||
android:padding="24dp">
|
|
||||||
|
|
||||||
<com.google.android.material.imageview.ShapeableImageView
|
|
||||||
android:id="@+id/edit_profile_image"
|
|
||||||
android:layout_width="100dp"
|
|
||||||
android:layout_height="100dp"
|
|
||||||
android:src="@drawable/ic_placeholder"
|
|
||||||
android:layout_gravity="center_horizontal"
|
|
||||||
android:layout_marginBottom="8dp"
|
|
||||||
android:scaleType="centerCrop"
|
|
||||||
app:shapeAppearanceOverlay="@style/ShapeAppearanceOverlay.App.CornerSize50Percent"
|
|
||||||
android:clickable="true"
|
|
||||||
android:focusable="true"/>
|
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
|
||||||
android:id="@+id/button_change_photo"
|
|
||||||
style="@style/Widget.MaterialComponents.Button.TextButton"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center_horizontal"
|
|
||||||
android:text="Mudar Foto"
|
|
||||||
android:layout_marginBottom="16dp"/>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="Editar Dados"
|
|
||||||
android:textSize="20sp"
|
|
||||||
android:textStyle="bold"
|
|
||||||
android:layout_gravity="center_horizontal"
|
|
||||||
android:layout_marginBottom="24dp"/>
|
|
||||||
|
|
||||||
<com.google.android.material.textfield.TextInputLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginBottom="16dp">
|
|
||||||
|
|
||||||
<com.google.android.material.textfield.TextInputEditText
|
|
||||||
android:id="@+id/edit_name"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:hint="Nome"
|
|
||||||
android:inputType="textPersonName" />
|
|
||||||
</com.google.android.material.textfield.TextInputLayout>
|
|
||||||
|
|
||||||
<com.google.android.material.textfield.TextInputLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginBottom="16dp">
|
|
||||||
|
|
||||||
<com.google.android.material.textfield.TextInputEditText
|
|
||||||
android:id="@+id/edit_age"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:hint="Idade"
|
|
||||||
android:maxLength="3"
|
|
||||||
android:inputType="number" />
|
|
||||||
</com.google.android.material.textfield.TextInputLayout>
|
|
||||||
|
|
||||||
<com.google.android.material.textfield.TextInputLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginBottom="16dp">
|
|
||||||
|
|
||||||
<com.google.android.material.textfield.TextInputEditText
|
|
||||||
android:id="@+id/edit_utente"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:hint="Nº Utente"
|
|
||||||
android:maxLength="9"
|
|
||||||
android:inputType="number" />
|
|
||||||
</com.google.android.material.textfield.TextInputLayout>
|
|
||||||
|
|
||||||
<com.google.android.material.textfield.TextInputLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginBottom="24dp">
|
|
||||||
|
|
||||||
<com.google.android.material.textfield.TextInputEditText
|
|
||||||
android:id="@+id/edit_email"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:hint="Email"
|
|
||||||
android:inputType="textEmailAddress" />
|
|
||||||
</com.google.android.material.textfield.TextInputLayout>
|
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
|
||||||
android:id="@+id/button_change_password"
|
|
||||||
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center_horizontal"
|
|
||||||
android:text="Alterar Palavra-passe"
|
|
||||||
android:layout_marginBottom="24dp"/>
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal"
|
android:orientation="vertical"
|
||||||
android:gravity="end">
|
android:padding="24dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Editar Perfil"
|
||||||
|
android:textSize="22sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:textColor="?attr/colorPrimary"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
|
android:layout_marginBottom="24dp"/>
|
||||||
|
|
||||||
|
<!-- Photo Section -->
|
||||||
|
<FrameLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
|
android:layout_marginBottom="24dp">
|
||||||
|
|
||||||
|
<com.google.android.material.imageview.ShapeableImageView
|
||||||
|
android:id="@+id/edit_profile_image"
|
||||||
|
android:layout_width="110dp"
|
||||||
|
android:layout_height="110dp"
|
||||||
|
android:padding="4dp"
|
||||||
|
app:strokeWidth="2dp"
|
||||||
|
app:strokeColor="?attr/colorPrimary"
|
||||||
|
android:src="@drawable/ic_user"
|
||||||
|
android:scaleType="centerCrop"
|
||||||
|
app:shapeAppearanceOverlay="@style/CircleImageView" />
|
||||||
|
|
||||||
|
<com.google.android.material.button.MaterialButton
|
||||||
|
android:id="@+id/button_change_photo"
|
||||||
|
style="@style/Widget.MaterialComponents.Button.Icon"
|
||||||
|
android:layout_width="36dp"
|
||||||
|
android:layout_height="36dp"
|
||||||
|
android:layout_gravity="bottom|end"
|
||||||
|
android:padding="8dp"
|
||||||
|
app:icon="@drawable/ic_camera"
|
||||||
|
app:iconSize="20dp"
|
||||||
|
app:iconGravity="textStart"
|
||||||
|
app:iconPadding="0dp"
|
||||||
|
app:cornerRadius="18dp"
|
||||||
|
android:insetLeft="0dp"
|
||||||
|
android:insetTop="0dp"
|
||||||
|
android:insetRight="0dp"
|
||||||
|
android:insetBottom="0dp"
|
||||||
|
app:backgroundTint="?attr/colorPrimary"/>
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
|
<!-- Inputs -->
|
||||||
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
|
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="12dp"
|
||||||
|
android:hint="Nome Completo"
|
||||||
|
app:startIconDrawable="@drawable/ic_user"
|
||||||
|
app:boxCornerRadiusBottomEnd="16dp"
|
||||||
|
app:boxCornerRadiusBottomStart="16dp"
|
||||||
|
app:boxCornerRadiusTopEnd="16dp"
|
||||||
|
app:boxCornerRadiusTopStart="16dp">
|
||||||
|
|
||||||
|
<com.google.android.material.textfield.TextInputEditText
|
||||||
|
android:id="@+id/edit_name"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:inputType="textPersonName" />
|
||||||
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_marginBottom="12dp">
|
||||||
|
|
||||||
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
|
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_marginEnd="6dp"
|
||||||
|
android:hint="Idade"
|
||||||
|
app:boxCornerRadiusBottomEnd="16dp"
|
||||||
|
app:boxCornerRadiusBottomStart="16dp"
|
||||||
|
app:boxCornerRadiusTopEnd="16dp"
|
||||||
|
app:boxCornerRadiusTopStart="16dp">
|
||||||
|
|
||||||
|
<com.google.android.material.textfield.TextInputEditText
|
||||||
|
android:id="@+id/edit_age"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:inputType="number" />
|
||||||
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
|
||||||
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
|
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="2"
|
||||||
|
android:layout_marginStart="6dp"
|
||||||
|
android:hint="Nº Utente"
|
||||||
|
app:boxCornerRadiusBottomEnd="16dp"
|
||||||
|
app:boxCornerRadiusBottomStart="16dp"
|
||||||
|
app:boxCornerRadiusTopEnd="16dp"
|
||||||
|
app:boxCornerRadiusTopStart="16dp">
|
||||||
|
|
||||||
|
<com.google.android.material.textfield.TextInputEditText
|
||||||
|
android:id="@+id/edit_utente"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:inputType="number" />
|
||||||
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
|
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="20dp"
|
||||||
|
android:hint="Email"
|
||||||
|
app:startIconDrawable="@drawable/ic_user"
|
||||||
|
app:boxCornerRadiusBottomEnd="16dp"
|
||||||
|
app:boxCornerRadiusBottomStart="16dp"
|
||||||
|
app:boxCornerRadiusTopEnd="16dp"
|
||||||
|
app:boxCornerRadiusTopStart="16dp">
|
||||||
|
|
||||||
|
<com.google.android.material.textfield.TextInputEditText
|
||||||
|
android:id="@+id/edit_email"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:inputType="textEmailAddress" />
|
||||||
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
<com.google.android.material.button.MaterialButton
|
||||||
android:id="@+id/button_cancel"
|
android:id="@+id/button_change_password"
|
||||||
style="@style/Widget.MaterialComponents.Button.TextButton"
|
style="@style/Widget.MaterialComponents.Button.TextButton"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Cancelar"
|
android:text="Alterar Palavra-passe"
|
||||||
android:layout_marginEnd="8dp"/>
|
android:textAllCaps="false"
|
||||||
|
android:textColor="?attr/colorPrimary"
|
||||||
|
android:layout_marginBottom="24dp"/>
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
<!-- Action Buttons -->
|
||||||
android:id="@+id/button_save"
|
<LinearLayout
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Salvar" />
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<com.google.android.material.button.MaterialButton
|
||||||
|
android:id="@+id/button_cancel"
|
||||||
|
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="56dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="Cancelar"
|
||||||
|
android:textAllCaps="false"
|
||||||
|
android:layout_marginEnd="8dp"
|
||||||
|
app:cornerRadius="16dp"
|
||||||
|
app:strokeColor="?attr/colorPrimary"
|
||||||
|
android:textColor="?attr/colorPrimary"/>
|
||||||
|
|
||||||
|
<com.google.android.material.button.MaterialButton
|
||||||
|
android:id="@+id/button_save"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="56dp"
|
||||||
|
android:layout_weight="1.5"
|
||||||
|
android:text="Salvar Dados"
|
||||||
|
android:textAllCaps="false"
|
||||||
|
android:textStyle="bold"
|
||||||
|
app:cornerRadius="16dp"
|
||||||
|
android:layout_marginStart="8dp"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
</androidx.core.widget.NestedScrollView>
|
||||||
</LinearLayout>
|
</com.google.android.material.card.MaterialCardView>
|
||||||
</ScrollView>
|
|
||||||
|
|||||||
@@ -6,51 +6,51 @@
|
|||||||
android:background="@color/background_color">
|
android:background="@color/background_color">
|
||||||
|
|
||||||
<!-- Header / Top Bar area -->
|
<!-- Header / Top Bar area -->
|
||||||
<View
|
<LinearLayout
|
||||||
android:id="@+id/header_bg"
|
android:id="@+id/header_bg"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="160dp"
|
|
||||||
android:background="@color/primary_color"
|
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
|
||||||
|
|
||||||
<com.google.android.material.imageview.ShapeableImageView
|
|
||||||
android:id="@+id/image_profile_home"
|
|
||||||
android:layout_width="64dp"
|
|
||||||
android:layout_height="64dp"
|
|
||||||
android:layout_marginStart="24dp"
|
|
||||||
android:layout_marginTop="48dp"
|
|
||||||
android:scaleType="centerCrop"
|
|
||||||
android:src="@drawable/ic_placeholder"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
|
||||||
app:shapeAppearanceOverlay="@style/ShapeAppearanceOverlay.App.CornerSize50Percent"
|
|
||||||
app:strokeWidth="2dp"
|
|
||||||
app:strokeColor="@color/white" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/text_greeting"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="16dp"
|
android:orientation="horizontal"
|
||||||
android:layout_marginEnd="24dp"
|
android:paddingTop="56dp"
|
||||||
android:text="Olá, utilizador!"
|
android:paddingBottom="40dp"
|
||||||
android:textColor="@color/white"
|
android:paddingHorizontal="28dp"
|
||||||
android:textSize="26sp"
|
android:background="@drawable/bg_gradient_header"
|
||||||
android:textStyle="bold"
|
android:elevation="12dp"
|
||||||
app:layout_constraintBottom_toBottomOf="@id/image_profile_home"
|
app:layout_constraintTop_toTopOf="parent">
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toEndOf="@id/image_profile_home"
|
<TextView
|
||||||
app:layout_constraintTop_toTopOf="@id/image_profile_home" />
|
android:id="@+id/text_greeting"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="Olá"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
android:textSize="38sp"
|
||||||
|
android:fontFamily="sans-serif-black"
|
||||||
|
android:gravity="center_vertical" />
|
||||||
|
|
||||||
|
<com.google.android.material.imageview.ShapeableImageView
|
||||||
|
android:id="@+id/image_profile_home"
|
||||||
|
android:layout_width="64dp"
|
||||||
|
android:layout_height="64dp"
|
||||||
|
android:layout_marginStart="16dp"
|
||||||
|
android:scaleType="centerCrop"
|
||||||
|
android:src="@drawable/ic_placeholder"
|
||||||
|
app:shapeAppearanceOverlay="@style/ShapeAppearanceOverlay.App.CornerSize50Percent"
|
||||||
|
app:strokeWidth="2dp"
|
||||||
|
app:strokeColor="@color/white"
|
||||||
|
android:visibility="gone" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<androidx.core.widget.NestedScrollView
|
<androidx.core.widget.NestedScrollView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_marginTop="24dp"
|
android:layout_marginTop="16dp"
|
||||||
android:fillViewport="true"
|
android:fillViewport="true"
|
||||||
android:clipToPadding="false"
|
android:clipToPadding="false"
|
||||||
android:paddingBottom="40dp"
|
android:paddingBottom="40dp"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/image_profile_home">
|
app:layout_constraintTop_toBottomOf="@id/header_bg">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:padding="24dp"
|
android:padding="24dp"
|
||||||
android:gravity="center_horizontal"
|
android:gravity="center"
|
||||||
android:background="@color/background_color">
|
android:background="@color/background_color">
|
||||||
|
|
||||||
<com.google.android.material.imageview.ShapeableImageView
|
<com.google.android.material.imageview.ShapeableImageView
|
||||||
@@ -116,7 +116,6 @@
|
|||||||
android:backgroundTint="@color/secondary_color"/>
|
android:backgroundTint="@color/secondary_color"/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
<com.google.android.material.button.MaterialButton
|
||||||
android:id="@+id/button_logout"
|
android:id="@+id/button_logout"
|
||||||
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
|
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
|
||||||
|
|||||||
@@ -37,4 +37,13 @@
|
|||||||
<style name="ShapeAppearanceOverlay.App.CornerSize50Percent" parent="">
|
<style name="ShapeAppearanceOverlay.App.CornerSize50Percent" parent="">
|
||||||
<item name="cornerSize">50%</item>
|
<item name="cornerSize">50%</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style name="CircleImageView" parent="">
|
||||||
|
<item name="cornerSize">50%</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style name="CustomDialogTheme" parent="Theme.MaterialComponents.Light.Dialog.Alert">
|
||||||
|
<item name="windowNoTitle">true</item>
|
||||||
|
<item name="android:windowBackground">@android:color/transparent</item>
|
||||||
|
</style>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
Reference in New Issue
Block a user