Different notification for notes and praises
MODIFY
app/src/main/java/io/github/wulkanowy/services/sync/works/NoteWork.kt
app/src/main/java/io/github/wulkanowy/services/sync/works/NoteWork.kt
@@ -14,6 +14,9 @@ import io.github.wulkanowy.data.db.entities.Semester
import io.github.wulkanowy.data.db.entities.Student
import io.github.wulkanowy.data.repositories.note.NoteRepository
import io.github.wulkanowy.data.repositories.preferences.PreferencesRepository
+import io.github.wulkanowy.sdk.scrapper.notes.NoteCategory
+import io.github.wulkanowy.sdk.scrapper.notes.NoteCategory.NEUTRAL
+import io.github.wulkanowy.sdk.scrapper.notes.NoteCategory.POSITIVE
import io.github.wulkanowy.services.sync.channels.NewNotesChannel
import io.github.wulkanowy.ui.modules.main.MainActivity
import io.github.wulkanowy.ui.modules.main.MainView
@@ -41,8 +44,20 @@ class NoteWork @Inject constructor(
private fun notify(notes: List<Note>) {
notificationManager.notify(Random.nextInt(Int.MAX_VALUE), NotificationCompat.Builder(context, NewNotesChannel.CHANNEL_ID)
- .setContentTitle(context.resources.getQuantityString(R.plurals.note_new_items, notes.size, notes.size))
- .setContentText(context.resources.getQuantityString(R.plurals.note_notify_new_items, notes.size, notes.size))
+ .setContentTitle(
+ when (NoteCategory.getByValue(notes.first().categoryType)) {
+ POSITIVE -> context.resources.getQuantityString(R.plurals.praise_new_items, notes.size, notes.size)
+ NEUTRAL -> context.resources.getQuantityString(R.plurals.neutral_note_new_items, notes.size, notes.size)
+ else -> context.resources.getQuantityString(R.plurals.note_new_items, notes.size, notes.size)
+ }
+ )
+ .setContentText(
+ when (NoteCategory.getByValue(notes.first().categoryType)) {
+ POSITIVE -> context.resources.getQuantityString(R.plurals.praise_notify_new_items, notes.size, notes.size)
+ NEUTRAL -> context.resources.getQuantityString(R.plurals.neutral_note_notify_new_items, notes.size, notes.size)
+ else -> context.resources.getQuantityString(R.plurals.note_notify_new_items, notes.size, notes.size)
+ }
+ )
.setSmallIcon(R.drawable.ic_stat_note)
.setAutoCancel(true)
.setDefaults(DEFAULT_ALL)
@@ -52,7 +67,13 @@ class NoteWork @Inject constructor(
PendingIntent.getActivity(context, MainView.Section.NOTE.id,
MainActivity.getStartIntent(context, MainView.Section.NOTE, true), FLAG_UPDATE_CURRENT))
.setStyle(NotificationCompat.InboxStyle().run {
- setSummaryText(context.resources.getQuantityString(R.plurals.note_number_item, notes.size, notes.size))
+ setSummaryText(
+ when (NoteCategory.getByValue(notes.first().categoryType)) {
+ POSITIVE -> context.resources.getQuantityString(R.plurals.praise_number_item, notes.size, notes.size)
+ NEUTRAL -> context.resources.getQuantityString(R.plurals.neutral_note_number_item, notes.size, notes.size)
+ else -> context.resources.getQuantityString(R.plurals.note_number_item, notes.size, notes.size)
+ }
+ )
notes.forEach { addLine("${it.teacher}: ${it.category}") }
this
})

MODIFY
app/src/main/res/values/strings.xml
app/src/main/res/values/strings.xml
<item quantity="other">You received %1$d notes</item>
</plurals>
+ <!--Praise-->
+ <plurals name="praise_number_item">
+ <item quantity="one">%d praise</item>
+ <item quantity="other">%d praises</item>
+ </plurals>
+ <plurals name="praise_new_items">
+ <item quantity="one">New praise</item>
+ <item quantity="other">New praises</item>
+ </plurals>
+ <plurals name="praise_notify_new_items">
+ <item quantity="one">You received %1$d praise</item>
+ <item quantity="other">You received %1$d praises</item>
+ </plurals>
+
+ <!--Neutral notes-->
+ <plurals name="neutral_note_number_item">
+ <item quantity="one">%d neutral note</item>
+ <item quantity="other">%d neutral notes</item>
+ </plurals>
+ <plurals name="neutral_note_new_items">
+ <item quantity="one">New neutral note</item>
+ <item quantity="other">New neutral notes</item>
+ </plurals>
+ <plurals name="neutral_note_notify_new_items">
+ <item quantity="one">You received %1$d neutral note</item>
+ <item quantity="other">You received %1$d neutral notes</item>
+ </plurals>
+
<!--Homework-->
<string name="homework_no_items">No info about homework</string>

Different notification for notes and praises (#952)