A new profile now comes with Lumi, Habits and Practice installed and
pinned in that order on every device; Lists, Diary and Leaderboard wait
in More apps. Existing profiles keep their apps.
A choice nobody made, such as a new profile's apps, is stored at time 1
and never uploaded, so a newly signed-in device takes the account's apps
instead of removing them. The owner's install and remove choices keep
syncing per app in private.inbe.v1.app-preferences.
The pinned apps and their order sync as one record, app_order, in a new
collection private.inbe.v1.app-order that older versions skip. It is sent
only when the owner pins, moves or unpins an app; the newest order wins,
a pending local order wins a tie, and a record this version can't read
changes nothing without stopping the sync. An arriving order sets
app_order_received and the pins take it once, also after a restart. An
app removed on another device is unpinned here too.
Tests: storage sync round trips for app choices and order (defaults
never sent, stale and same-time records, unreadable records), the order
SQL, restore SQL, launcher policy encoding, and updated onboarding,
launcher, startup and Leaderboard UI expectations for the new defaults.
The Data screenshot scene installs Lists, which it opens from. The
Telegram flow fake gains HttpTransferPollLength, which sync_async has
called since c4babc97.
877 lines
39 KiB
Ziran
877 lines
39 KiB
Ziran
c :: #system_library "c";
|
|
app_force_dark_mode :: () -> bool #foreign c;
|
|
#import, file "../habits/habit_types.zi";
|
|
#import, file "../breaks/break_types.zi";
|
|
#import, file "../breaks/break_calendar.zi";
|
|
#import, file "../practices/sun_salutation/sun_salutation_rules.zi";
|
|
#import, file "../practices/tai_chi/tai_chi_course.zi";
|
|
#import, file "../practices/tai_chi/tai_chi_rules.zi";
|
|
#import, file "app_types.zi";
|
|
#import, file "exercise_types.zi";
|
|
#import, file "route_types.zi";
|
|
#import, file "app.zi";
|
|
#import, file "../core/types.zi";
|
|
#import, file "../core/breath_timing.zi";
|
|
#import, file "metrics.zi";
|
|
#import, file "locale.zi";
|
|
#import, file "locale_preferences.zi";
|
|
#import, file "text_buffers.zi";
|
|
#import, file "theme_catalog.zi";
|
|
#import, file "style_customization.zi";
|
|
#import "c_string"
|
|
#import, file "manual_seen.zi";
|
|
#import, file "settings_cache.zi";
|
|
#import, file "settings_upgrade.zi";
|
|
#import, file "settings_key.zi";
|
|
#import, file "settings_store.zi";
|
|
#import, file "bottom_nav_policy.zi";
|
|
#import, file "launcher_policy.zi";
|
|
#import, file "../cells/inbe_types.zi";
|
|
#import, file "../cells/catalog.zi";
|
|
#import, file "profile_picture_policy.zi";
|
|
#import, file "../platform/environment.zi";
|
|
#import, file "../platform/telegram_bridge.zi";
|
|
#import, file "../platform/web_storage.zi";
|
|
#import "layout"
|
|
|
|
#import, file "audio_selection.zi";
|
|
#import, file "audio_settings.zi";
|
|
|
|
using BreathAnimation;
|
|
using AppThemeMode;
|
|
using AppThemeSource;
|
|
using AppOrientationMode;
|
|
using NavigationMode;
|
|
using NavigationPlacement;
|
|
using AppMainTab;
|
|
using AppNavRoute;
|
|
using ExerciseType;
|
|
SettingsClamp :: (value: s32, minimum: s32, maximum: s32) -> s32 {
|
|
if value < minimum {
|
|
return minimum
|
|
}
|
|
if value > maximum {
|
|
return maximum
|
|
}
|
|
return value
|
|
}
|
|
|
|
load_navigation_mode :: () -> s32 {
|
|
default_nav: s32 = ifx AndroidPlatform() != 0 then cast(s32)NAV_MODE_DROPDOWN else cast(s32)NAV_MODE_TABBAR
|
|
|
|
value := SettingsCacheInt("navigation_mode", default_nav)
|
|
if value == NAV_MODE_DROPDOWN {
|
|
return NAV_MODE_DROPDOWN
|
|
}
|
|
return NAV_MODE_TABBAR
|
|
}
|
|
|
|
load_profile_picture_icon :: () -> s32 {
|
|
saved := SettingsCacheInt("profile_picture_icon", ProfilePictureDefault())
|
|
return ProfilePictureSelected(saved)
|
|
}
|
|
|
|
load_bottom_nav_routes :: (app: *InnerBreeze) {
|
|
if app == null {
|
|
return
|
|
}
|
|
// A new profile's apps, Lumi, Habits and Practice, in their order.
|
|
app.bottom_nav_route_count =
|
|
SettingsCacheInt("bottom_nav_route_count", 4)
|
|
app.bottom_nav_routes[0] =
|
|
SettingsCacheInt("bottom_nav_route_0", APP_NAV_ROUTE_LUMI)
|
|
app.bottom_nav_routes[1] =
|
|
SettingsCacheInt("bottom_nav_route_1", APP_NAV_ROUTE_HABITS)
|
|
app.bottom_nav_routes[2] =
|
|
SettingsCacheInt("bottom_nav_route_2", APP_NAV_ROUTE_PRACTICE)
|
|
app.bottom_nav_routes[3] =
|
|
SettingsCacheInt("bottom_nav_route_3", APP_NAV_ROUTE_SETTINGS)
|
|
app.bottom_nav_routes[4] = SettingsCacheInt("bottom_nav_route_4", APP_NAV_ROUTE_NONE)
|
|
app.bottom_nav_routes[5] = SettingsCacheInt("bottom_nav_route_5", APP_NAV_ROUTE_NONE)
|
|
app.bottom_nav_routes[6] = SettingsCacheInt("bottom_nav_route_6", APP_NAV_ROUTE_NONE)
|
|
profile_allowed := DesktopPlatform() != 0 && IsDesktopWidth(app.ui.view_width, 1.0)
|
|
app.bottom_nav_route_count = BottomNavSanitize(
|
|
app.bottom_nav_routes[:], app.bottom_nav_route_count, profile_allowed)
|
|
if SettingsCacheContains("launcher_favorite_count") {
|
|
app.launcher_favorite_count = SettingsCacheInt("launcher_favorite_count", 2)
|
|
app.launcher_favorites[0] = SettingsCacheInt("launcher_favorite_0", APP_NAV_ROUTE_HABITS)
|
|
app.launcher_favorites[1] = SettingsCacheInt("launcher_favorite_1", APP_NAV_ROUTE_PRACTICE)
|
|
for index: cast(s32)2..cast(s32)app.launcher_favorites.count - 1 {
|
|
key := SettingsKeyIndexed("launcher_favorite_", index, "")
|
|
app.launcher_favorites[index] = SettingsCacheIntBytes(
|
|
key.bytes[0:key.count], APP_NAV_ROUTE_NONE)
|
|
}
|
|
app.launcher_favorite_count = LauncherSanitizeFavorites(
|
|
app.launcher_favorites[:], app.launcher_favorite_count)
|
|
} else {
|
|
// Preserve every personal shortcut without changing app choices.
|
|
app.launcher_favorite_count = 0
|
|
if SettingsCacheContains("bottom_nav_route_count") {
|
|
for index: cast(s32)0..app.bottom_nav_route_count - 1 {
|
|
route := app.bottom_nav_routes[index]
|
|
app.launcher_favorite_count = LauncherToggleFavorite(
|
|
app.launcher_favorites[:], app.launcher_favorite_count, route)
|
|
}
|
|
} else {
|
|
app.launcher_favorite_count = LauncherDefaults(app.launcher_favorites[:])
|
|
}
|
|
}
|
|
// Pins another device of the account changed arrived before this device
|
|
// took them, for example when it closed during a practice.
|
|
if SettingsCacheInt(AppOrderReceivedKey, 0) != 0 {
|
|
order: [LAUNCHER_ORDER_TEXT_MAX + 1]u8
|
|
unused SettingsCacheCopyText(AppOrderKey, order[:])
|
|
unused app_take_app_order(app, AppTextFromCString(*order[0], LAUNCHER_ORDER_TEXT_MAX + 1))
|
|
}
|
|
}
|
|
|
|
// The pinned apps another device of the account sent replace this device's
|
|
// pins, once: a later change here stays here until the owner changes pins.
|
|
#program_export
|
|
app_take_app_order :: (app: *InnerBreeze, order: string) -> bool {
|
|
routes: [LAUNCHER_APP_COUNT]s32
|
|
count := LauncherOrderRoutes(order, routes[:])
|
|
changed := count != app.launcher_favorite_count
|
|
for index: cast(s32)0..count - 1 {
|
|
if routes[index] != app.launcher_favorites[index] {
|
|
changed = true
|
|
}
|
|
}
|
|
for index: cast(s32)0..count - 1 {
|
|
app.launcher_favorites[index] = routes[index]
|
|
}
|
|
app.launcher_favorite_count = count
|
|
if changed {
|
|
save_launcher_favorites(app)
|
|
}
|
|
unused SettingsStoreInt(AppOrderReceivedKey, 0)
|
|
return changed
|
|
}
|
|
|
|
// The owner changed the pins: their order goes to the account's other
|
|
// devices. A default or an order from another device is never sent back.
|
|
app_save_app_order :: (app: *InnerBreeze) {
|
|
if app == null || TelegramHostPresent() {
|
|
return
|
|
}
|
|
order: [LAUNCHER_ORDER_TEXT_MAX + 1]u8
|
|
unused LauncherOrderText(app.launcher_favorites[:], app.launcher_favorite_count, order[:])
|
|
unused SettingsStoreText(AppOrderKey, order[:])
|
|
}
|
|
|
|
save_launcher_favorites :: (app: *InnerBreeze) {
|
|
save_setting_int("launcher_favorite_count", app.launcher_favorite_count)
|
|
save_setting_int("launcher_favorite_0", app.launcher_favorites[0])
|
|
save_setting_int("launcher_favorite_1", app.launcher_favorites[1])
|
|
for index: cast(s32)2..cast(s32)app.launcher_favorites.count - 1 {
|
|
key := SettingsKeyIndexed("launcher_favorite_", index, "")
|
|
unused SettingsStoreInt(AppTextFromCString(*key.bytes[0], 48), app.launcher_favorites[index])
|
|
}
|
|
}
|
|
|
|
default_theme_source :: () -> s32 {
|
|
return APP_THEME_SOURCE_APP
|
|
}
|
|
|
|
apply_settings :: (breathing: *BreathSession, speed: s32, max_rounds: s32,
|
|
max_breaths: s32, pause_seconds: s32) {
|
|
speed = SettingsClamp(speed, SETTINGS_SPEED_MIN, SETTINGS_SPEED_MAX)
|
|
breathing.speed_level = speed
|
|
breathing.breath_half_ticks = BreathHalfTicksForSpeed(speed)
|
|
breathing.breath_animation = SettingsClamp(breathing.breath_animation,
|
|
BreathAnimationLinear,
|
|
BreathAnimationCount - 1)
|
|
breathing.progressive_start_speed = SettingsClamp(breathing.progressive_start_speed,
|
|
SETTINGS_SPEED_MIN, speed)
|
|
breathing.max_rounds = SettingsClamp(max_rounds, 1, MaxRounds)
|
|
breathing.pause_seconds = SettingsClamp(pause_seconds, SETTINGS_PAUSE_MIN,
|
|
SETTINGS_PAUSE_MAX)
|
|
BreathDigitsWrite(breathing.maxbreaths[:],
|
|
SettingsClamp(max_breaths, SETTINGS_BREATHS_MIN,
|
|
SETTINGS_BREATHS_MAX))
|
|
}
|
|
|
|
reset_settings_preview :: (app: *InnerBreeze) {
|
|
speed := app.breathing.speed_level
|
|
max_rounds := app.breathing.max_rounds
|
|
max_breaths := BreathDigitsRead(app.breathing.maxbreaths[:])
|
|
pause_seconds := app.breathing.pause_seconds
|
|
play_in_background := app.breathing.play_in_background
|
|
breath_animation := app.breathing.breath_animation
|
|
view_width := app.ui.view_width
|
|
if view_width <= 0 {
|
|
view_width = ifx DesktopPlatform() != 0 then 900 else 320
|
|
}
|
|
column := CenteredColumnFor(view_width, CONTENT_MAX_W, CONTENT_SIDE_PAD)
|
|
|
|
app.settings_preview = BreathSessionInit()
|
|
app.settings_preview.progressive_speed = 0
|
|
app.settings_preview.play_in_background = play_in_background
|
|
app.settings_preview.breath_animation = breath_animation
|
|
app.settings_preview = BreathPreviewBounds(app.settings_preview,
|
|
column.width, AppScale(132), AppScale(60), AppScale(120),
|
|
AppScale(24), AppScale(10))
|
|
apply_settings(*app.settings_preview, speed, max_rounds, max_breaths,
|
|
pause_seconds)
|
|
app.settings_preview = BreathResetRoundBreathe(app.settings_preview)
|
|
}
|
|
|
|
save_setting_int :: (key: string, value: s32) {
|
|
SettingsStoreInt(key, value)
|
|
}
|
|
|
|
save_key_bool :: (key: SettingsKey, value: s32) {
|
|
SettingsStoreKeyInt(key, ifx value != 0 then 1 else 0)
|
|
}
|
|
|
|
#program_export
|
|
save_settings :: (app: *InnerBreeze) {
|
|
if app == null {
|
|
return
|
|
}
|
|
|
|
SettingsBeginWrite()
|
|
save_setting_int("speed", app.breathing.speed_level)
|
|
save_setting_int("max_rounds", app.breathing.max_rounds)
|
|
save_setting_int("max_breaths", BreathDigitsRead(app.breathing.maxbreaths[:]))
|
|
save_setting_int("pause_seconds", app.breathing.pause_seconds)
|
|
save_setting_int("sound_volume", app.sound_volume)
|
|
save_setting_int("music_volume", app.music_volume)
|
|
save_setting_int("voice_narration_enabled", app.voice_narration_enabled)
|
|
AudioSettingsSave(app)
|
|
save_setting_int("retention_marker_enabled",
|
|
ifx app.retention_marker_enabled != 0 then 1 else 0)
|
|
save_setting_int("minute_bell_enabled",
|
|
ifx app.minute_bell_enabled != 0 then 1 else 0)
|
|
save_setting_int("tutorial_seen", ifx app.tutorial_seen != 0 then 1 else 0)
|
|
save_setting_int("tutorial_step", app.tutorial_step)
|
|
save_setting_int("habits_guide_seen", ifx app.habits_guide_seen != 0 then 1 else 0)
|
|
save_setting_int("launcher_guide_seen", app.launcher_guide_seen)
|
|
save_setting_int("lumi_guides_seen", app.lumi_guides_seen)
|
|
save_setting_int("exercise_manual_seen_mask", app.exercise_manual_seen_mask)
|
|
save_setting_int("style_pack", app.style_index)
|
|
save_setting_int("theme", app.theme_id)
|
|
save_setting_int("theme_source", app.theme_source)
|
|
save_setting_int("dark_mode", app.dark_mode)
|
|
save_setting_int("theme_mode", app.theme_mode)
|
|
save_setting_int("style_lightfield_glow", ifx app.lightfield_glow_enabled != 0 then 1 else 0)
|
|
save_setting_int("orientation_mode", app.orientation_mode)
|
|
save_setting_int("ui_scale", app.ui_scale_tenths)
|
|
save_setting_int("navigation_mode", app.navigation_mode)
|
|
save_setting_int("navigation_placement", app.navigation_placement)
|
|
save_setting_int("navigation_collapsed", app.nav_rail_collapsed)
|
|
save_launcher_favorites(app)
|
|
save_setting_int("profile_picture_icon", app.profile_picture_icon)
|
|
save_setting_int("bottom_nav_route_count", app.bottom_nav_route_count)
|
|
save_setting_int("bottom_nav_route_0", app.bottom_nav_routes[0])
|
|
save_setting_int("bottom_nav_route_1", app.bottom_nav_routes[1])
|
|
save_setting_int("bottom_nav_route_2", app.bottom_nav_routes[2])
|
|
save_setting_int("bottom_nav_route_3", app.bottom_nav_routes[3])
|
|
save_setting_int("bottom_nav_route_4", app.bottom_nav_routes[4])
|
|
save_setting_int("bottom_nav_route_5", app.bottom_nav_routes[5])
|
|
save_setting_int("bottom_nav_route_6", app.bottom_nav_routes[6])
|
|
save_setting_int("main_tab", app.main_tab)
|
|
SettingsStoreText("profile_display_name", app.profile_display_name[:])
|
|
SettingsStoreText("profile_intention", app.profile_intention[:])
|
|
save_setting_int("habits_screen_mode", app.habits.screen_mode)
|
|
save_setting_int("habits_tab", app.habits.tab)
|
|
save_setting_int("habits_view_mode", app.habits.view_mode)
|
|
save_setting_int("fullscreen", ifx app.fullscreen_enabled != 0 then 1 else 0)
|
|
save_setting_int("on_screen_keyboard",
|
|
ifx app.on_screen_keyboard_enabled != 0 then 1 else 0)
|
|
save_setting_int("picture_in_picture",
|
|
ifx app.picture_in_picture_enabled != 0 then 1 else 0)
|
|
save_setting_int("notification_friend_request",
|
|
ifx app.notification_friend_request != 0 then 1 else 0)
|
|
save_setting_int("notification_habit_reminders",
|
|
ifx app.notification_habit_reminders != 0 then 1 else 0)
|
|
save_setting_int("reminder_count", app.reminder_count)
|
|
for i: 0..(APP_REMINDER_MAX - 1) {
|
|
r: *AppReminder = *app.reminders[i]
|
|
practice: s32 = 0
|
|
hour: s32 = 0
|
|
enabled: s32 = 0
|
|
last_day: s32 = 0
|
|
if cast(s32)i < app.reminder_count {
|
|
practice = r.practice
|
|
hour = r.hour
|
|
last_day = r.last_day
|
|
if r.enabled != 0 { enabled = 1 }
|
|
}
|
|
SettingsStoreKeyInt(SettingsKeyReminder(cast(s32)i, "practice"), practice)
|
|
SettingsStoreKeyInt(SettingsKeyReminder(cast(s32)i, "hour"), hour)
|
|
SettingsStoreKeyInt(SettingsKeyReminder(cast(s32)i, "enabled"), enabled)
|
|
SettingsStoreKeyInt(SettingsKeyReminder(cast(s32)i, "last_day"), last_day)
|
|
}
|
|
save_setting_int("progressive_speed", app.breathing.progressive_speed)
|
|
save_setting_int("progressive_start_speed",
|
|
app.breathing.progressive_start_speed)
|
|
save_setting_int("breath_animation", app.breathing.breath_animation)
|
|
save_setting_int("advanced_session_controls",
|
|
ifx app.advanced_session_controls != 0 then 1 else 0)
|
|
save_setting_int("double_tap_to_breathe",
|
|
ifx app.double_tap_to_breathe != 0 then 1 else 0)
|
|
save_setting_int("exercise_type", app.exercise_type)
|
|
save_setting_int("sun_salutation_character", app.sun_salutation.character)
|
|
save_setting_int("practice_order", practice_order_code())
|
|
save_setting_int("sun_salutation_flat_characters", 1)
|
|
save_setting_int("sun_salutation_repetitions",
|
|
app.sun_salutation.repetitions)
|
|
save_setting_int("sun_salutation_start_seconds",
|
|
app.sun_salutation.start_seconds)
|
|
save_setting_int("sun_salutation_end_seconds",
|
|
app.sun_salutation.end_seconds)
|
|
save_setting_int("sun_salutation_breath_tempo", 1)
|
|
save_setting_int("sun_salutation_voice", app.sun_salutation_voice)
|
|
unused SettingsStoreText("sun_salutation_narration_language", app.sun_salutation_narration_language[:])
|
|
unused SettingsStoreText("tai_chi_narration_language", app.tai_chi_narration_language[:])
|
|
save_setting_int("tai_chi_character", app.tai_chi.character)
|
|
save_setting_int("tai_chi_view", app.tai_chi.view)
|
|
save_setting_int("tai_chi_voice", app.tai_chi.voice)
|
|
save_setting_int("tai_chi_item", app.tai_chi.item)
|
|
save_setting_int("tai_chi_habit_made", app.tai_chi.habit_made)
|
|
tai_chi_progress: [TAI_CHI_PROGRESS_DIGITS + 1]u8
|
|
unused TaiChiProgressText(app.tai_chi, tai_chi_progress[:])
|
|
unused SettingsStoreText("tai_chi_progress", tai_chi_progress[:])
|
|
save_setting_int("meditation_duration_mode",
|
|
app.meditation.duration_mode)
|
|
save_setting_int("meditation_custom_minutes",
|
|
app.meditation.custom_minutes)
|
|
save_setting_int("meditation_show_extend_controls",
|
|
ifx app.meditation.show_extend_controls != 0 then 1 else 0)
|
|
save_setting_int("meditation_interval_bell",
|
|
app.meditation.interval_bell_minutes)
|
|
save_setting_int("meditation_music_track", app.meditation.music_track)
|
|
save_setting_int("practice_music_mask",
|
|
app.meditation.music_practice_mask)
|
|
for i: 0..(EXERCISE_COUNT - 1) {
|
|
SettingsStoreKeyInt(SettingsKeyMusicTrack(cast(s32)i),
|
|
app.meditation.music_practice_tracks[i])
|
|
}
|
|
save_setting_int("play_in_background", app.breathing.play_in_background)
|
|
save_setting_int("play_in_background_default_on", 1)
|
|
save_setting_int("practice_category_tab", app.practice_category_tab)
|
|
save_setting_int("patterns_preset", app.patterns.preset)
|
|
save_setting_int("patterns_custom_in", app.patterns.custom[0])
|
|
save_setting_int("patterns_custom_hold_in", app.patterns.custom[1])
|
|
save_setting_int("patterns_custom_exhale", app.patterns.custom[2])
|
|
save_setting_int("patterns_custom_hold_out", app.patterns.custom[3])
|
|
save_setting_int("patterns_duration_minutes", app.patterns.duration_minutes)
|
|
|
|
if DesktopPlatform() != 0 {
|
|
save_setting_int("breaks_enabled", ifx app.breaks_enabled != 0 then 1 else 0)
|
|
} else if WebPlatform() != 0 {
|
|
save_setting_int("breaks_enabled",
|
|
ifx WebExtensionHost() != 0 && app.breaks_enabled != 0 then 1 else 0)
|
|
} else {
|
|
save_setting_int("breaks_enabled", 0)
|
|
}
|
|
save_setting_int("desktop_startup_mode", app.desktop_startup_mode)
|
|
save_setting_int("desktop_close_action", app.desktop_close_action)
|
|
save_setting_int("break_block_mode", app.break_block_mode)
|
|
save_setting_int("break_sounds_enabled", ifx app.break_sounds_enabled != 0 then 1 else 0)
|
|
save_setting_int("break_hud_x", app.break_hud_x)
|
|
save_setting_int("break_hud_y", app.break_hud_y)
|
|
save_setting_int("break_reading_mode", ifx app.breaks.reading_mode != 0 then 1 else 0)
|
|
save_setting_int("break_micro_counts_as_activity",
|
|
ifx app.breaks.micro_counts_as_activity != 0 then 1 else 0)
|
|
for t: 0..(BREAK_TYPE_COUNT - 1) {
|
|
timer: *BreakTimer = *app.breaks.timers[t]
|
|
save_key_bool(SettingsKeyBreak(cast(s32)t, "enabled"), timer.enabled)
|
|
SettingsStoreKeyInt(SettingsKeyBreak(cast(s32)t, "limit"), timer.limit_s)
|
|
SettingsStoreKeyInt(SettingsKeyBreak(cast(s32)t, "duration"), timer.duration_s)
|
|
SettingsStoreKeyInt(SettingsKeyBreak(cast(s32)t, "postpone"), timer.postpone_s)
|
|
SettingsStoreKeyInt(SettingsKeyBreak(cast(s32)t, "max_prompts"),
|
|
timer.max_prompts)
|
|
save_key_bool(SettingsKeyBreak(cast(s32)t, "show_skip"), timer.show_skip)
|
|
save_key_bool(SettingsKeyBreak(cast(s32)t, "show_postpone"),
|
|
timer.show_postpone)
|
|
}
|
|
save_setting_int("break_daily_state_day", app.breaks.day_key)
|
|
save_setting_int("break_daily_state_active",
|
|
app.breaks.timers[BREAK_DAILY].active_s)
|
|
save_setting_int("break_daily_state_skipped",
|
|
ifx app.breaks.timers[BREAK_DAILY].skipped_today != 0 then 1 else 0)
|
|
|
|
if app.language_selected != 0 && app.language_system == 0 && app.language[0] != 0 {
|
|
SettingsStoreText("language", app.language[:])
|
|
} else {
|
|
empty_language: [1]u8
|
|
SettingsStoreText("language", empty_language[:])
|
|
}
|
|
save_setting_int("language_setup_done", ifx app.language_selected != 0 then 1 else 0)
|
|
// A Telegram delegate cannot change the owner's app preferences. In a
|
|
// fresh hosted profile, these writes would also queue unowned changes
|
|
// before explicit account creation or recovery has been approved.
|
|
if !TelegramHostPresent() {
|
|
save_setting_int("enabled_apps", app.enabled_apps)
|
|
save_setting_int("apps_setup_done", app.apps_selected)
|
|
if app.apps_selected != 0 {
|
|
for index: cast(s32)1..cast(s32)(PackageCount - 1) {
|
|
save_setting_int(PackagePreferenceKey(index),
|
|
ifx (app.enabled_apps & PackageBit(index)) != 0 then 1 else 0)
|
|
}
|
|
}
|
|
}
|
|
SettingsEndWrite()
|
|
sync_web_storage()
|
|
app.settings_dirty = 0
|
|
app.settings_save_delay_ticks = 0
|
|
}
|
|
|
|
load_language_setting :: (app: *InnerBreeze, settings_missing: s32) {
|
|
SettingsCacheCopyText("language", app.language[:])
|
|
setup_done := SettingsCacheInt("language_setup_done",
|
|
ifx settings_missing != 0 then 0 else 1)
|
|
|
|
had_saved_code := app.language[0] != 0
|
|
app.language_needs_save = 0
|
|
if had_saved_code && LocaleUse(AppTextFromCString(*app.language[0], 16)) {
|
|
app.language_system = 0
|
|
app.language_selected = 1
|
|
} else {
|
|
preferred := LocalePreferred(LocaleSystemPreferences())
|
|
if !LocaleUse(preferred) {
|
|
LocaleUse("en")
|
|
}
|
|
CopyCString(LocaleActiveCode(), app.language[:])
|
|
app.language_system = 1
|
|
app.language_selected = ifx had_saved_code || setup_done != 0 then 1 else 0
|
|
app.language_needs_save = ifx had_saved_code then 1 else 0
|
|
}
|
|
app.language_index = LocaleActiveIndex()
|
|
}
|
|
|
|
load_bool_setting :: (dst: *s32, key: string, fallback: s32) {
|
|
dst.* = ifx SettingsCacheInt(key, fallback) != 0 then 1 else 0
|
|
}
|
|
|
|
load_clamped_setting :: (dst: *s32,
|
|
key: string, fallback: s32, min_value: s32,
|
|
max_value: s32) {
|
|
value := SettingsCacheInt(key, fallback)
|
|
dst.* = SettingsClamp(value, min_value, max_value)
|
|
}
|
|
|
|
load_bool_key :: (dst: *s32, key: SettingsKey, fallback: s32) {
|
|
if !key.valid { return }
|
|
dst.* = 0
|
|
if SettingsCacheIntBytes(key.bytes[0:key.count], fallback) != 0 {
|
|
dst.* = 1
|
|
}
|
|
}
|
|
|
|
load_clamped_key :: (dst: *s32, key: SettingsKey, fallback: s32,
|
|
min_value: s32, max_value: s32) {
|
|
if !key.valid { return }
|
|
value: s32 = SettingsCacheIntBytes(key.bytes[0:key.count], fallback)
|
|
dst.* = SettingsClamp(value, min_value, max_value)
|
|
}
|
|
|
|
load_reminders :: (app: *InnerBreeze) {
|
|
if app == null {
|
|
return
|
|
}
|
|
if !SettingsCacheContains("reminder_count") {
|
|
app.reminder_count = 1
|
|
app.reminders[0].practice = 0
|
|
app.reminders[0].hour = 8
|
|
app.reminders[0].enabled = 1
|
|
app.reminders[0].last_day = 0
|
|
return
|
|
}
|
|
app.reminder_count = SettingsClamp(
|
|
SettingsCacheInt("reminder_count", 1), 0,
|
|
APP_REMINDER_MAX)
|
|
for i: 0..(cast(int)app.reminder_count - 1) {
|
|
r: *AppReminder = *app.reminders[i]
|
|
r.practice = 0
|
|
r.hour = 8
|
|
r.enabled = 1
|
|
r.last_day = 0
|
|
load_clamped_key(*r.practice, SettingsKeyReminder(cast(s32)i, "practice"),
|
|
0, 0, APP_REMINDER_PRACTICE_COUNT - 1)
|
|
load_clamped_key(*r.hour, SettingsKeyReminder(cast(s32)i, "hour"), 8, 0, 23)
|
|
load_bool_key(*r.enabled, SettingsKeyReminder(cast(s32)i, "enabled"), 1)
|
|
load_clamped_key(*r.last_day, SettingsKeyReminder(cast(s32)i, "last_day"),
|
|
0, 0, 99999999)
|
|
}
|
|
}
|
|
|
|
app_load_settings :: (app: *InnerBreeze) -> s32 {
|
|
settings_missing: s32
|
|
speed: s32
|
|
max_rounds: s32
|
|
max_breaths: s32
|
|
pause_seconds: s32
|
|
manual_seen_mask: s32
|
|
music_max: s32
|
|
|
|
if app == null {
|
|
return 0
|
|
}
|
|
|
|
settings_missing = SettingsEmpty()
|
|
SettingsCacheLoad()
|
|
StyleCustomizationLoad()
|
|
|
|
speed = SettingsCacheInt("speed", DefaultSpeedLevel)
|
|
max_rounds = SettingsCacheInt("max_rounds",
|
|
DefaultMaxRounds)
|
|
max_breaths = SettingsCacheInt("max_breaths",
|
|
DefaultMaxBreaths)
|
|
pause_seconds = SettingsCacheInt("pause_seconds",
|
|
DefaultPauseSeconds)
|
|
|
|
load_bool_setting(*app.tutorial_seen, "tutorial_seen", 0)
|
|
load_clamped_setting(*app.tutorial_step,
|
|
"tutorial_step", 0, 0, 9999)
|
|
load_bool_setting(*app.habits_guide_seen,
|
|
"habits_guide_seen", 0)
|
|
load_bool_setting(*app.launcher_guide_seen, "launcher_guide_seen", 0)
|
|
load_clamped_setting(*app.lumi_guides_seen, "lumi_guides_seen", 0, 0, 127)
|
|
load_bool_setting(*app.dark_mode, "dark_mode", 0)
|
|
load_bool_setting(*app.fullscreen_enabled,
|
|
"fullscreen", 0)
|
|
if AndroidPlatform() != 0 || WebPlatform() != 0 {
|
|
load_bool_setting(*app.on_screen_keyboard_enabled,
|
|
"on_screen_keyboard", 1)
|
|
} else {
|
|
load_bool_setting(*app.on_screen_keyboard_enabled,
|
|
"on_screen_keyboard", 0)
|
|
}
|
|
load_bool_setting(*app.picture_in_picture_enabled,
|
|
"picture_in_picture", 1)
|
|
load_bool_setting(*app.notification_friend_request,
|
|
"notification_friend_request", 1)
|
|
load_bool_setting(*app.notification_habit_reminders,
|
|
"notification_habit_reminders", 0)
|
|
load_reminders(app)
|
|
load_bool_setting(*app.breathing.progressive_speed,
|
|
"progressive_speed", 1)
|
|
load_bool_setting(*app.advanced_session_controls,
|
|
"advanced_session_controls", 0)
|
|
load_bool_setting(*app.double_tap_to_breathe,
|
|
"double_tap_to_breathe", 0)
|
|
load_bool_setting(*app.meditation.show_extend_controls,
|
|
"meditation_show_extend_controls", 1)
|
|
load_bool_setting(*app.retention_marker_enabled,
|
|
"retention_marker_enabled", 0)
|
|
load_bool_setting(*app.minute_bell_enabled,
|
|
"minute_bell_enabled", 0)
|
|
load_bool_setting(*app.breaks_enabled,
|
|
"breaks_enabled", app.breaks_enabled)
|
|
if WebPlatform() != 0 {
|
|
if WebExtensionHost() == 0 {
|
|
app.breaks_enabled = 0
|
|
}
|
|
} else if DesktopPlatform() == 0 {
|
|
app.breaks_enabled = 0
|
|
}
|
|
load_clamped_setting(*app.desktop_startup_mode,
|
|
"desktop_startup_mode", 0, 0, STARTUP_COUNT - 1)
|
|
load_clamped_setting(*app.desktop_close_action,
|
|
"desktop_close_action", 0, 0, CLOSE_COUNT - 1)
|
|
load_clamped_setting(*app.break_block_mode,
|
|
"break_block_mode", 0, 0, 2)
|
|
load_bool_setting(*app.break_sounds_enabled,
|
|
"break_sounds_enabled", 1)
|
|
load_clamped_setting(*app.break_hud_x,
|
|
"break_hud_x", -1, -1, 32767)
|
|
load_clamped_setting(*app.break_hud_y,
|
|
"break_hud_y", -1, -1, 32767)
|
|
load_bool_setting(*app.breaks.reading_mode,
|
|
"break_reading_mode", 0)
|
|
load_bool_setting(*app.breaks.micro_counts_as_activity,
|
|
"break_micro_counts_as_activity", 0)
|
|
for t: 0..(BREAK_TYPE_COUNT - 1) {
|
|
timer: *BreakTimer = *app.breaks.timers[t]
|
|
load_bool_key(*timer.enabled, SettingsKeyBreak(cast(s32)t, "enabled"),
|
|
timer.enabled)
|
|
load_clamped_key(*timer.limit_s, SettingsKeyBreak(cast(s32)t, "limit"),
|
|
timer.limit_s, 30, 86400)
|
|
load_clamped_key(*timer.duration_s,
|
|
SettingsKeyBreak(cast(s32)t, "duration"), timer.duration_s, 0, 3600)
|
|
load_clamped_key(*timer.postpone_s,
|
|
SettingsKeyBreak(cast(s32)t, "postpone"), timer.postpone_s, 10, 3600)
|
|
load_clamped_key(*timer.max_prompts,
|
|
SettingsKeyBreak(cast(s32)t, "max_prompts"), timer.max_prompts, 0, 10)
|
|
load_bool_key(*timer.show_skip, SettingsKeyBreak(cast(s32)t, "show_skip"),
|
|
timer.show_skip)
|
|
load_bool_key(*timer.show_postpone,
|
|
SettingsKeyBreak(cast(s32)t, "show_postpone"), timer.show_postpone)
|
|
}
|
|
load_clamped_setting(*app.breaks.day_key,
|
|
"break_daily_state_day", 0, 0, 999999999)
|
|
app.breaks.day_key = BreakDayFromStoredKey(app.breaks.day_key)
|
|
load_clamped_setting(
|
|
*app.breaks.timers[BREAK_DAILY].active_s,
|
|
"break_daily_state_active", 0, 0, 86400)
|
|
load_bool_setting(
|
|
*app.breaks.timers[BREAK_DAILY].skipped_today,
|
|
"break_daily_state_skipped", 0)
|
|
if AndroidPlatform() != 0 || WebPlatform() != 0 {
|
|
app.on_screen_keyboard_enabled = 1
|
|
}
|
|
|
|
load_clamped_setting(*app.sound_volume, "sound_volume",
|
|
100, SETTINGS_VOLUME_MIN, SETTINGS_VOLUME_MAX)
|
|
load_clamped_setting(*app.music_volume, "music_volume",
|
|
50, SETTINGS_VOLUME_MIN, SETTINGS_VOLUME_MAX)
|
|
load_bool_setting(*app.voice_narration_enabled, "voice_narration_enabled", 1)
|
|
AudioSettingsLoad(app)
|
|
music_max = app_audio_music_count(app) - 1
|
|
if music_max < 0 {
|
|
music_max = 0
|
|
}
|
|
load_clamped_setting(*app.style_index, "style_pack", 1, 1, 3)
|
|
load_clamped_setting(*app.theme_id, "theme", ThemeDefaultId, 0,
|
|
ThemeCount - 1)
|
|
theme_source_default := default_theme_source()
|
|
if SettingsThemePickedBeforeSources() {
|
|
theme_source_default = APP_THEME_SOURCE_APP
|
|
}
|
|
load_clamped_setting(*app.theme_source, "theme_source",
|
|
theme_source_default, APP_THEME_SOURCE_APP,
|
|
APP_THEME_SOURCE_SYSTEM)
|
|
load_clamped_setting(*app.theme_mode, "theme_mode",
|
|
APP_THEME_DARK, APP_THEME_SYSTEM, APP_THEME_DARK)
|
|
if SettingsCacheContains("style_lightfield_glow") {
|
|
load_bool_setting(*app.lightfield_glow_enabled,
|
|
"style_lightfield_glow", 0)
|
|
} else {
|
|
load_bool_setting(*app.lightfield_glow_enabled, "glow_effects", 0)
|
|
save_setting_int("style_lightfield_glow", app.lightfield_glow_enabled)
|
|
}
|
|
load_clamped_setting(*app.orientation_mode,
|
|
"orientation_mode", APP_ORIENTATION_SYSTEM,
|
|
APP_ORIENTATION_SYSTEM, APP_ORIENTATION_SENSOR)
|
|
load_clamped_setting(*app.ui_scale_tenths,
|
|
"ui_scale", 10, 5, 25)
|
|
load_clamped_setting(*app.main_tab, "main_tab",
|
|
APP_MAIN_TAB_LUMI, APP_MAIN_TAB_NONE,
|
|
APP_MAIN_TAB_LEADERBOARD)
|
|
load_clamped_setting(*app.habits.screen_mode,
|
|
"habits_screen_mode", HABITS_SCREEN_OVERVIEW,
|
|
HABITS_SCREEN_OVERVIEW, HABITS_SCREEN_STATISTICS)
|
|
load_clamped_setting(*app.habits.tab, "habits_tab",
|
|
HABIT_TAB_WEEKLY, HABIT_TAB_WEEKLY,
|
|
HABIT_TAB_COUNT - 1)
|
|
load_clamped_setting(*app.habits.view_mode,
|
|
"habits_view_mode", HABIT_VIEW_WEEKLY,
|
|
HABIT_VIEW_CALENDAR, HABIT_VIEW_WEEKLY)
|
|
load_clamped_setting(*app.breathing.progressive_start_speed,
|
|
"progressive_start_speed",
|
|
DefaultProgressiveStartSpeed, SETTINGS_SPEED_MIN,
|
|
SETTINGS_SPEED_MAX)
|
|
load_clamped_setting(*app.breathing.breath_animation,
|
|
"breath_animation", BreathAnimationLinear,
|
|
BreathAnimationLinear,
|
|
BreathAnimationCount - 1)
|
|
load_clamped_setting(*app.exercise_type,
|
|
"exercise_type", EXERCISE_WIM_HOF,
|
|
EXERCISE_WIM_HOF, EXERCISE_COUNT - 1)
|
|
practice_order_load(SettingsCacheInt("practice_order", 0))
|
|
// The four painted characters became the flat woman and man. A choice
|
|
// saved before keeps its side once: the painted women (0 and 1) become
|
|
// the woman, the painted men (2 and 3) the man.
|
|
flat_characters: s32 = 0
|
|
load_clamped_setting(*flat_characters, "sun_salutation_flat_characters", 0, 0, 1)
|
|
if flat_characters == 0 {
|
|
painted_character: s32 = 0
|
|
load_clamped_setting(*painted_character, "sun_salutation_character", 0, 0, 3)
|
|
app.sun_salutation.character = 0
|
|
if painted_character >= 2 {
|
|
app.sun_salutation.character = SUN_SALUTATION_MAN
|
|
}
|
|
} else {
|
|
load_clamped_setting(*app.sun_salutation.character,
|
|
"sun_salutation_character", 0, 0,
|
|
SUN_SALUTATION_CHARACTER_COUNT - 1)
|
|
}
|
|
load_clamped_setting(*app.sun_salutation.repetitions,
|
|
"sun_salutation_repetitions", 3, 2, 12)
|
|
load_clamped_setting(*app.sun_salutation.start_seconds,
|
|
"sun_salutation_start_seconds", SUN_SALUTATION_DEFAULT_START_SECONDS,
|
|
SUN_SALUTATION_SECONDS_MIN, SUN_SALUTATION_SECONDS_MAX)
|
|
load_clamped_setting(*app.sun_salutation.end_seconds,
|
|
"sun_salutation_end_seconds", SUN_SALUTATION_DEFAULT_END_SECONDS,
|
|
SUN_SALUTATION_SECONDS_MIN, SUN_SALUTATION_SECONDS_MAX)
|
|
// Each pose now follows one breath. Settings still on the old default
|
|
// tempo (8 s slowing to 5 s per pose, saved with every setting) move to
|
|
// the breath tempo once; a tempo chosen later stays.
|
|
breath_tempo: s32 = 0
|
|
load_clamped_setting(*breath_tempo, "sun_salutation_breath_tempo", 0, 0, 1)
|
|
if breath_tempo == 0 && app.sun_salutation.start_seconds == 8 &&
|
|
app.sun_salutation.end_seconds == 5 {
|
|
app.sun_salutation.start_seconds = SUN_SALUTATION_DEFAULT_START_SECONDS
|
|
app.sun_salutation.end_seconds = SUN_SALUTATION_DEFAULT_END_SECONDS
|
|
}
|
|
load_clamped_setting(*app.sun_salutation_voice, "sun_salutation_voice", -1, -1, 1)
|
|
unused SettingsCacheCopyText("sun_salutation_narration_language", app.sun_salutation_narration_language[:])
|
|
unused SettingsCacheCopyText("tai_chi_narration_language", app.tai_chi_narration_language[:])
|
|
load_clamped_setting(*app.tai_chi.character,
|
|
"tai_chi_character", 0, 0, TAI_CHI_CHARACTER_COUNT - 1)
|
|
load_clamped_setting(*app.tai_chi.view,
|
|
"tai_chi_view", TAI_CHI_VIEW_FRONT, 0, TAI_CHI_VIEW_COUNT - 1)
|
|
load_clamped_setting(*app.tai_chi.voice, "tai_chi_voice", -1, -1, 1)
|
|
load_clamped_setting(*app.tai_chi.item,
|
|
"tai_chi_item", -1, -1, TAI_CHI_ITEM_CAPACITY - 1)
|
|
load_clamped_setting(*app.tai_chi.habit_made,
|
|
"tai_chi_habit_made", 0, 0, 1)
|
|
tai_chi_progress: [TAI_CHI_PROGRESS_DIGITS + 1]u8
|
|
if SettingsCacheCopyText("tai_chi_progress", tai_chi_progress[:]) {
|
|
app.tai_chi = TaiChiProgressRead(app.tai_chi,
|
|
AppTextFromCString(*tai_chi_progress[0], TAI_CHI_PROGRESS_DIGITS + 1))
|
|
}
|
|
load_clamped_setting(*app.meditation.duration_mode,
|
|
"meditation_duration_mode", 1, 0, 5)
|
|
load_clamped_setting(*app.meditation.custom_minutes,
|
|
"meditation_custom_minutes", 20, 1, 240)
|
|
load_clamped_setting(*app.meditation.interval_bell_minutes,
|
|
"meditation_interval_bell", 0, 0, 30)
|
|
load_clamped_setting(*app.meditation.music_track,
|
|
"meditation_music_track", 0, 0,
|
|
music_max)
|
|
load_clamped_setting(
|
|
*app.meditation.music_practice_mask,
|
|
"practice_music_mask", 1 << EXERCISE_MEDITATION,
|
|
0, (1 << EXERCISE_COUNT) - 1)
|
|
for i: 0..(EXERCISE_COUNT - 1) {
|
|
default_track: s32 = AUDIO_MUSIC_NONE
|
|
if i == EXERCISE_MEDITATION { default_track = 0 }
|
|
load_clamped_key(*app.meditation.music_practice_tracks[i],
|
|
SettingsKeyMusicTrack(cast(s32)i), default_track, -1, music_max)
|
|
}
|
|
for i: 0..(EXERCISE_COUNT - 1) {
|
|
if (app.meditation.music_practice_mask & (1 << cast(s32)i)) == 0 && app.meditation.music_practice_tracks[i] >= 0 {
|
|
app.meditation.music_practice_tracks[i] = AUDIO_MUSIC_NONE
|
|
}
|
|
}
|
|
app_audio_music_sanitize_selection(app)
|
|
load_clamped_setting(*app.practice_category_tab,
|
|
"practice_category_tab", PRACTICE_CATEGORY_MIND,
|
|
0, PRACTICE_CATEGORY_COUNT - 1)
|
|
load_clamped_setting(*app.patterns.preset,
|
|
"patterns_preset", 0, 0, 4)
|
|
load_clamped_setting(*app.patterns.custom[0],
|
|
"patterns_custom_in", 4, 0, 60)
|
|
load_clamped_setting(*app.patterns.custom[1],
|
|
"patterns_custom_hold_in", 4, 0, 60)
|
|
load_clamped_setting(*app.patterns.custom[2],
|
|
"patterns_custom_exhale", 4, 0, 60)
|
|
load_clamped_setting(*app.patterns.custom[3],
|
|
"patterns_custom_hold_out", 0, 0, 60)
|
|
load_clamped_setting(*app.patterns.duration_minutes,
|
|
"patterns_duration_minutes", 5, 0, 120)
|
|
app.navigation_mode = load_navigation_mode()
|
|
load_clamped_setting(*app.navigation_placement,
|
|
"navigation_placement", NAVIGATION_AUTOMATIC,
|
|
NAVIGATION_AUTOMATIC, NAVIGATION_TOP)
|
|
load_bool_setting(*app.nav_rail_collapsed,
|
|
"navigation_collapsed", 0)
|
|
app.profile_picture_icon = load_profile_picture_icon()
|
|
SettingsCacheCopyText("profile_display_name", app.profile_display_name[:])
|
|
SettingsCacheCopyText("profile_intention", app.profile_intention[:])
|
|
app.profile_name_cursor = cast(s32)AppTextFromCString(
|
|
*app.profile_display_name[0], 64).count
|
|
app.profile_intention_cursor = cast(s32)AppTextFromCString(
|
|
*app.profile_intention[0], 128).count
|
|
load_bottom_nav_routes(app)
|
|
if app.bottom_nav_route_count <= 0 {
|
|
app.main_tab = APP_MAIN_TAB_NONE
|
|
} else if app.main_tab == APP_MAIN_TAB_NONE {
|
|
if app.bottom_nav_routes[0] == APP_NAV_ROUTE_HABITS {
|
|
app.main_tab = APP_MAIN_TAB_HABITS
|
|
} else {
|
|
app.main_tab = APP_MAIN_TAB_PRACTICE
|
|
}
|
|
}
|
|
|
|
manual_seen_mask = SettingsCacheInt(
|
|
"exercise_manual_seen_mask", -1)
|
|
if manual_seen_mask < 0 {
|
|
manual_seen_mask = 0
|
|
if app.tutorial_seen != 0 {
|
|
manual_seen_mask = exercise_manual_seen_bit(EXERCISE_WIM_HOF)
|
|
}
|
|
}
|
|
app.exercise_manual_seen_mask =
|
|
manual_seen_mask & ((1 << EXERCISE_COUNT) - 1)
|
|
load_language_setting(app, settings_missing)
|
|
// Existing profiles retain their app choices. A new profile comes with
|
|
// Lumi, Habits and Practice; the other apps are added from More apps.
|
|
app.enabled_apps = SettingsCacheInt("enabled_apps",
|
|
ifx settings_missing != 0 then APP_RECOMMENDED else APP_LISTS | APP_RECOMMENDED) & APP_ALL
|
|
for index: cast(s32)1..cast(s32)(PackageCount - 1) {
|
|
key := PackagePreferenceKey(index)
|
|
if SettingsCacheContains(key) {
|
|
bit := PackageBit(index)
|
|
if SettingsCacheInt(key, 0) != 0 {
|
|
app.enabled_apps |= bit
|
|
}
|
|
else {
|
|
app.enabled_apps &= ~bit
|
|
}
|
|
}
|
|
}
|
|
// Ordinary profiles migrate their saved app choices. A hosted delegate
|
|
// reads those choices without creating owner preference outbox rows.
|
|
// A new profile already has Lumi among its default apps.
|
|
if !TelegramHostPresent() && !SettingsCacheContains("lumi_introduced") {
|
|
if settings_missing == 0 && !SettingsCacheContains("app_used_lumi") {
|
|
app.enabled_apps |= APP_LUMI
|
|
save_setting_int("app_used_lumi", 1)
|
|
}
|
|
save_setting_int("enabled_apps", app.enabled_apps)
|
|
save_setting_int("lumi_introduced", 1)
|
|
}
|
|
// Leaderboard moved from Profile into its own app. Existing profiles get
|
|
// it installed once, and removing it later is respected. New profiles
|
|
// add it from More apps.
|
|
if !TelegramHostPresent() && !SettingsCacheContains("leaderboard_introduced") {
|
|
if settings_missing == 0 && !SettingsCacheContains("app_used_leaderboard") {
|
|
app.enabled_apps |= APP_LEADERBOARD
|
|
save_setting_int("app_used_leaderboard", 1)
|
|
save_setting_int("enabled_apps", app.enabled_apps)
|
|
}
|
|
save_setting_int("leaderboard_introduced", 1)
|
|
}
|
|
// Apps nobody chose, such as a new profile's, are stored as defaults: a
|
|
// choice from the account's other devices replaces them, and they are
|
|
// never sent, so a new device cannot remove the account's apps.
|
|
if !TelegramHostPresent() {
|
|
for index: cast(s32)1..cast(s32)(PackageCount - 1) {
|
|
key := PackagePreferenceKey(index)
|
|
if !SettingsCacheContains(key) {
|
|
unused SettingsStoreDefaultBool(key, (app.enabled_apps & PackageBit(index)) != 0)
|
|
}
|
|
}
|
|
}
|
|
app.apps_selected = SettingsCacheInt("apps_setup_done",
|
|
ifx settings_missing != 0 then 0 else 1)
|
|
|
|
if app_force_dark_mode() {
|
|
app.theme_mode = APP_THEME_DARK
|
|
}
|
|
// Practices keep playing in the background by default. An older release
|
|
// switched this off for every install, so each install is moved back on
|
|
// once; after that the Settings toggle is the user's choice.
|
|
if !SettingsCacheContains("play_in_background_default_on") {
|
|
app.breathing.play_in_background = 1
|
|
SettingsStoreInt("play_in_background", 1)
|
|
SettingsStoreInt("play_in_background_default_on", 1)
|
|
} else {
|
|
app.breathing.play_in_background = 0
|
|
if SettingsCacheInt("play_in_background", 1) != 0 {
|
|
app.breathing.play_in_background = 1
|
|
}
|
|
}
|
|
app.backgrounded = 0
|
|
|
|
apply_settings(*app.breathing, speed, max_rounds, max_breaths,
|
|
pause_seconds)
|
|
SettingsCacheFree()
|
|
return settings_missing
|
|
}
|