Skip to content

Commit 4702bbf

Browse files
committed
Adaptive icon, notification budge
1 parent 8b3aab8 commit 4702bbf

29 files changed

+19
-9
lines changed

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
def final VERSION_CODE = 5
2-
def final VERSION_NAME = '1.0.0-alpha5'
1+
def final VERSION_CODE = 6
2+
def final VERSION_NAME = '1.0.0-beta1'
33

44
apply plugin: 'com.android.application'
55
apply plugin: 'kotlin-android'
-5.68 KB
Binary file not shown.
-3.39 KB
Binary file not shown.
-8.24 KB
Binary file not shown.
-14.6 KB
Binary file not shown.
-22.3 KB
Binary file not shown.

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
android:fullBackupContent="@xml/backup_descriptor"
2121
android:icon="@mipmap/ic_launcher"
2222
android:label="@string/app_name"
23+
android:roundIcon="@mipmap/ic_launcher_round"
2324
android:supportsRtl="true"
2425
android:theme="@style/AppTheme"
2526
tools:replace="android:allowBackup">

app/src/main/kotlin/com/glodanif/bluetoothchat/view/NotificationViewImpl.kt

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,10 @@ class NotificationViewImpl(private val context: Context) : NotificationView {
3939
notificationManager.createNotificationChannel(channel)
4040
}
4141

42-
val icon = BitmapFactory.decodeResource(resources, R.mipmap.ic_launcher)
4342
val builder = NotificationCompat.Builder(context, CHANNEL_FOREGROUND)
4443
.setContentTitle(context.getString(R.string.app_name))
4544
.setContentText(message)
4645
.setSmallIcon(R.drawable.ic_notification)
47-
.setLargeIcon(Bitmap.createScaledBitmap(icon, 128, 128, false))
4846
.setContentIntent(pendingIntent)
4947
.setOngoing(true)
5048
.setPriority(Notification.PRIORITY_LOW)
@@ -64,11 +62,11 @@ class NotificationViewImpl(private val context: Context) : NotificationView {
6462
notificationIntent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
6563
val pendingIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0)
6664

67-
val icon = BitmapFactory.decodeResource(resources, R.mipmap.ic_launcher)
6865
val name = if (displayName.isNullOrEmpty()) deviceName else "$displayName ($deviceName)"
6966

7067
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
7168
val channel = NotificationChannel(CHANNEL_MESSAGE, context.getString(R.string.notification__channel_message), NotificationManager.IMPORTANCE_MAX)
69+
channel.setShowBadge(true)
7270
notificationManager.createNotificationChannel(channel)
7371
}
7472

@@ -77,7 +75,6 @@ class NotificationViewImpl(private val context: Context) : NotificationView {
7775
.setContentText(message)
7876
.setLights(Color.BLUE, 3000, 3000)
7977
.setSmallIcon(R.drawable.ic_new_message)
80-
.setLargeIcon(Bitmap.createScaledBitmap(icon, 128, 128, false))
8178
.setContentIntent(pendingIntent)
8279
.setAutoCancel(true)
8380
.setPriority(Notification.PRIORITY_MAX)
@@ -107,17 +104,15 @@ class NotificationViewImpl(private val context: Context) : NotificationView {
107104

108105
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
109106
val channel = NotificationChannel(CHANNEL_REQUEST, context.getString(R.string.notification__channel_request), NotificationManager.IMPORTANCE_MAX)
107+
channel.setShowBadge(true)
110108
notificationManager.createNotificationChannel(channel)
111109
}
112110

113-
val icon = BitmapFactory.decodeResource(resources, R.mipmap.ic_launcher)
114-
115111
val builder = NotificationCompat.Builder(context, CHANNEL_REQUEST)
116112
.setContentTitle(context.getString(R.string.notification__connection_request))
117113
.setContentText(context.getString(R.string.notification__connection_request_body, deviceName))
118114
.setLights(Color.BLUE, 3000, 3000)
119115
.setSmallIcon(R.drawable.ic_connection_request)
120-
.setLargeIcon(Bitmap.createScaledBitmap(icon, 128, 128, false))
121116
.setContentIntent(pendingIntent)
122117
.setAutoCancel(true)
123118
.setPriority(Notification.PRIORITY_MAX)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
3+
<background android:drawable="@color/ic_launcher_background"/>
4+
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
5+
</adaptive-icon>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
3+
<background android:drawable="@color/ic_launcher_background"/>
4+
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
5+
</adaptive-icon>

0 commit comments

Comments
 (0)