diff --git a/app/src/main/java/be/lepl1509group13/workoutwarrior/ProgramCreationActivity.java b/app/src/main/java/be/lepl1509group13/workoutwarrior/ProgramCreationActivity.java index 7e333d967595fb3290483f2cf821d0676f0058fd..771a1b622312e8d3b7ee4edd9b932ba65fbb0460 100644 --- a/app/src/main/java/be/lepl1509group13/workoutwarrior/ProgramCreationActivity.java +++ b/app/src/main/java/be/lepl1509group13/workoutwarrior/ProgramCreationActivity.java @@ -13,6 +13,7 @@ import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.CheckBox; import android.widget.CompoundButton; +import android.widget.EditText; import android.widget.ImageButton; import android.widget.ImageView; import android.widget.ListView; @@ -33,14 +34,19 @@ import com.google.firebase.database.Query; import com.google.firebase.database.ValueEventListener; import java.io.BufferedReader; +import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStreamReader; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; +import java.io.Serializable; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.Map; import java.util.Objects; @@ -132,18 +138,33 @@ public class ProgramCreationActivity extends AppCompatActivity { testbtn.setOnClickListener(v -> { System.out.println("EXO SAVED: \n"); try { - FileInputStream fis = openFileInput("data.txt"); - InputStreamReader isr = new InputStreamReader(fis); - BufferedReader br = new BufferedReader(isr); - String line; - while ((line = br.readLine()) != null) { - System.out.println(line); + // recup files saved (garde que ".ser") + File dir = getFilesDir(); + String[] fileNames = dir.list(); + assert fileNames != null; + for (String filename : fileNames){ + if (filename.endsWith(".ser")){ + + System.out.println("FILENAME: " + filename + "\n"); + FileInputStream fileInputStream = openFileInput(filename); + ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream); + ExerciseEntry exerciseEntry = (ExerciseEntry) objectInputStream.readObject(); + + // ici tu peux utiliser entry comme programme perso + HashMap<String, ArrayList<Exercise>> entry = exerciseEntry.getEntry(); + + + for (Map.Entry<String, ArrayList<Exercise>> set : entry.entrySet()) { + System.out.println(set.getKey() + " = " + set.getValue()); + } + + objectInputStream.close(); + fileInputStream.close(); + } } - br.close(); - } catch (FileNotFoundException e) { - throw new RuntimeException(e); - } catch (IOException e) { - throw new RuntimeException(e); + + } catch (IOException | ClassNotFoundException e) { + e.printStackTrace(); } }); } @@ -167,21 +188,22 @@ public class ProgramCreationActivity extends AppCompatActivity { private void saveProgramListener(){ Button save_btn = findViewById((R.id.save_button)); save_btn.setOnClickListener(v -> { - System.out.println("Voici la liste des exos pour ce programme : \n"); - for (Map.Entry<String, ArrayList<Exercise>> set : exoDetailsForEachDay.entrySet()) { - System.out.println(set.getKey() + " = " + set.getValue()); - } - try { - FileOutputStream fos = openFileOutput("data.txt", Context.MODE_PRIVATE); - PrintWriter writer = new PrintWriter(new OutputStreamWriter(fos)); - for (Map.Entry<String, ArrayList<Exercise>> set : exoDetailsForEachDay.entrySet()) { - String key = set.getKey(); - ArrayList<Exercise> value = set.getValue(); - writer.println(key + " = " + value.toString()); - } + try { + // recup le nom de programme comme nom de fichier -> nomdeprogramme.ser + EditText programNameEditText = findViewById(R.id.program_name); + String programName = programNameEditText.getText().toString(); + String programpath = programName + ".ser"; + + // place le HashMap du programme dans nomdeprogramme.ser + HashMap<String, ArrayList<Exercise>> entry = exoDetailsForEachDay; + ExerciseEntry exerciseEntry = new ExerciseEntry(entry); + FileOutputStream fileOutputStream = openFileOutput(programpath, Context.MODE_PRIVATE); + ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream); + objectOutputStream.writeObject(exerciseEntry); + objectOutputStream.close(); + fileOutputStream.close(); - writer.close(); } catch (Exception e) { e.printStackTrace(); } @@ -402,7 +424,8 @@ public class ProgramCreationActivity extends AppCompatActivity { } } -class Exercise { +class Exercise implements Serializable { + private static final long serialVersionUID = 1L; String name; String description; int breakVal; @@ -420,7 +443,19 @@ class Exercise { @NonNull @Override public String toString() { - return name + ", " + description + ", temps de pause : " + breakVal; + return name + ", " + description + ", temps de pause : " + breakVal + ", image_url : " + image_url + ", timer : " + timer; } } +class ExerciseEntry implements Serializable { + private static final long serialVersionUID = 1L; + private final HashMap<String, ArrayList<Exercise>> entry; + + public ExerciseEntry(HashMap<String, ArrayList<Exercise>> entry) { + this.entry = entry; + } + + public HashMap<String, ArrayList<Exercise>> getEntry() { + return entry; + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable/homepage_add_prog.xml b/app/src/main/res/drawable/homepage_add_prog.xml index 860772c5487c57e890cf0c73f3cf74cd82e9a4dd..85af99c3e8a62f2451fa71d90b23a43920371dae 100644 --- a/app/src/main/res/drawable/homepage_add_prog.xml +++ b/app/src/main/res/drawable/homepage_add_prog.xml @@ -1,4 +1,4 @@ <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <corners android:radius="5dp" /> - <solid android:color="#000000" /> + <solid android:color="@color/orange" /> </shape> diff --git a/app/src/main/res/layout/activity_account.xml b/app/src/main/res/layout/activity_account.xml index 6121e5c8bfd292e0d92ed5b83c08dcf202199039..06a01823926ec251e6de950a7809b560a128bd6d 100644 --- a/app/src/main/res/layout/activity_account.xml +++ b/app/src/main/res/layout/activity_account.xml @@ -119,6 +119,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Deconnexion" + android:backgroundTint="@color/orange" app:layout_constraintBottom_toBottomOf="@+id/relativeLayout" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toTopOf="parent" diff --git a/app/src/main/res/layout/activity_detail_program.xml b/app/src/main/res/layout/activity_detail_program.xml index a21ad1aadf58c852e1bb31a153fcc89c816b3b1b..7865b3bb986117211a3a3c8391b9cbb2c775541f 100644 --- a/app/src/main/res/layout/activity_detail_program.xml +++ b/app/src/main/res/layout/activity_detail_program.xml @@ -4,7 +4,6 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - android:background="@color/bwhite" tools:context=".MainActivity"> <Button @@ -51,7 +50,6 @@ android:fontFamily="@font/poppins_extrabold" android:gravity="center" android:text="" - android:textColor="#454040" android:textSize="24sp" android:translationY="40dp" app:layout_constraintEnd_toEndOf="parent" diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index e8b300f4e22c4035375ccb13e4abf6b848c9d30d..6e83f1921b6a96538cc4af0a7b40c3906be0d4ce 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -4,7 +4,6 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - android:background="@color/bwhite" tools:context=".MainActivity"> <androidx.constraintlayout.widget.ConstraintLayout @@ -44,7 +43,6 @@ android:fontFamily="@font/poppins_semibold" android:gravity="center" android:text="@string/bienvenue_message" - android:textColor="#1E2432" android:textSize="29sp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" @@ -65,7 +63,8 @@ app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toTopOf="parent" - android:src="@drawable/user"/> + android:src="@drawable/user" + app:tint="@color/orange" /> </androidx.constraintlayout.widget.ConstraintLayout> @@ -99,9 +98,7 @@ android:id="@+id/program_creation_button" android:layout_width="318dp" android:layout_height="37dp" - android:background="@drawable/homepage_add_prog" android:backgroundTint="@color/orange" - android:backgroundTintMode="add" android:clipToOutline="true" android:text="Créer un programme" /> diff --git a/app/src/main/res/layout/activity_workout.xml b/app/src/main/res/layout/activity_workout.xml index 033c487eabf83f3fa346e2df4b818bf3ebc1c48d..fcac691e1cc911fde21782882079178ba0ea6809 100644 --- a/app/src/main/res/layout/activity_workout.xml +++ b/app/src/main/res/layout/activity_workout.xml @@ -13,6 +13,7 @@ android:layout_marginTop="25dp" android:fontFamily="@font/poppins_semibold" android:text="" + android:textColor="@color/bwhite" android:textSize="20dp" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" @@ -24,7 +25,6 @@ android:layout_height="40dp" android:layout_marginLeft="20dp" android:layout_marginTop="20dp" - android:backgroundTint="@color/light_grey" android:fontFamily="@font/poppins_semibold" android:paddingLeft="10dp" android:paddingTop="1dp" diff --git a/app/src/main/res/layout/edit_workout.xml b/app/src/main/res/layout/edit_workout.xml index e5b2ba141fe6980df9c2634b3067a2fda21e9f09..c8edf55d704c617990bf08e8084213845eaab39b 100644 --- a/app/src/main/res/layout/edit_workout.xml +++ b/app/src/main/res/layout/edit_workout.xml @@ -3,8 +3,7 @@ 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" - android:background="@color/bwhite"> + android:layout_height="match_parent"> <androidx.constraintlayout.widget.ConstraintLayout @@ -80,7 +79,6 @@ android:layout_marginTop="30dp" android:background="@color/orange" android:text="Sauvegarder modifications" - android:textColor="@color/white" android:textSize="16sp" /> diff --git a/app/src/main/res/layout/exercice.xml b/app/src/main/res/layout/exercice.xml index 5cb97bb9fc0135bbcd648ae1e58fcf9fef90b522..20f2aa807b2572c013152e3cfca397442d55eb49 100644 --- a/app/src/main/res/layout/exercice.xml +++ b/app/src/main/res/layout/exercice.xml @@ -1,5 +1,6 @@ <?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"> @@ -29,6 +30,7 @@ android:layout_alignParentStart="true" android:clickable="true" android:src="@drawable/ic_launcher_background" + android:focusable="true" android:layout_width="20dp" android:layout_height="20dp"/> @@ -40,7 +42,8 @@ android:src="@drawable/ic_launcher_background" android:focusable="true" android:layout_width="20dp" - android:layout_height="20dp"/> + android:layout_height="20dp" + app:tint="@color/orange" /> </LinearLayout> </LinearLayout> diff --git a/app/src/main/res/layout/exercice_details_pop_up.xml b/app/src/main/res/layout/exercice_details_pop_up.xml index 72c9d3225de4d2301895cf37cd42739616b7b97b..50c71f4200de2e2bc60fb3f954444b858fbda6e4 100644 --- a/app/src/main/res/layout/exercice_details_pop_up.xml +++ b/app/src/main/res/layout/exercice_details_pop_up.xml @@ -3,8 +3,7 @@ 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" - android:background="@color/bwhite"> + android:layout_height="match_parent"> <TextView android:id="@+id/exercise_popup_name" diff --git a/app/src/main/res/layout/help_creation_program_popup.xml b/app/src/main/res/layout/help_creation_program_popup.xml index 01538f2b585fc5407ce5d9573baccde242ff0275..7aa203eefbb37da605a6cf038b8acd610c687de2 100644 --- a/app/src/main/res/layout/help_creation_program_popup.xml +++ b/app/src/main/res/layout/help_creation_program_popup.xml @@ -3,8 +3,7 @@ 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" - android:background="@color/bwhite"> + android:layout_height="match_parent"> <TextView android:id="@+id/exercise_popup_name" @@ -39,7 +38,6 @@ android:layout_width="350dp" android:layout_height="match_parent" android:text="• Pour commencer, sélectionnez le(s) jour(s) au(x)quel(s) vous voulez ajouter un ou plusieurs exercices." - android:textColor="@color/black" android:textSize="16dp" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" /> @@ -50,7 +48,6 @@ android:layout_height="match_parent" android:layout_marginTop="15dp" android:text="• Sélectionnez l'exercice que vous voulez ajouter pour ce(s) jour(s) dans la liste déroulante et cliquez sur le bouton ajouter exercice." - android:textColor="@color/black" android:textSize="16dp" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" @@ -63,7 +60,6 @@ android:layout_height="match_parent" android:layout_marginTop="15dp" android:text="• Cliquez sur un jour pour voir le(s) exercice(s) enregistré(s) pour ce dernier." - android:textColor="@color/black" android:textSize="16dp" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" @@ -75,7 +71,6 @@ android:layout_height="match_parent" android:layout_marginTop="15dp" android:text="• Cliquez sur le bouton Enregistrer pour sauvegarder votre nouveau programme." - android:textColor="@color/black" android:textSize="16dp" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" diff --git a/app/src/main/res/layout/program_creation.xml b/app/src/main/res/layout/program_creation.xml index 88c8a0e6055db0f8b3769fe77179821e6e841530..d82391bd80d04abf844f32aa495ebcbee633e882 100644 --- a/app/src/main/res/layout/program_creation.xml +++ b/app/src/main/res/layout/program_creation.xml @@ -3,8 +3,7 @@ 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" - android:background="@color/bwhite"> + android:layout_height="match_parent"> <RelativeLayout android:id="@+id/relativeLayout4" @@ -93,7 +92,6 @@ android:fontFamily="@font/poppins_extrabold" android:gravity="center" android:text="Création de programme" - android:textColor="@color/black" android:textSize="18sp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" @@ -190,6 +188,7 @@ android:id="@+id/checkbox_monday" android:layout_width="30dp" android:layout_height="wrap_content" + android:buttonTint="@color/orange" android:fontFamily="@font/poppins" /> <TextView @@ -202,13 +201,13 @@ android:onClick="onNewDayTextClick" android:tag="lundi" android:text="Lundi" - android:textColor="@color/black" android:textSize="15dp" /> <CheckBox android:id="@+id/checkbox_tuesday" android:layout_width="30dp" android:layout_height="wrap_content" + android:buttonTint="@color/orange" android:fontFamily="@font/poppins" /> <TextView @@ -221,13 +220,13 @@ android:onClick="onNewDayTextClick" android:tag="mardi" android:text="Mardi" - android:textColor="@color/black" android:textSize="15dp" /> <CheckBox android:id="@+id/checkbox_wednesday" android:layout_width="30dp" android:layout_height="wrap_content" + android:buttonTint="@color/orange" android:fontFamily="@font/poppins" /> <TextView @@ -254,6 +253,7 @@ android:id="@+id/checkbox_thursday" android:layout_width="30dp" android:layout_height="wrap_content" + android:buttonTint="@color/orange" android:fontFamily="@font/poppins" /> <TextView @@ -266,13 +266,13 @@ android:onClick="onNewDayTextClick" android:tag="jeudi" android:text="Jeudi" - android:textColor="@color/black" android:textSize="15dp" /> <CheckBox android:id="@+id/checkbox_friday" android:layout_width="30dp" android:layout_height="wrap_content" + android:buttonTint="@color/orange" android:fontFamily="@font/poppins" /> <TextView @@ -285,13 +285,13 @@ android:onClick="onNewDayTextClick" android:tag="vendredi" android:text="Vendredi" - android:textColor="@color/black" android:textSize="15dp" /> <CheckBox android:id="@+id/checkbox_saturday" android:layout_width="30dp" android:layout_height="wrap_content" + android:buttonTint="@color/orange" android:fontFamily="@font/poppins" /> <TextView @@ -304,7 +304,6 @@ android:onClick="onNewDayTextClick" android:tag="samedi" android:text="Samedi" - android:textColor="@color/black" android:textSize="15dp" /> </LinearLayout> @@ -318,6 +317,7 @@ android:id="@+id/checkbox_sunday" android:layout_width="30dp" android:layout_height="wrap_content" + android:buttonTint="@color/orange" android:fontFamily="@font/poppins" /> <TextView @@ -330,7 +330,6 @@ android:onClick="onNewDayTextClick" android:tag="dimanche" android:text="Dimanche" - android:textColor="@color/black" android:textSize="15dp" /> </LinearLayout> diff --git a/app/src/main/res/values-night/themes.xml b/app/src/main/res/values-night/themes.xml index f50be00ebbe83f14c18f810a661c297fbcd69ef8..0dc0ded86b3b7ad225741020007ef2c1a0dd4bbf 100644 --- a/app/src/main/res/values-night/themes.xml +++ b/app/src/main/res/values-night/themes.xml @@ -11,6 +11,7 @@ <item name="colorOnSecondary">@color/orange</item> <!-- Status bar color. --> <item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item> + <item name="android:textColor">@color/bwhite</item> <!-- Customize your theme here. --> </style> </resources> \ No newline at end of file diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index f50be00ebbe83f14c18f810a661c297fbcd69ef8..7a1d84a827812a944e3daf68e1b8d2109fbee589 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -2,11 +2,11 @@ <!-- Base application theme. --> <style name="Theme.WorkoutWarrior" parent="Theme.MaterialComponents.DayNight.DarkActionBar"> <!-- Primary brand color. --> - <item name="colorPrimary">@color/orange</item> + <item name="colorPrimary">@color/bwhite</item> <item name="colorPrimaryVariant">@color/black</item> <item name="colorOnPrimary">@color/black</item> <!-- Secondary brand color. --> - <item name="colorSecondary">@color/black</item> + <item name="colorSecondary">@color/bwhite</item> <item name="colorSecondaryVariant">@color/black</item> <item name="colorOnSecondary">@color/orange</item> <!-- Status bar color. -->