S5 : menu et liste adapter interactive
This commit is contained in:
parent
bf3797f5d8
commit
55912c0679
26 changed files with 889 additions and 281 deletions
|
|
@ -3,8 +3,8 @@
|
|||
<component name="deploymentTargetSelector">
|
||||
<selectionStates>
|
||||
<SelectionState runConfigName="app">
|
||||
<option name="selectionMode" value="DIALOG" />
|
||||
<DropdownSelection timestamp="2026-02-04T13:11:46.468249700Z">
|
||||
<option name="selectionMode" value="DROPDOWN" />
|
||||
<DropdownSelection timestamp="2026-02-05T11:33:42.096254600Z">
|
||||
<Target type="DEFAULT_BOOT">
|
||||
<handle>
|
||||
<DeviceId pluginId="PhysicalDevice" identifier="serial=QGP7K78LKBMVZTRC" />
|
||||
|
|
@ -27,7 +27,28 @@
|
|||
</DialogSelection>
|
||||
</SelectionState>
|
||||
<SelectionState runConfigName="testCalculIMG()">
|
||||
<option name="selectionMode" value="DROPDOWN" />
|
||||
<option name="selectionMode" value="DIALOG" />
|
||||
<DropdownSelection timestamp="2026-02-04T16:57:48.611512800Z">
|
||||
<Target type="DEFAULT_BOOT">
|
||||
<handle>
|
||||
<DeviceId pluginId="PhysicalDevice" identifier="serial=QGP7K78LKBMVZTRC" />
|
||||
</handle>
|
||||
</Target>
|
||||
</DropdownSelection>
|
||||
<DialogSelection>
|
||||
<targets>
|
||||
<Target type="DEFAULT_BOOT">
|
||||
<handle>
|
||||
<DeviceId pluginId="PhysicalDevice" identifier="serial=QGP7K78LKBMVZTRC" />
|
||||
</handle>
|
||||
</Target>
|
||||
<Target type="DEFAULT_BOOT">
|
||||
<handle>
|
||||
<DeviceId pluginId="LocalEmulator" identifier="path=C:\Users\erwan\.android\avd\Medium_Phone.avd" />
|
||||
</handle>
|
||||
</Target>
|
||||
</targets>
|
||||
</DialogSelection>
|
||||
</SelectionState>
|
||||
</selectionStates>
|
||||
</component>
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ android {
|
|||
|
||||
defaultConfig {
|
||||
applicationId "com.example.coach"
|
||||
minSdk 16
|
||||
minSdk 21
|
||||
targetSdk 36
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
|
|
@ -34,6 +34,7 @@ dependencies {
|
|||
implementation libs.material
|
||||
implementation libs.activity
|
||||
implementation libs.constraintlayout
|
||||
implementation libs.recyclerview
|
||||
testImplementation libs.junit
|
||||
androidTestImplementation libs.ext.junit
|
||||
androidTestImplementation libs.espresso.core
|
||||
|
|
|
|||
|
|
@ -12,15 +12,14 @@ import static androidx.test.espresso.action.ViewActions.click;
|
|||
import static androidx.test.espresso.action.ViewActions.typeText;
|
||||
import static androidx.test.espresso.action.ViewActions.closeSoftKeyboard;
|
||||
import static androidx.test.espresso.matcher.ViewMatchers.withId;
|
||||
import static androidx.test.espresso.assertion.ViewAssertions.matches;
|
||||
import static androidx.test.espresso.matcher.ViewMatchers.withText;
|
||||
|
||||
import com.example.coach.R;
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class MainActivityTest {
|
||||
public class CalculActivityTest {
|
||||
@Rule
|
||||
public ActivityScenarioRule activityRule = new ActivityScenarioRule<>(MainActivity.class);
|
||||
public ActivityScenarioRule activityRule = new ActivityScenarioRule<>(CalculActivity.class);
|
||||
|
||||
@Test
|
||||
public void testCalculIMG(){
|
||||
|
|
@ -2,6 +2,8 @@
|
|||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:dataExtractionRules="@xml/data_extraction_rules"
|
||||
|
|
@ -12,15 +14,24 @@
|
|||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.Coach"
|
||||
android:usesCleartextTraffic="true">
|
||||
<activity
|
||||
android:name=".view.HistoActivity"
|
||||
android:parentActivityName=".view.MainActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".view.MainActivity"
|
||||
android:exported="true">
|
||||
android:exported="true"
|
||||
android:launchMode="singleTop">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".view.CalculActivity"
|
||||
android:exported="false"
|
||||
android:parentActivityName=".view.MainActivity"></activity>
|
||||
</application>
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
|
||||
</manifest>
|
||||
45
app/src/main/java/com/example/coach/api/HelperApi.java
Normal file
45
app/src/main/java/com/example/coach/api/HelperApi.java
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
package com.example.coach.api;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.example.coach.model.Profil;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
public class HelperApi {
|
||||
private static final IRequestApi api = CoachApi.getRetrofit().create(IRequestApi.class);
|
||||
|
||||
public static IRequestApi getApi()
|
||||
{
|
||||
return api;
|
||||
}
|
||||
|
||||
public static <T> void call(Call<ResponseApi<T>> call, ICallbackApi<T> callback)
|
||||
{
|
||||
call.enqueue(new Callback<ResponseApi<T>>() {
|
||||
@Override
|
||||
public void onResponse(Call<ResponseApi<T>> call, Response<ResponseApi<T>> response) {
|
||||
Log.d("API", "code : " + response.body().getCode() +
|
||||
" message : " + response.body().getMessage() +
|
||||
" result : " + response.body().getResult()
|
||||
);
|
||||
if (response.isSuccessful() && response.body() != null) {
|
||||
callback.onSuccess(response.body().getResult());
|
||||
} else {
|
||||
callback.onError();
|
||||
Log.e("API", "Erreur API: " + response.code());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<ResponseApi<T>> call, Throwable throwable) {
|
||||
callback.onError();
|
||||
Log.e("API", "Erreur API", throwable);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
package com.example.coach.api;
|
||||
|
||||
public interface ICallbackApi<T> {
|
||||
void onSuccess(T result);
|
||||
void onError();
|
||||
}
|
||||
|
|
@ -5,10 +5,12 @@ import com.example.coach.model.Profil;
|
|||
import java.util.List;
|
||||
|
||||
import retrofit2.Call;
|
||||
import retrofit2.http.DELETE;
|
||||
import retrofit2.http.Field;
|
||||
import retrofit2.http.FormUrlEncoded;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.POST;
|
||||
import retrofit2.http.Path;
|
||||
|
||||
public interface IRequestApi {
|
||||
@GET("profil")
|
||||
|
|
@ -17,4 +19,7 @@ public interface IRequestApi {
|
|||
@FormUrlEncoded
|
||||
@POST("profil")
|
||||
Call<ResponseApi<Integer>> creerProfil(@Field("champs") String profilJson);
|
||||
|
||||
@DELETE("profil/{champs}")
|
||||
Call<ResponseApi<Integer>> supprProfil(@Path(value = "champs", encoded = true) String profilJson);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
package com.example.coach.contract;
|
||||
|
||||
public interface IAllView {
|
||||
void afficherMessage(String message);
|
||||
}
|
||||
|
|
@ -3,7 +3,7 @@ package com.example.coach.contract;
|
|||
/**
|
||||
* Contrat pour que le CalculPresenter puisse envoyer des infos à la vue
|
||||
*/
|
||||
public interface ICalculView {
|
||||
public interface ICalculView extends IAllView{
|
||||
/**
|
||||
* Méthode permettant le transfert des résultats vers la vue
|
||||
* @param image nom du fichier du smiley
|
||||
|
|
|
|||
10
app/src/main/java/com/example/coach/contract/IHistoView.java
Normal file
10
app/src/main/java/com/example/coach/contract/IHistoView.java
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
package com.example.coach.contract;
|
||||
|
||||
import com.example.coach.model.Profil;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IHistoView extends IAllView {
|
||||
void afficherListe(List profils);
|
||||
void transfertProfil(Profil profil);
|
||||
}
|
||||
|
|
@ -1,11 +1,12 @@
|
|||
package com.example.coach.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Classe métier contenant les informations d'un profil
|
||||
*/
|
||||
public class Profil {
|
||||
public class Profil implements Serializable {
|
||||
private static final int MIN_FEMME = 25;
|
||||
private static final int MAX_FEMME = 30;
|
||||
private static final int MIN_HOMME = 15;
|
||||
|
|
@ -83,7 +84,7 @@ public class Profil {
|
|||
* @return Valeur de l'img
|
||||
*/
|
||||
public double getImg(){
|
||||
return this.img;
|
||||
return calculImg();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ import android.util.Log;
|
|||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.example.coach.api.CoachApi;
|
||||
import com.example.coach.api.HelperApi;
|
||||
import com.example.coach.api.ICallbackApi;
|
||||
import com.example.coach.api.IRequestApi;
|
||||
import com.example.coach.api.ResponseApi;
|
||||
import com.example.coach.contract.ICalculView;
|
||||
|
|
@ -43,53 +45,51 @@ public class CalculPresenter {
|
|||
public void creerProfil(Integer sexe, Integer poids, Integer taille, Integer age)
|
||||
{
|
||||
Profil profil = new Profil(poids, taille, age, sexe, new Date());
|
||||
vue.AfficherResultat(profil.getImage(), profil.getImg(), profil.getMessage(), profil.normal());
|
||||
String profilJson = CoachApi.getGson().toJson(profil);
|
||||
|
||||
IRequestApi api = CoachApi.getRetrofit().create(IRequestApi.class);
|
||||
Call<ResponseApi<Integer>> call = api.creerProfil(profilJson);
|
||||
|
||||
call.enqueue(new Callback<ResponseApi<Integer>>() {
|
||||
HelperApi.call(HelperApi.getApi().creerProfil(profilJson), new ICallbackApi<Integer>() {
|
||||
@Override
|
||||
public void onResponse(Call<ResponseApi<Integer>> call, Response<ResponseApi<Integer>> response) {
|
||||
Log.d("API", "code : " + response.body().getCode() +
|
||||
" message : " + response.body().getMessage() +
|
||||
" result : " + response.body().getResult()
|
||||
);
|
||||
if(response.isSuccessful() && response.body().getResult() == 1){
|
||||
vue.AfficherResultat(profil.getImage(), profil.getImg(), profil.getMessage(), profil.normal());
|
||||
public void onSuccess(Integer result) {
|
||||
if (result == 1) {
|
||||
vue.afficherMessage("profil enregistré");
|
||||
}else{
|
||||
Log.e("API", "Erreur API: " + response.code());
|
||||
vue.afficherMessage("échec enregistrement profil");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<ResponseApi<Integer>> call, @NonNull Throwable throwable) {
|
||||
Log.e("API", "Échec d'accès à l'api", throwable);
|
||||
public void onError() {
|
||||
vue.afficherMessage("échec enregistrement profil");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void chargerDernierProfil()
|
||||
{
|
||||
IRequestApi api = CoachApi.getRetrofit().create(IRequestApi.class);
|
||||
Call<ResponseApi<List<Profil>>> call = api.getProfils();
|
||||
|
||||
call.enqueue(new Callback<ResponseApi<List<Profil>>>() {
|
||||
IRequestApi api = HelperApi.getApi();
|
||||
HelperApi.call(api.getProfils(), new ICallbackApi<List<Profil>>() {
|
||||
@Override
|
||||
public void onResponse(Call<ResponseApi<List<Profil>>> call, Response<ResponseApi<List<Profil>>> response) {
|
||||
List<Profil> profils = response.body().getResult();
|
||||
if(profils != null && !profils.isEmpty()){
|
||||
Profil dernier = Collections.max(
|
||||
profils,
|
||||
(p1, p2) -> p1.getDateMesure().compareTo(p2.getDateMesure())
|
||||
);
|
||||
vue.remplirChamps(dernier.getPoids(), dernier.getTaille(), dernier.getAge(), dernier.getSexe());
|
||||
public void onSuccess(List<Profil> result) {
|
||||
if(result != null){
|
||||
List<Profil> profils = result;
|
||||
if (profils != null && !profils.isEmpty()) {
|
||||
// récupérer le plus récent
|
||||
Profil dernier = Collections.max(profils,
|
||||
(p1, p2) -> p1.getDateMesure().compareTo(p2.getDateMesure())
|
||||
);
|
||||
vue.remplirChamps(dernier.getPoids(), dernier.getTaille(),
|
||||
dernier.getAge(), dernier.getSexe());
|
||||
}else{
|
||||
vue.afficherMessage("échec récupération dernier profil");
|
||||
}
|
||||
}else{
|
||||
vue.afficherMessage("échec récupération dernier profil");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<ResponseApi<List<Profil>>> call, Throwable throwable) {
|
||||
Log.e("API", "Échec d'accès à l'api", throwable);
|
||||
public void onError() {
|
||||
vue.afficherMessage("échec récupération dernier profil");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,74 @@
|
|||
package com.example.coach.presenter;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.example.coach.api.CoachApi;
|
||||
import com.example.coach.api.HelperApi;
|
||||
import com.example.coach.api.ICallbackApi;
|
||||
import com.example.coach.api.IRequestApi;
|
||||
import com.example.coach.api.ResponseApi;
|
||||
import com.example.coach.contract.IHistoView;
|
||||
import com.example.coach.model.Profil;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
public class HistoPresenter {
|
||||
private IHistoView vue;
|
||||
|
||||
public HistoPresenter(IHistoView vue)
|
||||
{
|
||||
this.vue = vue;
|
||||
}
|
||||
|
||||
public void chargerProfils()
|
||||
{
|
||||
HelperApi.call(HelperApi.getApi().getProfils(), new ICallbackApi<List<Profil>>() {
|
||||
@Override
|
||||
public void onSuccess(List<Profil> result) {
|
||||
if(result != null){
|
||||
List<Profil> profils = result;
|
||||
Collections.sort(profils, (p1, p2) -> p2.getDateMesure().compareTo(p1.getDateMesure()));
|
||||
vue.afficherListe(profils);
|
||||
}else{
|
||||
vue.afficherMessage("échec récupération des derniers profils");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
vue.afficherMessage("échec récupération des derniers profils");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void supprProfil(Profil profil, ICallbackApi<Void> callback)
|
||||
{
|
||||
String profilJson = CoachApi.getGson().toJson(profil);
|
||||
HelperApi.call(HelperApi.getApi().supprProfil(profilJson), new ICallbackApi<Integer>() {
|
||||
@Override
|
||||
public void onSuccess(Integer result) {
|
||||
if (result == 1) {
|
||||
vue.afficherMessage("profil supprimé");
|
||||
callback.onSuccess(null);
|
||||
}else{
|
||||
vue.afficherMessage("échec suppression profil");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
vue.afficherMessage("échec suppression profil");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void transfertProfil(Profil profil)
|
||||
{
|
||||
vue.transfertProfil(profil);
|
||||
}
|
||||
}
|
||||
167
app/src/main/java/com/example/coach/view/CalculActivity.java
Normal file
167
app/src/main/java/com/example/coach/view/CalculActivity.java
Normal file
|
|
@ -0,0 +1,167 @@
|
|||
package com.example.coach.view;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RadioButton;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.activity.EdgeToEdge;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.graphics.Insets;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.view.WindowInsetsCompat;
|
||||
|
||||
import com.example.coach.R;
|
||||
import com.example.coach.contract.ICalculView;
|
||||
import com.example.coach.model.Profil;
|
||||
import com.example.coach.presenter.CalculPresenter;
|
||||
|
||||
/**
|
||||
* Activity qui permet le calcul de l'img
|
||||
*/
|
||||
public class CalculActivity extends AppCompatActivity implements ICalculView {
|
||||
|
||||
private EditText txtPoids;
|
||||
private EditText txtTaille;
|
||||
private EditText txtAge;
|
||||
private RadioButton rdHomme;
|
||||
private RadioButton rdFemme;
|
||||
private TextView lblIMG;
|
||||
private ImageView imgSmiley;
|
||||
private Button btnCalc;
|
||||
|
||||
private CalculPresenter presenter;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
EdgeToEdge.enable(this);
|
||||
setContentView(R.layout.activity_calcul);
|
||||
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
|
||||
Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
|
||||
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
|
||||
return insets;
|
||||
});
|
||||
init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Méthode permettant l'affichage du résultat du calcul de l'img
|
||||
* @param image nom du fichier drawable pour le smiley
|
||||
* @param img valeur de l'img
|
||||
* @param message message à afficher
|
||||
* @param normal faux si l'img n'est pas normal, vrai dans le cas inverse
|
||||
*/
|
||||
@Override
|
||||
public void AfficherResultat(String image, double img, String message, boolean normal) {
|
||||
int iamgeId = getResources().getIdentifier(image, "drawable", getPackageName());
|
||||
String texte = String.format("%.01f", img) + " : IMG " + message;
|
||||
|
||||
if(iamgeId == 0){
|
||||
imgSmiley.setImageResource(R.drawable.normal);
|
||||
}else{
|
||||
imgSmiley.setImageResource(iamgeId);
|
||||
}
|
||||
lblIMG.setText(texte);
|
||||
if(!normal){
|
||||
lblIMG.setTextColor(Color.RED);
|
||||
}else{
|
||||
lblIMG.setTextColor(Color.GREEN);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param poids poids stocké
|
||||
* @param taille taille stockée
|
||||
* @param age âge stocké
|
||||
* @param sexe sexe stocké
|
||||
*/
|
||||
@Override
|
||||
public void remplirChamps(Integer poids, Integer taille, Integer age, Integer sexe) {
|
||||
txtPoids.setText(poids.toString());
|
||||
txtTaille.setText(taille.toString());
|
||||
txtAge.setText(age.toString());
|
||||
|
||||
if(sexe == 1){
|
||||
rdHomme.setChecked(true);
|
||||
}else{
|
||||
rdFemme.setChecked(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Traitements à réaliser lors du lancement de l'application
|
||||
*/
|
||||
private void init()
|
||||
{
|
||||
chargeObjetsGraphiques();
|
||||
presenter = new CalculPresenter(this);
|
||||
btnCalc.setOnClickListener(v -> btnCalcClic());
|
||||
recupProfil();
|
||||
}
|
||||
|
||||
/**
|
||||
* Récupère les objets graphiques
|
||||
*/
|
||||
private void chargeObjetsGraphiques()
|
||||
{
|
||||
txtPoids = (EditText) findViewById(R.id.txtPoids);
|
||||
txtTaille = (EditText) findViewById(R.id.txtTaille);
|
||||
txtAge = (EditText) findViewById(R.id.txtAge);
|
||||
|
||||
rdHomme = (RadioButton) findViewById(R.id.rdHomme);
|
||||
rdFemme = (RadioButton) findViewById(R.id.rdFemme);
|
||||
|
||||
lblIMG = (TextView) findViewById(R.id.lblResultat);
|
||||
|
||||
imgSmiley = (ImageView) findViewById(R.id.imgSmiley);
|
||||
|
||||
btnCalc = (Button) findViewById(R.id.btnCalc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Traitements à réaliser lors du clic sur le bouton
|
||||
*/
|
||||
private void btnCalcClic()
|
||||
{
|
||||
int poids = 0, taille = 0, age = 0, sexe = 0;
|
||||
|
||||
try {
|
||||
poids = Integer.parseInt(txtPoids.getText().toString());
|
||||
taille = Integer.parseInt(txtTaille.getText().toString());
|
||||
age = Integer.parseInt(txtAge.getText().toString());
|
||||
}catch (Exception ignored){}
|
||||
|
||||
if(rdHomme.isChecked()){
|
||||
sexe = 1;
|
||||
}
|
||||
|
||||
if(poids == 0 || taille == 0 || age == 0){
|
||||
Toast.makeText(this, "Veuillez remplir tous les champs", Toast.LENGTH_SHORT).show();
|
||||
}else{
|
||||
presenter.creerProfil(sexe, poids, taille, age);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param message
|
||||
*/
|
||||
@Override
|
||||
public void afficherMessage(String message) {
|
||||
Toast.makeText(this, message, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
private void recupProfil()
|
||||
{
|
||||
Profil profil = (Profil) getIntent().getSerializableExtra("profil");
|
||||
if(profil != null){
|
||||
remplirChamps(profil.getPoids(), profil.getTaille(), profil.getAge(), profil.getSexe());
|
||||
}else{
|
||||
presenter.chargerDernierProfil();
|
||||
}
|
||||
}
|
||||
}
|
||||
74
app/src/main/java/com/example/coach/view/HistoActivity.java
Normal file
74
app/src/main/java/com/example/coach/view/HistoActivity.java
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
package com.example.coach.view;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.activity.EdgeToEdge;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.graphics.Insets;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.view.WindowInsetsCompat;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.example.coach.R;
|
||||
import com.example.coach.contract.IHistoView;
|
||||
import com.example.coach.model.Profil;
|
||||
import com.example.coach.presenter.HistoPresenter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class HistoActivity extends AppCompatActivity implements IHistoView {
|
||||
HistoPresenter presenter;
|
||||
|
||||
private void init()
|
||||
{
|
||||
presenter = new HistoPresenter(this);
|
||||
presenter.chargerProfils();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
EdgeToEdge.enable(this);
|
||||
setContentView(R.layout.activity_histo);
|
||||
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
|
||||
Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
|
||||
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
|
||||
init();
|
||||
return insets;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param profils
|
||||
*/
|
||||
@Override
|
||||
public void afficherListe(List profils) {
|
||||
if(profils != null){
|
||||
RecyclerView lstHisto = (RecyclerView) findViewById(R.id.lstHisto);
|
||||
HistoListAdapter adapter = new HistoListAdapter(profils, HistoActivity.this);
|
||||
lstHisto.setAdapter(adapter);
|
||||
lstHisto.setLayoutManager(new LinearLayoutManager(HistoActivity.this));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param profil
|
||||
*/
|
||||
@Override
|
||||
public void transfertProfil(Profil profil) {
|
||||
Intent intent = new Intent(HistoActivity.this, CalculActivity.class);
|
||||
intent.putExtra("profil", profil);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param message
|
||||
*/
|
||||
@Override
|
||||
public void afficherMessage(String message) {
|
||||
Toast.makeText(this, message, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
128
app/src/main/java/com/example/coach/view/HistoListAdapter.java
Normal file
128
app/src/main/java/com/example/coach/view/HistoListAdapter.java
Normal file
|
|
@ -0,0 +1,128 @@
|
|||
package com.example.coach.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.example.coach.R;
|
||||
import com.example.coach.api.ICallbackApi;
|
||||
import com.example.coach.contract.IHistoView;
|
||||
import com.example.coach.model.Profil;
|
||||
import com.example.coach.presenter.HistoPresenter;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class HistoListAdapter extends RecyclerView.Adapter<HistoListAdapter.ViewHolder> {
|
||||
|
||||
private List<Profil> profils;
|
||||
private IHistoView vue;
|
||||
|
||||
/**
|
||||
* Retourne une ligne de la liste
|
||||
* @param parent The ViewGroup into which the new View will be added after it is bound to
|
||||
* an adapter position.
|
||||
* @param viewType The view type of the new View.
|
||||
* @return
|
||||
*/
|
||||
@NonNull
|
||||
@Override
|
||||
public HistoListAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
Context parentContext = parent.getContext();
|
||||
LayoutInflater layout = LayoutInflater.from(parentContext);
|
||||
View view = layout.inflate(R.layout.layout_list_histo, parent, false);
|
||||
|
||||
return new HistoListAdapter.ViewHolder(view);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rempli une ligne
|
||||
* @param holder The ViewHolder which should be updated to represent the contents of the
|
||||
* item at the given position in the data set.
|
||||
* @param position The position of the item within the adapter's data set.
|
||||
*/
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull HistoListAdapter.ViewHolder holder, int position) {
|
||||
Double img = profils.get(position).getImg();
|
||||
String img1desimal = String.format("%.01f", img);
|
||||
holder.txtListIMG.setText(img1desimal);
|
||||
|
||||
Date dateMesure = profils.get(position).getDateMesure();
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss", Locale.getDefault());
|
||||
String dateFormatee = sdf.format(dateMesure);
|
||||
holder.txtListDate.setText(dateFormatee);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compte le nombre de lignes
|
||||
* @return int
|
||||
*/
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return profils.size();
|
||||
}
|
||||
|
||||
public HistoListAdapter(List<Profil> profils, IHistoView vue)
|
||||
{
|
||||
this.profils = profils;
|
||||
this.vue = vue;
|
||||
}
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder{
|
||||
final TextView txtListDate;
|
||||
final TextView txtListIMG;
|
||||
final ImageButton btnListSuppr;
|
||||
|
||||
HistoPresenter presenter;
|
||||
public ViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
|
||||
txtListDate = (TextView) itemView.findViewById(R.id.txtListDate);
|
||||
txtListIMG = (TextView) itemView.findViewById(R.id.txtListIMG);
|
||||
btnListSuppr = (ImageButton) itemView.findViewById(R.id.btnListSuppr);
|
||||
init();
|
||||
}
|
||||
|
||||
private void btnListSuppr_clic()
|
||||
{
|
||||
int position = getBindingAdapterPosition();
|
||||
presenter.supprProfil(profils.get(position), new ICallbackApi<Void>() {
|
||||
@Override
|
||||
public void onSuccess(Void result) {
|
||||
profils.remove(position);
|
||||
notifyItemRemoved(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void init()
|
||||
{
|
||||
btnListSuppr.setOnClickListener(v -> btnListSuppr_clic());
|
||||
txtListDate.setOnClickListener(v -> txtListDateOrImg_clic());
|
||||
txtListIMG.setOnClickListener(v -> txtListDateOrImg_clic());
|
||||
presenter = new HistoPresenter(vue);
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void txtListDateOrImg_clic()
|
||||
{
|
||||
int position = getBindingAdapterPosition();
|
||||
presenter.transfertProfil(profils.get(position));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,13 +1,8 @@
|
|||
package com.example.coach.view;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RadioButton;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import android.widget.ImageButton;
|
||||
|
||||
import androidx.activity.EdgeToEdge;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
|
@ -16,24 +11,11 @@ import androidx.core.view.ViewCompat;
|
|||
import androidx.core.view.WindowInsetsCompat;
|
||||
|
||||
import com.example.coach.R;
|
||||
import com.example.coach.contract.ICalculView;
|
||||
import com.example.coach.presenter.CalculPresenter;
|
||||
|
||||
/**
|
||||
* Activity qui permet le calcul de l'img
|
||||
*/
|
||||
public class MainActivity extends AppCompatActivity implements ICalculView {
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
|
||||
private EditText txtPoids;
|
||||
private EditText txtTaille;
|
||||
private EditText txtAge;
|
||||
private RadioButton rdHomme;
|
||||
private RadioButton rdFemme;
|
||||
private TextView lblIMG;
|
||||
private ImageView imgSmiley;
|
||||
private Button btnCalc;
|
||||
|
||||
private CalculPresenter presenter;
|
||||
private ImageButton btnMonIMG;
|
||||
private ImageButton btnMonHistorique;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
|
@ -43,107 +25,32 @@ public class MainActivity extends AppCompatActivity implements ICalculView {
|
|||
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
|
||||
Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
|
||||
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
|
||||
init();
|
||||
return insets;
|
||||
});
|
||||
init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Méthode permettant l'affichage du résultat du calcul de l'img
|
||||
* @param image nom du fichier drawable pour le smiley
|
||||
* @param img valeur de l'img
|
||||
* @param message message à afficher
|
||||
* @param normal faux si l'img n'est pas normal, vrai dans le cas inverse
|
||||
*/
|
||||
@Override
|
||||
public void AfficherResultat(String image, double img, String message, boolean normal) {
|
||||
int iamgeId = getResources().getIdentifier(image, "drawable", getPackageName());
|
||||
String texte = String.format("%.01f", img) + " : IMG " + message;
|
||||
|
||||
if(iamgeId == 0){
|
||||
imgSmiley.setImageResource(R.drawable.normal);
|
||||
}else{
|
||||
imgSmiley.setImageResource(iamgeId);
|
||||
}
|
||||
lblIMG.setText(texte);
|
||||
if(!normal){
|
||||
lblIMG.setTextColor(Color.RED);
|
||||
}else{
|
||||
lblIMG.setTextColor(Color.GREEN);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param poids poids stocké
|
||||
* @param taille taille stockée
|
||||
* @param age âge stocké
|
||||
* @param sexe sexe stocké
|
||||
*/
|
||||
@Override
|
||||
public void remplirChamps(Integer poids, Integer taille, Integer age, Integer sexe) {
|
||||
txtPoids.setText(poids.toString());
|
||||
txtTaille.setText(taille.toString());
|
||||
txtAge.setText(age.toString());
|
||||
|
||||
if(sexe == 1){
|
||||
rdHomme.setChecked(true);
|
||||
}else{
|
||||
rdFemme.setChecked(false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Traitements à réaliser lors du lancement de l'application
|
||||
*/
|
||||
private void init()
|
||||
{
|
||||
chargeObjetsGraphiques();
|
||||
presenter = new CalculPresenter(this);
|
||||
btnCalc.setOnClickListener(v -> btnCalcClic());
|
||||
|
||||
presenter.chargerDernierProfil();
|
||||
creerMenu();
|
||||
}
|
||||
|
||||
/**
|
||||
* Récupère les objets graphiques
|
||||
*/
|
||||
private void chargeObjetsGraphiques()
|
||||
{
|
||||
txtPoids = (EditText) findViewById(R.id.txtPoids);
|
||||
txtTaille = (EditText) findViewById(R.id.txtTaille);
|
||||
txtAge = (EditText) findViewById(R.id.txtAge);
|
||||
|
||||
rdHomme = (RadioButton) findViewById(R.id.rdHomme);
|
||||
rdFemme = (RadioButton) findViewById(R.id.rdFemme);
|
||||
|
||||
lblIMG = (TextView) findViewById(R.id.lblResultat);
|
||||
|
||||
imgSmiley = (ImageView) findViewById(R.id.imgSmiley);
|
||||
|
||||
btnCalc = (Button) findViewById(R.id.btnCalc);
|
||||
btnMonIMG = (ImageButton) findViewById(R.id.btnMonIMG);
|
||||
btnMonHistorique = (ImageButton) findViewById(R.id.btnMonHistorique);
|
||||
}
|
||||
|
||||
/**
|
||||
* Traitements à réaliser lors du clic sur le bouton
|
||||
*/
|
||||
private void btnCalcClic()
|
||||
private void ecouteMenu(Class classe)
|
||||
{
|
||||
int poids = 0, taille = 0, age = 0, sexe = 0;
|
||||
Intent intent = new Intent(MainActivity.this, classe);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
try {
|
||||
poids = Integer.parseInt(txtPoids.getText().toString());
|
||||
taille = Integer.parseInt(txtTaille.getText().toString());
|
||||
age = Integer.parseInt(txtAge.getText().toString());
|
||||
}catch (Exception ignored){}
|
||||
|
||||
if(rdHomme.isChecked()){
|
||||
sexe = 1;
|
||||
}
|
||||
|
||||
if(poids == 0 || taille == 0 || age == 0){
|
||||
Toast.makeText(this, "Veuillez remplir tous les champs", Toast.LENGTH_SHORT).show();
|
||||
}else{
|
||||
presenter.creerProfil(sexe, poids, taille, age);
|
||||
}
|
||||
private void creerMenu()
|
||||
{
|
||||
btnMonIMG.setOnClickListener(v -> ecouteMenu(CalculActivity.class));
|
||||
btnMonHistorique.setOnClickListener(v -> ecouteMenu(HistoActivity.class));
|
||||
}
|
||||
}
|
||||
BIN
app/src/main/res/drawable/historique.png
Normal file
BIN
app/src/main/res/drawable/historique.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 21 KiB |
BIN
app/src/main/res/drawable/suppr.png
Normal file
BIN
app/src/main/res/drawable/suppr.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.2 KiB |
173
app/src/main/res/layout/activity_calcul.xml
Normal file
173
app/src/main/res/layout/activity_calcul.xml
Normal file
|
|
@ -0,0 +1,173 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/main"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".view.CalculActivity">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
tools:layout_editor_absoluteX="1dp"
|
||||
tools:layout_editor_absoluteY="1dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_weight="1"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center_horizontal|center_vertical"
|
||||
android:orientation="vertical">
|
||||
|
||||
<RadioGroup
|
||||
android:id="@+id/grpRadioSexe"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/rdHomme"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:checked="true"
|
||||
android:text="Homme" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/rdFemme"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:text="Femme" />
|
||||
</RadioGroup>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center_horizontal|center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="Poids :" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/txtPoids"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:ems="10"
|
||||
android:inputType="number" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center_horizontal|center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView2"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="Taille :" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/txtTaille"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:ems="10"
|
||||
android:inputType="number" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center_horizontal|center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView3"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="Age :" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/txtAge"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:ems="10"
|
||||
android:inputType="number" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_weight="0"
|
||||
android:gravity="center_horizontal|center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnCalc"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="Calculer" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center_horizontal|center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imgSmiley"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
app:srcCompat="@drawable/normal" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/lblResultat"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
22
app/src/main/res/layout/activity_histo.xml
Normal file
22
app/src/main/res/layout/activity_histo.xml
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/main"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".view.HistoActivity">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/lstHisto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="?attr/actionBarSize"
|
||||
android:scrollbars="vertical" />
|
||||
</LinearLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
|
@ -10,164 +10,64 @@
|
|||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
tools:layout_editor_absoluteX="1dp"
|
||||
tools:layout_editor_absoluteY="1dp">
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_weight="1"
|
||||
android:orientation="horizontal">
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center_horizontal|center_vertical"
|
||||
android:orientation="vertical">
|
||||
|
||||
<RadioGroup
|
||||
android:id="@+id/grpRadioSexe"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/rdHomme"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:checked="true"
|
||||
android:text="Homme" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/rdFemme"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:text="Femme" />
|
||||
</RadioGroup>
|
||||
</LinearLayout>
|
||||
android:orientation="vertical"></LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
<TextView
|
||||
android:id="@+id/textView4"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_horizontal"
|
||||
android:text="mon IMG"
|
||||
android:textSize="34sp" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/btnMonIMG"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center_horizontal|center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="Poids :" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/txtPoids"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:ems="10"
|
||||
android:inputType="number" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center_horizontal|center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView2"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="Taille :" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/txtTaille"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:ems="10"
|
||||
android:inputType="number" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center_horizontal|center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView3"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="Age :" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/txtAge"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:ems="10"
|
||||
android:inputType="number" />
|
||||
</LinearLayout>
|
||||
app:srcCompat="@drawable/normal" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_weight="0"
|
||||
android:gravity="center_horizontal|center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnCalc"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="Calculer" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center_horizontal|center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imgSmiley"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
app:srcCompat="@drawable/normal" />
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/lblResultat"
|
||||
android:layout_width="0dp"
|
||||
android:id="@+id/textView5"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1" />
|
||||
android:gravity="center_horizontal"
|
||||
android:text="mon historique"
|
||||
android:textSize="34sp" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/btnMonHistorique"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
app:srcCompat="@drawable/historique" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
57
app/src/main/res/layout/layout_list_histo.xml
Normal file
57
app/src/main/res/layout/layout_list_histo.xml
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0"
|
||||
android:gravity="clip_vertical"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/btnListSuppr"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:srcCompat="@drawable/suppr" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:gravity="clip_vertical"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtListDate"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="TextView" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:gravity="clip_vertical"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtListIMG"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="end"
|
||||
android:text="TextView"
|
||||
android:textSize="24sp"
|
||||
android:textStyle="bold" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<!-- Base application theme. -->
|
||||
<style name="Base.Theme.Coach" parent="Theme.Material3.DayNight.NoActionBar">
|
||||
<style name="Base.Theme.Coach" parent="Theme.AppCompat.DayNight.DarkActionBar">
|
||||
<!-- Customize your dark theme here. -->
|
||||
<!-- <item name="colorPrimary">@color/my_dark_primary</item> -->
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<!-- Base application theme. -->
|
||||
<style name="Base.Theme.Coach" parent="Theme.Material3.DayNight.NoActionBar">
|
||||
<style name="Base.Theme.Coach" parent="Theme.AppCompat.DayNight">
|
||||
<!-- Customize your light theme here. -->
|
||||
<!-- <item name="colorPrimary">@color/my_light_primary</item> -->
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ appcompat = "1.6.1"
|
|||
material = "1.10.0"
|
||||
activity = "1.8.0"
|
||||
constraintlayout = "2.1.4"
|
||||
recyclerview = "1.4.0"
|
||||
|
||||
[libraries]
|
||||
junit = { group = "junit", name = "junit", version.ref = "junit" }
|
||||
|
|
@ -16,6 +17,7 @@ appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "a
|
|||
material = { group = "com.google.android.material", name = "material", version.ref = "material" }
|
||||
activity = { group = "androidx.activity", name = "activity", version.ref = "activity" }
|
||||
constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" }
|
||||
recyclerview = { group = "androidx.recyclerview", name = "recyclerview", version.ref = "recyclerview" }
|
||||
|
||||
[plugins]
|
||||
android-application = { id = "com.android.application", version.ref = "agp" }
|
||||
|
|
|
|||
Loading…
Reference in a new issue