Wellbeing mode (#1992)
* Add wellbeing mode settings toggle * Translate wellbeing mode string to german * Disable fav/boost count on toots if wellbeing is enabled * Hide follow/post stats on profiles * Reload notifications when wellbeing mode is toggled * Add wellbeing mode explainer dialog * Move wellbeing filter timeline into own category * Add toggles for quantitative stats * Hide announcement badge counts if wellbeing is enabled * Move fetching of wellbeing setting to activity * Add wellbeing option to statusDisplayOptions * Update post filters for all accounts * Remove local translations * Revert "Remove local translations" This reverts commit e92e636a5c759b09649174ab68ec91bc13680287. * Remove german translations
This commit is contained in:
parent
05233de0f9
commit
0fbb4e9713
21 changed files with 164 additions and 29 deletions
|
|
@ -19,10 +19,14 @@ import android.os.Bundle
|
|||
import androidx.preference.Preference
|
||||
import androidx.preference.PreferenceFragmentCompat
|
||||
import com.keylesspalace.tusky.R
|
||||
import com.keylesspalace.tusky.db.AccountManager
|
||||
import com.keylesspalace.tusky.di.Injectable
|
||||
import com.keylesspalace.tusky.entity.Notification
|
||||
import com.keylesspalace.tusky.settings.*
|
||||
import com.keylesspalace.tusky.util.ThemeUtils
|
||||
import com.keylesspalace.tusky.util.deserialize
|
||||
import com.keylesspalace.tusky.util.getNonNullString
|
||||
import com.keylesspalace.tusky.util.serialize
|
||||
import com.mikepenz.iconics.IconicsDrawable
|
||||
import com.mikepenz.iconics.typeface.library.googlematerial.GoogleMaterial
|
||||
import com.mikepenz.iconics.utils.colorInt
|
||||
|
|
@ -35,6 +39,9 @@ class PreferencesFragment : PreferenceFragmentCompat(), Injectable {
|
|||
@Inject
|
||||
lateinit var okhttpclient: OkHttpClient
|
||||
|
||||
@Inject
|
||||
lateinit var accountManager: AccountManager
|
||||
|
||||
private val iconSize by lazy { resources.getDimensionPixelSize(R.dimen.preference_icon_size) }
|
||||
private var httpProxyPref: Preference? = null
|
||||
|
||||
|
|
@ -192,6 +199,45 @@ class PreferencesFragment : PreferenceFragmentCompat(), Injectable {
|
|||
}
|
||||
}
|
||||
|
||||
preferenceCategory(R.string.pref_title_wellbeing_mode) {
|
||||
switchPreference {
|
||||
title = getString(R.string.limit_notifications)
|
||||
setDefaultValue(false)
|
||||
key = PrefKeys.WELLBEING_LIMITED_NOTIFICATIONS
|
||||
setOnPreferenceChangeListener { _, value ->
|
||||
for (account in accountManager.accounts) {
|
||||
val notificationFilter = deserialize(account.notificationsFilter).toMutableSet()
|
||||
|
||||
if (value == true) {
|
||||
notificationFilter.add(Notification.Type.FAVOURITE)
|
||||
notificationFilter.add(Notification.Type.FOLLOW)
|
||||
notificationFilter.add(Notification.Type.REBLOG)
|
||||
} else {
|
||||
notificationFilter.remove(Notification.Type.FAVOURITE)
|
||||
notificationFilter.remove(Notification.Type.FOLLOW)
|
||||
notificationFilter.remove(Notification.Type.REBLOG)
|
||||
}
|
||||
|
||||
account.notificationsFilter = serialize(notificationFilter)
|
||||
accountManager.saveAccount(account)
|
||||
}
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
switchPreference {
|
||||
title = getString(R.string.wellbeing_hide_stats_posts)
|
||||
setDefaultValue(false)
|
||||
key = PrefKeys.WELLBEING_HIDE_STATS_POSTS
|
||||
}
|
||||
|
||||
switchPreference {
|
||||
title = getString(R.string.wellbeing_hide_stats_profile)
|
||||
setDefaultValue(false)
|
||||
key = PrefKeys.WELLBEING_HIDE_STATS_PROFILE
|
||||
}
|
||||
}
|
||||
|
||||
preferenceCategory(R.string.pref_title_proxy_settings) {
|
||||
httpProxyPref = preference {
|
||||
setTitle(R.string.pref_title_http_proxy_settings)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue