diff --git a/app/src/main/java/net/mynero/wallet/fragment/home/HomeFragment.java b/app/src/main/java/net/mynero/wallet/fragment/home/HomeFragment.java index 838b422..ecf8379 100644 --- a/app/src/main/java/net/mynero/wallet/fragment/home/HomeFragment.java +++ b/app/src/main/java/net/mynero/wallet/fragment/home/HomeFragment.java @@ -31,6 +31,7 @@ import net.mynero.wallet.model.WalletManager; import net.mynero.wallet.service.BalanceService; import net.mynero.wallet.service.BlockchainService; import net.mynero.wallet.service.HistoryService; +import net.mynero.wallet.service.PrefService; import net.mynero.wallet.util.Constants; import java.util.Collections; @@ -133,6 +134,7 @@ public class HomeFragment extends Fragment implements TransactionInfoAdapter.TxI if (history.isEmpty()) { txHistoryRecyclerView.setVisibility(View.GONE); noHistoryLayout.setVisibility(View.VISIBLE); + displayEmptyHistory(view); } else { Collections.sort(history); if (history.size() > 100) { @@ -164,4 +166,17 @@ public class HomeFragment extends Fragment implements TransactionInfoAdapter.TxI } } } + + private void displayEmptyHistory(View view) { + boolean displayMonerochan = PrefService.getInstance().getBoolean(Constants.PREF_MONEROCHAN, true); + if(displayMonerochan) { + view.findViewById(R.id.monerochan_imageview).setVisibility(View.VISIBLE); + view.findViewById(R.id.monerochan_empty_tx_textview).setVisibility(View.VISIBLE); + view.findViewById(R.id.empty_tx_textview).setVisibility(View.GONE); + } else { + view.findViewById(R.id.monerochan_imageview).setVisibility(View.GONE); + view.findViewById(R.id.monerochan_empty_tx_textview).setVisibility(View.GONE); + view.findViewById(R.id.empty_tx_textview).setVisibility(View.VISIBLE); + } + } } \ No newline at end of file diff --git a/app/src/main/java/net/mynero/wallet/fragment/settings/SettingsFragment.java b/app/src/main/java/net/mynero/wallet/fragment/settings/SettingsFragment.java index 172e765..81380b6 100644 --- a/app/src/main/java/net/mynero/wallet/fragment/settings/SettingsFragment.java +++ b/app/src/main/java/net/mynero/wallet/fragment/settings/SettingsFragment.java @@ -35,6 +35,7 @@ import net.mynero.wallet.model.Wallet; import net.mynero.wallet.model.WalletManager; import net.mynero.wallet.service.BalanceService; import net.mynero.wallet.service.BlockchainService; +import net.mynero.wallet.service.HistoryService; import net.mynero.wallet.service.PrefService; import net.mynero.wallet.util.Constants; import net.mynero.wallet.util.DayNightMode; @@ -99,6 +100,7 @@ public class SettingsFragment extends Fragment implements PasswordBottomSheetDia selectNodeButton = view.findViewById(R.id.select_node_button); SwitchCompat nightModeSwitch = view.findViewById(R.id.day_night_switch); SwitchCompat streetModeSwitch = view.findViewById(R.id.street_mode_switch); + SwitchCompat monerochanSwitch = view.findViewById(R.id.monerochan_switch); SwitchCompat torSwitch = view.findViewById(R.id.tor_switch); ConstraintLayout proxySettingsLayout = view.findViewById(R.id.wallet_proxy_settings_layout); walletProxyAddressEditText = view.findViewById(R.id.wallet_proxy_address_edittext); @@ -119,6 +121,12 @@ public class SettingsFragment extends Fragment implements PasswordBottomSheetDia BalanceService.getInstance().refreshBalance(); }); + monerochanSwitch.setChecked(PrefService.getInstance().getBoolean(Constants.PREF_MONEROCHAN, true)); + monerochanSwitch.setOnCheckedChangeListener((compoundButton, b) -> { + PrefService.getInstance().edit().putBoolean(Constants.PREF_MONEROCHAN, b).apply(); + HistoryService.getInstance().refreshHistory(); + }); + boolean usesProxy = PrefService.getInstance().getBoolean(Constants.PREF_USES_TOR, false); String proxy = PrefService.getInstance().getString(Constants.PREF_PROXY, ""); if (proxy.contains(":")) { diff --git a/app/src/main/java/net/mynero/wallet/service/PrefService.java b/app/src/main/java/net/mynero/wallet/service/PrefService.java index b66d34c..e865c50 100644 --- a/app/src/main/java/net/mynero/wallet/service/PrefService.java +++ b/app/src/main/java/net/mynero/wallet/service/PrefService.java @@ -98,8 +98,9 @@ public class PrefService extends ServiceBase { } public boolean getBoolean(String key, boolean defaultValue) { + boolean containsKey = preferences.contains(key); boolean value = preferences.getBoolean(key, false); - if(!value && defaultValue) { + if(!value && defaultValue && !containsKey) { edit().putBoolean(key, true).apply(); return true; } diff --git a/app/src/main/java/net/mynero/wallet/util/Constants.java b/app/src/main/java/net/mynero/wallet/util/Constants.java index 864f263..939f956 100644 --- a/app/src/main/java/net/mynero/wallet/util/Constants.java +++ b/app/src/main/java/net/mynero/wallet/util/Constants.java @@ -11,6 +11,7 @@ public class Constants { public static final String PREF_CUSTOM_NODES = "pref_custom_nodes"; public static final String PREF_USES_OFFSET = "pref_uses_offset"; public static final String PREF_STREET_MODE = "pref_street_mode"; + public static final String PREF_MONEROCHAN = "pref_monerochan"; public static final String URI_PREFIX = "monero:"; public static final String URI_ARG_AMOUNT = "tx_amount"; diff --git a/app/src/main/res/layout/fragment_home.xml b/app/src/main/res/layout/fragment_home.xml index 9cbb04b..10240cb 100644 --- a/app/src/main/res/layout/fragment_home.xml +++ b/app/src/main/res/layout/fragment_home.xml @@ -72,9 +72,9 @@ android:src="@drawable/xmrchan_png" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintStart_toStartOf="parent" - app:layout_constraintEnd_toStartOf="@id/empty_tx_textview"/> + app:layout_constraintEnd_toStartOf="@id/monerochan_empty_tx_textview"/> + + + + + + app:layout_constraintTop_toBottomOf="@id/monerochan_switch" />