From 3525ef88c1cfafc62b178b0ad69410fe84ba22c7 Mon Sep 17 00:00:00 2001 From: X1nto Date: Sun, 28 Feb 2021 15:02:01 +0400 Subject: [PATCH] property access syntax goes brrrrr --- .../manager/ui/dialogs/AppVersionSelectorDialog.kt | 4 ++-- .../vanced/manager/ui/dialogs/ManagerLanguageDialog.kt | 4 ++-- .../vanced/manager/ui/dialogs/ManagerThemeDialog.kt | 4 ++-- .../vanced/manager/ui/dialogs/ManagerVariantDialog.kt | 4 ++-- .../manager/ui/dialogs/VancedThemeSelectorDialog.kt | 4 ++-- .../main/java/com/vanced/manager/utils/Extensions.kt | 10 +++------- 6 files changed, 13 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/com/vanced/manager/ui/dialogs/AppVersionSelectorDialog.kt b/app/src/main/java/com/vanced/manager/ui/dialogs/AppVersionSelectorDialog.kt index 11f64c4f..b0eb08b1 100644 --- a/app/src/main/java/com/vanced/manager/ui/dialogs/AppVersionSelectorDialog.kt +++ b/app/src/main/java/com/vanced/manager/ui/dialogs/AppVersionSelectorDialog.kt @@ -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() { @@ -64,7 +64,7 @@ class AppVersionSelectorDialog : BindingBottomSheetDialogFragment(language)?.isChecked = true languageSave.setOnClickListener { - val newPref = binding.languageRadiogroup.getCheckedButtonTag() + val newPref = binding.languageRadiogroup.checkedButtonTag if (language != newPref) { prefs.managerLang = newPref dismiss() diff --git a/app/src/main/java/com/vanced/manager/ui/dialogs/ManagerThemeDialog.kt b/app/src/main/java/com/vanced/manager/ui/dialogs/ManagerThemeDialog.kt index 72db5d50..8113a0ed 100644 --- a/app/src/main/java/com/vanced/manager/ui/dialogs/ManagerThemeDialog.kt +++ b/app/src/main/java/com/vanced/manager/ui/dialogs/ManagerThemeDialog.kt @@ -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() { @@ -36,7 +36,7 @@ class ManagerThemeDialog : BindingBottomSheetDialogFragment(theme).isChecked = true themeSave.setOnClickListener { - val newPref = themeRadiogroup.getCheckedButtonTag() + val newPref = themeRadiogroup.checkedButtonTag if (theme != newPref) { prefs.managerTheme = newPref dismiss() diff --git a/app/src/main/java/com/vanced/manager/ui/dialogs/ManagerVariantDialog.kt b/app/src/main/java/com/vanced/manager/ui/dialogs/ManagerVariantDialog.kt index 79dd203e..945dae82 100644 --- a/app/src/main/java/com/vanced/manager/ui/dialogs/ManagerVariantDialog.kt +++ b/app/src/main/java/com/vanced/manager/ui/dialogs/ManagerVariantDialog.kt @@ -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() { @@ -37,7 +37,7 @@ class ManagerVariantDialog : BindingBottomSheetDialogFragment(variant).isChecked = true variantSave.setOnClickListener { - val newPref = variantRadiogroup.getCheckedButtonTag() + val newPref = variantRadiogroup.checkedButtonTag if (variant != newPref) { prefs.managerVariant = if (newPref == "root" && Shell.rootAccess()) { diff --git a/app/src/main/java/com/vanced/manager/ui/dialogs/VancedThemeSelectorDialog.kt b/app/src/main/java/com/vanced/manager/ui/dialogs/VancedThemeSelectorDialog.kt index 18688cb7..ab332ca0 100644 --- a/app/src/main/java/com/vanced/manager/ui/dialogs/VancedThemeSelectorDialog.kt +++ b/app/src/main/java/com/vanced/manager/ui/dialogs/VancedThemeSelectorDialog.kt @@ -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(checkedRadioButtonId)?.tag?.toString() -} +val RadioGroup.checkedButtonTag: String? get() = findViewById(checkedRadioButtonId)?.tag?.toString() fun DialogFragment.show(activity: FragmentActivity) { try { @@ -34,10 +32,8 @@ fun List.convertToAppVersions(): List = 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 = if (this == "latest") versions.reversed()[0] else this