From 54b56768c1cfe17dcb5b90a68cd433d34c01afea Mon Sep 17 00:00:00 2001 From: Kacper Ziubryniewicz Date: Sun, 29 Sep 2019 12:39:07 +0200 Subject: [PATCH 1/4] [Homework] Fix homework sorting --- .../edziennik/ui/modules/homework/HomeworkListFragment.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/homework/HomeworkListFragment.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/homework/HomeworkListFragment.kt index 22da31a5..ad3d736f 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/homework/HomeworkListFragment.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/homework/HomeworkListFragment.kt @@ -64,7 +64,7 @@ class HomeworkListFragment : Fragment() { if (app.profile == null || !isAdded) return@Observer if (homeworkList != null && homeworkList.size > 0) { - val adapter = HomeworkAdapter(context, homeworkList) + val adapter = HomeworkAdapter(context, homeworkList.reversed()) b.homeworkView.adapter = adapter b.homeworkView.visibility = View.VISIBLE b.homeworkNoData.visibility = View.GONE From 8d86f9c7af9fadcbaa2bc7c28c46e440dead369e Mon Sep 17 00:00:00 2001 From: Kacper Ziubryniewicz Date: Sun, 29 Sep 2019 12:44:20 +0200 Subject: [PATCH 2/4] [Homework/UI] Make better gaining attention on FAB --- .../java/pl/szczodrzynski/edziennik/MainActivity.kt | 12 +++++++++--- .../ui/modules/homework/HomeworkFragment.kt | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/MainActivity.kt b/app/src/main/java/pl/szczodrzynski/edziennik/MainActivity.kt index 4995f873..6b1dd0f7 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/MainActivity.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/MainActivity.kt @@ -755,7 +755,7 @@ class MainActivity : AppCompatActivity() { drawer.setSelection(target.id, fireOnClick = false) navView.toolbar.setTitle(target.title ?: target.name) navView.bottomBar.fabEnable = false - navView.bottomBar.fabExtended = true + navView.bottomBar.fabExtended = false navView.bottomBar.setFabOnClickListener(null) Log.d("NavDebug", "Navigating from ${navTarget.fragmentClass?.java?.simpleName} to ${target.fragmentClass?.java?.simpleName}") @@ -868,10 +868,16 @@ class MainActivity : AppCompatActivity() { }, 2000) } - fun collapseFab() { + fun gainAttentionFAB() { + navView.bottomBar.fabExtended = false + + b.navView.postDelayed({ + navView.bottomBar.fabExtended = true + }, 1000) + b.navView.postDelayed({ navView.bottomBar.fabExtended = false - }, 2000) + }, 3000) } /* _____ _ _ diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/homework/HomeworkFragment.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/homework/HomeworkFragment.kt index 9ccd97ce..5afdd9a6 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/homework/HomeworkFragment.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/homework/HomeworkFragment.kt @@ -101,6 +101,6 @@ class HomeworkFragment : Fragment() { }) activity.gainAttention() - activity.collapseFab() + activity.gainAttentionFAB() } } From 07d46169748b20d56750efcd685013c55c1a2ab7 Mon Sep 17 00:00:00 2001 From: Kacper Ziubryniewicz Date: Sun, 29 Sep 2019 12:54:41 +0200 Subject: [PATCH 3/4] [Homework] Optimize sorting using layout manager --- .../edziennik/ui/modules/homework/HomeworkListFragment.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/homework/HomeworkListFragment.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/homework/HomeworkListFragment.kt index ad3d736f..e0f2daba 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/homework/HomeworkListFragment.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/homework/HomeworkListFragment.kt @@ -47,8 +47,8 @@ class HomeworkListFragment : Fragment() { } val layoutManager = LinearLayoutManager(context) - layoutManager.reverseLayout = false - layoutManager.stackFromEnd = false + layoutManager.reverseLayout = true + layoutManager.stackFromEnd = true b.homeworkView.setHasFixedSize(true) b.homeworkView.layoutManager = layoutManager @@ -64,7 +64,7 @@ class HomeworkListFragment : Fragment() { if (app.profile == null || !isAdded) return@Observer if (homeworkList != null && homeworkList.size > 0) { - val adapter = HomeworkAdapter(context, homeworkList.reversed()) + val adapter = HomeworkAdapter(context, homeworkList) b.homeworkView.adapter = adapter b.homeworkView.visibility = View.VISIBLE b.homeworkNoData.visibility = View.GONE From 1a74c2a174f9ef776c1bdecc412354072c163eb5 Mon Sep 17 00:00:00 2001 From: Kacper Ziubryniewicz Date: Sun, 29 Sep 2019 15:54:59 +0200 Subject: [PATCH 4/4] [API/Librus] Add syncing grade comments --- .../edziennik/data/api/Librus.java | 32 +++++++++++++++++++ app/src/main/res/values-en/strings.xml | 2 ++ app/src/main/res/values/strings.xml | 1 + 3 files changed, 35 insertions(+) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/Librus.java b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/Librus.java index aa7f635f..cb8c5608 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/Librus.java +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/Librus.java @@ -291,6 +291,7 @@ public class Librus implements EdziennikInterface { targetEndpoints.add("DescriptiveGrades"); targetEndpoints.add("TextGrades"); targetEndpoints.add("BehaviourGrades"); + targetEndpoints.add("GradesComments"); targetEndpoints.add("Events"); targetEndpoints.add("CustomTypes"); @@ -364,6 +365,8 @@ public class Librus implements EdziennikInterface { targetEndpoints.add("DescriptiveGrades"); targetEndpoints.add("TextGrades"); targetEndpoints.add("BehaviourGrades"); + + targetEndpoints.add("GradesComments"); break; case FEATURE_HOMEWORK: targetEndpoints.add("Homework"); @@ -509,6 +512,9 @@ public class Librus implements EdziennikInterface { case "TextGrades": getTextGrades(); break; + case "GradesComments": + getGradesComments(); + break; case "BehaviourGrades": getBehaviourGrades(); break; @@ -1970,6 +1976,32 @@ public class Librus implements EdziennikInterface { }); } + private void getGradesComments() { + callback.onActionStarted(R.string.sync_action_syncing_grade_comments); + apiRequest("Grades/Comments", data -> { + if (data == null) { + r("finish", "GradesComments"); + return; + } + + JsonArray comments = data.get("Comments").getAsJsonArray(); + for (JsonElement commentEl : comments) { + JsonObject comment = commentEl.getAsJsonObject(); + long gradeId = comment.get("Grade").getAsJsonObject().get("Id").getAsLong(); + String text = comment.get("Text").getAsString(); + + for (Grade grade : gradeList) { + if (grade.id == gradeId) { + grade.description = text; + break; + } + } + } + + r("finish", "GradesComments"); + }); + } + private void getPointGradesCategories() { if (!fullSync || !enablePointGrades) { // cancel every not-full sync; no need to download categories again diff --git a/app/src/main/res/values-en/strings.xml b/app/src/main/res/values-en/strings.xml index 599c4191..a2614274 100644 --- a/app/src/main/res/values-en/strings.xml +++ b/app/src/main/res/values-en/strings.xml @@ -851,4 +851,6 @@ Abort message Save draft Send + Getting grade comments + Getting school free days diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index b9de8bbb..407df6c0 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -908,4 +908,5 @@ Aktualne Minione Brak zadaƄ domowych. + Pobieranie komentarzy ocen