Remove usage of grid layouts

This commit is contained in:
topjohnwu 2020-07-04 03:28:10 -07:00
parent bd14994eb9
commit 0f7caa66fb
8 changed files with 7 additions and 31 deletions

View File

@ -47,16 +47,13 @@ object Config : PreferenceModel, DBConfig {
const val UPDATE_CHANNEL = "update_channel" const val UPDATE_CHANNEL = "update_channel"
const val CUSTOM_CHANNEL = "custom_channel" const val CUSTOM_CHANNEL = "custom_channel"
const val LOCALE = "locale" const val LOCALE = "locale"
const val DARK_THEME = "dark_theme" const val DARK_THEME = "dark_theme_extended"
const val DARK_THEME_EXTENDED = "dark_theme_extended"
const val REPO_ORDER = "repo_order" const val REPO_ORDER = "repo_order"
const val SHOW_SYSTEM_APP = "show_system" const val SHOW_SYSTEM_APP = "show_system"
const val DOWNLOAD_PATH = "download_path" const val DOWNLOAD_PATH = "download_path"
const val REDESIGN = "redesign"
const val SAFETY = "safety_notice" const val SAFETY = "safety_notice"
const val THEME_ORDINAL = "theme_ordinal" const val THEME_ORDINAL = "theme_ordinal"
const val BOOT_ID = "boot_id" const val BOOT_ID = "boot_id"
const val LIST_SPAN_COUNT = "column_count"
// system state // system state
const val MAGISKHIDE = "magiskhide" const val MAGISKHIDE = "magiskhide"
@ -120,17 +117,12 @@ object Config : PreferenceModel, DBConfig {
var updateChannel by preferenceStrInt(Key.UPDATE_CHANNEL, defaultChannel) var updateChannel by preferenceStrInt(Key.UPDATE_CHANNEL, defaultChannel)
var safetyNotice by preference(Key.SAFETY, true) var safetyNotice by preference(Key.SAFETY, true)
var darkThemeExtended by preference( var darkTheme by preference(Key.DARK_THEME, AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM)
Key.DARK_THEME_EXTENDED,
AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
)
var themeOrdinal by preference(Key.THEME_ORDINAL, Theme.Piplup.ordinal) var themeOrdinal by preference(Key.THEME_ORDINAL, Theme.Piplup.ordinal)
var suReAuth by preference(Key.SU_REAUTH, false) var suReAuth by preference(Key.SU_REAUTH, false)
var checkUpdate by preference(Key.CHECK_UPDATES, true) var checkUpdate by preference(Key.CHECK_UPDATES, true)
var magiskHide by preference(Key.MAGISKHIDE, true) var magiskHide by preference(Key.MAGISKHIDE, true)
var showSystemApp by preference(Key.SHOW_SYSTEM_APP, false) var showSystemApp by preference(Key.SHOW_SYSTEM_APP, false)
@JvmStatic
var listSpanCount by preference(Key.LIST_SPAN_COUNT, 1)
var customChannelUrl by preference(Key.CUSTOM_CHANNEL, "") var customChannelUrl by preference(Key.CUSTOM_CHANNEL, "")
var locale by preference(Key.LOCALE, "") var locale by preference(Key.LOCALE, "")

View File

@ -42,7 +42,7 @@ class DarkThemeDialog : DialogEvent(), ActivityExecutor {
} }
private fun selectTheme(mode: Int) { private fun selectTheme(mode: Int) {
Config.darkThemeExtended = mode Config.darkTheme = mode
activity?.get()?.recreate() activity?.get()?.recreate()
} }

View File

@ -47,7 +47,7 @@ abstract class BaseUIActivity<ViewModel : BaseViewModel, Binding : ViewDataBindi
open val snackbarView get() = binding.root open val snackbarView get() = binding.root
init { init {
val theme = Config.darkThemeExtended val theme = Config.darkTheme
AppCompatDelegate.setDefaultNightMode(theme) AppCompatDelegate.setDefaultNightMode(theme)
} }

View File

@ -21,8 +21,6 @@ import com.topjohnwu.magisk.model.entity.recycler.SettingsItem
import com.topjohnwu.magisk.utils.asTransitive import com.topjohnwu.magisk.utils.asTransitive
import com.topjohnwu.superuser.Shell import com.topjohnwu.superuser.Shell
import java.io.File import java.io.File
import kotlin.math.max
import kotlin.math.min
// --- Customization // --- Customization
@ -123,17 +121,6 @@ object DownloadPath : SettingsItem.Input() {
.inflate(LayoutInflater.from(context)).also { it.data = this }.root .inflate(LayoutInflater.from(context)).also { it.data = this }.root
} }
object GridSize : SettingsItem.Selector() {
override var value by bindableValue(Config.listSpanCount - 1) {
Config.listSpanCount = max(1, min(2, it + 1))
}
override val title = R.string.settings_grid_column_count_title.asTransitive()
override val description = R.string.settings_grid_column_count_summary.asTransitive()
override val entryRes = R.array.span_count
override val entryValRes = R.array.value_array
}
object UpdateChannel : SettingsItem.Selector() { object UpdateChannel : SettingsItem.Selector() {
override var value by bindableValue(Config.updateChannel) { Config.updateChannel = it } override var value by bindableValue(Config.updateChannel) { Config.updateChannel = it }

View File

@ -40,7 +40,7 @@ class SettingsViewModel(
// Customization // Customization
val list = mutableListOf( val list = mutableListOf(
Customization, Customization,
Theme, Language, GridSize Theme, Language
) )
if (Build.VERSION.SDK_INT < 21) { if (Build.VERSION.SDK_INT < 21) {
// Pre 5.0 does not support getting colors from attributes, // Pre 5.0 does not support getting colors from attributes,

View File

@ -36,7 +36,6 @@
gone="@{viewModel.loading &amp;&amp; viewModel.items.empty}" gone="@{viewModel.loading &amp;&amp; viewModel.items.empty}"
itemBinding="@{viewModel.itemBinding}" itemBinding="@{viewModel.itemBinding}"
items="@{viewModel.items}" items="@{viewModel.items}"
spanCount="@{Config.listSpanCount}"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:clipToPadding="false" android:clipToPadding="false"

View File

@ -19,7 +19,6 @@
dividerVertical="@{@drawable/divider_l_50}" dividerVertical="@{@drawable/divider_l_50}"
itemBinding="@{viewModel.itemBinding}" itemBinding="@{viewModel.itemBinding}"
items="@{viewModel.items}" items="@{viewModel.items}"
spanCount="@{Config.listSpanCount}"
android:id="@+id/settings_list" android:id="@+id/settings_list"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
@ -30,7 +29,7 @@
android:paddingTop="@{viewModel.insets.top + (int) @dimen/internal_action_bar_size}" android:paddingTop="@{viewModel.insets.top + (int) @dimen/internal_action_bar_size}"
android:paddingEnd="@dimen/l_50" android:paddingEnd="@dimen/l_50"
android:paddingBottom="@{viewModel.insets.bottom + (int) @dimen/l1}" android:paddingBottom="@{viewModel.insets.bottom + (int) @dimen/l1}"
app:layoutManager="androidx.recyclerview.widget.StaggeredGridLayoutManager" app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:spanCount="1" app:spanCount="1"
tools:layout_marginTop="24dp" tools:layout_marginTop="24dp"
tools:listitem="@layout/item_settings_toggle" tools:listitem="@layout/item_settings_toggle"

View File

@ -28,7 +28,6 @@
dividerVertical="@{@drawable/divider_l1}" dividerVertical="@{@drawable/divider_l1}"
itemBinding="@{viewModel.itemSearchBinding}" itemBinding="@{viewModel.itemSearchBinding}"
items="@{viewModel.itemsSearch}" items="@{viewModel.itemsSearch}"
spanCount="@{Config.listSpanCount}"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp" android:layout_height="0dp"
android:layout_marginBottom="@dimen/l1" android:layout_marginBottom="@dimen/l1"
@ -41,7 +40,7 @@
app:fastScrollHorizontalTrackDrawable="@drawable/fast_scroll_track" app:fastScrollHorizontalTrackDrawable="@drawable/fast_scroll_track"
app:fastScrollVerticalThumbDrawable="@drawable/fast_scroll_thumb" app:fastScrollVerticalThumbDrawable="@drawable/fast_scroll_thumb"
app:fastScrollVerticalTrackDrawable="@drawable/fast_scroll_track" app:fastScrollVerticalTrackDrawable="@drawable/fast_scroll_track"
app:layoutManager="androidx.recyclerview.widget.StaggeredGridLayoutManager" app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_constrainedHeight="true" app:layout_constrainedHeight="true"
app:layout_constraintBottom_toTopOf="@+id/module_filter_title_search" app:layout_constraintBottom_toTopOf="@+id/module_filter_title_search"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"