Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@
[submodule "android-build-logic"]
path = android-build-logic
url = https://github.com/gruntsoftware/android-build-logic.git
[submodule "modules/bw-gdlib"]
path = modules/bw-gdlib
url = https://github.com/gruntsoftware/bw-gdlib.git
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ fun BalanceBentoScreen(
val context = LocalContext.current
val infiniteTransition = rememberInfiniteTransition()
var previousBalance by remember { mutableStateOf(BigDecimal.ZERO) }
val boingAudioPlayer = remember { MediaPlayer.create(context, R.raw.boingspringmouthharp042013) }

val throbOpacity by infiniteTransition.animateFloat(
initialValue = 0.5f,
Expand Down Expand Up @@ -180,6 +181,7 @@ fun BalanceBentoScreen(
indication = null
) {
isSwapped = !isSwapped
boingAudioPlayer.start()
AnalyticsManager.logCustomEventWithParams("did_toggle_fiat_ltc", null)
}
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ data class MainScreenState(
val selectedCurrency: CurrencyEntity = CurrencyEntity(
"USD",
"US Dollar",
-1f,
0f,
"$"
),
val isInternetReachable: Boolean = true,
Expand Down
37 changes: 25 additions & 12 deletions app/src/main/java/com/brainwallet/ui/screens/main/MainViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import androidx.lifecycle.viewModelScope
import com.brainwallet.R
import com.brainwallet.constants.BWConstants
import com.brainwallet.data.model.AppSetting
import com.brainwallet.data.model.CurrencyEntity
import com.brainwallet.data.model.GlobalCurrency
import com.brainwallet.data.model.GlobalCurrency.entries
import com.brainwallet.data.repository.ConnectivityRepository
Expand All @@ -25,7 +26,6 @@ import com.brainwallet.util.CurrencyDataGetter
import com.brainwallet.util.VersionCodeProvider
import com.brainwallet.wallet.BRPeerManager
import com.brainwallet.wallet.BRWalletManager
import com.google.firebase.crashlytics.FirebaseCrashlytics
import kotlinx.collections.immutable.toImmutableList
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.Dispatchers
Expand Down Expand Up @@ -97,18 +97,23 @@ class MainViewModel(
viewModelScope.launch {
ltcRepository.rates
.combine(appSetting) { currencies, setting ->
currencies.firstOrNull { it.code == setting.currency.code }
currencies.firstOrNull {
it.code == setting.currency.code && it.symbol == setting.currency.symbol
}
}
.filterNotNull()
.collect { selectedCurrency ->
val msg = String.format("selectedCurrency β€” Name: %s", selectedCurrency.name)
Timber.d("ISO: %s", msg)
FirebaseCrashlytics.getInstance().log(msg)
_state.update {
it.copy(
fiatSymbol = selectedCurrency.symbol,
fiatiSOCode = selectedCurrency.code,
fiatRate = BigDecimal(selectedCurrency.rate.toDouble()),
selectedCurrency = CurrencyEntity(
code = selectedCurrency.code,
name = selectedCurrency.name,
rate = selectedCurrency.rate,
symbol = selectedCurrency.symbol,
),
)
}
}
Expand Down Expand Up @@ -180,12 +185,16 @@ class MainViewModel(
}
if (isWalletCreated()) {
addObservers()
val balance = BigDecimal(BRSharedPrefs.getCachedBalance(app).toDouble())
val balance = BRSharedPrefs.getCachedBalance(app)
_state.update {
it.copy(
ltcBalance = balance,
litoshiBalance = balance
.divide(BigDecimal(ONE_LITECOIN_OF_LITOSHIS)),
ltcBalance = BigDecimal(balance),
litoshiBalance = BigDecimal(balance)
.divide(
BigDecimal(ONE_LITECOIN_OF_LITOSHIS),
8,
BWConstants.ROUNDING_MODE
)
)
}
txRepository.refresh()
Expand Down Expand Up @@ -219,9 +228,13 @@ class MainViewModel(
override fun onBalanceChanged(balance: Long) {
_state.update {
it.copy(
ltcBalance = BigDecimal(balance.toDouble()),
litoshiBalance = BigDecimal(balance.toDouble())
.divide(BigDecimal(ONE_LITECOIN_OF_LITOSHIS)),
ltcBalance = BigDecimal(balance),
litoshiBalance = BigDecimal(balance)
.divide(
BigDecimal(ONE_LITECOIN_OF_LITOSHIS),
8,
BWConstants.ROUNDING_MODE
),
)
}
viewModelScope.launch(Dispatchers.IO) {
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/jni/core
Submodule core updated from fcbf4a to 4c9031
Binary file not shown.
1 change: 1 addition & 0 deletions modules/bw-gdlib
Submodule bw-gdlib added at f3e537
Loading