generated from ali/HarmonyTemplate
提交 Haven Android 仓库源码 v5.87.79
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
plugins {
|
||||
alias(libs.plugins.android.library)
|
||||
alias(libs.plugins.kotlin.compose)
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "sh.haven.core.toolbar"
|
||||
compileSdk = 37
|
||||
|
||||
defaultConfig {
|
||||
minSdk = 26
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility = JavaVersion.VERSION_17
|
||||
targetCompatibility = JavaVersion.VERSION_17
|
||||
}
|
||||
|
||||
// MotionEvent's action constants are compile-time ints, but the stubbed
|
||||
// android.jar still needs unmocked calls to return rather than throw.
|
||||
testOptions {
|
||||
unitTests.isReturnDefaultValues = true
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(project(":core:ui"))
|
||||
implementation(project(":core:data"))
|
||||
implementation(libs.termlib) // for optional SelectionController parameter
|
||||
implementation(libs.core.ktx)
|
||||
implementation(libs.activity.compose)
|
||||
testImplementation(libs.junit)
|
||||
}
|
||||
|
||||
kotlin {
|
||||
compilerOptions {
|
||||
jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest />
|
||||
File diff suppressed because it is too large
Load Diff
+212
@@ -0,0 +1,212 @@
|
||||
package sh.haven.core.toolbar
|
||||
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Add
|
||||
import androidx.compose.material.icons.filled.Delete
|
||||
import androidx.compose.material3.AlertDialog
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.HorizontalDivider
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.ListItem
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.ModalBottomSheet
|
||||
import androidx.compose.material3.OutlinedTextField
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TextButton
|
||||
import androidx.compose.material3.rememberModalBottomSheetState
|
||||
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.res.stringResource
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import sh.haven.core.data.preferences.ToolbarItem
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun SnippetsBottomSheet(
|
||||
snippets: List<ToolbarItem.Custom>,
|
||||
onDismiss: () -> Unit,
|
||||
onSnippetTap: (ToolbarItem.Custom) -> Unit,
|
||||
onAddSnippet: (ToolbarItem.Custom) -> Unit,
|
||||
onDeleteSnippet: (ToolbarItem.Custom) -> Unit,
|
||||
) {
|
||||
var searchQuery by remember { mutableStateOf("") }
|
||||
var showAddDialog by remember { mutableStateOf(false) }
|
||||
|
||||
val filtered = remember(snippets, searchQuery) {
|
||||
if (searchQuery.isBlank()) snippets
|
||||
else snippets.filter { snippet ->
|
||||
snippet.label.contains(searchQuery, ignoreCase = true) ||
|
||||
displaySendSequence(snippet.send).contains(searchQuery, ignoreCase = true)
|
||||
}
|
||||
}
|
||||
|
||||
ModalBottomSheet(
|
||||
onDismissRequest = onDismiss,
|
||||
sheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true),
|
||||
) {
|
||||
Column(modifier = Modifier.padding(horizontal = 16.dp)) {
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
) {
|
||||
Text(
|
||||
stringResource(R.string.toolbar_snippet_title),
|
||||
style = MaterialTheme.typography.titleMedium,
|
||||
modifier = Modifier.weight(1f),
|
||||
)
|
||||
IconButton(onClick = { showAddDialog = true }) {
|
||||
Icon(Icons.Filled.Add, contentDescription = stringResource(R.string.toolbar_snippet_add))
|
||||
}
|
||||
}
|
||||
|
||||
OutlinedTextField(
|
||||
value = searchQuery,
|
||||
onValueChange = { searchQuery = it },
|
||||
placeholder = { Text(stringResource(R.string.toolbar_snippet_search)) },
|
||||
singleLine = true,
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
|
||||
if (filtered.isEmpty()) {
|
||||
Text(
|
||||
if (snippets.isEmpty()) stringResource(R.string.toolbar_snippet_empty)
|
||||
else stringResource(R.string.toolbar_snippet_empty_filtered),
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
modifier = Modifier.padding(vertical = 16.dp),
|
||||
)
|
||||
} else {
|
||||
LazyColumn(modifier = Modifier.height(300.dp)) {
|
||||
items(filtered) { snippet ->
|
||||
ListItem(
|
||||
headlineContent = {
|
||||
// bodyMedium (14sp) rather than ListItem's default
|
||||
// bodyLarge (16sp) — the default looked oversized next
|
||||
// to the toolbar keys and the row's own send-sequence.
|
||||
Text(
|
||||
snippet.label,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
)
|
||||
},
|
||||
supportingContent = {
|
||||
Text(
|
||||
displaySendSequence(snippet.send),
|
||||
maxLines = 2,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
)
|
||||
},
|
||||
trailingContent = {
|
||||
IconButton(
|
||||
onClick = { onDeleteSnippet(snippet) },
|
||||
modifier = Modifier.size(32.dp),
|
||||
) {
|
||||
Icon(
|
||||
Icons.Filled.Delete,
|
||||
contentDescription = stringResource(R.string.toolbar_snippet_delete),
|
||||
modifier = Modifier.size(18.dp),
|
||||
)
|
||||
}
|
||||
},
|
||||
modifier = Modifier.clickable { onSnippetTap(snippet) },
|
||||
)
|
||||
HorizontalDivider()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
}
|
||||
}
|
||||
|
||||
if (showAddDialog) {
|
||||
AddSnippetDialog(
|
||||
onDismiss = { showAddDialog = false },
|
||||
onSave = { snippet ->
|
||||
onAddSnippet(snippet)
|
||||
showAddDialog = false
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun AddSnippetDialog(
|
||||
onDismiss: () -> Unit,
|
||||
onSave: (ToolbarItem.Custom) -> Unit,
|
||||
) {
|
||||
var label by remember { mutableStateOf("") }
|
||||
var command by remember { mutableStateOf("") }
|
||||
|
||||
AlertDialog(
|
||||
onDismissRequest = onDismiss,
|
||||
title = { Text(stringResource(R.string.toolbar_snippet_dialog_title)) },
|
||||
text = {
|
||||
Column {
|
||||
OutlinedTextField(
|
||||
value = label,
|
||||
onValueChange = { label = it },
|
||||
label = { Text(stringResource(R.string.toolbar_snippet_label)) },
|
||||
placeholder = { Text(stringResource(R.string.toolbar_snippet_label_placeholder)) },
|
||||
singleLine = true,
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
|
||||
OutlinedTextField(
|
||||
value = command,
|
||||
onValueChange = { command = it },
|
||||
label = { Text(stringResource(R.string.toolbar_snippet_command)) },
|
||||
placeholder = { Text("e.g. docker compose up -d\\n") },
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
minLines = 2,
|
||||
maxLines = 4,
|
||||
)
|
||||
|
||||
Text(
|
||||
text = "Use \\n for Enter, \\u001b for Escape",
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
modifier = Modifier.padding(top = 4.dp),
|
||||
)
|
||||
}
|
||||
},
|
||||
confirmButton = {
|
||||
TextButton(
|
||||
onClick = {
|
||||
val parsed = parseSendSequence(command)
|
||||
onSave(ToolbarItem.Custom(label.trim(), parsed))
|
||||
},
|
||||
enabled = label.isNotBlank() && command.isNotBlank(),
|
||||
) {
|
||||
Text(stringResource(R.string.toolbar_custom_key_add))
|
||||
}
|
||||
},
|
||||
dismissButton = {
|
||||
TextButton(onClick = onDismiss) { Text(stringResource(R.string.toolbar_custom_key_cancel)) }
|
||||
},
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<!-- #135 third pass: keyboard toolbar accessibility / dialog labels.
|
||||
The core/toolbar module previously had no res/values at all —
|
||||
every string was hardcoded. -->
|
||||
<string name="toolbar_add_custom_key">إضافة مفتاح مخصص</string>
|
||||
<string name="toolbar_toggle_keyboard">إظهار/إخفاء لوحة المفاتيح</string>
|
||||
<string name="toolbar_reorder_keys">إعادة ترتيب مفاتيح الشريط</string>
|
||||
<string name="toolbar_done_reordering">انتهت إعادة الترتيب</string>
|
||||
<string name="toolbar_vnc_desktop">سطح مكتب VNC</string>
|
||||
<string name="toolbar_settings">إعدادات شريط الأدوات</string>
|
||||
<string name="toolbar_custom_key_dialog_title">إضافة مفتاح مخصص</string>
|
||||
<string name="toolbar_custom_key_label">التسمية</string>
|
||||
<string name="toolbar_custom_key_sequence">التسلسل</string>
|
||||
<string name="toolbar_custom_key_add">Add</string>
|
||||
<string name="toolbar_custom_key_cancel">إلغاء</string>
|
||||
<string name="toolbar_snippet_add">إضافة مقتطف</string>
|
||||
<string name="toolbar_snippet_search">بحث في المقتطفات…</string>
|
||||
<string name="toolbar_snippet_delete">حذف</string>
|
||||
<string name="toolbar_snippet_dialog_title">إضافة مقتطف</string>
|
||||
<string name="toolbar_snippet_label">التسمية</string>
|
||||
<string name="toolbar_snippet_command">الأمر</string>
|
||||
|
||||
<!-- i18n sweep #210 -->
|
||||
<string name="toolbar_snippet_title">المقتطفات</string>
|
||||
<string name="toolbar_snippet_empty">لا توجد مقتطفات بعد. أضِف مفاتيح مخصصة إلى شريط الأدوات، أو اضغط + أعلاه.</string>
|
||||
<string name="toolbar_snippet_empty_filtered">لا توجد مقتطفات مطابقة.</string>
|
||||
<string name="toolbar_snippet_label_placeholder">مثال: نشر، إعادة تشغيل</string>
|
||||
<string name="toolbar_keyboard_standard_desc">لوحة مفاتيح قياسية (الإدخال الصوتي والاقتراحات والتصحيح التلقائي مفعّلة)</string>
|
||||
<string name="toolbar_keyboard_secure_desc">لوحة مفاتيح آمنة (بدون اقتراحات، بدون تصحيح تلقائي)</string>
|
||||
<string name="toolbar_attach_desc">إرفاق ملف للإرسال إلى الجهاز البعيد</string>
|
||||
<string name="toolbar_presets_label">الإعدادات المسبقة</string>
|
||||
<string name="toolbar_custom_key_label_placeholder">مثال: ^C, Paste</string>
|
||||
<string name="toolbar_text_input_desc">فتح إدخال النص العائم</string>
|
||||
<string name="toolbar_dictate_desc">إملاء: بدء الإدخال الصوتي</string>
|
||||
</resources>
|
||||
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<!-- #135 third pass: keyboard toolbar accessibility / dialog labels.
|
||||
The core/toolbar module previously had no res/values at all —
|
||||
every string was hardcoded. -->
|
||||
<string name="toolbar_add_custom_key">কাস্টম কী যোগ করুন</string>
|
||||
<string name="toolbar_toggle_keyboard">কীবোর্ড দেখান/লুকান</string>
|
||||
<string name="toolbar_reorder_keys">টুলবারের কী সাজান</string>
|
||||
<string name="toolbar_done_reordering">সাজানো শেষ</string>
|
||||
<string name="toolbar_vnc_desktop">VNC ডেস্কটপ</string>
|
||||
<string name="toolbar_settings">টুলবার সেটিংস</string>
|
||||
<string name="toolbar_custom_key_dialog_title">কাস্টম কী যোগ করুন</string>
|
||||
<string name="toolbar_custom_key_label">লেবেল</string>
|
||||
<string name="toolbar_custom_key_sequence">সিকোয়েন্স</string>
|
||||
<string name="toolbar_custom_key_add">Add</string>
|
||||
<string name="toolbar_custom_key_cancel">বাতিল</string>
|
||||
<string name="toolbar_snippet_add">স্নিপেট যোগ করুন</string>
|
||||
<string name="toolbar_snippet_search">স্নিপেট খুঁজুন…</string>
|
||||
<string name="toolbar_snippet_delete">মুছুন</string>
|
||||
<string name="toolbar_snippet_dialog_title">স্নিপেট যোগ করুন</string>
|
||||
<string name="toolbar_snippet_label">লেবেল</string>
|
||||
<string name="toolbar_snippet_command">কমান্ড</string>
|
||||
|
||||
<!-- i18n sweep #210 -->
|
||||
<string name="toolbar_snippet_title">Snippets</string>
|
||||
<string name="toolbar_snippet_empty">এখনো কোনো snippet নেই। টুলবারে কাস্টম কী যোগ করুন, বা উপরে + চাপুন।</string>
|
||||
<string name="toolbar_snippet_empty_filtered">কোনো মেলানো snippet নেই।</string>
|
||||
<string name="toolbar_snippet_label_placeholder">যেমন Deploy, Restart</string>
|
||||
<string name="toolbar_keyboard_standard_desc">Standard কীবোর্ড (ভয়েস, সাজেশন, autocorrect চালু)</string>
|
||||
<string name="toolbar_keyboard_secure_desc">Secure কীবোর্ড (কোনো সাজেশন নেই, কোনো autocorrect নেই)</string>
|
||||
<string name="toolbar_attach_desc">রিমোটে পাঠাতে ফাইল সংযুক্ত করুন</string>
|
||||
<string name="toolbar_presets_label">Presets</string>
|
||||
<string name="toolbar_custom_key_label_placeholder">যেমন ^C, Paste</string>
|
||||
<string name="toolbar_text_input_desc">ভাসমান টেক্সট ইনপুট খুলুন</string>
|
||||
<string name="toolbar_dictate_desc">ডিক্টেশন: ভয়েস ইনপুট চালু করুন</string>
|
||||
</resources>
|
||||
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<!-- #135 third pass: keyboard toolbar accessibility / dialog labels.
|
||||
The core/toolbar module previously had no res/values at all —
|
||||
every string was hardcoded. -->
|
||||
<string name="toolbar_add_custom_key">Eigene Taste hinzufügen</string>
|
||||
<string name="toolbar_toggle_keyboard">Toggle keyboard</string>
|
||||
<string name="toolbar_reorder_keys">Symbolleistentasten neu anordnen</string>
|
||||
<string name="toolbar_done_reordering">Done reordering</string>
|
||||
<string name="toolbar_vnc_desktop">VNC Desktop</string>
|
||||
<string name="toolbar_settings">Toolbar settings</string>
|
||||
<string name="toolbar_custom_key_dialog_title">Eigene Taste hinzufügen</string>
|
||||
<string name="toolbar_custom_key_label">Label</string>
|
||||
<string name="toolbar_custom_key_sequence">Sequence</string>
|
||||
<string name="toolbar_custom_key_add">Add</string>
|
||||
<string name="toolbar_custom_key_cancel">Cancel</string>
|
||||
<string name="toolbar_snippet_add">Add snippet</string>
|
||||
<string name="toolbar_snippet_search">Search snippets…</string>
|
||||
<string name="toolbar_snippet_delete">Delete</string>
|
||||
<string name="toolbar_snippet_dialog_title">Add snippet</string>
|
||||
<string name="toolbar_snippet_label">Label</string>
|
||||
<string name="toolbar_snippet_command">Command</string>
|
||||
|
||||
<!-- i18n sweep #210 -->
|
||||
<string name="toolbar_snippet_title">Snippets</string>
|
||||
<string name="toolbar_snippet_empty">Noch keine Snippets. Füge benutzerdefinierte Tasten zur Toolbar hinzu oder tippe oben auf +.</string>
|
||||
<string name="toolbar_snippet_empty_filtered">Keine passenden Snippets.</string>
|
||||
<string name="toolbar_snippet_label_placeholder">z. B. Deployen, Neustart</string>
|
||||
<string name="toolbar_keyboard_standard_desc">Standard-Tastatur (Spracheingabe, Vorschläge, Autokorrektur aktiv)</string>
|
||||
<string name="toolbar_keyboard_secure_desc">Sichere Tastatur (keine Vorschläge, keine Autokorrektur)</string>
|
||||
<string name="toolbar_attach_desc">Datei anhängen und an Remote senden</string>
|
||||
<string name="toolbar_presets_label">Vorlagen</string>
|
||||
<string name="toolbar_custom_key_label_placeholder">z. B. ^C, Einfügen</string>
|
||||
<string name="toolbar_text_input_desc">Schwebende Texteingabe öffnen</string>
|
||||
<string name="toolbar_dictate_desc">Diktat: Spracheingabe starten</string>
|
||||
</resources>
|
||||
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<!-- #135 third pass: keyboard toolbar accessibility / dialog labels.
|
||||
The core/toolbar module previously had no res/values at all —
|
||||
every string was hardcoded. -->
|
||||
<string name="toolbar_add_custom_key">Añadir tecla personalizada</string>
|
||||
<string name="toolbar_toggle_keyboard">Toggle keyboard</string>
|
||||
<string name="toolbar_reorder_keys">Reordenar teclas de la barra</string>
|
||||
<string name="toolbar_done_reordering">Done reordering</string>
|
||||
<string name="toolbar_vnc_desktop">VNC Desktop</string>
|
||||
<string name="toolbar_settings">Toolbar settings</string>
|
||||
<string name="toolbar_custom_key_dialog_title">Añadir tecla personalizada</string>
|
||||
<string name="toolbar_custom_key_label">Label</string>
|
||||
<string name="toolbar_custom_key_sequence">Sequence</string>
|
||||
<string name="toolbar_custom_key_add">Add</string>
|
||||
<string name="toolbar_custom_key_cancel">Cancel</string>
|
||||
<string name="toolbar_snippet_add">Add snippet</string>
|
||||
<string name="toolbar_snippet_search">Search snippets…</string>
|
||||
<string name="toolbar_snippet_delete">Delete</string>
|
||||
<string name="toolbar_snippet_dialog_title">Add snippet</string>
|
||||
<string name="toolbar_snippet_label">Label</string>
|
||||
<string name="toolbar_snippet_command">Command</string>
|
||||
|
||||
<!-- i18n sweep #210 -->
|
||||
<string name="toolbar_snippet_title">Fragmentos</string>
|
||||
<string name="toolbar_snippet_empty">Aún no hay fragmentos. Agrega teclas personalizadas a la barra o toca + arriba.</string>
|
||||
<string name="toolbar_snippet_empty_filtered">No hay fragmentos que coincidan.</string>
|
||||
<string name="toolbar_snippet_label_placeholder">p. ej. Deploy, Restart</string>
|
||||
<string name="toolbar_keyboard_standard_desc">Teclado estándar (voz, sugerencias y autocorrección activos)</string>
|
||||
<string name="toolbar_keyboard_secure_desc">Teclado seguro (sin sugerencias, sin autocorrección)</string>
|
||||
<string name="toolbar_attach_desc">Adjuntar archivo para enviar al remoto</string>
|
||||
<string name="toolbar_presets_label">Presets</string>
|
||||
<string name="toolbar_custom_key_label_placeholder">p. ej. ^C, Paste</string>
|
||||
<string name="toolbar_text_input_desc">Abrir entrada de texto flotante</string>
|
||||
<string name="toolbar_dictate_desc">Dictar: iniciar entrada de voz</string>
|
||||
</resources>
|
||||
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<!-- #135 third pass: keyboard toolbar accessibility / dialog labels.
|
||||
The core/toolbar module previously had no res/values at all —
|
||||
every string was hardcoded. -->
|
||||
<string name="toolbar_add_custom_key">Ajouter une touche personnalisée</string>
|
||||
<string name="toolbar_toggle_keyboard">Toggle keyboard</string>
|
||||
<string name="toolbar_reorder_keys">Réorganiser les touches de la barre</string>
|
||||
<string name="toolbar_done_reordering">Done reordering</string>
|
||||
<string name="toolbar_vnc_desktop">VNC Desktop</string>
|
||||
<string name="toolbar_settings">Toolbar settings</string>
|
||||
<string name="toolbar_custom_key_dialog_title">Ajouter une touche personnalisée</string>
|
||||
<string name="toolbar_custom_key_label">Label</string>
|
||||
<string name="toolbar_custom_key_sequence">Sequence</string>
|
||||
<string name="toolbar_custom_key_add">Add</string>
|
||||
<string name="toolbar_custom_key_cancel">Cancel</string>
|
||||
<string name="toolbar_snippet_add">Add snippet</string>
|
||||
<string name="toolbar_snippet_search">Search snippets…</string>
|
||||
<string name="toolbar_snippet_delete">Delete</string>
|
||||
<string name="toolbar_snippet_dialog_title">Add snippet</string>
|
||||
<string name="toolbar_snippet_label">Label</string>
|
||||
<string name="toolbar_snippet_command">Command</string>
|
||||
|
||||
<!-- i18n sweep #210 -->
|
||||
<string name="toolbar_snippet_title">Extraits</string>
|
||||
<string name="toolbar_snippet_empty">Aucun extrait. Ajoutez des touches personnalisées à la barre ou appuyez sur + ci-dessus.</string>
|
||||
<string name="toolbar_snippet_empty_filtered">Aucun extrait correspondant.</string>
|
||||
<string name="toolbar_snippet_label_placeholder">ex. Déployer, Redémarrer</string>
|
||||
<string name="toolbar_keyboard_standard_desc">Clavier standard (voix, suggestions, correction automatique activés)</string>
|
||||
<string name="toolbar_keyboard_secure_desc">Clavier sécurisé (sans suggestions, sans correction automatique)</string>
|
||||
<string name="toolbar_attach_desc">Joindre un fichier à envoyer au serveur distant</string>
|
||||
<string name="toolbar_presets_label">Modèles</string>
|
||||
<string name="toolbar_custom_key_label_placeholder">ex. ^C, Coller</string>
|
||||
<string name="toolbar_text_input_desc">Ouvrir la saisie de texte flottante</string>
|
||||
<string name="toolbar_dictate_desc">Dictée : lancer la saisie vocale</string>
|
||||
</resources>
|
||||
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<!-- #135 third pass: keyboard toolbar accessibility / dialog labels.
|
||||
The core/toolbar module previously had no res/values at all —
|
||||
every string was hardcoded. -->
|
||||
<string name="toolbar_add_custom_key">कस्टम कुंजी जोड़ें</string>
|
||||
<string name="toolbar_toggle_keyboard">कीबोर्ड दिखाएँ/छिपाएँ</string>
|
||||
<string name="toolbar_reorder_keys">टूलबार कुंजियाँ पुनः क्रमित करें</string>
|
||||
<string name="toolbar_done_reordering">क्रम बदलना पूर्ण</string>
|
||||
<string name="toolbar_vnc_desktop">VNC डेस्कटॉप</string>
|
||||
<string name="toolbar_settings">टूलबार सेटिंग्स</string>
|
||||
<string name="toolbar_custom_key_dialog_title">कस्टम कुंजी जोड़ें</string>
|
||||
<string name="toolbar_custom_key_label">लेबल</string>
|
||||
<string name="toolbar_custom_key_sequence">अनुक्रम</string>
|
||||
<string name="toolbar_custom_key_add">Add</string>
|
||||
<string name="toolbar_custom_key_cancel">रद्द करें</string>
|
||||
<string name="toolbar_snippet_add">स्निपेट जोड़ें</string>
|
||||
<string name="toolbar_snippet_search">स्निपेट खोजें…</string>
|
||||
<string name="toolbar_snippet_delete">हटाएँ</string>
|
||||
<string name="toolbar_snippet_dialog_title">स्निपेट जोड़ें</string>
|
||||
<string name="toolbar_snippet_label">लेबल</string>
|
||||
<string name="toolbar_snippet_command">कमांड</string>
|
||||
|
||||
<!-- i18n sweep #210 -->
|
||||
<string name="toolbar_snippet_title">Snippets</string>
|
||||
<string name="toolbar_snippet_empty">अभी कोई snippet नहीं। टूलबार में कस्टम कुंजियाँ जोड़ें, या ऊपर + दबाएँ।</string>
|
||||
<string name="toolbar_snippet_empty_filtered">कोई मिलता snippet नहीं।</string>
|
||||
<string name="toolbar_snippet_label_placeholder">उदा. Deploy, Restart</string>
|
||||
<string name="toolbar_keyboard_standard_desc">Standard keyboard (voice, सुझाव, autocorrect चालू)</string>
|
||||
<string name="toolbar_keyboard_secure_desc">Secure keyboard (कोई सुझाव नहीं, कोई autocorrect नहीं)</string>
|
||||
<string name="toolbar_attach_desc">रिमोट पर भेजने के लिए फ़ाइल संलग्न करें</string>
|
||||
<string name="toolbar_presets_label">Presets</string>
|
||||
<string name="toolbar_custom_key_label_placeholder">उदा. ^C, Paste</string>
|
||||
<string name="toolbar_text_input_desc">फ़्लोटिंग टेक्स्ट इनपुट खोलें</string>
|
||||
<string name="toolbar_dictate_desc">बोलकर लिखें: वॉइस इनपुट शुरू करें</string>
|
||||
</resources>
|
||||
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<!-- #135 third pass: keyboard toolbar accessibility / dialog labels.
|
||||
The core/toolbar module previously had no res/values at all —
|
||||
every string was hardcoded. -->
|
||||
<string name="toolbar_add_custom_key">カスタムキーを追加</string>
|
||||
<string name="toolbar_toggle_keyboard">キーボードの表示切り替え</string>
|
||||
<string name="toolbar_reorder_keys">ツールバーのキーを並べ替える</string>
|
||||
<string name="toolbar_done_reordering">並べ替えを完了</string>
|
||||
<string name="toolbar_vnc_desktop">VNC デスクトップ</string>
|
||||
<string name="toolbar_settings">ツールバー設定</string>
|
||||
<string name="toolbar_custom_key_dialog_title">カスタムキーを追加</string>
|
||||
<string name="toolbar_custom_key_label">ラベル</string>
|
||||
<string name="toolbar_custom_key_sequence">シーケンス</string>
|
||||
<string name="toolbar_custom_key_add">Add</string>
|
||||
<string name="toolbar_custom_key_cancel">キャンセル</string>
|
||||
<string name="toolbar_snippet_add">スニペットを追加</string>
|
||||
<string name="toolbar_snippet_search">スニペットを検索…</string>
|
||||
<string name="toolbar_snippet_delete">削除</string>
|
||||
<string name="toolbar_snippet_dialog_title">スニペットを追加</string>
|
||||
<string name="toolbar_snippet_label">ラベル</string>
|
||||
<string name="toolbar_snippet_command">コマンド</string>
|
||||
|
||||
<!-- i18n sweep #210 -->
|
||||
<string name="toolbar_snippet_title">スニペット</string>
|
||||
<string name="toolbar_snippet_empty">スニペットはまだありません。ツールバーにカスタムキーを追加するか、上の + をタップしてください。</string>
|
||||
<string name="toolbar_snippet_empty_filtered">一致するスニペットがありません。</string>
|
||||
<string name="toolbar_snippet_label_placeholder">例: Deploy, Restart</string>
|
||||
<string name="toolbar_keyboard_standard_desc">標準キーボード(音声入力・候補・自動修正 オン)</string>
|
||||
<string name="toolbar_keyboard_secure_desc">セキュアキーボード(候補なし、自動修正なし)</string>
|
||||
<string name="toolbar_attach_desc">ファイルをリモートに送信するために添付</string>
|
||||
<string name="toolbar_presets_label">プリセット</string>
|
||||
<string name="toolbar_custom_key_label_placeholder">例: ^C, Paste</string>
|
||||
<string name="toolbar_text_input_desc">フローティング テキスト入力を開く</string>
|
||||
<string name="toolbar_dictate_desc">音声入力: ディクテーション開始</string>
|
||||
</resources>
|
||||
@@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="toolbar_add_custom_key">사용자 지정 키 추가</string>
|
||||
<string name="toolbar_toggle_keyboard">키보드 전환</string>
|
||||
<string name="toolbar_reorder_keys">도구 모음 키 순서 변경</string>
|
||||
<string name="toolbar_done_reordering">순서 변경 완료</string>
|
||||
<string name="toolbar_vnc_desktop">VNC 데스크톱</string>
|
||||
<string name="toolbar_settings">도구 모음 설정</string>
|
||||
<string name="toolbar_custom_key_dialog_title">사용자 지정 키 추가</string>
|
||||
<string name="toolbar_custom_key_label">라벨</string>
|
||||
<string name="toolbar_custom_key_sequence">시퀀스</string>
|
||||
<string name="toolbar_custom_key_add">추가</string>
|
||||
<string name="toolbar_custom_key_cancel">취소</string>
|
||||
<string name="toolbar_snippet_add">스니펫 추가</string>
|
||||
<string name="toolbar_snippet_search">스니펫 검색…</string>
|
||||
<string name="toolbar_snippet_delete">삭제</string>
|
||||
<string name="toolbar_snippet_dialog_title">스니펫 추가</string>
|
||||
<string name="toolbar_snippet_label">라벨</string>
|
||||
<string name="toolbar_snippet_command">명령</string>
|
||||
<string name="toolbar_snippet_title">스니펫</string>
|
||||
<string name="toolbar_snippet_empty">스니펫이 없습니다. 도구 모음에 사용자 지정 키를 추가하거나 위의 +를 누르세요.</string>
|
||||
<string name="toolbar_snippet_empty_filtered">일치하는 스니펫이 없습니다.</string>
|
||||
<string name="toolbar_snippet_label_placeholder">예: Deploy, Restart</string>
|
||||
<string name="toolbar_keyboard_standard_desc">기본 키보드 (음성, 추천, 자동 교정 켜짐)</string>
|
||||
<string name="toolbar_keyboard_secure_desc">보안 키보드 (추천 없음, 자동 교정 없음)</string>
|
||||
<string name="toolbar_attach_desc">원격으로 보낼 파일 첨부</string>
|
||||
<string name="toolbar_presets_label">프리셋</string>
|
||||
<string name="toolbar_custom_key_label_placeholder">예: ^C, Paste</string>
|
||||
<string name="toolbar_text_input_desc">플로팅 텍스트 입력 열기</string>
|
||||
<string name="toolbar_dictate_desc">구두 입력: 음성 입력 시작</string>
|
||||
</resources>
|
||||
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<!-- #135 third pass: keyboard toolbar accessibility / dialog labels.
|
||||
The core/toolbar module previously had no res/values at all —
|
||||
every string was hardcoded. -->
|
||||
<string name="toolbar_add_custom_key">Adicionar tecla personalizada</string>
|
||||
<string name="toolbar_toggle_keyboard">Toggle keyboard</string>
|
||||
<string name="toolbar_reorder_keys">Reordenar teclas da barra</string>
|
||||
<string name="toolbar_done_reordering">Done reordering</string>
|
||||
<string name="toolbar_vnc_desktop">VNC Desktop</string>
|
||||
<string name="toolbar_settings">Toolbar settings</string>
|
||||
<string name="toolbar_custom_key_dialog_title">Adicionar tecla personalizada</string>
|
||||
<string name="toolbar_custom_key_label">Label</string>
|
||||
<string name="toolbar_custom_key_sequence">Sequence</string>
|
||||
<string name="toolbar_custom_key_add">Add</string>
|
||||
<string name="toolbar_custom_key_cancel">Cancel</string>
|
||||
<string name="toolbar_snippet_add">Add snippet</string>
|
||||
<string name="toolbar_snippet_search">Search snippets…</string>
|
||||
<string name="toolbar_snippet_delete">Delete</string>
|
||||
<string name="toolbar_snippet_dialog_title">Add snippet</string>
|
||||
<string name="toolbar_snippet_label">Label</string>
|
||||
<string name="toolbar_snippet_command">Command</string>
|
||||
|
||||
<!-- i18n sweep #210 -->
|
||||
<string name="toolbar_snippet_title">Trechos</string>
|
||||
<string name="toolbar_snippet_empty">Nenhum trecho ainda. Adicione teclas personalizadas à barra ou toque em + acima.</string>
|
||||
<string name="toolbar_snippet_empty_filtered">Nenhum trecho encontrado.</string>
|
||||
<string name="toolbar_snippet_label_placeholder">ex. Deploy, Reiniciar</string>
|
||||
<string name="toolbar_keyboard_standard_desc">Teclado padrão (voz, sugestões e autocorreção ativos)</string>
|
||||
<string name="toolbar_keyboard_secure_desc">Teclado seguro (sem sugestões, sem autocorreção)</string>
|
||||
<string name="toolbar_attach_desc">Anexar arquivo para enviar ao remoto</string>
|
||||
<string name="toolbar_presets_label">Predefinições</string>
|
||||
<string name="toolbar_custom_key_label_placeholder">ex. ^C, Colar</string>
|
||||
<string name="toolbar_text_input_desc">Abrir entrada de texto flutuante</string>
|
||||
<string name="toolbar_dictate_desc">Ditar: iniciar entrada de voz</string>
|
||||
</resources>
|
||||
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<!-- #135 third pass: keyboard toolbar accessibility / dialog labels.
|
||||
The core/toolbar module previously had no res/values at all —
|
||||
every string was hardcoded. -->
|
||||
<string name="toolbar_add_custom_key">Добавить свою клавишу</string>
|
||||
<string name="toolbar_toggle_keyboard">Показать/скрыть клавиатуру</string>
|
||||
<string name="toolbar_reorder_keys">Изменить порядок клавиш панели</string>
|
||||
<string name="toolbar_done_reordering">Перестановка завершена</string>
|
||||
<string name="toolbar_vnc_desktop">Рабочий стол VNC</string>
|
||||
<string name="toolbar_settings">Настройки панели</string>
|
||||
<string name="toolbar_custom_key_dialog_title">Добавить свою клавишу</string>
|
||||
<string name="toolbar_custom_key_label">Метка</string>
|
||||
<string name="toolbar_custom_key_sequence">Последовательность</string>
|
||||
<string name="toolbar_custom_key_add">Add</string>
|
||||
<string name="toolbar_custom_key_cancel">Отмена</string>
|
||||
<string name="toolbar_snippet_add">Добавить сниппет</string>
|
||||
<string name="toolbar_snippet_search">Поиск сниппетов…</string>
|
||||
<string name="toolbar_snippet_delete">Удалить</string>
|
||||
<string name="toolbar_snippet_dialog_title">Добавить сниппет</string>
|
||||
<string name="toolbar_snippet_label">Метка</string>
|
||||
<string name="toolbar_snippet_command">Команда</string>
|
||||
|
||||
<!-- #210 i18n sweep -->
|
||||
<string name="toolbar_snippet_title">Сниппеты</string>
|
||||
<string name="toolbar_snippet_empty">Сниппетов пока нет. Добавьте пользовательские клавиши на панель или нажмите + выше.</string>
|
||||
<string name="toolbar_snippet_empty_filtered">Подходящих сниппетов не найдено.</string>
|
||||
<string name="toolbar_snippet_label_placeholder">напр. Deploy, Restart</string>
|
||||
<string name="toolbar_keyboard_standard_desc">Стандартная клавиатура (голос, подсказки, автокоррекция включены)</string>
|
||||
<string name="toolbar_keyboard_secure_desc">Защищённая клавиатура (без подсказок, без автокоррекции)</string>
|
||||
<string name="toolbar_attach_desc">Прикрепить файл для отправки на удалённый сервер</string>
|
||||
<string name="toolbar_presets_label">Шаблоны</string>
|
||||
<string name="toolbar_custom_key_label_placeholder">напр. ^C, Paste</string>
|
||||
<string name="toolbar_text_input_desc">Открыть плавающее поле ввода</string>
|
||||
<string name="toolbar_dictate_desc">Диктовка: начать голосовой ввод</string>
|
||||
</resources>
|
||||
@@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="toolbar_add_custom_key">Додај произвољни тастер</string>
|
||||
<string name="toolbar_toggle_keyboard">Укљ./искљ. тастатуру</string>
|
||||
<string name="toolbar_reorder_keys">Промени редослед тастера алатне линије</string>
|
||||
<string name="toolbar_done_reordering">Промена редоследа је завршена</string>
|
||||
<string name="toolbar_vnc_desktop">VNC десктоп</string>
|
||||
<string name="toolbar_settings">Подешавања алатне линије</string>
|
||||
<string name="toolbar_custom_key_dialog_title">Додавање произвољног тастера</string>
|
||||
<string name="toolbar_custom_key_label">Ознака</string>
|
||||
<string name="toolbar_custom_key_sequence">Низ тастера</string>
|
||||
<string name="toolbar_custom_key_add">Додај</string>
|
||||
<string name="toolbar_custom_key_cancel">Откажи</string>
|
||||
<string name="toolbar_snippet_add">Додај одломак</string>
|
||||
<string name="toolbar_snippet_search">Претражи одломке…</string>
|
||||
<string name="toolbar_snippet_delete">Обриши</string>
|
||||
<string name="toolbar_snippet_dialog_title">Додавање одломка</string>
|
||||
<string name="toolbar_snippet_label">Ознака</string>
|
||||
<string name="toolbar_snippet_command">Команда</string>
|
||||
<string name="toolbar_snippet_title">Одломци</string>
|
||||
<string name="toolbar_snippet_empty">Још увек нема ниједног одломка. Додајте произвољне тастере на алатну линију, или тапните на + изнад.</string>
|
||||
<string name="toolbar_snippet_empty_filtered">Ниједан одломак се не подудара.</string>
|
||||
<string name="toolbar_snippet_label_placeholder">нпр. Постави, Поново покрени</string>
|
||||
<string name="toolbar_keyboard_standard_desc">Стандардна тастатура (глас, предлози, укљ. аутоисправљање)</string>
|
||||
<string name="toolbar_keyboard_secure_desc">Безбедна тастатура (нема предлога, нема аутоисправљања)</string>
|
||||
<string name="toolbar_attach_desc">Прикачите фајл који се шаље удаљеном</string>
|
||||
<string name="toolbar_dictate_desc">Диктирање: започиње унос гласом</string>
|
||||
<string name="toolbar_text_input_desc">Отвара плутајући унос текста</string>
|
||||
<string name="toolbar_presets_label">Сачувана подешавања</string>
|
||||
<string name="toolbar_custom_key_label_placeholder">нпр. ^C, Налепи</string>
|
||||
</resources>
|
||||
@@ -0,0 +1,33 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="toolbar_add_custom_key">添加自定义按键</string>
|
||||
<string name="toolbar_toggle_keyboard">切换键盘</string>
|
||||
<string name="toolbar_reorder_keys">重新排序工具栏按键</string>
|
||||
<string name="toolbar_done_reordering">完成排序</string>
|
||||
<string name="toolbar_vnc_desktop">VNC 桌面</string>
|
||||
<string name="toolbar_settings">工具栏设置</string>
|
||||
<string name="toolbar_custom_key_dialog_title">添加自定义按键</string>
|
||||
<string name="toolbar_custom_key_label">标签</string>
|
||||
<string name="toolbar_custom_key_sequence">序列</string>
|
||||
<string name="toolbar_custom_key_add">添加</string>
|
||||
<string name="toolbar_custom_key_cancel">取消</string>
|
||||
<string name="toolbar_snippet_add">添加片段</string>
|
||||
<string name="toolbar_snippet_search">搜索片段…</string>
|
||||
<string name="toolbar_snippet_delete">删除</string>
|
||||
<string name="toolbar_snippet_dialog_title">添加片段</string>
|
||||
<string name="toolbar_snippet_label">标签</string>
|
||||
<string name="toolbar_snippet_command">命令</string>
|
||||
|
||||
<!-- i18n sweep #210 -->
|
||||
<string name="toolbar_snippet_title">片段</string>
|
||||
<string name="toolbar_snippet_empty">暂无片段。向工具栏添加自定义按键,或点击上方的 +。</string>
|
||||
<string name="toolbar_snippet_empty_filtered">无匹配片段。</string>
|
||||
<string name="toolbar_snippet_label_placeholder">例如 Deploy、Restart</string>
|
||||
<string name="toolbar_keyboard_standard_desc">标准键盘(开启语音、建议和自动纠正)</string>
|
||||
<string name="toolbar_keyboard_secure_desc">安全键盘(无建议,无自动纠正)</string>
|
||||
<string name="toolbar_attach_desc">附加文件发送到远程</string>
|
||||
<string name="toolbar_presets_label">预设</string>
|
||||
<string name="toolbar_custom_key_label_placeholder">例如 ^C、Paste</string>
|
||||
<string name="toolbar_text_input_desc">打开悬浮文本输入</string>
|
||||
<string name="toolbar_dictate_desc">听写:开始语音输入</string>
|
||||
</resources>
|
||||
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<!-- #135 third pass: keyboard toolbar accessibility / dialog labels.
|
||||
The core/toolbar module previously had no res/values at all —
|
||||
every string was hardcoded. -->
|
||||
<string name="toolbar_add_custom_key">Add custom key</string>
|
||||
<string name="toolbar_toggle_keyboard">Toggle keyboard</string>
|
||||
<string name="toolbar_reorder_keys">Reorder toolbar keys</string>
|
||||
<string name="toolbar_done_reordering">Done reordering</string>
|
||||
<string name="toolbar_vnc_desktop">VNC Desktop</string>
|
||||
<string name="toolbar_settings">Toolbar settings</string>
|
||||
<string name="toolbar_custom_key_dialog_title">Add custom key</string>
|
||||
<string name="toolbar_custom_key_label">Label</string>
|
||||
<string name="toolbar_custom_key_sequence">Sequence</string>
|
||||
<string name="toolbar_custom_key_add">Add</string>
|
||||
<string name="toolbar_custom_key_cancel">Cancel</string>
|
||||
<string name="toolbar_snippet_add">Add snippet</string>
|
||||
<string name="toolbar_snippet_search">Search snippets…</string>
|
||||
<string name="toolbar_snippet_delete">Delete</string>
|
||||
<string name="toolbar_snippet_dialog_title">Add snippet</string>
|
||||
<string name="toolbar_snippet_label">Label</string>
|
||||
<string name="toolbar_snippet_command">Command</string>
|
||||
<!-- Strings added for issue #210 localisation -->
|
||||
<string name="toolbar_snippet_title">Snippets</string>
|
||||
<string name="toolbar_snippet_empty">No snippets yet. Add custom keys to the toolbar, or tap + above.</string>
|
||||
<string name="toolbar_snippet_empty_filtered">No matching snippets.</string>
|
||||
<string name="toolbar_snippet_label_placeholder">e.g. Deploy, Restart</string>
|
||||
<string name="toolbar_keyboard_standard_desc">Standard keyboard (voice, suggestions, autocorrect on)</string>
|
||||
<string name="toolbar_keyboard_secure_desc">Secure keyboard (no suggestions, no autocorrect)</string>
|
||||
<string name="toolbar_attach_desc">Attach file to send to remote</string>
|
||||
<string name="toolbar_dictate_desc">Dictate: start voice input</string>
|
||||
<string name="toolbar_text_input_desc">Open floating text input</string>
|
||||
<string name="toolbar_presets_label">Presets</string>
|
||||
<string name="toolbar_custom_key_label_placeholder">e.g. ^C, Paste</string>
|
||||
</resources>
|
||||
@@ -0,0 +1,141 @@
|
||||
package sh.haven.core.toolbar
|
||||
|
||||
import android.view.MotionEvent
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
|
||||
/**
|
||||
* #515 — "Arrow buttons stop working after a few taps."
|
||||
*
|
||||
* The reported symptom was a toolbar arrow that still highlighted on touch but
|
||||
* sent nothing, and stayed that way until the session was closed and reopened.
|
||||
* Two independent latches produced it, and each gets a test here:
|
||||
*
|
||||
* 1. The touch filter switched on `MotionEvent.action`. Compose hands the
|
||||
* callback the window's original event, so once a second finger is down the
|
||||
* release arrives as ACTION_POINTER_UP — a *packed* value (0x0106 for pointer
|
||||
* index 1), never equal to ACTION_UP. It fell through to the ignore branch
|
||||
* and neither flag was cleared.
|
||||
* 2. `didRepeat` was reset at the top of the repeat effect rather than on
|
||||
* release. A DOWN and UP landing in the same frame leave `pressed` unchanged
|
||||
* as far as composition can see, so the effect never relaunches and the flag
|
||||
* stays true for the life of the composable.
|
||||
*
|
||||
* With `didRepeat` latched, every later tap takes the "this is the tail of a
|
||||
* hold" path and emits no click. The flags live inside `key(sessionId)`, which is
|
||||
* why only a new session cleared it.
|
||||
*/
|
||||
class KeyTouchTest {
|
||||
|
||||
/** ACTION_POINTER_UP as the platform really delivers it: pointer index 1 packed into bits 8-15. */
|
||||
private val pointerUpIndex1 =
|
||||
MotionEvent.ACTION_POINTER_UP or (1 shl MotionEvent.ACTION_POINTER_INDEX_SHIFT)
|
||||
|
||||
private val pointerDownIndex1 =
|
||||
MotionEvent.ACTION_POINTER_DOWN or (1 shl MotionEvent.ACTION_POINTER_INDEX_SHIFT)
|
||||
|
||||
@Test
|
||||
fun `a plain tap emits one click`() {
|
||||
val down = keyTouch(MotionEvent.ACTION_DOWN, pressed = false, didRepeat = false)
|
||||
assertTrue(down.pressed)
|
||||
assertFalse("pressing must not click; the click belongs to the release", down.emitClick)
|
||||
|
||||
val up = keyTouch(MotionEvent.ACTION_UP, down.pressed, down.didRepeat)
|
||||
assertTrue("a tap that never repeated must click on release", up.emitClick)
|
||||
assertFalse(up.pressed)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `a hold does not add a click on release`() {
|
||||
val up = keyTouch(MotionEvent.ACTION_UP, pressed = true, didRepeat = true)
|
||||
assertFalse("the repeat loop already delivered these keys", up.emitClick)
|
||||
}
|
||||
|
||||
/** Latch 1: the release arrives packed, and must still be treated as a release. */
|
||||
@Test
|
||||
fun `a packed pointer-up releases the key`() {
|
||||
val result = keyTouch(pointerUpIndex1, pressed = true, didRepeat = true)
|
||||
|
||||
assertTrue(
|
||||
"ACTION_POINTER_UP must be recognised — masking it off is the whole point",
|
||||
result.consumed,
|
||||
)
|
||||
assertFalse("a release that leaves pressed set never stops the repeat loop", result.pressed)
|
||||
assertFalse("a release that leaves didRepeat set kills every later tap", result.didRepeat)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `a packed pointer-down presses the key`() {
|
||||
val result = keyTouch(pointerDownIndex1, pressed = false, didRepeat = false)
|
||||
assertTrue(result.pressed)
|
||||
assertTrue(result.consumed)
|
||||
}
|
||||
|
||||
/** Latch 2: no terminal event may leave didRepeat set, whatever it was before. */
|
||||
@Test
|
||||
fun `every release clears didRepeat`() {
|
||||
val releases = mapOf(
|
||||
"ACTION_UP" to MotionEvent.ACTION_UP,
|
||||
"ACTION_POINTER_UP" to pointerUpIndex1,
|
||||
"ACTION_CANCEL" to MotionEvent.ACTION_CANCEL,
|
||||
)
|
||||
for ((name, action) in releases) {
|
||||
val result = keyTouch(action, pressed = true, didRepeat = true)
|
||||
assertFalse("$name left didRepeat set", result.didRepeat)
|
||||
assertFalse("$name left pressed set", result.pressed)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The reported sequence end to end: hold one arrow past the repeat threshold,
|
||||
* release it while a second finger is on the toolbar, then tap it again. The
|
||||
* second tap has to type.
|
||||
*/
|
||||
@Test
|
||||
fun `holding then releasing under multi-touch leaves the key usable`() {
|
||||
var pressed = keyTouch(MotionEvent.ACTION_DOWN, false, false).pressed
|
||||
var didRepeat = true // the repeat loop has been running for a while
|
||||
|
||||
// Second finger lands elsewhere on the toolbar; this key sees the packed form.
|
||||
keyTouch(pointerDownIndex1, pressed, didRepeat).let {
|
||||
pressed = it.pressed
|
||||
didRepeat = it.didRepeat
|
||||
}
|
||||
// Lift off this key while the other finger is still down.
|
||||
keyTouch(pointerUpIndex1, pressed, didRepeat).let {
|
||||
pressed = it.pressed
|
||||
didRepeat = it.didRepeat
|
||||
}
|
||||
|
||||
val tapDown = keyTouch(MotionEvent.ACTION_DOWN, pressed, didRepeat)
|
||||
val tapUp = keyTouch(MotionEvent.ACTION_UP, tapDown.pressed, tapDown.didRepeat)
|
||||
assertTrue("the arrow is dead — this is the bug in #515", tapUp.emitClick)
|
||||
}
|
||||
|
||||
/**
|
||||
* A tap whose DOWN and UP collapse into one frame: composition never observes
|
||||
* `pressed` change, so the repeat effect never runs. The transition must not
|
||||
* depend on it having run.
|
||||
*/
|
||||
@Test
|
||||
fun `taps still click when the repeat effect never gets to run`() {
|
||||
var pressed = false
|
||||
var didRepeat = false
|
||||
repeat(5) { i ->
|
||||
val down = keyTouch(MotionEvent.ACTION_DOWN, pressed, didRepeat)
|
||||
val up = keyTouch(MotionEvent.ACTION_UP, down.pressed, down.didRepeat)
|
||||
assertTrue("tap $i sent nothing", up.emitClick)
|
||||
pressed = up.pressed
|
||||
didRepeat = up.didRepeat
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `unrelated events are left alone`() {
|
||||
val result = keyTouch(MotionEvent.ACTION_MOVE, pressed = true, didRepeat = true)
|
||||
assertFalse("a move must not steal the event from the scrolling parent", result.consumed)
|
||||
assertTrue("a move must not disturb the press state", result.pressed)
|
||||
assertTrue(result.didRepeat)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user