definições
This commit is contained in:
@@ -13,6 +13,9 @@
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.LifeGrid">
|
||||
<activity
|
||||
android:name=".DefinicoesActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".TelaInicialActivity"
|
||||
android:exported="false" />
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
package com.example.lifegrid;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.Switch;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.activity.EdgeToEdge;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.graphics.Insets;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.view.WindowInsetsCompat;
|
||||
|
||||
import com.google.firebase.auth.FirebaseAuth;
|
||||
import com.google.firebase.auth.FirebaseUser;
|
||||
|
||||
public class DefinicoesActivity extends AppCompatActivity {
|
||||
|
||||
private ImageView btnBack;
|
||||
private TextView tvLogout;
|
||||
private Button btnSaveSettings;
|
||||
private EditText etUsername;
|
||||
private Switch switchNotifications;
|
||||
private Spinner spinnerCurrency;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
EdgeToEdge.enable(this);
|
||||
setContentView(R.layout.activity_definicoes);
|
||||
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;
|
||||
});
|
||||
|
||||
btnBack = findViewById(R.id.btnBack);
|
||||
tvLogout = findViewById(R.id.tvLogout);
|
||||
btnSaveSettings = findViewById(R.id.btnSaveSettings);
|
||||
etUsername = findViewById(R.id.etUsername);
|
||||
switchNotifications = findViewById(R.id.switchNotifications);
|
||||
spinnerCurrency = findViewById(R.id.spinnerCurrency);
|
||||
|
||||
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
|
||||
if (user != null && user.getDisplayName() != null && !user.getDisplayName().isEmpty()) {
|
||||
etUsername.setText(user.getDisplayName());
|
||||
}
|
||||
|
||||
btnBack.setOnClickListener(v -> {
|
||||
finish();
|
||||
});
|
||||
|
||||
tvLogout.setOnClickListener(v -> {
|
||||
FirebaseAuth.getInstance().signOut();
|
||||
Intent intent = new Intent(DefinicoesActivity.this, LoginActivity.class);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
});
|
||||
|
||||
btnSaveSettings.setOnClickListener(v -> {
|
||||
// Em implementações futuras isto iria guardar a foto, username (Firebase UserProfileChangeRequest)
|
||||
// Notificações e moeda escolhida no Firebase Realtime Database
|
||||
Toast.makeText(this, "Definições guardadas com sucesso!", Toast.LENGTH_SHORT).show();
|
||||
finish();
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.example.lifegrid;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.content.Intent;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
@@ -129,10 +130,8 @@ public class TelaInicialActivity extends AppCompatActivity {
|
||||
});
|
||||
ImageView definicoesImageView = findViewById(R.id.definicoesImageView);
|
||||
definicoesImageView.setOnClickListener(v -> {
|
||||
Fragment definicoesFragment = new DefinicoesFragment();
|
||||
getSupportFragmentManager().beginTransaction()
|
||||
.replace(R.id.fragmentContainerView, definicoesFragment)
|
||||
.commit();
|
||||
Intent intent = new Intent(TelaInicialActivity.this, DefinicoesActivity.class);
|
||||
startActivity(intent);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
253
app/src/main/res/layout/activity_definicoes.xml
Normal file
253
app/src/main/res/layout/activity_definicoes.xml
Normal file
@@ -0,0 +1,253 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/branco"
|
||||
android:id="@+id/main">
|
||||
|
||||
<!-- Header -->
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/headerLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="16dp"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/btnBack"
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="32dp"
|
||||
android:src="@drawable/diagonalarrowleftdownoutline_110924"
|
||||
app:tint="@color/preto"
|
||||
android:rotation="45"
|
||||
android:padding="4dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
<!-- using existing icon but rotated to act as back arrow, or I could just use a standard one. Actually diagonalarrowleftdownoutline rotated 45 might look weird. Let's use android.R.drawable.ic_menu_revert or similar. Actually, let's use standard text "Voltar" or use an existing arrow if available. There is no simple back arrow in drawables. Wait, there's `ic_arrow_down.xml`. I can rotate it 90 degrees to point left. -->
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Definições"
|
||||
android:textColor="@color/preto"
|
||||
android:textSize="22sp"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:fillViewport="true"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/headerLayout">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="24dp">
|
||||
|
||||
<!-- Profile Section -->
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Perfil"
|
||||
android:textColor="@color/preto"
|
||||
android:textSize="18sp"
|
||||
android:textStyle="bold"
|
||||
android:layout_marginBottom="8dp" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/cardview_background"
|
||||
android:orientation="vertical"
|
||||
android:padding="20dp"
|
||||
android:gravity="center_horizontal"
|
||||
android:layout_marginBottom="24dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivProfilePicture"
|
||||
android:layout_width="80dp"
|
||||
android:layout_height="80dp"
|
||||
android:background="@drawable/bg_circle_green"
|
||||
android:src="@drawable/ic_launcher_foreground"
|
||||
app:tint="@color/branco"
|
||||
android:padding="16dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvChangePhoto"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="Mudar Fotografia"
|
||||
android:textColor="#1C4DF6"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:text="Nome de Utilizador"
|
||||
android:textColor="@color/cinzaescuro"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/etUsername"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:layout_marginTop="4dp"
|
||||
android:background="@drawable/rounded_input_bg"
|
||||
android:paddingHorizontal="16dp"
|
||||
android:textColor="@color/preto"
|
||||
android:hint="O teu nome" />
|
||||
</LinearLayout>
|
||||
|
||||
<!-- Preferences Section -->
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Preferências"
|
||||
android:textColor="@color/preto"
|
||||
android:textSize="18sp"
|
||||
android:textStyle="bold"
|
||||
android:layout_marginBottom="8dp" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/cardview_background"
|
||||
android:orientation="vertical"
|
||||
android:padding="16dp"
|
||||
android:layout_marginBottom="24dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Notificações"
|
||||
android:textColor="@color/preto"
|
||||
android:textSize="16sp" />
|
||||
|
||||
<Switch
|
||||
android:id="@+id/switchNotifications"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:checked="true" />
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="#E0E0E0"
|
||||
android:layout_marginVertical="12dp" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Moeda Base"
|
||||
android:textColor="@color/preto"
|
||||
android:textSize="16sp" />
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/spinnerCurrency"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="40dp"
|
||||
android:background="@drawable/rounded_input_bg"
|
||||
android:entries="@array/moedas_array" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<!-- Extras Section -->
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Outros"
|
||||
android:textColor="@color/preto"
|
||||
android:textSize="18sp"
|
||||
android:textStyle="bold"
|
||||
android:layout_marginBottom="8dp" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/cardview_background"
|
||||
android:orientation="vertical"
|
||||
android:padding="16dp"
|
||||
android:layout_marginBottom="32dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvTerms"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Termos e Condições"
|
||||
android:textColor="@color/preto"
|
||||
android:textSize="16sp"
|
||||
android:paddingVertical="8dp" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="#E0E0E0"
|
||||
android:layout_marginVertical="4dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvPrivacy"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Política de Privacidade"
|
||||
android:textColor="@color/preto"
|
||||
android:textSize="16sp"
|
||||
android:paddingVertical="8dp" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="#E0E0E0"
|
||||
android:layout_marginVertical="4dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvLogout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Terminar Sessão"
|
||||
android:textColor="#ef4444"
|
||||
android:textStyle="bold"
|
||||
android:textSize="16sp"
|
||||
android:paddingVertical="8dp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnSaveSettings"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="55dp"
|
||||
android:backgroundTint="@color/preto"
|
||||
android:text="Guardar Alterações"
|
||||
android:textSize="16sp"
|
||||
app:cornerRadius="14dp"
|
||||
android:layout_marginBottom="32dp" />
|
||||
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -37,4 +37,10 @@
|
||||
<item>Imóveis</item>
|
||||
<item>Criptomoedas</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="moedas_array">
|
||||
<item>EUR (€)</item>
|
||||
<item>USD ($)</item>
|
||||
<item>BRL (R$)</item>
|
||||
</string-array>
|
||||
</resources>
|
||||
Reference in New Issue
Block a user