updating widget config screens

This commit is contained in:
tibbi 2023-01-07 23:31:20 +01:00
parent a5339a9520
commit 14c99a53d3
6 changed files with 82 additions and 174 deletions

View File

@ -6,14 +6,13 @@ import android.content.Intent
import android.content.res.ColorStateList import android.content.res.ColorStateList
import android.graphics.Color import android.graphics.Color
import android.os.Bundle import android.os.Bundle
import android.widget.SeekBar
import com.simplemobiletools.calendar.pro.R import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.calendar.pro.extensions.config import com.simplemobiletools.calendar.pro.extensions.config
import com.simplemobiletools.calendar.pro.helpers.Formatter import com.simplemobiletools.calendar.pro.helpers.Formatter
import com.simplemobiletools.calendar.pro.helpers.MyWidgetDateProvider import com.simplemobiletools.calendar.pro.helpers.MyWidgetDateProvider
import com.simplemobiletools.commons.dialogs.ColorPickerDialog import com.simplemobiletools.commons.dialogs.ColorPickerDialog
import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.LOWER_ALPHA import com.simplemobiletools.commons.helpers.IS_CUSTOMIZING_COLORS
import kotlinx.android.synthetic.main.widget_config_date.* import kotlinx.android.synthetic.main.widget_config_date.*
class WidgetDateConfigureActivity : SimpleActivity() { class WidgetDateConfigureActivity : SimpleActivity() {
@ -21,10 +20,7 @@ class WidgetDateConfigureActivity : SimpleActivity() {
private var mWidgetId = 0 private var mWidgetId = 0
private var mBgColorWithoutTransparency = 0 private var mBgColorWithoutTransparency = 0
private var mBgColor = 0 private var mBgColor = 0
private var mTextColorWithoutTransparency = 0
private var mTextColor = 0 private var mTextColor = 0
private var mWeakTextColor = 0
private var mPrimaryColor = 0
public override fun onCreate(savedInstanceState: Bundle?) { public override fun onCreate(savedInstanceState: Bundle?) {
useDynamicTheme = false useDynamicTheme = false
@ -33,37 +29,40 @@ class WidgetDateConfigureActivity : SimpleActivity() {
setContentView(R.layout.widget_config_date) setContentView(R.layout.widget_config_date)
initVariables() initVariables()
val extras = intent.extras val isCustomizingColors = intent.extras?.getBoolean(IS_CUSTOMIZING_COLORS) ?: false
if (extras != null) mWidgetId = intent.extras?.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID) ?: AppWidgetManager.INVALID_APPWIDGET_ID
mWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID)
if (mWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID) if (mWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID && !isCustomizingColors) {
finish() finish()
}
val primaryColor = getProperPrimaryColor()
config_save.setOnClickListener { saveConfig() } config_save.setOnClickListener { saveConfig() }
config_bg_color.setOnClickListener { pickBackgroundColor() } config_bg_color.setOnClickListener { pickBackgroundColor() }
config_text_color.setOnClickListener { pickTextColor() } config_text_color.setOnClickListener { pickTextColor() }
config_bg_seekbar.setColors(mTextColor, mPrimaryColor, mPrimaryColor) config_bg_seekbar.setColors(mTextColor, primaryColor, primaryColor)
widget_date_label.text = Formatter.getTodayDayNumber() widget_date_label.text = Formatter.getTodayDayNumber()
widget_month_label.text = Formatter.getCurrentMonthShort() widget_month_label.text = Formatter.getCurrentMonthShort()
} }
override fun onResume() {
super.onResume()
setupToolbar(config_toolbar)
}
private fun initVariables() { private fun initVariables() {
mTextColorWithoutTransparency = config.widgetTextColor
updateColors()
mBgColor = config.widgetBgColor mBgColor = config.widgetBgColor
mBgAlpha = Color.alpha(mBgColor) / 255.toFloat() mBgAlpha = Color.alpha(mBgColor) / 255.toFloat()
mBgColorWithoutTransparency = Color.rgb(Color.red(mBgColor), Color.green(mBgColor), Color.blue(mBgColor)) mBgColorWithoutTransparency = Color.rgb(Color.red(mBgColor), Color.green(mBgColor), Color.blue(mBgColor))
config_bg_seekbar.setOnSeekBarChangeListener(bgSeekbarChangeListener)
config_bg_seekbar.progress = (mBgAlpha * 100).toInt() config_bg_seekbar.progress = (mBgAlpha * 100).toInt()
updateBgColor() updateBackgroundColor()
config_bg_seekbar.onSeekBarChangeListener { progress ->
mBgAlpha = progress / 100.toFloat()
updateBackgroundColor()
}
mTextColor = config.widgetTextColor
if (mTextColor == resources.getColor(R.color.default_widget_text_color) && config.isUsingSystemTheme) {
mTextColor = resources.getColor(R.color.you_primary_color, theme)
}
updateTextColor()
} }
private fun saveConfig() { private fun saveConfig() {
@ -80,7 +79,7 @@ class WidgetDateConfigureActivity : SimpleActivity() {
private fun storeWidgetColors() { private fun storeWidgetColors() {
config.apply { config.apply {
widgetBgColor = mBgColor widgetBgColor = mBgColor
widgetTextColor = mTextColorWithoutTransparency widgetTextColor = mTextColor
} }
} }
@ -88,7 +87,7 @@ class WidgetDateConfigureActivity : SimpleActivity() {
ColorPickerDialog(this, mBgColorWithoutTransparency) { wasPositivePressed, color -> ColorPickerDialog(this, mBgColorWithoutTransparency) { wasPositivePressed, color ->
if (wasPositivePressed) { if (wasPositivePressed) {
mBgColorWithoutTransparency = color mBgColorWithoutTransparency = color
updateBgColor() updateBackgroundColor()
} }
} }
} }
@ -96,8 +95,8 @@ class WidgetDateConfigureActivity : SimpleActivity() {
private fun pickTextColor() { private fun pickTextColor() {
ColorPickerDialog(this, mTextColor) { wasPositivePressed, color -> ColorPickerDialog(this, mTextColor) { wasPositivePressed, color ->
if (wasPositivePressed) { if (wasPositivePressed) {
mTextColorWithoutTransparency = color mTextColor = color
updateColors() updateTextColor()
} }
} }
} }
@ -109,32 +108,17 @@ class WidgetDateConfigureActivity : SimpleActivity() {
} }
} }
private fun updateColors() { private fun updateTextColor() {
mTextColor = mTextColorWithoutTransparency
mWeakTextColor = mTextColorWithoutTransparency.adjustAlpha(LOWER_ALPHA)
mPrimaryColor = getProperPrimaryColor()
config_text_color.setFillWithStroke(mTextColor, mTextColor) config_text_color.setFillWithStroke(mTextColor, mTextColor)
widget_date_label.setTextColor(mTextColor) widget_date_label.setTextColor(mTextColor)
widget_month_label.setTextColor(mTextColor) widget_month_label.setTextColor(mTextColor)
config_save.setTextColor(getProperPrimaryColor().getContrastColor()) config_save.setTextColor(getProperPrimaryColor().getContrastColor())
} }
private fun updateBgColor() { private fun updateBackgroundColor() {
mBgColor = mBgColorWithoutTransparency.adjustAlpha(mBgAlpha) mBgColor = mBgColorWithoutTransparency.adjustAlpha(mBgAlpha)
config_date_time_wrapper.background.applyColorFilter(mBgColor) config_date_time_wrapper.background.applyColorFilter(mBgColor)
config_bg_color.setFillWithStroke(mBgColor, mBgColor) config_bg_color.setFillWithStroke(mBgColor, mBgColor)
config_save.backgroundTintList = ColorStateList.valueOf(getProperPrimaryColor()) config_save.backgroundTintList = ColorStateList.valueOf(getProperPrimaryColor())
} }
private val bgSeekbarChangeListener = object : SeekBar.OnSeekBarChangeListener {
override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
mBgAlpha = progress.toFloat() / 100.toFloat()
updateBgColor()
}
override fun onStartTrackingTouch(seekBar: SeekBar) {}
override fun onStopTrackingTouch(seekBar: SeekBar) {}
}
} }

