mirror of
https://github.com/szkolny-eu/szkolny-android.git
synced 2025-01-18 21:06:44 -06:00
[UI] Add notification icons. (#23)
* Add notification icons * Change color of icons * [Notifications] Update icon colors. * [Notifications] Update lucky number icon. * Add icons to Notifications List Fragment * Update notifications_list_item.xml * Move the gravity to the LinearLayout * add paddingLeft * Change IconicsImageView to View. * Rearrange XML attributes. Co-authored-by: Kuba Szczodrzyński <kuba@szczodrzynski.pl>
This commit is contained in:
parent
ccf0bdaf05
commit
634ef16bc5
@ -8,6 +8,9 @@ import android.util.SparseIntArray
|
|||||||
import androidx.core.app.NotificationCompat
|
import androidx.core.app.NotificationCompat
|
||||||
import androidx.core.util.forEach
|
import androidx.core.util.forEach
|
||||||
import androidx.core.util.set
|
import androidx.core.util.set
|
||||||
|
import com.mikepenz.iconics.IconicsDrawable
|
||||||
|
import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial
|
||||||
|
import com.mikepenz.iconics.utils.*
|
||||||
import pl.szczodrzynski.edziennik.*
|
import pl.szczodrzynski.edziennik.*
|
||||||
import pl.szczodrzynski.edziennik.data.db.entity.Notification.Companion.TYPE_SERVER_MESSAGE
|
import pl.szczodrzynski.edziennik.data.db.entity.Notification.Companion.TYPE_SERVER_MESSAGE
|
||||||
import pl.szczodrzynski.edziennik.utils.models.Time
|
import pl.szczodrzynski.edziennik.utils.models.Time
|
||||||
@ -107,6 +110,10 @@ class PostNotifications(val app: App, nList: List<AppNotification>) {
|
|||||||
.setContentText(buildSummaryText(summaryCounts))
|
.setContentText(buildSummaryText(summaryCounts))
|
||||||
.setTicker(newNotificationsText)
|
.setTicker(newNotificationsText)
|
||||||
.setSmallIcon(R.drawable.ic_notification)
|
.setSmallIcon(R.drawable.ic_notification)
|
||||||
|
.setLargeIcon(IconicsDrawable(app).apply {
|
||||||
|
icon = CommunityMaterial.Icon.cmd_bell_ring_outline
|
||||||
|
colorRes = R.color.colorPrimary
|
||||||
|
}.toBitmap())
|
||||||
.setStyle(NotificationCompat.InboxStyle()
|
.setStyle(NotificationCompat.InboxStyle()
|
||||||
.also {
|
.also {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||||
@ -137,6 +144,9 @@ class PostNotifications(val app: App, nList: List<AppNotification>) {
|
|||||||
.setSubText(if (it.type == TYPE_SERVER_MESSAGE) null else it.title)
|
.setSubText(if (it.type == TYPE_SERVER_MESSAGE) null else it.title)
|
||||||
.setTicker("${it.profileName}: ${it.title}")
|
.setTicker("${it.profileName}: ${it.title}")
|
||||||
.setSmallIcon(R.drawable.ic_notification)
|
.setSmallIcon(R.drawable.ic_notification)
|
||||||
|
.setLargeIcon(IconicsDrawable(app, it.getLargeIcon()).apply {
|
||||||
|
colorRes = R.color.colorPrimary
|
||||||
|
}.toBitmap())
|
||||||
.setStyle(NotificationCompat.BigTextStyle()
|
.setStyle(NotificationCompat.BigTextStyle()
|
||||||
.bigText(it.text))
|
.bigText(it.text))
|
||||||
.setWhen(it.addedDate)
|
.setWhen(it.addedDate)
|
||||||
@ -160,6 +170,10 @@ class PostNotifications(val app: App, nList: List<AppNotification>) {
|
|||||||
.setContentText(buildSummaryText(summaryCounts))
|
.setContentText(buildSummaryText(summaryCounts))
|
||||||
.setTicker(newNotificationsText)
|
.setTicker(newNotificationsText)
|
||||||
.setSmallIcon(R.drawable.ic_notification)
|
.setSmallIcon(R.drawable.ic_notification)
|
||||||
|
.setLargeIcon(IconicsDrawable(app).apply {
|
||||||
|
icon = CommunityMaterial.Icon.cmd_bell_ring_outline
|
||||||
|
colorRes = R.color.colorPrimary
|
||||||
|
}.toBitmap())
|
||||||
.addDefaults()
|
.addDefaults()
|
||||||
.setGroupSummary(true)
|
.setGroupSummary(true)
|
||||||
.setContentIntent(summaryIntent)
|
.setContentIntent(summaryIntent)
|
||||||
|
@ -10,6 +10,8 @@ import android.content.Intent
|
|||||||
import androidx.room.Entity
|
import androidx.room.Entity
|
||||||
import androidx.room.PrimaryKey
|
import androidx.room.PrimaryKey
|
||||||
import com.google.gson.JsonObject
|
import com.google.gson.JsonObject
|
||||||
|
import com.mikepenz.iconics.typeface.IIcon
|
||||||
|
import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial
|
||||||
import pl.szczodrzynski.edziennik.MainActivity
|
import pl.szczodrzynski.edziennik.MainActivity
|
||||||
|
|
||||||
@Entity(tableName = "notifications")
|
@Entity(tableName = "notifications")
|
||||||
@ -96,4 +98,19 @@ data class Notification(
|
|||||||
fillIntent(intent)
|
fillIntent(intent)
|
||||||
return PendingIntent.getActivity(context, id.toInt(), intent, PendingIntent.FLAG_ONE_SHOT)
|
return PendingIntent.getActivity(context, id.toInt(), intent, PendingIntent.FLAG_ONE_SHOT)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getLargeIcon(): IIcon = when (type) {
|
||||||
|
TYPE_TIMETABLE_LESSON_CHANGE -> CommunityMaterial.Icon3.cmd_timetable
|
||||||
|
TYPE_NEW_GRADE -> CommunityMaterial.Icon3.cmd_numeric_5_box_outline
|
||||||
|
TYPE_NEW_EVENT -> CommunityMaterial.Icon.cmd_calendar_outline
|
||||||
|
TYPE_NEW_HOMEWORK -> CommunityMaterial.Icon3.cmd_notebook_outline
|
||||||
|
TYPE_NEW_SHARED_EVENT -> CommunityMaterial.Icon.cmd_calendar_outline
|
||||||
|
TYPE_NEW_SHARED_HOMEWORK -> CommunityMaterial.Icon3.cmd_notebook_outline
|
||||||
|
TYPE_NEW_MESSAGE -> CommunityMaterial.Icon.cmd_email_outline
|
||||||
|
TYPE_NEW_NOTICE -> CommunityMaterial.Icon.cmd_emoticon_outline
|
||||||
|
TYPE_NEW_ATTENDANCE -> CommunityMaterial.Icon.cmd_calendar_remove_outline
|
||||||
|
TYPE_LUCKY_NUMBER -> CommunityMaterial.Icon.cmd_emoticon_excited_outline
|
||||||
|
TYPE_NEW_ANNOUNCEMENT -> CommunityMaterial.Icon.cmd_bullhorn_outline
|
||||||
|
else -> CommunityMaterial.Icon.cmd_bell_ring_outline
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,8 @@ import android.view.LayoutInflater
|
|||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import com.mikepenz.iconics.IconicsDrawable
|
||||||
|
import com.mikepenz.iconics.utils.colorRes
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.Job
|
import kotlinx.coroutines.Job
|
||||||
@ -43,6 +45,10 @@ class NotificationsAdapter(
|
|||||||
val date = Date.fromMillis(item.addedDate).formattedString
|
val date = Date.fromMillis(item.addedDate).formattedString
|
||||||
val colorSecondary = android.R.attr.textColorSecondary.resolveAttr(activity)
|
val colorSecondary = android.R.attr.textColorSecondary.resolveAttr(activity)
|
||||||
|
|
||||||
|
b.notificationIcon.background = IconicsDrawable(app, item.getLargeIcon()).apply {
|
||||||
|
colorRes = R.color.colorPrimary
|
||||||
|
}
|
||||||
|
|
||||||
b.title.text = item.text
|
b.title.text = item.text
|
||||||
b.profileDate.text = listOf(
|
b.profileDate.text = listOf(
|
||||||
item.profileName ?: "",
|
item.profileName ?: "",
|
||||||
|
@ -9,12 +9,28 @@
|
|||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:padding="8dp">
|
android:padding="8dp">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/notificationIcon"
|
||||||
|
android:layout_width="24dp"
|
||||||
|
android:layout_height="24dp"
|
||||||
|
android:scaleType="centerInside"
|
||||||
|
tools:background="@android:drawable/ic_menu_more" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/title"
|
android:id="@+id/title"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingStart="8dp"
|
||||||
|
android:paddingLeft="8dp"
|
||||||
android:textAppearance="@style/NavView.TextView.Medium"
|
android:textAppearance="@style/NavView.TextView.Medium"
|
||||||
tools:text="Dzisiaj 1 to szczęśliwy numerek" />
|
tools:text="Dzisiaj 1 to szczęśliwy numerek" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user