Compare commits
3 Commits
v0.5.2
...
de2915064a
| Author | SHA1 | Date | |
|---|---|---|---|
| de2915064a | |||
| 48e66a539e | |||
| 432dd2a439 |
@@ -10,8 +10,8 @@ android {
|
|||||||
applicationId "com.stock.pignon"
|
applicationId "com.stock.pignon"
|
||||||
minSdkVersion 17
|
minSdkVersion 17
|
||||||
targetSdkVersion 36
|
targetSdkVersion 36
|
||||||
versionCode 7
|
versionCode 2
|
||||||
versionName "0.5.2"
|
versionName "0.2.0"
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
app/src/main/assets/images/FD.jpg
Normal file
|
After Width: | Height: | Size: 8.7 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 6.4 KiB After Width: | Height: | Size: 6.4 KiB |
|
Before Width: | Height: | Size: 5.5 KiB After Width: | Height: | Size: 5.5 KiB |
|
Before Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 9.7 KiB After Width: | Height: | Size: 9.7 KiB |
|
Before Width: | Height: | Size: 288 KiB |
|
Before Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 8.0 KiB After Width: | Height: | Size: 8.0 KiB |
|
Before Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 9.0 KiB |
|
Before Width: | Height: | Size: 9.5 KiB |
|
Before Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 9.3 KiB |
|
Before Width: | Height: | Size: 8.4 KiB |
|
Before Width: | Height: | Size: 5.8 KiB After Width: | Height: | Size: 5.8 KiB |
|
Before Width: | Height: | Size: 8.1 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 7.0 KiB After Width: | Height: | Size: 7.0 KiB |
|
Before Width: | Height: | Size: 9.5 KiB After Width: | Height: | Size: 9.5 KiB |
|
Before Width: | Height: | Size: 5.8 KiB After Width: | Height: | Size: 5.8 KiB |
|
Before Width: | Height: | Size: 8.5 KiB |
|
Before Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 14 KiB |
BIN
app/src/main/assets/images/pneu.jpg
Normal file
|
After Width: | Height: | Size: 9.0 KiB |
|
Before Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 8.3 KiB |
|
Before Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 9.6 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 7.0 KiB After Width: | Height: | Size: 7.0 KiB |
|
Before Width: | Height: | Size: 7.9 KiB After Width: | Height: | Size: 7.9 KiB |
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
BIN
app/src/main/assets/images/poignees.jpg
Normal file
|
After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 6.9 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 8.6 KiB After Width: | Height: | Size: 8.6 KiB |
|
Before Width: | Height: | Size: 5.9 KiB After Width: | Height: | Size: 5.9 KiB |
|
Before Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 7.7 KiB |
|
Before Width: | Height: | Size: 5.8 KiB |
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 7.4 KiB |
|
Before Width: | Height: | Size: 5.0 KiB After Width: | Height: | Size: 5.0 KiB |
|
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 6.6 KiB |
|
Before Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 7.4 KiB After Width: | Height: | Size: 7.4 KiB |
@@ -8,11 +8,10 @@
|
|||||||
"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": "tige_selle"},
|
{"name": "Tige de selle", "minPrice": 1, "maxPrice": 10, "image": "tigeselle"},
|
||||||
{"name": "Collier de selle", "minPrice": 1, "maxPrice": 4, "image": "collier_selle"}
|
{"name": "Collier de selle", "minPrice": 1, "maxPrice": 4, "image": "collierselle"}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -21,14 +20,10 @@
|
|||||||
"textColor": "#000000",
|
"textColor": "#000000",
|
||||||
"items": [
|
"items": [
|
||||||
{"name": "Fourche", "minPrice": 10, "maxPrice": 20, "image": "fourche"},
|
{"name": "Fourche", "minPrice": 10, "maxPrice": 20, "image": "fourche"},
|
||||||
{"name": "Fourche suspendue", "minPrice": 10, "maxPrice": 20, "image": "fourche_suspendue"},
|
{"name": "Jeu de direction", "minPrice": 1, "maxPrice": 8, "image": "jeudirection"},
|
||||||
{"name": "Roulement direction", "minPrice": 1, "maxPrice": 8, "image": "roulement_direction"},
|
{"name": "Potence headset", "minPrice": 2, "maxPrice": 8, "image": "potenceheadset"},
|
||||||
{"name": "Jeu de direction", "minPrice": 1, "maxPrice": 8, "image": "jeu_direction"},
|
{"name": "Potence plongeur", "minPrice": 2, "maxPrice": 8, "image": "potenceplongeur"},
|
||||||
{"name": "Potence headset", "minPrice": 2, "maxPrice": 8, "image": "potence_headset"},
|
{"name": "Tige plongeur", "minPrice": 1, "maxPrice": 4, "image": "tigeplongeur"}
|
||||||
{"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"}
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -36,14 +31,13 @@
|
|||||||
"bgColor": "#F16000",
|
"bgColor": "#F16000",
|
||||||
"textColor": "#000000",
|
"textColor": "#000000",
|
||||||
"items": [
|
"items": [
|
||||||
{"name": "Poignée combo", "minPrice": 2, "maxPrice": 8, "image": "poignee_combo"},
|
{"name": "Poignée combo", "minPrice": 2, "maxPrice": 8, "image": "poigneecombo"},
|
||||||
{"name": "Poignée frein", "minPrice": 2, "maxPrice": 8, "image": "poignee_frein"},
|
{"name": "Poignée frein", "minPrice": 2, "maxPrice": 8, "image": "poigneefrein"},
|
||||||
{"name": "Poignée gachette", "minPrice": 2, "maxPrice": 8, "image": "poignee_gachette"},
|
{"name": "Poignée gachette", "minPrice": 2, "maxPrice": 8, "image": "poigneegachette"},
|
||||||
{"name": "Poignée tournante", "minPrice": 2, "maxPrice": 6, "image": "poignee_tournante"},
|
{"name": "Poignée tournante", "minPrice": 2, "maxPrice": 6, "image": "poigneetournante"},
|
||||||
{"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": "poignee"},
|
{"name": "Poignée", "minPrice": 1, "maxPrice": 4, "image": "poignees"},
|
||||||
{"name": "Cintre", "minPrice": 5, "maxPrice": 10,"image": "cintre"}
|
{"name": "Cintre", "minPrice": 5, "maxPrice": 10,"image": "cintre"}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -52,15 +46,11 @@
|
|||||||
"bgColor": "#FF00FF",
|
"bgColor": "#FF00FF",
|
||||||
"textColor": "#000000",
|
"textColor": "#000000",
|
||||||
"items": [
|
"items": [
|
||||||
{"name": "Étrier V-brake", "minPrice": 2, "maxPrice": 8, "image": "etrier_vbrake"},
|
{"name": "Étrier patin", "minPrice": 2, "maxPrice": 8, "image": "etrierpatin"},
|
||||||
{"name": "Étrier Cantilever", "minPrice": 2, "maxPrice": 8, "image": "etrier_cantilever"},
|
{"name": "Étrier disque", "minPrice": 2, "maxPrice": 8, "image": "etrierdisque"},
|
||||||
{"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": "Pont central cantilever", "minPrice": 0, "maxPrice": 1, "image": "frein_pontcentral"},
|
{"name": "Visserie frein", "minPrice": 0, "maxPrice": 1, "image": "visseriefrein"}
|
||||||
{"name": "Visserie frein", "minPrice": 0, "maxPrice": 1, "image": "visserie_frein"}
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -68,23 +58,15 @@
|
|||||||
"bgColor": "#0000FF",
|
"bgColor": "#0000FF",
|
||||||
"textColor": "#FFFFFF",
|
"textColor": "#FFFFFF",
|
||||||
"items": [
|
"items": [
|
||||||
{"name": "Chambre à air", "minPrice": 20, "maxPrice": 40, "image": "chambre_air"},
|
{"name": "Roue avant", "minPrice": 20, "maxPrice": 40, "image": "roueavant"},
|
||||||
{"name": "Roue avant", "minPrice": 20, "maxPrice": 40, "image": "roue_avant"},
|
{"name": "Roue arrière", "minPrice": 20, "maxPrice": 40, "image": "rouearriere"},
|
||||||
{"name": "Roue arrière", "minPrice": 20, "maxPrice": 40, "image": "roue_arriere"},
|
{"name": "Axe rapide", "minPrice": 1, "maxPrice": 2, "image": "axerapide"},
|
||||||
{"name": "Axe rapide", "minPrice": 1, "maxPrice": 2, "image": "axe_rapide"},
|
{"name": "Axe roue", "minPrice": 1, "maxPrice": 3, "image": "axeroue"},
|
||||||
{"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": "Jante", "minPrice": 0, "maxPrice": 2, "image": "jante"},
|
{"name": "Moyeu avant", "minPrice": 2, "maxPrice": 8, "image": "moyeuavant"},
|
||||||
{"name": "Fond de jante", "minPrice": 0, "maxPrice": 2, "image": "fond_jante"},
|
{"name": "Moyeu arrière", "minPrice": 2, "maxPrice": 10, "image": "moyeuarriere"},
|
||||||
{"name": "Moyeu avant", "minPrice": 2, "maxPrice": 8, "image": "moyeu_avant"},
|
{"name": "Pneu", "minPrice": 10, "maxPrice": 20, "image": "pneu"},
|
||||||
{"name": "Moyeu arrière cassette", "minPrice": 2, "maxPrice": 10, "image": "moyeu_arriere_cassette"},
|
{"name": "Visserie roue", "minPrice": 0, "maxPrice": 1, "image": "visserieroue"}
|
||||||
{"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"}
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -92,13 +74,12 @@
|
|||||||
"bgColor": "#FFCC00",
|
"bgColor": "#FFCC00",
|
||||||
"textColor": "#000000",
|
"textColor": "#000000",
|
||||||
"items": [
|
"items": [
|
||||||
{"name": "Dérailleur arrière", "minPrice": 2, "maxPrice": 10, "image": "derailleur_arriere"},
|
{"name": "Dérailleur avant", "minPrice": 2, "maxPrice": 10, "image": "fd"},
|
||||||
{"name": "Dérailleur avant tirage bas", "minPrice": 4, "maxPrice": 12, "image": "derailleur_avant_tiragebas"},
|
{"name": "Dérailleur arrière", "minPrice": 4, "maxPrice": 12, "image": "rd"},
|
||||||
{"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": "roue_libre"},
|
{"name": "Roue libre", "minPrice": 2, "maxPrice": 6, "image": "rouelibre"},
|
||||||
{"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": "visserie_transmission"}
|
{"name": "Visserie transmission", "minPrice": 0, "maxPrice": 1, "image": "visserietransmission"}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -106,17 +87,13 @@
|
|||||||
"bgColor": "#00FFFF",
|
"bgColor": "#00FFFF",
|
||||||
"textColor": "#000000",
|
"textColor": "#000000",
|
||||||
"items": [
|
"items": [
|
||||||
{"name": "Axe pédalier carré ou clavette", "minPrice": 4, "maxPrice": 12, "image": "axe_pedalier"},
|
{"name": "Boîtier pédalier", "minPrice": 4, "maxPrice": 12, "image": "boitierpedalier"},
|
||||||
{"name": "Roulement pédalier", "minPrice": 4, "maxPrice": 12, "image": "roulement_pedalier"},
|
{"name": "Manivelle gauche", "minPrice": 4, "maxPrice": 12, "image": "manivellegauche"},
|
||||||
{"name": "Boîtier pédalier cartouche", "minPrice": 4, "maxPrice": 12, "image": "boitier_cartouche"},
|
{"name": "Manivelle droite", "minPrice": 4, "maxPrice": 12, "image": "manivelledroite"},
|
||||||
{"name": "Boîtier pédalier Hollowtech 2", "minPrice": 4, "maxPrice": 12, "image": "boitier_hollowtech"},
|
{"name": "Pédalier complet", "minPrice": 6, "maxPrice": 15, "image": "pedaliercomplet"},
|
||||||
{"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 4 branches", "minPrice": 2, "maxPrice": 8, "image": "plateau_4"},
|
{"name": "Plateau", "minPrice": 2, "maxPrice": 8, "image": "plateau"},
|
||||||
{"name": "Plateau 5 branches", "minPrice": 2, "maxPrice": 8, "image": "plateau_5"},
|
{"name": "Visserie pédalier", "minPrice": 0, "maxPrice": 1, "image": "visseriepedalier"}
|
||||||
{"name": "Visserie pédalier", "minPrice": 0, "maxPrice": 1, "image": "visserie_pedalier"}
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -125,13 +102,10 @@
|
|||||||
"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": "garde_boue"},
|
{"name": "Garde boue", "minPrice": 2, "maxPrice": 8, "image": "gardeboue"},
|
||||||
{"name": "Lampe", "minPrice": 1, "maxPrice": 5, "image": "lampe"},
|
{"name": "Lampe", "minPrice": 1, "maxPrice": 5, "image": "lampe"},
|
||||||
{"name": "Porte bagage", "minPrice": 2, "maxPrice": 10, "image": "porte_bagage"},
|
{"name": "Porte bagage", "minPrice": 2, "maxPrice": 10, "image": "portebagage"},
|
||||||
{"name": "Porte bidon", "minPrice": 0, "maxPrice": 1, "image": "porte_bidon"},
|
{"name": "Porte bidon", "minPrice": 0, "maxPrice": 1, "image": "portebidon"}
|
||||||
{"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"}
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.stock.pignon;
|
|||||||
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
@@ -21,8 +22,9 @@ import java.io.FileOutputStream;
|
|||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.OutputStreamWriter;
|
import java.io.OutputStreamWriter;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.util.ArrayList;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action on shopping cart: validation, clearing, and persistence
|
* Action on shopping cart: validation, clearing, and persistence
|
||||||
@@ -31,21 +33,6 @@ public class CartActionHelper {
|
|||||||
|
|
||||||
private static final String TAG = "CartActionHelper";
|
private static final String TAG = "CartActionHelper";
|
||||||
|
|
||||||
/**
|
|
||||||
* Data structure for JSON and CSV
|
|
||||||
*/
|
|
||||||
private static class StockEntry {
|
|
||||||
String date;
|
|
||||||
String name;
|
|
||||||
int qty;
|
|
||||||
|
|
||||||
StockEntry(String date, String name, int qty) {
|
|
||||||
this.date = date;
|
|
||||||
this.name = name;
|
|
||||||
this.qty = qty;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resets the cart data and refreshes UI
|
* Resets the cart data and refreshes UI
|
||||||
*/
|
*/
|
||||||
@@ -103,74 +90,6 @@ public class CartActionHelper {
|
|||||||
.show();
|
.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Merges current cart items with the existing stock file (json and csv) on the SD Card.
|
|
||||||
*/
|
|
||||||
private static void saveCartToExternalFile(List<CartItem> cartItems) {
|
|
||||||
File dir = new File(Environment.getExternalStorageDirectory(), Config.EXTERNAL_DIR_NAME);
|
|
||||||
File stockFile = new File(dir, Config.OUTPUT_JSON_NAME);
|
|
||||||
File csvFile = new File(dir, Config.OUTPUT_CSV_NAME);
|
|
||||||
|
|
||||||
String today = DateHelper.getTodayIso();
|
|
||||||
Gson gson = new Gson();
|
|
||||||
|
|
||||||
// Load previous list
|
|
||||||
List<StockEntry> history = loadHistory(stockFile, gson);
|
|
||||||
|
|
||||||
// Merge current cart items in previous list
|
|
||||||
for (CartItem cartItem : cartItems) {
|
|
||||||
boolean merged = false;
|
|
||||||
for (StockEntry entry : history) {
|
|
||||||
// Same date same name ? Add it
|
|
||||||
if (entry.date.equals(today) && entry.name.equals(cartItem.getName())) {
|
|
||||||
entry.qty += cartItem.getQuantity();
|
|
||||||
merged = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Not found on the same date ? Create it
|
|
||||||
if (!merged) {
|
|
||||||
history.add(new StockEntry(today, cartItem.getName(), cartItem.getQuantity()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Save to JSON
|
|
||||||
try (FileOutputStream fos = new FileOutputStream(stockFile);
|
|
||||||
OutputStreamWriter writer = new OutputStreamWriter(fos, "UTF-8")) {
|
|
||||||
gson.newBuilder().setPrettyPrinting().create().toJson(history, writer);
|
|
||||||
} catch (Exception e) {
|
|
||||||
Log.e(TAG, "Error writing JSON", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Save to CSV, french format with ";"
|
|
||||||
try (FileOutputStream fos = new FileOutputStream(csvFile);
|
|
||||||
OutputStreamWriter writer = new OutputStreamWriter(fos, "UTF-8")) {
|
|
||||||
writer.write('\ufeff');
|
|
||||||
writer.write("Date;Article;Quantité\n");
|
|
||||||
for (StockEntry entry : history) {
|
|
||||||
writer.write(entry.date + ";" + entry.name.replace(";", ",") + ";" + entry.qty + "\n");
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
Log.e(TAG, "Error writing CSV", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Load JSON history
|
|
||||||
*/
|
|
||||||
private static List<StockEntry> loadHistory(File file, Gson gson) {
|
|
||||||
if (!file.exists()) return new ArrayList<>();
|
|
||||||
try (InputStreamReader reader = new InputStreamReader(new FileInputStream(file), "UTF-8")) {
|
|
||||||
Type type = new TypeToken<List<StockEntry>>(){}.getType();
|
|
||||||
List<StockEntry> result = gson.fromJson(reader, type);
|
|
||||||
return (result != null) ? result : new ArrayList<>();
|
|
||||||
} catch (Exception e) {
|
|
||||||
Log.e(TAG, "Error reading json history", e);
|
|
||||||
return new ArrayList<>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays a thank you popup and returns to the main menu after 2 seconds.
|
* Displays a thank you popup and returns to the main menu after 2 seconds.
|
||||||
*/
|
*/
|
||||||
@@ -182,21 +101,80 @@ public class CartActionHelper {
|
|||||||
.create();
|
.create();
|
||||||
merciDialog.show();
|
merciDialog.show();
|
||||||
|
|
||||||
|
|
||||||
new Handler().postDelayed(() -> {
|
new Handler().postDelayed(() -> {
|
||||||
// Close dialog
|
// Close dialog
|
||||||
merciDialog.dismiss();
|
merciDialog.dismiss();
|
||||||
|
// Go to home if not already
|
||||||
if (activity instanceof MainActivity) {
|
if (!(activity instanceof MainActivity)) {
|
||||||
MainActivity main = (MainActivity) activity;
|
Intent intent = new Intent(activity, MainActivity.class);
|
||||||
// Go to home if not already
|
|
||||||
main.showHome();
|
|
||||||
// Clear the backstack so the user can't "go back" to a validated cart
|
// Clear the backstack so the user can't "go back" to a validated cart
|
||||||
GridLayout grid = main.findViewById(R.id.gridPieces);
|
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
||||||
refreshGridQuantities(grid);
|
activity.startActivity(intent);
|
||||||
}
|
}
|
||||||
}, 2000);
|
}, 2000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Merges current cart items with the existing stock file on the SD Card.
|
||||||
|
*/
|
||||||
|
private static void saveCartToExternalFile(List<CartItem> cartItems) {
|
||||||
|
File dir = new File(Environment.getExternalStorageDirectory(), Config.EXTERNAL_DIR_NAME);
|
||||||
|
File stockFile = new File(dir, Config.STOCK_FILE_NAME);
|
||||||
|
|
||||||
|
Gson gson = new Gson();
|
||||||
|
Map<String, Integer> stockMap;
|
||||||
|
|
||||||
|
// Load data into a Map (Key: Item Name, Value: Total Quantity)
|
||||||
|
stockMap = loadExistingStock(stockFile, gson);
|
||||||
|
|
||||||
|
// Merge with new items from current cart
|
||||||
|
for (CartItem item : cartItems) {
|
||||||
|
// Get previous quantity
|
||||||
|
Integer qtyObj = stockMap.get(item.getName());
|
||||||
|
int currentQty = (qtyObj != null) ? qtyObj : 0;
|
||||||
|
// Add
|
||||||
|
stockMap.put(item.getName(), currentQty + item.getQuantity());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Overwrite the file with updated data
|
||||||
|
// Needs WRITE_EXTERNAL_STORAGE permission
|
||||||
|
try (FileOutputStream fos = new FileOutputStream(stockFile);
|
||||||
|
@SuppressWarnings("CharsetObjectCanBeUsed")
|
||||||
|
OutputStreamWriter writer = new OutputStreamWriter(fos, "UTF-8")) {
|
||||||
|
|
||||||
|
// Writing directly to the stream
|
||||||
|
gson.toJson(stockMap, writer);
|
||||||
|
Log.i(TAG, "Stock updated successfully at: " + stockFile.getAbsolutePath());
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.e(TAG, "Failed to write stock file", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads the current stock file. If the file is missing or corrupted, returns an empty map.
|
||||||
|
*/
|
||||||
|
private static Map<String, Integer> loadExistingStock(File stockFile, Gson gson) {
|
||||||
|
if (!stockFile.exists()) return new HashMap<>();
|
||||||
|
|
||||||
|
try (FileInputStream fis = new FileInputStream(stockFile);
|
||||||
|
@SuppressWarnings("CharsetObjectCanBeUsed")
|
||||||
|
InputStreamReader reader = new InputStreamReader(fis, "UTF-8")) {
|
||||||
|
|
||||||
|
// Type definition for Map required by GSON : <String, Integer>
|
||||||
|
Type type = new TypeToken<Map<String, Integer>>(){}.getType();
|
||||||
|
// Read and fill map
|
||||||
|
Map<String, Integer> result = gson.fromJson(reader, type);
|
||||||
|
|
||||||
|
return (result != null) ? result : new HashMap<>();
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.e(TAG, "Error reading existing stock, starting fresh", e);
|
||||||
|
return new HashMap<>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the UI grid to reflect quantities.
|
* Updates the UI grid to reflect quantities.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -22,16 +22,17 @@ import java.util.List;
|
|||||||
public class CartViewHelper {
|
public class CartViewHelper {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Refreshes cart UI by synchronizing the visual list with the current CartManager state
|
* Refreshes the entire cart side-panel or list
|
||||||
|
* Clears everything and rebuild on current CartManager data
|
||||||
*/
|
*/
|
||||||
public static void updateCartView(LinearLayout cartList, Context context) {
|
public static void updateCartView(LinearLayout cartList, Context context) {
|
||||||
if (cartList == null) return;
|
if (cartList == null) return;
|
||||||
|
|
||||||
// Clean item lists
|
// Clear and get current items
|
||||||
cartList.removeAllViews();
|
cartList.removeAllViews();
|
||||||
List<CartItem> cartItems = CartManager.getItems();
|
List<CartItem> cartItems = CartManager.getItems();
|
||||||
|
|
||||||
// Manage empty cart
|
// If empty cart, show it to user
|
||||||
if (cartItems.isEmpty()) {
|
if (cartItems.isEmpty()) {
|
||||||
TextView empty = new TextView(context);
|
TextView empty = new TextView(context);
|
||||||
empty.setText(context.getString(R.string.cart_empty));
|
empty.setText(context.getString(R.string.cart_empty));
|
||||||
@@ -39,19 +40,35 @@ public class CartViewHelper {
|
|||||||
empty.setGravity(Gravity.CENTER);
|
empty.setGravity(Gravity.CENTER);
|
||||||
empty.setPadding(0, 50, 0, 0);
|
empty.setPadding(0, 50, 0, 0);
|
||||||
cartList.addView(empty);
|
cartList.addView(empty);
|
||||||
updateTotalDisplay(context, 0, 0);
|
|
||||||
} else {
|
|
||||||
// Create list if not empty
|
|
||||||
int totalMin = 0;
|
|
||||||
int totalMax = 0;
|
|
||||||
for (CartItem item : cartItems) {
|
|
||||||
totalMin += item.getTotalMin();
|
|
||||||
totalMax += item.getTotalMax();
|
|
||||||
|
|
||||||
// Create a line for each item
|
updateTotalDisplay(context, 0, 0);
|
||||||
cartList.addView(createCartItemView(item, cartList, context));
|
return;
|
||||||
}
|
}
|
||||||
updateTotalDisplay(context, totalMin, totalMax);
|
|
||||||
|
// Build list and calculate total at the same time
|
||||||
|
int totalMin = 0;
|
||||||
|
int totalMax = 0;
|
||||||
|
|
||||||
|
for (CartItem item : cartItems) {
|
||||||
|
totalMin += item.getTotalMin();
|
||||||
|
totalMax += item.getTotalMax();
|
||||||
|
|
||||||
|
// Create and add the row view
|
||||||
|
cartList.addView(createCartItemView(item, cartList, context));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Display global price range at the end
|
||||||
|
updateTotalDisplay(context, totalMin, totalMax);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the global price range at the bottom of the screen
|
||||||
|
*/
|
||||||
|
private static void updateTotalDisplay(Context context, int min, int max) {
|
||||||
|
TextView totalView = ((Activity) context).findViewById(R.id.totalView);
|
||||||
|
if (totalView != null) {
|
||||||
|
// Using string resources
|
||||||
|
totalView.setText(context.getString(R.string.price_range, min, max, "€"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,6 +81,7 @@ public class CartViewHelper {
|
|||||||
row.setOrientation(LinearLayout.HORIZONTAL);
|
row.setOrientation(LinearLayout.HORIZONTAL);
|
||||||
row.setGravity(Gravity.CENTER_VERTICAL);
|
row.setGravity(Gravity.CENTER_VERTICAL);
|
||||||
|
|
||||||
|
// Layout parameters
|
||||||
LinearLayout.LayoutParams rowParams = new LinearLayout.LayoutParams(
|
LinearLayout.LayoutParams rowParams = new LinearLayout.LayoutParams(
|
||||||
LinearLayout.LayoutParams.MATCH_PARENT,
|
LinearLayout.LayoutParams.MATCH_PARENT,
|
||||||
LinearLayout.LayoutParams.WRAP_CONTENT);
|
LinearLayout.LayoutParams.WRAP_CONTENT);
|
||||||
@@ -72,13 +90,13 @@ public class CartViewHelper {
|
|||||||
|
|
||||||
// Image
|
// Image
|
||||||
ImageView image = new ImageView(context);
|
ImageView image = new ImageView(context);
|
||||||
ImageLoader.loadImage(image, item.getImageFile(), 200, 200);
|
ImageLoader.loadImage(image, item.getImageFile(),200,200);
|
||||||
LinearLayout.LayoutParams imgParams = new LinearLayout.LayoutParams(100, 100);
|
LinearLayout.LayoutParams imgParams = new LinearLayout.LayoutParams(100, 100);
|
||||||
imgParams.setMargins(0, 0, 20, 0);
|
imgParams.setMargins(0, 0, 20, 0);
|
||||||
image.setLayoutParams(imgParams);
|
image.setLayoutParams(imgParams);
|
||||||
row.addView(image);
|
row.addView(image);
|
||||||
|
|
||||||
// Sublayout infos
|
// Sublayout for name + [quantity + price]
|
||||||
LinearLayout infoLayout = new LinearLayout(context);
|
LinearLayout infoLayout = new LinearLayout(context);
|
||||||
infoLayout.setOrientation(LinearLayout.VERTICAL);
|
infoLayout.setOrientation(LinearLayout.VERTICAL);
|
||||||
infoLayout.setLayoutParams(new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT, 1f));
|
infoLayout.setLayoutParams(new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT, 1f));
|
||||||
@@ -90,7 +108,7 @@ public class CartViewHelper {
|
|||||||
nameView.setTypeface(null, Typeface.BOLD);
|
nameView.setTypeface(null, Typeface.BOLD);
|
||||||
infoLayout.addView(nameView);
|
infoLayout.addView(nameView);
|
||||||
|
|
||||||
// Quantity / price
|
// Quantity and price range
|
||||||
TextView detailsView = new TextView(context);
|
TextView detailsView = new TextView(context);
|
||||||
String details = context.getString(R.string.cart_item, item.getQuantity(), item.getTotalMin(), item.getTotalMax());
|
String details = context.getString(R.string.cart_item, item.getQuantity(), item.getTotalMin(), item.getTotalMax());
|
||||||
detailsView.setText(details);
|
detailsView.setText(details);
|
||||||
@@ -106,35 +124,42 @@ public class CartViewHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the delete button for each item
|
* Creates the delete button
|
||||||
*/
|
*/
|
||||||
private static Button createRemoveButton(CartItem item, LinearLayout cartList, Context context) {
|
private static Button createRemoveButton(CartItem item, LinearLayout cartList, Context context) {
|
||||||
Button btn = new Button(context);
|
Button btn = new Button(context);
|
||||||
btn.setText("✖");
|
btn.setText("✖");
|
||||||
|
btn.setTextSize(18);
|
||||||
btn.setTextColor(Color.WHITE);
|
btn.setTextColor(Color.WHITE);
|
||||||
|
btn.setGravity(Gravity.CENTER);
|
||||||
|
|
||||||
|
// Conversion DP to PX for consistent size on all screens
|
||||||
float scale = context.getResources().getDisplayMetrics().density;
|
float scale = context.getResources().getDisplayMetrics().density;
|
||||||
int sizePx = (int) (48 * scale + 0.5f);
|
int sizePx = (int) (48 * scale + 0.5f);
|
||||||
btn.setLayoutParams(new LinearLayout.LayoutParams(sizePx, sizePx));
|
|
||||||
|
|
||||||
|
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(sizePx, sizePx);
|
||||||
|
btn.setLayoutParams(params);
|
||||||
|
|
||||||
|
// Background: grey rounded rectangle (API 17 fallback)
|
||||||
GradientDrawable shape = new GradientDrawable();
|
GradientDrawable shape = new GradientDrawable();
|
||||||
shape.setColor(Color.parseColor("#E53935"));
|
shape.setColor(Color.parseColor("#E53935")); // Reddish to indicate delete
|
||||||
shape.setCornerRadius(4 * scale);
|
shape.setCornerRadius(4 * scale);
|
||||||
btn.setBackground(shape);
|
btn.setBackground(shape);
|
||||||
|
|
||||||
btn.setOnClickListener(v -> {
|
btn.setOnClickListener(v -> {
|
||||||
CartManager.addOrUpdateItem(item.getName(), item.getMinPrice(), item.getMaxPrice(), 0, item.getImageFile());
|
// setting quantity to 0 removes the item
|
||||||
|
CartManager.addOrUpdateItem(
|
||||||
|
item.getName(),
|
||||||
|
item.getMinPrice(),
|
||||||
|
item.getMaxPrice(),
|
||||||
|
0, // Setting quantity to 0 triggers removal
|
||||||
|
item.getImageFile()
|
||||||
|
);
|
||||||
|
|
||||||
|
// visual refresh of the cart list
|
||||||
updateCartView(cartList, context);
|
updateCartView(cartList, context);
|
||||||
});
|
});
|
||||||
|
|
||||||
return btn;
|
return btn;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Manage price range for whole cart
|
|
||||||
*/
|
|
||||||
private static void updateTotalDisplay(Context context, int min, int max) {
|
|
||||||
TextView totalView = ((Activity) context).findViewById(R.id.totalView);
|
|
||||||
if (totalView != null) {
|
|
||||||
totalView.setText(context.getString(R.string.price_range, min, max, "€"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -9,11 +9,8 @@ public class Config {
|
|||||||
public static final String IMAGES_SUBDIR_NAME = "images";
|
public static final String IMAGES_SUBDIR_NAME = "images";
|
||||||
|
|
||||||
// Input json
|
// Input json
|
||||||
public static final String INPUT_JSON_NAME = "pieces.json";
|
public static final String PIECES_FILE_NAME = "pieces.json";
|
||||||
|
|
||||||
// Output json
|
// Output json
|
||||||
public static final String OUTPUT_JSON_NAME = "stock.json";
|
public static final String STOCK_FILE_NAME = "stock.json";
|
||||||
|
|
||||||
// Output json
|
|
||||||
public static final String OUTPUT_CSV_NAME = "stock.csv";
|
|
||||||
}
|
}
|
||||||
@@ -37,25 +37,12 @@ public class ControlServer extends NanoHTTPD {
|
|||||||
// Get requested address
|
// Get requested address
|
||||||
String uri = session.getUri();
|
String uri = session.getUri();
|
||||||
|
|
||||||
switch (uri) {
|
// Adapt URL to find the file : /stock.json become stock.json
|
||||||
case "/download_input":
|
if (uri.equals("/download_orders")) {
|
||||||
return downloadFile(Config.INPUT_JSON_NAME);
|
return downloadFile(Config.STOCK_FILE_NAME);
|
||||||
|
}
|
||||||
case "/output_json":
|
if (uri.equals("/download_json")) {
|
||||||
return viewFile(Config.OUTPUT_JSON_NAME);
|
return downloadFile(Config.PIECES_FILE_NAME);
|
||||||
|
|
||||||
case "/download_output_json":
|
|
||||||
return downloadFile(Config.OUTPUT_JSON_NAME);
|
|
||||||
|
|
||||||
case "/output_csv":
|
|
||||||
return viewFile(Config.OUTPUT_CSV_NAME);
|
|
||||||
|
|
||||||
case "/download_output_csv":
|
|
||||||
return downloadFile(Config.OUTPUT_CSV_NAME);
|
|
||||||
|
|
||||||
case "/":
|
|
||||||
case "/index.html":
|
|
||||||
return newFixedLengthResponse(getHtmlResponse());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// File upload management
|
// File upload management
|
||||||
@@ -67,7 +54,8 @@ public class ControlServer extends NanoHTTPD {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return newFixedLengthResponse(Response.Status.NOT_FOUND, MIME_PLAINTEXT, "❌ Page non trouvée");
|
// Return UI
|
||||||
|
return newFixedLengthResponse(getHtmlResponse());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -83,7 +71,7 @@ public class ControlServer extends NanoHTTPD {
|
|||||||
"h1 { color: #0049AF; border-bottom: 2px solid #0049AF; }" +
|
"h1 { color: #0049AF; border-bottom: 2px solid #0049AF; }" +
|
||||||
"h2 { color: #555; margin-top: 30px; }" +
|
"h2 { color: #555; margin-top: 30px; }" +
|
||||||
".card { background: #f4f4f4; padding: 15px; border-radius: 8px; margin-bottom: 20px; border: 1px solid #ddd; }" +
|
".card { background: #f4f4f4; padding: 15px; border-radius: 8px; margin-bottom: 20px; border: 1px solid #ddd; }" +
|
||||||
".btn { display: inline-block; width: 280px; height: 45px; line-height: 45px; text-align: center; background: #0049AF; color: white; text-decoration: none; border-radius: 4px; border: none; cursor: pointer; font-weight: bold; box-sizing: border-box; padding: 0; -webkit-appearance: none; font-family: inherit; font-size: 14px; font-style: normal; letter-spacing: normal; margin: 10px 5px; vertical-align: middle;}" +
|
".btn { display: inline-block; width: 280px; height: 45px; line-height: 45px; text-align: center; background: #0049AF; color: white; text-decoration: none; border-radius: 4px; border: none; cursor: pointer; font-weight: bold; box-sizing: border-box; padding: 0; -webkit-appearance: none; font-family: inherit; font-size: 14px; font-style: normal; letter-spacing: normal; }" +
|
||||||
".btn-download { background: #2E7D32; }" +
|
".btn-download { background: #2E7D32; }" +
|
||||||
"input[type='file'] { margin: 10px 0; }" +
|
"input[type='file'] { margin: 10px 0; }" +
|
||||||
".status { font-weight: bold; color: green; }" +
|
".status { font-weight: bold; color: green; }" +
|
||||||
@@ -96,16 +84,13 @@ public class ControlServer extends NanoHTTPD {
|
|||||||
"<div class='card'>" +
|
"<div class='card'>" +
|
||||||
"<h3>Récupérer les sacoches des adhérent·es</h3>" +
|
"<h3>Récupérer les sacoches des adhérent·es</h3>" +
|
||||||
"<p>Télécharger le décompte des pièces sorties de l'atelier.</p>" +
|
"<p>Télécharger le décompte des pièces sorties de l'atelier.</p>" +
|
||||||
"<a href='/output_json' class='btn'>Voir stock.json</a>" +
|
"<a href='/download_orders' class='btn'>Télécharger stock.json</a>" +
|
||||||
"<a href='/output_csv' class='btn'>Voir stock.csv</a>" +
|
|
||||||
"<a href='/download_output_json' class='btn'>Télécharger stock.json</a>" +
|
|
||||||
"<a href='/download_output_csv' class='btn'>Télécharger stock.csv</a>" +
|
|
||||||
"</div>" +
|
"</div>" +
|
||||||
|
|
||||||
"<h2>Modifier le catalogue</h2>" +
|
"<h2>Modifier le catalogue</h2>" +
|
||||||
"<div class='card'>" +
|
"<div class='card'>" +
|
||||||
"<h3>Gestion du fichier JSON</h3>" +
|
"<h3>Gestion du fichier JSON</h3>" +
|
||||||
"<p>Catalogue actuel : <a href='/download_input' class='btn'>Télécharger pieces.json</a></p>" +
|
"<p>Catalogue actuel : <a href='/download_json' class='btn'>Télécharger pieces.json</a></p>" +
|
||||||
"<hr>" +
|
"<hr>" +
|
||||||
"<form action='/upload_json' method='post' enctype='multipart/form-data'>" +
|
"<form action='/upload_json' method='post' enctype='multipart/form-data'>" +
|
||||||
"<p><strong>Envoyer un nouveau catalogue :</strong></p>" +
|
"<p><strong>Envoyer un nouveau catalogue :</strong></p>" +
|
||||||
@@ -139,7 +124,7 @@ public class ControlServer extends NanoHTTPD {
|
|||||||
if (tmpPath == null) return newFixedLengthResponse("❌ Aucun fichier reçu.");
|
if (tmpPath == null) return newFixedLengthResponse("❌ Aucun fichier reçu.");
|
||||||
|
|
||||||
File src = new File(tmpPath);
|
File src = new File(tmpPath);
|
||||||
File dest = new File(baseDir, Config.INPUT_JSON_NAME);
|
File dest = new File(baseDir, Config.PIECES_FILE_NAME);
|
||||||
|
|
||||||
copyFile(src, dest);
|
copyFile(src, dest);
|
||||||
return newFixedLengthResponse("✅ Catalogue mis à jour ! <a href='/'>Retour</a>");
|
return newFixedLengthResponse("✅ Catalogue mis à jour ! <a href='/'>Retour</a>");
|
||||||
@@ -194,43 +179,20 @@ public class ControlServer extends NanoHTTPD {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prepare file and offer as download
|
* Prepare local file to send it to remote.
|
||||||
*/
|
*/
|
||||||
private Response downloadFile(String filename) {
|
private Response downloadFile(String filename) {
|
||||||
File file = new File(baseDir, filename);
|
File file = new File(baseDir, filename);
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
return newFixedLengthResponse(Response.Status.NOT_FOUND, MIME_PLAINTEXT, "❌ Fichier non trouvé.");
|
return newFixedLengthResponse(Response.Status.NOT_FOUND, MIME_PLAINTEXT, "❌ Fichier non trouvé : " + filename);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
InputStream is = new FileInputStream(file);
|
InputStream is = new FileInputStream(file);
|
||||||
|
|
||||||
// Force download
|
|
||||||
Response res = newChunkedResponse(Response.Status.OK, "application/octet-stream", is);
|
Response res = newChunkedResponse(Response.Status.OK, "application/octet-stream", is);
|
||||||
|
|
||||||
|
// Force file download name
|
||||||
res.addHeader("Content-Disposition", "attachment; filename=\"" + filename + "\"");
|
res.addHeader("Content-Disposition", "attachment; filename=\"" + filename + "\"");
|
||||||
return res;
|
|
||||||
} catch (IOException e) {
|
|
||||||
return newFixedLengthResponse("❌ Erreur de lecture.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Prepare file and print it in browser
|
|
||||||
*/
|
|
||||||
private Response viewFile(String filename) {
|
|
||||||
File file = new File(baseDir, filename);
|
|
||||||
if (!file.exists()) {
|
|
||||||
return newFixedLengthResponse(Response.Status.NOT_FOUND, MIME_PLAINTEXT, "❌ Fichier non trouvé.");
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
InputStream is = new FileInputStream(file);
|
|
||||||
|
|
||||||
// Force Mime type to print file inside browser
|
|
||||||
String mimeType = "text/plain";
|
|
||||||
|
|
||||||
Response res = newChunkedResponse(Response.Status.OK, mimeType + "; charset=utf-8", is);
|
|
||||||
|
|
||||||
res.addHeader("Content-Disposition", "inline");
|
|
||||||
return res;
|
return res;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
return newFixedLengthResponse("❌ Erreur de lecture.");
|
return newFixedLengthResponse("❌ Erreur de lecture.");
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import java.util.List;
|
|||||||
public class DataLoader {
|
public class DataLoader {
|
||||||
private static final String TAG = "DataLoader"; // For readable logs
|
private static final String TAG = "DataLoader"; // For readable logs
|
||||||
private static final String EXTERNAL_DIR = Config.EXTERNAL_DIR_NAME;
|
private static final String EXTERNAL_DIR = Config.EXTERNAL_DIR_NAME;
|
||||||
private static final String PIECES_FILE = Config.INPUT_JSON_NAME;
|
private static final String PIECES_FILE = Config.PIECES_FILE_NAME;
|
||||||
|
|
||||||
// Raw data
|
// Raw data
|
||||||
private static List<Category> cachedCategories = new ArrayList<>();
|
private static List<Category> cachedCategories = new ArrayList<>();
|
||||||
|
|||||||
@@ -1,15 +0,0 @@
|
|||||||
// DateHelper.java
|
|
||||||
package com.stock.pignon;
|
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
public class DateHelper {
|
|
||||||
/**
|
|
||||||
* Return ISO format date (AAAA-MM-JJ)
|
|
||||||
*/
|
|
||||||
public static String getTodayIso() {
|
|
||||||
return new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()).format(new Date());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -12,7 +12,6 @@ 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;
|
||||||
@@ -36,7 +35,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
// UI components
|
// UI components
|
||||||
private LinearLayout cartList;
|
private LinearLayout cartList;
|
||||||
private LinearLayout homeLayout;
|
private LinearLayout homeLayout;
|
||||||
private FrameLayout categoryItemsLayout;
|
private LinearLayout categoryItemsLayout;
|
||||||
private LinearLayout categoriesLayout;
|
private LinearLayout categoriesLayout;
|
||||||
private GridLayout gridPieces;
|
private GridLayout gridPieces;
|
||||||
private ImageView mainImage;
|
private ImageView mainImage;
|
||||||
@@ -62,6 +61,12 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
gridPieces = findViewById(R.id.gridPieces);
|
gridPieces = findViewById(R.id.gridPieces);
|
||||||
mainImage = findViewById(R.id.mainImage);
|
mainImage = findViewById(R.id.mainImage);
|
||||||
|
|
||||||
|
// Setup Back Button
|
||||||
|
Button backBtn = findViewById(R.id.backToHomeBtn);
|
||||||
|
if (backBtn != null) {
|
||||||
|
backBtn.setOnClickListener(v -> showHome());
|
||||||
|
}
|
||||||
|
|
||||||
// Copy assets to sd card if not founded
|
// Copy assets to sd card if not founded
|
||||||
copyAssetsIfEmpty();
|
copyAssetsIfEmpty();
|
||||||
// Get data from sd card
|
// Get data from sd card
|
||||||
@@ -80,48 +85,22 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
getSupportActionBar().setTitle(" 🚲 Atelier du Pignon - Gestion du stock à prix libre");
|
getSupportActionBar().setTitle(" 🚲 Atelier du Pignon - Gestion du stock à prix libre");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get app version
|
|
||||||
String versionName;
|
|
||||||
try {
|
|
||||||
versionName = "App v" + getPackageManager().getPackageInfo(getPackageName(), 0).versionName;
|
|
||||||
} catch (Exception e) {
|
|
||||||
versionName = ""; // Fallback
|
|
||||||
}
|
|
||||||
|
|
||||||
// Launch server
|
// Launch server
|
||||||
server = new ControlServer(8080);
|
server = new ControlServer(8080);
|
||||||
try {
|
try {
|
||||||
server.start();
|
server.start();
|
||||||
String url = "http://" + getDeviceIP() + ":8080";
|
String url = "http://" + getDeviceIP() + ":8080";
|
||||||
|
|
||||||
// Print URL in action bar for user
|
// On met l'URL directement dans le sous-titre de l'ActionBar
|
||||||
if (getSupportActionBar() != null) {
|
if (getSupportActionBar() != null) {
|
||||||
getSupportActionBar().setSubtitle("Serveur en ligne : " + url + " - " + versionName);
|
getSupportActionBar().setSubtitle("🟢 Serveur actif : " + url);
|
||||||
}
|
}
|
||||||
Log.i(TAG, "Server started on : " + url);
|
Log.i(TAG, "Serveur démarré sur : " + url);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
if (getSupportActionBar() != null) {
|
if (getSupportActionBar() != null) {
|
||||||
getSupportActionBar().setSubtitle("Erreur serveur" + " - " + versionName);
|
getSupportActionBar().setSubtitle("🔴 Erreur serveur : Port 8080 occupé");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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
|
||||||
@@ -136,7 +115,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
if (server != null) {
|
if (server != null) {
|
||||||
server.stop();
|
server.stop();
|
||||||
Log.i(TAG, "Server stopped.");
|
Log.i(TAG, "Serveur arrêté.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -279,7 +258,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
CartViewHelper.updateCartView(cartList, this);
|
CartViewHelper.updateCartView(cartList, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showHome() {
|
private void showHome() {
|
||||||
categoryItemsLayout.setVisibility(View.GONE);
|
categoryItemsLayout.setVisibility(View.GONE);
|
||||||
homeLayout.setVisibility(View.VISIBLE);
|
homeLayout.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
@@ -289,70 +268,39 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
ImageLoader.loadImage(mainImage, "_velo", 800,800);
|
ImageLoader.loadImage(mainImage, "_velo", 800,800);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --- Button Actions (linked via android:onClick in XML) ---
|
||||||
|
|
||||||
|
public void emptyCart(View view) {
|
||||||
|
CartActionHelper.emptyCart(cartList, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void validateCart(View view) {
|
||||||
|
CartActionHelper.validateCart(cartList, this);
|
||||||
|
}
|
||||||
|
|
||||||
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());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void copyAssetsIfEmpty() {
|
private void copyAssetsIfEmpty() {
|
||||||
File rootDir = new File(Environment.getExternalStorageDirectory(), Config.EXTERNAL_DIR_NAME);
|
File folder = new File(Environment.getExternalStorageDirectory(), Config.EXTERNAL_DIR_NAME);
|
||||||
|
|
||||||
// Create root folder if not found
|
// First safety : is folder already in sdcard ?
|
||||||
if (!rootDir.exists()) {
|
if (!folder.exists()) {
|
||||||
if (!rootDir.mkdirs()) {
|
// Second safety : are we able to create folder ?
|
||||||
Log.e("MainActivity", "Can't create root dir." + rootDir.getAbsolutePath());
|
if (folder.mkdirs()) {
|
||||||
return;
|
// Copy JSON file
|
||||||
}
|
copyFileFromAssets(Config.PIECES_FILE_NAME, new File(folder, Config.PIECES_FILE_NAME));
|
||||||
}
|
|
||||||
|
|
||||||
// Check pieces.json
|
// Copy images subfolder
|
||||||
File inputJson = new File(rootDir, Config.INPUT_JSON_NAME);
|
File imgFolder = new File(folder, Config.IMAGES_SUBDIR_NAME);
|
||||||
if (!inputJson.exists()) {
|
if (imgFolder.mkdirs()) {
|
||||||
Log.i("MainActivity", "pieces.json not found, copying it...");
|
copyFolderFromAssets(Config.IMAGES_SUBDIR_NAME, imgFolder);
|
||||||
copyFileFromAssets(Config.INPUT_JSON_NAME, inputJson);
|
}
|
||||||
} else {
|
|
||||||
Log.d("MainActivity", "Keep existing pieces.json");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check stock.json and stock.csv output files to avoid control server error
|
|
||||||
checkOrCreateEmptyFile(new File(rootDir, Config.OUTPUT_JSON_NAME), "[]");
|
|
||||||
checkOrCreateEmptyFile(new File(rootDir, Config.OUTPUT_CSV_NAME), "");
|
|
||||||
|
|
||||||
// Check images folder
|
|
||||||
File imgDir = new File(rootDir, Config.IMAGES_SUBDIR_NAME);
|
|
||||||
if (!imgDir.exists()) {
|
|
||||||
if (!imgDir.mkdirs()) {
|
|
||||||
Log.e("MainActivity", "Can't create images dir.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Copy images only if not found
|
|
||||||
String[] filesInImgDir = imgDir.list();
|
|
||||||
if (filesInImgDir == null || filesInImgDir.length == 0) {
|
|
||||||
Log.i("MainActivity", "Images folder empty. Installing images...");
|
|
||||||
copyFolderFromAssets(Config.IMAGES_SUBDIR_NAME, imgDir);
|
|
||||||
} else {
|
|
||||||
Log.d("MainActivity", "Keep existing images.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a file with default content if not found
|
|
||||||
*/
|
|
||||||
private void checkOrCreateEmptyFile(File file, String defaultContent) {
|
|
||||||
if (!file.exists()) {
|
|
||||||
try (FileOutputStream fos = new FileOutputStream(file)) {
|
|
||||||
fos.write(defaultContent.getBytes());
|
|
||||||
Log.d(TAG, "Initialisation de : " + file.getName());
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.e(TAG, "Erreur lors de l'initialisation de " + file.getName(), e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Copy folder from assets
|
|
||||||
*/
|
|
||||||
private void copyFolderFromAssets(String assetDirName, File destDir) {
|
private void copyFolderFromAssets(String assetDirName, File destDir) {
|
||||||
try {
|
try {
|
||||||
String[] files = getAssets().list(assetDirName);
|
String[] files = getAssets().list(assetDirName);
|
||||||
@@ -368,28 +316,25 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.e("MainActivity", "Listing assets error: " + assetDirName, e);
|
Log.e("MainActivity", "Erreur listing assets: " + assetDirName, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Copy file from assets
|
|
||||||
*/
|
|
||||||
private void copyFileFromAssets(String assetName, File destFile) {
|
private void copyFileFromAssets(String assetName, File destFile) {
|
||||||
// Optimized read
|
// Optimized read
|
||||||
// Try-with-resources ensures streams are automatically closed, avoid memory leaks
|
// Try-with-resources ensures streams are automatically closed, avoid memory leaks
|
||||||
try (InputStream in = getAssets().open(assetName);
|
try (InputStream in = getAssets().open(assetName);
|
||||||
OutputStream out = new FileOutputStream(destFile)) {
|
OutputStream out = new FileOutputStream(destFile)) {
|
||||||
|
|
||||||
byte[] buffer = new byte[8192];
|
byte[] buffer = new byte[1024];
|
||||||
int read;
|
int read;
|
||||||
while ((read = in.read(buffer)) != -1) {
|
while ((read = in.read(buffer)) != -1) {
|
||||||
out.write(buffer, 0, read);
|
out.write(buffer, 0, read);
|
||||||
}
|
}
|
||||||
Log.d("MainActivity", "Success : " + assetName + " copied.");
|
Log.d("MainActivity", "Succès : " + assetName + " copié.");
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.e("MainActivity", "Can't copy asset: " + assetName, e);
|
Log.e("MainActivity", "Erreur copie asset: " + assetName, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -410,7 +355,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e(TAG, "IP error", e);
|
Log.e(TAG, "Erreur IP", e);
|
||||||
}
|
}
|
||||||
return "127.0.0.1";
|
return "127.0.0.1";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,81 +1,64 @@
|
|||||||
<?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
|
|
||||||
android:id="@+id/contentFrame"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_weight="1">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/homeLayout"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:orientation="horizontal"
|
|
||||||
android:paddingStart="20dp"
|
|
||||||
android:paddingEnd="20dp"
|
|
||||||
tools:ignore="RtlSymmetry"> <LinearLayout
|
|
||||||
android:id="@+id/categoriesLayout"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:gravity="center_vertical"/>
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/mainImage"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:scaleType="fitCenter"
|
|
||||||
android:contentDescription="@string/app_name" /> </LinearLayout>
|
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:id="@+id/categoryItemsLayout"
|
android:id="@+id/contentFrame"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="0dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:visibility="gone">
|
android:layout_weight="1">
|
||||||
|
|
||||||
<ScrollView
|
<LinearLayout
|
||||||
|
android:id="@+id/homeLayout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:padding="10dp">
|
android:orientation="horizontal"
|
||||||
|
android:paddingLeft="20dp">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:id="@+id/categoriesLayout"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:gravity="center_vertical"/>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/mainImage"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:scaleType="fitCenter" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/categoryItemsLayout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:padding="10dp">
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/backToHomeBtn"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical">
|
android:text="← Retour" />
|
||||||
|
|
||||||
|
<ScrollView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
<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
|
</LinearLayout>
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="100dp" />
|
|
||||||
</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" />
|
||||||
|
|
||||||
|
|||||||
@@ -19,15 +19,13 @@
|
|||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/itemName"
|
android:id="@+id/itemName"
|
||||||
android:layout_width="150dp"
|
android:layout_width="wrap_content"
|
||||||
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:minLines="2"
|
android:lines="1"
|
||||||
android:maxLines="2"
|
android:ellipsize="end" />
|
||||||
android:ellipsize="end"
|
|
||||||
android:gravity="center"/>
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/itemPrice"
|
android:id="@+id/itemPrice"
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
<?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"
|
||||||
@@ -57,29 +56,29 @@
|
|||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:weightSum="2">
|
android:weightSum="2">
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatButton
|
<Button
|
||||||
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="70dp"
|
android:layout_height="60dp"
|
||||||
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"
|
||||||
app:backgroundTint="#E53935"
|
android:background="#E53935"
|
||||||
android:layout_marginEnd="5dp"/>
|
android:layout_marginEnd="5dp"
|
||||||
|
android:onClick="emptyCart"/>
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatButton
|
<Button
|
||||||
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="70dp"
|
android:layout_height="60dp"
|
||||||
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"
|
||||||
app:backgroundTint="#43A047"
|
android:background="#43A047"
|
||||||
android:layout_marginStart="5dp"/>
|
android:layout_marginStart="5dp"
|
||||||
|
android:onClick="validateCart"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
@@ -3,9 +3,8 @@
|
|||||||
|
|
||||||
<string name="cart_name">Mes sacoches</string>
|
<string name="cart_name">Mes sacoches</string>
|
||||||
<string name="cart_validate_btn">Valider</string>
|
<string name="cart_validate_btn">Valider</string>
|
||||||
<string name="cart_back_btn">Retour</string>
|
|
||||||
<string name="cart_empty_btn">Vider</string>
|
<string name="cart_empty_btn">Vider</string>
|
||||||
<string name="cart_empty">C\'est vide !</string>
|
<string name="cart_empty">Sacoches vides</string>
|
||||||
<string name="cart_item">Quantité : %1$d (%2$d - %3$d €)</string>
|
<string name="cart_item">Quantité : %1$d (%2$d - %3$d €)</string>
|
||||||
|
|
||||||
<string name="currency">€</string>
|
<string name="currency">€</string>
|
||||||
@@ -14,6 +13,6 @@
|
|||||||
<string name="popup_name">Mes sacoches</string>
|
<string name="popup_name">Mes sacoches</string>
|
||||||
<string name="popup_item"><![CDATA[<b>%1$d x %2$s</b> : %3$d - %4$d €<br>]]></string>
|
<string name="popup_item"><![CDATA[<b>%1$d x %2$s</b> : %3$d - %4$d €<br>]]></string>
|
||||||
<string name="popup_total"><![CDATA[<br><b>Contribution consciente dans la petite boîte : %1$d - %2$d €</b>]]></string>
|
<string name="popup_total"><![CDATA[<br><b>Contribution consciente dans la petite boîte : %1$d - %2$d €</b>]]></string>
|
||||||
<string name="popup_end">Sacoches sauvegardées, merci ! ❤️</string>
|
<string name="popup_end">Sacoches sauvegardées, merci !</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||