Highlighted course is now highlighted with the primary colour, 50% translucent

This commit is contained in:
denizk0461
2023-04-20 14:30:48 +02:00
parent b5f5e06b7f
commit 07a2902367
9 changed files with 37 additions and 14 deletions
@@ -1,5 +1,6 @@
package com.denizk0461.studip.adapter package com.denizk0461.studip.adapter
import android.content.res.ColorStateList
import android.util.TypedValue import android.util.TypedValue
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.ViewGroup import android.view.ViewGroup
@@ -39,20 +40,29 @@ class StudIPEventItemAdapter(
holder.binding.textRoom.text = currentItem.room holder.binding.textRoom.text = currentItem.room
holder.binding.textTimeslot.text = currentItem.timeslot() holder.binding.textTimeslot.text = currentItem.timeslot()
val colorPrimary = TypedValue() val colorPrimaryTranslucent = TypedValue()
val colorTextHint = TypedValue() val colorCardBackground = TypedValue()
val colorTextHintLighter = TypedValue()
val theme = holder.binding.root.context.theme val theme = holder.binding.root.context.theme
theme.resolveAttribute(R.attr.colorPrimary, colorPrimary, true)
theme.resolveAttribute(R.attr.colorTextHintLighter, colorTextHint, true) theme.resolveAttribute(R.attr.colorPrimaryTranslucent, colorPrimaryTranslucent, true)
theme.resolveAttribute(R.attr.colorCardBackground, colorCardBackground, true)
theme.resolveAttribute(R.attr.colorTextHintLighter, colorTextHintLighter, true)
if (!isAnyCourseHighlighted && currentItem.isCurrentCourse(currentCalendar)) { // highlight if (!isAnyCourseHighlighted && currentItem.isCurrentCourse(currentCalendar)) { // highlight
isAnyCourseHighlighted = true isAnyCourseHighlighted = true
holder.binding.cardBackground.strokeColor = colorPrimary.data holder.binding.cardBackground.apply {
holder.binding.cardBackground.strokeWidth = 6 // TODO replace this with proper float -> dp conversion backgroundTintList = ColorStateList.valueOf(colorPrimaryTranslucent.data)//R.attr.colorPrimaryTranslucent)
strokeColor = context.getColor(android.R.color.transparent)
}//colorPrimary.data
// holder.binding.cardBackground.strokeWidth = 6 // TODO replace this with proper float -> dp conversion
// R.color.list_card_selected) // R.color.list_card_selected)
} else { // un-highlight } else { // un-highlight
holder.binding.cardBackground.strokeColor = colorTextHint.data holder.binding.cardBackground.apply {
holder.binding.cardBackground.strokeWidth = 3 // this should (?) be 1dp backgroundTintList = ColorStateList.valueOf(colorCardBackground.data)//context.getColor(R.attr.colorCardBackground))
strokeColor = colorTextHintLighter.data
}
// holder.binding.cardBackground.strokeWidth = 3 // this should (?) be 1dp
} }
holder.binding.cardBackground.setOnClickListener { holder.binding.cardBackground.setOnClickListener {
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="?attr/colorCardBackground"/>
</selector>
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="?attr/colorPrimaryTranslucent"/>
</selector>
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:color="?attr/colorPrimary" /> <item android:state_checked="true" android:color="?attr/colorPrimaryTranslucent" />
<item android:color="?attr/colorBackground" /> <item android:color="?attr/colorBackground" />
</selector> </selector>
+1 -1
View File
@@ -11,7 +11,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
style="@style/Widget.Material3.CardView.Outlined" style="@style/Widget.Material3.CardView.Outlined"
android:backgroundTint="?attr/colorCardBackground"> android:backgroundTint="@color/card_background_default">
<androidx.appcompat.widget.LinearLayoutCompat <androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent" android:layout_width="match_parent"
+4 -3
View File
@@ -3,6 +3,7 @@
<style name="Base.Theme.StudIPTimetable" parent="Theme.Material3.DayNight.NoActionBar"> <style name="Base.Theme.StudIPTimetable" parent="Theme.Material3.DayNight.NoActionBar">
<item name="colorPrimary">@color/primaryNight</item> <item name="colorPrimary">@color/primaryNight</item>
<item name="colorPrimaryTranslucent">@color/primaryNightTranslucent</item>
<item name="rippleColor">@color/primaryNight</item> <item name="rippleColor">@color/primaryNight</item>
<item name="colorOnPrimary">@color/colorTextNight</item> <item name="colorOnPrimary">@color/colorTextNight</item>
@@ -21,9 +22,9 @@
<item name="colorNavHighlight">@color/highlightNight</item> <item name="colorNavHighlight">@color/highlightNight</item>
</style> </style>
<style name="NavigationViewItemIndicator" parent="Widget.Material3.BottomNavigationView.ActiveIndicator"> <!-- <style name="NavigationViewItemIndicator" parent="Widget.Material3.BottomNavigationView.ActiveIndicator">-->
<item name="android:color">@color/primaryNight</item> <!-- <item name="android:color">@color/primaryNight</item>-->
</style> <!-- </style>-->
<style name="SelectableItemTheme"> <style name="SelectableItemTheme">
<item name="colorControlHighlight">@color/primaryNight</item> <item name="colorControlHighlight">@color/primaryNight</item>
+1
View File
@@ -3,6 +3,7 @@
<attr name="colorNavHighlight" format="color" /> <attr name="colorNavHighlight" format="color" />
<attr name="colorPrimaryOnContrast" format="color" /> <attr name="colorPrimaryOnContrast" format="color" />
<attr name="colorPrimary" format="color" /> <attr name="colorPrimary" format="color" />
<attr name="colorPrimaryTranslucent" format="color" />
<attr name="colorOnPrimary" format="color" /> <attr name="colorOnPrimary" format="color" />
<attr name="colorText" format="color" /> <attr name="colorText" format="color" />
<attr name="colorTextHint" format="color" /> <attr name="colorTextHint" format="color" />
+2
View File
@@ -6,7 +6,9 @@
<!-- colours i defined --> <!-- colours i defined -->
<color name="primaryDay">#B2665A</color> <color name="primaryDay">#B2665A</color>
<color name="primaryDayTranslucent">#80B2665A</color>
<color name="primaryNight">#995348</color> <color name="primaryNight">#995348</color>
<color name="primaryNightTranslucent">#80995348</color>
<color name="highlightDay">#871D1E</color> <color name="highlightDay">#871D1E</color>
<color name="highlightNight">#CB9890</color> <color name="highlightNight">#CB9890</color>
+2 -1
View File
@@ -4,6 +4,7 @@
<!-- <item name="fontFamily">@font/lato_regular</item>--> <!-- <item name="fontFamily">@font/lato_regular</item>-->
<item name="colorPrimary">@color/primaryDay</item> <item name="colorPrimary">@color/primaryDay</item>
<item name="colorPrimaryTranslucent">@color/primaryDayTranslucent</item>
<item name="rippleColor">@color/primaryDay</item> <item name="rippleColor">@color/primaryDay</item>
<item name="colorOnPrimary">@color/colorBackgroundDay</item> <item name="colorOnPrimary">@color/colorBackgroundDay</item>
@@ -31,7 +32,7 @@
</style> </style>
<style name="NavigationViewItemIndicator" parent="Widget.Material3.BottomNavigationView.ActiveIndicator"> <style name="NavigationViewItemIndicator" parent="Widget.Material3.BottomNavigationView.ActiveIndicator">
<item name="android:color">@color/primaryDay</item> <item name="android:color">@color/primaryDayTranslucent</item>
</style> </style>
<style name="SelectableItemTheme"> <style name="SelectableItemTheme">