mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-09-25 12:11:45 +02:00
@@ -209,6 +209,10 @@ object ExternalSignerUtils {
|
|||||||
if (it !== null) {
|
if (it !== null) {
|
||||||
if (it.moveToFirst()) {
|
if (it.moveToFirst()) {
|
||||||
val index = it.getColumnIndex(columnName)
|
val index = it.getColumnIndex(columnName)
|
||||||
|
if (index < 0) {
|
||||||
|
Log.d("getDataFromResolver", "column '$columnName' not found")
|
||||||
|
return null
|
||||||
|
}
|
||||||
return it.getString(index)
|
return it.getString(index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -24,7 +24,6 @@ import androidx.compose.ui.Modifier
|
|||||||
import androidx.compose.ui.autofill.AutofillNode
|
import androidx.compose.ui.autofill.AutofillNode
|
||||||
import androidx.compose.ui.autofill.AutofillType
|
import androidx.compose.ui.autofill.AutofillType
|
||||||
import androidx.compose.ui.focus.onFocusChanged
|
import androidx.compose.ui.focus.onFocusChanged
|
||||||
import androidx.compose.ui.graphics.Color
|
|
||||||
import androidx.compose.ui.layout.ContentScale
|
import androidx.compose.ui.layout.ContentScale
|
||||||
import androidx.compose.ui.layout.boundsInWindow
|
import androidx.compose.ui.layout.boundsInWindow
|
||||||
import androidx.compose.ui.layout.onGloballyPositioned
|
import androidx.compose.ui.layout.onGloballyPositioned
|
||||||
@@ -321,10 +320,10 @@ fun LoginPage(
|
|||||||
|
|
||||||
Box(modifier = Modifier.padding(40.dp, 0.dp, 40.dp, 0.dp)) {
|
Box(modifier = Modifier.padding(40.dp, 0.dp, 40.dp, 0.dp)) {
|
||||||
Button(
|
Button(
|
||||||
|
enabled = acceptedTerms.value,
|
||||||
onClick = {
|
onClick = {
|
||||||
if (!acceptedTerms.value) {
|
if (!acceptedTerms.value) {
|
||||||
termsAcceptanceIsRequired =
|
termsAcceptanceIsRequired = context.getString(R.string.acceptance_of_terms_is_required)
|
||||||
context.getString(R.string.acceptance_of_terms_is_required)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key.value.text.isBlank()) {
|
if (key.value.text.isBlank()) {
|
||||||
@@ -343,11 +342,7 @@ fun LoginPage(
|
|||||||
shape = RoundedCornerShape(Size35dp),
|
shape = RoundedCornerShape(Size35dp),
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.height(50.dp),
|
.height(50.dp)
|
||||||
colors = ButtonDefaults
|
|
||||||
.buttonColors(
|
|
||||||
backgroundColor = if (acceptedTerms.value) MaterialTheme.colors.primary else Color.Gray
|
|
||||||
)
|
|
||||||
) {
|
) {
|
||||||
Text(text = stringResource(R.string.login))
|
Text(text = stringResource(R.string.login))
|
||||||
}
|
}
|
||||||
@@ -356,44 +351,43 @@ fun LoginPage(
|
|||||||
if (PackageUtils.isAmberInstalled(context)) {
|
if (PackageUtils.isAmberInstalled(context)) {
|
||||||
Box(modifier = Modifier.padding(40.dp, 40.dp, 40.dp, 0.dp)) {
|
Box(modifier = Modifier.padding(40.dp, 40.dp, 40.dp, 0.dp)) {
|
||||||
Button(
|
Button(
|
||||||
|
enabled = acceptedTerms.value,
|
||||||
onClick = {
|
onClick = {
|
||||||
val result = ExternalSignerUtils.getDataFromResolver(SignerType.GET_PUBLIC_KEY, arrayOf("login"), "")
|
if (!acceptedTerms.value) {
|
||||||
|
termsAcceptanceIsRequired = context.getString(R.string.acceptance_of_terms_is_required)
|
||||||
|
return@Button
|
||||||
|
}
|
||||||
|
|
||||||
|
val result = ExternalSignerUtils.getDataFromResolver(SignerType.GET_PUBLIC_KEY, arrayOf("login"))
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
loginWithExternalSigner = true
|
loginWithExternalSigner = true
|
||||||
return@Button
|
return@Button
|
||||||
}
|
} else {
|
||||||
key.value = TextFieldValue(result)
|
key.value = TextFieldValue(result)
|
||||||
if (!acceptedTerms.value) {
|
if (key.value.text.isBlank()) {
|
||||||
termsAcceptanceIsRequired =
|
errorMessage = context.getString(R.string.key_is_required)
|
||||||
context.getString(R.string.acceptance_of_terms_is_required)
|
return@Button
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key.value.text.isBlank()) {
|
if (acceptedTerms.value && key.value.text.isNotBlank()) {
|
||||||
errorMessage = context.getString(R.string.key_is_required)
|
try {
|
||||||
}
|
accountViewModel.startUI(
|
||||||
|
key.value.text,
|
||||||
if (acceptedTerms.value && key.value.text.isNotBlank()) {
|
useProxy.value,
|
||||||
try {
|
proxyPort.value.toInt(),
|
||||||
accountViewModel.startUI(
|
true
|
||||||
key.value.text,
|
)
|
||||||
useProxy.value,
|
} catch (e: Exception) {
|
||||||
proxyPort.value.toInt(),
|
Log.e("Login", "Could not sign in", e)
|
||||||
true
|
errorMessage = context.getString(R.string.invalid_key)
|
||||||
)
|
}
|
||||||
} catch (e: Exception) {
|
|
||||||
Log.e("Login", "Could not sign in", e)
|
|
||||||
errorMessage = context.getString(R.string.invalid_key)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
shape = RoundedCornerShape(Size35dp),
|
shape = RoundedCornerShape(Size35dp),
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.height(50.dp),
|
.height(50.dp)
|
||||||
colors = ButtonDefaults
|
|
||||||
.buttonColors(
|
|
||||||
backgroundColor = if (acceptedTerms.value) MaterialTheme.colors.primary else Color.Gray
|
|
||||||
)
|
|
||||||
) {
|
) {
|
||||||
Text(text = stringResource(R.string.login_with_external_signer))
|
Text(text = stringResource(R.string.login_with_external_signer))
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user