Merge branch 'develop'

This commit is contained in:
Kuba Szczodrzyński 2022-03-14 18:46:37 +01:00
commit c1ef0e9d11
No known key found for this signature in database
GPG Key ID: 70CB8A85BA1633CB
16 changed files with 123 additions and 19 deletions

View File

@ -1,6 +1,6 @@
<h3>Wersja 4.11.3, 2022-02-21</h3>
<h3>Wersja 4.11.4, 2022-03-14</h3>
<ul>
<li>Naprawiono odświeżanie planu lekcji po pobraniu wybranego tygodnia.</li>
<li>Poprawiono wyświetlanie ocen w przypadku przedmiotów z nieznaną nazwą.</li>
</ul>
<br>
<br>

View File

@ -9,7 +9,7 @@
/*secret password - removed for source code publication*/
static toys AES_IV[16] = {
0x90, 0xe9, 0x2f, 0x20, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
0x3d, 0x32, 0x00, 0x89, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
unsigned char *agony(unsigned int laugh, unsigned char *box, unsigned char *heat);

View File

@ -46,6 +46,6 @@ object Signing {
/*fun provideKey(param1: String, param2: Long): ByteArray {*/
fun pleaseStopRightNow(param1: String, param2: Long): ByteArray {
return "$param1.MTIzNDU2Nzg5MDw/KY+My+===.$param2".sha256()
return "$param1.MTIzNDU2Nzg5MDvXV/n0BA===.$param2".sha256()
}
}

View File

@ -164,7 +164,7 @@ class SzkolnyAppFirebase(val app: App, val profiles: List<Profile>, val message:
val type = if (event.isHomework) Notification.TYPE_NEW_SHARED_HOMEWORK else Notification.TYPE_NEW_SHARED_EVENT
val notificationFilter = app.config.getFor(event.profileId).sync.notificationFilter
if (!notificationFilter.contains(type) && event.sharedBy != "self") {
if (!notificationFilter.contains(type) && event.sharedBy != "self" && event.date >= Date.getToday()) {
val notification = Notification(
id = Notification.buildId(event.profileId, type, event.id),
title = app.getNotificationTitle(type),

View File

@ -36,6 +36,7 @@ class GradesAdapter(
private const val ITEM_TYPE_EMPTY = 2
private const val ITEM_TYPE_GRADE = 3
private const val ITEM_TYPE_STATS = 4
private const val ITEM_TYPE_UNKNOWN_SUBJECT = 5
const val STATE_CLOSED = 0
const val STATE_OPENED = 1
}
@ -58,6 +59,7 @@ class GradesAdapter(
ITEM_TYPE_EMPTY -> EmptyViewHolder(inflater, parent)
ITEM_TYPE_GRADE -> GradeViewHolder(inflater, parent)
ITEM_TYPE_STATS -> StatsViewHolder(inflater, parent)
ITEM_TYPE_UNKNOWN_SUBJECT -> UnknownSubjectViewHolder(inflater, parent)
else -> throw IllegalArgumentException("Incorrect viewType")
}
}
@ -69,6 +71,7 @@ class GradesAdapter(
is GradesEmpty -> ITEM_TYPE_EMPTY
is Grade -> ITEM_TYPE_GRADE
is GradesStats -> ITEM_TYPE_STATS
is GradesUnknownSubject -> ITEM_TYPE_UNKNOWN_SUBJECT
else -> throw IllegalArgumentException("Incorrect viewType")
}
}
@ -86,7 +89,7 @@ class GradesAdapter(
fun expandModel(model: ExpandableItemModel<*>?, view: View?, notifyAdapter: Boolean = true) {
model ?: return
val position = items.indexOf(model)
var position = items.indexOf(model)
if (position == -1)
return
@ -138,9 +141,16 @@ class GradesAdapter(
else -> model.items
}
if (model is GradesSubject && model.isUnknown) {
position++
items.add(position, GradesUnknownSubject())
if (notifyAdapter) notifyItemInserted(position)
}
position++
model.state = STATE_OPENED
items.addAll(position + 1, subItems.filterNotNull())
if (notifyAdapter) notifyItemRangeInserted(position + 1, subItems.size)
items.addAll(position, subItems.filterNotNull())
if (notifyAdapter) notifyItemRangeInserted(position, subItems.size)
if (model is GradesSubject) {
// auto expand first semester
@ -156,9 +166,10 @@ class GradesAdapter(
else -> semester.grades
}
position++
semester.state = STATE_OPENED
items.addAll(position + 2 + semesterIndex, grades)
if (notifyAdapter) notifyItemRangeInserted(position + 2 + semesterIndex, grades.size)
items.addAll(position + semesterIndex, grades)
if (notifyAdapter) notifyItemRangeInserted(position + semesterIndex, grades.size)
}
}
}
@ -198,6 +209,7 @@ class GradesAdapter(
is EmptyViewHolder -> ITEM_TYPE_EMPTY
is GradeViewHolder -> ITEM_TYPE_GRADE
is StatsViewHolder -> ITEM_TYPE_STATS
is UnknownSubjectViewHolder -> ITEM_TYPE_UNKNOWN_SUBJECT
else -> throw IllegalArgumentException("Incorrect viewType")
}
holder.itemView.setTag(R.string.tag_key_view_type, viewType)
@ -210,6 +222,7 @@ class GradesAdapter(
holder is EmptyViewHolder && item is GradesEmpty -> holder.onBind(activity, app, item, position, this)
holder is GradeViewHolder && item is GradeFull -> holder.onBind(activity, app, item, position, this)
holder is StatsViewHolder && item is GradesStats -> holder.onBind(activity, app, item, position, this)
holder is UnknownSubjectViewHolder && item is GradesUnknownSubject -> holder.onBind(activity, app, item, position, this)
}
if (holder is SemesterViewHolder && item is GradesSemester) {

View File

@ -182,6 +182,7 @@ class GradesListFragment : Fragment(), CoroutineScope {
@Suppress("SuspendFunctionOnCoroutineScope")
private fun processGrades(grades: List<GradeFull>): MutableList<Any> {
val items = mutableListOf<GradesSubject>()
var unknownSubjectItem: GradesSubject? = null
var subjectId = -1L
var semesterNumber = 0
@ -200,17 +201,31 @@ class GradesListFragment : Fragment(), CoroutineScope {
subjectId = grade.subjectId
semesterNumber = 0
subject = items.firstOrNull { it.subjectId == subjectId }
?: GradesSubject(grade.subjectId, grade.subjectLongName ?: "").also {
subject = items.firstOrNull { it.subjectId == subjectId } ?: run {
if (grade.subjectLongName != null) {
return@run GradesSubject(grade.subjectId, grade.subjectLongName!!).also {
items += it
it.semester = 2
}
}
if (unknownSubjectItem == null) {
unknownSubjectItem = GradesSubject(-1, "unknown").also {
items += it
it.semester = 2
it.isUnknown = true
}
}
return@run unknownSubjectItem!!
}
}
if (grade.semester != semesterNumber) {
semesterNumber = grade.semester
semester = subject.semesters.firstOrNull { it.number == semesterNumber }
?: GradesSemester(subject.subjectId, grade.semester).also { subject.semesters += it }
?: GradesSemester(subject.subjectId, grade.semester).also {
subject.semesters += it
it.hideEditor = subject.isUnknown
}
}
grade.showAsUnseen = !grade.seen
@ -221,6 +236,11 @@ class GradesListFragment : Fragment(), CoroutineScope {
semester.hasUnseen = true
}
if (subject.isUnknown) {
// unknown subjects may have final grades (i.e. Mobidziennik)
grade.type = Grade.TYPE_NORMAL
}
when (grade.type) {
Grade.TYPE_SEMESTER1_PROPOSED,
Grade.TYPE_SEMESTER2_PROPOSED -> semester.proposedGrade = grade
@ -255,6 +275,10 @@ class GradesListFragment : Fragment(), CoroutineScope {
val yearlyPoint = mutableListOf<Float>()
for (item in items) {
if (item.isUnknown) {
// do not count averages for "unknown" subjects
continue
}
item.semesters.forEach { sem ->
manager.calculateAverages(sem.averages)
if (sem.number == 1) {

View File

@ -14,6 +14,7 @@ data class GradesSemester(
override var level = 2
var hasUnseen = false
var hideEditor = false
val averages = GradesAverages()
var proposedGrade: GradeFull? = null

View File

@ -15,6 +15,7 @@ data class GradesSubject(
var lastAddedDate = 0L
var semester: Int = 1
var isUnknown = false
var hasUnseen: Boolean = false
get() = field || semesters.any { it.hasUnseen }

View File

@ -0,0 +1,7 @@
/*
* Copyright (c) Kuba Szczodrzyński 2022-3-14.
*/
package pl.szczodrzynski.edziennik.ui.grades.models
class GradesUnknownSubject

View File

@ -61,6 +61,8 @@ class SemesterViewHolder(
}
}
b.editButton.isVisible = !item.hideEditor
b.average.text = manager.getAverageString(app, item.averages)
b.proposedGrade.setGrade(item.proposedGrade, manager)
b.finalGrade.setGrade(item.finalGrade, manager)

View File

@ -19,9 +19,7 @@ import androidx.recyclerview.widget.RecyclerView
import pl.szczodrzynski.edziennik.App
import pl.szczodrzynski.edziennik.R
import pl.szczodrzynski.edziennik.databinding.GradesItemSubjectBinding
import pl.szczodrzynski.edziennik.ext.dp
import pl.szczodrzynski.edziennik.ext.resolveAttr
import pl.szczodrzynski.edziennik.ext.setText
import pl.szczodrzynski.edziennik.ext.*
import pl.szczodrzynski.edziennik.ui.grades.GradeView
import pl.szczodrzynski.edziennik.ui.grades.GradesAdapter
import pl.szczodrzynski.edziennik.ui.grades.GradesAdapter.Companion.STATE_CLOSED
@ -41,7 +39,12 @@ class SubjectViewHolder(
val manager = app.gradesManager
val contextWrapper = ContextThemeWrapper(activity, Themes.appTheme)
b.subjectName.text = item.subjectName
if (!item.isUnknown) {
b.subjectName.text = item.subjectName
}
else {
b.subjectName.text = R.string.grades_subject_unknown.resolveString(activity).asItalicSpannable()
}
b.dropdownIcon.rotation = when (item.state) {
STATE_CLOSED -> 0f
else -> 180f

View File

@ -0,0 +1,29 @@
/*
* Copyright (c) Kuba Szczodrzyński 2022-3-14.
*/
package pl.szczodrzynski.edziennik.ui.grades.viewholder
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.RecyclerView
import pl.szczodrzynski.edziennik.App
import pl.szczodrzynski.edziennik.databinding.GradesItemUnknownSubjectBinding
import pl.szczodrzynski.edziennik.ui.grades.GradesAdapter
import pl.szczodrzynski.edziennik.ui.grades.models.GradesUnknownSubject
class UnknownSubjectViewHolder(
inflater: LayoutInflater,
parent: ViewGroup,
val b: GradesItemUnknownSubjectBinding = GradesItemUnknownSubjectBinding.inflate(inflater, parent, false)
) : RecyclerView.ViewHolder(b.root), BindableViewHolder<GradesUnknownSubject, GradesAdapter> {
companion object {
private const val TAG = "UnknownSubjectViewHolder"
}
override fun onBind(activity: AppCompatActivity, app: App, item: GradesUnknownSubject, position: Int, adapter: GradesAdapter) {
}
}

View File

@ -85,6 +85,9 @@ class HomeGradesCard(
grades.forEach { grade ->
val model = ItemGradesSubjectModel.searchModelBySubjectId(subjects, grade.subjectId)
?: run {
if (grade.subjectLongName == null) {
return@forEach
}
subjects.add(ItemGradesSubjectModel(
profile,
Subject(profile.id, grade.subjectId, grade.subjectLongName, grade.subjectShortName),

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) Kuba Szczodrzyński 2022-3-14.
-->
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.mikepenz.iconics.view.IconicsTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:text="@string/grades_subject_unknown_help"
android:textColor="?android:textColorSecondary" />
</LinearLayout>
</layout>

View File

@ -1549,4 +1549,6 @@
<string name="card_notes_header_title">Najnowsze notatki</string>
<string name="login_summary_account_child">(uczeń)</string>
<string name="login_summary_account_parent">(rodzic)</string>
<string name="grades_subject_unknown">- nieznany przedmiot -</string>
<string name="grades_subject_unknown_help">{cmd-information-outline} Oceny, których przedmiot nie został podany w dzienniku. Może to być na przykład taki, który nie jest prowadzony w tym roku szkolnym.</string>
</resources>

View File

@ -5,8 +5,8 @@ buildscript {
kotlin_version = '1.5.30'
release = [
versionName: "4.11.3",
versionCode: 4110399
versionName: "4.11.4",
versionCode: 4110499
]
setup = [