add PosParameters new params secondaryColor bankMode printLogo
This commit is contained in:
parent
8b892e68df
commit
f53cd006bd
|
@ -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
|
||||||
|
|
|
@ -66,9 +66,11 @@ 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<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<>();
|
||||||
|
@ -235,6 +237,14 @@ 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 +407,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 +504,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: 30 MiB |
Loading…
Reference in New Issue