-
-
Notifications
You must be signed in to change notification settings - Fork 213
Add action to modify Android system settings via key mappings #1872
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 11 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
4e0e707
Initial plan
Copilot 841feaa
Add core implementation for modify system settings actions
Copilot d0d21d3
Add UI bottom sheet for modifying system settings
Copilot 4cc6ed9
Add action title and description display for modify settings
Copilot 6237188
Fix SystemBridge settings implementation with proper ContentResolver …
Copilot 927a3d6
Refactor to use single ActionId with SettingType enum
Copilot 51b18eb
Refactor settings modification to use SettingsAdapter and permissions
Copilot b57cdf8
Add ChooseSettingScreen and ViewModel for setting selection
Copilot c1f999f
Fix code review feedback: remove fully qualified names and use KeyMap…
Copilot c351c61
Refactor SettingsAdapter and ModifySettingActionBottomSheet per review
Copilot 67d4efd
Merge branch 'develop' into copilot/modify-system-settings-permission
sds100 b149abf
Consolidate SettingsAdapter methods and import SettingType in ActionE…
Copilot e441a04
Merge branch 'develop' into copilot/modify-system-settings-permission
sds100 162a959
#1871 clean up modify settings bottom sheet
sds100 16ef439
#1871 use segmented buttons to switch setting type
sds100 1862d3b
#1871 clean up ChooseSettingScreen.kt and add previews
sds100 a75ea9f
#1871 ModifySetting action is now editable
sds100 8149230
#1871 add backhandler to ChooseSettingScreen
sds100 95d22d0
#1871 fix dismissing ModifySettingActionBottomSheet
sds100 2b0efdc
chore: upgrade compose BOM and navigation libraries
sds100 0f168ad
#1871 use monospace font in ChooseSettingScreen.kt
sds100 94b77f2
#1871 fix saving ModifySettings action
sds100 f300bf8
#1871 add TODO
sds100 9a92925
Merge branch 'develop' into copilot/modify-system-settings-permission
sds100 302095d
feat: WRITE_SECURE_SETTINGS permission dialog now directs the user to…
sds100 ca8951d
#1871 feat: complete modify system setting action
sds100 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -147,4 +147,6 @@ enum class ActionId { | |
|
|
||
| FORCE_STOP_APP, | ||
| CLEAR_RECENT_APP, | ||
|
|
||
| MODIFY_SETTING, | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
155 changes: 155 additions & 0 deletions
155
base/src/main/java/io/github/sds100/keymapper/base/actions/ChooseSettingScreen.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,155 @@ | ||
| package io.github.sds100.keymapper.base.actions | ||
|
|
||
| import androidx.compose.foundation.clickable | ||
| import androidx.compose.foundation.layout.Box | ||
| import androidx.compose.foundation.layout.Column | ||
| import androidx.compose.foundation.layout.displayCutoutPadding | ||
| import androidx.compose.foundation.layout.fillMaxSize | ||
| import androidx.compose.foundation.layout.fillMaxWidth | ||
| import androidx.compose.foundation.layout.imePadding | ||
| import androidx.compose.foundation.layout.padding | ||
| import androidx.compose.foundation.lazy.LazyColumn | ||
| import androidx.compose.foundation.lazy.items | ||
| import androidx.compose.material3.BottomAppBar | ||
| import androidx.compose.material3.CircularProgressIndicator | ||
| import androidx.compose.material3.ExperimentalMaterial3Api | ||
| import androidx.compose.material3.HorizontalDivider | ||
| import androidx.compose.material3.ListItem | ||
| import androidx.compose.material3.MaterialTheme | ||
| import androidx.compose.material3.Scaffold | ||
| import androidx.compose.material3.Surface | ||
| import androidx.compose.material3.Text | ||
| import androidx.compose.material3.TopAppBar | ||
| 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.unit.dp | ||
| import androidx.lifecycle.compose.collectAsStateWithLifecycle | ||
| import io.github.sds100.keymapper.base.R | ||
| import io.github.sds100.keymapper.base.utils.ui.compose.KeyMapperDropdownMenu | ||
| import io.github.sds100.keymapper.base.utils.ui.compose.SearchAppBarActions | ||
| import io.github.sds100.keymapper.common.utils.State | ||
| import io.github.sds100.keymapper.system.settings.SettingType | ||
| import kotlinx.coroutines.flow.update | ||
|
|
||
| @Composable | ||
| fun ChooseSettingScreen(modifier: Modifier = Modifier, viewModel: ChooseSettingViewModel) { | ||
| val state by viewModel.settings.collectAsStateWithLifecycle() | ||
| val query by viewModel.searchQuery.collectAsStateWithLifecycle() | ||
| val settingType by viewModel.selectedSettingType.collectAsStateWithLifecycle() | ||
|
|
||
| ChooseSettingScreen( | ||
| modifier = modifier, | ||
| state = state, | ||
| query = query, | ||
| settingType = settingType, | ||
| onQueryChange = { newQuery -> viewModel.searchQuery.update { newQuery } }, | ||
| onCloseSearch = { viewModel.searchQuery.update { null } }, | ||
| onSettingTypeChange = { viewModel.selectedSettingType.value = it }, | ||
| onClickSetting = viewModel::onSettingClick, | ||
| onNavigateBack = viewModel::onNavigateBack, | ||
| ) | ||
| } | ||
|
|
||
| @OptIn(ExperimentalMaterial3Api::class) | ||
| @Composable | ||
| private fun ChooseSettingScreen( | ||
| modifier: Modifier = Modifier, | ||
| state: State<List<SettingItem>>, | ||
| query: String? = null, | ||
| settingType: SettingType, | ||
| onQueryChange: (String) -> Unit = {}, | ||
| onCloseSearch: () -> Unit = {}, | ||
| onSettingTypeChange: (SettingType) -> Unit = {}, | ||
| onClickSetting: (String, String?) -> Unit = { _, _ -> }, | ||
| onNavigateBack: () -> Unit = {}, | ||
| ) { | ||
| Scaffold( | ||
| modifier = modifier.displayCutoutPadding(), | ||
| topBar = { | ||
| TopAppBar( | ||
| title = { Text(stringResource(R.string.choose_setting_title)) }, | ||
| ) | ||
| }, | ||
| bottomBar = { | ||
| BottomAppBar( | ||
| modifier = Modifier.imePadding(), | ||
| actions = { | ||
| SearchAppBarActions( | ||
| onCloseSearch = onCloseSearch, | ||
| onNavigateBack = onNavigateBack, | ||
| onQueryChange = onQueryChange, | ||
| enabled = state is State.Data, | ||
| query = query, | ||
| ) | ||
| }, | ||
| ) | ||
| }, | ||
| ) { innerPadding -> | ||
| Surface( | ||
| modifier = Modifier | ||
| .fillMaxSize() | ||
| .padding(innerPadding), | ||
| ) { | ||
| Column(modifier = Modifier.fillMaxSize()) { | ||
| // Setting type dropdown | ||
| var expanded by remember { mutableStateOf(false) } | ||
|
|
||
| KeyMapperDropdownMenu( | ||
| modifier = Modifier | ||
| .fillMaxWidth() | ||
| .padding(16.dp), | ||
| expanded = expanded, | ||
| onExpandedChange = { expanded = it }, | ||
| label = { Text(stringResource(R.string.modify_setting_type_label)) }, | ||
| selectedValue = settingType, | ||
| values = listOf( | ||
| SettingType.SYSTEM to stringResource(R.string.modify_setting_type_system), | ||
| SettingType.SECURE to stringResource(R.string.modify_setting_type_secure), | ||
| SettingType.GLOBAL to stringResource(R.string.modify_setting_type_global), | ||
| ), | ||
| onValueChanged = onSettingTypeChange, | ||
| ) | ||
|
|
||
| HorizontalDivider() | ||
|
|
||
| // Settings list | ||
| when (state) { | ||
| State.Loading -> { | ||
| Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center) { | ||
| CircularProgressIndicator() | ||
| } | ||
| } | ||
| is State.Data -> { | ||
| if (state.data.isEmpty()) { | ||
| Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center) { | ||
| Text( | ||
| text = stringResource(R.string.choose_setting_empty), | ||
| style = MaterialTheme.typography.bodyLarge, | ||
| ) | ||
| } | ||
| } else { | ||
| LazyColumn(modifier = Modifier.fillMaxSize()) { | ||
| items(state.data) { item -> | ||
| ListItem( | ||
| headlineContent = { Text(item.key) }, | ||
| supportingContent = item.value?.let { { Text(it) } }, | ||
| modifier = Modifier.clickable { | ||
| onClickSetting(item.key, item.value) | ||
| }, | ||
| ) | ||
| HorizontalDivider() | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import SettingType
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in b149abf. Now importing
SettingTypeand using it throughout the file instead of fully qualified name.