From aba2e3b5b4ecc40a03e7d3d53769de082bed10ce Mon Sep 17 00:00:00 2001 From: jacquarg Date: Wed, 3 Sep 2025 17:40:11 +0200 Subject: [PATCH 1/3] feat:3467: activate silently, revert settings screen implementation --- app/build.gradle | 6 -- app/src/main/AndroidManifest.xml | 20 ------ .../heckel/ntfy/service/SubscriberService.kt | 8 +-- .../ntfy/service/SubscriberServiceManager.kt | 15 ++-- .../io/heckel/ntfy/ui/MainSettingsActivity.kt | 71 ------------------- .../io/heckel/ntfy/ui/PreferencesFragment.kt | 37 ---------- app/src/main/res/drawable/ic_notification.xml | 14 ++-- .../res/layout/main_settings_activity.xml | 49 ------------- app/src/main/res/values-de/strings.xml | 2 - app/src/main/res/values-es/strings.xml | 2 - app/src/main/res/values-fr/strings.xml | 2 - app/src/main/res/values-it/strings.xml | 2 - app/src/main/res/values/strings.xml | 6 -- app/src/main/res/values/styles.xml | 22 ------ app/src/main/res/xml/settings_preferences.xml | 11 --- build.gradle | 1 - 16 files changed, 13 insertions(+), 255 deletions(-) delete mode 100644 app/src/main/java/io/heckel/ntfy/ui/MainSettingsActivity.kt delete mode 100644 app/src/main/java/io/heckel/ntfy/ui/PreferencesFragment.kt delete mode 100644 app/src/main/res/layout/main_settings_activity.xml delete mode 100644 app/src/main/res/xml/settings_preferences.xml diff --git a/app/build.gradle b/app/build.gradle index ca3c445f..f80aa65e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -27,10 +27,6 @@ android { } } - buildFeatures { - viewBinding = true - } - buildTypes { release { minifyEnabled true @@ -133,6 +129,4 @@ dependencies { // Image viewer implementation 'com.github.stfalcon-studio:StfalconImageViewer:v1.0.1' - - implementation 'foundation.e:elib:0.0.1-alpha11' } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 29093161..c1baa027 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -176,25 +176,5 @@ android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths"/> - - - - - - - - - - diff --git a/app/src/main/java/io/heckel/ntfy/service/SubscriberService.kt b/app/src/main/java/io/heckel/ntfy/service/SubscriberService.kt index a70acf09..7fd6f932 100644 --- a/app/src/main/java/io/heckel/ntfy/service/SubscriberService.kt +++ b/app/src/main/java/io/heckel/ntfy/service/SubscriberService.kt @@ -10,7 +10,6 @@ import android.os.PowerManager import android.os.SystemClock import androidx.core.app.NotificationCompat import androidx.core.content.ContextCompat -import androidx.preference.PreferenceManager import io.heckel.ntfy.BuildConfig import io.heckel.ntfy.R import io.heckel.ntfy.app.Application @@ -94,11 +93,7 @@ class SubscriberService : Service() { override fun onDestroy() { Log.d(TAG, "Subscriber service has been destroyed") stopService() - val preferenceKey = getString(R.string.eos_preference_key_is_enabled) - if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean(preferenceKey, false)) { - sendBroadcast(Intent(this, AutoRestartReceiver::class.java)) - } - + sendBroadcast(Intent(this, AutoRestartReceiver::class.java)) // Restart it if necessary! super.onDestroy() } @@ -132,6 +127,7 @@ class SubscriberService : Service() { } } wakeLock = null + stopForeground(true) stopSelf() } catch (e: Exception) { Log.d(TAG, "Service stopped without being started: ${e.message}") diff --git a/app/src/main/java/io/heckel/ntfy/service/SubscriberServiceManager.kt b/app/src/main/java/io/heckel/ntfy/service/SubscriberServiceManager.kt index 18ed4f94..f7573f29 100644 --- a/app/src/main/java/io/heckel/ntfy/service/SubscriberServiceManager.kt +++ b/app/src/main/java/io/heckel/ntfy/service/SubscriberServiceManager.kt @@ -2,11 +2,10 @@ package io.heckel.ntfy.service import android.content.Context import android.content.Intent -import androidx.preference.PreferenceManager +import androidx.core.content.ContextCompat import androidx.work.* import io.heckel.ntfy.app.Application import io.heckel.ntfy.util.Log -import io.heckel.ntfy.R import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext @@ -44,17 +43,11 @@ class SubscriberServiceManager(private val context: Context) { Log.d(TAG, "ServiceStartWorker: Failed, no application found (work ID: ${id})") return Result.failure() } - withContext(Dispatchers.IO) { val app = context.applicationContext as Application - val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(app) - val preferenceKey = context.getString(R.string.eos_preference_key_is_enabled) - val action = if (sharedPreferences.getBoolean(preferenceKey, false)) { - SubscriberService.Action.START - } else { - SubscriberService.Action.STOP - } - + val subscriptionIdsWithInstantStatus = app.repository.getSubscriptionIdsWithInstantStatus() + val instantSubscriptions = subscriptionIdsWithInstantStatus.toList().filter { (_, instant) -> instant }.size + val action = if (instantSubscriptions > 0) SubscriberService.Action.START else SubscriberService.Action.STOP val serviceState = SubscriberService.readServiceState(context) if (serviceState == SubscriberService.ServiceState.STOPPED && action == SubscriberService.Action.STOP) { return@withContext Result.success() diff --git a/app/src/main/java/io/heckel/ntfy/ui/MainSettingsActivity.kt b/app/src/main/java/io/heckel/ntfy/ui/MainSettingsActivity.kt deleted file mode 100644 index 1aabb1a1..00000000 --- a/app/src/main/java/io/heckel/ntfy/ui/MainSettingsActivity.kt +++ /dev/null @@ -1,71 +0,0 @@ -package io.heckel.ntfy.ui - -import android.content.res.Configuration -import android.os.Build -import android.os.Bundle -import android.view.WindowInsetsController -import androidx.annotation.RequiresApi -import androidx.appcompat.app.AppCompatActivity -import io.heckel.ntfy.R -import io.heckel.ntfy.databinding.MainSettingsActivityBinding - -class MainSettingsActivity : AppCompatActivity() { - - private lateinit var mBinding: MainSettingsActivityBinding - - @RequiresApi(Build.VERSION_CODES.R) - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - - mBinding = MainSettingsActivityBinding.inflate(layoutInflater) - setContentView(mBinding.root) - - setupToolbar() - setSystemBarsAppearance() - showPreferencesFragment() - } - - private fun setupToolbar() { - mBinding.toolbar.setNavigationOnClickListener { - onBackPressedDispatcher.onBackPressed() - } - } - - @RequiresApi(Build.VERSION_CODES.R) - private fun setSystemBarsAppearance() { - val insetsController = window.insetsController ?: return - - val isLightMode = isSystemInLightMode() - if (isLightMode) { - insetsController.setSystemBarsAppearance( - WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS, - WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS - ) - insetsController.setSystemBarsAppearance( - WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS, - WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS - ) - } else { - insetsController.setSystemBarsAppearance( - 0, - WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS - ) - insetsController.setSystemBarsAppearance( - 0, - WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS - ) - } - } - - private fun isSystemInLightMode(): Boolean { - val nightModeFlags = resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK - return nightModeFlags != Configuration.UI_MODE_NIGHT_YES - } - - private fun showPreferencesFragment() { - supportFragmentManager - .beginTransaction() - .replace(R.id.fragment_container, PreferencesFragment()) - .commit() - } -} \ No newline at end of file diff --git a/app/src/main/java/io/heckel/ntfy/ui/PreferencesFragment.kt b/app/src/main/java/io/heckel/ntfy/ui/PreferencesFragment.kt deleted file mode 100644 index 2bc5e30d..00000000 --- a/app/src/main/java/io/heckel/ntfy/ui/PreferencesFragment.kt +++ /dev/null @@ -1,37 +0,0 @@ -package io.heckel.ntfy.ui - -import android.content.Context -import android.content.Intent -import android.os.Bundle -import android.view.Menu -import android.view.MenuInflater -import android.view.MenuItem -import android.widget.Toolbar -import androidx.preference.PreferenceFragmentCompat -import androidx.preference.SwitchPreferenceCompat -import io.heckel.ntfy.R -import io.heckel.ntfy.service.SubscriberService -import io.heckel.ntfy.util.Log - -class PreferencesFragment : PreferenceFragmentCompat() { - - override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { - setPreferencesFromResource(R.xml.settings_preferences, rootKey) - - val preference: SwitchPreferenceCompat? = - findPreference(getString(R.string.eos_preference_key_is_enabled)) - - preference?.setOnPreferenceChangeListener { _, newValue -> - val isChecked = newValue as Boolean - val intent = Intent(context, SubscriberService::class.java) - intent.action = if (isChecked) { - SubscriberService.Action.START.name - } else { - SubscriberService.Action.STOP.name - } - - requireContext().startService(intent) - true - } - } -} \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_notification.xml b/app/src/main/res/drawable/ic_notification.xml index 900100ba..d02140aa 100644 --- a/app/src/main/res/drawable/ic_notification.xml +++ b/app/src/main/res/drawable/ic_notification.xml @@ -1,31 +1,31 @@ diff --git a/app/src/main/res/layout/main_settings_activity.xml b/app/src/main/res/layout/main_settings_activity.xml deleted file mode 100644 index 06731953..00000000 --- a/app/src/main/res/layout/main_settings_activity.xml +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index bef8d4f9..a9c38b99 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -343,6 +343,4 @@ ntfy arbeitet nicht als UnifiedPush-Distributor UnifiedPush aktivieren ntfy arbeitet als UnifiedPush-Distributor - Den Verteiler aktivieren - Es ermöglicht Drittanbieteranwendungen, UnifiedPush-Benachrichtigungen zu empfangen \ No newline at end of file diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 33f9aa92..0bda4a7a 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -343,6 +343,4 @@ Activar UnifiedPush ntfy actuará como distribuidor UnifiedPush ntfy no actuará como distribuidor UnifiedPush - Habilitar el distribuidor - Permite a las aplicaciones de terceros recibir notificaciones de UnifiedPush \ No newline at end of file diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 97d536c8..348eecc2 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -343,6 +343,4 @@ ntfy agira comme un distributeur UnifiedPush ntfy n\'agira pas comme un distributeur UnifiedPush Activer le \"UnifiedPush\" - Activer le distributeur - Cela permet aux applications tierces de recevoir des notifications UnifiedPush \ No newline at end of file diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 84d2254d..703806f4 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -330,6 +330,4 @@ Default Dona 💸 Le app non possono più essere installate: devono essere scaricate via browser. Vedi l\'issue #531 per dettagli. - Abilitare il distributore - Consente alle applicazioni di terze parti di ricevere notifiche UnifiedPush \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 2eddd123..c7759901 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -391,10 +391,4 @@ Cancel Delete user Save - - - isEnabled - UnifiedPush - Enable the distributor - It allows 3rd party applications to receive UnifiedPush notifications diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index e7244948..4f0902d8 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -30,26 +30,4 @@ rounded 5dp - - - diff --git a/app/src/main/res/xml/settings_preferences.xml b/app/src/main/res/xml/settings_preferences.xml deleted file mode 100644 index 6b02c9c4..00000000 --- a/app/src/main/res/xml/settings_preferences.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - \ No newline at end of file diff --git a/build.gradle b/build.gradle index 86592581..fd508003 100644 --- a/build.gradle +++ b/build.gradle @@ -18,7 +18,6 @@ allprojects { repositories { google() mavenCentral() - maven { url 'https://gitlab.e.foundation/api/v4/groups/9/-/packages/maven'} maven { url "https://jitpack.io" } // For StfalconImageViewer } } -- GitLab From 025cf2320cca78b343dfbcd30d041019654c6d0e Mon Sep 17 00:00:00 2001 From: jacquarg Date: Wed, 3 Sep 2025 17:50:41 +0200 Subject: [PATCH 2/3] feat:3467: set push server to push.murena.com --- app/src/main/res/values/values.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/res/values/values.xml b/app/src/main/res/values/values.xml index f94a598b..1dea3b89 100644 --- a/app/src/main/res/values/values.xml +++ b/app/src/main/res/values/values.xml @@ -5,7 +5,7 @@ ntfy - https://ntfy.sh + https://push.murena.com https://github.com/binwiederhier/ntfy/issues -- GitLab From 60679467005a018b2d42c26842ca671600a086c3 Mon Sep 17 00:00:00 2001 From: jacquarg Date: Wed, 3 Sep 2025 18:01:25 +0200 Subject: [PATCH 3/3] chore: fix build, replace jitpack repository. --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index fd508003..babcca89 100644 --- a/build.gradle +++ b/build.gradle @@ -18,7 +18,7 @@ allprojects { repositories { google() mavenCentral() - maven { url "https://jitpack.io" } // For StfalconImageViewer + maven { url 'https://maven.scijava.org/content/repositories/public/' } // For StfalconImageViewer } } -- GitLab