teste
This commit is contained in:
@@ -33,6 +33,7 @@ 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);
|
||||||
|
//teste
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -37,7 +37,7 @@ public class MapFragment extends Fragment {
|
|||||||
db = FirebaseFirestore.getInstance();
|
db = FirebaseFirestore.getInstance();
|
||||||
auth = FirebaseAuth.getInstance();
|
auth = FirebaseAuth.getInstance();
|
||||||
|
|
||||||
// Agora o Java vai encontrar estes IDs porque colocamos no XML acima
|
// Encontra os IDs no XML
|
||||||
layoutEmptyState = root.findViewById(R.id.layoutEmptyState);
|
layoutEmptyState = root.findViewById(R.id.layoutEmptyState);
|
||||||
mapContainer = root.findViewById(R.id.mapContainer);
|
mapContainer = root.findViewById(R.id.mapContainer);
|
||||||
btnAddChild = root.findViewById(R.id.btnAddChild);
|
btnAddChild = root.findViewById(R.id.btnAddChild);
|
||||||
@@ -46,7 +46,7 @@ public class MapFragment extends Fragment {
|
|||||||
btnAddChild.setOnClickListener(v -> {
|
btnAddChild.setOnClickListener(v -> {
|
||||||
FirebaseUser user = auth.getCurrentUser();
|
FirebaseUser user = auth.getCurrentUser();
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
openAddChildScreen(); // Agora esta função existe lá embaixo
|
openAddChildScreen();
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(getContext(), "Erro: Utilizador não autenticado", Toast.LENGTH_SHORT).show();
|
Toast.makeText(getContext(), "Erro: Utilizador não autenticado", Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
@@ -111,27 +111,41 @@ public class MapFragment extends Fragment {
|
|||||||
if (mapContainer != null) mapContainer.setVisibility(View.GONE);
|
if (mapContainer != null) mapContainer.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Esta é a função que estava faltando ou mal fechada
|
|
||||||
private void openAddChildScreen() {
|
private void openAddChildScreen() {
|
||||||
AddChildBottomSheet bottomSheet = new AddChildBottomSheet();
|
AddChildBottomSheet bottomSheet = new AddChildBottomSheet();
|
||||||
|
|
||||||
bottomSheet.setListener(code -> {
|
bottomSheet.setListener(code -> {
|
||||||
|
// Quando o código é gerado, mostramos o diálogo de escolha
|
||||||
showCodeDialog(code);
|
showCodeDialog(code);
|
||||||
});
|
});
|
||||||
|
|
||||||
bottomSheet.show(getParentFragmentManager(), "AddChildSheet");
|
bottomSheet.show(getParentFragmentManager(), "AddChildSheet");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --- AQUI ESTÁ A MUDANÇA PRINCIPAL ---
|
||||||
private void showCodeDialog(String code) {
|
private void showCodeDialog(String code) {
|
||||||
if (getContext() == null) return;
|
if (getContext() == null) return;
|
||||||
new AlertDialog.Builder(getContext())
|
|
||||||
.setTitle("Perfil Criado!")
|
// 1. Copia o código automaticamente para a área de transferência
|
||||||
.setMessage("Digite este código no telemóvel do filho:\n\n" + code)
|
|
||||||
.setPositiveButton("Copiar Código", (dialog, which) -> {
|
|
||||||
ClipboardManager clipboard = (ClipboardManager) requireContext().getSystemService(Context.CLIPBOARD_SERVICE);
|
ClipboardManager clipboard = (ClipboardManager) requireContext().getSystemService(Context.CLIPBOARD_SERVICE);
|
||||||
ClipData clip = ClipData.newPlainText("Código", code);
|
ClipData clip = ClipData.newPlainText("Código", code);
|
||||||
clipboard.setPrimaryClip(clip);
|
clipboard.setPrimaryClip(clip);
|
||||||
Toast.makeText(getContext(), "Copiado!", Toast.LENGTH_SHORT).show();
|
Toast.makeText(getContext(), "Código copiado!", Toast.LENGTH_SHORT).show();
|
||||||
|
|
||||||
|
// 2. Cria o Alerta com as Duas Opções
|
||||||
|
new AlertDialog.Builder(getContext())
|
||||||
|
.setTitle("Filho Adicionado!")
|
||||||
|
.setMessage("O código de acesso é: " + code + "\n\n(Já copiado automaticamente)")
|
||||||
|
.setCancelable(false) // Impede fechar clicando fora
|
||||||
|
|
||||||
|
// OPÇÃO 1: Ir para o Mapa (Atualiza a tela)
|
||||||
|
.setPositiveButton("Ir para o Mapa", (dialog, which) -> {
|
||||||
|
checkIfHasChildren(); // <--- Esta função recarrega a tela e mostra o mapa
|
||||||
|
})
|
||||||
|
|
||||||
|
// OPÇÃO 2: Adicionar Outro (Fica na mesma tela)
|
||||||
|
.setNegativeButton("Adicionar Outro", (dialog, which) -> {
|
||||||
|
dialog.dismiss(); // Apenas fecha o alerta e continua na tela azul
|
||||||
})
|
})
|
||||||
.show();
|
.show();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
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"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="#F3F6FB">
|
android:background="#F3F6FB">
|
||||||
@@ -73,7 +74,7 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="24dp"
|
android:layout_marginTop="24dp"
|
||||||
android:text="Nenhum filho adicionado"
|
android:text="Nenhum membro adicionado"
|
||||||
android:textSize="18sp"
|
android:textSize="18sp"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
app:layout_constraintBottom_toTopOf="@+id/tvNoChildDesc"
|
app:layout_constraintBottom_toTopOf="@+id/tvNoChildDesc"
|
||||||
@@ -87,7 +88,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="8dp"
|
android:layout_marginTop="8dp"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:text="Adicione o seu primeiro filho para começar."
|
android:text="Adicione o seu primeiro membro para começar."
|
||||||
app:layout_constraintBottom_toTopOf="@+id/btnAddChild"
|
app:layout_constraintBottom_toTopOf="@+id/btnAddChild"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
@@ -97,11 +98,12 @@
|
|||||||
android:id="@+id/btnAddChild"
|
android:id="@+id/btnAddChild"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="60dp"
|
android:layout_height="60dp"
|
||||||
android:text="Adicionar Filho"
|
android:text="Adicionar Membro"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
app:backgroundTint="#3D6DFF"
|
app:backgroundTint="#3D6DFF"
|
||||||
app:cornerRadius="12dp"
|
app:cornerRadius="12dp"
|
||||||
app:layout_constraintBottom_toBottomOf="parent" />
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
tools:layout_editor_absoluteX="24dp" />
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
</androidx.cardview.widget.CardView>
|
</androidx.cardview.widget.CardView>
|
||||||
|
|||||||
@@ -65,11 +65,11 @@
|
|||||||
android:layout_width="50dp"
|
android:layout_width="50dp"
|
||||||
android:layout_height="50dp"
|
android:layout_height="50dp"
|
||||||
android:src="@android:drawable/ic_menu_add"
|
android:src="@android:drawable/ic_menu_add"
|
||||||
app:tint="#3D6DFF"
|
|
||||||
app:layout_constraintBottom_toBottomOf="@+id/bgIcon"
|
app:layout_constraintBottom_toBottomOf="@+id/bgIcon"
|
||||||
app:layout_constraintEnd_toEndOf="@+id/bgIcon"
|
app:layout_constraintEnd_toEndOf="@+id/bgIcon"
|
||||||
app:layout_constraintStart_toStartOf="@+id/bgIcon"
|
app:layout_constraintStart_toStartOf="@+id/bgIcon"
|
||||||
app:layout_constraintTop_toTopOf="@+id/bgIcon" />
|
app:layout_constraintTop_toTopOf="@+id/bgIcon"
|
||||||
|
app:tint="#3D6DFF" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tvNoChildTitle"
|
android:id="@+id/tvNoChildTitle"
|
||||||
|
|||||||
Reference in New Issue
Block a user