You've already forked Magisk
mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-09-06 06:36:58 +00:00
Rewrite configs with Kotlin delagate properties
This commit is contained in:
@@ -12,8 +12,6 @@ import androidx.core.view.isVisible
|
||||
import androidx.preference.*
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.topjohnwu.magisk.App
|
||||
import com.topjohnwu.magisk.Config
|
||||
import com.topjohnwu.magisk.KConfig
|
||||
import com.topjohnwu.magisk.R
|
||||
import org.koin.android.ext.android.inject
|
||||
|
||||
@@ -63,22 +61,6 @@ abstract class BasePreferenceFragment : PreferenceFragmentCompat(),
|
||||
view.setPadding(0, view.paddingTop, view.paddingRight, view.paddingBottom)
|
||||
}
|
||||
|
||||
protected fun setCustomUpdateChannel(userRepo: String) {
|
||||
KConfig.customUpdateChannel = userRepo
|
||||
}
|
||||
|
||||
protected fun getChannelCompat(channel: Int): KConfig.UpdateChannel {
|
||||
return when (channel) {
|
||||
Config.Value.STABLE_CHANNEL,
|
||||
Config.Value.DEFAULT_CHANNEL -> KConfig.UpdateChannel.STABLE
|
||||
Config.Value.BETA_CHANNEL -> KConfig.UpdateChannel.BETA
|
||||
Config.Value.CANARY_CHANNEL -> KConfig.UpdateChannel.CANARY
|
||||
Config.Value.CANARY_DEBUG_CHANNEL -> KConfig.UpdateChannel.CANARY_DEBUG
|
||||
Config.Value.CUSTOM_CHANNEL -> KConfig.UpdateChannel.CUSTOM
|
||||
else -> KConfig.updateChannel
|
||||
}
|
||||
}
|
||||
|
||||
protected fun <T: Preference> findPref(key: CharSequence): T {
|
||||
return findPreference(key) as T
|
||||
}
|
||||
|
||||
@@ -51,14 +51,12 @@ abstract class MagiskActivity<ViewModel : MagiskViewModel, Binding : ViewDataBin
|
||||
get() = navigationController?.let { it.currentStackIndex != defaultPosition } ?: false
|
||||
|
||||
init {
|
||||
val isDarkTheme = Config.get<Boolean>(Config.Key.DARK_THEME)
|
||||
val theme = if (isDarkTheme) {
|
||||
val theme = if (Config.darkTheme) {
|
||||
AppCompatDelegate.MODE_NIGHT_YES
|
||||
} else {
|
||||
AppCompatDelegate.MODE_NIGHT_NO
|
||||
}
|
||||
AppCompatDelegate.setDefaultNightMode(theme)
|
||||
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true)
|
||||
}
|
||||
|
||||
override fun applyOverrideConfiguration(config: Configuration?) {
|
||||
|
||||
Reference in New Issue
Block a user