Compare commits

...

8 Commits

Author SHA1 Message Date
Kuba Szczodrzyński
96da698551
[4.14.2] Update build.gradle, signing and changelog 2025-02-25 17:57:46 +01:00
KrystianQur
ee30232530
[API/Librus] Fix TeacherFreeDays API problems (#215)
* [Librus] Fix TeacherFreeDays API problems

* [Librus] Small Teacher Free Days Bug fix & improvement

* [Librus] Implementation fix

* Apply suggestions from code review

---------

Co-authored-by: Kuba Szczodrzyński <kuba@szczodrzynski.pl>
2025-02-23 22:19:19 +01:00
Kuba Szczodrzyński
988d7cac76
[4.14.1] Update build.gradle, signing and changelog 2025-02-05 18:17:10 +01:00
Kuba Szczodrzyński
2f029c096f
[UI/Widgets] Set FLAG_UPDATE_CURRENT on pending intents 2025-02-05 18:14:40 +01:00
Adam Rurański
908959f7ee
[UI] Make snowfall condition consistent (#195) 2025-02-05 18:14:13 +01:00
Kuba Szczodrzyński
d1ae14a65c
[App] Set RECEIVER_EXPORTED flag on registerReceiver() 2025-02-05 18:09:14 +01:00
Kuba Szczodrzyński
541979dcd6
[App] Add foreground service type to services 2025-02-05 17:51:40 +01:00
Kuba Szczodrzyński
f65d01de1b
[App] Update target SDK to 34 2025-02-02 18:13:47 +01:00
16 changed files with 56 additions and 23 deletions

View File

@ -13,6 +13,7 @@
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
<!-- PowerPermission uses minSdk 21, it's safe to override as it is used only in >= 23 -->
<uses-sdk tools:overrideLibrary="com.qifan.powerpermission.coroutines, com.qifan.powerpermission.core" />
@ -84,7 +85,7 @@
android:resource="@xml/widget_timetable_info" />
</receiver>
<service android:name=".ui.widgets.timetable.WidgetTimetableService"
android:permission="android.permission.BIND_REMOTEVIEWS" />
android:permission="android.permission.BIND_REMOTEVIEWS" android:foregroundServiceType="dataSync" />
<activity android:name=".ui.widgets.LessonDialogActivity"
android:label=""
android:configChanges="orientation|keyboardHidden"
@ -105,7 +106,7 @@
android:resource="@xml/widget_notifications_info" />
</receiver>
<service android:name=".ui.widgets.notifications.WidgetNotificationsService"
android:permission="android.permission.BIND_REMOTEVIEWS" />
android:permission="android.permission.BIND_REMOTEVIEWS" android:foregroundServiceType="dataSync" />
<!-- LUCKY NUMBER -->
<receiver android:name=".ui.widgets.luckynumber.WidgetLuckyNumberProvider"
android:label="@string/widget_lucky_number_title"
@ -202,15 +203,15 @@
____) | __/ | \ V /| | (_| __/\__ \
|_____/ \___|_| \_/ |_|\___\___||___/
-->
<service android:name=".data.api.ApiService" />
<service android:name=".data.api.ApiService" android:foregroundServiceType="dataSync" />
<service android:name=".data.firebase.MyFirebaseService"
android:exported="false">
android:exported="false" android:foregroundServiceType="dataSync">
<intent-filter android:priority="10000000">
<action android:name="com.google.firebase.MESSAGING_EVENT" />
<action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
</intent-filter>
</service>
<service android:name=".sync.UpdateDownloaderService" />
<service android:name=".sync.UpdateDownloaderService" android:foregroundServiceType="dataSync" />
<!--
_____ _ _

View File

@ -1,9 +1,12 @@
<h3>Wersja 4.14, 2025-02-02</h3>
<h3>Wersja 4.14.2, 2025-02-25</h3>
<ul>
<li>USOS: <b>dodano obsługę ocen</b>.</li>
<li>USOS: obliczanie średniej za studia oraz punktów ECTS.</li>
<li>USOS: poprawiono brak planu zajęć po rozpoczęciu roku.</li>
<li>Wyłączono archiwizator profili.</li>
<li>Naprawiono zatrzymanie aplikacji na Androidzie 14.</li>
<li>Udostępniono opcję wyłączania śniegu również w lutym.</li>
<li>Poprawiono błędy synchronizacji. @KrystianQur</li>
</ul>
<br>
<br>

View File

@ -9,7 +9,7 @@
/*secret password - removed for source code publication*/
static toys AES_IV[16] = {
0xee, 0x23, 0xf1, 0x03, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
0x3e, 0x4b, 0xe4, 0xc4, 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

@ -15,6 +15,8 @@ import android.view.Gravity
import android.view.View
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat
import androidx.core.graphics.ColorUtils
import androidx.core.view.isVisible
import androidx.navigation.NavOptions
@ -829,7 +831,12 @@ class MainActivity : AppCompatActivity(), CoroutineScope {
d(TAG, "Activity resumed")
val filter = IntentFilter()
filter.addAction(Intent.ACTION_MAIN)
registerReceiver(intentReceiver, filter)
ActivityCompat.registerReceiver(
this,
intentReceiver,
filter,
ContextCompat.RECEIVER_EXPORTED,
)
EventBus.getDefault().register(this)
super.onResume()
}

View File

@ -148,6 +148,7 @@ const val ERROR_LIBRUS_MESSAGES_NOT_FOUND = 186
const val ERROR_LOGIN_LIBRUS_API_INVALID_REQUEST = 187
const val ERROR_LIBRUS_MESSAGES_ATTACHMENT_NOT_FOUND = 188
const val ERROR_LOGIN_LIBRUS_MESSAGES_TIMEOUT = 189
const val ERROR_LIBRUS_API_TEACHER_FREE_DAYS_NOT_PUBLIC = 190
const val ERROR_LOGIN_MOBIDZIENNIK_WEB_INVALID_LOGIN = 201
const val ERROR_LOGIN_MOBIDZIENNIK_WEB_OLD_PASSWORD = 202

View File

@ -29,6 +29,9 @@ import pl.szczodrzynski.edziennik.data.db.enums.LoginMethod
import pl.szczodrzynski.edziennik.data.db.full.AnnouncementFull
import pl.szczodrzynski.edziennik.data.db.full.EventFull
import pl.szczodrzynski.edziennik.data.db.full.MessageFull
import pl.szczodrzynski.edziennik.ext.DAY
import pl.szczodrzynski.edziennik.ext.HOUR
import pl.szczodrzynski.edziennik.ext.WEEK
import pl.szczodrzynski.edziennik.utils.Utils.d
class Librus(val app: App, val profile: Profile?, val loginStore: LoginStore, val callback: EdziennikCallback) : EdziennikInterface {
@ -235,6 +238,11 @@ class Librus(val app: App, val profile: Profile?, val loginStore: LoginStore, va
data.app.config.sync.tokenLibrusList + data.profileId
data()
}
ERROR_LIBRUS_API_TEACHER_FREE_DAYS_NOT_PUBLIC -> {
d(TAG, "Student not have access to Teacher Free Days resource")
data.setSyncNext(ENDPOINT_LIBRUS_API_TEACHER_FREE_DAYS, 1 * WEEK, FeatureType.AGENDA)
data()
}
else -> callback.onError(apiError)
}
}

View File

@ -69,6 +69,7 @@ open class LibrusApi(open val data: DataLibrus, open val lastSync: Long?) {
"NoticeboardProblem" -> ERROR_LIBRUS_API_NOTICEBOARD_PROBLEM
"DeviceRegistered" -> ERROR_LIBRUS_API_DEVICE_REGISTERED
"Maintenance" -> ERROR_LIBRUS_API_MAINTENANCE
"TeacherFreeDaysIsNotActive" -> ERROR_LIBRUS_API_TEACHER_FREE_DAYS_NOT_PUBLIC
else -> ERROR_LIBRUS_API_OTHER
}.let { errorCode ->
if (errorCode !in ignoreErrors) {

View File

@ -29,7 +29,7 @@ class LibrusApiTeacherFreeDays(override val data: DataLibrus,
data.db.teacherAbsenceTypeDao().getAllNow(profileId).toSparseArray(data.teacherAbsenceTypes) { it.id }
}
apiGet(TAG, "TeacherFreeDays") { json ->
apiGet(TAG, "Calendars/TeacherFreeDays") { json ->
val teacherAbsences = json.getJsonArray("TeacherFreeDays")?.asJsonObjectList()
teacherAbsences?.forEach { teacherAbsence ->

View File

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

View File

@ -66,9 +66,7 @@ class AttendanceBar : View {
}
@SuppressLint("DrawAllocation", "CanvasSize")
override fun onDraw(canvas: Canvas?) {
canvas ?: return
override fun onDraw(canvas: Canvas) {
val sum = attendancesList.sumOf { it.count }
if (sum == 0) {
return

View File

@ -26,7 +26,7 @@ class SettingsThemeCard(util: SettingsUtil) : SettingsCard(util) {
)
override fun getItems(card: MaterialAboutCard) = listOfNotNull(
if (Date.getToday().month % 11 == 1) // cool math games
if (Date.getToday().month / 3 % 4 == 0) // cool math games
util.createPropertyItem(
text = R.string.settings_theme_snowfall_text,
subText = R.string.settings_theme_snowfall_subtext,

View File

@ -388,7 +388,7 @@ class GenerateBlockTimetableDialog(
try {
val uri = resolver.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values) ?: return@withContext null
resolver.openOutputStream(uri).use {
bitmap.compress(Bitmap.CompressFormat.PNG, 100, it)
bitmap.compress(Bitmap.CompressFormat.PNG, 100, it ?: return@use)
}
uri
} catch (e: Exception) {

View File

@ -14,6 +14,8 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat
import androidx.fragment.app.Fragment
import androidx.viewpager.widget.ViewPager
import com.google.android.material.datepicker.MaterialDatePicker
@ -90,8 +92,18 @@ class TimetableFragment : Fragment(), CoroutineScope {
}
override fun onResume() {
super.onResume()
activity.registerReceiver(broadcastReceiver, IntentFilter(ACTION_SCROLL_TO_DATE))
activity.registerReceiver(broadcastReceiver, IntentFilter(ACTION_RELOAD_PAGES))
ActivityCompat.registerReceiver(
activity,
broadcastReceiver,
IntentFilter(ACTION_SCROLL_TO_DATE),
ContextCompat.RECEIVER_EXPORTED
)
ActivityCompat.registerReceiver(
activity,
broadcastReceiver,
IntentFilter(ACTION_RELOAD_PAGES),
ContextCompat.RECEIVER_EXPORTED
)
}
override fun onPause() {
super.onPause()

View File

@ -5,6 +5,7 @@
package pl.szczodrzynski.edziennik.ui.widgets.timetable
import android.app.PendingIntent
import android.app.PendingIntent.FLAG_UPDATE_CURRENT
import android.appwidget.AppWidgetManager
import android.appwidget.AppWidgetProvider
import android.content.ComponentName
@ -395,7 +396,7 @@ class WidgetTimetableProvider : AppWidgetProvider() {
}
}
headerIntent.putExtras("fragmentId" to NavTarget.TIMETABLE)
val headerPendingIntent = PendingIntent.getActivity(app, appWidgetId, headerIntent, pendingIntentMutable())
val headerPendingIntent = PendingIntent.getActivity(app, appWidgetId, headerIntent, FLAG_UPDATE_CURRENT or pendingIntentMutable())
views.setOnClickPendingIntent(R.id.widgetTimetableHeader, headerPendingIntent)
timetables!!.put(appWidgetId, models)
@ -409,7 +410,7 @@ class WidgetTimetableProvider : AppWidgetProvider() {
// create an intent used to display the lesson details dialog
val itemIntent = Intent(app, LessonDialogActivity::class.java)
itemIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK/* or Intent.FLAG_ACTIVITY_CLEAR_TASK*/)
val itemPendingIntent = PendingIntent.getActivity(app, appWidgetId, itemIntent, pendingIntentMutable())
val itemPendingIntent = PendingIntent.getActivity(app, appWidgetId, itemIntent, FLAG_UPDATE_CURRENT or pendingIntentMutable())
views.setPendingIntentTemplate(R.id.widgetTimetableListView, itemPendingIntent)
if (!unified)

View File

@ -120,6 +120,7 @@
<string name="error_187" translatable="false">ERROR_LOGIN_LIBRUS_API_INVALID_REQUEST</string>
<string name="error_188" translatable="false">ERROR_LIBRUS_MESSAGES_ATTACHMENT_NOT_FOUND</string>
<string name="error_189" translatable="false">ERROR_LOGIN_LIBRUS_MESSAGES_TIMEOUT</string>
<string name="error_190" translatable="false">ERROR_LIBRUS_API_TEACHER_FREE_DAYS_NOT_PUBLIC</string>
<string name="error_201" translatable="false">ERROR_LOGIN_MOBIDZIENNIK_WEB_INVALID_LOGIN</string>
<string name="error_202" translatable="false">ERROR_LOGIN_MOBIDZIENNIK_WEB_OLD_PASSWORD</string>

View File

@ -5,14 +5,14 @@ buildscript {
kotlin_version = '1.6.10'
release = [
versionName: "4.14",
versionCode: 4140099
versionName: "4.14.2",
versionCode: 4140299
]
setup = [
compileSdk: 33,
compileSdk: 34,
minSdk : 16,
targetSdk : 33
targetSdk : 34
]
}