diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/home/cards/HomeTimetableCard.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/home/cards/HomeTimetableCard.kt
index 20f9c848..458a52e1 100644
--- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/home/cards/HomeTimetableCard.kt
+++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/home/cards/HomeTimetableCard.kt
@@ -14,9 +14,16 @@ import androidx.core.view.setMargins
import androidx.lifecycle.Observer
import com.mikepenz.iconics.IconicsDrawable
import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial
+import com.mikepenz.iconics.typeface.library.szkolny.font.SzkolnyFont
import com.mikepenz.iconics.utils.sizeDp
import kotlinx.coroutines.*
+import org.greenrobot.eventbus.EventBus
+import org.greenrobot.eventbus.Subscribe
+import org.greenrobot.eventbus.ThreadMode
import pl.szczodrzynski.edziennik.*
+import pl.szczodrzynski.edziennik.data.api.LOGIN_TYPE_LIBRUS
+import pl.szczodrzynski.edziennik.data.api.events.ApiTaskAllFinishedEvent
+import pl.szczodrzynski.edziennik.data.api.task.EdziennikTask
import pl.szczodrzynski.edziennik.data.db.modules.events.Event
import pl.szczodrzynski.edziennik.data.db.modules.profiles.Profile
import pl.szczodrzynski.edziennik.data.db.modules.timetable.Lesson
@@ -80,7 +87,7 @@ class HomeTimetableCard(
.colorAttr(activity, R.attr.colorIcon)
.sizeDp(20))
- b.bellSync.setImageDrawable(IconicsDrawable(activity, CommunityMaterial.Icon.cmd_alarm_bell)
+ b.bellSync.setImageDrawable(IconicsDrawable(activity, SzkolnyFont.Icon.szf_alarm_bell_outline)
.colorAttr(activity, R.attr.colorIcon)
.sizeDp(20))
@@ -90,6 +97,18 @@ class HomeTimetableCard(
)
}
+ b.root.onClick {
+ activity.loadTarget(MainActivity.DRAWER_ITEM_TIMETABLE, Bundle().apply {
+ putString("timetableDate", timetableDate.stringY_m_d)
+ })
+ }
+
+ if (app.profile.loginStoreType == LOGIN_TYPE_LIBRUS && app.profile.getLoginData("timetableNotPublic", false)) {
+ b.timetableLayout.visibility = View.GONE
+ b.notPublicLayout.visibility = View.VISIBLE
+ return
+ }
+
// get current bell-sync params
app.config.timetable.bellSyncDiff?.let {
bellSyncDiffMillis = (it.hour * 60 * 60 * 1000 + it.minute * 60 * 1000 + it.second * 1000).toLong()
@@ -103,11 +122,7 @@ class HomeTimetableCard(
update()
})
- b.root.setOnClickListener {
- activity.loadTarget(MainActivity.DRAWER_ITEM_TIMETABLE, Bundle().apply {
- putString("timetableDate", timetableDate.stringY_m_d)
- })
- }
+ EventBus.getDefault().register(this)
}
private fun update() { launch {
@@ -144,6 +159,42 @@ class HomeTimetableCard(
timetableDate = deferred.await()
+ if (lessons.isEmpty()) {
+ // timetable is not downloaded yet
+ b.timetableLayout.visibility = View.GONE
+ b.noTimetableLayout.visibility = View.VISIBLE
+ b.noLessonsLayout.visibility = View.GONE
+ val weekStart = timetableDate.clone().weekStart
+ b.noTimetableText.setText(
+ R.string.home_timetable_no_timetable_text,
+ weekStart.stringY_m_d
+ )
+ b.noTimetableSync.onClick {
+ it.isEnabled = false
+ EdziennikTask.syncProfile(
+ profileId = App.profileId,
+ viewIds = listOf(
+ MainActivity.DRAWER_ITEM_TIMETABLE to 0
+ ),
+ arguments = JsonObject(
+ "weekStart" to weekStart
+ )
+ ).enqueue(activity)
+ }
+ return@launch
+ }
+ if (lessons.size == 1 && lessons[0].type == Lesson.TYPE_NO_LESSONS) {
+ // in next 7 days only NO_LESSONS is found
+ b.timetableLayout.visibility = View.GONE
+ b.noTimetableLayout.visibility = View.GONE
+ b.noLessonsLayout.visibility = View.VISIBLE
+ return@launch
+ }
+
+ b.timetableLayout.visibility = View.VISIBLE
+ b.noTimetableLayout.visibility = View.GONE
+ b.noLessonsLayout.visibility = View.GONE
+
val isToday = today == timetableDate
b.progress.visibility = View.GONE
@@ -290,5 +341,10 @@ class HomeTimetableCard(
}
}
+ @Subscribe(threadMode = ThreadMode.MAIN)
+ fun onSyncFinishedEvent(event: ApiTaskAllFinishedEvent) {
+ b.noTimetableSync.isEnabled = true
+ }
+
override fun unbind(position: Int, holder: HomeCardAdapter.ViewHolder) = Unit
}
diff --git a/app/src/main/res/layout/card_home_timetable.xml b/app/src/main/res/layout/card_home_timetable.xml
index ef6436b0..415c8390 100644
--- a/app/src/main/res/layout/card_home_timetable.xml
+++ b/app/src/main/res/layout/card_home_timetable.xml
@@ -6,124 +6,256 @@
-
+ android:orientation="horizontal"
+ android:visibility="gone"
+ tools:visibility="visible">
+
+
+ android:text="@string/home_timetable_no_timetable" />
+ android:textSize="16sp"
+ android:text="@string/home_timetable_no_timetable_text"/>
+
+
+
-
-
-
-
-
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ android:gravity="center_vertical"
+ android:visibility="gone"
+ tools:layout_marginTop="150dp"
+ tools:visibility="visible">
+
+
+ android:textAppearance="@style/NavView.TextView.Title"
+ android:text="@string/home_timetable_no_lessons" />
-
-
+ android:textSize="16sp"
+ android:text="@string/home_timetable_no_lessons_text"/>
-
+
+
+
+
+
+
+ android:layout_marginLeft="8dp"
+ android:layout_marginStart="8dp"
+ android:orientation="vertical">
+
+
+
+
+
+
-
-
-
+ android:orientation="vertical"
+ tools:layout_marginTop="350dp">
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 43d3df29..1fd7d796 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -1113,4 +1113,11 @@
Skanuj kod QR
Odłącz
Połączono %s
+ Nie pobrano planu lekcji
+ Plan lekcji na tydzień %s nie został jeszcze pobrany.
+ Pobierz
+ Nie ma żadnych lekcji
+ Przez następne 7 dni nie ma żadnych lekcji.
+ Brak planu lekcji
+ Plan lekcji nie został opublikowany przez szkołę.\n\nSkontaktuj się z wychowawcą.