Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e64cd79c authored by Philipp Heckel's avatar Philipp Heckel
Browse files

Fix Android 5 crashes on unsubscribing

parent 6a8d222e
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -14,8 +14,8 @@ android {
        minSdkVersion 21
        targetSdkVersion 33

        versionCode 31
        versionName "1.15.2"
        versionCode 32
        versionName "1.16.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

+1 −0
Original line number Diff line number Diff line
package io.heckel.ntfy.firebase

@Suppress("UNUSED_PARAMETER")
class FirebaseMessenger {
    fun subscribe(topic: String) {
        // Dummy to keep F-Droid flavor happy
+3 −3
Original line number Diff line number Diff line
@@ -89,7 +89,7 @@ class Backuper(val context: Context) {

    private suspend fun applySubscriptions(subscriptions: List<Subscription>?) {
        if (subscriptions == null) {
            return;
            return
        }
        val appBaseUrl = context.getString(R.string.app_base_url)
        subscriptions.forEach { s ->
@@ -119,7 +119,7 @@ class Backuper(val context: Context) {

    private suspend fun applyNotifications(notifications: List<Notification>?) {
        if (notifications == null) {
            return;
            return
        }
        notifications.forEach { n ->
            try {
@@ -188,7 +188,7 @@ class Backuper(val context: Context) {

    private suspend fun applyUsers(users: List<User>?) {
        if (users == null) {
            return;
            return
        }
        users.forEach { u ->
            try {
+5 −5
Original line number Diff line number Diff line
@@ -310,11 +310,11 @@ class SubscriberService : Service() {
    override fun onTaskRemoved(rootIntent: Intent) {
        val restartServiceIntent = Intent(applicationContext, SubscriberService::class.java).also {
            it.setPackage(packageName)
        };
        val restartServicePendingIntent: PendingIntent = PendingIntent.getService(this, 1, restartServiceIntent, PendingIntent.FLAG_ONE_SHOT or PendingIntent.FLAG_IMMUTABLE);
        applicationContext.getSystemService(Context.ALARM_SERVICE);
        val alarmService: AlarmManager = applicationContext.getSystemService(Context.ALARM_SERVICE) as AlarmManager;
        alarmService.set(AlarmManager.ELAPSED_REALTIME, SystemClock.elapsedRealtime() + 1000, restartServicePendingIntent);
        }
        val restartServicePendingIntent: PendingIntent = PendingIntent.getService(this, 1, restartServiceIntent, PendingIntent.FLAG_ONE_SHOT or PendingIntent.FLAG_IMMUTABLE)
        applicationContext.getSystemService(Context.ALARM_SERVICE)
        val alarmService: AlarmManager = applicationContext.getSystemService(Context.ALARM_SERVICE) as AlarmManager
        alarmService.set(AlarmManager.ELAPSED_REALTIME, SystemClock.elapsedRealtime() + 1000, restartServicePendingIntent)
    }

    /* This re-starts the service on reboot; see manifest */
+7 −6
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@ import android.content.Context
import android.content.Intent
import android.content.Intent.ACTION_VIEW
import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.text.Html
import android.view.ActionMode
@@ -178,7 +179,7 @@ class DetailActivity : AppCompatActivity(), ActionMode.Callback, NotificationFra
        howToExample.linksClickable = true

        val howToText = getString(R.string.detail_how_to_example, topicUrl)
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
            howToExample.text = Html.fromHtml(howToText, Html.FROM_HTML_MODE_LEGACY)
        } else {
            howToExample.text = Html.fromHtml(howToText)
@@ -241,7 +242,7 @@ class DetailActivity : AppCompatActivity(), ActionMode.Callback, NotificationFra
        adapter.registerAdapterDataObserver(object : RecyclerView.AdapterDataObserver() {
            override fun onItemRangeInserted(positionStart: Int, itemCount: Int) {
                if (positionStart == 0) {
                    Log.d(TAG, "$itemCount item(s) inserted at $positionStart, scrolling to the top")
                    Log.d(TAG, "$itemCount item(s) inserted at 0, scrolling to the top")
                    mainList.scrollToPosition(positionStart)
                }
            }
@@ -571,7 +572,7 @@ class DetailActivity : AppCompatActivity(), ActionMode.Callback, NotificationFra
        dialog.setOnShowListener {
            dialog
                .getButton(AlertDialog.BUTTON_POSITIVE)
                .setTextAppearance(R.style.DangerText)
                .dangerButton(this)
        }
        dialog.show()
    }
@@ -609,7 +610,7 @@ class DetailActivity : AppCompatActivity(), ActionMode.Callback, NotificationFra
        dialog.setOnShowListener {
            dialog
                .getButton(AlertDialog.BUTTON_POSITIVE)
                .setTextAppearance(R.style.DangerText)
                .dangerButton(this)
        }
        dialog.show()
    }
@@ -619,7 +620,7 @@ class DetailActivity : AppCompatActivity(), ActionMode.Callback, NotificationFra
            handleActionModeClick(notification)
        } else if (notification.click != "") {
            try {
                startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(notification.click)))
                startActivity(Intent(ACTION_VIEW, Uri.parse(notification.click)))
            } catch (e: Exception) {
                Log.w(TAG, "Cannot open click URL", e)
                runOnUiThread {
@@ -720,7 +721,7 @@ class DetailActivity : AppCompatActivity(), ActionMode.Callback, NotificationFra
        dialog.setOnShowListener {
            dialog
                .getButton(AlertDialog.BUTTON_POSITIVE)
                .setTextAppearance(R.style.DangerText)
                .dangerButton(this)
        }
        dialog.show()
    }
Loading