diff --git a/app/src/main/java/com/topjohnwu/magisk/redesign/settings/SettingsItems.kt b/app/src/main/java/com/topjohnwu/magisk/redesign/settings/SettingsItems.kt index 882ee4262..74ad13a29 100644 --- a/app/src/main/java/com/topjohnwu/magisk/redesign/settings/SettingsItems.kt +++ b/app/src/main/java/com/topjohnwu/magisk/redesign/settings/SettingsItems.kt @@ -16,6 +16,8 @@ import com.topjohnwu.magisk.model.entity.recycler.SettingsItem import com.topjohnwu.magisk.utils.* import com.topjohnwu.superuser.Shell import java.io.File +import kotlin.math.max +import kotlin.math.min // --- Customization @@ -122,6 +124,22 @@ object DownloadPath : SettingsItem.Input() { .inflate(LayoutInflater.from(context)).also { it.data = this }.root } +object GridSize : SettingsItem.Selector() { + override var value by dataObservable(Config.listSpanCount - 1) { + Config.listSpanCount = max(1, min(3, it + 1)) + } + + override val title = R.string.settings_grid_span_count_title.asTransitive() + override val description = R.string.settings_grid_span_count_summary.asTransitive() + + init { + setValues( + resources.getStringArray(R.array.span_count), + resources.getStringArray(R.array.value_array) + ) + } +} + object UpdateChannel : SettingsItem.Selector() { override var value by dataObservable(Config.updateChannel) { Config.updateChannel = it } override val title = R.string.settings_update_channel_title.asTransitive() diff --git a/app/src/main/java/com/topjohnwu/magisk/redesign/settings/SettingsViewModel.kt b/app/src/main/java/com/topjohnwu/magisk/redesign/settings/SettingsViewModel.kt index f0013009f..eb8434cdc 100644 --- a/app/src/main/java/com/topjohnwu/magisk/redesign/settings/SettingsViewModel.kt +++ b/app/src/main/java/com/topjohnwu/magisk/redesign/settings/SettingsViewModel.kt @@ -35,7 +35,7 @@ class SettingsViewModel( val itemBinding = itemBindingOf { it.bindExtra(BR.callback, this) } val items = diffListOf( Customization, - Theme, Language, Redesign, DownloadPath, + Theme, Language, Redesign, DownloadPath, GridSize, Manager, UpdateChannel, UpdateChannelUrl, ClearRepoCache, HideOrRestore(), UpdateChecker, diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index 0beedc71e..aac4b4a38 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -91,4 +91,10 @@ @string/sort_by_update + + @string/settings_grid_span_count_1 + @string/settings_grid_span_count_2 + @string/settings_grid_span_count_3 + + \ No newline at end of file diff --git a/app/src/main/res/values/strings_md2.xml b/app/src/main/res/values/strings_md2.xml index 9ac599291..e013ca4f2 100644 --- a/app/src/main/res/values/strings_md2.xml +++ b/app/src/main/res/values/strings_md2.xml @@ -70,6 +70,11 @@ Always Dark Safe Mode Disables everything but essential functionality within Magisk and Magisk Manager. Magisk Hide, as a separate subsystem, will stand unaffected. + Grid Column Size + Sets column size for all eligible grid lists. You can set this outside settings by performing pinch gesture. + One item per line (Small Screens) + Two items per line (Recommended) + Three item per line (Tablet/TV) Options Method