forked from github/wulkanowy-mirror
Add missing dashboard item in default view settings (#1450)
This commit is contained in:
parent
cebd1aa75d
commit
55518cb044
@ -30,6 +30,7 @@ class PreferencesRepository @Inject constructor(
|
|||||||
@ApplicationContext val context: Context,
|
@ApplicationContext val context: Context,
|
||||||
moshi: Moshi
|
moshi: Moshi
|
||||||
) {
|
) {
|
||||||
|
|
||||||
@OptIn(ExperimentalStdlibApi::class)
|
@OptIn(ExperimentalStdlibApi::class)
|
||||||
private val dashboardItemsPositionAdapter: JsonAdapter<Map<DashboardItem.Type, Int>> =
|
private val dashboardItemsPositionAdapter: JsonAdapter<Map<DashboardItem.Type, Int>> =
|
||||||
moshi.adapter()
|
moshi.adapter()
|
||||||
|
@ -20,7 +20,7 @@ import javax.inject.Inject
|
|||||||
|
|
||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
class ExamFragment : BaseFragment<FragmentExamBinding>(R.layout.fragment_exam), ExamView,
|
class ExamFragment : BaseFragment<FragmentExamBinding>(R.layout.fragment_exam), ExamView,
|
||||||
MainView.MainChildView, MainView.TitledView {
|
MainView.TitledView {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var presenter: ExamPresenter
|
lateinit var presenter: ExamPresenter
|
||||||
@ -90,14 +90,6 @@ class ExamFragment : BaseFragment<FragmentExamBinding>(R.layout.fragment_exam),
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun resetView() {
|
|
||||||
binding.examRecycler.scrollToPosition(0)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onFragmentReselected() {
|
|
||||||
if (::presenter.isInitialized) presenter.onViewReselected()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun showEmpty(show: Boolean) {
|
override fun showEmpty(show: Boolean) {
|
||||||
binding.examEmpty.visibility = if (show) VISIBLE else GONE
|
binding.examEmpty.visibility = if (show) VISIBLE else GONE
|
||||||
}
|
}
|
||||||
|
@ -82,16 +82,6 @@ class ExamPresenter @Inject constructor(
|
|||||||
view?.showExamDialog(exam)
|
view?.showExamDialog(exam)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onViewReselected() {
|
|
||||||
Timber.i("Exam view is reselected")
|
|
||||||
baseDate.also {
|
|
||||||
if (currentDate != it) {
|
|
||||||
reloadView(it)
|
|
||||||
loadData()
|
|
||||||
} else if (view?.isViewEmpty == false) view?.resetView()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun setBaseDateOnHolidays() {
|
private fun setBaseDateOnHolidays() {
|
||||||
flow {
|
flow {
|
||||||
val student = studentRepository.getCurrentStudent()
|
val student = studentRepository.getCurrentStudent()
|
||||||
|
@ -17,8 +17,6 @@ interface ExamView : BaseView {
|
|||||||
|
|
||||||
fun showRefresh(show: Boolean)
|
fun showRefresh(show: Boolean)
|
||||||
|
|
||||||
fun resetView()
|
|
||||||
|
|
||||||
fun showEmpty(show: Boolean)
|
fun showEmpty(show: Boolean)
|
||||||
|
|
||||||
fun showErrorView(show: Boolean)
|
fun showErrorView(show: Boolean)
|
||||||
|
@ -34,6 +34,7 @@ import io.github.wulkanowy.ui.modules.account.accountquick.AccountQuickDialog
|
|||||||
import io.github.wulkanowy.ui.modules.attendance.AttendanceFragment
|
import io.github.wulkanowy.ui.modules.attendance.AttendanceFragment
|
||||||
import io.github.wulkanowy.ui.modules.conference.ConferenceFragment
|
import io.github.wulkanowy.ui.modules.conference.ConferenceFragment
|
||||||
import io.github.wulkanowy.ui.modules.dashboard.DashboardFragment
|
import io.github.wulkanowy.ui.modules.dashboard.DashboardFragment
|
||||||
|
import io.github.wulkanowy.ui.modules.exam.ExamFragment
|
||||||
import io.github.wulkanowy.ui.modules.grade.GradeFragment
|
import io.github.wulkanowy.ui.modules.grade.GradeFragment
|
||||||
import io.github.wulkanowy.ui.modules.homework.HomeworkFragment
|
import io.github.wulkanowy.ui.modules.homework.HomeworkFragment
|
||||||
import io.github.wulkanowy.ui.modules.luckynumber.LuckyNumberFragment
|
import io.github.wulkanowy.ui.modules.luckynumber.LuckyNumberFragment
|
||||||
@ -107,11 +108,12 @@ class MainActivity : BaseActivity<MainPresenter, ActivityMainBinding>(), MainVie
|
|||||||
|
|
||||||
private val moreMenuFragments = mapOf<Int, Fragment>(
|
private val moreMenuFragments = mapOf<Int, Fragment>(
|
||||||
MainView.Section.MESSAGE.id to MessageFragment.newInstance(),
|
MainView.Section.MESSAGE.id to MessageFragment.newInstance(),
|
||||||
|
MainView.Section.EXAM.id to ExamFragment.newInstance(),
|
||||||
MainView.Section.HOMEWORK.id to HomeworkFragment.newInstance(),
|
MainView.Section.HOMEWORK.id to HomeworkFragment.newInstance(),
|
||||||
MainView.Section.NOTE.id to NoteFragment.newInstance(),
|
MainView.Section.NOTE.id to NoteFragment.newInstance(),
|
||||||
MainView.Section.LUCKY_NUMBER.id to LuckyNumberFragment.newInstance(),
|
|
||||||
MainView.Section.SCHOOL_ANNOUNCEMENT.id to SchoolAnnouncementFragment.newInstance(),
|
|
||||||
MainView.Section.CONFERENCE.id to ConferenceFragment.newInstance(),
|
MainView.Section.CONFERENCE.id to ConferenceFragment.newInstance(),
|
||||||
|
MainView.Section.SCHOOL_ANNOUNCEMENT.id to SchoolAnnouncementFragment.newInstance(),
|
||||||
|
MainView.Section.LUCKY_NUMBER.id to LuckyNumberFragment.newInstance(),
|
||||||
)
|
)
|
||||||
|
|
||||||
@SuppressLint("NewApi")
|
@SuppressLint("NewApi")
|
||||||
|
@ -118,11 +118,9 @@ class MainPresenter @Inject constructor(
|
|||||||
view?.showStudentAvatar(currentStudent)
|
view?.showStudentAvatar(currentStudent)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getProperViewIndexes(initMenu: MainView.Section?): Pair<Int, Int> {
|
private fun getProperViewIndexes(initMenu: MainView.Section?) = when (initMenu?.id) {
|
||||||
return when (initMenu?.id) {
|
|
||||||
in 0..3 -> initMenu!!.id to -1
|
in 0..3 -> initMenu!!.id to -1
|
||||||
in 4..10 -> 4 to initMenu!!.id
|
in 4..100 -> 4 to initMenu!!.id
|
||||||
else -> prefRepository.startMenuIndex to -1
|
else -> prefRepository.startMenuIndex to -1
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -56,22 +56,24 @@ interface MainView : BaseView {
|
|||||||
set(_) {}
|
set(_) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
enum class Section(val id: Int) {
|
enum class Section {
|
||||||
GRADE(0),
|
DASHBOARD,
|
||||||
ATTENDANCE(1),
|
GRADE,
|
||||||
EXAM(2),
|
ATTENDANCE,
|
||||||
TIMETABLE(3),
|
TIMETABLE,
|
||||||
MORE(4),
|
MORE,
|
||||||
MESSAGE(5),
|
MESSAGE,
|
||||||
HOMEWORK(6),
|
EXAM,
|
||||||
NOTE(7),
|
HOMEWORK,
|
||||||
LUCKY_NUMBER(8),
|
NOTE,
|
||||||
SETTINGS(9),
|
CONFERENCE,
|
||||||
ABOUT(10),
|
SCHOOL_ANNOUNCEMENT,
|
||||||
SCHOOL(11),
|
SCHOOL,
|
||||||
ACCOUNT(12),
|
LUCKY_NUMBER,
|
||||||
STUDENT_INFO(13),
|
ACCOUNT,
|
||||||
CONFERENCE(14),
|
STUDENT_INFO,
|
||||||
SCHOOL_ANNOUNCEMENT(15)
|
SETTINGS;
|
||||||
|
|
||||||
|
val id get() = ordinal
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
package io.github.wulkanowy.utils
|
package io.github.wulkanowy.utils
|
||||||
|
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import io.github.wulkanowy.ui.modules.about.AboutFragment
|
|
||||||
import io.github.wulkanowy.ui.modules.account.AccountFragment
|
import io.github.wulkanowy.ui.modules.account.AccountFragment
|
||||||
import io.github.wulkanowy.ui.modules.account.accountdetails.AccountDetailsFragment
|
import io.github.wulkanowy.ui.modules.account.accountdetails.AccountDetailsFragment
|
||||||
import io.github.wulkanowy.ui.modules.attendance.AttendanceFragment
|
import io.github.wulkanowy.ui.modules.attendance.AttendanceFragment
|
||||||
import io.github.wulkanowy.ui.modules.conference.ConferenceFragment
|
import io.github.wulkanowy.ui.modules.conference.ConferenceFragment
|
||||||
|
import io.github.wulkanowy.ui.modules.dashboard.DashboardFragment
|
||||||
import io.github.wulkanowy.ui.modules.exam.ExamFragment
|
import io.github.wulkanowy.ui.modules.exam.ExamFragment
|
||||||
import io.github.wulkanowy.ui.modules.grade.GradeFragment
|
import io.github.wulkanowy.ui.modules.grade.GradeFragment
|
||||||
import io.github.wulkanowy.ui.modules.homework.HomeworkFragment
|
import io.github.wulkanowy.ui.modules.homework.HomeworkFragment
|
||||||
@ -32,13 +32,13 @@ fun Fragment.toSection(): MainView.Section? {
|
|||||||
is NoteFragment -> MainView.Section.NOTE
|
is NoteFragment -> MainView.Section.NOTE
|
||||||
is LuckyNumberFragment -> MainView.Section.LUCKY_NUMBER
|
is LuckyNumberFragment -> MainView.Section.LUCKY_NUMBER
|
||||||
is SettingsFragment -> MainView.Section.SETTINGS
|
is SettingsFragment -> MainView.Section.SETTINGS
|
||||||
is AboutFragment -> MainView.Section.ABOUT
|
|
||||||
is SchoolAndTeachersFragment -> MainView.Section.SCHOOL
|
is SchoolAndTeachersFragment -> MainView.Section.SCHOOL
|
||||||
is AccountFragment -> MainView.Section.ACCOUNT
|
is AccountFragment -> MainView.Section.ACCOUNT
|
||||||
is AccountDetailsFragment -> MainView.Section.ACCOUNT
|
is AccountDetailsFragment -> MainView.Section.ACCOUNT
|
||||||
is StudentInfoFragment -> MainView.Section.STUDENT_INFO
|
is StudentInfoFragment -> MainView.Section.STUDENT_INFO
|
||||||
is ConferenceFragment -> MainView.Section.CONFERENCE
|
is ConferenceFragment -> MainView.Section.CONFERENCE
|
||||||
is SchoolAnnouncementFragment -> MainView.Section.SCHOOL_ANNOUNCEMENT
|
is SchoolAnnouncementFragment -> MainView.Section.SCHOOL_ANNOUNCEMENT
|
||||||
|
is DashboardFragment -> MainView.Section.DASHBOARD
|
||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingTranslation">
|
<resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingTranslation">
|
||||||
<string name="pref_key_start_menu">start_menu</string>
|
<string name="pref_key_start_menu">default_menu_index</string>
|
||||||
<string name="pref_key_attendance_present">attendance_present</string>
|
<string name="pref_key_attendance_present">attendance_present</string>
|
||||||
<string name="pref_key_app_theme">app_theme</string>
|
<string name="pref_key_app_theme">app_theme</string>
|
||||||
<string name="pref_key_dashboard_tiles">dashboard_tiles</string>
|
<string name="pref_key_dashboard_tiles">dashboard_tiles</string>
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||||
<string-array name="startup_tab_entries" translatable="false">
|
<string-array name="startup_tab_entries" translatable="false">
|
||||||
|
<item>@string/dashboard_title</item>
|
||||||
<item>@string/grade_title</item>
|
<item>@string/grade_title</item>
|
||||||
<item>@string/attendance_title</item>
|
<item>@string/attendance_title</item>
|
||||||
<item>@string/exam_title</item>
|
|
||||||
<item>@string/timetable_title</item>
|
<item>@string/timetable_title</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
<string-array name="startup_tab_value" translatable="false">
|
<string-array name="startup_tab_value" translatable="false">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user