Archived
Restored option to center widget text; added option to change text opacity (currently non-functional)
This commit is contained in:
@@ -66,7 +66,7 @@ class SettingsFragment : BaseFragment(R.layout.fragment_settings) {
|
||||
}
|
||||
}
|
||||
|
||||
binding.transparencyPicker.apply {
|
||||
binding.textTransparencyPicker.apply {
|
||||
minValue = 0
|
||||
maxValue = 20
|
||||
val formatter = NumberPicker.Formatter { value ->
|
||||
@@ -76,12 +76,35 @@ class SettingsFragment : BaseFragment(R.layout.fragment_settings) {
|
||||
setFormatter(formatter)
|
||||
descendantFocusability = ViewGroup.FOCUS_BLOCK_DESCENDANTS
|
||||
wrapSelectorWheel = false
|
||||
value = storage.getTransparency()
|
||||
value = storage.getBackgroundTransparency()
|
||||
|
||||
// Do not touch - fix for value on spinner not showing up until touched
|
||||
val f: Field = NumberPicker::class.java.getDeclaredField("mInputText")
|
||||
f.isAccessible = true
|
||||
val inputText: EditText = f.get(binding.transparencyPicker) as EditText
|
||||
val inputText: EditText = f.get(binding.textTransparencyPicker) as EditText
|
||||
inputText.filters = arrayOfNulls(0)
|
||||
|
||||
setOnValueChangedListener { _, _, _ ->
|
||||
updatePreview()
|
||||
}
|
||||
}
|
||||
|
||||
binding.bgTransparencyPicker.apply {
|
||||
minValue = 0
|
||||
maxValue = 20
|
||||
val formatter = NumberPicker.Formatter { value ->
|
||||
val temp = value * 5
|
||||
"" + temp
|
||||
}
|
||||
setFormatter(formatter)
|
||||
descendantFocusability = ViewGroup.FOCUS_BLOCK_DESCENDANTS
|
||||
wrapSelectorWheel = false
|
||||
value = storage.getBackgroundTransparency()
|
||||
|
||||
// Do not touch - fix for value on spinner not showing up until touched
|
||||
val f: Field = NumberPicker::class.java.getDeclaredField("mInputText")
|
||||
f.isAccessible = true
|
||||
val inputText: EditText = f.get(binding.bgTransparencyPicker) as EditText
|
||||
inputText.filters = arrayOfNulls(0)
|
||||
|
||||
setOnValueChangedListener { _, _, _ ->
|
||||
@@ -117,31 +140,6 @@ class SettingsFragment : BaseFragment(R.layout.fragment_settings) {
|
||||
}
|
||||
}
|
||||
|
||||
// binding.switchHighContrast.apply {
|
||||
// isChecked = storage.isHighContrastEnabled()
|
||||
//
|
||||
// setOnCheckedChangeListener { _, _ ->
|
||||
// updatePreview()
|
||||
// }
|
||||
// }
|
||||
|
||||
// binding.typefaceMenuTextview.apply {
|
||||
// typefaceIndex = storage.getTypefaceIndex()
|
||||
// val typefaces = context.resources.getStringArray(R.array.typefaces)
|
||||
// val typefaceAdapter = ArrayAdapter(
|
||||
// context,
|
||||
// android.R.layout.simple_dropdown_item_1line,
|
||||
// typefaces
|
||||
// )
|
||||
// setAdapter(typefaceAdapter)
|
||||
// setText(typefaces[typefaceIndex], false)
|
||||
//
|
||||
// setOnItemClickListener { adapterView, view, index, l ->
|
||||
// typefaceIndex = index
|
||||
// updatePreview()
|
||||
// }
|
||||
// }
|
||||
|
||||
binding.typefaceToggleButton.apply {
|
||||
typefaceIndex = storage.getTypefaceIndex()
|
||||
|
||||
@@ -244,36 +242,13 @@ class SettingsFragment : BaseFragment(R.layout.fragment_settings) {
|
||||
}
|
||||
}
|
||||
|
||||
// val isBackgroundDark = if (storage.isInvertedEnabled()) { // bg white
|
||||
// (storage.getTransparency() * 5) <= 5
|
||||
// } else { // bg black
|
||||
// (storage.getTransparency() * 5) > 5
|
||||
// }
|
||||
|
||||
// Log.d("ASDF", isBackgroundDark.toString())
|
||||
|
||||
// binding.textPreviewBackground.setBackgroundColor(
|
||||
// Color.parseColor(ColorTransparentUtils.transparentColor(context.getColor(if (isBackgroundDark) {
|
||||
// R.color.md_theme_light_background
|
||||
// } else {
|
||||
// R.color.md_theme_dark_background
|
||||
// }), storage.getTransparency() * 5)))
|
||||
|
||||
// binding.textPreviewBackground.setBackgroundColor(
|
||||
// storage.getColours(
|
||||
// !storage.isInvertedEnabled(),
|
||||
// abs(storage.getTransparency() - 100),
|
||||
// context = context
|
||||
// ).second
|
||||
// )
|
||||
|
||||
binding.textPreviewBackgroundDark.setBackgroundColor(
|
||||
Color.parseColor(ColorTransparentUtils.transparentColor(
|
||||
context.getColor(R.color.md_theme_dark_background),
|
||||
if (storage.isInvertedEnabled()) {
|
||||
abs((storage.getTransparency() * 5))
|
||||
abs((storage.getBackgroundTransparency() * 5))
|
||||
} else {
|
||||
abs((storage.getTransparency() * 5) - 100)
|
||||
abs((storage.getBackgroundTransparency() * 5) - 100)
|
||||
}
|
||||
))
|
||||
)
|
||||
@@ -281,26 +256,14 @@ class SettingsFragment : BaseFragment(R.layout.fragment_settings) {
|
||||
val bitmap = CanvasText.drawText(context, true)
|
||||
|
||||
binding.textPreview.setImageBitmap(bitmap)
|
||||
|
||||
// val colours = storage.getColours(
|
||||
// binding.switchInvert.isChecked,
|
||||
//// binding.switchHighContrast.isChecked,
|
||||
// binding.transparencyPicker.value,
|
||||
// context
|
||||
// )
|
||||
//// binding.exampleText.textSize = binding.textSizePicker.value.toFloat()
|
||||
// binding.exampleText.setTextColor(colours.first)
|
||||
// binding.background.setBackgroundColor(colours.second)
|
||||
|
||||
// Log.d("VALVALUE", "${(binding.transparencyPicker.value * 5).toString()} /// ${colours.second}")
|
||||
}
|
||||
|
||||
private fun save() {
|
||||
storage.saveSettings(
|
||||
binding.textSizePicker.value,
|
||||
binding.switchInvert.isChecked,
|
||||
// binding.switchHighContrast.isChecked,
|
||||
binding.transparencyPicker.value,
|
||||
binding.textTransparencyPicker.value,
|
||||
binding.bgTransparencyPicker.value,
|
||||
binding.switchRandom.isChecked,
|
||||
widgetGravity,
|
||||
backgroundIndex,
|
||||
|
||||
Reference in New Issue
Block a user