corrigir os novos erros amnhã e adicionar qual tipo de sexo a pessoa é no register
This commit is contained in:
@@ -32,9 +32,9 @@
|
|||||||
<activity android:name=".HomeActivity" android:exported="false" />
|
<activity android:name=".HomeActivity" android:exported="false" />
|
||||||
<activity android:name=".RegisterActivity" android:exported="false" />
|
<activity android:name=".RegisterActivity" android:exported="false" />
|
||||||
<activity android:name=".MainActivity" android:exported="false" />
|
<activity android:name=".MainActivity" android:exported="false" />
|
||||||
|
|
||||||
<!-- AQUI ESTÁ A ACTIVITY QUE FALTAVA! -->
|
|
||||||
<activity android:name=".VerificacaoActivity" android:exported="false" />
|
<activity android:name=".VerificacaoActivity" android:exported="false" />
|
||||||
|
<activity android:name=".MudarEmailActivity" android:exported="false" />
|
||||||
|
<activity android:name=".MudarPasswordActivity" android:exported="false" />
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".LoginActivity"
|
android:name=".LoginActivity"
|
||||||
|
|||||||
@@ -1,74 +1,66 @@
|
|||||||
package com.example.pap;
|
package com.example.pap;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.Switch;
|
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.appcompat.app.AppCompatDelegate;
|
|
||||||
|
|
||||||
public class DefinicoesActivity extends AppCompatActivity {
|
public class DefinicoesActivity extends AppCompatActivity {
|
||||||
|
|
||||||
private Switch switchModoEscuro;
|
private EditText etNovoNome;
|
||||||
private EditText etNovoNome, etNovoEmail, etNovaPassword;
|
private Button btnGuardarNome, btnSairConta, btnIrMudarEmail, btnIrMudarPassword;
|
||||||
private Button btnGuardarAlteracoes;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_definicoes);
|
setContentView(R.layout.activity_definicoes);
|
||||||
|
|
||||||
switchModoEscuro = findViewById(R.id.switchModoEscuro);
|
|
||||||
etNovoNome = findViewById(R.id.etNovoNome);
|
etNovoNome = findViewById(R.id.etNovoNome);
|
||||||
etNovoEmail = findViewById(R.id.etNovoEmail);
|
btnGuardarNome = findViewById(R.id.btnGuardarNome);
|
||||||
etNovaPassword = findViewById(R.id.etNovaPassword);
|
btnSairConta = findViewById(R.id.btnSairConta);
|
||||||
btnGuardarAlteracoes = findViewById(R.id.btnGuardarAlteracoes);
|
btnIrMudarEmail = findViewById(R.id.btnIrMudarEmail);
|
||||||
|
btnIrMudarPassword = findViewById(R.id.btnIrMudarPassword);
|
||||||
|
|
||||||
findViewById(R.id.btnVoltarDefinicoes).setOnClickListener(v -> finish());
|
findViewById(R.id.btnVoltarDefinicoes).setOnClickListener(v -> finish());
|
||||||
|
|
||||||
// 1. CARREGAR E CONFIGURAR O MODO ESCURO
|
SharedPreferences dadosPrefs = getSharedPreferences("MeusDadosApp", MODE_PRIVATE);
|
||||||
SharedPreferences themePrefs = getSharedPreferences("Definicoes", MODE_PRIVATE);
|
etNovoNome.setText(dadosPrefs.getString("nome", ""));
|
||||||
boolean isDark = themePrefs.getBoolean("dark_mode", false);
|
|
||||||
switchModoEscuro.setChecked(isDark);
|
|
||||||
|
|
||||||
switchModoEscuro.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
// Ir para Mudar Email
|
||||||
SharedPreferences.Editor editor = themePrefs.edit();
|
btnIrMudarEmail.setOnClickListener(v -> {
|
||||||
editor.putBoolean("dark_mode", isChecked);
|
startActivity(new Intent(DefinicoesActivity.this, MudarEmailActivity.class));
|
||||||
editor.apply();
|
});
|
||||||
|
|
||||||
if (isChecked) {
|
// Ir para Mudar Password
|
||||||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
|
btnIrMudarPassword.setOnClickListener(v -> {
|
||||||
} else {
|
startActivity(new Intent(DefinicoesActivity.this, MudarPasswordActivity.class));
|
||||||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
|
});
|
||||||
|
|
||||||
|
// Guardar Apenas o Nome (Porque Email e Password têm ecrãs próprios)
|
||||||
|
btnGuardarNome.setOnClickListener(v -> {
|
||||||
|
String novoNome = etNovoNome.getText().toString().trim();
|
||||||
|
if (!novoNome.isEmpty()) {
|
||||||
|
SharedPreferences.Editor editor = dadosPrefs.edit();
|
||||||
|
editor.putString("nome", novoNome);
|
||||||
|
editor.apply();
|
||||||
|
Toast.makeText(this, "Nome atualizado!", Toast.LENGTH_SHORT).show();
|
||||||
|
finish();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// 2. CARREGAR O NOME E EMAIL ATUAIS PARA O CAMPO DE TEXTO
|
// Terminar Sessão
|
||||||
SharedPreferences dadosPrefs = getSharedPreferences("MeusDadosApp", MODE_PRIVATE);
|
btnSairConta.setOnClickListener(v -> {
|
||||||
etNovoNome.setText(dadosPrefs.getString("nome", ""));
|
|
||||||
etNovoEmail.setText(dadosPrefs.getString("email", ""));
|
|
||||||
|
|
||||||
// 3. GUARDAR AS ALTERAÇÕES
|
|
||||||
btnGuardarAlteracoes.setOnClickListener(v -> {
|
|
||||||
String novoNome = etNovoNome.getText().toString().trim();
|
|
||||||
String novoEmail = etNovoEmail.getText().toString().trim();
|
|
||||||
String novaPassword = etNovaPassword.getText().toString().trim();
|
|
||||||
|
|
||||||
SharedPreferences.Editor editor = dadosPrefs.edit();
|
SharedPreferences.Editor editor = dadosPrefs.edit();
|
||||||
|
editor.clear();
|
||||||
if (!novoNome.isEmpty()) {
|
|
||||||
editor.putString("nome", novoNome);
|
|
||||||
}
|
|
||||||
if (!novoEmail.isEmpty()) {
|
|
||||||
editor.putString("email", novoEmail);
|
|
||||||
}
|
|
||||||
|
|
||||||
editor.apply();
|
editor.apply();
|
||||||
|
Toast.makeText(this, "Sessão terminada", Toast.LENGTH_SHORT).show();
|
||||||
Toast.makeText(this, "Alterações guardadas com sucesso!", Toast.LENGTH_SHORT).show();
|
Intent intent = new Intent(DefinicoesActivity.this, LoginActivity.class);
|
||||||
finish(); // Volta ao ecrã anterior
|
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||||
|
startActivity(intent);
|
||||||
|
finish();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7,8 +7,13 @@ import android.widget.ProgressBar;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import retrofit2.Call;
|
||||||
|
import retrofit2.Callback;
|
||||||
|
import retrofit2.Response;
|
||||||
|
|
||||||
public class EstatisticasActivity extends AppCompatActivity {
|
public class EstatisticasActivity extends AppCompatActivity {
|
||||||
|
|
||||||
private TextView tvValorIMC, tvStatusIMC, tvCaloriasMeta, tvDicaIA, tvCaloriasQueimadas;
|
private TextView tvValorIMC, tvStatusIMC, tvCaloriasMeta, tvDicaIA, tvCaloriasQueimadas;
|
||||||
@@ -16,6 +21,9 @@ public class EstatisticasActivity extends AppCompatActivity {
|
|||||||
private TextView tvAguaStats;
|
private TextView tvAguaStats;
|
||||||
private ProgressBar progressProt, progressHidr, progressGord;
|
private ProgressBar progressProt, progressHidr, progressGord;
|
||||||
|
|
||||||
|
// COLOCA A TUA API KEY AQUI
|
||||||
|
private final String MINHA_API_KEY = "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";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@@ -41,11 +49,15 @@ public class EstatisticasActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
findViewById(R.id.btnVoltarStats).setOnClickListener(v -> finish());
|
findViewById(R.id.btnVoltarStats).setOnClickListener(v -> finish());
|
||||||
|
|
||||||
|
// Carrega os painéis locais
|
||||||
calcularIMC();
|
calcularIMC();
|
||||||
calcularTMB();
|
calcularTMB();
|
||||||
carregarMacrosDaIA();
|
carregarMacrosDaIA();
|
||||||
carregarAgua();
|
carregarAgua();
|
||||||
carregarCaloriasQueimadas();
|
carregarCaloriasQueimadas();
|
||||||
|
|
||||||
|
// CHAMA A IA PARA AVALIAR O ESTADO GERAL DO UTILIZADOR
|
||||||
|
gerarInsightInteligente();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void calcularIMC() {
|
private void calcularIMC() {
|
||||||
@@ -80,10 +92,10 @@ public class EstatisticasActivity extends AppCompatActivity {
|
|||||||
SharedPreferences prefs = getSharedPreferences("MeusDadosApp", MODE_PRIVATE);
|
SharedPreferences prefs = getSharedPreferences("MeusDadosApp", MODE_PRIVATE);
|
||||||
float peso = prefs.getFloat("peso", 0);
|
float peso = prefs.getFloat("peso", 0);
|
||||||
float alturaMetros = prefs.getFloat("altura", 0);
|
float alturaMetros = prefs.getFloat("altura", 0);
|
||||||
String sexo = prefs.getString("sexo", "");
|
String sexo = prefs.getString("sexo", "Masculino"); // Assumido Masculino como padrão
|
||||||
int idade = prefs.getInt("idade", 20);
|
int idade = prefs.getInt("idade", 20);
|
||||||
|
|
||||||
if (peso > 0 && alturaMetros > 0 && !sexo.isEmpty()) {
|
if (peso > 0 && alturaMetros > 0) {
|
||||||
float alturaCm = alturaMetros * 100;
|
float alturaCm = alturaMetros * 100;
|
||||||
double tmb;
|
double tmb;
|
||||||
|
|
||||||
@@ -108,10 +120,6 @@ public class EstatisticasActivity extends AppCompatActivity {
|
|||||||
int gord = prefs.getInt("gord_hoje", 0);
|
int gord = prefs.getInt("gord_hoje", 0);
|
||||||
String ultimaComida = prefs.getString("ultimo_prato", "Ainda não leste nada hoje.");
|
String ultimaComida = prefs.getString("ultimo_prato", "Ainda não leste nada hoje.");
|
||||||
|
|
||||||
// Puxa a dica extraída da foto!
|
|
||||||
String dicaIa = prefs.getString("ultima_dica_ia", "Continua a registar as tuas refeições para ver dicas.");
|
|
||||||
tvDicaIA.setText(dicaIa);
|
|
||||||
|
|
||||||
tvProtGramas.setText("Proteína: " + prot + "g");
|
tvProtGramas.setText("Proteína: " + prot + "g");
|
||||||
tvHidrGramas.setText("Hidratos: " + hidr + "g");
|
tvHidrGramas.setText("Hidratos: " + hidr + "g");
|
||||||
tvGordGramas.setText("Gordura: " + gord + "g");
|
tvGordGramas.setText("Gordura: " + gord + "g");
|
||||||
@@ -135,4 +143,65 @@ public class EstatisticasActivity extends AppCompatActivity {
|
|||||||
int kcalQueimadas = prefs.getInt("calorias_desafios", 0);
|
int kcalQueimadas = prefs.getInt("calorias_desafios", 0);
|
||||||
tvCaloriasQueimadas.setText(kcalQueimadas + " kcal");
|
tvCaloriasQueimadas.setText(kcalQueimadas + " kcal");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ==========================================
|
||||||
|
// NOVA FUNÇÃO: O CÉREBRO DA IA NAS ESTATÍSTICAS
|
||||||
|
// ==========================================
|
||||||
|
private void gerarInsightInteligente() {
|
||||||
|
tvDicaIA.setText("A analisar os teus dados diários... ⏳");
|
||||||
|
|
||||||
|
// 1. Recolher a informação toda das gavetas (SharedPreferences)
|
||||||
|
SharedPreferences prefsDados = getSharedPreferences("MeusDadosApp", MODE_PRIVATE);
|
||||||
|
SharedPreferences prefsSaude = getSharedPreferences("DadosSaude", MODE_PRIVATE);
|
||||||
|
SharedPreferences prefsGam = getSharedPreferences("DadosGamificacao", MODE_PRIVATE);
|
||||||
|
|
||||||
|
float peso = prefsDados.getFloat("peso", 0);
|
||||||
|
float altura = prefsDados.getFloat("altura", 0);
|
||||||
|
float imc = (peso > 0 && altura > 0) ? (peso / (altura * altura)) : 0;
|
||||||
|
|
||||||
|
int prot = prefsSaude.getInt("prot_hoje", 0);
|
||||||
|
int hidr = prefsSaude.getInt("hidr_hoje", 0);
|
||||||
|
int gord = prefsSaude.getInt("gord_hoje", 0);
|
||||||
|
|
||||||
|
float litrosAgua = prefsGam.getInt("agua_hoje", 0) * 0.25f;
|
||||||
|
int kcalQueimadas = prefsGam.getInt("calorias_desafios", 0);
|
||||||
|
|
||||||
|
// 2. Criar o Prompt a explicar o cenário à IA
|
||||||
|
String promptDaIA = "És o treinador e nutricionista pessoal do utilizador. " +
|
||||||
|
"Os dados dele hoje são: IMC = " + String.format(Locale.getDefault(), "%.1f", imc) + ", " +
|
||||||
|
"Água bebida = " + litrosAgua + " Litros, Calorias Queimadas = " + kcalQueimadas + " kcal. " +
|
||||||
|
"Macros consumidos: Proteína=" + prot + "g, Hidratos=" + hidr + "g, Gordura=" + gord + "g. " +
|
||||||
|
"Avalia estes números de forma realista. Se ele bebeu pouca água, avisa-o. Se tem pouca proteína, alerta-o. " +
|
||||||
|
"Regra de Ouro: Escreve apenas 2 frases curtas, diretas e motivadoras. NÃO USES ASTERISCOS.";
|
||||||
|
|
||||||
|
// 3. Enviar o pedido usando a classe AiApi que já tens (enviamos só texto, sem imagem)
|
||||||
|
AiRequest request = new AiRequest(Collections.singletonList(
|
||||||
|
new Message("user", Collections.singletonList(new ContentPart("text", promptDaIA)))
|
||||||
|
));
|
||||||
|
|
||||||
|
AiConfig.getRetrofit().create(AiApi.class)
|
||||||
|
.analisarImagem("Bearer " + MINHA_API_KEY, request) // Usamos o mesmo método mas sem enviar a foto
|
||||||
|
.enqueue(new Callback<AiResponse>() {
|
||||||
|
@Override
|
||||||
|
public void onResponse(Call<AiResponse> call, Response<AiResponse> response) {
|
||||||
|
if (response.isSuccessful() && response.body() != null) {
|
||||||
|
try {
|
||||||
|
String resposta = response.body().choices.get(0).message.content;
|
||||||
|
// Limpa qualquer formatação extra que a IA tente mandar
|
||||||
|
String dicaLimpa = resposta.replace("**", "").replace("*", "");
|
||||||
|
tvDicaIA.setText(dicaLimpa);
|
||||||
|
} catch (Exception e) {
|
||||||
|
tvDicaIA.setText("Continua o bom trabalho! Mantém o foco na água e macros.");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
tvDicaIA.setText("Servidor indisponível no momento. Foca-te em beber água!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(Call<AiResponse> call, Throwable t) {
|
||||||
|
tvDicaIA.setText("Estás offline. Regista os dados localmente!");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -11,10 +11,15 @@ import android.provider.MediaStore;
|
|||||||
import android.util.Base64;
|
import android.util.Base64;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
|
import android.widget.EditText;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.activity.result.ActivityResultLauncher;
|
import androidx.activity.result.ActivityResultLauncher;
|
||||||
import androidx.activity.result.contract.ActivityResultContracts;
|
import androidx.activity.result.contract.ActivityResultContracts;
|
||||||
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
@@ -28,12 +33,12 @@ import retrofit2.Response;
|
|||||||
public class FotoActivity extends AppCompatActivity {
|
public class FotoActivity extends AppCompatActivity {
|
||||||
|
|
||||||
private ImageView ivFotoComida;
|
private ImageView ivFotoComida;
|
||||||
private Button btnTirarFoto, btnGaleria, btnAnalisarIA, btnIrParaChat;
|
private Button btnTirarFoto, btnGaleria, btnAnalisarIA, btnIrParaChat, btnCorrigir;
|
||||||
private TextView tvResultadoIA;
|
private TextView tvResultadoIA;
|
||||||
private Bitmap imagemCapturada;
|
private Bitmap imagemCapturada;
|
||||||
private String textoAnalise = "";
|
private String textoAnalise = "";
|
||||||
|
|
||||||
// MANTÉM A TUA CHAVE (cuidado para não partilhar no futuro)
|
// MANTÉM A TUA CHAVE AQUI
|
||||||
private final String MINHA_API_KEY = "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";
|
private final String MINHA_API_KEY = "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";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -46,6 +51,7 @@ public class FotoActivity extends AppCompatActivity {
|
|||||||
btnGaleria = findViewById(R.id.btnGaleria);
|
btnGaleria = findViewById(R.id.btnGaleria);
|
||||||
btnAnalisarIA = findViewById(R.id.btnAnalisarIA);
|
btnAnalisarIA = findViewById(R.id.btnAnalisarIA);
|
||||||
btnIrParaChat = findViewById(R.id.btnIrParaChat);
|
btnIrParaChat = findViewById(R.id.btnIrParaChat);
|
||||||
|
btnCorrigir = findViewById(R.id.btnCorrigir); // Ligado ao XML
|
||||||
tvResultadoIA = findViewById(R.id.tvResultadoIA);
|
tvResultadoIA = findViewById(R.id.tvResultadoIA);
|
||||||
|
|
||||||
ActivityResultLauncher<Intent> camLauncher = registerForActivityResult(
|
ActivityResultLauncher<Intent> camLauncher = registerForActivityResult(
|
||||||
@@ -85,7 +91,8 @@ public class FotoActivity extends AppCompatActivity {
|
|||||||
galLauncher.launch(intent);
|
galLauncher.launch(intent);
|
||||||
});
|
});
|
||||||
|
|
||||||
btnAnalisarIA.setOnClickListener(v -> enviarParaIA());
|
// Clique para analisar pela primeira vez
|
||||||
|
btnAnalisarIA.setOnClickListener(v -> enviarParaIA(null));
|
||||||
|
|
||||||
btnIrParaChat.setOnClickListener(v -> {
|
btnIrParaChat.setOnClickListener(v -> {
|
||||||
Intent intent = new Intent(FotoActivity.this, ChatActivity.class);
|
Intent intent = new Intent(FotoActivity.this, ChatActivity.class);
|
||||||
@@ -93,6 +100,9 @@ public class FotoActivity extends AppCompatActivity {
|
|||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// NOVO: Clique para corrigir erro
|
||||||
|
btnCorrigir.setOnClickListener(v -> mostrarPopupCorrecao());
|
||||||
|
|
||||||
findViewById(R.id.btnVoltarFoto).setOnClickListener(v -> finish());
|
findViewById(R.id.btnVoltarFoto).setOnClickListener(v -> finish());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,26 +113,42 @@ public class FotoActivity extends AppCompatActivity {
|
|||||||
ivFotoComida.setImageBitmap(imagemCapturada);
|
ivFotoComida.setImageBitmap(imagemCapturada);
|
||||||
btnAnalisarIA.setVisibility(View.VISIBLE);
|
btnAnalisarIA.setVisibility(View.VISIBLE);
|
||||||
btnIrParaChat.setVisibility(View.GONE);
|
btnIrParaChat.setVisibility(View.GONE);
|
||||||
|
btnCorrigir.setVisibility(View.GONE); // Esconde a correção até analisar
|
||||||
tvResultadoIA.setText("Pronto para analisar.");
|
tvResultadoIA.setText("Pronto para analisar.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void enviarParaIA() {
|
// Função melhorada que aceita a comida certa se o utilizador corrigir
|
||||||
|
private void enviarParaIA(String comidaCerta) {
|
||||||
tvResultadoIA.setText("A processar... ⏳");
|
tvResultadoIA.setText("A processar... ⏳");
|
||||||
btnAnalisarIA.setEnabled(false);
|
btnAnalisarIA.setEnabled(false);
|
||||||
btnIrParaChat.setVisibility(View.GONE);
|
btnIrParaChat.setVisibility(View.GONE);
|
||||||
|
btnCorrigir.setVisibility(View.GONE);
|
||||||
|
|
||||||
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||||
imagemCapturada.compress(Bitmap.CompressFormat.JPEG, 50, os);
|
imagemCapturada.compress(Bitmap.CompressFormat.JPEG, 50, os);
|
||||||
String base64 = Base64.encodeToString(os.toByteArray(), Base64.NO_WRAP);
|
String base64 = Base64.encodeToString(os.toByteArray(), Base64.NO_WRAP);
|
||||||
|
|
||||||
String ordemParaIA = "És um nutricionista prático. Identifica a comida e dá os valores de forma SUPER RESUMIDA. " +
|
String ordemParaIA;
|
||||||
"REGRAS: 1. Português de Portugal. 2. SEM asteriscos. 3. Máximo 4 linhas. " +
|
if (comidaCerta == null) {
|
||||||
"Formato exato: \n" +
|
// Análise normal
|
||||||
"Prato: [Nome]\n" +
|
ordemParaIA = "És um nutricionista prático. Identifica a comida e dá os valores de forma SUPER RESUMIDA. " +
|
||||||
"Calorias: [Valor] kcal\n" +
|
"REGRAS: 1. Português de Portugal. 2. SEM asteriscos. 3. Máximo 4 linhas. " +
|
||||||
"Macros: [X]g Proteína, [X]g Hidratos, [X]g Gordura\n" +
|
"Formato exato: \n" +
|
||||||
"Dica: [Uma frase curta].";
|
"Prato: [Nome]\n" +
|
||||||
|
"Calorias: [Valor] kcal\n" +
|
||||||
|
"Macros: [X]g Proteína, [X]g Hidratos, [X]g Gordura\n" +
|
||||||
|
"Dica: [Uma frase curta].";
|
||||||
|
} else {
|
||||||
|
// Análise forçada com a correção do utilizador
|
||||||
|
ordemParaIA = "Atenção: A tua análise anterior falhou. O prato na imagem é na verdade: '" + comidaCerta + "'. " +
|
||||||
|
"Esquece tudo o resto e foca-te em dar os valores reais APENAS para '" + comidaCerta + "'. " +
|
||||||
|
"Usa este formato exato: \n" +
|
||||||
|
"Prato: " + comidaCerta + "\n" +
|
||||||
|
"Calorias: [Valor] kcal\n" +
|
||||||
|
"Macros: [X]g Proteína, [X]g Hidratos, [X]g Gordura\n" +
|
||||||
|
"Dica: [Frase de saúde curta e sem asteriscos].";
|
||||||
|
}
|
||||||
|
|
||||||
AiRequest request = new AiRequest(Collections.singletonList(
|
AiRequest request = new AiRequest(Collections.singletonList(
|
||||||
new Message("user", java.util.Arrays.asList(
|
new Message("user", java.util.Arrays.asList(
|
||||||
@@ -142,9 +168,17 @@ public class FotoActivity extends AppCompatActivity {
|
|||||||
String resposta = response.body().choices.get(0).message.content;
|
String resposta = response.body().choices.get(0).message.content;
|
||||||
textoAnalise = resposta.replace("**", "").replace("*", "");
|
textoAnalise = resposta.replace("**", "").replace("*", "");
|
||||||
tvResultadoIA.setText(textoAnalise);
|
tvResultadoIA.setText(textoAnalise);
|
||||||
btnIrParaChat.setVisibility(View.VISIBLE);
|
|
||||||
|
|
||||||
// A MAGIA ACONTECE AQUI!
|
// Mostra os botões
|
||||||
|
btnIrParaChat.setVisibility(View.VISIBLE);
|
||||||
|
btnCorrigir.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
|
// Se ele estiver a corrigir, apagamos o erro passado!
|
||||||
|
if (comidaCerta != null) {
|
||||||
|
desfazerUltimoErro();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Guarda a nova resposta
|
||||||
extrairEGuardarDados(textoAnalise);
|
extrairEGuardarDados(textoAnalise);
|
||||||
|
|
||||||
} catch (Exception e) { tvResultadoIA.setText("Erro na resposta."); }
|
} catch (Exception e) { tvResultadoIA.setText("Erro na resposta."); }
|
||||||
@@ -158,7 +192,34 @@ public class FotoActivity extends AppCompatActivity {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Função que "lê" a resposta da IA e guarda os números E A DICA
|
// --- POPUP PARA CORREÇÃO MANUAL ---
|
||||||
|
private void mostrarPopupCorrecao() {
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||||
|
builder.setTitle("Corrigir a IA 🤔");
|
||||||
|
builder.setMessage("A IA enganou-se? O que estava realmente no teu prato?");
|
||||||
|
|
||||||
|
final EditText input = new EditText(this);
|
||||||
|
input.setHint("Ex: Hambúrguer de Frango");
|
||||||
|
|
||||||
|
LinearLayout layout = new LinearLayout(this);
|
||||||
|
layout.setPadding(50, 20, 50, 0);
|
||||||
|
layout.addView(input);
|
||||||
|
builder.setView(layout);
|
||||||
|
|
||||||
|
builder.setPositiveButton("Re-Analisar", (dialog, which) -> {
|
||||||
|
String comidaCerta = input.getText().toString().trim();
|
||||||
|
if (!comidaCerta.isEmpty()) {
|
||||||
|
enviarParaIA(comidaCerta); // Manda o texto escrito pelo user
|
||||||
|
} else {
|
||||||
|
Toast.makeText(FotoActivity.this, "Tens de escrever a comida!", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
builder.setNegativeButton("Cancelar", null);
|
||||||
|
builder.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- FUNÇÃO PARA SALVAR OS DADOS E A DICA ---
|
||||||
private void extrairEGuardarDados(String texto) {
|
private void extrairEGuardarDados(String texto) {
|
||||||
try {
|
try {
|
||||||
int indexNomeStart = texto.indexOf("Prato: ") + 7;
|
int indexNomeStart = texto.indexOf("Prato: ") + 7;
|
||||||
@@ -170,7 +231,6 @@ public class FotoActivity extends AppCompatActivity {
|
|||||||
int hidratos = extrairNumero(texto, "Proteína, ", "g Hidratos");
|
int hidratos = extrairNumero(texto, "Proteína, ", "g Hidratos");
|
||||||
int gordura = extrairNumero(texto, "Hidratos, ", "g Gordura");
|
int gordura = extrairNumero(texto, "Hidratos, ", "g Gordura");
|
||||||
|
|
||||||
// EXTRAIR A DICA DA IA
|
|
||||||
String dicaIA = "Continua a registar refeições para ver dicas.";
|
String dicaIA = "Continua a registar refeições para ver dicas.";
|
||||||
if (texto.contains("Dica: ")) {
|
if (texto.contains("Dica: ")) {
|
||||||
int indexDica = texto.indexOf("Dica: ") + 6;
|
int indexDica = texto.indexOf("Dica: ") + 6;
|
||||||
@@ -181,17 +241,39 @@ public class FotoActivity extends AppCompatActivity {
|
|||||||
SharedPreferences.Editor editor = prefs.edit();
|
SharedPreferences.Editor editor = prefs.edit();
|
||||||
|
|
||||||
editor.putString("ultimo_prato", nomePrato);
|
editor.putString("ultimo_prato", nomePrato);
|
||||||
editor.putString("ultima_dica_ia", dicaIA); // Guarda a dica
|
editor.putString("ultima_dica_ia", dicaIA);
|
||||||
|
|
||||||
editor.putInt("cal_hoje", prefs.getInt("cal_hoje", 0) + calorias);
|
editor.putInt("cal_hoje", prefs.getInt("cal_hoje", 0) + calorias);
|
||||||
editor.putInt("prot_hoje", prefs.getInt("prot_hoje", 0) + proteina);
|
editor.putInt("prot_hoje", prefs.getInt("prot_hoje", 0) + proteina);
|
||||||
editor.putInt("hidr_hoje", prefs.getInt("hidr_hoje", 0) + hidratos);
|
editor.putInt("hidr_hoje", prefs.getInt("hidr_hoje", 0) + hidratos);
|
||||||
editor.putInt("gord_hoje", prefs.getInt("gord_hoje", 0) + gordura);
|
editor.putInt("gord_hoje", prefs.getInt("gord_hoje", 0) + gordura);
|
||||||
|
|
||||||
|
// GUAAAAARDA O ERRO PARA PODERMOS APAGAR SE O GAJO CLICAR EM "CORRIGIR"
|
||||||
|
editor.putInt("ultimo_erro_cal", calorias);
|
||||||
|
editor.putInt("ultimo_erro_prot", proteina);
|
||||||
|
editor.putInt("ultimo_erro_hidr", hidratos);
|
||||||
|
editor.putInt("ultimo_erro_gord", gordura);
|
||||||
|
|
||||||
editor.apply();
|
editor.apply();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {}
|
||||||
// Ignora se a IA responder noutro formato para não crashar
|
}
|
||||||
}
|
|
||||||
|
// --- FUNÇÃO PARA REMOVER O ÚLTIMO PRATO QUE FOI MAL LIDO ---
|
||||||
|
private void desfazerUltimoErro() {
|
||||||
|
SharedPreferences prefs = getSharedPreferences("DadosSaude", MODE_PRIVATE);
|
||||||
|
SharedPreferences.Editor editor = prefs.edit();
|
||||||
|
|
||||||
|
int calAntiga = prefs.getInt("ultimo_erro_cal", 0);
|
||||||
|
int protAntiga = prefs.getInt("ultimo_erro_prot", 0);
|
||||||
|
int hidrAntiga = prefs.getInt("ultimo_erro_hidr", 0);
|
||||||
|
int gordAntiga = prefs.getInt("ultimo_erro_gord", 0);
|
||||||
|
|
||||||
|
editor.putInt("cal_hoje", prefs.getInt("cal_hoje", 0) - calAntiga);
|
||||||
|
editor.putInt("prot_hoje", prefs.getInt("prot_hoje", 0) - protAntiga);
|
||||||
|
editor.putInt("hidr_hoje", prefs.getInt("hidr_hoje", 0) - hidrAntiga);
|
||||||
|
editor.putInt("gord_hoje", prefs.getInt("gord_hoje", 0) - gordAntiga);
|
||||||
|
|
||||||
|
editor.apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
private int extrairNumero(String texto, String inicio, String fim) {
|
private int extrairNumero(String texto, String inicio, String fim) {
|
||||||
|
|||||||
88
app/src/main/java/com/example/pap/MudarEmailActivity.java
Normal file
88
app/src/main/java/com/example/pap/MudarEmailActivity.java
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
package com.example.pap;
|
||||||
|
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.widget.Toast;
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import retrofit2.Call;
|
||||||
|
import retrofit2.Callback;
|
||||||
|
import retrofit2.Response;
|
||||||
|
|
||||||
|
public class MudarEmailActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
private EditText etAlterarEmail, etAlterarPassword1, etAlterarPassword2;
|
||||||
|
private Button btnConfirmarEmailNovo;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_mudar_email);
|
||||||
|
|
||||||
|
etAlterarEmail = findViewById(R.id.etAlterarEmail);
|
||||||
|
etAlterarPassword1 = findViewById(R.id.etAlterarPassword1);
|
||||||
|
etAlterarPassword2 = findViewById(R.id.etAlterarPassword2);
|
||||||
|
btnConfirmarEmailNovo = findViewById(R.id.btnConfirmarEmailNovo);
|
||||||
|
|
||||||
|
findViewById(R.id.btnVoltarMudarEmail).setOnClickListener(v -> finish());
|
||||||
|
|
||||||
|
SharedPreferences dadosPrefs = getSharedPreferences("MeusDadosApp", MODE_PRIVATE);
|
||||||
|
|
||||||
|
btnConfirmarEmailNovo.setOnClickListener(v -> {
|
||||||
|
String novoEmail = etAlterarEmail.getText().toString().trim();
|
||||||
|
String pass1 = etAlterarPassword1.getText().toString().trim();
|
||||||
|
String pass2 = etAlterarPassword2.getText().toString().trim();
|
||||||
|
|
||||||
|
if (novoEmail.isEmpty() || pass1.isEmpty() || pass2.isEmpty()) {
|
||||||
|
Toast.makeText(this, "Preenche todos os campos!", Toast.LENGTH_SHORT).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 1. Validação: Verifica se os dois campos de password antiga coincidem
|
||||||
|
if (!pass1.equals(pass2)) {
|
||||||
|
Toast.makeText(this, "As confirmações de password não coincidem!", Toast.LENGTH_SHORT).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. Validação: Verifica se a password escrita é mesmo a senha correta da conta
|
||||||
|
String passwordReal = dadosPrefs.getString("password", "");
|
||||||
|
if (!passwordReal.isEmpty() && !pass1.equals(passwordReal)) {
|
||||||
|
Toast.makeText(this, "A password atual introduzida está errada!", Toast.LENGTH_SHORT).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String token = dadosPrefs.getString("access_token", "");
|
||||||
|
if (token.isEmpty()) {
|
||||||
|
Toast.makeText(this, "Erro: Faz login novamente.", Toast.LENGTH_LONG).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Envia as alterações para o Supabase
|
||||||
|
Map<String, String> updates = new HashMap<>();
|
||||||
|
updates.put("email", novoEmail);
|
||||||
|
|
||||||
|
SupabaseApi api = SupabaseConfig.getRetrofit().create(SupabaseApi.class);
|
||||||
|
api.updateUserData(SupabaseConfig.SUPABASE_KEY, "Bearer " + token, updates).enqueue(new Callback<Void>() {
|
||||||
|
@Override
|
||||||
|
public void onResponse(Call<Void> call, Response<Void> response) {
|
||||||
|
if (response.isSuccessful()) {
|
||||||
|
Toast.makeText(MudarEmailActivity.this, "Vai à caixa do novo email confirmar!", Toast.LENGTH_LONG).show();
|
||||||
|
finish();
|
||||||
|
} else {
|
||||||
|
Toast.makeText(MudarEmailActivity.this, "Erro ao mudar o email no Supabase.", Toast.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(Call<Void> call, Throwable t) {
|
||||||
|
Toast.makeText(MudarEmailActivity.this, "Falha na internet.", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
93
app/src/main/java/com/example/pap/MudarPasswordActivity.java
Normal file
93
app/src/main/java/com/example/pap/MudarPasswordActivity.java
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
package com.example.pap;
|
||||||
|
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.widget.Toast;
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import retrofit2.Call;
|
||||||
|
import retrofit2.Callback;
|
||||||
|
import retrofit2.Response;
|
||||||
|
|
||||||
|
public class MudarPasswordActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
private EditText etPasswordAntiga, etNovaPassword1, etNovaPassword2;
|
||||||
|
private Button btnConfirmarPassword;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_mudar_password);
|
||||||
|
|
||||||
|
etPasswordAntiga = findViewById(R.id.etPasswordAntiga);
|
||||||
|
etNovaPassword1 = findViewById(R.id.etNovaPassword1);
|
||||||
|
etNovaPassword2 = findViewById(R.id.etNovaPassword2);
|
||||||
|
btnConfirmarPassword = findViewById(R.id.btnConfirmarPassword);
|
||||||
|
|
||||||
|
findViewById(R.id.btnVoltarMudarPassword).setOnClickListener(v -> finish());
|
||||||
|
|
||||||
|
SharedPreferences dadosPrefs = getSharedPreferences("MeusDadosApp", MODE_PRIVATE);
|
||||||
|
|
||||||
|
btnConfirmarPassword.setOnClickListener(v -> {
|
||||||
|
String passAntiga = etPasswordAntiga.getText().toString().trim();
|
||||||
|
String novaPass1 = etNovaPassword1.getText().toString().trim();
|
||||||
|
String novaPass2 = etNovaPassword2.getText().toString().trim();
|
||||||
|
|
||||||
|
if (passAntiga.isEmpty() || novaPass1.isEmpty() || novaPass2.isEmpty()) {
|
||||||
|
Toast.makeText(this, "Preenche todos os campos!", Toast.LENGTH_SHORT).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Confirma se as duas passwords novas são iguais
|
||||||
|
if (!novaPass1.equals(novaPass2)) {
|
||||||
|
Toast.makeText(this, "As passwords novas não coincidem!", Toast.LENGTH_SHORT).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Confirma se a password antiga escrita bate certo com a guardada no telemóvel
|
||||||
|
String passwordReal = dadosPrefs.getString("password", "");
|
||||||
|
if (!passwordReal.isEmpty() && !passAntiga.equals(passwordReal)) {
|
||||||
|
Toast.makeText(this, "A password antiga está errada!", Toast.LENGTH_SHORT).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String token = dadosPrefs.getString("access_token", "");
|
||||||
|
if (token.isEmpty()) {
|
||||||
|
Toast.makeText(this, "Erro: Faz login novamente.", Toast.LENGTH_SHORT).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Atualizar na nuvem
|
||||||
|
Map<String, String> updates = new HashMap<>();
|
||||||
|
updates.put("password", novaPass1);
|
||||||
|
|
||||||
|
SupabaseApi api = SupabaseConfig.getRetrofit().create(SupabaseApi.class);
|
||||||
|
api.updateUserData(SupabaseConfig.SUPABASE_KEY, "Bearer " + token, updates).enqueue(new Callback<Void>() {
|
||||||
|
@Override
|
||||||
|
public void onResponse(Call<Void> call, Response<Void> response) {
|
||||||
|
if (response.isSuccessful()) {
|
||||||
|
// Guardar a nova password na memória para os próximos testes
|
||||||
|
SharedPreferences.Editor editor = dadosPrefs.edit();
|
||||||
|
editor.putString("password", novaPass1);
|
||||||
|
editor.apply();
|
||||||
|
|
||||||
|
Toast.makeText(MudarPasswordActivity.this, "Password alterada com sucesso!", Toast.LENGTH_SHORT).show();
|
||||||
|
finish();
|
||||||
|
} else {
|
||||||
|
Toast.makeText(MudarPasswordActivity.this, "Erro ao mudar password.", Toast.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(Call<Void> call, Throwable t) {
|
||||||
|
Toast.makeText(MudarPasswordActivity.this, "Falha na internet.", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,44 +10,81 @@ import androidx.appcompat.app.AppCompatActivity;
|
|||||||
|
|
||||||
public class PerfilActivity extends AppCompatActivity {
|
public class PerfilActivity extends AppCompatActivity {
|
||||||
|
|
||||||
private TextView tvPerfilPontos, tvPerfilDesafios, tvPerfilSequencia;
|
private TextView tvPerfilNome, tvPerfilPontos, tvPerfilDesafios, tvPerfilSequencia;
|
||||||
|
private TextView tvPerfilEmail, tvPerfilPassword;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_perfil);
|
setContentView(R.layout.activity_perfil);
|
||||||
|
|
||||||
tvPerfilPontos = findViewById(R.id.tvPerfilPontos);
|
try {
|
||||||
tvPerfilDesafios = findViewById(R.id.tvPerfilDesafios);
|
tvPerfilNome = findViewById(R.id.tvPerfilNome);
|
||||||
tvPerfilSequencia = findViewById(R.id.tvPerfilSequencia);
|
tvPerfilPontos = findViewById(R.id.tvPerfilPontos);
|
||||||
|
tvPerfilDesafios = findViewById(R.id.tvPerfilDesafios);
|
||||||
|
tvPerfilSequencia = findViewById(R.id.tvPerfilSequencia);
|
||||||
|
|
||||||
Button btnDefinicoes = findViewById(R.id.btnDefinicoes);
|
// Ligar os novos textos do Email e Password
|
||||||
TextView btnVoltar = findViewById(R.id.btnVoltarPerfil);
|
tvPerfilEmail = findViewById(R.id.tvPerfilEmail);
|
||||||
|
tvPerfilPassword = findViewById(R.id.tvPerfilPassword);
|
||||||
|
|
||||||
// Ler a pontuação guardada (vamos ligar isto mais à frente)
|
Button btnDefinicoes = findViewById(R.id.btnDefinicoes);
|
||||||
|
TextView btnVoltar = findViewById(R.id.btnVoltarPerfil);
|
||||||
|
|
||||||
|
if (btnDefinicoes != null) {
|
||||||
|
btnDefinicoes.setOnClickListener(v -> {
|
||||||
|
Intent intent = new Intent(PerfilActivity.this, DefinicoesActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (btnVoltar != null) {
|
||||||
|
btnVoltar.setOnClickListener(v -> finish());
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
Toast.makeText(this, "Erro visual. Verifica o layout.", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onResume() {
|
||||||
|
super.onResume();
|
||||||
carregarProgresso();
|
carregarProgresso();
|
||||||
|
|
||||||
// Botão Definições
|
|
||||||
btnDefinicoes.setOnClickListener(v -> {
|
|
||||||
// Quando tiveres o ecrã de definições criado, trocas o Toast por isto:
|
|
||||||
// Intent intent = new Intent(PerfilActivity.this, DefinicoesActivity.class);
|
|
||||||
// startActivity(intent);
|
|
||||||
Toast.makeText(this, "A abrir Definições...", Toast.LENGTH_SHORT).show();
|
|
||||||
});
|
|
||||||
|
|
||||||
// Botão Voltar (manda-te de volta para o Home/Menu)
|
|
||||||
btnVoltar.setOnClickListener(v -> finish());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void carregarProgresso() {
|
private void carregarProgresso() {
|
||||||
SharedPreferences prefs = getSharedPreferences("DadosGamificacao", MODE_PRIVATE);
|
try {
|
||||||
|
// Puxa o nome, email e password
|
||||||
|
SharedPreferences perfilPrefs = getSharedPreferences("MeusDadosApp", MODE_PRIVATE);
|
||||||
|
|
||||||
int pontos = prefs.getInt("pontos", 0);
|
if (tvPerfilNome != null) tvPerfilNome.setText(perfilPrefs.getString("nome", "Utilizador"));
|
||||||
int desafios = prefs.getInt("desafios", 0);
|
if (tvPerfilEmail != null) tvPerfilEmail.setText(perfilPrefs.getString("email", "Sem Email"));
|
||||||
int sequencia = prefs.getInt("sequencia", 1);
|
if (tvPerfilPassword != null) tvPerfilPassword.setText(perfilPrefs.getString("password", "********"));
|
||||||
|
|
||||||
tvPerfilPontos.setText(String.valueOf(pontos));
|
// Puxa pontos e desafios
|
||||||
tvPerfilDesafios.setText(String.valueOf(desafios));
|
int pontos = 0;
|
||||||
tvPerfilSequencia.setText(String.valueOf(sequencia));
|
int desafios = 0;
|
||||||
|
try {
|
||||||
|
pontos = perfilPrefs.getInt("pontos", 0);
|
||||||
|
desafios = perfilPrefs.getInt("desafios_concluidos", 0);
|
||||||
|
} catch (Exception e) {
|
||||||
|
try {
|
||||||
|
String pts = perfilPrefs.getString("pontos", "0");
|
||||||
|
pontos = Integer.parseInt(pts.replaceAll("[^0-9]", ""));
|
||||||
|
} catch (Exception ignored) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Puxa a sequência
|
||||||
|
SharedPreferences gamificacaoPrefs = getSharedPreferences("DadosGamificacao", MODE_PRIVATE);
|
||||||
|
int sequencia = gamificacaoPrefs.getInt("sequencia", 1);
|
||||||
|
|
||||||
|
if (tvPerfilPontos != null) tvPerfilPontos.setText(String.valueOf(pontos));
|
||||||
|
if (tvPerfilDesafios != null) tvPerfilDesafios.setText(String.valueOf(desafios));
|
||||||
|
if (tvPerfilSequencia != null) tvPerfilSequencia.setText(String.valueOf(sequencia));
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:background="?android:attr/colorBackground"
|
android:background="#FFFFFF"
|
||||||
android:padding="24dp">
|
android:padding="24dp">
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
android:text="Definições"
|
android:text="Definições"
|
||||||
android:textSize="18sp"
|
android:textSize="18sp"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
android:textColor="?android:attr/textColorPrimary"
|
android:textColor="#1C1C1E"
|
||||||
android:layout_centerInParent="true" />
|
android:layout_centerInParent="true" />
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
@@ -40,34 +40,6 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<androidx.cardview.widget.CardView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginBottom="24dp"
|
|
||||||
app:cardCornerRadius="16dp"
|
|
||||||
app:cardElevation="0dp"
|
|
||||||
app:cardBackgroundColor="#F2F2F7">
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="horizontal"
|
|
||||||
android:padding="20dp"
|
|
||||||
android:gravity="center_vertical">
|
|
||||||
<TextView
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="Modo Escuro"
|
|
||||||
android:textSize="16sp"
|
|
||||||
android:textStyle="bold"
|
|
||||||
android:textColor="#1C1C1E"/>
|
|
||||||
<Switch
|
|
||||||
android:id="@+id/switchModoEscuro"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content" />
|
|
||||||
</LinearLayout>
|
|
||||||
</androidx.cardview.widget.CardView>
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
@@ -95,41 +67,61 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="50dp"
|
android:layout_height="50dp"
|
||||||
android:hint="Novo Nome"
|
android:hint="Novo Nome"
|
||||||
|
android:textColor="#1C1C1E"
|
||||||
android:background="@android:color/transparent"
|
android:background="@android:color/transparent"
|
||||||
android:inputType="textPersonName"
|
android:inputType="textPersonName"
|
||||||
android:layout_marginBottom="8dp"/>
|
android:layout_marginBottom="8dp"/>
|
||||||
<View android:layout_width="match_parent" android:layout_height="1dp" android:background="#E5E5EA" android:layout_marginBottom="8dp"/>
|
<View android:layout_width="match_parent" android:layout_height="1dp" android:background="#E5E5EA" android:layout_marginBottom="8dp"/>
|
||||||
|
|
||||||
<EditText
|
<Button
|
||||||
android:id="@+id/etNovoEmail"
|
android:id="@+id/btnIrMudarEmail"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="50dp"
|
android:layout_height="50dp"
|
||||||
android:hint="Novo Email"
|
android:text="Mudar Email"
|
||||||
android:background="@android:color/transparent"
|
android:textColor="#1C1C1E"
|
||||||
android:inputType="textEmailAddress"
|
android:backgroundTint="#E5E5EA"
|
||||||
android:layout_marginBottom="8dp"/>
|
android:layout_marginBottom="8dp"
|
||||||
|
app:cornerRadius="8dp"
|
||||||
|
android:elevation="0dp"
|
||||||
|
style="?android:attr/borderlessButtonStyle"/>
|
||||||
<View android:layout_width="match_parent" android:layout_height="1dp" android:background="#E5E5EA" android:layout_marginBottom="8dp"/>
|
<View android:layout_width="match_parent" android:layout_height="1dp" android:background="#E5E5EA" android:layout_marginBottom="8dp"/>
|
||||||
|
|
||||||
<EditText
|
<Button
|
||||||
android:id="@+id/etNovaPassword"
|
android:id="@+id/btnIrMudarPassword"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="50dp"
|
android:layout_height="50dp"
|
||||||
android:hint="Nova Password"
|
android:text="Mudar Password"
|
||||||
android:background="@android:color/transparent"
|
android:textColor="#1C1C1E"
|
||||||
android:inputType="textPassword"/>
|
android:backgroundTint="#E5E5EA"
|
||||||
|
app:cornerRadius="8dp"
|
||||||
|
android:elevation="0dp"
|
||||||
|
style="?android:attr/borderlessButtonStyle"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</androidx.cardview.widget.CardView>
|
</androidx.cardview.widget.CardView>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/btnGuardarAlteracoes"
|
android:id="@+id/btnGuardarNome"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="60dp"
|
android:layout_height="60dp"
|
||||||
android:text="Guardar Alterações"
|
android:text="Guardar Nome"
|
||||||
android:backgroundTint="#03A9F4"
|
android:backgroundTint="#03A9F4"
|
||||||
android:textColor="#FFFFFF"
|
android:textColor="#FFFFFF"
|
||||||
android:textSize="16sp"
|
android:textSize="16sp"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
app:cornerRadius="16dp"/>
|
app:cornerRadius="16dp"/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/btnSairConta"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="60dp"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:text="Terminar Sessão"
|
||||||
|
android:backgroundTint="#FF3B30"
|
||||||
|
android:textColor="#FFFFFF"
|
||||||
|
android:textSize="16sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
app:cornerRadius="16dp"
|
||||||
|
android:layout_marginBottom="24dp"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
@@ -114,7 +114,19 @@
|
|||||||
android:backgroundTint="#F2F2F7"
|
android:backgroundTint="#F2F2F7"
|
||||||
android:textColor="#1C1C1E"
|
android:textColor="#1C1C1E"
|
||||||
app:cornerRadius="16dp"
|
app:cornerRadius="16dp"
|
||||||
android:visibility="gone" />
|
android:visibility="gone"
|
||||||
|
android:layout_marginBottom="12dp"/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/btnCorrigir"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="60dp"
|
||||||
|
android:text="A IA errou? Corrigir"
|
||||||
|
android:textColor="#EF4444"
|
||||||
|
android:backgroundTint="#FEF2F2"
|
||||||
|
app:cornerRadius="16dp"
|
||||||
|
android:visibility="gone"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
@@ -198,7 +198,7 @@
|
|||||||
android:layout_marginStart="20dp">
|
android:layout_marginStart="20dp">
|
||||||
|
|
||||||
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Desafios Diários" android:textSize="17sp" android:textStyle="bold" android:textColor="#1C1C1E"/>
|
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Desafios Diários" android:textSize="17sp" android:textStyle="bold" android:textColor="#1C1C1E"/>
|
||||||
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Ganha pontos de recompensa" android:textSize="13sp" android:textColor="#8E8E93" android:layout_marginTop="2dp"/>
|
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Faça desafios para melhor o seu desempenho" android:textSize="13sp" android:textColor="#8E8E93" android:layout_marginTop="2dp"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="›" android:textSize="28sp" android:textColor="#C7C7CC" android:layout_marginStart="8dp"/>
|
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="›" android:textSize="28sp" android:textColor="#C7C7CC" android:layout_marginStart="8dp"/>
|
||||||
@@ -238,7 +238,7 @@
|
|||||||
android:layout_marginStart="20dp">
|
android:layout_marginStart="20dp">
|
||||||
|
|
||||||
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="O Meu Perfil" android:textSize="17sp" android:textStyle="bold" android:textColor="#1C1C1E"/>
|
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="O Meu Perfil" android:textSize="17sp" android:textStyle="bold" android:textColor="#1C1C1E"/>
|
||||||
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Dados, pontuação e definições" android:textSize="13sp" android:textColor="#8E8E93" android:layout_marginTop="2dp"/>
|
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Dados e definições" android:textSize="13sp" android:textColor="#8E8E93" android:layout_marginTop="2dp"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="›" android:textSize="28sp" android:textColor="#C7C7CC" android:layout_marginStart="8dp"/>
|
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="›" android:textSize="28sp" android:textColor="#C7C7CC" android:layout_marginStart="8dp"/>
|
||||||
|
|||||||
@@ -56,7 +56,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="55dp"
|
android:layout_height="55dp"
|
||||||
android:background="@android:color/transparent"
|
android:background="@android:color/transparent"
|
||||||
android:hint="A tua Password"
|
android:hint="A tua Palavra-passe"
|
||||||
android:inputType="textPassword"
|
android:inputType="textPassword"
|
||||||
android:paddingStart="16dp"
|
android:paddingStart="16dp"
|
||||||
android:paddingEnd="16dp"
|
android:paddingEnd="16dp"
|
||||||
|
|||||||
90
app/src/main/res/layout/activity_mudar_email.xml
Normal file
90
app/src/main/res/layout/activity_mudar_email.xml
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:background="#FFFFFF"
|
||||||
|
android:padding="24dp">
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="32dp">
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/btnVoltarMudarEmail"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Cancelar"
|
||||||
|
android:textSize="16sp"
|
||||||
|
android:textColor="#FF3B30"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:padding="8dp"/>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Mudar Email"
|
||||||
|
android:textSize="18sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:textColor="#1C1C1E"
|
||||||
|
android:layout_centerInParent="true" />
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
<androidx.cardview.widget.CardView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="24dp"
|
||||||
|
app:cardCornerRadius="16dp"
|
||||||
|
app:cardElevation="0dp"
|
||||||
|
app:cardBackgroundColor="#F2F2F7">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:padding="20dp">
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/etAlterarEmail"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="50dp"
|
||||||
|
android:hint="Novo Email"
|
||||||
|
android:textColor="#1C1C1E"
|
||||||
|
android:background="@android:color/transparent"
|
||||||
|
android:inputType="textEmailAddress"
|
||||||
|
android:layout_marginBottom="8dp"/>
|
||||||
|
<View android:layout_width="match_parent" android:layout_height="1dp" android:background="#E5E5EA" android:layout_marginBottom="8dp"/>
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/etAlterarPassword1"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="50dp"
|
||||||
|
android:hint="Escreve a tua Palavra-passe Atual"
|
||||||
|
android:textColor="#1C1C1E"
|
||||||
|
android:background="@android:color/transparent"
|
||||||
|
android:inputType="textPassword"
|
||||||
|
android:layout_marginBottom="8dp"/>
|
||||||
|
<View android:layout_width="match_parent" android:layout_height="1dp" android:background="#E5E5EA" android:layout_marginBottom="8dp"/>
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/etAlterarPassword2"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="50dp"
|
||||||
|
android:hint="Confirma a tua Palavra-passe Atual"
|
||||||
|
android:textColor="#1C1C1E"
|
||||||
|
android:background="@android:color/transparent"
|
||||||
|
android:inputType="textPassword"/>
|
||||||
|
</LinearLayout>
|
||||||
|
</androidx.cardview.widget.CardView>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/btnConfirmarEmailNovo"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="60dp"
|
||||||
|
android:text="Confirmar Alteração"
|
||||||
|
android:backgroundTint="#03A9F4"
|
||||||
|
android:textColor="#FFFFFF"
|
||||||
|
android:textSize="16sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
app:cornerRadius="16dp"/>
|
||||||
|
</LinearLayout>
|
||||||
90
app/src/main/res/layout/activity_mudar_password.xml
Normal file
90
app/src/main/res/layout/activity_mudar_password.xml
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:background="#FFFFFF"
|
||||||
|
android:padding="24dp">
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="32dp">
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/btnVoltarMudarPassword"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Cancelar"
|
||||||
|
android:textSize="16sp"
|
||||||
|
android:textColor="#FF3B30"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:padding="8dp"/>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Mudar Password"
|
||||||
|
android:textSize="18sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:textColor="#1C1C1E"
|
||||||
|
android:layout_centerInParent="true" />
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
<androidx.cardview.widget.CardView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="24dp"
|
||||||
|
app:cardCornerRadius="16dp"
|
||||||
|
app:cardElevation="0dp"
|
||||||
|
app:cardBackgroundColor="#F2F2F7">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:padding="20dp">
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/etPasswordAntiga"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="50dp"
|
||||||
|
android:hint="Palavra-passe Antiga"
|
||||||
|
android:textColor="#1C1C1E"
|
||||||
|
android:background="@android:color/transparent"
|
||||||
|
android:inputType="textPassword"
|
||||||
|
android:layout_marginBottom="8dp"/>
|
||||||
|
<View android:layout_width="match_parent" android:layout_height="1dp" android:background="#E5E5EA" android:layout_marginBottom="8dp"/>
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/etNovaPassword1"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="50dp"
|
||||||
|
android:hint="Nova Palavra-passe"
|
||||||
|
android:textColor="#1C1C1E"
|
||||||
|
android:background="@android:color/transparent"
|
||||||
|
android:inputType="textPassword"
|
||||||
|
android:layout_marginBottom="8dp"/>
|
||||||
|
<View android:layout_width="match_parent" android:layout_height="1dp" android:background="#E5E5EA" android:layout_marginBottom="8dp"/>
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/etNovaPassword2"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="50dp"
|
||||||
|
android:hint="Confirma a Nova Palavra-passe"
|
||||||
|
android:textColor="#1C1C1E"
|
||||||
|
android:background="@android:color/transparent"
|
||||||
|
android:inputType="textPassword"/>
|
||||||
|
</LinearLayout>
|
||||||
|
</androidx.cardview.widget.CardView>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/btnConfirmarPassword"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="60dp"
|
||||||
|
android:text="Guardar Password"
|
||||||
|
android:backgroundTint="#03A9F4"
|
||||||
|
android:textColor="#FFFFFF"
|
||||||
|
android:textSize="16sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
app:cornerRadius="16dp"/>
|
||||||
|
</LinearLayout>
|
||||||
@@ -47,32 +47,15 @@
|
|||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:gravity="center_horizontal">
|
android:gravity="center_horizontal">
|
||||||
|
|
||||||
<androidx.cardview.widget.CardView
|
|
||||||
android:layout_width="120dp"
|
|
||||||
android:layout_height="120dp"
|
|
||||||
app:cardCornerRadius="60dp"
|
|
||||||
app:cardElevation="0dp"
|
|
||||||
app:cardBackgroundColor="#F2F2F7"
|
|
||||||
android:layout_marginTop="10dp">
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/ivFotoPerfil"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:src="@android:drawable/ic_menu_gallery"
|
|
||||||
android:scaleType="centerCrop"
|
|
||||||
android:padding="30dp"
|
|
||||||
app:tint="#C7C7CC"/>
|
|
||||||
</androidx.cardview.widget.CardView>
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tvPerfilNome"
|
android:id="@+id/tvPerfilNome"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Nome do Utilizador"
|
android:text="Nome do Utilizador"
|
||||||
android:textSize="22sp"
|
android:textSize="24sp"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
android:textColor="#1C1C1E"
|
android:textColor="#1C1C1E"
|
||||||
android:layout_marginTop="16dp"
|
android:layout_marginTop="20dp"
|
||||||
android:layout_marginBottom="32dp"/>
|
android:layout_marginBottom="32dp"/>
|
||||||
|
|
||||||
<androidx.cardview.widget.CardView
|
<androidx.cardview.widget.CardView
|
||||||
@@ -81,7 +64,7 @@
|
|||||||
app:cardCornerRadius="24dp"
|
app:cardCornerRadius="24dp"
|
||||||
app:cardElevation="0dp"
|
app:cardElevation="0dp"
|
||||||
app:cardBackgroundColor="#F2F2F7"
|
app:cardBackgroundColor="#F2F2F7"
|
||||||
android:layout_marginBottom="32dp">
|
android:layout_marginBottom="24dp">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -97,7 +80,7 @@
|
|||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:gravity="center">
|
android:gravity="center">
|
||||||
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="⭐" android:textSize="24sp" android:layout_marginBottom="4dp"/>
|
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="⭐" android:textSize="24sp" android:layout_marginBottom="4dp"/>
|
||||||
<TextView android:id="@+id/tvPerfilPontos" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="1450" android:textSize="20sp" android:textStyle="bold" android:textColor="#1C1C1E"/>
|
<TextView android:id="@+id/tvPerfilPontos" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="0" android:textSize="20sp" android:textStyle="bold" android:textColor="#1C1C1E"/>
|
||||||
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Pontos" android:textSize="12sp" android:textColor="#8E8E93"/>
|
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Pontos" android:textSize="12sp" android:textColor="#8E8E93"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
@@ -110,7 +93,7 @@
|
|||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:gravity="center">
|
android:gravity="center">
|
||||||
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="🏆" android:textSize="24sp" android:layout_marginBottom="4dp"/>
|
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="🏆" android:textSize="24sp" android:layout_marginBottom="4dp"/>
|
||||||
<TextView android:id="@+id/tvPerfilDesafios" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="28" android:textSize="20sp" android:textStyle="bold" android:textColor="#1C1C1E"/>
|
<TextView android:id="@+id/tvPerfilDesafios" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="0" android:textSize="20sp" android:textStyle="bold" android:textColor="#1C1C1E"/>
|
||||||
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Desafios" android:textSize="12sp" android:textColor="#8E8E93"/>
|
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Desafios" android:textSize="12sp" android:textColor="#8E8E93"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
@@ -123,17 +106,40 @@
|
|||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:gravity="center">
|
android:gravity="center">
|
||||||
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="🔥" android:textSize="24sp" android:layout_marginBottom="4dp"/>
|
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="🔥" android:textSize="24sp" android:layout_marginBottom="4dp"/>
|
||||||
<TextView android:id="@+id/tvPerfilSequencia" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="5" android:textSize="20sp" android:textStyle="bold" android:textColor="#1C1C1E"/>
|
<TextView android:id="@+id/tvPerfilSequencia" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="1" android:textSize="20sp" android:textStyle="bold" android:textColor="#1C1C1E"/>
|
||||||
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Sequência" android:textSize="12sp" android:textColor="#8E8E93"/>
|
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Sequência" android:textSize="12sp" android:textColor="#8E8E93"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</androidx.cardview.widget.CardView>
|
</androidx.cardview.widget.CardView>
|
||||||
|
|
||||||
|
<androidx.cardview.widget.CardView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:cardCornerRadius="24dp"
|
||||||
|
app:cardElevation="0dp"
|
||||||
|
app:cardBackgroundColor="#F8FAFC"
|
||||||
|
android:layout_marginBottom="24dp">
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:padding="20dp">
|
||||||
|
|
||||||
|
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Email Registado" android:textSize="12sp" android:textColor="#8E8E93" android:textStyle="bold"/>
|
||||||
|
<TextView android:id="@+id/tvPerfilEmail" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="email@exemplo.com" android:textSize="16sp" android:textColor="#1C1C1E" android:layout_marginBottom="12dp" android:layout_marginTop="2dp"/>
|
||||||
|
|
||||||
|
<View android:layout_width="match_parent" android:layout_height="1dp" android:background="#E2E8F0" android:layout_marginBottom="12dp"/>
|
||||||
|
|
||||||
|
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Palavra-passe" android:textSize="12sp" android:textColor="#8E8E93" android:textStyle="bold"/>
|
||||||
|
<TextView android:id="@+id/tvPerfilPassword" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="********" android:textSize="16sp" android:textColor="#1C1C1E" android:layout_marginTop="2dp"/>
|
||||||
|
</LinearLayout>
|
||||||
|
</androidx.cardview.widget.CardView>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/btnDefinicoes"
|
android:id="@+id/btnDefinicoes"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="60dp"
|
android:layout_height="60dp"
|
||||||
android:text="Definições da Conta"
|
android:text="Editar Conta"
|
||||||
android:textSize="16sp"
|
android:textSize="16sp"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
android:textColor="#FFFFFF"
|
android:textColor="#FFFFFF"
|
||||||
|
|||||||
@@ -77,7 +77,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="55dp"
|
android:layout_height="55dp"
|
||||||
android:background="@android:color/transparent"
|
android:background="@android:color/transparent"
|
||||||
android:hint="Password (mín. 6 letras)"
|
android:hint="Palavra-passe (mín. 6 letras)"
|
||||||
android:inputType="textPassword"
|
android:inputType="textPassword"
|
||||||
android:paddingStart="16dp"
|
android:paddingStart="16dp"
|
||||||
android:paddingEnd="16dp"/>
|
android:paddingEnd="16dp"/>
|
||||||
|
|||||||
Reference in New Issue
Block a user