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

Commit 6f0bf4d1 authored by Philipp Heckel's avatar Philipp Heckel
Browse files

Merge branch 'main' into custom_notification_channels

parents 209cf852 1e70ae0d
Loading
Loading
Loading
Loading
+21 −2
Original line number Diff line number Diff line
@@ -14,8 +14,8 @@ android {
        minSdkVersion 21
        targetSdkVersion 33

        versionCode 29
        versionName "1.15.0"
        versionCode 32
        versionName "1.16.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

@@ -44,10 +44,12 @@ android {
        play {
            buildConfigField 'boolean', 'FIREBASE_AVAILABLE', 'true'
            buildConfigField 'boolean', 'RATE_APP_AVAILABLE', 'true'
            buildConfigField 'boolean', 'INSTALL_PACKAGES_AVAILABLE', 'false'
        }
        fdroid {
            buildConfigField 'boolean', 'FIREBASE_AVAILABLE', 'false'
            buildConfigField 'boolean', 'RATE_APP_AVAILABLE', 'false'
            buildConfigField 'boolean', 'INSTALL_PACKAGES_AVAILABLE', 'true'
        }
    }

@@ -64,12 +66,29 @@ android {
    }
}

// Disables GoogleServices tasks for F-Droid variant
android.applicationVariants.all { variant ->
    def shouldProcessGoogleServices = variant.flavorName == "play"
    def googleTask = tasks.findByName("process${variant.name.capitalize()}GoogleServices")
    googleTask.enabled = shouldProcessGoogleServices
}

// Strips out REQUEST_INSTALL_PACKAGES permission for Google Play variant
android.applicationVariants.all { variant ->
    def shouldStripInstallPermission = variant.flavorName == "play"
    if (shouldStripInstallPermission) {
        variant.outputs.each { output ->
            def processManifest = output.getProcessManifestProvider().get()
            processManifest.doLast { task ->
                def outputDir = task.getMultiApkManifestOutputDirectory().get().asFile
                def manifestOutFile = file("$outputDir/AndroidManifest.xml")
                def newFileContents = manifestOutFile.collect { s -> s.contains("android.permission.REQUEST_INSTALL_PACKAGES") ? "" : s }.join("\n")
                manifestOutFile.write(newFileContents, 'UTF-8')
            }
        }
    }
}

dependencies {
    // AndroidX, The Basics
    implementation "androidx.appcompat:appcompat:1.5.1"
+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
+9 −1
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="io.heckel.ntfy">

    <!-- Permissions -->
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE"/> <!-- For instant delivery foregrounds service -->
@@ -8,10 +9,17 @@
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/> <!-- To restart service on reboot -->
    <uses-permission android:name="android.permission.VIBRATE"/> <!-- Incoming notifications should be able to vibrate the phone -->
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="28"/> <!-- Only required on SDK <= 28 -->
    <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES"/> <!-- To install packages downloaded through ntfy; craazyy! -->
    <uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM"/> <!-- To reschedule the websocket retry -->
    <uses-permission android:name="android.permission.POST_NOTIFICATIONS"/> <!-- As of Android 13, we need to ask for permission to post notifications -->

    <!--
        Permission REQUEST_INSTALL_PACKAGES (F-Droid only!):
          - Permission is used to install .apk files that were received as attachments
          - Google rejected the permission for ntfy, so this permission is STRIPPED OUT by the build process
            for the Google Play variant of the app.
    -->
    <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES"/>

    <application
            android:name=".app.Application"
            android:allowBackup="true"
+0 −1
Original line number Diff line number Diff line
package io.heckel.ntfy.app

import android.app.Application
import android.content.Context
import io.heckel.ntfy.db.Database
import io.heckel.ntfy.db.Repository
import io.heckel.ntfy.util.Log
+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 ->
@@ -120,7 +120,7 @@ class Backuper(val context: Context) {

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

    private suspend fun applyUsers(users: List<User>?) {
        if (users == null) {
            return;
            return
        }
        users.forEach { u ->
            try {
Loading