Skip to content
Extraits de code Groupes Projets
Valider 021937b4 rédigé par Rémy Mathieu's avatar Rémy Mathieu
Parcourir les fichiers

Merge branch 'main' into 'remy'

# Conflicts:
#   app/src/main/java/be/lepl1509group13/workoutwarrior/ProgramDetailActivity.java
parents 3a665096 a790843b
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion!39Remy
package be.lepl1509group13.workoutwarrior;
import android.app.Dialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.TextView;
import android.widget.Toast;
......@@ -47,6 +51,10 @@ public class ProgramDetailActivity extends AppCompatActivity implements ProgramA
TextView start_workout, delete_workout, show_workout, share_workout;
private boolean isLocalProgram = false;
private String[][] exercisesData = null;
private ArrayList<ArrayList<String>> allExercices = new ArrayList<ArrayList<String>>();
Map<String, ArrayList<Exercise>> all_ex_all_days = new HashMap<>();
String program_name = "";
ArrayList<String> all_days_exos = new ArrayList<String>();
@Override
protected void onCreate(Bundle savedInstanceState) {
......@@ -56,6 +64,7 @@ public class ProgramDetailActivity extends AppCompatActivity implements ProgramA
//get the id of the workout && launch the workout
Intent this_intent = this.getIntent();
program_name = this_intent.getStringExtra("name");
int id = this_intent.getIntExtra("id", 0);
//finish activity of there is no id
if (id == 0){ this.finish(); }
......@@ -166,7 +175,64 @@ public class ProgramDetailActivity extends AppCompatActivity implements ProgramA
}
private void showWorkout() {
//todo
Dialog dialog = new Dialog(ProgramDetailActivity.this);
dialog.setContentView(R.layout.detail_program_popup);
TextView program_name_popup = dialog.findViewById(R.id.program_name);
program_name_popup.setText(program_name);
ImageView closeButton = dialog.findViewById(R.id.close_btn);
closeButton.setOnClickListener(w -> dialog.dismiss());
ListView listView = dialog.findViewById(R.id.list_exo_program);
// Création tableau avec nom d'exo
String[] exo_name = new String[exercisesData.length];
for (int i = 0; i < exercisesData.length; i++) {
exo_name[i] = exercisesData[i][0];
}
String[] days_exos = new String[exercisesData.length];
for (int i = 0; i < exercisesData.length; i++) {
String globalString = "";
for (String key : all_ex_all_days.keySet()) {
ArrayList<Exercise> values = all_ex_all_days.get(key);
for (Exercise ex : values) {
if (ex.name.equals(exercisesData[i][0])) {
globalString += key + ", ";
break;
}
}
}
globalString = globalString.replaceAll(", $", " ");
days_exos[i] = globalString;
}
// Création tableau avec description d'exo
String[] exo_description = new String[exercisesData.length];
for (int i = 0; i < exercisesData.length; i++) {
exo_description[i] = exercisesData[i][1];
}
ArrayList<HashMap<String, String>> list = new ArrayList<>();
for (int i = 0; i < exo_name.length; i++) {
HashMap<String, String> map = new HashMap<>();
map.put("title", exo_name[i]);
map.put("subtitle", exo_description[i]);
map.put("days", days_exos[i]);
list.add(map);
}
SimpleAdapter adapter = new SimpleAdapter(
ProgramDetailActivity.this,
list,
R.layout.exo_in_program_item,
new String[]{"title", "subtitle", "days"},
new int[]{R.id.title_textview, R.id.subtitle_textview, R.id.day_item});
listView.setAdapter(adapter);
dialog.show();
}
private void deleteWorkout() {
......@@ -235,9 +301,12 @@ public class ProgramDetailActivity extends AppCompatActivity implements ProgramA
for (String filename : fileNames){
if (filename.equals(name + ".ser")){
ArrayList<String> exo = new ArrayList<String>();
//update the title of the program
TextView title = findViewById(R.id.title);
title.setText(name);
exo.add(name);
FileInputStream fileInputStream = openFileInput(filename);
ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream);
......@@ -247,9 +316,23 @@ public class ProgramDetailActivity extends AppCompatActivity implements ProgramA
HashMap<String, ArrayList<Exercise>> entry = exerciseEntry.getEntry();
programHash = entry;
for (Map.Entry<String, ArrayList<Exercise>> entrySet : entry.entrySet()) {
String key = entrySet.getKey(); // Récupération de la clé
ArrayList<Exercise> value = entrySet.getValue(); // Récupération de la valeur correspondante
all_ex_all_days.put(key, value);
}
for (Map.Entry<String, ArrayList<Exercise>> set : entry.entrySet()) {
for (Exercise values : set.getValue()){
String customName = values.name;
exo.add(customName);
String description = values.description;
exo.add(description);
}
String dayOfTheWeek = new SimpleDateFormat("EEEE", Locale.FRENCH).format(date.getTime());
String day = set.getKey();
if(Objects.equals(dayOfTheWeek, day)){
//Get the data from the day of the week only
int totalExercises = 0;
......@@ -277,6 +360,16 @@ public class ProgramDetailActivity extends AppCompatActivity implements ProgramA
recyclerView.setAdapter(adapter);
}
}
boolean axo_in_program = false;
for (ArrayList<String> element : allExercices) {
if (element.equals(exo)) {
axo_in_program = true;
break;
}
}
if(!axo_in_program) {
allExercices.add(exo);
}
objectInputStream.close();
fileInputStream.close();
}
......
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/linearLayout"
android:layout_width="match_parent"
android:layout_marginTop="40dp"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:id="@+id/program_name"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:fontFamily="@font/poppins_semibold"
android:gravity="center"
android:textColor="@color/orange"
android:textSize="28sp"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="@+id/constraintLayout2"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</LinearLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/constraintLayout2"
android:layout_width="387dp"
android:layout_height="524dp"
android:layout_marginBottom="50dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/linearLayout">
<RelativeLayout
android:layout_width="290dp"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ListView
android:id="@+id/list_exo_program"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</ListView>
</RelativeLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
<ImageView
android:id="@+id/close_btn"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="10dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/close_btn" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp">
<TextView
android:id="@+id/title_textview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="18sp" />
<TextView
android:id="@+id/subtitle_textview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/title_textview"
android:layout_marginTop="8dp"
android:textSize="16sp" />
<TextView
android:id="@+id/info_textview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/subtitle_textview"
android:layout_marginTop="8dp"
android:text="Vous devez effectuer cet exercice au(x) jour(s) suivant(s) :"
android:textSize="14sp" />
<TextView
android:id="@+id/day_item"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/info_textview"
android:layout_marginTop="8dp"
android:textSize="14sp"/>
</RelativeLayout>
\ No newline at end of file
......@@ -9,7 +9,7 @@
<string name="entrainement_badminton">Entrainement Badminton</string>
<string name="launch_workout">Démarrer</string>
<string name="delete_workout">Supprimer le programme</string>
<string name="show_workout">Afficher / Modifier le programme</string>
<string name="show_workout">Afficher le programme</string>
<string name="title_activity_account">AccountActivity</string>
<string name="prompt_email">Email</string>
<string name="prompt_password">Password</string>
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter