From 5b5dc5cadee17426fffba0d0c7e183e41cdba34c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Szczodrzy=C5=84ski?= Date: Mon, 21 Feb 2022 20:19:29 +0100 Subject: [PATCH 1/5] [Gradle] Add non-Play flavor without self-updater. --- app/build.gradle | 17 ++++++++++++-- .../edziennik/sync/UpdateDownloaderService.kt | 0 .../edziennik/sync/UpdateDownloaderService.kt | 23 +++++++++++++++++++ 3 files changed, 38 insertions(+), 2 deletions(-) rename app/src/{main => play-not}/java/pl/szczodrzynski/edziennik/sync/UpdateDownloaderService.kt (100%) create mode 100644 app/src/play/java/pl/szczodrzynski/edziennik/sync/UpdateDownloaderService.kt diff --git a/app/build.gradle b/app/build.gradle index ecf9159d..ed17da34 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -41,6 +41,7 @@ android { buildTypes { debug { + getIsDefault().set(true) minifyEnabled = false manifestPlaceholders = [ buildTimestamp: 0 @@ -55,7 +56,8 @@ android { } flavorDimensions "platform" productFlavors { - main { + unofficial { + getIsDefault().set(true) versionName "${release.versionName}-${gitInfo.versionSuffix}" } official {} @@ -63,7 +65,18 @@ android { } variantFilter { variant -> def flavors = variant.flavors*.name - setIgnore(variant.buildType.name == "debug" && !flavors.contains("main")) + setIgnore(variant.buildType.name == "debug" && !flavors.contains("unofficial") || flavors.contains("main")) + } + sourceSets { + unofficial { + java.srcDirs = ["src/main/java", "src/play-not/java"] + } + official { + java.srcDirs = ["src/main/java", "src/play-not/java"] + } + play { + java.srcDirs = ["src/main/java", "src/play/java"] + } } defaultConfig { diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/sync/UpdateDownloaderService.kt b/app/src/play-not/java/pl/szczodrzynski/edziennik/sync/UpdateDownloaderService.kt similarity index 100% rename from app/src/main/java/pl/szczodrzynski/edziennik/sync/UpdateDownloaderService.kt rename to app/src/play-not/java/pl/szczodrzynski/edziennik/sync/UpdateDownloaderService.kt diff --git a/app/src/play/java/pl/szczodrzynski/edziennik/sync/UpdateDownloaderService.kt b/app/src/play/java/pl/szczodrzynski/edziennik/sync/UpdateDownloaderService.kt new file mode 100644 index 00000000..4b7f4342 --- /dev/null +++ b/app/src/play/java/pl/szczodrzynski/edziennik/sync/UpdateDownloaderService.kt @@ -0,0 +1,23 @@ +/* + * Copyright (c) Kuba Szczodrzyński 2022-2-21. + */ + +package pl.szczodrzynski.edziennik.sync + +import android.app.IntentService +import android.content.Intent +import android.widget.Toast +import pl.szczodrzynski.edziennik.utils.Utils + +class UpdateDownloaderService : IntentService(UpdateDownloaderService::class.java.simpleName) { + + override fun onHandleIntent(intent: Intent?) { + try { + Utils.openGooglePlay(this, application.packageName) + } + catch (e: Exception) { + e.printStackTrace() + Toast.makeText(this, "Nie znaleziono Google Play. Pobierz aktualizację ręcznie.", Toast.LENGTH_SHORT).show() + } + } +} From 1bf0679e9237dc3b076f18fca05a977aaae25408 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Szczodrzy=C5=84ski?= Date: Mon, 21 Feb 2022 20:36:11 +0100 Subject: [PATCH 2/5] [App] Disable SSLProvider in Google Play builds. --- app/build.gradle | 3 +- .../java/pl/szczodrzynski/edziennik/App.kt | 20 +++-------- .../edziennik/network/SSLProviderInstaller.kt | 33 +++++++++++++++++++ .../edziennik/network/SSLProviderInstaller.kt | 19 +++++++++++ 4 files changed, 58 insertions(+), 17 deletions(-) create mode 100644 app/src/play-not/java/pl/szczodrzynski/edziennik/network/SSLProviderInstaller.kt create mode 100644 app/src/play/java/pl/szczodrzynski/edziennik/network/SSLProviderInstaller.kt diff --git a/app/build.gradle b/app/build.gradle index ed17da34..7635b8c1 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -183,7 +183,8 @@ dependencies { implementation "eu.szkolny:mhttp:af4b62e6e9" implementation "eu.szkolny:nachos:0e5dfcaceb" implementation "eu.szkolny.selective-dao:annotation:27f8f3f194" - implementation "eu.szkolny:ssl-provider:1.0.0" + officialImplementation "eu.szkolny:ssl-provider:1.0.0" + unofficialImplementation "eu.szkolny:ssl-provider:1.0.0" implementation "pl.szczodrzynski:navlib:0.8.0" implementation "pl.szczodrzynski:numberslidingpicker:2921225f76" implementation "pl.szczodrzynski:recyclertablayout:700f980584" diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/App.kt b/app/src/main/java/pl/szczodrzynski/edziennik/App.kt index 78f27450..56886775 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/App.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/App.kt @@ -26,8 +26,6 @@ import com.google.firebase.messaging.FirebaseMessaging import com.google.gson.Gson import com.hypertrack.hyperlog.HyperLog import com.mikepenz.iconics.Iconics -import eu.szkolny.sslprovider.SSLProvider -import eu.szkolny.sslprovider.enableSupportedTls import im.wangchao.mhttp.MHttp import kotlinx.coroutines.* import me.leolin.shortcutbadger.ShortcutBadger @@ -42,6 +40,7 @@ import pl.szczodrzynski.edziennik.data.db.entity.Profile import pl.szczodrzynski.edziennik.ext.DAY import pl.szczodrzynski.edziennik.ext.MS import pl.szczodrzynski.edziennik.ext.setLanguage +import pl.szczodrzynski.edziennik.network.SSLProviderInstaller import pl.szczodrzynski.edziennik.network.cookie.DumbCookieJar import pl.szczodrzynski.edziennik.sync.SyncWorker import pl.szczodrzynski.edziennik.sync.UpdateWorker @@ -49,7 +48,6 @@ import pl.szczodrzynski.edziennik.ui.base.CrashActivity import pl.szczodrzynski.edziennik.utils.* import pl.szczodrzynski.edziennik.utils.Utils.d import pl.szczodrzynski.edziennik.utils.managers.* -import timber.log.Timber import java.util.concurrent.TimeUnit import kotlin.coroutines.CoroutineContext @@ -119,7 +117,8 @@ class App : MultiDexApplication(), Configuration.Provider, CoroutineScope { .connectTimeout(15, TimeUnit.SECONDS) .writeTimeout(10, TimeUnit.SECONDS) .readTimeout(30, TimeUnit.SECONDS) - .enableSupportedTls(enableCleartext = true) + + SSLProviderInstaller.enableSupportedTls(builder, enableCleartext = true) if (devMode) { HyperLog.initialize(this) @@ -203,18 +202,7 @@ class App : MultiDexApplication(), Configuration.Provider, CoroutineScope { withContext(Dispatchers.Default) { config.migrate(this@App) - SSLProvider.install( - applicationContext, - downloadIfNeeded = true, - supportTls13 = false, - onFinish = { - buildHttp() - }, - onError = { - Timber.e("Failed to install SSLProvider: $it") - it.printStackTrace() - } - ) + SSLProviderInstaller.install(applicationContext, this@App::buildHttp) if (config.devModePassword != null) checkDevModePassword() diff --git a/app/src/play-not/java/pl/szczodrzynski/edziennik/network/SSLProviderInstaller.kt b/app/src/play-not/java/pl/szczodrzynski/edziennik/network/SSLProviderInstaller.kt new file mode 100644 index 00000000..a18243b1 --- /dev/null +++ b/app/src/play-not/java/pl/szczodrzynski/edziennik/network/SSLProviderInstaller.kt @@ -0,0 +1,33 @@ +/* + * Copyright (c) Kuba Szczodrzyński 2022-2-21. + */ + +package pl.szczodrzynski.edziennik.network + +import android.content.Context +import eu.szkolny.sslprovider.SSLProvider +import eu.szkolny.sslprovider.enableSupportedTls +import okhttp3.OkHttpClient +import timber.log.Timber + +object SSLProviderInstaller { + + fun install(applicationContext: Context, rebuildCallback: () -> Unit) { + SSLProvider.install( + applicationContext, + downloadIfNeeded = true, + supportTls13 = false, + onFinish = { + rebuildCallback() + }, + onError = { + Timber.e("Failed to install SSLProvider: $it") + it.printStackTrace() + } + ) + } + + fun enableSupportedTls(builder: OkHttpClient.Builder, enableCleartext: Boolean = true) { + builder.enableSupportedTls(enableCleartext) + } +} diff --git a/app/src/play/java/pl/szczodrzynski/edziennik/network/SSLProviderInstaller.kt b/app/src/play/java/pl/szczodrzynski/edziennik/network/SSLProviderInstaller.kt new file mode 100644 index 00000000..53b4e769 --- /dev/null +++ b/app/src/play/java/pl/szczodrzynski/edziennik/network/SSLProviderInstaller.kt @@ -0,0 +1,19 @@ +/* + * Copyright (c) Kuba Szczodrzyński 2022-2-21. + */ + +package pl.szczodrzynski.edziennik.network + +import android.content.Context +import okhttp3.OkHttpClient + +object SSLProviderInstaller { + + fun install(applicationContext: Context, rebuildCallback: () -> Unit) { + + } + + fun enableSupportedTls(builder: OkHttpClient.Builder, enableCleartext: Boolean = true) { + + } +} From 6c50a80b4220c320c29b808ae27284db54145bd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Szczodrzy=C5=84ski?= Date: Mon, 21 Feb 2022 21:08:59 +0100 Subject: [PATCH 3/5] [UI/Timetable] Fix syncing a week not refreshing the current page. --- .../ui/timetable/TimetableDayFragment.kt | 11 +++++++++++ .../edziennik/ui/timetable/TimetableFragment.kt | 15 ++++++++++++--- .../ui/timetable/TimetablePagerAdapter.kt | 4 ++++ 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/timetable/TimetableDayFragment.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/timetable/TimetableDayFragment.kt index 8ea7909f..754bd4f5 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/timetable/TimetableDayFragment.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/timetable/TimetableDayFragment.kt @@ -62,6 +62,8 @@ class TimetableDayFragment : LazyFragment(), CoroutineScope { private var firstEventMinute = 24 * 60 private var paddingTop = 0 + private var viewsRemoved = false + private val manager get() = app.timetableManager private val attendanceManager @@ -127,6 +129,7 @@ class TimetableDayFragment : LazyFragment(), CoroutineScope { inflater.inflate(R.layout.timetable_no_timetable, b.root) { view, _, _ -> b.root.removeAllViews() b.root.addView(view) + viewsRemoved = true val b = TimetableNoTimetableBinding.bind(view) val weekStart = date.weekStart.stringY_m_d @@ -151,6 +154,7 @@ class TimetableDayFragment : LazyFragment(), CoroutineScope { inflater.inflate(R.layout.timetable_no_lessons, b.root) { view, _, _ -> b.root.removeAllViews() b.root.addView(view) + viewsRemoved = true } return } @@ -162,6 +166,13 @@ class TimetableDayFragment : LazyFragment(), CoroutineScope { return } + // the timetable was not synced (the day layout views are removed) and is now available + if (viewsRemoved) { + viewsRemoved = false + activity.sendBroadcast(Intent(TimetableFragment.ACTION_RELOAD_PAGES)) + return + } + b.scrollView.isVisible = true b.dayFrame.removeView(dayView) b.dayFrame.addView(dayView, 0) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/timetable/TimetableFragment.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/timetable/TimetableFragment.kt index 44e861d4..b046ff68 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/timetable/TimetableFragment.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/timetable/TimetableFragment.kt @@ -36,6 +36,7 @@ class TimetableFragment : Fragment(), CoroutineScope { companion object { private const val TAG = "TimetableFragment" const val ACTION_SCROLL_TO_DATE = "pl.szczodrzynski.edziennik.timetable.SCROLL_TO_DATE" + const val ACTION_RELOAD_PAGES = "pl.szczodrzynski.edziennik.timetable.RELOAD_PAGES" const val DEFAULT_START_HOUR = 6 const val DEFAULT_END_HOUR = 19 var pageSelection: Date? = null @@ -66,14 +67,22 @@ class TimetableFragment : Fragment(), CoroutineScope { override fun onReceive(context: Context, i: Intent) { if (!isAdded) return - val dateStr = i.extras?.getString("timetableDate", null) ?: return - val date = Date.fromY_m_d(dateStr) - b.viewPager.setCurrentItem(items.indexOf(date), true) + when (i.action) { + ACTION_SCROLL_TO_DATE -> { + val dateStr = i.extras?.getString("timetableDate", null) ?: return + val date = Date.fromY_m_d(dateStr) + b.viewPager.setCurrentItem(items.indexOf(date), true) + } + ACTION_RELOAD_PAGES -> { + b.viewPager.adapter?.notifyDataSetChanged() + } + } } } override fun onResume() { super.onResume() activity.registerReceiver(broadcastReceiver, IntentFilter(ACTION_SCROLL_TO_DATE)) + activity.registerReceiver(broadcastReceiver, IntentFilter(ACTION_RELOAD_PAGES)) } override fun onPause() { super.onPause() diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/timetable/TimetablePagerAdapter.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/timetable/TimetablePagerAdapter.kt index fb8cf88a..2f1adfd2 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/timetable/TimetablePagerAdapter.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/timetable/TimetablePagerAdapter.kt @@ -47,4 +47,8 @@ class TimetablePagerAdapter( } return pageTitle } + + override fun getItemPosition(`object`: Any): Int { + return POSITION_NONE + } } From 148597e578d12d658da1eb156bc87a47dc37dc59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Szczodrzy=C5=84ski?= Date: Mon, 21 Feb 2022 21:46:16 +0100 Subject: [PATCH 4/5] [UI/Messages] Fix sending message not showing the message fragment. --- .../szczodrzynski/edziennik/utils/managers/MessageManager.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/utils/managers/MessageManager.kt b/app/src/main/java/pl/szczodrzynski/edziennik/utils/managers/MessageManager.kt index b6946207..996ac3bf 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/utils/managers/MessageManager.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/utils/managers/MessageManager.kt @@ -72,6 +72,9 @@ class MessageManager(private val app: App) { if (sentDate > 0L) { it.addedDate = sentDate } + withContext(Dispatchers.IO) { + it.recipients = app.db.messageRecipientDao().getAllByMessageId(profileId, it.id) + } } } else { withContext(Dispatchers.IO) { From f8ac9e793a1a098478a495ca0248ce2f4ed59060 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Szczodrzy=C5=84ski?= Date: Mon, 21 Feb 2022 21:48:28 +0100 Subject: [PATCH 5/5] [4.11.3] Update build.gradle, signing and changelog. --- app/src/main/assets/pl-changelog.html | 4 ++-- app/src/main/cpp/szkolny-signing.cpp | 2 +- .../edziennik/data/api/szkolny/interceptor/Signing.kt | 2 +- build.gradle | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/src/main/assets/pl-changelog.html b/app/src/main/assets/pl-changelog.html index a7bfcaa6..40490597 100644 --- a/app/src/main/assets/pl-changelog.html +++ b/app/src/main/assets/pl-changelog.html @@ -1,6 +1,6 @@ -

Wersja 4.11.2, 2022-02-05

+

Wersja 4.11.3, 2022-02-21

    -
  • Mobidziennik: naprawiono brak nadawców w liście wiadomości.
  • +
  • Naprawiono odświeżanie planu lekcji po pobraniu wybranego tygodnia.


diff --git a/app/src/main/cpp/szkolny-signing.cpp b/app/src/main/cpp/szkolny-signing.cpp index 88369629..cb7abb6a 100644 --- a/app/src/main/cpp/szkolny-signing.cpp +++ b/app/src/main/cpp/szkolny-signing.cpp @@ -9,7 +9,7 @@ /*secret password - removed for source code publication*/ static toys AES_IV[16] = { - 0x66, 0xae, 0x85, 0x2a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; + 0x90, 0xe9, 0x2f, 0x20, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; unsigned char *agony(unsigned int laugh, unsigned char *box, unsigned char *heat); diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/szkolny/interceptor/Signing.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/szkolny/interceptor/Signing.kt index dcbea186..13c9c762 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/szkolny/interceptor/Signing.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/szkolny/interceptor/Signing.kt @@ -46,6 +46,6 @@ object Signing { /*fun provideKey(param1: String, param2: Long): ByteArray {*/ fun pleaseStopRightNow(param1: String, param2: Long): ByteArray { - return "$param1.MTIzNDU2Nzg5MDMIlcxGrq===.$param2".sha256() + return "$param1.MTIzNDU2Nzg5MDw/KY+My+===.$param2".sha256() } } diff --git a/build.gradle b/build.gradle index 668185ea..ad977b77 100644 --- a/build.gradle +++ b/build.gradle @@ -5,8 +5,8 @@ buildscript { kotlin_version = '1.5.30' release = [ - versionName: "4.11.2", - versionCode: 4110299 + versionName: "4.11.3", + versionCode: 4110399 ] setup = [