aboutsummaryrefslogtreecommitdiff
path: root/wallet
diff options
context:
space:
mode:
Diffstat (limited to 'wallet')
-rw-r--r--wallet/src/main/java/net/taler/wallet/MainActivity.kt8
-rw-r--r--wallet/src/main/java/net/taler/wallet/MainFragment.kt8
-rw-r--r--wallet/src/main/java/net/taler/wallet/balances/BalancesFragment.kt6
-rw-r--r--wallet/src/main/java/net/taler/wallet/transactions/TransactionsFragment.kt31
-rw-r--r--wallet/src/main/res/layout/fragment_transactions.xml9
-rw-r--r--wallet/src/main/res/navigation/nav_graph.xml6
6 files changed, 44 insertions, 24 deletions
diff --git a/wallet/src/main/java/net/taler/wallet/MainActivity.kt b/wallet/src/main/java/net/taler/wallet/MainActivity.kt
index baf0609..0e04f44 100644
--- a/wallet/src/main/java/net/taler/wallet/MainActivity.kt
+++ b/wallet/src/main/java/net/taler/wallet/MainActivity.kt
@@ -94,19 +94,19 @@ class MainActivity : AppCompatActivity(), OnNavigationItemSelectedListener,
)
ui.content.toolbar.setupWithNavController(nav, appBarConfiguration)
- model.showProgressBar.observe(this, { show ->
+ model.showProgressBar.observe(this) { show ->
ui.content.progressBar.visibility = if (show) VISIBLE else INVISIBLE
- })
+ }
val versionView: TextView = ui.navView.getHeaderView(0).findViewById(R.id.versionView)
- model.devMode.observe(this, { enabled ->
+ model.devMode.observe(this) { enabled ->
ui.navView.menu.findItem(R.id.nav_dev).isVisible = enabled
if (enabled) {
@SuppressLint("SetTextI18n")
versionView.text = "$VERSION_NAME ($VERSION_CODE)"
versionView.visibility = VISIBLE
} else versionView.visibility = GONE
- })
+ }
if (intent.action == ACTION_VIEW) intent.dataString?.let { uri ->
handleTalerUri(uri, "intent")
diff --git a/wallet/src/main/java/net/taler/wallet/MainFragment.kt b/wallet/src/main/java/net/taler/wallet/MainFragment.kt
index 1479bc0..6c84925 100644
--- a/wallet/src/main/java/net/taler/wallet/MainFragment.kt
+++ b/wallet/src/main/java/net/taler/wallet/MainFragment.kt
@@ -43,16 +43,16 @@ class MainFragment : Fragment() {
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
- savedInstanceState: Bundle?
- ): View? {
+ savedInstanceState: Bundle?,
+ ): View {
ui = FragmentMainBinding.inflate(inflater, container, false)
return ui.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
- model.balances.observe(viewLifecycleOwner, {
+ model.balances.observe(viewLifecycleOwner) {
onBalancesChanged(it)
- })
+ }
model.transactionsEvent.observe(viewLifecycleOwner, EventObserver { currency ->
// we only need to navigate to a dedicated list, when in multi-currency mode
if (currencyMode == MULTI) {
diff --git a/wallet/src/main/java/net/taler/wallet/balances/BalancesFragment.kt b/wallet/src/main/java/net/taler/wallet/balances/BalancesFragment.kt
index afd9a23..c1be674 100644
--- a/wallet/src/main/java/net/taler/wallet/balances/BalancesFragment.kt
+++ b/wallet/src/main/java/net/taler/wallet/balances/BalancesFragment.kt
@@ -48,7 +48,7 @@ class BalancesFragment : Fragment(),
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
- ): View? {
+ ): View {
ui = FragmentBalancesBinding.inflate(inflater, container, false)
return ui.root
}
@@ -59,9 +59,9 @@ class BalancesFragment : Fragment(),
addItemDecoration(DividerItemDecoration(context, VERTICAL))
}
- model.balances.observe(viewLifecycleOwner, {
+ model.balances.observe(viewLifecycleOwner) {
onBalancesChanged(it)
- })
+ }
}
private fun onBalancesChanged(balances: List<BalanceItem>) {
diff --git a/wallet/src/main/java/net/taler/wallet/transactions/TransactionsFragment.kt b/wallet/src/main/java/net/taler/wallet/transactions/TransactionsFragment.kt
index e63d451..ff2574f 100644
--- a/wallet/src/main/java/net/taler/wallet/transactions/TransactionsFragment.kt
+++ b/wallet/src/main/java/net/taler/wallet/transactions/TransactionsFragment.kt
@@ -23,6 +23,7 @@ import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import android.view.View
+import android.view.View.INVISIBLE
import android.view.ViewGroup
import android.widget.Toast
import android.widget.Toast.LENGTH_LONG
@@ -42,6 +43,7 @@ import net.taler.common.fadeOut
import net.taler.wallet.MainViewModel
import net.taler.wallet.R
import net.taler.wallet.databinding.FragmentTransactionsBinding
+import net.taler.wallet.scanQrCode
interface OnTransactionClickListener {
fun onTransactionClicked(transaction: Transaction)
@@ -65,8 +67,8 @@ class TransactionsFragment : Fragment(), OnTransactionClickListener, ActionMode.
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
- savedInstanceState: Bundle?
- ): View? {
+ savedInstanceState: Bundle?,
+ ): View {
ui = FragmentTransactionsBinding.inflate(inflater, container, false)
return ui.root
}
@@ -103,22 +105,27 @@ class TransactionsFragment : Fragment(), OnTransactionClickListener, ActionMode.
}
})
- transactionManager.progress.observe(viewLifecycleOwner, { show ->
- if (show) ui.progressBar.fadeIn() else ui.progressBar.fadeOut()
- })
- transactionManager.transactions.observe(viewLifecycleOwner, { result ->
- onTransactionsResult(result)
- })
- }
-
- override fun onActivityCreated(savedInstanceState: Bundle?) {
- super.onActivityCreated(savedInstanceState)
model.balances.observe(viewLifecycleOwner) { balances ->
+ // hide extra fab when in single currency mode (uses MainFragment's FAB)
+ if (balances.size == 1) ui.mainFab.visibility = INVISIBLE
balances.find { it.currency == currency }?.available?.let { amount: Amount ->
requireActivity().title =
getString(R.string.transactions_detail_title_balance, amount)
}
}
+ transactionManager.progress.observe(viewLifecycleOwner) { show ->
+ if (show) ui.progressBar.fadeIn() else ui.progressBar.fadeOut()
+ }
+ transactionManager.transactions.observe(viewLifecycleOwner) { result ->
+ onTransactionsResult(result)
+ }
+ ui.mainFab.setOnClickListener {
+ scanQrCode(requireActivity())
+ }
+ ui.mainFab.setOnLongClickListener {
+ findNavController().navigate(R.id.action_nav_transactions_to_nav_uri_input)
+ true
+ }
}
override fun onSaveInstanceState(outState: Bundle) {
diff --git a/wallet/src/main/res/layout/fragment_transactions.xml b/wallet/src/main/res/layout/fragment_transactions.xml
index aaf638c..22d6d48 100644
--- a/wallet/src/main/res/layout/fragment_transactions.xml
+++ b/wallet/src/main/res/layout/fragment_transactions.xml
@@ -48,4 +48,13 @@
android:visibility="invisible"
tools:visibility="visible" />
+ <com.google.android.material.floatingactionbutton.FloatingActionButton
+ android:id="@+id/mainFab"
+ style="@style/FabStyle"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:contentDescription="@string/button_scan_qr_code"
+ android:src="@drawable/ic_scan_qr"
+ app:layout_behavior="com.google.android.material.behavior.HideBottomViewOnScrollBehavior" />
+
</FrameLayout>
diff --git a/wallet/src/main/res/navigation/nav_graph.xml b/wallet/src/main/res/navigation/nav_graph.xml
index b3f96c5..f0048d9 100644
--- a/wallet/src/main/res/navigation/nav_graph.xml
+++ b/wallet/src/main/res/navigation/nav_graph.xml
@@ -118,7 +118,11 @@
android:id="@+id/nav_transactions"
android:name="net.taler.wallet.transactions.TransactionsFragment"
android:label="@string/transactions_title"
- tools:layout="@layout/fragment_transactions" />
+ tools:layout="@layout/fragment_transactions" >
+ <action
+ android:id="@+id/action_nav_transactions_to_nav_uri_input"
+ app:destination="@id/nav_uri_input" />
+ </fragment>
<fragment
android:id="@+id/nav_transactions_detail_withdrawal"