diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 3b6b9e66..a331c41f 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -168,7 +168,7 @@
+ android:resource="@drawable/ic_stat_all" />
) {
notificationManager.notify(Random.nextInt(Int.MAX_VALUE), getNotificationBuilder()
.setContentTitle(context.resources.getQuantityString(R.plurals.grade_new_items, grades.size, grades.size))
@@ -100,4 +89,23 @@ class GradeWork @Inject constructor(
.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
+ )
+ )
+ }
}
diff --git a/app/src/main/java/io/github/wulkanowy/services/sync/works/HomeworkWork.kt b/app/src/main/java/io/github/wulkanowy/services/sync/works/HomeworkWork.kt
index d0729cf7..a2fed98d 100644
--- a/app/src/main/java/io/github/wulkanowy/services/sync/works/HomeworkWork.kt
+++ b/app/src/main/java/io/github/wulkanowy/services/sync/works/HomeworkWork.kt
@@ -14,6 +14,7 @@ import io.github.wulkanowy.data.repositories.PreferencesRepository
import io.github.wulkanowy.services.sync.channels.NewHomeworkChannel
import io.github.wulkanowy.ui.modules.main.MainActivity
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.monday
import io.github.wulkanowy.utils.sunday
@@ -56,12 +57,13 @@ class HomeworkWork @Inject constructor(
NotificationCompat.Builder(context, NewHomeworkChannel.CHANNEL_ID)
.setContentTitle(
context.resources.getQuantityString(
- R.plurals.homework_notify_new_item_title,
- homework.size,
- homework.size
+ R.plurals.homework_notify_new_item_title, 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)
.setDefaults(NotificationCompat.DEFAULT_ALL)
.setPriority(NotificationCompat.PRIORITY_HIGH)
@@ -76,9 +78,7 @@ class HomeworkWork @Inject constructor(
.setStyle(NotificationCompat.InboxStyle().run {
setSummaryText(
context.resources.getQuantityString(
- R.plurals.homework_number_item,
- homework.size,
- homework.size
+ R.plurals.homework_number_item, homework.size, homework.size
)
)
homework.forEach { addLine("${it.subject}: ${it.content}") }
diff --git a/app/src/main/java/io/github/wulkanowy/services/sync/works/LuckyNumberWork.kt b/app/src/main/java/io/github/wulkanowy/services/sync/works/LuckyNumberWork.kt
index 9f536553..6ae32abf 100644
--- a/app/src/main/java/io/github/wulkanowy/services/sync/works/LuckyNumberWork.kt
+++ b/app/src/main/java/io/github/wulkanowy/services/sync/works/LuckyNumberWork.kt
@@ -17,6 +17,7 @@ import io.github.wulkanowy.data.repositories.PreferencesRepository
import io.github.wulkanowy.services.sync.channels.LuckyNumberChannel
import io.github.wulkanowy.ui.modules.main.MainActivity
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.waitForResult
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)
.setContentTitle(context.getString(R.string.lucky_number_notify_new_item_title))
.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)
.setDefaults(DEFAULT_ALL)
.setPriority(PRIORITY_HIGH)
diff --git a/app/src/main/java/io/github/wulkanowy/services/sync/works/MessageWork.kt b/app/src/main/java/io/github/wulkanowy/services/sync/works/MessageWork.kt
index 93c30b57..011e0c3f 100644
--- a/app/src/main/java/io/github/wulkanowy/services/sync/works/MessageWork.kt
+++ b/app/src/main/java/io/github/wulkanowy/services/sync/works/MessageWork.kt
@@ -18,6 +18,7 @@ import io.github.wulkanowy.data.repositories.PreferencesRepository
import io.github.wulkanowy.services.sync.channels.NewMessagesChannel
import io.github.wulkanowy.ui.modules.main.MainActivity
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.waitForResult
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)
.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))
- .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)
.setDefaults(DEFAULT_ALL)
.setPriority(PRIORITY_HIGH)
diff --git a/app/src/main/java/io/github/wulkanowy/services/sync/works/NoteWork.kt b/app/src/main/java/io/github/wulkanowy/services/sync/works/NoteWork.kt
index 50f418ed..34e1610e 100644
--- a/app/src/main/java/io/github/wulkanowy/services/sync/works/NoteWork.kt
+++ b/app/src/main/java/io/github/wulkanowy/services/sync/works/NoteWork.kt
@@ -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.ui.modules.main.MainActivity
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.waitForResult
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)
}
)
- .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)
.setDefaults(DEFAULT_ALL)
.setPriority(PRIORITY_HIGH)
diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/about/AboutFragment.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/about/AboutFragment.kt
index badf78fd..1c613800 100644
--- a/app/src/main/java/io/github/wulkanowy/ui/modules/about/AboutFragment.kt
+++ b/app/src/main/java/io/github/wulkanowy/ui/modules/about/AboutFragment.kt
@@ -21,10 +21,6 @@ import io.github.wulkanowy.utils.openInternetBrowser
import io.github.wulkanowy.utils.toFormattedString
import io.github.wulkanowy.utils.toLocalDateTime
import javax.inject.Inject
-import android.content.Intent
-import android.net.Uri
-import android.provider.Settings
-import android.util.Log
@AndroidEntryPoint
class AboutFragment : BaseFragment(R.layout.fragment_about), AboutView,
diff --git a/app/src/main/java/io/github/wulkanowy/utils/ContextExtension.kt b/app/src/main/java/io/github/wulkanowy/utils/ContextExtension.kt
index 92c0ddfc..f7f56034 100644
--- a/app/src/main/java/io/github/wulkanowy/utils/ContextExtension.kt
+++ b/app/src/main/java/io/github/wulkanowy/utils/ContextExtension.kt
@@ -6,6 +6,8 @@ import android.content.Intent
import android.graphics.Bitmap
import android.graphics.Color
import android.graphics.Paint
+import android.graphics.PorterDuff
+import android.graphics.PorterDuffColorFilter
import android.graphics.Rect
import android.graphics.Typeface
import android.net.Uri
@@ -20,6 +22,7 @@ import androidx.core.graphics.ColorUtils
import androidx.core.graphics.applyCanvas
import androidx.core.graphics.drawable.RoundedBitmapDrawable
import androidx.core.graphics.drawable.RoundedBitmapDrawableFactory
+import androidx.core.graphics.drawable.toBitmap
import io.github.wulkanowy.BuildConfig.APPLICATION_ID
@ColorInt
@@ -43,6 +46,16 @@ fun Context.getCompatColor(@ColorRes colorRes: Int) = ContextCompat.getColor(thi
fun Context.getCompatDrawable(@DrawableRes drawableRes: Int) =
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) {
Intent.parseUri(uri, 0).let {
if (it.resolveActivity(packageManager) != null) startActivity(it)
diff --git a/app/src/main/res/drawable-hdpi/ic_stat_push.png b/app/src/main/res/drawable-hdpi/ic_stat_all.png
similarity index 100%
rename from app/src/main/res/drawable-hdpi/ic_stat_push.png
rename to app/src/main/res/drawable-hdpi/ic_stat_all.png
diff --git a/app/src/main/res/drawable-mdpi/ic_stat_push.png b/app/src/main/res/drawable-mdpi/ic_stat_all.png
similarity index 100%
rename from app/src/main/res/drawable-mdpi/ic_stat_push.png
rename to app/src/main/res/drawable-mdpi/ic_stat_all.png
diff --git a/app/src/main/res/drawable-xhdpi/ic_stat_push.png b/app/src/main/res/drawable-xhdpi/ic_stat_all.png
similarity index 100%
rename from app/src/main/res/drawable-xhdpi/ic_stat_push.png
rename to app/src/main/res/drawable-xhdpi/ic_stat_all.png
diff --git a/app/src/main/res/drawable-xxhdpi/ic_stat_push.png b/app/src/main/res/drawable-xxhdpi/ic_stat_all.png
similarity index 100%
rename from app/src/main/res/drawable-xxhdpi/ic_stat_push.png
rename to app/src/main/res/drawable-xxhdpi/ic_stat_all.png
diff --git a/app/src/main/res/drawable-xxxhdpi/ic_stat_push.png b/app/src/main/res/drawable-xxxhdpi/ic_stat_all.png
similarity index 100%
rename from app/src/main/res/drawable-xxxhdpi/ic_stat_push.png
rename to app/src/main/res/drawable-xxxhdpi/ic_stat_all.png