mirror of
https://github.com/YTVanced/VancedManager
synced 2025-01-03 14:10:59 +00:00
property access syntax goes brrrrr
This commit is contained in:
parent
1f600430ea
commit
3525ef88c1
6 changed files with 13 additions and 17 deletions
|
@ -13,7 +13,7 @@ import com.vanced.manager.databinding.DialogBottomRadioButtonBinding
|
|||
import com.vanced.manager.ui.core.ThemedMaterialRadioButton
|
||||
import com.vanced.manager.utils.defPrefs
|
||||
import com.vanced.manager.utils.formatVersion
|
||||
import com.vanced.manager.utils.getCheckedButtonTag
|
||||
import com.vanced.manager.utils.checkedButtonTag
|
||||
|
||||
class AppVersionSelectorDialog : BindingBottomSheetDialogFragment<DialogBottomRadioButtonBinding>() {
|
||||
|
||||
|
@ -64,7 +64,7 @@ class AppVersionSelectorDialog : BindingBottomSheetDialogFragment<DialogBottomRa
|
|||
}
|
||||
dialogTitle.text = getString(R.string.version)
|
||||
dialogSave.setOnClickListener {
|
||||
val checkedTag = dialogRadiogroup.getCheckedButtonTag()
|
||||
val checkedTag = dialogRadiogroup.checkedButtonTag
|
||||
if (checkedTag != null) {
|
||||
prefs.edit { putString("${arguments?.getString(TAG_APP)}_version", checkedTag) }
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import com.vanced.manager.BuildConfig.MANAGER_LANGUAGES
|
|||
import com.vanced.manager.core.ui.base.BindingBottomSheetDialogFragment
|
||||
import com.vanced.manager.databinding.DialogManagerLanguageBinding
|
||||
import com.vanced.manager.ui.core.ThemedMaterialRadioButton
|
||||
import com.vanced.manager.utils.getCheckedButtonTag
|
||||
import com.vanced.manager.utils.checkedButtonTag
|
||||
import com.vanced.manager.utils.getLanguageFormat
|
||||
import com.vanced.manager.utils.managerLang
|
||||
|
||||
|
@ -43,7 +43,7 @@ class ManagerLanguageDialog : BindingBottomSheetDialogFragment<DialogManagerLang
|
|||
val language = prefs.managerLang
|
||||
root.findViewWithTag<ThemedMaterialRadioButton>(language)?.isChecked = true
|
||||
languageSave.setOnClickListener {
|
||||
val newPref = binding.languageRadiogroup.getCheckedButtonTag()
|
||||
val newPref = binding.languageRadiogroup.checkedButtonTag
|
||||
if (language != newPref) {
|
||||
prefs.managerLang = newPref
|
||||
dismiss()
|
||||
|
|
|
@ -7,7 +7,7 @@ import androidx.preference.PreferenceManager.getDefaultSharedPreferences
|
|||
import com.google.android.material.radiobutton.MaterialRadioButton
|
||||
import com.vanced.manager.core.ui.base.BindingBottomSheetDialogFragment
|
||||
import com.vanced.manager.databinding.DialogManagerThemeBinding
|
||||
import com.vanced.manager.utils.getCheckedButtonTag
|
||||
import com.vanced.manager.utils.checkedButtonTag
|
||||
import com.vanced.manager.utils.managerTheme
|
||||
|
||||
class ManagerThemeDialog : BindingBottomSheetDialogFragment<DialogManagerThemeBinding>() {
|
||||
|
@ -36,7 +36,7 @@ class ManagerThemeDialog : BindingBottomSheetDialogFragment<DialogManagerThemeBi
|
|||
val theme = prefs.managerTheme
|
||||
root.findViewWithTag<MaterialRadioButton>(theme).isChecked = true
|
||||
themeSave.setOnClickListener {
|
||||
val newPref = themeRadiogroup.getCheckedButtonTag()
|
||||
val newPref = themeRadiogroup.checkedButtonTag
|
||||
if (theme != newPref) {
|
||||
prefs.managerTheme = newPref
|
||||
dismiss()
|
||||
|
|
|
@ -8,7 +8,7 @@ import com.google.android.material.radiobutton.MaterialRadioButton
|
|||
import com.topjohnwu.superuser.Shell
|
||||
import com.vanced.manager.core.ui.base.BindingBottomSheetDialogFragment
|
||||
import com.vanced.manager.databinding.DialogManagerVariantBinding
|
||||
import com.vanced.manager.utils.getCheckedButtonTag
|
||||
import com.vanced.manager.utils.checkedButtonTag
|
||||
import com.vanced.manager.utils.managerVariant
|
||||
|
||||
class ManagerVariantDialog : BindingBottomSheetDialogFragment<DialogManagerVariantBinding>() {
|
||||
|
@ -37,7 +37,7 @@ class ManagerVariantDialog : BindingBottomSheetDialogFragment<DialogManagerVaria
|
|||
val variant = prefs.managerVariant
|
||||
root.findViewWithTag<MaterialRadioButton>(variant).isChecked = true
|
||||
variantSave.setOnClickListener {
|
||||
val newPref = variantRadiogroup.getCheckedButtonTag()
|
||||
val newPref = variantRadiogroup.checkedButtonTag
|
||||
if (variant != newPref) {
|
||||
prefs.managerVariant =
|
||||
if (newPref == "root" && Shell.rootAccess()) {
|
||||
|
|
|
@ -11,7 +11,7 @@ import com.vanced.manager.core.ui.ext.showDialog
|
|||
import com.vanced.manager.databinding.DialogBottomRadioButtonBinding
|
||||
import com.vanced.manager.ui.core.ThemedMaterialRadioButton
|
||||
import com.vanced.manager.utils.convertToAppTheme
|
||||
import com.vanced.manager.utils.getCheckedButtonTag
|
||||
import com.vanced.manager.utils.checkedButtonTag
|
||||
import com.vanced.manager.utils.theme
|
||||
import com.vanced.manager.utils.vanced
|
||||
|
||||
|
@ -51,7 +51,7 @@ class VancedThemeSelectorDialog : BindingBottomSheetDialogFragment<DialogBottomR
|
|||
tag.isChecked = true
|
||||
}
|
||||
dialogSave.setOnClickListener {
|
||||
val checkedTag = binding.dialogRadiogroup.getCheckedButtonTag()
|
||||
val checkedTag = binding.dialogRadiogroup.checkedButtonTag
|
||||
if (checkedTag != null) {
|
||||
prefs.theme = checkedTag
|
||||
}
|
||||
|
|
|
@ -17,9 +17,7 @@ import com.vanced.manager.R
|
|||
import com.vanced.manager.utils.AppUtils.log
|
||||
import java.util.*
|
||||
|
||||
fun RadioGroup.getCheckedButtonTag(): String? {
|
||||
return findViewById<MaterialRadioButton>(checkedRadioButtonId)?.tag?.toString()
|
||||
}
|
||||
val RadioGroup.checkedButtonTag: String? get() = findViewById<MaterialRadioButton>(checkedRadioButtonId)?.tag?.toString()
|
||||
|
||||
fun DialogFragment.show(activity: FragmentActivity) {
|
||||
try {
|
||||
|
@ -34,10 +32,8 @@ fun List<String>.convertToAppVersions(): List<String> = listOf("latest") + rever
|
|||
|
||||
fun String.formatVersion(context: Context): String = if (this == "latest") context.getString(R.string.install_latest) else this
|
||||
|
||||
fun String.convertToAppTheme(context: Context): String {
|
||||
return with(context) {
|
||||
getString(R.string.light_plus_other, if (this@convertToAppTheme == "dark") getString(R.string.vanced_dark) else getString(R.string.vanced_black))
|
||||
}
|
||||
fun String.convertToAppTheme(context: Context): String = with(context) {
|
||||
getString(R.string.light_plus_other, if (this@convertToAppTheme == "dark") getString(R.string.vanced_dark) else getString(R.string.vanced_black))
|
||||
}
|
||||
|
||||
fun String.getLatestAppVersion(versions: List<String>): String = if (this == "latest") versions.reversed()[0] else this
|
||||
|
|
Loading…
Reference in a new issue