2 Commits

71 changed files with 159 additions and 129 deletions

View File

@@ -10,8 +10,8 @@ android {
applicationId "com.stock.pignon" applicationId "com.stock.pignon"
minSdkVersion 17 minSdkVersion 17
targetSdkVersion 36 targetSdkVersion 36
versionCode 5 versionCode 7
versionName "0.5.0" versionName "0.5.2"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

View File

Before

Width:  |  Height:  |  Size: 6.4 KiB

After

Width:  |  Height:  |  Size: 6.4 KiB

View File

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

View File

Before

Width:  |  Height:  |  Size: 9.7 KiB

After

Width:  |  Height:  |  Size: 9.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 288 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

View File

Before

Width:  |  Height:  |  Size: 8.0 KiB

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

View File

Before

Width:  |  Height:  |  Size: 5.8 KiB

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

View File

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

Before

Width:  |  Height:  |  Size: 7.0 KiB

After

Width:  |  Height:  |  Size: 7.0 KiB

View File

Before

Width:  |  Height:  |  Size: 9.5 KiB

After

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

View File

Before

Width:  |  Height:  |  Size: 5.8 KiB

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

View File

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB

View File

Before

Width:  |  Height:  |  Size: 7.0 KiB

After

Width:  |  Height:  |  Size: 7.0 KiB

View File

Before

Width:  |  Height:  |  Size: 7.9 KiB

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View File

Before

Width:  |  Height:  |  Size: 8.6 KiB

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

View File

Before

Width:  |  Height:  |  Size: 5.9 KiB

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

View File

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View File

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View File

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.4 KiB

View File

Before

Width:  |  Height:  |  Size: 5.0 KiB

After

Width:  |  Height:  |  Size: 5.0 KiB

View File

Before

Width:  |  Height:  |  Size: 6.6 KiB

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View File

Before

Width:  |  Height:  |  Size: 7.4 KiB

After

Width:  |  Height:  |  Size: 7.4 KiB

View File

@@ -8,10 +8,11 @@
"bgColor": "#FF0000", "bgColor": "#FF0000",
"textColor": "#000000", "textColor": "#000000",
"items": [ "items": [
{"name": "Vélo", "minPrice": 20, "maxPrice": 40, "image": "velo"},
{"name": "Cadre", "minPrice": 20, "maxPrice": 40, "image": "cadre"}, {"name": "Cadre", "minPrice": 20, "maxPrice": 40, "image": "cadre"},
{"name": "Selle", "minPrice": 1, "maxPrice": 7, "image": "selle"}, {"name": "Selle", "minPrice": 1, "maxPrice": 7, "image": "selle"},
{"name": "Tige de selle", "minPrice": 1, "maxPrice": 10, "image": "tigeselle"}, {"name": "Tige de selle", "minPrice": 1, "maxPrice": 10, "image": "tige_selle"},
{"name": "Collier de selle", "minPrice": 1, "maxPrice": 4, "image": "collierselle"} {"name": "Collier de selle", "minPrice": 1, "maxPrice": 4, "image": "collier_selle"}
] ]
}, },
{ {
@@ -20,10 +21,14 @@
"textColor": "#000000", "textColor": "#000000",
"items": [ "items": [
{"name": "Fourche", "minPrice": 10, "maxPrice": 20, "image": "fourche"}, {"name": "Fourche", "minPrice": 10, "maxPrice": 20, "image": "fourche"},
{"name": "Jeu de direction", "minPrice": 1, "maxPrice": 8, "image": "jeudirection"}, {"name": "Fourche suspendue", "minPrice": 10, "maxPrice": 20, "image": "fourche_suspendue"},
{"name": "Potence headset", "minPrice": 2, "maxPrice": 8, "image": "potenceheadset"}, {"name": "Roulement direction", "minPrice": 1, "maxPrice": 8, "image": "roulement_direction"},
{"name": "Potence plongeur", "minPrice": 2, "maxPrice": 8, "image": "potenceplongeur"}, {"name": "Jeu de direction", "minPrice": 1, "maxPrice": 8, "image": "jeu_direction"},
{"name": "Tige plongeur", "minPrice": 1, "maxPrice": 4, "image": "tigeplongeur"} {"name": "Potence headset", "minPrice": 2, "maxPrice": 8, "image": "potence_headset"},
{"name": "Potence headset réglable", "minPrice": 2, "maxPrice": 8, "image": "potence_headset_reglable"},
{"name": "Potence plongeur", "minPrice": 2, "maxPrice": 8, "image": "potence_plongeur"},
{"name": "Potence plongeur réglable", "minPrice": 2, "maxPrice": 8, "image": "potence_plongeur_reglable"},
{"name": "Tige plongeur", "minPrice": 1, "maxPrice": 4, "image": "tige_plongeur"}
] ]
}, },
{ {
@@ -31,13 +36,14 @@
"bgColor": "#F16000", "bgColor": "#F16000",
"textColor": "#000000", "textColor": "#000000",
"items": [ "items": [
{"name": "Poignée combo", "minPrice": 2, "maxPrice": 8, "image": "poigneecombo"}, {"name": "Poignée combo", "minPrice": 2, "maxPrice": 8, "image": "poignee_combo"},
{"name": "Poignée frein", "minPrice": 2, "maxPrice": 8, "image": "poigneefrein"}, {"name": "Poignée frein", "minPrice": 2, "maxPrice": 8, "image": "poignee_frein"},
{"name": "Poignée gachette", "minPrice": 2, "maxPrice": 8, "image": "poigneegachette"}, {"name": "Poignée gachette", "minPrice": 2, "maxPrice": 8, "image": "poignee_gachette"},
{"name": "Poignée tournante", "minPrice": 2, "maxPrice": 6, "image": "poigneetournante"}, {"name": "Poignée tournante", "minPrice": 2, "maxPrice": 6, "image": "poignee_tournante"},
{"name": "Manette cadre", "minPrice": 2, "maxPrice": 6, "image": "manette_cadre"},
{"name": "Gaine", "minPrice": 0, "maxPrice": 2, "image": "gaine"}, {"name": "Gaine", "minPrice": 0, "maxPrice": 2, "image": "gaine"},
{"name": "Câble", "minPrice": 0, "maxPrice": 1, "image": "cable"}, {"name": "Câble", "minPrice": 0, "maxPrice": 1, "image": "cable"},
{"name": "Poignée", "minPrice": 1, "maxPrice": 4, "image": "poignees"}, {"name": "Poignée", "minPrice": 1, "maxPrice": 4, "image": "poignee"},
{"name": "Cintre", "minPrice": 5, "maxPrice": 10,"image": "cintre"} {"name": "Cintre", "minPrice": 5, "maxPrice": 10,"image": "cintre"}
] ]
}, },
@@ -46,11 +52,15 @@
"bgColor": "#FF00FF", "bgColor": "#FF00FF",
"textColor": "#000000", "textColor": "#000000",
"items": [ "items": [
{"name": "Étrier patin", "minPrice": 2, "maxPrice": 8, "image": "etrierpatin"}, {"name": "Étrier V-brake", "minPrice": 2, "maxPrice": 8, "image": "etrier_vbrake"},
{"name": "Étrier disque", "minPrice": 2, "maxPrice": 8, "image": "etrierdisque"}, {"name": "Étrier Cantilever", "minPrice": 2, "maxPrice": 8, "image": "etrier_cantilever"},
{"name": "Étrier Caliper ou Mafac", "minPrice": 2, "maxPrice": 8, "image": "etrier_mafac_caliper"},
{"name": "Étrier disque câble", "minPrice": 2, "maxPrice": 8, "image": "etrier_cable"},
{"name": "Étrier disque hydraulique", "minPrice": 2, "maxPrice": 8, "image": "etrier_hydraulique"},
{"name": "Patins", "minPrice": 1, "maxPrice": 2, "image": "patins"}, {"name": "Patins", "minPrice": 1, "maxPrice": 2, "image": "patins"},
{"name": "Disque", "minPrice": 1, "maxPrice": 5, "image": "disque"}, {"name": "Disque", "minPrice": 1, "maxPrice": 5, "image": "disque"},
{"name": "Visserie frein", "minPrice": 0, "maxPrice": 1, "image": "visseriefrein"} {"name": "Pont central cantilever", "minPrice": 0, "maxPrice": 1, "image": "frein_pontcentral"},
{"name": "Visserie frein", "minPrice": 0, "maxPrice": 1, "image": "visserie_frein"}
] ]
}, },
{ {
@@ -58,15 +68,23 @@
"bgColor": "#0000FF", "bgColor": "#0000FF",
"textColor": "#FFFFFF", "textColor": "#FFFFFF",
"items": [ "items": [
{"name": "Roue avant", "minPrice": 20, "maxPrice": 40, "image": "roueavant"}, {"name": "Chambre à air", "minPrice": 20, "maxPrice": 40, "image": "chambre_air"},
{"name": "Roue arrière", "minPrice": 20, "maxPrice": 40, "image": "rouearriere"}, {"name": "Roue avant", "minPrice": 20, "maxPrice": 40, "image": "roue_avant"},
{"name": "Axe rapide", "minPrice": 1, "maxPrice": 2, "image": "axerapide"}, {"name": "Roue arrière", "minPrice": 20, "maxPrice": 40, "image": "roue_arriere"},
{"name": "Axe roue", "minPrice": 1, "maxPrice": 3, "image": "axeroue"}, {"name": "Axe rapide", "minPrice": 1, "maxPrice": 2, "image": "axe_rapide"},
{"name": "Axe roue", "minPrice": 1, "maxPrice": 3, "image": "axe_roue"},
{"name": "Rayon", "minPrice": 0, "maxPrice": 2, "image": "rayon"}, {"name": "Rayon", "minPrice": 0, "maxPrice": 2, "image": "rayon"},
{"name": "Moyeu avant", "minPrice": 2, "maxPrice": 8, "image": "moyeuavant"}, {"name": "Jante", "minPrice": 0, "maxPrice": 2, "image": "jante"},
{"name": "Moyeu arrière", "minPrice": 2, "maxPrice": 10, "image": "moyeuarriere"}, {"name": "Fond de jante", "minPrice": 0, "maxPrice": 2, "image": "fond_jante"},
{"name": "Pneu", "minPrice": 10, "maxPrice": 20, "image": "pneu"}, {"name": "Moyeu avant", "minPrice": 2, "maxPrice": 8, "image": "moyeu_avant"},
{"name": "Visserie roue", "minPrice": 0, "maxPrice": 1, "image": "visserieroue"} {"name": "Moyeu arrière cassette", "minPrice": 2, "maxPrice": 10, "image": "moyeu_arriere_cassette"},
{"name": "Moyeu arrière roue libre", "minPrice": 2, "maxPrice": 10, "image": "moyeu_arriere_rouelibre"},
{"name": "Moyeu arrière rétropédalage", "minPrice": 2, "maxPrice": 10, "image": "moyeu_retropedalage"},
{"name": "Pneu petite taille", "minPrice": 10, "maxPrice": 20, "image": "pneu_petit"},
{"name": "Pneu 26\"", "minPrice": 10, "maxPrice": 20, "image": "pneu_26"},
{"name": "Pneu 28\" route", "minPrice": 10, "maxPrice": 20, "image": "pneu_route"},
{"name": "Pneu 28\" large", "minPrice": 10, "maxPrice": 20, "image": "pneu_large"},
{"name": "Visserie roue", "minPrice": 0, "maxPrice": 1, "image": "visserie_roue"}
] ]
}, },
{ {
@@ -74,12 +92,13 @@
"bgColor": "#FFCC00", "bgColor": "#FFCC00",
"textColor": "#000000", "textColor": "#000000",
"items": [ "items": [
{"name": "Dérailleur avant", "minPrice": 2, "maxPrice": 10, "image": "fd"}, {"name": "Dérailleur arrière", "minPrice": 2, "maxPrice": 10, "image": "derailleur_arriere"},
{"name": "Dérailleur arrière", "minPrice": 4, "maxPrice": 12, "image": "rd"}, {"name": "Dérailleur avant tirage bas", "minPrice": 4, "maxPrice": 12, "image": "derailleur_avant_tiragebas"},
{"name": "Dérailleur avant tirage haut", "minPrice": 4, "maxPrice": 12, "image": "derailleur_avant_tiragebas"},
{"name": "Cassette", "minPrice": 2, "maxPrice": 6, "image": "cassette"}, {"name": "Cassette", "minPrice": 2, "maxPrice": 6, "image": "cassette"},
{"name": "Roue libre", "minPrice": 2, "maxPrice": 6, "image": "rouelibre"}, {"name": "Roue libre", "minPrice": 2, "maxPrice": 6, "image": "roue_libre"},
{"name": "Chaîne", "minPrice": 2, "maxPrice": 6, "image": "chaine"}, {"name": "Chaîne", "minPrice": 2, "maxPrice": 6, "image": "chaine"},
{"name": "Visserie transmission", "minPrice": 0, "maxPrice": 1, "image": "visserietransmission"} {"name": "Visserie transmission", "minPrice": 0, "maxPrice": 1, "image": "visserie_transmission"}
] ]
}, },
{ {
@@ -87,13 +106,17 @@
"bgColor": "#00FFFF", "bgColor": "#00FFFF",
"textColor": "#000000", "textColor": "#000000",
"items": [ "items": [
{"name": "Boîtier pédalier", "minPrice": 4, "maxPrice": 12, "image": "boitierpedalier"}, {"name": "Axe pédalier carré ou clavette", "minPrice": 4, "maxPrice": 12, "image": "axe_pedalier"},
{"name": "Manivelle gauche", "minPrice": 4, "maxPrice": 12, "image": "manivellegauche"}, {"name": "Roulement pédalier", "minPrice": 4, "maxPrice": 12, "image": "roulement_pedalier"},
{"name": "Manivelle droite", "minPrice": 4, "maxPrice": 12, "image": "manivelledroite"}, {"name": "Boîtier pédalier cartouche", "minPrice": 4, "maxPrice": 12, "image": "boitier_cartouche"},
{"name": "Pédalier complet", "minPrice": 6, "maxPrice": 15, "image": "pedaliercomplet"}, {"name": "Boîtier pédalier Hollowtech 2", "minPrice": 4, "maxPrice": 12, "image": "boitier_hollowtech"},
{"name": "Manivelle gauche", "minPrice": 4, "maxPrice": 12, "image": "manivelle_gauche"},
{"name": "Manivelle droite", "minPrice": 4, "maxPrice": 12, "image": "manivelle_droite"},
{"name": "Pédalier complet", "minPrice": 6, "maxPrice": 15, "image": "pedalier_complet"},
{"name": "Pédales", "minPrice": 2, "maxPrice": 8, "image": "pedales"}, {"name": "Pédales", "minPrice": 2, "maxPrice": 8, "image": "pedales"},
{"name": "Plateau", "minPrice": 2, "maxPrice": 8, "image": "plateau"}, {"name": "Plateau 4 branches", "minPrice": 2, "maxPrice": 8, "image": "plateau_4"},
{"name": "Visserie pédalier", "minPrice": 0, "maxPrice": 1, "image": "visseriepedalier"} {"name": "Plateau 5 branches", "minPrice": 2, "maxPrice": 8, "image": "plateau_5"},
{"name": "Visserie pédalier", "minPrice": 0, "maxPrice": 1, "image": "visserie_pedalier"}
] ]
}, },
{ {
@@ -102,10 +125,13 @@
"textColor": "#000000", "textColor": "#000000",
"items": [ "items": [
{"name": "Béquille", "minPrice": 2, "maxPrice": 8, "image": "bequille"}, {"name": "Béquille", "minPrice": 2, "maxPrice": 8, "image": "bequille"},
{"name": "Garde boue", "minPrice": 2, "maxPrice": 8, "image": "gardeboue"}, {"name": "Garde boue", "minPrice": 2, "maxPrice": 8, "image": "garde_boue"},
{"name": "Lampe", "minPrice": 1, "maxPrice": 5, "image": "lampe"}, {"name": "Lampe", "minPrice": 1, "maxPrice": 5, "image": "lampe"},
{"name": "Porte bagage", "minPrice": 2, "maxPrice": 10, "image": "portebagage"}, {"name": "Porte bagage", "minPrice": 2, "maxPrice": 10, "image": "porte_bagage"},
{"name": "Porte bidon", "minPrice": 0, "maxPrice": 1, "image": "portebidon"} {"name": "Porte bidon", "minPrice": 0, "maxPrice": 1, "image": "porte_bidon"},
{"name": "Pompe", "minPrice": 0, "maxPrice": 1, "image": "pompe"},
{"name": "Panier", "minPrice": 0, "maxPrice": 1, "image": "panier"},
{"name": "Rétroviseur", "minPrice": 0, "maxPrice": 1, "image": "retroviseur"}
] ]
} }
] ]

