Commit 56ddc3d9 authored by Vladislav Bogdashkin's avatar Vladislav Bogdashkin 🎣

Merge branch 'feature/icons_and_notyes' into develop

parents fa9765ed e26e797b
package com.biganto.visual.roompark.data
import com.biganto.visual.roompark.base.RoomParkApplication
import com.biganto.visual.roompark.data.service.notification.INotificationCenter
import com.google.firebase.messaging.FirebaseMessagingService
import com.google.firebase.messaging.RemoteMessage
import timber.log.Timber
import javax.inject.Inject
class RoomParkMessageService : FirebaseMessagingService() {
@Inject
lateinit var notyCenter: INotificationCenter
init {
notyCenter = RoomParkApplication.component.provideNotifivations()
}
override fun onNewToken(p0: String) {
super.onNewToken(p0)
Timber.d("NEW TOKEN REGISTERED: ${p0}")
......@@ -19,6 +30,7 @@ class RoomParkMessageService : FirebaseMessagingService() {
// Check if message contains a data payload.
if (remoteMessage.data.size > 0) {
Timber.d("Message data payload: %s", remoteMessage.data)
if ( /* Check if data needs to be processed by long running job */true) { // For long-running tasks (10 seconds or more) use Firebase Job Dispatcher.
// scheduleJob()
} else { // Handle message within 10 seconds
......@@ -27,7 +39,8 @@ class RoomParkMessageService : FirebaseMessagingService() {
}
// Check if message contains a notification payload.
if (remoteMessage.notification != null) {
Timber.d("Message Notification Body: %s", remoteMessage.notification!!.body)
Timber.d("Message Notification Body: %s", remoteMessage.notification?.body)
notyCenter.showPushNotifyMessage(remoteMessage.notification?.body?:"Уведомление")
}
// Also if you intend on generating your own notifications as a result of a received FCM
// message, here is where that should be initiated. See sendNotification method below.
......
......@@ -22,8 +22,11 @@ import javax.inject.Singleton
const val ANDROID_CHANNEL_ID = "com.biganto.visual.androidplayer.data.services.downloader.DownloadManagerService.CHANNEL_ID"
const val TOURS_CHANNEL_ID = "com.biganto.visual.androidplayer.data.services.downloader.DownloadManagerService.TOURS_CHANNEL_ID"
const val DOWNLOAD_SERVICE_ID = 7897
const val TOUR_INFO_SERVICE_ID = 7899
const val PUSH_CHANNEL_ID = "com.biganto.visual.androidplayer.data.services.downloader.DownloadManagerService.PUSH_CHANNEL_ID"
const val DOWNLOAD_SERVICE_ID = 7990
const val TOUR_INFO_SERVICE_ID = 7991
const val PUSH_INFO_SERVICE_ID = 7992
const val NOTIFICATION_INTENT="NOTIFICATION_INTENT_KEY"
const val NOTIFICATION_START_SCREEN="NOTIFICATION_START_SCREEN_KEY"
......@@ -48,6 +51,9 @@ interface INotificationCenter{
,progressMax:Int=0
,indeterminate:Boolean=true
,message: String)
val IncomingPushServiceNotification: Notification
fun showPushNotifyMessage(message: String)
}
......@@ -64,11 +70,13 @@ class NotificationCenter @Inject constructor(val context: Application) : INotif
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
createNotificationChannel()
createToursNotificationChannel()
createPushNotificationChannel()
}
}
private val builder = NotificationCompat.Builder(context, ANDROID_CHANNEL_ID)
private val toursNotyBuilder = NotificationCompat.Builder(context, TOURS_CHANNEL_ID)
private val pushNotyBuilder = NotificationCompat.Builder(context, PUSH_CHANNEL_ID)
private val notificationSystemColor = ContextCompat.getColor(context, R.color.colorAccent)
private val icon = BitmapFactory.decodeResource(context.resources, R.mipmap.ic_launcher_round);
......@@ -85,6 +93,14 @@ class NotificationCenter @Inject constructor(val context: Application) : INotif
.setColor(notificationSystemColor)
.build()
override val IncomingPushServiceNotification: Notification =
pushNotyBuilder
.setContentTitle(context.getString(R.string.notification_content_title))//getString(R.string.app_name))
.setPriority(NotificationCompat.PRIORITY_HIGH)
.setSmallIcon(R.mipmap.ic_launcher)
.setColor(notificationSystemColor)
.build()
//Заготовка под переход в определенный экран приложения по нажатию на нотификацию
private val toDownloadsIntent =
Intent(context, RoomParkMainActivity::class.java)
......@@ -113,6 +129,37 @@ class NotificationCenter @Inject constructor(val context: Application) : INotif
donwloadServiceProgressNotfication(indeterminate = false,message = message)
}
override fun showPushNotifyMessage(message: String){
val pendingIntent = PendingIntent.getActivity(context
, PENDING_REQUEST_CODE
, toDownloadsIntent
, PendingIntent.FLAG_ONE_SHOT
)
val noty = pushNotyBuilder
.setContentTitle(context.getString(R.string.notification_content_title))//getString(R.string.app_name))
.setPriority(NotificationCompat.PRIORITY_HIGH)
.setSmallIcon(R.mipmap.ic_launcher)
.setColor(notificationSystemColor)
.setContentTitle(context.getString(R.string.notification_content_title))
.setContentIntent(pendingIntent)
.setContentText(message)
.setStyle(NotificationCompat.BigTextStyle()
.setBigContentTitle(context.getString(R.string.notification_content_title))
.bigText(
message
))
.setAutoCancel(true)
.build()
actualNotifyManager.notify(
PUSH_INFO_SERVICE_ID
, noty)
}
override fun donwloadServiceProgressNotfication(progress:Int
, progressMax:Int
, indeterminate:Boolean
......@@ -137,7 +184,7 @@ class NotificationCenter @Inject constructor(val context: Application) : INotif
.setColor(notificationSystemColor)
.setLargeIcon(icon)
.setContentIntent(pendingIntent)
.setAutoCancel(false)
.setAutoCancel(true)
.build()
actualNotifyManager.notify(
......@@ -175,6 +222,24 @@ class NotificationCenter @Inject constructor(val context: Application) : INotif
return channelId
}
@TargetApi(Build.VERSION_CODES.O)
@RequiresApi(Build.VERSION_CODES.O)
private fun createPushNotificationChannel(): String {
val channelId = PUSH_CHANNEL_ID
val channelName = "RoomPark push info update"
val chan = NotificationChannel(channelId,
channelName, NotificationManager.IMPORTANCE_DEFAULT)
chan.lockscreenVisibility = Notification.VISIBILITY_PUBLIC
chan.enableVibration(true)
chan.lightColor = R.color.colorPrimary
val service = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
service.createNotificationChannel(chan)
return channelId
}
private fun DownloadState.notyName() =
when(this){
DownloadState.Downloaded ->context.getString(R.string.state_downloaded_notify_message)
......
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="1536dp"
android:height="1536dp"
android:viewportWidth="1536"
android:viewportHeight="1536">
<path
android:pathData="M0,0h1536v1536h-1536z"
android:fillColor="#FFFFFF"
android:strokeColor="#00000000"
android:fillAlpha="1"/>
<group>
<clip-path
android:pathData="M418,287L1118,287L1118,357L418,357ZM629.07,496.38L911.21,496.38L911.21,565L629.07,565ZM842,565L911.21,565L911.21,981L842,981ZM629.07,565L701,565L701,981L629.07,981ZM629.07,981L911.21,981L911.21,1050.63L629.07,1050.63ZM418,357L488,357L488,1050.63L418,1050.63ZM418,1050.63L701.25,1050.63L701.25,1120.75L418,1120.75ZM1049,357L1118,357L1118,1190L1049,1190ZM628.33,1120.75L701.25,1120.75L701.25,1190L628.33,1190ZM628.33,1190L1118,1190L1118,1257L628.33,1257ZM628.33,1257L697.34,1257L697.34,1536L628.33,1536ZM628.33,1257"/>
<path
android:pathData="M413,282L1123,282L1123,1541L413,1541ZM413,282"
android:fillColor="#227F79"
android:fillAlpha="1"
android:fillType="nonZero"
android:strokeColor="#00000000"/>
</group>
</vector>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="1536dp"
android:height="1536dp"
android:viewportWidth="1536"
android:viewportHeight="1536">
<path
android:pathData="M0,0h1536v1536h-1536z"
android:fillColor="#FFFFFF"
android:strokeColor="#00000000"
android:fillAlpha="1"/>
<group>
<clip-path
android:pathData="M418,287L1118,287L1118,357L418,357ZM629.07,496.38L911.21,496.38L911.21,565L629.07,565ZM842,565L911.21,565L911.21,981L842,981ZM629.07,565L701,565L701,981L629.07,981ZM629.07,981L911.21,981L911.21,1050.63L629.07,1050.63ZM418,357L488,357L488,1050.63L418,1050.63ZM418,1050.63L701.25,1050.63L701.25,1120.75L418,1120.75ZM1049,357L1118,357L1118,1190L1049,1190ZM628.33,1120.75L701.25,1120.75L701.25,1190L628.33,1190ZM628.33,1190L1118,1190L1118,1257L628.33,1257ZM628.33,1257L697.34,1257L697.34,1536L628.33,1536ZM628.33,1257"/>
<path
android:pathData="M413,282L1123,282L1123,1541L413,1541ZM413,282"
android:fillColor="#227F79"
android:fillAlpha="1"
android:fillType="nonZero"
android:strokeColor="#00000000"/>
</group>
</vector>
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
<background android:drawable="@drawable/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
<background android:drawable="@drawable/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>
\ No newline at end of file
......@@ -112,6 +112,13 @@
<!--endregion-->
<!-- region notifications-->
<string name="push_notification_content_title">Уведомление!</string>
<!--endregion-->
<string name="on_all_tours_downloaded_notification_message">Загрузка туров завершена</string>
<string name="on_all_tours_deleted_notification_message">Удаление туров завершено</string>
<string name="noty_tours_delete_left">Осталось удалить: %d%n</string>
......
......@@ -5,8 +5,8 @@ ext {
minSdkVersion_RoomPark = 23
compileSdkVersion_RoomPark = 28
VERSION_CODE = 3
VERSION_NAME = "0.8.1"
VERSION_CODE = 4
VERSION_NAME = "0.8.4"
// supportLibraryVersion = '1.1.0-alpha05'
constrainLayoutVersion = '1.1.3'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment