Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -96,24 +95,40 @@ 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),
context.getOpenNotePendingIntent(note),
)
.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)
}
Expand Down Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ class ChangeHistory(
}
changeStack.add(change)
stackPointer.value = newStackPointer + 1
Log.d(TAG, "addChange: $change")
}

fun redo() {
Expand Down
20 changes: 20 additions & 0 deletions app/src/main/res/drawable/notebook_multiple.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?attr/colorControlNormal"
android:viewportWidth="24"
android:viewportHeight="24">

<path
android:fillColor="#000000"
android:pathData="M1,7v14c0,1.1 0.9,2 2,2h14v-2H3V7H1z" />

<path
android:fillColor="#000000"
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" />

<path
android:fillColor="#000000"
android:pathData="M15,16H8v-2h7V16zM18,12H8v-2h10V12zM18,8H8V6h10V8z" />

</vector>