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:retrofit:2.9.0")
|
||||||
implementation("com.squareup.retrofit2:converter-gson:2.9.0")
|
implementation("com.squareup.retrofit2:converter-gson:2.9.0")
|
||||||
implementation("com.squareup.okhttp3:logging-interceptor:4.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">
|
xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
|
<uses-feature android:name="android.hardware.camera" android:required="false" />
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
@@ -14,7 +15,10 @@
|
|||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:theme="@style/Theme.PAP">
|
android:theme="@style/Theme.PAP">
|
||||||
<activity
|
<activity
|
||||||
android:name=".Ingrediente"
|
android:name=".EditarPerfilActivity"
|
||||||
|
android:exported="false" />
|
||||||
|
<activity
|
||||||
|
android:name=".DefinicoesActivity"
|
||||||
android:exported="false" />
|
android:exported="false" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".PerfilActivity"
|
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;
|
package com.example.pap;
|
||||||
|
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.drawable.GradientDrawable;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
|
||||||
import android.os.Looper;
|
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.View;
|
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
|
import android.widget.ImageButton;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.ScrollView;
|
import android.widget.ScrollView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
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 {
|
public class ChatActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
private EditText etMensagem;
|
||||||
|
private ImageButton btnEnviar;
|
||||||
private LinearLayout chatLayout;
|
private LinearLayout chatLayout;
|
||||||
private ScrollView chatScrollView;
|
private ScrollView chatScrollView;
|
||||||
private EditText etNovaMensagem;
|
|
||||||
private Button btnEnviarMensagem;
|
// A TUA CHAVE DA GOOGLE VEM PARA AQUI!
|
||||||
private Button btnVoltarChat;
|
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
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_chat);
|
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);
|
chatLayout = findViewById(R.id.chatLayout);
|
||||||
chatScrollView = findViewById(R.id.chatScrollView);
|
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ã
|
client = new OkHttpClient();
|
||||||
adicionarMensagemBalao("Olá! Sou o teu IA Coach de Saúde. Como te posso ajudar hoje na tua jornada de emagrecimento?", false);
|
|
||||||
|
|
||||||
// 2. Clique no botão de Enviar
|
// Dá as boas vindas
|
||||||
btnEnviarMensagem.setOnClickListener(new View.OnClickListener() {
|
adicionarBalaoNoEcra("Olá! Sou o NutriChat AI 🤖. O que comeste hoje ou que dúvidas tens sobre a tua dieta?", false);
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
String mensagemUser = etNovaMensagem.getText().toString().trim();
|
|
||||||
|
|
||||||
if (!mensagemUser.isEmpty()) {
|
btnEnviar.setOnClickListener(v -> {
|
||||||
// Adiciona a mensagem do utilizador no ecrã
|
String pergunta = etMensagem.getText().toString().trim();
|
||||||
adicionarMensagemBalao(mensagemUser, true);
|
if (pergunta.isEmpty()) {
|
||||||
|
Toast.makeText(this, "Escreve alguma merda primeiro!", Toast.LENGTH_SHORT).show();
|
||||||
// Limpa a caixa de texto
|
return;
|
||||||
etNovaMensagem.setText("");
|
|
||||||
|
|
||||||
// Simula a IA a processar e a responder
|
|
||||||
simularRespostaDaIA(mensagemUser);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// 3. Clique no botão de Voltar
|
// 1. Mostrar a mensagem do utilizador no ecrã
|
||||||
btnVoltarChat.setOnClickListener(new View.OnClickListener() {
|
adicionarBalaoNoEcra(pergunta, true);
|
||||||
@Override
|
etMensagem.setText(""); // Limpa a caixa de texto
|
||||||
public void onClick(View v) {
|
|
||||||
finish();
|
// 2. Chamar a Inteligência Artificial
|
||||||
}
|
chamarGemini(pergunta);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Passo 3: Função para desenhar os balões de conversa no ecrã
|
// Função que desenha os balões de conversa no ecrã
|
||||||
private void adicionarMensagemBalao(String texto, boolean isUser) {
|
private void adicionarBalaoNoEcra(String texto, boolean isUser) {
|
||||||
TextView textView = new TextView(this);
|
runOnUiThread(() -> {
|
||||||
textView.setText(texto);
|
TextView tv = new TextView(this);
|
||||||
textView.setTextSize(16f);
|
tv.setText(texto);
|
||||||
textView.setPadding(32, 24, 32, 24);
|
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 params = new LinearLayout.LayoutParams(
|
||||||
LinearLayout.LayoutParams.WRAP_CONTENT,
|
LinearLayout.LayoutParams.WRAP_CONTENT,
|
||||||
LinearLayout.LayoutParams.WRAP_CONTENT
|
LinearLayout.LayoutParams.WRAP_CONTENT
|
||||||
);
|
);
|
||||||
params.setMargins(0, 16, 0, 16);
|
params.setMargins(0, 10, 0, 10);
|
||||||
|
|
||||||
// Configurar o design arredondado do balão
|
|
||||||
GradientDrawable background = new GradientDrawable();
|
|
||||||
background.setCornerRadius(32f);
|
|
||||||
|
|
||||||
|
// Se for o utilizador, o balão vai para a direita e fica azul
|
||||||
if (isUser) {
|
if (isUser) {
|
||||||
// Estilo do Utilizador (Fundo Verde, Texto Branco, Alinhado à direita)
|
|
||||||
params.gravity = Gravity.END;
|
params.gravity = Gravity.END;
|
||||||
background.setColor(Color.parseColor("#4CAF50"));
|
tv.setBackgroundResource(R.drawable.balao_user); // Já vamos criar isto!
|
||||||
textView.setTextColor(Color.WHITE);
|
|
||||||
} else {
|
} 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;
|
params.gravity = Gravity.START;
|
||||||
background.setColor(Color.parseColor("#FFFFFF"));
|
tv.setBackgroundResource(R.drawable.balao_ai); // Já vamos criar isto!
|
||||||
textView.setTextColor(Color.parseColor("#2E3D32"));
|
|
||||||
textView.setElevation(4f); // Dá uma pequena sombra ao balão da IA
|
|
||||||
}
|
}
|
||||||
|
|
||||||
textView.setLayoutParams(params);
|
tv.setLayoutParams(params);
|
||||||
textView.setBackground(background);
|
chatLayout.addView(tv);
|
||||||
|
|
||||||
// Adicionar o balão ao ecrã
|
// Faz scroll automático para o fundo para ver a mensagem nova
|
||||||
chatLayout.addView(textView);
|
chatScrollView.post(() -> chatScrollView.fullScroll(ScrollView.FOCUS_DOWN));
|
||||||
|
|
||||||
// Fazer scroll automático para baixo para ver a nova mensagem
|
|
||||||
chatScrollView.post(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
chatScrollView.fullScroll(ScrollView.FOCUS_DOWN);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Passo 4: Função para simular a inteligência da IA
|
// Função que vai à internet falar com o cérebro da Google
|
||||||
private void simularRespostaDaIA(String perguntaUtilizador) {
|
private void chamarGemini(String pergunta) {
|
||||||
perguntaUtilizador = perguntaUtilizador.toLowerCase();
|
try {
|
||||||
final String resposta;
|
// 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
|
// Construir o JSON que o Gemini exige
|
||||||
if (perguntaUtilizador.contains("água") || perguntaUtilizador.contains("agua")) {
|
JSONObject part = new JSONObject();
|
||||||
resposta = "A hidratação é fundamental! O ideal é beberes pelo menos 2 a 3 litros de água por dia. Já bebeste algum copo hoje?";
|
part.put("text", promptCompleto);
|
||||||
} else if (perguntaUtilizador.contains("comer") || perguntaUtilizador.contains("fome") || perguntaUtilizador.contains("dieta")) {
|
JSONArray parts = new JSONArray();
|
||||||
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!";
|
parts.put(part);
|
||||||
} else if (perguntaUtilizador.contains("treino") || perguntaUtilizador.contains("exercício") || perguntaUtilizador.contains("correr")) {
|
JSONObject content = new JSONObject();
|
||||||
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.";
|
content.put("parts", parts);
|
||||||
} else {
|
JSONArray contents = new JSONArray();
|
||||||
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!";
|
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)
|
RequestBody body = RequestBody.create(jsonBody.toString(), MediaType.get("application/json; charset=utf-8"));
|
||||||
new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
|
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
|
@Override
|
||||||
public void run() {
|
public void onFailure(Call call, IOException e) {
|
||||||
adicionarMensagemBalao(resposta, false);
|
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;
|
package com.example.pap;
|
||||||
|
|
||||||
import android.content.ActivityNotFoundException;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
|
||||||
import android.os.Looper;
|
|
||||||
import android.provider.MediaStore;
|
import android.provider.MediaStore;
|
||||||
|
import android.util.Base64;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
|
||||||
import androidx.activity.result.ActivityResultLauncher;
|
import androidx.activity.result.ActivityResultLauncher;
|
||||||
import androidx.activity.result.contract.ActivityResultContracts;
|
import androidx.activity.result.contract.ActivityResultContracts;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.Collections;
|
||||||
|
|
||||||
|
import retrofit2.Call;
|
||||||
|
import retrofit2.Callback;
|
||||||
|
import retrofit2.Response;
|
||||||
|
|
||||||
public class FotoActivity extends AppCompatActivity {
|
public class FotoActivity extends AppCompatActivity {
|
||||||
|
|
||||||
private ImageView ivFotoComida;
|
private ImageView ivFotoComida;
|
||||||
private Button btnTirarFoto, btnVoltar, btnAddManual, btnConfirmar;
|
private Button btnTirarFoto, btnAnalisarIA, btnVoltarFoto;
|
||||||
private LinearLayout layoutResultadosIA;
|
private TextView tvResultadoIA;
|
||||||
private TextView tvTotalCalorias, tvNomePrato;
|
private Bitmap imagemCapturada;
|
||||||
private RecyclerView recyclerView;
|
|
||||||
private IngredientesAdapter adapter;
|
|
||||||
private ArrayList<Ingrediente> listaIngredientes;
|
|
||||||
|
|
||||||
// Lançador da Câmara
|
// COLA A TUA CHAVE DO OPENROUTER AQUI (Aquela que tiraste sem telemóvel e sem VPN)
|
||||||
private final ActivityResultLauncher<Intent> cameraLauncher = registerForActivityResult(
|
private final String MINHA_API_KEY = "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";
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_foto);
|
setContentView(R.layout.activity_foto);
|
||||||
|
|
||||||
// Inicializar vistas
|
|
||||||
ivFotoComida = findViewById(R.id.ivFotoComida);
|
ivFotoComida = findViewById(R.id.ivFotoComida);
|
||||||
btnTirarFoto = findViewById(R.id.btnTirarFotoComida);
|
btnTirarFoto = findViewById(R.id.btnTirarFoto);
|
||||||
btnVoltar = findViewById(R.id.btnVoltarFoto);
|
btnAnalisarIA = findViewById(R.id.btnAnalisarIA);
|
||||||
layoutResultadosIA = findViewById(R.id.layoutResultadosIA);
|
tvResultadoIA = findViewById(R.id.tvResultadoIA);
|
||||||
tvTotalCalorias = findViewById(R.id.tvTotalCalorias);
|
btnVoltarFoto = findViewById(R.id.btnVoltarFoto);
|
||||||
tvNomePrato = findViewById(R.id.tvNomePratoDetectado);
|
|
||||||
recyclerView = findViewById(R.id.recyclerViewIngredientes);
|
|
||||||
btnAddManual = findViewById(R.id.btnAddIngredienteManual);
|
|
||||||
btnConfirmar = findViewById(R.id.btnConfirmarRefeicao);
|
|
||||||
|
|
||||||
// Configurar a RecyclerView
|
ActivityResultLauncher<Intent> cameraLauncher = registerForActivityResult(
|
||||||
listaIngredientes = new ArrayList<>();
|
new ActivityResultContracts.StartActivityForResult(),
|
||||||
recyclerView.setLayoutManager(new LinearLayoutManager(this));
|
result -> {
|
||||||
adapter = new IngredientesAdapter(listaIngredientes);
|
if (result.getResultCode() == RESULT_OK && result.getData() != null) {
|
||||||
recyclerView.setAdapter(adapter);
|
Bundle extras = result.getData().getExtras();
|
||||||
|
imagemCapturada = (Bitmap) extras.get("data");
|
||||||
|
|
||||||
// Configurar o clique no botão de apagar (lixo) na lista
|
ivFotoComida.setPadding(0, 0, 0, 0);
|
||||||
adapter.setOnItemClickListener(new IngredientesAdapter.OnItemClickListener() {
|
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
|
@Override
|
||||||
public void onDeleteClick(int position) {
|
public void onResponse(Call<AiResponse> call, Response<AiResponse> response) {
|
||||||
removerIngrediente(position);
|
btnAnalisarIA.setEnabled(true);
|
||||||
}
|
if (response.isSuccessful() && response.body() != null) {
|
||||||
});
|
|
||||||
|
|
||||||
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);
|
|
||||||
try {
|
try {
|
||||||
cameraLauncher.launch(takePictureIntent);
|
String resultado = response.body().choices.get(0).message.content;
|
||||||
} catch (ActivityNotFoundException e) {
|
tvResultadoIA.setText(resultado);
|
||||||
Toast.makeText(this, "Erro ao abrir a câmara.", Toast.LENGTH_SHORT).show();
|
} 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
|
@Override
|
||||||
private void simularAnaliseIA() {
|
public void onFailure(Call<AiResponse> call, Throwable t) {
|
||||||
new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
btnAnalisarIA.setEnabled(true);
|
||||||
// 1. Mostra a área de resultados
|
tvResultadoIA.setText("Falha na ligação à Internet.");
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
// 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.text.InputType;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
@@ -15,58 +16,46 @@ public class HomeActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
private SharedPreferences sharedPreferences;
|
private SharedPreferences sharedPreferences;
|
||||||
|
|
||||||
// Agora são 6 cartões!
|
// Os 5 cartões principais do teu novo design
|
||||||
private CardView cardPerfil, cardEstatisticas, cardTirarFoto, cardChat, cardDesafios, cardDefinicoes;
|
private CardView cardTirarFoto, cardChat, cardEstatisticas, cardDesafios, cardPerfil;
|
||||||
|
private TextView tvSaudacaoHome;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_home);
|
setContentView(R.layout.activity_home);
|
||||||
|
|
||||||
// 1. Iniciar a memória do telemóvel
|
// 1. Iniciar a memória do telemóvel (Onde guardámos os dados no Registo)
|
||||||
sharedPreferences = getSharedPreferences("AppEmagrecimento", MODE_PRIVATE);
|
sharedPreferences = getSharedPreferences("MeusDadosApp", MODE_PRIVATE);
|
||||||
|
|
||||||
// 2. Ligar os cartões do XML ao código
|
// 2. Ligar ao XML
|
||||||
cardPerfil = findViewById(R.id.cardPerfil);
|
|
||||||
cardEstatisticas = findViewById(R.id.cardEstatisticas);
|
|
||||||
cardTirarFoto = findViewById(R.id.cardTirarFoto);
|
cardTirarFoto = findViewById(R.id.cardTirarFoto);
|
||||||
cardChat = findViewById(R.id.cardChat);
|
cardChat = findViewById(R.id.cardChat);
|
||||||
|
cardEstatisticas = findViewById(R.id.cardEstatisticas);
|
||||||
cardDesafios = findViewById(R.id.cardDesafios);
|
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
|
// 3. Preencher o nome do utilizador no cabeçalho
|
||||||
cardPerfil.setOnClickListener(v -> {
|
String nome = sharedPreferences.getString("nome", "Guerreiro");
|
||||||
Toast.makeText(this, "A abrir O Meu Perfil...", Toast.LENGTH_SHORT).show();
|
tvSaudacaoHome.setText("Olá, " + nome + "! 👋");
|
||||||
// startActivity(new Intent(HomeActivity.this, PerfilActivity.class));
|
|
||||||
});
|
|
||||||
|
|
||||||
cardEstatisticas.setOnClickListener(v -> {
|
// 4. ATIVAR OS CLIQUES (Os Intents para abrir os outros ecrãs)
|
||||||
Toast.makeText(this, "A abrir Estatísticas...", Toast.LENGTH_SHORT).show();
|
cardTirarFoto.setOnClickListener(v -> startActivity(new Intent(HomeActivity.this, FotoActivity.class)));
|
||||||
// startActivity(new Intent(HomeActivity.this, EstatisticasActivity.class));
|
|
||||||
});
|
|
||||||
|
|
||||||
cardTirarFoto.setOnClickListener(v -> {
|
cardChat.setOnClickListener(v -> startActivity(new Intent(HomeActivity.this, ChatActivity.class)));
|
||||||
startActivity(new Intent(HomeActivity.this, FotoActivity.class));
|
|
||||||
});
|
|
||||||
|
|
||||||
cardChat.setOnClickListener(v -> {
|
cardEstatisticas.setOnClickListener(v -> startActivity(new Intent(HomeActivity.this, EstatisticasActivity.class)));
|
||||||
startActivity(new Intent(HomeActivity.this, ChatActivity.class));
|
|
||||||
});
|
|
||||||
|
|
||||||
cardDesafios.setOnClickListener(v -> {
|
cardDesafios.setOnClickListener(v -> startActivity(new Intent(HomeActivity.this, DesafiosActivity.class)));
|
||||||
startActivity(new Intent(HomeActivity.this, DesafiosActivity.class));
|
|
||||||
});
|
|
||||||
|
|
||||||
cardDefinicoes.setOnClickListener(v -> {
|
cardPerfil.setOnClickListener(v -> startActivity(new Intent(HomeActivity.this, PerfilActivity.class)));
|
||||||
Toast.makeText(this, "A abrir Definições...", Toast.LENGTH_SHORT).show();
|
|
||||||
// startActivity(new Intent(HomeActivity.this, DefinicoesActivity.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();
|
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() {
|
private void verificarAtualizacaoSemanal() {
|
||||||
long dataUltimaAtualizacao = sharedPreferences.getLong("data_ultima_atualizacao", 0);
|
long dataUltimaAtualizacao = sharedPreferences.getLong("data_ultima_atualizacao", 0);
|
||||||
long dataAtual = System.currentTimeMillis();
|
long dataAtual = System.currentTimeMillis();
|
||||||
@@ -75,7 +64,7 @@ public class HomeActivity extends AppCompatActivity {
|
|||||||
sharedPreferences.edit().putLong("data_ultima_atualizacao", dataAtual).apply();
|
sharedPreferences.edit().putLong("data_ultima_atualizacao", dataAtual).apply();
|
||||||
} else {
|
} else {
|
||||||
// TEMPO CONFIGURADO PARA TESTES: 10 segundos!
|
// 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;
|
long tempoNecessario = 10 * 1000;
|
||||||
|
|
||||||
if (dataAtual - dataUltimaAtualizacao >= tempoNecessario) {
|
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() {
|
private void mostrarPopupAtualizacao() {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||||
builder.setTitle("Hora da pesagem! ⚖️");
|
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);
|
builder.setCancelable(false);
|
||||||
|
|
||||||
LinearLayout layout = new LinearLayout(this);
|
LinearLayout layout = new LinearLayout(this);
|
||||||
@@ -119,16 +108,17 @@ public class HomeActivity extends AppCompatActivity {
|
|||||||
float novoPeso = Float.parseFloat(pesoStr);
|
float novoPeso = Float.parseFloat(pesoStr);
|
||||||
float novaAltura = Float.parseFloat(alturaStr);
|
float novaAltura = Float.parseFloat(alturaStr);
|
||||||
|
|
||||||
|
// Grava os novos dados com as chaves corretas no bloco de notas
|
||||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||||
editor.putFloat("pesoAtual", novoPeso);
|
editor.putFloat("peso", novoPeso);
|
||||||
editor.putFloat("alturaAtual", novaAltura);
|
editor.putFloat("altura", novaAltura);
|
||||||
editor.putLong("data_ultima_atualizacao", System.currentTimeMillis());
|
editor.putLong("data_ultima_atualizacao", System.currentTimeMillis());
|
||||||
editor.apply();
|
editor.apply();
|
||||||
|
|
||||||
Toast.makeText(HomeActivity.this, "Dados atualizados com sucesso! 💪", Toast.LENGTH_SHORT).show();
|
Toast.makeText(HomeActivity.this, "Dados atualizados com sucesso! 💪", Toast.LENGTH_SHORT).show();
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
} else {
|
} 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;
|
package com.example.pap;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
import android.util.Log;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
@@ -12,82 +13,74 @@ import androidx.appcompat.app.AppCompatActivity;
|
|||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
import retrofit2.Response;
|
import retrofit2.Response;
|
||||||
import retrofit2.Retrofit;
|
|
||||||
import retrofit2.converter.gson.GsonConverterFactory;
|
|
||||||
|
|
||||||
public class LoginActivity extends AppCompatActivity {
|
public class LoginActivity extends AppCompatActivity {
|
||||||
|
|
||||||
private EditText etLoginEmail, etLoginPassword;
|
private EditText etLoginEmail, etLoginPassword;
|
||||||
private Button btnLogin;
|
private Button btnLogin;
|
||||||
private TextView tvGoToRegister;
|
private TextView tvGoToRegister;
|
||||||
private SupabaseApi api;
|
private SharedPreferences sharedPreferences;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_login);
|
setContentView(R.layout.activity_login);
|
||||||
|
|
||||||
// 1. Inicializar os componentes
|
// Ligar o código aos IDs do ecrã
|
||||||
etLoginEmail = findViewById(R.id.etLoginEmail);
|
etLoginEmail = findViewById(R.id.etLoginEmail);
|
||||||
etLoginPassword = findViewById(R.id.etLoginPassword);
|
etLoginPassword = findViewById(R.id.etLoginPassword);
|
||||||
btnLogin = findViewById(R.id.btnLogin);
|
btnLogin = findViewById(R.id.btnLogin);
|
||||||
tvGoToRegister = findViewById(R.id.tvGoToRegister);
|
tvGoToRegister = findViewById(R.id.tvGoToRegister);
|
||||||
|
|
||||||
// 2. Iniciar a comunicação com a API do Supabase
|
// Iniciar a memória do telemóvel
|
||||||
Retrofit retrofit = new Retrofit.Builder()
|
sharedPreferences = getSharedPreferences("MeusDadosApp", MODE_PRIVATE);
|
||||||
.baseUrl(SupabaseConfig.URL)
|
|
||||||
.addConverterFactory(GsonConverterFactory.create())
|
|
||||||
.build();
|
|
||||||
api = retrofit.create(SupabaseApi.class);
|
|
||||||
|
|
||||||
// 3. Configurar os cliques
|
|
||||||
btnLogin.setOnClickListener(v -> efetuarLogin());
|
|
||||||
|
|
||||||
|
// Enviar para o Registo
|
||||||
tvGoToRegister.setOnClickListener(v -> {
|
tvGoToRegister.setOnClickListener(v -> {
|
||||||
Intent intent = new Intent(LoginActivity.this, RegisterActivity.class);
|
Intent intent = new Intent(LoginActivity.this, RegisterActivity.class);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
private void efetuarLogin() {
|
// Botão de Entrar
|
||||||
|
btnLogin.setOnClickListener(v -> {
|
||||||
String email = etLoginEmail.getText().toString().trim();
|
String email = etLoginEmail.getText().toString().trim();
|
||||||
String password = etLoginPassword.getText().toString().trim();
|
String password = etLoginPassword.getText().toString().trim();
|
||||||
|
|
||||||
// Validação básica
|
|
||||||
if (email.isEmpty() || password.isEmpty()) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
UserCredentials credentials = new UserCredentials(email, password);
|
UserCredentials credentials = new UserCredentials(email, password);
|
||||||
|
SupabaseApi api = SupabaseConfig.getRetrofit().create(SupabaseApi.class);
|
||||||
|
|
||||||
// Faz o pedido de Login ao Supabase
|
api.login(SupabaseConfig.SUPABASE_KEY, credentials).enqueue(new Callback<SupabaseResponse>() {
|
||||||
api.login(SupabaseConfig.API_KEY, credentials).enqueue(new Callback<SupabaseResponse>() {
|
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(Call<SupabaseResponse> call, Response<SupabaseResponse> response) {
|
public void onResponse(Call<SupabaseResponse> call, Response<SupabaseResponse> response) {
|
||||||
if (response.isSuccessful() && response.body() != null) {
|
if (response.isSuccessful() && response.body() != null) {
|
||||||
|
|
||||||
// Login com sucesso! Vai para a Home
|
// Guardar o token e o email para usar nas Definições
|
||||||
Toast.makeText(LoginActivity.this, "Login com sucesso!", Toast.LENGTH_SHORT).show();
|
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);
|
Intent intent = new Intent(LoginActivity.this, HomeActivity.class);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
finish(); // Fecha a tela de login
|
finish();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// SE DER ERRO (ex: 404, 400), MOSTRA O LINK EXATO E O CÓDIGO
|
Toast.makeText(LoginActivity.this, "Dados errados! Verifica a tua password e email.", Toast.LENGTH_LONG).show();
|
||||||
String urlQueFalhou = response.raw().request().url().toString();
|
Log.e("SUPABASE", "Erro Login: " + response.code());
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Call<SupabaseResponse> call, Throwable t) {
|
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;
|
package com.example.pap;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
|
import android.widget.TextView;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
public class PerfilActivity extends AppCompatActivity {
|
public class PerfilActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
private TextView tvPerfilNome, tvPerfilPontos, tvPerfilDesafios, tvPerfilSequencia;
|
||||||
|
private Button btnDefinicoes, btnVoltarPerfil;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_perfil);
|
setContentView(R.layout.activity_perfil);
|
||||||
|
|
||||||
Button btnVoltar = findViewById(R.id.btnVoltarPerfil);
|
tvPerfilNome = findViewById(R.id.tvPerfilNome);
|
||||||
Button btnSair = findViewById(R.id.btnSair);
|
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
|
btnDefinicoes.setOnClickListener(v -> {
|
||||||
btnVoltar.setOnClickListener(new View.OnClickListener() {
|
startActivity(new Intent(PerfilActivity.this, DefinicoesActivity.class));
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Terminar Sessão (Voltar ao Login e limpar a Home)
|
btnVoltarPerfil.setOnClickListener(v -> finish());
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
// 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;
|
package com.example.pap;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
import android.util.Log;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
@@ -12,22 +13,19 @@ import androidx.appcompat.app.AppCompatActivity;
|
|||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
import retrofit2.Response;
|
import retrofit2.Response;
|
||||||
import retrofit2.Retrofit;
|
|
||||||
import retrofit2.converter.gson.GsonConverterFactory;
|
|
||||||
|
|
||||||
public class RegisterActivity extends AppCompatActivity {
|
public class RegisterActivity extends AppCompatActivity {
|
||||||
|
|
||||||
private EditText etRegNome, etRegEmail, etRegPassword, etRegAltura, etRegPeso;
|
private EditText etRegNome, etRegEmail, etRegPassword, etRegAltura, etRegPeso;
|
||||||
private Button btnRegister;
|
private Button btnRegister;
|
||||||
private TextView tvGoToLogin;
|
private TextView tvGoToLogin;
|
||||||
private SupabaseApi api;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_register);
|
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);
|
etRegNome = findViewById(R.id.etRegNome);
|
||||||
etRegEmail = findViewById(R.id.etRegEmail);
|
etRegEmail = findViewById(R.id.etRegEmail);
|
||||||
etRegPassword = findViewById(R.id.etRegPassword);
|
etRegPassword = findViewById(R.id.etRegPassword);
|
||||||
@@ -36,99 +34,63 @@ public class RegisterActivity extends AppCompatActivity {
|
|||||||
btnRegister = findViewById(R.id.btnRegister);
|
btnRegister = findViewById(R.id.btnRegister);
|
||||||
tvGoToLogin = findViewById(R.id.tvGoToLogin);
|
tvGoToLogin = findViewById(R.id.tvGoToLogin);
|
||||||
|
|
||||||
// 2. Configurar o Retrofit (A ponte de comunicação com o Supabase)
|
// Se o utilizador já tem conta, volta para o Login
|
||||||
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());
|
|
||||||
tvGoToLogin.setOnClickListener(v -> finish());
|
tvGoToLogin.setOnClickListener(v -> finish());
|
||||||
}
|
|
||||||
|
|
||||||
private void efetuarRegisto() {
|
// Quando clica no botão de Registar
|
||||||
|
btnRegister.setOnClickListener(v -> {
|
||||||
String nome = etRegNome.getText().toString().trim();
|
String nome = etRegNome.getText().toString().trim();
|
||||||
String email = etRegEmail.getText().toString().trim();
|
String email = etRegEmail.getText().toString().trim();
|
||||||
String password = etRegPassword.getText().toString().trim();
|
String password = etRegPassword.getText().toString().trim();
|
||||||
String pesoStr = etRegPeso.getText().toString().trim();
|
|
||||||
String alturaStr = etRegAltura.getText().toString().trim();
|
String alturaStr = etRegAltura.getText().toString().trim();
|
||||||
|
String pesoStr = etRegPeso.getText().toString().trim();
|
||||||
|
|
||||||
// Verificações para garantir que o utilizador preencheu tudo
|
// 1. Verificar se não há campos vazios
|
||||||
if (nome.isEmpty() || email.isEmpty() || password.isEmpty() || pesoStr.isEmpty() || alturaStr.isEmpty()) {
|
if (nome.isEmpty() || email.isEmpty() || password.isEmpty() || alturaStr.isEmpty() || pesoStr.isEmpty()) {
|
||||||
Toast.makeText(this, "Preencha todos os campos!", Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, "Por favor, preenche todos os campos!", Toast.LENGTH_SHORT).show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (password.length() < 6) {
|
// 2. GUARDAR NOME, ALTURA E PESO NA MEMÓRIA (SharedPreferences)
|
||||||
Toast.makeText(this, "A password precisa de pelo menos 6 caracteres.", Toast.LENGTH_SHORT).show();
|
SharedPreferences prefs = getSharedPreferences("MeusDadosApp", MODE_PRIVATE);
|
||||||
return;
|
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);
|
// 3. Preparar os dados para enviar para o Supabase
|
||||||
float altura = Float.parseFloat(alturaStr);
|
|
||||||
|
|
||||||
// FASE 1: Criar a conta (Email e Password) no Supabase Auth
|
|
||||||
UserCredentials credentials = new UserCredentials(email, password);
|
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
|
@Override
|
||||||
public void onResponse(Call<SupabaseResponse> call, Response<SupabaseResponse> response) {
|
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
|
// NOVO FLUXO: Mandar para o ecrã de espera com os dados passados em segurança!
|
||||||
String userId = response.body().id != null ? response.body().id : response.body().user.id;
|
Intent intent = new Intent(RegisterActivity.this, VerificacaoActivity.class);
|
||||||
String token = "Bearer " + response.body().access_token;
|
intent.putExtra("email_registo", email);
|
||||||
|
intent.putExtra("password_registo", password);
|
||||||
// FASE 2: Guardar o Nome, Peso e Altura na tabela "profiles"
|
startActivity(intent);
|
||||||
salvarPerfil(userId, nome, email, peso, altura, token);
|
finish();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
String urlQueFalhou = response.raw().request().url().toString();
|
Toast.makeText(RegisterActivity.this, "Erro ao criar conta. O email já existe?", Toast.LENGTH_LONG).show();
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Call<SupabaseResponse> call, Throwable t) {
|
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.Call;
|
||||||
import retrofit2.http.Body;
|
import retrofit2.http.Body;
|
||||||
import retrofit2.http.Header;
|
import retrofit2.http.Header;
|
||||||
|
import retrofit2.http.PUT;
|
||||||
import retrofit2.http.POST;
|
import retrofit2.http.POST;
|
||||||
|
|
||||||
public interface SupabaseApi {
|
public interface SupabaseApi {
|
||||||
|
|
||||||
// Rota para criar a conta
|
// 1. Rota para criar a conta
|
||||||
@POST("auth/v1/signup")
|
@POST("auth/v1/signup")
|
||||||
Call<SupabaseResponse> signUp(@Header("apikey") String apiKey, @Body UserCredentials credentials);
|
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")
|
@POST("auth/v1/token?grant_type=password")
|
||||||
Call<SupabaseResponse> login(@Header("apikey") String apiKey, @Body UserCredentials credentials);
|
Call<SupabaseResponse> login(@Header("apikey") String apiKey, @Body UserCredentials credentials);
|
||||||
|
|
||||||
// Rota para guardar o Nome, Peso e Altura na base de dados
|
// 3. Rota para atualizar a palavra-passe ou dados do utilizador (CORRIGIDO PARA @PUT)
|
||||||
@POST("rest/v1/profiles")
|
@PUT("auth/v1/user")
|
||||||
Call<Void> insertProfile(
|
Call<Void> updateUserData(
|
||||||
@Header("apikey") String apiKey,
|
@Header("apikey") String apikey,
|
||||||
@Header("Authorization") String token,
|
@Header("Authorization") String accessToken,
|
||||||
@Header("Content-Type") String contentType,
|
@Body java.util.Map<String, String> updates
|
||||||
@Header("Prefer") String prefer,
|
|
||||||
@Body ProfileData profile
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---- Classes Auxiliares para Formatarem os Dados ----
|
// ---- Classes Auxiliares ----
|
||||||
|
|
||||||
class UserCredentials {
|
class UserCredentials {
|
||||||
String email;
|
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 {
|
class SupabaseResponse {
|
||||||
String id;
|
public String access_token;
|
||||||
String access_token;
|
|
||||||
UserResponse user;
|
|
||||||
|
|
||||||
class UserResponse {
|
|
||||||
String id;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,31 @@
|
|||||||
package com.example.pap;
|
package com.example.pap;
|
||||||
|
|
||||||
|
import retrofit2.Retrofit;
|
||||||
|
import retrofit2.converter.gson.GsonConverterFactory;
|
||||||
|
|
||||||
public class SupabaseConfig {
|
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
|
// 1. O teu Project URL (Ex: https://xyzabc.supabase.co/)
|
||||||
public static final String API_KEY = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImxramJiYmdhdm95a251eGFza2hvIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzI2MjM4OTMsImV4cCI6MjA4ODE5OTg5M30.HV9ZXYCaF1V8dZwPxv_p5_gDi9cN_ioumDm9mgmEQPU";
|
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"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<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_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="#F4F9F5">
|
android:background="#F8FAFC"> <androidx.cardview.widget.CardView
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/headerChat"
|
android:id="@+id/headerChat"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="#FFFFFF"
|
app:cardElevation="8dp"
|
||||||
android:elevation="4dp"
|
app:cardCornerRadius="0dp"
|
||||||
android:orientation="horizontal"
|
app:cardBackgroundColor="#FFFFFF">
|
||||||
android:padding="16dp"
|
|
||||||
android:gravity="center_vertical">
|
|
||||||
|
|
||||||
<Button
|
<LinearLayout
|
||||||
android:id="@+id/btnVoltarChat"
|
android:layout_width="match_parent"
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Voltar"
|
android:gravity="center_vertical"
|
||||||
android:backgroundTint="#E0E0E0"
|
android:padding="16dp"
|
||||||
android:textColor="#000000"
|
android:orientation="horizontal">
|
||||||
android:layout_marginEnd="16dp"/>
|
|
||||||
|
<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
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="IA Coach de Saúde"
|
android:text="NutriChat AI"
|
||||||
android:textSize="20sp"
|
android:textSize="18sp"
|
||||||
android:textStyle="bold"
|
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>
|
||||||
|
</LinearLayout>
|
||||||
|
</androidx.cardview.widget.CardView>
|
||||||
|
|
||||||
<ScrollView
|
<ScrollView
|
||||||
android:id="@+id/chatScrollView"
|
android:id="@+id/chatScrollView"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
android:layout_above="@+id/inputArea"
|
||||||
android:layout_below="@id/headerChat"
|
android:layout_below="@id/headerChat"
|
||||||
android:layout_above="@+id/layoutInput"
|
android:paddingHorizontal="16dp"
|
||||||
android:padding="16dp"
|
android:paddingTop="16dp"
|
||||||
android:fillViewport="true">
|
android:paddingBottom="8dp"
|
||||||
|
android:clipToPadding="false">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/chatLayout"
|
android:id="@+id/chatLayout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical" />
|
||||||
android:paddingBottom="16dp"/>
|
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/layoutInput"
|
android:id="@+id/inputArea"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentBottom="true"
|
android:layout_alignParentBottom="true"
|
||||||
android:background="#FFFFFF"
|
android:paddingHorizontal="12dp"
|
||||||
android:elevation="8dp"
|
android:paddingVertical="12dp"
|
||||||
|
android:background="#00000000"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:padding="8dp"
|
|
||||||
android:gravity="center_vertical">
|
android:gravity="center_vertical">
|
||||||
|
|
||||||
<EditText
|
<androidx.cardview.widget.CardView
|
||||||
android:id="@+id/etNovaMensagem"
|
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="50dp"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:background="#F0F0F0"
|
app:cardCornerRadius="24dp"
|
||||||
android:hint="Pede uma dica de saúde..."
|
app:cardElevation="2dp"
|
||||||
android:paddingStart="16dp"
|
app:cardBackgroundColor="#FFFFFF"
|
||||||
android:paddingEnd="16dp"
|
android:layout_marginEnd="8dp">
|
||||||
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>
|
</LinearLayout>
|
||||||
|
|
||||||
</RelativeLayout>
|
</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"?>
|
<?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_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="#F4F9F5"
|
android:orientation="vertical"
|
||||||
android:fillViewport="true">
|
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
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:padding="24dp"
|
android:padding="24dp"
|
||||||
android:gravity="top">
|
android:gravity="center">
|
||||||
|
|
||||||
<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">
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="🏋️"
|
android:text="Os Teus Pontos"
|
||||||
android:textSize="32sp"
|
android:textColor="#E0F2FE"
|
||||||
android:layout_marginEnd="16dp"/>
|
android:textSize="14sp"
|
||||||
|
android:textStyle="bold"/>
|
||||||
<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"/>
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tvPontos"
|
android:id="@+id/tvPontos"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="0"
|
android:text="0"
|
||||||
android:textSize="24sp"
|
android:textColor="#FFFFFF"
|
||||||
android:textStyle="bold"
|
android:textSize="48sp"
|
||||||
android:textColor="#4CAF50"/>
|
android:textStyle="bold"/>
|
||||||
</LinearLayout>
|
</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
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:background="#FFFFFF"
|
android:padding="16dp">
|
||||||
android:elevation="2dp"
|
|
||||||
android:padding="16dp"
|
|
||||||
android:layout_marginBottom="16dp">
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="1. Fazer 10 Flexões (+20 pts)"
|
android:text="Desafio: 20 Flexões"
|
||||||
android:textSize="18sp"
|
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
android:textColor="#2E3D32"/>
|
android:textSize="16sp"
|
||||||
|
android:textColor="#0F172A"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tvStatusDesafio1"
|
android:id="@+id/tvStatusDesafio1"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Estado: Pendente"
|
android:text="Pendente"
|
||||||
android:textColor="#FF9800"
|
android:textColor="#64748B"
|
||||||
android:layout_marginTop="4dp"
|
android:textSize="14sp"
|
||||||
android:layout_marginBottom="8dp"/>
|
android:layout_marginTop="4dp"/>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/btnVideoDesafio1"
|
android:id="@+id/btnVideoDesafio1"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Gravar Vídeo"
|
android:text="Gravar Vídeo Prova"
|
||||||
android:backgroundTint="#2196F3"
|
android:layout_marginTop="12dp"
|
||||||
android:drawableStart="@android:drawable/ic_menu_camera"
|
android:backgroundTint="#03A9F4"
|
||||||
android:paddingStart="16dp"/>
|
app:cornerRadius="8dp"/>
|
||||||
</LinearLayout>
|
</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
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:background="#FFFFFF"
|
android:padding="16dp">
|
||||||
android:elevation="2dp"
|
|
||||||
android:padding="16dp"
|
|
||||||
android:layout_marginBottom="16dp">
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="2. Prancha de 30 Segundos (+30 pts)"
|
android:text="Desafio: 30 Agachamentos"
|
||||||
android:textSize="18sp"
|
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
android:textColor="#2E3D32"/>
|
android:textSize="16sp"
|
||||||
|
android:textColor="#0F172A"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tvStatusDesafio2"
|
android:id="@+id/tvStatusDesafio2"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Estado: Pendente"
|
android:text="Pendente"
|
||||||
android:textColor="#FF9800"
|
android:textColor="#64748B"
|
||||||
android:layout_marginTop="4dp"
|
android:textSize="14sp"
|
||||||
android:layout_marginBottom="8dp"/>
|
android:layout_marginTop="4dp"/>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/btnVideoDesafio2"
|
android:id="@+id/btnVideoDesafio2"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Gravar Vídeo"
|
android:text="Gravar Vídeo Prova"
|
||||||
android:backgroundTint="#2196F3"
|
android:layout_marginTop="12dp"
|
||||||
android:drawableStart="@android:drawable/ic_menu_camera"
|
android:backgroundTint="#03A9F4"
|
||||||
android:paddingStart="16dp"/>
|
app:cornerRadius="8dp"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
</androidx.cardview.widget.CardView>
|
||||||
|
|
||||||
<View
|
</LinearLayout>
|
||||||
android:layout_width="match_parent"
|
</ScrollView>
|
||||||
android:layout_height="0dp"
|
|
||||||
android:layout_weight="1"/>
|
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/btnVoltarDesafios"
|
android:id="@+id/btnVoltarDesafios"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="60dp"
|
android:layout_height="55dp"
|
||||||
android:backgroundTint="#E0E0E0"
|
android:layout_margin="16dp"
|
||||||
android:textColor="#000000"
|
|
||||||
android:text="Voltar ao Início"
|
android:text="Voltar ao Início"
|
||||||
android:layout_marginTop="16dp"/>
|
android:backgroundTint="#94A3B8"
|
||||||
|
app:cornerRadius="12dp"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</ScrollView>
|
|
||||||
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"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout 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_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:padding="32dp"
|
android:background="#F8FAFC">
|
||||||
android:gravity="top|center_horizontal">
|
|
||||||
|
<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
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="O Teu Progresso"
|
android:text="O Teu IMC"
|
||||||
android:textSize="28sp"
|
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:textStyle="bold"
|
||||||
android:layout_marginBottom="32dp"/>
|
android:textColor="#0369A1"
|
||||||
|
android:layout_marginVertical="8dp"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:id="@+id/tvImcStatus"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Objetivo de Peso"
|
android:text="A calcular..."
|
||||||
android:textSize="18sp"
|
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
|
<LinearLayout
|
||||||
android:id="@+id/tvPesoStatus"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Faltam 5 kg para a tua meta!"
|
android:orientation="horizontal"
|
||||||
android:layout_marginTop="8dp"/>
|
android:layout_marginBottom="16dp">
|
||||||
|
|
||||||
<ProgressBar
|
<androidx.cardview.widget.CardView
|
||||||
android:id="@+id/progressPeso"
|
android:layout_width="0dp"
|
||||||
style="?android:attr/progressBarStyleHorizontal"
|
android:layout_height="wrap_content"
|
||||||
android:layout_width="match_parent"
|
android:layout_weight="1"
|
||||||
android:layout_height="24dp"
|
app:cardCornerRadius="12dp"
|
||||||
android:max="100"
|
android:layout_marginEnd="8dp">
|
||||||
android:progress="60"
|
<LinearLayout
|
||||||
android:layout_marginTop="8dp"
|
|
||||||
android:layout_marginBottom="24dp"/>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Calorias Consumidas (Hoje)"
|
android:orientation="vertical"
|
||||||
android:textSize="18sp"
|
android:padding="16dp"
|
||||||
android:textStyle="bold"/>
|
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
|
<androidx.cardview.widget.CardView
|
||||||
android:id="@+id/tvCalorias"
|
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_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="1200 / 1800 kcal"
|
android:orientation="vertical"
|
||||||
android:textSize="22sp"
|
android:padding="16dp"
|
||||||
android:textColor="#FF9800"
|
android:gravity="center">
|
||||||
android:layout_marginTop="8dp"
|
<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"/>
|
||||||
android:layout_marginBottom="24dp"/>
|
</LinearLayout>
|
||||||
|
</androidx.cardview.widget.CardView>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<TextView
|
<androidx.cardview.widget.CardView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Água Bebida"
|
app:cardCornerRadius="16dp"
|
||||||
android:textSize="18sp"
|
android:layout_marginBottom="24dp">
|
||||||
android:textStyle="bold"/>
|
<LinearLayout
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/tvAgua"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="1.5 L / 2.5 L"
|
android:orientation="vertical"
|
||||||
android:textSize="22sp"
|
android:padding="16dp">
|
||||||
android:textColor="#03A9F4"
|
</LinearLayout>
|
||||||
android:layout_marginTop="8dp"
|
</androidx.cardview.widget.CardView>
|
||||||
android:layout_marginBottom="32dp"/>
|
|
||||||
|
</LinearLayout>
|
||||||
|
</ScrollView>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/btnVoltarHome"
|
android:id="@+id/btnVoltarHome"
|
||||||
android:layout_width="match_parent"
|
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: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>
|
</LinearLayout>
|
||||||
@@ -1,129 +1,106 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?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_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="#F4F9F5"
|
android:orientation="vertical"
|
||||||
android:fillViewport="true">
|
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
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
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"/>
|
|
||||||
|
|
||||||
|
<!-- Caixa onde vai aparecer a foto -->
|
||||||
<androidx.cardview.widget.CardView
|
<androidx.cardview.widget.CardView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="250dp"
|
android:layout_height="250dp"
|
||||||
android:layout_marginBottom="24dp"
|
|
||||||
app:cardCornerRadius="16dp"
|
app:cardCornerRadius="16dp"
|
||||||
app:cardElevation="4dp"
|
app:cardElevation="2dp"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
android:layout_marginBottom="24dp">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/ivFotoComida"
|
android:id="@+id/ivFotoComida"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:src="@android:drawable/ic_menu_camera"
|
android:src="@android:drawable/ic_menu_camera"
|
||||||
android:scaleType="centerCrop"
|
android:scaleType="centerCrop"
|
||||||
android:background="#E0E0E0"/>
|
android:background="#E2E8F0"
|
||||||
|
android:padding="60dp" />
|
||||||
</androidx.cardview.widget.CardView>
|
</androidx.cardview.widget.CardView>
|
||||||
|
|
||||||
|
<!-- Botão para abrir a câmara do telemóvel -->
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/btnTirarFotoComida"
|
android:id="@+id/btnTirarFoto"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="60dp"
|
android:layout_height="60dp"
|
||||||
android:text="Tirar Foto e Analisar"
|
android:text="Abrir Câmara"
|
||||||
android:backgroundTint="#4CAF50"
|
android:textSize="16sp"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
android:layout_marginBottom="24dp"/>
|
android:backgroundTint="#0284C7"
|
||||||
|
app:cornerRadius="15dp"
|
||||||
<LinearLayout
|
android:layout_marginBottom="12dp"/>
|
||||||
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>
|
|
||||||
|
|
||||||
|
<!-- Botão para analisar (só aparece depois de tirar a foto) -->
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/btnAddIngredienteManual"
|
android:id="@+id/btnAnalisarIA"
|
||||||
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:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="60dp"
|
android:layout_height="60dp"
|
||||||
android:text="Confirmar Refeição"
|
android:text="Analisar com IA ✨"
|
||||||
android:backgroundTint="#FF9800"
|
android:textSize="16sp"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
android:layout_marginTop="16dp"/>
|
android:backgroundTint="#10B981"
|
||||||
</LinearLayout>
|
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
|
<Button
|
||||||
android:id="@+id/btnVoltarFoto"
|
android:id="@+id/btnVoltarFoto"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="60dp"
|
android:layout_height="50dp"
|
||||||
android:text="Voltar"
|
android:text="Voltar"
|
||||||
android:backgroundTint="#E0E0E0"
|
android:textColor="#0F172A"
|
||||||
android:textColor="#000000"
|
android:backgroundTint="#E2E8F0"
|
||||||
|
app:cornerRadius="12dp"
|
||||||
android:layout_marginTop="24dp"/>
|
android:layout_marginTop="24dp"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
</LinearLayout>
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="#F8FAFA"
|
android:background="#F8FAFC"
|
||||||
android:fillViewport="true">
|
android:fillViewport="true">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
@@ -15,149 +15,21 @@
|
|||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Meu Progresso"
|
android:text="A tua jornada começa aqui,"
|
||||||
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:textSize="14sp"
|
android:textSize="14sp"
|
||||||
android:textColor="#6B7280"
|
android:textColor="#64748B"
|
||||||
android:layout_marginTop="4dp"
|
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"/>
|
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
|
<androidx.cardview.widget.CardView
|
||||||
android:id="@+id/cardTirarFoto"
|
android:id="@+id/cardTirarFoto"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -166,9 +38,10 @@
|
|||||||
android:clickable="true"
|
android:clickable="true"
|
||||||
android:focusable="true"
|
android:focusable="true"
|
||||||
android:foreground="?android:attr/selectableItemBackground"
|
android:foreground="?android:attr/selectableItemBackground"
|
||||||
app:cardCornerRadius="16dp"
|
app:cardCornerRadius="20dp"
|
||||||
app:cardElevation="2dp"
|
app:cardElevation="6dp"
|
||||||
app:contentPadding="16dp">
|
app:cardBackgroundColor="#0F172A"
|
||||||
|
app:contentPadding="20dp">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -177,14 +50,14 @@
|
|||||||
android:gravity="center_vertical">
|
android:gravity="center_vertical">
|
||||||
|
|
||||||
<androidx.cardview.widget.CardView
|
<androidx.cardview.widget.CardView
|
||||||
android:layout_width="48dp"
|
android:layout_width="56dp"
|
||||||
android:layout_height="48dp"
|
android:layout_height="56dp"
|
||||||
app:cardCornerRadius="12dp"
|
app:cardCornerRadius="16dp"
|
||||||
app:cardBackgroundColor="#E91E63"
|
app:cardBackgroundColor="#38BDF8"
|
||||||
app:cardElevation="0dp">
|
app:cardElevation="0dp">
|
||||||
<ImageView
|
<ImageView
|
||||||
android:layout_width="24dp"
|
android:layout_width="28dp"
|
||||||
android:layout_height="24dp"
|
android:layout_height="28dp"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:src="@android:drawable/ic_menu_camera"
|
android:src="@android:drawable/ic_menu_camera"
|
||||||
app:tint="#FFFFFF"/>
|
app:tint="#FFFFFF"/>
|
||||||
@@ -199,16 +72,16 @@
|
|||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Tirar foto"
|
android:text="Escanear Comida"
|
||||||
android:textSize="16sp"
|
android:textSize="18sp"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
android:textColor="#111827"/>
|
android:textColor="#FFFFFF"/>
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Acompanhe a sua dieta"
|
android:text="A IA analisa a tua refeição"
|
||||||
android:textSize="12sp"
|
android:textSize="13sp"
|
||||||
android:textColor="#6B7280"
|
android:textColor="#94A3B8"
|
||||||
android:layout_marginTop="2dp"/>
|
android:layout_marginTop="2dp"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
@@ -216,8 +89,8 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="›"
|
android:text="›"
|
||||||
android:textSize="28sp"
|
android:textSize="32sp"
|
||||||
android:textColor="#D1D5DB"
|
android:textColor="#38BDF8"
|
||||||
android:layout_marginStart="8dp"/>
|
android:layout_marginStart="8dp"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</androidx.cardview.widget.CardView>
|
</androidx.cardview.widget.CardView>
|
||||||
@@ -244,7 +117,7 @@
|
|||||||
android:layout_width="48dp"
|
android:layout_width="48dp"
|
||||||
android:layout_height="48dp"
|
android:layout_height="48dp"
|
||||||
app:cardCornerRadius="12dp"
|
app:cardCornerRadius="12dp"
|
||||||
app:cardBackgroundColor="#00BFA5"
|
app:cardBackgroundColor="#10B981"
|
||||||
app:cardElevation="0dp">
|
app:cardElevation="0dp">
|
||||||
<ImageView
|
<ImageView
|
||||||
android:layout_width="24dp"
|
android:layout_width="24dp"
|
||||||
@@ -260,29 +133,57 @@
|
|||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_marginStart="16dp">
|
android:layout_marginStart="16dp">
|
||||||
<TextView
|
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="NutriChat AI" android:textSize="16sp" android:textStyle="bold" android:textColor="#0F172A"/>
|
||||||
android:layout_width="wrap_content"
|
<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"/>
|
||||||
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"/>
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<TextView
|
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="›" android:textSize="28sp" android:textColor="#CBD5E1" android:layout_marginStart="8dp"/>
|
||||||
android:layout_width="wrap_content"
|
</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_height="wrap_content"
|
||||||
android:text="›"
|
android:layout_marginBottom="16dp"
|
||||||
android:textSize="28sp"
|
android:clickable="true"
|
||||||
android:textColor="#D1D5DB"
|
android:focusable="true"
|
||||||
android:layout_marginStart="8dp"/>
|
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>
|
</LinearLayout>
|
||||||
</androidx.cardview.widget.CardView>
|
</androidx.cardview.widget.CardView>
|
||||||
|
|
||||||
@@ -308,7 +209,7 @@
|
|||||||
android:layout_width="48dp"
|
android:layout_width="48dp"
|
||||||
android:layout_height="48dp"
|
android:layout_height="48dp"
|
||||||
app:cardCornerRadius="12dp"
|
app:cardCornerRadius="12dp"
|
||||||
app:cardBackgroundColor="#FF5722"
|
app:cardBackgroundColor="#F59E0B"
|
||||||
app:cardElevation="0dp">
|
app:cardElevation="0dp">
|
||||||
<ImageView
|
<ImageView
|
||||||
android:layout_width="24dp"
|
android:layout_width="24dp"
|
||||||
@@ -324,34 +225,16 @@
|
|||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_marginStart="16dp">
|
android:layout_marginStart="16dp">
|
||||||
<TextView
|
<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"/>
|
||||||
android:layout_width="wrap_content"
|
<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"/>
|
||||||
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"/>
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<TextView
|
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="›" android:textSize="28sp" android:textColor="#CBD5E1" android:layout_marginStart="8dp"/>
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="›"
|
|
||||||
android:textSize="28sp"
|
|
||||||
android:textColor="#D1D5DB"
|
|
||||||
android:layout_marginStart="8dp"/>
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</androidx.cardview.widget.CardView>
|
</androidx.cardview.widget.CardView>
|
||||||
|
|
||||||
<androidx.cardview.widget.CardView
|
<androidx.cardview.widget.CardView
|
||||||
android:id="@+id/cardDefinicoes"
|
android:id="@+id/cardPerfil"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="32dp"
|
android:layout_marginBottom="32dp"
|
||||||
@@ -372,13 +255,13 @@
|
|||||||
android:layout_width="48dp"
|
android:layout_width="48dp"
|
||||||
android:layout_height="48dp"
|
android:layout_height="48dp"
|
||||||
app:cardCornerRadius="12dp"
|
app:cardCornerRadius="12dp"
|
||||||
app:cardBackgroundColor="#37474F"
|
app:cardBackgroundColor="#8B5CF6"
|
||||||
app:cardElevation="0dp">
|
app:cardElevation="0dp">
|
||||||
<ImageView
|
<ImageView
|
||||||
android:layout_width="24dp"
|
android:layout_width="24dp"
|
||||||
android:layout_height="24dp"
|
android:layout_height="24dp"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:src="@android:drawable/ic_menu_preferences"
|
android:src="@android:drawable/ic_menu_myplaces"
|
||||||
app:tint="#FFFFFF"/>
|
app:tint="#FFFFFF"/>
|
||||||
</androidx.cardview.widget.CardView>
|
</androidx.cardview.widget.CardView>
|
||||||
|
|
||||||
@@ -388,29 +271,11 @@
|
|||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_marginStart="16dp">
|
android:layout_marginStart="16dp">
|
||||||
<TextView
|
<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"/>
|
||||||
android:layout_width="wrap_content"
|
<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"/>
|
||||||
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"/>
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<TextView
|
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="›" android:textSize="28sp" android:textColor="#CBD5E1" android:layout_marginStart="8dp"/>
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="›"
|
|
||||||
android:textSize="28sp"
|
|
||||||
android:textColor="#D1D5DB"
|
|
||||||
android:layout_marginStart="8dp"/>
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</androidx.cardview.widget.CardView>
|
</androidx.cardview.widget.CardView>
|
||||||
|
|
||||||
|
|||||||
@@ -1,80 +1,189 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout 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_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="#F4F9F5"
|
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:padding="32dp"
|
android:background="#F8FAFC">
|
||||||
android:gravity="center_horizontal">
|
|
||||||
|
|
||||||
<ImageView
|
<LinearLayout
|
||||||
android:layout_width="120dp"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="120dp"
|
android:layout_height="wrap_content"
|
||||||
android:src="@android:drawable/ic_menu_myplaces"
|
android:orientation="horizontal"
|
||||||
android:background="#E8F5E9"
|
android:padding="20dp"
|
||||||
android:padding="24dp"
|
android:background="#FFFFFF"
|
||||||
android:layout_marginTop="32dp"
|
android:elevation="4dp">
|
||||||
android:layout_marginBottom="16dp"/>
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tvNomePerfil"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Nome do Utilizador"
|
android:text="O Meu Perfil"
|
||||||
android:textSize="24sp"
|
android:textSize="22sp"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
android:textColor="#2E3D32"
|
android:textColor="#0F172A"/>
|
||||||
android:layout_marginBottom="32dp"/>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<ScrollView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:padding="24dp">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:background="#FFFFFF"
|
android:gravity="center_horizontal">
|
||||||
android:elevation="2dp"
|
|
||||||
android:padding="24dp"
|
<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">
|
android:layout_marginBottom="32dp">
|
||||||
|
|
||||||
<TextView
|
<LinearLayout
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Email: utilizador@email.com"
|
android:orientation="horizontal"
|
||||||
android:textSize="16sp"
|
android:padding="20dp"
|
||||||
android:textColor="#757575"
|
android:weightSum="3">
|
||||||
android:layout_marginBottom="12dp"/>
|
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:gravity="center">
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Altura: 175 cm"
|
android:text="⭐"
|
||||||
android:textSize="16sp"
|
android:textSize="24sp"/>
|
||||||
android:textColor="#757575"
|
<TextView
|
||||||
android:layout_marginBottom="12dp"/>
|
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
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Peso Inicial: 80 kg"
|
android:text="Pontos"
|
||||||
android:textSize="16sp"
|
android:textSize="12sp"
|
||||||
android:textColor="#757575"/>
|
android:textColor="#64748B"/>
|
||||||
</LinearLayout>
|
</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
|
<Button
|
||||||
android:id="@+id/btnSair"
|
android:id="@+id/btnDefinicoes"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="60dp"
|
android:layout_height="60dp"
|
||||||
android:backgroundTint="#F44336"
|
android:text="Definições da Conta"
|
||||||
android:text="Terminar Sessão"
|
android:textAllCaps="false"
|
||||||
android:textColor="#FFFFFF"
|
android:textSize="16sp"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
android:layout_marginBottom="16dp"/>
|
android:backgroundTint="#0F172A"
|
||||||
|
app:cornerRadius="15dp"
|
||||||
|
android:layout_marginBottom="12dp"/>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/btnVoltarPerfil"
|
android:id="@+id/btnVoltarPerfil"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="60dp"
|
android:layout_height="60dp"
|
||||||
android:backgroundTint="#E0E0E0"
|
|
||||||
android:text="Voltar"
|
android:text="Voltar"
|
||||||
android:textColor="#000000" />
|
android:textAllCaps="false"
|
||||||
|
android:textSize="16sp"
|
||||||
|
android:textColor="#0F172A"
|
||||||
|
android:backgroundTint="#E2E8F0"
|
||||||
|
app:cornerRadius="15dp"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
</ScrollView>
|
||||||
</LinearLayout>
|
</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