Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
83bd064
Added with WelcomeActivity
kcw-grunt Feb 12, 2025
47b1d23
renamed our main Composables package
kcw-grunt Feb 12, 2025
80606eb
Moved @kiejosie Composables to composables directory
kcw-grunt Feb 12, 2025
313a01f
Added the lottie file: welcome aninmation
kcw-grunt Feb 12, 2025
2a13693
update the icon
kcw-grunt Feb 13, 2025
94dadf5
added more brand logotypes
kcw-grunt Feb 13, 2025
21ef868
DELETED IntroActivity
kcw-grunt Feb 13, 2025
e3ac148
WIP Color
kcw-grunt Feb 13, 2025
d9670c4
Added Open Sauce One fonts
kcw-grunt Feb 13, 2025
dfa659c
Layout in process
kcw-grunt Feb 13, 2025
1b78152
clean up host
kcw-grunt Feb 13, 2025
6ce7b17
Rename .java to .kt
andhikayuana Feb 15, 2025
7fbffef
chore: wip compose communication with legacy code
andhikayuana Feb 15, 2025
7fdb9b9
chore: wip compose communication with legacy code
andhikayuana Feb 15, 2025
ec2ae2d
chore: add SetPasscodeConfirmScreen from feat/set-pincode-issue-31
andhikayuana Feb 15, 2025
324161c
feat: add fragment compose, add new home
andhikayuana Feb 15, 2025
f6e9d47
feat: add UnLockScreen
andhikayuana Feb 15, 2025
dbf4650
feat: UnLockScreen using onNavigate
andhikayuana Feb 15, 2025
e2c3b17
feat: wip implement new navigation
andhikayuana Feb 17, 2025
4710ac7
feat: wrap BRAnimator.startBreadActivity with LegacyNavigation.startB…
andhikayuana Feb 17, 2025
b1bb731
feat: wip create wallet flow
andhikayuana Feb 17, 2025
602d701
feat: create wallet flow and paper key prove flow
andhikayuana Feb 17, 2025
6ed9a36
feat: wipe wallet with old flow
andhikayuana Feb 17, 2025
d630d1f
fix: fix passcode verified flow
andhikayuana Feb 17, 2025
e0d635c
chore: remove unused code
andhikayuana Feb 17, 2025
32d3d69
chore: comment language and dark mode switch at WelcomeScreen
andhikayuana Feb 17, 2025
84fac7f
chore: update FragmentSend
andhikayuana Feb 17, 2025
709c220
chore: adjustment for Dialog
andhikayuana Feb 17, 2025
928d5ea
chore: optimize import for
andhikayuana Feb 17, 2025
43f03ed
chore: optimize import for
andhikayuana Feb 17, 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
2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ dependencies {
implementation(libs.bundles.google.play.feature.delivery)
implementation(libs.bundles.google.play.review)
implementation(libs.kotlinx.serialization.json)
implementation (libs.airbnb.lottie.compose)

implementation(libs.squareup.okhttp)
implementation(libs.jakewarthon.timber)
Expand All @@ -219,7 +220,6 @@ dependencies {
implementation(libs.sigpipe.jbsdiff)
implementation(libs.unstoppable.domain)
implementation(libs.razir.progressbutton)

implementation(libs.appsflyer)
implementation(libs.android.installreferrer)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import androidx.test.rule.GrantPermissionRule
import androidx.test.uiautomator.UiDevice
import com.brainwallet.BuildConfig
import com.brainwallet.R
import com.brainwallet.presenter.activities.intro.IntroActivity
import com.brainwallet.ui.BrainwalletActivity
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
Expand All @@ -26,6 +26,9 @@ import tools.fastlane.screengrab.FalconScreenshotStrategy
import tools.fastlane.screengrab.Screengrab
import tools.fastlane.screengrab.locale.LocaleTestRule

/**
* TODO: revisit this, since breaking with new navigation
*/
@RunWith(JUnit4::class)
@LargeTest
class RecoverWalletScreenGrabsTest {
Expand All @@ -42,7 +45,7 @@ class RecoverWalletScreenGrabsTest {
)

@get:Rule
val composeTestRule = createAndroidComposeRule<IntroActivity>()
val composeTestRule = createAndroidComposeRule<BrainwalletActivity>()

@Test
fun onRecoverFlowSuccess() {
Expand Down
11 changes: 7 additions & 4 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,19 @@
android:windowSoftInputMode="stateVisible|adjustResize"
tools:ignore="GoogleAppIndexingWarning,UnusedAttribute"
tools:replace="android:fullBackupContent,android:allowBackup">

<!-- Main Compose Activity -->
<activity
android:name=".presenter.activities.intro.IntroActivity"
android:name=".ui.BrainwalletActivity"
android:exported="true"
android:launchMode="singleTask"
android:screenOrientation="portrait">
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize">
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

</activity>
<activity
android:name=".presenter.activities.BreadActivity"
Expand Down Expand Up @@ -219,7 +222,7 @@

<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="@drawable/brainwallet_logotype_white_notifications" />
android:resource="@drawable/bw_white_logotype" />
</application>

</manifest>
Binary file modified app/src/main/ic_launcher-playstore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 16 additions & 16 deletions app/src/main/java/com/brainwallet/BrainwalletApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

public class BrainwalletApp extends Application {
public static int DISPLAY_HEIGHT_PX;
public static String HOST = "api.loafwallet.org";
public static String HOST = "apigsltd.net";
private static List<OnAppBackgrounded> listeners;
private static Timer isBackgroundChecker;
public static AtomicInteger activityCounter = new AtomicInteger();
Expand All @@ -57,21 +57,21 @@ public void onCreate() {

if (BuildConfig.DEBUG) Timber.plant(new Timber.DebugTree());

//dev: uncomment for debugging
// FirebaseMessaging.getInstance()
// .getToken()
// .addOnSuccessListener(new OnSuccessListener<String>() {
// @Override
// public void onSuccess(String s) {
// Timber.d("timber: fcm getToken= %s", s);
// }
// })
// .addOnFailureListener(new OnFailureListener() {
// @Override
// public void onFailure(@NonNull Exception e) {
// Timber.d(e, "timber: fcm getToken failure");
// }
// });
// DEV: uncomment for debugging
// FirebaseMessaging.getInstance()
// .getToken()
// .addOnSuccessListener(new OnSuccessListener<String>() {
// @Override
// public void onSuccess(String s) {
// Timber.d("timber: fcm getToken= %s", s);
// }
// })
// .addOnFailureListener(new OnFailureListener() {
// @Override
// public void onFailure(@NonNull Exception e) {
// Timber.d(e, "timber: fcm getToken failure");
// }
// });

if (BuildConfig.DEBUG) Timber.plant(new Timber.DebugTree());
DISPLAY_HEIGHT_PX = Resources.getSystem().getDisplayMetrics().heightPixels;
Expand Down
46 changes: 46 additions & 0 deletions app/src/main/java/com/brainwallet/navigation/LegacyNavigation.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.brainwallet.navigation

import android.app.Activity
import android.content.Context
import android.content.Intent
import com.brainwallet.R
import com.brainwallet.presenter.activities.BreadActivity
import com.brainwallet.presenter.activities.LoginActivity
import com.brainwallet.ui.BrainwalletActivity
import timber.log.Timber

//provide old navigation using intent activity
object LegacyNavigation {

//todo

/**
* wrapper for old `startBreadActivity`
* at [com.brainwallet.tools.animation.BRAnimator.startBreadActivity]
*/
@JvmStatic
fun startBreadActivity(
from: Activity,
auth: Boolean
) {
Timber.i("timber: startBreadActivity: %s", from.javaClass.name)
val toStart: Class<*> = if (auth) LoginActivity::class.java else BreadActivity::class.java
val intent = Intent(from, toStart)
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK)
from.startActivity(intent)
from.overridePendingTransition(R.anim.fade_up, R.anim.fade_down)
if (!from.isDestroyed) {
from.finish()
}
}

//open compose from old activity
@JvmStatic
fun openComposeScreen(
context: Context,
destination: Route = Route.Welcome
) = BrainwalletActivity.createIntent(context, destination).also {
context.startActivity(it)
}

}
107 changes: 107 additions & 0 deletions app/src/main/java/com/brainwallet/navigation/MainNav.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
package com.brainwallet.navigation

import androidx.compose.runtime.Composable
import androidx.navigation.NavGraphBuilder
import androidx.navigation.NavHostController
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController
import androidx.navigation.toRoute
import com.brainwallet.ui.screens.inputwords.InputWordsScreen
import com.brainwallet.ui.screens.ready.ReadyScreen
import com.brainwallet.ui.screens.setpasscode.SetPasscodeScreen
import com.brainwallet.ui.screens.unlock.UnLockScreen
import com.brainwallet.ui.screens.welcome.WelcomeScreen
import com.brainwallet.ui.screens.yourseedproveit.YourSeedProveItScreen
import com.brainwallet.ui.screens.yourseedwords.YourSeedWordsScreen

/**
* Main Navigation Host for compose
*
* @param startDestination from [Route], e.g. we are opening compose screen from old activity
* @param onFinish if the navController didn't have back stack then trigger this to close the activity,
* maybe we have back stack activity from the old
*
*/
@Composable
fun MainNavHost(
startDestination: Any = Route.Welcome,
onFinish: () -> Unit,
navController: NavHostController = rememberNavController(),
) {
NavHost(
navController = navController,
startDestination = startDestination //since we still have multiple activity, we just start from the param
) {
mainNavGraph(
onNavigate = {
if (it.isBack() && navController.previousBackStackEntry == null) {
onFinish()
return@mainNavGraph
}

if (it.isBack()) {
navController.navigateUp()
return@mainNavGraph
}

navController.navigate(route = it.destinationRoute!!) {
it.navOptionsBuilder?.invoke(this)
}
}
)
}
}

/**
* navigation graph
*/
fun NavGraphBuilder.mainNavGraph(
onNavigate: OnNavigate
) {
composable<Route.Welcome> {
WelcomeScreen(onNavigate = onNavigate)
}
composable<Route.Ready> {
ReadyScreen(onNavigate = onNavigate)
}
composable<Route.SetPasscode> { navBackStackEntry ->
val route: Route.SetPasscode = navBackStackEntry.toRoute()
SetPasscodeScreen(onNavigate = onNavigate, passcode = route.passcode)
}
composable<Route.InputWords> { navBackStackEntry ->
val route: Route.InputWords = navBackStackEntry.toRoute()
InputWordsScreen(
onNavigate = onNavigate,
source = route.source,
)
}
composable<Route.YourSeedWords> { navBackStackEntry ->
val route: Route.YourSeedWords = navBackStackEntry.toRoute()
YourSeedWordsScreen(
onNavigate = onNavigate,
seedWords = route.seedWords,
)
}
composable<Route.YourSeedProveIt> { navBackStackEntry ->
val route: Route.YourSeedProveIt = navBackStackEntry.toRoute()
YourSeedProveItScreen(
onNavigate = onNavigate,
seedWords = route.seedWords
)
}
/**
* for now, still using old activity & fragment [com.brainwallet.presenter.activities.BreadActivity]
*/
// composable<Route.Home> {
// HomeScreen(onNavigate = onNavigate)
// }

composable<Route.UnLock> {
UnLockScreen(onNavigate = onNavigate)
}

//todo add more composable screens
}


40 changes: 40 additions & 0 deletions app/src/main/java/com/brainwallet/navigation/Route.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.brainwallet.navigation

import kotlinx.serialization.Serializable
import java.io.Serializable as JavaSerializable


sealed class Route : JavaSerializable {

@Serializable
object Welcome : Route()

@Serializable
object Ready : Route()

@Serializable
data class SetPasscode(
val passcode: List<Int> = emptyList()
) : Route()

@Serializable
data class InputWords(val source: Source? = null) : Route() {
enum class Source {
RESET_PIN,
SETTING_WIPE
}
}

@Serializable
data class YourSeedWords(val seedWords: List<String>) : Route()

@Serializable
data class YourSeedProveIt(val seedWords: List<String>) : Route()

// for now, still using old activity & fragment
// @Serializable
// object Home : Route()

@Serializable
object UnLock : Route()
}
41 changes: 41 additions & 0 deletions app/src/main/java/com/brainwallet/navigation/UiEffect.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.brainwallet.navigation

import androidx.navigation.NavOptionsBuilder

typealias OnNavigate = (UiEffect.Navigate) -> Unit

sealed class UiEffect {
data class Navigate(
val destinationRoute: Route? = null, // If null, it acts as PopBackStack
val forcePopBackStack: Boolean = false,
val navOptionsBuilder: (NavOptionsBuilder.() -> Unit)? = null
) : UiEffect() {

fun isBack(): Boolean = destinationRoute == null

companion object {
fun Back(): Navigate = Navigate()
}
}

data class ShowDialog(val name: String): UiEffect()

data class ShowMessage(
val message: String,
val type: Type = Type.Success,
) : UiEffect() {
sealed class Type {
object Error : Type()
object Success : Type()
}

companion object {
fun Error(message: String): ShowMessage {
return ShowMessage(
type = Type.Error,
message = message
)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ object NotificationHandler {
val notification = NotificationCompat.Builder(context, channelId)
.setContentTitle(title)
.setContentText(body)
.setSmallIcon(R.drawable.brainwallet_logotype_white_notifications)
.setSmallIcon(R.drawable.bw_white_logotype)
.setContentIntent(pendingIntent)
.setAutoCancel(true)

Expand Down
Loading