View File

@ -7,7 +7,6 @@ import android.content.res.ColorStateList
import android.graphics.Color import android.graphics.Color
import android.graphics.drawable.ColorDrawable import android.graphics.drawable.ColorDrawable
import android.os.Bundle import android.os.Bundle
import android.widget.SeekBar
import com.simplemobiletools.calendar.pro.R import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.calendar.pro.adapters.EventListAdapter import com.simplemobiletools.calendar.pro.adapters.EventListAdapter
import com.simplemobiletools.calendar.pro.dialogs.CustomPeriodPickerDialog import com.simplemobiletools.calendar.pro.dialogs.CustomPeriodPickerDialog
@ -36,9 +35,8 @@ class WidgetListConfigureActivity : SimpleActivity() {
private var mWidgetId = 0 private var mWidgetId = 0
private var mBgColorWithoutTransparency = 0 private var mBgColorWithoutTransparency = 0
private var mBgColor = 0 private var mBgColor = 0
private var mTextColorWithoutTransparency = 0
private var mTextColor = 0 private var mTextColor = 0
private var selectedPeriodOption = 0 private var mSelectedPeriodOption = 0
public override fun onCreate(savedInstanceState: Bundle?) { public override fun onCreate(savedInstanceState: Bundle?) {
useDynamicTheme = false useDynamicTheme = false
@ -74,27 +72,28 @@ class WidgetListConfigureActivity : SimpleActivity() {
updateSelectedPeriod(config.lastUsedEventSpan) updateSelectedPeriod(config.lastUsedEventSpan)
} }
override fun onResume() {
super.onResume()
updateTextColors(config_list_holder)
setupToolbar(config_toolbar)
}
private fun initVariables() { private fun initVariables() {
mTextColorWithoutTransparency = config.widgetTextColor
updateColors()
mBgColor = config.widgetBgColor mBgColor = config.widgetBgColor
mBgAlpha = Color.alpha(mBgColor) / 255.toFloat() mBgAlpha = Color.alpha(mBgColor) / 255.toFloat()
mBgColorWithoutTransparency = Color.rgb(Color.red(mBgColor), Color.green(mBgColor), Color.blue(mBgColor)) mBgColorWithoutTransparency = Color.rgb(Color.red(mBgColor), Color.green(mBgColor), Color.blue(mBgColor))
config_bg_seekbar.setOnSeekBarChangeListener(bgSeekbarChangeListener)
config_bg_seekbar.progress = (mBgAlpha * 100).toInt() config_bg_seekbar.progress = (mBgAlpha * 100).toInt()
updateBgColor() updateBackgroundColor()
config_bg_seekbar.onSeekBarChangeListener { progress ->
mBgAlpha = progress / 100.toFloat()
updateBackgroundColor()
}
mTextColor = config.widgetTextColor
if (mTextColor == resources.getColor(R.color.default_widget_text_color) && config.isUsingSystemTheme) {
mTextColor = resources.getColor(R.color.you_primary_color, theme)
}
updateTextColor()
} }
private fun saveConfig() { private fun saveConfig() {
val widget = Widget(null, mWidgetId, selectedPeriodOption) val widget = Widget(null, mWidgetId, mSelectedPeriodOption)
ensureBackgroundThread { ensureBackgroundThread {
widgetsDB.insertOrUpdate(widget) widgetsDB.insertOrUpdate(widget)
} }
@ -102,7 +101,7 @@ class WidgetListConfigureActivity : SimpleActivity() {
storeWidgetColors() storeWidgetColors()
requestWidgetUpdate() requestWidgetUpdate()
config.lastUsedEventSpan = selectedPeriodOption config.lastUsedEventSpan = mSelectedPeriodOption
Intent().apply { Intent().apply {
putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, mWidgetId) putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, mWidgetId)
@ -119,7 +118,7 @@ class WidgetListConfigureActivity : SimpleActivity() {
add(WEEK_SECONDS) add(WEEK_SECONDS)
add(MONTH_SECONDS) add(MONTH_SECONDS)
add(YEAR_SECONDS) add(YEAR_SECONDS)
add(selectedPeriodOption) add(mSelectedPeriodOption)
} }
val items = ArrayList<RadioItem>(seconds.size) val items = ArrayList<RadioItem>(seconds.size)
@ -129,7 +128,7 @@ class WidgetListConfigureActivity : SimpleActivity() {
var selectedIndex = 0 var selectedIndex = 0
seconds.forEachIndexed { index, value -> seconds.forEachIndexed { index, value ->
if (value == selectedPeriodOption) { if (value == mSelectedPeriodOption) {
selectedIndex = index selectedIndex = index
} }
} }
@ -149,14 +148,14 @@ class WidgetListConfigureActivity : SimpleActivity() {
} }
private fun updateSelectedPeriod(selectedPeriod: Int) { private fun updateSelectedPeriod(selectedPeriod: Int) {
selectedPeriodOption = selectedPeriod mSelectedPeriodOption = selectedPeriod
when (selectedPeriod) { when (selectedPeriod) {
0 -> { 0 -> {
selectedPeriodOption = YEAR_SECONDS mSelectedPeriodOption = YEAR_SECONDS
period_picker_value.setText(R.string.within_the_next_one_year) period_picker_value.setText(R.string.within_the_next_one_year)
} }
EVENT_PERIOD_TODAY -> period_picker_value.setText(R.string.today_only) EVENT_PERIOD_TODAY -> period_picker_value.setText(R.string.today_only)
else -> period_picker_value.text = getFormattedSeconds(selectedPeriodOption) else -> period_picker_value.text = getFormattedSeconds(mSelectedPeriodOption)
} }
} }
@ -174,7 +173,7 @@ class WidgetListConfigureActivity : SimpleActivity() {
private fun storeWidgetColors() { private fun storeWidgetColors() {
config.apply { config.apply {
widgetBgColor = mBgColor widgetBgColor = mBgColor
widgetTextColor = mTextColorWithoutTransparency widgetTextColor = mTextColor
} }
} }
@ -182,7 +181,7 @@ class WidgetListConfigureActivity : SimpleActivity() {
ColorPickerDialog(this, mBgColorWithoutTransparency) { wasPositivePressed, color -> ColorPickerDialog(this, mBgColorWithoutTransparency) { wasPositivePressed, color ->
if (wasPositivePressed) { if (wasPositivePressed) {
mBgColorWithoutTransparency = color mBgColorWithoutTransparency = color
updateBgColor() updateBackgroundColor()
} }
} }
} }
@ -190,8 +189,8 @@ class WidgetListConfigureActivity : SimpleActivity() {
private fun pickTextColor() { private fun pickTextColor() {
ColorPickerDialog(this, mTextColor) { wasPositivePressed, color -> ColorPickerDialog(this, mTextColor) { wasPositivePressed, color ->
if (wasPositivePressed) { if (wasPositivePressed) {
mTextColorWithoutTransparency = color mTextColor = color
updateColors() updateTextColor()
} }
} }
} }
@ -203,14 +202,13 @@ class WidgetListConfigureActivity : SimpleActivity() {
} }
} }
private fun updateColors() { private fun updateTextColor() {
mTextColor = mTextColorWithoutTransparency
(config_events_list.adapter as? EventListAdapter)?.updateTextColor(mTextColor) (config_events_list.adapter as? EventListAdapter)?.updateTextColor(mTextColor)
config_text_color.setFillWithStroke(mTextColor, mTextColor) config_text_color.setFillWithStroke(mTextColor, mTextColor)
config_save.setTextColor(getProperPrimaryColor().getContrastColor()) config_save.setTextColor(getProperPrimaryColor().getContrastColor())
} }
private fun updateBgColor() { private fun updateBackgroundColor() {
mBgColor = mBgColorWithoutTransparency.adjustAlpha(mBgAlpha) mBgColor = mBgColorWithoutTransparency.adjustAlpha(mBgAlpha)
config_events_list.background.applyColorFilter(mBgColor) config_events_list.background.applyColorFilter(mBgColor)
config_bg_color.setFillWithStroke(mBgColor, mBgColor) config_bg_color.setFillWithStroke(mBgColor, mBgColor)
@ -318,15 +316,4 @@ class WidgetListConfigureActivity : SimpleActivity() {
return listItems return listItems
} }
private val bgSeekbarChangeListener = object : SeekBar.OnSeekBarChangeListener {
override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
mBgAlpha = progress.toFloat() / 100.toFloat()
updateBgColor()
}
override fun onStartTrackingTouch(seekBar: SeekBar) {}
override fun onStopTrackingTouch(seekBar: SeekBar) {}
}
} }

