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