Yuito-app-android/app/src/main/java/com/keylesspalace/tusky/settings/SettingsConstants.kt

118 lines
5.5 KiB
Kotlin
Raw Normal View History

package com.keylesspalace.tusky.settings
enum class AppTheme(val value: String) {
NIGHT("night"),
DAY("day"),
BLACK("black"),
AUTO("auto"),
AUTO_SYSTEM("auto_system");
companion object {
fun stringValues() = values().map { it.value }.toTypedArray()
}
}
/**
* Current preferences schema version. Format is 4-digit year + 2 digit month (zero padded) + 2
* digit day (zero padded) + 2 digit counter (zero padded).
*
* If you make an incompatible change to the preferences schema you must:
*
* - Update this value
* - Update the code in
* [TuskyApplication.upgradeSharedPreferences][com.keylesspalace.tusky.TuskyApplication.upgradeSharedPreferences]
* to migrate from the old schema version to the new schema version.
*
* An incompatible change is:
*
* - Deleting a preference. The migration should delete the old preference.
* - Changing a preference's default value (e.g., from true to false, or from one enum value to
* another). The migration should check to see if the user had set an explicit value for
* that preference ([SharedPreferences.contains][android.content.SharedPreferences.contains]);
* if they hadn't then the migration should set the *old* default value as the preference's
* value, so the app behaviour does not unexpectedly change.
* - Changing a preference's type (e.g,. from a boolean to an enum). If you do this you may want
* to give the preference a different name, but you still need to migrate the user's previous
* preference value to the new preference.
* - Renaming a preference key. The migration should copy the user's previous value for the
* preference under the old key to the value for the new, and delete the old preference.
*
* A compatible change is:
*
* - Adding a new preference that does not change the interpretation of an existing preference
*/
const val SCHEMA_VERSION = 2023022701
object PrefKeys {
// Note: not all of these keys are actually used as SharedPreferences keys but we must give
// each preference a key for it to work.
Perform preference schema upgrades at startup (#3186) * Perform preference schema upgrades at startup Over time it can be desirable to change how preferences are interpreted. Preferences might be removed, or renamed. Or the default value for a preference might be changed. When this happens it's important that users upgrading from one version to the next (or jumping from one version to several versions ahead) get a consistent experience. In particular: - Preferences that no longer exist should be deleted - Preferences that have been renamed should have the old preference values copied over - If the user used the default value for the preference, and the default has changed, the previous default value should be explicitly set as their value for the preference To support this, store a SCHEMA_VERSION as a preference. This is not exposed to the user, and corresponds to the app's VERSION_CODE. If the version code does not match the schema version then this is a newer version of the app with older preferences that may need to be changed. Those changes will be implemented in `upgradeSharedPreferences`. * Translated using Weblate (Hungarian) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: Gera, Zoltan <gerazo@manioka.hu> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/hu/ Translation: Tusky/Tusky * Translated using Weblate (Chinese (Simplified)) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: Eric <alchemillatruth@purelymail.com> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/zh_Hans/ Translation: Tusky/Tusky * Translated using Weblate (Ukrainian) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: Ihor Hordiichuk <igor_ck@outlook.com> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/uk/ Translation: Tusky/Tusky * Translated using Weblate (Vietnamese) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: Hồ Nhất Duy <mastoduy@gmail.com> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/vi/ Translation: Tusky/Tusky * Translated using Weblate (Belarusian) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: Mikalai <mikalai.hryb@gmail.com> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/be/ Translation: Tusky/Tusky * Translated using Weblate (Belarusian) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: Andrej Zabavin <andre.zabavin@gmail.com> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/be/ Translation: Tusky/Tusky * Translated using Weblate (Belarusian) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: Mikalai <mikalai.hryb@gmail.com> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/be/ Translation: Tusky/Tusky * Translated using Weblate (Belarusian) Currently translated at 100.0% (552 of 552 strings) Translated using Weblate (Belarusian) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: xzFantom <xzfantom@gmail.com> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/be/ Translation: Tusky/Tusky * Translated using Weblate (Japanese) Currently translated at 91.3% (504 of 552 strings) Co-authored-by: TAKAHASHI Shuuji <shuuji3@gmail.com> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/ja/ Translation: Tusky/Tusky * Translated using Weblate (Icelandic) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: Sveinn í Felli <sv1@fellsnet.is> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/is/ Translation: Tusky/Tusky * Translated using Weblate (Belarusian) Currently translated at 100.0% (552 of 552 strings) Co-authored-by: Mikalai <mikalai.hryb@gmail.com> Translate-URL: https://weblate.tusky.app/projects/tusky/tusky/be/ Translation: Tusky/Tusky * Lint --------- Co-authored-by: Gera, Zoltan <gerazo@manioka.hu> Co-authored-by: Eric <alchemillatruth@purelymail.com> Co-authored-by: Ihor Hordiichuk <igor_ck@outlook.com> Co-authored-by: Hồ Nhất Duy <mastoduy@gmail.com> Co-authored-by: Mikalai <mikalai.hryb@gmail.com> Co-authored-by: Andrej Zabavin <andre.zabavin@gmail.com> Co-authored-by: xzFantom <xzfantom@gmail.com> Co-authored-by: TAKAHASHI Shuuji <shuuji3@gmail.com> Co-authored-by: Sveinn í Felli <sv1@fellsnet.is>
2023-02-04 20:19:01 +01:00
const val SCHEMA_VERSION: String = "schema_version"
const val APP_THEME = "appTheme"
const val EMOJI = "selected_emoji_font"
const val FAB_HIDE = "fabHide"
const val LANGUAGE = "language"
const val STATUS_TEXT_SIZE = "statusTextSize"
Keep scroll position when loading missing statuses (#3000) * Change "Load more" to load oldest statuses first in home timeline Previous behaviour loaded missing statuses by using "since_id" and "max_id". This loads the most recent N statuses, looking backwards from "max_id". Change to load the oldest statuses first, assuming the user is scrolling up through the timeline and will want to load statuses in reverse chronological order. * Scroll to the bottom of new entries added by "Load more" - Remember the position of the "Load more" placeholder - Check the position of inserted entries - If they match, scroll to the bottom * Change "Load more" to load oldest statuses first in home timeline Previous behaviour loaded missing statuses by using "since_id" and "max_id". This loads the most recent N statuses, looking backwards from "max_id". Change to load the oldest statuses first, assuming the user is scrolling up through the timeline and will want to load statuses in reverse chronological order. * Scroll to the bottom of new entries added by "Load more" - Remember the position of the "Load more" placeholder - Check the position of inserted entries - If they match, scroll to the bottom * Ensure the user can't have two simultaneous "Load more" coroutines Having two simultanous coroutines would break the calculation used to figure out which item in the list to scroll to after a "Load more" in the timeline. Do this by: - Creating a TimelineUiState and associated flow that tracks the "Load more" state - Updating this in the (Cached|Network)TimelineViewModel - Listening for changes to it in TimelineFragment, and notifying the adapter - The adapter will disable any placeholder views while "Load more" is active * Revert changes that loaded the oldest statuses instead of the newest * Be more robust about locating the status to scroll to Weirdness with the PagingData library meant that positionStart could still be wrong after "Load more" was clicked. Instead, remember the position of the "Load more" item and the ID of the status immediately after it. When new items are added, search for the remembered status at the position of the "Load more" item. This is quick, testing at most LOAD_AT_ONCE items in the adapter. If the remembered status is not visible on screen then scroll to it. * Lint * Add a preference to specify the reading order Default behaviour (oldest first) is for "load more" to load statuses and stay at the oldest of the new statuses. Alternative behaviour (if the user is reading from top to bottom) is to stay at the newest of the new statuses. * Move ReadingOrder enum construction logic in to the enum * Jump to top if swipe/refresh while preferring newest-first order * Show a circular progress spinner during "Load more" operations Remove a dedicated view, and use an icon on the button instead. Adjust the placeholder attributes and styles accordingly. * Remove the "loadMoreActive" property Complicates the code and doesn't really achieve the desired effect. If the user wants to tap multiple "Load more" buttons they can. * Update comments in TimelineFragment * Respect the user's reading order preference if it changes * Add developer tools This is for functionality that makes it easier for developers to interact with the app, or get it in to a known-state. These features are for use by users, so are only visible in debug builds. * Adjust how content is loaded based on preferred reading order - Add the readingOrder to TimelineViewModel so derived classes can use it. - Update the homeTimeline API to support the `minId` parameter and update calls in NetworkTimelineViewModel In CachedTimelineViewModel: - Set the bounds of the load to be the status IDs on either side of the placeholder ID (update TimelineDao with a new query for this) - Load statuses using either minId or sinceId depending on the reading order - Is there was no overlap then insert the new placeholder at the start/end of the list depending on reading order * Lint * Rename unused dialog parameter to _ * Update API arguments in tests * Simplify ReadingOrder preference handling * Fix bug with Placeholder and the "expanded" property If a status is a Placeholder the "expanded" propery is used to indicate whether or not it is loading. replaceStatusRange() set this property based on the old value, and the user's alwaysOpenSpoiler preference setting. This shouldn't have been used if the status is a Placeholder, as it can lead to incorrect loading states. Fix this. While I'm here, introduce an explicit computed property for whether a TimelineStatusEntity is a placeholder, and use that for code clarity. * Set the "Load more" button background to transparent * Fix typo. * Inline spec, update comment * Revert 1480c6aa3ac5c0c2d362fb271f47ea2259ab14e2 Turns out the behaviour is not desired. * Remove unnecessary Log call * Extract function * Change default to newest first
2023-01-13 19:26:24 +01:00
const val READING_ORDER = "readingOrder"
const val MAIN_NAV_POSITION = "mainNavPosition"
2020-08-16 10:01:51 +02:00
const val HIDE_TOP_TOOLBAR = "hideTopToolbar"
const val ABSOLUTE_TIME_VIEW = "absoluteTimeView"
const val SHOW_BOT_OVERLAY = "showBotOverlay"
const val ANIMATE_GIF_AVATARS = "animateGifAvatars"
const val USE_BLURHASH = "useBlurhash"
const val SHOW_SELF_USERNAME = "showSelfUsername"
const val SHOW_NOTIFICATIONS_FILTER = "showNotificationsFilter"
const val SHOW_CARDS_IN_TIMELINES = "showCardsInTimelines"
const val CONFIRM_REBLOGS = "confirmReblogs"
const val CONFIRM_FAVOURITES = "confirmFavourites"
const val ENABLE_SWIPE_FOR_TABS = "enableSwipeForTabs"
const val ANIMATE_CUSTOM_EMOJIS = "animateCustomEmojis"
const val SHOW_STATS_INLINE = "showStatsInline"
2021-08-03 17:16:40 +02:00
const val USE_QUICK_TOOT = "useQuickToot"
const val LIMITED_BANDWIDTH_ACTIVE = "limitedBandwidthActive"
const val LIMITED_BANDWIDTH_ONLY_MOBILE_NETWORK = "limitedBandwidthOnlyMobileNetwork"
const val LIMITED_BANDWIDTH_TIMELINE_LOADING = "limitedBandwidthTimelineLoading"
const val CUSTOM_TABS = "customTabs"
const val WELLBEING_LIMITED_NOTIFICATIONS = "wellbeingModeLimitedNotifications"
const val WELLBEING_HIDE_STATS_POSTS = "wellbeingHideStatsPosts"
const val WELLBEING_HIDE_STATS_PROFILE = "wellbeingHideStatsProfile"
const val HTTP_PROXY_ENABLED = "httpProxyEnabled"
const val HTTP_PROXY_SERVER = "httpProxyServer"
const val HTTP_PROXY_PORT = "httpProxyPort"
const val VIEW_PAGER_OFF_SCREEN_LIMIT = "viewPagerOffScreenLimit"
const val SEND_CRASH_REPORT = "sendCrashReport"
const val STACK_TRACE = "stackTrace"
const val DEFAULT_POST_PRIVACY = "defaultPostPrivacy"
const val DEFAULT_POST_LANGUAGE = "defaultPostLanguage"
const val DEFAULT_MEDIA_SENSITIVITY = "defaultMediaSensitivity"
const val MEDIA_PREVIEW_ENABLED = "mediaPreviewEnabled"
const val ALWAYS_SHOW_SENSITIVE_MEDIA = "alwaysShowSensitiveMedia"
const val ALWAYS_OPEN_SPOILER = "alwaysOpenSpoiler"
const val NOTIFICATIONS_ENABLED = "notificationsEnabled"
const val NOTIFICATION_ALERT_LIGHT = "notificationAlertLight"
const val NOTIFICATION_ALERT_VIBRATE = "notificationAlertVibrate"
const val NOTIFICATION_ALERT_SOUND = "notificationAlertSound"
const val NOTIFICATION_FILTER_POLLS = "notificationFilterPolls"
const val NOTIFICATION_FILTER_FAVS = "notificationFilterFavourites"
const val NOTIFICATION_FILTER_REBLOGS = "notificationFilterReblogs"
const val NOTIFICATION_FILTER_FOLLOW_REQUESTS = "notificationFilterFollowRequests"
const val NOTIFICATIONS_FILTER_FOLLOWS = "notificationFilterFollows"
const val NOTIFICATION_FILTER_SUBSCRIPTIONS = "notificationFilterSubscriptions"
const val NOTIFICATION_FILTER_SIGN_UPS = "notificationFilterSignUps"
const val NOTIFICATION_FILTER_UPDATES = "notificationFilterUpdates"
const val NOTIFICATION_FILTER_REPORTS = "notificationFilterReports"
const val TAB_FILTER_HOME_REPLIES = "tabFilterHomeReplies_v2" // This was changed once to reset an unintentionally set default.
const val TAB_FILTER_HOME_BOOSTS = "tabFilterHomeBoosts"
/** UI text scaling factor, stored as float, 100 = 100% = no scaling */
const val UI_TEXT_SCALE_RATIO = "uiTextScaleRatio"
}