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:
denizk0461
2023-05-01 22:19:44 +02:00
parent b0631d323e
commit 5a9ab267aa
16 changed files with 236 additions and 160 deletions
@@ -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()
Binary file not shown.

After

Width:  |  Height:  |  Size: 353 KiB

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/selectable_item_ripple" />
</selector>
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/selectable_item_ripple_highlighted" />
</selector>
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<ripple
xmlns:android="http://schemas.android.com/apk/res/android"
android:color="?attr/colorSecondaryContainer"/>
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<ripple
xmlns:android="http://schemas.android.com/apk/res/android"
android:color="?attr/colorSecondary"/>
@@ -70,7 +70,7 @@
android:id="@+id/button_refresh_schedule"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground"
android:background="@drawable/selectable_item_background"
android:clickable="true"
android:focusable="true"
android:orientation="vertical"
@@ -174,7 +174,7 @@
android:id="@+id/button_allergens_config"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground"
android:background="@drawable/selectable_item_background"
android:clickable="true"
android:focusable="true"
android:orientation="vertical"
@@ -407,7 +407,7 @@
android:id="@+id/button_data_handling"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground"
android:background="@drawable/selectable_item_background"
android:clickable="true"
android:focusable="true"
android:orientation="vertical"
@@ -434,7 +434,7 @@
android:id="@+id/button_licences"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground"
android:background="@drawable/selectable_item_background"
android:clickable="true"
android:focusable="true"
android:orientation="vertical"
@@ -462,7 +462,7 @@
android:id="@+id/button_app_version"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground"
android:background="@drawable/selectable_item_background"
android:clickable="true"
android:focusable="true"
android:orientation="vertical"
@@ -6,7 +6,7 @@
android:orientation="horizontal"
android:clickable="true"
android:focusable="true"
android:background="?android:attr/selectableItemBackground"
android:background="@drawable/selectable_item_background"
android:paddingHorizontal="16dp"
android:paddingVertical="2dp">
+3
View File
@@ -14,9 +14,12 @@
style="@style/Widget.Material3.CardView.Outlined">
<androidx.appcompat.widget.LinearLayoutCompat
android:id="@+id/linear_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:clickable="true"
android:focusable="true"
android:padding="16dp">
<TextView
+18 -9
View File
@@ -5,7 +5,6 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="16dp"
android:paddingHorizontal="24dp"
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">
<com.google.android.material.bottomsheet.BottomSheetDragHandleView
@@ -19,7 +18,8 @@
android:layout_height="wrap_content"
android:textSize="22sp"
android:fontFamily="@font/lato_blackitalic"
android:layout_marginBottom="2dp"/>
android:layout_marginBottom="2dp"
android:paddingHorizontal="24dp"/>
<TextView
android:id="@+id/text_title"
@@ -27,12 +27,19 @@
android:layout_height="wrap_content"
android:textSize="22sp"
android:fontFamily="@font/lato_bolditalic"
android:layout_marginBottom="8dp"/>
android:layout_marginBottom="8dp"
android:paddingHorizontal="24dp"/>
<!-- <androidx.core.widget.NestedScrollView-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:scrollbars="vertical">-->
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical">
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingHorizontal="24dp">
<androidx.appcompat.widget.LinearLayoutCompat
android:id="@+id/container_preferences"
@@ -46,7 +53,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"/>
<!-- android:textSize="16sp"-->
<!-- android:textSize="16sp"-->
<TextView
android:id="@+id/text_price"
@@ -56,6 +63,8 @@
android:fontFamily="@font/lato_bolditalic"
android:layout_marginTop="4dp"/>
<!-- </androidx.core.widget.NestedScrollView>-->
</androidx.appcompat.widget.LinearLayoutCompat>
</androidx.core.widget.NestedScrollView>
</LinearLayout>
@@ -5,8 +5,6 @@
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:paddingBottom="16dp"
android:paddingHorizontal="24dp"
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">
<com.google.android.material.bottomsheet.BottomSheetDragHandleView
@@ -25,7 +23,8 @@
android:textSize="22sp"
android:fontFamily="@font/lato_blackitalic"
android:text="@string/sheet_schedule_update_header"
android:layout_gravity="start|center_vertical"/>
android:layout_gravity="start|center_vertical"
android:paddingHorizontal="24dp"/>
<com.google.android.material.button.MaterialButton
style="@style/Widget.Material3.Button.TextButton"
@@ -36,10 +35,23 @@
app:icon="@drawable/cross"
app:iconPadding="0dp"
android:layout_gravity="end|center_vertical"
app:iconTint="?attr/colorOnSurfaceVariant"/>
app:iconTint="?attr/colorOnSurfaceVariant"
android:paddingHorizontal="24dp"/>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical">
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="16dp"
android:paddingHorizontal="24dp">
<com.google.android.material.textfield.TextInputLayout
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
@@ -178,4 +190,8 @@
</androidx.appcompat.widget.LinearLayoutCompat>
</androidx.appcompat.widget.LinearLayoutCompat>
</androidx.core.widget.NestedScrollView>
</androidx.appcompat.widget.LinearLayoutCompat>
+4 -3
View File
@@ -130,13 +130,14 @@
<string name="refresh_schedule_title">Aktualisiere Deinen Stud.IP-Stundenplan</string>
<string name="refresh_schedule_subtitle">Dies wird alle Anpassungen löschen!</string>
<string name="settings_highlight_title">Markiere meinen nächsten Kurs</string>
<string name="settings_highlight_subtitle">Funktioniert nur wenn Kurse sich nicht überschneiden!</string>
<string name="settings_highlight_title">Markiere den nächsten Kurs</string>
<string name="settings_highlight_subtitle">Funktioniert nur, wenn Kurse sich nicht überschneiden!</string>
<string name="allergens_config_title">Verstecke Angebote mit bestimmten Allergenen</string>
<string name="allergens_config_subtitle">Angebote mit ausgeschlossenen Allergenen werden Dir nicht angezeigt</string>
<string name="allergens_config_header">Stelle ein, welche Allergene Du vermeiden möchtest</string>
<string name="allergens_config_header">Wähle, welche Allergene Du vermeiden möchtest</string>
<string name="allergens_config_content">Achtung: bitte verlasse Dich nicht vollständig auf diese Funktion. Stelle immer in der Mensa, die Du besuchst, sicher, dass die Stoffe, auf die Du allergisch reagierst, nicht in deren Angeboten vorhanden sind.</string>
<string name="allergens_config_confirmation">Deine Allergene wurden gespeichert.</string>
<string name="settings_allergens_title">Markiere Angebote mit Allergenen mit einem Stern*</string>
<string name="settings_allergens_subtitle">Wird auch für Zusatzstoffe genutzt</string>
+3 -2
View File
@@ -140,14 +140,15 @@
<string name="allergens_config_title">Hide offers containing certain allergens</string>
<string name="allergens_config_subtitle">Offers with excluded allergens won\'t be shown to you</string>
<string name="allergens_config_header">Set which allergens you\'d like to avoid</string>
<string name="allergens_config_header">Select which allergens you\'d like to avoid</string>
<string name="allergens_config_content">Note: please don\'t entirely rely on this. Always check the notices displayed at the canteen you\'re visiting to confirm substances you may be allergic against are not present in their offerings.</string>
<string name="allergens_config_confirmation">Your allergen settings have been saved.</string>
<string name="settings_allergens_title">Mark offers with allergens with a star*</string>
<string name="settings_allergens_subtitle">Also applies to additives</string>
<string name="settings_pref_colour_title">Colour dietary preferences</string>
<string name="settings_pref_colour_subtitle">This colours the icons similar to the website</string> <!-- TODO this text sucks, DE too -->
<string name="settings_pref_colour_subtitle">This colours the icons similar to how they look the website</string> <!-- TODO this text sucks, DE too -->
<string name="settings_launch_canteen_title">Show canteen plan on app launch</string>
<string name="settings_launch_canteen_subtitle">Otherwise your schedule will be shown at launch</string>