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() // Use parsed timeslot string as defined in StudIPEvent#timeslot()
holder.binding.textTimeslot.text = currentItem.timeslot() holder.binding.textTimeslot.text = currentItem.timeslot()
// TODO highlighting functionality is currently not supported! // Get current theme
// 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)
// }
val theme = holder.binding.root.context.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. * current day, and if no other course has been highlighted, to avoid double highlighting.
*/ */
if (!isAnyCourseHighlighted && currentItem.isCurrentCourse(currentCalendar)) { if (!isAnyCourseHighlighted && currentItem.isCurrentCourse(currentCalendar)) {
@@ -102,6 +91,8 @@ class StudIPEventItemAdapter(
// Hide card stroke // Hide card stroke
strokeColor = context.getColor(android.R.color.transparent) 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 // Otherwise, apply colours to ensure that the item will not be highlighted
} else { } else {
holder.binding.cardBackground.apply { holder.binding.cardBackground.apply {
@@ -109,8 +100,10 @@ class StudIPEventItemAdapter(
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 // 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 // Set up single click listener
@@ -2,7 +2,6 @@ package com.denizk0461.studip.fragment
import android.os.Bundle import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.MenuItem
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.appcompat.widget.PopupMenu import androidx.appcompat.widget.PopupMenu
@@ -59,7 +58,7 @@ class CanteenFragment : AppFragment(), CanteenOfferItemAdapter.OnClickListener {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
// TODO KDoc and finish // Open the menu for the canteen picker button
binding.buttonCanteenPicker.setOnClickListener { binding.buttonCanteenPicker.setOnClickListener {
PopupMenu(binding.root.context, binding.buttonCanteenPicker).apply { PopupMenu(binding.root.context, binding.buttonCanteenPicker).apply {
setOnMenuItemClickListener { item -> setOnMenuItemClickListener { item ->
@@ -76,8 +75,13 @@ class CanteenFragment : AppFragment(), CanteenOfferItemAdapter.OnClickListener {
R.id.mensa_hfk -> 9 R.id.mensa_hfk -> 9
else -> 0 else -> 0
} }
// Set currently selected canteen to the button // Set newly selected canteen to the button
binding.buttonCanteenPicker.text = getCurrentlySelectedCanteenName() 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() refresh()
true true
} }
@@ -86,6 +90,9 @@ class CanteenFragment : AppFragment(), CanteenOfferItemAdapter.OnClickListener {
} }
} }
// Set currently selected canteen to the button
binding.buttonCanteenPicker.text = getCurrentlySelectedCanteenName()
binding.buttonInfo.setOnClickListener { binding.buttonInfo.setOnClickListener {
openBottomSheet( openBottomSheet(
TextSheet( 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 // Set click listener for the app version button
binding.buttonAppVersion.setOnClickListener { binding.buttonAppVersion.setOnClickListener {
when (appVersionClick) { when (appVersionClick) {
@@ -353,6 +353,34 @@
</androidx.appcompat.widget.LinearLayoutCompat> </androidx.appcompat.widget.LinearLayoutCompat>
<!-- Licences -->
<androidx.appcompat.widget.LinearLayoutCompat
android:id="@+id/button_licences"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:clickable="true"
android:focusable="true"
android:paddingHorizontal="16dp"
android:paddingVertical="8dp"
android:background="?android:attr/selectableItemBackground">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp"
android:fontFamily="@font/lato_bolditalic"
android:text="@string/settings_licences_title"/>
<TextView
android:id="@+id/licences_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp"
android:text="@string/settings_licences_subtitle"/>
</androidx.appcompat.widget.LinearLayoutCompat>
<!-- App version --> <!-- App version -->
<androidx.appcompat.widget.LinearLayoutCompat <androidx.appcompat.widget.LinearLayoutCompat
android:id="@+id/button_app_version" android:id="@+id/button_app_version"
+1
View File
@@ -26,6 +26,7 @@
android:fontFamily="@font/lato_bolditalic"/> android:fontFamily="@font/lato_bolditalic"/>
<com.google.android.material.divider.MaterialDivider <com.google.android.material.divider.MaterialDivider
android:id="@+id/divider"
style="@style/DividerTheme" style="@style/DividerTheme"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
+5
View File
@@ -19,6 +19,8 @@
<string name="sheet_schedule_update_lecturers_hint">Dozierende(r)</string> <string name="sheet_schedule_update_lecturers_hint">Dozierende(r)</string>
<string name="sheet_schedule_update_room_hint">Raum</string> <string name="sheet_schedule_update_room_hint">Raum</string>
<string name="sheet_licences_header">Lizenzen</string>
<string name="title_schedule">Dein Stundenplan</string> <string name="title_schedule">Dein Stundenplan</string>
<string name="title_food">Mensenangebote</string> <string name="title_food">Mensenangebote</string>
<string name="title_settings">App-Einstellungen</string> <string name="title_settings">App-Einstellungen</string>
@@ -128,6 +130,9 @@
<string name="settings_data_sheet_header">TL;DR: nein, aber Google könnte mir Bescheid geben, falls die App mal abstürzt.</string> <string name="settings_data_sheet_header">TL;DR: nein, aber Google könnte mir Bescheid geben, falls die App mal abstürzt.</string>
<string name="settings_data_sheet_content">Die App funktioniert standalone, was bedeutet, dass sie sich niemals mit einem Server verbindet, der mir gehört. Sie ist ein Web-Scraper, also ein Programm, welches eine Internetseite öffnet und dann all die Informationen dieser Webseite herunterlädt und analysiert. In diesem Fall sind es die Webseiten der Mensen und Cafeterien des Studierendenwerks Bremen (stw-bremen.de) sowie die Stud.IP-Seite (elearning.uni-bremen.de).\n\nDies funktioniert relativ einfach für die Essenspläne, da diese Pläne öffentlich zugänglich sind. Um jedoch Deinen persönlichen Stud.IP-Stundenplan herunterzuladen, braucht die App Zugriff auf diese Webseite während Dein Account eingeloggt ist. Dies erfolgt, indem die App Dich mit deinem Account einloggen lässt - dies geschieht, wenn Du den Knopf zum Aktualisieren des Plans drückst und die App Dir die Login-Seite zeigt - und Du dann den Knopf klickst, um den Inhalt, den HTML-Quellcode, herunterzuladen. Der HTML-Quellcode beinhält Informationen darüber, was auf einer Webseite angezeigt wird und wie es aussehen soll, aber er kann niemals persönliche Details beinhalten, wie zum Beispiel Passwörter oder andere Daten, die auf Deinem Gerät vorhanden sind.\n\nDer Quellcode wird dann lokal, also auf Deinem Gerät, zu den Karten verarbeitet, die Du dann in der App sehen kannst, ohne, dass jegliche Daten irgendwohin geschickt werden müssten.\n\nEinige Daten könnten jedoch dennoch nach außen geschickt werden. Diese App nutzt \"Crashlytics\" von Google. Dies ist ein Tool, welches Absturzreporte an Google-Server schickt, wenn in der App etwas schief läuft. Diese werden genutzt, um Probleme in der App zu lösen.\n\nDies ist jedoch gemäß europäischer Datenschutz-Grundverordnung Opt-In, was bedeutet, dass Du zustimmen musst, bevor Daten nach außen geschickt werden. Du wurdest danach gefragt, als Du die App zum ersten Mal gestartet hast, und du kannst jederzeit deine Meinung ändern, indem Du den Schalter hierfür in den Einstellungen umstellst. Solltest Du dich entscheiden, keine Daten verschicken zu lassen, wird auch nichts mit Google (und mir) geteilt.\n\nSolltest du dich versichern wollen, dass wirklich keine Daten an irgendwelche Server verschickt wird (abgesehen von den Absturzreports an Google), kannst Du jederzeit das Projekt erkunden, da es Open-Source und auf meinen GitHub-Profil öffentlich zugänglich ist:\nhttps://github.com/denizk0461/studip-timetable/\n\nSchreib mir ansonsten gerne eine E-Mail:\ndenizk0461+kyzil@gmail.com</string> <string name="settings_data_sheet_content">Die App funktioniert standalone, was bedeutet, dass sie sich niemals mit einem Server verbindet, der mir gehört. Sie ist ein Web-Scraper, also ein Programm, welches eine Internetseite öffnet und dann all die Informationen dieser Webseite herunterlädt und analysiert. In diesem Fall sind es die Webseiten der Mensen und Cafeterien des Studierendenwerks Bremen (stw-bremen.de) sowie die Stud.IP-Seite (elearning.uni-bremen.de).\n\nDies funktioniert relativ einfach für die Essenspläne, da diese Pläne öffentlich zugänglich sind. Um jedoch Deinen persönlichen Stud.IP-Stundenplan herunterzuladen, braucht die App Zugriff auf diese Webseite während Dein Account eingeloggt ist. Dies erfolgt, indem die App Dich mit deinem Account einloggen lässt - dies geschieht, wenn Du den Knopf zum Aktualisieren des Plans drückst und die App Dir die Login-Seite zeigt - und Du dann den Knopf klickst, um den Inhalt, den HTML-Quellcode, herunterzuladen. Der HTML-Quellcode beinhält Informationen darüber, was auf einer Webseite angezeigt wird und wie es aussehen soll, aber er kann niemals persönliche Details beinhalten, wie zum Beispiel Passwörter oder andere Daten, die auf Deinem Gerät vorhanden sind.\n\nDer Quellcode wird dann lokal, also auf Deinem Gerät, zu den Karten verarbeitet, die Du dann in der App sehen kannst, ohne, dass jegliche Daten irgendwohin geschickt werden müssten.\n\nEinige Daten könnten jedoch dennoch nach außen geschickt werden. Diese App nutzt \"Crashlytics\" von Google. Dies ist ein Tool, welches Absturzreporte an Google-Server schickt, wenn in der App etwas schief läuft. Diese werden genutzt, um Probleme in der App zu lösen.\n\nDies ist jedoch gemäß europäischer Datenschutz-Grundverordnung Opt-In, was bedeutet, dass Du zustimmen musst, bevor Daten nach außen geschickt werden. Du wurdest danach gefragt, als Du die App zum ersten Mal gestartet hast, und du kannst jederzeit deine Meinung ändern, indem Du den Schalter hierfür in den Einstellungen umstellst. Solltest Du dich entscheiden, keine Daten verschicken zu lassen, wird auch nichts mit Google (und mir) geteilt.\n\nSolltest du dich versichern wollen, dass wirklich keine Daten an irgendwelche Server verschickt wird (abgesehen von den Absturzreports an Google), kannst Du jederzeit das Projekt erkunden, da es Open-Source und auf meinen GitHub-Profil öffentlich zugänglich ist:\nhttps://github.com/denizk0461/studip-timetable/\n\nSchreib mir ansonsten gerne eine E-Mail:\ndenizk0461+kyzil@gmail.com</string>
<string name="settings_licences_title">Siehe Lizenzen</string>
<string name="settings_licences_subtitle">Ressourcen, die diese App möglich gemacht haben</string>
<string name="settings_app_version">App-Version</string> <string name="settings_app_version">App-Version</string>
<string name="with_love">mit ♡️ aus Bremen-Osterholz\von denizk0461 \\__*</string> <string name="with_love">mit ♡️ aus Bremen-Osterholz\von denizk0461 \\__*</string>
+1
View File
@@ -29,6 +29,7 @@
<item name="colorPrimaryInverse">@color/md_theme_dark_inversePrimary</item> <item name="colorPrimaryInverse">@color/md_theme_dark_inversePrimary</item>
<item name="android:textColor">@color/md_theme_dark_onSurfaceVariant</item> <item name="android:textColor">@color/md_theme_dark_onSurfaceVariant</item>
<item name="colorText">@color/md_theme_dark_onSurfaceVariant</item>
<item name="android:scrollbarThumbVertical">@color/md_theme_dark_onSurfaceVariant</item> <item name="android:scrollbarThumbVertical">@color/md_theme_dark_onSurfaceVariant</item>
<item name="colorOutlineVariant">@color/md_theme_dark_outlineVariant</item> <item name="colorOutlineVariant">@color/md_theme_dark_outlineVariant</item>
+2
View File
@@ -8,4 +8,6 @@
<attr name="colorOnErrorContainer" type="color"/> <attr name="colorOnErrorContainer" type="color"/>
<attr name="colorSecondaryContainer" type="color"/> <attr name="colorSecondaryContainer" type="color"/>
<attr name="colorOnSecondaryContainer" type="color"/> <attr name="colorOnSecondaryContainer" type="color"/>
<attr name="colorText" type="color"/>
<!-- <attr name="colorOutline" type="color"/>-->
</resources> </resources>
+6 -1
View File
@@ -20,6 +20,9 @@
<string name="sheet_schedule_update_room_hint">Room</string> <string name="sheet_schedule_update_room_hint">Room</string>
<string name="sheet_schedule_update_timeslot_middle" translatable="false"></string> <string name="sheet_schedule_update_timeslot_middle" translatable="false"></string>
<string name="sheet_licences_header">Licences</string>
<string name="sheet_licences_content" translatable="false">Android developer resources provided by Google.\nhttps://developer.android.com/\n\nCrash reporting provided by Google.\nhttps://firebase.google.com/products/crashlytics/\n\nDesign guidelines, icons, and colour palette provided by Google.\nhttps://m3.material.io/\n\nAdditional icons provided by Flaticon.\nhttps://www.flaticon.com/\n\nWeb scraping functionality provided by Jonathan Hedley.\nhttps://jhy.io/ | https://jsoup.org/</string>
<string name="title_schedule">Your Schedule</string> <string name="title_schedule">Your Schedule</string>
<string name="title_food">Canteen Offers</string> <string name="title_food">Canteen Offers</string>
<string name="title_settings">App Settings</string> <string name="title_settings">App Settings</string>
@@ -112,7 +115,7 @@
<string name="refresh_schedule_subtitle">This will clear any customisations!</string> <string name="refresh_schedule_subtitle">This will clear any customisations!</string>
<string name="settings_highlight_title">Highlight next course</string> <string name="settings_highlight_title">Highlight next course</string>
<string name="settings_highlight_subtitle">Only works properly if courses don\'t overlap!\nNOTE: Currently broken!</string> <string name="settings_highlight_subtitle">Only works properly if courses don\'t overlap!</string>
<string name="settings_quarter_title">Use academic quarter</string> <string name="settings_quarter_title">Use academic quarter</string>
<string name="settings_quarter_subtitle">Where applicable</string> <string name="settings_quarter_subtitle">Where applicable</string>
@@ -131,6 +134,8 @@
<string name="settings_data_sheet_header">TL;DR: no, but Google may let me know if the app crashes on your device.</string> <string name="settings_data_sheet_header">TL;DR: no, but Google may let me know if the app crashes on your device.</string>
<string name="settings_data_sheet_content">This app works standalone, which is to say, it doesn\'t ever connect to a server I own. Instead, it is a web scraper, which means that it opens a website and then downloads and analyses all the data from that website by itself. In this case, those websites are the canteen websites of the Studierendenwerk Bremen (stw-bremen.de) and the Stud.IP page (elearning.uni-bremen.de).\n\nThis works fairly easily for the canteen offers, since the plans are public and anyone can access them. However, to access your personal Stud.IP schedule, the app needs access to that website, with your account logged in. This is done by letting you log into the website by yourself (which happens when you click the button to refresh the schedule and the app opens the login page) and then clicking a button to download the content, the HTML source code, of the website. The HTML source code contains information about which elements are shown on the website and how they look, but it can never contain your personal details such as passwords, or any other sensitive data you may store on your device.\n\nThe HTML source is then processed locally on your device, which means that your device will handle converting the HTML source to the cards you will be shown in the app by itself, without needing to send any data anywhere.\n\nHowever, some data may still be sent outside of your device. This app uses \"Crashlytics\" by Google, which is a tool that sends crash reports to Google servers if something breaks. These are used to fix problems that occur in the app.\n\nThis, in compliance with the European General Data Protection Regulation, is of course opt-in, which means that you need to accept this before any data is sent outside of your device. You have been prompted for this when you first started the app, and you can always change your mind in the app settings by clicking the corresponding switch. Should you choose to not share crash data with Google (and me), no data will be sent outside of your device.\n\nShould you want to reassure yourself that no data is sent to any servers (outside of the crash reports from Google), feel free to explore the project, since it is open-source and documented on my GitHub profile:\nhttps://github.com/denizk0461/studip-timetable/\n\nYou\'re also welcome to send me an email:\ndenizk0461+kyzil@gmail.com</string> <string name="settings_data_sheet_content">This app works standalone, which is to say, it doesn\'t ever connect to a server I own. Instead, it is a web scraper, which means that it opens a website and then downloads and analyses all the data from that website by itself. In this case, those websites are the canteen websites of the Studierendenwerk Bremen (stw-bremen.de) and the Stud.IP page (elearning.uni-bremen.de).\n\nThis works fairly easily for the canteen offers, since the plans are public and anyone can access them. However, to access your personal Stud.IP schedule, the app needs access to that website, with your account logged in. This is done by letting you log into the website by yourself (which happens when you click the button to refresh the schedule and the app opens the login page) and then clicking a button to download the content, the HTML source code, of the website. The HTML source code contains information about which elements are shown on the website and how they look, but it can never contain your personal details such as passwords, or any other sensitive data you may store on your device.\n\nThe HTML source is then processed locally on your device, which means that your device will handle converting the HTML source to the cards you will be shown in the app by itself, without needing to send any data anywhere.\n\nHowever, some data may still be sent outside of your device. This app uses \"Crashlytics\" by Google, which is a tool that sends crash reports to Google servers if something breaks. These are used to fix problems that occur in the app.\n\nThis, in compliance with the European General Data Protection Regulation, is of course opt-in, which means that you need to accept this before any data is sent outside of your device. You have been prompted for this when you first started the app, and you can always change your mind in the app settings by clicking the corresponding switch. Should you choose to not share crash data with Google (and me), no data will be sent outside of your device.\n\nShould you want to reassure yourself that no data is sent to any servers (outside of the crash reports from Google), feel free to explore the project, since it is open-source and documented on my GitHub profile:\nhttps://github.com/denizk0461/studip-timetable/\n\nYou\'re also welcome to send me an email:\ndenizk0461+kyzil@gmail.com</string>
<string name="settings_licences_title">View licences</string>
<string name="settings_licences_subtitle">Resources that made this app possible</string>
<string name="settings_app_version">App Version</string> <string name="settings_app_version">App Version</string>
<string name="with_love">with ♡️ from Bremen-Osterholz\nmade by denizk0461 \\__*</string> <string name="with_love">with ♡️ from Bremen-Osterholz\nmade by denizk0461 \\__*</string>
+1
View File
@@ -29,6 +29,7 @@
<item name="colorPrimaryInverse">@color/md_theme_light_inversePrimary</item> <item name="colorPrimaryInverse">@color/md_theme_light_inversePrimary</item>
<item name="android:textColor">@color/md_theme_light_onSurfaceVariant</item> <item name="android:textColor">@color/md_theme_light_onSurfaceVariant</item>
<item name="colorText">@color/md_theme_light_onSurfaceVariant</item>
<item name="android:scrollbarThumbVertical">@color/md_theme_light_onSurfaceVariant</item> <item name="android:scrollbarThumbVertical">@color/md_theme_light_onSurfaceVariant</item>
<item name="colorOutlineVariant">@color/md_theme_light_outlineVariant</item> <item name="colorOutlineVariant">@color/md_theme_light_outlineVariant</item>