corrige o erro da camera e da ia não funcionar e mudar o layout futuramente
This commit is contained in:
@@ -43,4 +43,9 @@ dependencies {
|
||||
implementation("com.squareup.retrofit2:retrofit:2.9.0")
|
||||
implementation("com.squareup.retrofit2:converter-gson:2.9.0")
|
||||
implementation("com.squareup.okhttp3:logging-interceptor:4.9.0")
|
||||
implementation("androidx.camera:camera-core:1.3.1")
|
||||
implementation("androidx.camera:camera-camera2:1.3.1")
|
||||
implementation("androidx.camera:camera-lifecycle:1.3.1")
|
||||
implementation("androidx.camera:camera-view:1.3.1")
|
||||
implementation("com.squareup.okhttp3:okhttp:4.12.0")
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-feature android:name="android.hardware.camera" android:required="false" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
@@ -14,7 +15,10 @@
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.PAP">
|
||||
<activity
|
||||
android:name=".Ingrediente"
|
||||
android:name=".EditarPerfilActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".DefinicoesActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".PerfilActivity"
|
||||
|
||||
14
app/src/main/java/com/example/pap/AiApi.java
Normal file
14
app/src/main/java/com/example/pap/AiApi.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package com.example.pap;
|
||||
|
||||
import retrofit2.Call;
|
||||
import retrofit2.http.Body;
|
||||
import retrofit2.http.Header;
|
||||
import retrofit2.http.POST;
|
||||
|
||||
public interface AiApi {
|
||||
@POST("chat/completions")
|
||||
Call<AiResponse> analisarImagem(
|
||||
@Header("Authorization") String authHeader,
|
||||
@Body AiRequest request
|
||||
);
|
||||
}
|
||||
19
app/src/main/java/com/example/pap/AiConfig.java
Normal file
19
app/src/main/java/com/example/pap/AiConfig.java
Normal file
@@ -0,0 +1,19 @@
|
||||
package com.example.pap;
|
||||
|
||||
import retrofit2.Retrofit;
|
||||
import retrofit2.converter.gson.GsonConverterFactory;
|
||||
|
||||
public class AiConfig {
|
||||
private static Retrofit retrofit;
|
||||
private static final String BASE_URL = "https://openrouter.ai/api/v1/";
|
||||
|
||||
public static Retrofit getRetrofit() {
|
||||
if (retrofit == null) {
|
||||
retrofit = new Retrofit.Builder()
|
||||
.baseUrl(BASE_URL)
|
||||
.addConverterFactory(GsonConverterFactory.create())
|
||||
.build();
|
||||
}
|
||||
return retrofit;
|
||||
}
|
||||
}
|
||||
54
app/src/main/java/com/example/pap/AiModels.java
Normal file
54
app/src/main/java/com/example/pap/AiModels.java
Normal file
@@ -0,0 +1,54 @@
|
||||
package com.example.pap;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
class AiRequest {
|
||||
// A MAGIA ESTÁ AQUI: Isto escolhe automaticamente a IA visual que estiver a funcionar hoje!
|
||||
String model = "openrouter/free";
|
||||
List<Message> messages;
|
||||
|
||||
AiRequest(List<Message> messages) { this.messages = messages; }
|
||||
}
|
||||
|
||||
class Message {
|
||||
String role;
|
||||
List<ContentPart> content;
|
||||
|
||||
Message(String role, List<ContentPart> content) {
|
||||
this.role = role;
|
||||
this.content = content;
|
||||
}
|
||||
}
|
||||
|
||||
class ContentPart {
|
||||
String type;
|
||||
String text;
|
||||
ImageUrl image_url;
|
||||
|
||||
ContentPart(String type, String text) {
|
||||
this.type = type;
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
ContentPart(String type, ImageUrl image_url) {
|
||||
this.type = type;
|
||||
this.image_url = image_url;
|
||||
}
|
||||
}
|
||||
|
||||
class ImageUrl {
|
||||
String url;
|
||||
ImageUrl(String url) { this.url = url; }
|
||||
}
|
||||
|
||||
class AiResponse {
|
||||
List<Choice> choices;
|
||||
|
||||
class Choice {
|
||||
MessageResponse message;
|
||||
}
|
||||
|
||||
class MessageResponse {
|
||||
String content;
|
||||
}
|
||||
}
|
||||
@@ -1,138 +1,168 @@
|
||||
package com.example.pap;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.GradientDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import okhttp3.Call;
|
||||
import okhttp3.Callback;
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.RequestBody;
|
||||
import okhttp3.Response;
|
||||
|
||||
public class ChatActivity extends AppCompatActivity {
|
||||
|
||||
private EditText etMensagem;
|
||||
private ImageButton btnEnviar;
|
||||
private LinearLayout chatLayout;
|
||||
private ScrollView chatScrollView;
|
||||
private EditText etNovaMensagem;
|
||||
private Button btnEnviarMensagem;
|
||||
private Button btnVoltarChat;
|
||||
|
||||
// A TUA CHAVE DA GOOGLE VEM PARA AQUI!
|
||||
private static final String GEMINI_API_KEY = "AQ.Ab8RN6IfhsFBO3UOpK3vYd7BrR2nfFb-mVE--nvqRnR46hB36A";
|
||||
|
||||
// O motor do Gemini 1.5 Flash
|
||||
private static final String GEMINI_URL = "https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash:generateContent?key=" + GEMINI_API_KEY;
|
||||
|
||||
private OkHttpClient client;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_chat);
|
||||
|
||||
// 1. Associar os componentes do layout
|
||||
etMensagem = findViewById(R.id.etMensagem);
|
||||
btnEnviar = findViewById(R.id.btnEnviar);
|
||||
chatLayout = findViewById(R.id.chatLayout);
|
||||
chatScrollView = findViewById(R.id.chatScrollView);
|
||||
etNovaMensagem = findViewById(R.id.etNovaMensagem);
|
||||
btnEnviarMensagem = findViewById(R.id.btnEnviarMensagem);
|
||||
btnVoltarChat = findViewById(R.id.btnVoltarChat);
|
||||
|
||||
// Mensagem inicial da IA ao abrir o ecrã
|
||||
adicionarMensagemBalao("Olá! Sou o teu IA Coach de Saúde. Como te posso ajudar hoje na tua jornada de emagrecimento?", false);
|
||||
client = new OkHttpClient();
|
||||
|
||||
// 2. Clique no botão de Enviar
|
||||
btnEnviarMensagem.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
String mensagemUser = etNovaMensagem.getText().toString().trim();
|
||||
// Dá as boas vindas
|
||||
adicionarBalaoNoEcra("Olá! Sou o NutriChat AI 🤖. O que comeste hoje ou que dúvidas tens sobre a tua dieta?", false);
|
||||
|
||||
if (!mensagemUser.isEmpty()) {
|
||||
// Adiciona a mensagem do utilizador no ecrã
|
||||
adicionarMensagemBalao(mensagemUser, true);
|
||||
|
||||
// Limpa a caixa de texto
|
||||
etNovaMensagem.setText("");
|
||||
|
||||
// Simula a IA a processar e a responder
|
||||
simularRespostaDaIA(mensagemUser);
|
||||
btnEnviar.setOnClickListener(v -> {
|
||||
String pergunta = etMensagem.getText().toString().trim();
|
||||
if (pergunta.isEmpty()) {
|
||||
Toast.makeText(this, "Escreve alguma merda primeiro!", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// 3. Clique no botão de Voltar
|
||||
btnVoltarChat.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
// 1. Mostrar a mensagem do utilizador no ecrã
|
||||
adicionarBalaoNoEcra(pergunta, true);
|
||||
etMensagem.setText(""); // Limpa a caixa de texto
|
||||
|
||||
// 2. Chamar a Inteligência Artificial
|
||||
chamarGemini(pergunta);
|
||||
});
|
||||
}
|
||||
|
||||
// Passo 3: Função para desenhar os balões de conversa no ecrã
|
||||
private void adicionarMensagemBalao(String texto, boolean isUser) {
|
||||
TextView textView = new TextView(this);
|
||||
textView.setText(texto);
|
||||
textView.setTextSize(16f);
|
||||
textView.setPadding(32, 24, 32, 24);
|
||||
// Função que desenha os balões de conversa no ecrã
|
||||
private void adicionarBalaoNoEcra(String texto, boolean isUser) {
|
||||
runOnUiThread(() -> {
|
||||
TextView tv = new TextView(this);
|
||||
tv.setText(texto);
|
||||
tv.setTextSize(16f);
|
||||
tv.setPadding(30, 20, 30, 20);
|
||||
tv.setTextColor(isUser ? Color.WHITE : Color.parseColor("#1E293B"));
|
||||
|
||||
// Configurar as margens e o alinhamento (Direita = Utilizador, Esquerda = IA)
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT
|
||||
);
|
||||
params.setMargins(0, 16, 0, 16);
|
||||
|
||||
// Configurar o design arredondado do balão
|
||||
GradientDrawable background = new GradientDrawable();
|
||||
background.setCornerRadius(32f);
|
||||
params.setMargins(0, 10, 0, 10);
|
||||
|
||||
// Se for o utilizador, o balão vai para a direita e fica azul
|
||||
if (isUser) {
|
||||
// Estilo do Utilizador (Fundo Verde, Texto Branco, Alinhado à direita)
|
||||
params.gravity = Gravity.END;
|
||||
background.setColor(Color.parseColor("#4CAF50"));
|
||||
textView.setTextColor(Color.WHITE);
|
||||
tv.setBackgroundResource(R.drawable.balao_user); // Já vamos criar isto!
|
||||
} else {
|
||||
// Estilo da IA (Fundo Cinza/Branco, Texto Escuro, Alinhado à esquerda)
|
||||
// Se for a IA, o balão vai para a esquerda e fica branco/cinza
|
||||
params.gravity = Gravity.START;
|
||||
background.setColor(Color.parseColor("#FFFFFF"));
|
||||
textView.setTextColor(Color.parseColor("#2E3D32"));
|
||||
textView.setElevation(4f); // Dá uma pequena sombra ao balão da IA
|
||||
tv.setBackgroundResource(R.drawable.balao_ai); // Já vamos criar isto!
|
||||
}
|
||||
|
||||
textView.setLayoutParams(params);
|
||||
textView.setBackground(background);
|
||||
tv.setLayoutParams(params);
|
||||
chatLayout.addView(tv);
|
||||
|
||||
// Adicionar o balão ao ecrã
|
||||
chatLayout.addView(textView);
|
||||
|
||||
// Fazer scroll automático para baixo para ver a nova mensagem
|
||||
chatScrollView.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
chatScrollView.fullScroll(ScrollView.FOCUS_DOWN);
|
||||
}
|
||||
// Faz scroll automático para o fundo para ver a mensagem nova
|
||||
chatScrollView.post(() -> chatScrollView.fullScroll(ScrollView.FOCUS_DOWN));
|
||||
});
|
||||
}
|
||||
|
||||
// Passo 4: Função para simular a inteligência da IA
|
||||
private void simularRespostaDaIA(String perguntaUtilizador) {
|
||||
perguntaUtilizador = perguntaUtilizador.toLowerCase();
|
||||
final String resposta;
|
||||
// Função que vai à internet falar com o cérebro da Google
|
||||
private void chamarGemini(String pergunta) {
|
||||
try {
|
||||
// Instrução secreta para ele agir como Nutricionista
|
||||
String promptCompleto = "Aja como um nutricionista simpático e profissional. Responda de forma curta e direta à seguinte mensagem do utilizador: " + pergunta;
|
||||
|
||||
// Regras simples para fingir que a IA está a entender a pergunta
|
||||
if (perguntaUtilizador.contains("água") || perguntaUtilizador.contains("agua")) {
|
||||
resposta = "A hidratação é fundamental! O ideal é beberes pelo menos 2 a 3 litros de água por dia. Já bebeste algum copo hoje?";
|
||||
} else if (perguntaUtilizador.contains("comer") || perguntaUtilizador.contains("fome") || perguntaUtilizador.contains("dieta")) {
|
||||
resposta = "Se sentires fome entre as refeições, opta por snacks saudáveis como uma peça de fruta ou um punhado de frutos secos. Evita os doces!";
|
||||
} else if (perguntaUtilizador.contains("treino") || perguntaUtilizador.contains("exercício") || perguntaUtilizador.contains("correr")) {
|
||||
resposta = "Excelente! O exercício acelera o metabolismo. Lembra-te que a consistência é mais importante do que a intensidade. 30 minutos de caminhada já fazem a diferença.";
|
||||
} else {
|
||||
resposta = "Essa é uma ótima questão! O segredo do emagrecimento é o défice calórico aliado a bons hábitos. Continua focado, estou aqui para te apoiar em cada passo!";
|
||||
}
|
||||
// Construir o JSON que o Gemini exige
|
||||
JSONObject part = new JSONObject();
|
||||
part.put("text", promptCompleto);
|
||||
JSONArray parts = new JSONArray();
|
||||
parts.put(part);
|
||||
JSONObject content = new JSONObject();
|
||||
content.put("parts", parts);
|
||||
JSONArray contents = new JSONArray();
|
||||
contents.put(content);
|
||||
JSONObject jsonBody = new JSONObject();
|
||||
jsonBody.put("contents", contents);
|
||||
|
||||
// Simular um tempo de "pensamento" da IA (espera 1.5 segundos antes de mostrar a resposta)
|
||||
new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
|
||||
RequestBody body = RequestBody.create(jsonBody.toString(), MediaType.get("application/json; charset=utf-8"));
|
||||
Request request = new Request.Builder()
|
||||
.url(GEMINI_URL)
|
||||
.post(body)
|
||||
.build();
|
||||
|
||||
// Fazer a chamada fora da Thread principal para a app não encravar
|
||||
client.newCall(request).enqueue(new Callback() {
|
||||
@Override
|
||||
public void run() {
|
||||
adicionarMensagemBalao(resposta, false);
|
||||
public void onFailure(Call call, IOException e) {
|
||||
adicionarBalaoNoEcra("Oops! Fiquei sem internet ou deu merda na ligação. 🔌", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(Call call, Response response) throws IOException {
|
||||
if (response.isSuccessful()) {
|
||||
try {
|
||||
String respostaJSON = response.body().string();
|
||||
JSONObject jsonObject = new JSONObject(respostaJSON);
|
||||
// Escarafunchar o JSON para tirar só o texto da resposta
|
||||
String respostaIA = jsonObject.getJSONArray("candidates")
|
||||
.getJSONObject(0)
|
||||
.getJSONObject("content")
|
||||
.getJSONArray("parts")
|
||||
.getJSONObject(0)
|
||||
.getString("text");
|
||||
|
||||
// Mostrar a resposta no ecrã
|
||||
adicionarBalaoNoEcra(respostaIA, false);
|
||||
|
||||
} catch (Exception e) {
|
||||
adicionarBalaoNoEcra("Deu um nó no meu cérebro ao ler os dados. 🤯", false);
|
||||
}
|
||||
} else {
|
||||
adicionarBalaoNoEcra("Erro da Google: " + response.code(), false);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}, 1500);
|
||||
}
|
||||
}
|
||||
237
app/src/main/java/com/example/pap/DefinicoesActivity.java
Normal file
237
app/src/main/java/com/example/pap/DefinicoesActivity.java
Normal file
@@ -0,0 +1,237 @@
|
||||
package com.example.pap;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.text.InputType;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.Toast;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.app.AppCompatDelegate;
|
||||
import androidx.appcompat.widget.SwitchCompat;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
public class DefinicoesActivity extends AppCompatActivity {
|
||||
|
||||
private SwitchCompat switchDarkMode;
|
||||
private Button btnEditarNome, btnMudarEmail, btnMudarPass, btnVoltarDef;
|
||||
private SharedPreferences sharedPreferences;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_definicoes);
|
||||
|
||||
// Iniciar a memória local do telemóvel
|
||||
sharedPreferences = getSharedPreferences("MeusDadosApp", MODE_PRIVATE);
|
||||
|
||||
// Ligar os elementos do design ao código
|
||||
switchDarkMode = findViewById(R.id.switchDarkMode);
|
||||
btnEditarNome = findViewById(R.id.btnEditarNome);
|
||||
btnMudarEmail = findViewById(R.id.btnMudarEmail);
|
||||
btnMudarPass = findViewById(R.id.btnMudarPass);
|
||||
btnVoltarDef = findViewById(R.id.btnVoltarDef);
|
||||
|
||||
// 1. Lógica do Modo Escuro
|
||||
boolean isDarkMode = sharedPreferences.getBoolean("dark_mode", false);
|
||||
switchDarkMode.setChecked(isDarkMode);
|
||||
|
||||
switchDarkMode.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||
if (isChecked) {
|
||||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
|
||||
} else {
|
||||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
|
||||
}
|
||||
sharedPreferences.edit().putBoolean("dark_mode", isChecked).apply();
|
||||
});
|
||||
|
||||
// Configurar os cliques nos botões
|
||||
btnEditarNome.setOnClickListener(v -> mostrarPopupNome());
|
||||
btnMudarEmail.setOnClickListener(v -> mostrarPopupEmail());
|
||||
btnMudarPass.setOnClickListener(v -> mostrarPopupPassword());
|
||||
btnVoltarDef.setOnClickListener(v -> finish());
|
||||
}
|
||||
|
||||
// --- FUNÇÕES DOS POP-UPS ---
|
||||
|
||||
private void mostrarPopupNome() {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setTitle("Mudar Nome");
|
||||
|
||||
final EditText input = new EditText(this);
|
||||
input.setHint("Novo nome");
|
||||
builder.setView(input);
|
||||
|
||||
builder.setPositiveButton("Guardar", (dialog, which) -> {
|
||||
String novoNome = input.getText().toString().trim();
|
||||
if (!novoNome.isEmpty()) {
|
||||
sharedPreferences.edit().putString("nome", novoNome).apply();
|
||||
Toast.makeText(this, "Nome atualizado com sucesso!", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
builder.show();
|
||||
}
|
||||
|
||||
private void mostrarPopupEmail() {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setTitle("Alterar Email");
|
||||
|
||||
LinearLayout layout = new LinearLayout(this);
|
||||
layout.setOrientation(LinearLayout.VERTICAL);
|
||||
layout.setPadding(50, 20, 50, 0);
|
||||
|
||||
final EditText etPassAtual = new EditText(this);
|
||||
etPassAtual.setHint("A tua Password atual");
|
||||
etPassAtual.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
|
||||
layout.addView(etPassAtual);
|
||||
|
||||
final EditText etNovoEmail = new EditText(this);
|
||||
etNovoEmail.setHint("Novo Email");
|
||||
layout.addView(etNovoEmail);
|
||||
|
||||
builder.setView(layout);
|
||||
builder.setPositiveButton("Alterar", (dialog, which) -> {
|
||||
String passAtual = etPassAtual.getText().toString().trim();
|
||||
String novoEmail = etNovoEmail.getText().toString().trim();
|
||||
String emailAtual = sharedPreferences.getString("email", "");
|
||||
|
||||
if (passAtual.isEmpty() || novoEmail.isEmpty()) {
|
||||
Toast.makeText(this, "Preenche todos os campos!", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
|
||||
SupabaseApi api = SupabaseConfig.getRetrofit().create(SupabaseApi.class);
|
||||
UserCredentials creds = new UserCredentials(emailAtual, passAtual);
|
||||
|
||||
// Confirma a identidade do utilizador (Mini-login)
|
||||
api.login(SupabaseConfig.SUPABASE_KEY, creds).enqueue(new Callback<SupabaseResponse>() {
|
||||
@Override
|
||||
public void onResponse(Call<SupabaseResponse> call, Response<SupabaseResponse> response) {
|
||||
if (response.isSuccessful() && response.body() != null) {
|
||||
String freshToken = response.body().access_token;
|
||||
|
||||
// Envia o pedido de alteração de email para o Supabase
|
||||
Map<String, String> updates = new HashMap<>();
|
||||
updates.put("email", novoEmail);
|
||||
|
||||
api.updateUserData(SupabaseConfig.SUPABASE_KEY, "Bearer " + freshToken, updates).enqueue(new Callback<Void>() {
|
||||
@Override
|
||||
public void onResponse(Call<Void> call, Response<Void> response) {
|
||||
if (response.isSuccessful()) {
|
||||
// Apenas avisa o utilizador. O email só muda após clicar no link!
|
||||
Toast.makeText(DefinicoesActivity.this, "Link enviado! Verifica a tua nova caixa de correio para confirmar.", Toast.LENGTH_LONG).show();
|
||||
} else {
|
||||
Toast.makeText(DefinicoesActivity.this, "Erro ao tentar enviar o email de confirmação.", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<Void> call, Throwable t) {
|
||||
Toast.makeText(DefinicoesActivity.this, "Verifica a tua ligação à internet!", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
Toast.makeText(DefinicoesActivity.this, "A password atual está incorreta!", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<SupabaseResponse> call, Throwable t) {
|
||||
Toast.makeText(DefinicoesActivity.this, "Verifica a tua ligação à internet!", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
});
|
||||
builder.show();
|
||||
}
|
||||
|
||||
private void mostrarPopupPassword() {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setTitle("Alterar Password");
|
||||
|
||||
LinearLayout layout = new LinearLayout(this);
|
||||
layout.setOrientation(LinearLayout.VERTICAL);
|
||||
layout.setPadding(50, 20, 50, 0);
|
||||
|
||||
final EditText etAntiga = new EditText(this);
|
||||
etAntiga.setHint("Password Antiga");
|
||||
etAntiga.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
|
||||
layout.addView(etAntiga);
|
||||
|
||||
final EditText etNova = new EditText(this);
|
||||
etNova.setHint("Nova Password (min. 6 caracteres)");
|
||||
etNova.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
|
||||
layout.addView(etNova);
|
||||
|
||||
final EditText etConfirma = new EditText(this);
|
||||
etConfirma.setHint("Confirma a Nova Password");
|
||||
etConfirma.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
|
||||
layout.addView(etConfirma);
|
||||
|
||||
builder.setView(layout);
|
||||
builder.setPositiveButton("Atualizar", (dialog, which) -> {
|
||||
String pAntiga = etAntiga.getText().toString().trim();
|
||||
String pNova = etNova.getText().toString().trim();
|
||||
String pConfirma = etConfirma.getText().toString().trim();
|
||||
String emailAtual = sharedPreferences.getString("email", "");
|
||||
|
||||
if (pAntiga.isEmpty() || pNova.isEmpty() || pConfirma.isEmpty()) {
|
||||
Toast.makeText(this, "Preenche todos os campos!", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!pNova.equals(pConfirma) || pNova.length() < 6) {
|
||||
Toast.makeText(this, "As novas passwords não coincidem ou são muito curtas!", Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
|
||||
SupabaseApi api = SupabaseConfig.getRetrofit().create(SupabaseApi.class);
|
||||
UserCredentials creds = new UserCredentials(emailAtual, pAntiga);
|
||||
|
||||
// Confirma a identidade do utilizador (Mini-login)
|
||||
api.login(SupabaseConfig.SUPABASE_KEY, creds).enqueue(new Callback<SupabaseResponse>() {
|
||||
@Override
|
||||
public void onResponse(Call<SupabaseResponse> call, Response<SupabaseResponse> response) {
|
||||
if (response.isSuccessful() && response.body() != null) {
|
||||
String freshToken = response.body().access_token;
|
||||
|
||||
// Atualiza a palavra-passe no Supabase
|
||||
Map<String, String> updates = new HashMap<>();
|
||||
updates.put("password", pNova);
|
||||
|
||||
api.updateUserData(SupabaseConfig.SUPABASE_KEY, "Bearer " + freshToken, updates).enqueue(new Callback<Void>() {
|
||||
@Override
|
||||
public void onResponse(Call<Void> call, Response<Void> response) {
|
||||
if (response.isSuccessful()) {
|
||||
Toast.makeText(DefinicoesActivity.this, "Password alterada com sucesso!", Toast.LENGTH_LONG).show();
|
||||
} else {
|
||||
Toast.makeText(DefinicoesActivity.this, "Erro no servidor ao mudar password.", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<Void> call, Throwable t) {
|
||||
Toast.makeText(DefinicoesActivity.this, "Verifica a tua ligação à internet!", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
Toast.makeText(DefinicoesActivity.this, "A password antiga está incorreta!", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<SupabaseResponse> call, Throwable t) {
|
||||
Toast.makeText(DefinicoesActivity.this, "Verifica a tua ligação à internet!", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
});
|
||||
builder.show();
|
||||
}
|
||||
}
|
||||
30
app/src/main/java/com/example/pap/EditarPerfilActivity.java
Normal file
30
app/src/main/java/com/example/pap/EditarPerfilActivity.java
Normal file
@@ -0,0 +1,30 @@
|
||||
package com.example.pap;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Toast;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
public class EditarPerfilActivity extends AppCompatActivity {
|
||||
|
||||
private EditText etEditNome, etEditEmail, etEditPassword;
|
||||
private Button btnGuardarPerfil;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_editar_perfil);
|
||||
|
||||
etEditNome = findViewById(R.id.etEditNome);
|
||||
etEditEmail = findViewById(R.id.etEditEmail);
|
||||
etEditPassword = findViewById(R.id.etEditPassword);
|
||||
btnGuardarPerfil = findViewById(R.id.btnGuardarPerfil);
|
||||
|
||||
btnGuardarPerfil.setOnClickListener(v -> {
|
||||
// Mais tarde ligamos esta merda ao Supabase!
|
||||
Toast.makeText(this, "Dados atualizados com sucesso, caralho! ✅", Toast.LENGTH_SHORT).show();
|
||||
finish(); // Fecha e volta atrás
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,146 +1,108 @@
|
||||
package com.example.pap;
|
||||
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.provider.MediaStore;
|
||||
import android.util.Base64;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import androidx.activity.result.ActivityResultLauncher;
|
||||
import androidx.activity.result.contract.ActivityResultContracts;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.util.Collections;
|
||||
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
public class FotoActivity extends AppCompatActivity {
|
||||
|
||||
private ImageView ivFotoComida;
|
||||
private Button btnTirarFoto, btnVoltar, btnAddManual, btnConfirmar;
|
||||
private LinearLayout layoutResultadosIA;
|
||||
private TextView tvTotalCalorias, tvNomePrato;
|
||||
private RecyclerView recyclerView;
|
||||
private IngredientesAdapter adapter;
|
||||
private ArrayList<Ingrediente> listaIngredientes;
|
||||
private Button btnTirarFoto, btnAnalisarIA, btnVoltarFoto;
|
||||
private TextView tvResultadoIA;
|
||||
private Bitmap imagemCapturada;
|
||||
|
||||
// Lançador da Câmara
|
||||
private final ActivityResultLauncher<Intent> cameraLauncher = registerForActivityResult(
|
||||
new ActivityResultContracts.StartActivityForResult(),
|
||||
result -> {
|
||||
if (result.getResultCode() == RESULT_OK && result.getData() != null) {
|
||||
// Recebe a miniatura da foto
|
||||
Bundle extras = result.getData().getExtras();
|
||||
Bitmap imageBitmap = (Bitmap) extras.get("data");
|
||||
ivFotoComida.setImageBitmap(imageBitmap);
|
||||
|
||||
// Inicia a simulação da IA
|
||||
Toast.makeText(this, "A analisar a imagem com IA...", Toast.LENGTH_SHORT).show();
|
||||
simularAnaliseIA();
|
||||
}
|
||||
}
|
||||
);
|
||||
// COLA A TUA CHAVE DO OPENROUTER AQUI (Aquela que tiraste sem telemóvel e sem VPN)
|
||||
private final String MINHA_API_KEY = "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";
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_foto);
|
||||
|
||||
// Inicializar vistas
|
||||
ivFotoComida = findViewById(R.id.ivFotoComida);
|
||||
btnTirarFoto = findViewById(R.id.btnTirarFotoComida);
|
||||
btnVoltar = findViewById(R.id.btnVoltarFoto);
|
||||
layoutResultadosIA = findViewById(R.id.layoutResultadosIA);
|
||||
tvTotalCalorias = findViewById(R.id.tvTotalCalorias);
|
||||
tvNomePrato = findViewById(R.id.tvNomePratoDetectado);
|
||||
recyclerView = findViewById(R.id.recyclerViewIngredientes);
|
||||
btnAddManual = findViewById(R.id.btnAddIngredienteManual);
|
||||
btnConfirmar = findViewById(R.id.btnConfirmarRefeicao);
|
||||
btnTirarFoto = findViewById(R.id.btnTirarFoto);
|
||||
btnAnalisarIA = findViewById(R.id.btnAnalisarIA);
|
||||
tvResultadoIA = findViewById(R.id.tvResultadoIA);
|
||||
btnVoltarFoto = findViewById(R.id.btnVoltarFoto);
|
||||
|
||||
// Configurar a RecyclerView
|
||||
listaIngredientes = new ArrayList<>();
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(this));
|
||||
adapter = new IngredientesAdapter(listaIngredientes);
|
||||
recyclerView.setAdapter(adapter);
|
||||
ActivityResultLauncher<Intent> cameraLauncher = registerForActivityResult(
|
||||
new ActivityResultContracts.StartActivityForResult(),
|
||||
result -> {
|
||||
if (result.getResultCode() == RESULT_OK && result.getData() != null) {
|
||||
Bundle extras = result.getData().getExtras();
|
||||
imagemCapturada = (Bitmap) extras.get("data");
|
||||
|
||||
// Configurar o clique no botão de apagar (lixo) na lista
|
||||
adapter.setOnItemClickListener(new IngredientesAdapter.OnItemClickListener() {
|
||||
ivFotoComida.setPadding(0, 0, 0, 0);
|
||||
ivFotoComida.setImageBitmap(imagemCapturada);
|
||||
|
||||
btnTirarFoto.setVisibility(View.GONE);
|
||||
btnAnalisarIA.setVisibility(View.VISIBLE);
|
||||
tvResultadoIA.setText("Prato detetado! Clica em Analisar.");
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
btnTirarFoto.setOnClickListener(v -> cameraLauncher.launch(new Intent(MediaStore.ACTION_IMAGE_CAPTURE)));
|
||||
|
||||
btnAnalisarIA.setOnClickListener(v -> { if (imagemCapturada != null) enviarParaIA(); });
|
||||
btnVoltarFoto.setOnClickListener(v -> finish());
|
||||
}
|
||||
|
||||
private void enviarParaIA() {
|
||||
tvResultadoIA.setText("A procurar servidor livre e a analisar... ⏳");
|
||||
btnAnalisarIA.setEnabled(false);
|
||||
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
imagemCapturada.compress(Bitmap.CompressFormat.JPEG, 60, outputStream);
|
||||
String base64Image = Base64.encodeToString(outputStream.toByteArray(), Base64.NO_WRAP);
|
||||
|
||||
String dataUrl = "data:image/jpeg;base64," + base64Image;
|
||||
String prompt = "Identifica a comida nesta imagem e diz-me as calorias e macronutrientes num pequeno parágrafo.";
|
||||
|
||||
ContentPart textPart = new ContentPart("text", prompt);
|
||||
ContentPart imagePart = new ContentPart("image_url", new ImageUrl(dataUrl));
|
||||
Message message = new Message("user", java.util.Arrays.asList(textPart, imagePart));
|
||||
AiRequest request = new AiRequest(Collections.singletonList(message));
|
||||
|
||||
AiApi api = AiConfig.getRetrofit().create(AiApi.class);
|
||||
api.analisarImagem("Bearer " + MINHA_API_KEY, request).enqueue(new Callback<AiResponse>() {
|
||||
@Override
|
||||
public void onDeleteClick(int position) {
|
||||
removerIngrediente(position);
|
||||
}
|
||||
});
|
||||
|
||||
btnTirarFoto.setOnClickListener(v -> abrirCamera());
|
||||
btnVoltar.setOnClickListener(v -> finish());
|
||||
|
||||
// Botão para simular adicionar um ingrediente extra manualmente
|
||||
btnAddManual.setOnClickListener(v -> {
|
||||
listaIngredientes.add(new Ingrediente("Azeite Extra (1 c.sopa)", 120));
|
||||
adapter.notifyItemInserted(listaIngredientes.size() - 1);
|
||||
calcularTotal();
|
||||
Toast.makeText(this, "Ingrediente adicionado!", Toast.LENGTH_SHORT).show();
|
||||
});
|
||||
|
||||
btnConfirmar.setOnClickListener(v -> {
|
||||
Toast.makeText(this, "Refeição registada no diário!", Toast.LENGTH_LONG).show();
|
||||
finish(); // Fecha o ecrã após confirmar
|
||||
});
|
||||
}
|
||||
|
||||
private void abrirCamera() {
|
||||
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
||||
public void onResponse(Call<AiResponse> call, Response<AiResponse> response) {
|
||||
btnAnalisarIA.setEnabled(true);
|
||||
if (response.isSuccessful() && response.body() != null) {
|
||||
try {
|
||||
cameraLauncher.launch(takePictureIntent);
|
||||
} catch (ActivityNotFoundException e) {
|
||||
Toast.makeText(this, "Erro ao abrir a câmara.", Toast.LENGTH_SHORT).show();
|
||||
String resultado = response.body().choices.get(0).message.content;
|
||||
tvResultadoIA.setText(resultado);
|
||||
} catch (Exception e) { tvResultadoIA.setText("Erro ao ler texto da IA."); }
|
||||
} else {
|
||||
try {
|
||||
String erroReal = response.errorBody() != null ? response.errorBody().string() : "Vazio";
|
||||
tvResultadoIA.setText("ERRO: " + response.code() + "\n" + erroReal);
|
||||
} catch (Exception e) { tvResultadoIA.setText("Erro desconhecido."); }
|
||||
}
|
||||
}
|
||||
|
||||
// Simula a resposta da IA após 2 segundos
|
||||
private void simularAnaliseIA() {
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
// 1. Mostra a área de resultados
|
||||
layoutResultadosIA.setVisibility(View.VISIBLE);
|
||||
btnTirarFoto.setText("Tirar Outra Foto");
|
||||
|
||||
// 2. Simula os dados detetados
|
||||
tvNomePrato.setText("Prato detetado: Salada César com Frango");
|
||||
listaIngredientes.clear();
|
||||
listaIngredientes.add(new Ingrediente("Peito de Frango Grelhado (150g)", 240));
|
||||
listaIngredientes.add(new Ingrediente("Alface Romana (200g)", 30));
|
||||
listaIngredientes.add(new Ingrediente("Molho César (2 c.sopa)", 160));
|
||||
listaIngredientes.add(new Ingrediente("Croutons (30g)", 120));
|
||||
listaIngredientes.add(new Ingrediente("Queijo Parmesão (20g)", 80));
|
||||
|
||||
// 3. Atualiza a lista e o total
|
||||
adapter.notifyDataSetChanged();
|
||||
calcularTotal();
|
||||
|
||||
}, 2000); // Espera 2 segundos
|
||||
@Override
|
||||
public void onFailure(Call<AiResponse> call, Throwable t) {
|
||||
btnAnalisarIA.setEnabled(true);
|
||||
tvResultadoIA.setText("Falha na ligação à Internet.");
|
||||
}
|
||||
|
||||
// Remove um item da lista e atualiza o total
|
||||
private void removerIngrediente(int position) {
|
||||
Ingrediente removido = listaIngredientes.get(position);
|
||||
listaIngredientes.remove(position);
|
||||
adapter.notifyItemRemoved(position);
|
||||
calcularTotal();
|
||||
Toast.makeText(this, "Removido: " + removido.getNome(), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
// Percorre a lista e soma as calorias
|
||||
private void calcularTotal() {
|
||||
int total = 0;
|
||||
for (Ingrediente ing : listaIngredientes) {
|
||||
total += ing.getCalorias();
|
||||
}
|
||||
tvTotalCalorias.setText(total + " kcal");
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import android.os.Bundle;
|
||||
import android.text.InputType;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
@@ -15,58 +16,46 @@ public class HomeActivity extends AppCompatActivity {
|
||||
|
||||
private SharedPreferences sharedPreferences;
|
||||
|
||||
// Agora são 6 cartões!
|
||||
private CardView cardPerfil, cardEstatisticas, cardTirarFoto, cardChat, cardDesafios, cardDefinicoes;
|
||||
// Os 5 cartões principais do teu novo design
|
||||
private CardView cardTirarFoto, cardChat, cardEstatisticas, cardDesafios, cardPerfil;
|
||||
private TextView tvSaudacaoHome;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_home);
|
||||
|
||||
// 1. Iniciar a memória do telemóvel
|
||||
sharedPreferences = getSharedPreferences("AppEmagrecimento", MODE_PRIVATE);
|
||||
// 1. Iniciar a memória do telemóvel (Onde guardámos os dados no Registo)
|
||||
sharedPreferences = getSharedPreferences("MeusDadosApp", MODE_PRIVATE);
|
||||
|
||||
// 2. Ligar os cartões do XML ao código
|
||||
cardPerfil = findViewById(R.id.cardPerfil);
|
||||
cardEstatisticas = findViewById(R.id.cardEstatisticas);
|
||||
// 2. Ligar ao XML
|
||||
cardTirarFoto = findViewById(R.id.cardTirarFoto);
|
||||
cardChat = findViewById(R.id.cardChat);
|
||||
cardEstatisticas = findViewById(R.id.cardEstatisticas);
|
||||
cardDesafios = findViewById(R.id.cardDesafios);
|
||||
cardDefinicoes = findViewById(R.id.cardDefinicoes);
|
||||
cardPerfil = findViewById(R.id.cardPerfil);
|
||||
tvSaudacaoHome = findViewById(R.id.tvSaudacaoHome);
|
||||
|
||||
// 3. Configurar os cliques para abrir os outros ecrãs
|
||||
cardPerfil.setOnClickListener(v -> {
|
||||
Toast.makeText(this, "A abrir O Meu Perfil...", Toast.LENGTH_SHORT).show();
|
||||
// startActivity(new Intent(HomeActivity.this, PerfilActivity.class));
|
||||
});
|
||||
// 3. Preencher o nome do utilizador no cabeçalho
|
||||
String nome = sharedPreferences.getString("nome", "Guerreiro");
|
||||
tvSaudacaoHome.setText("Olá, " + nome + "! 👋");
|
||||
|
||||
cardEstatisticas.setOnClickListener(v -> {
|
||||
Toast.makeText(this, "A abrir Estatísticas...", Toast.LENGTH_SHORT).show();
|
||||
// startActivity(new Intent(HomeActivity.this, EstatisticasActivity.class));
|
||||
});
|
||||
// 4. ATIVAR OS CLIQUES (Os Intents para abrir os outros ecrãs)
|
||||
cardTirarFoto.setOnClickListener(v -> startActivity(new Intent(HomeActivity.this, FotoActivity.class)));
|
||||
|
||||
cardTirarFoto.setOnClickListener(v -> {
|
||||
startActivity(new Intent(HomeActivity.this, FotoActivity.class));
|
||||
});
|
||||
cardChat.setOnClickListener(v -> startActivity(new Intent(HomeActivity.this, ChatActivity.class)));
|
||||
|
||||
cardChat.setOnClickListener(v -> {
|
||||
startActivity(new Intent(HomeActivity.this, ChatActivity.class));
|
||||
});
|
||||
cardEstatisticas.setOnClickListener(v -> startActivity(new Intent(HomeActivity.this, EstatisticasActivity.class)));
|
||||
|
||||
cardDesafios.setOnClickListener(v -> {
|
||||
startActivity(new Intent(HomeActivity.this, DesafiosActivity.class));
|
||||
});
|
||||
cardDesafios.setOnClickListener(v -> startActivity(new Intent(HomeActivity.this, DesafiosActivity.class)));
|
||||
|
||||
cardDefinicoes.setOnClickListener(v -> {
|
||||
Toast.makeText(this, "A abrir Definições...", Toast.LENGTH_SHORT).show();
|
||||
// startActivity(new Intent(HomeActivity.this, DefinicoesActivity.class));
|
||||
});
|
||||
cardPerfil.setOnClickListener(v -> startActivity(new Intent(HomeActivity.this, PerfilActivity.class)));
|
||||
|
||||
// 4. Verifica se já passou o tempo para pedir o novo peso
|
||||
// 5. Verifica se já passou o tempo para pedir o novo peso
|
||||
verificarAtualizacaoSemanal();
|
||||
}
|
||||
|
||||
// Função que calcula se já passou o tempo (1 semana ou 10 segundos)
|
||||
// Função que calcula o tempo passado
|
||||
private void verificarAtualizacaoSemanal() {
|
||||
long dataUltimaAtualizacao = sharedPreferences.getLong("data_ultima_atualizacao", 0);
|
||||
long dataAtual = System.currentTimeMillis();
|
||||
@@ -75,7 +64,7 @@ public class HomeActivity extends AppCompatActivity {
|
||||
sharedPreferences.edit().putLong("data_ultima_atualizacao", dataAtual).apply();
|
||||
} else {
|
||||
// TEMPO CONFIGURADO PARA TESTES: 10 segundos!
|
||||
// Para a PAP final usa: long tempoNecessario = 7L * 24 * 60 * 60 * 1000;
|
||||
// Quando fores apresentar a PAP, podes mudar isto para 1 semana.
|
||||
long tempoNecessario = 10 * 1000;
|
||||
|
||||
if (dataAtual - dataUltimaAtualizacao >= tempoNecessario) {
|
||||
@@ -84,11 +73,11 @@ public class HomeActivity extends AppCompatActivity {
|
||||
}
|
||||
}
|
||||
|
||||
// Função que cria o pop-up para atualizar o peso
|
||||
// Função que cria o pop-up no ecrã para atualizar peso e altura
|
||||
private void mostrarPopupAtualizacao() {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setTitle("Hora da pesagem! ⚖️");
|
||||
builder.setMessage("Já passou 1 semana! Atualiza o teu peso e altura para acompanharmos a tua evolução.");
|
||||
builder.setMessage("Já passou algum tempo! Atualiza o teu peso e altura para acompanharmos a tua evolução.");
|
||||
builder.setCancelable(false);
|
||||
|
||||
LinearLayout layout = new LinearLayout(this);
|
||||
@@ -119,16 +108,17 @@ public class HomeActivity extends AppCompatActivity {
|
||||
float novoPeso = Float.parseFloat(pesoStr);
|
||||
float novaAltura = Float.parseFloat(alturaStr);
|
||||
|
||||
// Grava os novos dados com as chaves corretas no bloco de notas
|
||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||
editor.putFloat("pesoAtual", novoPeso);
|
||||
editor.putFloat("alturaAtual", novaAltura);
|
||||
editor.putFloat("peso", novoPeso);
|
||||
editor.putFloat("altura", novaAltura);
|
||||
editor.putLong("data_ultima_atualizacao", System.currentTimeMillis());
|
||||
editor.apply();
|
||||
|
||||
Toast.makeText(HomeActivity.this, "Dados atualizados com sucesso! 💪", Toast.LENGTH_SHORT).show();
|
||||
dialog.dismiss();
|
||||
} else {
|
||||
Toast.makeText(HomeActivity.this, "Tens de preencher os dois campos!", Toast.LENGTH_SHORT).show();
|
||||
Toast.makeText(HomeActivity.this, "Tens de preencher os dois campos, caralho!", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
package com.example.pap;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.util.Log;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
@@ -12,82 +13,74 @@ import androidx.appcompat.app.AppCompatActivity;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
import retrofit2.Retrofit;
|
||||
import retrofit2.converter.gson.GsonConverterFactory;
|
||||
|
||||
public class LoginActivity extends AppCompatActivity {
|
||||
|
||||
private EditText etLoginEmail, etLoginPassword;
|
||||
private Button btnLogin;
|
||||
private TextView tvGoToRegister;
|
||||
private SupabaseApi api;
|
||||
private SharedPreferences sharedPreferences;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_login);
|
||||
|
||||
// 1. Inicializar os componentes
|
||||
// Ligar o código aos IDs do ecrã
|
||||
etLoginEmail = findViewById(R.id.etLoginEmail);
|
||||
etLoginPassword = findViewById(R.id.etLoginPassword);
|
||||
btnLogin = findViewById(R.id.btnLogin);
|
||||
tvGoToRegister = findViewById(R.id.tvGoToRegister);
|
||||
|
||||
// 2. Iniciar a comunicação com a API do Supabase
|
||||
Retrofit retrofit = new Retrofit.Builder()
|
||||
.baseUrl(SupabaseConfig.URL)
|
||||
.addConverterFactory(GsonConverterFactory.create())
|
||||
.build();
|
||||
api = retrofit.create(SupabaseApi.class);
|
||||
|
||||
// 3. Configurar os cliques
|
||||
btnLogin.setOnClickListener(v -> efetuarLogin());
|
||||
// Iniciar a memória do telemóvel
|
||||
sharedPreferences = getSharedPreferences("MeusDadosApp", MODE_PRIVATE);
|
||||
|
||||
// Enviar para o Registo
|
||||
tvGoToRegister.setOnClickListener(v -> {
|
||||
Intent intent = new Intent(LoginActivity.this, RegisterActivity.class);
|
||||
startActivity(intent);
|
||||
});
|
||||
}
|
||||
|
||||
private void efetuarLogin() {
|
||||
// Botão de Entrar
|
||||
btnLogin.setOnClickListener(v -> {
|
||||
String email = etLoginEmail.getText().toString().trim();
|
||||
String password = etLoginPassword.getText().toString().trim();
|
||||
|
||||
// Validação básica
|
||||
if (email.isEmpty() || password.isEmpty()) {
|
||||
Toast.makeText(this, "Preencha o email e a password!", Toast.LENGTH_SHORT).show();
|
||||
Toast.makeText(this, "Preenche o email e a password!", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
|
||||
UserCredentials credentials = new UserCredentials(email, password);
|
||||
SupabaseApi api = SupabaseConfig.getRetrofit().create(SupabaseApi.class);
|
||||
|
||||
// Faz o pedido de Login ao Supabase
|
||||
api.login(SupabaseConfig.API_KEY, credentials).enqueue(new Callback<SupabaseResponse>() {
|
||||
api.login(SupabaseConfig.SUPABASE_KEY, credentials).enqueue(new Callback<SupabaseResponse>() {
|
||||
@Override
|
||||
public void onResponse(Call<SupabaseResponse> call, Response<SupabaseResponse> response) {
|
||||
if (response.isSuccessful() && response.body() != null) {
|
||||
|
||||
// Login com sucesso! Vai para a Home
|
||||
Toast.makeText(LoginActivity.this, "Login com sucesso!", Toast.LENGTH_SHORT).show();
|
||||
// Guardar o token e o email para usar nas Definições
|
||||
String token = response.body().access_token;
|
||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||
editor.putString("access_token", token);
|
||||
editor.putString("email", email);
|
||||
editor.apply();
|
||||
|
||||
Toast.makeText(LoginActivity.this, "Entraste com sucesso! 🚀", Toast.LENGTH_SHORT).show();
|
||||
Intent intent = new Intent(LoginActivity.this, HomeActivity.class);
|
||||
startActivity(intent);
|
||||
finish(); // Fecha a tela de login
|
||||
|
||||
finish();
|
||||
} else {
|
||||
// SE DER ERRO (ex: 404, 400), MOSTRA O LINK EXATO E O CÓDIGO
|
||||
String urlQueFalhou = response.raw().request().url().toString();
|
||||
if (response.code() == 400) {
|
||||
Toast.makeText(LoginActivity.this, "Email ou password incorretos!", Toast.LENGTH_LONG).show();
|
||||
} else {
|
||||
Toast.makeText(LoginActivity.this, "Erro " + response.code() + "! Link: " + urlQueFalhou, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
Toast.makeText(LoginActivity.this, "Dados errados! Verifica a tua password e email.", Toast.LENGTH_LONG).show();
|
||||
Log.e("SUPABASE", "Erro Login: " + response.code());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<SupabaseResponse> call, Throwable t) {
|
||||
Toast.makeText(LoginActivity.this, "Falha na ligação: " + t.getMessage(), Toast.LENGTH_SHORT).show();
|
||||
Toast.makeText(LoginActivity.this, "Falha na ligação! Verifica a internet.", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,39 +1,51 @@
|
||||
package com.example.pap;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
public class PerfilActivity extends AppCompatActivity {
|
||||
|
||||
private TextView tvPerfilNome, tvPerfilPontos, tvPerfilDesafios, tvPerfilSequencia;
|
||||
private Button btnDefinicoes, btnVoltarPerfil;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_perfil);
|
||||
|
||||
Button btnVoltar = findViewById(R.id.btnVoltarPerfil);
|
||||
Button btnSair = findViewById(R.id.btnSair);
|
||||
tvPerfilNome = findViewById(R.id.tvPerfilNome);
|
||||
tvPerfilPontos = findViewById(R.id.tvPerfilPontos);
|
||||
tvPerfilDesafios = findViewById(R.id.tvPerfilDesafios);
|
||||
tvPerfilSequencia = findViewById(R.id.tvPerfilSequencia);
|
||||
btnDefinicoes = findViewById(R.id.btnDefinicoes);
|
||||
btnVoltarPerfil = findViewById(R.id.btnVoltarPerfil);
|
||||
|
||||
// Voltar à Home
|
||||
btnVoltar.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
btnDefinicoes.setOnClickListener(v -> {
|
||||
startActivity(new Intent(PerfilActivity.this, DefinicoesActivity.class));
|
||||
});
|
||||
|
||||
// Terminar Sessão (Voltar ao Login e limpar a Home)
|
||||
btnSair.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(PerfilActivity.this, LoginActivity.class);
|
||||
// Estas flags garantem que o utilizador não consegue clicar em "Voltar" no telemóvel e ir para a Home de novo
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
btnVoltarPerfil.setOnClickListener(v -> finish());
|
||||
}
|
||||
});
|
||||
|
||||
// A MAGIA ACONTECE AQUI: Atualiza os dados sempre que o ecrã aparece!
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
|
||||
SharedPreferences prefs = getSharedPreferences("MeusDadosApp", MODE_PRIVATE);
|
||||
|
||||
String nome = prefs.getString("nome", "Utilizador");
|
||||
int pontos = prefs.getInt("pontos", 0);
|
||||
int desafios = prefs.getInt("desafios_concluidos", 0);
|
||||
int streak = prefs.getInt("sequencia_diaria", 1);
|
||||
|
||||
tvPerfilNome.setText(nome);
|
||||
tvPerfilPontos.setText(String.valueOf(pontos));
|
||||
tvPerfilDesafios.setText(String.valueOf(desafios));
|
||||
tvPerfilSequencia.setText(String.valueOf(streak));
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
package com.example.pap;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.util.Log;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
@@ -12,22 +13,19 @@ import androidx.appcompat.app.AppCompatActivity;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
import retrofit2.Retrofit;
|
||||
import retrofit2.converter.gson.GsonConverterFactory;
|
||||
|
||||
public class RegisterActivity extends AppCompatActivity {
|
||||
|
||||
private EditText etRegNome, etRegEmail, etRegPassword, etRegAltura, etRegPeso;
|
||||
private Button btnRegister;
|
||||
private TextView tvGoToLogin;
|
||||
private SupabaseApi api;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_register);
|
||||
|
||||
// 1. Ligar os elementos do design ao código
|
||||
// Ligar o código aos IDs do ecrã
|
||||
etRegNome = findViewById(R.id.etRegNome);
|
||||
etRegEmail = findViewById(R.id.etRegEmail);
|
||||
etRegPassword = findViewById(R.id.etRegPassword);
|
||||
@@ -36,99 +34,63 @@ public class RegisterActivity extends AppCompatActivity {
|
||||
btnRegister = findViewById(R.id.btnRegister);
|
||||
tvGoToLogin = findViewById(R.id.tvGoToLogin);
|
||||
|
||||
// 2. Configurar o Retrofit (A ponte de comunicação com o Supabase)
|
||||
Retrofit retrofit = new Retrofit.Builder()
|
||||
.baseUrl(SupabaseConfig.URL)
|
||||
.addConverterFactory(GsonConverterFactory.create())
|
||||
.build();
|
||||
api = retrofit.create(SupabaseApi.class);
|
||||
|
||||
// 3. Configurar os cliques dos botões
|
||||
btnRegister.setOnClickListener(v -> efetuarRegisto());
|
||||
// Se o utilizador já tem conta, volta para o Login
|
||||
tvGoToLogin.setOnClickListener(v -> finish());
|
||||
}
|
||||
|
||||
private void efetuarRegisto() {
|
||||
// Quando clica no botão de Registar
|
||||
btnRegister.setOnClickListener(v -> {
|
||||
String nome = etRegNome.getText().toString().trim();
|
||||
String email = etRegEmail.getText().toString().trim();
|
||||
String password = etRegPassword.getText().toString().trim();
|
||||
String pesoStr = etRegPeso.getText().toString().trim();
|
||||
String alturaStr = etRegAltura.getText().toString().trim();
|
||||
String pesoStr = etRegPeso.getText().toString().trim();
|
||||
|
||||
// Verificações para garantir que o utilizador preencheu tudo
|
||||
if (nome.isEmpty() || email.isEmpty() || password.isEmpty() || pesoStr.isEmpty() || alturaStr.isEmpty()) {
|
||||
Toast.makeText(this, "Preencha todos os campos!", Toast.LENGTH_SHORT).show();
|
||||
// 1. Verificar se não há campos vazios
|
||||
if (nome.isEmpty() || email.isEmpty() || password.isEmpty() || alturaStr.isEmpty() || pesoStr.isEmpty()) {
|
||||
Toast.makeText(this, "Por favor, preenche todos os campos!", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
|
||||
if (password.length() < 6) {
|
||||
Toast.makeText(this, "A password precisa de pelo menos 6 caracteres.", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
// 2. GUARDAR NOME, ALTURA E PESO NA MEMÓRIA (SharedPreferences)
|
||||
SharedPreferences prefs = getSharedPreferences("MeusDadosApp", MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = prefs.edit();
|
||||
editor.putString("nome", nome);
|
||||
editor.putString("email", email);
|
||||
editor.putFloat("altura", Float.parseFloat(alturaStr));
|
||||
editor.putFloat("peso", Float.parseFloat(pesoStr));
|
||||
editor.apply();
|
||||
|
||||
float peso = Float.parseFloat(pesoStr);
|
||||
float altura = Float.parseFloat(alturaStr);
|
||||
|
||||
// FASE 1: Criar a conta (Email e Password) no Supabase Auth
|
||||
// 3. Preparar os dados para enviar para o Supabase
|
||||
UserCredentials credentials = new UserCredentials(email, password);
|
||||
|
||||
api.signUp(SupabaseConfig.API_KEY, credentials).enqueue(new Callback<SupabaseResponse>() {
|
||||
// Vai buscar o Retrofit ao ficheiro SupabaseConfig
|
||||
SupabaseApi api = SupabaseConfig.getRetrofit().create(SupabaseApi.class);
|
||||
|
||||
// 4. Fazer o Registo na Internet usando a chave configurada
|
||||
api.signUp(SupabaseConfig.SUPABASE_KEY, credentials).enqueue(new Callback<SupabaseResponse>() {
|
||||
@Override
|
||||
public void onResponse(Call<SupabaseResponse> call, Response<SupabaseResponse> response) {
|
||||
if (response.isSuccessful() && response.body() != null) {
|
||||
if (response.isSuccessful()) {
|
||||
Toast.makeText(RegisterActivity.this, "Conta criada! Verifica o teu email.", Toast.LENGTH_LONG).show();
|
||||
|
||||
// Sucesso! A conta foi criada. Vamos extrair o ID e o Token
|
||||
String userId = response.body().id != null ? response.body().id : response.body().user.id;
|
||||
String token = "Bearer " + response.body().access_token;
|
||||
|
||||
// FASE 2: Guardar o Nome, Peso e Altura na tabela "profiles"
|
||||
salvarPerfil(userId, nome, email, peso, altura, token);
|
||||
// NOVO FLUXO: Mandar para o ecrã de espera com os dados passados em segurança!
|
||||
Intent intent = new Intent(RegisterActivity.this, VerificacaoActivity.class);
|
||||
intent.putExtra("email_registo", email);
|
||||
intent.putExtra("password_registo", password);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
|
||||
} else {
|
||||
String urlQueFalhou = response.raw().request().url().toString();
|
||||
if (response.code() == 400) {
|
||||
Toast.makeText(RegisterActivity.this, "Erro 400: Este email já existe ou a password é fraca.", Toast.LENGTH_LONG).show();
|
||||
} else {
|
||||
Toast.makeText(RegisterActivity.this, "Erro " + response.code() + " no Auth! Link: " + urlQueFalhou, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
Toast.makeText(RegisterActivity.this, "Erro ao criar conta. O email já existe?", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<SupabaseResponse> call, Throwable t) {
|
||||
Toast.makeText(RegisterActivity.this, "Falha de rede (Sem internet?): " + t.getMessage(), Toast.LENGTH_SHORT).show();
|
||||
// Sem internet ou falha de ligação
|
||||
Toast.makeText(RegisterActivity.this, "Falha na ligação! Verifica a tua internet.", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Método responsável por guardar os dados extras na tabela profiles
|
||||
private void salvarPerfil(String id, String nome, String email, float peso, float altura, String token) {
|
||||
ProfileData profile = new ProfileData(id, nome, email, peso, altura);
|
||||
|
||||
api.insertProfile(SupabaseConfig.API_KEY, token, "application/json", "return=minimal", profile)
|
||||
.enqueue(new Callback<Void>() {
|
||||
@Override
|
||||
public void onResponse(Call<Void> call, Response<Void> response) {
|
||||
if (response.isSuccessful()) {
|
||||
// TUDO CORREU BEM!
|
||||
Toast.makeText(RegisterActivity.this, "Conta e Perfil criados com sucesso!", Toast.LENGTH_LONG).show();
|
||||
finish(); // Volta para o ecrã de login
|
||||
} else {
|
||||
// DEU ERRO A GUARDAR O PESO E ALTURA. VAMOS LER O ERRO EXATO!
|
||||
try {
|
||||
String erroExato = response.errorBody().string();
|
||||
// Esta mensagem vai mostrar-te o que está mal configurado no painel do Supabase
|
||||
Toast.makeText(RegisterActivity.this, "ERRO DA BASE DE DADOS: " + erroExato, Toast.LENGTH_LONG).show();
|
||||
} catch (Exception e) {
|
||||
Toast.makeText(RegisterActivity.this, "Erro a ler a resposta da base de dados.", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<Void> call, Throwable t) {
|
||||
Toast.makeText(RegisterActivity.this, "Erro ao conectar à base de dados.", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -3,30 +3,29 @@ package com.example.pap;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.http.Body;
|
||||
import retrofit2.http.Header;
|
||||
import retrofit2.http.PUT;
|
||||
import retrofit2.http.POST;
|
||||
|
||||
public interface SupabaseApi {
|
||||
|
||||
// Rota para criar a conta
|
||||
// 1. Rota para criar a conta
|
||||
@POST("auth/v1/signup")
|
||||
Call<SupabaseResponse> signUp(@Header("apikey") String apiKey, @Body UserCredentials credentials);
|
||||
|
||||
// Rota para fazer login
|
||||
// 2. Rota para fazer login
|
||||
@POST("auth/v1/token?grant_type=password")
|
||||
Call<SupabaseResponse> login(@Header("apikey") String apiKey, @Body UserCredentials credentials);
|
||||
|
||||
// Rota para guardar o Nome, Peso e Altura na base de dados
|
||||
@POST("rest/v1/profiles")
|
||||
Call<Void> insertProfile(
|
||||
@Header("apikey") String apiKey,
|
||||
@Header("Authorization") String token,
|
||||
@Header("Content-Type") String contentType,
|
||||
@Header("Prefer") String prefer,
|
||||
@Body ProfileData profile
|
||||
// 3. Rota para atualizar a palavra-passe ou dados do utilizador (CORRIGIDO PARA @PUT)
|
||||
@PUT("auth/v1/user")
|
||||
Call<Void> updateUserData(
|
||||
@Header("apikey") String apikey,
|
||||
@Header("Authorization") String accessToken,
|
||||
@Body java.util.Map<String, String> updates
|
||||
);
|
||||
}
|
||||
|
||||
// ---- Classes Auxiliares para Formatarem os Dados ----
|
||||
// ---- Classes Auxiliares ----
|
||||
|
||||
class UserCredentials {
|
||||
String email;
|
||||
@@ -38,28 +37,6 @@ class UserCredentials {
|
||||
}
|
||||
}
|
||||
|
||||
class ProfileData {
|
||||
String id;
|
||||
String nome;
|
||||
String email;
|
||||
float peso;
|
||||
float altura;
|
||||
|
||||
public ProfileData(String id, String nome, String email, float peso, float altura) {
|
||||
this.id = id;
|
||||
this.nome = nome;
|
||||
this.email = email;
|
||||
this.peso = peso;
|
||||
this.altura = altura;
|
||||
}
|
||||
}
|
||||
|
||||
class SupabaseResponse {
|
||||
String id;
|
||||
String access_token;
|
||||
UserResponse user;
|
||||
|
||||
class UserResponse {
|
||||
String id;
|
||||
}
|
||||
public String access_token;
|
||||
}
|
||||
@@ -1,10 +1,31 @@
|
||||
package com.example.pap;
|
||||
|
||||
import retrofit2.Retrofit;
|
||||
import retrofit2.converter.gson.GsonConverterFactory;
|
||||
|
||||
public class SupabaseConfig {
|
||||
|
||||
// O URL limpo, apenas com a barra no final!
|
||||
public static final String URL = "https://lkjbbbgavoyknuxaskho.supabase.co";
|
||||
// =========================================================================
|
||||
// CONFIGURAÇÃO DO NOVO PROJETO (SUBSTITUI PELOS TEUS DADOS DO SUPABASE)
|
||||
// =========================================================================
|
||||
|
||||
// A tua chave está perfeita
|
||||
public static final String API_KEY = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImxramJiYmdhdm95a251eGFza2hvIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzI2MjM4OTMsImV4cCI6MjA4ODE5OTg5M30.HV9ZXYCaF1V8dZwPxv_p5_gDi9cN_ioumDm9mgmEQPU";
|
||||
// 1. O teu Project URL (Ex: https://xyzabc.supabase.co/)
|
||||
public static final String BASE_URL = "https://zfwfimmptccyzxvscbrg.supabase.co/";
|
||||
// 2. A tua API Key (A que diz 'anon' e 'public')
|
||||
public static final String SUPABASE_KEY = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Inpmd2ZpbW1wdGNjeXp4dnNjYnJnIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzcyODQ5MDMsImV4cCI6MjA5Mjg2MDkwM30.aE_JSy6OGx3aPfzraCCQ_CtQeA8qFSBGhgkaGBJDHos";
|
||||
|
||||
// =========================================================================
|
||||
|
||||
private static Retrofit retrofit = null;
|
||||
|
||||
// Método que cria e entrega a ligação configurada para o resto da App
|
||||
public static Retrofit getRetrofit() {
|
||||
if (retrofit == null) {
|
||||
retrofit = new Retrofit.Builder()
|
||||
.baseUrl(BASE_URL)
|
||||
.addConverterFactory(GsonConverterFactory.create()) // Transforma JSON em código Java
|
||||
.build();
|
||||
}
|
||||
return retrofit;
|
||||
}
|
||||
}
|
||||
75
app/src/main/java/com/example/pap/VerificacaoActivity.java
Normal file
75
app/src/main/java/com/example/pap/VerificacaoActivity.java
Normal file
@@ -0,0 +1,75 @@
|
||||
package com.example.pap;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.widget.Button;
|
||||
import android.widget.Toast;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
public class VerificacaoActivity extends AppCompatActivity {
|
||||
|
||||
private Button btnJaConfirmei, btnVoltarLoginVerificacao;
|
||||
private String emailGuardado, passwordGuardada;
|
||||
private SharedPreferences sharedPreferences;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_verificacao);
|
||||
|
||||
btnJaConfirmei = findViewById(R.id.btnJaConfirmei);
|
||||
btnVoltarLoginVerificacao = findViewById(R.id.btnVoltarLoginVerificacao);
|
||||
sharedPreferences = getSharedPreferences("MeusDadosApp", MODE_PRIVATE);
|
||||
|
||||
// Receber o email e a password do ecrã de Registo
|
||||
emailGuardado = getIntent().getStringExtra("email_registo");
|
||||
passwordGuardada = getIntent().getStringExtra("password_registo");
|
||||
|
||||
btnJaConfirmei.setOnClickListener(v -> {
|
||||
Toast.makeText(this, "A verificar...", Toast.LENGTH_SHORT).show();
|
||||
tentarFazerLogin();
|
||||
});
|
||||
|
||||
btnVoltarLoginVerificacao.setOnClickListener(v -> {
|
||||
startActivity(new Intent(VerificacaoActivity.this, LoginActivity.class));
|
||||
finish();
|
||||
});
|
||||
}
|
||||
|
||||
private void tentarFazerLogin() {
|
||||
SupabaseApi api = SupabaseConfig.getRetrofit().create(SupabaseApi.class);
|
||||
UserCredentials creds = new UserCredentials(emailGuardado, passwordGuardada);
|
||||
|
||||
api.login(SupabaseConfig.SUPABASE_KEY, creds).enqueue(new Callback<SupabaseResponse>() {
|
||||
@Override
|
||||
public void onResponse(Call<SupabaseResponse> call, Response<SupabaseResponse> response) {
|
||||
if (response.isSuccessful() && response.body() != null) {
|
||||
// SUCESSO! O email foi confirmado e o login funcionou
|
||||
String token = response.body().access_token;
|
||||
|
||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||
editor.putString("access_token", token);
|
||||
editor.putString("email", emailGuardado);
|
||||
editor.apply();
|
||||
|
||||
Toast.makeText(VerificacaoActivity.this, "Email confirmado com sucesso! Bem-vindo!", Toast.LENGTH_LONG).show();
|
||||
startActivity(new Intent(VerificacaoActivity.this, HomeActivity.class));
|
||||
finish();
|
||||
} else {
|
||||
// ERRO! Provavelmente o gajo ainda não clicou no link do email
|
||||
Toast.makeText(VerificacaoActivity.this, "Ainda não confirmaste! Vai ao teu email e clica no link.", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<SupabaseResponse> call, Throwable t) {
|
||||
Toast.makeText(VerificacaoActivity.this, "Sem ligação à internet!", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
6
app/src/main/res/drawable/balao_ai.xml
Normal file
6
app/src/main/res/drawable/balao_ai.xml
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid android:color="#FFFFFF" />
|
||||
<stroke android:width="1dp" android:color="#E2E8F0"/>
|
||||
<corners android:topLeftRadius="20dp" android:topRightRadius="20dp" android:bottomLeftRadius="4dp" android:bottomRightRadius="20dp" />
|
||||
</shape>
|
||||
5
app/src/main/res/drawable/balao_user.xml
Normal file
5
app/src/main/res/drawable/balao_user.xml
Normal file
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid android:color="#0284C7" />
|
||||
<corners android:topLeftRadius="20dp" android:topRightRadius="20dp" android:bottomLeftRadius="20dp" android:bottomRightRadius="4dp" />
|
||||
</shape>
|
||||
11
app/src/main/res/drawable/fundo_input_ingredientes.xml
Normal file
11
app/src/main/res/drawable/fundo_input_ingredientes.xml
Normal file
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
|
||||
<solid android:color="#F8FAFC" />
|
||||
|
||||
<stroke android:width="1dp" android:color="#CBD5E1" />
|
||||
|
||||
<corners android:radius="12dp" />
|
||||
|
||||
</shape>
|
||||
6
app/src/main/res/drawable/ic_online_dot.xml
Normal file
6
app/src/main/res/drawable/ic_online_dot.xml
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="oval">
|
||||
<solid android:color="#4CAF50" />
|
||||
<size android:width="12dp" android:height="12dp" />
|
||||
</shape>
|
||||
9
app/src/main/res/drawable/retangulo_mira.xml
Normal file
9
app/src/main/res/drawable/retangulo_mira.xml
Normal file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<solid android:color="@android:color/transparent" />
|
||||
<stroke
|
||||
android:width="4dp"
|
||||
android:color="#03A9F4" />
|
||||
<corners android:radius="24dp" />
|
||||
</shape>
|
||||
@@ -1,83 +1,148 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout 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:background="#F4F9F5">
|
||||
|
||||
<LinearLayout
|
||||
android:background="#F8FAFC"> <androidx.cardview.widget.CardView
|
||||
android:id="@+id/headerChat"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="#FFFFFF"
|
||||
android:elevation="4dp"
|
||||
android:orientation="horizontal"
|
||||
android:padding="16dp"
|
||||
android:gravity="center_vertical">
|
||||
app:cardElevation="8dp"
|
||||
app:cardCornerRadius="0dp"
|
||||
app:cardBackgroundColor="#FFFFFF">
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnVoltarChat"
|
||||
android:layout_width="wrap_content"
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Voltar"
|
||||
android:backgroundTint="#E0E0E0"
|
||||
android:textColor="#000000"
|
||||
android:layout_marginEnd="16dp"/>
|
||||
android:gravity="center_vertical"
|
||||
android:padding="16dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="45dp"
|
||||
android:layout_height="45dp"
|
||||
app:cardCornerRadius="22.5dp"
|
||||
app:cardBackgroundColor="#E0F2FE"
|
||||
app:cardElevation="0dp"
|
||||
android:layout_marginEnd="12dp">
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:text="🤖"
|
||||
android:textSize="26sp"
|
||||
android:gravity="center"/>
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="IA Coach de Saúde"
|
||||
android:textSize="20sp"
|
||||
android:text="NutriChat AI"
|
||||
android:textSize="18sp"
|
||||
android:textStyle="bold"
|
||||
android:textColor="#2E3D32"/>
|
||||
android:textColor="#0F172A"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center_vertical"
|
||||
android:layout_marginTop="2dp">
|
||||
|
||||
<View
|
||||
android:layout_width="8dp"
|
||||
android:layout_height="8dp"
|
||||
android:background="@drawable/ic_online_dot"
|
||||
android:layout_marginEnd="6dp"/>
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Sempre online"
|
||||
android:textSize="13sp"
|
||||
android:textColor="#64748B"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<ScrollView
|
||||
android:id="@+id/chatScrollView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_above="@+id/inputArea"
|
||||
android:layout_below="@id/headerChat"
|
||||
android:layout_above="@+id/layoutInput"
|
||||
android:padding="16dp"
|
||||
android:fillViewport="true">
|
||||
android:paddingHorizontal="16dp"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingBottom="8dp"
|
||||
android:clipToPadding="false">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/chatLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="16dp"/>
|
||||
android:orientation="vertical" />
|
||||
</ScrollView>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/layoutInput"
|
||||
android:id="@+id/inputArea"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:background="#FFFFFF"
|
||||
android:elevation="8dp"
|
||||
android:paddingHorizontal="12dp"
|
||||
android:paddingVertical="12dp"
|
||||
android:background="#00000000"
|
||||
android:orientation="horizontal"
|
||||
android:padding="8dp"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/etNovaMensagem"
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="50dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:background="#F0F0F0"
|
||||
android:hint="Pede uma dica de saúde..."
|
||||
android:paddingStart="16dp"
|
||||
android:paddingEnd="16dp"
|
||||
android:layout_marginEnd="8dp"/>
|
||||
app:cardCornerRadius="24dp"
|
||||
app:cardElevation="2dp"
|
||||
app:cardBackgroundColor="#FFFFFF"
|
||||
android:layout_marginEnd="8dp">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/etMensagem"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="48dp"
|
||||
android:maxLines="4"
|
||||
android:inputType="textMultiLine"
|
||||
android:background="@android:color/transparent"
|
||||
android:hint="Escreve a tua mensagem..."
|
||||
android:textColorHint="#94A3B8"
|
||||
android:textColor="#1E293B"
|
||||
android:paddingStart="20dp"
|
||||
android:paddingEnd="20dp"
|
||||
android:paddingTop="12dp"
|
||||
android:paddingBottom="12dp"
|
||||
android:textSize="16sp" />
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
app:cardCornerRadius="24dp"
|
||||
app:cardElevation="4dp"
|
||||
app:cardBackgroundColor="#0284C7">
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/btnEnviar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@android:color/transparent"
|
||||
android:src="@android:drawable/ic_menu_send"
|
||||
android:paddingStart="4dp"
|
||||
app:tint="#FFFFFF" />
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnEnviarMensagem"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="50dp"
|
||||
android:backgroundTint="#4CAF50"
|
||||
android:text="Enviar"
|
||||
android:textStyle="bold"/>
|
||||
</LinearLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
125
app/src/main/res/layout/activity_definicoes.xml
Normal file
125
app/src/main/res/layout/activity_definicoes.xml
Normal file
@@ -0,0 +1,125 @@
|
||||
<?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="#F8FAFC">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="20dp"
|
||||
android:background="#FFFFFF"
|
||||
android:elevation="4dp">
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Definições"
|
||||
android:textSize="22sp"
|
||||
android:textStyle="bold"
|
||||
android:textColor="#0F172A"/>
|
||||
</LinearLayout>
|
||||
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:padding="16dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="APARÊNCIA"
|
||||
android:textSize="12sp"
|
||||
android:textStyle="bold"
|
||||
android:textColor="#64748B"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginStart="8dp"/>
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:cardCornerRadius="12dp"
|
||||
android:layout_marginBottom="24dp">
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="16dp"
|
||||
android:gravity="center_vertical">
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="Modo Escuro"
|
||||
android:textSize="16sp"
|
||||
android:textColor="#0F172A"/>
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/switchDarkMode"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
</LinearLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="CONTA E SEGURANÇA"
|
||||
android:textSize="12sp"
|
||||
android:textStyle="bold"
|
||||
android:textColor="#64748B"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginStart="8dp"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnEditarNome"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="55dp"
|
||||
android:text="Mudar Nome"
|
||||
android:backgroundTint="#FFFFFF"
|
||||
android:textColor="#0F172A"
|
||||
android:layout_marginBottom="8dp"
|
||||
app:cornerRadius="12dp"
|
||||
android:gravity="start|center_vertical"
|
||||
android:paddingStart="16dp"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnMudarEmail"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="55dp"
|
||||
android:text="Alterar Email"
|
||||
android:backgroundTint="#FFFFFF"
|
||||
android:textColor="#0F172A"
|
||||
android:layout_marginBottom="8dp"
|
||||
app:cornerRadius="12dp"
|
||||
android:gravity="start|center_vertical"
|
||||
android:paddingStart="16dp"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnMudarPass"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="55dp"
|
||||
android:text="Alterar Palavra-Passe"
|
||||
android:backgroundTint="#FFFFFF"
|
||||
android:textColor="#0F172A"
|
||||
android:layout_marginBottom="24dp"
|
||||
app:cornerRadius="12dp"
|
||||
android:gravity="start|center_vertical"
|
||||
android:paddingStart="16dp"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnVoltarDef"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="55dp"
|
||||
android:text="Voltar"
|
||||
android:backgroundTint="#E2E8F0"
|
||||
android:textColor="#0F172A"
|
||||
app:cornerRadius="12dp"/>
|
||||
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
</LinearLayout>
|
||||
@@ -1,149 +1,156 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<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:background="#F4F9F5"
|
||||
android:fillViewport="true">
|
||||
android:orientation="vertical"
|
||||
android:background="#F1F5F9">
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:cardElevation="4dp"
|
||||
app:cardCornerRadius="0dp"
|
||||
app:cardBackgroundColor="#03A9F4">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="24dp"
|
||||
android:gravity="top">
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Desafios"
|
||||
android:textSize="24sp"
|
||||
android:textStyle="bold"
|
||||
android:textColor="#2E3D32"
|
||||
android:gravity="center"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="16dp"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:background="#FFFFFF"
|
||||
android:elevation="4dp"
|
||||
android:padding="16dp"
|
||||
android:gravity="center"
|
||||
android:layout_marginBottom="24dp">
|
||||
android:gravity="center">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="🏋️"
|
||||
android:textSize="32sp"
|
||||
android:layout_marginEnd="16dp"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Pontos:"
|
||||
android:textSize="20sp"
|
||||
android:textStyle="bold"
|
||||
android:textColor="#757575"
|
||||
android:layout_marginEnd="8dp"/>
|
||||
android:text="Os Teus Pontos"
|
||||
android:textColor="#E0F2FE"
|
||||
android:textSize="14sp"
|
||||
android:textStyle="bold"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvPontos"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="0"
|
||||
android:textSize="24sp"
|
||||
android:textStyle="bold"
|
||||
android:textColor="#4CAF50"/>
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="48sp"
|
||||
android:textStyle="bold"/>
|
||||
</LinearLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:padding="16dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Desafios Diários"
|
||||
android:textSize="20sp"
|
||||
android:textStyle="bold"
|
||||
android:textColor="#1E293B"
|
||||
android:layout_marginBottom="16dp"/>
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:cardCornerRadius="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
app:cardElevation="2dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:background="#FFFFFF"
|
||||
android:elevation="2dp"
|
||||
android:padding="16dp"
|
||||
android:layout_marginBottom="16dp">
|
||||
android:padding="16dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="1. Fazer 10 Flexões (+20 pts)"
|
||||
android:textSize="18sp"
|
||||
android:text="Desafio: 20 Flexões"
|
||||
android:textStyle="bold"
|
||||
android:textColor="#2E3D32"/>
|
||||
android:textSize="16sp"
|
||||
android:textColor="#0F172A"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvStatusDesafio1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Estado: Pendente"
|
||||
android:textColor="#FF9800"
|
||||
android:layout_marginTop="4dp"
|
||||
android:layout_marginBottom="8dp"/>
|
||||
android:text="Pendente"
|
||||
android:textColor="#64748B"
|
||||
android:textSize="14sp"
|
||||
android:layout_marginTop="4dp"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnVideoDesafio1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Gravar Vídeo"
|
||||
android:backgroundTint="#2196F3"
|
||||
android:drawableStart="@android:drawable/ic_menu_camera"
|
||||
android:paddingStart="16dp"/>
|
||||
android:text="Gravar Vídeo Prova"
|
||||
android:layout_marginTop="12dp"
|
||||
android:backgroundTint="#03A9F4"
|
||||
app:cornerRadius="8dp"/>
|
||||
</LinearLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:cardCornerRadius="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
app:cardElevation="2dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:background="#FFFFFF"
|
||||
android:elevation="2dp"
|
||||
android:padding="16dp"
|
||||
android:layout_marginBottom="16dp">
|
||||
android:padding="16dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="2. Prancha de 30 Segundos (+30 pts)"
|
||||
android:textSize="18sp"
|
||||
android:text="Desafio: 30 Agachamentos"
|
||||
android:textStyle="bold"
|
||||
android:textColor="#2E3D32"/>
|
||||
android:textSize="16sp"
|
||||
android:textColor="#0F172A"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvStatusDesafio2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Estado: Pendente"
|
||||
android:textColor="#FF9800"
|
||||
android:layout_marginTop="4dp"
|
||||
android:layout_marginBottom="8dp"/>
|
||||
android:text="Pendente"
|
||||
android:textColor="#64748B"
|
||||
android:textSize="14sp"
|
||||
android:layout_marginTop="4dp"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnVideoDesafio2"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Gravar Vídeo"
|
||||
android:backgroundTint="#2196F3"
|
||||
android:drawableStart="@android:drawable/ic_menu_camera"
|
||||
android:paddingStart="16dp"/>
|
||||
android:text="Gravar Vídeo Prova"
|
||||
android:layout_marginTop="12dp"
|
||||
android:backgroundTint="#03A9F4"
|
||||
app:cornerRadius="8dp"/>
|
||||
</LinearLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"/>
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnVoltarDesafios"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="60dp"
|
||||
android:backgroundTint="#E0E0E0"
|
||||
android:textColor="#000000"
|
||||
android:layout_height="55dp"
|
||||
android:layout_margin="16dp"
|
||||
android:text="Voltar ao Início"
|
||||
android:layout_marginTop="16dp"/>
|
||||
android:backgroundTint="#94A3B8"
|
||||
app:cornerRadius="12dp"/>
|
||||
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
</LinearLayout>
|
||||
79
app/src/main/res/layout/activity_editar_perfil.xml
Normal file
79
app/src/main/res/layout/activity_editar_perfil.xml
Normal file
@@ -0,0 +1,79 @@
|
||||
<?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="#F8FAFA"
|
||||
android:padding="24dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Editar Conta"
|
||||
android:textSize="28sp"
|
||||
android:textStyle="bold"
|
||||
android:textColor="#111827"
|
||||
android:layout_marginBottom="32dp"/>
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="16dp"
|
||||
app:cardCornerRadius="12dp"
|
||||
app:cardElevation="2dp">
|
||||
<EditText
|
||||
android:id="@+id/etEditNome"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="55dp"
|
||||
android:background="@android:color/transparent"
|
||||
android:hint="Novo Nome"
|
||||
android:paddingStart="16dp"
|
||||
android:paddingEnd="16dp"/>
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="16dp"
|
||||
app:cardCornerRadius="12dp"
|
||||
app:cardElevation="2dp">
|
||||
<EditText
|
||||
android:id="@+id/etEditEmail"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="55dp"
|
||||
android:background="@android:color/transparent"
|
||||
android:hint="Novo Email"
|
||||
android:paddingStart="16dp"
|
||||
android:paddingEnd="16dp"/>
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="32dp"
|
||||
app:cardCornerRadius="12dp"
|
||||
app:cardElevation="2dp">
|
||||
<EditText
|
||||
android:id="@+id/etEditPassword"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="55dp"
|
||||
android:background="@android:color/transparent"
|
||||
android:hint="Nova Password"
|
||||
android:inputType="textPassword"
|
||||
android:paddingStart="16dp"
|
||||
android:paddingEnd="16dp"/>
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnGuardarPerfil"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="60dp"
|
||||
android:text="Guardar Alterações"
|
||||
android:textSize="18sp"
|
||||
android:textStyle="bold"
|
||||
android:backgroundTint="#03A9F4"
|
||||
android:textColor="#FFFFFF"
|
||||
app:cornerRadius="12dp"/>
|
||||
|
||||
</LinearLayout>
|
||||
@@ -1,82 +1,145 @@
|
||||
<?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:padding="32dp"
|
||||
android:gravity="top|center_horizontal">
|
||||
android:background="#F8FAFC">
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Avaliação Física"
|
||||
android:textSize="24sp"
|
||||
android:textStyle="bold"
|
||||
android:textColor="#1E293B"
|
||||
android:padding="20dp"
|
||||
android:background="#FFFFFF"
|
||||
android:elevation="4dp"/>
|
||||
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:padding="16dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:cardCornerRadius="16dp"
|
||||
app:cardElevation="2dp"
|
||||
android:layout_marginBottom="16dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center"
|
||||
android:padding="24dp"
|
||||
android:background="#E0F2FE">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="O Teu Progresso"
|
||||
android:textSize="28sp"
|
||||
android:text="O Teu IMC"
|
||||
android:textSize="14sp"
|
||||
android:textColor="#0284C7"
|
||||
android:textStyle="bold"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvImcEst"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="00.0"
|
||||
android:textSize="48sp"
|
||||
android:textStyle="bold"
|
||||
android:layout_marginBottom="32dp"/>
|
||||
android:textColor="#0369A1"
|
||||
android:layout_marginVertical="8dp"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:id="@+id/tvImcStatus"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Objetivo de Peso"
|
||||
android:text="A calcular..."
|
||||
android:textSize="18sp"
|
||||
android:textStyle="bold"/>
|
||||
android:textStyle="bold"
|
||||
android:textColor="#FFFFFF"
|
||||
android:background="#0284C7"
|
||||
android:paddingHorizontal="16dp"
|
||||
android:paddingVertical="6dp"/>
|
||||
</LinearLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvPesoStatus"
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Faltam 5 kg para a tua meta!"
|
||||
android:layout_marginTop="8dp"/>
|
||||
android:orientation="horizontal"
|
||||
android:layout_marginBottom="16dp">
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progressPeso"
|
||||
style="?android:attr/progressBarStyleHorizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="24dp"
|
||||
android:max="100"
|
||||
android:progress="60"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="24dp"/>
|
||||
|
||||
<TextView
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
app:cardCornerRadius="12dp"
|
||||
android:layout_marginEnd="8dp">
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Calorias Consumidas (Hoje)"
|
||||
android:textSize="18sp"
|
||||
android:textStyle="bold"/>
|
||||
android:orientation="vertical"
|
||||
android:padding="16dp"
|
||||
android:gravity="center">
|
||||
<TextView android:id="@+id/tvPesoEst" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="-- kg" android:textSize="22sp" android:textStyle="bold" android:textColor="#0F172A"/>
|
||||
</LinearLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvCalorias"
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
app:cardCornerRadius="12dp"
|
||||
android:layout_marginStart="8dp">
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="1200 / 1800 kcal"
|
||||
android:textSize="22sp"
|
||||
android:textColor="#FF9800"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="24dp"/>
|
||||
android:orientation="vertical"
|
||||
android:padding="16dp"
|
||||
android:gravity="center">
|
||||
<TextView android:id="@+id/tvAlturaEst" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="-- m" android:textSize="22sp" android:textStyle="bold" android:textColor="#0F172A"/>
|
||||
</LinearLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Água Bebida"
|
||||
android:textSize="18sp"
|
||||
android:textStyle="bold"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvAgua"
|
||||
app:cardCornerRadius="16dp"
|
||||
android:layout_marginBottom="24dp">
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="1.5 L / 2.5 L"
|
||||
android:textSize="22sp"
|
||||
android:textColor="#03A9F4"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="32dp"/>
|
||||
android:orientation="vertical"
|
||||
android:padding="16dp">
|
||||
</LinearLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnVoltarHome"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="60dp"
|
||||
android:layout_margin="16dp"
|
||||
android:text="Voltar ao Início"
|
||||
android:layout_marginTop="16dp"/>
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold"
|
||||
android:backgroundTint="#94A3B8"
|
||||
android:textColor="#FFFFFF"
|
||||
app:cornerRadius="12dp"/>
|
||||
|
||||
</LinearLayout>
|
||||
@@ -1,129 +1,106 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<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:background="#F4F9F5"
|
||||
android:fillViewport="true">
|
||||
android:orientation="vertical"
|
||||
android:background="#F8FAFC">
|
||||
|
||||
<!-- Cabeçalho -->
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="20dp"
|
||||
android:background="#FFFFFF"
|
||||
android:elevation="4dp"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="Escanear Comida 📸"
|
||||
android:textSize="22sp"
|
||||
android:textStyle="bold"
|
||||
android:textColor="#0F172A"/>
|
||||
</LinearLayout>
|
||||
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:padding="24dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="24dp"
|
||||
android:gravity="center_horizontal">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Scanner
|
||||
"
|
||||
android:textSize="24sp"
|
||||
android:textStyle="bold"
|
||||
android:textColor="#2E3D32"
|
||||
android:layout_marginBottom="24dp"/>
|
||||
android:orientation="vertical">
|
||||
|
||||
<!-- Caixa onde vai aparecer a foto -->
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="250dp"
|
||||
android:layout_marginBottom="24dp"
|
||||
app:cardCornerRadius="16dp"
|
||||
app:cardElevation="4dp"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
app:cardElevation="2dp"
|
||||
android:layout_marginBottom="24dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivFotoComida"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:src="@android:drawable/ic_menu_camera"
|
||||
android:scaleType="centerCrop"
|
||||
android:background="#E0E0E0"/>
|
||||
android:background="#E2E8F0"
|
||||
android:padding="60dp" />
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<!-- Botão para abrir a câmara do telemóvel -->
|
||||
<Button
|
||||
android:id="@+id/btnTirarFotoComida"
|
||||
android:id="@+id/btnTirarFoto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="60dp"
|
||||
android:text="Tirar Foto e Analisar"
|
||||
android:backgroundTint="#4CAF50"
|
||||
android:text="Abrir Câmara"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold"
|
||||
android:layout_marginBottom="24dp"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/layoutResultadosIA"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone"
|
||||
android:background="#FFFFFF"
|
||||
android:padding="16dp"
|
||||
android:elevation="4dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvNomePratoDetectado"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Prato detetado: Salada César"
|
||||
android:textSize="18sp"
|
||||
android:textStyle="bold"
|
||||
android:textColor="#2E3D32"
|
||||
android:layout_marginBottom="16dp"/>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recyclerViewIngredientes"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="16dp"/>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="#E0E0E0"
|
||||
android:layout_marginBottom="16dp"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center_vertical">
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Total Estimado:"
|
||||
android:textSize="20sp"
|
||||
android:layout_weight="1"/>
|
||||
<TextView
|
||||
android:id="@+id/tvTotalCalorias"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="0 kcal"
|
||||
android:textSize="24sp"
|
||||
android:textStyle="bold"
|
||||
android:textColor="#4CAF50"/>
|
||||
</LinearLayout>
|
||||
android:backgroundTint="#0284C7"
|
||||
app:cornerRadius="15dp"
|
||||
android:layout_marginBottom="12dp"/>
|
||||
|
||||
<!-- Botão para analisar (só aparece depois de tirar a foto) -->
|
||||
<Button
|
||||
android:id="@+id/btnAddIngredienteManual"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="+ Adicionar Ingrediente Extra"
|
||||
android:backgroundTint="#2196F3"
|
||||
android:layout_marginTop="16dp"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnConfirmarRefeicao"
|
||||
android:id="@+id/btnAnalisarIA"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="60dp"
|
||||
android:text="Confirmar Refeição"
|
||||
android:backgroundTint="#FF9800"
|
||||
android:text="Analisar com IA ✨"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold"
|
||||
android:layout_marginTop="16dp"/>
|
||||
</LinearLayout>
|
||||
android:backgroundTint="#10B981"
|
||||
app:cornerRadius="15dp"
|
||||
android:layout_marginBottom="24dp"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<!-- Caixa onde vai aparecer o resultado da IA -->
|
||||
<TextView
|
||||
android:id="@+id/tvResultadoIA"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Tira uma foto ao teu prato para a Inteligência Artificial calcular as calorias e os macronutrientes!"
|
||||
android:textSize="16sp"
|
||||
android:textColor="#64748B"
|
||||
android:textAlignment="center"
|
||||
android:background="@android:color/transparent"
|
||||
android:padding="16dp"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnVoltarFoto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="60dp"
|
||||
android:layout_height="50dp"
|
||||
android:text="Voltar"
|
||||
android:backgroundTint="#E0E0E0"
|
||||
android:textColor="#000000"
|
||||
android:textColor="#0F172A"
|
||||
android:backgroundTint="#E2E8F0"
|
||||
app:cornerRadius="12dp"
|
||||
android:layout_marginTop="24dp"/>
|
||||
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
</ScrollView>
|
||||
</LinearLayout>
|
||||
@@ -3,7 +3,7 @@
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#F8FAFA"
|
||||
android:background="#F8FAFC"
|
||||
android:fillViewport="true">
|
||||
|
||||
<LinearLayout
|
||||
@@ -15,149 +15,21 @@
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Meu Progresso"
|
||||
android:textSize="28sp"
|
||||
android:textStyle="bold"
|
||||
android:textColor="#111827"
|
||||
android:layout_marginTop="16dp"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Acompanhe sua jornada de emagrecimento"
|
||||
android:text="A tua jornada começa aqui,"
|
||||
android:textSize="14sp"
|
||||
android:textColor="#6B7280"
|
||||
android:layout_marginTop="4dp"
|
||||
android:textColor="#64748B"
|
||||
android:layout_marginTop="8dp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvSaudacaoHome"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Carregando..."
|
||||
android:textSize="28sp"
|
||||
android:textStyle="bold"
|
||||
android:textColor="#0F172A"
|
||||
android:layout_marginBottom="32dp"/>
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:id="@+id/cardPerfil"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:foreground="?android:attr/selectableItemBackground"
|
||||
app:cardCornerRadius="16dp"
|
||||
app:cardElevation="2dp"
|
||||
app:contentPadding="16dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
app:cardCornerRadius="12dp"
|
||||
app:cardBackgroundColor="#673AB7"
|
||||
app:cardElevation="0dp">
|
||||
<ImageView
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_gravity="center"
|
||||
android:src="@android:drawable/ic_menu_myplaces"
|
||||
app:tint="#FFFFFF"/>
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical"
|
||||
android:layout_marginStart="16dp">
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="O Meu Perfil"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold"
|
||||
android:textColor="#111827"/>
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Vê e edita os teus dados pessoais"
|
||||
android:textSize="12sp"
|
||||
android:textColor="#6B7280"
|
||||
android:layout_marginTop="2dp"/>
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="›"
|
||||
android:textSize="28sp"
|
||||
android:textColor="#D1D5DB"
|
||||
android:layout_marginStart="8dp"/>
|
||||
</LinearLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:id="@+id/cardEstatisticas"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:foreground="?android:attr/selectableItemBackground"
|
||||
app:cardCornerRadius="16dp"
|
||||
app:cardElevation="2dp"
|
||||
app:contentPadding="16dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
app:cardCornerRadius="12dp"
|
||||
app:cardBackgroundColor="#03A9F4"
|
||||
app:cardElevation="0dp">
|
||||
<ImageView
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_gravity="center"
|
||||
android:src="@android:drawable/ic_menu_sort_by_size"
|
||||
app:tint="#FFFFFF"/>
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical"
|
||||
android:layout_marginStart="16dp">
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Estatísticas"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold"
|
||||
android:textColor="#111827"/>
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Veja seus números e progresso"
|
||||
android:textSize="12sp"
|
||||
android:textColor="#6B7280"
|
||||
android:layout_marginTop="2dp"/>
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="›"
|
||||
android:textSize="28sp"
|
||||
android:textColor="#D1D5DB"
|
||||
android:layout_marginStart="8dp"/>
|
||||
</LinearLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:id="@+id/cardTirarFoto"
|
||||
android:layout_width="match_parent"
|
||||
@@ -166,9 +38,10 @@
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:foreground="?android:attr/selectableItemBackground"
|
||||
app:cardCornerRadius="16dp"
|
||||
app:cardElevation="2dp"
|
||||
app:contentPadding="16dp">
|
||||
app:cardCornerRadius="20dp"
|
||||
app:cardElevation="6dp"
|
||||
app:cardBackgroundColor="#0F172A"
|
||||
app:contentPadding="20dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
@@ -177,14 +50,14 @@
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
app:cardCornerRadius="12dp"
|
||||
app:cardBackgroundColor="#E91E63"
|
||||
android:layout_width="56dp"
|
||||
android:layout_height="56dp"
|
||||
app:cardCornerRadius="16dp"
|
||||
app:cardBackgroundColor="#38BDF8"
|
||||
app:cardElevation="0dp">
|
||||
<ImageView
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_width="28dp"
|
||||
android:layout_height="28dp"
|
||||
android:layout_gravity="center"
|
||||
android:src="@android:drawable/ic_menu_camera"
|
||||
app:tint="#FFFFFF"/>
|
||||
@@ -199,16 +72,16 @@
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Tirar foto"
|
||||
android:textSize="16sp"
|
||||
android:text="Escanear Comida"
|
||||
android:textSize="18sp"
|
||||
android:textStyle="bold"
|
||||
android:textColor="#111827"/>
|
||||
android:textColor="#FFFFFF"/>
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Acompanhe a sua dieta"
|
||||
android:textSize="12sp"
|
||||
android:textColor="#6B7280"
|
||||
android:text="A IA analisa a tua refeição"
|
||||
android:textSize="13sp"
|
||||
android:textColor="#94A3B8"
|
||||
android:layout_marginTop="2dp"/>
|
||||
</LinearLayout>
|
||||
|
||||
@@ -216,8 +89,8 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="›"
|
||||
android:textSize="28sp"
|
||||
android:textColor="#D1D5DB"
|
||||
android:textSize="32sp"
|
||||
android:textColor="#38BDF8"
|
||||
android:layout_marginStart="8dp"/>
|
||||
</LinearLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
@@ -244,7 +117,7 @@
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
app:cardCornerRadius="12dp"
|
||||
app:cardBackgroundColor="#00BFA5"
|
||||
app:cardBackgroundColor="#10B981"
|
||||
app:cardElevation="0dp">
|
||||
<ImageView
|
||||
android:layout_width="24dp"
|
||||
@@ -260,29 +133,57 @@
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical"
|
||||
android:layout_marginStart="16dp">
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Chat IA"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold"
|
||||
android:textColor="#111827"/>
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Converse com seu assistente"
|
||||
android:textSize="12sp"
|
||||
android:textColor="#6B7280"
|
||||
android:layout_marginTop="2dp"/>
|
||||
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="NutriChat AI" android:textSize="16sp" android:textStyle="bold" android:textColor="#0F172A"/>
|
||||
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Fala com o teu assistente" android:textSize="12sp" android:textColor="#64748B" android:layout_marginTop="2dp"/>
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="›" android:textSize="28sp" android:textColor="#CBD5E1" android:layout_marginStart="8dp"/>
|
||||
</LinearLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:id="@+id/cardEstatisticas"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="›"
|
||||
android:textSize="28sp"
|
||||
android:textColor="#D1D5DB"
|
||||
android:layout_marginStart="8dp"/>
|
||||
android:layout_marginBottom="16dp"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:foreground="?android:attr/selectableItemBackground"
|
||||
app:cardCornerRadius="16dp"
|
||||
app:cardElevation="2dp"
|
||||
app:contentPadding="16dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
app:cardCornerRadius="12dp"
|
||||
app:cardBackgroundColor="#0284C7"
|
||||
app:cardElevation="0dp">
|
||||
<ImageView
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_gravity="center"
|
||||
android:src="@android:drawable/ic_menu_sort_by_size"
|
||||
app:tint="#FFFFFF"/>
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical"
|
||||
android:layout_marginStart="16dp">
|
||||
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Estatísticas" android:textSize="16sp" android:textStyle="bold" android:textColor="#0F172A"/>
|
||||
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Vê os teus números e progresso" android:textSize="12sp" android:textColor="#64748B" android:layout_marginTop="2dp"/>
|
||||
</LinearLayout>
|
||||
|
||||
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="›" android:textSize="28sp" android:textColor="#CBD5E1" android:layout_marginStart="8dp"/>
|
||||
</LinearLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
@@ -308,7 +209,7 @@
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
app:cardCornerRadius="12dp"
|
||||
app:cardBackgroundColor="#FF5722"
|
||||
app:cardBackgroundColor="#F59E0B"
|
||||
app:cardElevation="0dp">
|
||||
<ImageView
|
||||
android:layout_width="24dp"
|
||||
@@ -324,34 +225,16 @@
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical"
|
||||
android:layout_marginStart="16dp">
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Desafios"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold"
|
||||
android:textColor="#111827"/>
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Complete missões e ganhe prêmios"
|
||||
android:textSize="12sp"
|
||||
android:textColor="#6B7280"
|
||||
android:layout_marginTop="2dp"/>
|
||||
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Desafios Diários" android:textSize="16sp" android:textStyle="bold" android:textColor="#0F172A"/>
|
||||
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Ganha pontos de recompensa" android:textSize="12sp" android:textColor="#64748B" android:layout_marginTop="2dp"/>
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="›"
|
||||
android:textSize="28sp"
|
||||
android:textColor="#D1D5DB"
|
||||
android:layout_marginStart="8dp"/>
|
||||
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="›" android:textSize="28sp" android:textColor="#CBD5E1" android:layout_marginStart="8dp"/>
|
||||
</LinearLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:id="@+id/cardDefinicoes"
|
||||
android:id="@+id/cardPerfil"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="32dp"
|
||||
@@ -372,13 +255,13 @@
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
app:cardCornerRadius="12dp"
|
||||
app:cardBackgroundColor="#37474F"
|
||||
app:cardBackgroundColor="#8B5CF6"
|
||||
app:cardElevation="0dp">
|
||||
<ImageView
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_gravity="center"
|
||||
android:src="@android:drawable/ic_menu_preferences"
|
||||
android:src="@android:drawable/ic_menu_myplaces"
|
||||
app:tint="#FFFFFF"/>
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
@@ -388,29 +271,11 @@
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical"
|
||||
android:layout_marginStart="16dp">
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Definições"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold"
|
||||
android:textColor="#111827"/>
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Personalize seu app"
|
||||
android:textSize="12sp"
|
||||
android:textColor="#6B7280"
|
||||
android:layout_marginTop="2dp"/>
|
||||
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="O Meu Perfil" android:textSize="16sp" android:textStyle="bold" android:textColor="#0F172A"/>
|
||||
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Dados, pontuação e definições" android:textSize="12sp" android:textColor="#64748B" android:layout_marginTop="2dp"/>
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="›"
|
||||
android:textSize="28sp"
|
||||
android:textColor="#D1D5DB"
|
||||
android:layout_marginStart="8dp"/>
|
||||
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="›" android:textSize="28sp" android:textColor="#CBD5E1" android:layout_marginStart="8dp"/>
|
||||
</LinearLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
|
||||
@@ -1,80 +1,189 @@
|
||||
<?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:background="#F4F9F5"
|
||||
android:orientation="vertical"
|
||||
android:padding="32dp"
|
||||
android:gravity="center_horizontal">
|
||||
android:background="#F8FAFC">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="120dp"
|
||||
android:src="@android:drawable/ic_menu_myplaces"
|
||||
android:background="#E8F5E9"
|
||||
android:padding="24dp"
|
||||
android:layout_marginTop="32dp"
|
||||
android:layout_marginBottom="16dp"/>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:padding="20dp"
|
||||
android:background="#FFFFFF"
|
||||
android:elevation="4dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvNomePerfil"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Nome do Utilizador"
|
||||
android:textSize="24sp"
|
||||
android:text="O Meu Perfil"
|
||||
android:textSize="22sp"
|
||||
android:textStyle="bold"
|
||||
android:textColor="#2E3D32"
|
||||
android:layout_marginBottom="32dp"/>
|
||||
android:textColor="#0F172A"/>
|
||||
</LinearLayout>
|
||||
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:padding="24dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:background="#FFFFFF"
|
||||
android:elevation="2dp"
|
||||
android:padding="24dp"
|
||||
android:gravity="center_horizontal">
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="120dp"
|
||||
app:cardCornerRadius="60dp"
|
||||
app:cardElevation="6dp"
|
||||
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:background="#E2E8F0"/>
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvPerfilNome"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Nome do Utilizador"
|
||||
android:textSize="24sp"
|
||||
android:textStyle="bold"
|
||||
android:textColor="#0F172A"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginBottom="32dp"/>
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:cardCornerRadius="20dp"
|
||||
app:cardElevation="2dp"
|
||||
android:layout_marginBottom="32dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Email: utilizador@email.com"
|
||||
android:textSize="16sp"
|
||||
android:textColor="#757575"
|
||||
android:layout_marginBottom="12dp"/>
|
||||
android:orientation="horizontal"
|
||||
android:padding="20dp"
|
||||
android:weightSum="3">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center">
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Altura: 175 cm"
|
||||
android:textSize="16sp"
|
||||
android:textColor="#757575"
|
||||
android:layout_marginBottom="12dp"/>
|
||||
|
||||
android:text="⭐"
|
||||
android:textSize="24sp"/>
|
||||
<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="#F59E0B"/>
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Peso Inicial: 80 kg"
|
||||
android:textSize="16sp"
|
||||
android:textColor="#757575"/>
|
||||
android:text="Pontos"
|
||||
android:textSize="12sp"
|
||||
android:textColor="#64748B"/>
|
||||
</LinearLayout>
|
||||
|
||||
<View android:layout_width="1dp" android:layout_height="match_parent" android:background="#E2E8F0"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center">
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="🏆"
|
||||
android:textSize="24sp"/>
|
||||
<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="#10B981"/>
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Desafios"
|
||||
android:textSize="12sp"
|
||||
android:textColor="#64748B"/>
|
||||
</LinearLayout>
|
||||
|
||||
<View android:layout_width="1dp" android:layout_height="match_parent" android:background="#E2E8F0"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center">
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="🔥"
|
||||
android:textSize="24sp"/>
|
||||
<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="#EF4444"/>
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Sequência"
|
||||
android:textSize="12sp"
|
||||
android:textColor="#64748B"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnSair"
|
||||
android:id="@+id/btnDefinicoes"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="60dp"
|
||||
android:backgroundTint="#F44336"
|
||||
android:text="Terminar Sessão"
|
||||
android:textColor="#FFFFFF"
|
||||
android:text="Definições da Conta"
|
||||
android:textAllCaps="false"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold"
|
||||
android:layout_marginBottom="16dp"/>
|
||||
android:backgroundTint="#0F172A"
|
||||
app:cornerRadius="15dp"
|
||||
android:layout_marginBottom="12dp"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnVoltarPerfil"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="60dp"
|
||||
android:backgroundTint="#E0E0E0"
|
||||
android:text="Voltar"
|
||||
android:textColor="#000000" />
|
||||
android:textAllCaps="false"
|
||||
android:textSize="16sp"
|
||||
android:textColor="#0F172A"
|
||||
android:backgroundTint="#E2E8F0"
|
||||
app:cornerRadius="15dp"/>
|
||||
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
</LinearLayout>
|
||||
56
app/src/main/res/layout/activity_verificacao.xml
Normal file
56
app/src/main/res/layout/activity_verificacao.xml
Normal file
@@ -0,0 +1,56 @@
|
||||
<?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:gravity="center"
|
||||
android:padding="32dp"
|
||||
android:background="#F8FAFC">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="120dp"
|
||||
android:src="@android:drawable/ic_dialog_email"
|
||||
app:tint="#38BDF8"
|
||||
android:layout_marginBottom="24dp"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Verifica o teu Email!"
|
||||
android:textSize="26sp"
|
||||
android:textStyle="bold"
|
||||
android:textColor="#0F172A"
|
||||
android:layout_marginBottom="16dp"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Enviámos um link de confirmação para o teu email. Por favor, abre a tua caixa de correio, clica no link e depois volta aqui."
|
||||
android:textSize="16sp"
|
||||
android:textColor="#64748B"
|
||||
android:textAlignment="center"
|
||||
android:layout_marginBottom="40dp"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnJaConfirmei"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="60dp"
|
||||
android:text="Já confirmei o Email"
|
||||
android:textSize="18sp"
|
||||
android:textStyle="bold"
|
||||
android:backgroundTint="#0F172A"
|
||||
app:cornerRadius="15dp"
|
||||
android:layout_marginBottom="16dp"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnVoltarLoginVerificacao"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="60dp"
|
||||
android:text="Voltar ao Login"
|
||||
android:textColor="#0F172A"
|
||||
android:backgroundTint="#E2E8F0"
|
||||
app:cornerRadius="15dp"/>
|
||||
|
||||
</LinearLayout>
|
||||
Reference in New Issue
Block a user