From c7e261d0e6686c0e7e431d254c2081973e7e88f2 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Sat, 13 Feb 2021 18:30:35 +0100 Subject: [PATCH 1/4] weekday picker working without view --- .../automation/elements/InputWeekDay.kt | 21 +++--- .../androidaps/utils/ui/WeekdayPicker.kt | 68 +++++++++++++++++ .../src/main/res/color/weekday_background.xml | 5 ++ .../src/main/res/color/weekend_background.xml | 5 ++ .../drawable/weekday_circle_brackground.xml | 7 ++ core/src/main/res/layout/weekday_picker.xml | 74 +++++++++++++++++++ core/src/main/res/values/colors.xml | 5 ++ core/src/main/res/values/strings.xml | 9 +++ 8 files changed, 182 insertions(+), 12 deletions(-) create mode 100644 core/src/main/java/info/nightscout/androidaps/utils/ui/WeekdayPicker.kt create mode 100644 core/src/main/res/color/weekday_background.xml create mode 100644 core/src/main/res/color/weekend_background.xml create mode 100644 core/src/main/res/drawable/weekday_circle_brackground.xml create mode 100644 core/src/main/res/layout/weekday_picker.xml diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputWeekDay.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputWeekDay.kt index 1f2531d95b..dda616de14 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputWeekDay.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputWeekDay.kt @@ -1,12 +1,10 @@ package info.nightscout.androidaps.plugins.general.automation.elements -import android.view.View -import android.view.ViewGroup import android.widget.LinearLayout import androidx.annotation.StringRes -import com.dpro.widgets.WeekdaysPicker import dagger.android.HasAndroidInjector import info.nightscout.androidaps.R +import info.nightscout.androidaps.utils.ui.WeekdayPicker import java.util.* class InputWeekDay(injector: HasAndroidInjector) : Element(injector) { @@ -22,6 +20,7 @@ class InputWeekDay(injector: HasAndroidInjector) : Element(injector) { get() = shortNames[ordinal] companion object { + private val calendarInts = intArrayOf( Calendar.MONDAY, Calendar.TUESDAY, @@ -56,7 +55,7 @@ class InputWeekDay(injector: HasAndroidInjector) : Element(injector) { for (day in DayOfWeek.values()) set(day, false) } - fun setAll(value:Boolean) { + fun setAll(value: Boolean) { for (day in DayOfWeek.values()) set(day, value) } @@ -78,13 +77,11 @@ class InputWeekDay(injector: HasAndroidInjector) : Element(injector) { } override fun addToLayout(root: LinearLayout) { - val weekdaysPicker = WeekdaysPicker(root.context) - weekdaysPicker.setEditable(true) - weekdaysPicker.selectedDays = getSelectedDays() - weekdaysPicker.setOnWeekdaysChangeListener { _: View?, i: Int, list: List -> set(DayOfWeek.fromCalendarInt(i), list.contains(i)) } - weekdaysPicker.layoutParams = LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) - weekdaysPicker.sundayFirstDay = Calendar.getInstance().firstDayOfWeek == Calendar.SUNDAY - weekdaysPicker.redrawDays() - root.addView(weekdaysPicker) + WeekdayPicker(root.context).apply { + setSelectedDays(getSelectedDays()) + setOnWeekdaysChangeListener { i: Int, selected: Boolean -> set(DayOfWeek.fromCalendarInt(i), selected) } + root.addView(this) + } + // TODO: remove library and dependency statement } } diff --git a/core/src/main/java/info/nightscout/androidaps/utils/ui/WeekdayPicker.kt b/core/src/main/java/info/nightscout/androidaps/utils/ui/WeekdayPicker.kt new file mode 100644 index 0000000000..0ac104a070 --- /dev/null +++ b/core/src/main/java/info/nightscout/androidaps/utils/ui/WeekdayPicker.kt @@ -0,0 +1,68 @@ +package info.nightscout.androidaps.utils.ui + +import android.content.Context +import android.util.AttributeSet +import android.view.LayoutInflater +import android.widget.Checkable +import android.widget.LinearLayout +import androidx.appcompat.widget.AppCompatCheckedTextView +import info.nightscout.androidaps.core.databinding.WeekdayPickerBinding +import info.nightscout.androidaps.utils.extensions.toVisibility +import java.util.* + +class WeekdayPicker @JvmOverloads constructor( + context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0 +) : LinearLayout(context, attrs, defStyleAttr) { + + private var changeListener: ((Int, Boolean) -> Unit)? = null + + private var binding: WeekdayPickerBinding + + init { + val inflater = LayoutInflater.from(context) + binding = WeekdayPickerBinding.inflate(inflater, this, true) + determineBeginOfWeek() + setupClickListeners() + } + + private fun determineBeginOfWeek() { + (Calendar.getInstance().firstDayOfWeek == Calendar.SUNDAY).let { + binding.weekdayPickerSundayStart.visibility = it.toVisibility() + binding.weekdayPickerSundayEnd.visibility = it.not().toVisibility() + } + } + + fun setSelectedDays(list: List) { + binding.weekdayPickerSundayStart.isChecked = list.contains(Calendar.SUNDAY) + binding.weekdayPickerSundayEnd.isChecked = list.contains(Calendar.SUNDAY) + binding.weekdayPickerMonday.isChecked = list.contains(Calendar.MONDAY) + binding.weekdayPickerTuesday.isChecked = list.contains(Calendar.TUESDAY) + binding.weekdayPickerWednesday.isChecked = list.contains(Calendar.WEDNESDAY) + binding.weekdayPickerThursday.isChecked = list.contains(Calendar.THURSDAY) + binding.weekdayPickerFriday.isChecked = list.contains(Calendar.FRIDAY) + binding.weekdayPickerSaturday.isChecked = list.contains(Calendar.SATURDAY) + } + + private fun setupClickListeners() { + binding.weekdayPickerSundayStart.setupCallbackFor(Calendar.SUNDAY) + binding.weekdayPickerSundayEnd.setupCallbackFor(Calendar.SUNDAY) + binding.weekdayPickerMonday.setupCallbackFor(Calendar.MONDAY) + binding.weekdayPickerTuesday.setupCallbackFor(Calendar.TUESDAY) + binding.weekdayPickerWednesday.setupCallbackFor(Calendar.WEDNESDAY) + binding.weekdayPickerThursday.setupCallbackFor(Calendar.THURSDAY) + binding.weekdayPickerFriday.setupCallbackFor(Calendar.FRIDAY) + binding.weekdayPickerSaturday.setupCallbackFor(Calendar.SATURDAY) + } + + fun setOnWeekdaysChangeListener(changeListener: (Int, Boolean) -> Unit) { + this.changeListener = changeListener + } + + private fun AppCompatCheckedTextView.setupCallbackFor(day: Int) = setOnClickListener{ + val checkable = it as Checkable + val checked = checkable.isChecked + checkable.isChecked = !checked + changeListener?.invoke(day, !checked) + } + +} \ No newline at end of file diff --git a/core/src/main/res/color/weekday_background.xml b/core/src/main/res/color/weekday_background.xml new file mode 100644 index 0000000000..b345f818d2 --- /dev/null +++ b/core/src/main/res/color/weekday_background.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/core/src/main/res/color/weekend_background.xml b/core/src/main/res/color/weekend_background.xml new file mode 100644 index 0000000000..1de73d0e17 --- /dev/null +++ b/core/src/main/res/color/weekend_background.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/core/src/main/res/drawable/weekday_circle_brackground.xml b/core/src/main/res/drawable/weekday_circle_brackground.xml new file mode 100644 index 0000000000..861dda73c2 --- /dev/null +++ b/core/src/main/res/drawable/weekday_circle_brackground.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/core/src/main/res/layout/weekday_picker.xml b/core/src/main/res/layout/weekday_picker.xml new file mode 100644 index 0000000000..82acbb829b --- /dev/null +++ b/core/src/main/res/layout/weekday_picker.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/core/src/main/res/values/colors.xml b/core/src/main/res/values/colors.xml index 7842897b59..6bd15fb852 100644 --- a/core/src/main/res/values/colors.xml +++ b/core/src/main/res/values/colors.xml @@ -41,6 +41,11 @@ #00d2d2 #ffffff + #8000FF00 + #1000FF00 + #800000FF + #100000FF + #FF8C00 diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml index e42bd8e553..06a686a867 100644 --- a/core/src/main/res/values/strings.xml +++ b/core/src/main/res/values/strings.xml @@ -315,6 +315,15 @@ Please reboot your phone or restart AndroidAPS from the System Settings \notherwise Android APS will not have logging (important to track and verify that the algorithms are working correctly)! + + M + T + W + T + F + S + S + %1$d day %1$d days From ff6a8f30c1c05cac3bde17dbf9df961102f35f51 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Sat, 13 Feb 2021 19:10:12 +0100 Subject: [PATCH 2/4] weekday component working --- .../androidaps/utils/ui/WeekdayPicker.kt | 3 +- .../res/color/day_selection_background.xml | 5 + .../src/main/res/color/weekday_background.xml | 5 - .../src/main/res/color/weekend_background.xml | 5 - .../drawable/weekday_circle_brackground.xml | 6 +- .../drawable/weekend_circle_brackground.xml | 7 + core/src/main/res/layout/weekday_picker.xml | 124 +++++++++++++----- core/src/main/res/values/colors.xml | 7 +- 8 files changed, 114 insertions(+), 48 deletions(-) create mode 100644 core/src/main/res/color/day_selection_background.xml delete mode 100644 core/src/main/res/color/weekday_background.xml delete mode 100644 core/src/main/res/color/weekend_background.xml create mode 100644 core/src/main/res/drawable/weekend_circle_brackground.xml diff --git a/core/src/main/java/info/nightscout/androidaps/utils/ui/WeekdayPicker.kt b/core/src/main/java/info/nightscout/androidaps/utils/ui/WeekdayPicker.kt index 0ac104a070..07af86879f 100644 --- a/core/src/main/java/info/nightscout/androidaps/utils/ui/WeekdayPicker.kt +++ b/core/src/main/java/info/nightscout/androidaps/utils/ui/WeekdayPicker.kt @@ -6,13 +6,14 @@ import android.view.LayoutInflater import android.widget.Checkable import android.widget.LinearLayout import androidx.appcompat.widget.AppCompatCheckedTextView +import androidx.constraintlayout.widget.ConstraintLayout import info.nightscout.androidaps.core.databinding.WeekdayPickerBinding import info.nightscout.androidaps.utils.extensions.toVisibility import java.util.* class WeekdayPicker @JvmOverloads constructor( context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0 -) : LinearLayout(context, attrs, defStyleAttr) { +) : ConstraintLayout(context, attrs, defStyleAttr) { private var changeListener: ((Int, Boolean) -> Unit)? = null diff --git a/core/src/main/res/color/day_selection_background.xml b/core/src/main/res/color/day_selection_background.xml new file mode 100644 index 0000000000..6dd68ef826 --- /dev/null +++ b/core/src/main/res/color/day_selection_background.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/core/src/main/res/color/weekday_background.xml b/core/src/main/res/color/weekday_background.xml deleted file mode 100644 index b345f818d2..0000000000 --- a/core/src/main/res/color/weekday_background.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/core/src/main/res/color/weekend_background.xml b/core/src/main/res/color/weekend_background.xml deleted file mode 100644 index 1de73d0e17..0000000000 --- a/core/src/main/res/color/weekend_background.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/core/src/main/res/drawable/weekday_circle_brackground.xml b/core/src/main/res/drawable/weekday_circle_brackground.xml index 861dda73c2..df71b0310e 100644 --- a/core/src/main/res/drawable/weekday_circle_brackground.xml +++ b/core/src/main/res/drawable/weekday_circle_brackground.xml @@ -1,7 +1,7 @@ - + + android:width="4dp" + android:color="@color/weekdayOutline"/> \ No newline at end of file diff --git a/core/src/main/res/drawable/weekend_circle_brackground.xml b/core/src/main/res/drawable/weekend_circle_brackground.xml new file mode 100644 index 0000000000..658780df37 --- /dev/null +++ b/core/src/main/res/drawable/weekend_circle_brackground.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/core/src/main/res/layout/weekday_picker.xml b/core/src/main/res/layout/weekday_picker.xml index 82acbb829b..db8219f583 100644 --- a/core/src/main/res/layout/weekday_picker.xml +++ b/core/src/main/res/layout/weekday_picker.xml @@ -1,74 +1,138 @@ - + android:layout_height="wrap_content"> + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintEnd_toStartOf="@+id/weekdayPickerMonday" + app:layout_constraintStart_toStartOf="parent" /> + android:gravity="center" + android:textAlignment="gravity" + android:padding="8dp" + android:layout_margin="2dp" + app:layout_constraintDimensionRatio="H,1:1" + app:autoSizeTextType="uniform" + android:text="@string/monday_short" + app:layout_constraintEnd_toStartOf="@+id/weekdayPickerTuesday" + app:layout_constraintStart_toEndOf="@+id/weekdayPickerSundayStart" + app:layout_constraintTop_toTopOf="parent" /> + app:layout_constraintBaseline_toBaselineOf="@+id/weekdayPickerWednesday" + app:layout_constraintEnd_toStartOf="@+id/weekdayPickerWednesday" + app:layout_constraintStart_toEndOf="@+id/weekdayPickerMonday" /> + app:layout_constraintEnd_toStartOf="@+id/weekdayPickerThursday" + app:layout_constraintStart_toEndOf="@+id/weekdayPickerTuesday" + app:layout_constraintTop_toTopOf="parent" /> + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintEnd_toStartOf="@+id/weekdayPickerFriday" + app:layout_constraintStart_toEndOf="@+id/weekdayPickerWednesday" /> + app:layout_constraintEnd_toStartOf="@+id/weekdayPickerSaturday" + app:layout_constraintStart_toEndOf="@+id/weekdayPickerThursday" + app:layout_constraintTop_toTopOf="parent" /> + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintEnd_toStartOf="@+id/weekdayPickerSundayEnd" + app:layout_constraintStart_toEndOf="@+id/weekdayPickerFriday" /> + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toEndOf="@+id/weekdayPickerSaturday" + app:layout_constraintTop_toTopOf="parent" /> - \ No newline at end of file + \ No newline at end of file diff --git a/core/src/main/res/values/colors.xml b/core/src/main/res/values/colors.xml index 6bd15fb852..a533a5c3aa 100644 --- a/core/src/main/res/values/colors.xml +++ b/core/src/main/res/values/colors.xml @@ -41,10 +41,9 @@ #00d2d2 #ffffff - #8000FF00 - #1000FF00 - #800000FF - #100000FF + #D000FF00 + #1ea3e5 + #1e88e5 #FF8C00 From 7c8caa659b4662b676524a216eadd56fcdbae96e Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Sat, 13 Feb 2021 19:19:14 +0100 Subject: [PATCH 3/4] remove crashing library --- app/build.gradle | 3 --- app/libs/weekdaysselector-1.1.1.aar | Bin 17376 -> 0 bytes 2 files changed, 3 deletions(-) delete mode 100644 app/libs/weekdaysselector-1.1.1.aar diff --git a/app/build.gradle b/app/build.gradle index 5df54d7711..45e91a54d6 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -241,9 +241,6 @@ dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') - // https://github.com/DavidProdinger/Weekdays-Selector (used outdated 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1') - implementation(name: 'weekdaysselector-1.1.1', ext: 'aar') - testImplementation "junit:junit:$junit_version" testImplementation 'org.json:json:20201115' testImplementation "org.mockito:mockito-core:${mockitoVersion}" diff --git a/app/libs/weekdaysselector-1.1.1.aar b/app/libs/weekdaysselector-1.1.1.aar deleted file mode 100644 index 214a429e3ab71fb2118cfd13579ed882ad6ef9a5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 17376 zcmZ^~V~j3Lur)fy9^1BU+qP}nwr$(CXP&WbduES~J-F}5cmJH+?{-r4qqC}$>Xr0L zI<*vKK*9b10YO0l0RagCNmO@FPeK3z0h0m&f&aIoOz-OHny0;MpUa8bzh99FIWfv; zwRK~LV^<@2S=|%WUZ+ko4T|3gVQVUzd}+P!m%wyD0Gp|63NpSQk>K|e3uopW5jL2S zM`%R@W<<4lWAHklxJp>Iao9}XNW*>foC~wp3|rQF0@Rl>7%$^Jh-qD4Ijb+ny@kIV>NWWwxE zvjvf|F_2V^q#pnk?hTSUs7n5X&p+;iTv?D`i^xb9WQMIm%RWcNY4az_%8WTQbUZ3VGfMypPPqbb|7^@630x`QIF{#F3$88`xTJw0 zu}%+eR!AM6(cSj01*<S(M>=|Q^F)*x|}5(nfH0yTW+ymC5QH_ zBzXi-xXfe>+2lee@uLXKpaN=LLSW@*a6R4FsbzZ_?P*M`C$Ge$F$!SS@e_&GBdEK% zk=b^!w*+5eR?DgwQ5o~>Wg#vnlSIqV0CD;4V)8z*k6;U0Rfxcsa%K5{i_{EMgBf0e zNFBwu&EdgT<yCf7<4q$1=6euR}X$S{+f(llHX)y7|t*~H^6F#Vc(!RL83(|P%}p#>*7Q(LCeOB)Hp zg8o8s!-XBhYKV46Z@~!pZIfYRxE=-bb`i6A{qQOGEAlA2AIW;Fw(ceAO&80NuG!ITn% ztsNO+kw(R#lQ7y?R$Pp5R`;2Kn`8C5R=-95D504jv>9V*FF|~g0Ga~t*8ct+ zKoK(ZyfwRmtDA)i6hB|+d25naCko%<4+gf9kH@(>inPTW*F~Xyf1*x(BO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Sep 17 00:00:00 2001 From: AdrianLxM Date: Sat, 13 Feb 2021 19:40:27 +0100 Subject: [PATCH 4/4] cleanups of new weekday selector --- .../automation/elements/InputWeekDay.kt | 2 - .../androidaps/utils/ui/WeekdayPicker.kt | 39 +++++---- core/src/main/res/layout/weekday_picker.xml | 81 +++++++++---------- 3 files changed, 59 insertions(+), 63 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputWeekDay.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputWeekDay.kt index dda616de14..53733acfc8 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputWeekDay.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputWeekDay.kt @@ -20,7 +20,6 @@ class InputWeekDay(injector: HasAndroidInjector) : Element(injector) { get() = shortNames[ordinal] companion object { - private val calendarInts = intArrayOf( Calendar.MONDAY, Calendar.TUESDAY, @@ -82,6 +81,5 @@ class InputWeekDay(injector: HasAndroidInjector) : Element(injector) { setOnWeekdaysChangeListener { i: Int, selected: Boolean -> set(DayOfWeek.fromCalendarInt(i), selected) } root.addView(this) } - // TODO: remove library and dependency statement } } diff --git a/core/src/main/java/info/nightscout/androidaps/utils/ui/WeekdayPicker.kt b/core/src/main/java/info/nightscout/androidaps/utils/ui/WeekdayPicker.kt index 07af86879f..e3352ec94d 100644 --- a/core/src/main/java/info/nightscout/androidaps/utils/ui/WeekdayPicker.kt +++ b/core/src/main/java/info/nightscout/androidaps/utils/ui/WeekdayPicker.kt @@ -4,7 +4,6 @@ import android.content.Context import android.util.AttributeSet import android.view.LayoutInflater import android.widget.Checkable -import android.widget.LinearLayout import androidx.appcompat.widget.AppCompatCheckedTextView import androidx.constraintlayout.widget.ConstraintLayout import info.nightscout.androidaps.core.databinding.WeekdayPickerBinding @@ -33,33 +32,33 @@ class WeekdayPicker @JvmOverloads constructor( } } - fun setSelectedDays(list: List) { - binding.weekdayPickerSundayStart.isChecked = list.contains(Calendar.SUNDAY) - binding.weekdayPickerSundayEnd.isChecked = list.contains(Calendar.SUNDAY) - binding.weekdayPickerMonday.isChecked = list.contains(Calendar.MONDAY) - binding.weekdayPickerTuesday.isChecked = list.contains(Calendar.TUESDAY) - binding.weekdayPickerWednesday.isChecked = list.contains(Calendar.WEDNESDAY) - binding.weekdayPickerThursday.isChecked = list.contains(Calendar.THURSDAY) - binding.weekdayPickerFriday.isChecked = list.contains(Calendar.FRIDAY) - binding.weekdayPickerSaturday.isChecked = list.contains(Calendar.SATURDAY) + fun setSelectedDays(list: List) = with(binding) { + weekdayPickerSundayStart.isChecked = list.contains(Calendar.SUNDAY) + weekdayPickerSundayEnd.isChecked = list.contains(Calendar.SUNDAY) + weekdayPickerMonday.isChecked = list.contains(Calendar.MONDAY) + weekdayPickerTuesday.isChecked = list.contains(Calendar.TUESDAY) + weekdayPickerWednesday.isChecked = list.contains(Calendar.WEDNESDAY) + weekdayPickerThursday.isChecked = list.contains(Calendar.THURSDAY) + weekdayPickerFriday.isChecked = list.contains(Calendar.FRIDAY) + weekdayPickerSaturday.isChecked = list.contains(Calendar.SATURDAY) } - private fun setupClickListeners() { - binding.weekdayPickerSundayStart.setupCallbackFor(Calendar.SUNDAY) - binding.weekdayPickerSundayEnd.setupCallbackFor(Calendar.SUNDAY) - binding.weekdayPickerMonday.setupCallbackFor(Calendar.MONDAY) - binding.weekdayPickerTuesday.setupCallbackFor(Calendar.TUESDAY) - binding.weekdayPickerWednesday.setupCallbackFor(Calendar.WEDNESDAY) - binding.weekdayPickerThursday.setupCallbackFor(Calendar.THURSDAY) - binding.weekdayPickerFriday.setupCallbackFor(Calendar.FRIDAY) - binding.weekdayPickerSaturday.setupCallbackFor(Calendar.SATURDAY) + private fun setupClickListeners() = with(binding) { + weekdayPickerSundayStart.setupCallbackFor(Calendar.SUNDAY) + weekdayPickerSundayEnd.setupCallbackFor(Calendar.SUNDAY) + weekdayPickerMonday.setupCallbackFor(Calendar.MONDAY) + weekdayPickerTuesday.setupCallbackFor(Calendar.TUESDAY) + weekdayPickerWednesday.setupCallbackFor(Calendar.WEDNESDAY) + weekdayPickerThursday.setupCallbackFor(Calendar.THURSDAY) + weekdayPickerFriday.setupCallbackFor(Calendar.FRIDAY) + weekdayPickerSaturday.setupCallbackFor(Calendar.SATURDAY) } fun setOnWeekdaysChangeListener(changeListener: (Int, Boolean) -> Unit) { this.changeListener = changeListener } - private fun AppCompatCheckedTextView.setupCallbackFor(day: Int) = setOnClickListener{ + private fun AppCompatCheckedTextView.setupCallbackFor(day: Int) = setOnClickListener { val checkable = it as Checkable val checked = checkable.isChecked checkable.isChecked = !checked diff --git a/core/src/main/res/layout/weekday_picker.xml b/core/src/main/res/layout/weekday_picker.xml index db8219f583..f20fec423d 100644 --- a/core/src/main/res/layout/weekday_picker.xml +++ b/core/src/main/res/layout/weekday_picker.xml @@ -1,40 +1,39 @@ + android:layout_height="wrap_content" + android:padding="2dp"> + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" /> @@ -43,15 +42,15 @@ android:id="@+id/weekdayPickerTuesday" android:layout_width="0dp" android:layout_height="0dp" + android:layout_margin="2dp" android:background="@drawable/weekday_circle_brackground" android:gravity="center" - android:textAlignment="gravity" android:padding="8dp" - android:layout_margin="2dp" - app:layout_constraintDimensionRatio="H,1:1" - app:autoSizeTextType="uniform" android:text="@string/tuesday_short" + android:textAlignment="gravity" + app:autoSizeTextType="uniform" app:layout_constraintBaseline_toBaselineOf="@+id/weekdayPickerWednesday" + app:layout_constraintDimensionRatio="H,1:1" app:layout_constraintEnd_toStartOf="@+id/weekdayPickerWednesday" app:layout_constraintStart_toEndOf="@+id/weekdayPickerMonday" /> @@ -59,14 +58,14 @@ android:id="@+id/weekdayPickerWednesday" android:layout_width="0dp" android:layout_height="0dp" + android:layout_margin="2dp" android:background="@drawable/weekday_circle_brackground" android:gravity="center" - android:textAlignment="gravity" android:padding="8dp" - android:layout_margin="2dp" - app:layout_constraintDimensionRatio="H,1:1" - app:autoSizeTextType="uniform" android:text="@string/wednesday_short" + android:textAlignment="gravity" + app:autoSizeTextType="uniform" + app:layout_constraintDimensionRatio="H,1:1" app:layout_constraintEnd_toStartOf="@+id/weekdayPickerThursday" app:layout_constraintStart_toEndOf="@+id/weekdayPickerTuesday" app:layout_constraintTop_toTopOf="parent" /> @@ -75,30 +74,30 @@ android:id="@+id/weekdayPickerThursday" android:layout_width="0dp" android:layout_height="0dp" + android:layout_margin="2dp" android:background="@drawable/weekday_circle_brackground" android:gravity="center" - android:textAlignment="gravity" android:padding="8dp" - android:layout_margin="2dp" - app:layout_constraintDimensionRatio="H,1:1" - app:autoSizeTextType="uniform" android:text="@string/thursday_short" - app:layout_constraintTop_toTopOf="parent" + android:textAlignment="gravity" + app:autoSizeTextType="uniform" + app:layout_constraintDimensionRatio="H,1:1" app:layout_constraintEnd_toStartOf="@+id/weekdayPickerFriday" - app:layout_constraintStart_toEndOf="@+id/weekdayPickerWednesday" /> + app:layout_constraintStart_toEndOf="@+id/weekdayPickerWednesday" + app:layout_constraintTop_toTopOf="parent" /> @@ -107,30 +106,30 @@ android:id="@+id/weekdayPickerSaturday" android:layout_width="0dp" android:layout_height="0dp" + android:layout_margin="2dp" android:background="@drawable/weekend_circle_brackground" android:gravity="center" - android:textAlignment="gravity" android:padding="8dp" - android:layout_margin="2dp" - app:layout_constraintDimensionRatio="H,1:1" - app:autoSizeTextType="uniform" android:text="@string/saturday_short" - app:layout_constraintTop_toTopOf="parent" + android:textAlignment="gravity" + app:autoSizeTextType="uniform" + app:layout_constraintDimensionRatio="H,1:1" app:layout_constraintEnd_toStartOf="@+id/weekdayPickerSundayEnd" - app:layout_constraintStart_toEndOf="@+id/weekdayPickerFriday" /> + app:layout_constraintStart_toEndOf="@+id/weekdayPickerFriday" + app:layout_constraintTop_toTopOf="parent" />