Added ExamOverviewFragment.kt and RoomFinderFragment.kt as well as respective layouts and view models to implement later; minor reformatting

This commit is contained in:
denizk0461
2023-05-20 22:03:51 +02:00
parent cbea5f124d
commit ff930b89c0
19 changed files with 115 additions and 74 deletions
+2
View File
@@ -13,6 +13,8 @@ Currently, nothing is outright broken, but a few things may be bodged together b
## TODO
- Adding exams, homework, etc.: users will be able to add any tasks they need to do as reminders. Those can be associated with events that either have been downloaded from the user's Stud.IP schedule, or ones the user has created manually. An overview will be provided that allows the user to have, well, an overview of everything they need to do.
- Finding your room: I'd like to add a feature that makes finding a specific room on the university's campus much easier than it is now. The university website does have a feature that, in theory, should do exactly that, but it works very poorly and does not list all rooms. My idea would be that the user could type in a room, the app could then make suggestions on which room the user may want to find based on the input, and then show the user a floor plan with the room highlighted.
- This could prove quite difficult though, as I do not have access to the university's proper floor plans. My best bet would be to either use the ones avalable online to create my own ones, or draw ones from scratch. As for finding all the rooms, I may have to walk around the university and find all rooms myself.
- Optimisations to data handling will be made. The app currently only supports storing a single timetable, which will be changed in future releases. A planned implementation will see the user being able to download schedules as well as create ones from scratch, with the schedules able to be selected via a dropdown menu.
- Some improvements to the Play Store screenshots are sorely needed...
@@ -2,17 +2,27 @@ package com.denizk0461.weserplaner.fragment
import android.content.Context
import androidx.fragment.app.Fragment
import androidx.viewbinding.ViewBinding
import com.denizk0461.weserplaner.sheet.AppSheet
/**
* Fragment super class providing common functionality. Fragments are used for providing the user
* with different views and functionality. All fragments should inherit from this.
*/
open class AppFragment : Fragment() {
abstract class AppFragment<T : ViewBinding> : Fragment() {
// Internal context object
private lateinit var _context: Context
// Nullable view binding reference. Instantiate this in classes that extend this class.
protected var _binding: T? = null
/*
* Non-null reference to the view binding. This property is only valid between onCreateView and
* onDestroyView.
*/
protected val binding: T get() = _binding!!
/**
* Get non-null context. Only valid after onAttach().
*/
@@ -25,16 +25,7 @@ import com.google.android.material.tabs.TabLayoutMediator
* User-facing fragment view that displays the canteen offers from the website of the
* Studierendenwerk Bremen.
*/
class CanteenFragment : AppFragment() {
// Nullable view binding reference
private var _binding: FragmentCanteenBinding? = null
/*
* Non-null reference to the view binding. This property is only valid between onCreateView and
* onDestroyView.
*/
private val binding get() = _binding!!
class CanteenFragment : AppFragment<FragmentCanteenBinding>() {
// Adapter for the view pager displaying all offers
private lateinit var viewPagerAdapter: CanteenOfferPageAdapter
@@ -21,16 +21,7 @@ import com.denizk0461.weserplaner.viewmodel.CanteenPageViewModel
* Fragment that is instantiated by [StudIPEventPageAdapter] to display individual days' pages and
* their events.
*/
class CanteenPageFragment : AppFragment(), CanteenOfferItemAdapter.OnClickListener {
// Nullable view binding reference
private var _binding: RecyclerViewBinding? = null
/*
* Non-null reference to the view binding. This property is only valid between onCreateView and
* onDestroyView.
*/
private val binding get() = _binding!!
class CanteenPageFragment : AppFragment<RecyclerViewBinding>(), CanteenOfferItemAdapter.OnClickListener {
// View model reference for providing access to the database
private val viewModel: CanteenPageViewModel by viewModels()
@@ -20,16 +20,7 @@ import java.util.*
/**
* User-facing fragment view that displays the user's Stud.IP schedule.
*/
class EventFragment : AppFragment() {
// Nullable view binding reference
private var _binding: FragmentEventBinding? = null
/*
* Non-null reference to the view binding. This property is only valid between onCreateView and
* onDestroyView.
*/
private val binding get() = _binding!!
class EventFragment : AppFragment<FragmentEventBinding>() {
// Adapter for the view pager displaying all events
private lateinit var viewPagerAdapter: StudIPEventPageAdapter
@@ -18,16 +18,7 @@ import com.denizk0461.weserplaner.viewmodel.EventPageViewModel
* Fragment that is instantiated by [StudIPEventPageAdapter] to display individual days' pages and
* their events.
*/
class EventPageFragment : AppFragment(), StudIPEventItemAdapter.OnClickListener {
// Nullable view binding reference
private var _binding: RecyclerViewBinding? = null
/*
* Non-null reference to the view binding. This property is only valid between onCreateView and
* onDestroyView.
*/
private val binding get() = _binding!!
class EventPageFragment : AppFragment<RecyclerViewBinding>(), StudIPEventItemAdapter.OnClickListener {
// View model reference for providing access to the database
private val viewModel: EventPageViewModel by viewModels()
@@ -0,0 +1,24 @@
package com.denizk0461.weserplaner.fragment
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.viewModels
import com.denizk0461.weserplaner.databinding.FragmentExamOverviewBinding
import com.denizk0461.weserplaner.viewmodel.ExamOverviewViewModel
/**
* Fragment that shows the user an overview of their exams.
*/
class ExamOverviewFragment : AppFragment<FragmentExamOverviewBinding>() {
// View model reference for providing access to the database
private val viewModel: ExamOverviewViewModel by viewModels()
// Instantiate the view binding
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
_binding = FragmentExamOverviewBinding.inflate(inflater, container, false)
return binding.root
}
}
@@ -0,0 +1,24 @@
package com.denizk0461.weserplaner.fragment
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.viewModels
import com.denizk0461.weserplaner.databinding.FragmentRoomFinderBinding
import com.denizk0461.weserplaner.viewmodel.RoomFinderViewModel
/**
* Fragment view that the user can use to find specific rooms on the university campus.
*/
class RoomFinderFragment : AppFragment<FragmentRoomFinderBinding>() {
// View model reference for providing access to the database
private val viewModel: RoomFinderViewModel by viewModels()
// Instantiate the view binding
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
_binding = FragmentRoomFinderBinding.inflate(inflater, container, false)
return binding.root
}
}
@@ -29,16 +29,7 @@ import java.util.*
/**
* User-facing fragment view that is used to change app settings.
*/
class SettingsFragment : AppFragment() {
// Nullable view binding reference
private var _binding: FragmentSettingsBinding? = null
/*
* Non-null reference to the view binding. This property is only valid between onCreateView and
* onDestroyView.
*/
private val binding get() = _binding!!
class SettingsFragment : AppFragment<FragmentSettingsBinding>() {
// View model reference for providing access to the database
private val viewModel: SettingsViewModel by viewModels()
@@ -0,0 +1,11 @@
package com.denizk0461.weserplaner.viewmodel
import android.app.Application
/**
* View model class for [com.denizk0461.weserplaner.fragment.ExamOverviewFragment].
*/
class ExamOverviewViewModel(application: Application) : AppViewModel(application) {
}
@@ -0,0 +1,11 @@
package com.denizk0461.weserplaner.viewmodel
import android.app.Application
/**
* View model class for [com.denizk0461.weserplaner.fragment.RoomFinderFragment].
*/
class RoomFinderViewModel(application: Application) : AppViewModel(application) {
}
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
</androidx.constraintlayout.widget.ConstraintLayout>
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
</androidx.constraintlayout.widget.ConstraintLayout>
+2 -1
View File
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.appcompat.widget.LinearLayoutCompat xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.appcompat.widget.LinearLayoutCompat
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingHorizontal="8dp"
+1 -5
View File
@@ -19,16 +19,12 @@
app:layout_constraintEnd_toEndOf="parent"/>
<com.google.android.material.button.MaterialButton
style="@style/SheetCloseButton"
android:id="@+id/button_cancel"
style="@style/Widget.Material3.Button.IconButton.Filled.Tonal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginHorizontal="16dp"
android:layout_marginTop="16dp"
android:minWidth="0dp"
app:icon="@drawable/cross"
app:iconPadding="0dp"
app:iconTint="?attr/colorOnSurfaceVariant"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
@@ -18,16 +18,12 @@
app:layout_constraintEnd_toEndOf="parent"/>
<com.google.android.material.button.MaterialButton
style="@style/SheetCloseButton"
android:id="@+id/button_cancel"
style="@style/Widget.Material3.Button.IconButton.Filled.Tonal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginHorizontal="16dp"
android:layout_marginTop="16dp"
android:minWidth="0dp"
app:icon="@drawable/cross"
app:iconPadding="0dp"
app:iconTint="?attr/colorOnSurfaceVariant"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.appcompat.widget.LinearLayoutCompat xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/sheet"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">
@@ -19,16 +19,12 @@
app:layout_constraintEnd_toEndOf="parent"/>
<com.google.android.material.button.MaterialButton
style="@style/SheetCloseButton"
android:id="@+id/button_cancel"
style="@style/Widget.Material3.Button.IconButton.Filled.Tonal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginHorizontal="16dp"
android:layout_marginTop="16dp"
android:minWidth="0dp"
app:icon="@drawable/cross"
app:iconPadding="0dp"
app:iconTint="?attr/colorOnSurfaceVariant"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
+2 -6
View File
@@ -18,18 +18,14 @@
app:layout_constraintEnd_toEndOf="parent"/>
<com.google.android.material.button.MaterialButton
style="@style/SheetCloseButton"
android:id="@+id/button_cancel"
style="@style/Widget.Material3.Button.IconButton.Filled.Tonal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginHorizontal="16dp"
android:layout_marginTop="16dp"
android:minWidth="0dp"
app:icon="@drawable/cross"
app:iconPadding="0dp"
app:iconTint="?attr/colorOnSurfaceVariant"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintTop_toTopOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>
+7
View File
@@ -102,4 +102,11 @@
<style name="TimePickerButtonStyle" parent="Widget.MaterialComponents.Button.TextButton">
<item name="android:textColor">@color/md_theme_light_primary</item>
</style>
<style name="SheetCloseButton" parent="Widget.Material3.Button.IconButton.Filled.Tonal">
<item name="icon">@drawable/cross</item>
<item name="iconPadding">0dp</item>
<item name="iconTint">?attr/colorOnSurfaceVariant</item>
<item name="minWidth">0dp</item>
</style>
</resources>