mirror of
https://github.com/szkolny-eu/szkolny-android.git
synced 2024-11-24 10:54:36 -06:00
[UI/Timetable] Add option to sync current week.
This commit is contained in:
parent
21c00bbe53
commit
ceca75ef4b
@ -40,6 +40,7 @@ import pl.szczodrzynski.edziennik.data.db.full.EventFull
|
|||||||
import pl.szczodrzynski.edziennik.data.db.full.LessonFull
|
import pl.szczodrzynski.edziennik.data.db.full.LessonFull
|
||||||
import pl.szczodrzynski.edziennik.databinding.TimetableDayFragmentBinding
|
import pl.szczodrzynski.edziennik.databinding.TimetableDayFragmentBinding
|
||||||
import pl.szczodrzynski.edziennik.databinding.TimetableLessonBinding
|
import pl.szczodrzynski.edziennik.databinding.TimetableLessonBinding
|
||||||
|
import pl.szczodrzynski.edziennik.databinding.TimetableNoLessonsBinding
|
||||||
import pl.szczodrzynski.edziennik.databinding.TimetableNoTimetableBinding
|
import pl.szczodrzynski.edziennik.databinding.TimetableNoTimetableBinding
|
||||||
import pl.szczodrzynski.edziennik.ext.Intent
|
import pl.szczodrzynski.edziennik.ext.Intent
|
||||||
import pl.szczodrzynski.edziennik.ext.JsonObject
|
import pl.szczodrzynski.edziennik.ext.JsonObject
|
||||||
@ -63,6 +64,7 @@ import pl.szczodrzynski.edziennik.utils.Colors
|
|||||||
import pl.szczodrzynski.edziennik.utils.managers.NoteManager
|
import pl.szczodrzynski.edziennik.utils.managers.NoteManager
|
||||||
import pl.szczodrzynski.edziennik.utils.models.Date
|
import pl.szczodrzynski.edziennik.utils.models.Date
|
||||||
import pl.szczodrzynski.edziennik.utils.models.Time
|
import pl.szczodrzynski.edziennik.utils.models.Time
|
||||||
|
import pl.szczodrzynski.edziennik.utils.models.Week
|
||||||
import pl.szczodrzynski.edziennik.utils.mutableLazy
|
import pl.szczodrzynski.edziennik.utils.mutableLazy
|
||||||
import kotlin.coroutines.CoroutineContext
|
import kotlin.coroutines.CoroutineContext
|
||||||
import kotlin.math.max
|
import kotlin.math.max
|
||||||
@ -182,6 +184,20 @@ class TimetableDayFragment : LazyFragment(), CoroutineScope {
|
|||||||
b.root.removeAllViews()
|
b.root.removeAllViews()
|
||||||
b.root.addView(view)
|
b.root.addView(view)
|
||||||
viewsRemoved = true
|
viewsRemoved = true
|
||||||
|
|
||||||
|
val b = TimetableNoLessonsBinding.bind(view)
|
||||||
|
val weekStart = date.weekStart.stringY_m_d
|
||||||
|
b.noLessonsSync.onClick {
|
||||||
|
it.isEnabled = false
|
||||||
|
EdziennikTask.syncProfile(
|
||||||
|
profileId = App.profileId,
|
||||||
|
featureTypes = setOf(FeatureType.TIMETABLE),
|
||||||
|
arguments = JsonObject(
|
||||||
|
"weekStart" to weekStart
|
||||||
|
)
|
||||||
|
).enqueue(activity)
|
||||||
|
}
|
||||||
|
b.noLessonsSync.isVisible = date.weekDay !in Week.SATURDAY..Week.SUNDAY
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -27,8 +27,11 @@ import kotlinx.coroutines.launch
|
|||||||
import pl.szczodrzynski.edziennik.App
|
import pl.szczodrzynski.edziennik.App
|
||||||
import pl.szczodrzynski.edziennik.MainActivity
|
import pl.szczodrzynski.edziennik.MainActivity
|
||||||
import pl.szczodrzynski.edziennik.R
|
import pl.szczodrzynski.edziennik.R
|
||||||
|
import pl.szczodrzynski.edziennik.data.api.edziennik.EdziennikTask
|
||||||
|
import pl.szczodrzynski.edziennik.data.db.enums.FeatureType
|
||||||
import pl.szczodrzynski.edziennik.data.db.enums.MetadataType
|
import pl.szczodrzynski.edziennik.data.db.enums.MetadataType
|
||||||
import pl.szczodrzynski.edziennik.databinding.FragmentTimetableV2Binding
|
import pl.szczodrzynski.edziennik.databinding.FragmentTimetableV2Binding
|
||||||
|
import pl.szczodrzynski.edziennik.ext.JsonObject
|
||||||
import pl.szczodrzynski.edziennik.ext.getSchoolYearConstrains
|
import pl.szczodrzynski.edziennik.ext.getSchoolYearConstrains
|
||||||
import pl.szczodrzynski.edziennik.ext.getStudentData
|
import pl.szczodrzynski.edziennik.ext.getStudentData
|
||||||
import pl.szczodrzynski.edziennik.ui.dialogs.settings.TimetableConfigDialog
|
import pl.szczodrzynski.edziennik.ui.dialogs.settings.TimetableConfigDialog
|
||||||
@ -178,6 +181,21 @@ class TimetableFragment : Fragment(), CoroutineScope {
|
|||||||
b.tabLayout.setCurrentItem(items.indexOfFirst { it.value == selectedDate?.value ?: today }, false)
|
b.tabLayout.setCurrentItem(items.indexOfFirst { it.value == selectedDate?.value ?: today }, false)
|
||||||
|
|
||||||
activity.navView.bottomSheet.prependItems(
|
activity.navView.bottomSheet.prependItems(
|
||||||
|
BottomSheetPrimaryItem(true)
|
||||||
|
.withTitle(R.string.menu_timetable_sync)
|
||||||
|
.withIcon(CommunityMaterial.Icon.cmd_calendar_sync_outline)
|
||||||
|
.withOnClickListener {
|
||||||
|
activity.bottomSheet.close()
|
||||||
|
val date = pageSelection ?: Date.getToday()
|
||||||
|
val weekStart = date.weekStart.stringY_m_d
|
||||||
|
EdziennikTask.syncProfile(
|
||||||
|
profileId = App.profileId,
|
||||||
|
featureTypes = setOf(FeatureType.TIMETABLE),
|
||||||
|
arguments = JsonObject(
|
||||||
|
"weekStart" to weekStart
|
||||||
|
)
|
||||||
|
).enqueue(activity)
|
||||||
|
},
|
||||||
BottomSheetPrimaryItem(true)
|
BottomSheetPrimaryItem(true)
|
||||||
.withTitle(R.string.timetable_select_day)
|
.withTitle(R.string.timetable_select_day)
|
||||||
.withIcon(SzkolnyFont.Icon.szf_calendar_today_outline)
|
.withIcon(SzkolnyFont.Icon.szf_calendar_today_outline)
|
||||||
|
@ -2,13 +2,29 @@
|
|||||||
~ Copyright (c) Kuba Szczodrzyński 2019-11-15.
|
~ Copyright (c) Kuba Szczodrzyński 2019-11-15.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatTextView xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:layout_width="wrap_content"
|
android:id="@+id/noTimetableLayout"
|
||||||
android:layout_height="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_gravity="center"
|
android:layout_height="match_parent"
|
||||||
android:drawablePadding="16dp"
|
android:gravity="center"
|
||||||
android:fontFamily="sans-serif-light"
|
android:orientation="vertical">
|
||||||
android:text="@string/timetable_no_lessons_title"
|
|
||||||
android:textSize="24sp"
|
<androidx.appcompat.widget.AppCompatTextView
|
||||||
app:drawableTopCompat="@drawable/ic_timetable" />
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:drawablePadding="16dp"
|
||||||
|
android:fontFamily="sans-serif-light"
|
||||||
|
android:text="@string/timetable_no_lessons_title"
|
||||||
|
android:textSize="24sp"
|
||||||
|
app:drawableTopCompat="@drawable/ic_timetable" />
|
||||||
|
|
||||||
|
<com.google.android.material.button.MaterialButton
|
||||||
|
android:id="@+id/noLessonsSync"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:text="@string/refresh" />
|
||||||
|
</LinearLayout>
|
||||||
|
@ -1241,7 +1241,7 @@
|
|||||||
<string name="timetable_not_public_hint">Skontaktuj się z wychowawcą w celu udostępnienia planu lekcji.</string>
|
<string name="timetable_not_public_hint">Skontaktuj się z wychowawcą w celu udostępnienia planu lekcji.</string>
|
||||||
<string name="timetable_not_public_text">Plan lekcji nie został opublikowany przez szkołę.</string>
|
<string name="timetable_not_public_text">Plan lekcji nie został opublikowany przez szkołę.</string>
|
||||||
<string name="timetable_not_public_title">Brak planu lekcji</string>
|
<string name="timetable_not_public_title">Brak planu lekcji</string>
|
||||||
<string name="timetable_select_day">Wybierz dzień</string>
|
<string name="timetable_select_day">Przejdź do daty</string>
|
||||||
<string name="timetable_syncing_text">Pobieranie planu lekcji na wybrany tydzień…</string>
|
<string name="timetable_syncing_text">Pobieranie planu lekcji na wybrany tydzień…</string>
|
||||||
<string name="timetable_today">Dzisiaj</string>
|
<string name="timetable_today">Dzisiaj</string>
|
||||||
<string name="title_all">Synchronizuj wszystko</string>
|
<string name="title_all">Synchronizuj wszystko</string>
|
||||||
@ -1552,4 +1552,5 @@
|
|||||||
<string name="settings_registration_section">Rejestracja</string>
|
<string name="settings_registration_section">Rejestracja</string>
|
||||||
<string name="home_timetable_all_lessons">Wszystkie lekcje:</string>
|
<string name="home_timetable_all_lessons">Wszystkie lekcje:</string>
|
||||||
<string name="agenda_config_subject_important">Wyświetl nazwę przedmiotu zamiast rodzaju</string>
|
<string name="agenda_config_subject_important">Wyświetl nazwę przedmiotu zamiast rodzaju</string>
|
||||||
|
<string name="menu_timetable_sync">Odśwież wybrany tydzień</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
Reference in New Issue
Block a user