Show the variant
This commit is contained in:
parent
c38b7a335c
commit
ecea1265e7
@ -94,7 +94,6 @@ object Preferences : KotprefModel() {
|
||||
var customFont by intPref(key = "PREF_CUSTOM_FONT", default = Constants.CUSTOM_FONT_GOOGLE_SANS)
|
||||
var customFontFile by stringPref(default = "")
|
||||
var customFontName by stringPref(default = "")
|
||||
var customFontVariant by stringPref(default = "")
|
||||
var showNextEvent by booleanPref(key = "PREF_SHOW_NEXT_EVENT", default = true)
|
||||
|
||||
var showDividers by booleanPref(default = true)
|
||||
|
@ -104,9 +104,9 @@ class CustomFontActivity : AppCompatActivity() {
|
||||
if (item.fontVariants.size <= 1) {
|
||||
saveFont(item)
|
||||
} else {
|
||||
val dialog = BottomSheetMenu<String>(this, header = item.fontFamily)
|
||||
item.fontVariants.filter { !it.contains("italic") }.forEach {
|
||||
dialog.addItem(SettingsStringHelper.getVariantLabel(this, it), it)
|
||||
val dialog = BottomSheetMenu<Int>(this, header = item.fontFamily)
|
||||
item.fontVariants.filter { !it.contains("italic") }.forEachIndexed { index, s ->
|
||||
dialog.addItem(SettingsStringHelper.getVariantLabel(this, s), index)
|
||||
}
|
||||
dialog.addOnSelectItemListener { value ->
|
||||
saveFont(item, value)
|
||||
@ -167,13 +167,12 @@ class CustomFontActivity : AppCompatActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun saveFont(font: Font, variant: String = "") {
|
||||
private fun saveFont(font: Font, variantPos: Int? = null) {
|
||||
val resultIntent = Intent()
|
||||
Preferences.blockingBulk {
|
||||
customFont = Constants.CUSTOM_FONT_DOWNLOADED
|
||||
customFontName = font.fontFamily
|
||||
customFontFile = font.queryString
|
||||
customFontVariant = variant
|
||||
customFontFile = if (variantPos != null) font.getQueryString(variantPos) else font.queryString
|
||||
}
|
||||
setResult(Activity.RESULT_OK, resultIntent)
|
||||
finish()
|
||||
|
@ -302,13 +302,6 @@ class GeneralTabFragment : Fragment() {
|
||||
}
|
||||
})
|
||||
|
||||
viewModel.customFontVariant.observe(viewLifecycleOwner, Observer {
|
||||
maintainScrollPosition {
|
||||
custom_font_label?.text = SettingsStringHelper.getCustomFontLabel(requireContext(), Preferences.customFont)
|
||||
MainWidget.updateWidget(requireContext())
|
||||
}
|
||||
})
|
||||
|
||||
viewModel.showDividers.observe(viewLifecycleOwner, Observer {
|
||||
maintainScrollPosition {
|
||||
show_dividers_label?.text =
|
||||
@ -506,7 +499,6 @@ class GeneralTabFragment : Fragment() {
|
||||
customFont = value
|
||||
customFontFile = ""
|
||||
customFontName = ""
|
||||
customFontVariant = ""
|
||||
}
|
||||
}
|
||||
}.show()
|
||||
|
@ -26,7 +26,6 @@ class MainViewModel : ViewModel() {
|
||||
val customFont = Preferences.asLiveData(Preferences::customFont)
|
||||
val customFontFile = Preferences.asLiveData(Preferences::customFontFile)
|
||||
val customFontName = Preferences.asLiveData(Preferences::customFontName)
|
||||
val customFontVariant = Preferences.asLiveData(Preferences::customFontVariant)
|
||||
val secondRowInformation = Preferences.asLiveData(Preferences::secondRowInformation)
|
||||
val showDividers = Preferences.asLiveData(Preferences::showDividers)
|
||||
val secondRowTopMargin = Preferences.asLiveData(Preferences::secondRowTopMargin)
|
||||
|
Loading…
x
Reference in New Issue
Block a user