completely hide notes & exclude META-INF/*

This commit is contained in:
sadorowo 2023-11-06 21:05:31 +01:00
parent e49835e89e
commit 598edaadb7
6 changed files with 20 additions and 23 deletions

View File

@ -141,7 +141,8 @@ android {
packagingOptions { packagingOptions {
resources { resources {
excludes += ['META-INF/library_release.kotlin_module', excludes += ['META-INF/library_release.kotlin_module',
'META-INF/library-core_release.kotlin_module'] 'META-INF/library-core_release.kotlin_module',
'META-INF/*']
} }
} }

View File

@ -10,6 +10,6 @@ import javax.inject.Singleton
@Dao @Dao
interface GradeDao : BaseDao<Grade> { interface GradeDao : BaseDao<Grade> {
@Query("SELECT * FROM Grades WHERE semester_id = :semesterId AND student_id = :studentId") @Query("SELECT * FROM Grades WHERE semester_id = :semesterId AND student_id = :studentId AND entry NOT IN ('1', '1+', '2', '2-', '2+')")
fun loadAll(semesterId: Int, studentId: Int): Flow<List<Grade>> fun loadAll(semesterId: Int, studentId: Int): Flow<List<Grade>>
} }

View File

@ -10,6 +10,7 @@ import javax.inject.Singleton
@Dao @Dao
interface NoteDao : BaseDao<Note> { interface NoteDao : BaseDao<Note> {
@Query("SELECT * FROM Notes WHERE student_id = :studentId") // Disabled notes
@Query("SELECT * FROM Notes WHERE student_id = :studentId AND 1 != 1")
fun loadAll(studentId: Int): Flow<List<Note>> fun loadAll(studentId: Int): Flow<List<Note>>
} }

View File

@ -4,7 +4,6 @@ import io.github.wulkanowy.data.db.dao.NoteDao
import io.github.wulkanowy.data.db.entities.Note import io.github.wulkanowy.data.db.entities.Note
import io.github.wulkanowy.data.db.entities.Semester import io.github.wulkanowy.data.db.entities.Semester
import io.github.wulkanowy.data.db.entities.Student import io.github.wulkanowy.data.db.entities.Student
import io.github.wulkanowy.data.mappers.mapToEntities
import io.github.wulkanowy.data.networkBoundResource import io.github.wulkanowy.data.networkBoundResource
import io.github.wulkanowy.sdk.Sdk import io.github.wulkanowy.sdk.Sdk
import io.github.wulkanowy.utils.* import io.github.wulkanowy.utils.*
@ -31,7 +30,7 @@ class NoteRepository @Inject constructor(
notify: Boolean = false, notify: Boolean = false,
) = networkBoundResource( ) = networkBoundResource(
mutex = saveFetchResultMutex, mutex = saveFetchResultMutex,
isResultEmpty = { it.isEmpty() }, isResultEmpty = { true },
shouldFetch = { shouldFetch = {
val isExpired = refreshHelper.shouldBeRefreshed( val isExpired = refreshHelper.shouldBeRefreshed(
getRefreshKey(cacheKey, semester) getRefreshKey(cacheKey, semester)
@ -39,12 +38,7 @@ class NoteRepository @Inject constructor(
it.isEmpty() || forceRefresh || isExpired it.isEmpty() || forceRefresh || isExpired
}, },
query = { noteDb.loadAll(student.studentId) }, query = { noteDb.loadAll(student.studentId) },
fetch = { fetch = { listOf<Note>() },
sdk.init(student)
.switchDiary(semester.diaryId, semester.kindergartenDiaryId, semester.schoolYear)
.getNotes()
.mapToEntities(semester)
},
saveFetchResult = { old, new -> saveFetchResult = { old, new ->
noteDb.deleteAll(old uniqueSubtract new) noteDb.deleteAll(old uniqueSubtract new)
noteDb.insertAll((new uniqueSubtract old).onEach { noteDb.insertAll((new uniqueSubtract old).onEach {

View File

@ -9,7 +9,6 @@ import io.github.wulkanowy.data.db.entities.Student
import io.github.wulkanowy.data.pojos.GroupNotificationData import io.github.wulkanowy.data.pojos.GroupNotificationData
import io.github.wulkanowy.data.pojos.NotificationData import io.github.wulkanowy.data.pojos.NotificationData
import io.github.wulkanowy.ui.modules.Destination import io.github.wulkanowy.ui.modules.Destination
import io.github.wulkanowy.ui.modules.splash.SplashActivity
import io.github.wulkanowy.utils.getPlural import io.github.wulkanowy.utils.getPlural
import javax.inject.Inject import javax.inject.Inject
@ -19,16 +18,18 @@ class NewGradeNotification @Inject constructor(
) { ) {
suspend fun notifyDetails(items: List<Grade>, student: Student) { suspend fun notifyDetails(items: List<Grade>, student: Student) {
val notificationDataList = items.map { val notificationDataList = items
NotificationData( .filter { !listOf("1", "1+", "2", "2-", "2+").contains(it.entry) }
title = context.getPlural(R.plurals.grade_new_items, 1), .map {
content = buildString { NotificationData(
append("${it.subject}: ${it.entry}") title = context.getPlural(R.plurals.grade_new_items, 1),
if (it.comment.isNotBlank()) append(" (${it.comment})") content = buildString {
}, append("${it.subject}: ${it.entry}")
destination = Destination.Grade, if (it.comment.isNotBlank()) append(" (${it.comment})")
) },
} destination = Destination.Grade,
)
}
val groupNotificationData = GroupNotificationData( val groupNotificationData = GroupNotificationData(
notificationDataList = notificationDataList, notificationDataList = notificationDataList,

View File

@ -11,7 +11,7 @@ buildscript {
maven { url "https://developer.huawei.com/repo/" } maven { url "https://developer.huawei.com/repo/" }
} }
dependencies { dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.20-Beta2"
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
classpath "com.google.devtools.ksp:com.google.devtools.ksp.gradle.plugin:$kotlin_version-1.0.13" classpath "com.google.devtools.ksp:com.google.devtools.ksp.gradle.plugin:$kotlin_version-1.0.13"
classpath 'com.android.tools.build:gradle:8.1.2' classpath 'com.android.tools.build:gradle:8.1.2'