Show the sign-in code exactly as it must be typed
The code was split as "abcd efgh" for readability, and phone keyboards added that space, capitalised the first letter or autocorrected the letters, so ya.ru/device rejected it. Show it unbroken with letter spacing, and add a hint: lowercase, no spaces. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
46610d95fa
commit
ed4e2d0ac6
5 files changed
+8
-13
No files matched your search
@@ -123,9 +123,5 @@ class SignInState(private val scope: CoroutineScope, private val onGranted: (Cre
|
|||||||
else -> R.string.signin_error_unexpected
|
else -> R.string.signin_error_unexpected
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
/** `ABCD1234` → `ABCD 1234` for easier reading; codes with separators stay as they are. */
|
|
||||||
fun spaced(code: String): String =
|
|
||||||
if (code.length == 8 && code.all { it.isLetterOrDigit() && it.code < 128 }) "${code.take(4)} ${code.drop(4)}" else code
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -49,6 +49,7 @@ import androidx.compose.ui.text.style.TextAlign
|
|||||||
import androidx.compose.ui.text.input.KeyboardType
|
import androidx.compose.ui.text.input.KeyboardType
|
||||||
import androidx.compose.ui.text.input.PasswordVisualTransformation
|
import androidx.compose.ui.text.input.PasswordVisualTransformation
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
|
import androidx.compose.ui.unit.em
|
||||||
import androidx.tv.material3.Text
|
import androidx.tv.material3.Text
|
||||||
import com.google.zxing.BarcodeFormat
|
import com.google.zxing.BarcodeFormat
|
||||||
import com.google.zxing.EncodeHintType
|
import com.google.zxing.EncodeHintType
|
||||||
@@ -182,9 +183,11 @@ private fun Steps(signIn: SignInState, stage: SignInState.Stage.Waiting, focus:
|
|||||||
Badge(2)
|
Badge(2)
|
||||||
Column(verticalArrangement = Arrangement.spacedBy(MusyxTheme.space.s)) {
|
Column(verticalArrangement = Arrangement.spacedBy(MusyxTheme.space.s)) {
|
||||||
Text(stringResource(R.string.signin_step_code), style = MusyxTheme.type.bodyMedium, color = c.fg)
|
Text(stringResource(R.string.signin_step_code), style = MusyxTheme.type.bodyMedium, color = c.fg)
|
||||||
|
// Shown exactly as it must be typed: a space or capital here ends up on the phone,
|
||||||
|
// and Yandex rejects the code. Letter spacing keeps it readable without one.
|
||||||
Text(
|
Text(
|
||||||
SignInState.spaced(code.userCode),
|
code.userCode,
|
||||||
style = MusyxTheme.type.displayS,
|
style = MusyxTheme.type.displayS.copy(letterSpacing = 0.12.em),
|
||||||
color = c.fg,
|
color = c.fg,
|
||||||
maxLines = 1,
|
maxLines = 1,
|
||||||
softWrap = false,
|
softWrap = false,
|
||||||
@@ -193,6 +196,7 @@ private fun Steps(signIn: SignInState, stage: SignInState.Stage.Waiting, focus:
|
|||||||
.border(BorderStroke(1.dp, c.line), RoundedCornerShape(MusyxTheme.radius.card))
|
.border(BorderStroke(1.dp, c.line), RoundedCornerShape(MusyxTheme.radius.card))
|
||||||
.padding(horizontal = 20.dp, vertical = 8.dp),
|
.padding(horizontal = 20.dp, vertical = 8.dp),
|
||||||
)
|
)
|
||||||
|
Text(stringResource(R.string.signin_step_code_hint), style = MusyxTheme.type.small, color = c.muted)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Step(3, stringResource(R.string.signin_step_back), stringResource(R.string.signin_step_back_hint))
|
Step(3, stringResource(R.string.signin_step_back), stringResource(R.string.signin_step_back_hint))
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
<string name="signin_step_open">Откройте %1$s</string>
|
<string name="signin_step_open">Откройте %1$s</string>
|
||||||
<string name="signin_step_open_hint">На телефоне или компьютере. Можно и отсканировать QR-код.</string>
|
<string name="signin_step_open_hint">На телефоне или компьютере. Можно и отсканировать QR-код.</string>
|
||||||
<string name="signin_step_code">Введите этот код</string>
|
<string name="signin_step_code">Введите этот код</string>
|
||||||
|
<string name="signin_step_code_hint">Строчными буквами, без пробелов. Если телефон сделает букву заглавной или исправит слово, верните как было.</string>
|
||||||
<string name="signin_step_back">Вернитесь сюда</string>
|
<string name="signin_step_back">Вернитесь сюда</string>
|
||||||
<string name="signin_step_back_hint">Musyx войдёт, как только вы разрешите доступ.</string>
|
<string name="signin_step_back_hint">Musyx войдёт, как только вы разрешите доступ.</string>
|
||||||
<string name="signin_waiting">Ждём подтверждения · код действует ещё %1$s</string>
|
<string name="signin_waiting">Ждём подтверждения · код действует ещё %1$s</string>
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
<string name="signin_step_open">Open %1$s</string>
|
<string name="signin_step_open">Open %1$s</string>
|
||||||
<string name="signin_step_open_hint">On your phone or computer. You can also scan the QR code.</string>
|
<string name="signin_step_open_hint">On your phone or computer. You can also scan the QR code.</string>
|
||||||
<string name="signin_step_code">Enter this code</string>
|
<string name="signin_step_code">Enter this code</string>
|
||||||
|
<string name="signin_step_code_hint">Lowercase, no spaces. If your phone capitalises or autocorrects it, fix it before you continue.</string>
|
||||||
<string name="signin_step_back">Come back here</string>
|
<string name="signin_step_back">Come back here</string>
|
||||||
<string name="signin_step_back_hint">Musyx signs you in as soon as you allow access.</string>
|
<string name="signin_step_back_hint">Musyx signs you in as soon as you allow access.</string>
|
||||||
<string name="signin_waiting">Waiting for confirmation · code expires in %1$s</string>
|
<string name="signin_waiting">Waiting for confirmation · code expires in %1$s</string>
|
||||||
|
|||||||
@@ -62,11 +62,4 @@ class StateTest {
|
|||||||
assertSame("a no-op keeps the list", removed, removed.with(Track.bare("2"), true))
|
assertSame("a no-op keeps the list", removed, removed.with(Track.bare("2"), true))
|
||||||
assertSame(Liked.NotLoaded, Liked.NotLoaded.with(Track.bare("9"), true))
|
assertSame(Liked.NotLoaded, Liked.NotLoaded.with(Track.bare("9"), true))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
fun spacedCodes() {
|
|
||||||
assertEquals("QX7K 29PM", SignInState.spaced("QX7K29PM"))
|
|
||||||
assertEquals("QX7-K29", SignInState.spaced("QX7-K29"))
|
|
||||||
assertEquals("1234567", SignInState.spaced("1234567"))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user