Skip to content

Commit

Permalink
Call finish on NotificationActivity to close it
Browse files Browse the repository at this point in the history
fix in OrMainActivity to show the dialog on the uiThread
#59
  • Loading branch information
Miggets7 committed Oct 2, 2024
1 parent 334f1c1 commit 94e2bd2
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import io.openremote.orlib.R
import io.openremote.orlib.models.ORAlertAction
import io.openremote.orlib.models.ORAlertButton
import io.openremote.orlib.ui.NotificationActivity
import io.openremote.orlib.ui.OrMainActivity
import java.util.logging.Level
import java.util.logging.Logger

Expand Down Expand Up @@ -230,13 +229,13 @@ class ORFirebaseMessagingService : com.google.firebase.messaging.FirebaseMessagi
this,
0,
actionIntent,
PendingIntent.FLAG_ONE_SHOT or PendingIntent.FLAG_IMMUTABLE)
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE)
} else {
PendingIntent.getService(
this,
0,
actionIntent,
PendingIntent.FLAG_ONE_SHOT or PendingIntent.FLAG_IMMUTABLE
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ class NotificationActivity : AppCompatActivity() {
startActivity(launchIntent)
}
}
finish()
}
}
}
62 changes: 32 additions & 30 deletions ORLib/src/main/java/io/openremote/orlib/ui/OrMainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ open class OrMainActivity : Activity() {
IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE),
ContextCompat.RECEIVER_NOT_EXPORTED
)
if (!webViewLoaded) {
if (!webViewLoaded && !webViewIsLoading) {
reloadWebView()
}
}
Expand Down Expand Up @@ -688,37 +688,39 @@ open class OrMainActivity : Activity() {
Manifest.permission.POST_NOTIFICATIONS
)
) {
AlertDialog.Builder(this@OrMainActivity)
.setTitle(R.string.push_notification_alert_title)
.setMessage(R.string.push_notification_alert_message)
.setIcon(R.drawable.ic_notification)
.setCancelable(false)
.setPositiveButton(
R.string.yes
) { dialog, which ->
requestPermissions(
arrayOf(Manifest.permission.POST_NOTIFICATIONS),
pushResponseCode
)
}
.setNegativeButton(
R.string.no
) { dialog, which ->
sharedPreferences.edit()
.putBoolean(
ORConstants.PUSH_PROVIDER_DISABLED_KEY,
true
runOnUiThread {
AlertDialog.Builder(this@OrMainActivity)
.setTitle(R.string.push_notification_alert_title)
.setMessage(R.string.push_notification_alert_message)
.setIcon(R.drawable.ic_notification)
.setCancelable(false)
.setPositiveButton(
R.string.yes
) { dialog, which ->
requestPermissions(
arrayOf(Manifest.permission.POST_NOTIFICATIONS),
pushResponseCode
)
.apply()
notifyClient(
hashMapOf(
"action" to "PROVIDER_ENABLE",
"provider" to "push",
"hasPermission" to false,
"success" to true
}
.setNegativeButton(
R.string.no
) { dialog, which ->
sharedPreferences.edit()
.putBoolean(
ORConstants.PUSH_PROVIDER_DISABLED_KEY,
true
)
.apply()
notifyClient(
hashMapOf(
"action" to "PROVIDER_ENABLE",
"provider" to "push",
"hasPermission" to false,
"success" to true
)
)
)
}.show()
}.show()
}
} else {
requestPermissions(
arrayOf(Manifest.permission.POST_NOTIFICATIONS),
Expand Down

0 comments on commit 94e2bd2

Please sign in to comment.