mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-03-30 03:33:50 -04:00
Refactor: Use FLAG_ACTIVITY_SINGLE_TOP for MainActivity intents (#2022)
This commit is contained in:
@@ -224,7 +224,9 @@ class MainActivity : AppCompatActivity(), Logging {
|
||||
val startActivityIntent = Intent(
|
||||
Intent.ACTION_VIEW, deepLink.toUri(),
|
||||
this, MainActivity::class.java
|
||||
)
|
||||
).apply {
|
||||
flags = Intent.FLAG_ACTIVITY_SINGLE_TOP
|
||||
}
|
||||
|
||||
val resultPendingIntent: PendingIntent? = TaskStackBuilder.create(this).run {
|
||||
addNextIntentWithParentStack(startActivityIntent)
|
||||
@@ -234,11 +236,13 @@ class MainActivity : AppCompatActivity(), Logging {
|
||||
}
|
||||
|
||||
private fun createSettingsIntent(): PendingIntent {
|
||||
val deepLink = "$DEEP_LINK_BASE_URI/settings"
|
||||
val deepLink = "$DEEP_LINK_BASE_URI/connections"
|
||||
val startActivityIntent = Intent(
|
||||
Intent.ACTION_VIEW, deepLink.toUri(),
|
||||
this, MainActivity::class.java
|
||||
)
|
||||
).apply {
|
||||
flags = Intent.FLAG_ACTIVITY_SINGLE_TOP
|
||||
}
|
||||
|
||||
val resultPendingIntent: PendingIntent? = TaskStackBuilder.create(this).run {
|
||||
addNextIntentWithParentStack(startActivityIntent)
|
||||
@@ -387,7 +391,6 @@ class MainActivity : AppCompatActivity(), Logging {
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
|
||||
bluetoothViewModel.enabled.observe(this) { enabled ->
|
||||
if (!enabled && !requestedEnable && model.selectedBluetooth) {
|
||||
requestedEnable = true
|
||||
|
||||
@@ -355,7 +355,9 @@ class MeshServiceNotifications(
|
||||
PendingIntent.getActivity(
|
||||
context,
|
||||
0,
|
||||
Intent(context, MainActivity::class.java),
|
||||
Intent(context, MainActivity::class.java).apply {
|
||||
flags = Intent.FLAG_ACTIVITY_SINGLE_TOP
|
||||
},
|
||||
PendingIntent.FLAG_MUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
|
||||
)
|
||||
}
|
||||
@@ -368,13 +370,16 @@ class MeshServiceNotifications(
|
||||
}
|
||||
|
||||
private fun createOpenMessageIntent(contactKey: String): PendingIntent {
|
||||
val intentFlags = Intent.FLAG_ACTIVITY_SINGLE_TOP
|
||||
val deepLink = "$DEEP_LINK_BASE_URI/messages/$contactKey"
|
||||
val deepLinkIntent = Intent(
|
||||
Intent.ACTION_VIEW,
|
||||
deepLink.toUri(),
|
||||
context,
|
||||
MainActivity::class.java
|
||||
)
|
||||
).apply {
|
||||
flags = intentFlags
|
||||
}
|
||||
|
||||
val deepLinkPendingIntent: PendingIntent = TaskStackBuilder.create(context).run {
|
||||
addNextIntentWithParentStack(deepLinkIntent)
|
||||
|
||||
Reference in New Issue
Block a user