diff --git a/app/src/main/java/com/philkes/notallyx/presentation/activity/note/reminders/DatePickerFragment.kt b/app/src/main/java/com/philkes/notallyx/presentation/activity/note/reminders/DatePickerFragment.kt index 0cb7fb8a..1aa6dcfc 100644 --- a/app/src/main/java/com/philkes/notallyx/presentation/activity/note/reminders/DatePickerFragment.kt +++ b/app/src/main/java/com/philkes/notallyx/presentation/activity/note/reminders/DatePickerFragment.kt @@ -3,6 +3,7 @@ package com.philkes.notallyx.presentation.activity.note.reminders import android.os.Bundle import androidx.fragment.app.DialogFragment import com.google.android.material.datepicker.MaterialDatePicker +import com.google.android.material.datepicker.MaterialDatePicker.INPUT_MODE_CALENDAR import com.philkes.notallyx.utils.now import java.util.Calendar import java.util.Date @@ -19,7 +20,10 @@ class DatePickerFragment( val c = date?.let { Calendar.getInstance().apply { time = it } } ?: now val datePicker = - MaterialDatePicker.Builder.datePicker().setSelection(c.timeInMillis).build() + MaterialDatePicker.Builder.datePicker() + .setSelection(c.timeInMillis) + .setInputMode(INPUT_MODE_CALENDAR) + .build() datePicker.addOnPositiveButtonClickListener { selection -> val calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC")) diff --git a/app/src/main/java/com/philkes/notallyx/presentation/activity/note/reminders/ReminderReceiver.kt b/app/src/main/java/com/philkes/notallyx/presentation/activity/note/reminders/ReminderReceiver.kt index 50c32dcb..e1cf4017 100644 --- a/app/src/main/java/com/philkes/notallyx/presentation/activity/note/reminders/ReminderReceiver.kt +++ b/app/src/main/java/com/philkes/notallyx/presentation/activity/note/reminders/ReminderReceiver.kt @@ -20,7 +20,6 @@ import com.philkes.notallyx.utils.cancelReminder import com.philkes.notallyx.utils.createChannelIfNotExists import com.philkes.notallyx.utils.getOpenNotePendingIntent import com.philkes.notallyx.utils.scheduleReminder -import com.philkes.notallyx.utils.truncate import java.util.Date import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers @@ -96,12 +95,20 @@ class ReminderReceiver : BroadcastReceiver() { ) } database.getBaseNoteDao().get(noteId)?.let { note -> + val contentText = + if (note.type == com.philkes.notallyx.data.model.Type.LIST) { + note.items.joinToString("\n") { (if (it.checked) "✅ " else "🔳 ") + it.body } + } else { + note.body + } val notification = NotificationCompat.Builder(context, NOTIFICATION_CHANNEL_ID) .setSmallIcon(R.drawable.notebook) - .setContentTitle(note.title) - .setContentText(note.body.truncate(200)) + .setContentTitle(note.title.ifEmpty { context.getString(R.string.note) }) + .setContentText(contentText) + .setStyle(NotificationCompat.BigTextStyle().bigText(contentText)) .setPriority(NotificationCompat.PRIORITY_HIGH) + .setGroup(GROUP_REMINDERS) .addAction( R.drawable.visibility, context.getString(R.string.open_note), @@ -109,11 +116,19 @@ class ReminderReceiver : BroadcastReceiver() { ) .setDeleteIntent(getDeletePendingIntent(context, noteId, reminderId)) .build() + val summaryNotification = + NotificationCompat.Builder(context, NOTIFICATION_CHANNEL_ID) + .setSmallIcon(R.drawable.notebook_multiple) + .setGroup(GROUP_REMINDERS) + .setGroupSummary(true) + .build() + note.reminders .find { it.id == reminderId } ?.let { reminder: Reminder -> setIsNotificationVisible(true, context, note.id, reminderId) manager.notify(note.id.toString(), reminderId.toInt(), notification) + manager.notify(SUMMARY_ID, summaryNotification) if (schedule) context.scheduleReminder(note.id, reminder, forceRepetition = true) } @@ -220,7 +235,9 @@ class ReminderReceiver : BroadcastReceiver() { companion object { private const val TAG = "ReminderReceiver" + private const val SUMMARY_ID = 1231325 private const val NOTIFICATION_CHANNEL_ID = "Reminders" + private const val GROUP_REMINDERS = "notallyx.notifications.group.reminders" const val EXTRA_REMINDER_ID = "notallyx.intent.extra.REMINDER_ID" const val EXTRA_NOTE_ID = "notallyx.intent.extra.NOTE_ID" diff --git a/app/src/main/java/com/philkes/notallyx/presentation/activity/note/reminders/TimePickerFragment.kt b/app/src/main/java/com/philkes/notallyx/presentation/activity/note/reminders/TimePickerFragment.kt index de3268df..b87dd84c 100644 --- a/app/src/main/java/com/philkes/notallyx/presentation/activity/note/reminders/TimePickerFragment.kt +++ b/app/src/main/java/com/philkes/notallyx/presentation/activity/note/reminders/TimePickerFragment.kt @@ -4,6 +4,7 @@ import android.os.Bundle import android.text.format.DateFormat import androidx.fragment.app.DialogFragment import com.google.android.material.timepicker.MaterialTimePicker +import com.google.android.material.timepicker.MaterialTimePicker.INPUT_MODE_CLOCK import com.google.android.material.timepicker.TimeFormat import java.util.Calendar @@ -19,6 +20,7 @@ class TimePickerFragment(private val calendar: Calendar, private val listener: T val timePicker = MaterialTimePicker.Builder() .setTimeFormat(if (is24Hour) TimeFormat.CLOCK_24H else TimeFormat.CLOCK_12H) + .setInputMode(INPUT_MODE_CLOCK) .setHour(hour) .setMinute(minute) .build() diff --git a/app/src/main/java/com/philkes/notallyx/utils/changehistory/ChangeHistory.kt b/app/src/main/java/com/philkes/notallyx/utils/changehistory/ChangeHistory.kt index 9a7a1b3b..ace66054 100644 --- a/app/src/main/java/com/philkes/notallyx/utils/changehistory/ChangeHistory.kt +++ b/app/src/main/java/com/philkes/notallyx/utils/changehistory/ChangeHistory.kt @@ -35,7 +35,6 @@ class ChangeHistory( } changeStack.add(change) stackPointer.value = newStackPointer + 1 - Log.d(TAG, "addChange: $change") } fun redo() { diff --git a/app/src/main/res/drawable/notebook_multiple.xml b/app/src/main/res/drawable/notebook_multiple.xml new file mode 100644 index 00000000..a2a0afb4 --- /dev/null +++ b/app/src/main/res/drawable/notebook_multiple.xml @@ -0,0 +1,20 @@ + + + + + + + + + \ No newline at end of file