added use of getters in more classes
This commit is contained in:
parent
dde6901dbe
commit
850b3dda1c
|
@ -14,6 +14,9 @@ import com.vanced.manager.model.DataModel
|
|||
import com.vanced.manager.model.RootDataModel
|
||||
import com.vanced.manager.ui.dialogs.AppInfoDialog
|
||||
import com.vanced.manager.ui.viewmodels.HomeViewModel
|
||||
import com.vanced.manager.utils.enableMusic
|
||||
import com.vanced.manager.utils.enableVanced
|
||||
import com.vanced.manager.utils.managerVariant
|
||||
|
||||
class AppListAdapter(
|
||||
private val context: FragmentActivity,
|
||||
|
@ -28,7 +31,7 @@ class AppListAdapter(
|
|||
private val prefs = getDefaultSharedPreferences(context)
|
||||
private var itemCount = 0
|
||||
|
||||
private val isRoot = prefs.getString("vanced_variant", "nonroot") == "root"
|
||||
private val isRoot = prefs.managerVariant == "root"
|
||||
|
||||
inner class ListViewHolder(private val binding: ViewAppBinding) : RecyclerView.ViewHolder(binding.root) {
|
||||
val appCard = binding.appCard
|
||||
|
@ -91,7 +94,7 @@ class AppListAdapter(
|
|||
|
||||
init {
|
||||
|
||||
if (prefs.getBoolean("enable_vanced", true)) {
|
||||
if (prefs.enableVanced) {
|
||||
if (isRoot) {
|
||||
rootDataModels.add(viewModel.vancedRootModel.value)
|
||||
} else {
|
||||
|
@ -101,7 +104,7 @@ class AppListAdapter(
|
|||
itemCount++
|
||||
}
|
||||
|
||||
if (prefs.getBoolean("enable_music", true)) {
|
||||
if (prefs.enableMusic) {
|
||||
if (isRoot) {
|
||||
rootDataModels.add(viewModel.musicRootModel.value)
|
||||
} else {
|
||||
|
|
|
@ -142,7 +142,7 @@ class MainActivity : AppCompatActivity() {
|
|||
|
||||
private fun initDialogs(firstLaunch: Boolean) {
|
||||
val prefs = getDefaultSharedPreferences(this)
|
||||
val variant = prefs.getString("vanced_variant", "nonroot")
|
||||
val variant = prefs.managerVariant
|
||||
prefs.getBoolean("show_root_dialog", true)
|
||||
|
||||
if (intent?.data != null && intent.dataString?.startsWith("https") == true) {
|
||||
|
|
|
@ -3,7 +3,6 @@ package com.vanced.manager.ui.dialogs
|
|||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import androidx.preference.PreferenceManager.getDefaultSharedPreferences
|
||||
import com.vanced.manager.R
|
||||
import com.vanced.manager.core.downloader.MicrogDownloader.startMicrogInstall
|
||||
import com.vanced.manager.core.downloader.MusicDownloader.startMusicInstall
|
||||
|
@ -11,6 +10,8 @@ import com.vanced.manager.core.downloader.VancedDownloader.startVancedInstall
|
|||
import com.vanced.manager.core.ui.base.BindingBottomSheetDialogFragment
|
||||
import com.vanced.manager.core.ui.ext.showDialog
|
||||
import com.vanced.manager.databinding.DialogInstallationFilesDetectedBinding
|
||||
import com.vanced.manager.utils.defPrefs
|
||||
import com.vanced.manager.utils.managerVariant
|
||||
|
||||
class InstallationFilesDetectedDialog : BindingBottomSheetDialogFragment<DialogInstallationFilesDetectedBinding>() {
|
||||
|
||||
|
@ -55,10 +56,7 @@ class InstallationFilesDetectedDialog : BindingBottomSheetDialogFragment<DialogI
|
|||
when (app) {
|
||||
getString(R.string.vanced) -> startVancedInstall(
|
||||
requireContext(),
|
||||
getDefaultSharedPreferences(requireContext()).getString(
|
||||
"vanced_variant",
|
||||
"nonroot"
|
||||
)
|
||||
context?.defPrefs?.managerVariant
|
||||
)
|
||||
getString(R.string.music) -> startMusicInstall(requireContext())
|
||||
getString(R.string.microg) -> startMicrogInstall(requireContext())
|
||||
|
|
|
@ -9,7 +9,6 @@ import android.view.ViewGroup.LayoutParams.MATCH_PARENT
|
|||
import android.view.ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.Toast
|
||||
import androidx.core.content.edit
|
||||
import com.google.android.material.checkbox.MaterialCheckBox
|
||||
import com.vanced.manager.R
|
||||
import com.vanced.manager.core.ui.base.BindingBottomSheetDialogFragment
|
||||
|
@ -17,6 +16,8 @@ import com.vanced.manager.core.ui.ext.showDialog
|
|||
import com.vanced.manager.databinding.DialogVancedLanguageSelectionBinding
|
||||
import com.vanced.manager.ui.core.ThemedMaterialCheckbox
|
||||
import com.vanced.manager.utils.getDefaultVancedLanguages
|
||||
import com.vanced.manager.utils.installPrefs
|
||||
import com.vanced.manager.utils.lang
|
||||
import com.vanced.manager.utils.vanced
|
||||
import java.util.*
|
||||
|
||||
|
@ -30,7 +31,7 @@ class VancedLanguageSelectionDialog : BindingBottomSheetDialogFragment<DialogVan
|
|||
}
|
||||
|
||||
private val langs = vanced.value?.array<String>("langs")?.value
|
||||
private val prefs by lazy { requireActivity().getSharedPreferences("installPrefs", Context.MODE_PRIVATE) }
|
||||
private val prefs by lazy { requireActivity().installPrefs }
|
||||
|
||||
override fun binding(
|
||||
inflater: LayoutInflater,
|
||||
|
@ -56,14 +57,14 @@ class VancedLanguageSelectionDialog : BindingBottomSheetDialogFragment<DialogVan
|
|||
Toast.makeText(requireActivity(), R.string.select_at_least_one_lang, Toast.LENGTH_SHORT).show()
|
||||
return@setOnClickListener
|
||||
}
|
||||
prefs?.edit { putString("lang", chosenLangs.joinToString()) }
|
||||
prefs.lang = chosenLangs.joinToString()
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun LinearLayout.loadBoxes() {
|
||||
val langPrefs = prefs.getString("lang", getDefaultVancedLanguages())
|
||||
val langPrefs = prefs.lang
|
||||
langs?.forEach { lang ->
|
||||
val loc = Locale(lang)
|
||||
val box = ThemedMaterialCheckbox(requireActivity()).apply {
|
||||
|
|
|
@ -3,7 +3,6 @@ package com.vanced.manager.ui.dialogs
|
|||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import androidx.core.content.edit
|
||||
import com.vanced.manager.R
|
||||
import com.vanced.manager.core.ui.base.BindingBottomSheetDialogFragment
|
||||
import com.vanced.manager.core.ui.ext.showDialog
|
||||
|
@ -36,7 +35,7 @@ class VancedPreferencesDialog : BindingBottomSheetDialogFragment<DialogVancedPre
|
|||
private fun bindData() {
|
||||
with(binding) {
|
||||
val showLang = mutableListOf<String>()
|
||||
installPrefs.getString("lang", getDefaultVancedLanguages())?.split(", ")?.toTypedArray()?.forEach { lang ->
|
||||
installPrefs.lang?.split(", ")?.toTypedArray()?.forEach { lang ->
|
||||
val loc = Locale(lang)
|
||||
showLang.add(loc.getDisplayLanguage(loc).capitalize(Locale.ROOT))
|
||||
}
|
||||
|
@ -64,9 +63,7 @@ class VancedPreferencesDialog : BindingBottomSheetDialogFragment<DialogVancedPre
|
|||
}
|
||||
vancedInstall.setOnClickListener {
|
||||
if (showLang.isEmpty()) {
|
||||
installPrefs.edit {
|
||||
putString("lang", "en")
|
||||
}
|
||||
installPrefs.lang = "en"
|
||||
}
|
||||
dismiss()
|
||||
showDialog(
|
||||
|
|
|
@ -5,7 +5,6 @@ import android.content.DialogInterface
|
|||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import androidx.core.content.edit
|
||||
import com.vanced.manager.R
|
||||
import com.vanced.manager.core.ui.base.BindingBottomSheetDialogFragment
|
||||
import com.vanced.manager.core.ui.ext.showDialog
|
||||
|
@ -13,6 +12,7 @@ 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.theme
|
||||
import com.vanced.manager.utils.vanced
|
||||
|
||||
class VancedThemeSelectorDialog : BindingBottomSheetDialogFragment<DialogBottomRadioButtonBinding>() {
|
||||
|
@ -46,14 +46,14 @@ class VancedThemeSelectorDialog : BindingBottomSheetDialogFragment<DialogBottomR
|
|||
)
|
||||
}
|
||||
dialogTitle.text = requireActivity().getString(R.string.theme)
|
||||
val tag = root.findViewWithTag<ThemedMaterialRadioButton>(prefs.getString("theme", "dark"))
|
||||
val tag = root.findViewWithTag<ThemedMaterialRadioButton>(prefs.theme)
|
||||
if (tag != null) {
|
||||
tag.isChecked = true
|
||||
}
|
||||
dialogSave.setOnClickListener {
|
||||
val checkedTag = binding.dialogRadiogroup.getCheckedButtonTag()
|
||||
if (checkedTag != null) {
|
||||
prefs.edit { putString("theme", checkedTag) }
|
||||
prefs.theme = checkedTag
|
||||
}
|
||||
dismiss()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue