summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTorsten Grote <t@grobox.de>2020-03-16 10:45:38 -0300
committerTorsten Grote <t@grobox.de>2020-03-16 10:45:38 -0300
commitc9abffa821fd3ecbb8038753726fdbd07fcae914 (patch)
tree21f307ccfeda2cfda72321c0e8dc9ca030742ae0
parent318fc3207e83267a41c85279970d20dd7c5f27f6 (diff)
downloadwallet-android-c9abffa821fd3ecbb8038753726fdbd07fcae914.tar.gz
wallet-android-c9abffa821fd3ecbb8038753726fdbd07fcae914.tar.bz2
wallet-android-c9abffa821fd3ecbb8038753726fdbd07fcae914.zip
Hide reload balance/history menu items when not in dev mode
-rw-r--r--app/src/main/java/net/taler/wallet/BalanceFragment.kt5
-rw-r--r--app/src/main/java/net/taler/wallet/history/WalletHistoryFragment.kt8
2 files changed, 13 insertions, 0 deletions
diff --git a/app/src/main/java/net/taler/wallet/BalanceFragment.kt b/app/src/main/java/net/taler/wallet/BalanceFragment.kt
index b9f5818..84a1b3c 100644
--- a/app/src/main/java/net/taler/wallet/BalanceFragment.kt
+++ b/app/src/main/java/net/taler/wallet/BalanceFragment.kt
@@ -46,6 +46,7 @@ class BalanceFragment : Fragment() {
private val model: WalletViewModel by activityViewModels()
private val withdrawManager by lazy { model.withdrawManager }
+ private var reloadBalanceMenuItem: MenuItem? = null
private val balancesAdapter = BalanceAdapter()
override fun onCreate(savedInstanceState: Bundle?) {
@@ -75,6 +76,7 @@ class BalanceFragment : Fragment() {
model.devMode.observe(viewLifecycleOwner, Observer { enabled ->
delayedTransition()
testWithdrawButton.visibility = if (enabled) VISIBLE else GONE
+ reloadBalanceMenuItem?.isVisible = enabled
})
testWithdrawButton.setOnClickListener {
withdrawManager.withdrawTestkudos()
@@ -117,6 +119,9 @@ class BalanceFragment : Fragment() {
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
inflater.inflate(R.menu.balance, menu)
menu.findItem(R.id.developer_mode).isChecked = model.devMode.value!!
+ reloadBalanceMenuItem = menu.findItem(R.id.reload_balance).apply {
+ isVisible = model.devMode.value!!
+ }
super.onCreateOptionsMenu(menu, inflater)
}
diff --git a/app/src/main/java/net/taler/wallet/history/WalletHistoryFragment.kt b/app/src/main/java/net/taler/wallet/history/WalletHistoryFragment.kt
index 75b7d02..4f8ab82 100644
--- a/app/src/main/java/net/taler/wallet/history/WalletHistoryFragment.kt
+++ b/app/src/main/java/net/taler/wallet/history/WalletHistoryFragment.kt
@@ -31,6 +31,7 @@ import androidx.lifecycle.Observer
import androidx.recyclerview.widget.DividerItemDecoration
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager.VERTICAL
+import kotlinx.android.synthetic.main.fragment_show_balance.*
import kotlinx.android.synthetic.main.fragment_show_history.*
import net.taler.wallet.R
import net.taler.wallet.WalletViewModel
@@ -44,6 +45,7 @@ class WalletHistoryFragment : Fragment(), OnEventClickListener {
private val model: WalletViewModel by activityViewModels()
private val historyManager by lazy { model.historyManager }
private lateinit var showAllItem: MenuItem
+ private var reloadHistoryItem: MenuItem? = null
private val historyAdapter = WalletHistoryAdapter(this)
override fun onCreate(savedInstanceState: Bundle?) {
@@ -65,6 +67,9 @@ class WalletHistoryFragment : Fragment(), OnEventClickListener {
addItemDecoration(DividerItemDecoration(context, VERTICAL))
}
+ model.devMode.observe(viewLifecycleOwner, Observer { enabled ->
+ reloadHistoryItem?.isVisible = enabled
+ })
historyManager.progress.observe(viewLifecycleOwner, Observer { show ->
historyProgressBar.visibility = if (show) VISIBLE else INVISIBLE
})
@@ -81,6 +86,9 @@ class WalletHistoryFragment : Fragment(), OnEventClickListener {
inflater.inflate(R.menu.history, menu)
showAllItem = menu.findItem(R.id.show_all_history)
showAllItem.isChecked = historyManager.showAll.value == true
+ reloadHistoryItem = menu.findItem(R.id.reload_history).apply {
+ isVisible = model.devMode.value!!
+ }
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {