Compare commits

...

10 Commits

23 changed files with 88 additions and 32 deletions

View File

@ -1,16 +1,11 @@
<h3>Wersja 4.13-rc.5, 2022-10-25</h3>
<h3>Wersja 4.13.1, 2022-11-03</h3>
<ul>
<li>Poprawione powiadomienia na Androidzie 13. @santoni0</li>
<li>Opcja kolorowania bloków w planie lekcji.</li>
<li><b>USOS</b> - pierwsza wersja obsługi systemu. Osobne rodzaje wydarzeń (oraz wygląd niektórych części aplikacji) lepiej dostosowany do nauki na studiach.</li>
<li>Możliwość dostosowania wyświetlania planu lekcji.</li>
<li>Opcja ustawienia nowych wydarzeń domyślnie jako udostępnione.</li>
<li>Poprawione udostępnianie notatek dotyczących danej lekcji</li>
<li>Bardziej czytelna legenda rodzaju udostępnionego wydarzenia.</li>
<li>Poprawione opcje filtrowania powiadomień i wyboru przycisków menu bocznego.</li>
<li>Ulepszony system pobierania aktualizacji aplikacji.</li>
<li>Edycja kart na stronie głównej znowu działa.</li>
<li>Poprawiono pobieranie nauczyciela w zakładce Uwagi. @BxOxSxS</li>
<li>Poprawiono oznaczanie daty przeczytania wiadomości wysłanych. @BxOxSxS</li>
<li>Dodano tłumaczenie karty planu lekcji. @MedzikUser</li>
</ul>
<br>
<br>
Dzięki za korzystanie ze Szkolnego!<br>
<i>&copy; [Kuba Szczodrzyński](@kuba2k2), [Kacper Ziubryniewicz](@kapi2289) 2022</i>
<i>&copy; [Kuba Szczodrzyński](@kuba2k2) 2022</i>

View File

