From 0f81c41537f00590011e3f397c0e21d4246b2dbd Mon Sep 17 00:00:00 2001 From: Rissu <90097027+rsuntk@users.noreply.github.com> Date: Mon, 11 Nov 2024 18:11:34 +0700 Subject: [PATCH 1/2] manager: Fix not refreshing after action button was pressed (#2201) - This commit fix issue #2171 Tested-by: backslashxx <118538522+backslashxx@users.noreply.github.com> --------- Signed-off-by: rsuntk --- .../me/weishu/kernelsu/ui/screen/ExecuteModuleAction.kt | 2 +- .../src/main/java/me/weishu/kernelsu/ui/screen/Module.kt | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/manager/app/src/main/java/me/weishu/kernelsu/ui/screen/ExecuteModuleAction.kt b/manager/app/src/main/java/me/weishu/kernelsu/ui/screen/ExecuteModuleAction.kt index 69480997d73f..21f40aa1c832 100644 --- a/manager/app/src/main/java/me/weishu/kernelsu/ui/screen/ExecuteModuleAction.kt +++ b/manager/app/src/main/java/me/weishu/kernelsu/ui/screen/ExecuteModuleAction.kt @@ -140,4 +140,4 @@ private fun TopBar(onBack: () -> Unit = {}, onSave: () -> Unit = {}) { } } ) -} +} \ No newline at end of file diff --git a/manager/app/src/main/java/me/weishu/kernelsu/ui/screen/Module.kt b/manager/app/src/main/java/me/weishu/kernelsu/ui/screen/Module.kt index a0d28f093189..193f76b21c46 100644 --- a/manager/app/src/main/java/me/weishu/kernelsu/ui/screen/Module.kt +++ b/manager/app/src/main/java/me/weishu/kernelsu/ui/screen/Module.kt @@ -477,6 +477,7 @@ fun ModuleItem( val textDecoration = if (!module.remove) null else TextDecoration.LineThrough val interactionSource = remember { MutableInteractionSource() } val indication = LocalIndication.current + val viewModel = viewModel() Column( modifier = Modifier @@ -580,7 +581,10 @@ fun ModuleItem( if (module.hasActionScript) { FilledTonalButton( modifier = Modifier.defaultMinSize(52.dp, 32.dp), - onClick = { navigator.navigate(ExecuteModuleActionScreenDestination(module.id)) }, + onClick = { + navigator.navigate(ExecuteModuleActionScreenDestination(module.id)) + viewModel.markNeedRefresh() + }, contentPadding = ButtonDefaults.TextButtonContentPadding ) { Icon( From e4e34df9cae9ab87519d622e3b5dcdf5a91d0914 Mon Sep 17 00:00:00 2001 From: silvzr <117378129+silvzr@users.noreply.github.com> Date: Mon, 11 Nov 2024 13:51:13 +0100 Subject: [PATCH 2/2] manager: Reset search filter after moving from SuperUser destination (#2204) By default there's an annoying behaviour for which the manager leaves the search filter after changing destination without even showing the search bar anymore. Fix that and reset the list to the top instead of leaving it at the searched app's height https://github.com/user-attachments/assets/268672af-ced9-4293-81df-4e1c7ef33489 original behaviour https://github.com/user-attachments/assets/b9b318cf-273a-4130-b199-712e99f6ed72 changed behaviour Tested-by: backslashxx [118538522+backslashxx@users.noreply.github.com](mailto:118538522+backslashxx@users.noreply.github.com) --- .../java/me/weishu/kernelsu/ui/screen/SuperUser.kt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/manager/app/src/main/java/me/weishu/kernelsu/ui/screen/SuperUser.kt b/manager/app/src/main/java/me/weishu/kernelsu/ui/screen/SuperUser.kt index 1a37d0110318..a2510a7fff94 100644 --- a/manager/app/src/main/java/me/weishu/kernelsu/ui/screen/SuperUser.kt +++ b/manager/app/src/main/java/me/weishu/kernelsu/ui/screen/SuperUser.kt @@ -4,6 +4,7 @@ import androidx.compose.foundation.background import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.* import androidx.compose.foundation.lazy.LazyColumn +import androidx.compose.foundation.lazy.rememberLazyListState import androidx.compose.foundation.lazy.items import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material.ExperimentalMaterialApi @@ -40,13 +41,21 @@ fun SuperUserScreen(navigator: DestinationsNavigator) { val viewModel = viewModel() val scope = rememberCoroutineScope() val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior(rememberTopAppBarState()) + val listState = rememberLazyListState() - LaunchedEffect(Unit) { + LaunchedEffect(key1 = navigator) { + viewModel.search = "" if (viewModel.appList.isEmpty()) { viewModel.fetchAppList() } } + LaunchedEffect(viewModel.search) { + if (viewModel.search.isEmpty()) { + listState.scrollToItem(0) + } + } + Scaffold( topBar = { SearchAppBar( @@ -104,6 +113,7 @@ fun SuperUserScreen(navigator: DestinationsNavigator) { isRefreshing = viewModel.isRefreshing ) { LazyColumn( + state = listState, modifier = Modifier .fillMaxSize() .nestedScroll(scrollBehavior.nestedScrollConnection)