View File

@ -12,7 +12,6 @@ import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.LinearLayout import android.widget.LinearLayout
import android.widget.RelativeLayout import android.widget.RelativeLayout
import android.widget.SeekBar
import android.widget.TextView import android.widget.TextView
import com.simplemobiletools.calendar.pro.R import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.calendar.pro.extensions.addDayEvents import com.simplemobiletools.calendar.pro.extensions.addDayEvents
@ -24,6 +23,7 @@ import com.simplemobiletools.calendar.pro.interfaces.MonthlyCalendar
import com.simplemobiletools.calendar.pro.models.DayMonthly import com.simplemobiletools.calendar.pro.models.DayMonthly
import com.simplemobiletools.commons.dialogs.ColorPickerDialog import com.simplemobiletools.commons.dialogs.ColorPickerDialog
import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.IS_CUSTOMIZING_COLORS
import com.simplemobiletools.commons.helpers.LOWER_ALPHA import com.simplemobiletools.commons.helpers.LOWER_ALPHA
import kotlinx.android.synthetic.main.day_monthly_number_view.view.* import kotlinx.android.synthetic.main.day_monthly_number_view.view.*
import kotlinx.android.synthetic.main.first_row.* import kotlinx.android.synthetic.main.first_row.*
@ -39,12 +39,7 @@ class WidgetMonthlyConfigureActivity : SimpleActivity(), MonthlyCalendar {
private var mWidgetId = 0 private var mWidgetId = 0
private var mBgColorWithoutTransparency = 0 private var mBgColorWithoutTransparency = 0
private var mBgColor = 0 private var mBgColor = 0
private var mTextColorWithoutTransparency = 0
private var mTextColor = 0 private var mTextColor = 0
private var mWeakTextColor = 0
private var mPrimaryColor = 0
private var mWeekendsTextColor = 0
private var mHighlightWeekends = false
public override fun onCreate(savedInstanceState: Bundle?) { public override fun onCreate(savedInstanceState: Bundle?) {
useDynamicTheme = false useDynamicTheme = false
@ -53,37 +48,40 @@ class WidgetMonthlyConfigureActivity : SimpleActivity(), MonthlyCalendar {
setContentView(R.layout.widget_config_monthly) setContentView(R.layout.widget_config_monthly)
initVariables() initVariables()
val extras = intent.extras val isCustomizingColors = intent.extras?.getBoolean(IS_CUSTOMIZING_COLORS) ?: false
if (extras != null) mWidgetId = intent.extras?.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID) ?: AppWidgetManager.INVALID_APPWIDGET_ID
mWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID)
if (mWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID) if (mWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID && !isCustomizingColors) {
finish() finish()
}
val primaryColor = getProperPrimaryColor()
config_save.setOnClickListener { saveConfig() } config_save.setOnClickListener { saveConfig() }
config_bg_color.setOnClickListener { pickBackgroundColor() } config_bg_color.setOnClickListener { pickBackgroundColor() }
config_text_color.setOnClickListener { pickTextColor() } config_text_color.setOnClickListener { pickTextColor() }
config_bg_seekbar.setColors(mTextColor, mPrimaryColor, mPrimaryColor) config_bg_seekbar.setColors(mTextColor, primaryColor, primaryColor)
}
override fun onResume() {
super.onResume()
setupToolbar(config_toolbar)
} }
private fun initVariables() { private fun initVariables() {
mTextColorWithoutTransparency = config.widgetTextColor
updateColors()
mBgColor = config.widgetBgColor mBgColor = config.widgetBgColor
mBgAlpha = Color.alpha(mBgColor) / 255.toFloat() mBgAlpha = Color.alpha(mBgColor) / 255.toFloat()
mBgColorWithoutTransparency = Color.rgb(Color.red(mBgColor), Color.green(mBgColor), Color.blue(mBgColor)) mBgColorWithoutTransparency = Color.rgb(Color.red(mBgColor), Color.green(mBgColor), Color.blue(mBgColor))
config_bg_seekbar.setOnSeekBarChangeListener(bgSeekbarChangeListener)
config_bg_seekbar.progress = (mBgAlpha * 100).toInt() config_bg_seekbar.progress = (mBgAlpha * 100).toInt()
updateBgColor() updateBackgroundColor()
config_bg_seekbar.onSeekBarChangeListener { progress ->
mBgAlpha = progress / 100.toFloat()
updateBackgroundColor()
}
MonthlyCalendarImpl(this, applicationContext).updateMonthlyCalendar(DateTime().withDayOfMonth(1)) mTextColor = config.widgetTextColor
if (mTextColor == resources.getColor(R.color.default_widget_text_color) && config.isUsingSystemTheme) {
mTextColor = resources.getColor(R.color.you_primary_color, theme)
}
updateTextColor()
MonthlyCalendarImpl(this, this).updateMonthlyCalendar(DateTime().withDayOfMonth(1))
} }
private fun saveConfig() { private fun saveConfig() {
@ -100,7 +98,7 @@ class WidgetMonthlyConfigureActivity : SimpleActivity(), MonthlyCalendar {
private fun storeWidgetColors() { private fun storeWidgetColors() {
config.apply { config.apply {
widgetBgColor = mBgColor widgetBgColor = mBgColor
widgetTextColor = mTextColorWithoutTransparency widgetTextColor = mTextColor
} }
} }
@ -108,7 +106,7 @@ class WidgetMonthlyConfigureActivity : SimpleActivity(), MonthlyCalendar {
ColorPickerDialog(this, mBgColorWithoutTransparency) { wasPositivePressed, color -> ColorPickerDialog(this, mBgColorWithoutTransparency) { wasPositivePressed, color ->
if (wasPositivePressed) { if (wasPositivePressed) {
mBgColorWithoutTransparency = color mBgColorWithoutTransparency = color
updateBgColor() updateBackgroundColor()
} }
} }
} }
@ -116,8 +114,8 @@ class WidgetMonthlyConfigureActivity : SimpleActivity(), MonthlyCalendar {
private fun pickTextColor() { private fun pickTextColor() {
ColorPickerDialog(this, mTextColor) { wasPositivePressed, color -> ColorPickerDialog(this, mTextColor) { wasPositivePressed, color ->
if (wasPositivePressed) { if (wasPositivePressed) {
mTextColorWithoutTransparency = color mTextColor = color
updateColors() updateTextColor()
updateDays() updateDays()
} }
} }
@ -130,32 +128,26 @@ class WidgetMonthlyConfigureActivity : SimpleActivity(), MonthlyCalendar {
} }
} }
private fun updateColors() { private fun updateTextColor() {
mTextColor = mTextColorWithoutTransparency
mWeakTextColor = mTextColorWithoutTransparency.adjustAlpha(LOWER_ALPHA)
mPrimaryColor = getProperPrimaryColor()
mWeekendsTextColor = config.highlightWeekendsColor
mHighlightWeekends = config.highlightWeekends
top_left_arrow.applyColorFilter(mTextColor) top_left_arrow.applyColorFilter(mTextColor)
top_right_arrow.applyColorFilter(mTextColor) top_right_arrow.applyColorFilter(mTextColor)
top_value.setTextColor(mTextColor) top_value.setTextColor(mTextColor)
config_text_color.setFillWithStroke(mTextColor, mTextColor) config_text_color.setFillWithStroke(mTextColor, mTextColor)
updateLabels() updateLabels()
config_save.backgroundTintList = ColorStateList.valueOf(getProperPrimaryColor())
config_save.setTextColor(getProperPrimaryColor().getContrastColor()) config_save.setTextColor(getProperPrimaryColor().getContrastColor())
} }
private fun updateBgColor() { private fun updateBackgroundColor() {
mBgColor = mBgColorWithoutTransparency.adjustAlpha(mBgAlpha) mBgColor = mBgColorWithoutTransparency.adjustAlpha(mBgAlpha)
config_calendar.background.applyColorFilter(mBgColor) config_calendar.background.applyColorFilter(mBgColor)
config_bg_color.setFillWithStroke(mBgColor, mBgColor) config_bg_color.setFillWithStroke(mBgColor, mBgColor)
config_save.backgroundTintList = ColorStateList.valueOf(getProperPrimaryColor())
} }
private fun updateDays() { private fun updateDays() {
val len = mDays!!.size val len = mDays!!.size
if (applicationContext.config.showWeekNumbers) { if (config.showWeekNumbers) {
week_num.setTextColor(mTextColor) week_num.setTextColor(mTextColor)
week_num.beVisible() week_num.beVisible()
@ -192,7 +184,7 @@ class WidgetMonthlyConfigureActivity : SimpleActivity(), MonthlyCalendar {
textColor = textColor.adjustAlpha(LOWER_ALPHA) textColor = textColor.adjustAlpha(LOWER_ALPHA)
} }
(View.inflate(applicationContext, R.layout.day_monthly_number_view, null) as RelativeLayout).apply { (View.inflate(this, R.layout.day_monthly_number_view, null) as RelativeLayout).apply {
layoutParams = LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT) layoutParams = LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)
linearLayout.addView(this) linearLayout.addView(this)
@ -210,17 +202,6 @@ class WidgetMonthlyConfigureActivity : SimpleActivity(), MonthlyCalendar {
} }
} }
private val bgSeekbarChangeListener = object : SeekBar.OnSeekBarChangeListener {
override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
mBgAlpha = progress.toFloat() / 100.toFloat()
updateBgColor()
}
override fun onStartTrackingTouch(seekBar: SeekBar) {}
override fun onStopTrackingTouch(seekBar: SeekBar) {}
}
override fun updateMonthlyCalendar(context: Context, month: String, days: ArrayList<DayMonthly>, checkedEvents: Boolean, currTargetDate: DateTime) { override fun updateMonthlyCalendar(context: Context, month: String, days: ArrayList<DayMonthly>, checkedEvents: Boolean, currTargetDate: DateTime) {
runOnUiThread { runOnUiThread {
mDays = days mDays = days
@ -230,10 +211,11 @@ class WidgetMonthlyConfigureActivity : SimpleActivity(), MonthlyCalendar {
} }
private fun updateLabels() { private fun updateLabels() {
val weekendsTextColor = config.highlightWeekendsColor
for (i in 0..6) { for (i in 0..6) {
findViewById<TextView>(resources.getIdentifier("label_$i", "id", packageName)).apply { findViewById<TextView>(resources.getIdentifier("label_$i", "id", packageName)).apply {
val textColor = if (config.highlightWeekends && isWeekend(i, config.isSundayFirst)) { val textColor = if (config.highlightWeekends && isWeekend(i, config.isSundayFirst)) {
mWeekendsTextColor weekendsTextColor
} else { } else {
mTextColor mTextColor
} }

View File

@ -6,21 +6,6 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/config_app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/config_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/color_primary"
app:title="@string/app_launcher_name"
app:titleTextAppearance="@style/AppTheme.ActionBar.TitleTextStyle" />
</com.google.android.material.appbar.AppBarLayout>
<RelativeLayout <RelativeLayout
android:id="@+id/config_date_time_holder" android:id="@+id/config_date_time_holder"
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@ -5,21 +5,6 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/config_app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/config_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/color_primary"
app:title="@string/app_launcher_name"
app:titleTextAppearance="@style/AppTheme.ActionBar.TitleTextStyle" />
</com.google.android.material.appbar.AppBarLayout>
<RelativeLayout <RelativeLayout
android:id="@+id/config_list_holder" android:id="@+id/config_list_holder"
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@ -5,21 +5,6 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/config_app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/config_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/color_primary"
app:title="@string/app_launcher_name"
app:titleTextAppearance="@style/AppTheme.ActionBar.TitleTextStyle" />
</com.google.android.material.appbar.AppBarLayout>
<RelativeLayout <RelativeLayout
android:id="@+id/config_holder" android:id="@+id/config_holder"
android:layout_width="match_parent" android:layout_width="match_parent"