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 {
resources {
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
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>>
}

View File

@ -10,6 +10,7 @@ import javax.inject.Singleton
@Dao
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>>
}

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.Semester
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.sdk.Sdk
import io.github.wulkanowy.utils.*
@ -31,7 +30,7 @@ class NoteRepository @Inject constructor(
notify: Boolean = false,
) = networkBoundResource(
mutex = saveFetchResultMutex,
isResultEmpty = { it.isEmpty() },
isResultEmpty = { true },
shouldFetch = {
val isExpired = refreshHelper.shouldBeRefreshed(
getRefreshKey(cacheKey, semester)
@ -39,12 +38,7 @@ class NoteRepository @Inject constructor(
it.isEmpty() || forceRefresh || isExpired
},
query = { noteDb.loadAll(student.studentId) },
fetch = {
sdk.init(student)
.switchDiary(semester.diaryId, semester.kindergartenDiaryId, semester.schoolYear)
.getNotes()
.mapToEntities(semester)
},
fetch = { listOf<Note>() },
saveFetchResult = { old, new ->
noteDb.deleteAll(old uniqueSubtract new)
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.NotificationData
import io.github.wulkanowy.ui.modules.Destination
import io.github.wulkanowy.ui.modules.splash.SplashActivity
import io.github.wulkanowy.utils.getPlural
import javax.inject.Inject
@ -19,16 +18,18 @@ class NewGradeNotification @Inject constructor(
) {
suspend fun notifyDetails(items: List<Grade>, student: Student) {
val notificationDataList = items.map {
NotificationData(
title = context.getPlural(R.plurals.grade_new_items, 1),
content = buildString {
append("${it.subject}: ${it.entry}")
if (it.comment.isNotBlank()) append(" (${it.comment})")
},
destination = Destination.Grade,
)
}
val notificationDataList = items
.filter { !listOf("1", "1+", "2", "2-", "2+").contains(it.entry) }
.map {
NotificationData(
title = context.getPlural(R.plurals.grade_new_items, 1),
content = buildString {
append("${it.subject}: ${it.entry}")
if (it.comment.isNotBlank()) append(" (${it.comment})")
},
destination = Destination.Grade,
)
}
val groupNotificationData = GroupNotificationData(
notificationDataList = notificationDataList,

View File

@ -11,7 +11,7 @@ buildscript {
maven { url "https://developer.huawei.com/repo/" }
}
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 "com.google.devtools.ksp:com.google.devtools.ksp.gradle.plugin:$kotlin_version-1.0.13"
classpath 'com.android.tools.build:gradle:8.1.2'