Archived
Highlighted course is now highlighted with the primary colour, 50% translucent
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.denizk0461.studip.adapter
|
||||
|
||||
import android.content.res.ColorStateList
|
||||
import android.util.TypedValue
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
@@ -39,20 +40,29 @@ class StudIPEventItemAdapter(
|
||||
holder.binding.textRoom.text = currentItem.room
|
||||
holder.binding.textTimeslot.text = currentItem.timeslot()
|
||||
|
||||
val colorPrimary = TypedValue()
|
||||
val colorTextHint = TypedValue()
|
||||
val colorPrimaryTranslucent = TypedValue()
|
||||
val colorCardBackground = TypedValue()
|
||||
val colorTextHintLighter = TypedValue()
|
||||
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
|
||||
isAnyCourseHighlighted = true
|
||||
holder.binding.cardBackground.strokeColor = colorPrimary.data
|
||||
holder.binding.cardBackground.strokeWidth = 6 // TODO replace this with proper float -> dp conversion
|
||||
holder.binding.cardBackground.apply {
|
||||
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)
|
||||
} else { // un-highlight
|
||||
holder.binding.cardBackground.strokeColor = colorTextHint.data
|
||||
holder.binding.cardBackground.strokeWidth = 3 // this should (?) be 1dp
|
||||
holder.binding.cardBackground.apply {
|
||||
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 {
|
||||
|
||||
@@ -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"?>
|
||||
<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" />
|
||||
</selector>
|
||||
@@ -11,7 +11,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/Widget.Material3.CardView.Outlined"
|
||||
android:backgroundTint="?attr/colorCardBackground">
|
||||
android:backgroundTint="@color/card_background_default">
|
||||
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
<style name="Base.Theme.StudIPTimetable" parent="Theme.Material3.DayNight.NoActionBar">
|
||||
|
||||
<item name="colorPrimary">@color/primaryNight</item>
|
||||
<item name="colorPrimaryTranslucent">@color/primaryNightTranslucent</item>
|
||||
<item name="rippleColor">@color/primaryNight</item>
|
||||
|
||||
<item name="colorOnPrimary">@color/colorTextNight</item>
|
||||
@@ -21,9 +22,9 @@
|
||||
<item name="colorNavHighlight">@color/highlightNight</item>
|
||||
</style>
|
||||
|
||||
<style name="NavigationViewItemIndicator" parent="Widget.Material3.BottomNavigationView.ActiveIndicator">
|
||||
<item name="android:color">@color/primaryNight</item>
|
||||
</style>
|
||||
<!-- <style name="NavigationViewItemIndicator" parent="Widget.Material3.BottomNavigationView.ActiveIndicator">-->
|
||||
<!-- <item name="android:color">@color/primaryNight</item>-->
|
||||
<!-- </style>-->
|
||||
|
||||
<style name="SelectableItemTheme">
|
||||
<item name="colorControlHighlight">@color/primaryNight</item>
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
<attr name="colorNavHighlight" format="color" />
|
||||
<attr name="colorPrimaryOnContrast" format="color" />
|
||||
<attr name="colorPrimary" format="color" />
|
||||
<attr name="colorPrimaryTranslucent" format="color" />
|
||||
<attr name="colorOnPrimary" format="color" />
|
||||
<attr name="colorText" format="color" />
|
||||
<attr name="colorTextHint" format="color" />
|
||||
|
||||
@@ -6,7 +6,9 @@
|
||||
|
||||
<!-- colours i defined -->
|
||||
<color name="primaryDay">#B2665A</color>
|
||||
<color name="primaryDayTranslucent">#80B2665A</color>
|
||||
<color name="primaryNight">#995348</color>
|
||||
<color name="primaryNightTranslucent">#80995348</color>
|
||||
|
||||
<color name="highlightDay">#871D1E</color>
|
||||
<color name="highlightNight">#CB9890</color>
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
<!-- <item name="fontFamily">@font/lato_regular</item>-->
|
||||
|
||||
<item name="colorPrimary">@color/primaryDay</item>
|
||||
<item name="colorPrimaryTranslucent">@color/primaryDayTranslucent</item>
|
||||
<item name="rippleColor">@color/primaryDay</item>
|
||||
|
||||
<item name="colorOnPrimary">@color/colorBackgroundDay</item>
|
||||
@@ -31,7 +32,7 @@
|
||||
</style>
|
||||
|
||||
<style name="NavigationViewItemIndicator" parent="Widget.Material3.BottomNavigationView.ActiveIndicator">
|
||||
<item name="android:color">@color/primaryDay</item>
|
||||
<item name="android:color">@color/primaryDayTranslucent</item>
|
||||
</style>
|
||||
|
||||
<style name="SelectableItemTheme">
|
||||
|
||||
Reference in New Issue
Block a user