forked from github/wulkanowy-mirror
Add remembering the full screen mode in homework (#956)
Co-authored-by: Faierbel <RafalBO99@outlook.com>
This commit is contained in:
parent
bafe52e310
commit
c6a99f1000
@ -80,6 +80,10 @@ class PreferencesRepository @Inject constructor(
|
|||||||
val showTimetableTimers: Boolean
|
val showTimetableTimers: Boolean
|
||||||
get() = getBoolean(R.string.pref_key_timetable_show_timers, R.bool.pref_default_timetable_show_timers)
|
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
|
val showSubjectsWithoutGrades: Boolean
|
||||||
get() = getBoolean(R.string.pref_key_subjects_without_grades, R.bool.pref_default_subjects_without_grades)
|
get() = getBoolean(R.string.pref_key_subjects_without_grades, R.bool.pref_default_subjects_without_grades)
|
||||||
|
|
||||||
|
@ -29,6 +29,8 @@ class HomeworkDetailsAdapter @Inject constructor() :
|
|||||||
attachments = value?.attachments.orEmpty()
|
attachments = value?.attachments.orEmpty()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var isHomeworkFullscreen = false
|
||||||
|
|
||||||
var onAttachmentClickListener: (url: String) -> Unit = {}
|
var onAttachmentClickListener: (url: String) -> Unit = {}
|
||||||
|
|
||||||
var onFullScreenClickListener = {}
|
var onFullScreenClickListener = {}
|
||||||
@ -67,6 +69,8 @@ class HomeworkDetailsAdapter @Inject constructor() :
|
|||||||
homeworkDialogSubject.text = homework?.subject
|
homeworkDialogSubject.text = homework?.subject
|
||||||
homeworkDialogTeacher.text = homework?.teacher
|
homeworkDialogTeacher.text = homework?.teacher
|
||||||
homeworkDialogContent.text = homework?.content
|
homeworkDialogContent.text = homework?.content
|
||||||
|
homeworkDialogFullScreen.visibility = if (isHomeworkFullscreen) GONE else VISIBLE
|
||||||
|
homeworkDialogFullScreenExit.visibility = if (isHomeworkFullscreen) VISIBLE else GONE
|
||||||
homeworkDialogFullScreen.setOnClickListener {
|
homeworkDialogFullScreen.setOnClickListener {
|
||||||
homeworkDialogFullScreen.visibility = GONE
|
homeworkDialogFullScreen.visibility = GONE
|
||||||
homeworkDialogFullScreenExit.visibility = VISIBLE
|
homeworkDialogFullScreenExit.visibility = VISIBLE
|
||||||
|
@ -62,12 +62,25 @@ class HomeworkDetailsDialog : BaseDialogFragment<DialogHomeworkBinding>(), Homew
|
|||||||
homeworkDialogClose.setOnClickListener { dismiss() }
|
homeworkDialogClose.setOnClickListener { dismiss() }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (presenter.isHomeworkFullscreen) {
|
||||||
|
dialog?.window?.setLayout(MATCH_PARENT, MATCH_PARENT)
|
||||||
|
} else {
|
||||||
|
dialog?.window?.setLayout(WRAP_CONTENT, WRAP_CONTENT)
|
||||||
|
}
|
||||||
|
|
||||||
with(binding.homeworkDialogRecycler) {
|
with(binding.homeworkDialogRecycler) {
|
||||||
layoutManager = LinearLayoutManager(context)
|
layoutManager = LinearLayoutManager(context)
|
||||||
adapter = detailsAdapter.apply {
|
adapter = detailsAdapter.apply {
|
||||||
onAttachmentClickListener = { context.openInternetBrowser(it, ::showMessage) }
|
onAttachmentClickListener = { context.openInternetBrowser(it, ::showMessage) }
|
||||||
onFullScreenClickListener = { dialog?.window?.setLayout(MATCH_PARENT, MATCH_PARENT) }
|
onFullScreenClickListener = {
|
||||||
onFullScreenExitClickListener = { dialog?.window?.setLayout(WRAP_CONTENT, WRAP_CONTENT) }
|
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
|
homework = this@HomeworkDetailsDialog.homework
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package io.github.wulkanowy.ui.modules.homework.details
|
|||||||
import io.github.wulkanowy.data.Status
|
import io.github.wulkanowy.data.Status
|
||||||
import io.github.wulkanowy.data.db.entities.Homework
|
import io.github.wulkanowy.data.db.entities.Homework
|
||||||
import io.github.wulkanowy.data.repositories.homework.HomeworkRepository
|
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.data.repositories.student.StudentRepository
|
||||||
import io.github.wulkanowy.ui.base.BasePresenter
|
import io.github.wulkanowy.ui.base.BasePresenter
|
||||||
import io.github.wulkanowy.ui.base.ErrorHandler
|
import io.github.wulkanowy.ui.base.ErrorHandler
|
||||||
@ -16,9 +17,16 @@ class HomeworkDetailsPresenter @Inject constructor(
|
|||||||
errorHandler: ErrorHandler,
|
errorHandler: ErrorHandler,
|
||||||
studentRepository: StudentRepository,
|
studentRepository: StudentRepository,
|
||||||
private val homeworkRepository: HomeworkRepository,
|
private val homeworkRepository: HomeworkRepository,
|
||||||
private val analytics: FirebaseAnalyticsHelper
|
private val analytics: FirebaseAnalyticsHelper,
|
||||||
|
private val preferencesRepository: PreferencesRepository
|
||||||
) : BasePresenter<HomeworkDetailsView>(errorHandler, studentRepository) {
|
) : BasePresenter<HomeworkDetailsView>(errorHandler, studentRepository) {
|
||||||
|
|
||||||
|
var isHomeworkFullscreen
|
||||||
|
get() = preferencesRepository.isHomeworkFullscreen
|
||||||
|
set(value) {
|
||||||
|
preferencesRepository.isHomeworkFullscreen = value
|
||||||
|
}
|
||||||
|
|
||||||
override fun onAttachView(view: HomeworkDetailsView) {
|
override fun onAttachView(view: HomeworkDetailsView) {
|
||||||
super.onAttachView(view)
|
super.onAttachView(view)
|
||||||
view.initView()
|
view.initView()
|
||||||
|
@ -20,5 +20,6 @@
|
|||||||
<bool name="pref_default_fill_message_content">true</bool>
|
<bool name="pref_default_fill_message_content">true</bool>
|
||||||
<string name="pref_default_timetable_show_whole_class">no</string>
|
<string name="pref_default_timetable_show_whole_class">no</string>
|
||||||
<bool name="pref_default_timetable_show_timers">false</bool>
|
<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>
|
<bool name="pref_default_subjects_without_grades">false</bool>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -22,5 +22,6 @@
|
|||||||
<string name="pref_key_fill_message_content">fill_message_content</string>
|
<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_whole_class">show_whole_class_plan</string>
|
||||||
<string name="pref_key_timetable_show_timers">timetable_show_timers</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>
|
<string name="pref_key_subjects_without_grades">subjects_without_grades</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user