mirror of
https://github.com/szkolny-eu/szkolny-android.git
synced 2024-11-24 10:54:36 -06:00
[UI] Add long text for notification descriptions.
This commit is contained in:
parent
fd0fc652a3
commit
85d74bec1c
@ -10,6 +10,7 @@ import pl.szczodrzynski.edziennik.R
|
||||
import pl.szczodrzynski.edziennik.data.db.entity.*
|
||||
import pl.szczodrzynski.edziennik.getNotificationTitle
|
||||
import pl.szczodrzynski.edziennik.utils.models.Date
|
||||
import pl.szczodrzynski.edziennik.utils.models.Week
|
||||
|
||||
class Notifications(val app: App, val notifications: MutableList<Notification>, val profiles: List<Profile>) {
|
||||
companion object {
|
||||
@ -42,13 +43,22 @@ class Notifications(val app: App, val notifications: MutableList<Notification>,
|
||||
val text = app.getString(
|
||||
R.string.notification_lesson_change_format,
|
||||
lesson.getDisplayChangeType(app),
|
||||
if (lesson.displayDate == null) "" else lesson.displayDate!!.formattedString,
|
||||
lesson.displayDate?.formattedString ?: "",
|
||||
lesson.changeSubjectName
|
||||
)
|
||||
val textLong = app.getString(
|
||||
R.string.notification_lesson_change_long_format,
|
||||
lesson.getDisplayChangeType(app),
|
||||
lesson.displayDate?.formattedString ?: "-",
|
||||
lesson.displayDate?.weekDay?.let { Week.getFullDayName(it) } ?: "-",
|
||||
lesson.changeSubjectName,
|
||||
lesson.changeTeacherName
|
||||
)
|
||||
notifications += Notification(
|
||||
id = Notification.buildId(lesson.profileId, Notification.TYPE_TIMETABLE_LESSON_CHANGE, lesson.id),
|
||||
title = app.getNotificationTitle(Notification.TYPE_TIMETABLE_LESSON_CHANGE),
|
||||
text = text,
|
||||
textLong = textLong,
|
||||
type = Notification.TYPE_TIMETABLE_LESSON_CHANGE,
|
||||
profileId = lesson.profileId,
|
||||
profileName = profiles.singleOrNull { it.id == lesson.profileId }?.name,
|
||||
@ -79,11 +89,21 @@ class Notifications(val app: App, val notifications: MutableList<Notification>,
|
||||
event.date.formattedString,
|
||||
event.subjectLongName
|
||||
)
|
||||
val textLong = app.getString(
|
||||
R.string.notification_event_long_format,
|
||||
event.typeName ?: "-",
|
||||
event.subjectLongName ?: "-",
|
||||
event.date.formattedString,
|
||||
Week.getFullDayName(event.date.weekDay),
|
||||
event.time?.stringHM ?: app.getString(R.string.event_all_day),
|
||||
event.topic.take(200)
|
||||
)
|
||||
val type = if (event.type == Event.TYPE_HOMEWORK) Notification.TYPE_NEW_HOMEWORK else Notification.TYPE_NEW_EVENT
|
||||
notifications += Notification(
|
||||
id = Notification.buildId(event.profileId, type, event.id),
|
||||
title = app.getNotificationTitle(type),
|
||||
text = text,
|
||||
textLong = textLong,
|
||||
type = type,
|
||||
profileId = event.profileId,
|
||||
profileName = profiles.singleOrNull { it.id == event.profileId }?.name,
|
||||
@ -102,11 +122,22 @@ class Notifications(val app: App, val notifications: MutableList<Notification>,
|
||||
event.date.formattedString,
|
||||
event.topic
|
||||
)
|
||||
val textLong = app.getString(
|
||||
R.string.notification_shared_event_long_format,
|
||||
event.sharedByName,
|
||||
event.typeName ?: "-",
|
||||
event.subjectLongName ?: "-",
|
||||
event.date.formattedString,
|
||||
Week.getFullDayName(event.date.weekDay),
|
||||
event.time?.stringHM ?: app.getString(R.string.event_all_day),
|
||||
event.topic.take(200)
|
||||
)
|
||||
val type = if (event.type == Event.TYPE_HOMEWORK) Notification.TYPE_NEW_HOMEWORK else Notification.TYPE_NEW_EVENT
|
||||
notifications += Notification(
|
||||
id = Notification.buildId(event.profileId, type, event.id),
|
||||
title = app.getNotificationTitle(type),
|
||||
text = text,
|
||||
textLong = textLong,
|
||||
type = type,
|
||||
profileId = event.profileId,
|
||||
profileName = profiles.singleOrNull { it.id == event.profileId }?.name,
|
||||
@ -130,10 +161,20 @@ class Notifications(val app: App, val notifications: MutableList<Notification>,
|
||||
gradeName,
|
||||
grade.subjectLongName
|
||||
)
|
||||
val textLong = app.getString(
|
||||
R.string.notification_grade_long_format,
|
||||
gradeName,
|
||||
grade.weight.toString(),
|
||||
grade.subjectLongName ?: "-",
|
||||
grade.category ?: "-",
|
||||
grade.description ?: "-",
|
||||
grade.teacherName ?: "-"
|
||||
)
|
||||
notifications += Notification(
|
||||
id = Notification.buildId(grade.profileId, Notification.TYPE_NEW_GRADE, grade.id),
|
||||
title = app.getNotificationTitle(Notification.TYPE_NEW_GRADE),
|
||||
text = text,
|
||||
textLong = textLong,
|
||||
type = Notification.TYPE_NEW_GRADE,
|
||||
profileId = grade.profileId,
|
||||
profileName = profiles.singleOrNull { it.id == grade.profileId }?.name,
|
||||
@ -158,10 +199,17 @@ class Notifications(val app: App, val notifications: MutableList<Notification>,
|
||||
notice.teacherName,
|
||||
Date.fromMillis(notice.addedDate).formattedString
|
||||
)
|
||||
val textLong = app.getString(
|
||||
R.string.notification_notice_long_format,
|
||||
noticeTypeStr,
|
||||
notice.teacherName ?: "-",
|
||||
notice.text.take(200)
|
||||
)
|
||||
notifications += Notification(
|
||||
id = Notification.buildId(notice.profileId, Notification.TYPE_NEW_NOTICE, notice.id),
|
||||
title = app.getNotificationTitle(Notification.TYPE_NEW_NOTICE),
|
||||
text = text,
|
||||
textLong = textLong,
|
||||
type = Notification.TYPE_NEW_NOTICE,
|
||||
profileId = notice.profileId,
|
||||
profileName = profiles.singleOrNull { it.id == notice.profileId }?.name,
|
||||
@ -193,10 +241,21 @@ class Notifications(val app: App, val notifications: MutableList<Notification>,
|
||||
attendance.subjectLongName,
|
||||
attendance.date.formattedString
|
||||
)
|
||||
val textLong = app.getString(
|
||||
R.string.notification_attendance_long_format,
|
||||
attendanceTypeStr,
|
||||
attendance.date.formattedString,
|
||||
attendance.startTime?.stringHM ?: "-",
|
||||
attendance.lessonNumber ?: "-",
|
||||
attendance.subjectLongName ?: "-",
|
||||
attendance.teacherName ?: "-",
|
||||
attendance.lessonTopic ?: "-"
|
||||
)
|
||||
notifications += Notification(
|
||||
id = Notification.buildId(attendance.profileId, Notification.TYPE_NEW_ATTENDANCE, attendance.id),
|
||||
title = app.getNotificationTitle(Notification.TYPE_NEW_ATTENDANCE),
|
||||
text = text,
|
||||
textLong = textLong,
|
||||
type = Notification.TYPE_NEW_ATTENDANCE,
|
||||
profileId = attendance.profileId,
|
||||
profileName = profiles.singleOrNull { it.id == attendance.profileId }?.name,
|
||||
|
@ -148,7 +148,7 @@ class PostNotifications(val app: App, nList: List<AppNotification>) {
|
||||
colorRes = R.color.colorPrimary
|
||||
}.toBitmap())
|
||||
.setStyle(NotificationCompat.BigTextStyle()
|
||||
.bigText(it.text))
|
||||
.bigText(it.textLong ?: it.text))
|
||||
.setWhen(it.addedDate)
|
||||
.addDefaults()
|
||||
.setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_SUMMARY)
|
||||
|
@ -21,6 +21,7 @@ data class Notification(
|
||||
|
||||
val title: String,
|
||||
val text: String,
|
||||
val textLong: String? = null,
|
||||
|
||||
val type: Int,
|
||||
|
||||
|
@ -45,6 +45,7 @@ class WidgetNotificationsFactory(val app: App, val config: WidgetConfig) : Remot
|
||||
getLong("id") ?: 0,
|
||||
getString("title") ?: "",
|
||||
getString("text") ?: "",
|
||||
getString("textLong"),
|
||||
getInt("type") ?: 0,
|
||||
getInt("profileId"),
|
||||
getString("profileName"),
|
||||
@ -74,4 +75,4 @@ class WidgetNotificationsFactory(val app: App, val config: WidgetConfig) : Remot
|
||||
override fun hasStableIds() = true
|
||||
override fun getViewTypeCount() = 1
|
||||
override fun onDestroy() = cursor?.close() ?: Unit
|
||||
}
|
||||
}
|
||||
|
@ -1451,4 +1451,10 @@
|
||||
<string name="messages_config_greeting_text">Treść podpisu</string>
|
||||
<string name="menu_messages_config">Ustawienia wiadomości</string>
|
||||
<string name="event_type_elearning">lekcja online</string>
|
||||
<string name="notification_lesson_change_long_format">Rodzaj: %s\nData: %s (%s)\nLekcja: %s\nNauczyciel: %s</string>
|
||||
<string name="notification_event_long_format">Rodzaj: %s\nPrzedmiot: %s\nTermin: %s (%s), %s\nTreść: %s</string>
|
||||
<string name="notification_shared_event_long_format">Dodane przez: %s\nRodzaj: %s\nPrzedmiot: %s\nTermin: %s (%s), %s\nTreść: %s</string>
|
||||
<string name="notification_grade_long_format">Ocena: %s (waga %s)\nPrzedmiot: %s\nKategoria: %s\nOpis: %s\nNauczyciel: %s</string>
|
||||
<string name="notification_notice_long_format">Rodzaj: %s\nNauczyciel: %s\nTreść: %s</string>
|
||||
<string name="notification_attendance_long_format">Rodzaj: %s\nTermin: %s, %s\nNr lekcji: %s\nPrzedmiot: %s\nNauczyciel: %s\nTemat lekcji: %s</string>
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user