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 4268e85..a70acf0 100644 --- a/app/src/main/java/io/heckel/ntfy/service/SubscriberService.kt +++ b/app/src/main/java/io/heckel/ntfy/service/SubscriberService.kt @@ -94,9 +94,11 @@ class SubscriberService : Service() { override fun onDestroy() { Log.d(TAG, "Subscriber service has been destroyed") stopService() - if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean("isEnabled", false)) { + val preferenceKey = getString(R.string.eos_preference_key_is_enabled) + if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean(preferenceKey, false)) { sendBroadcast(Intent(this, AutoRestartReceiver::class.java)) } + super.onDestroy() } 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 8301363..18ed4f9 100644 --- a/app/src/main/java/io/heckel/ntfy/service/SubscriberServiceManager.kt +++ b/app/src/main/java/io/heckel/ntfy/service/SubscriberServiceManager.kt @@ -6,6 +6,7 @@ import androidx.preference.PreferenceManager 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 @@ -47,7 +48,8 @@ class SubscriberServiceManager(private val context: Context) { withContext(Dispatchers.IO) { val app = context.applicationContext as Application val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(app) - val action = if (sharedPreferences.getBoolean("isEnabled", false)) { + 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 diff --git a/app/src/main/java/io/heckel/ntfy/ui/PreferencesFragment.kt b/app/src/main/java/io/heckel/ntfy/ui/PreferencesFragment.kt index d5f0a5f..2bc5e30 100644 --- a/app/src/main/java/io/heckel/ntfy/ui/PreferencesFragment.kt +++ b/app/src/main/java/io/heckel/ntfy/ui/PreferencesFragment.kt @@ -17,7 +17,9 @@ class PreferencesFragment : PreferenceFragmentCompat() { override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { setPreferencesFromResource(R.xml.settings_preferences, rootKey) - val preference: SwitchPreferenceCompat? = findPreference("isEnabled") + + val preference: SwitchPreferenceCompat? = + findPreference(getString(R.string.eos_preference_key_is_enabled)) preference?.setOnPreferenceChangeListener { _, newValue -> val isChecked = newValue as Boolean diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 2cdbb03..1d08618 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -393,6 +393,7 @@ Save + isEnabled UnifiedPush Enable UnifiedPush distributor It allows 3rd party applications to receive UnifiedPush notifications diff --git a/app/src/main/res/xml/settings_preferences.xml b/app/src/main/res/xml/settings_preferences.xml index 489df1f..6b02c9c 100644 --- a/app/src/main/res/xml/settings_preferences.xml +++ b/app/src/main/res/xml/settings_preferences.xml @@ -3,7 +3,7 @@