launching the app when tapping the summary notification
This commit is contained in:
parent
995377343b
commit
73331b3d1e
|
@ -1,6 +1,5 @@
|
||||||
package app.dapk.st.graph
|
package app.dapk.st.graph
|
||||||
|
|
||||||
import android.app.Activity
|
|
||||||
import android.app.Application
|
import android.app.Application
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
@ -90,9 +89,9 @@ internal class AppModule(context: Application, logger: MatrixLogger) {
|
||||||
val domainModules = DomainModules(matrixModules, trackingModule.errorTracker)
|
val domainModules = DomainModules(matrixModules, trackingModule.errorTracker)
|
||||||
|
|
||||||
val coreAndroidModule = CoreAndroidModule(intentFactory = object : IntentFactory {
|
val coreAndroidModule = CoreAndroidModule(intentFactory = object : IntentFactory {
|
||||||
override fun home(activity: Activity) = Intent(activity, MainActivity::class.java)
|
override fun home(context: Context) = Intent(context, MainActivity::class.java)
|
||||||
override fun messenger(activity: Activity, roomId: RoomId) = MessengerActivity.newInstance(activity, roomId)
|
override fun messenger(context: Context, roomId: RoomId) = MessengerActivity.newInstance(context, roomId)
|
||||||
override fun messengerShortcut(activity: Activity, roomId: RoomId) = MessengerActivity.newShortcutInstance(activity, roomId)
|
override fun messengerShortcut(context: Context, roomId: RoomId) = MessengerActivity.newShortcutInstance(context, roomId)
|
||||||
})
|
})
|
||||||
|
|
||||||
val featureModules = FeatureModules(
|
val featureModules = FeatureModules(
|
||||||
|
@ -101,6 +100,7 @@ internal class AppModule(context: Application, logger: MatrixLogger) {
|
||||||
domainModules,
|
domainModules,
|
||||||
trackingModule,
|
trackingModule,
|
||||||
workModule,
|
workModule,
|
||||||
|
coreAndroidModule,
|
||||||
imageLoaderModule,
|
imageLoaderModule,
|
||||||
context,
|
context,
|
||||||
buildMeta,
|
buildMeta,
|
||||||
|
@ -115,6 +115,7 @@ internal class FeatureModules internal constructor(
|
||||||
private val domainModules: DomainModules,
|
private val domainModules: DomainModules,
|
||||||
private val trackingModule: TrackingModule,
|
private val trackingModule: TrackingModule,
|
||||||
private val workModule: WorkModule,
|
private val workModule: WorkModule,
|
||||||
|
private val coreAndroidModule: CoreAndroidModule,
|
||||||
imageLoaderModule: ImageLoaderModule,
|
imageLoaderModule: ImageLoaderModule,
|
||||||
context: Context,
|
context: Context,
|
||||||
buildMeta: BuildMeta,
|
buildMeta: BuildMeta,
|
||||||
|
@ -172,6 +173,7 @@ internal class FeatureModules internal constructor(
|
||||||
storeModule.value.roomStore(),
|
storeModule.value.roomStore(),
|
||||||
context,
|
context,
|
||||||
workModule.workScheduler(),
|
workModule.workScheduler(),
|
||||||
|
intentFactory = coreAndroidModule.intentFactory(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package app.dapk.st.navigator
|
package app.dapk.st.navigator
|
||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import app.dapk.st.matrix.common.RoomId
|
import app.dapk.st.matrix.common.RoomId
|
||||||
import kotlin.properties.ReadOnlyProperty
|
import kotlin.properties.ReadOnlyProperty
|
||||||
|
@ -39,10 +40,9 @@ interface Navigator {
|
||||||
|
|
||||||
interface IntentFactory {
|
interface IntentFactory {
|
||||||
|
|
||||||
fun home(activity: Activity): Intent
|
fun home(context: Context): Intent
|
||||||
fun messenger(activity: Activity, roomId: RoomId): Intent
|
fun messenger(context: Context, roomId: RoomId): Intent
|
||||||
fun messengerShortcut(activity: Activity, roomId: RoomId): Intent
|
fun messengerShortcut(context: Context, roomId: RoomId): Intent
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ dependencies {
|
||||||
implementation project(":core")
|
implementation project(":core")
|
||||||
implementation project(":domains:android:imageloader")
|
implementation project(":domains:android:imageloader")
|
||||||
implementation project(":features:messenger")
|
implementation project(":features:messenger")
|
||||||
|
implementation project(":features:navigator")
|
||||||
|
|
||||||
implementation platform('com.google.firebase:firebase-bom:29.0.3')
|
implementation platform('com.google.firebase:firebase-bom:29.0.3')
|
||||||
implementation 'com.google.firebase:firebase-messaging'
|
implementation 'com.google.firebase:firebase-messaging'
|
||||||
|
|
|
@ -11,6 +11,7 @@ import app.dapk.st.imageloader.IconLoader
|
||||||
import app.dapk.st.matrix.sync.RoomEvent
|
import app.dapk.st.matrix.sync.RoomEvent
|
||||||
import app.dapk.st.matrix.sync.RoomOverview
|
import app.dapk.st.matrix.sync.RoomOverview
|
||||||
import app.dapk.st.messenger.MessengerActivity
|
import app.dapk.st.messenger.MessengerActivity
|
||||||
|
import app.dapk.st.navigator.IntentFactory
|
||||||
|
|
||||||
private const val GROUP_ID = "st"
|
private const val GROUP_ID = "st"
|
||||||
private const val channelId = "message"
|
private const val channelId = "message"
|
||||||
|
@ -18,6 +19,7 @@ private const val channelId = "message"
|
||||||
class NotificationFactory(
|
class NotificationFactory(
|
||||||
private val iconLoader: IconLoader,
|
private val iconLoader: IconLoader,
|
||||||
private val context: Context,
|
private val context: Context,
|
||||||
|
private val intentFactory: IntentFactory,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
suspend fun createNotifications(events: Map<RoomOverview, List<RoomEvent>>, onlyContainsRemovals: Boolean): Notifications {
|
suspend fun createNotifications(events: Map<RoomOverview, List<RoomEvent>>, onlyContainsRemovals: Boolean): Notifications {
|
||||||
|
@ -53,6 +55,14 @@ class NotificationFactory(
|
||||||
summaryInboxStyle.setSummaryText("${notifications.countMessages()} messages from ${notifications.size} chats")
|
summaryInboxStyle.setSummaryText("${notifications.countMessages()} messages from ${notifications.size} chats")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val openAppIntent = PendingIntent.getActivity(
|
||||||
|
context,
|
||||||
|
1000,
|
||||||
|
intentFactory.home(context)
|
||||||
|
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_NEW_TASK),
|
||||||
|
PendingIntent.FLAG_ONE_SHOT or PendingIntent.FLAG_IMMUTABLE
|
||||||
|
)
|
||||||
|
|
||||||
return builder()
|
return builder()
|
||||||
.setStyle(summaryInboxStyle)
|
.setStyle(summaryInboxStyle)
|
||||||
.setOnlyAlertOnce(onlyContainsRemovals)
|
.setOnlyAlertOnce(onlyContainsRemovals)
|
||||||
|
@ -60,6 +70,7 @@ class NotificationFactory(
|
||||||
.setCategory(Notification.CATEGORY_MESSAGE)
|
.setCategory(Notification.CATEGORY_MESSAGE)
|
||||||
.setGroupSummary(true)
|
.setGroupSummary(true)
|
||||||
.setGroup(GROUP_ID)
|
.setGroup(GROUP_ID)
|
||||||
|
.setContentIntent(openAppIntent)
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ import app.dapk.st.matrix.common.CredentialsStore
|
||||||
import app.dapk.st.matrix.push.PushService
|
import app.dapk.st.matrix.push.PushService
|
||||||
import app.dapk.st.matrix.sync.RoomStore
|
import app.dapk.st.matrix.sync.RoomStore
|
||||||
import app.dapk.st.matrix.sync.SyncService
|
import app.dapk.st.matrix.sync.SyncService
|
||||||
|
import app.dapk.st.navigator.IntentFactory
|
||||||
import app.dapk.st.push.RegisterFirebasePushTokenUseCase
|
import app.dapk.st.push.RegisterFirebasePushTokenUseCase
|
||||||
import app.dapk.st.work.WorkScheduler
|
import app.dapk.st.work.WorkScheduler
|
||||||
|
|
||||||
|
@ -20,6 +21,7 @@ class NotificationsModule(
|
||||||
private val roomStore: RoomStore,
|
private val roomStore: RoomStore,
|
||||||
private val context: Context,
|
private val context: Context,
|
||||||
private val workScheduler: WorkScheduler,
|
private val workScheduler: WorkScheduler,
|
||||||
|
private val intentFactory: IntentFactory,
|
||||||
) : ProvidableModule {
|
) : ProvidableModule {
|
||||||
|
|
||||||
fun pushUseCase() = pushService
|
fun pushUseCase() = pushService
|
||||||
|
@ -28,7 +30,7 @@ class NotificationsModule(
|
||||||
fun firebasePushTokenUseCase() = firebasePushTokenUseCase
|
fun firebasePushTokenUseCase() = firebasePushTokenUseCase
|
||||||
fun notificationsUseCase() = NotificationsUseCase(
|
fun notificationsUseCase() = NotificationsUseCase(
|
||||||
roomStore,
|
roomStore,
|
||||||
NotificationRenderer(notificationManager(), NotificationFactory(iconLoader, context)),
|
NotificationRenderer(notificationManager(), NotificationFactory(iconLoader, context, intentFactory)),
|
||||||
NotificationChannels(notificationManager()),
|
NotificationChannels(notificationManager()),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue