Skip to content
Extraits de code Groupes Projets

Comparer les révisions

Les modifications sont affichées comme si la révision source était fusionnée avec la révision cible. En savoir plus sur la comparaison des révisions.

Source

Sélectionner le projet cible
No results found

Cible

Sélectionner le projet cible
  • schamrotha/LEPL1509-Projet
1 résultat
Afficher les modifications
Validations sur la source (8)
Affichage de
avec 109 ajouts et 59 suppressions
......@@ -2,6 +2,7 @@ package be.lepl1509group13.workoutwarrior;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Typeface;
import android.os.Bundle;
import android.widget.AdapterView;
import android.content.Context;
......@@ -12,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;
......@@ -32,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;
......@@ -68,6 +75,7 @@ public class ProgramCreationActivity extends AppCompatActivity {
public static int lastCheckedPosition = -1;
ArrayList<String> currentExoList = new ArrayList<>();
ArrayList<TextView> days_TextView = new ArrayList<>();
@Override
......@@ -76,6 +84,9 @@ public class ProgramCreationActivity extends AppCompatActivity {
setContentView(R.layout.program_creation);
getSupportActionBar().hide();
init_days_TextView();
((TextView) findViewById(R.id.textview_monday)).setTypeface(Typeface.DEFAULT, Typeface.BOLD);
db = firebaseDb.getReference("Workouts");
get_DB_Exercices();
......@@ -127,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();
}
});
}
......@@ -162,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();
}
......@@ -219,6 +246,19 @@ public class ProgramCreationActivity extends AppCompatActivity {
System.out.println(exoDetailsForEachDay);
}
void init_days_TextView() {
/**
* Ajoute à days_TextView tous les TextView des jours
*/
days_TextView.add(findViewById(R.id.textview_monday));
days_TextView.add(findViewById(R.id.textview_tuesday));
days_TextView.add(findViewById(R.id.textview_wednesday));
days_TextView.add(findViewById(R.id.textview_thursday));
days_TextView.add(findViewById(R.id.textview_friday));
days_TextView.add(findViewById(R.id.textview_saturday));
days_TextView.add(findViewById(R.id.textview_sunday));
}
private void addExerciceListener() {
......@@ -364,6 +404,12 @@ public class ProgramCreationActivity extends AppCompatActivity {
public void onNewDayTextClick(View view){
current_day_displayed = (String) view.getTag();
TextView day = (TextView) view;
for (TextView text : days_TextView) {
if (text.getTypeface().isBold()) text.setTypeface(Typeface.DEFAULT, Typeface.NORMAL);
}
day.setTypeface(Typeface.DEFAULT, Typeface.BOLD);
ArrayList<Exercise> exoList = exoDetailsForEachDay.get(current_day_displayed);
......@@ -378,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;
......@@ -396,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
<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>
......@@ -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"
......
......@@ -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"
......
......@@ -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" />
......
......@@ -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"
......
......@@ -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" />
......
<?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>
......
......@@ -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"
......
......@@ -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"
......
......@@ -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
......@@ -239,7 +238,7 @@
android:fontFamily="@font/poppins"
android:onClick="onNewDayTextClick"
android:tag="mercredi"
android:text="Mercre"
android:text="Mercredi"
android:textColor="@color/black"
android:textSize="15dp" />
......@@ -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>
......
......@@ -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
......@@ -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. -->
......