) {
- Bundle().apply {
- params.forEach { (key, value) ->
- if (value == null) return@forEach
- when (value) {
- is String -> putString(key, value)
- is Int -> putInt(key, value)
- is Boolean -> putBoolean(key, value)
- }
- }
- analytics.onEvent(name, this)
- }
- }
-
- fun setCurrentScreen(activity: Activity, name: String?) {
- analytics.pageStart(name, activity::class.simpleName)
- }
-
- fun popCurrentScreen(name: String?) {
- analytics.pageEnd(name)
- }
-}
diff --git a/app/src/hms/java/io/github/wulkanowy/utils/CrashLogUtils.kt b/app/src/hms/java/io/github/wulkanowy/utils/CrashLogUtils.kt
deleted file mode 100644
index 2b1f1d30..00000000
--- a/app/src/hms/java/io/github/wulkanowy/utils/CrashLogUtils.kt
+++ /dev/null
@@ -1,32 +0,0 @@
-package io.github.wulkanowy.utils
-
-import android.util.Log
-import com.huawei.agconnect.crash.AGConnectCrash
-import fr.bipi.treessence.base.FormatterPriorityTree
-import fr.bipi.treessence.common.StackTraceRecorder
-
-class CrashLogTree : FormatterPriorityTree(Log.VERBOSE) {
-
- private val connectCrash by lazy { AGConnectCrash.getInstance() }
-
- override fun log(priority: Int, tag: String?, message: String, t: Throwable?) {
- if (skipLog(priority, tag, message, t)) return
-
- connectCrash.log(format(priority, tag, message))
- }
-}
-
-class CrashLogExceptionTree : FormatterPriorityTree(Log.ERROR, ExceptionFilter) {
-
- private val connectCrash by lazy { AGConnectCrash.getInstance() }
-
- override fun log(priority: Int, tag: String?, message: String, t: Throwable?) {
- if (skipLog(priority, tag, message, t)) return
-
- if (t != null) {
- connectCrash.recordException(t)
- } else {
- connectCrash.recordException(StackTraceRecorder(format(priority, tag, message)))
- }
- }
-}
diff --git a/app/src/hms/java/io/github/wulkanowy/utils/InAppReviewHelper.kt b/app/src/hms/java/io/github/wulkanowy/utils/InAppReviewHelper.kt
deleted file mode 100644
index adb162fd..00000000
--- a/app/src/hms/java/io/github/wulkanowy/utils/InAppReviewHelper.kt
+++ /dev/null
@@ -1,18 +0,0 @@
-package io.github.wulkanowy.utils
-
-import android.content.Context
-import dagger.hilt.android.qualifiers.ApplicationContext
-import io.github.wulkanowy.ui.modules.main.MainActivity
-import javax.inject.Inject
-import javax.inject.Singleton
-
-@Singleton
-@Suppress("UNUSED_PARAMETER", "unused")
-class InAppReviewHelper @Inject constructor(
- @ApplicationContext private val context: Context
-) {
-
- fun showInAppReview(activity: MainActivity) {
- // do nothing
- }
-}
diff --git a/app/src/hms/java/io/github/wulkanowy/utils/InAppUpdateHelper.kt b/app/src/hms/java/io/github/wulkanowy/utils/InAppUpdateHelper.kt
deleted file mode 100644
index 51b22ec7..00000000
--- a/app/src/hms/java/io/github/wulkanowy/utils/InAppUpdateHelper.kt
+++ /dev/null
@@ -1,13 +0,0 @@
-package io.github.wulkanowy.utils
-
-import android.view.View
-import javax.inject.Inject
-
-class InAppUpdateHelper @Inject constructor() {
-
- lateinit var messageContainer: View
-
- fun checkAndInstallUpdates() {}
-
- fun onResume() {}
-}
diff --git a/app/src/hms/java/io/github/wulkanowy/utils/IntegrityHelper.kt b/app/src/hms/java/io/github/wulkanowy/utils/IntegrityHelper.kt
deleted file mode 100644
index 7af68058..00000000
--- a/app/src/hms/java/io/github/wulkanowy/utils/IntegrityHelper.kt
+++ /dev/null
@@ -1,11 +0,0 @@
-package io.github.wulkanowy.utils
-
-import javax.inject.Inject
-import javax.inject.Singleton
-
-@Singleton
-class IntegrityHelper @Inject constructor() {
-
- @Suppress("UNUSED_PARAMETER")
- fun getIntegrityToken(requestId: String): String? = null
-}
diff --git a/app/src/hms/java/io/github/wulkanowy/utils/RemoteConfigHelper.kt b/app/src/hms/java/io/github/wulkanowy/utils/RemoteConfigHelper.kt
deleted file mode 100644
index 88f2598f..00000000
--- a/app/src/hms/java/io/github/wulkanowy/utils/RemoteConfigHelper.kt
+++ /dev/null
@@ -1,7 +0,0 @@
-package io.github.wulkanowy.utils
-
-import javax.inject.Inject
-import javax.inject.Singleton
-
-@Singleton
-class RemoteConfigHelper @Inject constructor() : BaseRemoteConfigHelper()
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 79d75bc0..2a214b8b 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -1,57 +1,30 @@
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ android:usesCleartextTraffic="true"
+ tools:ignore="GoogleAppIndexingWarning,UnusedAttribute">
+ android:theme="@style/WulkanowyTheme.SplashScreen">
@@ -61,24 +34,21 @@
android:name=".ui.modules.login.LoginActivity"
android:configChanges="orientation|screenSize"
android:label="@string/login_title"
- android:theme="@style/WulkanowyTheme.Login"
+ android:theme="@style/WulkanowyTheme.NoActionBar"
android:windowSoftInputMode="adjustResize" />
+ android:theme="@style/WulkanowyTheme.NoActionBar" />
+ android:theme="@style/WulkanowyTheme.NoActionBar" />
@@ -88,7 +58,6 @@
@@ -99,22 +68,6 @@
-
-
-
-
-
-
-
-
-
-
+
@@ -139,36 +92,17 @@
android:resource="@xml/provider_widget_lucky_number" />
-
-
-
-
-
+ tools:node="remove" />
+ android:name="io.fabric.ApiKey"
+ android:value="${fabric_api_key}" />
-
-
-
+ android:name="firebase_crashlytics_collection_enabled"
+ android:value="${crashlytics_enabled}" />
diff --git a/app/src/main/assets/contributors.json b/app/src/main/assets/contributors.json
deleted file mode 100644
index 97ac9356..00000000
--- a/app/src/main/assets/contributors.json
+++ /dev/null
@@ -1,62 +0,0 @@
-[
- {
- "displayName": "Mikołaj Pich",
- "githubUsername": "mklkj"
- },
- {
- "displayName": "Rafał Borcz",
- "githubUsername": "Faierbel"
- },
- {
- "displayName": "Dominik Korsa",
- "githubUsername": "dominik-korsa"
- },
- {
- "displayName": "Kacper Ziubryniewicz",
- "githubUsername": "kapi2289"
- },
- {
- "displayName": "doteq",
- "githubUsername": "doteq"
- },
- {
- "displayName": "Paweł Krzyś",
- "githubUsername": "pavuloff"
- },
- {
- "displayName": "Piotr Romanowski",
- "githubUsername": "v0idzz"
- },
- {
- "displayName": "Dinolek",
- "githubUsername": "Dinolek"
- },
- {
- "displayName": "Mateusz Idziejczak",
- "githubUsername": "Luncenok"
- },
- {
- "displayName": "Daniel Olczyk",
- "githubUsername": "MRmlik12"
- },
- {
- "displayName": "Damian Czupryn",
- "githubUsername": "Daxxxis"
- },
- {
- "displayName": "Kamil Studziński",
- "githubUsername": "studzinskik"
- },
- {
- "displayName": "Tomasz F.",
- "githubUsername": "Pengwius"
- },
- {
- "displayName": "Antoni Paduch",
- "githubUsername": "janAte1"
- },
- {
- "displayName": "Kamil Wąsik",
- "githubUsername": "JestemKamil"
- }
-]
diff --git a/app/src/main/assets/message-print-page.html b/app/src/main/assets/message-print-page.html
deleted file mode 100644
index 8da7dec6..00000000
--- a/app/src/main/assets/message-print-page.html
+++ /dev/null
@@ -1,94 +0,0 @@
-
-
-
-
- %SUBJECT% | Wulkanowy
-
-
-
-%SUBJECT%
-
-
- %INFO%
-
-
-
-
-
Treść wiadomości
- %CONTENT%
-
-
-
diff --git a/app/src/main/assets/wulkanowy-logo-black.svg b/app/src/main/assets/wulkanowy-logo-black.svg
deleted file mode 100644
index 9bfbe2c0..00000000
--- a/app/src/main/assets/wulkanowy-logo-black.svg
+++ /dev/null
@@ -1,74 +0,0 @@
-
-
\ No newline at end of file
diff --git a/app/src/main/java/io/github/wulkanowy/WulkanowyApp.kt b/app/src/main/java/io/github/wulkanowy/WulkanowyApp.kt
index 38fade0a..35a0e8da 100644
--- a/app/src/main/java/io/github/wulkanowy/WulkanowyApp.kt
+++ b/app/src/main/java/io/github/wulkanowy/WulkanowyApp.kt
@@ -1,87 +1,64 @@
package io.github.wulkanowy
-import android.app.Application
-import android.util.Log.DEBUG
-import android.util.Log.INFO
-import android.util.Log.VERBOSE
-import androidx.hilt.work.HiltWorkerFactory
+import android.content.Context
+import androidx.multidex.MultiDex
import androidx.work.Configuration
-import com.yariksoffice.lingver.Lingver
-import dagger.hilt.android.HiltAndroidApp
-import fr.bipi.treessence.file.FileLoggerTree
-import io.github.wulkanowy.data.repositories.PreferencesRepository
-import io.github.wulkanowy.ui.base.ThemeManager
+import androidx.work.WorkManager
+import com.jakewharton.threetenabp.AndroidThreeTen
+import dagger.android.AndroidInjector
+import dagger.android.support.DaggerApplication
+import eu.davidea.flexibleadapter.FlexibleAdapter
+import eu.davidea.flexibleadapter.utils.Log
+import io.github.wulkanowy.BuildConfig.DEBUG
+import io.github.wulkanowy.di.DaggerAppComponent
+import io.github.wulkanowy.services.sync.SyncWorkerFactory
import io.github.wulkanowy.utils.ActivityLifecycleLogger
-import io.github.wulkanowy.utils.AnalyticsHelper
-import io.github.wulkanowy.utils.AppInfo
-import io.github.wulkanowy.utils.CrashLogExceptionTree
-import io.github.wulkanowy.utils.CrashLogTree
+import io.github.wulkanowy.utils.CrashlyticsTree
import io.github.wulkanowy.utils.DebugLogTree
-import io.github.wulkanowy.utils.RemoteConfigHelper
+import io.github.wulkanowy.utils.initCrashlytics
+import io.reactivex.exceptions.UndeliverableException
+import io.reactivex.plugins.RxJavaPlugins
import timber.log.Timber
+import java.io.IOException
import javax.inject.Inject
-@HiltAndroidApp
-class WulkanowyApp : Application(), Configuration.Provider {
+class WulkanowyApp : DaggerApplication() {
@Inject
- lateinit var themeManager: ThemeManager
+ lateinit var workerFactory: SyncWorkerFactory
- @Inject
- lateinit var appInfo: AppInfo
-
- @Inject
- lateinit var preferencesRepository: PreferencesRepository
-
- @Inject
- lateinit var analyticsHelper: AnalyticsHelper
-
- @Inject
- lateinit var remoteConfigHelper: RemoteConfigHelper
-
- @Inject
- lateinit var workerFactory: HiltWorkerFactory
-
- override val workManagerConfiguration: Configuration
- get() = Configuration.Builder()
- .setWorkerFactory(workerFactory)
- .setMinimumLoggingLevel(if (appInfo.isDebug) VERBOSE else INFO)
- .build()
+ override fun attachBaseContext(base: Context?) {
+ super.attachBaseContext(base)
+ MultiDex.install(this)
+ }
override fun onCreate() {
super.onCreate()
- initializeAppLanguage()
- themeManager.applyDefaultTheme()
- remoteConfigHelper.initialize()
+ AndroidThreeTen.init(this)
+ WorkManager.initialize(this, Configuration.Builder().setWorkerFactory(workerFactory).build())
+ RxJavaPlugins.setErrorHandler(::onError)
+
+ initCrashlytics(applicationContext)
initLogging()
}
private fun initLogging() {
- if (appInfo.isDebug) {
+ if (DEBUG) {
Timber.plant(DebugLogTree())
- Timber.plant(
- FileLoggerTree.Builder()
- .withFileName("wulkanowy.%g.log")
- .withDirName(applicationContext.filesDir.absolutePath)
- .withFileLimit(10)
- .withMinPriority(DEBUG)
- .build()
- )
+ FlexibleAdapter.enableLogs(Log.Level.DEBUG)
} else {
- Timber.plant(CrashLogExceptionTree())
- Timber.plant(CrashLogTree())
+ Timber.plant(CrashlyticsTree())
}
registerActivityLifecycleCallbacks(ActivityLifecycleLogger())
}
- private fun initializeAppLanguage() {
- Lingver.init(this)
+ private fun onError(error: Throwable) {
+ if (error is UndeliverableException && error.cause is IOException || error.cause is InterruptedException) {
+ Timber.e(error.cause, "An undeliverable error occurred")
+ } else throw error
+ }
- if (preferencesRepository.appLanguage == "system") {
- Lingver.getInstance().setFollowSystemLocale(this)
- analyticsHelper.logEvent("language", "startup" to appInfo.systemLanguage)
- } else {
- analyticsHelper.logEvent("language", "startup" to preferencesRepository.appLanguage)
- }
+ override fun applicationInjector(): AndroidInjector {
+ return DaggerAppComponent.factory().create(this)
}
}
diff --git a/app/src/main/java/io/github/wulkanowy/data/ApiHelper.kt b/app/src/main/java/io/github/wulkanowy/data/ApiHelper.kt
new file mode 100644
index 00000000..b6eee316
--- /dev/null
+++ b/app/src/main/java/io/github/wulkanowy/data/ApiHelper.kt
@@ -0,0 +1,35 @@
+package io.github.wulkanowy.data
+
+import io.github.wulkanowy.api.Api
+import io.github.wulkanowy.data.db.entities.Student
+import java.net.URL
+import javax.inject.Inject
+
+class ApiHelper @Inject constructor(private val api: Api) {
+
+ fun initApi(student: Student) {
+ api.apply {
+ email = student.email
+ password = student.password
+ symbol = student.symbol
+ schoolSymbol = student.schoolSymbol
+ studentId = student.studentId
+ classId = student.classId
+ host = URL(student.endpoint).run { host + ":$port".removeSuffix(":-1") }
+ ssl = student.endpoint.startsWith("https")
+ loginType = Api.LoginType.valueOf(student.loginType)
+ useNewStudent = true
+ }
+ }
+
+ fun initApi(email: String, password: String, symbol: String, endpoint: String) {
+ api.apply {
+ this.email = email
+ this.password = password
+ this.symbol = symbol
+ host = URL(endpoint).run { host + ":$port".removeSuffix(":-1") }
+ ssl = endpoint.startsWith("https")
+ useNewStudent = true
+ }
+ }
+}
diff --git a/app/src/main/java/io/github/wulkanowy/data/DataModule.kt b/app/src/main/java/io/github/wulkanowy/data/DataModule.kt
deleted file mode 100644
index a21d56cc..00000000
--- a/app/src/main/java/io/github/wulkanowy/data/DataModule.kt
+++ /dev/null
@@ -1,246 +0,0 @@
-package io.github.wulkanowy.data
-
-import android.content.Context
-import android.content.SharedPreferences
-import androidx.preference.PreferenceManager
-import com.chuckerteam.chucker.api.ChuckerCollector
-import com.chuckerteam.chucker.api.ChuckerInterceptor
-import com.chuckerteam.chucker.api.RetentionManager
-import com.fredporciuncula.flow.preferences.FlowSharedPreferences
-import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFactory
-import dagger.Module
-import dagger.Provides
-import dagger.hilt.InstallIn
-import dagger.hilt.android.qualifiers.ApplicationContext
-import dagger.hilt.components.SingletonComponent
-import io.github.wulkanowy.data.api.services.SchoolsService
-import io.github.wulkanowy.data.api.services.WulkanowyService
-import io.github.wulkanowy.data.db.AppDatabase
-import io.github.wulkanowy.data.db.SharedPrefProvider
-import io.github.wulkanowy.data.repositories.PreferencesRepository
-import io.github.wulkanowy.utils.AppInfo
-import kotlinx.serialization.json.Json
-import okhttp3.MediaType.Companion.toMediaType
-import okhttp3.OkHttpClient
-import okhttp3.logging.HttpLoggingInterceptor
-import retrofit2.Retrofit
-import retrofit2.create
-import java.util.concurrent.TimeUnit
-import javax.inject.Singleton
-
-@Module
-@InstallIn(SingletonComponent::class)
-internal class DataModule {
-
- @Singleton
- @Provides
- fun provideChuckerCollector(
- @ApplicationContext context: Context,
- prefRepository: PreferencesRepository
- ) = ChuckerCollector(
- context = context,
- showNotification = prefRepository.isDebugNotificationEnable,
- retentionPeriod = RetentionManager.Period.ONE_HOUR
- )
-
- @Singleton
- @Provides
- fun provideChuckerInterceptor(
- @ApplicationContext context: Context,
- chuckerCollector: ChuckerCollector
- ) = ChuckerInterceptor.Builder(context)
- .collector(chuckerCollector)
- .alwaysReadResponseBody(true)
- .build()
-
- @Singleton
- @Provides
- fun provideOkHttpClient(chuckerInterceptor: ChuckerInterceptor): OkHttpClient =
- OkHttpClient.Builder()
- .addNetworkInterceptor(chuckerInterceptor)
- .addInterceptor(HttpLoggingInterceptor().apply {
- level = HttpLoggingInterceptor.Level.BASIC
- })
- .connectTimeout(30, TimeUnit.SECONDS)
- .readTimeout(30, TimeUnit.SECONDS)
- .build()
-
- @Singleton
- @Provides
- fun provideAdminMessageService(
- okHttpClient: OkHttpClient,
- json: Json,
- appInfo: AppInfo
- ): WulkanowyService = Retrofit.Builder()
- .baseUrl(appInfo.messagesBaseUrl)
- .client(okHttpClient)
- .addConverterFactory(json.asConverterFactory("application/json".toMediaType()))
- .build()
- .create()
-
- @Singleton
- @Provides
- fun provideSchoolsService(
- okHttpClient: OkHttpClient,
- json: Json,
- appInfo: AppInfo,
- ): SchoolsService = Retrofit.Builder()
- .baseUrl(appInfo.schoolsBaseUrl)
- .client(okHttpClient)
- .addConverterFactory(json.asConverterFactory("application/json".toMediaType()))
- .build()
- .create()
-
- @Singleton
- @Provides
- fun provideDatabase(
- @ApplicationContext context: Context,
- sharedPrefProvider: SharedPrefProvider,
- appInfo: AppInfo
- ) = AppDatabase.newInstance(context, sharedPrefProvider, appInfo)
-
- @Singleton
- @Provides
- fun provideSharedPref(@ApplicationContext context: Context): SharedPreferences =
- PreferenceManager.getDefaultSharedPreferences(context)
-
- @Singleton
- @Provides
- fun provideFlowSharedPref(sharedPreferences: SharedPreferences) =
- FlowSharedPreferences(sharedPreferences)
-
- @Singleton
- @Provides
- fun provideJson() = Json {
- ignoreUnknownKeys = true
- }
-
- @Singleton
- @Provides
- fun provideStudentDao(database: AppDatabase) = database.studentDao
-
- @Singleton
- @Provides
- fun provideSemesterDao(database: AppDatabase) = database.semesterDao
-
- @Singleton
- @Provides
- fun provideGradeDao(database: AppDatabase) = database.gradeDao
-
- @Singleton
- @Provides
- fun provideGradeSummaryDao(database: AppDatabase) = database.gradeSummaryDao
-
- @Singleton
- @Provides
- fun provideGradePartialStatisticsDao(database: AppDatabase) = database.gradePartialStatisticsDao
-
- @Singleton
- @Provides
- fun provideGradeSemesterStatisticsDao(database: AppDatabase) =
- database.gradeSemesterStatisticsDao
-
- @Singleton
- @Provides
- fun provideGradePointsStatisticsDao(database: AppDatabase) = database.gradePointsStatisticsDao
-
- @Singleton
- @Provides
- fun provideMessagesDao(database: AppDatabase) = database.messagesDao
-
- @Singleton
- @Provides
- fun provideMessageAttachmentsDao(database: AppDatabase) = database.messageAttachmentDao
-
- @Singleton
- @Provides
- fun provideExamDao(database: AppDatabase) = database.examsDao
-
- @Singleton
- @Provides
- fun provideAttendanceDao(database: AppDatabase) = database.attendanceDao
-
- @Singleton
- @Provides
- fun provideAttendanceSummaryDao(database: AppDatabase) = database.attendanceSummaryDao
-
- @Singleton
- @Provides
- fun provideTimetableDao(database: AppDatabase) = database.timetableDao
-
- @Singleton
- @Provides
- fun provideNoteDao(database: AppDatabase) = database.noteDao
-
- @Singleton
- @Provides
- fun provideHomeworkDao(database: AppDatabase) = database.homeworkDao
-
- @Singleton
- @Provides
- fun provideSubjectDao(database: AppDatabase) = database.subjectDao
-
- @Singleton
- @Provides
- fun provideLuckyNumberDao(database: AppDatabase) = database.luckyNumberDao
-
- @Singleton
- @Provides
- fun provideCompletedLessonsDao(database: AppDatabase) = database.completedLessonsDao
-
- @Singleton
- @Provides
- fun provideMailboxesDao(database: AppDatabase) = database.mailboxDao
-
- @Singleton
- @Provides
- fun provideRecipientDao(database: AppDatabase) = database.recipientDao
-
- @Singleton
- @Provides
- fun provideMobileDevicesDao(database: AppDatabase) = database.mobileDeviceDao
-
- @Singleton
- @Provides
- fun provideTeacherDao(database: AppDatabase) = database.teacherDao
-
- @Singleton
- @Provides
- fun provideSchoolInfoDao(database: AppDatabase) = database.schoolDao
-
- @Singleton
- @Provides
- fun provideConferenceDao(database: AppDatabase) = database.conferenceDao
-
- @Singleton
- @Provides
- fun provideTimetableAdditionalDao(database: AppDatabase) = database.timetableAdditionalDao
-
- @Singleton
- @Provides
- fun provideStudentInfoDao(database: AppDatabase) = database.studentInfoDao
-
- @Singleton
- @Provides
- fun provideTimetableHeaderDao(database: AppDatabase) = database.timetableHeaderDao
-
- @Singleton
- @Provides
- fun provideSchoolAnnouncementDao(database: AppDatabase) = database.schoolAnnouncementDao
-
- @Singleton
- @Provides
- fun provideNotificationDao(database: AppDatabase) = database.notificationDao
-
- @Singleton
- @Provides
- fun provideAdminMessageDao(database: AppDatabase) = database.adminMessagesDao
-
- @Singleton
- @Provides
- fun provideMutesDao(database: AppDatabase) = database.mutedMessageSendersDao
-
- @Singleton
- @Provides
- fun provideGradeDescriptiveDao(database: AppDatabase) = database.gradeDescriptiveDao
-}
diff --git a/app/src/main/java/io/github/wulkanowy/data/RepositoryModule.kt b/app/src/main/java/io/github/wulkanowy/data/RepositoryModule.kt
new file mode 100644
index 00000000..97da6bb8
--- /dev/null
+++ b/app/src/main/java/io/github/wulkanowy/data/RepositoryModule.kt
@@ -0,0 +1,139 @@
+package io.github.wulkanowy.data
+
+import android.content.Context
+import android.content.SharedPreferences
+import android.content.res.Resources
+import androidx.preference.PreferenceManager
+import com.github.pwittchen.reactivenetwork.library.rx2.internet.observing.InternetObservingSettings
+import com.github.pwittchen.reactivenetwork.library.rx2.internet.observing.strategy.WalledGardenInternetObservingStrategy
+import com.readystatesoftware.chuck.api.ChuckCollector
+import com.readystatesoftware.chuck.api.ChuckInterceptor
+import com.readystatesoftware.chuck.api.RetentionManager
+import dagger.Module
+import dagger.Provides
+import io.github.wulkanowy.api.Api
+import io.github.wulkanowy.data.db.AppDatabase
+import io.github.wulkanowy.data.repositories.preferences.PreferencesRepository
+import okhttp3.logging.HttpLoggingInterceptor
+import okhttp3.logging.HttpLoggingInterceptor.Level.BASIC
+import okhttp3.logging.HttpLoggingInterceptor.Level.NONE
+import timber.log.Timber
+import javax.inject.Singleton
+
+@Module
+internal class RepositoryModule {
+
+ @Singleton
+ @Provides
+ fun provideInternetObservingSettings(): InternetObservingSettings {
+ return InternetObservingSettings.builder()
+ .strategy(WalledGardenInternetObservingStrategy())
+ .build()
+ }
+
+ @Singleton
+ @Provides
+ fun provideApi(chuckCollector: ChuckCollector, context: Context): Api {
+ return Api().apply {
+ logLevel = NONE
+ androidVersion = android.os.Build.VERSION.RELEASE
+ buildTag = android.os.Build.MODEL
+ setInterceptor(HttpLoggingInterceptor(HttpLoggingInterceptor.Logger { Timber.d(it) }).setLevel(BASIC))
+
+ // for debug only
+ setInterceptor(ChuckInterceptor(context, chuckCollector).maxContentLength(250000L), true, 0)
+ }
+ }
+
+ @Singleton
+ @Provides
+ fun provideChuckCollector(context: Context, prefRepository: PreferencesRepository): ChuckCollector {
+ return ChuckCollector(context)
+ .showNotification(prefRepository.isDebugNotificationEnable)
+ .retentionManager(RetentionManager(context, ChuckCollector.Period.ONE_HOUR))
+ }
+
+ @Singleton
+ @Provides
+ fun provideDatabase(context: Context) = AppDatabase.newInstance(context)
+
+ @Singleton
+ @Provides
+ fun provideResources(context: Context): Resources = context.resources
+
+ @Singleton
+ @Provides
+ fun provideSharedPref(context: Context): SharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)
+
+ @Singleton
+ @Provides
+ fun provideStudentDao(database: AppDatabase) = database.studentDao
+
+ @Singleton
+ @Provides
+ fun provideSemesterDao(database: AppDatabase) = database.semesterDao
+
+ @Singleton
+ @Provides
+ fun provideGradeDao(database: AppDatabase) = database.gradeDao
+
+ @Singleton
+ @Provides
+ fun provideGradeSummaryDao(database: AppDatabase) = database.gradeSummaryDao
+
+ @Singleton
+ @Provides
+ fun provideGradeStatisticsDao(database: AppDatabase) = database.gradeStatistics
+
+ @Singleton
+ @Provides
+ fun provideMessagesDao(database: AppDatabase) = database.messagesDao
+
+ @Singleton
+ @Provides
+ fun provideExamDao(database: AppDatabase) = database.examsDao
+
+ @Singleton
+ @Provides
+ fun provideAttendanceDao(database: AppDatabase) = database.attendanceDao
+
+ @Singleton
+ @Provides
+ fun provideAttendanceSummaryDao(database: AppDatabase) = database.attendanceSummaryDao
+
+ @Singleton
+ @Provides
+ fun provideTimetableDao(database: AppDatabase) = database.timetableDao
+
+ @Singleton
+ @Provides
+ fun provideNoteDao(database: AppDatabase) = database.noteDao
+
+ @Singleton
+ @Provides
+ fun provideHomeworkDao(database: AppDatabase) = database.homeworkDao
+
+ @Singleton
+ @Provides
+ fun provideSubjectDao(database: AppDatabase) = database.subjectDao
+
+ @Singleton
+ @Provides
+ fun provideLuckyNumberDao(database: AppDatabase) = database.luckyNumberDao
+
+ @Singleton
+ @Provides
+ fun provideCompletedLessonsDao(database: AppDatabase) = database.completedLessonsDao
+
+ @Singleton
+ @Provides
+ fun provideReportingUnitDao(database: AppDatabase) = database.reportingUnitDao
+
+ @Singleton
+ @Provides
+ fun provideRecipientDao(database: AppDatabase) = database.recipientDao
+
+ @Singleton
+ @Provides
+ fun provideMobileDevicesDao(database: AppDatabase) = database.mobileDeviceDao
+}
diff --git a/app/src/main/java/io/github/wulkanowy/data/Resource.kt b/app/src/main/java/io/github/wulkanowy/data/Resource.kt
deleted file mode 100644
index 712a946f..00000000
--- a/app/src/main/java/io/github/wulkanowy/data/Resource.kt
+++ /dev/null
@@ -1,285 +0,0 @@
-package io.github.wulkanowy.data
-
-import kotlinx.coroutines.ExperimentalCoroutinesApi
-import kotlinx.coroutines.FlowPreview
-import kotlinx.coroutines.flow.Flow
-import kotlinx.coroutines.flow.catch
-import kotlinx.coroutines.flow.collect
-import kotlinx.coroutines.flow.combine
-import kotlinx.coroutines.flow.debounce
-import kotlinx.coroutines.flow.emitAll
-import kotlinx.coroutines.flow.filter
-import kotlinx.coroutines.flow.filterNot
-import kotlinx.coroutines.flow.first
-import kotlinx.coroutines.flow.flatMapLatest
-import kotlinx.coroutines.flow.flow
-import kotlinx.coroutines.flow.flowOf
-import kotlinx.coroutines.flow.map
-import kotlinx.coroutines.flow.onEach
-import kotlinx.coroutines.flow.takeWhile
-import kotlinx.coroutines.sync.Mutex
-import kotlinx.coroutines.sync.withLock
-import timber.log.Timber
-import kotlin.time.Duration
-import kotlin.time.Duration.Companion.seconds
-
-sealed interface Resource {
- /**
- * The initial value of a resource flow. Indicates no data that is currently available to be shown,
- * however with the expectation that the state will transition to another one soon.
- */
- open class Loading : Resource
-
- /**
- * A semi-loading state with some data available to be displayed (usually cached data loaded from
- * the database). Still not the target state and it's expected to transition into another one soon.
- */
- data class Intermediate(val data: T) : Loading()
-
- /**
- * The happy-path target state. Data can either be:
- * - loaded from the database - while it may seem like this case is already handled by the
- * Intermediate state, the difference here is semantic. Cached data is returned as Intermediate
- * when there's a API request in progress (or soon expected to be), however when there is no
- * intention of immediately querying the API, the cached data is returned as a Success.
- * - fetched from the API.
- */
- data class Success(val data: T) : Resource
-
- /**
- * Something bad happened and we were unable to get the requested data. This can be caused by
- * a database error, a network error, or really just any other error. Upon receiving this state
- * the UI can either: display a full screen error, or, when it has received any data previously,
- * display a snack bar informing of the problem.
- */
- data class Error(val error: Throwable) : Resource
-}
-
-val Resource.dataOrNull: T?
- get() = when (this) {
- is Resource.Success -> this.data
- is Resource.Intermediate -> this.data
- else -> null
- }
-
-val Resource.dataOrThrow: T
- get() = when (this) {
- is Resource.Success -> this.data
- is Resource.Intermediate -> this.data
- is Resource.Loading -> throw IllegalStateException("Resource is in loading state")
- is Resource.Error -> throw this.error
- }
-
-val Resource.errorOrNull: Throwable?
- get() = when (this) {
- is Resource.Error -> this.error
- else -> null
- }
-
-fun resourceFlow(block: suspend () -> T) = flow {
- emit(Resource.Loading())
- emit(Resource.Success(block()))
-}.catch { emit(Resource.Error(it)) }
-
-fun flatResourceFlow(block: suspend () -> Flow>) = flow {
- emit(Resource.Loading())
- emitAll(block().filter { it is Resource.Intermediate || it !is Resource.Loading })
-}.catch { emit(Resource.Error(it)) }
-
-fun Resource.mapData(block: (T) -> U) = when (this) {
- is Resource.Success -> Resource.Success(block(this.data))
- is Resource.Intermediate -> Resource.Intermediate(block(this.data))
- is Resource.Loading -> Resource.Loading()
- is Resource.Error -> Resource.Error(this.error)
-}
-
-/**
- * Injects another flow into this flow's resource data.
- */
-inline fun Flow>.combineWithResourceData(
- flow: Flow,
- crossinline block: suspend (T1, T2) -> R
-): Flow> =
- combine(flow) { resource, inject ->
- when (resource) {
- is Resource.Success -> Resource.Success(block(resource.data, inject))
- is Resource.Intermediate -> Resource.Intermediate(block(resource.data, inject))
- is Resource.Loading -> Resource.Loading()
- is Resource.Error -> Resource.Error(resource.error)
- }
- }
-
-fun Flow>.logResourceStatus(name: String, showData: Boolean = false) = onEach {
- val description = when (it) {
- is Resource.Intermediate -> "intermediate data received" + if (showData) " (data: `${it.data}`)" else ""
- is Resource.Loading -> "started"
- is Resource.Success -> "success" + if (showData) " (data: `${it.data}`)" else ""
- is Resource.Error -> "exception occurred: ${it.error}"
- }
- Timber.i("$name: $description")
-}
-
-inline fun Flow>.mapResourceData(crossinline block: suspend (T) -> U) = map {
- when (it) {
- is Resource.Success -> Resource.Success(block(it.data))
- is Resource.Intermediate -> Resource.Intermediate(block(it.data))
- is Resource.Loading -> Resource.Loading()
- is Resource.Error -> Resource.Error(it.error)
- }
-}
-
-@OptIn(ExperimentalCoroutinesApi::class)
-fun Flow>.flatMapResourceData(
- inheritIntermediate: Boolean = true, block: suspend (T) -> Flow>
-) = flatMapLatest {
- when (it) {
- is Resource.Success -> block(it.data)
- is Resource.Intermediate -> block(it.data).map { newRes ->
- if (inheritIntermediate && newRes is Resource.Success) Resource.Intermediate(newRes.data)
- else newRes
- }
-
- is Resource.Loading -> flowOf(Resource.Loading())
- is Resource.Error -> flowOf(Resource.Error(it.error))
- }
-}
-
-fun Flow>.onResourceData(block: suspend (T) -> Unit) = onEach {
- when (it) {
- is Resource.Success -> block(it.data)
- is Resource.Intermediate -> block(it.data)
- is Resource.Error,
- is Resource.Loading -> Unit
- }
-}
-
-fun Flow>.onResourceLoading(block: suspend () -> Unit) = onEach {
- if (it is Resource.Loading) {
- block()
- }
-}
-
-fun Flow>.onResourceIntermediate(block: suspend (T) -> Unit) = onEach {
- if (it is Resource.Intermediate) {
- block(it.data)
- }
-}
-
-fun Flow>.onResourceSuccess(block: suspend (T) -> Unit) = onEach {
- if (it is Resource.Success) {
- block(it.data)
- }
-}
-
-fun Flow>.onResourceError(block: suspend (Throwable) -> Unit) = onEach {
- if (it is Resource.Error) {
- block(it.error)
- }
-}
-
-fun Flow>.onResourceNotLoading(block: suspend () -> Unit) = onEach {
- if (it !is Resource.Loading) {
- block()
- }
-}
-
-suspend fun Flow>.toFirstResult() = filter { it !is Resource.Loading }.first()
-
-suspend fun Flow>.waitForResult() = takeWhile { it is Resource.Loading }.collect()
-
-// Can cause excessive amounts of `Resource.Intermediate` to be emitted. Unless that is desired,
-// use `debounceIntermediates` to alleviate this behavior.
-inline fun combineResourceFlows(flows: Iterable>>): Flow>> =
- combine(flows) { items ->
- var isIntermediate = false
- val data = mutableListOf()
- for (item in items) {
- when (item) {
- is Resource.Success -> data.add(item.data)
- is Resource.Intermediate -> {
- isIntermediate = true
- data.add(item.data)
- }
-
- is Resource.Loading -> return@combine Resource.Loading()
- is Resource.Error -> continue
- }
- }
- if (data.isEmpty()) {
- // All items have to be errors for this to happen, so just return the first one.
- // mapData is functionally useless and exists only to satisfy the type checker
- items.first().mapData { listOf(it) }
- } else if (isIntermediate) {
- Resource.Intermediate(data)
- } else {
- Resource.Success(data)
- }
- }
-
-@OptIn(FlowPreview::class)
-fun Flow>.debounceIntermediates(timeout: Duration = 5.seconds) = flow {
- var wasIntermediate = false
-
- emitAll(this@debounceIntermediates.debounce {
- if (it is Resource.Intermediate) {
- if (!wasIntermediate) {
- wasIntermediate = true
- Duration.ZERO
- } else {
- timeout
- }
- } else {
- wasIntermediate = false
- Duration.ZERO
- }
- })
-}
-
-
-inline fun networkBoundResource(
- mutex: Mutex = Mutex(),
- crossinline isResultEmpty: (OutputType) -> Boolean,
- crossinline query: () -> Flow,
- crossinline fetch: suspend () -> ApiType,
- crossinline saveFetchResult: suspend (old: OutputType, new: ApiType) -> Unit,
- crossinline shouldFetch: (OutputType) -> Boolean = { true },
- crossinline filterResult: (OutputType) -> OutputType = { it }
-) = networkBoundResource(
- mutex = mutex,
- isResultEmpty = isResultEmpty,
- query = query,
- fetch = fetch,
- saveFetchResult = saveFetchResult,
- shouldFetch = shouldFetch,
- mapResult = filterResult
-)
-
-@JvmName("networkBoundResourceWithMap")
-inline fun networkBoundResource(
- mutex: Mutex = Mutex(),
- crossinline isResultEmpty: (OutputType) -> Boolean,
- crossinline query: () -> Flow,
- crossinline fetch: suspend () -> ApiType,
- crossinline saveFetchResult: suspend (old: DatabaseType, new: ApiType) -> Unit,
- crossinline shouldFetch: (DatabaseType) -> Boolean = { true },
- crossinline mapResult: (DatabaseType) -> OutputType,
-) = flow {
- emit(Resource.Loading())
-
- val data = query().first()
- if (shouldFetch(data)) {
- emit(Resource.Intermediate(data))
-
- try {
- val newData = fetch()
- mutex.withLock { saveFetchResult(query().first(), newData) }
- } catch (throwable: Throwable) {
- emit(Resource.Error(throwable))
- return@flow
- }
- }
-
- emitAll(query().map { Resource.Success(it) })
-}
- .mapResourceData { mapResult(it) }
- .filterNot { it is Resource.Intermediate && isResultEmpty(it.data) }
diff --git a/app/src/main/java/io/github/wulkanowy/data/WulkanowySdkFactory.kt b/app/src/main/java/io/github/wulkanowy/data/WulkanowySdkFactory.kt
deleted file mode 100644
index dbd34cee..00000000
--- a/app/src/main/java/io/github/wulkanowy/data/WulkanowySdkFactory.kt
+++ /dev/null
@@ -1,143 +0,0 @@
-package io.github.wulkanowy.data
-
-import com.chuckerteam.chucker.api.ChuckerInterceptor
-import io.github.wulkanowy.data.db.dao.StudentDao
-import io.github.wulkanowy.data.db.entities.Semester
-import io.github.wulkanowy.data.db.entities.Student
-import io.github.wulkanowy.data.db.entities.StudentIsEduOne
-import io.github.wulkanowy.data.repositories.WulkanowyRepository
-import io.github.wulkanowy.sdk.Sdk
-import io.github.wulkanowy.utils.RemoteConfigHelper
-import io.github.wulkanowy.utils.WebkitCookieManagerProxy
-import kotlinx.coroutines.sync.Mutex
-import kotlinx.coroutines.sync.withLock
-import timber.log.Timber
-import javax.inject.Inject
-import javax.inject.Singleton
-
-@Singleton
-class WulkanowySdkFactory @Inject constructor(
- private val chuckerInterceptor: ChuckerInterceptor,
- private val remoteConfig: RemoteConfigHelper,
- private val webkitCookieManagerProxy: WebkitCookieManagerProxy,
- private val studentDb: StudentDao,
- private val wulkanowyRepository: WulkanowyRepository,
-) {
-
- private val eduOneMutex = Mutex()
- private val migrationFailedStudentIds = mutableSetOf()
-
- private val sdk = Sdk().apply {
- androidVersion = android.os.Build.VERSION.RELEASE
- buildTag = android.os.Build.MODEL
- userAgentTemplate = remoteConfig.userAgentTemplate
- setSimpleHttpLogger { Timber.d(it) }
- setAdditionalCookieManager(webkitCookieManagerProxy)
-
- // for debug only
- addInterceptor(chuckerInterceptor, network = true)
- }
-
- fun createBase() = sdk
-
- suspend fun create(): Sdk {
- val mapping = wulkanowyRepository.getMapping()
-
- return createBase().apply {
- if (mapping != null) {
- endpointsMapping = mapping.endpoints
- vTokenMapping = mapping.vTokens
- vTokenSchemeMapping = mapping.vTokenScheme
- }
- }
- }
-
- suspend fun create(student: Student, semester: Semester? = null): Sdk {
- val overrideIsEduOne = checkEduOneAndMigrateIfNecessary(student)
- return buildSdk(student, semester, overrideIsEduOne)
- }
-
- private suspend fun buildSdk(
- student: Student,
- semester: Semester?,
- isStudentEduOne: Boolean
- ): Sdk {
- return create().apply {
- email = student.email
- password = student.password
- symbol = student.symbol
- schoolSymbol = student.schoolSymbol
- studentId = student.studentId
- classId = student.classId
- emptyCookieJarInterceptor = true
- isEduOne = isStudentEduOne
-
- if (Sdk.Mode.valueOf(student.loginMode) == Sdk.Mode.HEBE) {
- mobileBaseUrl = student.mobileBaseUrl
- } else {
- scrapperBaseUrl = student.scrapperBaseUrl
- domainSuffix = student.scrapperDomainSuffix
- loginType = Sdk.ScrapperLoginType.valueOf(student.loginType)
- }
-
- mode = Sdk.Mode.valueOf(student.loginMode)
- mobileBaseUrl = student.mobileBaseUrl
- keyId = student.certificateKey
- privatePem = student.privateKey
-
- if (semester != null) {
- diaryId = semester.diaryId
- kindergartenDiaryId = semester.kindergartenDiaryId
- schoolYear = semester.schoolYear
- unitId = semester.unitId
- }
- }
- }
-
- private suspend fun checkEduOneAndMigrateIfNecessary(student: Student): Boolean {
- if (student.isEduOne != null) return student.isEduOne
-
- if (student.id in migrationFailedStudentIds) {
- Timber.i("Migration eduOne: skipping because of previous failure")
- return false
- }
-
- eduOneMutex.withLock {
- if (student.id in migrationFailedStudentIds) {
- Timber.i("Migration eduOne: skipping because of previous failure")
- return false
- }
-
- val studentFromDatabase = studentDb.loadById(student.id)
- if (studentFromDatabase?.isEduOne != null) {
- Timber.i("Migration eduOne: already done")
- return studentFromDatabase.isEduOne
- }
-
- Timber.i("Migration eduOne: flag missing. Running migration...")
- val initializedSdk = buildSdk(
- student = student,
- semester = null,
- isStudentEduOne = false, // doesn't matter
- )
- val newCurrentStudent = runCatching { initializedSdk.getCurrentStudent() }
- .onFailure { Timber.e(it, "Migration eduOne: can't get current student") }
- .getOrNull()
-
- if (newCurrentStudent == null) {
- Timber.i("Migration eduOne: failed, so skipping")
- migrationFailedStudentIds.add(student.id)
- return false
- }
-
- Timber.i("Migration eduOne: success. New isEduOne flag: ${newCurrentStudent.isEduOne}")
-
- val studentIsEduOne = StudentIsEduOne(
- id = student.id,
- isEduOne = newCurrentStudent.isEduOne
- )
- studentDb.update(studentIsEduOne)
- return newCurrentStudent.isEduOne
- }
- }
-}
diff --git a/app/src/main/java/io/github/wulkanowy/data/api/models/Mapping.kt b/app/src/main/java/io/github/wulkanowy/data/api/models/Mapping.kt
deleted file mode 100644
index c4667a47..00000000
--- a/app/src/main/java/io/github/wulkanowy/data/api/models/Mapping.kt
+++ /dev/null
@@ -1,17 +0,0 @@
-package io.github.wulkanowy.data.api.models
-
-import kotlinx.serialization.SerialName
-import kotlinx.serialization.Serializable
-
-@Serializable
-data class Mapping(
-
- @SerialName("endpoints")
- val endpoints: Map>>,
-
- @SerialName("vTokens")
- val vTokens: Map>>,
-
- @SerialName("vTokenScheme")
- val vTokenScheme: Map> = emptyMap(),
-)
diff --git a/app/src/main/java/io/github/wulkanowy/data/api/services/SchoolsService.kt b/app/src/main/java/io/github/wulkanowy/data/api/services/SchoolsService.kt
deleted file mode 100644
index 07fbeb89..00000000
--- a/app/src/main/java/io/github/wulkanowy/data/api/services/SchoolsService.kt
+++ /dev/null
@@ -1,14 +0,0 @@
-package io.github.wulkanowy.data.api.services
-
-import io.github.wulkanowy.data.pojos.IntegrityRequest
-import io.github.wulkanowy.data.pojos.LoginEvent
-import retrofit2.http.Body
-import retrofit2.http.POST
-import javax.inject.Singleton
-
-@Singleton
-interface SchoolsService {
-
- @POST("/log/loginEvent")
- suspend fun logLoginEvent(@Body request: IntegrityRequest)
-}
diff --git a/app/src/main/java/io/github/wulkanowy/data/api/services/WulkanowyService.kt b/app/src/main/java/io/github/wulkanowy/data/api/services/WulkanowyService.kt
deleted file mode 100644
index 161e93d6..00000000
--- a/app/src/main/java/io/github/wulkanowy/data/api/services/WulkanowyService.kt
+++ /dev/null
@@ -1,16 +0,0 @@
-package io.github.wulkanowy.data.api.services
-
-import io.github.wulkanowy.data.api.models.Mapping
-import io.github.wulkanowy.data.db.entities.AdminMessage
-import retrofit2.http.GET
-import javax.inject.Singleton
-
-@Singleton
-interface WulkanowyService {
-
- @GET("/v1.json")
- suspend fun getAdminMessages(): List
-
- @GET("/mapping2.json")
- suspend fun getMapping(): Mapping
-}
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/AppDatabase.kt b/app/src/main/java/io/github/wulkanowy/data/db/AppDatabase.kt
index f23c79de..a97a3042 100644
--- a/app/src/main/java/io/github/wulkanowy/data/db/AppDatabase.kt
+++ b/app/src/main/java/io/github/wulkanowy/data/db/AppDatabase.kt
@@ -1,130 +1,61 @@
package io.github.wulkanowy.data.db
import android.content.Context
-import androidx.room.AutoMigration
import androidx.room.Database
import androidx.room.Room
import androidx.room.RoomDatabase
import androidx.room.RoomDatabase.JournalMode.TRUNCATE
import androidx.room.TypeConverters
-import io.github.wulkanowy.data.db.dao.AdminMessageDao
import io.github.wulkanowy.data.db.dao.AttendanceDao
import io.github.wulkanowy.data.db.dao.AttendanceSummaryDao
import io.github.wulkanowy.data.db.dao.CompletedLessonsDao
-import io.github.wulkanowy.data.db.dao.ConferenceDao
import io.github.wulkanowy.data.db.dao.ExamDao
import io.github.wulkanowy.data.db.dao.GradeDao
-import io.github.wulkanowy.data.db.dao.GradeDescriptiveDao
-import io.github.wulkanowy.data.db.dao.GradePartialStatisticsDao
-import io.github.wulkanowy.data.db.dao.GradePointsStatisticsDao
-import io.github.wulkanowy.data.db.dao.GradeSemesterStatisticsDao
+import io.github.wulkanowy.data.db.dao.GradeStatisticsDao
import io.github.wulkanowy.data.db.dao.GradeSummaryDao
import io.github.wulkanowy.data.db.dao.HomeworkDao
import io.github.wulkanowy.data.db.dao.LuckyNumberDao
-import io.github.wulkanowy.data.db.dao.MailboxDao
-import io.github.wulkanowy.data.db.dao.MessageAttachmentDao
import io.github.wulkanowy.data.db.dao.MessagesDao
import io.github.wulkanowy.data.db.dao.MobileDeviceDao
-import io.github.wulkanowy.data.db.dao.MutedMessageSendersDao
import io.github.wulkanowy.data.db.dao.NoteDao
-import io.github.wulkanowy.data.db.dao.NotificationDao
import io.github.wulkanowy.data.db.dao.RecipientDao
-import io.github.wulkanowy.data.db.dao.SchoolAnnouncementDao
-import io.github.wulkanowy.data.db.dao.SchoolDao
+import io.github.wulkanowy.data.db.dao.ReportingUnitDao
import io.github.wulkanowy.data.db.dao.SemesterDao
import io.github.wulkanowy.data.db.dao.StudentDao
-import io.github.wulkanowy.data.db.dao.StudentInfoDao
import io.github.wulkanowy.data.db.dao.SubjectDao
-import io.github.wulkanowy.data.db.dao.TeacherDao
-import io.github.wulkanowy.data.db.dao.TimetableAdditionalDao
import io.github.wulkanowy.data.db.dao.TimetableDao
-import io.github.wulkanowy.data.db.dao.TimetableHeaderDao
-import io.github.wulkanowy.data.db.entities.AdminMessage
import io.github.wulkanowy.data.db.entities.Attendance
import io.github.wulkanowy.data.db.entities.AttendanceSummary
import io.github.wulkanowy.data.db.entities.CompletedLesson
-import io.github.wulkanowy.data.db.entities.Conference
import io.github.wulkanowy.data.db.entities.Exam
import io.github.wulkanowy.data.db.entities.Grade
-import io.github.wulkanowy.data.db.entities.GradeDescriptive
-import io.github.wulkanowy.data.db.entities.GradePartialStatistics
-import io.github.wulkanowy.data.db.entities.GradePointsStatistics
-import io.github.wulkanowy.data.db.entities.GradeSemesterStatistics
+import io.github.wulkanowy.data.db.entities.GradeStatistics
import io.github.wulkanowy.data.db.entities.GradeSummary
import io.github.wulkanowy.data.db.entities.Homework
import io.github.wulkanowy.data.db.entities.LuckyNumber
-import io.github.wulkanowy.data.db.entities.Mailbox
import io.github.wulkanowy.data.db.entities.Message
-import io.github.wulkanowy.data.db.entities.MessageAttachment
import io.github.wulkanowy.data.db.entities.MobileDevice
-import io.github.wulkanowy.data.db.entities.MutedMessageSender
import io.github.wulkanowy.data.db.entities.Note
-import io.github.wulkanowy.data.db.entities.Notification
import io.github.wulkanowy.data.db.entities.Recipient
-import io.github.wulkanowy.data.db.entities.School
-import io.github.wulkanowy.data.db.entities.SchoolAnnouncement
+import io.github.wulkanowy.data.db.entities.ReportingUnit
import io.github.wulkanowy.data.db.entities.Semester
import io.github.wulkanowy.data.db.entities.Student
-import io.github.wulkanowy.data.db.entities.StudentInfo
import io.github.wulkanowy.data.db.entities.Subject
-import io.github.wulkanowy.data.db.entities.Teacher
import io.github.wulkanowy.data.db.entities.Timetable
-import io.github.wulkanowy.data.db.entities.TimetableAdditional
-import io.github.wulkanowy.data.db.entities.TimetableHeader
import io.github.wulkanowy.data.db.migrations.Migration10
import io.github.wulkanowy.data.db.migrations.Migration11
import io.github.wulkanowy.data.db.migrations.Migration12
import io.github.wulkanowy.data.db.migrations.Migration13
import io.github.wulkanowy.data.db.migrations.Migration14
import io.github.wulkanowy.data.db.migrations.Migration15
-import io.github.wulkanowy.data.db.migrations.Migration16
-import io.github.wulkanowy.data.db.migrations.Migration17
-import io.github.wulkanowy.data.db.migrations.Migration18
-import io.github.wulkanowy.data.db.migrations.Migration19
import io.github.wulkanowy.data.db.migrations.Migration2
-import io.github.wulkanowy.data.db.migrations.Migration20
-import io.github.wulkanowy.data.db.migrations.Migration21
-import io.github.wulkanowy.data.db.migrations.Migration22
-import io.github.wulkanowy.data.db.migrations.Migration23
-import io.github.wulkanowy.data.db.migrations.Migration24
-import io.github.wulkanowy.data.db.migrations.Migration25
-import io.github.wulkanowy.data.db.migrations.Migration26
-import io.github.wulkanowy.data.db.migrations.Migration27
-import io.github.wulkanowy.data.db.migrations.Migration28
-import io.github.wulkanowy.data.db.migrations.Migration29
import io.github.wulkanowy.data.db.migrations.Migration3
-import io.github.wulkanowy.data.db.migrations.Migration30
-import io.github.wulkanowy.data.db.migrations.Migration31
-import io.github.wulkanowy.data.db.migrations.Migration32
-import io.github.wulkanowy.data.db.migrations.Migration33
-import io.github.wulkanowy.data.db.migrations.Migration34
-import io.github.wulkanowy.data.db.migrations.Migration35
-import io.github.wulkanowy.data.db.migrations.Migration36
-import io.github.wulkanowy.data.db.migrations.Migration37
-import io.github.wulkanowy.data.db.migrations.Migration38
-import io.github.wulkanowy.data.db.migrations.Migration39
import io.github.wulkanowy.data.db.migrations.Migration4
-import io.github.wulkanowy.data.db.migrations.Migration40
-import io.github.wulkanowy.data.db.migrations.Migration41
-import io.github.wulkanowy.data.db.migrations.Migration42
-import io.github.wulkanowy.data.db.migrations.Migration43
-import io.github.wulkanowy.data.db.migrations.Migration44
-import io.github.wulkanowy.data.db.migrations.Migration46
-import io.github.wulkanowy.data.db.migrations.Migration49
import io.github.wulkanowy.data.db.migrations.Migration5
-import io.github.wulkanowy.data.db.migrations.Migration50
-import io.github.wulkanowy.data.db.migrations.Migration51
-import io.github.wulkanowy.data.db.migrations.Migration53
-import io.github.wulkanowy.data.db.migrations.Migration54
-import io.github.wulkanowy.data.db.migrations.Migration55
-import io.github.wulkanowy.data.db.migrations.Migration57
-import io.github.wulkanowy.data.db.migrations.Migration58
import io.github.wulkanowy.data.db.migrations.Migration6
-import io.github.wulkanowy.data.db.migrations.Migration63
import io.github.wulkanowy.data.db.migrations.Migration7
import io.github.wulkanowy.data.db.migrations.Migration8
import io.github.wulkanowy.data.db.migrations.Migration9
-import io.github.wulkanowy.utils.AppInfo
import javax.inject.Singleton
@Singleton
@@ -138,46 +69,16 @@ import javax.inject.Singleton
AttendanceSummary::class,
Grade::class,
GradeSummary::class,
- GradePartialStatistics::class,
- GradePointsStatistics::class,
- GradeSemesterStatistics::class,
+ GradeStatistics::class,
Message::class,
- MessageAttachment::class,
Note::class,
Homework::class,
Subject::class,
LuckyNumber::class,
CompletedLesson::class,
- Mailbox::class,
+ ReportingUnit::class,
Recipient::class,
- MobileDevice::class,
- Teacher::class,
- School::class,
- Conference::class,
- TimetableAdditional::class,
- StudentInfo::class,
- TimetableHeader::class,
- SchoolAnnouncement::class,
- Notification::class,
- AdminMessage::class,
- MutedMessageSender::class,
- GradeDescriptive::class,
- ],
- autoMigrations = [
- AutoMigration(from = 44, to = 45),
- AutoMigration(from = 46, to = 47),
- AutoMigration(from = 47, to = 48),
- AutoMigration(from = 51, to = 52),
- AutoMigration(from = 54, to = 55, spec = Migration55::class),
- AutoMigration(from = 55, to = 56),
- AutoMigration(from = 56, to = 57, spec = Migration57::class),
- AutoMigration(from = 57, to = 58, spec = Migration58::class),
- AutoMigration(from = 58, to = 59),
- AutoMigration(from = 59, to = 60),
- AutoMigration(from = 60, to = 61),
- AutoMigration(from = 61, to = 62),
- AutoMigration(from = 62, to = 63, spec = Migration63::class),
- AutoMigration(from = 63, to = 64),
+ MobileDevice::class
],
version = AppDatabase.VERSION_SCHEMA,
exportSchema = true
@@ -186,70 +87,31 @@ import javax.inject.Singleton
abstract class AppDatabase : RoomDatabase() {
companion object {
- const val VERSION_SCHEMA = 64
+ const val VERSION_SCHEMA = 15
- fun getMigrations(sharedPrefProvider: SharedPrefProvider, appInfo: AppInfo) = arrayOf(
- Migration2(),
- Migration3(),
- Migration4(),
- Migration5(),
- Migration6(),
- Migration7(),
- Migration8(),
- Migration9(),
- Migration10(),
- Migration11(),
- Migration12(),
- Migration13(),
- Migration14(),
- Migration15(),
- Migration16(),
- Migration17(),
- Migration18(),
- Migration19(sharedPrefProvider),
- Migration20(),
- Migration21(),
- Migration22(),
- Migration23(),
- Migration24(),
- Migration25(),
- Migration26(),
- Migration27(),
- Migration28(),
- Migration29(),
- Migration30(),
- Migration31(),
- Migration32(),
- Migration33(),
- Migration34(),
- Migration35(appInfo),
- Migration36(),
- Migration37(),
- Migration38(),
- Migration39(),
- Migration40(),
- Migration41(sharedPrefProvider),
- Migration42(),
- Migration43(),
- Migration44(),
- Migration46(),
- Migration49(),
- Migration50(),
- Migration51(),
- Migration53(),
- Migration54(),
- )
-
- fun newInstance(
- context: Context,
- sharedPrefProvider: SharedPrefProvider,
- appInfo: AppInfo
- ) = Room.databaseBuilder(context, AppDatabase::class.java, "wulkanowy_database")
- .setJournalMode(TRUNCATE)
- .fallbackToDestructiveMigrationFrom(VERSION_SCHEMA + 1)
- .fallbackToDestructiveMigrationOnDowngrade()
- .addMigrations(*getMigrations(sharedPrefProvider, appInfo))
- .build()
+ fun newInstance(context: Context): AppDatabase {
+ return Room.databaseBuilder(context, AppDatabase::class.java, "wulkanowy_database")
+ .setJournalMode(TRUNCATE)
+ .fallbackToDestructiveMigrationFrom(VERSION_SCHEMA + 1)
+ .fallbackToDestructiveMigrationOnDowngrade()
+ .addMigrations(
+ Migration2(),
+ Migration3(),
+ Migration4(),
+ Migration5(),
+ Migration6(),
+ Migration7(),
+ Migration8(),
+ Migration9(),
+ Migration10(),
+ Migration11(),
+ Migration12(),
+ Migration13(),
+ Migration14(),
+ Migration15()
+ )
+ .build()
+ }
}
abstract val studentDao: StudentDao
@@ -268,16 +130,10 @@ abstract class AppDatabase : RoomDatabase() {
abstract val gradeSummaryDao: GradeSummaryDao
- abstract val gradePartialStatisticsDao: GradePartialStatisticsDao
-
- abstract val gradePointsStatisticsDao: GradePointsStatisticsDao
-
- abstract val gradeSemesterStatisticsDao: GradeSemesterStatisticsDao
+ abstract val gradeStatistics: GradeStatisticsDao
abstract val messagesDao: MessagesDao
- abstract val messageAttachmentDao: MessageAttachmentDao
-
abstract val noteDao: NoteDao
abstract val homeworkDao: HomeworkDao
@@ -288,31 +144,9 @@ abstract class AppDatabase : RoomDatabase() {
abstract val completedLessonsDao: CompletedLessonsDao
- abstract val mailboxDao: MailboxDao
+ abstract val reportingUnitDao: ReportingUnitDao
abstract val recipientDao: RecipientDao
abstract val mobileDeviceDao: MobileDeviceDao
-
- abstract val teacherDao: TeacherDao
-
- abstract val schoolDao: SchoolDao
-
- abstract val conferenceDao: ConferenceDao
-
- abstract val timetableAdditionalDao: TimetableAdditionalDao
-
- abstract val studentInfoDao: StudentInfoDao
-
- abstract val timetableHeaderDao: TimetableHeaderDao
-
- abstract val schoolAnnouncementDao: SchoolAnnouncementDao
-
- abstract val notificationDao: NotificationDao
-
- abstract val adminMessagesDao: AdminMessageDao
-
- abstract val mutedMessageSendersDao: MutedMessageSendersDao
-
- abstract val gradeDescriptiveDao: GradeDescriptiveDao
}
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/Converters.kt b/app/src/main/java/io/github/wulkanowy/data/db/Converters.kt
index 7bc8d12a..73a04d23 100644
--- a/app/src/main/java/io/github/wulkanowy/data/db/Converters.kt
+++ b/app/src/main/java/io/github/wulkanowy/data/db/Converters.kt
@@ -1,37 +1,37 @@
package io.github.wulkanowy.data.db
import androidx.room.TypeConverter
-import io.github.wulkanowy.data.enums.MessageType
-import io.github.wulkanowy.ui.modules.Destination
-import io.github.wulkanowy.utils.toTimestamp
-import kotlinx.serialization.SerializationException
-import kotlinx.serialization.decodeFromString
-import kotlinx.serialization.encodeToString
-import kotlinx.serialization.json.Json
-import java.time.*
-import java.util.*
-import java.time.Instant
-import java.time.LocalDate
-import java.time.Month
-import java.time.ZoneOffset
-import java.util.*
+import com.google.gson.Gson
+import com.google.gson.reflect.TypeToken
+import org.threeten.bp.DateTimeUtils
+import org.threeten.bp.Instant
+import org.threeten.bp.LocalDate
+import org.threeten.bp.LocalDateTime
+import org.threeten.bp.Month
+import org.threeten.bp.ZoneOffset
+import java.util.Date
class Converters {
- private val json = Json
+ @TypeConverter
+ fun timestampToDate(value: Long?): LocalDate? = value?.run {
+ DateTimeUtils.toInstant(Date(value)).atZone(ZoneOffset.UTC).toLocalDate()
+ }
@TypeConverter
- fun timestampToLocalDate(value: Long?): LocalDate? =
- value?.let(::Date)?.toInstant()?.atZone(ZoneOffset.UTC)?.toLocalDate()
+ fun dateToTimestamp(date: LocalDate?): Long? {
+ return date?.atStartOfDay()?.toInstant(ZoneOffset.UTC)?.toEpochMilli()
+ }
@TypeConverter
- fun dateToTimestamp(date: LocalDate?): Long? = date?.toTimestamp()
+ fun timestampToTime(value: Long?): LocalDateTime? = value?.let {
+ LocalDateTime.ofInstant(Instant.ofEpochMilli(value), ZoneOffset.UTC)
+ }
@TypeConverter
- fun instantToTimestamp(instant: Instant?): Long? = instant?.toEpochMilli()
-
- @TypeConverter
- fun timestampToInstant(timestamp: Long?): Instant? = timestamp?.let(Instant::ofEpochMilli)
+ fun timeToTimestamp(date: LocalDateTime?): Long? {
+ return date?.atZone(ZoneOffset.UTC)?.toInstant()?.toEpochMilli()
+ }
@TypeConverter
fun monthToInt(month: Month?) = month?.value
@@ -40,38 +40,12 @@ class Converters {
fun intToMonth(value: Int?) = value?.let { Month.of(it) }
@TypeConverter
- fun intListToJson(list: List): String {
- return json.encodeToString(list)
+ fun intListToGson(list: List): String {
+ return Gson().toJson(list)
}
@TypeConverter
- fun jsonToIntList(value: String): List {
- return json.decodeFromString(value)
+ fun gsonToIntList(value: String): List {
+ return Gson().fromJson(value, object : TypeToken>() {}.type)
}
-
- @TypeConverter
- fun stringPairListToJson(list: List>): String {
- return json.encodeToString(list)
- }
-
- @TypeConverter
- fun jsonToStringPairList(value: String): List> {
- return try {
- json.decodeFromString(value)
- } catch (e: SerializationException) {
- emptyList() // handle errors from old gson Pair serialized data
- }
- }
-
- @TypeConverter
- fun destinationToString(destination: Destination) = json.encodeToString(destination)
-
- @TypeConverter
- fun stringToDestination(destination: String): Destination = json.decodeFromString(destination)
-
- @TypeConverter
- fun messageTypesToString(types: List): String = json.encodeToString(types)
-
- @TypeConverter
- fun stringToMessageTypes(text: String): List = json.decodeFromString(text)
}
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/SharedPrefHelper.kt b/app/src/main/java/io/github/wulkanowy/data/db/SharedPrefHelper.kt
new file mode 100644
index 00000000..74f9fa65
--- /dev/null
+++ b/app/src/main/java/io/github/wulkanowy/data/db/SharedPrefHelper.kt
@@ -0,0 +1,23 @@
+package io.github.wulkanowy.data.db
+
+import android.annotation.SuppressLint
+import android.content.SharedPreferences
+import javax.inject.Inject
+import javax.inject.Singleton
+
+@Singleton
+@SuppressLint("ApplySharedPref")
+class SharedPrefHelper @Inject constructor(private val sharedPref: SharedPreferences) {
+
+ fun putLong(key: String, value: Long, sync: Boolean = false) {
+ sharedPref.edit().putLong(key, value).apply {
+ if (sync) commit() else apply()
+ }
+ }
+
+ fun getLong(key: String, defaultValue: Long) = sharedPref.getLong(key, defaultValue)
+
+ fun delete(key: String) {
+ sharedPref.edit().remove(key).apply()
+ }
+}
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/SharedPrefProvider.kt b/app/src/main/java/io/github/wulkanowy/data/db/SharedPrefProvider.kt
deleted file mode 100644
index 4929f046..00000000
--- a/app/src/main/java/io/github/wulkanowy/data/db/SharedPrefProvider.kt
+++ /dev/null
@@ -1,41 +0,0 @@
-package io.github.wulkanowy.data.db
-
-import android.content.SharedPreferences
-import androidx.core.content.edit
-import javax.inject.Inject
-import javax.inject.Singleton
-
-@Singleton
-class SharedPrefProvider @Inject constructor(
- private val sharedPref: SharedPreferences
-) {
-
- companion object {
- const val APP_VERSION_CODE_KEY = "app_version_code"
- }
-
- fun putLong(key: String, value: Long, sync: Boolean = false) {
- sharedPref.edit(sync) { putLong(key, value) }
- }
-
- fun getLong(key: String, defaultValue: Long) = sharedPref.getLong(key, defaultValue)
-
- fun getString(key: String) = sharedPref.getString(key, null)
-
- fun getString(key: String, defaultValue: String): String =
- sharedPref.getString(key, defaultValue) ?: defaultValue
-
- fun getBoolean(key: String, defaultValue: Boolean): Boolean =
- sharedPref.getBoolean(key, defaultValue)
-
- fun putBoolean(key: String, value: Boolean, sync: Boolean = false) =
- sharedPref.edit(sync) { putBoolean(key, value) }
-
- fun putString(key: String, value: String?, sync: Boolean = false) {
- sharedPref.edit(sync) { putString(key, value) }
- }
-
- fun delete(key: String) {
- sharedPref.edit().remove(key).apply()
- }
-}
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/dao/AdminMessageDao.kt b/app/src/main/java/io/github/wulkanowy/data/db/dao/AdminMessageDao.kt
deleted file mode 100644
index 6c8d7e47..00000000
--- a/app/src/main/java/io/github/wulkanowy/data/db/dao/AdminMessageDao.kt
+++ /dev/null
@@ -1,15 +0,0 @@
-package io.github.wulkanowy.data.db.dao
-
-import androidx.room.Dao
-import androidx.room.Query
-import io.github.wulkanowy.data.db.entities.AdminMessage
-import kotlinx.coroutines.flow.Flow
-import javax.inject.Singleton
-
-@Singleton
-@Dao
-interface AdminMessageDao : BaseDao {
-
- @Query("SELECT * FROM AdminMessages")
- fun loadAll(): Flow>
-}
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/dao/AttendanceDao.kt b/app/src/main/java/io/github/wulkanowy/data/db/dao/AttendanceDao.kt
index 7d20c9a7..d3c4f146 100644
--- a/app/src/main/java/io/github/wulkanowy/data/db/dao/AttendanceDao.kt
+++ b/app/src/main/java/io/github/wulkanowy/data/db/dao/AttendanceDao.kt
@@ -1,22 +1,24 @@
package io.github.wulkanowy.data.db.dao
import androidx.room.Dao
+import androidx.room.Delete
+import androidx.room.Insert
import androidx.room.Query
import io.github.wulkanowy.data.db.entities.Attendance
-import io.github.wulkanowy.ui.modules.dashboard.DashboardItem
-import kotlinx.coroutines.flow.Flow
-import java.time.LocalDate
+import io.reactivex.Maybe
+import org.threeten.bp.LocalDate
import javax.inject.Singleton
@Singleton
@Dao
-interface AttendanceDao : BaseDao {
+interface AttendanceDao {
- @Query("SELECT * FROM Attendance WHERE diary_id = :diaryId AND student_id = :studentId AND date >= :start AND date <= :end")
- fun loadAll(
- diaryId: Int,
- studentId: Int,
- start: LocalDate,
- end: LocalDate
- ): Flow>
+ @Insert
+ fun insertAll(exams: List): List
+
+ @Delete
+ fun deleteAll(exams: List)
+
+ @Query("SELECT * FROM Attendance WHERE diary_id = :diaryId AND student_id = :studentId AND date >= :from AND date <= :end")
+ fun loadAll(diaryId: Int, studentId: Int, from: LocalDate, end: LocalDate): Maybe>
}
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/dao/AttendanceSummaryDao.kt b/app/src/main/java/io/github/wulkanowy/data/db/dao/AttendanceSummaryDao.kt
index 4218855c..a7413de5 100644
--- a/app/src/main/java/io/github/wulkanowy/data/db/dao/AttendanceSummaryDao.kt
+++ b/app/src/main/java/io/github/wulkanowy/data/db/dao/AttendanceSummaryDao.kt
@@ -1,13 +1,21 @@
package io.github.wulkanowy.data.db.dao
import androidx.room.Dao
+import androidx.room.Delete
+import androidx.room.Insert
import androidx.room.Query
import io.github.wulkanowy.data.db.entities.AttendanceSummary
-import kotlinx.coroutines.flow.Flow
+import io.reactivex.Maybe
@Dao
-interface AttendanceSummaryDao : BaseDao {
+interface AttendanceSummaryDao {
+
+ @Insert
+ fun insertAll(exams: List): List
+
+ @Delete
+ fun deleteAll(exams: List)
@Query("SELECT * FROM AttendanceSummary WHERE diary_id = :diaryId AND student_id = :studentId AND subject_id = :subjectId")
- fun loadAll(diaryId: Int, studentId: Int, subjectId: Int): Flow>
+ fun loadAll(diaryId: Int, studentId: Int, subjectId: Int): Maybe>
}
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/dao/BaseDao.kt b/app/src/main/java/io/github/wulkanowy/data/db/dao/BaseDao.kt
deleted file mode 100644
index 937e9824..00000000
--- a/app/src/main/java/io/github/wulkanowy/data/db/dao/BaseDao.kt
+++ /dev/null
@@ -1,25 +0,0 @@
-package io.github.wulkanowy.data.db.dao
-
-import androidx.room.Delete
-import androidx.room.Insert
-import androidx.room.OnConflictStrategy
-import androidx.room.Transaction
-import androidx.room.Update
-
-interface BaseDao {
-
- @Insert(onConflict = OnConflictStrategy.REPLACE)
- suspend fun insertAll(items: List): List
-
- @Update
- suspend fun updateAll(items: List)
-
- @Delete
- suspend fun deleteAll(items: List)
-
- @Transaction
- suspend fun removeOldAndSaveNew(oldItems: List, newItems: List) {
- deleteAll(oldItems)
- insertAll(newItems)
- }
-}
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/dao/CompletedLessonsDao.kt b/app/src/main/java/io/github/wulkanowy/data/db/dao/CompletedLessonsDao.kt
index 097ad7c8..6816ceaa 100644
--- a/app/src/main/java/io/github/wulkanowy/data/db/dao/CompletedLessonsDao.kt
+++ b/app/src/main/java/io/github/wulkanowy/data/db/dao/CompletedLessonsDao.kt
@@ -1,16 +1,24 @@
package io.github.wulkanowy.data.db.dao
import androidx.room.Dao
+import androidx.room.Delete
+import androidx.room.Insert
import androidx.room.Query
import io.github.wulkanowy.data.db.entities.CompletedLesson
-import kotlinx.coroutines.flow.Flow
-import java.time.LocalDate
+import io.reactivex.Maybe
+import org.threeten.bp.LocalDate
import javax.inject.Singleton
@Singleton
@Dao
-interface CompletedLessonsDao : BaseDao {
+interface CompletedLessonsDao {
+
+ @Insert
+ fun insertAll(exams: List)
+
+ @Delete
+ fun deleteAll(exams: List)
@Query("SELECT * FROM CompletedLesson WHERE diary_id = :diaryId AND student_id = :studentId AND date >= :from AND date <= :end")
- fun loadAll(studentId: Int, diaryId: Int, from: LocalDate, end: LocalDate): Flow>
+ fun loadAll(diaryId: Int, studentId: Int, from: LocalDate, end: LocalDate): Maybe>
}
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/dao/ConferenceDao.kt b/app/src/main/java/io/github/wulkanowy/data/db/dao/ConferenceDao.kt
deleted file mode 100644
index ca9da9ea..00000000
--- a/app/src/main/java/io/github/wulkanowy/data/db/dao/ConferenceDao.kt
+++ /dev/null
@@ -1,16 +0,0 @@
-package io.github.wulkanowy.data.db.dao
-
-import androidx.room.Dao
-import androidx.room.Query
-import io.github.wulkanowy.data.db.entities.Conference
-import kotlinx.coroutines.flow.Flow
-import java.time.Instant
-import javax.inject.Singleton
-
-@Dao
-@Singleton
-interface ConferenceDao : BaseDao {
-
- @Query("SELECT * FROM Conferences WHERE diary_id = :diaryId AND student_id = :studentId AND date >= :startDate")
- fun loadAll(diaryId: Int, studentId: Int, startDate: Instant): Flow>
-}
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/dao/ExamDao.kt b/app/src/main/java/io/github/wulkanowy/data/db/dao/ExamDao.kt
index 311eeb9c..06cd5613 100644
--- a/app/src/main/java/io/github/wulkanowy/data/db/dao/ExamDao.kt
+++ b/app/src/main/java/io/github/wulkanowy/data/db/dao/ExamDao.kt
@@ -1,16 +1,24 @@
package io.github.wulkanowy.data.db.dao
import androidx.room.Dao
+import androidx.room.Delete
+import androidx.room.Insert
import androidx.room.Query
import io.github.wulkanowy.data.db.entities.Exam
-import kotlinx.coroutines.flow.Flow
-import java.time.LocalDate
+import io.reactivex.Maybe
+import org.threeten.bp.LocalDate
import javax.inject.Singleton
@Singleton
@Dao
-interface ExamDao : BaseDao {
+interface ExamDao {
+
+ @Insert
+ fun insertAll(exams: List): List
+
+ @Delete
+ fun deleteAll(exams: List)
@Query("SELECT * FROM Exams WHERE diary_id = :diaryId AND student_id = :studentId AND date >= :from AND date <= :end")
- fun loadAll(diaryId: Int, studentId: Int, from: LocalDate, end: LocalDate): Flow>
+ fun loadAll(diaryId: Int, studentId: Int, from: LocalDate, end: LocalDate): Maybe>
}
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/dao/GradeDao.kt b/app/src/main/java/io/github/wulkanowy/data/db/dao/GradeDao.kt
index ff332618..0bd210b0 100644
--- a/app/src/main/java/io/github/wulkanowy/data/db/dao/GradeDao.kt
+++ b/app/src/main/java/io/github/wulkanowy/data/db/dao/GradeDao.kt
@@ -1,19 +1,28 @@
package io.github.wulkanowy.data.db.dao
import androidx.room.Dao
+import androidx.room.Delete
+import androidx.room.Insert
import androidx.room.Query
+import androidx.room.Update
import io.github.wulkanowy.data.db.entities.Grade
-import kotlinx.coroutines.flow.Flow
+import io.reactivex.Maybe
import javax.inject.Singleton
@Singleton
@Dao
-interface GradeDao : BaseDao {
+interface GradeDao {
+
+ @Insert
+ fun insertAll(grades: List)
+
+ @Update
+ fun updateAll(grade: List)
+
+ @Delete
+ fun deleteAll(grades: List)
@Query("SELECT * FROM Grades WHERE semester_id = :semesterId AND student_id = :studentId")
- fun loadAll(semesterId: Int, studentId: Int): Flow>
+ fun loadAll(semesterId: Int, studentId: Int): Maybe>
- @Query("SELECT * FROM Grades WHERE semester_id = :semesterId AND student_id = :studentId " +
- "AND entry NOT IN(:censoredEntries)")
- fun loadAllCensored(semesterId: Int, studentId: Int, censoredEntries: Array): Flow>
}
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/dao/GradeDescriptiveDao.kt b/app/src/main/java/io/github/wulkanowy/data/db/dao/GradeDescriptiveDao.kt
deleted file mode 100644
index 6282c080..00000000
--- a/app/src/main/java/io/github/wulkanowy/data/db/dao/GradeDescriptiveDao.kt
+++ /dev/null
@@ -1,15 +0,0 @@
-package io.github.wulkanowy.data.db.dao
-
-import androidx.room.Dao
-import androidx.room.Query
-import io.github.wulkanowy.data.db.entities.GradeDescriptive
-import kotlinx.coroutines.flow.Flow
-import javax.inject.Singleton
-
-@Singleton
-@Dao
-interface GradeDescriptiveDao : BaseDao {
-
- @Query("SELECT * FROM GradesDescriptive WHERE semester_id = :semesterId AND student_id = :studentId")
- fun loadAll(semesterId: Int, studentId: Int): Flow>
-}
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/dao/GradePartialStatisticsDao.kt b/app/src/main/java/io/github/wulkanowy/data/db/dao/GradePartialStatisticsDao.kt
deleted file mode 100644
index bce6ce57..00000000
--- a/app/src/main/java/io/github/wulkanowy/data/db/dao/GradePartialStatisticsDao.kt
+++ /dev/null
@@ -1,13 +0,0 @@
-package io.github.wulkanowy.data.db.dao
-
-import androidx.room.Dao
-import androidx.room.Query
-import io.github.wulkanowy.data.db.entities.GradePartialStatistics
-import kotlinx.coroutines.flow.Flow
-
-@Dao
-interface GradePartialStatisticsDao : BaseDao {
-
- @Query("SELECT * FROM GradePartialStatistics WHERE student_id = :studentId AND semester_id = :semesterId")
- fun loadAll(semesterId: Int, studentId: Int): Flow>
-}
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/dao/GradePointsStatisticsDao.kt b/app/src/main/java/io/github/wulkanowy/data/db/dao/GradePointsStatisticsDao.kt
deleted file mode 100644
index e8074f00..00000000
--- a/app/src/main/java/io/github/wulkanowy/data/db/dao/GradePointsStatisticsDao.kt
+++ /dev/null
@@ -1,18 +0,0 @@
-package io.github.wulkanowy.data.db.dao
-
-import androidx.room.Dao
-import androidx.room.Query
-import io.github.wulkanowy.data.db.entities.GradePointsStatistics
-import kotlinx.coroutines.flow.Flow
-import javax.inject.Singleton
-
-@Singleton
-@Dao
-interface GradePointsStatisticsDao : BaseDao {
-
- @Query("SELECT * FROM GradesPointsStatistics WHERE student_id = :studentId AND semester_id = :semesterId AND subject = :subjectName")
- fun loadSubject(semesterId: Int, studentId: Int, subjectName: String): Flow>
-
- @Query("SELECT * FROM GradesPointsStatistics WHERE student_id = :studentId AND semester_id = :semesterId")
- fun loadAll(semesterId: Int, studentId: Int): Flow>
-}
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/dao/GradeSemesterStatisticsDao.kt b/app/src/main/java/io/github/wulkanowy/data/db/dao/GradeSemesterStatisticsDao.kt
deleted file mode 100644
index 09ae8171..00000000
--- a/app/src/main/java/io/github/wulkanowy/data/db/dao/GradeSemesterStatisticsDao.kt
+++ /dev/null
@@ -1,13 +0,0 @@
-package io.github.wulkanowy.data.db.dao
-
-import androidx.room.Dao
-import androidx.room.Query
-import io.github.wulkanowy.data.db.entities.GradeSemesterStatistics
-import kotlinx.coroutines.flow.Flow
-
-@Dao
-interface GradeSemesterStatisticsDao : BaseDao {
-
- @Query("SELECT * FROM GradeSemesterStatistics WHERE student_id = :studentId AND semester_id = :semesterId")
- fun loadAll(semesterId: Int, studentId: Int): Flow>
-}
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/dao/GradeStatisticsDao.kt b/app/src/main/java/io/github/wulkanowy/data/db/dao/GradeStatisticsDao.kt
new file mode 100644
index 00000000..338c369f
--- /dev/null
+++ b/app/src/main/java/io/github/wulkanowy/data/db/dao/GradeStatisticsDao.kt
@@ -0,0 +1,26 @@
+package io.github.wulkanowy.data.db.dao
+
+import androidx.room.Dao
+import androidx.room.Delete
+import androidx.room.Insert
+import androidx.room.Query
+import io.github.wulkanowy.data.db.entities.GradeStatistics
+import io.reactivex.Maybe
+import javax.inject.Singleton
+
+@Singleton
+@Dao
+interface GradeStatisticsDao {
+
+ @Insert
+ fun insertAll(gradesStatistics: List)
+
+ @Delete
+ fun deleteAll(gradesStatistics: List)
+
+ @Query("SELECT * FROM GradesStatistics WHERE student_id = :studentId AND semester_id = :semesterId AND subject = :subjectName AND is_semester = :isSemester")
+ fun loadSubject(semesterId: Int, studentId: Int, subjectName: String, isSemester: Boolean): Maybe>
+
+ @Query("SELECT * FROM GradesStatistics WHERE student_id = :studentId AND semester_id = :semesterId AND is_semester = :isSemester")
+ fun loadAll(semesterId: Int, studentId: Int, isSemester: Boolean): Maybe>
+}
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/dao/GradeSummaryDao.kt b/app/src/main/java/io/github/wulkanowy/data/db/dao/GradeSummaryDao.kt
index fc9ad66e..3f2e87bd 100644
--- a/app/src/main/java/io/github/wulkanowy/data/db/dao/GradeSummaryDao.kt
+++ b/app/src/main/java/io/github/wulkanowy/data/db/dao/GradeSummaryDao.kt
@@ -1,15 +1,23 @@
package io.github.wulkanowy.data.db.dao
import androidx.room.Dao
+import androidx.room.Delete
+import androidx.room.Insert
import androidx.room.Query
import io.github.wulkanowy.data.db.entities.GradeSummary
-import kotlinx.coroutines.flow.Flow
+import io.reactivex.Maybe
import javax.inject.Singleton
@Singleton
@Dao
-interface GradeSummaryDao : BaseDao {
+interface GradeSummaryDao {
+
+ @Insert
+ fun insertAll(gradesSummary: List)
+
+ @Delete
+ fun deleteAll(gradesSummary: List)
@Query("SELECT * FROM GradesSummary WHERE student_id = :studentId AND semester_id = :semesterId")
- fun loadAll(semesterId: Int, studentId: Int): Flow>
+ fun loadAll(semesterId: Int, studentId: Int): Maybe>
}
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/dao/HomeworkDao.kt b/app/src/main/java/io/github/wulkanowy/data/db/dao/HomeworkDao.kt
index 2092de49..253bdb11 100644
--- a/app/src/main/java/io/github/wulkanowy/data/db/dao/HomeworkDao.kt
+++ b/app/src/main/java/io/github/wulkanowy/data/db/dao/HomeworkDao.kt
@@ -1,16 +1,24 @@
package io.github.wulkanowy.data.db.dao
import androidx.room.Dao
+import androidx.room.Delete
+import androidx.room.Insert
import androidx.room.Query
import io.github.wulkanowy.data.db.entities.Homework
-import kotlinx.coroutines.flow.Flow
-import java.time.LocalDate
+import io.reactivex.Maybe
+import org.threeten.bp.LocalDate
import javax.inject.Singleton
@Singleton
@Dao
-interface HomeworkDao : BaseDao {
+interface HomeworkDao {
+
+ @Insert
+ fun insertAll(homework: List)
+
+ @Delete
+ fun deleteAll(homework: List)
@Query("SELECT * FROM Homework WHERE semester_id = :semesterId AND student_id = :studentId AND date >= :from AND date <= :end")
- fun loadAll(semesterId: Int, studentId: Int, from: LocalDate, end: LocalDate): Flow>
+ fun loadAll(semesterId: Int, studentId: Int, from: LocalDate, end: LocalDate): Maybe>
}
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/dao/LuckyNumberDao.kt b/app/src/main/java/io/github/wulkanowy/data/db/dao/LuckyNumberDao.kt
index d9aa2436..afd7905c 100644
--- a/app/src/main/java/io/github/wulkanowy/data/db/dao/LuckyNumberDao.kt
+++ b/app/src/main/java/io/github/wulkanowy/data/db/dao/LuckyNumberDao.kt
@@ -1,19 +1,29 @@
package io.github.wulkanowy.data.db.dao
import androidx.room.Dao
+import androidx.room.Delete
+import androidx.room.Insert
import androidx.room.Query
+import androidx.room.Update
import io.github.wulkanowy.data.db.entities.LuckyNumber
-import kotlinx.coroutines.flow.Flow
-import java.time.LocalDate
+import io.reactivex.Maybe
+import org.threeten.bp.LocalDate
import javax.inject.Singleton
@Singleton
@Dao
-interface LuckyNumberDao : BaseDao {
+interface LuckyNumberDao {
+
+ @Insert
+ fun insert(luckyNumber: LuckyNumber)
+
+ @Update
+ fun update(luckyNumber: LuckyNumber)
+
+ @Delete
+ fun delete(luckyNumber: LuckyNumber)
@Query("SELECT * FROM LuckyNumbers WHERE student_id = :studentId AND date = :date")
- fun load(studentId: Int, date: LocalDate): Flow
+ fun load(studentId: Int, date: LocalDate): Maybe
- @Query("SELECT * FROM LuckyNumbers WHERE student_id = :studentId AND date >= :start AND date <= :end")
- fun getAll(studentId: Int, start: LocalDate, end: LocalDate): Flow>
}
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/dao/MailboxDao.kt b/app/src/main/java/io/github/wulkanowy/data/db/dao/MailboxDao.kt
deleted file mode 100644
index 084192a0..00000000
--- a/app/src/main/java/io/github/wulkanowy/data/db/dao/MailboxDao.kt
+++ /dev/null
@@ -1,18 +0,0 @@
-package io.github.wulkanowy.data.db.dao
-
-import androidx.room.Dao
-import androidx.room.Query
-import io.github.wulkanowy.data.db.entities.Mailbox
-import kotlinx.coroutines.flow.Flow
-import javax.inject.Singleton
-
-@Singleton
-@Dao
-interface MailboxDao : BaseDao {
-
- @Query("SELECT * FROM Mailboxes WHERE email = :email")
- suspend fun loadAll(email: String): List
-
- @Query("SELECT * FROM Mailboxes WHERE email = :email AND symbol = :symbol AND schoolId = :schoolId")
- fun loadAll(email: String, symbol: String, schoolId: String): Flow>
-}
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/dao/MessageAttachmentDao.kt b/app/src/main/java/io/github/wulkanowy/data/db/dao/MessageAttachmentDao.kt
deleted file mode 100644
index b69083a1..00000000
--- a/app/src/main/java/io/github/wulkanowy/data/db/dao/MessageAttachmentDao.kt
+++ /dev/null
@@ -1,13 +0,0 @@
-package io.github.wulkanowy.data.db.dao
-
-import androidx.room.Dao
-import androidx.room.Insert
-import androidx.room.OnConflictStrategy
-import io.github.wulkanowy.data.db.entities.MessageAttachment
-
-@Dao
-interface MessageAttachmentDao : BaseDao {
-
- @Insert(onConflict = OnConflictStrategy.REPLACE)
- suspend fun insertAttachments(items: List): List
-}
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/dao/MessagesDao.kt b/app/src/main/java/io/github/wulkanowy/data/db/dao/MessagesDao.kt
index 11e6da1e..4f72c6c9 100644
--- a/app/src/main/java/io/github/wulkanowy/data/db/dao/MessagesDao.kt
+++ b/app/src/main/java/io/github/wulkanowy/data/db/dao/MessagesDao.kt
@@ -1,30 +1,31 @@
package io.github.wulkanowy.data.db.dao
import androidx.room.Dao
+import androidx.room.Delete
+import androidx.room.Insert
import androidx.room.Query
-import androidx.room.Transaction
+import androidx.room.Update
import io.github.wulkanowy.data.db.entities.Message
-import io.github.wulkanowy.data.db.entities.MessageWithAttachment
-import io.github.wulkanowy.data.db.entities.MessageWithMutedAuthor
-import kotlinx.coroutines.flow.Flow
+import io.reactivex.Maybe
@Dao
-interface MessagesDao : BaseDao {
- @Transaction
- @Query("SELECT * FROM Messages WHERE message_global_key = :messageGlobalKey")
- fun loadMessageWithAttachment(messageGlobalKey: String): Flow
+interface MessagesDao {
- @Transaction
- @Query("SELECT * FROM Messages WHERE mailbox_key = :mailboxKey AND folder_id = :folder ORDER BY date DESC")
- fun loadMessagesWithMutedAuthor(mailboxKey: String, folder: Int): Flow>
+ @Insert
+ fun insertAll(messages: List)
- @Transaction
- @Query("SELECT * FROM Messages WHERE email = :email AND folder_id = :folder ORDER BY date DESC")
- fun loadMessagesWithMutedAuthor(folder: Int, email: String): Flow>
+ @Delete
+ fun deleteAll(messages: List)
- @Query("SELECT * FROM Messages WHERE mailbox_key = :mailboxKey AND folder_id = :folder ORDER BY date DESC")
- fun loadAll(mailboxKey: String, folder: Int): Flow>
+ @Update
+ fun updateAll(messages: List)
- @Query("SELECT * FROM Messages WHERE email = :email AND folder_id = :folder ORDER BY date DESC")
- fun loadAll(folder: Int, email: String): Flow>
+ @Query("SELECT * FROM Messages WHERE student_id = :studentId AND folder_id = :folder AND removed = 0 ORDER BY date DESC")
+ fun loadAll(studentId: Int, folder: Int): Maybe>
+
+ @Query("SELECT * FROM Messages WHERE id = :id")
+ fun load(id: Long): Maybe
+
+ @Query("SELECT * FROM Messages WHERE student_id = :studentId AND removed = 1 ORDER BY date DESC")
+ fun loadDeleted(studentId: Int): Maybe>
}
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/dao/MobileDeviceDao.kt b/app/src/main/java/io/github/wulkanowy/data/db/dao/MobileDeviceDao.kt
index 5ddb4dd0..d6b97f6a 100644
--- a/app/src/main/java/io/github/wulkanowy/data/db/dao/MobileDeviceDao.kt
+++ b/app/src/main/java/io/github/wulkanowy/data/db/dao/MobileDeviceDao.kt
@@ -1,13 +1,21 @@
package io.github.wulkanowy.data.db.dao
import androidx.room.Dao
+import androidx.room.Delete
+import androidx.room.Insert
import androidx.room.Query
import io.github.wulkanowy.data.db.entities.MobileDevice
-import kotlinx.coroutines.flow.Flow
+import io.reactivex.Maybe
@Dao
-interface MobileDeviceDao : BaseDao {
+interface MobileDeviceDao {
- @Query("SELECT * FROM MobileDevices WHERE user_login_id = :studentId ORDER BY date DESC")
- fun loadAll(studentId: Int): Flow>
+ @Insert
+ fun insertAll(devices: List)
+
+ @Delete
+ fun deleteAll(devices: List)
+
+ @Query("SELECT * FROM MobileDevices WHERE student_id = :studentId ORDER BY date DESC")
+ fun loadAll(studentId: Int): Maybe>
}
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/dao/MutedMessageSendersDao.kt b/app/src/main/java/io/github/wulkanowy/data/db/dao/MutedMessageSendersDao.kt
deleted file mode 100644
index 0a866401..00000000
--- a/app/src/main/java/io/github/wulkanowy/data/db/dao/MutedMessageSendersDao.kt
+++ /dev/null
@@ -1,20 +0,0 @@
-package io.github.wulkanowy.data.db.dao
-
-import androidx.room.Dao
-import androidx.room.Insert
-import androidx.room.OnConflictStrategy
-import androidx.room.Query
-import io.github.wulkanowy.data.db.entities.MutedMessageSender
-
-@Dao
-interface MutedMessageSendersDao : BaseDao {
-
- @Query("SELECT COUNT(*) FROM MutedMessageSenders WHERE author = :author")
- suspend fun checkMute(author: String): Boolean
-
- @Insert(onConflict = OnConflictStrategy.IGNORE)
- suspend fun insertMute(mute: MutedMessageSender): Long
-
- @Query("DELETE FROM MutedMessageSenders WHERE author = :author")
- suspend fun deleteMute(author: String)
-}
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/dao/NoteDao.kt b/app/src/main/java/io/github/wulkanowy/data/db/dao/NoteDao.kt
index 98de5ba3..867e06a2 100644
--- a/app/src/main/java/io/github/wulkanowy/data/db/dao/NoteDao.kt
+++ b/app/src/main/java/io/github/wulkanowy/data/db/dao/NoteDao.kt
@@ -1,14 +1,28 @@
package io.github.wulkanowy.data.db.dao
import androidx.room.Dao
+import androidx.room.Delete
+import androidx.room.Insert
import androidx.room.Query
+import androidx.room.Update
import io.github.wulkanowy.data.db.entities.Note
-import kotlinx.coroutines.flow.Flow
+import io.reactivex.Maybe
import javax.inject.Singleton
@Singleton
@Dao
-interface NoteDao : BaseDao {
+interface NoteDao {
+
+ @Insert
+ fun insertAll(notes: List)
+
+ @Update
+ fun updateAll(notes: List)
+
+ @Delete
+ fun deleteAll(notes: List)
+
@Query("SELECT * FROM Notes WHERE student_id = :studentId")
- fun loadAll(studentId: Int): Flow>
+ fun loadAll(studentId: Int): Maybe>
+
}
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/dao/NotificationDao.kt b/app/src/main/java/io/github/wulkanowy/data/db/dao/NotificationDao.kt
deleted file mode 100644
index c5ae21bc..00000000
--- a/app/src/main/java/io/github/wulkanowy/data/db/dao/NotificationDao.kt
+++ /dev/null
@@ -1,15 +0,0 @@
-package io.github.wulkanowy.data.db.dao
-
-import androidx.room.Dao
-import androidx.room.Query
-import io.github.wulkanowy.data.db.entities.Notification
-import kotlinx.coroutines.flow.Flow
-import javax.inject.Singleton
-
-@Singleton
-@Dao
-interface NotificationDao : BaseDao {
-
- @Query("SELECT * FROM Notifications WHERE student_id = :studentId OR student_id = -1")
- fun loadAll(studentId: Long): Flow>
-}
\ No newline at end of file
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/dao/RecipientDao.kt b/app/src/main/java/io/github/wulkanowy/data/db/dao/RecipientDao.kt
index 1956261e..7c5fd6ca 100644
--- a/app/src/main/java/io/github/wulkanowy/data/db/dao/RecipientDao.kt
+++ b/app/src/main/java/io/github/wulkanowy/data/db/dao/RecipientDao.kt
@@ -1,15 +1,23 @@
package io.github.wulkanowy.data.db.dao
import androidx.room.Dao
+import androidx.room.Delete
+import androidx.room.Insert
import androidx.room.Query
-import io.github.wulkanowy.data.db.entities.MailboxType
import io.github.wulkanowy.data.db.entities.Recipient
+import io.reactivex.Maybe
import javax.inject.Singleton
@Singleton
@Dao
-interface RecipientDao : BaseDao {
+interface RecipientDao {
- @Query("SELECT * FROM Recipients WHERE type = :type AND studentMailboxGlobalKey = :studentMailboxGlobalKey")
- suspend fun loadAll(type: MailboxType, studentMailboxGlobalKey: String): List
+ @Insert
+ fun insertAll(messages: List)
+
+ @Delete
+ fun deleteAll(messages: List)
+
+ @Query("SELECT * FROM Recipients WHERE student_id = :studentId AND role = :role AND unit_id = :unitId")
+ fun load(studentId: Int, role: Int, unitId: Int): Maybe>
}
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/dao/ReportingUnitDao.kt b/app/src/main/java/io/github/wulkanowy/data/db/dao/ReportingUnitDao.kt
new file mode 100644
index 00000000..1898390a
--- /dev/null
+++ b/app/src/main/java/io/github/wulkanowy/data/db/dao/ReportingUnitDao.kt
@@ -0,0 +1,26 @@
+package io.github.wulkanowy.data.db.dao
+
+import androidx.room.Dao
+import androidx.room.Delete
+import androidx.room.Insert
+import androidx.room.Query
+import io.github.wulkanowy.data.db.entities.ReportingUnit
+import io.reactivex.Maybe
+import javax.inject.Singleton
+
+@Singleton
+@Dao
+interface ReportingUnitDao {
+
+ @Insert
+ fun insertAll(reportingUnits: List)
+
+ @Delete
+ fun deleteAll(reportingUnits: List)
+
+ @Query("SELECT * FROM ReportingUnits WHERE student_id = :studentId")
+ fun load(studentId: Int): Maybe>
+
+ @Query("SELECT * FROM ReportingUnits WHERE student_id = :studentId AND real_id = :unitId")
+ fun loadOne(studentId: Int, unitId: Int): Maybe
+}
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/dao/SchoolAnnouncementDao.kt b/app/src/main/java/io/github/wulkanowy/data/db/dao/SchoolAnnouncementDao.kt
deleted file mode 100644
index 64d49bce..00000000
--- a/app/src/main/java/io/github/wulkanowy/data/db/dao/SchoolAnnouncementDao.kt
+++ /dev/null
@@ -1,15 +0,0 @@
-package io.github.wulkanowy.data.db.dao
-
-import androidx.room.Dao
-import androidx.room.Query
-import io.github.wulkanowy.data.db.entities.SchoolAnnouncement
-import kotlinx.coroutines.flow.Flow
-import javax.inject.Singleton
-
-@Dao
-@Singleton
-interface SchoolAnnouncementDao : BaseDao {
-
- @Query("SELECT * FROM SchoolAnnouncements WHERE user_login_id = :studentId ORDER BY date DESC")
- fun loadAll(studentId: Int): Flow>
-}
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/dao/SchoolDao.kt b/app/src/main/java/io/github/wulkanowy/data/db/dao/SchoolDao.kt
deleted file mode 100644
index f39791f6..00000000
--- a/app/src/main/java/io/github/wulkanowy/data/db/dao/SchoolDao.kt
+++ /dev/null
@@ -1,15 +0,0 @@
-package io.github.wulkanowy.data.db.dao
-
-import androidx.room.Dao
-import androidx.room.Query
-import io.github.wulkanowy.data.db.entities.School
-import kotlinx.coroutines.flow.Flow
-import javax.inject.Singleton
-
-@Singleton
-@Dao
-interface SchoolDao : BaseDao {
-
- @Query("SELECT * FROM School WHERE student_id = :studentId AND class_id = :classId")
- fun load(studentId: Int, classId: Int): Flow
-}
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/dao/SemesterDao.kt b/app/src/main/java/io/github/wulkanowy/data/db/dao/SemesterDao.kt
index bf9a34d0..01841fb6 100644
--- a/app/src/main/java/io/github/wulkanowy/data/db/dao/SemesterDao.kt
+++ b/app/src/main/java/io/github/wulkanowy/data/db/dao/SemesterDao.kt
@@ -1,19 +1,23 @@
package io.github.wulkanowy.data.db.dao
import androidx.room.Dao
+import androidx.room.Delete
import androidx.room.Insert
-import androidx.room.OnConflictStrategy
import androidx.room.Query
import io.github.wulkanowy.data.db.entities.Semester
+import io.reactivex.Maybe
import javax.inject.Singleton
@Singleton
@Dao
-interface SemesterDao : BaseDao {
+interface SemesterDao {
- @Insert(onConflict = OnConflictStrategy.IGNORE)
- suspend fun insertSemesters(items: List): List
+ @Insert
+ fun insertAll(semester: List)
- @Query("SELECT * FROM Semesters WHERE (student_id = :studentId AND class_id = :classId) OR (student_id = :studentId AND class_id = 0)")
- suspend fun loadAll(studentId: Int, classId: Int): List
+ @Delete
+ fun deleteAll(semester: List)
+
+ @Query("SELECT * FROM Semesters WHERE student_id = :studentId AND class_id = :classId")
+ fun loadAll(studentId: Int, classId: Int): Maybe>
}
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/dao/StudentDao.kt b/app/src/main/java/io/github/wulkanowy/data/db/dao/StudentDao.kt
index 5302b320..57bf25fb 100644
--- a/app/src/main/java/io/github/wulkanowy/data/db/dao/StudentDao.kt
+++ b/app/src/main/java/io/github/wulkanowy/data/db/dao/StudentDao.kt
@@ -3,69 +3,31 @@ package io.github.wulkanowy.data.db.dao
import androidx.room.Dao
import androidx.room.Delete
import androidx.room.Insert
-import androidx.room.OnConflictStrategy
+import androidx.room.OnConflictStrategy.ABORT
import androidx.room.Query
-import androidx.room.Transaction
-import androidx.room.Update
-import io.github.wulkanowy.data.db.entities.Semester
import io.github.wulkanowy.data.db.entities.Student
-import io.github.wulkanowy.data.db.entities.StudentIsAuthorized
-import io.github.wulkanowy.data.db.entities.StudentIsEduOne
-import io.github.wulkanowy.data.db.entities.StudentName
-import io.github.wulkanowy.data.db.entities.StudentNickAndAvatar
+import io.reactivex.Maybe
import javax.inject.Singleton
@Singleton
@Dao
-abstract class StudentDao {
+interface StudentDao {
- @Insert(onConflict = OnConflictStrategy.ABORT)
- abstract suspend fun insertAll(student: List): List
+ @Insert(onConflict = ABORT)
+ fun insertAll(student: List): List
@Delete
- abstract suspend fun delete(student: Student)
-
- @Update(entity = Student::class)
- abstract suspend fun update(studentIsAuthorized: StudentIsAuthorized)
-
- @Update(entity = Student::class)
- abstract suspend fun update(studentIsEduOne: StudentIsEduOne)
-
- @Update(entity = Student::class)
- abstract suspend fun update(studentNickAndAvatar: StudentNickAndAvatar)
-
- @Update(entity = Student::class)
- abstract suspend fun update(studentName: StudentName)
+ fun delete(student: Student)
@Query("SELECT * FROM Students WHERE is_current = 1")
- abstract suspend fun loadCurrent(): Student?
-
- @Query("SELECT * FROM Students WHERE id = :id")
- abstract suspend fun loadById(id: Long): Student?
+ fun loadCurrent(): Maybe
@Query("SELECT * FROM Students")
- abstract suspend fun loadAll(): List
-
- @Transaction
- @Query("SELECT * FROM Students JOIN Semesters ON (Students.student_id = Semesters.student_id AND Students.class_id = Semesters.class_id) OR (Students.student_id = Semesters.student_id AND Semesters.class_id = 0)")
- abstract suspend fun loadStudentsWithSemesters(): Map>
-
- @Transaction
- @Query("SELECT * FROM Students JOIN Semesters ON (Students.student_id = Semesters.student_id AND Students.class_id = Semesters.class_id) OR (Students.student_id = Semesters.student_id AND Semesters.class_id = 0) WHERE Students.id = :id")
- abstract suspend fun loadStudentWithSemestersById(id: Long): Map>
+ fun loadAll(): Maybe>
@Query("UPDATE Students SET is_current = 1 WHERE id = :id")
- abstract suspend fun updateCurrent(id: Long)
+ fun updateCurrent(id: Long)
@Query("UPDATE Students SET is_current = 0")
- abstract suspend fun resetCurrent()
-
- @Query("DELETE FROM Students WHERE email = :email AND user_name = :userName")
- abstract suspend fun deleteByEmailAndUserName(email: String, userName: String)
-
- @Transaction
- open suspend fun switchCurrent(id: Long) {
- resetCurrent()
- updateCurrent(id)
- }
+ fun resetCurrent()
}
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/dao/StudentInfoDao.kt b/app/src/main/java/io/github/wulkanowy/data/db/dao/StudentInfoDao.kt
deleted file mode 100644
index 5ec86af1..00000000
--- a/app/src/main/java/io/github/wulkanowy/data/db/dao/StudentInfoDao.kt
+++ /dev/null
@@ -1,15 +0,0 @@
-package io.github.wulkanowy.data.db.dao
-
-import androidx.room.Dao
-import androidx.room.Query
-import io.github.wulkanowy.data.db.entities.StudentInfo
-import kotlinx.coroutines.flow.Flow
-import javax.inject.Singleton
-
-@Singleton
-@Dao
-interface StudentInfoDao : BaseDao {
-
- @Query("SELECT * FROM StudentInfo WHERE student_id = :studentId")
- fun loadStudentInfo(studentId: Int): Flow
-}
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/dao/SubjectDao.kt b/app/src/main/java/io/github/wulkanowy/data/db/dao/SubjectDao.kt
index 4cd742b5..725a371a 100644
--- a/app/src/main/java/io/github/wulkanowy/data/db/dao/SubjectDao.kt
+++ b/app/src/main/java/io/github/wulkanowy/data/db/dao/SubjectDao.kt
@@ -1,13 +1,21 @@
package io.github.wulkanowy.data.db.dao
import androidx.room.Dao
+import androidx.room.Delete
+import androidx.room.Insert
import androidx.room.Query
import io.github.wulkanowy.data.db.entities.Subject
-import kotlinx.coroutines.flow.Flow
+import io.reactivex.Maybe
@Dao
-interface SubjectDao : BaseDao {
+interface SubjectDao {
+
+ @Insert
+ fun insertAll(subjects: List): List
+
+ @Delete
+ fun deleteAll(subjects: List)
@Query("SELECT * FROM Subjects WHERE diary_id = :diaryId AND student_id = :studentId")
- fun loadAll(diaryId: Int, studentId: Int): Flow>
+ fun loadAll(diaryId: Int, studentId: Int): Maybe>
}
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/dao/TeacherDao.kt b/app/src/main/java/io/github/wulkanowy/data/db/dao/TeacherDao.kt
deleted file mode 100644
index 6adac220..00000000
--- a/app/src/main/java/io/github/wulkanowy/data/db/dao/TeacherDao.kt
+++ /dev/null
@@ -1,15 +0,0 @@
-package io.github.wulkanowy.data.db.dao
-
-import androidx.room.Dao
-import androidx.room.Query
-import io.github.wulkanowy.data.db.entities.Teacher
-import kotlinx.coroutines.flow.Flow
-import javax.inject.Singleton
-
-@Singleton
-@Dao
-interface TeacherDao : BaseDao {
-
- @Query("SELECT * FROM Teachers WHERE student_id = :studentId AND class_id = :classId")
- fun loadAll(studentId: Int, classId: Int): Flow>
-}
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/dao/TimetableAdditionalDao.kt b/app/src/main/java/io/github/wulkanowy/data/db/dao/TimetableAdditionalDao.kt
deleted file mode 100644
index 914ce340..00000000
--- a/app/src/main/java/io/github/wulkanowy/data/db/dao/TimetableAdditionalDao.kt
+++ /dev/null
@@ -1,25 +0,0 @@
-package io.github.wulkanowy.data.db.dao
-
-import androidx.room.Dao
-import androidx.room.Query
-import io.github.wulkanowy.data.db.entities.TimetableAdditional
-import kotlinx.coroutines.flow.Flow
-import java.time.LocalDate
-import java.util.UUID
-import javax.inject.Singleton
-
-@Dao
-@Singleton
-interface TimetableAdditionalDao : BaseDao {
-
- @Query("SELECT * FROM TimetableAdditional WHERE diary_id = :diaryId AND student_id = :studentId AND date >= :from AND date <= :end")
- fun loadAll(
- diaryId: Int,
- studentId: Int,
- from: LocalDate,
- end: LocalDate
- ): Flow>
-
- @Query("DELETE FROM TimetableAdditional WHERE repeat_id = :repeatId")
- suspend fun deleteAllByRepeatId(repeatId: UUID)
-}
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/dao/TimetableDao.kt b/app/src/main/java/io/github/wulkanowy/data/db/dao/TimetableDao.kt
index 40d97ea9..abe21361 100644
--- a/app/src/main/java/io/github/wulkanowy/data/db/dao/TimetableDao.kt
+++ b/app/src/main/java/io/github/wulkanowy/data/db/dao/TimetableDao.kt
@@ -1,19 +1,24 @@
package io.github.wulkanowy.data.db.dao
import androidx.room.Dao
+import androidx.room.Delete
+import androidx.room.Insert
import androidx.room.Query
import io.github.wulkanowy.data.db.entities.Timetable
-import kotlinx.coroutines.flow.Flow
-import java.time.LocalDate
+import io.reactivex.Maybe
+import org.threeten.bp.LocalDate
import javax.inject.Singleton
@Singleton
@Dao
-interface TimetableDao : BaseDao {
+interface TimetableDao {
+
+ @Insert
+ fun insertAll(exams: List): List
+
+ @Delete
+ fun deleteAll(exams: List)
@Query("SELECT * FROM Timetable WHERE diary_id = :diaryId AND student_id = :studentId AND date >= :from AND date <= :end")
- fun loadAll(diaryId: Int, studentId: Int, from: LocalDate, end: LocalDate): Flow>
-
- @Query("SELECT * FROM Timetable WHERE diary_id = :diaryId AND student_id = :studentId AND date >= :from AND date <= :end")
- suspend fun load(diaryId: Int, studentId: Int, from: LocalDate, end: LocalDate): List
+ fun loadAll(diaryId: Int, studentId: Int, from: LocalDate, end: LocalDate): Maybe>
}
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/dao/TimetableHeaderDao.kt b/app/src/main/java/io/github/wulkanowy/data/db/dao/TimetableHeaderDao.kt
deleted file mode 100644
index 916d1901..00000000
--- a/app/src/main/java/io/github/wulkanowy/data/db/dao/TimetableHeaderDao.kt
+++ /dev/null
@@ -1,16 +0,0 @@
-package io.github.wulkanowy.data.db.dao
-
-import androidx.room.Dao
-import androidx.room.Query
-import io.github.wulkanowy.data.db.entities.TimetableHeader
-import kotlinx.coroutines.flow.Flow
-import java.time.LocalDate
-import javax.inject.Singleton
-
-@Dao
-@Singleton
-interface TimetableHeaderDao : BaseDao {
-
- @Query("SELECT * FROM TimetableHeaders WHERE diary_id = :diaryId AND student_id = :studentId AND date >= :from AND date <= :end")
- fun loadAll(diaryId: Int, studentId: Int, from: LocalDate, end: LocalDate): Flow>
-}
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/entities/AdminMessage.kt b/app/src/main/java/io/github/wulkanowy/data/db/entities/AdminMessage.kt
deleted file mode 100644
index a8604c5c..00000000
--- a/app/src/main/java/io/github/wulkanowy/data/db/entities/AdminMessage.kt
+++ /dev/null
@@ -1,49 +0,0 @@
-package io.github.wulkanowy.data.db.entities
-
-import androidx.room.ColumnInfo
-import androidx.room.Entity
-import androidx.room.PrimaryKey
-import io.github.wulkanowy.data.enums.MessageType
-import io.github.wulkanowy.data.serializers.SafeMessageTypeEnumListSerializer
-import kotlinx.serialization.SerialName
-import kotlinx.serialization.Serializable
-
-@Serializable
-@Entity(tableName = "AdminMessages")
-data class AdminMessage(
-
- @PrimaryKey
- val id: Int,
-
- val title: String,
-
- val content: String,
-
- @ColumnInfo(name = "version_name")
- val versionMin: Int? = null,
-
- @ColumnInfo(name = "version_max")
- val versionMax: Int? = null,
-
- @ColumnInfo(name = "target_register_host")
- val targetRegisterHost: String? = null,
-
- @ColumnInfo(name = "target_flavor")
- val targetFlavor: String? = null,
-
- @ColumnInfo(name = "destination_url")
- val destinationUrl: String? = null,
-
- val priority: String,
-
- @SerialName("messageTypes")
- @Serializable(with = SafeMessageTypeEnumListSerializer::class)
- @ColumnInfo(name = "types", defaultValue = "[]")
- val types: List = emptyList(),
-
- @ColumnInfo(name = "is_ok_visible", defaultValue = "0")
- val isOkVisible: Boolean = false,
-
- @ColumnInfo(name = "is_x_visible", defaultValue = "0")
- val isXVisible: Boolean = false
-)
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/entities/Attendance.kt b/app/src/main/java/io/github/wulkanowy/data/db/entities/Attendance.kt
index b40dd52e..3c58971a 100644
--- a/app/src/main/java/io/github/wulkanowy/data/db/entities/Attendance.kt
+++ b/app/src/main/java/io/github/wulkanowy/data/db/entities/Attendance.kt
@@ -3,8 +3,8 @@ package io.github.wulkanowy.data.db.entities
import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.PrimaryKey
+import org.threeten.bp.LocalDate
import java.io.Serializable
-import java.time.LocalDate
@Entity(tableName = "Attendance")
data class Attendance(
@@ -15,9 +15,6 @@ data class Attendance(
@ColumnInfo(name = "diary_id")
val diaryId: Int,
- @ColumnInfo(name = "time_id")
- val timeId: Int,
-
val date: LocalDate,
val number: Int,
@@ -36,18 +33,9 @@ data class Attendance(
val excused: Boolean,
- val deleted: Boolean,
-
- val excusable: Boolean,
-
- @ColumnInfo(name = "excuse_status")
- val excuseStatus: String?
-
+ val deleted: Boolean
) : Serializable {
@PrimaryKey(autoGenerate = true)
var id: Long = 0
-
- @ColumnInfo(name = "is_notified")
- var isNotified: Boolean = true
}
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/entities/AttendanceSummary.kt b/app/src/main/java/io/github/wulkanowy/data/db/entities/AttendanceSummary.kt
index 7d628eba..d2e1f174 100644
--- a/app/src/main/java/io/github/wulkanowy/data/db/entities/AttendanceSummary.kt
+++ b/app/src/main/java/io/github/wulkanowy/data/db/entities/AttendanceSummary.kt
@@ -3,8 +3,8 @@ package io.github.wulkanowy.data.db.entities
import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.PrimaryKey
+import org.threeten.bp.Month
import java.io.Serializable
-import java.time.Month
@Entity(tableName = "AttendanceSummary")
data class AttendanceSummary(
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/entities/CompletedLesson.kt b/app/src/main/java/io/github/wulkanowy/data/db/entities/CompletedLesson.kt
index e305d467..775f3f55 100644
--- a/app/src/main/java/io/github/wulkanowy/data/db/entities/CompletedLesson.kt
+++ b/app/src/main/java/io/github/wulkanowy/data/db/entities/CompletedLesson.kt
@@ -3,8 +3,8 @@ package io.github.wulkanowy.data.db.entities
import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.PrimaryKey
+import org.threeten.bp.LocalDate
import java.io.Serializable
-import java.time.LocalDate
@Entity(tableName = "CompletedLesson")
data class CompletedLesson(
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/entities/Conference.kt b/app/src/main/java/io/github/wulkanowy/data/db/entities/Conference.kt
deleted file mode 100644
index ba3958db..00000000
--- a/app/src/main/java/io/github/wulkanowy/data/db/entities/Conference.kt
+++ /dev/null
@@ -1,38 +0,0 @@
-package io.github.wulkanowy.data.db.entities
-
-import androidx.room.ColumnInfo
-import androidx.room.Entity
-import androidx.room.PrimaryKey
-import java.io.Serializable
-import java.time.Instant
-
-@Entity(tableName = "Conferences")
-data class Conference(
-
- @ColumnInfo(name = "student_id")
- val studentId: Int,
-
- @ColumnInfo(name = "diary_id")
- val diaryId: Int,
-
- val title: String,
-
- val subject: String,
-
- val agenda: String,
-
- @ColumnInfo(name = "present_on_conference")
- val presentOnConference: String,
-
- @ColumnInfo(name = "conference_id")
- val conferenceId: Int,
-
- val date: Instant,
-) : Serializable {
-
- @PrimaryKey(autoGenerate = true)
- var id: Long = 0
-
- @ColumnInfo(name = "is_notified")
- var isNotified: Boolean = true
-}
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/entities/Exam.kt b/app/src/main/java/io/github/wulkanowy/data/db/entities/Exam.kt
index 2292c3e6..9ae795e7 100644
--- a/app/src/main/java/io/github/wulkanowy/data/db/entities/Exam.kt
+++ b/app/src/main/java/io/github/wulkanowy/data/db/entities/Exam.kt
@@ -3,8 +3,8 @@ package io.github.wulkanowy.data.db.entities
import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.PrimaryKey
+import org.threeten.bp.LocalDate
import java.io.Serializable
-import java.time.LocalDate
@Entity(tableName = "Exams")
data class Exam(
@@ -22,7 +22,6 @@ data class Exam(
val subject: String,
- @Deprecated("not available anymore")
val group: String,
val type: String,
@@ -37,7 +36,4 @@ data class Exam(
@PrimaryKey(autoGenerate = true)
var id: Long = 0
-
- @ColumnInfo(name = "is_notified")
- var isNotified: Boolean = true
}
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/entities/Grade.kt b/app/src/main/java/io/github/wulkanowy/data/db/entities/Grade.kt
index a0f1c3a6..1221a7aa 100644
--- a/app/src/main/java/io/github/wulkanowy/data/db/entities/Grade.kt
+++ b/app/src/main/java/io/github/wulkanowy/data/db/entities/Grade.kt
@@ -3,8 +3,8 @@ package io.github.wulkanowy.data.db.entities
import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.PrimaryKey
+import org.threeten.bp.LocalDate
import java.io.Serializable
-import java.time.LocalDate
@Entity(tableName = "Grades")
data class Grade(
@@ -19,7 +19,7 @@ data class Grade(
val entry: String,
- val value: Double,
+ val value: Int,
val modifier: Double,
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/entities/GradeDescriptive.kt b/app/src/main/java/io/github/wulkanowy/data/db/entities/GradeDescriptive.kt
deleted file mode 100644
index 9aec9599..00000000
--- a/app/src/main/java/io/github/wulkanowy/data/db/entities/GradeDescriptive.kt
+++ /dev/null
@@ -1,27 +0,0 @@
-package io.github.wulkanowy.data.db.entities
-
-import androidx.room.ColumnInfo
-import androidx.room.Entity
-import androidx.room.PrimaryKey
-import java.io.Serializable
-
-@Entity(tableName = "GradesDescriptive")
-data class GradeDescriptive(
-
- @ColumnInfo(name = "semester_id")
- val semesterId: Int,
-
- @ColumnInfo(name = "student_id")
- val studentId: Int,
-
- val subject: String,
-
- val description: String,
-) : Serializable {
-
- @PrimaryKey(autoGenerate = true)
- var id: Long = 0
-
- @ColumnInfo(name = "is_notified")
- var isNotified: Boolean = true
-}
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/entities/GradePartialStatistics.kt b/app/src/main/java/io/github/wulkanowy/data/db/entities/GradePartialStatistics.kt
deleted file mode 100644
index db164afd..00000000
--- a/app/src/main/java/io/github/wulkanowy/data/db/entities/GradePartialStatistics.kt
+++ /dev/null
@@ -1,33 +0,0 @@
-package io.github.wulkanowy.data.db.entities
-
-import androidx.room.ColumnInfo
-import androidx.room.Entity
-import androidx.room.PrimaryKey
-
-@Entity(tableName = "GradePartialStatistics")
-data class GradePartialStatistics(
-
- @ColumnInfo(name = "student_id")
- val studentId: Int,
-
- @ColumnInfo(name = "semester_id")
- val semesterId: Int,
-
- val subject: String,
-
- @ColumnInfo(name = "class_average")
- val classAverage: String,
-
- @ColumnInfo(name = "student_average")
- val studentAverage: String,
-
- @ColumnInfo(name = "class_amounts")
- val classAmounts: List,
-
- @ColumnInfo(name = "student_amounts")
- val studentAmounts: List
-
-) {
- @PrimaryKey(autoGenerate = true)
- var id: Long = 0
-}
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/entities/GradeSemesterStatistics.kt b/app/src/main/java/io/github/wulkanowy/data/db/entities/GradeSemesterStatistics.kt
deleted file mode 100644
index 9e08b86b..00000000
--- a/app/src/main/java/io/github/wulkanowy/data/db/entities/GradeSemesterStatistics.kt
+++ /dev/null
@@ -1,31 +0,0 @@
-package io.github.wulkanowy.data.db.entities
-
-import androidx.room.ColumnInfo
-import androidx.room.Entity
-import androidx.room.PrimaryKey
-
-@Entity(tableName = "GradeSemesterStatistics")
-data class GradeSemesterStatistics(
-
- @ColumnInfo(name = "student_id")
- val studentId: Int,
-
- @ColumnInfo(name = "semester_id")
- val semesterId: Int,
-
- val subject: String,
-
- val amounts: List,
-
- @ColumnInfo(name = "student_grade")
- val studentGrade: Int
-) {
- @PrimaryKey(autoGenerate = true)
- var id: Long = 0
-
- @Transient
- var classAverage: String = ""
-
- @Transient
- var studentAverage: String = ""
-}
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/entities/GradePointsStatistics.kt b/app/src/main/java/io/github/wulkanowy/data/db/entities/GradeStatistics.kt
similarity index 67%
rename from app/src/main/java/io/github/wulkanowy/data/db/entities/GradePointsStatistics.kt
rename to app/src/main/java/io/github/wulkanowy/data/db/entities/GradeStatistics.kt
index 407f18bd..8ad8b8b8 100644
--- a/app/src/main/java/io/github/wulkanowy/data/db/entities/GradePointsStatistics.kt
+++ b/app/src/main/java/io/github/wulkanowy/data/db/entities/GradeStatistics.kt
@@ -4,8 +4,8 @@ import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.PrimaryKey
-@Entity(tableName = "GradesPointsStatistics")
-data class GradePointsStatistics(
+@Entity(tableName = "GradesStatistics")
+data class GradeStatistics(
@ColumnInfo(name = "student_id")
val studentId: Int,
@@ -15,9 +15,12 @@ data class GradePointsStatistics(
val subject: String,
- val others: Double,
+ val grade: Int,
- val student: Double
+ val amount: Int,
+
+ @ColumnInfo(name = "is_semester")
+ val semester: Boolean
) {
@PrimaryKey(autoGenerate = true)
var id: Long = 0
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/entities/GradeSummary.kt b/app/src/main/java/io/github/wulkanowy/data/db/entities/GradeSummary.kt
index f8a357a3..6e29112b 100644
--- a/app/src/main/java/io/github/wulkanowy/data/db/entities/GradeSummary.kt
+++ b/app/src/main/java/io/github/wulkanowy/data/db/entities/GradeSummary.kt
@@ -3,7 +3,6 @@ package io.github.wulkanowy.data.db.entities
import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.PrimaryKey
-import java.time.Instant
@Entity(tableName = "GradesSummary")
data class GradeSummary(
@@ -33,26 +32,8 @@ data class GradeSummary(
@ColumnInfo(name = "points_sum")
val pointsSum: String,
- @ColumnInfo(name = "points_sum_all_year")
- val pointsSumAllYear: String?,
-
- val average: Double,
-
- @ColumnInfo(name = "average_all_year")
- val averageAllYear: Double? = null,
+ val average: Double
) {
@PrimaryKey(autoGenerate = true)
var id: Long = 0
-
- @ColumnInfo(name = "is_predicted_grade_notified")
- var isPredictedGradeNotified: Boolean = true
-
- @ColumnInfo(name = "is_final_grade_notified")
- var isFinalGradeNotified: Boolean = true
-
- @ColumnInfo(name = "predicted_grade_last_change")
- var predictedGradeLastChange: Instant = Instant.now()
-
- @ColumnInfo(name = "final_grade_last_change")
- var finalGradeLastChange: Instant = Instant.now()
}
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/entities/Homework.kt b/app/src/main/java/io/github/wulkanowy/data/db/entities/Homework.kt
index 4538cf31..a22df096 100644
--- a/app/src/main/java/io/github/wulkanowy/data/db/entities/Homework.kt
+++ b/app/src/main/java/io/github/wulkanowy/data/db/entities/Homework.kt
@@ -3,8 +3,8 @@ package io.github.wulkanowy.data.db.entities
import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.PrimaryKey
+import org.threeten.bp.LocalDate
import java.io.Serializable
-import java.time.LocalDate
@Entity(tableName = "Homework")
data class Homework(
@@ -27,20 +27,10 @@ data class Homework(
val teacher: String,
@ColumnInfo(name = "teacher_symbol")
- val teacherSymbol: String,
+ val teacherSymbol: String
- val attachments: List>
) : Serializable {
@PrimaryKey(autoGenerate = true)
var id: Long = 0
-
- @ColumnInfo(name = "is_done")
- var isDone: Boolean = false
-
- @ColumnInfo(name = "is_notified")
- var isNotified: Boolean = true
-
- @ColumnInfo(name = "is_added_by_user")
- var isAddedByUser: Boolean = false
}
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/entities/LuckyNumber.kt b/app/src/main/java/io/github/wulkanowy/data/db/entities/LuckyNumber.kt
index 7c24c8f5..5b9130f5 100644
--- a/app/src/main/java/io/github/wulkanowy/data/db/entities/LuckyNumber.kt
+++ b/app/src/main/java/io/github/wulkanowy/data/db/entities/LuckyNumber.kt
@@ -3,8 +3,8 @@ package io.github.wulkanowy.data.db.entities
import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.PrimaryKey
+import org.threeten.bp.LocalDate
import java.io.Serializable
-import java.time.LocalDate
@Entity(tableName = "LuckyNumbers")
data class LuckyNumber (
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/entities/Mailbox.kt b/app/src/main/java/io/github/wulkanowy/data/db/entities/Mailbox.kt
deleted file mode 100644
index e65e213d..00000000
--- a/app/src/main/java/io/github/wulkanowy/data/db/entities/Mailbox.kt
+++ /dev/null
@@ -1,32 +0,0 @@
-package io.github.wulkanowy.data.db.entities
-
-import android.os.Parcelable
-import androidx.room.Entity
-import androidx.room.PrimaryKey
-import kotlinx.parcelize.Parcelize
-
-@Parcelize
-@Entity(tableName = "Mailboxes")
-data class Mailbox(
-
- @PrimaryKey
- val globalKey: String,
-
- val email: String,
- val symbol: String,
- val schoolId: String,
-
- val fullName: String,
- val userName: String,
- val studentName: String,
- val schoolNameShort: String,
- val type: MailboxType,
-) : java.io.Serializable, Parcelable
-
-enum class MailboxType {
- STUDENT,
- PARENT,
- GUARDIAN,
- EMPLOYEE,
- UNKNOWN,
-}
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/entities/Message.kt b/app/src/main/java/io/github/wulkanowy/data/db/entities/Message.kt
index d1356b33..48b4fd02 100644
--- a/app/src/main/java/io/github/wulkanowy/data/db/entities/Message.kt
+++ b/app/src/main/java/io/github/wulkanowy/data/db/entities/Message.kt
@@ -3,43 +3,46 @@ package io.github.wulkanowy.data.db.entities
import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.PrimaryKey
+import org.threeten.bp.LocalDateTime
import java.io.Serializable
-import java.time.Instant
@Entity(tableName = "Messages")
data class Message(
- @ColumnInfo(name = "email")
- val email: String,
+ @ColumnInfo(name = "student_id")
+ val studentId: Int,
- @ColumnInfo(name = "message_global_key")
- val messageGlobalKey: String,
-
- @ColumnInfo(name = "mailbox_key")
- val mailboxKey: String,
+ @ColumnInfo(name = "real_id")
+ val realId: Int,
@ColumnInfo(name = "message_id")
val messageId: Int,
- val correspondents: String,
+ @ColumnInfo(name = "sender_name")
+ val sender: String,
+
+ @ColumnInfo(name = "sender_id")
+ val senderId: Int,
+
+ @ColumnInfo(name = "recipient_name")
+ val recipient: String,
val subject: String,
- val date: Instant,
+ val date: LocalDateTime,
@ColumnInfo(name = "folder_id")
val folderId: Int,
var unread: Boolean,
- @ColumnInfo(name = "read_by")
- val readBy: Int?,
-
@ColumnInfo(name = "unread_by")
- val unreadBy: Int?,
+ val unreadBy: Int,
- @ColumnInfo(name = "has_attachments")
- val hasAttachments: Boolean
+ @ColumnInfo(name = "read_by")
+ val readBy: Int,
+
+ val removed: Boolean
) : Serializable {
@PrimaryKey(autoGenerate = true)
@@ -48,7 +51,5 @@ data class Message(
@ColumnInfo(name = "is_notified")
var isNotified: Boolean = true
- var content: String = ""
- var sender: String? = null
- var recipients: String? = null
+ var content: String? = null
}
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/entities/MessageAttachment.kt b/app/src/main/java/io/github/wulkanowy/data/db/entities/MessageAttachment.kt
deleted file mode 100644
index 6f0c84ad..00000000
--- a/app/src/main/java/io/github/wulkanowy/data/db/entities/MessageAttachment.kt
+++ /dev/null
@@ -1,21 +0,0 @@
-package io.github.wulkanowy.data.db.entities
-
-import androidx.room.ColumnInfo
-import androidx.room.Entity
-import java.io.Serializable
-
-@Entity(
- tableName = "MessageAttachments",
- primaryKeys = ["message_global_key", "url", "filename"],
-)
-data class MessageAttachment(
-
- @ColumnInfo(name = "message_global_key")
- val messageGlobalKey: String,
-
- @ColumnInfo(name = "url")
- val url: String,
-
- @ColumnInfo(name = "filename")
- val filename: String
-) : Serializable
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/entities/MessageWithAttachment.kt b/app/src/main/java/io/github/wulkanowy/data/db/entities/MessageWithAttachment.kt
deleted file mode 100644
index fc890e76..00000000
--- a/app/src/main/java/io/github/wulkanowy/data/db/entities/MessageWithAttachment.kt
+++ /dev/null
@@ -1,16 +0,0 @@
-package io.github.wulkanowy.data.db.entities
-
-import androidx.room.Embedded
-import androidx.room.Relation
-import java.io.Serializable
-
-data class MessageWithAttachment(
- @Embedded
- val message: Message,
-
- @Relation(parentColumn = "message_global_key", entityColumn = "message_global_key")
- val attachments: List,
-
- @Relation(parentColumn = "correspondents", entityColumn = "author")
- val mutedMessageSender: MutedMessageSender?,
-) : Serializable
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/entities/MessageWithMutedAuthor.kt b/app/src/main/java/io/github/wulkanowy/data/db/entities/MessageWithMutedAuthor.kt
deleted file mode 100644
index e3cd1ca7..00000000
--- a/app/src/main/java/io/github/wulkanowy/data/db/entities/MessageWithMutedAuthor.kt
+++ /dev/null
@@ -1,12 +0,0 @@
-package io.github.wulkanowy.data.db.entities
-
-import androidx.room.Embedded
-import androidx.room.Relation
-
-data class MessageWithMutedAuthor(
- @Embedded
- val message: Message,
-
- @Relation(parentColumn = "correspondents", entityColumn = "author")
- val mutedMessageSender: MutedMessageSender?,
-)
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/entities/MobileDevice.kt b/app/src/main/java/io/github/wulkanowy/data/db/entities/MobileDevice.kt
index 44e90064..f67ed599 100644
--- a/app/src/main/java/io/github/wulkanowy/data/db/entities/MobileDevice.kt
+++ b/app/src/main/java/io/github/wulkanowy/data/db/entities/MobileDevice.kt
@@ -3,13 +3,13 @@ package io.github.wulkanowy.data.db.entities
import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.PrimaryKey
+import org.threeten.bp.LocalDateTime
import java.io.Serializable
-import java.time.Instant
@Entity(tableName = "MobileDevices")
data class MobileDevice(
- @ColumnInfo(name = "user_login_id") // todo: change column name
+ @ColumnInfo(name = "student_id")
val studentId: Int,
@ColumnInfo(name = "device_id")
@@ -17,7 +17,7 @@ data class MobileDevice(
val name: String,
- val date: Instant,
+ val date: LocalDateTime
) : Serializable {
@PrimaryKey(autoGenerate = true)
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/entities/MutedMessageSender.kt b/app/src/main/java/io/github/wulkanowy/data/db/entities/MutedMessageSender.kt
deleted file mode 100644
index f1770e64..00000000
--- a/app/src/main/java/io/github/wulkanowy/data/db/entities/MutedMessageSender.kt
+++ /dev/null
@@ -1,15 +0,0 @@
-package io.github.wulkanowy.data.db.entities
-
-import androidx.room.ColumnInfo
-import androidx.room.Entity
-import androidx.room.PrimaryKey
-import java.io.Serializable
-
-@Entity(tableName = "MutedMessageSenders")
-data class MutedMessageSender(
- @ColumnInfo(name = "author")
- val author: String,
-) : Serializable {
- @PrimaryKey(autoGenerate = true)
- var id: Long = 0
-}
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/entities/Note.kt b/app/src/main/java/io/github/wulkanowy/data/db/entities/Note.kt
index cfd54962..5f3a92ab 100644
--- a/app/src/main/java/io/github/wulkanowy/data/db/entities/Note.kt
+++ b/app/src/main/java/io/github/wulkanowy/data/db/entities/Note.kt
@@ -3,8 +3,8 @@ package io.github.wulkanowy.data.db.entities
import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.PrimaryKey
+import org.threeten.bp.LocalDate
import java.io.Serializable
-import java.time.LocalDate
@Entity(tableName = "Notes")
data class Note(
@@ -16,19 +16,8 @@ data class Note(
val teacher: String,
- @ColumnInfo(name = "teacher_symbol")
- val teacherSymbol: String,
-
val category: String,
- @ColumnInfo(name = "category_type")
- val categoryType: Int,
-
- @ColumnInfo(name = "is_points_show")
- val isPointsShow: Boolean,
-
- val points: Int,
-
val content: String
) : Serializable {
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/entities/Notification.kt b/app/src/main/java/io/github/wulkanowy/data/db/entities/Notification.kt
deleted file mode 100644
index c3267f24..00000000
--- a/app/src/main/java/io/github/wulkanowy/data/db/entities/Notification.kt
+++ /dev/null
@@ -1,31 +0,0 @@
-package io.github.wulkanowy.data.db.entities
-
-import androidx.room.ColumnInfo
-import androidx.room.Entity
-import androidx.room.PrimaryKey
-import io.github.wulkanowy.services.sync.notifications.NotificationType
-import io.github.wulkanowy.ui.modules.Destination
-import java.time.Instant
-
-@Entity(tableName = "Notifications")
-data class Notification(
-
- @ColumnInfo(name = "student_id")
- val studentId: Long,
-
- val title: String,
-
- val content: String,
-
- val type: NotificationType,
-
- @ColumnInfo(defaultValue = "{\"type\":\"io.github.wulkanowy.ui.modules.Destination.Dashboard\"}")
- val destination: Destination,
-
- val date: Instant,
-
- val data: String? = null
-) {
- @PrimaryKey(autoGenerate = true)
- var id: Long = 0
-}
\ No newline at end of file
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/entities/Recipient.kt b/app/src/main/java/io/github/wulkanowy/data/db/entities/Recipient.kt
index d09742cd..3021da72 100644
--- a/app/src/main/java/io/github/wulkanowy/data/db/entities/Recipient.kt
+++ b/app/src/main/java/io/github/wulkanowy/data/db/entities/Recipient.kt
@@ -1,22 +1,38 @@
package io.github.wulkanowy.data.db.entities
+import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.PrimaryKey
import java.io.Serializable
-@kotlinx.serialization.Serializable
@Entity(tableName = "Recipients")
data class Recipient(
- val mailboxGlobalKey: String,
- val studentMailboxGlobalKey: String,
- val fullName: String,
- val userName: String,
- val schoolShortName: String,
- val type: MailboxType,
+
+ @ColumnInfo(name = "student_id")
+ val studentId: Int,
+
+ @ColumnInfo(name = "real_id")
+ val realId: String,
+
+ val name: String,
+
+ @ColumnInfo(name = "real_name")
+ val realName: String,
+
+ @ColumnInfo(name = "login_id")
+ val loginId: Int,
+
+ @ColumnInfo(name = "unit_id")
+ val unitId: Int,
+
+ val role: Int,
+
+ val hash: String
+
) : Serializable {
@PrimaryKey(autoGenerate = true)
var id: Long = 0
- override fun toString() = userName
+ override fun toString() = name
}
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/entities/ReportingUnit.kt b/app/src/main/java/io/github/wulkanowy/data/db/entities/ReportingUnit.kt
new file mode 100644
index 00000000..601d8aac
--- /dev/null
+++ b/app/src/main/java/io/github/wulkanowy/data/db/entities/ReportingUnit.kt
@@ -0,0 +1,32 @@
+package io.github.wulkanowy.data.db.entities
+
+import androidx.room.ColumnInfo
+import androidx.room.Entity
+import androidx.room.PrimaryKey
+import java.io.Serializable
+
+@Entity(tableName = "ReportingUnits")
+data class ReportingUnit(
+
+ @ColumnInfo(name = "student_id")
+ val studentId: Int,
+
+ @ColumnInfo(name = "real_id")
+ val realId: Int,
+
+ @ColumnInfo(name = "short")
+ val shortName: String,
+
+ @ColumnInfo(name = "sender_id")
+ val senderId: Int,
+
+ @ColumnInfo(name = "sender_name")
+ val senderName: String,
+
+ val roles: List
+
+) : Serializable {
+
+ @PrimaryKey(autoGenerate = true)
+ var id: Long = 0
+}
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/entities/School.kt b/app/src/main/java/io/github/wulkanowy/data/db/entities/School.kt
deleted file mode 100644
index 20fae450..00000000
--- a/app/src/main/java/io/github/wulkanowy/data/db/entities/School.kt
+++ /dev/null
@@ -1,30 +0,0 @@
-package io.github.wulkanowy.data.db.entities
-
-import androidx.room.ColumnInfo
-import androidx.room.Entity
-import androidx.room.PrimaryKey
-import java.io.Serializable
-
-@Entity(tableName = "School")
-data class School(
-
- @ColumnInfo(name = "student_id")
- val studentId: Int,
-
- @ColumnInfo(name = "class_id")
- val classId: Int,
-
- val name: String,
-
- val address: String,
-
- val contact: String,
-
- val headmaster: String,
-
- val pedagogue: String
-) : Serializable {
-
- @PrimaryKey(autoGenerate = true)
- var id: Long = 0
-}
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/entities/SchoolAnnouncement.kt b/app/src/main/java/io/github/wulkanowy/data/db/entities/SchoolAnnouncement.kt
deleted file mode 100644
index 814a3c8d..00000000
--- a/app/src/main/java/io/github/wulkanowy/data/db/entities/SchoolAnnouncement.kt
+++ /dev/null
@@ -1,29 +0,0 @@
-package io.github.wulkanowy.data.db.entities
-
-import androidx.room.ColumnInfo
-import androidx.room.Entity
-import androidx.room.PrimaryKey
-import java.io.Serializable
-import java.time.LocalDate
-
-@Entity(tableName = "SchoolAnnouncements")
-data class SchoolAnnouncement(
-
- @ColumnInfo(name = "user_login_id") // todo: change column name
- val studentId: Int,
-
- val date: LocalDate,
-
- val subject: String,
-
- val content: String,
-
- val author: String? = null,
-) : Serializable {
-
- @PrimaryKey(autoGenerate = true)
- var id: Long = 0
-
- @ColumnInfo(name = "is_notified")
- var isNotified: Boolean = true
-}
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/entities/Semester.kt b/app/src/main/java/io/github/wulkanowy/data/db/entities/Semester.kt
index 187890c9..6c06be11 100644
--- a/app/src/main/java/io/github/wulkanowy/data/db/entities/Semester.kt
+++ b/app/src/main/java/io/github/wulkanowy/data/db/entities/Semester.kt
@@ -4,15 +4,9 @@ import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.Index
import androidx.room.PrimaryKey
-import java.io.Serializable
-import java.time.LocalDate
+import org.threeten.bp.LocalDate
-@Entity(
- tableName = "Semesters", indices = [Index(
- value = ["student_id", "diary_id", "kindergarten_diary_id", "semester_id"],
- unique = true
- )]
-)
+@Entity(tableName = "Semesters", indices = [Index(value = ["student_id", "diary_id", "semester_id"], unique = true)])
data class Semester(
@ColumnInfo(name = "student_id")
@@ -21,9 +15,6 @@ data class Semester(
@ColumnInfo(name = "diary_id")
val diaryId: Int,
- @ColumnInfo(name = "kindergarten_diary_id", defaultValue = "0")
- val kindergartenDiaryId: Int,
-
@ColumnInfo(name = "diary_name")
val diaryName: String,
@@ -36,6 +27,9 @@ data class Semester(
@ColumnInfo(name = "semester_name")
val semesterName: Int,
+ @ColumnInfo(name = "is_current")
+ val isCurrent: Boolean,
+
val start: LocalDate,
val end: LocalDate,
@@ -45,11 +39,8 @@ data class Semester(
@ColumnInfo(name = "unit_id")
val unitId: Int
-) : Serializable {
+) {
@PrimaryKey(autoGenerate = true)
var id: Long = 0
-
- @ColumnInfo(name = "is_current")
- var current: Boolean = false
}
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/entities/Student.kt b/app/src/main/java/io/github/wulkanowy/data/db/entities/Student.kt
index 0300506a..13c5ee08 100644
--- a/app/src/main/java/io/github/wulkanowy/data/db/entities/Student.kt
+++ b/app/src/main/java/io/github/wulkanowy/data/db/entities/Student.kt
@@ -4,42 +4,16 @@ import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.Index
import androidx.room.PrimaryKey
+import org.threeten.bp.LocalDateTime
import java.io.Serializable
-import java.time.Instant
-@Entity(
- tableName = "Students",
- indices = [Index(
- value = ["email", "symbol", "student_id", "school_id", "class_id"],
- unique = true
- )]
-)
+@Entity(tableName = "Students", indices = [Index(value = ["email", "symbol", "student_id", "school_id", "class_id"], unique = true)])
data class Student(
- @ColumnInfo(name = "scrapper_base_url")
- val scrapperBaseUrl: String,
+ val endpoint: String,
- @ColumnInfo(name = "scrapper_domain_suffix", defaultValue = "")
- val scrapperDomainSuffix: String,
-
- @ColumnInfo(name = "mobile_base_url")
- val mobileBaseUrl: String,
-
- @ColumnInfo(name = "login_type")
val loginType: String,
- @ColumnInfo(name = "login_mode")
- val loginMode: String,
-
- @ColumnInfo(name = "certificate_key")
- val certificateKey: String,
-
- @ColumnInfo(name = "private_key")
- val privateKey: String,
-
- @ColumnInfo(name = "is_parent")
- val isParent: Boolean,
-
val email: String,
var password: String,
@@ -49,22 +23,12 @@ data class Student(
@ColumnInfo(name = "student_id")
val studentId: Int,
- @Deprecated("not available in VULCAN anymore")
- @ColumnInfo(name = "user_login_id")
- val userLoginId: Int,
-
- @ColumnInfo(name = "user_name")
- val userName: String,
-
@ColumnInfo(name = "student_name")
val studentName: String,
@ColumnInfo(name = "school_id")
val schoolSymbol: String,
- @ColumnInfo(name = "school_short")
- val schoolShortName: String,
-
@ColumnInfo(name = "school_name")
val schoolName: String,
@@ -78,40 +42,9 @@ data class Student(
val isCurrent: Boolean,
@ColumnInfo(name = "registration_date")
- val registrationDate: Instant,
-
- @ColumnInfo(name = "is_authorized", defaultValue = "0")
- val isAuthorized: Boolean,
-
- @ColumnInfo(name = "is_edu_one", defaultValue = "NULL")
- val isEduOne: Boolean?,
-
+ val registrationDate: LocalDateTime
) : Serializable {
@PrimaryKey(autoGenerate = true)
var id: Long = 0
-
- var nick = ""
-
- @ColumnInfo(name = "avatar_color")
- var avatarColor = 0L
}
-
-@Entity
-data class StudentIsAuthorized(
-
- @PrimaryKey
- var id: Long,
-
- @ColumnInfo(name = "is_authorized", defaultValue = "NULL")
- val isAuthorized: Boolean?,
-) : Serializable
-
-@Entity
-data class StudentIsEduOne(
- @PrimaryKey
- var id: Long,
-
- @ColumnInfo(name = "is_edu_one", defaultValue = "NULL")
- val isEduOne: Boolean?,
-) : Serializable
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/entities/StudentInfo.kt b/app/src/main/java/io/github/wulkanowy/data/db/entities/StudentInfo.kt
deleted file mode 100644
index 7366e547..00000000
--- a/app/src/main/java/io/github/wulkanowy/data/db/entities/StudentInfo.kt
+++ /dev/null
@@ -1,85 +0,0 @@
-package io.github.wulkanowy.data.db.entities
-
-import androidx.room.ColumnInfo
-import androidx.room.Embedded
-import androidx.room.Entity
-import androidx.room.PrimaryKey
-import io.github.wulkanowy.data.enums.Gender
-import java.io.Serializable
-import java.time.LocalDate
-
-@Entity(tableName = "StudentInfo")
-data class StudentInfo(
-
- @ColumnInfo(name = "student_id")
- val studentId: Int,
-
- @ColumnInfo(name = "full_name")
- val fullName: String,
-
- @ColumnInfo(name = "first_name")
- val firstName: String,
-
- @ColumnInfo(name = "second_name")
- val secondName: String,
-
- val surname: String,
-
- @ColumnInfo(name = "birth_date")
- val birthDate: LocalDate,
-
- @ColumnInfo(name = "birth_place")
- val birthPlace: String,
-
- val gender: Gender,
-
- @ColumnInfo(name = "has_polish_citizenship")
- val hasPolishCitizenship: Boolean,
-
- @ColumnInfo(name = "family_name")
- val familyName: String,
-
- @ColumnInfo(name = "parents_names")
- val parentsNames: String,
-
- val address: String,
-
- @ColumnInfo(name = "registered_address")
- val registeredAddress: String,
-
- @ColumnInfo(name = "correspondence_address")
- val correspondenceAddress: String,
-
- @ColumnInfo(name = "phone_number")
- val phoneNumber: String,
-
- @ColumnInfo(name = "cell_phone_number")
- val cellPhoneNumber: String,
-
- val email: String,
-
- @Embedded(prefix = "first_guardian_")
- val firstGuardian: StudentGuardian?,
-
- @Embedded(prefix = "second_guardian_")
- val secondGuardian: StudentGuardian?
-
-) : Serializable {
-
- @PrimaryKey(autoGenerate = true)
- var id: Long = 0
-}
-
-data class StudentGuardian(
-
- @ColumnInfo(name = "full_name")
- val fullName: String,
-
- val kinship: String,
-
- val address: String,
-
- val phones: String,
-
- val email: String
-) : Serializable
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/entities/StudentName.kt b/app/src/main/java/io/github/wulkanowy/data/db/entities/StudentName.kt
deleted file mode 100644
index 46f754b5..00000000
--- a/app/src/main/java/io/github/wulkanowy/data/db/entities/StudentName.kt
+++ /dev/null
@@ -1,18 +0,0 @@
-package io.github.wulkanowy.data.db.entities
-
-import androidx.room.ColumnInfo
-import androidx.room.Entity
-import androidx.room.PrimaryKey
-import java.io.Serializable
-
-@Entity
-data class StudentName(
-
- @ColumnInfo(name = "student_name")
- val studentName: String
-
-) : Serializable {
-
- @PrimaryKey
- var id: Long = 0
-}
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/entities/StudentNickAndAvatar.kt b/app/src/main/java/io/github/wulkanowy/data/db/entities/StudentNickAndAvatar.kt
deleted file mode 100644
index 546059ee..00000000
--- a/app/src/main/java/io/github/wulkanowy/data/db/entities/StudentNickAndAvatar.kt
+++ /dev/null
@@ -1,20 +0,0 @@
-package io.github.wulkanowy.data.db.entities
-
-import androidx.room.ColumnInfo
-import androidx.room.Entity
-import androidx.room.PrimaryKey
-import java.io.Serializable
-
-@Entity
-data class StudentNickAndAvatar(
-
- val nick: String,
-
- @ColumnInfo(name = "avatar_color")
- var avatarColor: Long
-
-) : Serializable {
-
- @PrimaryKey
- var id: Long = 0
-}
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/entities/StudentWithSemesters.kt b/app/src/main/java/io/github/wulkanowy/data/db/entities/StudentWithSemesters.kt
deleted file mode 100644
index f9869d4e..00000000
--- a/app/src/main/java/io/github/wulkanowy/data/db/entities/StudentWithSemesters.kt
+++ /dev/null
@@ -1,8 +0,0 @@
-package io.github.wulkanowy.data.db.entities
-
-import java.io.Serializable
-
-data class StudentWithSemesters(
- val student: Student,
- val semesters: List
-) : Serializable
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/entities/Teacher.kt b/app/src/main/java/io/github/wulkanowy/data/db/entities/Teacher.kt
deleted file mode 100644
index 52c96f8a..00000000
--- a/app/src/main/java/io/github/wulkanowy/data/db/entities/Teacher.kt
+++ /dev/null
@@ -1,27 +0,0 @@
-package io.github.wulkanowy.data.db.entities
-
-import androidx.room.ColumnInfo
-import androidx.room.Entity
-import androidx.room.PrimaryKey
-import java.io.Serializable
-
-@Entity(tableName = "Teachers")
-data class Teacher(
-
- @ColumnInfo(name = "student_id")
- val studentId: Int,
-
- @ColumnInfo(name = "class_id")
- val classId: Int,
-
- val subject: String,
-
- val name: String,
-
- @ColumnInfo(name = "short_name")
- val shortName: String
-) : Serializable {
-
- @PrimaryKey(autoGenerate = true)
- var id: Long = 0
-}
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/entities/Timetable.kt b/app/src/main/java/io/github/wulkanowy/data/db/entities/Timetable.kt
index d23d388f..9bc3d214 100644
--- a/app/src/main/java/io/github/wulkanowy/data/db/entities/Timetable.kt
+++ b/app/src/main/java/io/github/wulkanowy/data/db/entities/Timetable.kt
@@ -3,9 +3,9 @@ package io.github.wulkanowy.data.db.entities
import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.PrimaryKey
+import org.threeten.bp.LocalDate
+import org.threeten.bp.LocalDateTime
import java.io.Serializable
-import java.time.Instant
-import java.time.LocalDate
@Entity(tableName = "Timetable")
data class Timetable(
@@ -18,9 +18,9 @@ data class Timetable(
val number: Int,
- val start: Instant,
+ val start: LocalDateTime,
- val end: Instant,
+ val end: LocalDateTime,
val date: LocalDate,
@@ -40,9 +40,6 @@ data class Timetable(
val info: String,
- @ColumnInfo(name = "student_plan")
- val isStudentPlan: Boolean,
-
val changes: Boolean,
val canceled: Boolean
@@ -50,7 +47,4 @@ data class Timetable(
@PrimaryKey(autoGenerate = true)
var id: Long = 0
-
- @ColumnInfo(name = "is_notified")
- var isNotified: Boolean = true
}
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/entities/TimetableAdditional.kt b/app/src/main/java/io/github/wulkanowy/data/db/entities/TimetableAdditional.kt
deleted file mode 100644
index 47802610..00000000
--- a/app/src/main/java/io/github/wulkanowy/data/db/entities/TimetableAdditional.kt
+++ /dev/null
@@ -1,37 +0,0 @@
-package io.github.wulkanowy.data.db.entities
-
-import androidx.room.ColumnInfo
-import androidx.room.Entity
-import androidx.room.PrimaryKey
-import java.io.Serializable
-import java.time.Instant
-import java.time.LocalDate
-import java.util.*
-
-@Entity(tableName = "TimetableAdditional")
-data class TimetableAdditional(
-
- @ColumnInfo(name = "student_id")
- val studentId: Int,
-
- @ColumnInfo(name = "diary_id")
- val diaryId: Int,
-
- val start: Instant,
-
- val end: Instant,
-
- val date: LocalDate,
-
- val subject: String,
-) : Serializable {
-
- @PrimaryKey(autoGenerate = true)
- var id: Long = 0
-
- @ColumnInfo(name = "repeat_id", defaultValue = "NULL")
- var repeatId: UUID? = null
-
- @ColumnInfo(name = "is_added_by_user", defaultValue = "0")
- var isAddedByUser: Boolean = false
-}
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/entities/TimetableHeader.kt b/app/src/main/java/io/github/wulkanowy/data/db/entities/TimetableHeader.kt
deleted file mode 100644
index 7f21bf54..00000000
--- a/app/src/main/java/io/github/wulkanowy/data/db/entities/TimetableHeader.kt
+++ /dev/null
@@ -1,25 +0,0 @@
-package io.github.wulkanowy.data.db.entities
-
-import androidx.room.ColumnInfo
-import androidx.room.Entity
-import androidx.room.PrimaryKey
-import java.io.Serializable
-import java.time.LocalDate
-
-@Entity(tableName = "TimetableHeaders")
-data class TimetableHeader(
-
- @ColumnInfo(name = "student_id")
- val studentId: Int,
-
- @ColumnInfo(name = "diary_id")
- val diaryId: Int,
-
- val date: LocalDate,
-
- val content: String,
-) : Serializable {
-
- @PrimaryKey(autoGenerate = true)
- var id: Long = 0
-}
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/migrations/Migration10.kt b/app/src/main/java/io/github/wulkanowy/data/db/migrations/Migration10.kt
index 0e7e1409..c26a02d1 100644
--- a/app/src/main/java/io/github/wulkanowy/data/db/migrations/Migration10.kt
+++ b/app/src/main/java/io/github/wulkanowy/data/db/migrations/Migration10.kt
@@ -5,7 +5,7 @@ import androidx.sqlite.db.SupportSQLiteDatabase
class Migration10 : Migration(9, 10) {
- override fun migrate(db: SupportSQLiteDatabase) {
- db.execSQL("ALTER TABLE Grades_Summary RENAME TO GradesSummary")
+ override fun migrate(database: SupportSQLiteDatabase) {
+ database.execSQL("ALTER TABLE Grades_Summary RENAME TO GradesSummary")
}
}
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/migrations/Migration11.kt b/app/src/main/java/io/github/wulkanowy/data/db/migrations/Migration11.kt
index 342e2e2e..6d129bca 100644
--- a/app/src/main/java/io/github/wulkanowy/data/db/migrations/Migration11.kt
+++ b/app/src/main/java/io/github/wulkanowy/data/db/migrations/Migration11.kt
@@ -5,9 +5,8 @@ import androidx.sqlite.db.SupportSQLiteDatabase
class Migration11 : Migration(10, 11) {
- override fun migrate(db: SupportSQLiteDatabase) {
- db.execSQL(
- """
+ override fun migrate(database: SupportSQLiteDatabase) {
+ database.execSQL("""
CREATE TABLE IF NOT EXISTS Grades_temp (
id INTEGER PRIMARY KEY NOT NULL,
is_read INTEGER NOT NULL,
@@ -27,10 +26,9 @@ class Migration11 : Migration(10, 11) {
date INTEGER NOT NULL,
teacher TEXT NOT NULL
)
- """
- )
- db.execSQL("INSERT INTO Grades_temp SELECT * FROM Grades")
- db.execSQL("DROP TABLE Grades")
- db.execSQL("ALTER TABLE Grades_temp RENAME TO Grades")
+ """)
+ database.execSQL("INSERT INTO Grades_temp SELECT * FROM Grades")
+ database.execSQL("DROP TABLE Grades")
+ database.execSQL("ALTER TABLE Grades_temp RENAME TO Grades")
}
}
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/migrations/Migration12.kt b/app/src/main/java/io/github/wulkanowy/data/db/migrations/Migration12.kt
index 6cc72695..1dc38e14 100644
--- a/app/src/main/java/io/github/wulkanowy/data/db/migrations/Migration12.kt
+++ b/app/src/main/java/io/github/wulkanowy/data/db/migrations/Migration12.kt
@@ -5,17 +5,16 @@ import androidx.sqlite.db.SupportSQLiteDatabase
class Migration12 : Migration(11, 12) {
- override fun migrate(db: SupportSQLiteDatabase) {
- createTempStudentsTable(db)
- replaceStudentTable(db)
- updateStudentsWithClassId(db, getStudentsIds(db))
- removeStudentsWithNoClassId(db)
- ensureThereIsOnlyOneCurrentStudent(db)
+ override fun migrate(database: SupportSQLiteDatabase) {
+ createTempStudentsTable(database)
+ replaceStudentTable(database)
+ updateStudentsWithClassId(database, getStudentsIds(database))
+ removeStudentsWithNoClassId(database)
+ ensureThereIsOnlyOneCurrentStudent(database)
}
- private fun createTempStudentsTable(db: SupportSQLiteDatabase) {
- db.execSQL(
- """
+ private fun createTempStudentsTable(database: SupportSQLiteDatabase) {
+ database.execSQL("""
CREATE TABLE IF NOT EXISTS Students_tmp (
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
endpoint TEXT NOT NULL,
@@ -31,43 +30,40 @@ class Migration12 : Migration(11, 12) {
registration_date INTEGER NOT NULL,
class_id INTEGER NOT NULL
)
- """
- )
- db.execSQL("CREATE UNIQUE INDEX index_Students_email_symbol_student_id_school_id_class_id ON Students_tmp (email, symbol, student_id, school_id, class_id)")
+ """)
+ database.execSQL("CREATE UNIQUE INDEX index_Students_email_symbol_student_id_school_id_class_id ON Students_tmp (email, symbol, student_id, school_id, class_id)")
}
- private fun replaceStudentTable(db: SupportSQLiteDatabase) {
- db.execSQL("ALTER TABLE Students ADD COLUMN class_id INTEGER DEFAULT 0 NOT NULL")
- db.execSQL("INSERT INTO Students_tmp SELECT * FROM Students")
- db.execSQL("DROP TABLE Students")
- db.execSQL("ALTER TABLE Students_tmp RENAME TO Students")
+ private fun replaceStudentTable(database: SupportSQLiteDatabase) {
+ database.execSQL("ALTER TABLE Students ADD COLUMN class_id INTEGER DEFAULT 0 NOT NULL")
+ database.execSQL("INSERT INTO Students_tmp SELECT * FROM Students")
+ database.execSQL("DROP TABLE Students")
+ database.execSQL("ALTER TABLE Students_tmp RENAME TO Students")
}
private fun getStudentsIds(database: SupportSQLiteDatabase): List {
val students = mutableListOf()
- database.query("SELECT student_id FROM Students").use {
- if (it.moveToFirst()) {
- do {
- students.add(it.getInt(0))
- } while (it.moveToNext())
- }
+ val studentsCursor = database.query("SELECT student_id FROM Students")
+ if (studentsCursor.moveToFirst()) {
+ do {
+ students.add(studentsCursor.getInt(0))
+ } while (studentsCursor.moveToNext())
}
-
return students
}
- private fun updateStudentsWithClassId(db: SupportSQLiteDatabase, students: List) {
+ private fun updateStudentsWithClassId(database: SupportSQLiteDatabase, students: List) {
students.forEach {
- db.execSQL("UPDATE Students SET class_id = IFNULL((SELECT class_id FROM Semesters WHERE student_id = $it), 0) WHERE student_id = $it")
+ database.execSQL("UPDATE Students SET class_id = IFNULL((SELECT class_id FROM Semesters WHERE student_id = $it), 0) WHERE student_id = $it")
}
}
- private fun removeStudentsWithNoClassId(db: SupportSQLiteDatabase) {
- db.execSQL("DELETE FROM Students WHERE class_id = 0")
+ private fun removeStudentsWithNoClassId(database: SupportSQLiteDatabase) {
+ database.execSQL("DELETE FROM Students WHERE class_id = 0")
}
- private fun ensureThereIsOnlyOneCurrentStudent(db: SupportSQLiteDatabase) {
- db.execSQL("UPDATE Students SET is_current = 0")
- db.execSQL("UPDATE Students SET is_current = 1 WHERE id = (SELECT MAX(id) FROM Students)")
+ private fun ensureThereIsOnlyOneCurrentStudent(database: SupportSQLiteDatabase) {
+ database.execSQL("UPDATE Students SET is_current = 0")
+ database.execSQL("UPDATE Students SET is_current = 1 WHERE id = (SELECT MAX(id) FROM Students)")
}
}
diff --git a/app/src/main/java/io/github/wulkanowy/data/db/migrations/Migration13.kt b/app/src/main/java/io/github/wulkanowy/data/db/migrations/Migration13.kt
index c5030232..0cf8cd9b 100644
--- a/app/src/main/java/io/github/wulkanowy/data/db/migrations/Migration13.kt
+++ b/app/src/main/java/io/github/wulkanowy/data/db/migrations/Migration13.kt
@@ -5,70 +5,60 @@ import androidx.sqlite.db.SupportSQLiteDatabase
class Migration13 : Migration(12, 13) {
- override fun migrate(db: SupportSQLiteDatabase) {
- addClassNameToStudents(db, getStudentsIds(db))
- updateSemestersTable(db)
- markAtLeastAndOnlyOneSemesterAtCurrent(db, getStudentsAndClassIds(db))
- clearMessagesTable(db)
+ override fun migrate(database: SupportSQLiteDatabase) {
+ addClassNameToStudents(database, getStudentsIds(database))
+ updateSemestersTable(database)
+ markAtLeastAndOnlyOneSemesterAtCurrent(database, getStudentsAndClassIds(database))
+ clearMessagesTable(database)
}
- private fun addClassNameToStudents(
- db: SupportSQLiteDatabase,
- students: List>
- ) {
- db.execSQL("ALTER TABLE Students ADD COLUMN class_name TEXT DEFAULT \"\" NOT NULL")
+ private fun addClassNameToStudents(database: SupportSQLiteDatabase, students: List>) {
+ database.execSQL("ALTER TABLE Students ADD COLUMN class_name TEXT DEFAULT \"\" NOT NULL")
students.forEach { (id, name) ->
val schoolName = name.substringAfter(" - ")
val className = name.substringBefore(" - ", "").replace("Klasa ", "")
- db.execSQL("UPDATE Students SET class_name = '$className' WHERE id = '$id'")
- db.execSQL("UPDATE Students SET school_name = '$schoolName' WHERE id = '$id'")
+ database.execSQL("UPDATE Students SET class_name = '$className' WHERE id = '$id'")
+ database.execSQL("UPDATE Students SET school_name = '$schoolName' WHERE id = '$id'")
}
}
- private fun getStudentsIds(db: SupportSQLiteDatabase): MutableList> {
+ private fun getStudentsIds(database: SupportSQLiteDatabase): MutableList> {
val students = mutableListOf>()
- db.query("SELECT id, school_name FROM Students").use {
- if (it.moveToFirst()) {
- do {
- students.add(it.getInt(0) to it.getString(1))
- } while (it.moveToNext())
- }
+ val studentsCursor = database.query("SELECT id, school_name FROM Students")
+ if (studentsCursor.moveToFirst()) {
+ do {
+ students.add(studentsCursor.getInt(0) to studentsCursor.getString(1))
+ } while (studentsCursor.moveToNext())
}
-
return students
}
- private fun updateSemestersTable(db: SupportSQLiteDatabase) {
- db.execSQL("ALTER TABLE Semesters ADD COLUMN school_year INTEGER DEFAULT 1970 NOT NULL")
- db.execSQL("ALTER TABLE Semesters ADD COLUMN start INTEGER DEFAULT 0 NOT NULL")
- db.execSQL("ALTER TABLE Semesters ADD COLUMN `end` INTEGER DEFAULT 0 NOT NULL")
+ private fun updateSemestersTable(database: SupportSQLiteDatabase) {
+ database.execSQL("ALTER TABLE Semesters ADD COLUMN school_year INTEGER DEFAULT 1970 NOT NULL")
+ database.execSQL("ALTER TABLE Semesters ADD COLUMN start INTEGER DEFAULT 0 NOT NULL")
+ database.execSQL("ALTER TABLE Semesters ADD COLUMN `end` INTEGER DEFAULT 0 NOT NULL")
}
- private fun getStudentsAndClassIds(db: SupportSQLiteDatabase): List> {
+ private fun getStudentsAndClassIds(database: SupportSQLiteDatabase): List> {
val students = mutableListOf>()
- db.query("SELECT student_id, class_id FROM Students").use {
- if (it.moveToFirst()) {
- do {
- students.add(it.getInt(0) to it.getInt(1))
- } while (it.moveToNext())
- }
+ val studentsCursor = database.query("SELECT student_id, class_id FROM Students")
+ if (studentsCursor.moveToFirst()) {
+ do {
+ students.add(studentsCursor.getInt(0) to studentsCursor.getInt(1))
+ } while (studentsCursor.moveToNext())
}
-
return students
}
- private fun markAtLeastAndOnlyOneSemesterAtCurrent(
- db: SupportSQLiteDatabase,
- students: List>
- ) {
+ private fun markAtLeastAndOnlyOneSemesterAtCurrent(database: SupportSQLiteDatabase, students: List