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

Commit 78bf83ac authored by Jonathan Klee's avatar Jonathan Klee
Browse files

Extract isEnabled key as resource

parent 5684aba3
Loading
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -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()
    }

+3 −1
Original line number Diff line number Diff line
@@ -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
+3 −1
Original line number Diff line number Diff line
@@ -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
+1 −0
Original line number Diff line number Diff line
@@ -393,6 +393,7 @@
    <string name="user_dialog_button_save">Save</string>

    <!-- /e/OS integration preferences -->
    <string name="eos_preference_key_is_enabled" translatable="false">isEnabled</string>
    <string name="eos_settings_title" translatable="false">UnifiedPush</string>
    <string name="eos_settings_enable_title" translatable="true">Enable UnifiedPush distributor</string>
    <string name="eos_settings_enable_description" translatable="true">It allows 3rd party applications to receive UnifiedPush notifications</string>
+1 −1
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@

    <SwitchPreferenceCompat
        app:icon="@drawable/ic_notification"
        app:key="isEnabled"
        app:key="@string/eos_preference_key_is_enabled"
        app:defaultValue="false"
        app:title="@string/eos_settings_enable_title"
        app:summary="@string/eos_settings_enable_description" />