Compare commits
3 Commits
6f73fb31c1
...
a9a9c22899
Author | SHA1 | Date |
---|---|---|
|
a9a9c22899 | |
|
a3782a09b6 | |
|
f53cd006bd |
|
@ -1,7 +1,16 @@
|
||||||
package com.dspread.pos.common.adapters;
|
package com.dspread.pos.common.adapters;
|
||||||
|
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.Canvas;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
|
import android.graphics.LinearGradient;
|
||||||
|
import android.graphics.Paint;
|
||||||
|
import android.graphics.PorterDuff;
|
||||||
|
import android.graphics.PorterDuffXfermode;
|
||||||
|
import android.graphics.Shader;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.graphics.drawable.GradientDrawable;
|
||||||
|
import android.graphics.drawable.LayerDrawable;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -124,4 +133,108 @@ public class BindingAdapters {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@BindingAdapter("android:background")
|
||||||
|
public static void setBackgroundResource(View view, ObservableField<Integer> backgroundResId) {
|
||||||
|
if (backgroundResId != null && backgroundResId.get() != null) {
|
||||||
|
view.setBackgroundResource(backgroundResId.get());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Optional: Also add one for regular Integer for flexibility
|
||||||
|
@BindingAdapter("android:background")
|
||||||
|
public static void setBackgroundResource(View view, Integer resourceId) {
|
||||||
|
if (resourceId != null) {
|
||||||
|
view.setBackgroundResource(resourceId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@BindingAdapter({"android:src", "primaryColor", "secondaryColor", "isBankMode"})
|
||||||
|
public static void setIconWithGradientTint(ImageView imageView, Object icon,
|
||||||
|
String primaryColor, String secondaryColor,
|
||||||
|
Boolean isBankMode) {
|
||||||
|
// Set the icon first
|
||||||
|
if (icon instanceof Integer) {
|
||||||
|
imageView.setImageResource((Integer) icon);
|
||||||
|
} else if (icon instanceof Bitmap) {
|
||||||
|
imageView.setImageBitmap((Bitmap) icon);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove any previous color filter
|
||||||
|
imageView.setColorFilter(null);
|
||||||
|
|
||||||
|
// Apply gradient tint or remove filter
|
||||||
|
if (false) {
|
||||||
|
// No tint in bank mode - already cleared above
|
||||||
|
} else if (primaryColor != null && secondaryColor != null) {
|
||||||
|
try {
|
||||||
|
// Parse colors
|
||||||
|
int startColor = Color.parseColor(primaryColor);
|
||||||
|
int endColor = Color.parseColor(secondaryColor);
|
||||||
|
|
||||||
|
// Create a temporary bitmap to apply gradient
|
||||||
|
applyGradientToImageView(imageView, startColor, endColor);
|
||||||
|
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
// Fallback to single color if gradient fails
|
||||||
|
if (primaryColor != null) {
|
||||||
|
try {
|
||||||
|
int color = Color.parseColor(primaryColor);
|
||||||
|
imageView.setColorFilter(color, PorterDuff.Mode.SRC_IN);
|
||||||
|
} catch (IllegalArgumentException ex) {
|
||||||
|
// Ignore
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (primaryColor != null) {
|
||||||
|
try {
|
||||||
|
int color = Color.parseColor(primaryColor);
|
||||||
|
imageView.setColorFilter(color, PorterDuff.Mode.SRC_IN);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
// Ignore
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void applyGradientToImageView(ImageView imageView, int startColor, int endColor) {
|
||||||
|
Drawable drawable = imageView.getDrawable();
|
||||||
|
if (drawable == null) return;
|
||||||
|
|
||||||
|
// Get drawable dimensions
|
||||||
|
int width = drawable.getIntrinsicWidth();
|
||||||
|
int height = drawable.getIntrinsicHeight();
|
||||||
|
|
||||||
|
if (width <= 0) width = 100;
|
||||||
|
if (height <= 0) height = 100;
|
||||||
|
|
||||||
|
// Create gradient bitmap
|
||||||
|
Bitmap gradientBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
|
||||||
|
Canvas gradientCanvas = new Canvas(gradientBitmap);
|
||||||
|
|
||||||
|
Paint gradientPaint = new Paint();
|
||||||
|
LinearGradient gradient = new LinearGradient(
|
||||||
|
0, 0, 0, height, // Top to bottom
|
||||||
|
startColor, endColor,
|
||||||
|
Shader.TileMode.CLAMP
|
||||||
|
);
|
||||||
|
gradientPaint.setShader(gradient);
|
||||||
|
gradientCanvas.drawRect(0, 0, width, height, gradientPaint);
|
||||||
|
|
||||||
|
// Create icon bitmap
|
||||||
|
Bitmap iconBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
|
||||||
|
Canvas iconCanvas = new Canvas(iconBitmap);
|
||||||
|
drawable.setBounds(0, 0, width, height);
|
||||||
|
drawable.draw(iconCanvas);
|
||||||
|
|
||||||
|
// Combine gradient and icon using SRC_IN mode
|
||||||
|
Paint combinePaint = new Paint();
|
||||||
|
combinePaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
|
||||||
|
|
||||||
|
Canvas resultCanvas = new Canvas(iconBitmap);
|
||||||
|
resultCanvas.drawBitmap(gradientBitmap, 0, 0, combinePaint);
|
||||||
|
|
||||||
|
imageView.setImageBitmap(iconBitmap);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -29,7 +29,6 @@ public class MulberryFragment extends BaseFragment<FragmentMulberryBinding, Mulb
|
||||||
binding.footerContainer,
|
binding.footerContainer,
|
||||||
binding.centerContainer,
|
binding.centerContainer,
|
||||||
binding.getRoot()
|
binding.getRoot()
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Handle fragment navigation
|
// Handle fragment navigation
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
package com.dspread.pos.ui.mulberry;
|
package com.dspread.pos.ui.mulberry;
|
||||||
|
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.Color;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.databinding.Observable;
|
||||||
import androidx.databinding.ObservableField;
|
import androidx.databinding.ObservableField;
|
||||||
|
|
||||||
import com.dspread.pos.utils.PosParameters;
|
import com.dspread.pos.utils.PosParameters;
|
||||||
|
@ -17,6 +20,11 @@ public class MulberryItemViewModel extends ItemViewModel<MulberryViewModel> {
|
||||||
// Display properties
|
// Display properties
|
||||||
public final ObservableField<String> title = new ObservableField<>();
|
public final ObservableField<String> title = new ObservableField<>();
|
||||||
public final ObservableField<Object> icon = new ObservableField<>(); // Can be Integer(resId), Bitmap, or String(path)
|
public final ObservableField<Object> icon = new ObservableField<>(); // Can be Integer(resId), Bitmap, or String(path)
|
||||||
|
public final ObservableField<Boolean> bankMode = new ObservableField<>(false);
|
||||||
|
public final ObservableField<Integer> textColor = new ObservableField<>(Color.WHITE);
|
||||||
|
public final ObservableField<String> primaryColor = new ObservableField<>("#000000");
|
||||||
|
public final ObservableField<String> secondaryColor = new ObservableField<>("#000000");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Click handler
|
// Click handler
|
||||||
|
@ -24,6 +32,8 @@ public class MulberryItemViewModel extends ItemViewModel<MulberryViewModel> {
|
||||||
viewModel.onItemClick(this);
|
viewModel.onItemClick(this);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Master constructor for all navigation items
|
* Master constructor for all navigation items
|
||||||
* @param viewModel Parent ViewModel
|
* @param viewModel Parent ViewModel
|
||||||
|
@ -42,7 +52,33 @@ public class MulberryItemViewModel extends ItemViewModel<MulberryViewModel> {
|
||||||
this.activityClass = activityClass;
|
this.activityClass = activityClass;
|
||||||
this.title.set(title);
|
this.title.set(title);
|
||||||
this.icon.set(iconSource);
|
this.icon.set(iconSource);
|
||||||
|
this.primaryColor.set(viewModel.primaryColor.get());
|
||||||
|
this.secondaryColor.set(viewModel.secondaryColor.get());
|
||||||
|
|
||||||
|
|
||||||
|
// Initialize with parent's bankMode value
|
||||||
|
if (viewModel != null && viewModel.bankMode != null) {
|
||||||
|
this.bankMode.set(viewModel.bankMode.get());
|
||||||
|
|
||||||
|
// Listen for parent bankMode changes
|
||||||
|
viewModel.bankMode.addOnPropertyChangedCallback(new Observable.OnPropertyChangedCallback() {
|
||||||
|
@Override
|
||||||
|
public void onPropertyChanged(Observable sender, int propertyId) {
|
||||||
|
bankMode.set(viewModel.bankMode.get());
|
||||||
|
updateTextColor();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
updateTextColor();
|
||||||
|
|
||||||
|
}
|
||||||
|
private void updateTextColor() {
|
||||||
|
if (Boolean.TRUE.equals(bankMode.get())) {
|
||||||
|
textColor.set(Color.BLACK);
|
||||||
|
} else {
|
||||||
|
textColor.set(Color.WHITE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -5,6 +5,7 @@ import static com.dspread.pos.utils.PosParameters.NAV_HOME;
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.BitmapFactory;
|
import android.graphics.BitmapFactory;
|
||||||
|
import android.graphics.Color;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -66,9 +67,14 @@ public class MulberryViewModel extends BaseAppViewModel {
|
||||||
public final ObservableField<Bitmap> footerLogoBitmap = new ObservableField<>();
|
public final ObservableField<Bitmap> footerLogoBitmap = new ObservableField<>();
|
||||||
public final ObservableField<Boolean> logoVisibility = PosParameters.footerLogoVisibility;
|
public final ObservableField<Boolean> logoVisibility = PosParameters.footerLogoVisibility;
|
||||||
public final ObservableField<Boolean> logoTextVisibility = PosParameters.footerTextVisibility;
|
public final ObservableField<Boolean> logoTextVisibility = PosParameters.footerTextVisibility;
|
||||||
|
public final ObservableField<Boolean> bankMode = PosParameters.bankmode;
|
||||||
|
public final ObservableField<Integer> backgroundResId = new ObservableField<>();
|
||||||
|
public final ObservableField<Integer> footerTextColor = new ObservableField<>(Color.WHITE);
|
||||||
|
|
||||||
public final ObservableField<String> greetingText = PosParameters.footerGreetingText;
|
public final ObservableField<String> greetingText = PosParameters.footerGreetingText;
|
||||||
public final ObservableField<String> footerText = PosParameters.footerText;
|
public final ObservableField<String> footerText = PosParameters.footerText;
|
||||||
public final ObservableField<String> primaryColor = PosParameters.primaryColor;
|
public final ObservableField<String> primaryColor = PosParameters.primaryColor;
|
||||||
|
public final ObservableField<String> secondaryColor = PosParameters.secondaryColor;
|
||||||
|
|
||||||
// Navigation
|
// Navigation
|
||||||
public final SingleLiveEvent<Integer> navigateToFragment = new SingleLiveEvent<>();
|
public final SingleLiveEvent<Integer> navigateToFragment = new SingleLiveEvent<>();
|
||||||
|
@ -91,6 +97,22 @@ public class MulberryViewModel extends BaseAppViewModel {
|
||||||
Log.d(TAG, "MulberryViewModel constructor called");
|
Log.d(TAG, "MulberryViewModel constructor called");
|
||||||
|
|
||||||
|
|
||||||
|
// Initialize background
|
||||||
|
backgroundResId.set(R.drawable.wallpaper_8f25c3);
|
||||||
|
|
||||||
|
// Add listener to bankMode changes
|
||||||
|
bankMode.addOnPropertyChangedCallback(new Observable.OnPropertyChangedCallback() {
|
||||||
|
@Override
|
||||||
|
public void onPropertyChanged(Observable sender, int propertyId) {
|
||||||
|
if (Boolean.TRUE.equals(bankMode.get())) {
|
||||||
|
Log.d(TAG, "background for bankmode");
|
||||||
|
backgroundResId.set(R.drawable.keyboard_keybg_white);
|
||||||
|
} else {
|
||||||
|
backgroundResId.set(R.drawable.white_wallpaper);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Add this to track initialization
|
// Add this to track initialization
|
||||||
Log.d(TAG, "ViewModel hash: " + this.hashCode());
|
Log.d(TAG, "ViewModel hash: " + this.hashCode());
|
||||||
// if (Build.MODEL.equalsIgnoreCase("D70") ||
|
// if (Build.MODEL.equalsIgnoreCase("D70") ||
|
||||||
|
@ -120,6 +142,16 @@ public class MulberryViewModel extends BaseAppViewModel {
|
||||||
initialize();
|
initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void updateBackground() {
|
||||||
|
if (Boolean.TRUE.equals(bankMode.get())) {
|
||||||
|
backgroundResId.set(R.drawable.keyboard_keybg_white);
|
||||||
|
footerTextColor.set(Color.BLACK);
|
||||||
|
} else {
|
||||||
|
backgroundResId.set(R.drawable.wallpaper_8f25c3);
|
||||||
|
footerTextColor.set(Color.WHITE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void adjustMulberryView(ImageView logoImageView,
|
public void adjustMulberryView(ImageView logoImageView,
|
||||||
LinearLayout containerLayout,
|
LinearLayout containerLayout,
|
||||||
LinearLayout footerContainer,
|
LinearLayout footerContainer,
|
||||||
|
@ -224,8 +256,17 @@ public class MulberryViewModel extends BaseAppViewModel {
|
||||||
if (fullRefresh) {
|
if (fullRefresh) {
|
||||||
imagesLoaded.postValue(true);
|
imagesLoaded.postValue(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Your existing code...
|
||||||
|
bankMode.set(PosParameters.bankmode.get());
|
||||||
|
|
||||||
|
// Add this line to update background when config changes
|
||||||
|
updateBackground();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void updateMainConfig(boolean loadImages) {
|
private void updateMainConfig(boolean loadImages) {
|
||||||
Log.d(TAG, "Updating main configuration");
|
Log.d(TAG, "Updating main configuration");
|
||||||
|
|
||||||
|
@ -235,6 +276,16 @@ public class MulberryViewModel extends BaseAppViewModel {
|
||||||
greetingText.set(PosParameters.footerGreetingText.get());
|
greetingText.set(PosParameters.footerGreetingText.get());
|
||||||
footerText.set(PosParameters.footerText.get());
|
footerText.set(PosParameters.footerText.get());
|
||||||
primaryColor.set(PosParameters.primaryColor.get());
|
primaryColor.set(PosParameters.primaryColor.get());
|
||||||
|
secondaryColor.set(PosParameters.secondaryColor.get());
|
||||||
|
bankMode.set(PosParameters.bankmode.get());
|
||||||
|
|
||||||
|
// Log.d(TAG, "bankMode is: " + bankMode.get());
|
||||||
|
|
||||||
|
if (Boolean.TRUE.equals(bankMode.get())){
|
||||||
|
Log.d(TAG, "bankMode is: zzzzz " + bankMode.get());
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// Load images if requested
|
// Load images if requested
|
||||||
if (loadImages) {
|
if (loadImages) {
|
||||||
|
@ -397,6 +448,8 @@ public class MulberryViewModel extends BaseAppViewModel {
|
||||||
super.onConfigurationUpdated();
|
super.onConfigurationUpdated();
|
||||||
Log.d(TAG, "onConfigurationUpdated called - hash: " + this.hashCode());
|
Log.d(TAG, "onConfigurationUpdated called - hash: " + this.hashCode());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Check if ViewModel is still active
|
// Check if ViewModel is still active
|
||||||
if (navItems == null) {
|
if (navItems == null) {
|
||||||
Log.w(TAG, "navItems is null - ViewModel might be cleared");
|
Log.w(TAG, "navItems is null - ViewModel might be cleared");
|
||||||
|
@ -492,6 +545,7 @@ public class MulberryViewModel extends BaseAppViewModel {
|
||||||
footerText.set(prefs.getString("footer_text", ""));
|
footerText.set(prefs.getString("footer_text", ""));
|
||||||
primaryColor.set(prefs.getString("primary_color", "#000000"));
|
primaryColor.set(prefs.getString("primary_color", "#000000"));
|
||||||
logoVisibility.set(prefs.getBoolean("footer_logo_visibility", true));
|
logoVisibility.set(prefs.getBoolean("footer_logo_visibility", true));
|
||||||
|
bankMode.set(prefs.getBoolean("bank_mode", true));
|
||||||
|
|
||||||
// 2. Load navigation items from prefs
|
// 2. Load navigation items from prefs
|
||||||
// String savedNavItemsJson = prefs.getString("PREF_NAV_ITEMS", null);
|
// String savedNavItemsJson = prefs.getString("PREF_NAV_ITEMS", null);
|
||||||
|
|
|
@ -25,10 +25,17 @@ public class PosParameters {
|
||||||
// Preference keys
|
// Preference keys
|
||||||
private static final String PREF_MAIN_LOGO = "main_logo";
|
private static final String PREF_MAIN_LOGO = "main_logo";
|
||||||
private static final String PREF_FOOTER_LOGO = "footer_logo";
|
private static final String PREF_FOOTER_LOGO = "footer_logo";
|
||||||
|
private static final String PREF_PRINT_LOGO = "print_logo";
|
||||||
|
|
||||||
private static final String PREF_FOOTER_LOGO_VISIBILITY = "footer_logo_visibility";
|
private static final String PREF_FOOTER_LOGO_VISIBILITY = "footer_logo_visibility";
|
||||||
private static final String PREF_FOOTER_GREETING_TEXT = "footer_greeting_text";
|
private static final String PREF_FOOTER_GREETING_TEXT = "footer_greeting_text";
|
||||||
private static final String PREF_FOOTER_TEXT = "footer_text";
|
private static final String PREF_FOOTER_TEXT = "footer_text";
|
||||||
private static final String PREF_PRIMARY_COLOR = "primary_color";
|
private static final String PREF_PRIMARY_COLOR = "primary_color";
|
||||||
|
private static final String PREF_SECONDARY_COLOR = "secondary_color";
|
||||||
|
|
||||||
|
private static final String PREF_BANK_MODE = "bank_mode";
|
||||||
|
private static final String PREF_PRINT_URL_TEXT = "print_url_text";
|
||||||
|
|
||||||
private static final String PREF_RAW_JSON = "raw_json";
|
private static final String PREF_RAW_JSON = "raw_json";
|
||||||
private static final String PREF_NAV_ITEMS = "nav_items";
|
private static final String PREF_NAV_ITEMS = "nav_items";
|
||||||
|
|
||||||
|
@ -43,19 +50,31 @@ public class PosParameters {
|
||||||
// Default values
|
// Default values
|
||||||
private static final int DEFAULT_MAIN_LOGO = R.drawable.am_mulberry_logo_wide_color;
|
private static final int DEFAULT_MAIN_LOGO = R.drawable.am_mulberry_logo_wide_color;
|
||||||
private static final int DEFAULT_FOOTER_LOGO = R.drawable.am_mulberry_logo_wide_color;
|
private static final int DEFAULT_FOOTER_LOGO = R.drawable.am_mulberry_logo_wide_color;
|
||||||
|
private static final int DEFAULT_PRINT_LOGO = R.drawable.am_mulberry_logo_wide_color;
|
||||||
private static final boolean DEFAULT_FOOTER_LOGO_VISIBILITY = true;
|
private static final boolean DEFAULT_FOOTER_LOGO_VISIBILITY = true;
|
||||||
|
private static final boolean DEFAULT_BANK_MODE = true;
|
||||||
|
|
||||||
private static final String DEFAULT_FOOTER_GREETING_TEXT = "Hello";
|
private static final String DEFAULT_FOOTER_GREETING_TEXT = "Hello";
|
||||||
private static final String DEFAULT_FOOTER_TEXT = "Mulberry ©2025 www.mulberrypos.com";
|
private static final String DEFAULT_FOOTER_TEXT = "Mulberry ©2025 www.mulberrypos.com";
|
||||||
|
private static final String DEFAULT_PRINT_URL_TEXT = "www.mulberrypos.com";
|
||||||
|
|
||||||
private static final String DEFAULT_PRIMARY_COLOR = "#3d3d3d";
|
private static final String DEFAULT_PRIMARY_COLOR = "#3d3d3d";
|
||||||
|
private static final String DEFAULT_SECONDARY_COLOR = "#ed2140ff";
|
||||||
|
|
||||||
// Observable fields
|
// Observable fields
|
||||||
public static final ObservableField<Integer> mainLogo = new ObservableField<>(DEFAULT_MAIN_LOGO);
|
public static final ObservableField<Integer> mainLogo = new ObservableField<>(DEFAULT_MAIN_LOGO);
|
||||||
public static final ObservableField<Integer> footerLogo = new ObservableField<>(DEFAULT_FOOTER_LOGO);
|
public static final ObservableField<Integer> footerLogo = new ObservableField<>(DEFAULT_FOOTER_LOGO);
|
||||||
|
public static final ObservableField<Integer> printlogo = new ObservableField<>(DEFAULT_PRINT_LOGO);
|
||||||
|
|
||||||
public static final ObservableField<Boolean> footerLogoVisibility = new ObservableField<>(DEFAULT_FOOTER_LOGO_VISIBILITY);
|
public static final ObservableField<Boolean> footerLogoVisibility = new ObservableField<>(DEFAULT_FOOTER_LOGO_VISIBILITY);
|
||||||
|
public static final ObservableField<Boolean> bankmode = new ObservableField<>(DEFAULT_BANK_MODE);
|
||||||
|
|
||||||
public static final ObservableField<Boolean> footerTextVisibility = new ObservableField<>(false);
|
public static final ObservableField<Boolean> footerTextVisibility = new ObservableField<>(false);
|
||||||
public static final ObservableField<String> footerGreetingText = new ObservableField<>(DEFAULT_FOOTER_GREETING_TEXT);
|
public static final ObservableField<String> footerGreetingText = new ObservableField<>(DEFAULT_FOOTER_GREETING_TEXT);
|
||||||
public static final ObservableField<String> footerText = new ObservableField<>(DEFAULT_FOOTER_TEXT);
|
public static final ObservableField<String> footerText = new ObservableField<>(DEFAULT_FOOTER_TEXT);
|
||||||
|
public static final ObservableField<String> printUrlText = new ObservableField<>(DEFAULT_PRINT_URL_TEXT);
|
||||||
public static final ObservableField<String> primaryColor = new ObservableField<>(DEFAULT_PRIMARY_COLOR);
|
public static final ObservableField<String> primaryColor = new ObservableField<>(DEFAULT_PRIMARY_COLOR);
|
||||||
|
public static final ObservableField<String> secondaryColor = new ObservableField<>(DEFAULT_SECONDARY_COLOR);
|
||||||
|
|
||||||
// Navigation items storage
|
// Navigation items storage
|
||||||
public static final Map<Integer, List<NavItem>> NAV_ITEMS = new HashMap<>();
|
public static final Map<Integer, List<NavItem>> NAV_ITEMS = new HashMap<>();
|
||||||
|
@ -229,7 +248,7 @@ public class PosParameters {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Footer Logo (same pattern)
|
// Footer Logo
|
||||||
if (config.has("footerLogo")) {
|
if (config.has("footerLogo")) {
|
||||||
JSONObject logoConfig = config.getJSONObject("footerLogo");
|
JSONObject logoConfig = config.getJSONObject("footerLogo");
|
||||||
Object logoSource = processIcon(logoConfig, context);
|
Object logoSource = processIcon(logoConfig, context);
|
||||||
|
@ -245,15 +264,40 @@ public class PosParameters {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Print Logo
|
||||||
|
if (config.has("printLogo")) {
|
||||||
|
JSONObject logoConfig = config.getJSONObject("printLogo");
|
||||||
|
Object logoSource = processIcon(logoConfig, context);
|
||||||
|
|
||||||
|
if (logoSource instanceof Integer) {
|
||||||
|
printlogo.set((Integer) logoSource);
|
||||||
|
prefs.saveInt("print_logo", (Integer) logoSource);
|
||||||
|
prefs.remove("print_logo_path");
|
||||||
|
} else if (logoSource instanceof String) {
|
||||||
|
printlogo.set(-1);
|
||||||
|
prefs.saveInt("print_logo", -1);
|
||||||
|
prefs.saveString("print_logo_path", (String) logoSource);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Visibility
|
// Visibility
|
||||||
boolean logoVisible = config.optBoolean("footerLogoVisibility", DEFAULT_FOOTER_LOGO_VISIBILITY);
|
boolean logoVisible = config.optBoolean("footerLogoVisibility", DEFAULT_FOOTER_LOGO_VISIBILITY);
|
||||||
footerLogoVisibility.set(logoVisible);
|
footerLogoVisibility.set(logoVisible);
|
||||||
footerTextVisibility.set(!logoVisible);
|
footerTextVisibility.set(!logoVisible);
|
||||||
|
|
||||||
|
// Bank Mode
|
||||||
|
boolean bankMode = config.optBoolean("bankMode", DEFAULT_BANK_MODE);
|
||||||
|
bankmode.set(bankMode);
|
||||||
|
|
||||||
// Texts
|
// Texts
|
||||||
footerGreetingText.set(config.optString("footerGreetingText", DEFAULT_FOOTER_GREETING_TEXT));
|
footerGreetingText.set(config.optString("footerGreetingText", DEFAULT_FOOTER_GREETING_TEXT));
|
||||||
|
|
||||||
|
printUrlText.set(config.optString("printUrlText", DEFAULT_PRINT_URL_TEXT));
|
||||||
|
|
||||||
footerText.set(config.optString("footerText", DEFAULT_FOOTER_TEXT));
|
footerText.set(config.optString("footerText", DEFAULT_FOOTER_TEXT));
|
||||||
primaryColor.set(config.optString("primaryColor", DEFAULT_PRIMARY_COLOR));
|
primaryColor.set(config.optString("primaryColor", DEFAULT_PRIMARY_COLOR));
|
||||||
|
secondaryColor.set(config.optString("secondaryColor", DEFAULT_SECONDARY_COLOR));
|
||||||
|
|
||||||
|
|
||||||
Log.d(TAG, "Main config updated");
|
Log.d(TAG, "Main config updated");
|
||||||
}
|
}
|
||||||
|
@ -289,16 +333,26 @@ public class PosParameters {
|
||||||
private static void saveCurrentConfigToPrefs(PreferencesManager prefs) {
|
private static void saveCurrentConfigToPrefs(PreferencesManager prefs) {
|
||||||
prefs.saveInt(PREF_MAIN_LOGO, mainLogo.get());
|
prefs.saveInt(PREF_MAIN_LOGO, mainLogo.get());
|
||||||
prefs.saveInt(PREF_FOOTER_LOGO, footerLogo.get());
|
prefs.saveInt(PREF_FOOTER_LOGO, footerLogo.get());
|
||||||
|
prefs.saveInt(PREF_PRINT_LOGO, printlogo.get());
|
||||||
|
|
||||||
prefs.saveString(PREF_FOOTER_GREETING_TEXT, footerGreetingText.get());
|
prefs.saveString(PREF_FOOTER_GREETING_TEXT, footerGreetingText.get());
|
||||||
|
prefs.saveString(PREF_PRINT_URL_TEXT, printUrlText.get());
|
||||||
|
|
||||||
prefs.saveString(PREF_FOOTER_TEXT, footerText.get());
|
prefs.saveString(PREF_FOOTER_TEXT, footerText.get());
|
||||||
prefs.saveString(PREF_PRIMARY_COLOR, primaryColor.get());
|
prefs.saveString(PREF_PRIMARY_COLOR, primaryColor.get());
|
||||||
|
prefs.saveString(PREF_SECONDARY_COLOR, secondaryColor.get());
|
||||||
|
|
||||||
prefs.saveBoolean(PREF_FOOTER_LOGO_VISIBILITY, footerLogoVisibility.get());
|
prefs.saveBoolean(PREF_FOOTER_LOGO_VISIBILITY, footerLogoVisibility.get());
|
||||||
|
prefs.saveBoolean(PREF_BANK_MODE, bankmode.get());
|
||||||
|
|
||||||
// Debug log for each config value being saved
|
// Debug log for each config value being saved
|
||||||
Log.d(TAG, "Saved current config to prefs: \n"
|
Log.d(TAG, "Saved current config to prefs: \n"
|
||||||
+ " * footerGreetingText: " + footerGreetingText.get() + " \n"
|
+ " * footerGreetingText: " + footerGreetingText.get() + " \n"
|
||||||
+ " * footerText: " + footerText.get() + " \n"
|
+ " * footerText: " + footerText.get() + " \n"
|
||||||
+ " * primaryColor: " + primaryColor.get() + " \n"
|
+ " * primaryColor: " + primaryColor.get() + " \n"
|
||||||
+ " * footerLogoVisibility: " + footerLogoVisibility.get()
|
+ " * printUrlText: " + printUrlText.get()
|
||||||
|
+ " * secondaryColor: " + secondaryColor.get()
|
||||||
|
+ " * bankmode: " + bankmode.get()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 1.4 MiB |
|
@ -17,12 +17,13 @@
|
||||||
<!-- binding:onClickCommand="@{viewModel.actionCommand}"-->
|
<!-- binding:onClickCommand="@{viewModel.actionCommand}"-->
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
android:id="@+id/full_container"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
|
||||||
android:padding="16dp"
|
android:padding="16dp"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:background="@drawable/wallpaper_8f25c3"
|
android:background="@{viewModel.backgroundResId}"
|
||||||
app:layout_constraintVertical_chainStyle="packed"
|
app:layout_constraintVertical_chainStyle="packed"
|
||||||
app:layout_constraintHorizontal_chainStyle="packed">
|
app:layout_constraintHorizontal_chainStyle="packed">
|
||||||
|
|
||||||
|
@ -180,7 +181,7 @@
|
||||||
app:layout_constraintEnd_toEndOf="parent">
|
app:layout_constraintEnd_toEndOf="parent">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:textColor="@color/white"
|
android:textColor="@{viewModel.footerTextColor}"
|
||||||
android:id="@+id/footertext"
|
android:id="@+id/footertext"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
|
|
@ -32,11 +32,14 @@
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="100dp"
|
android:layout_height="100dp"
|
||||||
android:src="@{viewModel.icon}"
|
android:src="@{viewModel.icon}"
|
||||||
|
app:primaryColor="@{viewModel.primaryColor}"
|
||||||
|
app:secondaryColor="@{viewModel.secondaryColor}"
|
||||||
|
app:isBankMode="@{viewModel.bankMode}"
|
||||||
android:scaleType="fitCenter"
|
android:scaleType="fitCenter"
|
||||||
tools:src="@drawable/ax_card_grey" /> <!-- Use your actual default drawable -->
|
tools:src="@drawable/ax_card_grey" /> <!-- Use your actual default drawable -->
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:textColor="@color/white"
|
android:textColor="@{viewModel.textColor}"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="8dp"
|
android:layout_marginTop="8dp"
|
||||||
|
|
Loading…
Reference in New Issue