From 6f2168d6417711be34d129a626cf31352a417571 Mon Sep 17 00:00:00 2001 From: Michael <5672750+mibac138@users.noreply.github.com> Date: Fri, 26 Apr 2024 23:33:45 +0200 Subject: [PATCH] Additional lessons in timetable view (#2491) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Mikołaj Pich --- .../data/enums/ShowAdditionalLessonsMode.kt | 11 ++ .../repositories/PreferencesRepository.kt | 7 + .../ui/modules/timetable/TimetableAdapter.kt | 24 +++ .../ui/modules/timetable/TimetableItem.kt | 8 +- .../modules/timetable/TimetablePresenter.kt | 130 ++++++++++----- .../additional/AdditionalLessonsFragment.kt | 14 +- .../additional/AdditionalLessonsPresenter.kt | 34 +++- .../additional/AdditionalLessonsView.kt | 2 +- .../add/AdditionalLessonAddDialog.kt | 14 +- .../add/AdditionalLessonAddPresenter.kt | 9 +- .../additional/add/AdditionalLessonAddView.kt | 2 +- .../layout/item_timetable_main_additional.xml | 153 ++++++++++++++++++ .../main/res/values/preferences_defaults.xml | 3 +- app/src/main/res/values/preferences_keys.xml | 1 + .../main/res/values/preferences_values.xml | 11 ++ app/src/main/res/values/strings.xml | 2 + .../res/xml/scheme_preferences_appearance.xml | 21 ++- 17 files changed, 379 insertions(+), 67 deletions(-) create mode 100644 app/src/main/java/io/github/wulkanowy/data/enums/ShowAdditionalLessonsMode.kt create mode 100644 app/src/main/res/layout/item_timetable_main_additional.xml diff --git a/app/src/main/java/io/github/wulkanowy/data/enums/ShowAdditionalLessonsMode.kt b/app/src/main/java/io/github/wulkanowy/data/enums/ShowAdditionalLessonsMode.kt new file mode 100644 index 00000000..3e7cdef5 --- /dev/null +++ b/app/src/main/java/io/github/wulkanowy/data/enums/ShowAdditionalLessonsMode.kt @@ -0,0 +1,11 @@ +package io.github.wulkanowy.data.enums + +enum class ShowAdditionalLessonsMode(val value: String) { + NONE("none"), + INLINE("inline"), + BELOW("below"); + + companion object { + fun getByValue(value: String) = entries.find { it.value == value } ?: INLINE + } +} diff --git a/app/src/main/java/io/github/wulkanowy/data/repositories/PreferencesRepository.kt b/app/src/main/java/io/github/wulkanowy/data/repositories/PreferencesRepository.kt index 2bb1538c..8082068c 100644 --- a/app/src/main/java/io/github/wulkanowy/data/repositories/PreferencesRepository.kt +++ b/app/src/main/java/io/github/wulkanowy/data/repositories/PreferencesRepository.kt @@ -14,6 +14,7 @@ import io.github.wulkanowy.data.enums.AttendanceCalculatorSortingMode import io.github.wulkanowy.data.enums.GradeColorTheme import io.github.wulkanowy.data.enums.GradeExpandMode import io.github.wulkanowy.data.enums.GradeSortingMode +import io.github.wulkanowy.data.enums.ShowAdditionalLessonsMode import io.github.wulkanowy.data.enums.TimetableGapsMode import io.github.wulkanowy.data.enums.TimetableMode import io.github.wulkanowy.ui.modules.dashboard.DashboardItem @@ -213,6 +214,12 @@ class PreferencesRepository @Inject constructor( ) ) + val showAdditionalLessonsInPlan: ShowAdditionalLessonsMode + get() = getString( + R.string.pref_key_timetable_show_additional_lessons, + R.string.pref_default_timetable_show_additional_lessons + ).let { ShowAdditionalLessonsMode.getByValue(it) } + val gradeSortingMode: GradeSortingMode get() = GradeSortingMode.getByValue( getString( diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/timetable/TimetableAdapter.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/timetable/TimetableAdapter.kt index b9b7a27e..5cb6c401 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/timetable/TimetableAdapter.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/timetable/TimetableAdapter.kt @@ -12,6 +12,7 @@ import io.github.wulkanowy.R import io.github.wulkanowy.data.db.entities.Timetable import io.github.wulkanowy.databinding.ItemTimetableBinding import io.github.wulkanowy.databinding.ItemTimetableEmptyBinding +import io.github.wulkanowy.databinding.ItemTimetableMainAdditionalBinding import io.github.wulkanowy.databinding.ItemTimetableSmallBinding import io.github.wulkanowy.utils.SyncListAdapter import io.github.wulkanowy.utils.getPlural @@ -39,6 +40,10 @@ class TimetableAdapter @Inject constructor() : TimetableItemType.EMPTY -> EmptyViewHolder( ItemTimetableEmptyBinding.inflate(inflater, parent, false) ) + + TimetableItemType.ADDITIONAL -> AdditionalViewHolder( + ItemTimetableMainAdditionalBinding.inflate(inflater, parent, false) + ) } } @@ -69,6 +74,22 @@ class TimetableAdapter @Inject constructor() : binding = holder.binding, item = getItem(position) as TimetableItem.Empty, ) + + is AdditionalViewHolder -> bindAdditionalView( + binding = holder.binding, + item = getItem(position) as TimetableItem.Additional, + ) + } + } + + private fun bindAdditionalView( + binding: ItemTimetableMainAdditionalBinding, + item: TimetableItem.Additional + ) { + with(binding) { + timetableItemSubject.text = item.additional.subject + timetableItemTimeStart.text = item.additional.start.toFormattedString("HH:mm") + timetableItemTimeFinish.text = item.additional.end.toFormattedString("HH:mm") } } @@ -305,6 +326,9 @@ class TimetableAdapter @Inject constructor() : private class EmptyViewHolder(val binding: ItemTimetableEmptyBinding) : RecyclerView.ViewHolder(binding.root) + private class AdditionalViewHolder(val binding: ItemTimetableMainAdditionalBinding) : + RecyclerView.ViewHolder(binding.root) + private object Differ : DiffUtil.ItemCallback() { override fun areItemsTheSame(oldItem: TimetableItem, newItem: TimetableItem): Boolean = when { diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/timetable/TimetableItem.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/timetable/TimetableItem.kt index 402b03dd..93290ba2 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/timetable/TimetableItem.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/timetable/TimetableItem.kt @@ -1,6 +1,7 @@ package io.github.wulkanowy.ui.modules.timetable import io.github.wulkanowy.data.db.entities.Timetable +import io.github.wulkanowy.data.db.entities.TimetableAdditional import java.time.Duration sealed class TimetableItem(val type: TimetableItemType) { @@ -23,6 +24,10 @@ sealed class TimetableItem(val type: TimetableItemType) { val numFrom: Int, val numTo: Int ) : TimetableItem(TimetableItemType.EMPTY) + + data class Additional( + val additional: TimetableAdditional, + ) : TimetableItem(TimetableItemType.ADDITIONAL) } data class TimeLeft( @@ -34,5 +39,6 @@ data class TimeLeft( enum class TimetableItemType { SMALL, NORMAL, - EMPTY + EMPTY, + ADDITIONAL, } diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/timetable/TimetablePresenter.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/timetable/TimetablePresenter.kt index 11105061..c00bdc3e 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/timetable/TimetablePresenter.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/timetable/TimetablePresenter.kt @@ -4,6 +4,9 @@ import android.os.Handler import android.os.Looper import io.github.wulkanowy.data.db.entities.Semester import io.github.wulkanowy.data.db.entities.Timetable +import io.github.wulkanowy.data.db.entities.TimetableAdditional +import io.github.wulkanowy.data.enums.ShowAdditionalLessonsMode.BELOW +import io.github.wulkanowy.data.enums.ShowAdditionalLessonsMode.NONE import io.github.wulkanowy.data.enums.TimetableGapsMode.BETWEEN_AND_BEFORE_LESSONS import io.github.wulkanowy.data.enums.TimetableGapsMode.NO_GAPS import io.github.wulkanowy.data.enums.TimetableMode @@ -14,6 +17,7 @@ import io.github.wulkanowy.data.onResourceError import io.github.wulkanowy.data.onResourceIntermediate import io.github.wulkanowy.data.onResourceNotLoading import io.github.wulkanowy.data.onResourceSuccess +import io.github.wulkanowy.data.pojos.TimetableFull import io.github.wulkanowy.data.repositories.PreferencesRepository import io.github.wulkanowy.data.repositories.SemesterRepository import io.github.wulkanowy.data.repositories.StudentRepository @@ -169,9 +173,9 @@ class TimetablePresenter @Inject constructor( enableSwipe(true) showProgress(false) showErrorView(false) - updateData(it.lessons, isDayChanged) - showContent(it.lessons.isNotEmpty()) - showEmpty(it.lessons.isEmpty()) + updateData(it, isDayChanged) + showContent(it.lessons.isNotEmpty() || it.additional.isNotEmpty()) + showEmpty(it.lessons.isEmpty() && it.additional.isEmpty()) setDayHeaderMessage(it.headers.find { header -> header.date == currentDate }?.content) reloadNavigation() } @@ -216,7 +220,7 @@ class TimetablePresenter @Inject constructor( } } - private fun updateData(lessons: List, isDayChanged: Boolean) { + private fun updateData(lessons: TimetableFull, isDayChanged: Boolean) { tickTimer?.cancel() view?.updateData(createItems(lessons), isDayChanged) @@ -229,53 +233,84 @@ class TimetablePresenter @Inject constructor( } } - private fun createItems(items: List): List { - val filteredItems = items - .filter { - if (prefRepository.showWholeClassPlan == TimetableMode.ONLY_CURRENT_GROUP) { - it.isStudentPlan - } else true - } - .sortedWith(compareBy({ item -> item.start }, { item -> !item.isStudentPlan })) + private sealed class Item( + val isStudentPlan: Boolean, + val start: Instant, + val number: Int?, + ) { + class Lesson(val lesson: Timetable) : + Item(lesson.isStudentPlan, lesson.start, lesson.number) + + class Additional(val additional: TimetableAdditional) : Item(true, additional.start, null) + } + + private fun createItems(fullTimetable: TimetableFull): List { + val showAdditionalLessonsInPlan = prefRepository.showAdditionalLessonsInPlan + val allItems = + fullTimetable.lessons.map(Item::Lesson) + fullTimetable.additional.map(Item::Additional) + .takeIf { showAdditionalLessonsInPlan != NONE }.orEmpty() + + val filteredItems = allItems.filter { + if (prefRepository.showWholeClassPlan == TimetableMode.ONLY_CURRENT_GROUP) { + it.isStudentPlan + } else true + }.sortedWith( + (compareBy { it is Item.Additional } + .takeIf { showAdditionalLessonsInPlan == BELOW } ?: EmptyComparator()) + .thenBy { it.start } + .thenBy { !it.isStudentPlan } + ) var prevNum = when (prefRepository.showTimetableGaps) { BETWEEN_AND_BEFORE_LESSONS -> 0 else -> null } + var prevIsAdditional = false return buildList { filteredItems.forEachIndexed { i, it -> - if (prefRepository.showTimetableGaps != NO_GAPS && prevNum != null && it.number > prevNum!! + 1) { - val emptyLesson = TimetableItem.Empty( - numFrom = prevNum!! + 1, - numTo = it.number - 1 - ) - add(emptyLesson) + if (prefRepository.showTimetableGaps != NO_GAPS) { + if (prevNum != null && it.number != null && it.number > prevNum!! + 1) { + if (!prevIsAdditional) { + // Additional lessons do count as a lesson so don't add empty lessons + // when there is an additional lesson present + val emptyLesson = TimetableItem.Empty( + numFrom = prevNum!! + 1, numTo = it.number - 1 + ) + add(emptyLesson) + } + } + prevNum = it.number + prevIsAdditional = it is Item.Additional } - if (it.isStudentPlan) { - val normalLesson = TimetableItem.Normal( - lesson = it, - showGroupsInPlan = prefRepository.showGroupsInPlan, - timeLeft = filteredItems.getTimeLeftForLesson(it, i), - onClick = ::onTimetableItemSelected, - isLessonNumberVisible = !isEduOne - ) - add(normalLesson) - } else { - val smallLesson = TimetableItem.Small( - lesson = it, - onClick = ::onTimetableItemSelected, - isLessonNumberVisible = !isEduOne - ) - add(smallLesson) + if (it is Item.Lesson) { + if (it.isStudentPlan) { + val normalLesson = TimetableItem.Normal( + lesson = it.lesson, + showGroupsInPlan = prefRepository.showGroupsInPlan, + timeLeft = filteredItems.getTimeLeftForLesson(it.lesson, i), + onClick = ::onTimetableItemSelected, + isLessonNumberVisible = !isEduOne + ) + add(normalLesson) + } else { + val smallLesson = TimetableItem.Small( + lesson = it.lesson, + onClick = ::onTimetableItemSelected, + isLessonNumberVisible = !isEduOne + ) + add(smallLesson) + } + } else if (it is Item.Additional) { + // If the user disabled showing additional lessons, they would've been filtered + // out already, so there's no need to check it again. + add(TimetableItem.Additional(it.additional)) } - - prevNum = it.number } } } - private fun List.getTimeLeftForLesson(lesson: Timetable, index: Int): TimeLeft { + private fun List.getTimeLeftForLesson(lesson: Timetable, index: Int): TimeLeft { val isShowTimeUntil = lesson.isShowTimeUntil(getPreviousLesson(index)) return TimeLeft( until = lesson.until.plusMinutes(1).takeIf { isShowTimeUntil }, @@ -284,11 +319,20 @@ class TimetablePresenter @Inject constructor( ) } - private fun List.getPreviousLesson(position: Int): Instant? { - return filter { it.isStudentPlan } - .getOrNull(position - 1 - filterIndexed { i, item -> i < position && !item.isStudentPlan }.size) + private fun List.getPreviousLesson(position: Int): Instant? { + val lessonAdditionalOffset = filterIndexed { i, item -> + i < position && item is Item.Additional + }.size + val lessonStudentPlanOffset = filterIndexed { i, item -> + i < position && !item.isStudentPlan + }.size + val lessonIndex = position - 1 - lessonAdditionalOffset - lessonStudentPlanOffset + + return filterIsInstance() + .filter { it.isStudentPlan } + .getOrNull(lessonIndex) ?.let { - if (!it.canceled && it.isStudentPlan) it.end + if (!it.lesson.canceled && it.isStudentPlan) it.lesson.end else null } } @@ -341,3 +385,7 @@ class TimetablePresenter @Inject constructor( super.onDetachView() } } + +private class EmptyComparator : Comparator { + override fun compare(o1: T, o2: T) = 0 +} diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/timetable/additional/AdditionalLessonsFragment.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/timetable/additional/AdditionalLessonsFragment.kt index faa833c2..bf6be56f 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/timetable/additional/AdditionalLessonsFragment.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/timetable/additional/AdditionalLessonsFragment.kt @@ -13,7 +13,11 @@ import io.github.wulkanowy.ui.modules.main.MainActivity import io.github.wulkanowy.ui.modules.main.MainView import io.github.wulkanowy.ui.modules.timetable.additional.add.AdditionalLessonAddDialog import io.github.wulkanowy.ui.widgets.DividerItemDecoration -import io.github.wulkanowy.utils.* +import io.github.wulkanowy.utils.dpToPx +import io.github.wulkanowy.utils.firstSchoolDayInSchoolYear +import io.github.wulkanowy.utils.getThemeAttrColor +import io.github.wulkanowy.utils.lastSchoolDayInSchoolYear +import io.github.wulkanowy.utils.openMaterialDatePicker import java.time.LocalDate import javax.inject.Inject @@ -132,8 +136,12 @@ class AdditionalLessonsFragment : binding.additionalLessonsNextButton.visibility = if (show) View.VISIBLE else View.INVISIBLE } - override fun showAddAdditionalLessonDialog() { - (activity as? MainActivity)?.showDialogFragment(AdditionalLessonAddDialog.newInstance()) + override fun showAddAdditionalLessonDialog(currentDate: LocalDate) { + (activity as? MainActivity)?.showDialogFragment( + AdditionalLessonAddDialog.newInstance( + currentDate + ) + ) } override fun showDatePickerDialog(selectedDate: LocalDate) { diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/timetable/additional/AdditionalLessonsPresenter.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/timetable/additional/AdditionalLessonsPresenter.kt index d0a01b38..16ec9746 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/timetable/additional/AdditionalLessonsPresenter.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/timetable/additional/AdditionalLessonsPresenter.kt @@ -1,14 +1,27 @@ package io.github.wulkanowy.ui.modules.timetable.additional import android.annotation.SuppressLint -import io.github.wulkanowy.data.* import io.github.wulkanowy.data.db.entities.TimetableAdditional +import io.github.wulkanowy.data.flatResourceFlow +import io.github.wulkanowy.data.logResourceStatus +import io.github.wulkanowy.data.onResourceData +import io.github.wulkanowy.data.onResourceError +import io.github.wulkanowy.data.onResourceNotLoading +import io.github.wulkanowy.data.onResourceSuccess import io.github.wulkanowy.data.repositories.SemesterRepository import io.github.wulkanowy.data.repositories.StudentRepository import io.github.wulkanowy.data.repositories.TimetableRepository +import io.github.wulkanowy.domain.timetable.IsStudentHasLessonsOnWeekendUseCase import io.github.wulkanowy.ui.base.BasePresenter import io.github.wulkanowy.ui.base.ErrorHandler -import io.github.wulkanowy.utils.* +import io.github.wulkanowy.utils.AnalyticsHelper +import io.github.wulkanowy.utils.capitalise +import io.github.wulkanowy.utils.getLastSchoolDayIfHoliday +import io.github.wulkanowy.utils.isHolidays +import io.github.wulkanowy.utils.nextOrSameSchoolDay +import io.github.wulkanowy.utils.nextSchoolDay +import io.github.wulkanowy.utils.previousSchoolDay +import io.github.wulkanowy.utils.toFormattedString import kotlinx.coroutines.flow.catch import kotlinx.coroutines.flow.flow import kotlinx.coroutines.flow.onEach @@ -22,11 +35,14 @@ class AdditionalLessonsPresenter @Inject constructor( errorHandler: ErrorHandler, private val semesterRepository: SemesterRepository, private val timetableRepository: TimetableRepository, + private val isStudentHasLessonsOnWeekendUseCase: IsStudentHasLessonsOnWeekendUseCase, private val analytics: AnalyticsHelper ) : BasePresenter(errorHandler, studentRepository) { private var baseDate: LocalDate = LocalDate.now().nextOrSameSchoolDay + private var isWeekendHasLessons: Boolean = false + lateinit var currentDate: LocalDate private set @@ -43,12 +59,18 @@ class AdditionalLessonsPresenter @Inject constructor( } fun onPreviousDay() { - loadData(currentDate.previousSchoolDay) + val date = if (isWeekendHasLessons) { + currentDate.minusDays(1) + } else currentDate.previousSchoolDay + loadData(date) reloadView() } fun onNextDay() { - loadData(currentDate.nextSchoolDay) + val date = if (isWeekendHasLessons) { + currentDate.plusDays(1) + } else currentDate.nextSchoolDay + loadData(date) reloadView() } @@ -57,7 +79,7 @@ class AdditionalLessonsPresenter @Inject constructor( } fun onAdditionalLessonAddButtonClicked() { - view?.showAddAdditionalLessonDialog() + view?.showAddAdditionalLessonDialog(currentDate) } fun onDateSet(year: Int, month: Int, day: Int) { @@ -131,6 +153,8 @@ class AdditionalLessonsPresenter @Inject constructor( flatResourceFlow { val student = studentRepository.getCurrentStudent() val semester = semesterRepository.getCurrentSemester(student) + + isWeekendHasLessons = isStudentHasLessonsOnWeekendUseCase(semester, currentDate) timetableRepository.getTimetable( student = student, semester = semester, diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/timetable/additional/AdditionalLessonsView.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/timetable/additional/AdditionalLessonsView.kt index 76d37b75..291c1217 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/timetable/additional/AdditionalLessonsView.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/timetable/additional/AdditionalLessonsView.kt @@ -36,7 +36,7 @@ interface AdditionalLessonsView : BaseView { fun showDatePickerDialog(selectedDate: LocalDate) - fun showAddAdditionalLessonDialog() + fun showAddAdditionalLessonDialog(currentDate: LocalDate) fun showSuccessMessage() diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/timetable/additional/add/AdditionalLessonAddDialog.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/timetable/additional/add/AdditionalLessonAddDialog.kt index 9a84fb0a..9470c910 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/timetable/additional/add/AdditionalLessonAddDialog.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/timetable/additional/add/AdditionalLessonAddDialog.kt @@ -3,6 +3,7 @@ package io.github.wulkanowy.ui.modules.timetable.additional.add import android.app.Dialog import android.os.Bundle import android.view.View +import androidx.core.os.bundleOf import androidx.core.widget.doOnTextChanged import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.timepicker.MaterialTimePicker @@ -26,10 +27,12 @@ class AdditionalLessonAddDialog : BaseDialogFragment lateinit var presenter: AdditionalLessonAddPresenter companion object { - fun newInstance() = AdditionalLessonAddDialog() + const val ARGUMENT_KEY = "additional_lesson_default_date" + fun newInstance(defaultDate: LocalDate) = AdditionalLessonAddDialog().apply { + arguments = bundleOf(ARGUMENT_KEY to defaultDate.toEpochDay()) + } } - override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { return MaterialAlertDialogBuilder(requireContext(), theme) .setView( @@ -40,10 +43,13 @@ class AdditionalLessonAddDialog : BaseDialogFragment override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) + arguments?.getLong(ARGUMENT_KEY)?.let(LocalDate::ofEpochDay)?.let { + presenter.onDateSelected(it) + } presenter.onAttachView(this) } - override fun initView() { + override fun initView(selectedDate: LocalDate) { with(binding) { additionalLessonDialogStartEdit.doOnTextChanged { _, _, _, _ -> additionalLessonDialogStart.isErrorEnabled = false @@ -53,6 +59,7 @@ class AdditionalLessonAddDialog : BaseDialogFragment additionalLessonDialogEnd.isErrorEnabled = false additionalLessonDialogEnd.error = null } + additionalLessonDialogDateEdit.setText(selectedDate.toFormattedString()) additionalLessonDialogDateEdit.doOnTextChanged { _, _, _, _ -> additionalLessonDialogDate.isErrorEnabled = false additionalLessonDialogDate.error = null @@ -61,7 +68,6 @@ class AdditionalLessonAddDialog : BaseDialogFragment additionalLessonDialogContent.isErrorEnabled = false additionalLessonDialogContent.error = null } - additionalLessonDialogAdd.setOnClickListener { presenter.onAddAdditionalClicked( start = additionalLessonDialogStartEdit.text?.toString(), diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/timetable/additional/add/AdditionalLessonAddPresenter.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/timetable/additional/add/AdditionalLessonAddPresenter.kt index c207165d..db59a2ab 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/timetable/additional/add/AdditionalLessonAddPresenter.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/timetable/additional/add/AdditionalLessonAddPresenter.kt @@ -10,9 +10,12 @@ import io.github.wulkanowy.utils.lastSchoolDayInSchoolYear import io.github.wulkanowy.utils.toLocalDate import kotlinx.coroutines.launch import timber.log.Timber -import java.time.* +import java.time.LocalDate +import java.time.LocalTime +import java.time.ZoneId +import java.time.ZonedDateTime import java.time.temporal.ChronoUnit -import java.util.* +import java.util.UUID import javax.inject.Inject class AdditionalLessonAddPresenter @Inject constructor( @@ -30,7 +33,7 @@ class AdditionalLessonAddPresenter @Inject constructor( override fun onAttachView(view: AdditionalLessonAddView) { super.onAttachView(view) - view.initView() + view.initView(selectedDate) Timber.i("AdditionalLesson details view was initialized") } diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/timetable/additional/add/AdditionalLessonAddView.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/timetable/additional/add/AdditionalLessonAddView.kt index 0df53815..8d9678e7 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/timetable/additional/add/AdditionalLessonAddView.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/timetable/additional/add/AdditionalLessonAddView.kt @@ -6,7 +6,7 @@ import java.time.LocalTime interface AdditionalLessonAddView : BaseView { - fun initView() + fun initView(selectedDate: LocalDate) fun closeDialog() diff --git a/app/src/main/res/layout/item_timetable_main_additional.xml b/app/src/main/res/layout/item_timetable_main_additional.xml new file mode 100644 index 00000000..b3aa55d4 --- /dev/null +++ b/app/src/main/res/layout/item_timetable_main_additional.xml @@ -0,0 +1,153 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/values/preferences_defaults.xml b/app/src/main/res/values/preferences_defaults.xml index 2981e184..2177b25f 100644 --- a/app/src/main/res/values/preferences_defaults.xml +++ b/app/src/main/res/values/preferences_defaults.xml @@ -22,7 +22,8 @@ 0.33 0.33 true - false + true + below no alphabetic between diff --git a/app/src/main/res/values/preferences_keys.xml b/app/src/main/res/values/preferences_keys.xml index e87e9854..ce877308 100644 --- a/app/src/main/res/values/preferences_keys.xml +++ b/app/src/main/res/values/preferences_keys.xml @@ -31,6 +31,7 @@ grade_sorting_mode show_whole_class_plan show_groups_in_plan + show_additional_lessons timetable_show_gaps subjects_without_grades optional_arithmetic_average diff --git a/app/src/main/res/values/preferences_values.xml b/app/src/main/res/values/preferences_values.xml index b588ea5e..e5020b53 100644 --- a/app/src/main/res/values/preferences_values.xml +++ b/app/src/main/res/values/preferences_values.xml @@ -152,6 +152,17 @@ before_and_between + + Don\'t show + Show inline + Show below regular lessons + + + none + inline + below + + Lucky number Unread messages diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index a8e159ec..8c3825b4 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -195,6 +195,7 @@ Lesson + Additional lesson Room Group Hours @@ -731,6 +732,7 @@ Theme Grades expanding Show groups next to subjects + Show additional lessons Show empty tiles where there\'s no lesson Show chart list in class grades Show subjects without grades diff --git a/app/src/main/res/xml/scheme_preferences_appearance.xml b/app/src/main/res/xml/scheme_preferences_appearance.xml index 1ca4d204..55f425d9 100644 --- a/app/src/main/res/xml/scheme_preferences_appearance.xml +++ b/app/src/main/res/xml/scheme_preferences_appearance.xml @@ -88,19 +88,18 @@ + app:key="@string/pref_key_attendance_calculator" + app:title="@string/pref_attendance_calculator_appearance_view"> + app:title="@string/pref_attendance_target" + app:updatesContinuously="true" /> +