Skip to content

Commit

Permalink
Release prep and refinement (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
SaintPatrck authored Apr 27, 2024
1 parent dd4a0a5 commit c0b0469
Show file tree
Hide file tree
Showing 12 changed files with 165 additions and 116 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,17 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
Expand All @@ -27,7 +30,7 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.bitwarden.authenticator.R
import com.bitwarden.authenticator.ui.platform.base.util.EventsEffect
import com.bitwarden.authenticator.ui.platform.base.util.asText
import com.bitwarden.authenticator.ui.platform.components.button.BitwardenOutlinedButton
import com.bitwarden.authenticator.ui.platform.components.button.BitwardenFilledTonalButton
import com.bitwarden.authenticator.ui.platform.components.dialog.BasicDialogState
import com.bitwarden.authenticator.ui.platform.components.dialog.BitwardenBasicDialog
import com.bitwarden.authenticator.ui.platform.components.dialog.BitwardenLoadingDialog
Expand Down Expand Up @@ -107,7 +110,7 @@ fun UnlockScreen(

BitwardenScaffold(
modifier = Modifier
.fillMaxSize()
.fillMaxSize(),
) { innerPadding ->
Box {
Column(
Expand All @@ -118,11 +121,17 @@ fun UnlockScreen(
horizontalAlignment = Alignment.CenterHorizontally
) {
Image(
modifier = Modifier
.padding(horizontal = 16.dp)
.width(220.dp)
.height(74.dp)
.fillMaxWidth(),
colorFilter = ColorFilter.tint(MaterialTheme.colorScheme.primary),
painter = painterResource(id = R.drawable.ic_logo_horizontal),
contentDescription = stringResource(R.string.bitwarden_authenticator)
contentDescription = stringResource(R.string.bitwarden_authenticator),
)
Spacer(modifier = Modifier.height(12.dp))
BitwardenOutlinedButton(
Spacer(modifier = Modifier.height(32.dp))
BitwardenFilledTonalButton(
label = stringResource(id = R.string.use_biometrics_to_unlock),
onClick = {
biometricsManager.promptBiometrics(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ fun EditItemContent(
modifier = Modifier
.fillMaxSize()
.padding(horizontal = 16.dp),
label = stringResource(id = R.string.secret_key),
label = stringResource(id = R.string.key),
value = viewState.itemData.totpCode,
onValueChange = onTotpCodeTextChange,
singleLine = true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,10 +320,10 @@ private fun ItemListingContent(
onScanQrCodeClick = onScanQrCodeClick,
),
ItemListingExpandableFabAction.EnterSetupKey(
label = R.string.enter_a_setup_key.asText(),
label = R.string.enter_key_manually.asText(),
icon = IconResource(
iconPainter = painterResource(id = R.drawable.ic_keyboard_24px),
contentDescription = stringResource(id = R.string.enter_a_setup_key),
contentDescription = stringResource(id = R.string.enter_key_manually),
testTag = "EnterSetupKeyButton",
),
onEnterSetupKeyClick = onEnterSetupKeyClick
Expand Down Expand Up @@ -413,10 +413,10 @@ fun EmptyItemListingContent(
onScanQrCodeClick = onScanQuCodeClick
),
ItemListingExpandableFabAction.EnterSetupKey(
label = R.string.enter_a_setup_key.asText(),
label = R.string.enter_key_manually.asText(),
icon = IconResource(
iconPainter = painterResource(id = R.drawable.ic_keyboard_24px),
contentDescription = stringResource(id = R.string.enter_a_setup_key),
contentDescription = stringResource(id = R.string.enter_key_manually),
testTag = "EnterSetupKeyButton",
),
onEnterSetupKeyClick = onEnterSetupKeyClick,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ import com.bitwarden.authenticator.ui.platform.base.util.EventsEffect
import com.bitwarden.authenticator.ui.platform.base.util.toAnnotatedString
import com.bitwarden.authenticator.ui.platform.components.appbar.BitwardenTopAppBar
import com.bitwarden.authenticator.ui.platform.components.button.BitwardenFilledTonalButton
import com.bitwarden.authenticator.ui.platform.components.dialog.BasicDialogState
import com.bitwarden.authenticator.ui.platform.components.dialog.BitwardenBasicDialog
import com.bitwarden.authenticator.ui.platform.components.dialog.BitwardenLoadingDialog
import com.bitwarden.authenticator.ui.platform.components.dialog.BitwardenTwoButtonDialog
import com.bitwarden.authenticator.ui.platform.components.dialog.LoadingDialogState
import com.bitwarden.authenticator.ui.platform.components.field.BitwardenTextField
import com.bitwarden.authenticator.ui.platform.components.scaffold.BitwardenScaffold
import com.bitwarden.authenticator.ui.platform.manager.intent.IntentManager
Expand Down Expand Up @@ -108,11 +112,38 @@ fun ManualCodeEntryScreen(
)
}

when (val dialog = state.dialog) {

is ManualCodeEntryState.DialogState.Error -> {
BitwardenBasicDialog(
visibilityState = BasicDialogState.Shown(
title = dialog.title,
message = dialog.message
),
onDismissRequest = remember(state) {
{ viewModel.trySendAction(ManualCodeEntryAction.DismissDialog) }
}
)
}

is ManualCodeEntryState.DialogState.Loading -> {
BitwardenLoadingDialog(
visibilityState = LoadingDialogState.Shown(
dialog.message
)
)
}

null -> {
Unit
}
}

BitwardenScaffold(
modifier = Modifier.fillMaxSize(),
topBar = {
BitwardenTopAppBar(
title = stringResource(id = R.string.authenticator_key_scanner),
title = stringResource(id = R.string.create_verification_code),
navigationIcon = painterResource(id = R.drawable.ic_close),
navigationIconContentDescription = stringResource(id = R.string.close),
onNavigationIconClick = remember(viewModel) {
Expand All @@ -133,22 +164,22 @@ fun ManualCodeEntryScreen(
Spacer(modifier = Modifier.height(8.dp))
BitwardenTextField(
label = stringResource(id = R.string.name),
value = state.issuer,
onValueChange = remember(viewModel) {
{
viewModel.trySendAction(
ManualCodeEntryAction.IssuerTextChange(it),
)
}
},
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 16.dp),
value = state.issuer,
onValueChange = remember(viewModel) {
{
viewModel.trySendAction(
ManualCodeEntryAction.IssuerTextChange(it),
)
}
},
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 16.dp),
)
Spacer(modifier = Modifier.height(8.dp))
BitwardenTextField(
singleLine = false,
label = stringResource(id = R.string.authenticator_key_scanner),
label = stringResource(id = R.string.key),
value = state.code,
onValueChange = remember(viewModel) {
{
Expand All @@ -164,7 +195,7 @@ fun ManualCodeEntryScreen(

Spacer(modifier = Modifier.height(16.dp))
BitwardenFilledTonalButton(
label = stringResource(id = R.string.add_totp),
label = stringResource(id = R.string.add_code),
onClick = remember(viewModel) {
{ viewModel.trySendAction(ManualCodeEntryAction.CodeSubmit) }
},
Expand All @@ -185,7 +216,7 @@ fun ManualCodeEntryScreen(
)

Text(
text = stringResource(id = R.string.cannot_add_authenticator_key),
text = stringResource(id = R.string.cannot_add_key),
style = MaterialTheme.typography.bodyMedium,
modifier = Modifier
.fillMaxWidth()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,17 @@ class ManualCodeEntryViewModel @Inject constructor(
is ManualCodeEntryAction.Internal.CreateItemResultReceive -> {
handleCreateItemReceive(action)
}

ManualCodeEntryAction.DismissDialog -> {
handleDialogDismiss()
}
}
}

private fun handleDialogDismiss() {
mutableStateFlow.update { it.copy(dialog = null) }
}

private fun handleIssuerTextChange(action: ManualCodeEntryAction.IssuerTextChange) {
mutableStateFlow.update {
it.copy(issuer = action.issuer)
Expand All @@ -63,6 +71,27 @@ class ManualCodeEntryViewModel @Inject constructor(
}

private fun handleCodeSubmit() {
if (state.code.isBlank()) {
mutableStateFlow.update {
it.copy(
dialog = ManualCodeEntryState.DialogState.Error(
message = R.string.key_is_required.asText()
)
)
}
return
}

if (state.issuer.isBlank()) {
mutableStateFlow.update {
it.copy(
dialog = ManualCodeEntryState.DialogState.Error(
message = R.string.name_is_required.asText()
)
)
}
return
}
viewModelScope.launch {
val result = authenticatorRepository.createItem(
AuthenticatorItemEntity(
Expand Down Expand Up @@ -216,4 +245,9 @@ sealed class ManualCodeEntryAction {
* The action for the user clicking the settings button.
*/
data object SettingsClick : ManualCodeEntryAction()

/**
* The user has dismissed the dialog.
*/
data object DismissDialog : ManualCodeEntryAction()
}
47 changes: 17 additions & 30 deletions app/src/main/res/drawable/ic_launcher_foreground.xml
Original file line number Diff line number Diff line change
@@ -1,34 +1,21 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<group>
<clip-path
android:pathData="M0,0h108v108h-108z"/>
<path
android:pathData="M71.57,34.63L113,76.06L89.71,119.08L40.65,70.02L53.53,77.45L70.88,60.11L71.57,34.63Z">
<aapt:attr name="android:fillColor">
<gradient
android:startX="37.85"
android:startY="38.81"
android:endX="89.01"
android:endY="89.97"
android:type="linear">
<item android:offset="0" android:color="#3F000000"/>
<item android:offset="1" android:color="#00000000"/>
</gradient>
</aapt:attr>
</path>
<path
android:pathData="M71.51,34.56C71.15,34.19 70.71,34 70.21,34H36.85C36.35,34 35.92,34.19 35.56,34.56C35.19,34.92 35,35.35 35,35.85V58.09C35,59.75 35.33,61.4 35.97,63.03C36.62,64.66 37.42,66.11 38.38,67.37C39.33,68.64 40.47,69.87 41.8,71.06C43.12,72.26 44.35,73.25 45.47,74.04C46.59,74.83 47.76,75.58 48.97,76.28C50.19,76.98 51.06,77.46 51.57,77.72C52.09,77.97 52.49,78.16 52.8,78.29C53.03,78.41 53.29,78.47 53.55,78.47C53.82,78.47 54.08,78.41 54.31,78.29C54.61,78.15 55.03,77.97 55.54,77.72C56.05,77.47 56.91,76.98 58.13,76.28C59.35,75.58 60.52,74.82 61.64,74.04C62.76,73.25 63.98,72.26 65.31,71.06C66.63,69.86 67.77,68.63 68.73,67.37C69.68,66.1 70.48,64.65 71.13,63.03C71.77,61.39 72.1,59.75 72.1,58.09V35.85C72.07,35.35 71.88,34.92 71.51,34.56ZM67.21,58.3C67.21,66.35 53.53,73.29 53.53,73.29V38.76H67.21C67.21,38.76 67.21,50.25 67.21,58.3Z"
android:fillColor="#ffffff"/>
<path
android:pathData="M55,49C55,47.34 56.34,46 58,46H107C108.66,46 110,47.34 110,49V60C110,61.66 108.66,63 107,63H58C56.34,63 55,61.66 55,60V49Z"
android:fillColor="#2DA49D"/>
<path
android:pathData="M64.22,54.63C64.22,55.6 64.04,56.41 63.67,57.05C63.3,57.7 62.77,58.19 62.07,58.51C61.37,58.84 60.53,59 59.54,59H57.12V50.43H59.81C60.7,50.43 61.48,50.59 62.14,50.91C62.8,51.23 63.32,51.7 63.68,52.33C64.04,52.95 64.22,53.72 64.22,54.63ZM62.34,54.68C62.34,54.05 62.24,53.53 62.06,53.12C61.87,52.71 61.6,52.41 61.24,52.21C60.88,52.02 60.43,51.92 59.9,51.92H58.93V57.5H59.71C60.6,57.5 61.26,57.26 61.69,56.79C62.12,56.32 62.34,55.62 62.34,54.68ZM70.93,59H66V50.43H70.93V51.92H67.82V53.8H70.72V55.29H67.82V57.5H70.93V59ZM79.45,50.43L76.53,59H74.55L71.65,50.43H73.48L75.09,55.53C75.12,55.62 75.16,55.78 75.23,56.02C75.29,56.25 75.35,56.5 75.41,56.77C75.48,57.03 75.53,57.25 75.55,57.42C75.57,57.25 75.61,57.03 75.67,56.77C75.74,56.51 75.8,56.26 75.85,56.02C75.92,55.79 75.96,55.62 75.99,55.53L77.61,50.43H79.45Z"
android:fillColor="#212529"/>
</group>
android:viewportHeight="108"
android:viewportWidth="108">
<path
android:fillColor="#ffffff"
android:pathData="M63.95,56.33V43H54.5V66.69C56.17,65.81 57.67,64.86 58.99,63.83C62.3,61.28 63.95,58.78 63.95,56.33ZM68,40.33V56.33C68,57.53 67.76,58.71 67.29,59.89C66.82,61.06 66.24,62.1 65.54,63.01C64.85,63.92 64.02,64.81 63.05,65.67C62.09,66.53 61.2,67.24 60.39,67.81C59.57,68.38 58.72,68.92 57.83,69.43C56.95,69.93 56.32,70.28 55.94,70.46C55.57,70.64 55.27,70.78 55.05,70.88C54.88,70.96 54.7,71 54.5,71C54.3,71 54.12,70.96 53.95,70.88C53.73,70.78 53.43,70.64 53.06,70.46C52.68,70.28 52.05,69.93 51.17,69.43C50.28,68.92 49.43,68.38 48.61,67.81C47.8,67.24 46.91,66.53 45.95,65.67C44.98,64.81 44.15,63.92 43.46,63.01C42.76,62.1 42.18,61.06 41.71,59.89C41.24,58.71 41,57.53 41,56.33V40.33C41,39.97 41.13,39.66 41.4,39.4C41.67,39.13 41.98,39 42.35,39H66.65C67.02,39 67.33,39.13 67.6,39.4C67.87,39.66 68,39.97 68,40.33Z" />
<path
android:fillColor="#2CDDE9"
android:pathData="M38.02,32C34.69,32 32,34.63 32,37.87V45.91C32,46.57 32.55,47.11 33.23,47.11C33.9,47.11 34.45,46.57 34.45,45.91V37.87C34.45,35.95 36.05,34.39 38.02,34.39H46.26C46.94,34.39 47.48,33.86 47.48,33.2C47.48,32.54 46.94,32 46.26,32H38.02Z" />
<path
android:fillColor="#2CDDE9"
android:pathData="M69.98,32C73.31,32 76,34.63 76,37.87V45.91C76,46.57 75.45,47.11 74.77,47.11C74.1,47.11 73.55,46.57 73.55,45.91V37.87C73.55,35.95 71.95,34.39 69.98,34.39H61.74C61.06,34.39 60.52,33.86 60.52,33.2C60.52,32.54 61.06,32 61.74,32H69.98Z" />
<path
android:fillColor="#2CDDE9"
android:pathData="M32,70.13C32,73.37 34.69,76 38.02,76H46.26C46.94,76 47.48,75.46 47.48,74.8C47.48,74.14 46.94,73.61 46.26,73.61H38.02C36.05,73.61 34.45,72.05 34.45,70.13V62.09C34.45,61.43 33.9,60.89 33.23,60.89C32.55,60.89 32,61.43 32,62.09V70.13Z" />
<path
android:fillColor="#2CDDE9"
android:pathData="M69.98,76C73.31,76 76,73.37 76,70.13V62.09C76,61.43 75.45,60.89 74.77,60.89C74.1,60.89 73.55,61.43 73.55,62.09V70.13C73.55,72.05 71.95,73.61 69.98,73.61H61.74C61.06,73.61 60.52,74.14 60.52,74.8C60.52,75.46 61.06,76 61.74,76H69.98Z" />
</vector>
Loading

0 comments on commit c0b0469

Please sign in to comment.