diff --git a/.idea/misc.xml b/.idea/misc.xml index 082568d876e7c3ebf113cc4188629a4f4a2de8ac..e44ff7ad645267c3208b32beff4a3dbf0760b2bd 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -4,14 +4,11 @@ <option name="filePathToZoomLevelMap"> <map> <entry key="..\:/Git/application-android-iut/app/src/main/res/layout-land/activity_main.xml" value="0.19635416666666666" /> + <entry key="..\:/Git/application-android-iut/app/src/main/res/layout-land/fragment_frag_horizontal_layout.xml" value="0.11197916666666667" /> <entry key="..\:/Git/application-android-iut/app/src/main/res/layout/activity_main.xml" value="0.176" /> <entry key="..\:/Git/application-android-iut/app/src/main/res/layout/activity_num_table.xml" value="0.264" /> - <entry key="..\:/Users/sofia/Documents/GitHub/application-android-iut/app/src/main/res/layout-land/activity_main.xml" value="0.21516754850088182" /> - <entry key="..\:/Users/sofia/Documents/GitHub/application-android-iut/app/src/main/res/layout-land/fragment_frag_horizontal_layout.xml" value="0.1" /> - <entry key="..\:/Users/sofia/Documents/GitHub/application-android-iut/app/src/main/res/layout/activity_main.xml" value="0.11302083333333333" /> - <entry key="..\:/Users/sofia/Documents/GitHub/application-android-iut/app/src/main/res/layout/activity_num_table.xml" value="0.24547101449275363" /> - <entry key="..\:/Users/sofia/Documents/GitHub/application-android-iut/app/src/main/res/layout/fragment_frag_horizontal_layout.xml" value="0.1" /> - <entry key="..\:/Users/sofia/Documents/GitHub/application-android-iut/app/src/main/res/layout/fragment_frag_vertical_layout.xml" value="0.1" /> + <entry key="..\:/Git/application-android-iut/app/src/main/res/layout/fragment_frag_vertical_layout.xml" value="0.1" /> + <entry key="..\:/Git/application-android-iut/app/src/main/res/layout/fragment_pizza_custom_vertical.xml" value="0.176" /> <entry key="..\:/Z IUT Orsay/AndroidStudioProjects/Pizzeria/app/src/main/res/layout-land/activity_main.xml" value="0.1" /> <entry key="..\:/Z IUT Orsay/AndroidStudioProjects/Pizzeria/app/src/main/res/layout/activity_main.xml" value="0.2" /> </map> diff --git a/app/src/main/java/com/slprojects/pizzeria/FragCustomPizza.java b/app/src/main/java/com/slprojects/pizzeria/FragCustomPizza.java new file mode 100644 index 0000000000000000000000000000000000000000..b971bc184cd7940e44301803734fb4ea63345258 --- /dev/null +++ b/app/src/main/java/com/slprojects/pizzeria/FragCustomPizza.java @@ -0,0 +1,16 @@ +package com.slprojects.pizzeria; + +import android.app.Fragment; +import android.os.Bundle; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +public class FragCustomPizza extends Fragment { + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + View view = inflater.inflate(R.layout.fragment_pizza_custom_vertical, container, false); + return view; + } +} diff --git a/app/src/main/java/com/slprojects/pizzeria/MainActivity.java b/app/src/main/java/com/slprojects/pizzeria/MainActivity.java index a871860d758d0582a19120267be45c502ffcd047..3b9a6a21292ad83e089682e3b1d71ff087275cef 100644 --- a/app/src/main/java/com/slprojects/pizzeria/MainActivity.java +++ b/app/src/main/java/com/slprojects/pizzeria/MainActivity.java @@ -11,6 +11,7 @@ import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.Button; +import android.widget.FrameLayout; import android.widget.TextView; import java.util.ArrayList; @@ -66,6 +67,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe boutons.add(frag.getView().findViewById(R.id.hawaii)); boutons.add(frag.getView().findViewById(R.id.pannaCotta)); boutons.add(frag.getView().findViewById(R.id.tiramisu)); + boutons.add(frag.getView().findViewById(R.id.pizzaperso)); // On ajoute un listener sur chaque bouton boutons.forEach((btn) -> btn.setOnClickListener(this)); @@ -96,15 +98,35 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe public void onClick(View v) { try{ - Button bouton = boutons.get(idIndexes.indexOf(v.getId())); - numCommands.set(idIndexes.indexOf(v.getId()), numCommands.get(idIndexes.indexOf(v.getId()))+1); - setButtonText(bouton); - - String message = numTable+nomBoutons.get(idIndexes.indexOf(v.getId())); - tacheDeFond = new backTasks(); - tacheDeFond.execute(message); - // Envoie de la commande - //tacheDeFond.registerCommand(numTable+nomBoutons.get(idIndexes.indexOf(v.getId()))); + if(v.getId() == R.id.pizzaperso){ + // On vide la vue du fragment + FrameLayout fl= findViewById(R.id.fragment_vertical_layout); + fl.removeAllViews(); + // On va afficher le fragment de la piza perso + FragCustomPizza customPizzaFrag = new FragCustomPizza(); + FragmentTransaction transaction = getFragmentManager().beginTransaction(); + transaction.add(R.id.fragment_vertical_layout, customPizzaFrag); + transaction.commit(); + }else if(v.getId() == R.id.btnValiderPizzaCustom) { + // On vide la vue du fragment + FrameLayout fl= findViewById(R.id.fragment_vertical_layout); + fl.removeAllViews(); + + // On affiche le fragment principal + FragmentTransaction transaction = getFragmentManager().beginTransaction(); + transaction.add(R.id.fragment_vertical_layout, frag); + transaction.commit(); + + } else { + Button bouton = boutons.get(idIndexes.indexOf(v.getId())); + numCommands.set(idIndexes.indexOf(v.getId()), numCommands.get(idIndexes.indexOf(v.getId()))+1); + setButtonText(bouton); + + String message = numTable+nomBoutons.get(idIndexes.indexOf(v.getId())); + // Envoie de la commande + tacheDeFond = new backTasks(); + tacheDeFond.execute(message); + } }catch ( Exception e ){ Log.e("Erreur", e.getMessage()); } diff --git a/app/src/main/res/layout/fragment_pizza_custom_vertical.xml b/app/src/main/res/layout/fragment_pizza_custom_vertical.xml new file mode 100644 index 0000000000000000000000000000000000000000..7bb431613cdb5c9620aa6450262d4a93935232b4 --- /dev/null +++ b/app/src/main/res/layout/fragment_pizza_custom_vertical.xml @@ -0,0 +1,147 @@ +<?xml version="1.0" encoding="utf-8"?> +<FrameLayout 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" + tools:context=".FragCustomPizza"> + + <androidx.constraintlayout.widget.ConstraintLayout + android:layout_width="match_parent" + android:layout_height="match_parent"> + + <LinearLayout + android:id="@+id/linearLayout1" + android:layout_width="match_parent" + android:layout_height="0dp" + android:orientation="horizontal" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintBottom_toTopOf="@+id/linearLayout2" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintEnd_toEndOf="parent" + tools:layout_editor_absoluteX="1dp"> + + <Button + android:id="@+id/mozzarella" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_marginEnd="5dp" + android:layout_weight="1" + android:backgroundTint="#E53935" + android:text="MOZZARELLA" /> + + <Button + android:id="@+id/gorgonzola" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_marginEnd="5dp" + android:layout_weight="1" + android:backgroundTint="#E53935" + android:text="GORGONZOLA" /> + </LinearLayout> + + <LinearLayout + android:id="@+id/linearLayout2" + android:layout_width="match_parent" + android:layout_height="0dp" + android:orientation="horizontal" + app:layout_constraintTop_toBottomOf="@+id/linearLayout1" + app:layout_constraintBottom_toTopOf="@+id/linearLayout3" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintEnd_toEndOf="parent" + tools:layout_editor_absoluteX="1dp"> + + <Button + android:id="@+id/anchois" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_marginEnd="5dp" + android:layout_weight="1" + android:backgroundTint="#FF6E40" + android:text="ANCHOIS" /> + + <Button + android:id="@+id/capres" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_marginEnd="5dp" + android:layout_weight="1" + android:backgroundTint="#FF6E40" + android:text="CÂPRES" /> + </LinearLayout> + + <LinearLayout + android:id="@+id/linearLayout3" + android:layout_width="match_parent" + android:layout_height="0dp" + android:orientation="horizontal" + app:layout_constraintTop_toBottomOf="@+id/linearLayout2" + app:layout_constraintBottom_toTopOf="@+id/linearLayout4" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintEnd_toEndOf="parent" + tools:layout_editor_absoluteX="1dp"> + + <Button + android:id="@+id/olives" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_marginEnd="5dp" + android:layout_weight="1" + android:backgroundTint="#009688" + android:text="OLIVES" /> + + <Button + android:id="@+id/artichauts" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_marginEnd="5dp" + android:layout_weight="1" + android:backgroundTint="#009688" + android:text="ARTICHAUTS" /> + </LinearLayout> + + <LinearLayout + android:id="@+id/linearLayout4" + android:layout_width="match_parent" + android:layout_height="0dp" + android:orientation="horizontal" + app:layout_constraintTop_toBottomOf="@+id/linearLayout3" + app:layout_constraintBottom_toTopOf="@+id/btnValiderPizzaCustom" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintEnd_toEndOf="parent" + tools:layout_editor_absoluteX="1dp"> + + <Button + android:id="@+id/merguezChipo" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_marginEnd="5dp" + android:layout_weight="1" + android:backgroundTint="#D32F2F" + android:text="MERGUEZ CHIPO" /> + + <Button + android:id="@+id/merguezPiquante" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_marginEnd="5dp" + android:layout_weight="1" + android:backgroundTint="#D32F2F" + android:text="MERGUEZ PIQUANTE" /> + </LinearLayout> + + <Button + android:id="@+id/btnValiderPizzaCustom" + android:layout_width="0dp" + android:layout_height="50dp" + android:layout_marginEnd="5dp" + android:layout_weight="1" + android:backgroundTint="#4CAF50" + android:text="VALIDER" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/linearLayout4" /> + </androidx.constraintlayout.widget.ConstraintLayout> + +</FrameLayout> \ No newline at end of file