Fixed user+password dialog
This commit is contained in:
parent
a68f6cdb96
commit
f2b0c40ff0
@ -150,8 +150,8 @@ class HttpCredentialsProvider @AssistedInject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
bufferedReader.use {
|
bufferedReader.use {
|
||||||
var line: String;
|
var line: String
|
||||||
while (bufferedReader.readLine().also { line = it } != null && !(usernameSet && passwordSet)) {
|
while (bufferedReader.readLine().also { line = checkNotNull(it) { "Cancelled authentication" } } != null && !(usernameSet && passwordSet)) {
|
||||||
if (line.startsWith("username=")) {
|
if (line.startsWith("username=")) {
|
||||||
val split = line.split("=")
|
val split = line.split("=")
|
||||||
val userName = split.getOrNull(1) ?: return ExternalCredentialsRequestResult.CREDENTIALS_NOT_STORED
|
val userName = split.getOrNull(1) ?: return ExternalCredentialsRequestResult.CREDENTIALS_NOT_STORED
|
||||||
|
@ -2,6 +2,7 @@ package com.jetpackduba.gitnuro.ui.dialogs
|
|||||||
|
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.layout.*
|
import androidx.compose.foundation.layout.*
|
||||||
|
import androidx.compose.material.Icon
|
||||||
import androidx.compose.material.MaterialTheme
|
import androidx.compose.material.MaterialTheme
|
||||||
import androidx.compose.material.OutlinedTextField
|
import androidx.compose.material.OutlinedTextField
|
||||||
import androidx.compose.material.Text
|
import androidx.compose.material.Text
|
||||||
@ -13,11 +14,15 @@ import androidx.compose.ui.focus.focusProperties
|
|||||||
import androidx.compose.ui.focus.focusRequester
|
import androidx.compose.ui.focus.focusRequester
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.input.key.onPreviewKeyEvent
|
import androidx.compose.ui.input.key.onPreviewKeyEvent
|
||||||
|
import androidx.compose.ui.res.painterResource
|
||||||
import androidx.compose.ui.text.input.PasswordVisualTransformation
|
import androidx.compose.ui.text.input.PasswordVisualTransformation
|
||||||
|
import androidx.compose.ui.text.style.TextAlign
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import com.jetpackduba.gitnuro.keybindings.KeybindingOption
|
import com.jetpackduba.gitnuro.keybindings.KeybindingOption
|
||||||
import com.jetpackduba.gitnuro.keybindings.matchesBinding
|
import com.jetpackduba.gitnuro.keybindings.matchesBinding
|
||||||
|
import com.jetpackduba.gitnuro.theme.onBackgroundSecondary
|
||||||
import com.jetpackduba.gitnuro.theme.outlinedTextFieldColors
|
import com.jetpackduba.gitnuro.theme.outlinedTextFieldColors
|
||||||
|
import com.jetpackduba.gitnuro.ui.components.AdjustableOutlinedTextField
|
||||||
import com.jetpackduba.gitnuro.ui.components.PrimaryButton
|
import com.jetpackduba.gitnuro.ui.components.PrimaryButton
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@ -37,21 +42,38 @@ fun UserPasswordDialog(
|
|||||||
onCloseRequested = onReject
|
onCloseRequested = onReject
|
||||||
) {
|
) {
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier
|
|
||||||
.background(MaterialTheme.colors.background),
|
|
||||||
horizontalAlignment = Alignment.CenterHorizontally,
|
horizontalAlignment = Alignment.CenterHorizontally,
|
||||||
verticalArrangement = Arrangement.Center,
|
verticalArrangement = Arrangement.Center,
|
||||||
) {
|
) {
|
||||||
|
Icon(
|
||||||
|
painterResource("lock.svg"),
|
||||||
|
contentDescription = null,
|
||||||
|
modifier = Modifier
|
||||||
|
.size(64.dp)
|
||||||
|
.padding(vertical = 16.dp),
|
||||||
|
tint = MaterialTheme.colors.onBackground,
|
||||||
|
)
|
||||||
|
|
||||||
Text(
|
Text(
|
||||||
text = "Introduce your remote server credentials",
|
text = "Introduce your remote server credentials",
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.padding(vertical = 8.dp),
|
.padding(bottom = 8.dp),
|
||||||
color = MaterialTheme.colors.onBackground,
|
color = MaterialTheme.colors.onBackground,
|
||||||
|
style = MaterialTheme.typography.body1,
|
||||||
)
|
)
|
||||||
|
|
||||||
OutlinedTextField(
|
Text(
|
||||||
|
text = "Your remote requires authentication with a\nusername and a password",
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
|
.padding(bottom = 16.dp),
|
||||||
|
color = MaterialTheme.colors.onBackgroundSecondary,
|
||||||
|
style = MaterialTheme.typography.body2,
|
||||||
|
textAlign = TextAlign.Center,
|
||||||
|
)
|
||||||
|
|
||||||
|
AdjustableOutlinedTextField(
|
||||||
|
modifier = Modifier
|
||||||
|
.padding(bottom = 8.dp)
|
||||||
.focusRequester(userFieldFocusRequester)
|
.focusRequester(userFieldFocusRequester)
|
||||||
.focusProperties {
|
.focusProperties {
|
||||||
this.next = passwordFieldFocusRequester
|
this.next = passwordFieldFocusRequester
|
||||||
@ -66,20 +88,13 @@ fun UserPasswordDialog(
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
value = userField,
|
value = userField,
|
||||||
singleLine = true,
|
maxLines = 1,
|
||||||
colors = outlinedTextFieldColors(),
|
hint = "Username",
|
||||||
label = {
|
|
||||||
Text(
|
|
||||||
"User",
|
|
||||||
style = MaterialTheme.typography.body1.copy(color = MaterialTheme.colors.primaryVariant),
|
|
||||||
)
|
|
||||||
},
|
|
||||||
textStyle = MaterialTheme.typography.body1,
|
|
||||||
onValueChange = {
|
onValueChange = {
|
||||||
userField = it
|
userField = it
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
OutlinedTextField(
|
AdjustableOutlinedTextField(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.padding(bottom = 8.dp)
|
.padding(bottom = 8.dp)
|
||||||
.focusRequester(passwordFieldFocusRequester)
|
.focusRequester(passwordFieldFocusRequester)
|
||||||
@ -97,16 +112,8 @@ fun UserPasswordDialog(
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
value = passwordField,
|
value = passwordField,
|
||||||
singleLine = true,
|
maxLines = 1,
|
||||||
label = {
|
hint = "Password",
|
||||||
Text(
|
|
||||||
"Password",
|
|
||||||
style = MaterialTheme.typography.body1,
|
|
||||||
color = MaterialTheme.colors.primaryVariant,
|
|
||||||
)
|
|
||||||
},
|
|
||||||
textStyle = MaterialTheme.typography.body1,
|
|
||||||
colors = outlinedTextFieldColors(),
|
|
||||||
onValueChange = {
|
onValueChange = {
|
||||||
passwordField = it
|
passwordField = it
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user