Loading app/build.gradle +6 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,10 @@ android { } } buildFeatures { viewBinding = true } buildTypes { release { minifyEnabled true Loading Loading @@ -128,4 +132,6 @@ dependencies { // Image viewer implementation 'com.github.stfalcon-studio:StfalconImageViewer:v1.0.1' implementation 'foundation.e:elib:0.0.1-alpha11' } app/src/main/AndroidManifest.xml +29 −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" xmlns:tools="http://schemas.android.com/tools" package="io.heckel.ntfy"> <!-- Permissions --> Loading Loading @@ -176,5 +177,32 @@ android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths"/> </provider> <activity android:name=".ui.MainSettingsActivity" android:theme="@style/ETheme" android:icon="@drawable/ic_notification" android:label="@string/app_name" android:process=":ui" android:roundIcon="@drawable/ic_notification"/> <activity-alias android:name=".ui.SettingsActivityLink" android:exported="true" android:icon="@drawable/ic_notification" android:label="@string/eos_settings_title" android:process=":ui" android:roundIcon="@drawable/ic_notification" android:targetActivity=".ui.MainSettingsActivity"> <intent-filter> <action android:name="com.android.settings.action.EXTRA_SETTINGS" /> </intent-filter> <meta-data android:name="com.android.settings.category" android:value="com.android.settings.category.device" /> <meta-data android:name="com.android.settings.icon" android:resource="@drawable/ic_notification" /> </activity-alias> </application> </manifest> app/src/main/java/io/heckel/ntfy/service/SubscriberService.kt +4 −2 Original line number Diff line number Diff line Loading @@ -10,6 +10,7 @@ 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 Loading Loading @@ -93,7 +94,9 @@ class SubscriberService : Service() { override fun onDestroy() { Log.d(TAG, "Subscriber service has been destroyed") stopService() sendBroadcast(Intent(this, AutoRestartReceiver::class.java)) // Restart it if necessary! if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean("isEnabled", false)) { sendBroadcast(Intent(this, AutoRestartReceiver::class.java)) } super.onDestroy() } Loading Loading @@ -127,7 +130,6 @@ class SubscriberService : Service() { } } wakeLock = null stopForeground(true) stopSelf() } catch (e: Exception) { Log.d(TAG, "Service stopped without being started: ${e.message}") Loading app/src/main/java/io/heckel/ntfy/service/SubscriberServiceManager.kt +9 −4 Original line number Diff line number Diff line Loading @@ -2,7 +2,7 @@ package io.heckel.ntfy.service import android.content.Context import android.content.Intent import androidx.core.content.ContextCompat import androidx.preference.PreferenceManager import androidx.work.* import io.heckel.ntfy.app.Application import io.heckel.ntfy.util.Log Loading Loading @@ -43,11 +43,16 @@ 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 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 sharedPreferences = PreferenceManager.getDefaultSharedPreferences(app) val action = if (sharedPreferences.getBoolean("isEnabled", false)) { 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() Loading app/src/main/java/io/heckel/ntfy/ui/MainSettingsActivity.kt 0 → 100644 +24 −0 Original line number Diff line number Diff line package io.heckel.ntfy.ui import android.os.Bundle import androidx.appcompat.app.AppCompatActivity import io.heckel.ntfy.R import io.heckel.ntfy.databinding.MainSettingsActivityBinding class MainSettingsActivity: AppCompatActivity() { private lateinit var mBinding: MainSettingsActivityBinding override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) mBinding = MainSettingsActivityBinding.inflate(layoutInflater) setContentView(mBinding.root) supportFragmentManager .beginTransaction() .replace(R.id.fragment_container, PreferencesFragment()) .commit() } } No newline at end of file Loading
app/build.gradle +6 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,10 @@ android { } } buildFeatures { viewBinding = true } buildTypes { release { minifyEnabled true Loading Loading @@ -128,4 +132,6 @@ dependencies { // Image viewer implementation 'com.github.stfalcon-studio:StfalconImageViewer:v1.0.1' implementation 'foundation.e:elib:0.0.1-alpha11' }
app/src/main/AndroidManifest.xml +29 −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" xmlns:tools="http://schemas.android.com/tools" package="io.heckel.ntfy"> <!-- Permissions --> Loading Loading @@ -176,5 +177,32 @@ android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths"/> </provider> <activity android:name=".ui.MainSettingsActivity" android:theme="@style/ETheme" android:icon="@drawable/ic_notification" android:label="@string/app_name" android:process=":ui" android:roundIcon="@drawable/ic_notification"/> <activity-alias android:name=".ui.SettingsActivityLink" android:exported="true" android:icon="@drawable/ic_notification" android:label="@string/eos_settings_title" android:process=":ui" android:roundIcon="@drawable/ic_notification" android:targetActivity=".ui.MainSettingsActivity"> <intent-filter> <action android:name="com.android.settings.action.EXTRA_SETTINGS" /> </intent-filter> <meta-data android:name="com.android.settings.category" android:value="com.android.settings.category.device" /> <meta-data android:name="com.android.settings.icon" android:resource="@drawable/ic_notification" /> </activity-alias> </application> </manifest>
app/src/main/java/io/heckel/ntfy/service/SubscriberService.kt +4 −2 Original line number Diff line number Diff line Loading @@ -10,6 +10,7 @@ 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 Loading Loading @@ -93,7 +94,9 @@ class SubscriberService : Service() { override fun onDestroy() { Log.d(TAG, "Subscriber service has been destroyed") stopService() sendBroadcast(Intent(this, AutoRestartReceiver::class.java)) // Restart it if necessary! if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean("isEnabled", false)) { sendBroadcast(Intent(this, AutoRestartReceiver::class.java)) } super.onDestroy() } Loading Loading @@ -127,7 +130,6 @@ class SubscriberService : Service() { } } wakeLock = null stopForeground(true) stopSelf() } catch (e: Exception) { Log.d(TAG, "Service stopped without being started: ${e.message}") Loading
app/src/main/java/io/heckel/ntfy/service/SubscriberServiceManager.kt +9 −4 Original line number Diff line number Diff line Loading @@ -2,7 +2,7 @@ package io.heckel.ntfy.service import android.content.Context import android.content.Intent import androidx.core.content.ContextCompat import androidx.preference.PreferenceManager import androidx.work.* import io.heckel.ntfy.app.Application import io.heckel.ntfy.util.Log Loading Loading @@ -43,11 +43,16 @@ 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 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 sharedPreferences = PreferenceManager.getDefaultSharedPreferences(app) val action = if (sharedPreferences.getBoolean("isEnabled", false)) { 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() Loading
app/src/main/java/io/heckel/ntfy/ui/MainSettingsActivity.kt 0 → 100644 +24 −0 Original line number Diff line number Diff line package io.heckel.ntfy.ui import android.os.Bundle import androidx.appcompat.app.AppCompatActivity import io.heckel.ntfy.R import io.heckel.ntfy.databinding.MainSettingsActivityBinding class MainSettingsActivity: AppCompatActivity() { private lateinit var mBinding: MainSettingsActivityBinding override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) mBinding = MainSettingsActivityBinding.inflate(layoutInflater) setContentView(mBinding.root) supportFragmentManager .beginTransaction() .replace(R.id.fragment_container, PreferencesFragment()) .commit() } } No newline at end of file