Open app when tapping repo update notification

This commit is contained in:
Torsten Grote
2025-11-25 15:51:54 -03:00
parent 42b5b31e0d
commit 0df5dc94a7

View File

@@ -6,6 +6,7 @@ import android.app.PendingIntent.FLAG_IMMUTABLE
import android.app.PendingIntent.FLAG_UPDATE_CURRENT
import android.content.Context
import android.content.Intent
import android.content.Intent.ACTION_MAIN
import android.content.pm.PackageManager.PERMISSION_GRANTED
import androidx.annotation.StringRes
import androidx.core.app.NotificationChannelCompat
@@ -91,6 +92,7 @@ class NotificationManager @Inject constructor(
.setCategory(CATEGORY_SERVICE)
.setContentTitle(context.getString(R.string.banner_updating_repositories))
.setContentText(msg)
.setContentIntent(getMainActivityPendingIntent(context))
.setOngoing(true)
.setProgress(100, progress ?: 0, progress == null)
@@ -173,6 +175,14 @@ class NotificationManager @Inject constructor(
return builder
}
private fun getMainActivityPendingIntent(context: Context): PendingIntent {
val i = Intent(ACTION_MAIN).apply {
setClass(context, MainActivity::class.java)
}
val flags = FLAG_UPDATE_CURRENT or FLAG_IMMUTABLE
return PendingIntent.getActivity(context, 0, i, flags)
}
private fun getMyAppsPendingIntent(context: Context): PendingIntent {
val i = Intent(ACTION_MY_APPS).apply {
setClass(context, MainActivity::class.java)