Skip to content

Commit e4195ff

Browse files
authored
Show notes contents in notification and use stack icon (#960)
1 parent 719dbf5 commit e4195ff

5 files changed

Lines changed: 47 additions & 5 deletions

File tree

app/src/main/java/com/philkes/notallyx/presentation/activity/note/reminders/DatePickerFragment.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package com.philkes.notallyx.presentation.activity.note.reminders
33
import android.os.Bundle
44
import androidx.fragment.app.DialogFragment
55
import com.google.android.material.datepicker.MaterialDatePicker
6+
import com.google.android.material.datepicker.MaterialDatePicker.INPUT_MODE_CALENDAR
67
import com.philkes.notallyx.utils.now
78
import java.util.Calendar
89
import java.util.Date
@@ -19,7 +20,10 @@ class DatePickerFragment(
1920
val c = date?.let { Calendar.getInstance().apply { time = it } } ?: now
2021

2122
val datePicker =
22-
MaterialDatePicker.Builder.datePicker().setSelection(c.timeInMillis).build()
23+
MaterialDatePicker.Builder.datePicker()
24+
.setSelection(c.timeInMillis)
25+
.setInputMode(INPUT_MODE_CALENDAR)
26+
.build()
2327

2428
datePicker.addOnPositiveButtonClickListener { selection ->
2529
val calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC"))

app/src/main/java/com/philkes/notallyx/presentation/activity/note/reminders/ReminderReceiver.kt

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import com.philkes.notallyx.utils.cancelReminder
2020
import com.philkes.notallyx.utils.createChannelIfNotExists
2121
import com.philkes.notallyx.utils.getOpenNotePendingIntent
2222
import com.philkes.notallyx.utils.scheduleReminder
23-
import com.philkes.notallyx.utils.truncate
2423
import java.util.Date
2524
import kotlinx.coroutines.CoroutineScope
2625
import kotlinx.coroutines.Dispatchers
@@ -96,24 +95,40 @@ class ReminderReceiver : BroadcastReceiver() {
9695
)
9796
}
9897
database.getBaseNoteDao().get(noteId)?.let { note ->
98+
val contentText =
99+
if (note.type == com.philkes.notallyx.data.model.Type.LIST) {
100+
note.items.joinToString("\n") { (if (it.checked) "" else "🔳 ") + it.body }
101+
} else {
102+
note.body
103+
}
99104
val notification =
100105
NotificationCompat.Builder(context, NOTIFICATION_CHANNEL_ID)
101106
.setSmallIcon(R.drawable.notebook)
102-
.setContentTitle(note.title)
103-
.setContentText(note.body.truncate(200))
107+
.setContentTitle(note.title.ifEmpty { context.getString(R.string.note) })
108+
.setContentText(contentText)
109+
.setStyle(NotificationCompat.BigTextStyle().bigText(contentText))
104110
.setPriority(NotificationCompat.PRIORITY_HIGH)
111+
.setGroup(GROUP_REMINDERS)
105112
.addAction(
106113
R.drawable.visibility,
107114
context.getString(R.string.open_note),
108115
context.getOpenNotePendingIntent(note),
109116
)
110117
.setDeleteIntent(getDeletePendingIntent(context, noteId, reminderId))
111118
.build()
119+
val summaryNotification =
120+
NotificationCompat.Builder(context, NOTIFICATION_CHANNEL_ID)
121+
.setSmallIcon(R.drawable.notebook_multiple)
122+
.setGroup(GROUP_REMINDERS)
123+
.setGroupSummary(true)
124+
.build()
125+
112126
note.reminders
113127
.find { it.id == reminderId }
114128
?.let { reminder: Reminder ->
115129
setIsNotificationVisible(true, context, note.id, reminderId)
116130
manager.notify(note.id.toString(), reminderId.toInt(), notification)
131+
manager.notify(SUMMARY_ID, summaryNotification)
117132
if (schedule)
118133
context.scheduleReminder(note.id, reminder, forceRepetition = true)
119134
}
@@ -220,7 +235,9 @@ class ReminderReceiver : BroadcastReceiver() {
220235
companion object {
221236
private const val TAG = "ReminderReceiver"
222237

238+
private const val SUMMARY_ID = 1231325
223239
private const val NOTIFICATION_CHANNEL_ID = "Reminders"
240+
private const val GROUP_REMINDERS = "notallyx.notifications.group.reminders"
224241

225242
const val EXTRA_REMINDER_ID = "notallyx.intent.extra.REMINDER_ID"
226243
const val EXTRA_NOTE_ID = "notallyx.intent.extra.NOTE_ID"

app/src/main/java/com/philkes/notallyx/presentation/activity/note/reminders/TimePickerFragment.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import android.os.Bundle
44
import android.text.format.DateFormat
55
import androidx.fragment.app.DialogFragment
66
import com.google.android.material.timepicker.MaterialTimePicker
7+
import com.google.android.material.timepicker.MaterialTimePicker.INPUT_MODE_CLOCK
78
import com.google.android.material.timepicker.TimeFormat
89
import java.util.Calendar
910

@@ -19,6 +20,7 @@ class TimePickerFragment(private val calendar: Calendar, private val listener: T
1920
val timePicker =
2021
MaterialTimePicker.Builder()
2122
.setTimeFormat(if (is24Hour) TimeFormat.CLOCK_24H else TimeFormat.CLOCK_12H)
23+
.setInputMode(INPUT_MODE_CLOCK)
2224
.setHour(hour)
2325
.setMinute(minute)
2426
.build()

app/src/main/java/com/philkes/notallyx/utils/changehistory/ChangeHistory.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ class ChangeHistory(
3535
}
3636
changeStack.add(change)
3737
stackPointer.value = newStackPointer + 1
38-
Log.d(TAG, "addChange: $change")
3938
}
4039

4140
fun redo() {
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="24dp"
3+
android:height="24dp"
4+
android:tint="?attr/colorControlNormal"
5+
android:viewportWidth="24"
6+
android:viewportHeight="24">
7+
8+
<path
9+
android:fillColor="#000000"
10+
android:pathData="M1,7v14c0,1.1 0.9,2 2,2h14v-2H3V7H1z" />
11+
12+
<path
13+
android:fillColor="#000000"
14+
android:pathData="M20,4v14H6V4H20M20,2H6C4.9,2 4,2.9 4,4v14c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 2,-2V4C22,2.9 21.1,2 20,2L20,2z" />
15+
16+
<path
17+
android:fillColor="#000000"
18+
android:pathData="M15,16H8v-2h7V16zM18,12H8v-2h10V12zM18,8H8V6h10V8z" />
19+
20+
</vector>

0 commit comments

Comments
 (0)