rename UnifiedPush variables
This commit is contained in:
parent
33d193d5ad
commit
c6229cb7ca
6 changed files with 22 additions and 22 deletions
|
@ -292,13 +292,13 @@ class Repository(private val sharedPrefs: SharedPreferences, private val databas
|
||||||
.apply()
|
.apply()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getEnableUP(): Boolean {
|
fun getUnifiedPushEnabled(): Boolean {
|
||||||
return sharedPrefs.getBoolean(SHARED_PREFS_ENABLE_UP, true) // Enabled by default
|
return sharedPrefs.getBoolean(SHARED_PREFS_UNIFIEDPUSH_ENABLED, true) // Enabled by default
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setEnableUP(enabled: Boolean) {
|
fun setUnifiedPushEnabled(enabled: Boolean) {
|
||||||
sharedPrefs.edit()
|
sharedPrefs.edit()
|
||||||
.putBoolean(SHARED_PREFS_ENABLE_UP, enabled)
|
.putBoolean(SHARED_PREFS_UNIFIEDPUSH_ENABLED, enabled)
|
||||||
.apply()
|
.apply()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -487,7 +487,7 @@ class Repository(private val sharedPrefs: SharedPreferences, private val databas
|
||||||
const val SHARED_PREFS_CONNECTION_PROTOCOL = "ConnectionProtocol"
|
const val SHARED_PREFS_CONNECTION_PROTOCOL = "ConnectionProtocol"
|
||||||
const val SHARED_PREFS_DARK_MODE = "DarkMode"
|
const val SHARED_PREFS_DARK_MODE = "DarkMode"
|
||||||
const val SHARED_PREFS_BROADCAST_ENABLED = "BroadcastEnabled"
|
const val SHARED_PREFS_BROADCAST_ENABLED = "BroadcastEnabled"
|
||||||
const val SHARED_PREFS_ENABLE_UP = "EnableUP"
|
const val SHARED_PREFS_UNIFIEDPUSH_ENABLED = "UnifiedPushEnabled"
|
||||||
const val SHARED_PREFS_INSISTENT_MAX_PRIORITY_ENABLED = "InsistentMaxPriority"
|
const val SHARED_PREFS_INSISTENT_MAX_PRIORITY_ENABLED = "InsistentMaxPriority"
|
||||||
const val SHARED_PREFS_RECORD_LOGS_ENABLED = "RecordLogs"
|
const val SHARED_PREFS_RECORD_LOGS_ENABLED = "RecordLogs"
|
||||||
const val SHARED_PREFS_BATTERY_OPTIMIZATIONS_REMIND_TIME = "BatteryOptimizationsRemindTime"
|
const val SHARED_PREFS_BATTERY_OPTIMIZATIONS_REMIND_TIME = "BatteryOptimizationsRemindTime"
|
||||||
|
|
|
@ -365,22 +365,22 @@ class SettingsActivity : AppCompatActivity(), PreferenceFragmentCompat.OnPrefere
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable UnifiedPush
|
// Enable UnifiedPush
|
||||||
val enableUPPrefId = context?.getString(R.string.settings_advanced_enable_up_key) ?: return
|
val unifiedPushEnabledPrefId = context?.getString(R.string.settings_advanced_unifiedpush_key) ?: return
|
||||||
val enableUP: SwitchPreference? = findPreference(enableUPPrefId)
|
val unifiedPushEnabled: SwitchPreference? = findPreference(unifiedPushEnabledPrefId)
|
||||||
enableUP?.isChecked = repository.getEnableUP()
|
unifiedPushEnabled?.isChecked = repository.getUnifiedPushEnabled()
|
||||||
enableUP?.preferenceDataStore = object : PreferenceDataStore() {
|
unifiedPushEnabled?.preferenceDataStore = object : PreferenceDataStore() {
|
||||||
override fun putBoolean(key: String?, value: Boolean) {
|
override fun putBoolean(key: String?, value: Boolean) {
|
||||||
repository.setEnableUP(value)
|
repository.setUnifiedPushEnabled(value)
|
||||||
}
|
}
|
||||||
override fun getBoolean(key: String?, defValue: Boolean): Boolean {
|
override fun getBoolean(key: String?, defValue: Boolean): Boolean {
|
||||||
return repository.getEnableUP()
|
return repository.getUnifiedPushEnabled()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
enableUP?.summaryProvider = Preference.SummaryProvider<SwitchPreference> { pref ->
|
unifiedPushEnabled?.summaryProvider = Preference.SummaryProvider<SwitchPreference> { pref ->
|
||||||
if (pref.isChecked) {
|
if (pref.isChecked) {
|
||||||
getString(R.string.settings_advanced_enable_up_summary_enabled)
|
getString(R.string.settings_advanced_unifiedpush_summary_enabled)
|
||||||
} else {
|
} else {
|
||||||
getString(R.string.settings_advanced_enable_up_summary_disabled)
|
getString(R.string.settings_advanced_unifiedpush_summary_disabled)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,9 +38,9 @@ class BroadcastReceiver : android.content.BroadcastReceiver() {
|
||||||
val repository = app.repository
|
val repository = app.repository
|
||||||
val distributor = Distributor(app)
|
val distributor = Distributor(app)
|
||||||
Log.d(TAG, "REGISTER received for app $appId (connectorToken=$connectorToken)")
|
Log.d(TAG, "REGISTER received for app $appId (connectorToken=$connectorToken)")
|
||||||
if (!repository.getEnableUP()) {
|
if (!repository.getUnifiedPushEnabled()) {
|
||||||
Log.w(TAG, "Refusing registration because 'EnableUP' is disabled")
|
Log.w(TAG, "Refusing registration because 'EnableUP' is disabled")
|
||||||
distributor.sendRegistrationFailed(appId, connectorToken, "EnableUP setting is disabled")
|
distributor.sendRegistrationFailed(appId, connectorToken, "UnifiedPush is disabled in ntfy")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (appId.isBlank()) {
|
if (appId.isBlank()) {
|
||||||
|
|
|
@ -320,9 +320,9 @@
|
||||||
<string name="settings_advanced_broadcast_title">Broadcast messages</string>
|
<string name="settings_advanced_broadcast_title">Broadcast messages</string>
|
||||||
<string name="settings_advanced_broadcast_summary_enabled">Apps can receive incoming notifications as broadcasts</string>
|
<string name="settings_advanced_broadcast_summary_enabled">Apps can receive incoming notifications as broadcasts</string>
|
||||||
<string name="settings_advanced_broadcast_summary_disabled">Apps cannot receive notifications as broadcasts</string>
|
<string name="settings_advanced_broadcast_summary_disabled">Apps cannot receive notifications as broadcasts</string>
|
||||||
<string name="settings_advanced_enable_up_title">Enable UnifiedPush</string>
|
<string name="settings_advanced_unifiedpush_title">Enable UnifiedPush</string>
|
||||||
<string name="settings_advanced_enable_up_summary_enabled">ntfy will act as a UnifiedPush distributor</string>
|
<string name="settings_advanced_unifiedpush_summary_enabled">ntfy will act as a UnifiedPush distributor</string>
|
||||||
<string name="settings_advanced_enable_up_summary_disabled">ntfy will NOT act as a UnifiedPush distributor</string>
|
<string name="settings_advanced_unifiedpush_summary_disabled">ntfy will not act as a UnifiedPush distributor</string>
|
||||||
<string name="settings_advanced_record_logs_title">Record logs</string>
|
<string name="settings_advanced_record_logs_title">Record logs</string>
|
||||||
<string name="settings_advanced_record_logs_summary_enabled">Logging (up to 1,000 entries) to device …</string>
|
<string name="settings_advanced_record_logs_summary_enabled">Logging (up to 1,000 entries) to device …</string>
|
||||||
<string name="settings_advanced_record_logs_summary_disabled">Turn on logging, so you can share logs later to diagnose issues.</string>
|
<string name="settings_advanced_record_logs_summary_disabled">Turn on logging, so you can share logs later to diagnose issues.</string>
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
<string name="settings_backup_restore_backup_key" translatable="false">Backup</string>
|
<string name="settings_backup_restore_backup_key" translatable="false">Backup</string>
|
||||||
<string name="settings_backup_restore_restore_key" translatable="false">Restore</string>
|
<string name="settings_backup_restore_restore_key" translatable="false">Restore</string>
|
||||||
<string name="settings_advanced_broadcast_key" translatable="false">BroadcastEnabled</string>
|
<string name="settings_advanced_broadcast_key" translatable="false">BroadcastEnabled</string>
|
||||||
<string name="settings_advanced_enable_up_key" translatable="false">EnableUP</string>
|
<string name="settings_advanced_unifiedpush_key" translatable="false">UnifiedPushEnabled</string>
|
||||||
<string name="settings_advanced_record_logs_key" translatable="false">RecordLogs</string>
|
<string name="settings_advanced_record_logs_key" translatable="false">RecordLogs</string>
|
||||||
<string name="settings_advanced_export_logs_key" translatable="false">ExportLogs</string>
|
<string name="settings_advanced_export_logs_key" translatable="false">ExportLogs</string>
|
||||||
<string name="settings_advanced_clear_logs_key" translatable="false">ClearLogs</string>
|
<string name="settings_advanced_clear_logs_key" translatable="false">ClearLogs</string>
|
||||||
|
|
|
@ -77,8 +77,8 @@
|
||||||
app:title="@string/settings_advanced_broadcast_title"
|
app:title="@string/settings_advanced_broadcast_title"
|
||||||
app:enabled="true"/>
|
app:enabled="true"/>
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
app:key="@string/settings_advanced_enable_up_key"
|
app:key="@string/settings_advanced_unifiedpush_key"
|
||||||
app:title="@string/settings_advanced_enable_up_title"
|
app:title="@string/settings_advanced_unifiedpush_title"
|
||||||
app:enabled="true"/>
|
app:enabled="true"/>
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
app:key="@string/settings_advanced_record_logs_key"
|
app:key="@string/settings_advanced_record_logs_key"
|
||||||
|
|
Loading…
Reference in a new issue