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
2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ android {
applicationId = "ltd.grunt.brainwallet"
minSdk = 29
targetSdk = 35
versionCode = 202506346
versionCode = 202506347
versionName = "v4.11.0"
multiDexEnabled = true
base.archivesName.set("${defaultConfig.versionName}(${defaultConfig.versionCode})")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class InAppReviewService(
public fun showInAppReviewDialogIfNeeded() {
val activity = activityProvider() ?: return
if (!BRSharedPrefs.isInAppReviewDone(app) &&
BRSharedPrefs.getSendTransactionCount(app) > 2
BRSharedPrefs.getSendTransactionCount(app) > 1

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will adjust over time

) {
val manager = ReviewManagerFactory.create(app)
val request = manager.requestReviewFlow()
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/java/com/brainwallet/di/AppModule.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package com.brainwallet.di

import android.app.Activity
import android.content.Context
import android.content.SharedPreferences
import com.brainwallet.BrainwalletApp
import com.brainwallet.BuildConfig
import com.brainwallet.appreview.InAppReviewService
import com.brainwallet.data.repository.TxRepository
import com.brainwallet.data.source.RemoteApiSource
import com.brainwallet.tools.sqlite.CurrencyDataSource
Expand Down Expand Up @@ -45,6 +48,7 @@ object AppModule {
single<SharedPreferences> { provideSharedPreferences(context = androidApplication()) }
single<TxRepository> { TxRepositoryImpl(get()) }
single { SyncThreadManager(get(), get()) }
single { InAppReviewService(androidApplication()) { BrainwalletApp.breadContext as? Activity } }
}

private fun provideSharedPreferences(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
Expand All @@ -51,6 +52,7 @@ import androidx.lifecycle.Lifecycle
import androidx.lifecycle.compose.LifecycleEventEffect
import androidx.lifecycle.viewmodel.compose.viewModel
import com.brainwallet.R
import com.brainwallet.appreview.InAppReviewService
import com.brainwallet.presenter.entities.TxItem
import com.brainwallet.tools.manager.AnalyticsManager
import com.brainwallet.ui.screens.main.MainScreenEvent
Expand All @@ -61,6 +63,9 @@ import com.brainwallet.ui.theme.IBMPlexSans
import com.brainwallet.ui.theme.balanceGameBentoSurface
import com.brainwallet.ui.theme.blurWhen
import kotlinx.collections.immutable.ImmutableList
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import org.koin.compose.koinInject
import org.koin.compose.viewmodel.koinViewModel
import java.math.BigDecimal

Expand Down Expand Up @@ -107,8 +112,10 @@ fun BalanceBentoScreen(
onDebugStatusUpdate: () -> Unit = {},
onDebugTxAdded: () -> Unit = {},
onDebugBalanceChanged: () -> Unit = {},
inAppReviewService: InAppReviewService = koinInject(),
) {
val context = LocalContext.current
val coroutineScope = rememberCoroutineScope()
val infiniteTransition = rememberInfiniteTransition()
var previousBalance by remember { mutableStateOf(BigDecimal.ZERO) }
val boingAudioPlayer = remember { MediaPlayer.create(context, R.raw.boingspringmouthharp042013) }
Expand Down Expand Up @@ -183,6 +190,12 @@ fun BalanceBentoScreen(
isSwapped = !isSwapped
boingAudioPlayer.start()
AnalyticsManager.logCustomEventWithParams("did_toggle_fiat_ltc", null)
if (isSwapped) {
coroutineScope.launch {
delay(800L)
inAppReviewService.showInAppReviewDialogIfNeeded()
}
}
}
) {
// ──────── MY BALANCE LABEL ────────
Expand Down Expand Up @@ -255,9 +268,14 @@ fun BalanceBentoScreen(
.clickable(
interactionSource = remember { MutableInteractionSource() },
) {
AnalyticsManager.logCustomEventWithParams("did_toggle_balance_visibility", null)

onEvent(BalanceBentoEvent.OnToggleBalanceVisibility)
AnalyticsManager.logCustomEventWithParams("did_toggle_balance_visibility", null)
if (state.balanceHidden) {
coroutineScope.launch {
delay(800L)
inAppReviewService.showInAppReviewDialogIfNeeded()
}
}
}
.blurWhen(!mainState.isInternetReachable),
painter = iconImage,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.wrapContentWidth
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.Color
Expand All @@ -21,15 +22,21 @@ import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.brainwallet.appreview.InAppReviewService
import com.brainwallet.ui.composable.CalloutWithPointers
import com.brainwallet.ui.composable.Pointer
import com.brainwallet.ui.theme.IBMPlexSans
import org.koin.compose.koinInject

@Composable
fun TutorialSendPage2(
darkMode: Boolean,
modifier: Modifier = Modifier
modifier: Modifier = Modifier,
inAppReviewService: InAppReviewService = koinInject()
) {
LaunchedEffect(Unit) {
inAppReviewService.showInAppReviewDialogIfNeeded()
}
Box(
modifier = Modifier
.fillMaxWidth()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.wrapContentWidth
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.Color
Expand All @@ -20,15 +21,22 @@ import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.brainwallet.appreview.InAppReviewService
import com.brainwallet.ui.composable.CalloutWithPointers
import com.brainwallet.ui.composable.Pointer
import com.brainwallet.ui.theme.IBMPlexSans
import org.koin.compose.koinInject

@Composable
fun TutorialWalkthroughPage3(
darkMode: Boolean,
modifier: Modifier = Modifier
modifier: Modifier = Modifier,
inAppReviewService: InAppReviewService = koinInject()
) {
LaunchedEffect(Unit) {
inAppReviewService.showInAppReviewDialogIfNeeded()
}

Box(
modifier = Modifier
.fillMaxWidth()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@ import android.graphics.BitmapFactory
import android.os.Bundle
import android.os.Environment
import androidx.core.content.FileProvider
import androidx.lifecycle.viewModelScope
import com.brainwallet.appreview.InAppReviewService
import com.brainwallet.tools.manager.AnalyticsManager
import com.brainwallet.ui.BrainwalletViewModel
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.launch
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.jsonObject
import kotlinx.serialization.json.jsonPrimitive
Expand All @@ -22,6 +26,7 @@ import java.io.FileOutputStream
@KoinViewModel
class GameHubViewModel(
private val app: Application,
private val inAppReviewService: InAppReviewService,
) : BrainwalletViewModel<GameHubEvent>() {
private val _state =
MutableStateFlow(GameHubState())
Expand Down Expand Up @@ -115,6 +120,12 @@ class GameHubViewModel(
}
)
}

AnalyticsManager.logCustomEventWithParams("did_play_game", null)
viewModelScope.launch {
delay(800L)
inAppReviewService.showInAppReviewDialogIfNeeded()
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.brainwallet.ui.screens.send
import android.app.Application
import androidx.lifecycle.viewModelScope
import com.brainwallet.R
import com.brainwallet.appreview.InAppReviewService
import com.brainwallet.constants.BWConstants
import com.brainwallet.data.repository.SettingRepository
import com.brainwallet.data.repository.TxRepository
Expand Down Expand Up @@ -46,6 +47,7 @@ class SendViewModel(
private val txRepository: TxRepository,
private val settingRepository: SettingRepository,
private val currencyDataGetter: CurrencyDataGetter,
private val inAppReviewService: InAppReviewService,
private val isWalletCreated: () -> Boolean = { BRWalletManager.getInstance().isCreated() },
private val validateAddress: (String) -> Boolean = { BRWalletManager.getInstance().validateAddress(it) },
private val getBalance: () -> Long = { BRWalletManager.getInstance().getBalance(app) },
Expand All @@ -57,7 +59,6 @@ class SendViewModel(
val state: StateFlow<SendState> = _state.asStateFlow()
private val _effect = MutableSharedFlow<SendEffect>(extraBufferCapacity = 1)
val effect: SharedFlow<SendEffect> = _effect.asSharedFlow()

init {
viewModelScope.launch {
settingRepository.currentSettings.collect { currentSettings ->
Expand Down Expand Up @@ -281,8 +282,10 @@ class SendViewModel(
_effect.emit(SendEffect.DismissSheet)
AnalyticsManager.logCustomEvent(BWConstants._20191105_DSL)
BRSharedPrefs.incrementSendTransactionCount(app)
delay(800L)
inAppReviewService.showInAppReviewDialogIfNeeded()
}
is BWSendResult.Error.InsufficientFunds -> {
is Error.InsufficientFunds -> {
_state.update {
it.copy(
errorResultString = String.format(
Expand All @@ -293,7 +296,7 @@ class SendViewModel(
)
}
}
is BWSendResult.Error.AmountTooSmall -> {
is Error.AmountTooSmall -> {
_state.update {
it.copy(
errorResultString = String.format(
Expand All @@ -304,9 +307,9 @@ class SendViewModel(
)
}
}
BWSendResult.Error.AlreadySending,
BWSendResult.Error.TimedOut,
is BWSendResult.Error.Unknown -> {
Error.AlreadySending,
Error.TimedOut,
is Error.Unknown -> {
Timber.e("Send unknown error: $result")
_state.update {
it.copy(
Expand Down
Loading