Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
a746d3d
Merge pull request #53 from gruntsoftware/release/v4.4.1
kcw-grunt Mar 30, 2025
ba8ea45
Revert "Updated the APIManager"
kcw-grunt Mar 31, 2025
638ce3a
Reverted the Kotlin APIManager.
kcw-grunt Mar 31, 2025
5344a96
Add version and code to welcome screen
kcw-grunt Mar 31, 2025
ebc3bb9
reset padding
kcw-grunt Mar 31, 2025
03c68b8
Merge pull request #56 from gruntsoftware/feature/add-version-issue-108
kcw-grunt Apr 1, 2025
c770f01
Revert "Updated the APIManager"
kcw-grunt Mar 31, 2025
f8c1bd5
Reverted the Kotlin APIManager.
kcw-grunt Mar 31, 2025
ff58b57
fix: fix crash when FragmentSignal dismissed
andhikayuana Apr 4, 2025
d64ea93
fix: fix sync after wipe
andhikayuana Apr 7, 2025
277f387
Merge branch 'hotfix/api-manager-fix' of https://github.com/brainwall…
kcw-grunt Apr 7, 2025
9a8a20f
fix: fix wrong lifecycle to trigger callback at FragmentSignal
andhikayuana Apr 7, 2025
832fa36
Update issue templates
kcw-grunt Apr 8, 2025
b294cd6
updated core changes
kcw-grunt Apr 8, 2025
4ed8af3
Merge pull request #57 from gruntsoftware/hotfix/api-manager-fix
kcw-grunt Apr 8, 2025
089995a
Rename .java to .kt
andhikayuana Apr 11, 2025
7e85987
chore: refactor BRApiManager & APIClient
andhikayuana Apr 11, 2025
0aa41e7
chore: remove unused part at APIClient
andhikayuana Apr 14, 2025
0cc29cb
feat: wip new peer discovery
andhikayuana Apr 14, 2025
54d2d9e
feat: implement selected peer ip address from cache (fetched from API)
andhikayuana Apr 14, 2025
c6923b1
feat: implement selected peer ip address from cache (fetched from API)
andhikayuana Apr 14, 2025
ef4e6d2
feat: filter out peers with NODE_NETWORK, NODE_BLOOM
andhikayuana Apr 15, 2025
2336939
fix: race condition when clear shared prefs values after wipeAll
andhikayuana Apr 16, 2025
51a4d9a
Merge pull request #62 from gruntsoftware/hotfix/prefs-race-condition
kcw-grunt Apr 16, 2025
62afb9d
Merge pull request #61 from gruntsoftware/feat/new-peer-discovery
kcw-grunt Apr 16, 2025
391e319
Updating the core library
kcw-grunt Apr 16, 2025
836b6f0
Chore/revert pre peer discovery (Android) (#69)
andhikayuana Apr 25, 2025
3caa1a7
feat: remove unused activity (ImportActivity) at AndroidManifest.xml …
andhikayuana Apr 29, 2025
a324444
fix: fix crash IllegalStateException: cannot make a new request becau…
andhikayuana May 2, 2025
1f9c5d0
code bump
kcw-grunt May 2, 2025
7ca17d3
Feat/move tx fee (#74)
andhikayuana May 5, 2025
e7fb2b7
fix: fix dismiss allow state loss (#76)
andhikayuana May 7, 2025
3d8ef98
fix: fix typo at strings.xml (#75)
andhikayuana May 7, 2025
25be1a8
feat: new UI for receive and topup flow (moonpay integration) (#72)
andhikayuana May 12, 2025
18eda46
version and code bump
kcw-grunt May 12, 2025
dbb6a5f
Added support url (#81)
kcw-grunt May 19, 2025
c82a5e3
version and code bump
kcw-grunt May 19, 2025
2981ec6
Revert from eda0f532 & cherry pick (#86)
andhikayuana May 25, 2025
c161fed
build bump
kcw-grunt May 25, 2025
63d7494
chore: open bread activity first then open moonpay widget (#88)
andhikayuana May 26, 2025
f09eb28
Adjustment for circleci (#89)
andhikayuana May 29, 2025
47c69cd
fix: android: Footer version label is obfuscated (#92)
andhikayuana May 29, 2025
a9c4a63
fix: You saved it right screen reset button covers words (#93)
andhikayuana May 29, 2025
d8f08ad
tiny resizing (#94)
kcw-grunt May 29, 2025
ef93585
code and version bump
kcw-grunt May 29, 2025
174d612
change break (#97)
kcw-grunt May 30, 2025
a4521d7
build code number
andhikayuana May 31, 2025
6fec1e2
fix: [#137] fix: Reset fiat options in Buy / Receive modal (#99)
andhikayuana Jun 2, 2025
c8fdf8d
Chore/update device data (#100)
kcw-grunt Jun 2, 2025
3f646df
Add agent string obfuscation (#103)
kcw-grunt Jun 14, 2025
642f9e6
updated metadata (#105)
kcw-grunt Jun 24, 2025
50f44de
chore: remove screen lock detection (#106)
andhikayuana Jun 24, 2025
ea15423
🧰 Fx/seed words UI polish (#108)
kcw-grunt Jun 25, 2025
5b6dff3
❇️ Feat/add polish punjabi farsi (#109)
kcw-grunt Jun 27, 2025
4ff50b8
fix: fix YourSeedProveItState.isWordUsedCorrectly (#111)
andhikayuana Jun 29, 2025
2fd094f
Upgrade targetSdk 36 (#113)
andhikayuana Aug 5, 2025
4efd95f
feat(#195): adopt koin annotation for dependency injection (#120)
JosephSanjaya Aug 18, 2025
5900ed4
Create PULL_REQUEST_TEMPLATE.md
kcw-grunt Aug 19, 2025
3b1f628
bump for test (#121)
kcw-grunt Aug 19, 2025
f11d5a8
feat(#174): initiate games module (#119)
JosephSanjaya Aug 20, 2025
77ed7df
Force pushed the version and code bump and catch up with Prod.
kcw-grunt Aug 20, 2025
ef353e3
πŸš€[Release v4.7.2] Merge into Develop (#127)
kcw-grunt Aug 25, 2025
e25e9e1
Fix(#227): Crash when launching MoonPay Widget (#126)
JosephSanjaya Aug 25, 2025
e0aebb5
feat(#138): Improve Unlock Screen UI and add dark mode toggle (#122)
JosephSanjaya Aug 25, 2025
7d8dd14
Redesign welcome screen (#123)
josikie Aug 25, 2025
18df293
fix(#226): android test failure on RecoverWalletScreenGrabsTest (#130)
JosephSanjaya Aug 26, 2025
9b191b7
fix(#223): fix issue on test environment SLF4J + agent warnings in te…
JosephSanjaya Aug 26, 2025
c9b1ef0
feat(#225): Send sync duration in Firebase Analytics as a custom even…
JosephSanjaya Aug 30, 2025
58f0cd8
feat(#234): Implement language-specific Firebase messaging topics (#132)
JosephSanjaya Aug 30, 2025
4bb06cf
bump code
kcw-grunt Aug 30, 2025
9f4908b
chore(#234): normalize Indonesian language code to "id" (#133)
JosephSanjaya Aug 30, 2025
cf52d0d
Merge branch 'main' into release/v4.7.2-202506296
kcw-grunt Sep 1, 2025
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
27 changes: 18 additions & 9 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ android {
applicationId = "ltd.grunt.brainwallet"
minSdk = 29
targetSdk = 36
versionCode = 202506295
versionCode = 202506296
versionName = "v4.7.2"

multiDexEnabled = true
Expand Down Expand Up @@ -71,6 +71,13 @@ android {
firebaseCrashlytics {
nativeSymbolUploadEnabled = true
}
buildConfigField("String[]", "SCREENGRAB_PAPERKEY",
"new String[] {${
localProperties.getProperty("SCREENGRAB_PAPERKEY", "")
.split(" ")
.joinToString { "\"$it\"" }
}}"
)
}

val release by getting {
Expand Down Expand Up @@ -125,13 +132,6 @@ android {
applicationId = "ltd.grunt.brainwallet.screengrab"
versionNameSuffix = "-screengrab"
resValue("string", "app_name", "Brainwallet (screengrab)")
buildConfigField("String[]", "SCREENGRAB_PAPERKEY",
"new String[] {${
localProperties.getProperty("SCREENGRAB_PAPERKEY", "")
.split(" ")
.joinToString { "\"$it\"" }
}}"
)

externalNativeBuild {
cmake {
Expand Down Expand Up @@ -220,6 +220,7 @@ dependencies {
implementation(libs.bundles.google.play.feature.delivery)
implementation(libs.bundles.google.play.review)
implementation(libs.kotlinx.serialization.json)
implementation(libs.kotlinx.coroutines.android)
implementation (libs.airbnb.lottie.compose)
implementation(platform(libs.koin.bom))
implementation(libs.bundles.koin)
Expand All @@ -243,11 +244,15 @@ dependencies {

testImplementation(libs.junit)
testImplementation(libs.mockk)
testImplementation(libs.turbine)
testImplementation(libs.slf4j.android)
testImplementation(libs.kotlinx.coroutines.tests)

androidTestImplementation(platform(libs.androidx.compose.bom))
androidTestImplementation(libs.bundles.androidx.compose.ui.test)
androidTestImplementation(libs.bundles.android.test)
androidTestImplementation(libs.fastlane.screengrab)
androidTestImplementation(libs.slf4j.android)
}

val ktlintCheck by tasks.registering(JavaExec::class) {
Expand Down Expand Up @@ -280,4 +285,8 @@ tasks.register<JavaExec>("ktlintFormat") {
"**.kts",
"!**/build/**",
)
}
}

tasks.withType<Test> {
jvmArgs("-XX:+EnableDynamicAgentLoading")
}
3 changes: 3 additions & 0 deletions app/src/main/java/com/brainwallet/BrainwalletApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import android.content.res.Resources
import com.appsflyer.AppsFlyerLib
import com.brainwallet.data.source.RemoteConfigSource
import com.brainwallet.di.AppModule
import com.brainwallet.domain.MessagingTopicUseCase
import com.brainwallet.notification.NotificationHandler
import com.brainwallet.presenter.activities.util.BRActivity
import com.brainwallet.presenter.entities.ServiceItems
Expand All @@ -32,6 +33,7 @@ open class BrainwalletApp : Application() {

private val remoteConfigSource: RemoteConfigSource by inject()
private val notificationHandler: NotificationHandler by inject()
private val messagingTopicHandler: MessagingTopicUseCase by inject()

override fun onCreate() {
super.onCreate()
Expand Down Expand Up @@ -80,6 +82,7 @@ open class BrainwalletApp : Application() {
modules(AppModule.dataModule, AppModule.module)
}
thread { remoteConfigSource.initialize() }
thread { messagingTopicHandler.initialize() }
}

// override fun attachBaseContext(base: Context) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.brainwallet.data.repository

import com.brainwallet.data.model.Language
import com.brainwallet.data.source.MessagingTopicDataSource
import org.koin.core.annotation.Single

@Single
class MessagingTopicRepository(
private val settingRepository: SettingRepository,
private val topicDataSource: MessagingTopicDataSource
) {
fun getCurrentTopics(): List<String> {
val currentLanguage = settingRepository.getCurrentLanguage()
return topicDataSource.getTopicsByLanguageCode(currentLanguage.code)
}

fun getTopicsByLanguage(language: Language): List<String> {
return topicDataSource.getTopicsByLanguageCode(language.code)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
package com.brainwallet.data.repository

import android.content.SharedPreferences
import androidx.core.content.edit
import com.brainwallet.data.source.AnalyticsSource
import com.brainwallet.data.source.PeerManagerSource
import org.koin.core.annotation.Single
import java.text.SimpleDateFormat
import java.util.Date
import java.util.Locale
import java.util.UUID

@Single
class SyncAnalyticsRepository(
private val analyticsSource: AnalyticsSource,
private val peerManagerSource: PeerManagerSource,
private val prefs: SharedPreferences,
) {
fun startSync() {
// Record the start time of the current sync segment.
prefs.edit {
putLong(KEY_CURRENT_SYNC_START_TIMESTAMP, peerManagerSource.getLastBlockTimestamp())
}
}

fun stopSync() {
val start = prefs.getLong(KEY_CURRENT_SYNC_START_TIMESTAMP, 0L)
if (start != 0L) {
val duration = peerManagerSource.getLastBlockTimestamp() - start
val accumulated = prefs.getLong(KEY_ACCUMULATED_DURATION, 0L)
prefs.edit {
putLong(KEY_ACCUMULATED_DURATION, accumulated + duration)
remove(KEY_CURRENT_SYNC_START_TIMESTAMP)
}
}
}

fun completeSync() {
// Capture the duration of the final segment.
stopSync()

val totalDuration = prefs.getLong(KEY_ACCUMULATED_DURATION, 0L)
if (totalDuration == 0L) return

val endTimestamp = peerManagerSource.getLastBlockTimestamp()
val endBlockHeight = peerManagerSource.getCurrentBlockHeight()
val uuid = UUID.randomUUID().toString()
val totalDurationInMillis = totalDuration * 1000

prefs.edit {
putString(KEY_LAST_UUID, uuid)
putLong(KEY_LAST_DURATION, totalDurationInMillis)
putLong(KEY_LAST_END, endTimestamp)
remove(KEY_ACCUMULATED_DURATION)
}

val params = mapOf(
KEY_UUID to uuid,
KEY_DURATION_MILLIS to (totalDurationInMillis),
KEY_END_TIMESTAMP to endTimestamp,
KEY_END_BLOCK_HEIGHT to endBlockHeight
)
analyticsSource.logEventWithParams(KEY_EVENT, params)
}

fun getLastSyncMetadata(): SyncMetadata? {
val uuid = prefs.getString(KEY_LAST_UUID, null) ?: return null
val duration = prefs.getLong(KEY_LAST_DURATION, 0L)
val end = prefs.getLong(KEY_LAST_END, 0L)
return SyncMetadata(uuid, duration, end)
}

data class SyncMetadata(
val uuid: String,
val durationMillis: Long,
val endTimestamp: Long
) {
class Formatter(
private val dateFormat: SimpleDateFormat = SimpleDateFormat(
"MMMM dd, yyyy h:mm:ss a",
Locale.getDefault()
)
) {
fun format(syncMetadata: SyncMetadata): String {
val durationSeconds = syncMetadata.durationMillis / 1000.0
val date = Date(syncMetadata.endTimestamp * 1000)
val dateString = dateFormat.format(date)

return "Duration: %.1f seconds\nTimestamp: %s".format(durationSeconds, dateString)
}
}
}

companion object {
private const val KEY_CURRENT_SYNC_START_TIMESTAMP = "current_sync_start_timestamp"
private const val KEY_ACCUMULATED_DURATION = "accumulated_sync_duration"
private const val KEY_LAST_UUID = "last_sync_uuid"
private const val KEY_LAST_DURATION = "last_sync_duration"
private const val KEY_LAST_END = "last_sync_end_timestamp"
private const val KEY_DURATION_MILLIS = "duration_millis"
private const val KEY_END_TIMESTAMP = "end_timestamp"
private const val KEY_END_BLOCK_HEIGHT = "end_block_height"
private const val KEY_UUID = "uuid"
private const val KEY_EVENT = "user_did_complete_sync"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.brainwallet.data.source

interface AnalyticsSource {
fun logEvent(event: String)
fun logEventWithParams(event: String, params: Map<String, Any?>)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.brainwallet.data.source

import android.content.Context
import android.os.Bundle
import com.google.firebase.analytics.FirebaseAnalytics
import org.koin.core.annotation.Single

@Single
class FirebaseAnalyticsSource(
private val context: Context,
private val analytics: FirebaseAnalytics = FirebaseAnalytics.getInstance(context)
) : AnalyticsSource {

override fun logEvent(event: String) {
analytics.logEvent(event, null)
}

override fun logEventWithParams(event: String, params: Map<String, Any?>) {
val bundle = Bundle().apply {
params.forEach { (key, value) ->
when (value) {
is String -> putString(key, value)
is Int -> putInt(key, value)
is Long -> putLong(key, value)
is Double -> putDouble(key, value)
is Boolean -> putBoolean(key, value)
// add more types if needed
}
}
}
analytics.logEvent(event, bundle)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.brainwallet.data.source

import com.brainwallet.data.model.Language
import org.koin.core.annotation.Single

@Single
class MessagingTopicDataSource(
private val supportedLanguages: List<Language> = Language.entries,
private val defaultLanguage: Language = Language.ENGLISH
) {
fun getTopicsByLanguageCode(languageCode: String): List<String> {
val baseLanguageCode = getBaseLanguageCode(languageCode)
return listOf(
"initial_$baseLanguageCode",
"news_$baseLanguageCode",
"promo_$baseLanguageCode",
"warn_$baseLanguageCode"
)
}

/**
* Note: Indonesian language code is normalized from "in" to "id" to maintain
* consistency with backend batch messaging server which uses ISO 639-1 standard.
* Supports both "in" and "id" as input for Indonesian language.
*/
private fun getBaseLanguageCode(languageCode: String): String {
val normalizedLanguageCode = languageCode.split("_", "-").first().lowercase()

// Handle reverse mapping: if "id" is passed, treat it as Indonesian
val searchCode = when (normalizedLanguageCode) {
"id" -> "in"
else -> normalizedLanguageCode
}

val targetLanguage = supportedLanguages.find {
it.code.split("-").first().lowercase() == searchCode
} ?: defaultLanguage

val baseCode = targetLanguage.code.split("-").first().lowercase()

return when (baseCode) {
"in" -> "id"
else -> baseCode
}
}
}
17 changes: 17 additions & 0 deletions app/src/main/java/com/brainwallet/data/source/PeerManagerSource.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.brainwallet.data.source

import com.brainwallet.wallet.BRPeerManager
import org.koin.core.annotation.Single

interface BRPeerManagerProxy {
fun getCurrentBlockHeight(): Int
fun getLastBlockTimestamp(): Long
}

@Single
class PeerManagerSource(
private val proxy: BRPeerManagerProxy = object : BRPeerManagerProxy {
override fun getCurrentBlockHeight(): Int = BRPeerManager.getCurrentBlockHeight()
override fun getLastBlockTimestamp(): Long = BRPeerManager.getInstance().lastBlockTimestamp
}
) : BRPeerManagerProxy by proxy
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.brainwallet.domain

import com.brainwallet.data.model.Language
import com.brainwallet.data.repository.SettingRepository
import org.koin.core.annotation.Single

@Single
class LanguageSwitcherUseCase(
private val settingRepository: SettingRepository,
private val messagingTopicUseCase: MessagingTopicUseCase
) {
fun switchLanguage(newLanguage: Language) {
messagingTopicUseCase.subscribeByLanguage(newLanguage)
settingRepository.updateCurrentLanguage(newLanguage.code)
}
}
36 changes: 36 additions & 0 deletions app/src/main/java/com/brainwallet/domain/MessagingTopicUseCase.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.brainwallet.domain

import com.brainwallet.data.model.Language
import com.brainwallet.data.repository.MessagingTopicRepository
import com.google.firebase.messaging.FirebaseMessaging
import org.koin.core.annotation.Single

@Single
class MessagingTopicUseCase(
private val messagingTopicRepository: MessagingTopicRepository,
private val firebaseMessaging: FirebaseMessaging = FirebaseMessaging.getInstance()
) {
fun initialize() {
val topics = messagingTopicRepository.getCurrentTopics()
subscribeToTopics(topics)
}

fun subscribeByLanguage(newLanguage: Language) {
val currentTopics = messagingTopicRepository.getCurrentTopics()
unsubscribeFromTopics(currentTopics)
val newTopics = messagingTopicRepository.getTopicsByLanguage(newLanguage)
subscribeToTopics(newTopics)
}

private fun subscribeToTopics(topics: List<String>) {
topics.forEach { topic ->
firebaseMessaging.subscribeToTopic(topic)
}
}

private fun unsubscribeFromTopics(topics: List<String>) {
topics.forEach { topic ->
firebaseMessaging.unsubscribeFromTopic(topic)
}
}
}
Loading