Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7571cd0213 | ||
|
|
c8e3312bff | ||
|
|
53adde3a95 | ||
|
|
8f16160794 | ||
|
|
64b9f06ff0 | ||
|
|
60e86cac2c | ||
|
|
dcae63056c | ||
|
|
98b23bac48 | ||
|
|
c440fc5024 |
No files matched your search
@@ -94,7 +94,7 @@ The main search screen remains usable as long as at least one indexed dictionary
|
||||
- OkHttp 5.5.1
|
||||
- kotlinx.serialization 1.12.0
|
||||
- AboutLibraries 15.3.0 metadata generation
|
||||
- Android Gradle Plugin 9.4.1
|
||||
- Android Gradle Plugin 9.5.1
|
||||
|
||||
## Build
|
||||
|
||||
|
||||
+12
-2
@@ -93,8 +93,8 @@ android {
|
||||
applicationId = "com.example.research"
|
||||
minSdk = project.property("minSdk").toString().toInt()
|
||||
targetSdk = project.property("targetSdk").toString().toInt()
|
||||
versionCode = 13
|
||||
versionName = "1.9.0"
|
||||
versionCode = 14
|
||||
versionName = "1.10.0"
|
||||
|
||||
vectorDrawables {
|
||||
useSupportLibrary = true
|
||||
@@ -112,6 +112,13 @@ android {
|
||||
release {
|
||||
if (project.hasProperty("research.debugSign")) {
|
||||
signingConfig = signingConfigs.getByName("debug")
|
||||
} else if (project.hasProperty("research.releaseSign")) {
|
||||
signingConfig = signingConfigs.create("researchRelease") {
|
||||
storeFile = file(project.property("research.keystore") as String)
|
||||
storePassword = project.property("research.storePass") as String
|
||||
keyAlias = project.property("research.keyAlias") as String
|
||||
keyPassword = project.property("research.keyPass") as String
|
||||
}
|
||||
}
|
||||
|
||||
ndk {
|
||||
@@ -175,7 +182,10 @@ dependencies {
|
||||
implementation(composeBom)
|
||||
implementation(libs.bundles.compose)
|
||||
implementation(libs.androidx.compose.material3.adaptive.layout)
|
||||
debugImplementation(libs.androidx.compose.runtime)
|
||||
debugImplementation(libs.androidx.compose.runtime.tracing)
|
||||
debugImplementation(libs.androidx.startup.runtime)
|
||||
debugImplementation(libs.androidx.tracing.wire)
|
||||
implementation(libs.androidx.paging.runtime)
|
||||
implementation(libs.androidx.paging.compose)
|
||||
implementation(libs.androidx.profileinstaller)
|
||||
|
||||
@@ -28,7 +28,6 @@ import com.example.research.common.ui.theme.ReSearchTheme
|
||||
import com.example.research.core.domain.model.AppTheme
|
||||
import com.example.research.core.domain.model.SearchBarPosition
|
||||
import com.example.research.data.local.preferences.SectionExpansionStates
|
||||
import com.example.research.feature.search.SearchAction
|
||||
import com.example.research.feature.search.SearchViewModel
|
||||
import com.example.research.ui.navigation.AppNavigation
|
||||
import com.example.research.ui.settings.SettingsViewModel
|
||||
@@ -144,7 +143,7 @@ class MainActivity : ComponentActivity() {
|
||||
val text = intent.getCharSequenceExtra(Intent.EXTRA_PROCESS_TEXT)
|
||||
?: intent.getCharSequenceExtra(Intent.EXTRA_PROCESS_TEXT_READONLY)
|
||||
text?.toString()?.let {
|
||||
searchViewModel.onAction(SearchAction.QueryChanged(it))
|
||||
searchViewModel.injectExternalQuery(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import kotlinx.coroutines.flow.*
|
||||
import kotlinx.coroutines.ensureActive
|
||||
import java.io.File
|
||||
import java.util.Collections
|
||||
import kotlin.time.Duration.Companion.seconds
|
||||
|
||||
class DictionaryImportManager(
|
||||
private val application: Application
|
||||
@@ -19,6 +20,10 @@ class DictionaryImportManager(
|
||||
private val mutableImportState = MutableStateFlow<ImportState>(ImportState.Idle)
|
||||
val importState: StateFlow<ImportState> = mutableImportState.asStateFlow()
|
||||
|
||||
companion object {
|
||||
private val TERMINAL_STATE_DURATION = 2.seconds
|
||||
}
|
||||
|
||||
private val managerScope = CoroutineScope(SupervisorJob() + Dispatchers.Main)
|
||||
private var importJob: Job? = null
|
||||
private val importedFiles = Collections.synchronizedList(mutableListOf<File>())
|
||||
@@ -130,6 +135,9 @@ class DictionaryImportManager(
|
||||
)
|
||||
mutableImportState.value = terminalState
|
||||
onTerminal?.invoke(terminalState)
|
||||
if (terminalState is ImportState.Error) {
|
||||
expireErrorStateToIdle(terminalState)
|
||||
}
|
||||
|
||||
} catch (e: CancellationException) {
|
||||
cleanupImportedFiles()
|
||||
@@ -141,9 +149,17 @@ class DictionaryImportManager(
|
||||
)
|
||||
mutableImportState.value = errorState
|
||||
onTerminal?.invoke(errorState)
|
||||
expireErrorStateToIdle(errorState)
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun expireErrorStateToIdle(errorState: ImportState.Error) {
|
||||
delay(TERMINAL_STATE_DURATION)
|
||||
if (mutableImportState.value === errorState) {
|
||||
mutableImportState.value = ImportState.Idle
|
||||
}
|
||||
}
|
||||
|
||||
private fun getFileName(uri: Uri): String? {
|
||||
var fileName: String? = null
|
||||
application.contentResolver.query(uri, null, null, null, null)?.use { cursor ->
|
||||
|
||||
@@ -44,6 +44,9 @@ class SearchViewModel(
|
||||
)
|
||||
val searchQuery: StateFlow<String> = mutableSearchQuery.asStateFlow()
|
||||
|
||||
private val mutableQueryInjection = MutableSharedFlow<String>(extraBufferCapacity = 1)
|
||||
val queryInjection: SharedFlow<String> = mutableQueryInjection.asSharedFlow()
|
||||
|
||||
private val mutableSelectedArticle = MutableStateFlow<ArticleState?>(null)
|
||||
val selectedArticle: StateFlow<ArticleState?> = mutableSelectedArticle.asStateFlow()
|
||||
|
||||
@@ -157,6 +160,12 @@ class SearchViewModel(
|
||||
}
|
||||
}
|
||||
|
||||
fun injectExternalQuery(query: String) {
|
||||
val sanitized = query.sanitizeQuery().trim()
|
||||
mutableQueryInjection.tryEmit(sanitized)
|
||||
onSearchQueryChanged(sanitized)
|
||||
}
|
||||
|
||||
private fun warmupIndexesInBackground() {
|
||||
indexWarmupJob?.cancel()
|
||||
indexWarmupJob = viewModelScope.launch(Dispatchers.Default) {
|
||||
|
||||
@@ -43,7 +43,6 @@ fun MainRoute(
|
||||
val searchHistory by searchViewModel.searchHistory.collectAsStateWithLifecycle()
|
||||
|
||||
val settingsState by settingsViewModel.uiState.collectAsStateWithLifecycle()
|
||||
val searchQuery by searchViewModel.searchQuery.collectAsStateWithLifecycle()
|
||||
val isSearchBarAtBottom = settingsState.searchBarPosition == SearchBarPosition.BOTTOM
|
||||
|
||||
val scrollPosition = remember(searchViewModel) {
|
||||
@@ -53,9 +52,9 @@ fun MainRoute(
|
||||
TextFieldState(initialText = searchViewModel.searchQuery.value)
|
||||
}
|
||||
|
||||
LaunchedEffect(searchState, searchQuery) {
|
||||
if (searchState.text.toString() != searchQuery) {
|
||||
searchState.edit { replace(0, length, searchQuery) }
|
||||
LaunchedEffect(searchViewModel) {
|
||||
searchViewModel.queryInjection.collect { query ->
|
||||
searchState.edit { replace(0, length, query) }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,13 +94,12 @@ fun MainRoute(
|
||||
MainAction.ClearError -> searchViewModel.clearError()
|
||||
is MainAction.SaveScrollPosition ->
|
||||
searchViewModel.saveScrollPosition(action.index, action.offset)
|
||||
is MainAction.HistoryEntryClicked ->
|
||||
is MainAction.HistoryEntryClicked -> {
|
||||
searchState.edit { replace(0, length, action.query) }
|
||||
if (isWide) {
|
||||
searchViewModel.onSearchQueryChanged(action.query)
|
||||
searchViewModel.onAction(SearchAction.SearchAndLoadArticle(action.query))
|
||||
} else {
|
||||
searchViewModel.onSearchQueryChanged(action.query)
|
||||
}
|
||||
}
|
||||
is MainAction.RemoveHistoryEntry ->
|
||||
searchViewModel.removeSearchHistoryEntry(action.query)
|
||||
MainAction.ClearHistory -> searchViewModel.clearSearchHistory()
|
||||
|
||||
@@ -89,8 +89,8 @@ internal fun SearchResultsPane(
|
||||
|
||||
SideEffect {
|
||||
val loaded = results.itemSnapshotList.items
|
||||
if (results.loadState.refresh is LoadState.NotLoading && loaded.isNotEmpty()) {
|
||||
staleEntries = loaded
|
||||
if (results.loadState.refresh is LoadState.NotLoading) {
|
||||
staleEntries = if (loaded.isNotEmpty()) loaded else emptyList()
|
||||
}
|
||||
}
|
||||
val pendingReload = results.itemCount == 0 &&
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -12,6 +12,12 @@ android {
|
||||
minSdk = project.property("minSdk").toString().toInt()
|
||||
targetSdk = project.property("targetSdk").toString().toInt()
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
project.findProperty("profileQuery")?.let {
|
||||
testInstrumentationRunnerArguments["query"] = it.toString()
|
||||
}
|
||||
project.findProperty("profileRefTarget")?.let {
|
||||
testInstrumentationRunnerArguments["refTarget"] = it.toString()
|
||||
}
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
|
||||
+32
-17
@@ -3,6 +3,7 @@ package com.example.research.baselineprofile
|
||||
import android.util.Base64
|
||||
import androidx.benchmark.macro.junit4.BaselineProfileRule
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import androidx.test.uiautomator.By
|
||||
import androidx.test.uiautomator.Direction
|
||||
import androidx.test.uiautomator.UiDevice
|
||||
@@ -180,24 +181,28 @@ class BaselineProfileGenerator {
|
||||
/**
|
||||
* Reads the first .dsl.gz archive from the shared Download folder and
|
||||
* extracts a search query from its first article, so the scenario does
|
||||
* not depend on a specific dictionary.
|
||||
* not depend on a specific dictionary. The `query` and `refTarget`
|
||||
* runner arguments override the head parsing, which cannot read heavy
|
||||
* archives because the UiAutomation shell output is size-capped.
|
||||
*/
|
||||
private fun loadProfileDictionary(device: UiDevice): ProfileDictionary {
|
||||
val fileName = device.executeShellCommand("ls $DOWNLOAD_DIR")
|
||||
.lineSequence()
|
||||
.map(String::trim)
|
||||
.filter { it.endsWith(GZ_SUFFIX) }
|
||||
.firstOrNull()
|
||||
.firstOrNull { it.endsWith(GZ_SUFFIX) }
|
||||
?: error("No $GZ_SUFFIX archives available in $DOWNLOAD_DIR")
|
||||
val archiveBytes = Base64.decode(
|
||||
device.executeShellCommand("base64 $DOWNLOAD_DIR/$fileName")
|
||||
.filter { it != '\n' && it != '\r' },
|
||||
Base64.DEFAULT,
|
||||
)
|
||||
val dictionaryBytes = ungzip(archiveBytes)
|
||||
val head = decodeWithBom(
|
||||
dictionaryBytes.copyOfRange(0, minOf(HEAD_BYTES, dictionaryBytes.size)),
|
||||
)
|
||||
val args = InstrumentationRegistry.getArguments()
|
||||
val argQuery = args.getString("query")?.takeIf { it.isNotEmpty() }
|
||||
val argRefTarget = args.getString("refTarget")?.takeIf { it.isNotEmpty() }
|
||||
if (argQuery != null) return ProfileDictionary(fileName, argQuery, argRefTarget)
|
||||
val head = try {
|
||||
decodeWithBom(readGzipHead(device, "$DOWNLOAD_DIR/$fileName", HEAD_BYTES))
|
||||
} catch (e: OutOfMemoryError) {
|
||||
error(
|
||||
"Staged archive does not fit the instrumentation heap; " +
|
||||
"pass the query and refTarget runner arguments",
|
||||
)
|
||||
}
|
||||
|
||||
var entry: String? = null
|
||||
var query: String? = null
|
||||
@@ -208,7 +213,7 @@ class BaselineProfileGenerator {
|
||||
val headword = entry?.let(::firstHeadword).orEmpty()
|
||||
if (headword.isNotEmpty()) query = headword
|
||||
} else {
|
||||
refTarget = refTarget ?: firstReference(line)
|
||||
refTarget = firstReference(line)
|
||||
if (refTarget != null) break
|
||||
}
|
||||
}
|
||||
@@ -222,7 +227,7 @@ class BaselineProfileGenerator {
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts the plain target of the first [ref]...[/ref] pair on the line,
|
||||
* Extracts the plain target of the first `[ref]...[/ref]` pair on the line,
|
||||
* dropping any nested DSL tags, so the scenario can follow a real
|
||||
* cross-reference instead of relying on a hardcoded word.
|
||||
*/
|
||||
@@ -239,6 +244,16 @@ class BaselineProfileGenerator {
|
||||
return target.ifEmpty { null }
|
||||
}
|
||||
|
||||
private fun readGzipHead(device: UiDevice, remotePath: String, textBytes: Int): ByteArray {
|
||||
val archiveBytes = Base64.decode(
|
||||
device.executeShellCommand("base64 $remotePath")
|
||||
.filter { it != '\n' && it != '\r' },
|
||||
Base64.DEFAULT,
|
||||
)
|
||||
val dictionaryBytes = ungzip(archiveBytes)
|
||||
return dictionaryBytes.copyOfRange(0, minOf(textBytes, dictionaryBytes.size))
|
||||
}
|
||||
|
||||
private fun ungzip(bytes: ByteArray): ByteArray {
|
||||
val output = ByteArrayOutputStream()
|
||||
GZIPInputStream(ByteArrayInputStream(bytes)).use { input ->
|
||||
@@ -259,11 +274,11 @@ class BaselineProfileGenerator {
|
||||
|
||||
bytes.size >= UTF16_BOM.size &&
|
||||
bytes[0] == UTF16_BOM[0] && bytes[1] == UTF16_BOM[1] ->
|
||||
String(bytes, UTF16_BOM.size, bytes.size - UTF16_BOM.size, Charsets.UTF_16LE)
|
||||
String(bytes, UTF16_BOM.size, bytes.size - UTF16_BOM.size, Charsets.UTF_16BE)
|
||||
|
||||
bytes.size >= UTF16_BOM.size &&
|
||||
bytes[0] == UTF16_BOM[1] && bytes[1] == UTF16_BOM[0] ->
|
||||
String(bytes, UTF16_BOM.size, bytes.size - UTF16_BOM.size, Charsets.UTF_16BE)
|
||||
String(bytes, UTF16_BOM.size, bytes.size - UTF16_BOM.size, Charsets.UTF_16LE)
|
||||
|
||||
bytes.size >= 2 && bytes[0] == 0.toByte() ->
|
||||
String(bytes, Charsets.UTF_16BE)
|
||||
@@ -307,7 +322,7 @@ class BaselineProfileGenerator {
|
||||
private companion object {
|
||||
val UTF8_BOM = byteArrayOf(0xEF.toByte(), 0xBB.toByte(), 0xBF.toByte())
|
||||
val UTF16_BOM = byteArrayOf(0xFE.toByte(), 0xFF.toByte())
|
||||
val NESTED_TAG_REGEX = Regex("\\[[^\\]]*\\]")
|
||||
val NESTED_TAG_REGEX = Regex("\\[[^]]*]")
|
||||
|
||||
const val DOWNLOAD_DIR = "/sdcard/Download"
|
||||
const val GZ_SUFFIX = ".dsl.gz"
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
- Stale search results no longer flash during a new search
|
||||
- Import errors no longer linger after the import finishes
|
||||
- Search history actions stay visible while scrolling
|
||||
- Text from other apps now fills the search field in one step
|
||||
- Refreshed performance profiles
|
||||
- Updated libraries and build tooling
|
||||
@@ -0,0 +1,6 @@
|
||||
- Устаревшие результаты поиска больше не мелькают при новом поиске
|
||||
- Ошибка импорта больше не остаётся после завершения импорта
|
||||
- Действия в истории поиска остаются видимыми при прокрутке
|
||||
- Текст из других приложений попадает в поле поиска одним шагом
|
||||
- Обновлены профили производительности
|
||||
- Обновлены библиотеки и инструменты сборки
|
||||
@@ -1,21 +1,24 @@
|
||||
[versions]
|
||||
aboutlibraries = "15.3.0"
|
||||
activity_compose = "1.13.0"
|
||||
agp = "9.4.1"
|
||||
agp = "9.5.1"
|
||||
baselineprofile = "1.5.0"
|
||||
benchmark_macro = "1.5.0"
|
||||
compose_bom = "2026.09.00"
|
||||
compose_runtime = "1.13.0-rc01"
|
||||
core = "1.19.1"
|
||||
datastore_preferences = "1.3.0"
|
||||
documentfile = "1.1.0"
|
||||
junit = "1.3.0"
|
||||
kotlin = "2.4.21"
|
||||
lifecycle_runtime_ktx = "2.11.0"
|
||||
material3 = "1.5.0-beta02"
|
||||
material3 = "1.5.0-rc01"
|
||||
okhttp = "5.5.1"
|
||||
paging = "3.5.3"
|
||||
profileinstaller = "1.4.1"
|
||||
uiautomator = "2.4.0"
|
||||
startup_runtime = "1.2.0"
|
||||
tracing_wire = "2.0.5"
|
||||
uiautomator = "2.4.1"
|
||||
kotlinx_coroutines = "1.11.0"
|
||||
kotlinx_serialization = "1.12.0"
|
||||
|
||||
@@ -25,7 +28,8 @@ androidx-benchmark-macro-junit4 = { module = "androidx.benchmark:benchmark-macro
|
||||
androidx-compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "compose_bom" }
|
||||
androidx-compose-material3 = { group = "androidx.compose.material3", name = "material3", version.ref = "material3" }
|
||||
androidx-compose-material3-adaptive-layout = { group = "androidx.compose.material3.adaptive", name = "adaptive-layout" }
|
||||
androidx-compose-runtime-tracing = { module = "androidx.compose.runtime:runtime-tracing" }
|
||||
androidx-compose-runtime = { module = "androidx.compose.runtime:runtime", version.ref = "compose_runtime" }
|
||||
androidx-compose-runtime-tracing = { module = "androidx.compose.runtime:runtime-tracing", version.ref = "compose_runtime" }
|
||||
androidx-compose-ui = { group = "androidx.compose.ui", name = "ui" }
|
||||
androidx-compose-ui-graphics = { group = "androidx.compose.ui", name = "ui-graphics" }
|
||||
androidx-compose-ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling" }
|
||||
@@ -37,7 +41,9 @@ androidx-lifecycle-runtime-compose = { module = "androidx.lifecycle:lifecycle-ru
|
||||
androidx-paging-runtime = { module = "androidx.paging:paging-runtime", version.ref = "paging" }
|
||||
androidx-paging-compose = { module = "androidx.paging:paging-compose", version.ref = "paging" }
|
||||
androidx-profileinstaller = { module = "androidx.profileinstaller:profileinstaller", version.ref = "profileinstaller" }
|
||||
androidx-startup-runtime = { module = "androidx.startup:startup-runtime", version.ref = "startup_runtime" }
|
||||
androidx-test-junit = { module = "androidx.test.ext:junit", version.ref = "junit" }
|
||||
androidx-tracing-wire = { module = "androidx.tracing:tracing-wire", version.ref = "tracing_wire" }
|
||||
androidx-uiautomator = { module = "androidx.test.uiautomator:uiautomator", version.ref = "uiautomator" }
|
||||
okhttp = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp" }
|
||||
kotlinx-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "kotlinx_coroutines" }
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.8.2-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.9.0-bin.zip
|
||||
networkTimeout=10000
|
||||
retries=0
|
||||
retryBackOffMs=500
|
||||
|
||||
Reference in new issue
Block a user