View File

@@ -22,16 +22,9 @@ import java.util.List;
public class CartViewHelper { public class CartViewHelper {
/** /**
* Short version for app resume : update without changing validate/back button state * Refreshes cart UI by synchronizing the visual list with the current CartManager state
*/ */
public static void updateCartView(LinearLayout cartList, Context context) { public static void updateCartView(LinearLayout cartList, Context context) {
updateCartView(cartList, context, false, false);
}
/**
* Full version with validate/back button management
*/
public static void updateCartView(LinearLayout cartList, Context context, boolean updateButton, boolean isHome) {
if (cartList == null) return; if (cartList == null) return;
// Clean item lists // Clean item lists
@@ -60,11 +53,6 @@ public class CartViewHelper {
} }
updateTotalDisplay(context, totalMin, totalMax); updateTotalDisplay(context, totalMin, totalMax);
} }
// Update validate/back button
if (updateButton && context instanceof MainActivity) {
((MainActivity) context).updateActionButton(isHome);
}
} }
/** /**

View File

@@ -12,6 +12,7 @@ import android.widget.Button;
import android.widget.GridLayout; import android.widget.GridLayout;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.FrameLayout;
import android.widget.TextView; import android.widget.TextView;
import android.os.Environment; import android.os.Environment;
import java.io.File; import java.io.File;
@@ -35,7 +36,7 @@ public class MainActivity extends AppCompatActivity {
// UI components // UI components
private LinearLayout cartList; private LinearLayout cartList;
private LinearLayout homeLayout; private LinearLayout homeLayout;
private LinearLayout categoryItemsLayout; private FrameLayout categoryItemsLayout;
private LinearLayout categoriesLayout; private LinearLayout categoriesLayout;
private GridLayout gridPieces; private GridLayout gridPieces;
private ImageView mainImage; private ImageView mainImage;
@@ -93,7 +94,7 @@ public class MainActivity extends AppCompatActivity {
server.start(); server.start();
String url = "http://" + getDeviceIP() + ":8080"; String url = "http://" + getDeviceIP() + ":8080";
// On met l'URL directement dans le sous-titre de l'ActionBar // Print URL in action bar for user
if (getSupportActionBar() != null) { if (getSupportActionBar() != null) {
getSupportActionBar().setSubtitle("Serveur en ligne : " + url + " - " + versionName); getSupportActionBar().setSubtitle("Serveur en ligne : " + url + " - " + versionName);
} }
@@ -103,6 +104,24 @@ public class MainActivity extends AppCompatActivity {
getSupportActionBar().setSubtitle("Erreur serveur" + " - " + versionName); getSupportActionBar().setSubtitle("Erreur serveur" + " - " + versionName);
} }
} }
// Back button (blue)
Button btnBack = findViewById(R.id.btnBackFromCategory);
if (btnBack != null) {
btnBack.setOnClickListener(v -> showHome());
}
// Empty button (red)
Button btnClear = findViewById(R.id.clearCartBtn);
if (btnClear != null) {
btnClear.setOnClickListener(v -> CartActionHelper.emptyCart(cartList, this));
}
// Validate button (green)
Button btnValidate = findViewById(R.id.validateCartBtn);
if (btnValidate != null) {
btnValidate.setOnClickListener(v -> CartActionHelper.validateCart(cartList, this));
}
} }
@Override @Override
@@ -194,8 +213,6 @@ public class MainActivity extends AppCompatActivity {
homeLayout.setVisibility(View.GONE); homeLayout.setVisibility(View.GONE);
categoryItemsLayout.setVisibility(View.VISIBLE); categoryItemsLayout.setVisibility(View.VISIBLE);
updateActionButton(false);
gridPieces.removeAllViews(); gridPieces.removeAllViews();
// Calculate item width for a 4-column grid // Calculate item width for a 4-column grid
@@ -265,8 +282,6 @@ public class MainActivity extends AppCompatActivity {
public void showHome() { public void showHome() {
categoryItemsLayout.setVisibility(View.GONE); categoryItemsLayout.setVisibility(View.GONE);
homeLayout.setVisibility(View.VISIBLE); homeLayout.setVisibility(View.VISIBLE);
updateActionButton(true);
} }
private void loadMainImage() { private void loadMainImage() {
@@ -274,31 +289,6 @@ public class MainActivity extends AppCompatActivity {
ImageLoader.loadImage(mainImage, "_velo", 800,800); ImageLoader.loadImage(mainImage, "_velo", 800,800);
} }
public void emptyCart(View view) {
CartActionHelper.emptyCart(cartList, this);
}
public void validateCart(View view) {
CartActionHelper.validateCart(cartList, this);
}
public void updateActionButton(boolean isHome) {
Button btn = findViewById(R.id.validateCartBtn);
if (btn == null) return;
if (isHome) {
// Home mode : validate button
btn.setText(getString(R.string.cart_validate_btn));
btn.setBackgroundColor(Color.parseColor("#43A047")); // Vert
btn.setOnClickListener(v -> validateCart(v));
} else {
// Category mode : back button
btn.setText(getString(R.string.cart_back_btn));
btn.setBackgroundColor(Color.parseColor("#1E88E5")); // Bleu
btn.setOnClickListener(v -> showHome());
}
}
private int dpToPx(int dp) { private int dpToPx(int dp) {
return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, getResources().getDisplayMetrics()); return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, getResources().getDisplayMetrics());
} }

View File

@@ -1,12 +1,13 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- activity_main.xml --> <!-- activity_main.xml -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout 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_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="horizontal" android:orientation="horizontal"
android:background="#ffffff"> android:background="#ffffff"
android:baselineAligned="false"> <FrameLayout
<FrameLayout
android:id="@+id/contentFrame" android:id="@+id/contentFrame"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="match_parent"
@@ -17,9 +18,9 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="horizontal" android:orientation="horizontal"
android:paddingLeft="20dp"> android:paddingStart="20dp"
android:paddingEnd="20dp"
<LinearLayout tools:ignore="RtlSymmetry"> <LinearLayout
android:id="@+id/categoriesLayout" android:id="@+id/categoriesLayout"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
@@ -31,27 +32,49 @@
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="1" android:layout_weight="1"
android:scaleType="fitCenter" /> android:scaleType="fitCenter"
</LinearLayout> android:contentDescription="@string/app_name" /> </LinearLayout>
<LinearLayout <FrameLayout
android:id="@+id/categoryItemsLayout" android:id="@+id/categoryItemsLayout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical" android:visibility="gone">
android:visibility="gone"
android:padding="10dp">
<ScrollView <ScrollView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent"
android:padding="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<GridLayout <GridLayout
android:id="@+id/gridPieces" android:id="@+id/gridPieces"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:columnCount="4" /> android:columnCount="4" />
</ScrollView>
<View
android:layout_width="match_parent"
android:layout_height="100dp" />
</LinearLayout> </LinearLayout>
</ScrollView>
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/btnBackFromCategory"
android:layout_width="200dp"
android:layout_height="70dp"
android:layout_gravity="bottom|start"
android:layout_margin="20dp"
android:text="@string/cart_back_btn"
android:textSize="20sp"
android:textStyle="bold"
android:textColor="#FFFFFF"
app:backgroundTint="#1E88E5"
android:elevation="8dp"
tools:targetApi="l" />
</FrameLayout>
</FrameLayout> </FrameLayout>
<include layout="@layout/partial_cart" /> <include layout="@layout/partial_cart" />

View File

@@ -19,13 +19,15 @@
<TextView <TextView
android:id="@+id/itemName" android:id="@+id/itemName"
android:layout_width="wrap_content" android:layout_width="150dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
tools:text="Item name" tools:text="Item name"
android:textSize="20sp" android:textSize="20sp"
android:layout_marginTop="0dp" android:layout_marginTop="0dp"
android:lines="1" android:minLines="2"
android:ellipsize="end" /> android:maxLines="2"
android:ellipsize="end"
android:gravity="center"/>
<TextView <TextView
android:id="@+id/itemPrice" android:id="@+id/itemPrice"

View File

@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- partial_panier.xml --> <!-- partial_panier.xml -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/cartContainer" android:id="@+id/cartContainer"
android:layout_width="350dp" android:layout_width="350dp"
android:layout_height="match_parent" android:layout_height="match_parent"
@@ -56,29 +57,29 @@
android:orientation="horizontal" android:orientation="horizontal"
android:weightSum="2"> android:weightSum="2">
<Button <androidx.appcompat.widget.AppCompatButton
android:id="@+id/clearCartBtn" android:id="@+id/clearCartBtn"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_weight="1" android:layout_weight="1"
android:layout_height="60dp" android:layout_height="70dp"
android:text="@string/cart_empty_btn" android:text="@string/cart_empty_btn"
android:textSize="18sp" android:textSize="18sp"
android:textStyle="bold"
android:textColor="#FFFFFF" android:textColor="#FFFFFF"
android:background="#E53935" app:backgroundTint="#E53935"
android:layout_marginEnd="5dp" android:layout_marginEnd="5dp"/>
android:onClick="emptyCart"/>
<Button <androidx.appcompat.widget.AppCompatButton
android:id="@+id/validateCartBtn" android:id="@+id/validateCartBtn"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_weight="1" android:layout_weight="1"
android:layout_height="60dp" android:layout_height="70dp"
android:text="@string/cart_validate_btn" android:text="@string/cart_validate_btn"
android:textSize="18sp" android:textSize="18sp"
android:textStyle="bold"
android:textColor="#FFFFFF" android:textColor="#FFFFFF"
android:background="#43A047" app:backgroundTint="#43A047"
android:layout_marginStart="5dp" android:layout_marginStart="5dp"/>
android:onClick="validateCart"/>
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>