@ -9,7 +9,7 @@
/*secret password - removed for source code publication*/
static toys AES_IV[16] = {
0x2f, 0xc0, 0xca, 0x16, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
0xe8, 0x2b, 0x2c, 0xd8, 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

@ -14,6 +14,7 @@ import pl.szczodrzynski.edziennik.ext.takePositive
import kotlin.coroutines.CoroutineContext
abstract class BaseConfig(
@Transient
val db: AppDb,
val profileId: Int? = null,
protected var entries: List<ConfigEntry>? = null,

View File

@ -33,7 +33,7 @@ class Config(db: AppDb) : BaseConfig(db) {
var update by config<Update?>(null)
var updatesChannel by config<String>("release")
var devMode by config<Boolean?>(null)
var devMode by config<Boolean?>("debugMode", null)
var devModePassword by config<String?>(null)
var enableChucker by config<Boolean?>(null)

View File

@ -115,9 +115,9 @@ class ConfigDelegate<T>(
is Boolean -> value
// enums, maps & collections
is Enum<*> -> value.toInt()
is Collection<*> -> JsonArray(value.map {
is Collection<*> -> value.map {
if (it is Number || it is Boolean) it else serialize(it, serializeObjects = false)
})
}.toJsonElement()
is Map<*, *> -> gson.toJson(value.mapValues { (_, it) ->
if (it is Number || it is Boolean) it else serialize(it, serializeObjects = false)
})

View File

@ -36,7 +36,7 @@ class LibrusApiNotices(override val data: DataLibrus,
val id = note.getLong("Id") ?: return@forEach
val text = note.getString("Text") ?: ""
val categoryId = note.getJsonObject("Category")?.getLong("Id") ?: -1
val teacherId = note.getJsonObject("AddedBy")?.getLong("Id") ?: -1
val teacherId = note.getJsonObject("Teacher")?.getLong("Id") ?: -1
val addedDate = note.getString("Date")?.let { Date.fromY_m_d(it) } ?: return@forEach
val type = when (note.getInt("Positive")) {

View File

@ -125,7 +125,7 @@ class LibrusMessagesGetMessage(override val data: DataLibrus,
val receiverId = teacher?.id ?: -1
teacher?.loginId = receiverLoginId
val readDateText = message.select("readed").text()
val readDateText = receiver.select("readed").text()
val readDate = when (readDateText.isNotNullNorEmpty()) {
true -> Date.fromIso(readDateText)
else -> 0

View File

@ -324,11 +324,14 @@ class SzkolnyApi(val app: App) : CoroutineScope {
}
@Throws(Exception::class)
fun shareNote(note: Note) {
fun shareNote(note: Note, teamId: Long? = null) {
val profile = app.db.profileDao().getByIdNow(note.profileId)
?: throw NullPointerException("Profile is not found")
val team = app.db.teamDao().getClassNow(note.profileId)
?: throw NullPointerException("TeamClass is not found")
val team = if (teamId == null)
app.db.teamDao().getClassNow(note.profileId)
else
app.db.teamDao().getByIdNow(note.profileId, teamId)
team ?: throw NullPointerException("TeamClass is not found")
val response = api.shareNote(NoteShareRequest(
deviceId = app.deviceId,

View File

@ -46,6 +46,6 @@ object Signing {
/*fun provideKey(param1: String, param2: Long): ByteArray {*/
fun pleaseStopRightNow(param1: String, param2: Long): ByteArray {
return "$param1.MTIzNDU2Nzg5MDF1TqH/cn===.$param2".sha256()
return "$param1.MTIzNDU2Nzg5MDsJslqno5===.$param2".sha256()
}
}

View File

@ -9,6 +9,7 @@ interface Noteable {
fun getNoteType(): Note.OwnerType
fun getNoteOwnerProfileId(): Int
fun getNoteOwnerId(): Long
fun getNoteShareTeamId(): Long? = null
var notes: MutableList<Note>

View File

@ -91,6 +91,7 @@ open class Profile(
get() = registration == REGISTRATION_ENABLED && !archived
@delegate:Ignore
@delegate:Transient
val config by lazy { App.config[this.id] }
override fun getImageDrawable(context: Context) = this.getDrawable(context)

View File

@ -9,6 +9,7 @@ import pl.szczodrzynski.edziennik.data.db.entity.Event
import pl.szczodrzynski.edziennik.data.db.entity.Metadata
import pl.szczodrzynski.edziennik.data.db.entity.Note
import pl.szczodrzynski.edziennik.data.db.entity.Noteable
import pl.szczodrzynski.edziennik.ext.takePositive
import pl.szczodrzynski.edziennik.ui.search.Searchable
import pl.szczodrzynski.edziennik.utils.html.BetterHtml
import pl.szczodrzynski.edziennik.utils.models.Date
@ -118,4 +119,5 @@ class EventFull(
override fun getNoteType() = Note.OwnerType.EVENT
override fun getNoteOwnerProfileId() = profileId
override fun getNoteOwnerId() = id
override fun getNoteShareTeamId() = teamId.takePositive()
}

View File

@ -9,6 +9,7 @@ import pl.szczodrzynski.edziennik.R
import pl.szczodrzynski.edziennik.data.db.entity.Lesson
import pl.szczodrzynski.edziennik.data.db.entity.Note
import pl.szczodrzynski.edziennik.data.db.entity.Noteable
import pl.szczodrzynski.edziennik.ext.takePositive
import pl.szczodrzynski.edziennik.utils.models.Time
class LessonFull(
@ -142,4 +143,5 @@ class LessonFull(
override fun getNoteType() = Note.OwnerType.LESSON
override fun getNoteOwnerProfileId() = profileId
override fun getNoteOwnerId() = ownerId
override fun getNoteShareTeamId() = teamId.takePositive()
}

View File

@ -5,6 +5,7 @@
package pl.szczodrzynski.edziennik.ext
import android.os.Bundle
import com.google.gson.Gson
import com.google.gson.JsonArray
import com.google.gson.JsonElement
import com.google.gson.JsonObject
@ -48,6 +49,11 @@ fun JsonObject.putEnum(key: String, value: Enum<*>) = addProperty(key, value.toI
fun String.toJsonObject(): JsonObject? = try { JsonParser.parseString(this).asJsonObject } catch (ignore: Exception) { null }
fun String.toJsonArray(): JsonArray? = try { JsonParser.parseString(this).asJsonArray } catch (ignore: Exception) { null }
fun Any?.toJsonElement(): JsonElement = when (this) {
is Collection<*> -> JsonArray(this)
else -> Gson().toJsonTree(this)
}
operator fun JsonObject.set(key: String, value: JsonElement) = this.add(key, value)
operator fun JsonObject.set(key: String, value: Boolean) = this.addProperty(key, value)
operator fun JsonObject.set(key: String, value: String?) = this.addProperty(key, value)
@ -67,6 +73,7 @@ fun JsonObject(vararg properties: Pair<String, Any?>): JsonObject {
is Number -> addProperty(key, value)
is Boolean -> addProperty(key, value)
is Enum<*> -> addProperty(key, value.toInt())
else -> add(key, property.toJsonElement())
}
}
}
@ -98,6 +105,8 @@ fun JsonArray(properties: Collection<Any?>): JsonArray {
is Char -> add(property as Char?)
is Number -> add(property as Number?)
is Boolean -> add(property as Boolean?)
is Enum<*> -> add(property.toInt())
else -> add(property.toJsonElement())
}
}
}

View File

@ -76,6 +76,9 @@ fun pendingIntentFlag(): Int {
fun Int?.takeValue() = if (this == -1) null else this
fun Int?.takePositive() = if (this == -1 || this == 0) null else this
fun Long?.takeValue() = if (this == -1L) null else this
fun Long?.takePositive() = if (this == -1L || this == 0L) null else this
fun String?.takeValue() = if (this.isNullOrBlank()) null else this
fun Any?.ignore() = Unit

View File

@ -75,6 +75,7 @@ class HomeTimetableCard(
private var counterJob: Job? = null
private var counterStart: Time? = null
private var counterEnd: Time? = null
private var showAllLessons: Boolean = false
private var subjectSpannable: CharSequence? = null
private val ignoreCancelled = false
@ -276,6 +277,8 @@ class HomeTimetableCard(
counterJob = startCoroutineTimer(repeatMillis = 500) {
count()
}
showAllLessons = !isOngoing
}
else {
val isTomorrow = today.clone().stepForward(0, 0, 1) == timetableDate
@ -312,12 +315,22 @@ class HomeTimetableCard(
} ?: run {
b.classroom.visibility = View.GONE
}
showAllLessons = true
}
val text = mutableListOf<CharSequence>(
if (showAllLessons)
activity.getString(R.string.home_timetable_all_lessons)
else
activity.getString(R.string.home_timetable_later)
)
val nextLessons = lessons.drop(skipFirst + 1)
val nextLessons = if (showAllLessons)
lessons.drop(skipFirst)
else
lessons.drop(skipFirst + 1)
for (lesson in nextLessons) {
text += listOf(
lesson.displayStartTime?.stringHM,
@ -348,6 +361,14 @@ class HomeTimetableCard(
}
val now = syncedNow
if (now >= counterStart && showAllLessons) {
// update "next lessons" view to remove current lesson
this.counterJob?.cancel()
this.counterStart = null
this.counterEnd = null
update()
return
}
if (now > counterEnd) {
// the lesson is already over
b.progress.visibility = View.GONE

View File

@ -87,7 +87,12 @@ class NoteEditorDialog(
.show()
}
val success = manager.saveNote(activity, note, wasShared = editingNote?.isShared ?: false)
val success = manager.saveNote(
activity = activity,
note = note,
teamId = owner?.getNoteShareTeamId(),
wasShared = editingNote?.isShared ?: false,
)
progressDialog?.dismiss()
return success
}

View File

@ -93,10 +93,15 @@ class NoteManager(private val app: App) {
return getOwner(note) != null
}
suspend fun saveNote(activity: AppCompatActivity, note: Note, wasShared: Boolean): Boolean {
suspend fun saveNote(
activity: AppCompatActivity,
note: Note,
teamId: Long?,
wasShared: Boolean,
): Boolean {
val success = when {
!note.isShared && wasShared -> unshareNote(activity, note)
note.isShared -> shareNote(activity, note)
note.isShared -> shareNote(activity, note, teamId)
else -> true
}
@ -124,9 +129,9 @@ class NoteManager(private val app: App) {
return true
}
private suspend fun shareNote(activity: AppCompatActivity, note: Note): Boolean {
private suspend fun shareNote(activity: AppCompatActivity, note: Note, teamId: Long?): Boolean {
return app.api.runCatching(activity) {
shareNote(note)
shareNote(note, teamId)
} != null
}

View File

@ -426,4 +426,10 @@ public class Date implements Comparable<Date>, Noteable {
public boolean hasReplacingNotes() {
return Noteable.DefaultImpls.hasReplacingNotes(this);
}
@Nullable
@Override
public Long getNoteShareTeamId() {
return Noteable.DefaultImpls.getNoteShareTeamId(this);
}
}

View File

@ -847,7 +847,7 @@
<string name="settings_about_licenses_text">Open-Source-Lizenzen</string>
<string name="settings_about_privacy_policy_text">Datenschutzrichtlinie</string>
<string name="settings_card_register_title">E-Klassenbuch</string>
<string name="settings_about_title_subtext">© Kuba Szczodrzyński &amp;&amp; Kacper Ziubryniewicz\nSeptember 2018 - 2022</string>
<string name="settings_about_title_subtext">© Kuba Szczodrzyński, September 2018 - 2022</string>
<string name="settings_about_update_subtext">Klicken Sie hier, um nach Aktualisierungen zu suchen</string>
<string name="settings_about_update_text">Aktualisierung</string>
<string name="settings_about_version_text">Version</string>

View File

@ -849,7 +849,7 @@
<string name="settings_about_licenses_text">Open-source licenses</string>
<string name="settings_about_privacy_policy_text">Privacy policy</string>
<string name="settings_card_register_title">E-register</string>
<string name="settings_about_title_subtext">© Kuba Szczodrzyński &amp;&amp; Kacper Ziubryniewicz\nSeptember 2018 2022</string>
<string name="settings_about_title_subtext">© Kuba Szczodrzyński, September 2018 2022</string>
<string name="settings_about_update_subtext">Click to check for updates</string>
<string name="settings_about_update_text">Update</string>
<string name="settings_about_version_text">Version</string>
@ -1433,4 +1433,5 @@
<string name="dialog_lesson_attendance_details">Details</string>
<string name="menu_agenda_config">Agenda settings</string>
<string name="registration_config_note_sharing_title">Share notes</string>
<string name="home_timetable_all_lessons">All lessons:</string>
</resources>

View File

@ -916,7 +916,7 @@
<string name="settings_about_licenses_text">Licencje open-source</string>
<string name="settings_about_privacy_policy_text">Polityka prywatności</string>
<string name="settings_card_register_title">E-dziennik</string>
<string name="settings_about_title_subtext">© Kuba Szczodrzyński &amp;&amp; Kacper Ziubryniewicz\nwrzesień 2018 - 2022</string>
<string name="settings_about_title_subtext">© Kuba Szczodrzyński, wrzesień 2018 - 2022</string>
<string name="settings_about_update_subtext">Kliknij, aby sprawdzić aktualizacje</string>
<string name="settings_about_update_text">Aktualizacja</string>
<string name="settings_about_version_text">Wersja</string>
@ -1550,4 +1550,5 @@
<string name="settings_register_share_by_default_text">Domyślnie udostępniaj wydarzenia</string>
<string name="settings_register_share_by_default_subtext">Ustaw tworzone wydarzenia domyślnie jako udostępnione</string>
<string name="settings_registration_section">Rejestracja</string>
<string name="home_timetable_all_lessons">Wszystkie lekcje:</string>
</resources>

View File

@ -5,8 +5,8 @@ buildscript {
kotlin_version = '1.6.10'
release = [
versionName: "4.13-rc.5",
versionCode: 4130050
versionName: "4.13.1",
versionCode: 4130199
]
setup = [