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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Bitkit Android (Native)

> [!CAUTION]
> ⚠️This **NOT** the repository of the Bitkit app from the app stores!
> ⚠️Work-in-progress
> ⚠️This **NOT** the repository of the Bitkit app from the app stores!<br>
> ⚠️Work-in-progress<br>
> The Bitkit app repository is here: **[github.com/synonymdev/bitkit](https://github.com/synonymdev/bitkit)**

---
Expand Down
9 changes: 8 additions & 1 deletion app/src/main/java/to/bitkit/ui/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import androidx.compose.animation.fadeOut
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Modifier
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.semantics.testTagsAsResourceId
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import androidx.fragment.app.FragmentActivity
import androidx.lifecycle.compose.collectAsStateWithLifecycle
Expand Down Expand Up @@ -75,7 +78,11 @@ class MainActivity : FragmentActivity() {
installSplashScreen()
enableAppEdgeToEdge()
setContent {
AppThemeSurface {
AppThemeSurface(
modifier = Modifier.semantics {
testTagsAsResourceId = true // see https://github.com/appium/appium/issues/15138
}
) {
val scope = rememberCoroutineScope()
if (!walletViewModel.walletExists) {
val startupNavController = rememberNavController()
Expand Down
14 changes: 10 additions & 4 deletions app/src/main/java/to/bitkit/ui/onboarding/CreateWalletScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.SpanStyle
Expand All @@ -33,10 +34,11 @@ import to.bitkit.ui.utils.withAccent
fun CreateWalletScreen(
onCreateClick: () -> Unit,
onRestoreClick: () -> Unit,
modifier: Modifier = Modifier,
) {
Box(
contentAlignment = Alignment.TopCenter,
modifier = Modifier
modifier = modifier
.fillMaxSize()
) {
Image(
Expand Down Expand Up @@ -70,20 +72,24 @@ fun CreateWalletScreen(
PrimaryButton(
text = stringResource(R.string.onboarding__new_wallet),
onClick = onCreateClick,
modifier = Modifier.weight(1f)
modifier = Modifier
.weight(1f)
.testTag("NewWallet")
)
SecondaryButton(
text = stringResource(R.string.onboarding__restore),
onClick = onRestoreClick,
modifier = Modifier.weight(1f)
modifier = Modifier
.weight(1f)
.testTag("RestoreWallet")
)
}
Spacer(modifier = Modifier.height(16.dp))
}
}
}

@Preview(showBackground = true)
@Preview(showSystemUi = true)
@Composable
private fun CreateWalletScreenPreview() {
AppThemeSurface {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.input.ImeAction
Expand Down Expand Up @@ -122,19 +123,21 @@ fun CreateWalletWithPassphraseScreen(
modifier = Modifier
.fillMaxWidth()
.padding(top = 4.dp)
.testTag("PassphraseInput")
)
Spacer(modifier = Modifier.height(32.dp))
PrimaryButton(
text = stringResource(R.string.onboarding__create_new_wallet),
onClick = { onCreateClick(bip39Passphrase) },
enabled = bip39Passphrase.isNotBlank(),
modifier = Modifier.testTag("CreateNewWallet")
)
Spacer(modifier = Modifier.height(32.dp))
}
}
}

@Preview(showBackground = true)
@Preview(showSystemUi = true)
@Composable
private fun CreateWalletWithPassphraseScreenPreview() {
AppThemeSurface {
Expand Down
9 changes: 7 additions & 2 deletions app/src/main/java/to/bitkit/ui/onboarding/IntroScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
Expand Down Expand Up @@ -80,12 +81,16 @@ fun IntroScreen(
PrimaryButton(
text = stringResource(R.string.onboarding__get_started),
onClick = onStartClick,
modifier = Modifier.weight(1f)
modifier = Modifier
.weight(1f)
.testTag("GetStarted")
)
SecondaryButton(
text = stringResource(R.string.onboarding__skip_intro),
onClick = onSkipClick,
modifier = Modifier.weight(1f)
modifier = Modifier
.weight(1f)
.testTag("SkipIntro")
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
Expand Down Expand Up @@ -77,6 +78,7 @@ fun OnboardingSlidesScreen(
title = stringResource(R.string.onboarding__slide0_header),
titleAccentColor = Colors.Blue,
text = stringResource(R.string.onboarding__slide0_text),
modifier = Modifier.testTag("Slide0")
)

1 -> OnboardingTab(
Expand All @@ -85,25 +87,29 @@ fun OnboardingSlidesScreen(
titleAccentColor = Colors.Purple,
text = stringResource(R.string.onboarding__slide1_text),
disclaimerText = stringResource(R.string.onboarding__slide1_note), // TODO use GeoBlocking state
modifier = Modifier.testTag("Slide1")
)

2 -> OnboardingTab(
imageResId = R.drawable.spark,
title = stringResource(R.string.onboarding__slide2_header),
titleAccentColor = Colors.Yellow,
text = stringResource(R.string.onboarding__slide2_text),
modifier = Modifier.testTag("Slide2")
)

3 -> OnboardingTab(
imageResId = R.drawable.shield,
title = stringResource(R.string.onboarding__slide3_header),
titleAccentColor = Colors.Green,
text = stringResource(R.string.onboarding__slide3_text),
modifier = Modifier.testTag("Slide3")
)

4 -> CreateWalletScreen(
onCreateClick = onCreateClick,
onRestoreClick = onRestoreClick,
modifier = Modifier.testTag("Slide4")
)
}
}
Expand Down Expand Up @@ -153,7 +159,10 @@ fun OnboardingSlidesScreen(
title = { },
actions = {
if (pagerState.currentPage == 4) {
TextButton(onClick = onAdvancedSetupClick) {
TextButton(
onClick = onAdvancedSetupClick,
modifier = Modifier.testTag("Passphrase")
) {
Text(
text = stringResource(R.string.onboarding__advanced_setup),
fontSize = 17.sp,
Expand All @@ -162,9 +171,12 @@ fun OnboardingSlidesScreen(
)
}
} else {
TextButton(onClick = {
scope.launch { pagerState.animateScrollToPage(4) }
}) {
TextButton(
onClick = {
scope.launch { pagerState.animateScrollToPage(pagerState.pageCount - 1) }
},
modifier = Modifier.testTag("SkipButton")
) {
Text(
text = stringResource(R.string.onboarding__skip),
fontSize = 17.sp,
Expand Down Expand Up @@ -218,7 +230,7 @@ fun OnboardingTab(
}
}

@Preview(showSystemUi = false)
@Preview(showSystemUi = true)
@Composable
private fun OnboardingViewPreview() {
AppThemeSurface {
Expand Down
12 changes: 9 additions & 3 deletions app/src/main/java/to/bitkit/ui/onboarding/RestoreWalletScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.onFocusChanged
import androidx.compose.ui.layout.onGloballyPositioned
import androidx.compose.ui.layout.positionInParent
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.input.ImeAction
Expand Down Expand Up @@ -283,6 +284,7 @@ fun RestoreWalletView(
modifier = Modifier
.fillMaxWidth()
.padding(top = 4.dp)
.testTag("PassphraseInput")
)
Spacer(modifier = Modifier.height(16.dp))
BodyS(
Expand Down Expand Up @@ -335,7 +337,9 @@ fun RestoreWalletView(
bip39Passphrase = ""
},
enabled = areButtonsEnabled,
modifier = Modifier.weight(1f)
modifier = Modifier
.weight(1f)
.testTag("AdvancedButton")
)
}
PrimaryButton(
Expand All @@ -344,7 +348,9 @@ fun RestoreWalletView(
onRestoreClick(bip39Mnemonic, bip39Passphrase.takeIf { it.isNotEmpty() })
},
enabled = areButtonsEnabled,
modifier = Modifier.weight(1f)
modifier = Modifier
.weight(1f)
.testTag("RestoreButton")
)
}
}
Expand Down Expand Up @@ -443,7 +449,7 @@ fun MnemonicInputField(
modifier = Modifier
.onFocusChanged { onFocusChanged(it.isFocused) }
.onGloballyPositioned { coordinates ->
val position = coordinates.positionInParent().y.toInt() * 2 //double the scroll to ensure enough space
val position = coordinates.positionInParent().y.toInt() * 2 // double the scroll to ensure enough space
onPositionChanged(position)
}
)
Expand Down
16 changes: 12 additions & 4 deletions app/src/main/java/to/bitkit/ui/onboarding/TermsOfUseScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.tooling.preview.Preview
Expand Down Expand Up @@ -71,6 +72,7 @@ fun TermsOfUseScreen(
.fillMaxWidth()
.padding(horizontal = horizontalPadding)
.verticalScroll(rememberScrollState())
.testTag("TOS")
) {
Spacer(modifier = Modifier.height(16.dp))
Display(text = stringResource(R.string.onboarding__tos_header).withAccent())
Expand Down Expand Up @@ -102,15 +104,19 @@ fun TermsOfUseScreen(
.withAccentLink(Env.TERMS_OF_USE_URL),
isChecked = termsAccepted,
onCheckedChange = { termsAccepted = it },
modifier = Modifier.padding(horizontal = horizontalPadding)
modifier = Modifier
.padding(horizontal = horizontalPadding)
.testTag("Check1")
)
CheckButton(
title = stringResource(R.string.onboarding__pp_checkbox),
htmlText = stringResource(R.string.onboarding__pp_checkbox_value)
.withAccentLink("https://bitkit.to/privacy-policy"),
isChecked = privacyAccepted,
onCheckedChange = { privacyAccepted = it },
modifier = Modifier.padding(horizontal = horizontalPadding)
modifier = Modifier
.padding(horizontal = horizontalPadding)
.testTag("Check2")
)

Spacer(modifier = Modifier.height(24.dp))
Expand All @@ -119,7 +125,9 @@ fun TermsOfUseScreen(
text = stringResource(R.string.common__continue),
onClick = onNavigateToIntro,
enabled = termsAccepted && privacyAccepted,
modifier = Modifier.padding(horizontal = horizontalPadding)
modifier = Modifier
.padding(horizontal = horizontalPadding)
.testTag("Continue")
)
}
}
Expand Down Expand Up @@ -185,7 +193,7 @@ private fun CheckmarkBox(isChecked: Boolean) {
}
}

@Preview
@Preview(showSystemUi = true)
@Composable
private fun TermsPreview() {
AppThemeSurface {
Expand Down
19 changes: 16 additions & 3 deletions app/src/main/java/to/bitkit/ui/onboarding/WalletInitResultView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
Expand Down Expand Up @@ -109,13 +110,20 @@ fun WalletInitResultView(
}
onButtonClick()
},
modifier = Modifier.testTag(
when (result) {
is WalletInitResult.Restored -> "GetStartedButton"
is WalletInitResult.Failed -> "TryAgainButton"
}
)
)

if (result is WalletInitResult.Failed && retryCount > 1 && onProceedWithoutRestore != null) {
Spacer(modifier = Modifier.height(12.dp))
SecondaryButton(
text = stringResource(R.string.onboarding__restore_no_backup_button),
onClick = { showProceedDialog = true }
onClick = { showProceedDialog = true },
modifier = Modifier.testTag("ProceedWithoutBackupButton")
)
}

Expand All @@ -132,7 +140,8 @@ fun WalletInitResultView(
retryCount = 0
onProceedWithoutRestore?.invoke()
},
onDismiss = { showProceedDialog = false }
onDismiss = { showProceedDialog = false },
modifier = Modifier.testTag("ProceedWithoutBackupDialog")
)
}
}
Expand All @@ -149,6 +158,10 @@ fun WalletInitResultViewRestoredPreview() {
@Composable
fun WalletInitResultViewErrorPreview() {
AppThemeSurface {
WalletInitResultView(result = WalletInitResult.Failed(Error("Something went wrong")), onButtonClick = {})
WalletInitResultView(
result = WalletInitResult.Failed(Error("Something went wrong")),
onButtonClick = {},
onProceedWithoutRestore = {},
)
}
}
Loading