From 5d4dd31b70a5ccf7fc7c6178cd269b947f6e5dc2 Mon Sep 17 00:00:00 2001 From: Kagura Date: Fri, 1 Nov 2024 16:35:41 +0800 Subject: [PATCH] fix: search: do not show result if no result --- .../filemanager/compose/ui/SearchFileColumn.kt | 14 ++++++++------ app/src/main/res/values/strings.xml | 3 ++- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/com/dazuoye/filemanager/compose/ui/SearchFileColumn.kt b/app/src/main/java/com/dazuoye/filemanager/compose/ui/SearchFileColumn.kt index ea0c967..4380d5e 100644 --- a/app/src/main/java/com/dazuoye/filemanager/compose/ui/SearchFileColumn.kt +++ b/app/src/main/java/com/dazuoye/filemanager/compose/ui/SearchFileColumn.kt @@ -45,10 +45,8 @@ import androidx.compose.ui.unit.sp import androidx.core.content.FileProvider import com.dazuoye.filemanager.R import com.dazuoye.filemanager.fileSystem.WrappedFile -import com.dazuoye.filemanager.fileSystem.WrappedFile.Type import com.dazuoye.filemanager.fileSystem.searchFile import com.dazuoye.filemanager.main_page -import com.dazuoye.filemanager.utils.AlertHelper import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch @@ -68,7 +66,7 @@ class SearchFileColumn( var isOkay by remember { mutableStateOf(false) } var sortByTime by remember { mutableStateOf(true) } - LaunchedEffect(isOkay, list,sortByTime) { + LaunchedEffect(isOkay, list, sortByTime) { isOkay = false fileList.clear() val wfList = list.map { WrappedFile(File(it)) } @@ -109,7 +107,11 @@ class SearchFileColumn( } Text( - text = context.getString(R.string.search_result, searchTypeName), + text = if (list.isEmpty()) { + context.getString(R.string.search_here, searchTypeName) + } else { + context.getString(R.string.search_result, searchTypeName) + }, fontSize = 28.sp, modifier = Modifier .padding(start = 10.dp) @@ -333,7 +335,7 @@ class SearchFileColumn( IconButton( onClick = { - showFileInfoAlert(context,file.path) + showFileInfoAlert(context, file.path) }, modifier = Modifier.padding(horizontal = 10.dp) ) { @@ -342,8 +344,8 @@ class SearchFileColumn( ) } } - } + fun showFileInfoAlert(context: Context, file: String) { val f = File(file) if (!f.exists()) { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index f30e21e..7096014 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -74,6 +74,7 @@ 已存在此文件(夹) ViewFileActivity SearchActivity + 搜索%s 搜索%s结果 请输入要搜索的内容 输入的搜索内容不合法 @@ -84,7 +85,7 @@ 已选择按时间排序 SettingActivity 隐藏扩展名 - 如果打开,则会显示文件名 abc.efg,否则显示文件全名 abc.efg.txt + 如果打开,则会显示文件名 abc.efg,否则显示文件全名 abc.efg.txt\n此选项不会影响搜索页面显示扩展名 隐藏点文件 隐藏所有以 . 开头的文件和文件夹\n. 开头的文件(或文件夹)通常表示隐藏文件(或文件夹)\n此选项只对查看全部文件功能有效