Skip to content
This repository has been archived by the owner on Oct 28, 2024. It is now read-only.

Custom icons for different types of notifications. #178

Merged
merged 6 commits into from
Dec 21, 2022
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 @@ -137,13 +137,20 @@ private void notify(Context context, PushNotification pn, String accountID, org.
builder.setContentTitle(pn.title)
.setContentText(pn.body)
.setStyle(new Notification.BigTextStyle().bigText(pn.body))
.setSmallIcon(R.drawable.ic_ntf_logo)
.setContentIntent(PendingIntent.getActivity(context, accountID.hashCode() & 0xFFFF, contentIntent, PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_UPDATE_CURRENT))
.setWhen(notification==null ? System.currentTimeMillis() : notification.createdAt.toEpochMilli())
.setShowWhen(true)
.setCategory(Notification.CATEGORY_SOCIAL)
.setAutoCancel(true)
.setColor(context.getColor(R.color.primary_700));
switch (pn.notificationType) {
case FAVORITE -> builder.setSmallIcon(R.drawable.ic_fluent_star_24_filled);
case REBLOG -> builder.setSmallIcon(R.drawable.ic_fluent_arrow_repeat_all_24_filled);
case FOLLOW -> builder.setSmallIcon(R.drawable.ic_fluent_person_add_24_filled);
case MENTION -> builder.setSmallIcon(R.drawable.ic_fluent_mention_24_filled);
case POLL -> builder.setSmallIcon(R.drawable.ic_fluent_poll_24_filled);
default -> builder.setSmallIcon(R.drawable.ic_ntf_logo);
}
if(avatar!=null){
builder.setLargeIcon(UiUtils.getBitmapFromDrawable(avatar));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M12,2c5.43,0 9.848,4.327 9.996,9.72L22,12v1.525a4,4 0,0 1,-7.415 2.06c-0.8,0.833 -1.882,1.348 -3.085,1.348 -2.515,0 -4.5,-2.25 -4.5,-4.966C7,9.25 8.985,7 11.5,7c0.937,0 1.8,0.312 2.514,0.844a1,1 0,0 1,1.98 0.04L16,8v5.5a2,2 0,0 0,3.994 0.15l0.006,-0.175L20,12a8,8 0,1 0,-8 8c0.921,0 1.82,-0.155 2.67,-0.456a1,1 0,1 1,0.667 1.886A9.985,9.985 0,0 1,12 22C6.477,22 2,17.523 2,12S6.477,2 12,2ZM11.65,9.005L11.5,9C10.15,9 9,10.302 9,11.967c0,1.664 1.15,2.966 2.5,2.966 1.3,0 2.415,-1.207 2.495,-2.783l0.005,-0.22c-0.017,-1.586 -1.075,-2.834 -2.35,-2.925L11.5,9l0.15,0.005Z"
android:fillColor="#212121"/>
</vector>
12 changes: 12 additions & 0 deletions mastodon/src/main/res/drawable/ic_fluent_person_add_24_filled.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M11,17.5a6.47,6.47 0,0 1,1.023 -3.5h-7.77a2.249,2.249 0,0 0,-2.25 2.25v0.919c0,0.572 0.18,1.13 0.511,1.596C4.056,20.929 6.58,22 10,22c0.932,0 1.797,-0.08 2.592,-0.24A6.475,6.475 0,0 1,11 17.502ZM15,7.005a5,5 0,1 0,-10 0,5 5,0 0,0 10,0Z"
android:fillColor="#212121"/>
<path
android:pathData="M23,17.5a5.5,5.5 0,1 0,-11 0,5.5 5.5,0 0,0 11,0ZM17.41,14.008L17.5,14l0.09,0.008a0.5,0.5 0,0 1,0.402 0.402l0.008,0.09L18,17h2.504l0.09,0.008a0.5,0.5 0,0 1,0.402 0.402l0.008,0.09 -0.008,0.09a0.5,0.5 0,0 1,-0.402 0.402l-0.09,0.008L18,18L18,20.5l-0.008,0.09a0.5,0.5 0,0 1,-0.402 0.402L17.5,21l-0.09,-0.008a0.5,0.5 0,0 1,-0.402 -0.402L17,20.5L17,18h-2.496l-0.09,-0.008a0.5,0.5 0,0 1,-0.402 -0.402l-0.008,-0.09 0.008,-0.09a0.5,0.5 0,0 1,0.402 -0.402l0.09,-0.008L17,17L17,14.5l0.008,-0.09a0.5,0.5 0,0 1,0.402 -0.402Z"
android:fillColor="#212121"/>
</vector>