mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-06 13:05:47 +00:00
feat(settings): Keep search history and center opened settings
Recall recent Settings searches and bring the setting opened from search into view.
This commit is contained in:
1 parent
f50691ebc9
commit
a4751dacbe
40 files changed
+290
-14
No files matched your search
@@ -10,6 +10,7 @@ import com.droiddeck.launcher.gpu.Cardboard
|
||||
import com.droiddeck.launcher.gpu.ScreenEffects
|
||||
import com.droiddeck.launcher.gpu.SystemVulkanDriver
|
||||
import com.droiddeck.launcher.gpu.TurnipDriver
|
||||
import org.json.JSONArray
|
||||
import org.json.JSONObject
|
||||
import java.io.File
|
||||
|
||||
@@ -317,6 +318,14 @@ object SessionPrefs {
|
||||
prefs(context).edit().putBoolean("telemetryAuto", on).apply()
|
||||
}
|
||||
|
||||
fun settingsSearches(context: Context): List<String> = runCatching {
|
||||
JSONArray(prefs(context).getString("settingsSearches", null) ?: "[]").let { a -> List(a.length()) { a.getString(it) } }
|
||||
}.getOrDefault(emptyList())
|
||||
|
||||
fun setSettingsSearches(context: Context, searches: List<String>) {
|
||||
prefs(context).edit().putString("settingsSearches", JSONArray(searches).toString()).apply()
|
||||
}
|
||||
|
||||
fun telemetryOff(context: Context): Set<String> = prefs(context).getStringSet("telemetryOff", null)?.toSet().orEmpty()
|
||||
|
||||
fun setTelemetryOff(context: Context, keys: Set<String>) {
|
||||
|
||||
@@ -231,7 +231,10 @@ internal fun SetupPanel(
|
||||
}
|
||||
val chipFocus = remember { List(tabs.size) { FocusRequester() } }
|
||||
var tabTurned by remember { mutableStateOf(false) }
|
||||
val pick: (Int) -> Unit = { i -> tab = i; tabTurned = true; searching = false; query = ""; if (i == DEVELOPER_TAB) logsRefresh++ }
|
||||
remember { SettingsSearchHistory.load(ctx) }
|
||||
var fromHistory by remember { mutableStateOf(false) }
|
||||
val keepSearch = { if (searching && SettingsIndex.search(ctx, query, frostRow).isNotEmpty()) SettingsSearchHistory.add(ctx, query) }
|
||||
val pick: (Int) -> Unit = { i -> keepSearch(); tab = i; tabTurned = true; searching = false; query = ""; if (i == DEVELOPER_TAB) logsRefresh++ }
|
||||
val inputModeManager = LocalInputModeManager.current
|
||||
LaunchedEffect(Unit) {
|
||||
while (true) {
|
||||
@@ -258,8 +261,9 @@ internal fun SetupPanel(
|
||||
) {
|
||||
val sectionBar: @Composable (Modifier) -> Unit = { m ->
|
||||
SettingsPillSearch(
|
||||
m, searching, query, { query = it },
|
||||
onOpen = { searching = true }, onClose = { searching = false; query = "" },
|
||||
m, searching, query, { query = it; fromHistory = false },
|
||||
onOpen = { searching = true }, onClose = { keepSearch(); searching = false; query = "" },
|
||||
keepOpen = SettingsSearchHistory.items.isNotEmpty(), onSearch = keepSearch,
|
||||
) { SheetChips(tabs, tab, chipFocus, onPick = pick) }
|
||||
}
|
||||
val portrait = androidx.compose.ui.platform.LocalConfiguration.current.orientation == android.content.res.Configuration.ORIENTATION_PORTRAIT
|
||||
@@ -268,9 +272,11 @@ internal fun SetupPanel(
|
||||
Row(Modifier.fillMaxWidth().padding(bottom = 10.dp)) { sectionBar(Modifier.weight(1f)) }
|
||||
} else PageHeader(stringResource(R.string.setup_title)) { sectionBar(Modifier.weight(1f)) }
|
||||
val listing = searching && query.isNotBlank()
|
||||
val fixed = tab == CONTROLLER_TAB && !listing
|
||||
val history = searching && query.isBlank() && SettingsSearchHistory.items.isNotEmpty()
|
||||
val fixed = tab == CONTROLLER_TAB && !listing && !history
|
||||
Column(modifier = Modifier.weight(1f).fillMaxWidth().then(if (fixed) Modifier else Modifier.verticalScroll(rememberScrollState())).padding(bottom = if (fixed) 0.dp else 24.dp)) {
|
||||
if (listing) SettingsSearchResults(query, frostRow) { section -> pick(section.ordinal) }
|
||||
if (listing) SettingsSearchResults(query, frostRow, focusFirst = fromHistory, onSearched = keepSearch) { section -> pick(section.ordinal) }
|
||||
else if (history) SettingsSearchHistoryList(onPick = { fromHistory = true; query = it }) { SettingsSearchHistory.clear(ctx) }
|
||||
else when (tab) {
|
||||
OVERVIEW_TAB -> {
|
||||
OnboardingCard(limitBlocks, a.onShowPhantomGate)
|
||||
|
||||
@@ -16,6 +16,10 @@ import androidx.compose.runtime.setValue
|
||||
import androidx.compose.runtime.withFrameNanos
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.drawBehind
|
||||
import androidx.compose.ui.geometry.Offset
|
||||
import androidx.compose.ui.geometry.Rect
|
||||
import androidx.compose.ui.layout.LayoutCoordinates
|
||||
import androidx.compose.ui.layout.onPlaced
|
||||
|
||||
/** The row a settings search result opens, so the page it lands on can scroll to it and flash it. */
|
||||
internal object SettingsJump {
|
||||
@@ -31,12 +35,32 @@ private const val JUMP_WINDOW_MS = 5_000L
|
||||
/** False in the search results, whose rows carry the same labels as the rows they open. */
|
||||
internal val LocalSearchTargets = staticCompositionLocalOf { true }
|
||||
|
||||
/** How far a page has to be scrolled to show a row in its middle, or as near to it as the page's ends allow. */
|
||||
internal fun centeredScroll(rowTop: Float, rowHeight: Float, page: Float, content: Float): Float =
|
||||
(rowTop + rowHeight / 2f - page / 2f).coerceIn(0f, (content - page).coerceAtLeast(0f))
|
||||
|
||||
/** The part of the page to show around a row to have it in the middle, relative to the row. Null when nothing around it scrolls. */
|
||||
private fun pageAround(row: LayoutCoordinates): Rect? {
|
||||
var content = row
|
||||
while (true) {
|
||||
val page = content.parentCoordinates ?: return null
|
||||
if (content.size.height > page.size.height) {
|
||||
val top = content.localPositionOf(row, Offset.Zero).y
|
||||
val height = page.size.height.toFloat()
|
||||
val from = centeredScroll(top, row.size.height.toFloat(), height, content.size.height.toFloat()) - top
|
||||
return Rect(0f, from, row.size.width.toFloat(), from + height)
|
||||
}
|
||||
content = page
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(androidx.compose.foundation.ExperimentalFoundationApi::class)
|
||||
@Composable
|
||||
internal fun Modifier.searchTarget(label: String): Modifier {
|
||||
val pal = LocalPalette.current
|
||||
val flash = remember { Animatable(0f) }
|
||||
val reveal = remember { BringIntoViewRequester() }
|
||||
val row = remember { arrayOfNulls<LayoutCoordinates>(1) }
|
||||
var claimed by remember { mutableStateOf<SettingsJump.Target?>(null) }
|
||||
val target = SettingsJump.target.takeIf { LocalSearchTargets.current }
|
||||
if (target != null && target.label == label) SideEffect {
|
||||
@@ -48,7 +72,7 @@ internal fun Modifier.searchTarget(label: String): Modifier {
|
||||
claimed?.let { mine ->
|
||||
LaunchedEffect(mine) {
|
||||
withFrameNanos { }
|
||||
reveal.bringIntoView()
|
||||
reveal.bringIntoView(row[0]?.takeIf { it.isAttached }?.let(::pageAround))
|
||||
repeat(2) {
|
||||
flash.animateTo(1f, tween(220))
|
||||
flash.animateTo(0f, tween(420))
|
||||
@@ -56,7 +80,7 @@ internal fun Modifier.searchTarget(label: String): Modifier {
|
||||
claimed = null
|
||||
}
|
||||
}
|
||||
return bringIntoViewRequester(reveal).drawBehind {
|
||||
return bringIntoViewRequester(reveal).onPlaced { row[0] = it }.drawBehind {
|
||||
if (flash.value > 0f) drawRect(pal.signal.copy(alpha = 0.28f * flash.value))
|
||||
}
|
||||
}
|
||||
@@ -42,7 +42,7 @@ import androidx.compose.ui.semantics.clearAndSetSemantics
|
||||
@Composable
|
||||
internal fun SettingsPillSearch(
|
||||
modifier: Modifier, searching: Boolean, query: String, onQuery: (String) -> Unit,
|
||||
onOpen: () -> Unit, onClose: () -> Unit, pills: @Composable () -> Unit,
|
||||
onOpen: () -> Unit, onClose: () -> Unit, keepOpen: Boolean = false, onSearch: () -> Unit = {}, pills: @Composable () -> Unit,
|
||||
) {
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val open by animateFloatAsState(if (searching) 1f else 0f, Motion.sp(0.75f, 420f), label = "settingsSearch")
|
||||
@@ -53,10 +53,11 @@ internal fun SettingsPillSearch(
|
||||
var fieldFocused by remember { mutableStateOf(false) }
|
||||
CancelPendingFocus(focusOnOpen, focusTap, fieldFocused) {
|
||||
focusOnOpen = false
|
||||
if (query.isEmpty()) onClose()
|
||||
if (query.isEmpty() && !keepOpen) onClose()
|
||||
}
|
||||
val close = { toIcon = true; focusOnOpen = false; onClose() }
|
||||
BackHandler(enabled = searching) { close() }
|
||||
LaunchedEffect(keepOpen) { if (!keepOpen && searching && !fieldFocused && !focusOnOpen && query.isEmpty()) close() }
|
||||
LaunchedEffect(toIcon, searching, open <= 0.01f) {
|
||||
if (searching) toIcon = false
|
||||
else if (toIcon && open <= 0.01f) { focusSoon { icon }; toIcon = false }
|
||||
@@ -80,10 +81,13 @@ internal fun SettingsPillSearch(
|
||||
AdbTextField(
|
||||
value = query, onValueChange = onQuery, label = "", keyboardType = KeyboardType.Text, imeAction = ImeAction.Search,
|
||||
placeholder = stringResource(R.string.settings_search), compact = true, showLabel = false, focusOnShow = focusOnOpen, focusAtTap = focusTap,
|
||||
clearFocus = !searching,
|
||||
clearFocus = !searching, onDone = onSearch,
|
||||
onFocusChange = { focused ->
|
||||
fieldFocused = focused
|
||||
if (!focused && query.isEmpty() && searching) { focusOnOpen = false; onClose() }
|
||||
if (!focused && query.isEmpty() && searching) {
|
||||
focusOnOpen = false
|
||||
if (!keepOpen) onClose()
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
@@ -96,13 +100,19 @@ internal fun SettingsPillSearch(
|
||||
}
|
||||
|
||||
@Composable
|
||||
internal fun SettingsSearchResults(query: String, frost: Boolean, onOpen: (SettingsSection) -> Unit) {
|
||||
internal fun SettingsSearchResults(query: String, frost: Boolean, focusFirst: Boolean = false, onSearched: () -> Unit = {}, onOpen: (SettingsSection) -> Unit) {
|
||||
val ctx = LocalContext.current
|
||||
val found = remember(query, frost) { SettingsIndex.search(ctx, query, frost) }
|
||||
if (found.isEmpty()) {
|
||||
Note(stringResource(R.string.settings_search_none, query.trim()))
|
||||
return
|
||||
}
|
||||
val first = remember { FocusRequester() }
|
||||
val firstToOpen = found.groupBy { it.place }.values.flatten().firstOrNull { it.section != null || it.tab != null }
|
||||
val inputMode = androidx.compose.ui.platform.LocalInputModeManager.current
|
||||
LaunchedEffect(Unit) {
|
||||
if (focusFirst && firstToOpen != null && inputMode.inputMode == androidx.compose.ui.input.InputMode.Keyboard) focusSoon { first }
|
||||
}
|
||||
androidx.compose.runtime.CompositionLocalProvider(LocalSearchTargets provides false) { Column {
|
||||
found.groupBy { it.place }.forEach { (place, entries) ->
|
||||
SettingsGroup(stringResource(place.title)) {
|
||||
@@ -111,10 +121,12 @@ internal fun SettingsSearchResults(query: String, frost: Boolean, onOpen: (Setti
|
||||
val title = stringResource(entry.title)
|
||||
val section = entry.section
|
||||
val tab = entry.tab
|
||||
val button = if (entry === firstToOpen) Modifier.focusRequester(first) else Modifier
|
||||
if (section != null) {
|
||||
ActionRow(title, within, stringResource(R.string.store_open), onClick = { SettingsJump.to(title); onOpen(section) })
|
||||
ActionRow(title, within, stringResource(R.string.store_open), modifier = button, onClick = { onSearched(); SettingsJump.to(title); onOpen(section) })
|
||||
} else if (tab != null) {
|
||||
ActionRow(title, within, stringResource(R.string.store_open), onClick = {
|
||||
ActionRow(title, within, stringResource(R.string.store_open), modifier = button, onClick = {
|
||||
onSearched()
|
||||
SettingsJump.to(title)
|
||||
if (tab == NavTabs.MORE) MoreTabs.editing = true
|
||||
if (tab == "downloads") DownloadsNav.showSettings = true
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
package com.droiddeck.launcher.ui
|
||||
|
||||
import android.content.Context
|
||||
import androidx.compose.foundation.LocalIndication
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.hoverable
|
||||
import androidx.compose.foundation.interaction.MutableInteractionSource
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.ExperimentalLayoutApi
|
||||
import androidx.compose.foundation.layout.FlowRow
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.heightIn
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.widthIn
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.outlined.Delete
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
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.draw.clip
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.semantics.Role
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import com.droiddeck.launcher.R
|
||||
import com.droiddeck.launcher.session.SessionPrefs
|
||||
|
||||
/** What was searched for in Settings, newest first. */
|
||||
internal object SettingsSearchHistory {
|
||||
const val MAX = 8
|
||||
|
||||
var items by mutableStateOf<List<String>>(emptyList())
|
||||
private set
|
||||
|
||||
fun load(context: Context) { items = SessionPrefs.settingsSearches(context) }
|
||||
|
||||
fun add(context: Context, query: String) {
|
||||
val next = withSearch(items, query)
|
||||
if (next == items) return
|
||||
items = next
|
||||
SessionPrefs.setSettingsSearches(context, next)
|
||||
}
|
||||
|
||||
fun clear(context: Context) {
|
||||
items = emptyList()
|
||||
SessionPrefs.setSettingsSearches(context, emptyList())
|
||||
}
|
||||
|
||||
fun withSearch(items: List<String>, query: String): List<String> {
|
||||
val text = query.trim().replace(Regex("\\s+"), " ")
|
||||
if (text.isEmpty()) return items
|
||||
return (listOf(text) + items.filterNot { it.equals(text, ignoreCase = true) }).take(MAX)
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalLayoutApi::class)
|
||||
@Composable
|
||||
internal fun SettingsSearchHistoryList(onPick: (String) -> Unit, onClear: () -> Unit) {
|
||||
val colors = MaterialTheme.colorScheme
|
||||
Column(Modifier.fillMaxWidth()) {
|
||||
Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier.fillMaxWidth().padding(top = 12.dp, bottom = 8.dp)) {
|
||||
Text(
|
||||
stringResource(R.string.settings_search_history), fontSize = 16.sp, fontWeight = FontWeight.SemiBold, color = colors.onSurfaceVariant,
|
||||
modifier = Modifier.weight(1f).padding(start = 4.dp),
|
||||
)
|
||||
SmallIconButton(Icons.Outlined.Delete, stringResource(R.string.settings_search_history_clear), tint = colors.onSurfaceVariant, onClick = onClear)
|
||||
}
|
||||
FlowRow(horizontalArrangement = Arrangement.spacedBy(8.dp), verticalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
SettingsSearchHistory.items.forEach { HistoryChip(it) { onPick(it) } }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun HistoryChip(text: String, onClick: () -> Unit) {
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val pal = LocalPalette.current
|
||||
val src = remember { MutableInteractionSource() }
|
||||
val hot = rememberHot(src)
|
||||
Box(
|
||||
contentAlignment = Alignment.Center,
|
||||
modifier = Modifier.heightIn(min = 40.dp).widthIn(min = 56.dp, max = 260.dp).clip(CircleShape)
|
||||
.background(colors.surface).glideBorder(hot, CircleShape, pal.signal, pal.line)
|
||||
.hoverable(src).clickable(interactionSource = src, indication = LocalIndication.current, role = Role.Button, onClick = onClick)
|
||||
.controllerConfirm(onClick = onClick)
|
||||
.padding(horizontal = 16.dp, vertical = 8.dp),
|
||||
) { Text(text, fontSize = 14.sp, color = colors.onBackground, maxLines = 1, overflow = TextOverflow.Ellipsis) }
|
||||
}
|
||||
@@ -4356,4 +4356,6 @@
|
||||
<string name="glasses_show_shortcut_hint">إظهار زر النظارات الذكية العائم فوق اللعبة.</string>
|
||||
<string name="display_filter_game_profile">استخدام ملف تعريف %1$s: %2$s</string>
|
||||
<string name="display_filter_default_profile">استخدام الملف التعريفي الافتراضي: %1$s</string>
|
||||
<string name="settings_search_history">سجل البحث</string>
|
||||
<string name="settings_search_history_clear">مسح سجل البحث</string>
|
||||
</resources>
|
||||
@@ -4234,4 +4234,6 @@
|
||||
<string name="glasses_show_shortcut_hint">Mostrar el botón flotante de Smart Glasses sobre el juego.</string>
|
||||
<string name="display_filter_game_profile">Usando el perfil %1$s: %2$s</string>
|
||||
<string name="display_filter_default_profile">Usando el perfil predeterminado: %1$s</string>
|
||||
<string name="settings_search_history">Historial de búsqueda</string>
|
||||
<string name="settings_search_history_clear">Borrar historial de búsqueda</string>
|
||||
</resources>
|
||||
@@ -4196,4 +4196,6 @@
|
||||
<string name="glasses_show_shortcut_hint">Показва плаващия бутон за Smart Glasses върху играта.</string>
|
||||
<string name="display_filter_game_profile">Използва се профил %1$s: %2$s</string>
|
||||
<string name="display_filter_default_profile">Използва се профилът по подразбиране: %1$s</string>
|
||||
<string name="settings_search_history">История на търсенето</string>
|
||||
<string name="settings_search_history_clear">Изчистване на историята на търсенето</string>
|
||||
</resources>
|
||||
@@ -4276,4 +4276,6 @@
|
||||
<string name="glasses_show_shortcut_hint">Zobrazit plovoucí tlačítko Smart Glasses nad hrou.</string>
|
||||
<string name="display_filter_game_profile">Používá se profil %1$s: %2$s</string>
|
||||
<string name="display_filter_default_profile">Používá se výchozí profil: %1$s</string>
|
||||
<string name="settings_search_history">Historie hledání</string>
|
||||
<string name="settings_search_history_clear">Vymazat historii hledání</string>
|
||||
</resources>
|
||||
@@ -4196,4 +4196,6 @@
|
||||
<string name="glasses_show_shortcut_hint">Vis den flydende Smart Glasses-knap oven på spillet.</string>
|
||||
<string name="display_filter_game_profile">Bruger profilen %1$s: %2$s</string>
|
||||
<string name="display_filter_default_profile">Bruger standardprofilen: %1$s</string>
|
||||
<string name="settings_search_history">Søgehistorik</string>
|
||||
<string name="settings_search_history_clear">Ryd søgehistorik</string>
|
||||
</resources>
|
||||
@@ -4196,4 +4196,6 @@
|
||||
<string name="glasses_show_shortcut_hint">Die schwebende Smart-Glasses-Schaltfläche über dem Spiel anzeigen.</string>
|
||||
<string name="display_filter_game_profile">Profil %1$s wird verwendet: %2$s</string>
|
||||
<string name="display_filter_default_profile">Standardprofil wird verwendet: %1$s</string>
|
||||
<string name="settings_search_history">Suchverlauf</string>
|
||||
<string name="settings_search_history_clear">Suchverlauf löschen</string>
|
||||
</resources>
|
||||
@@ -4196,4 +4196,6 @@
|
||||
<string name="glasses_show_shortcut_hint">Εμφάνιση του αιωρούμενου κουμπιού Smart Glasses πάνω από το παιχνίδι.</string>
|
||||
<string name="display_filter_game_profile">Χρήση προφίλ %1$s: %2$s</string>
|
||||
<string name="display_filter_default_profile">Χρήση προεπιλεγμένου προφίλ: %1$s</string>
|
||||
<string name="settings_search_history">Ιστορικό αναζήτησης</string>
|
||||
<string name="settings_search_history_clear">Εκκαθάριση ιστορικού αναζήτησης</string>
|
||||
</resources>
|
||||
@@ -4236,4 +4236,6 @@
|
||||
<string name="glasses_show_shortcut_hint">Mostrar el botón flotante de Smart Glasses sobre el juego.</string>
|
||||
<string name="display_filter_game_profile">Usando el perfil %1$s: %2$s</string>
|
||||
<string name="display_filter_default_profile">Usando el perfil predeterminado: %1$s</string>
|
||||
<string name="settings_search_history">Historial de búsqueda</string>
|
||||
<string name="settings_search_history_clear">Borrar historial de búsqueda</string>
|
||||
</resources>
|
||||
@@ -4196,4 +4196,6 @@
|
||||
<string name="glasses_show_shortcut_hint">Näytä pelin päällä kelluva Smart Glasses -painike.</string>
|
||||
<string name="display_filter_game_profile">Käytössä profiili %1$s: %2$s</string>
|
||||
<string name="display_filter_default_profile">Käytössä oletusprofiili: %1$s</string>
|
||||
<string name="settings_search_history">Hakuhistoria</string>
|
||||
<string name="settings_search_history_clear">Tyhjennä hakuhistoria</string>
|
||||
</resources>
|
||||
@@ -4235,4 +4235,6 @@
|
||||
<string name="glasses_show_shortcut_hint">Afficher le bouton flottant Smart Glasses par-dessus le jeu.</string>
|
||||
<string name="display_filter_game_profile">Profil %1$s utilisé : %2$s</string>
|
||||
<string name="display_filter_default_profile">Profil par défaut utilisé : %1$s</string>
|
||||
<string name="settings_search_history">Historique de recherche</string>
|
||||
<string name="settings_search_history_clear">Effacer l\'historique de recherche</string>
|
||||
</resources>
|
||||
@@ -4196,4 +4196,6 @@
|
||||
<string name="glasses_show_shortcut_hint">गेम के ऊपर तैरता हुआ Smart Glasses बटन दिखाएँ।</string>
|
||||
<string name="display_filter_game_profile">%1$s प्रोफ़ाइल का उपयोग: %2$s</string>
|
||||
<string name="display_filter_default_profile">डिफ़ॉल्ट प्रोफ़ाइल का उपयोग: %1$s</string>
|
||||
<string name="settings_search_history">खोज इतिहास</string>
|
||||
<string name="settings_search_history_clear">खोज इतिहास मिटाएं</string>
|
||||
</resources>
|
||||
@@ -4196,4 +4196,6 @@
|
||||
<string name="glasses_show_shortcut_hint">A játék fölött lebegő Smart Glasses gomb megjelenítése.</string>
|
||||
<string name="display_filter_game_profile">Használt profil: %1$s – %2$s</string>
|
||||
<string name="display_filter_default_profile">Alapértelmezett profil használata: %1$s</string>
|
||||
<string name="settings_search_history">Keresési előzmények</string>
|
||||
<string name="settings_search_history_clear">Keresési előzmények törlése</string>
|
||||
</resources>
|
||||
@@ -4166,4 +4166,6 @@
|
||||
<string name="glasses_show_shortcut_hint">Tampilkan tombol Smart Glasses mengambang di atas game.</string>
|
||||
<string name="display_filter_game_profile">Menggunakan profil %1$s: %2$s</string>
|
||||
<string name="display_filter_default_profile">Menggunakan profil default: %1$s</string>
|
||||
<string name="settings_search_history">Riwayat pencarian</string>
|
||||
<string name="settings_search_history_clear">Hapus riwayat pencarian</string>
|
||||
</resources>
|
||||
@@ -4235,4 +4235,6 @@
|
||||
<string name="glasses_show_shortcut_hint">Mostra il pulsante mobile Smart Glasses sopra il gioco.</string>
|
||||
<string name="display_filter_game_profile">Profilo %1$s in uso: %2$s</string>
|
||||
<string name="display_filter_default_profile">Profilo predefinito in uso: %1$s</string>
|
||||
<string name="settings_search_history">Cronologia ricerche</string>
|
||||
<string name="settings_search_history_clear">Cancella cronologia ricerche</string>
|
||||
</resources>
|
||||
@@ -4166,4 +4166,6 @@
|
||||
<string name="glasses_show_shortcut_hint">ゲーム画面上に Smart Glasses のフローティングボタンを表示します。</string>
|
||||
<string name="display_filter_game_profile">%1$s プロファイルを使用中: %2$s</string>
|
||||
<string name="display_filter_default_profile">デフォルトプロファイルを使用中: %1$s</string>
|
||||
<string name="settings_search_history">検索履歴</string>
|
||||
<string name="settings_search_history_clear">検索履歴を消去</string>
|
||||
</resources>
|
||||
@@ -4166,4 +4166,6 @@
|
||||
<string name="glasses_show_shortcut_hint">게임 위에 떠 있는 Smart Glasses 버튼을 표시합니다.</string>
|
||||
<string name="display_filter_game_profile">%1$s 프로필 사용 중: %2$s</string>
|
||||
<string name="display_filter_default_profile">기본 프로필 사용 중: %1$s</string>
|
||||
<string name="settings_search_history">검색 기록</string>
|
||||
<string name="settings_search_history_clear">검색 기록 지우기</string>
|
||||
</resources>
|
||||
@@ -4166,4 +4166,6 @@
|
||||
<string name="glasses_show_shortcut_hint">Tunjukkan butang Smart Glasses terapung di atas permainan.</string>
|
||||
<string name="display_filter_game_profile">Menggunakan profil %1$s: %2$s</string>
|
||||
<string name="display_filter_default_profile">Menggunakan profil lalai: %1$s</string>
|
||||
<string name="settings_search_history">Sejarah carian</string>
|
||||
<string name="settings_search_history_clear">Kosongkan sejarah carian</string>
|
||||
</resources>
|
||||
@@ -4196,4 +4196,6 @@
|
||||
<string name="glasses_show_shortcut_hint">Vis den flytende Smart Glasses-knappen over spillet.</string>
|
||||
<string name="display_filter_game_profile">Bruker profilen %1$s: %2$s</string>
|
||||
<string name="display_filter_default_profile">Bruker standardprofilen: %1$s</string>
|
||||
<string name="settings_search_history">Søkelogg</string>
|
||||
<string name="settings_search_history_clear">Tøm søkeloggen</string>
|
||||
</resources>
|
||||
@@ -4196,4 +4196,6 @@
|
||||
<string name="glasses_show_shortcut_hint">Toon de zwevende Smart Glasses-knop boven het spel.</string>
|
||||
<string name="display_filter_game_profile">Profiel %1$s in gebruik: %2$s</string>
|
||||
<string name="display_filter_default_profile">Standaardprofiel in gebruik: %1$s</string>
|
||||
<string name="settings_search_history">Zoekgeschiedenis</string>
|
||||
<string name="settings_search_history_clear">Zoekgeschiedenis wissen</string>
|
||||
</resources>
|
||||
@@ -4276,4 +4276,6 @@
|
||||
<string name="glasses_show_shortcut_hint">Pokaż pływający przycisk Smart Glasses nad grą.</string>
|
||||
<string name="display_filter_game_profile">Używany profil %1$s: %2$s</string>
|
||||
<string name="display_filter_default_profile">Używany profil domyślny: %1$s</string>
|
||||
<string name="settings_search_history">Historia wyszukiwania</string>
|
||||
<string name="settings_search_history_clear">Wyczyść historię wyszukiwania</string>
|
||||
</resources>
|
||||
@@ -4235,4 +4235,6 @@
|
||||
<string name="glasses_show_shortcut_hint">Mostrar o botão flutuante do Smart Glasses sobre o jogo.</string>
|
||||
<string name="display_filter_game_profile">Perfil %1$s em utilização: %2$s</string>
|
||||
<string name="display_filter_default_profile">Perfil predefinido em utilização: %1$s</string>
|
||||
<string name="settings_search_history">Histórico de pesquisa</string>
|
||||
<string name="settings_search_history_clear">Limpar histórico de pesquisa</string>
|
||||
</resources>
|
||||
@@ -4243,4 +4243,6 @@
|
||||
<string name="glasses_show_shortcut_hint">Mostrar o botão flutuante do Smart Glasses sobre o jogo.</string>
|
||||
<string name="display_filter_game_profile">Perfil %1$s em uso: %2$s</string>
|
||||
<string name="display_filter_default_profile">Perfil predefinido em uso: %1$s</string>
|
||||
<string name="settings_search_history">Histórico de pesquisa</string>
|
||||
<string name="settings_search_history_clear">Limpar histórico de pesquisa</string>
|
||||
</resources>
|
||||
@@ -4236,4 +4236,6 @@
|
||||
<string name="glasses_show_shortcut_hint">Afișează butonul plutitor Smart Glasses peste joc.</string>
|
||||
<string name="display_filter_game_profile">Se folosește profilul %1$s: %2$s</string>
|
||||
<string name="display_filter_default_profile">Se folosește profilul implicit: %1$s</string>
|
||||
<string name="settings_search_history">Istoricul căutărilor</string>
|
||||
<string name="settings_search_history_clear">Șterge istoricul căutărilor</string>
|
||||
</resources>
|
||||
@@ -4277,4 +4277,6 @@
|
||||
<string name="glasses_show_shortcut_hint">Показывать плавающую кнопку Smart Glasses поверх игры.</string>
|
||||
<string name="display_filter_game_profile">Используется профиль %1$s: %2$s</string>
|
||||
<string name="display_filter_default_profile">Используется профиль по умолчанию: %1$s</string>
|
||||
<string name="settings_search_history">История поиска</string>
|
||||
<string name="settings_search_history_clear">Очистить историю поиска</string>
|
||||
</resources>
|
||||
@@ -4196,4 +4196,6 @@
|
||||
<string name="glasses_show_shortcut_hint">Visa den flytande Smart Glasses-knappen ovanpå spelet.</string>
|
||||
<string name="display_filter_game_profile">Använder profilen %1$s: %2$s</string>
|
||||
<string name="display_filter_default_profile">Använder standardprofilen: %1$s</string>
|
||||
<string name="settings_search_history">Sökhistorik</string>
|
||||
<string name="settings_search_history_clear">Rensa sökhistorik</string>
|
||||
</resources>
|
||||
@@ -4166,4 +4166,6 @@
|
||||
<string name="glasses_show_shortcut_hint">แสดงปุ่ม Smart Glasses แบบลอยทับบนเกม</string>
|
||||
<string name="display_filter_game_profile">ใช้โปรไฟล์ %1$s: %2$s</string>
|
||||
<string name="display_filter_default_profile">ใช้โปรไฟล์เริ่มต้น: %1$s</string>
|
||||
<string name="settings_search_history">ประวัติการค้นหา</string>
|
||||
<string name="settings_search_history_clear">ล้างประวัติการค้นหา</string>
|
||||
</resources>
|
||||
@@ -4196,4 +4196,6 @@
|
||||
<string name="glasses_show_shortcut_hint">Oyun üzerinde yüzen Smart Glasses düğmesini göster.</string>
|
||||
<string name="display_filter_game_profile">%1$s profili kullanılıyor: %2$s</string>
|
||||
<string name="display_filter_default_profile">Varsayılan profil kullanılıyor: %1$s</string>
|
||||
<string name="settings_search_history">Arama geçmişi</string>
|
||||
<string name="settings_search_history_clear">Arama geçmişini temizle</string>
|
||||
</resources>
|
||||
@@ -4276,4 +4276,6 @@
|
||||
<string name="glasses_show_shortcut_hint">Показувати плаваючу кнопку Smart Glasses поверх гри.</string>
|
||||
<string name="display_filter_game_profile">Використовується профіль %1$s: %2$s</string>
|
||||
<string name="display_filter_default_profile">Використовується профіль за замовчуванням: %1$s</string>
|
||||
<string name="settings_search_history">Історія пошуку</string>
|
||||
<string name="settings_search_history_clear">Очистити історію пошуку</string>
|
||||
</resources>
|
||||
@@ -4166,4 +4166,6 @@
|
||||
<string name="glasses_show_shortcut_hint">Hiển thị nút Smart Glasses nổi phía trên trò chơi.</string>
|
||||
<string name="display_filter_game_profile">Đang dùng hồ sơ %1$s: %2$s</string>
|
||||
<string name="display_filter_default_profile">Đang dùng hồ sơ mặc định: %1$s</string>
|
||||
<string name="settings_search_history">Lịch sử tìm kiếm</string>
|
||||
<string name="settings_search_history_clear">Xóa lịch sử tìm kiếm</string>
|
||||
</resources>
|
||||
@@ -4164,4 +4164,6 @@
|
||||
<string name="glasses_show_shortcut_hint">在游戏画面上显示悬浮的 Smart Glasses 按钮。</string>
|
||||
<string name="display_filter_game_profile">正在使用 %1$s 配置:%2$s</string>
|
||||
<string name="display_filter_default_profile">正在使用默认配置:%1$s</string>
|
||||
<string name="settings_search_history">搜索历史</string>
|
||||
<string name="settings_search_history_clear">清除搜索历史</string>
|
||||
</resources>
|
||||
@@ -4164,4 +4164,6 @@
|
||||
<string name="glasses_show_shortcut_hint">在遊戲畫面上顯示浮動的 Smart Glasses 按鈕。</string>
|
||||
<string name="display_filter_game_profile">正在使用 %1$s 設定檔:%2$s</string>
|
||||
<string name="display_filter_default_profile">正在使用預設設定檔:%1$s</string>
|
||||
<string name="settings_search_history">搜尋記錄</string>
|
||||
<string name="settings_search_history_clear">清除搜尋記錄</string>
|
||||
</resources>
|
||||
@@ -4164,4 +4164,6 @@
|
||||
<string name="glasses_show_shortcut_hint">在遊戲畫面上顯示浮動的 Smart Glasses 按鈕。</string>
|
||||
<string name="display_filter_game_profile">正在使用 %1$s 設定檔:%2$s</string>
|
||||
<string name="display_filter_default_profile">正在使用預設設定檔:%1$s</string>
|
||||
<string name="settings_search_history">搜尋記錄</string>
|
||||
<string name="settings_search_history_clear">清除搜尋記錄</string>
|
||||
</resources>
|
||||
@@ -4459,6 +4459,8 @@
|
||||
<string name="settings_search">Search settings</string>
|
||||
<string name="settings_search_none">No setting matches \"%1$s\"</string>
|
||||
<string name="settings_search_clear">Clear search</string>
|
||||
<string name="settings_search_history">Search history</string>
|
||||
<string name="settings_search_history_clear">Clear search history</string>
|
||||
<string name="settings_place_settings">Settings</string>
|
||||
<string name="settings_place_drawer">In-game menu</string>
|
||||
<string name="settings_place_sheet">Steam or Desktop options (swipe up)</string>
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.droiddeck.launcher.ui
|
||||
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Test
|
||||
|
||||
class SettingsJumpTest {
|
||||
@Test fun rowInTheMiddleOfThePageIsCentered() = assertEquals(1050f, centeredScroll(1500f, 100f, 1000f, 4000f), 0f)
|
||||
|
||||
@Test fun rowsNearTheEndsStopAtTheEnds() {
|
||||
assertEquals(0f, centeredScroll(200f, 100f, 1000f, 4000f), 0f)
|
||||
assertEquals(3000f, centeredScroll(3800f, 100f, 1000f, 4000f), 0f)
|
||||
}
|
||||
|
||||
@Test fun pageThatFitsDoesNotScroll() = assertEquals(0f, centeredScroll(700f, 100f, 1000f, 800f), 0f)
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.droiddeck.launcher.ui
|
||||
|
||||
import android.content.Context
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.RuntimeEnvironment
|
||||
import org.robolectric.annotation.Config
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@Config(sdk = [28], manifest = Config.NONE)
|
||||
class SettingsSearchHistoryTest {
|
||||
private val context: Context get() = RuntimeEnvironment.getApplication()
|
||||
|
||||
@Before fun reset() = SettingsSearchHistory.clear(context)
|
||||
|
||||
@Test fun newestComesFirstAndARepeatMovesUp() {
|
||||
listOf("font", "cpu", "Font ").forEach { SettingsSearchHistory.add(context, it) }
|
||||
assertEquals(listOf("Font", "cpu"), SettingsSearchHistory.items)
|
||||
}
|
||||
|
||||
@Test fun blankSearchesAreNotKept() {
|
||||
SettingsSearchHistory.add(context, " ")
|
||||
assertEquals(emptyList<String>(), SettingsSearchHistory.items)
|
||||
}
|
||||
|
||||
@Test fun onlyTheLatestAreKept() {
|
||||
(1..SettingsSearchHistory.MAX + 2).forEach { SettingsSearchHistory.add(context, "search $it") }
|
||||
assertEquals(SettingsSearchHistory.MAX, SettingsSearchHistory.items.size)
|
||||
assertEquals("search ${SettingsSearchHistory.MAX + 2}", SettingsSearchHistory.items.first())
|
||||
}
|
||||
|
||||
@Test fun savedSearchesLoadInOrderUntilCleared() {
|
||||
listOf("one", "two, \"three\"").forEach { SettingsSearchHistory.add(context, it) }
|
||||
SettingsSearchHistory.load(context)
|
||||
assertEquals(listOf("two, \"three\"", "one"), SettingsSearchHistory.items)
|
||||
SettingsSearchHistory.clear(context)
|
||||
SettingsSearchHistory.load(context)
|
||||
assertEquals(emptyList<String>(), SettingsSearchHistory.items)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user