gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-taler-android] branch master updated (688b7a2 -> c435770)


From: gnunet
Subject: [taler-taler-android] branch master updated (688b7a2 -> c435770)
Date: Wed, 13 May 2020 15:12:55 +0200

This is an automated email from the git hooks/post-receive script.

torsten-grote pushed a change to branch master
in repository taler-android.

    from 688b7a2  [wallet] upgrade wallet-core and show supported versions in 
settings
     new 508a12b  [wallet] adapt fee parsing to wallet-core changes
     new c435770  [wallet] switch to multi-currency mode when a new currency 
gets added

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 wallet/build.gradle                                |  9 ++++--
 .../src/main/java/net/taler/wallet/MainFragment.kt |  9 ++++--
 .../java/net/taler/wallet/withdraw/ExchangeFees.kt | 36 ++++++++++------------
 .../wallet/withdraw/SelectExchangeFragment.kt      | 17 +++++-----
 .../main/res/layout/fragment_select_exchange.xml   | 15 ++++++---
 5 files changed, 47 insertions(+), 39 deletions(-)

diff --git a/wallet/build.gradle b/wallet/build.gradle
index b86f99c..f976b24 100644
--- a/wallet/build.gradle
+++ b/wallet/build.gradle
@@ -23,7 +23,7 @@ plugins {
     id "de.undercouch.download"
 }
 
