minor code cleanup

This commit is contained in:
tibbi
2023-01-09 16:49:38 +01:00
parent d522de1c42
commit b378f768be
6 changed files with 30 additions and 26 deletions

View File

@@ -47,15 +47,18 @@ class WidgetDateConfigureActivity : SimpleActivity() {
private fun initVariables() { private fun initVariables() {
mBgColor = config.widgetBgColor mBgColor = config.widgetBgColor
mBgAlpha = Color.alpha(mBgColor) / 255.toFloat() mBgAlpha = Color.alpha(mBgColor) / 255f
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.progress = (mBgAlpha * 100).toInt() config_bg_seekbar.apply {
updateBackgroundColor() progress = (mBgAlpha * 100).toInt()
config_bg_seekbar.onSeekBarChangeListener { progress ->
mBgAlpha = progress / 100.toFloat() onSeekBarChangeListener { progress ->
updateBackgroundColor() mBgAlpha = progress / 100f
updateBackgroundColor()
}
} }
updateBackgroundColor()
mTextColor = config.widgetTextColor mTextColor = config.widgetTextColor
if (mTextColor == resources.getColor(R.color.default_widget_text_color) && config.isUsingSystemTheme) { if (mTextColor == resources.getColor(R.color.default_widget_text_color) && config.isUsingSystemTheme) {

View File

@@ -74,15 +74,18 @@ class WidgetListConfigureActivity : SimpleActivity() {
private fun initVariables() { private fun initVariables() {
mBgColor = config.widgetBgColor mBgColor = config.widgetBgColor
mBgAlpha = Color.alpha(mBgColor) / 255.toFloat() mBgAlpha = Color.alpha(mBgColor) / 255f
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.progress = (mBgAlpha * 100).toInt() config_bg_seekbar.apply {
updateBackgroundColor() progress = (mBgAlpha * 100).toInt()
config_bg_seekbar.onSeekBarChangeListener { progress ->
mBgAlpha = progress / 100.toFloat() onSeekBarChangeListener { progress ->
updateBackgroundColor() mBgAlpha = progress / 100f
updateBackgroundColor()
}
} }
updateBackgroundColor()
mTextColor = config.widgetTextColor mTextColor = config.widgetTextColor
if (mTextColor == resources.getColor(R.color.default_widget_text_color) && config.isUsingSystemTheme) { if (mTextColor == resources.getColor(R.color.default_widget_text_color) && config.isUsingSystemTheme) {

View File

@@ -64,15 +64,18 @@ class WidgetMonthlyConfigureActivity : SimpleActivity(), MonthlyCalendar {
private fun initVariables() { private fun initVariables() {
mBgColor = config.widgetBgColor mBgColor = config.widgetBgColor
mBgAlpha = Color.alpha(mBgColor) / 255.toFloat() mBgAlpha = Color.alpha(mBgColor) / 255f
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.progress = (mBgAlpha * 100).toInt() config_bg_seekbar.apply {
updateBackgroundColor() progress = (mBgAlpha * 100).toInt()
config_bg_seekbar.onSeekBarChangeListener { progress ->
mBgAlpha = progress / 100.toFloat() onSeekBarChangeListener { progress ->
updateBackgroundColor() mBgAlpha = progress / 100f
updateBackgroundColor()
}
} }
updateBackgroundColor()
mTextColor = config.widgetTextColor mTextColor = config.widgetTextColor
if (mTextColor == resources.getColor(R.color.default_widget_text_color) && config.isUsingSystemTheme) { if (mTextColor == resources.getColor(R.color.default_widget_text_color) && config.isUsingSystemTheme) {

View File

@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/config_coordinator" android:id="@+id/config_coordinator"
android:layout_width="match_parent" android:layout_width="match_parent"
@@ -11,8 +10,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_centerHorizontal="true" android:layout_centerHorizontal="true"
android:layout_margin="@dimen/activity_margin" android:layout_margin="@dimen/activity_margin">
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<RelativeLayout <RelativeLayout
android:id="@+id/config_date_time_wrapper" android:id="@+id/config_date_time_wrapper"

View File

@@ -10,8 +10,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_centerHorizontal="true" android:layout_centerHorizontal="true"
android:layout_margin="@dimen/activity_margin" android:layout_margin="@dimen/activity_margin">
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<RelativeLayout <RelativeLayout
android:id="@+id/period_picker_holder" android:id="@+id/period_picker_holder"

View File

@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/config_coordinator" android:id="@+id/config_coordinator"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
@@ -10,8 +9,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_centerHorizontal="true" android:layout_centerHorizontal="true"
android:layout_margin="@dimen/activity_margin" android:layout_margin="@dimen/activity_margin">
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<include <include
android:id="@+id/config_calendar" android:id="@+id/config_calendar"