From f56c315207bb9c8ab058d2cdc321fcb70ec71c21 Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Tue, 26 Jul 2022 14:33:08 +0200 Subject: [PATCH] Dedicated notification builder and opening map on tap of notification --- vector/src/main/AndroidManifest.xml | 2 +- .../location/LocationSharingFragment.kt | 1 + .../LocationSharingServiceConnection.kt | 1 + .../live/map/LocationLiveMapViewActivity.kt | 10 ++- .../LiveLocationNotificationBuilder.kt | 83 +++++++++++++++++++ .../LocationSharingAndroidService.kt | 9 +- .../notifications/NotificationUtils.kt | 18 +--- 7 files changed, 101 insertions(+), 23 deletions(-) create mode 100644 vector/src/main/java/im/vector/app/features/location/live/tracking/LiveLocationNotificationBuilder.kt rename vector/src/main/java/im/vector/app/features/location/{ => live/tracking}/LocationSharingAndroidService.kt (96%) diff --git a/vector/src/main/AndroidManifest.xml b/vector/src/main/AndroidManifest.xml index fa89013707..63c713d9e6 100644 --- a/vector/src/main/AndroidManifest.xml +++ b/vector/src/main/AndroidManifest.xml @@ -377,7 +377,7 @@ diff --git a/vector/src/main/java/im/vector/app/features/location/LocationSharingFragment.kt b/vector/src/main/java/im/vector/app/features/location/LocationSharingFragment.kt index 17e53e63d1..ca524a0126 100644 --- a/vector/src/main/java/im/vector/app/features/location/LocationSharingFragment.kt +++ b/vector/src/main/java/im/vector/app/features/location/LocationSharingFragment.kt @@ -42,6 +42,7 @@ import im.vector.app.features.home.AvatarRenderer import im.vector.app.features.home.room.detail.timeline.helper.MatrixItemColorProvider import im.vector.app.features.location.live.LiveLocationLabsFlagPromotionBottomSheet import im.vector.app.features.location.live.duration.ChooseLiveDurationBottomSheet +import im.vector.app.features.location.live.tracking.LocationSharingAndroidService import im.vector.app.features.location.option.LocationSharingOption import im.vector.app.features.settings.VectorPreferences import org.matrix.android.sdk.api.util.MatrixItem diff --git a/vector/src/main/java/im/vector/app/features/location/LocationSharingServiceConnection.kt b/vector/src/main/java/im/vector/app/features/location/LocationSharingServiceConnection.kt index 3be73e9fd4..9e905060d9 100644 --- a/vector/src/main/java/im/vector/app/features/location/LocationSharingServiceConnection.kt +++ b/vector/src/main/java/im/vector/app/features/location/LocationSharingServiceConnection.kt @@ -22,6 +22,7 @@ import android.content.Intent import android.content.ServiceConnection import android.os.IBinder import im.vector.app.core.di.ActiveSessionHolder +import im.vector.app.features.location.live.tracking.LocationSharingAndroidService import im.vector.app.features.session.coroutineScope import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.flow.launchIn diff --git a/vector/src/main/java/im/vector/app/features/location/live/map/LocationLiveMapViewActivity.kt b/vector/src/main/java/im/vector/app/features/location/live/map/LocationLiveMapViewActivity.kt index c0f07dba57..fabdda49d8 100644 --- a/vector/src/main/java/im/vector/app/features/location/live/map/LocationLiveMapViewActivity.kt +++ b/vector/src/main/java/im/vector/app/features/location/live/map/LocationLiveMapViewActivity.kt @@ -24,6 +24,7 @@ import im.vector.app.R import im.vector.app.core.extensions.addFragment import im.vector.app.core.platform.VectorBaseActivity import im.vector.app.databinding.ActivityLocationSharingBinding +import im.vector.app.features.MainActivity import kotlinx.parcelize.Parcelize @Parcelize @@ -59,10 +60,15 @@ class LocationLiveMapViewActivity : VectorBaseActivity= Build.VERSION_CODES.O) @@ -540,20 +540,6 @@ class NotificationUtils @Inject constructor( return builder.build() } - /** - * Creates a notification that indicates the application is retrieving location even if it is in background or killed. - */ - fun buildLiveLocationSharingNotification(): Notification { - return NotificationCompat.Builder(context, SILENT_NOTIFICATION_CHANNEL_ID) - .setContentTitle(stringProvider.getString(R.string.live_location_sharing_notification_title)) - .setContentText(stringProvider.getString(R.string.live_location_sharing_notification_description)) - .setSmallIcon(R.drawable.ic_attachment_location_live_white) - .setColor(ThemeUtils.getColor(context, android.R.attr.colorPrimary)) - .setCategory(NotificationCompat.CATEGORY_LOCATION_SHARING) - .setContentIntent(buildOpenHomePendingIntentForSummary()) - .build() - } - /** * Creates a notification that indicates the application is capturing the screen. */