Add remembering the full screen mode in homework
MODIFY
app/src/main/java/io/github/wulkanowy/data/repositories/preferences/PreferencesRepository.kt
app/src/main/java/io/github/wulkanowy/data/repositories/preferences/PreferencesRepository.kt
@@ -80,6 +80,10 @@ class PreferencesRepository @Inject constructor(
val showTimetableTimers: Boolean
get() = getBoolean(R.string.pref_key_timetable_show_timers, R.bool.pref_default_timetable_show_timers)
+ var isHomeworkFullscreen: Boolean
+ get() = getBoolean(R.string.pref_key_homework_fullscreen, R.bool.pref_default_homework_fullscreen)
+ set(value) = sharedPref.edit().putBoolean("homework_fullscreen", value).apply()
+
val showSubjectsWithoutGrades: Boolean
get() = getBoolean(R.string.pref_key_subjects_without_grades, R.bool.pref_default_subjects_without_grades)

MODIFY
app/src/main/java/io/github/wulkanowy/ui/modules/homework/details/HomeworkDetailsAdapter.kt
app/src/main/java/io/github/wulkanowy/ui/modules/homework/details/HomeworkDetailsAdapter.kt
@@ -29,6 +29,8 @@ class HomeworkDetailsAdapter @Inject constructor() :
attachments = value?.attachments.orEmpty()
}
+ var isHomeworkFullscreen = false
+
var onAttachmentClickListener: (url: String) -> Unit = {}
var onFullScreenClickListener = {}
@@ -67,6 +69,8 @@ class HomeworkDetailsAdapter @Inject constructor() :
homeworkDialogSubject.text = homework?.subject
homeworkDialogTeacher.text = homework?.teacher
homeworkDialogContent.text = homework?.content
+ homeworkDialogFullScreen.visibility = if (isHomeworkFullscreen) GONE else VISIBLE
+ homeworkDialogFullScreenExit.visibility = if (isHomeworkFullscreen) VISIBLE else GONE
homeworkDialogFullScreen.setOnClickListener {
homeworkDialogFullScreen.visibility = GONE
homeworkDialogFullScreenExit.visibility = VISIBLE

MODIFY
app/src/main/java/io/github/wulkanowy/ui/modules/homework/details/HomeworkDetailsDialog.kt
app/src/main/java/io/github/wulkanowy/ui/modules/homework/details/HomeworkDetailsDialog.kt
@@ -62,12 +62,25 @@ class HomeworkDetailsDialog : BaseDialogFragment<DialogHomeworkBinding>(), Homew
homeworkDialogClose.setOnClickListener { dismiss() }
}
+ if (presenter.isHomeworkFullscreen) {
+ dialog?.window?.setLayout(MATCH_PARENT, MATCH_PARENT)
+ } else {
+ dialog?.window?.setLayout(WRAP_CONTENT, WRAP_CONTENT)
+ }
+
with(binding.homeworkDialogRecycler) {
layoutManager = LinearLayoutManager(context)
adapter = detailsAdapter.apply {
onAttachmentClickListener = { context.openInternetBrowser(it, ::showMessage) }
- onFullScreenClickListener = { dialog?.window?.setLayout(MATCH_PARENT, MATCH_PARENT) }
- onFullScreenExitClickListener = { dialog?.window?.setLayout(WRAP_CONTENT, WRAP_CONTENT) }
+ onFullScreenClickListener = {
+ dialog?.window?.setLayout(MATCH_PARENT, MATCH_PARENT)
+ presenter.isHomeworkFullscreen = true
+ }
+ onFullScreenExitClickListener = {
+ dialog?.window?.setLayout(WRAP_CONTENT, WRAP_CONTENT)
+ presenter.isHomeworkFullscreen = false
+ }
+ isHomeworkFullscreen = presenter.isHomeworkFullscreen
homework = this@HomeworkDetailsDialog.homework
}
}

MODIFY
app/src/main/java/io/github/wulkanowy/ui/modules/homework/details/HomeworkDetailsPresenter.kt
app/src/main/java/io/github/wulkanowy/ui/modules/homework/details/HomeworkDetailsPresenter.kt
@@ -3,6 +3,7 @@ package io.github.wulkanowy.ui.modules.homework.details
import io.github.wulkanowy.data.Status
import io.github.wulkanowy.data.db.entities.Homework
import io.github.wulkanowy.data.repositories.homework.HomeworkRepository
+import io.github.wulkanowy.data.repositories.preferences.PreferencesRepository
import io.github.wulkanowy.data.repositories.student.StudentRepository
import io.github.wulkanowy.ui.base.BasePresenter
import io.github.wulkanowy.ui.base.ErrorHandler
@@ -16,9 +17,16 @@ class HomeworkDetailsPresenter @Inject constructor(
errorHandler: ErrorHandler,
studentRepository: StudentRepository,
private val homeworkRepository: HomeworkRepository,
- private val analytics: FirebaseAnalyticsHelper
+ private val analytics: FirebaseAnalyticsHelper,
+ private val preferencesRepository: PreferencesRepository
) : BasePresenter<HomeworkDetailsView>(errorHandler, studentRepository) {
+ var isHomeworkFullscreen
+ get() = preferencesRepository.isHomeworkFullscreen
+ set(value) {
+ preferencesRepository.isHomeworkFullscreen = value
+ }
+
override fun onAttachView(view: HomeworkDetailsView) {
super.onAttachView(view)
view.initView()

MODIFY
app/src/main/res/values/preferences_defaults.xml
app/src/main/res/values/preferences_defaults.xml
<bool name="pref_default_fill_message_content">true</bool>
<string name="pref_default_timetable_show_whole_class">no</string>
<bool name="pref_default_timetable_show_timers">false</bool>
+ <bool name="pref_default_homework_fullscreen">false</bool>
<bool name="pref_default_subjects_without_grades">false</bool>
</resources>

MODIFY
app/src/main/res/values/preferences_keys.xml
app/src/main/res/values/preferences_keys.xml
<string name="pref_key_fill_message_content">fill_message_content</string>
<string name="pref_key_timetable_show_whole_class">show_whole_class_plan</string>
<string name="pref_key_timetable_show_timers">timetable_show_timers</string>
+ <string name="pref_key_homework_fullscreen">homework_fullscreen</string>
<string name="pref_key_subjects_without_grades">subjects_without_grades</string>
</resources>

Add remembering the full screen mode in homework (#956)

Co-authored-by: Faierbel <RafalBO99@outlook.com>