weekday component working

This commit is contained in:
AdrianLxM 2021-02-13 19:10:12 +01:00
parent c7e261d0e6
commit ff6a8f30c1
8 changed files with 114 additions and 48 deletions

View file

@ -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

View file

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:color="@color/daySelected"/>
<item android:color="@android:color/transparent"/>
</selector>

View file

@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:color="@color/weekdaySelected"/>
<item android:color="@color/weekdayNotSelected"/>
</selector>

View file

@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:color="@color/weekendSelected"/>
<item android:color="@color/weekendNotSelected"/>
</selector>

View file

@ -1,7 +1,7 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="@color/weekdaySelected"/>
<solid android:color="@color/day_selection_background"/>
<stroke
android:width="2dp"
android:color="@color/weekday_background"/>
android:width="4dp"
android:color="@color/weekdayOutline"/>
</shape>

View file

@ -0,0 +1,7 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="@color/day_selection_background"/>
<stroke
android:width="4dp"
android:color="@color/weekendOutline"/>
</shape>

View file

@ -1,74 +1,138 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout 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"
android:id="@+id/linearLayout"
android:padding="2dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
android:layout_height="wrap_content">
<androidx.appcompat.widget.AppCompatCheckedTextView
android:id="@+id/weekdayPickerSundayStart"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_height="0dp"
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/sunday_short"
app:autoSizeTextType="uniform" />
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toStartOf="@+id/weekdayPickerMonday"
app:layout_constraintStart_toStartOf="parent" />
<androidx.appcompat.widget.AppCompatCheckedTextView
android:id="@+id/weekdayPickerMonday"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/monday_short"
android:gravity="center"
android:layout_height="0dp"
android:background="@drawable/weekday_circle_brackground"
app:autoSizeTextType="uniform" />
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" />
<androidx.appcompat.widget.AppCompatCheckedTextView
android:id="@+id/weekdayPickerTuesday"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_height="0dp"
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"
app:autoSizeTextType="uniform" />
app:layout_constraintBaseline_toBaselineOf="@+id/weekdayPickerWednesday"
app:layout_constraintEnd_toStartOf="@+id/weekdayPickerWednesday"
app:layout_constraintStart_toEndOf="@+id/weekdayPickerMonday" />
<androidx.appcompat.widget.AppCompatCheckedTextView
android:id="@+id/weekdayPickerWednesday"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_height="0dp"
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"
app:autoSizeTextType="uniform" />
app:layout_constraintEnd_toStartOf="@+id/weekdayPickerThursday"
app:layout_constraintStart_toEndOf="@+id/weekdayPickerTuesday"
app:layout_constraintTop_toTopOf="parent" />
<androidx.appcompat.widget.AppCompatCheckedTextView
android:id="@+id/weekdayPickerThursday"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_height="0dp"
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:autoSizeTextType="uniform" />
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toStartOf="@+id/weekdayPickerFriday"
app:layout_constraintStart_toEndOf="@+id/weekdayPickerWednesday" />
<androidx.appcompat.widget.AppCompatCheckedTextView
android:id="@+id/weekdayPickerFriday"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_height="0dp"
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/friday_short"
app:autoSizeTextType="uniform" />
app:layout_constraintEnd_toStartOf="@+id/weekdayPickerSaturday"
app:layout_constraintStart_toEndOf="@+id/weekdayPickerThursday"
app:layout_constraintTop_toTopOf="parent" />
<androidx.appcompat.widget.AppCompatCheckedTextView
android:id="@+id/weekdayPickerSaturday"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_height="0dp"
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:autoSizeTextType="uniform" />
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toStartOf="@+id/weekdayPickerSundayEnd"
app:layout_constraintStart_toEndOf="@+id/weekdayPickerFriday" />
<androidx.appcompat.widget.AppCompatCheckedTextView
android:id="@+id/weekdayPickerSundayEnd"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_height="0dp"
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/sunday_short"
app:autoSizeTextType="uniform" />
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/weekdayPickerSaturday"
app:layout_constraintTop_toTopOf="parent" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -41,10 +41,9 @@
<color name="zt">#00d2d2</color>
<color name="white">#ffffff</color>
<color name="weekdaySelected">#8000FF00</color>
<color name="weekdayNotSelected">#1000FF00</color>
<color name="weekendSelected">#800000FF</color>
<color name="weekendNotSelected">#100000FF</color>
<color name="daySelected">#D000FF00</color>
<color name="weekdayOutline">#1ea3e5</color>
<color name="weekendOutline">#1e88e5</color>
<!-- CareportalEvent-->
<color name="notificationAnnouncement">#FF8C00</color>