Skip to content

Commit

Permalink
#186 fix export amount locale
Browse files Browse the repository at this point in the history
#163 fix max receive/send amount
#206 change empty password error
#208 fix confirm seed UI
hide utxo list in transaction details with privacy mode
  • Loading branch information
Miolin committed May 3, 2019
1 parent d4ad0dc commit e644d76
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 16 deletions.
2 changes: 1 addition & 1 deletion app/src/main/java/com/mw/beam/beamwallet/core/App.kt
Expand Up @@ -61,7 +61,7 @@ class App : Application() {
AppConfig.DB_PATH = filesDir.absolutePath
AppConfig.LOG_PATH = AppConfig.DB_PATH + "/logs"
AppConfig.TRANSACTIONS_PATH = AppConfig.DB_PATH + "/transactions"
AppConfig.LOCALE = Locale.getDefault()
//AppConfig.LOCALE = Locale.getDefault()

if (BuildConfig.DEBUG) {
LeakCanary.install(self)
Expand Down
Expand Up @@ -17,12 +17,14 @@
package com.mw.beam.beamwallet.core.helpers

import java.text.DecimalFormat
import java.text.DecimalFormatSymbols
import java.util.*

/**
* Created by vain onnellinen on 3/14/19.
*/
fun Long.convertToBeamString(): String = (this.toDouble() / 100000000).convertToBeamString()
fun Double.convertToBeamString(): String = DecimalFormat("#.########").format(this)
fun Double.convertToBeamString(): String = DecimalFormat("#.########").apply { decimalFormatSymbols = DecimalFormatSymbols.getInstance(Locale.US) }.format(this)
fun Long.convertToBeam(): Double = this.toDouble() / 100000000
fun Long.convertToBeamWithSign(isSent: Boolean) = if (isSent) "-${this.convertToBeamString()}" else "+${this.convertToBeamString()}"
fun Double.convertToGroth() = Math.round(this * 100000000)
Expand Up @@ -46,14 +46,14 @@ object TransactionFields {
fun formatTransaction(txDescription: TxDescription): String {
val sender = if (txDescription.sender.value) txDescription.myId else txDescription.peerId
val receiver = if (txDescription.sender.value) txDescription.peerId else txDescription.myId
return "${if (txDescription.sender.value) SEND_BEAM_TYPE else RECEIVE_BEAM_TYPE}," +
"${CalendarUtils.fromTimestampUS(txDescription.modifyTime)}," +
"${txDescription.amount.convertToBeamString()}," +
"${txDescription.statusString}," +
"$sender," +
"$receiver," +
"${txDescription.fee.convertToBeamString()}," +
"${txDescription.id}," +
return "${if (txDescription.sender.value) SEND_BEAM_TYPE else RECEIVE_BEAM_TYPE} ," +
"${CalendarUtils.fromTimestampUS(txDescription.modifyTime)} ," +
"${txDescription.amount.convertToBeamString()} ," +
"${txDescription.statusString} ," +
"$sender ," +
"$receiver ," +
"${txDescription.fee.convertToBeamString()} ," +
"${txDescription.id} ," +
"${txDescription.kernelId}\n"
}
}
Expand Up @@ -23,7 +23,7 @@ import android.text.Spanned
* Created by vain onnellinen on 2/11/19.
*/
class AmountFilter : InputFilter {
private val regExp = "^(([1-9][0-9]{0,7})|(1[0-9]{8})|(2[0-4][0-9]{7})|(25[0-3][0-9]{6})|(0))(\\.[0-9]{0,7}[1-9]?)?$".toRegex()
private val regExp = "^(([0-9]|[1-8][0-9]|9[0-9]|[1-8][0-9]{2}|9[0-8][0-9]|99[0-9]|[1-8][0-9]{3}|9[0-8][0-9]{2}|99[0-8][0-9]|999[0-9]|[1-8][0-9]{4}|9[0-8][0-9]{3}|99[0-8][0-9]{2}|999[0-8][0-9]|9999[0-9]|[1-8][0-9]{5}|9[0-8][0-9]{4}|99[0-8][0-9]{3}|999[0-8][0-9]{2}|9999[0-8][0-9]|99999[0-9]|[1-8][0-9]{6}|9[0-8][0-9]{5}|99[0-8][0-9]{4}|999[0-8][0-9]{3}|9999[0-8][0-9]{2}|99999[0-8][0-9]|999999[0-9]|[1-8][0-9]{7}|9[0-8][0-9]{6}|99[0-8][0-9]{5}|999[0-8][0-9]{4}|9999[0-8][0-9]{3}|99999[0-8][0-9]{2}|999999[0-8][0-9]|9999999[0-9]|1[0-9]{8}|2[0-5][0-9]{7}|26[01][0-9]{6}|262[0-7][0-9]{5})(\\.[0-9]{0,7}[1-9]?)?|262800000)$".toRegex()

override fun filter(source: CharSequence, start: Int, end: Int, dest: Spanned, dstart: Int, dend: Int): CharSequence? {
if (source.isNotEmpty()) {
Expand Down
Expand Up @@ -116,7 +116,7 @@ class SendConfirmationDialog : BaseDialogFragment<SendConfirmationPresenter>(),

override fun showEmptyPasswordError() {
pass.isStateError = true
passError.text = getString(R.string.pass_empty_error)
passError.text = getString(R.string.settings_password_empty_error)
passError.visibility = View.VISIBLE
}

Expand Down
Expand Up @@ -89,8 +89,8 @@ class TransactionDetailsActivity : BaseActivity<TransactionDetailsPresenter>(),
}

@SuppressLint("InflateParams")
override fun updateUtxos(utxoInfoList: List<UtxoInfoItem>) {
transactionUtxoContainer.visibility = if (utxoInfoList.isEmpty()) View.GONE else View.VISIBLE
override fun updateUtxos(utxoInfoList: List<UtxoInfoItem>, isEnablePrivacyMode: Boolean) {
transactionUtxoContainer.visibility = if (utxoInfoList.isEmpty() || isEnablePrivacyMode) View.GONE else View.VISIBLE
transactionUtxoList.removeAllViews()

utxoInfoList.forEach { utxo ->
Expand Down
Expand Up @@ -37,7 +37,7 @@ interface TransactionDetailsContract {
fun updatePaymentProof(paymentProof: PaymentProof)
fun configMenuItems(menu: Menu?, txStatus: TxStatus)
fun finishScreen()
fun updateUtxos(utxoInfoList: List<UtxoInfoItem>)
fun updateUtxos(utxoInfoList: List<UtxoInfoItem>, isEnablePrivacyMode: Boolean)
fun showCopiedAlert()
fun showPaymentProof(paymentProof: PaymentProof)
}
Expand Down
Expand Up @@ -84,7 +84,7 @@ class TransactionDetailsPresenter(currentView: TransactionDetailsContract.View,
}

UtxoInfoItem(type, utxo.amount)
})
}, repository.isPrivacyModeEnabled())
}

private fun isExchangeUtxo(utxo: Utxo): Boolean {
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/fragment_welcome_confirm.xml
Expand Up @@ -7,6 +7,7 @@
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:filterTouchesWhenObscured="true">

<android.support.constraint.ConstraintLayout
Expand Down

0 comments on commit e644d76

Please sign in to comment.