Implemented licences dialogue in the settings; fully restored highlighting event functionality

This commit is contained in:
denizk0461
2023-04-26 10:21:16 +02:00
parent ced111d93d
commit d0819553bc
10 changed files with 72 additions and 19 deletions
@@ -73,22 +73,11 @@ class StudIPEventItemAdapter(
// Use parsed timeslot string as defined in StudIPEvent#timeslot()
holder.binding.textTimeslot.text = currentItem.timeslot()
// TODO highlighting functionality is currently not supported!
// Set up colours used for highlighting and un-highlighting an item.
// val colorPrimaryTranslucent = TypedValue()
// val colorCardBackground = TypedValue()
// val colorTextHintLighter = TypedValue()
// Resolve themed attributes to get the right values for day and night modes
// holder.binding.root.context.theme.apply {
// resolveAttribute(com.google.android.material.R.attr.colorSecondaryContainer, colorPrimaryTranslucent, true)
// resolveAttribute(R.attr.colorCardBackground, colorCardBackground, true)
// resolveAttribute(R.attr.colorTextHintLighter, colorTextHintLighter, true)
// }
// Get current theme
val theme = holder.binding.root.context.theme
/* Highlight the next upcoming course of the day if the day of the adapter matches the
/*
* Highlight the next upcoming course of the day if the day of the adapter matches the
* current day, and if no other course has been highlighted, to avoid double highlighting.
*/
if (!isAnyCourseHighlighted && currentItem.isCurrentCourse(currentCalendar)) {
@@ -102,6 +91,8 @@ class StudIPEventItemAdapter(
// Hide card stroke
strokeColor = context.getColor(android.R.color.transparent)
}
// Set the divider colour to the text colour
holder.binding.divider.dividerColor = theme.getThemedColor(com.denizk0461.studip.R.attr.colorText)
// Otherwise, apply colours to ensure that the item will not be highlighted
} else {
holder.binding.cardBackground.apply {
@@ -109,8 +100,10 @@ class StudIPEventItemAdapter(
backgroundTintList = ColorStateList.valueOf(theme.getThemedColor(R.attr.colorSurface))
// Set the card's stroke to its default colour
strokeColor = theme.getThemedColor(R.attr.colorOutlineVariant)
strokeColor = theme.getThemedColor(R.attr.colorOutline)
}
// Set the divider colour to its default value
holder.binding.divider.dividerColor = theme.getThemedColor(R.attr.colorOutlineVariant)
}
// Set up single click listener
@@ -2,7 +2,6 @@ package com.denizk0461.studip.fragment
import android.os.Bundle
import android.view.LayoutInflater
import android.view.MenuItem
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.widget.PopupMenu
@@ -59,7 +58,7 @@ class CanteenFragment : AppFragment(), CanteenOfferItemAdapter.OnClickListener {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
// TODO KDoc and finish
// Open the menu for the canteen picker button
binding.buttonCanteenPicker.setOnClickListener {
PopupMenu(binding.root.context, binding.buttonCanteenPicker).apply {
setOnMenuItemClickListener { item ->
@@ -76,8 +75,13 @@ class CanteenFragment : AppFragment(), CanteenOfferItemAdapter.OnClickListener {
R.id.mensa_hfk -> 9
else -> 0
}
// Set currently selected canteen to the button
// Set newly selected canteen to the button
binding.buttonCanteenPicker.text = getCurrentlySelectedCanteenName()
// Display to the user that the canteen plan will be refreshed
binding.swipeRefreshLayout.isRefreshing = true
// Refresh the canteen menu for the newly selected canteen
refresh()
true
}
@@ -86,6 +90,9 @@ class CanteenFragment : AppFragment(), CanteenOfferItemAdapter.OnClickListener {
}
}
// Set currently selected canteen to the button
binding.buttonCanteenPicker.text = getCurrentlySelectedCanteenName()
binding.buttonInfo.setOnClickListener {
openBottomSheet(
TextSheet(
@@ -94,6 +94,16 @@ class SettingsFragment : AppFragment() {
))
}
// Set click listener for showing licences dialogue
binding.buttonLicences.setOnClickListener {
openBottomSheet(
TextSheet(
getString(R.string.sheet_licences_header),
getString(R.string.sheet_licences_content),
)
)
}
// Set click listener for the app version button
binding.buttonAppVersion.setOnClickListener {
when (appVersionClick) {