2020-10-31 19:45:39 +00:00
|
|
|
package com.vanced.manager.ui.dialogs
|
|
|
|
|
|
|
|
import android.os.Bundle
|
|
|
|
import android.view.LayoutInflater
|
|
|
|
import android.view.ViewGroup
|
|
|
|
import com.vanced.manager.R
|
2020-11-26 15:37:03 +00:00
|
|
|
import com.vanced.manager.core.ui.base.BindingBottomSheetDialogFragment
|
|
|
|
import com.vanced.manager.core.ui.ext.showDialog
|
2020-11-08 12:46:17 +00:00
|
|
|
import com.vanced.manager.databinding.DialogVancedPreferencesBinding
|
2021-01-16 17:00:38 +00:00
|
|
|
import com.vanced.manager.utils.*
|
2020-10-31 19:45:39 +00:00
|
|
|
import java.util.*
|
|
|
|
|
2020-11-15 17:39:37 +00:00
|
|
|
class VancedPreferencesDialog : BindingBottomSheetDialogFragment<DialogVancedPreferencesBinding>() {
|
2020-10-31 19:45:39 +00:00
|
|
|
|
2020-11-15 17:39:37 +00:00
|
|
|
companion object {
|
2020-10-31 19:45:39 +00:00
|
|
|
|
2020-11-15 17:39:37 +00:00
|
|
|
fun newInstance(): VancedPreferencesDialog = VancedPreferencesDialog().apply {
|
|
|
|
arguments = Bundle()
|
2020-10-31 19:45:39 +00:00
|
|
|
}
|
2020-11-15 17:39:37 +00:00
|
|
|
}
|
2020-10-31 19:45:39 +00:00
|
|
|
|
2021-01-24 18:12:06 +00:00
|
|
|
private val defPrefs by lazy { requireActivity().defPrefs }
|
|
|
|
private val installPrefs by lazy { requireActivity().installPrefs }
|
2020-10-31 19:45:39 +00:00
|
|
|
|
2020-11-15 17:39:37 +00:00
|
|
|
override fun binding(
|
|
|
|
inflater: LayoutInflater,
|
|
|
|
container: ViewGroup?,
|
|
|
|
savedInstanceState: Bundle?
|
|
|
|
) = DialogVancedPreferencesBinding.inflate(inflater, container, false)
|
2020-10-31 19:45:39 +00:00
|
|
|
|
2020-11-15 17:39:37 +00:00
|
|
|
override fun otherSetups() {
|
|
|
|
bindData()
|
|
|
|
}
|
2020-10-31 19:45:39 +00:00
|
|
|
|
2020-11-15 17:39:37 +00:00
|
|
|
private fun bindData() {
|
|
|
|
with(binding) {
|
|
|
|
val showLang = mutableListOf<String>()
|
2021-02-05 09:07:05 +00:00
|
|
|
installPrefs.lang?.split(", ")?.forEach { lang ->
|
2020-11-15 17:39:37 +00:00
|
|
|
val loc = Locale(lang)
|
|
|
|
showLang.add(loc.getDisplayLanguage(loc).capitalize(Locale.ROOT))
|
|
|
|
}
|
2021-01-27 16:58:18 +00:00
|
|
|
val vancedVersionsConv = vancedVersions.value?.value?.convertToAppVersions()
|
2021-04-19 15:57:14 +00:00
|
|
|
vancedInstallTitle.text =
|
|
|
|
getString(R.string.app_installation_preferences, getString(R.string.vanced))
|
|
|
|
vancedTheme.text = getString(
|
|
|
|
R.string.chosen_theme,
|
|
|
|
installPrefs.theme?.convertToAppTheme(requireActivity())
|
|
|
|
)
|
|
|
|
vancedVersion.text = getString(
|
|
|
|
R.string.chosen_version,
|
|
|
|
defPrefs.vancedVersion?.formatVersion(requireActivity())
|
|
|
|
)
|
2020-11-15 17:39:37 +00:00
|
|
|
vancedLang.text = getString(R.string.chosen_lang, showLang)
|
2021-02-13 13:31:09 +00:00
|
|
|
openThemeSelectorLayout.setOnClickListener {
|
2020-11-15 17:39:37 +00:00
|
|
|
dismiss()
|
2020-11-26 15:37:03 +00:00
|
|
|
showDialog(VancedThemeSelectorDialog())
|
2020-11-15 17:39:37 +00:00
|
|
|
}
|
2021-02-13 13:31:09 +00:00
|
|
|
openVersionSelectorLayout.setOnClickListener {
|
2020-11-15 17:39:37 +00:00
|
|
|
dismiss()
|
2020-11-26 15:37:03 +00:00
|
|
|
showDialog(
|
|
|
|
AppVersionSelectorDialog.newInstance(
|
|
|
|
versions = vancedVersionsConv,
|
|
|
|
app = "vanced"
|
|
|
|
)
|
|
|
|
)
|
2020-11-15 17:39:37 +00:00
|
|
|
}
|
2021-02-13 13:31:09 +00:00
|
|
|
openLanguageSelectorLayout.setOnClickListener {
|
2020-11-15 17:39:37 +00:00
|
|
|
dismiss()
|
2020-11-26 15:37:03 +00:00
|
|
|
showDialog(VancedLanguageSelectionDialog())
|
2020-11-15 17:39:37 +00:00
|
|
|
}
|
|
|
|
vancedInstall.setOnClickListener {
|
2020-12-22 19:23:18 +00:00
|
|
|
if (showLang.isEmpty()) {
|
2021-01-24 18:17:19 +00:00
|
|
|
installPrefs.lang = "en"
|
2020-12-22 19:23:18 +00:00
|
|
|
}
|
2021-04-26 19:40:53 +00:00
|
|
|
dismiss()
|
|
|
|
showDialog(
|
|
|
|
AppDownloadDialog.newInstance(
|
|
|
|
app = getString(R.string.vanced)
|
2021-04-19 15:57:14 +00:00
|
|
|
)
|
2021-04-26 19:40:53 +00:00
|
|
|
)
|
2020-11-15 17:39:37 +00:00
|
|
|
}
|
2020-10-31 19:45:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|