Add notification icons (#1276)
Co-authored-by: Mikołaj Pich <m.pich@outlook.com>
@ -168,7 +168,7 @@
|
|||||||
|
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="com.google.firebase.messaging.default_notification_icon"
|
android:name="com.google.firebase.messaging.default_notification_icon"
|
||||||
android:resource="@drawable/ic_stat_push" />
|
android:resource="@drawable/ic_stat_all" />
|
||||||
|
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="com.google.firebase.messaging.default_notification_channel_id"
|
android:name="com.google.firebase.messaging.default_notification_channel_id"
|
||||||
|
@ -81,7 +81,7 @@ class SyncWorker @AssistedInject constructor(
|
|||||||
Random.nextInt(Int.MAX_VALUE),
|
Random.nextInt(Int.MAX_VALUE),
|
||||||
NotificationCompat.Builder(applicationContext, DebugChannel.CHANNEL_ID)
|
NotificationCompat.Builder(applicationContext, DebugChannel.CHANNEL_ID)
|
||||||
.setContentTitle("Debug notification")
|
.setContentTitle("Debug notification")
|
||||||
.setSmallIcon(R.drawable.ic_stat_push)
|
.setSmallIcon(R.drawable.ic_stat_all)
|
||||||
.setAutoCancel(true)
|
.setAutoCancel(true)
|
||||||
.setColor(applicationContext.getCompatColor(R.color.colorPrimary))
|
.setColor(applicationContext.getCompatColor(R.color.colorPrimary))
|
||||||
.setStyle(BigTextStyle().bigText("${SyncWorker::class.java.simpleName} result: $result"))
|
.setStyle(BigTextStyle().bigText("${SyncWorker::class.java.simpleName} result: $result"))
|
||||||
|
@ -14,6 +14,7 @@ import io.github.wulkanowy.data.repositories.PreferencesRepository
|
|||||||
import io.github.wulkanowy.services.sync.channels.NewExamChannel
|
import io.github.wulkanowy.services.sync.channels.NewExamChannel
|
||||||
import io.github.wulkanowy.ui.modules.main.MainActivity
|
import io.github.wulkanowy.ui.modules.main.MainActivity
|
||||||
import io.github.wulkanowy.ui.modules.main.MainView
|
import io.github.wulkanowy.ui.modules.main.MainView
|
||||||
|
import io.github.wulkanowy.utils.getCompatBitmap
|
||||||
import io.github.wulkanowy.utils.getCompatColor
|
import io.github.wulkanowy.utils.getCompatColor
|
||||||
import io.github.wulkanowy.utils.waitForResult
|
import io.github.wulkanowy.utils.waitForResult
|
||||||
import kotlinx.coroutines.flow.first
|
import kotlinx.coroutines.flow.first
|
||||||
@ -51,12 +52,13 @@ class ExamWork @Inject constructor(
|
|||||||
NotificationCompat.Builder(context, NewExamChannel.CHANNEL_ID)
|
NotificationCompat.Builder(context, NewExamChannel.CHANNEL_ID)
|
||||||
.setContentTitle(
|
.setContentTitle(
|
||||||
context.resources.getQuantityString(
|
context.resources.getQuantityString(
|
||||||
R.plurals.exam_notify_new_item_title,
|
R.plurals.exam_notify_new_item_title, exam.size, exam.size
|
||||||
exam.size,
|
|
||||||
exam.size
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.setSmallIcon(R.drawable.ic_main_exam)
|
.setSmallIcon(R.drawable.ic_stat_all)
|
||||||
|
.setLargeIcon(
|
||||||
|
context.getCompatBitmap(R.drawable.ic_main_exam, R.color.colorPrimary)
|
||||||
|
)
|
||||||
.setAutoCancel(true)
|
.setAutoCancel(true)
|
||||||
.setDefaults(NotificationCompat.DEFAULT_ALL)
|
.setDefaults(NotificationCompat.DEFAULT_ALL)
|
||||||
.setPriority(NotificationCompat.PRIORITY_HIGH)
|
.setPriority(NotificationCompat.PRIORITY_HIGH)
|
||||||
|
@ -18,6 +18,7 @@ import io.github.wulkanowy.data.repositories.PreferencesRepository
|
|||||||
import io.github.wulkanowy.services.sync.channels.NewGradesChannel
|
import io.github.wulkanowy.services.sync.channels.NewGradesChannel
|
||||||
import io.github.wulkanowy.ui.modules.main.MainActivity
|
import io.github.wulkanowy.ui.modules.main.MainActivity
|
||||||
import io.github.wulkanowy.ui.modules.main.MainView
|
import io.github.wulkanowy.ui.modules.main.MainView
|
||||||
|
import io.github.wulkanowy.utils.getCompatBitmap
|
||||||
import io.github.wulkanowy.utils.getCompatColor
|
import io.github.wulkanowy.utils.getCompatColor
|
||||||
import io.github.wulkanowy.utils.waitForResult
|
import io.github.wulkanowy.utils.waitForResult
|
||||||
import kotlinx.coroutines.flow.first
|
import kotlinx.coroutines.flow.first
|
||||||
@ -50,18 +51,6 @@ class GradeWork @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getNotificationBuilder(): NotificationCompat.Builder {
|
|
||||||
return NotificationCompat.Builder(context, NewGradesChannel.CHANNEL_ID)
|
|
||||||
.setSmallIcon(R.drawable.ic_stat_grade)
|
|
||||||
.setAutoCancel(true)
|
|
||||||
.setPriority(PRIORITY_HIGH)
|
|
||||||
.setDefaults(DEFAULT_ALL)
|
|
||||||
.setColor(context.getCompatColor(R.color.colorPrimary))
|
|
||||||
.setContentIntent(
|
|
||||||
PendingIntent.getActivity(context, MainView.Section.GRADE.id,
|
|
||||||
MainActivity.getStartIntent(context, MainView.Section.GRADE, true), FLAG_UPDATE_CURRENT))
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun notifyDetails(grades: List<Grade>) {
|
private fun notifyDetails(grades: List<Grade>) {
|
||||||
notificationManager.notify(Random.nextInt(Int.MAX_VALUE), getNotificationBuilder()
|
notificationManager.notify(Random.nextInt(Int.MAX_VALUE), getNotificationBuilder()
|
||||||
.setContentTitle(context.resources.getQuantityString(R.plurals.grade_new_items, grades.size, grades.size))
|
.setContentTitle(context.resources.getQuantityString(R.plurals.grade_new_items, grades.size, grades.size))
|
||||||
@ -100,4 +89,23 @@ class GradeWork @Inject constructor(
|
|||||||
.build()
|
.build()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun getNotificationBuilder(): NotificationCompat.Builder {
|
||||||
|
return NotificationCompat.Builder(context, NewGradesChannel.CHANNEL_ID)
|
||||||
|
.setSmallIcon(R.drawable.ic_stat_all)
|
||||||
|
.setLargeIcon(
|
||||||
|
context.getCompatBitmap(R.drawable.ic_stat_grade, R.color.colorPrimary)
|
||||||
|
)
|
||||||
|
.setAutoCancel(true)
|
||||||
|
.setPriority(PRIORITY_HIGH)
|
||||||
|
.setDefaults(DEFAULT_ALL)
|
||||||
|
.setColor(context.getCompatColor(R.color.colorPrimary))
|
||||||
|
.setContentIntent(
|
||||||
|
PendingIntent.getActivity(
|
||||||
|
context, MainView.Section.GRADE.id,
|
||||||
|
MainActivity.getStartIntent(context, MainView.Section.GRADE, true),
|
||||||
|
FLAG_UPDATE_CURRENT
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ import io.github.wulkanowy.data.repositories.PreferencesRepository
|
|||||||
import io.github.wulkanowy.services.sync.channels.NewHomeworkChannel
|
import io.github.wulkanowy.services.sync.channels.NewHomeworkChannel
|
||||||
import io.github.wulkanowy.ui.modules.main.MainActivity
|
import io.github.wulkanowy.ui.modules.main.MainActivity
|
||||||
import io.github.wulkanowy.ui.modules.main.MainView
|
import io.github.wulkanowy.ui.modules.main.MainView
|
||||||
|
import io.github.wulkanowy.utils.getCompatBitmap
|
||||||
import io.github.wulkanowy.utils.getCompatColor
|
import io.github.wulkanowy.utils.getCompatColor
|
||||||
import io.github.wulkanowy.utils.monday
|
import io.github.wulkanowy.utils.monday
|
||||||
import io.github.wulkanowy.utils.sunday
|
import io.github.wulkanowy.utils.sunday
|
||||||
@ -56,12 +57,13 @@ class HomeworkWork @Inject constructor(
|
|||||||
NotificationCompat.Builder(context, NewHomeworkChannel.CHANNEL_ID)
|
NotificationCompat.Builder(context, NewHomeworkChannel.CHANNEL_ID)
|
||||||
.setContentTitle(
|
.setContentTitle(
|
||||||
context.resources.getQuantityString(
|
context.resources.getQuantityString(
|
||||||
R.plurals.homework_notify_new_item_title,
|
R.plurals.homework_notify_new_item_title, homework.size, homework.size
|
||||||
homework.size,
|
|
||||||
homework.size
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.setSmallIcon(R.drawable.ic_more_homework)
|
.setSmallIcon(R.drawable.ic_stat_all)
|
||||||
|
.setLargeIcon(
|
||||||
|
context.getCompatBitmap(R.drawable.ic_more_homework, R.color.colorPrimary)
|
||||||
|
)
|
||||||
.setAutoCancel(true)
|
.setAutoCancel(true)
|
||||||
.setDefaults(NotificationCompat.DEFAULT_ALL)
|
.setDefaults(NotificationCompat.DEFAULT_ALL)
|
||||||
.setPriority(NotificationCompat.PRIORITY_HIGH)
|
.setPriority(NotificationCompat.PRIORITY_HIGH)
|
||||||
@ -76,9 +78,7 @@ class HomeworkWork @Inject constructor(
|
|||||||
.setStyle(NotificationCompat.InboxStyle().run {
|
.setStyle(NotificationCompat.InboxStyle().run {
|
||||||
setSummaryText(
|
setSummaryText(
|
||||||
context.resources.getQuantityString(
|
context.resources.getQuantityString(
|
||||||
R.plurals.homework_number_item,
|
R.plurals.homework_number_item, homework.size, homework.size
|
||||||
homework.size,
|
|
||||||
homework.size
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
homework.forEach { addLine("${it.subject}: ${it.content}") }
|
homework.forEach { addLine("${it.subject}: ${it.content}") }
|
||||||
|
@ -17,6 +17,7 @@ import io.github.wulkanowy.data.repositories.PreferencesRepository
|
|||||||
import io.github.wulkanowy.services.sync.channels.LuckyNumberChannel
|
import io.github.wulkanowy.services.sync.channels.LuckyNumberChannel
|
||||||
import io.github.wulkanowy.ui.modules.main.MainActivity
|
import io.github.wulkanowy.ui.modules.main.MainActivity
|
||||||
import io.github.wulkanowy.ui.modules.main.MainView
|
import io.github.wulkanowy.ui.modules.main.MainView
|
||||||
|
import io.github.wulkanowy.utils.getCompatBitmap
|
||||||
import io.github.wulkanowy.utils.getCompatColor
|
import io.github.wulkanowy.utils.getCompatColor
|
||||||
import io.github.wulkanowy.utils.waitForResult
|
import io.github.wulkanowy.utils.waitForResult
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
@ -42,7 +43,10 @@ class LuckyNumberWork @Inject constructor(
|
|||||||
notificationManager.notify(Random.nextInt(Int.MAX_VALUE), NotificationCompat.Builder(context, LuckyNumberChannel.CHANNEL_ID)
|
notificationManager.notify(Random.nextInt(Int.MAX_VALUE), NotificationCompat.Builder(context, LuckyNumberChannel.CHANNEL_ID)
|
||||||
.setContentTitle(context.getString(R.string.lucky_number_notify_new_item_title))
|
.setContentTitle(context.getString(R.string.lucky_number_notify_new_item_title))
|
||||||
.setContentText(context.getString(R.string.lucky_number_notify_new_item, luckyNumber.luckyNumber))
|
.setContentText(context.getString(R.string.lucky_number_notify_new_item, luckyNumber.luckyNumber))
|
||||||
.setSmallIcon(R.drawable.ic_stat_luckynumber)
|
.setSmallIcon(R.drawable.ic_stat_all)
|
||||||
|
.setLargeIcon(
|
||||||
|
context.getCompatBitmap(R.drawable.ic_stat_luckynumber, R.color.colorPrimary)
|
||||||
|
)
|
||||||
.setAutoCancel(true)
|
.setAutoCancel(true)
|
||||||
.setDefaults(DEFAULT_ALL)
|
.setDefaults(DEFAULT_ALL)
|
||||||
.setPriority(PRIORITY_HIGH)
|
.setPriority(PRIORITY_HIGH)
|
||||||
|
@ -18,6 +18,7 @@ import io.github.wulkanowy.data.repositories.PreferencesRepository
|
|||||||
import io.github.wulkanowy.services.sync.channels.NewMessagesChannel
|
import io.github.wulkanowy.services.sync.channels.NewMessagesChannel
|
||||||
import io.github.wulkanowy.ui.modules.main.MainActivity
|
import io.github.wulkanowy.ui.modules.main.MainActivity
|
||||||
import io.github.wulkanowy.ui.modules.main.MainView
|
import io.github.wulkanowy.ui.modules.main.MainView
|
||||||
|
import io.github.wulkanowy.utils.getCompatBitmap
|
||||||
import io.github.wulkanowy.utils.getCompatColor
|
import io.github.wulkanowy.utils.getCompatColor
|
||||||
import io.github.wulkanowy.utils.waitForResult
|
import io.github.wulkanowy.utils.waitForResult
|
||||||
import kotlinx.coroutines.flow.first
|
import kotlinx.coroutines.flow.first
|
||||||
@ -44,7 +45,10 @@ class MessageWork @Inject constructor(
|
|||||||
notificationManager.notify(Random.nextInt(Int.MAX_VALUE), NotificationCompat.Builder(context, NewMessagesChannel.CHANNEL_ID)
|
notificationManager.notify(Random.nextInt(Int.MAX_VALUE), NotificationCompat.Builder(context, NewMessagesChannel.CHANNEL_ID)
|
||||||
.setContentTitle(context.resources.getQuantityString(R.plurals.message_new_items, messages.size, messages.size))
|
.setContentTitle(context.resources.getQuantityString(R.plurals.message_new_items, messages.size, messages.size))
|
||||||
.setContentText(context.resources.getQuantityString(R.plurals.message_notify_new_items, messages.size, messages.size))
|
.setContentText(context.resources.getQuantityString(R.plurals.message_notify_new_items, messages.size, messages.size))
|
||||||
.setSmallIcon(R.drawable.ic_stat_message)
|
.setSmallIcon(R.drawable.ic_stat_all)
|
||||||
|
.setLargeIcon(
|
||||||
|
context.getCompatBitmap(R.drawable.ic_stat_message, R.color.colorPrimary)
|
||||||
|
)
|
||||||
.setAutoCancel(true)
|
.setAutoCancel(true)
|
||||||
.setDefaults(DEFAULT_ALL)
|
.setDefaults(DEFAULT_ALL)
|
||||||
.setPriority(PRIORITY_HIGH)
|
.setPriority(PRIORITY_HIGH)
|
||||||
|
@ -20,6 +20,7 @@ import io.github.wulkanowy.sdk.scrapper.notes.NoteCategory.POSITIVE
|
|||||||
import io.github.wulkanowy.services.sync.channels.NewNotesChannel
|
import io.github.wulkanowy.services.sync.channels.NewNotesChannel
|
||||||
import io.github.wulkanowy.ui.modules.main.MainActivity
|
import io.github.wulkanowy.ui.modules.main.MainActivity
|
||||||
import io.github.wulkanowy.ui.modules.main.MainView
|
import io.github.wulkanowy.ui.modules.main.MainView
|
||||||
|
import io.github.wulkanowy.utils.getCompatBitmap
|
||||||
import io.github.wulkanowy.utils.getCompatColor
|
import io.github.wulkanowy.utils.getCompatColor
|
||||||
import io.github.wulkanowy.utils.waitForResult
|
import io.github.wulkanowy.utils.waitForResult
|
||||||
import kotlinx.coroutines.flow.first
|
import kotlinx.coroutines.flow.first
|
||||||
@ -58,7 +59,10 @@ class NoteWork @Inject constructor(
|
|||||||
else -> context.resources.getQuantityString(R.plurals.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)
|
.setSmallIcon(R.drawable.ic_stat_all)
|
||||||
|
.setLargeIcon(
|
||||||
|
context.getCompatBitmap(R.drawable.ic_stat_note, R.color.colorPrimary)
|
||||||
|
)
|
||||||
.setAutoCancel(true)
|
.setAutoCancel(true)
|
||||||
.setDefaults(DEFAULT_ALL)
|
.setDefaults(DEFAULT_ALL)
|
||||||
.setPriority(PRIORITY_HIGH)
|
.setPriority(PRIORITY_HIGH)
|
||||||
|
@ -21,10 +21,6 @@ import io.github.wulkanowy.utils.openInternetBrowser
|
|||||||
import io.github.wulkanowy.utils.toFormattedString
|
import io.github.wulkanowy.utils.toFormattedString
|
||||||
import io.github.wulkanowy.utils.toLocalDateTime
|
import io.github.wulkanowy.utils.toLocalDateTime
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import android.content.Intent
|
|
||||||
import android.net.Uri
|
|
||||||
import android.provider.Settings
|
|
||||||
import android.util.Log
|
|
||||||
|
|
||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
class AboutFragment : BaseFragment<FragmentAboutBinding>(R.layout.fragment_about), AboutView,
|
class AboutFragment : BaseFragment<FragmentAboutBinding>(R.layout.fragment_about), AboutView,
|
||||||
|
@ -6,6 +6,8 @@ import android.content.Intent
|
|||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import android.graphics.Paint
|
import android.graphics.Paint
|
||||||
|
import android.graphics.PorterDuff
|
||||||
|
import android.graphics.PorterDuffColorFilter
|
||||||
import android.graphics.Rect
|
import android.graphics.Rect
|
||||||
import android.graphics.Typeface
|
import android.graphics.Typeface
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
@ -20,6 +22,7 @@ import androidx.core.graphics.ColorUtils
|
|||||||
import androidx.core.graphics.applyCanvas
|
import androidx.core.graphics.applyCanvas
|
||||||
import androidx.core.graphics.drawable.RoundedBitmapDrawable
|
import androidx.core.graphics.drawable.RoundedBitmapDrawable
|
||||||
import androidx.core.graphics.drawable.RoundedBitmapDrawableFactory
|
import androidx.core.graphics.drawable.RoundedBitmapDrawableFactory
|
||||||
|
import androidx.core.graphics.drawable.toBitmap
|
||||||
import io.github.wulkanowy.BuildConfig.APPLICATION_ID
|
import io.github.wulkanowy.BuildConfig.APPLICATION_ID
|
||||||
|
|
||||||
@ColorInt
|
@ColorInt
|
||||||
@ -43,6 +46,16 @@ fun Context.getCompatColor(@ColorRes colorRes: Int) = ContextCompat.getColor(thi
|
|||||||
fun Context.getCompatDrawable(@DrawableRes drawableRes: Int) =
|
fun Context.getCompatDrawable(@DrawableRes drawableRes: Int) =
|
||||||
ContextCompat.getDrawable(this, drawableRes)
|
ContextCompat.getDrawable(this, drawableRes)
|
||||||
|
|
||||||
|
fun Context.getCompatDrawable(@DrawableRes drawableRes: Int, @ColorRes colorRes: Int) =
|
||||||
|
getCompatDrawable(drawableRes)?.mutate()?.apply {
|
||||||
|
colorFilter = PorterDuffColorFilter(
|
||||||
|
getCompatColor(colorRes), PorterDuff.Mode.MULTIPLY
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Context.getCompatBitmap(@DrawableRes drawableRes: Int, @ColorRes colorRes: Int) =
|
||||||
|
getCompatDrawable(drawableRes, colorRes)?.toBitmap()
|
||||||
|
|
||||||
fun Context.openInternetBrowser(uri: String, onActivityNotFound: (uri: String) -> Unit) {
|
fun Context.openInternetBrowser(uri: String, onActivityNotFound: (uri: String) -> Unit) {
|
||||||
Intent.parseUri(uri, 0).let {
|
Intent.parseUri(uri, 0).let {
|
||||||
if (it.resolveActivity(packageManager) != null) startActivity(it)
|
if (it.resolveActivity(packageManager) != null) startActivity(it)
|
||||||
|
Before Width: | Height: | Size: 724 B After Width: | Height: | Size: 724 B |
Before Width: | Height: | Size: 470 B After Width: | Height: | Size: 470 B |
Before Width: | Height: | Size: 955 B After Width: | Height: | Size: 955 B |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |