Archived
All sheets now have the ability to scroll; a custom selectable item background has been added to clickable views to get a custom coloured ripple effect on click
This commit is contained in:
@@ -26,6 +26,7 @@ class ImageActivity : AppCompatActivity() {
|
||||
binding.imageView.setImageResource(when (intent.extras?.getString("img") ?: "") {
|
||||
"bojack" -> { R.drawable.man }
|
||||
"garbage" -> { R.drawable.garbage }
|
||||
"bcells" -> { R.drawable.bcells }
|
||||
else -> { R.drawable.engineering }
|
||||
})
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.denizk0461.studip.adapter
|
||||
import android.content.res.ColorStateList
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import androidx.appcompat.content.res.AppCompatResources.getDrawable
|
||||
import androidx.recyclerview.widget.DiffUtil
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.denizk0461.studip.data.AppDiffUtilCallback
|
||||
@@ -88,33 +89,49 @@ class StudIPEventItemAdapter(
|
||||
|
||||
holder.binding.cardBackground.apply {
|
||||
// Set the card's background colour to a desaturated shade of the primary colour
|
||||
backgroundTintList = ColorStateList.valueOf(theme.getThemedColor(R.attr.colorSecondaryContainer))
|
||||
backgroundTintList =
|
||||
ColorStateList.valueOf(theme.getThemedColor(R.attr.colorSecondaryContainer))
|
||||
|
||||
// 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)
|
||||
holder.binding.divider.dividerColor =
|
||||
theme.getThemedColor(com.denizk0461.studip.R.attr.colorText)
|
||||
|
||||
// Set ripple colour
|
||||
holder.binding.linearLayout.background = getDrawable(
|
||||
holder.binding.root.context,
|
||||
com.denizk0461.studip.R.drawable.selectable_item_background_highlighted,
|
||||
)
|
||||
|
||||
// Otherwise, apply colours to ensure that the item will not be highlighted
|
||||
} else {
|
||||
holder.binding.cardBackground.apply {
|
||||
// Set the card's background colour to its default value
|
||||
backgroundTintList = ColorStateList.valueOf(theme.getThemedColor(R.attr.colorSurface))
|
||||
backgroundTintList =
|
||||
ColorStateList.valueOf(theme.getThemedColor(R.attr.colorSurface))
|
||||
|
||||
// Set the card's stroke to its default colour
|
||||
strokeColor = theme.getThemedColor(R.attr.colorOutline)
|
||||
}
|
||||
// Set the divider colour to its default value
|
||||
holder.binding.divider.dividerColor = theme.getThemedColor(R.attr.colorOutlineVariant)
|
||||
|
||||
// Set ripple colour
|
||||
holder.binding.linearLayout.background = getDrawable(
|
||||
holder.binding.root.context,
|
||||
com.denizk0461.studip.R.drawable.selectable_item_background,
|
||||
)
|
||||
}
|
||||
|
||||
// Set up single click listener
|
||||
holder.binding.cardBackground.setOnClickListener {
|
||||
holder.binding.linearLayout.setOnClickListener {
|
||||
onClickListener.onClick(currentItem)
|
||||
}
|
||||
|
||||
// Set up long press listener
|
||||
holder.binding.cardBackground.setOnLongClickListener {
|
||||
holder.binding.linearLayout.setOnLongClickListener {
|
||||
onClickListener.onLongClick(currentItem)
|
||||
}
|
||||
}
|
||||
@@ -151,7 +168,9 @@ class StudIPEventItemAdapter(
|
||||
*/
|
||||
private fun StudIPEvent.isCurrentCourse(calendar: Calendar): Boolean =
|
||||
(calendar.get(Calendar.DAY_OF_WEEK) == this.day.toCalendarDay()) &&
|
||||
((calendar.get(Calendar.MINUTE) + calendar.get(Calendar.HOUR_OF_DAY) * 60) < this.timeslotEnd.parseToMinutes())
|
||||
((calendar.get(Calendar.MINUTE) + calendar.get(
|
||||
Calendar.HOUR_OF_DAY
|
||||
) * 60) < this.timeslotEnd.parseToMinutes())
|
||||
|
||||
/**
|
||||
* Converts a numeric value as defined in StudIPEvent.kt to a calendar day. Used to convert from
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.denizk0461.studip.sheet
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import com.denizk0461.studip.R
|
||||
import com.denizk0461.studip.data.showToast
|
||||
import com.denizk0461.studip.data.viewBinding
|
||||
import com.denizk0461.studip.databinding.SheetAllergenConfigBinding
|
||||
import com.denizk0461.studip.model.AllergenPreferences
|
||||
@@ -100,6 +101,9 @@ class AllergenConfigSheet(
|
||||
)
|
||||
}
|
||||
|
||||
// Tell the user that saving was successful
|
||||
showToast(context, getString(R.string.allergens_config_confirmation))
|
||||
|
||||
// Close the sheet
|
||||
dismiss()
|
||||
}
|
||||
|
||||
@@ -73,6 +73,13 @@ class DevCodeSheet(
|
||||
intent.putExtras(bundle)
|
||||
})
|
||||
}
|
||||
"QkNFTExT".d64 -> {
|
||||
startActivity(Intent(context, ImageActivity::class.java).also { intent ->
|
||||
val bundle = Bundle()
|
||||
bundle.putString("img", "bcells")
|
||||
intent.putExtras(bundle)
|
||||
})
|
||||
}
|
||||
"NEVENT" -> { // nuke events
|
||||
nukeEvents()
|
||||
showToast(context, "Nuked all events")
|
||||
@@ -97,7 +104,6 @@ class DevCodeSheet(
|
||||
nukeEverything()
|
||||
showToast(context, "Nuked everything")
|
||||
}
|
||||
"HACK()" -> showToast(context, "Hack attempt unsuccessful")
|
||||
else -> showToast(context, "Code is invalid")
|
||||
}
|
||||
dismiss()
|
||||
|
||||
Reference in New Issue
Block a user