streaming: add opt-out option in the account settings
This commit is contained in:
parent
60565f9597
commit
f1bcc5bf02
|
@ -12,7 +12,8 @@
|
||||||
<string name="action_disable_formatting_syntax">Disable %s</string>
|
<string name="action_disable_formatting_syntax">Disable %s</string>
|
||||||
<string name="action_sticker">Stickers</string>
|
<string name="action_sticker">Stickers</string>
|
||||||
<string name="action_open_in_external_app">Open in external app</string>
|
<string name="action_open_in_external_app">Open in external app</string>
|
||||||
|
<string name="action_chat">Open a chat</string>
|
||||||
|
|
||||||
<string name="title_emoji_reacted_by">%s reacted by</string>
|
<string name="title_emoji_reacted_by">%s reacted by</string>
|
||||||
|
|
||||||
<string name="hint_appname">Application name</string>
|
<string name="hint_appname">Application name</string>
|
||||||
|
@ -31,6 +32,9 @@
|
||||||
<string name="notification_chat_message_name">Chat Messages</string>
|
<string name="notification_chat_message_name">Chat Messages</string>
|
||||||
<string name="notification_chat_message_description">Notifications about new chat messages</string>
|
<string name="notification_chat_message_description">Notifications about new chat messages</string>
|
||||||
|
|
||||||
|
<string name="pref_title_other">Other</string>
|
||||||
|
<string name="pref_title_live_notifications">Live notifications</string>
|
||||||
|
<string name="pref_summary_live_notifications">May slightly increase power consumption</string>
|
||||||
<string name="pref_title_default_formatting">Default formatting syntax(if supported by instance)</string>
|
<string name="pref_title_default_formatting">Default formatting syntax(if supported by instance)</string>
|
||||||
<string name="pref_title_notification_filter_emoji">my posts are reacted with emojis</string>
|
<string name="pref_title_notification_filter_emoji">my posts are reacted with emojis</string>
|
||||||
<string name="pref_title_notification_filter_chat_messages">received a chat message</string>
|
<string name="pref_title_notification_filter_chat_messages">received a chat message</string>
|
||||||
|
|
|
@ -61,6 +61,7 @@ import com.keylesspalace.tusky.interfaces.ActionButtonActivity
|
||||||
import com.keylesspalace.tusky.interfaces.ReselectableFragment
|
import com.keylesspalace.tusky.interfaces.ReselectableFragment
|
||||||
import com.keylesspalace.tusky.pager.MainPagerAdapter
|
import com.keylesspalace.tusky.pager.MainPagerAdapter
|
||||||
import com.keylesspalace.tusky.service.StreamingService
|
import com.keylesspalace.tusky.service.StreamingService
|
||||||
|
import com.keylesspalace.tusky.settings.PrefKeys
|
||||||
import com.keylesspalace.tusky.util.*
|
import com.keylesspalace.tusky.util.*
|
||||||
import com.mikepenz.iconics.IconicsDrawable
|
import com.mikepenz.iconics.IconicsDrawable
|
||||||
import com.mikepenz.iconics.typeface.library.googlematerial.GoogleMaterial
|
import com.mikepenz.iconics.typeface.library.googlematerial.GoogleMaterial
|
||||||
|
@ -190,7 +191,30 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje
|
||||||
|
|
||||||
setupTabs(showNotificationTab)
|
setupTabs(showNotificationTab)
|
||||||
|
|
||||||
// Setup push notifications
|
initPullNotifications()
|
||||||
|
|
||||||
|
eventHub.events
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.autoDispose(this, Lifecycle.Event.ON_DESTROY)
|
||||||
|
.subscribe { event: Event? ->
|
||||||
|
when (event) {
|
||||||
|
is ProfileEditedEvent -> onFetchUserInfoSuccess(event.newProfileData)
|
||||||
|
is MainTabsChangedEvent -> setupTabs(false)
|
||||||
|
is PreferenceChangedEvent -> {
|
||||||
|
when(event.preferenceKey) {
|
||||||
|
PrefKeys.LIVE_NOTIFICATIONS -> {
|
||||||
|
initPullNotifications()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Flush old media that was cached for sharing
|
||||||
|
deleteStaleCachedMedia(applicationContext.getExternalFilesDir("Husky"))
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun initPullNotifications() {
|
||||||
if (NotificationHelper.areNotificationsEnabled(this, accountManager)) {
|
if (NotificationHelper.areNotificationsEnabled(this, accountManager)) {
|
||||||
if(accountManager.areNotificationsStreamingEnabled()) {
|
if(accountManager.areNotificationsStreamingEnabled()) {
|
||||||
NotificationHelper.disablePullNotifications(this)
|
NotificationHelper.disablePullNotifications(this)
|
||||||
|
@ -203,18 +227,6 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje
|
||||||
StreamingService.stopStreaming(this)
|
StreamingService.stopStreaming(this)
|
||||||
NotificationHelper.disablePullNotifications(this)
|
NotificationHelper.disablePullNotifications(this)
|
||||||
}
|
}
|
||||||
eventHub.events
|
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
|
||||||
.autoDispose(this, Lifecycle.Event.ON_DESTROY)
|
|
||||||
.subscribe { event: Event? ->
|
|
||||||
when (event) {
|
|
||||||
is ProfileEditedEvent -> onFetchUserInfoSuccess(event.newProfileData)
|
|
||||||
is MainTabsChangedEvent -> setupTabs(false)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Flush old media that was cached for sharing
|
|
||||||
deleteStaleCachedMedia(applicationContext.getExternalFilesDir("Husky"))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
|
|
|
@ -229,6 +229,21 @@ class AccountPreferencesFragment : PreferenceFragmentCompat(), Injectable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
preferenceCategory(R.string.pref_title_other) {
|
||||||
|
switchPreference {
|
||||||
|
key = PrefKeys.LIVE_NOTIFICATIONS
|
||||||
|
setTitle(R.string.pref_title_live_notifications)
|
||||||
|
setSummary(R.string.pref_summary_live_notifications)
|
||||||
|
isSingleLineTitle = false
|
||||||
|
isChecked = accountManager.activeAccount?.notificationsStreamingEnabled ?: false
|
||||||
|
setOnPreferenceChangeListener { _, newValue ->
|
||||||
|
updateAccount { it.notificationsStreamingEnabled = newValue as Boolean }
|
||||||
|
eventHub.dispatch(PreferenceChangedEvent(key))
|
||||||
|
true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
preferenceCategory(R.string.pref_title_timeline_filters) {
|
preferenceCategory(R.string.pref_title_timeline_filters) {
|
||||||
preference {
|
preference {
|
||||||
setTitle(R.string.pref_title_public_filter_keywords)
|
setTitle(R.string.pref_title_public_filter_keywords)
|
||||||
|
|
|
@ -45,6 +45,7 @@ object PrefKeys {
|
||||||
const val MEDIA_PREVIEW_ENABLED = "mediaPreviewEnabled"
|
const val MEDIA_PREVIEW_ENABLED = "mediaPreviewEnabled"
|
||||||
const val ALWAYS_SHOW_SENSITIVE_MEDIA = "alwaysShowSensitiveMedia"
|
const val ALWAYS_SHOW_SENSITIVE_MEDIA = "alwaysShowSensitiveMedia"
|
||||||
const val ALWAYS_OPEN_SPOILER = "alwaysOpenSpoiler"
|
const val ALWAYS_OPEN_SPOILER = "alwaysOpenSpoiler"
|
||||||
|
const val LIVE_NOTIFICATIONS = "liveNotifications"
|
||||||
|
|
||||||
const val NOTIFICATIONS_ENABLED = "notificationsEnabled"
|
const val NOTIFICATIONS_ENABLED = "notificationsEnabled"
|
||||||
const val NOTIFICATION_ALERT_LIGHT = "notificationAlertLight"
|
const val NOTIFICATION_ALERT_LIGHT = "notificationAlertLight"
|
||||||
|
|
Loading…
Reference in New Issue