Archived
CanteenFragment.kt: replaced buttons for opening hours and canteen switch embedded in the app bar with floating action buttons; implemented a possible fix for the app crashing after refreshing the canteen plan. This may have been caused by accessing the view/context of the fragment to let the user know that the refresh succeeded or encountered an error. Reference will be null by the time the fragment is inactive, causing a NullPointerException
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
<vector android:height="24dp" android:tint="#000000"
|
||||
android:viewportHeight="24" android:viewportWidth="24"
|
||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="@android:color/white" android:pathData="M7.41,8.59L12,13.17l4.59,-4.58L18,10l-6,6 -6,-6 1.41,-1.41z"/>
|
||||
</vector>
|
||||
@@ -0,0 +1,6 @@
|
||||
<vector android:height="24dp" android:tint="#000000"
|
||||
android:viewportHeight="24" android:viewportWidth="24"
|
||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="@android:color/white" android:pathData="M11.99,2C6.47,2 2,6.48 2,12s4.47,10 9.99,10C17.52,22 22,17.52 22,12S17.52,2 11.99,2zM12,20c-4.42,0 -8,-3.58 -8,-8s3.58,-8 8,-8 8,3.58 8,8 -3.58,8 -8,8z"/>
|
||||
<path android:fillColor="@android:color/white" android:pathData="M12.5,7H11v6l5.25,3.15 0.75,-1.23 -4.5,-2.67z"/>
|
||||
</vector>
|
||||
@@ -0,0 +1,6 @@
|
||||
<vector android:height="24dp" android:tint="#000000"
|
||||
android:viewportHeight="24" android:viewportWidth="24"
|
||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="@android:color/white" android:pathData="M18,12l4,-4l-4,-4l0,3l-15,0l0,2l15,0z"/>
|
||||
<path android:fillColor="@android:color/white" android:pathData="M6,12l-4,4l4,4l0,-3l15,0l0,-2l-15,0z"/>
|
||||
</vector>
|
||||
@@ -1,6 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/snackbar_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
@@ -17,48 +18,21 @@
|
||||
android:orientation="vertical"
|
||||
app:layout_scrollFlags="scroll|exitUntilCollapsed">
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/button_canteen_picker"
|
||||
style="@style/Widget.Material3.Button.TextButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="18sp"
|
||||
android:layout_gravity="start"
|
||||
android:layout_marginStart="8dp"
|
||||
android:fontFamily="@font/lato_bolditalic"/>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
<TextView
|
||||
android:id="@+id/app_title_bar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="16dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/app_title_bar"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/title_food"
|
||||
android:textSize="32sp"
|
||||
android:fontFamily="@font/lato_bolditalic"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@id/button_info"/>
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
style="@style/Widget.Material3.Button.TextButton"
|
||||
android:id="@+id/button_info"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:minWidth="0dp"
|
||||
app:icon="@drawable/info"
|
||||
app:iconPadding="0dp"
|
||||
android:layout_gravity="center_vertical|end"
|
||||
app:iconTint="?attr/colorOnSurfaceVariant"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
android:text="@string/title_food"
|
||||
android:textSize="28sp"
|
||||
android:fontFamily="@font/lato_bolditalic"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginHorizontal="16dp"
|
||||
android:singleLine="true"
|
||||
android:ellipsize="marquee"
|
||||
android:marqueeRepeatLimit="marquee_forever"
|
||||
android:focusable="true"
|
||||
android:focusableInTouchMode="true"
|
||||
android:scrollHorizontally="true"/>
|
||||
|
||||
<HorizontalScrollView
|
||||
android:id="@+id/scroll_view_chip"
|
||||
@@ -222,16 +196,48 @@
|
||||
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/fab_refresh_offers"
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:srcCompat="@drawable/refresh"
|
||||
android:contentDescription="@string/canteen_fab_refresh_content_desc"
|
||||
android:orientation="vertical"
|
||||
android:layout_gravity="bottom|end"
|
||||
android:layout_marginEnd="@dimen/fab_margin"
|
||||
android:layout_marginBottom="@dimen/fab_margin"
|
||||
app:layout_behavior="com.google.android.material.behavior.HideBottomViewOnScrollBehavior"/>
|
||||
app:layout_behavior="com.google.android.material.behavior.HideBottomViewOnScrollBehavior">
|
||||
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
style="?attr/floatingActionButtonSmallStyle"
|
||||
android:id="@+id/fab_opening_hours"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:srcCompat="@drawable/clock"
|
||||
android:contentDescription="@string/canteen_fab_opening_hours_content_desc"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:tooltipText="@string/canteen_fab_opening_hours_content_desc"
|
||||
tools:ignore="UnusedAttribute"/>
|
||||
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
style="?attr/floatingActionButtonSmallStyle"
|
||||
android:id="@+id/fab_switch_canteen"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:srcCompat="@drawable/switch_arrows"
|
||||
android:contentDescription="@string/canteen_fab_switch_canteen_content_desc"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:tooltipText="@string/canteen_fab_switch_canteen_content_desc"
|
||||
tools:ignore="UnusedAttribute"/>
|
||||
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/fab_refresh_offers"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:srcCompat="@drawable/refresh"
|
||||
android:contentDescription="@string/canteen_fab_refresh_content_desc"
|
||||
android:tooltipText="@string/canteen_fab_refresh_content_desc"
|
||||
tools:ignore="UnusedAttribute"/>
|
||||
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
<!-- <androidx.coordinatorlayout.widget.CoordinatorLayout-->
|
||||
<!-- android:id="@+id/snackbar_container"-->
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/title_schedule"
|
||||
android:textSize="32sp"
|
||||
android:textSize="28sp"
|
||||
android:fontFamily="@font/lato_bolditalic"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginHorizontal="16dp"
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
android:fontFamily="@font/lato_bolditalic"
|
||||
android:text="@string/title_settings"
|
||||
app:layout_scrollFlags="scroll|exitUntilCollapsed"
|
||||
android:textSize="32sp"/>
|
||||
android:textSize="28sp"/>
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
|
||||
@@ -58,12 +58,15 @@
|
||||
|
||||
<string name="canteen_no_offer_header">Kein Angebot</string>
|
||||
<string name="canteen_no_offer_desc">Für diesen Tag sind keine Angebote vorhanden</string>
|
||||
<string name="canteen_fab_opening_hours_content_desc">Zeige Öffnungszeiten</string>
|
||||
<string name="canteen_fab_switch_canteen_content_desc">Wechsle Mensa</string>
|
||||
<string name="canteen_fab_refresh_content_desc">Aktualisiere Angebote</string>
|
||||
|
||||
<string name="sheet_licences_header">Lizenzen</string>
|
||||
|
||||
<string name="title_schedule">Dein Stundenplan</string>
|
||||
<string name="title_food">Mensenangebote</string>
|
||||
<string name="title_canteen_template">%s – Angebote</string>
|
||||
<string name="title_settings">App-Einstellungen</string>
|
||||
|
||||
<string name="canteen_opening_hours">%s – Öffnungszeiten</string>
|
||||
|
||||
@@ -80,24 +80,9 @@
|
||||
<item name="colorOnPrimaryGame">@color/game_dark_onPrimary</item>
|
||||
<item name="colorContainerGame">@color/game_dark_container</item>
|
||||
<item name="colorOnContainerGame">@color/game_dark_onContainer</item>
|
||||
|
||||
<item name="materialTimePickerTheme">@style/TimeDialogTheme</item>
|
||||
</style>
|
||||
|
||||
<style name="DividerTheme" parent="Widget.Material3.MaterialDivider">
|
||||
<item name="dividerColor">@color/md_theme_dark_outlineVariant</item>
|
||||
</style>
|
||||
|
||||
<style name="TimeDialogTheme" parent="ThemeOverlay.MaterialComponents.Dialog">
|
||||
<item name="android:colorAccent">@color/md_theme_dark_primary</item>
|
||||
<item name="android:colorPrimary">@color/md_theme_dark_primary</item>
|
||||
<item name="android:colorPrimaryDark">@color/md_theme_dark_secondary</item>
|
||||
<!-- <item name="buttonBarPositiveButtonStyle">@style/TextButton</item>-->
|
||||
<!-- <item name="buttonBarNegativeButtonStyle">@style/TextButton</item>-->
|
||||
</style>
|
||||
|
||||
<style name="TextButton" parent="Widget.MaterialComponents.Button.TextButton.Dialog">
|
||||
<item name="android:textColor">@color/md_theme_dark_primary</item>
|
||||
<item name="backgroundTint">@color/md_theme_dark_primary</item>
|
||||
</style>
|
||||
</resources>
|
||||
@@ -59,6 +59,8 @@
|
||||
|
||||
<string name="canteen_no_offer_header">No offers</string>
|
||||
<string name="canteen_no_offer_desc">There are no offers available for this day</string>
|
||||
<string name="canteen_fab_opening_hours_content_desc">Show opening hours</string>
|
||||
<string name="canteen_fab_switch_canteen_content_desc">Switch canteen</string>
|
||||
<string name="canteen_fab_refresh_content_desc">Refresh offers</string>
|
||||
|
||||
<string name="sheet_licences_header">Licences</string>
|
||||
@@ -66,6 +68,7 @@
|
||||
|
||||
<string name="title_schedule">Your Schedule</string>
|
||||
<string name="title_food">Canteen Offers</string>
|
||||
<string name="title_canteen_template">%s – Offers</string>
|
||||
<string name="title_settings">App Settings</string>
|
||||
|
||||
<string name="canteen_opening_hours">%s – Opening Hours</string>
|
||||
|
||||
@@ -80,8 +80,6 @@
|
||||
<item name="colorOnPrimaryGame">@color/game_light_onPrimary</item>
|
||||
<item name="colorContainerGame">@color/game_light_container</item>
|
||||
<item name="colorOnContainerGame">@color/game_light_onContainer</item>
|
||||
|
||||
<item name="materialTimePickerTheme">@style/TimeDialogTheme</item> <!-- TimePicker dialog -->
|
||||
</style>
|
||||
|
||||
<style name="Theme.StudIPTimetable" parent="Base.Theme.StudIPTimetable" />
|
||||
@@ -94,17 +92,4 @@
|
||||
<item name="checkedIconEnabled">false</item>
|
||||
<item name="checkedIcon">@null</item>
|
||||
</style>
|
||||
|
||||
<style name="TimeDialogTheme" parent="ThemeOverlay.MaterialComponents.TimePicker">
|
||||
<item name="android:colorAccent">@color/md_theme_light_primary</item>
|
||||
<item name="android:colorPrimary">@color/md_theme_light_primary</item>
|
||||
<item name="android:colorPrimaryDark">@color/md_theme_light_secondary</item>
|
||||
<item name="buttonBarPositiveButtonStyle">@style/TextButton</item>
|
||||
<item name="buttonBarNegativeButtonStyle">@style/TextButton</item>
|
||||
</style>
|
||||
|
||||
<style name="TextButton" parent="Widget.MaterialComponents.Button.TextButton.Dialog">
|
||||
<item name="android:textColor">@color/md_theme_light_primary</item>
|
||||
<item name="backgroundTint">@color/md_theme_light_primary</item>
|
||||
</style>
|
||||
</resources>
|
||||
Reference in New Issue
Block a user