mirror of
https://github.com/lucasroyerdev/stock-pignon.git
synced 2026-05-10 11:02:26 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f4be7a90eb |
@@ -10,8 +10,8 @@ android {
|
|||||||
applicationId "com.stock.pignon"
|
applicationId "com.stock.pignon"
|
||||||
minSdkVersion 17
|
minSdkVersion 17
|
||||||
targetSdkVersion 36
|
targetSdkVersion 36
|
||||||
versionCode 5
|
versionCode 6
|
||||||
versionName "0.5.0"
|
versionName "0.5.1"
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -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());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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,28 +32,41 @@
|
|||||||
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">
|
||||||
<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>
|
</ScrollView>
|
||||||
</LinearLayout>
|
|
||||||
|
<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" />
|
||||||
|
|
||||||
|
|||||||
@@ -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>
|
||||||
Reference in New Issue
Block a user