mirror of
https://github.com/lucasroyerdev/stock-pignon.git
synced 2026-05-10 02:52:26 +00:00
fix: back to home after cart validation
This commit is contained in:
@@ -10,8 +10,8 @@ android {
|
|||||||
applicationId "com.stock.pignon"
|
applicationId "com.stock.pignon"
|
||||||
minSdkVersion 17
|
minSdkVersion 17
|
||||||
targetSdkVersion 36
|
targetSdkVersion 36
|
||||||
versionCode 3
|
versionCode 4
|
||||||
versionName "0.3.0"
|
versionName "0.4.0"
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -183,16 +183,17 @@ 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) {
|
||||||
Intent intent = new Intent(activity, MainActivity.class);
|
MainActivity main = (MainActivity) activity;
|
||||||
|
// 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
|
||||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
GridLayout grid = main.findViewById(R.id.gridPieces);
|
||||||
activity.startActivity(intent);
|
refreshGridQuantities(grid);
|
||||||
}
|
}
|
||||||
}, 2000);
|
}, 2000);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,6 +85,14 @@ 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 {
|
||||||
@@ -93,12 +101,12 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
// On met l'URL directement dans le sous-titre de l'ActionBar
|
// On met l'URL directement dans le sous-titre de l'ActionBar
|
||||||
if (getSupportActionBar() != null) {
|
if (getSupportActionBar() != null) {
|
||||||
getSupportActionBar().setSubtitle("🟢 Server online : " + url);
|
getSupportActionBar().setSubtitle("Serveur en ligne : " + url + " - " + versionName);
|
||||||
}
|
}
|
||||||
Log.i(TAG, "Server started on : " + url);
|
Log.i(TAG, "Server started on : " + url);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
if (getSupportActionBar() != null) {
|
if (getSupportActionBar() != null) {
|
||||||
getSupportActionBar().setSubtitle("🔴 Server error : port 8080 busy");
|
getSupportActionBar().setSubtitle("Erreur serveur" + " - " + versionName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -258,7 +266,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
CartViewHelper.updateCartView(cartList, this);
|
CartViewHelper.updateCartView(cartList, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showHome() {
|
public void showHome() {
|
||||||
categoryItemsLayout.setVisibility(View.GONE);
|
categoryItemsLayout.setVisibility(View.GONE);
|
||||||
homeLayout.setVisibility(View.VISIBLE);
|
homeLayout.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<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_empty_btn">Vider</string>
|
<string name="cart_empty_btn">Vider</string>
|
||||||
<string name="cart_empty">Sacoches vides</string>
|
<string name="cart_empty">C\'est vide !</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>
|
||||||
@@ -13,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>
|
||||||
Reference in New Issue
Block a user