-def walletCoreVersion = "v0.7.1-dev.2"
+def walletCoreVersion = "v0.7.1-dev.3"
 
 android {
     compileSdkVersion 29
@@ -35,7 +35,7 @@ android {
         minSdkVersion 24
         targetSdkVersion 29
         versionCode 6
-        versionName "0.7.1.dev.1"
+        versionName "0.7.1.dev.3"
         testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
         buildConfigField "String", "WALLET_CORE_VERSION", 
"\"$walletCoreVersion\""
     }
@@ -112,6 +112,11 @@ task downloadWalletLibrary(type: Download) {
     overwrite false
     doFirst {
         new File(walletLibraryDir).mkdirs()
+        if (!file(dest).exists()) {  // delete old versions before fetching 
new one
+            delete fileTree(walletLibraryDir) {
+                include 'taler-wallet-android-*.js'
+            }
+        }
     }
 }
 tasks.withType(MergeResources) {
diff --git a/wallet/src/main/java/net/taler/wallet/MainFragment.kt 
b/wallet/src/main/java/net/taler/wallet/MainFragment.kt
index 0bc6084..2905238 100644
--- a/wallet/src/main/java/net/taler/wallet/MainFragment.kt
+++ b/wallet/src/main/java/net/taler/wallet/MainFragment.kt
@@ -30,6 +30,7 @@ import net.taler.wallet.transactions.TransactionsFragment
 class MainFragment : Fragment() {
 
     private val model: MainViewModel by activityViewModels()
+    private var currentTag: String? = null
 
     override fun onCreateView(
         inflater: LayoutInflater,
@@ -55,15 +56,17 @@ class MainFragment : Fragment() {
     }
 
     private fun onBalancesChanged(balances: List<BalanceItem>) {
-        if (childFragmentManager.fragments.isEmpty()) {
-            val f = if (balances.size == 1) {
+        val tag = if (balances.size == 1) "single" else "multi"
+        if (currentTag != tag) {
+            val f = if (tag == "single") {
                 model.transactionManager.selectedCurrency = 
balances[0].available.currency
                 TransactionsFragment()
             } else {
                 BalancesFragment()
             }
+            currentTag = tag
             childFragmentManager.beginTransaction()
-                .add(R.id.mainFragmentContainer, f)
+                .replace(R.id.mainFragmentContainer, f, tag)
                 .commitNow()
         }
     }
diff --git a/wallet/src/main/java/net/taler/wallet/withdraw/ExchangeFees.kt 
b/wallet/src/main/java/net/taler/wallet/withdraw/ExchangeFees.kt
index 4494e38..9c815c9 100644
--- a/wallet/src/main/java/net/taler/wallet/withdraw/ExchangeFees.kt
+++ b/wallet/src/main/java/net/taler/wallet/withdraw/ExchangeFees.kt
@@ -22,17 +22,13 @@ import org.json.JSONObject
 
 data class CoinFee(
     val coin: Amount,
+    val quantity: Int,
     val feeDeposit: Amount,
     val feeRefresh: Amount,
     val feeRefund: Amount,
     val feeWithdraw: Amount
 )
 
-data class CoinFees(
-    val quantity: Int,
-    val coinFee: CoinFee
-)
-
 data class WireFee(
     val start: Timestamp,
     val end: Timestamp,
@@ -44,26 +40,28 @@ data class ExchangeFees(
     val withdrawFee: Amount,
     val overhead: Amount,
     val earliestDepositExpiration: Timestamp,
-    val coinFees: List<CoinFees>,
+    val coinFees: List<CoinFee>,
     val wireFees: List<WireFee>
 ) {
     companion object {
         fun fromExchangeWithdrawDetailsJson(json: JSONObject): ExchangeFees {
             val earliestDepositExpiration =
                 json.getJSONObject("earliestDepositExpiration").getLong("t_ms")
-
-            val selectedDenoms = json.getJSONArray("selectedDenoms")
-            val coinFees = HashMap<CoinFee, Int>(selectedDenoms.length())
-            for (i in 0 until selectedDenoms.length()) {
-                val denom = selectedDenoms.getJSONObject(i)
+            val selectedDenoms = json.getJSONObject("selectedDenoms")
+            val denoms = selectedDenoms.getJSONArray("selectedDenoms")
+            val coinFees = ArrayList<CoinFee>(denoms.length())
+            for (i in 0 until denoms.length()) {
+                val denom = denoms.getJSONObject(i)
+                val d = denom.getJSONObject("denom")
                 val coinFee = CoinFee(
-                    coin = Amount.fromJsonObject(denom.getJSONObject("value")),
-                    feeDeposit = 
Amount.fromJsonObject(denom.getJSONObject("feeDeposit")),
-                    feeRefresh = 
Amount.fromJsonObject(denom.getJSONObject("feeRefresh")),
-                    feeRefund = 
Amount.fromJsonObject(denom.getJSONObject("feeRefund")),
-                    feeWithdraw = 
Amount.fromJsonObject(denom.getJSONObject("feeWithdraw"))
+                    coin = Amount.fromJsonObject(d.getJSONObject("value")),
+                    quantity = denom.getInt("count"),
+                    feeDeposit = 
Amount.fromJsonObject(d.getJSONObject("feeDeposit")),
+                    feeRefresh = 
Amount.fromJsonObject(d.getJSONObject("feeRefresh")),
+                    feeRefund = 
Amount.fromJsonObject(d.getJSONObject("feeRefund")),
+                    feeWithdraw = 
Amount.fromJsonObject(d.getJSONObject("feeWithdraw"))
                 )
-                coinFees[coinFee] = (coinFees[coinFee] ?: 0) + 1
+                coinFees.add(coinFee)
             }
 
             val wireFeesJson = json.getJSONObject("wireFees")
@@ -89,9 +87,7 @@ data class ExchangeFees(
                 withdrawFee = 
Amount.fromJsonObject(json.getJSONObject("withdrawFee")),
                 overhead = 
Amount.fromJsonObject(json.getJSONObject("overhead")),
                 earliestDepositExpiration = 
Timestamp(earliestDepositExpiration),
-                coinFees = coinFees.map { (coinFee, quantity) ->
-                    CoinFees(quantity, coinFee)
-                },
+                coinFees = coinFees,
                 wireFees = wireFees
             )
         }
diff --git 
a/wallet/src/main/java/net/taler/wallet/withdraw/SelectExchangeFragment.kt 
b/wallet/src/main/java/net/taler/wallet/withdraw/SelectExchangeFragment.kt
index fd614c6..2ade9f2 100644
--- a/wallet/src/main/java/net/taler/wallet/withdraw/SelectExchangeFragment.kt
+++ b/wallet/src/main/java/net/taler/wallet/withdraw/SelectExchangeFragment.kt
@@ -31,8 +31,8 @@ import 
kotlinx.android.synthetic.main.fragment_select_exchange.*
 import net.taler.common.Amount
 import net.taler.common.toRelativeTime
 import net.taler.common.toShortDate
-import net.taler.wallet.R
 import net.taler.wallet.MainViewModel
+import net.taler.wallet.R
 import net.taler.wallet.withdraw.CoinFeeAdapter.CoinFeeViewHolder
 import net.taler.wallet.withdraw.WireFeeAdapter.WireFeeViewHolder
 
@@ -73,7 +73,7 @@ class SelectExchangeFragment : Fragment() {
 
 }
 
-private class CoinFeeAdapter(private val items: List<CoinFees>) : 
Adapter<CoinFeeViewHolder>() {
+private class CoinFeeAdapter(private val items: List<CoinFee>) : 
Adapter<CoinFeeViewHolder>() {
     override fun getItemCount() = items.size
     override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): 
CoinFeeViewHolder {
         val v =
@@ -92,22 +92,21 @@ private class CoinFeeAdapter(private val items: 
List<CoinFees>) : Adapter<CoinFe
         private val depositFeeView: TextView = 
v.findViewById(R.id.depositFeeView)
         private val refreshFeeView: TextView = 
v.findViewById(R.id.refreshFeeView)
         private val refundFeeView: TextView = 
v.findViewById(R.id.refundFeeView)
-        fun bind(item: CoinFees) {
-            val fee = item.coinFee
+        fun bind(item: CoinFee) {
             coinView.text = res.getQuantityString(
                 R.plurals.exchange_fee_coin,
                 item.quantity,
-                fee.coin,
+                item.coin,
                 item.quantity
             )
             withdrawFeeView.text =
-                v.context.getString(R.string.exchange_fee_withdraw_fee, 
fee.feeWithdraw)
+                v.context.getString(R.string.exchange_fee_withdraw_fee, 
item.feeWithdraw)
             depositFeeView.text =
-                v.context.getString(R.string.exchange_fee_deposit_fee, 
fee.feeDeposit)
+                v.context.getString(R.string.exchange_fee_deposit_fee, 
item.feeDeposit)
             refreshFeeView.text =
-                v.context.getString(R.string.exchange_fee_refresh_fee, 
fee.feeRefresh)
+                v.context.getString(R.string.exchange_fee_refresh_fee, 
item.feeRefresh)
             refundFeeView.text =
-                v.context.getString(R.string.exchange_fee_refund_fee, 
fee.feeRefresh)
+                v.context.getString(R.string.exchange_fee_refund_fee, 
item.feeRefresh)
         }
     }
 }
diff --git a/wallet/src/main/res/layout/fragment_select_exchange.xml 
b/wallet/src/main/res/layout/fragment_select_exchange.xml
index cb8d35a..6f8814f 100644
--- a/wallet/src/main/res/layout/fragment_select_exchange.xml
+++ b/wallet/src/main/res/layout/fragment_select_exchange.xml
@@ -80,7 +80,8 @@
             android:layout_width="0dp"
             android:layout_height="wrap_content"
             android:layout_marginStart="8dp"
-            app:layout_constraintEnd_toEndOf="@+id/withdrawFeeView"
+            android:layout_marginEnd="16dp"
+            app:layout_constraintEnd_toEndOf="parent"
             app:layout_constraintStart_toEndOf="@+id/expirationLabel"
             app:layout_constraintTop_toTopOf="@+id/expirationLabel"
             tools:text="in 5 years" />
@@ -100,11 +101,13 @@
             android:id="@+id/coinFeesList"
             android:layout_width="0dp"
             android:layout_height="wrap_content"
+            android:layout_marginStart="16dp"
             android:layout_marginTop="8dp"
+            android:layout_marginEnd="16dp"
             android:overScrollMode="never"
             
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
-            app:layout_constraintEnd_toEndOf="@+id/withdrawFeeView"
-            app:layout_constraintStart_toStartOf="@+id/withdrawFeeLabel"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintStart_toStartOf="parent"
             app:layout_constraintTop_toBottomOf="@+id/coinFeesLabel"
             tools:listitem="@layout/list_item_coin_fee" />
 
@@ -123,11 +126,13 @@
             android:id="@+id/wireFeesList"
             android:layout_width="0dp"
             android:layout_height="wrap_content"
+            android:layout_marginStart="16dp"
             android:layout_marginTop="8dp"
+            android:layout_marginEnd="16dp"
             android:overScrollMode="never"
             
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
-            app:layout_constraintEnd_toEndOf="@+id/withdrawFeeView"
-            app:layout_constraintStart_toStartOf="@+id/withdrawFeeLabel"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintStart_toStartOf="parent"
             app:layout_constraintTop_toBottomOf="@+id/wireFeesLabel"
             tools:listitem="@layout/list_item_wire_fee" />
 

-- 
To stop receiving notification emails like this one, please contact
address@hidden.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]