Added grid column count settings

*Cough, cough* Use pinch to zoom gesture instead, not a fan of this.
This commit is contained in:
Viktor De Pasquale 2020-01-06 19:59:41 +01:00
parent 6a2acbe929
commit fcedd06e72
4 changed files with 30 additions and 1 deletions

View File

@ -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()

View File

@ -35,7 +35,7 @@ class SettingsViewModel(
val itemBinding = itemBindingOf<SettingsItem> { it.bindExtra(BR.callback, this) }
val items = diffListOf(
Customization,
Theme, Language, Redesign, DownloadPath,
Theme, Language, Redesign, DownloadPath, GridSize,
Manager,
UpdateChannel, UpdateChannelUrl, ClearRepoCache, HideOrRestore(), UpdateChecker,

View File

@ -91,4 +91,10 @@
<item>@string/sort_by_update</item>
</string-array>
<string-array name="span_count">
<item>@string/settings_grid_span_count_1</item>
<item>@string/settings_grid_span_count_2</item>
<item>@string/settings_grid_span_count_3</item>
</string-array>
</resources>

View File

@ -70,6 +70,11 @@
<string name="settings_dark_mode_dark">Always Dark</string>
<string name="settings_safe_mode_title">Safe Mode</string>
<string name="settings_safe_mode_summary">Disables everything but essential functionality within Magisk and Magisk Manager. Magisk Hide, as a separate subsystem, will stand unaffected.</string>
<string name="settings_grid_span_count_title">Grid Column Size</string>
<string name="settings_grid_span_count_summary">Sets column size for all eligible grid lists. You can set this outside settings by performing pinch gesture.</string>
<string name="settings_grid_span_count_1">One item per line (Small Screens)</string>
<string name="settings_grid_span_count_2">Two items per line (Recommended)</string>
<string name="settings_grid_span_count_3">Three item per line (Tablet/TV)</string>
<string name="install_options_title">Options</string>
<string name="install_method_title">Method</string>