Compare commits

...
6 Commits
Author SHA1 Message Date
waozixyz f12ef05421 update version 2026-06-17 18:50:36 -03:00
waozixyz 1732b31031 improve and fix improt 2026-06-17 18:50:24 -03:00
waozixyz b14ca1c8c9 fix issues with runtime assets 2026-06-17 16:43:48 -03:00
waozixyz 9466bf02ed fix no of assets 2026-06-17 16:33:01 -03:00
waozixyz acbd43bc65 bug fixes 2026-06-17 16:30:25 -03:00
waozixyz 06d79002e1 fix appimage 2026-06-17 15:36:27 -03:00
39 changed files with 1718 additions and 224 deletions

No files matched your search

+10
View File
@@ -1,4 +1,14 @@
# Changelog
## [1.3.3] - 2026-06-17
### Fixed
- Import now restores habits, habit sync settings, and optionally app settings from Inbe SQLite exports.
## [1.3.2] - 2026-06-17
### Fixed
- Unified scroll containers so content stays out of scrollbar tracks and scroll positions clamp cleanly at the bottom.
- Android meditation audio downloads now show a localized network-permission/connectivity modal when the host cannot be resolved.
- Windows builds now support runtime meditation audio downloads.
## [1.3.1] - 2026-06-17
### Fixed
- Fixed Android orientation resizing and habit import merging by name.
+25 -12
View File
@@ -61,8 +61,8 @@ FLINT_SRCS := $(filter-out $(FLINT_ICON_ASSETS_C),$(wildcard $(FLINT_DIR)/src/*.
FLINT_WEB_SRCS := $(filter-out $(FLINT_DIR)/src/flint_file_dialog.c,$(FLINT_SRCS))
FLINT_WINDOWS_SRCS := $(filter-out $(FLINT_DIR)/src/flint_file_dialog.c,$(FLINT_SRCS))
FLINT_INCLUDE := -I$(FLINT_DIR)/include
FLINT_CURL_CFLAGS ?= $(shell pkg-config --cflags libcurl 2>/dev/null)
FLINT_CURL_LDLIBS ?= $(shell pkg-config --libs libcurl 2>/dev/null)
FLINT_CURL_CFLAGS ?= $(shell pkg-config --cflags libcurl 2>/dev/null || curl-config --cflags 2>/dev/null)
FLINT_CURL_LDLIBS ?= $(shell pkg-config --libs libcurl 2>/dev/null || curl-config --libs 2>/dev/null)
SQLITE_DIR := vendor/sqlite
SQLITE_BUILD_DIR := $(BUILD_OBJ_DIR)/sqlite
SQLITE_AMALGAMATION_C := $(SQLITE_BUILD_DIR)/sqlite3.c
@@ -72,13 +72,9 @@ SQLITE_INCLUDE := -I$(SQLITE_BUILD_DIR)
TEST_BIN_DIR := $(BUILD_BIN_DIR)/tests
STORAGE_IMPORT_TEST := $(TEST_BIN_DIR)/storage_import_test
FLINT_TEXT_SCALING_TEST := $(TEST_BIN_DIR)/flint_text_scaling_test
ifneq ($(strip $(FLINT_CURL_LDLIBS)),)
LOCALE_KEYS_TEST := $(TEST_BIN_DIR)/locale_keys_test
FLINT_RUNTIME_ASSET_CFLAGS := -DFLINT_HAS_LIBCURL=1 $(FLINT_CURL_CFLAGS)
FLINT_RUNTIME_ASSET_LDLIBS := $(FLINT_CURL_LDLIBS)
else
FLINT_RUNTIME_ASSET_CFLAGS :=
FLINT_RUNTIME_ASSET_LDLIBS :=
endif
APP_SRCS := \
src/main.c \
@@ -117,7 +113,7 @@ WINDOWS_CFLAGS := -Wall -Wextra -std=c99 -Os -D_DEFAULT_SOURCE -D_GNU_SOURCE -ff
WEB_CFLAGS := $(filter-out -std=c99,$(CFLAGS)) -std=gnu99
LDFLAGS := -Wl,--gc-sections -s
WINDOWS_LDFLAGS := -Wl,--gc-sections -static -static-libgcc -mwindows
WINDOWS_LDLIBS := -lgdi32 -lwinmm -lopengl32 -luser32 -lshell32 -lole32 -lcomdlg32 -lcomctl32 -luuid -lm
WINDOWS_LDLIBS := -lgdi32 -lwinmm -lopengl32 -luser32 -lshell32 -lole32 -lcomdlg32 -lcomctl32 -luuid -lwininet -lm
ifneq ($(strip $(MCFGTHREADS)),)
WIN64_THREAD_LDFLAGS := -L$(MCFGTHREADS)/lib
else
@@ -147,7 +143,7 @@ WEB_ASSET_FILES := $(shell find web-assets -type f 2>/dev/null)
UNPACKAGED_AUDIO_DIR := unpackaged_assets/audio
MEDITATION_AUDIO_ZIP := web-assets/dl/inbe-meditation-audio-v1.zip
.PHONY: all native run test dist appimage clean clean-linux clean-raylib android-check-keystore android-copy-assets android-debug android-release android-bundle android-install android-install-release android-clean package-unpackaged-assets windows windows64 windows32 web
.PHONY: all native run test dist appimage clean clean-linux clean-raylib android-check-keystore android-copy-assets android-debug android-release android-bundle android-install android-install-release android-clean package-unpackaged-assets windows-runtime-assets-check windows windows64 windows32 web
.NOTPARALLEL: dist windows windows64 windows32 android-release android-bundle
all: native
@@ -180,9 +176,10 @@ appimage: $(APPIMAGE_TARGET)
run: $(TARGET)
./$(TARGET)
test: $(STORAGE_IMPORT_TEST) $(FLINT_TEXT_SCALING_TEST)
test: $(STORAGE_IMPORT_TEST) $(FLINT_TEXT_SCALING_TEST) $(LOCALE_KEYS_TEST)
$(STORAGE_IMPORT_TEST)
$(FLINT_TEXT_SCALING_TEST)
$(LOCALE_KEYS_TEST)
$(STORAGE_IMPORT_TEST): tests/storage_import_test.c src/storage/storage.c src/storage/storage.h src/screens/habits_screen.c src/screens/habits_screen.h src/third_party/miniz.c src/third_party/miniz.h $(SQLITE_SRC) $(SQLITE_AMALGAMATION_H) | $(TEST_BIN_DIR)
$(CC) -Wall -Wextra -std=c99 -D_DEFAULT_SOURCE -D_GNU_SOURCE -DMINIZ_NO_ZLIB_COMPATIBLE_NAMES -ffunction-sections -fdata-sections \
@@ -198,6 +195,11 @@ $(FLINT_TEXT_SCALING_TEST): tests/flint_text_scaling_test.c flint/src/flint_text
tests/flint_text_scaling_test.c flint/src/flint_text.c flint/src/flint_clip.c flint/src/flint_scaling.c \
-Wl,--gc-sections -lm
$(LOCALE_KEYS_TEST): tests/locale_keys_test.c $(LOCALE_FILES) | $(TEST_BIN_DIR)
$(CC) -Wall -Wextra -std=c99 -D_DEFAULT_SOURCE \
-o $@ \
tests/locale_keys_test.c
$(BUILD_OBJ_DIR) $(LINUX_BIN_DIR) $(LINUX_DIST_DIR) $(LINUX_APPIMAGE_BUILD_DIR) $(WINDOWS_DIST_DIR) $(ANDROID_BUILD_DIR) $(TEST_BIN_DIR) $(WEB_OBJ_DIR) $(WEB_DIST_DIR):
mkdir -p $@
@@ -353,11 +355,16 @@ $(APPIMAGE_TARGET): $(TARGET) $(LINUX_APPIMAGE_APPRUN) $(LINUX_APPIMAGE_DESKTOP)
echo "appimagetool is missing. Re-enter the flake shell with: nix develop"; \
exit 1; \
}
@command -v patchelf >/dev/null || { \
echo "patchelf is missing. Re-enter the flake shell with: nix develop"; \
exit 1; \
}
rm -rf $(LINUX_APPDIR)
rm -rf $(LINUX_DIST_DIR)/*.AppDir
rm -f $(LINUX_DIST_DIR)/*.AppImage
mkdir -p $(LINUX_APPDIR)/usr/bin $(LINUX_APPDIR)/usr/share/applications $(LINUX_APPDIR)/usr/share/icons/hicolor/512x512/apps
cp $(TARGET) $(LINUX_APPDIR)/usr/bin/$(APP_NAME)
patchelf --set-interpreter /lib64/ld-linux-x86-64.so.2 $(LINUX_APPDIR)/usr/bin/$(APP_NAME)
cp $(LINUX_APPIMAGE_APPRUN) $(LINUX_APPDIR)/AppRun
chmod +x $(LINUX_APPDIR)/AppRun
cp $(LINUX_APPIMAGE_DESKTOP) $(LINUX_APPDIR)/$(APP_NAME).desktop
@@ -525,9 +532,12 @@ package-unpackaged-assets:
rm -f $(MEDITATION_AUDIO_ZIP)
cd $(UNPACKAGED_AUDIO_DIR) && find . -mindepth 2 -type f -name '*.ogg' -exec zip -9 -r $(abspath $(MEDITATION_AUDIO_ZIP)) {} + && zip -9 -r $(abspath $(MEDITATION_AUDIO_ZIP)) LICENSE.md MANIFEST.txt
windows64: $(WIN64_TARGET)
windows-runtime-assets-check:
@:
windows32: $(WIN32_TARGET)
windows64: windows-runtime-assets-check $(WIN64_TARGET)
windows32: windows-runtime-assets-check $(WIN32_TARGET)
windows:
$(MAKE) windows64
@@ -568,4 +578,7 @@ endif
ifeq ($(strip $(RAY_RAYLIB_CONFIG)),)
$(error RAY_RAYLIB_CONFIG is not set. Enter the ray flake shell with 'nix develop')
endif
ifeq ($(strip $(FLINT_CURL_LDLIBS)),)
$(error libcurl pkg-config metadata is missing. Runtime asset downloads are required; enter the flake shell with 'nix develop' or set FLINT_CURL_CFLAGS/FLINT_CURL_LDLIBS explicitly)
endif
endif
Binary file not shown.
Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.
Binary file not shown.

Before

Width:  |  Height:  |  Size: 72 KiB

After

Width:  |  Height:  |  Size: 76 KiB

+2 -2
View File
@@ -35,8 +35,8 @@ android {
defaultConfig {
minSdk 19
targetSdk 35
versionCode 29
versionName "1.3.1"
versionCode 31
versionName "1.3.3"
}
@@ -27,6 +27,9 @@ import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.SocketException;
import java.net.SocketTimeoutException;
import java.net.UnknownHostException;
import java.net.URL;
public class MainActivity extends NativeActivity {
@@ -249,6 +252,9 @@ public class MainActivity extends NativeActivity {
}
nativeRuntimeAssetDownloadSucceeded(handle, written, status);
} catch (UnknownHostException | SocketException | SocketTimeoutException e) {
outputFile.delete();
nativeRuntimeAssetDownloadFailed(handle, status, "NETWORK_UNAVAILABLE");
} catch (Exception e) {
outputFile.delete();
nativeRuntimeAssetDownloadFailed(handle, status, e.getMessage());
@@ -0,0 +1,3 @@
### Fixed
- Unified scroll containers so content stays out of scrollbar tracks and scroll positions clamp cleanly at the bottom.
- Android meditation audio downloads now show a localized network-permission/connectivity modal when the host cannot be resolved.
@@ -0,0 +1,2 @@
### Fixed
- Import now restores habits, habit sync settings, and optionally app settings from Inbe SQLite exports.
+1
View File
@@ -191,6 +191,7 @@ EOF
butler
cmake
curl
curl.dev
emscripten
gcc
git-lfs
+3
View File
@@ -126,6 +126,8 @@ typedef struct {
typedef struct {
Rectangle bounds;
int content_height;
int content_x;
int content_width;
int *scroll_offset;
int wheel_step;
int scrollbar_x;
@@ -257,6 +259,7 @@ int ui_scrollbar_reserved_width(int max_scroll);
int ui_scrollbar_content_width(int content_width, int max_scroll);
int ui_scrollbar_safe_content_width(int content_x, int content_width,
int scrollbar_x, int max_scroll);
FlintUIScrollView ui_scroll_container_measure(FlintUIScrollArea area);
FlintUIScrollView ui_scroll_container_begin(FlintUIScrollArea area);
void ui_scroll_container_end(FlintUIScrollArea area, FlintUIScrollView view);
int ui_draw_scrollbar(int x, int y, int viewport_h, int content_h, int *scroll_offset, int max_scroll);
+145 -1
View File
@@ -7,6 +7,8 @@
#if defined(_WIN32)
#include <direct.h>
#include <windows.h>
#include <wininet.h>
#define FLINT_MKDIR(path) _mkdir(path)
#else
#include <errno.h>
@@ -208,6 +210,128 @@ fetch_failed(emscripten_fetch_t *fetch)
}
#endif
#if defined(_WIN32) && !defined(__EMSCRIPTEN__)
typedef struct WindowsDownloadContext {
FlintRuntimeAssetDownload *download;
} WindowsDownloadContext;
static void
windows_set_last_error(FlintRuntimeAssetDownload *download, const char *prefix)
{
DWORD err = GetLastError();
if(download == NULL)
return;
snprintf(download->error, sizeof(download->error), "%s (%lu)",
prefix != NULL ? prefix : "Windows download failed",
(unsigned long)err);
}
static DWORD WINAPI
windows_download_thread_main(void *user_data)
{
WindowsDownloadContext *ctx = (WindowsDownloadContext *)user_data;
FlintRuntimeAssetDownload *download = ctx != NULL ? ctx->download : NULL;
HINTERNET internet = NULL;
HINTERNET request = NULL;
FILE *file = NULL;
char status_buf[32];
DWORD status_len = sizeof(status_buf);
DWORD status_index = 0;
char length_buf[64];
DWORD length_len = sizeof(length_buf);
DWORD length_index = 0;
BYTE buffer[32768];
DWORD bytes_read = 0;
BOOL read_ok;
free(ctx);
if(download == NULL)
return 0;
file = fopen(download->path, "wb");
if(file == NULL) {
snprintf(download->error, sizeof(download->error), "failed to open %.200s", download->path);
download->status = FLINT_RUNTIME_ASSET_ERROR;
return 0;
}
internet = InternetOpenA("flint-runtime-assets/1",
INTERNET_OPEN_TYPE_PRECONFIG,
NULL, NULL, 0);
if(internet == NULL) {
fclose(file);
windows_set_last_error(download, "failed to initialize Windows networking");
download->status = FLINT_RUNTIME_ASSET_ERROR;
return 0;
}
request = InternetOpenUrlA(internet, download->url, NULL, 0,
INTERNET_FLAG_RELOAD |
INTERNET_FLAG_NO_CACHE_WRITE |
INTERNET_FLAG_PRAGMA_NOCACHE,
0);
if(request == NULL) {
fclose(file);
InternetCloseHandle(internet);
remove(download->path);
windows_set_last_error(download, "Windows download failed");
download->status = FLINT_RUNTIME_ASSET_ERROR;
return 0;
}
if(HttpQueryInfoA(request, HTTP_QUERY_STATUS_CODE, status_buf, &status_len, &status_index)) {
status_buf[sizeof(status_buf) - 1] = '\0';
download->http_status = strtol(status_buf, NULL, 10);
}
if(download->http_status < 200 || download->http_status >= 300) {
snprintf(download->error, sizeof(download->error), "HTTP %ld", download->http_status);
fclose(file);
InternetCloseHandle(request);
InternetCloseHandle(internet);
remove(download->path);
download->status = FLINT_RUNTIME_ASSET_ERROR;
return 0;
}
if(HttpQueryInfoA(request, HTTP_QUERY_CONTENT_LENGTH, length_buf, &length_len, &length_index)) {
length_buf[sizeof(length_buf) - 1] = '\0';
download->total_bytes = (size_t)strtoull(length_buf, NULL, 10);
}
while((read_ok = InternetReadFile(request, buffer, sizeof(buffer), &bytes_read)) && bytes_read > 0) {
if(fwrite(buffer, 1, bytes_read, file) != bytes_read) {
snprintf(download->error, sizeof(download->error), "failed to write %.200s", download->path);
fclose(file);
InternetCloseHandle(request);
InternetCloseHandle(internet);
remove(download->path);
download->status = FLINT_RUNTIME_ASSET_ERROR;
return 0;
}
download->bytes += (size_t)bytes_read;
}
if(!read_ok) {
fclose(file);
InternetCloseHandle(request);
InternetCloseHandle(internet);
remove(download->path);
windows_set_last_error(download, "Windows download failed");
download->status = FLINT_RUNTIME_ASSET_ERROR;
return 0;
}
fclose(file);
InternetCloseHandle(request);
InternetCloseHandle(internet);
if(download->total_bytes == 0)
download->total_bytes = download->bytes;
download->status = FLINT_RUNTIME_ASSET_READY;
return 0;
}
#endif
#if defined(FLINT_HAS_LIBCURL) && !defined(__EMSCRIPTEN__)
typedef struct NativeDownloadContext {
FlintRuntimeAssetDownload *download;
@@ -251,7 +375,7 @@ curl_thread_main(void *user_data)
file = fopen(download->path, "wb");
if(file == NULL) {
snprintf(download->error, sizeof(download->error), "failed to open %s", download->path);
snprintf(download->error, sizeof(download->error), "failed to open %.200s", download->path);
download->status = FLINT_RUNTIME_ASSET_ERROR;
return NULL;
}
@@ -348,6 +472,26 @@ flint_runtime_asset_download(FlintRuntimeAssetDownload *download,
emscripten_fetch(&attr, download->url);
return 1;
}
#elif defined(_WIN32)
{
HANDLE thread;
WindowsDownloadContext *ctx = (WindowsDownloadContext *)calloc(1, sizeof(*ctx));
if(ctx == NULL) {
snprintf(download->error, sizeof(download->error), "out of memory");
download->status = FLINT_RUNTIME_ASSET_ERROR;
return 0;
}
ctx->download = download;
thread = CreateThread(NULL, 0, windows_download_thread_main, ctx, 0, NULL);
if(thread == NULL) {
free(ctx);
windows_set_last_error(download, "failed to create download thread");
download->status = FLINT_RUNTIME_ASSET_ERROR;
return 0;
}
CloseHandle(thread);
return 1;
}
#elif defined(FLINT_HAS_LIBCURL)
{
pthread_t thread;
+37 -25
View File
@@ -2779,25 +2779,22 @@ ui_scrollbar_safe_content_width(int content_x, int content_width,
}
FlintUIScrollView
ui_scroll_container_begin(FlintUIScrollArea area)
ui_scroll_container_measure(FlintUIScrollArea area)
{
static int content_drag_active = 0;
static int content_dragging = 0;
static int content_drag_start_y = 0;
static int content_drag_start_scroll = 0;
FlintUIScrollView view;
Vector2 mouse_world = ui_mouse_world();
int wheel_step = area.wheel_step > 0 ? area.wheel_step : flint_px(42);
int x = (int)area.bounds.x;
int y = (int)area.bounds.y;
int w = (int)area.bounds.width;
int h = (int)area.bounds.height;
int inside = CheckCollisionPointRec(mouse_world, area.bounds);
int captured = ui_input_captures_click(mouse_world);
int drag_threshold = flint_px(5);
int scrollbar_w = flint_px(8);
int scrollbar_x = area.scrollbar_x > 0
? area.scrollbar_x
: x + w - scrollbar_w;
int content_x = area.content_x > 0 ? area.content_x : x;
int content_w = area.content_width > 0 ? area.content_width : w;
memset(&view, 0, sizeof(view));
view.content_x = x;
view.content_x = content_x;
view.viewport_h = h;
view.content_h = area.content_height > 0 ? area.content_height : 0;
view.max_scroll = view.content_h - h;
@@ -2805,19 +2802,39 @@ ui_scroll_container_begin(FlintUIScrollArea area)
view.max_scroll = 0;
if(area.scroll_offset != NULL) {
if(*area.scroll_offset < 0)
*area.scroll_offset = 0;
if(*area.scroll_offset > view.max_scroll)
*area.scroll_offset = view.max_scroll;
int scroll_offset = ui_clampi(*area.scroll_offset, 0, view.max_scroll);
view.content_y = y - scroll_offset;
} else {
view.content_y = y;
}
view.content_w = ui_scrollbar_safe_content_width(content_x, content_w,
scrollbar_x, view.max_scroll);
return view;
}
FlintUIScrollView
ui_scroll_container_begin(FlintUIScrollArea area)
{
static int content_drag_active = 0;
static int content_dragging = 0;
static int content_drag_start_y = 0;
static int content_drag_start_scroll = 0;
FlintUIScrollView view = ui_scroll_container_measure(area);
Vector2 mouse_world = ui_mouse_world();
int y = (int)area.bounds.y;
int wheel_step = area.wheel_step > 0 ? area.wheel_step : flint_px(42);
int inside = CheckCollisionPointRec(mouse_world, area.bounds);
int captured = ui_input_captures_click(mouse_world);
int drag_threshold = flint_px(5);
if(area.scroll_offset != NULL) {
*area.scroll_offset = ui_clampi(*area.scroll_offset, 0, view.max_scroll);
if(view.max_scroll > 0 && inside && !captured) {
float wheel = GetMouseWheelMove();
if(wheel != 0.0f) {
*area.scroll_offset -= (int)(wheel * (float)wheel_step);
if(*area.scroll_offset < 0)
*area.scroll_offset = 0;
if(*area.scroll_offset > view.max_scroll)
*area.scroll_offset = view.max_scroll;
*area.scroll_offset = ui_clampi(*area.scroll_offset, 0, view.max_scroll);
}
}
@@ -2849,10 +2866,7 @@ ui_scroll_container_begin(FlintUIScrollArea area)
g_ui_pointer_owner = UI_POINTER_OWNER_SCROLL;
content_dragging = 1;
*area.scroll_offset = content_drag_start_scroll - dy;
if(*area.scroll_offset < 0)
*area.scroll_offset = 0;
if(*area.scroll_offset > view.max_scroll)
*area.scroll_offset = view.max_scroll;
*area.scroll_offset = ui_clampi(*area.scroll_offset, 0, view.max_scroll);
ui_set_input_blocked(1);
}
} else if(content_drag_active) {
@@ -2865,8 +2879,6 @@ ui_scroll_container_begin(FlintUIScrollArea area)
} else {
view.content_y = y;
}
view.content_w = ui_scrollbar_content_width(w, view.max_scroll);
{
Rectangle screen_bounds = {
g_ui_camera.offset.x + area.bounds.x * g_ui_camera.zoom,
+45
View File
@@ -70,6 +70,12 @@ Vyzkoušet přehrání
[meditation_music_stop_test_button]
Zastavit test
---
[meditation_music_network_error_title]
Síť není dostupná
---
[meditation_music_network_error_message]
Nelze se připojit k serveru s meditačním audiem. Zkontrolujte síťová oprávnění Androidu a připojení k internetu a zkuste to znovu.
---
[duration_5m]
5m
---
@@ -103,6 +109,9 @@ Uložit dokončená kola před ukončením?
[cancel_button]
Zrušit
---
[ok_button]
OK
---
[save_button]
Uložit
---
@@ -294,6 +303,9 @@ Importovat data
[import_failed]
Import selhal
---
[imported_data]
Data importována
---
[imported_sessions]
Importováno %d sezení
---
@@ -303,6 +315,18 @@ Neplatný exportní soubor
[import_cancelled]
Import zrušen
---
[import_choice_title]
Importovat nastavení?
---
[import_choice_message]
Nalezeny data a nastavení.
---
[import_data_only_button]
Data
---
[import_data_settings_button]
Data+Nastavení
---
[export_cancelled]
Export cancelled
---
@@ -446,3 +470,24 @@ Smazat toto kolo? Tuto akci nelze vrátit.
[delete_button]
Smazat
---
[meditation_music_attribution]
Hudba od Elijah_K.
---
[theme_system]
Systém
---
[orientation_label]
Orientace
---
[orientation_system]
Systém
---
[orientation_portrait]
Na výšku
---
[orientation_landscape]
Na šířku
---
[orientation_sensor]
Senzor
---
+45
View File
@@ -70,6 +70,12 @@ Testwiedergabe
[meditation_music_stop_test_button]
Test stoppen
---
[meditation_music_network_error_title]
Netzwerk nicht verfügbar
---
[meditation_music_network_error_message]
Der Meditations-Audioserver konnte nicht erreicht werden. Prüfe die Android-Netzwerkberechtigungen und deine Internetverbindung und versuche es erneut.
---
[duration_5m]
5m
---
@@ -103,6 +109,9 @@ Abgeschlossene Runden vor dem Beenden speichern?
[cancel_button]
Abbrechen
---
[ok_button]
OK
---
[save_button]
Speichern
---
@@ -294,6 +303,9 @@ Daten importieren
[import_failed]
Import fehlgeschlagen
---
[imported_data]
Daten importiert
---
[imported_sessions]
%d Sitzungen importiert
---
@@ -303,6 +315,18 @@ Ungültige Exportdatei
[import_cancelled]
Import cancelled
---
[import_choice_title]
Einstellungen importieren?
---
[import_choice_message]
Daten und Einstellungen gefunden.
---
[import_data_only_button]
Daten
---
[import_data_settings_button]
Daten+Einstellungen
---
[export_cancelled]
Export cancelled
---
@@ -446,3 +470,24 @@ Diese Runde löschen? Das kann nicht rückgängig gemacht werden.
[delete_button]
Löschen
---
[meditation_music_attribution]
Musik von Elijah_K.
---
[theme_system]
System
---
[orientation_label]
Ausrichtung
---
[orientation_system]
System
---
[orientation_portrait]
Hochformat
---
[orientation_landscape]
Querformat
---
[orientation_sensor]
Sensor
---
+24
View File
@@ -70,6 +70,12 @@ Test audio
[meditation_music_stop_test_button]
Stop test
---
[meditation_music_network_error_title]
Network unavailable
---
[meditation_music_network_error_message]
Could not reach the meditation audio server. Check Android network permissions and your internet connection, then try again.
---
[meditation_music_attribution]
Music by Elijah_K.
---
@@ -106,6 +112,9 @@ Save completed rounds before exit?
[cancel_button]
Cancel
---
[ok_button]
OK
---
[save_button]
Save
---
@@ -315,6 +324,9 @@ Import Data
[import_failed]
Import failed
---
[imported_data]
Imported data
---
[imported_sessions]
Imported %d sessions
---
@@ -324,6 +336,18 @@ Invalid export file
[import_cancelled]
Import cancelled
---
[import_choice_title]
Import settings?
---
[import_choice_message]
Data and settings found.
---
[import_data_only_button]
Data
---
[import_data_settings_button]
Data+Settings
---
[export_cancelled]
Export cancelled
---
+45
View File
@@ -70,6 +70,12 @@ Probar reproducción
[meditation_music_stop_test_button]
Detener prueba
---
[meditation_music_network_error_title]
Red no disponible
---
[meditation_music_network_error_message]
No se pudo acceder al servidor de audio de meditación. Revisa los permisos de red de Android y tu conexión a internet, e inténtalo de nuevo.
---
[duration_5m]
5m
---
@@ -103,6 +109,9 @@ INICIO
[cancel_button]
Cancelar
---
[ok_button]
Aceptar
---
[save_button]
Guardar
---
@@ -294,6 +303,9 @@ Importar datos
[import_failed]
Error al importar
---
[imported_data]
Datos importados
---
[imported_sessions]
%d sesiones importadas
---
@@ -303,6 +315,18 @@ Archivo de exportación no válido
[import_cancelled]
Import cancelled
---
[import_choice_title]
¿Importar ajustes?
---
[import_choice_message]
Datos y ajustes encontrados.
---
[import_data_only_button]
Datos
---
[import_data_settings_button]
Datos+Ajustes
---
[export_cancelled]
Export cancelled
---
@@ -446,3 +470,24 @@ Recuento de sesiones: %d
[delete_button]
Eliminar
---
[meditation_music_attribution]
Música de Elijah_K.
---
[theme_system]
Sistema
---
[orientation_label]
Orientación
---
[orientation_system]
Sistema
---
[orientation_portrait]
Vertical
---
[orientation_landscape]
Horizontal
---
[orientation_sensor]
Sensor
---
+45
View File
@@ -70,6 +70,12 @@ Tester la lecture
[meditation_music_stop_test_button]
Arrêter le test
---
[meditation_music_network_error_title]
Réseau indisponible
---
[meditation_music_network_error_message]
Impossible de joindre le serveur audio de méditation. Vérifiez les autorisations réseau d'Android et votre connexion internet, puis réessayez.
---
[duration_5m]
5m
---
@@ -103,6 +109,9 @@ Enregistrer les cycles terminés avant de quitter ?
[cancel_button]
Annuler
---
[ok_button]
OK
---
[save_button]
Enregistrer
---
@@ -294,6 +303,9 @@ Importer les données
[import_failed]
Échec de l'import
---
[imported_data]
Données importées
---
[imported_sessions]
%d sessions importées
---
@@ -303,6 +315,18 @@ Fichier d'export invalide
[import_cancelled]
Import annulé
---
[import_choice_title]
Importer les réglages ?
---
[import_choice_message]
Données et réglages trouvés.
---
[import_data_only_button]
Données
---
[import_data_settings_button]
Données+Réglages
---
[export_cancelled]
Export cancelled
---
@@ -446,3 +470,24 @@ Supprimer ce cycle ? Cette action est irréversible.
[delete_button]
Supprimer
---
[meditation_music_attribution]
Musique par Elijah_K.
---
[theme_system]
Système
---
[orientation_label]
Orientation
---
[orientation_system]
Système
---
[orientation_portrait]
Portrait
---
[orientation_landscape]
Paysage
---
[orientation_sensor]
Capteur
---
+45
View File
@@ -70,6 +70,12 @@ Coba putar
[meditation_music_stop_test_button]
Hentikan tes
---
[meditation_music_network_error_title]
Jaringan tidak tersedia
---
[meditation_music_network_error_message]
Tidak dapat menjangkau server audio meditasi. Periksa izin jaringan Android dan koneksi internetmu, lalu coba lagi.
---
[duration_5m]
5m
---
@@ -103,6 +109,9 @@ Simpan ronde yang selesai sebelum keluar?
[cancel_button]
Batal
---
[ok_button]
OK
---
[save_button]
Simpan
---
@@ -294,6 +303,9 @@ Impor Data
[import_failed]
Impor gagal
---
[imported_data]
Data diimpor
---
[imported_sessions]
Mengimpor %d sesi
---
@@ -303,6 +315,18 @@ File ekspor tidak valid
[import_cancelled]
Impor dibatalkan
---
[import_choice_title]
Impor pengaturan?
---
[import_choice_message]
Data dan pengaturan ditemukan.
---
[import_data_only_button]
Data
---
[import_data_settings_button]
Data+Pengaturan
---
[export_cancelled]
Export cancelled
---
@@ -446,3 +470,24 @@ Hapus ronde ini? Tidak dapat dibatalkan.
[delete_button]
Hapus
---
[meditation_music_attribution]
Musik oleh Elijah_K.
---
[theme_system]
Sistem
---
[orientation_label]
Orientasi
---
[orientation_system]
Sistem
---
[orientation_portrait]
Potret
---
[orientation_landscape]
Lanskap
---
[orientation_sensor]
Sensor
---
+27
View File
@@ -70,6 +70,12 @@ Test audio
[meditation_music_stop_test_button]
Ferma test
---
[meditation_music_network_error_title]
Rete non disponibile
---
[meditation_music_network_error_message]
Impossibile raggiungere il server audio per la meditazione. Controlla le autorizzazioni di rete di Android e la connessione a internet, poi riprova.
---
[duration_5m]
5 min
---
@@ -103,6 +109,9 @@ Salvare i round completati prima di uscire?
[cancel_button]
Annulla
---
[ok_button]
OK
---
[save_button]
Salva
---
@@ -310,6 +319,9 @@ Importa Dati
[import_failed]
Importazione fallita
---
[imported_data]
Dati importati
---
[imported_sessions]
Importate %d sessioni
---
@@ -319,6 +331,18 @@ File di esportazione non valido
[import_cancelled]
Importazione annullata
---
[import_choice_title]
Importare impostazioni?
---
[import_choice_message]
Dati e impostazioni trovati.
---
[import_data_only_button]
Dati
---
[import_data_settings_button]
Dati+Impostazioni
---
[export_cancelled]
Esportazione annullata
---
@@ -462,3 +486,6 @@ Eliminare questo round? Questa azione non può essere annullata.
[delete_button]
Elimina
---
[meditation_music_attribution]
Musica di Elijah_K.
---
+46
View File
@@ -70,6 +70,12 @@
[meditation_music_stop_test_button]
テスト停止
---
[meditation_music_network_error_title]
ネットワークを利用できません
---
[meditation_music_network_error_message]
瞑想音声サーバーに接続できませんでした。Android のネットワーク権限とインターネット接続を確認してから、もう一度お試しください。
---
[duration_5m]
5分
---
@@ -103,6 +109,9 @@
[cancel_button]
キャンセル
---
[ok_button]
OK
---
[save_button]
保存
---
@@ -294,6 +303,9 @@ In / Out
[import_failed]
インポートに失敗しました
---
[imported_data]
データをインポートしました
---
[imported_sessions]
%dセッションをインポートしました
---
@@ -303,6 +315,18 @@ In / Out
[import_cancelled]
Import cancelled
---
[import_choice_title]
設定もインポートしますか?
---
[import_choice_message]
データと設定があります。
---
[import_data_only_button]
データ
---
[import_data_settings_button]
データ+設定
---
[export_cancelled]
Export cancelled
---
@@ -439,3 +463,25 @@ Inner Breeze データ書き出し
---
[delete_button]
削除
---
[meditation_music_attribution]
音楽: Elijah_K.
---
[theme_system]
システム
---
[orientation_label]
向き
---
[orientation_system]
システム
---
[orientation_portrait]
縦向き
---
[orientation_landscape]
横向き
---
[orientation_sensor]
センサー
---
+27
View File
@@ -70,6 +70,12 @@ Inner Breeze
[meditation_music_stop_test_button]
테스트 중지
---
[meditation_music_network_error_title]
네트워크를 사용할 수 없음
---
[meditation_music_network_error_message]
명상 오디오 서버에 연결할 수 없습니다. Android 네트워크 권한과 인터넷 연결을 확인한 뒤 다시 시도하세요.
---
[duration_5m]
5분
---
@@ -103,6 +109,9 @@ Inner Breeze
[cancel_button]
취소
---
[ok_button]
확인
---
[save_button]
저장
---
@@ -310,6 +319,9 @@ In / Out
[import_failed]
가져오기 실패
---
[imported_data]
데이터를 가져왔습니다
---
[imported_sessions]
%d개 세션을 가져왔습니다
---
@@ -319,6 +331,18 @@ In / Out
[import_cancelled]
가져오기 취소됨
---
[import_choice_title]
설정을 가져올까요?
---
[import_choice_message]
데이터와 설정을 찾았습니다.
---
[import_data_only_button]
데이터
---
[import_data_settings_button]
데이터+설정
---
[export_cancelled]
내보내기 취소됨
---
@@ -461,3 +485,6 @@ Inner Breeze 데이터 내보내기
[delete_button]
삭제
---
[meditation_music_attribution]
음악: Elijah_K.
---
+45
View File
@@ -70,6 +70,12 @@ Testar reprodução
[meditation_music_stop_test_button]
Parar teste
---
[meditation_music_network_error_title]
Rede indisponível
---
[meditation_music_network_error_message]
Não foi possível acessar o servidor de áudio de meditação. Verifique as permissões de rede do Android e sua conexão com a internet, depois tente novamente.
---
[duration_5m]
5m
---
@@ -103,6 +109,9 @@ Salvar rodadas concluídas antes de sair?
[cancel_button]
Cancelar
---
[ok_button]
OK
---
[save_button]
Salvar
---
@@ -294,6 +303,9 @@ Importar dados
[import_failed]
Falha ao importar
---
[imported_data]
Dados importados
---
[imported_sessions]
%d sessões importadas
---
@@ -303,6 +315,18 @@ Arquivo de exportação inválido
[import_cancelled]
Importação cancelada
---
[import_choice_title]
Importar configurações?
---
[import_choice_message]
Dados e configurações encontrados.
---
[import_data_only_button]
Dados
---
[import_data_settings_button]
Dados+Config.
---
[export_cancelled]
Export cancelled
---
@@ -446,3 +470,24 @@ Excluir esta rodada? Isso não pode ser desfeito.
[delete_button]
Excluir
---
[meditation_music_attribution]
Música por Elijah_K.
---
[theme_system]
Sistema
---
[orientation_label]
Orientação
---
[orientation_system]
Sistema
---
[orientation_portrait]
Retrato
---
[orientation_landscape]
Paisagem
---
[orientation_sensor]
Sensor
---
+46
View File
@@ -70,6 +70,12 @@ Wim Hof 呼吸
[meditation_music_stop_test_button]
停止测试
---
[meditation_music_network_error_title]
网络不可用
---
[meditation_music_network_error_message]
无法连接到冥想音频服务器。请检查 Android 网络权限和互联网连接,然后重试。
---
[duration_5m]
5分钟
---
@@ -103,6 +109,9 @@ Wim Hof 呼吸
[cancel_button]
取消
---
[ok_button]
确定
---
[save_button]
保存
---
@@ -294,6 +303,9 @@ In / Out
[import_failed]
导入失败
---
[imported_data]
数据已导入
---
[imported_sessions]
已导入 %d 个会话
---
@@ -303,6 +315,18 @@ In / Out
[import_cancelled]
Import cancelled
---
[import_choice_title]
导入设置?
---
[import_choice_message]
找到数据和设置。
---
[import_data_only_button]
数据
---
[import_data_settings_button]
数据+设置
---
[export_cancelled]
Export cancelled
---
@@ -437,3 +461,25 @@ Inner Breeze 数据导出
---
[delete_button]
删除
---
[meditation_music_attribution]
音乐来自 Elijah_K。
---
[theme_system]
系统
---
[orientation_label]
方向
---
[orientation_system]
系统
---
[orientation_portrait]
竖屏
---
[orientation_landscape]
横屏
---
[orientation_sensor]
传感器
---
+42
View File
@@ -673,6 +673,27 @@ load_settings(InbeApp *app)
save_settings(app);
}
void
app_reload_after_import(InbeApp *app, int reload_settings)
{
if(app == NULL)
return;
if(reload_settings) {
load_settings(app);
reset_settings_preview(app);
update_session_sounds(app);
}
inbe_habits_init(&app->habits);
if(app->habit_detail_index >= app->habits.count)
app->habit_detail_index = -1;
if(app->habits.selected < 0 || app->habits.selected >= app->habits.count)
app->habits.selected = app->habits.count > 0 ? 0 : -1;
app->habit_session_edit_active = 0;
app->habit_edit_active = 0;
}
static Texture2D
load_pixel_texture_from_asset(const char *path)
{
@@ -1322,6 +1343,26 @@ handle_back_button(InbeApp *app)
}
}
static void
draw_global_modal(InbeApp *app)
{
int modal_result;
if(app == NULL || !app->modal.active)
return;
if(app->modal.type == UIModalMeditationNetworkError) {
modal_result = ui_draw_modal(locale_get("meditation_music_network_error_title"),
locale_get("meditation_music_network_error_message"),
locale_get("ok_button"),
locale_get("ok_button"));
if(modal_result != 0) {
app->modal.active = 0;
app->modal.type = UIModalNone;
}
}
}
static void
updateapp(InbeApp *app)
{
@@ -1505,6 +1546,7 @@ updateapp(InbeApp *app)
}
finish_frame:
draw_global_modal(app);
app_flush_deferred_settings(app);
app->inbe.frame++;
}
+4
View File
@@ -59,6 +59,8 @@ typedef enum {
UIModalConfirmDeleteData,
UIModalConfirmDeleteHabit,
UIModalEditProgressiveStartSpeed,
UIModalMeditationNetworkError,
UIModalConfirmImportDataSettings,
} UIModalType;
typedef struct {
@@ -222,6 +224,7 @@ struct InbeApp {
int meditation_music_playing;
int meditation_music_test_playing;
int meditation_music_archive_extracted;
int meditation_music_network_error_notified;
Music meditation_music;
FlintRuntimeAssetDownload meditation_music_download;
char meditation_music_cache_dir[FS_PATH_MAX];
@@ -241,6 +244,7 @@ int clampi(int x, int min, int max);
int int_from_count(const char src[4]);
void count_from_int(char dst[4], int value);
void save_settings(InbeApp *app);
void app_reload_after_import(InbeApp *app, int reload_settings);
void reset_settings_preview(InbeApp *app);
void update_preview_bounds(Inbe *inbe, int content_w, int max_h);
void apply_settings(Inbe *inbe, int speed, int max_rounds, int max_breaths, int pause_seconds);
+2 -2
View File
@@ -3,7 +3,7 @@
#define INBE_VERSION_MAJOR 1
#define INBE_VERSION_MINOR 3
#define INBE_VERSION_PATCH 1
#define INBE_VERSION_STRING "1.3.1"
#define INBE_VERSION_PATCH 3
#define INBE_VERSION_STRING "1.3.3"
#endif
+10 -4
View File
@@ -1216,10 +1216,13 @@ draw_habits_screen(InbeApp *app)
scroll_h = 0;
scroll_area = (FlintUIScrollArea){
.bounds = {(float)content_x, (float)scroll_y, (float)content_w, (float)scroll_h},
.bounds = {0.0f, (float)scroll_y, (float)view_width, (float)scroll_h},
.content_height = scroll_content_h,
.content_x = content_x,
.content_width = content_w,
.scroll_offset = &app->habits.scroll,
.wheel_step = flint_px(42)
.wheel_step = flint_px(42),
.scrollbar_x = view_width - flint_px(8)
};
scroll_view = ui_scroll_container_begin(scroll_area);
content_x = scroll_view.content_x;
@@ -1540,10 +1543,13 @@ draw_habit_session_edit_screen(InbeApp *app)
flint_centered_column(max_w, side_padding, &content_x, &content_w);
content_h = draw_habit_session_edit_content(app, &ctx, content_x, content_w, y, 0) - y;
scroll_area = (FlintUIScrollArea){
.bounds = {(float)content_x, (float)y, (float)content_w, (float)viewport_h},
.bounds = {0.0f, (float)y, (float)view_width, (float)viewport_h},
.content_height = content_h,
.content_x = content_x,
.content_width = content_w,
.scroll_offset = &app->habit_session_edit_scroll,
.wheel_step = flint_px(42)
.wheel_step = flint_px(42),
.scrollbar_x = view_width - flint_px(8)
};
scroll_view = ui_scroll_container_begin(scroll_area);
draw_habit_session_edit_content(app, &ctx, scroll_view.content_x, scroll_view.content_w,
+116 -95
View File
@@ -94,6 +94,47 @@ draw_tutorial_paragraph(InbeApp *app, int step, int content_x, int *y, int conte
flint_ui_paragraph_draw(tutorial_paragraph(app, step, content_w, body_font), content_x, y);
}
static int
manual_tutorial_content_height(InbeApp *app, int step, int content_w, int body_font)
{
int actual_content_h = 0;
if(step == 0) {
actual_content_h += flint_px(170) + flint_px(22) +
tutorial_paragraph_height(app, 0, content_w, body_font);
} else if(step == 1) {
actual_content_h += tutorial_paragraph_height(app, 1, content_w, body_font);
} else if(step == 2) {
actual_content_h += tutorial_paragraph_height(app, 2, content_w, body_font) + flint_px(68);
if(app->inbe.progressive_speed)
actual_content_h += flint_px(66);
} else if(step == 3) {
int preview_span;
int preview_rmax;
int slider_h = flint_px(40);
actual_content_h += tutorial_paragraph_height(app, 3, content_w, body_font) + flint_px(20);
preview_span = (content_w < flint_px(132)) ? content_w : flint_px(132);
preview_rmax = preview_span / 2;
if(preview_rmax < flint_px(60)) preview_rmax = flint_px(60);
if(preview_rmax > flint_px(120)) preview_rmax = flint_px(120);
actual_content_h += flint_px(40) + (int)((float)preview_rmax * 0.72f) + flint_px(14);
actual_content_h += slider_h + flint_px(8);
} else if(step == 4) {
int hold_preview_radius = flint_px(54);
int hold_preview_extent = hold_preview_radius + flint_px(8) + flint_px(5);
actual_content_h += flint_px(26) + flint_px(36) + flint_px(20);
actual_content_h += hold_preview_extent * 2 + flint_px(24);
actual_content_h += tutorial_paragraph_height(app, 4, content_w, body_font);
} else {
actual_content_h += flint_px(200) + flint_px(22) +
tutorial_paragraph_height(app, 5, content_w, body_font);
}
return actual_content_h;
}
void
manual_screen_reset_layouts(InbeApp *app)
{
@@ -146,7 +187,7 @@ meditation_manual_draw(InbeApp *app)
int button_y = view_height - flint_px(52);
int content_y = title_h + flint_px(20);
int content_h = button_y - content_y - flint_px(16);
int content_total_h = flint_px(520);
int content_total_h;
FlintUIScrollArea scroll_area;
FlintUIScrollView scroll_view;
FlintUIParagraph paragraph;
@@ -174,19 +215,50 @@ meditation_manual_draw(InbeApp *app)
.line_gap = TUTORIAL_LINE_SPACING,
.color = theme_get_text(),
};
for(int pass = 0; pass < 3; pass++) {
FlintUIScrollView measured;
paragraph.width = content_w;
content_total_h = meditation_music_measure_settings(app, content_w, 0, 1) +
flint_px(34) +
flint_ui_paragraph_height(paragraph) +
flint_px(20);
scroll_area = (FlintUIScrollArea){
.bounds = {0.0f, (float)content_y,
(float)view_width, (float)content_h},
.content_height = content_total_h,
.content_x = content_x,
.content_width = content_w,
.scroll_offset = &app->manual_scroll,
.wheel_step = flint_px(42),
.scrollbar_x = view_width - flint_px(8)
};
measured = ui_scroll_container_measure(scroll_area);
if(measured.content_w == content_w)
break;
content_w = measured.content_w;
}
paragraph.width = content_w;
content_total_h = meditation_music_measure_settings(app, content_w, 0, 1) +
flint_px(34) +
flint_ui_paragraph_height(paragraph) +
flint_px(20);
scroll_area = (FlintUIScrollArea){
.bounds = {(float)content_x, (float)content_y,
(float)content_w, (float)content_h},
.bounds = {0.0f, (float)content_y,
(float)view_width, (float)content_h},
.content_height = content_total_h,
.content_x = content_x,
.content_width = content_w,
.scroll_offset = &app->manual_scroll,
.wheel_step = flint_px(42)
.wheel_step = flint_px(42),
.scrollbar_x = view_width - flint_px(8)
};
scroll_view = ui_scroll_container_begin(scroll_area);
y = scroll_view.content_y;
meditation_music_draw_guide_settings(app, content_x, content_w, &y);
meditation_music_draw_guide_settings(app, scroll_view.content_x, scroll_view.content_w, &y);
y += flint_px(34);
flint_ui_paragraph_draw(paragraph, content_x, &y);
paragraph.width = scroll_view.content_w;
flint_ui_paragraph_draw(paragraph, scroll_view.content_x, &y);
ui_scroll_container_end(scroll_area, scroll_view);
meditation_music_draw_dropdown_menu(app);
@@ -220,6 +292,8 @@ manual_screen_draw(InbeApp *app)
char page_label[32];
int close_clicked = 0;
int step = app->tutorial_step;
FlintUIScrollArea scroll_area;
FlintUIScrollView scroll_view;
if(app->exercise_type == EXERCISE_MEDITATION) {
meditation_manual_draw(app);
@@ -272,89 +346,46 @@ manual_screen_draw(InbeApp *app)
if(close_clicked)
manual_screen_close_tutorial(app, 0);
/* Calculate actual content height based on current step and text layouts */
/* Don't include padding in this calculation - it's handled separately */
int actual_content_h = 0; /* Content only, no padding */
if(step == 0) {
actual_content_h += flint_px(170) + flint_px(22) +
tutorial_paragraph_height(app, 0, content_w, body_font);
} else if(step == 1) {
actual_content_h += tutorial_paragraph_height(app, 1, content_w, body_font);
} else if(step == 2) {
actual_content_h += tutorial_paragraph_height(app, 2, content_w, body_font) + flint_px(68);
if(app->inbe.progressive_speed)
actual_content_h += flint_px(66);
} else if(step == 3) {
actual_content_h += tutorial_paragraph_height(app, 3, content_w, body_font) + flint_px(20);
/* Circle preview height - calculate actual rmax based on content_w */
/* update_preview_bounds uses min(content_w, 132)/2 clamped to 60-120 for rmax */
int preview_span = (content_w < flint_px(132)) ? content_w : flint_px(132);
int preview_rmax = preview_span / 2;
if(preview_rmax < flint_px(60)) preview_rmax = flint_px(60);
if(preview_rmax > flint_px(120)) preview_rmax = flint_px(120);
/* Circle is drawn at y+flint_px(40) with radius 0.72*preview_rmax */
actual_content_h += flint_px(40) + (int)((float)preview_rmax * 0.72f) + flint_px(14);
int slider_h = flint_px(40);
actual_content_h += slider_h + flint_px(8);
} else if(step == 4) {
int hold_preview_radius = flint_px(54);
int hold_preview_extent = hold_preview_radius + flint_px(8) + flint_px(5);
actual_content_h += flint_px(26) + flint_px(36) + flint_px(20);
actual_content_h += hold_preview_extent * 2 + flint_px(24);
actual_content_h += tutorial_paragraph_height(app, 4, content_w, body_font);
} else {
actual_content_h += flint_px(200) + flint_px(22) +
tutorial_paragraph_height(app, 5, content_w, body_font);
}
/* Calculate scroll range for virtual content space */
int top_padding = flint_px(16);
int total_content_h = actual_content_h + top_padding;
int viewport_content_h = content_area_h;
int max_scroll = total_content_h - viewport_content_h;
if(max_scroll < 0)
max_scroll = 0;
{
int top_padding = flint_px(16);
int total_content_h;
/* Reset scroll position if content now fits in viewport */
if(max_scroll == 0) {
app->manual_scroll = 0;
}
/* Clamp scroll position to new max */
app->manual_scroll = clampi(app->manual_scroll, 0, max_scroll);
app->manual_scroll -= (int)(GetMouseWheelMove() * 24.0f);
app->manual_scroll = clampi(app->manual_scroll, 0, max_scroll);
for(int pass = 0; pass < 3; pass++) {
FlintUIScrollView measured;
/* Handle content area drag scrolling */
static int content_drag_active = 0;
static int content_drag_start_y = 0;
static int content_drag_start_scroll = 0;
Vector2 mouse_pos = GetMousePosition();
int content_area_y = title_h;
Rectangle content_bounds = {content_x, content_area_y, content_w, content_area_h};
if(IsMouseButtonDown(MOUSE_BUTTON_LEFT)) {
if(!content_drag_active) {
/* Start drag if clicking in content area */
if(CheckCollisionPointRec(mouse_pos, content_bounds)) {
content_drag_active = 1;
content_drag_start_y = (int)mouse_pos.y;
content_drag_start_scroll = app->manual_scroll;
}
} else {
/* Continue drag */
int dy = (int)mouse_pos.y - content_drag_start_y;
app->manual_scroll = content_drag_start_scroll - dy;
app->manual_scroll = clampi(app->manual_scroll, 0, max_scroll);
total_content_h = manual_tutorial_content_height(app, step, content_w, body_font) +
top_padding;
scroll_area = (FlintUIScrollArea){
.bounds = {0.0f, (float)title_h, (float)view_width, (float)content_area_h},
.content_height = total_content_h,
.content_x = content_x,
.content_width = content_w,
.scroll_offset = &app->manual_scroll,
.wheel_step = flint_px(42),
.scrollbar_x = view_width - flint_px(8)
};
measured = ui_scroll_container_measure(scroll_area);
if(measured.content_w == content_w)
break;
content_w = measured.content_w;
}
} else {
content_drag_active = 0;
scroll_area = (FlintUIScrollArea){
.bounds = {0.0f, (float)title_h, (float)view_width, (float)content_area_h},
.content_height = manual_tutorial_content_height(app, step, content_w, body_font) +
top_padding,
.content_x = content_x,
.content_width = content_w,
.scroll_offset = &app->manual_scroll,
.wheel_step = flint_px(42),
.scrollbar_x = view_width - flint_px(8)
};
}
flint_clip_begin((int)app->camera.offset.x,
(int)(app->camera.offset.y + title_h * app->camera.zoom),
(int)(view_width * app->camera.zoom),
(int)(content_area_h * app->camera.zoom));
int y = title_h + flint_px(16) - app->manual_scroll;
scroll_view = ui_scroll_container_begin(scroll_area);
content_x = scroll_view.content_x;
content_w = scroll_view.content_w;
{
int y = scroll_view.content_y + flint_px(16);
if(step == 0) {
int img_h = flint_px(170);
ui_draw_tutorial_image(app->whm_1_image, "whm/1.jpg", content_x, y, content_w, img_h);
@@ -427,18 +458,8 @@ manual_screen_draw(InbeApp *app)
y += img_h + flint_px(22);
draw_tutorial_paragraph(app, 5, content_x, &y, content_w, body_font);
}
flint_clip_end();
/* Draw scrollbar if content overflows */
if(max_scroll > 0) {
/* Transform world coordinates to screen coordinates for scrollbar function */
int scrollbar_x = (int)(app->camera.offset.x + (content_x + content_w + flint_px(4)) * app->camera.zoom);
int scrollbar_y = (int)(app->camera.offset.y + title_h * app->camera.zoom);
int scrollbar_viewport = (int)(content_area_h * app->camera.zoom); /* Scaled by camera zoom */
int total_content_screen_h = (int)(total_content_h * app->camera.zoom); /* Also scaled for ratio calculations */
ui_draw_scrollbar(scrollbar_x, scrollbar_y, scrollbar_viewport, total_content_screen_h,
&app->manual_scroll, max_scroll);
}
ui_scroll_container_end(scroll_area, scroll_view);
locale_format(page_label, sizeof(page_label), "tutorial_page_label",
step + 1, (int)TUTORIAL_STEPS_COUNT);
+185 -65
View File
@@ -153,6 +153,8 @@ settings_draw_progressive_start_speed_editor(InbeApp *app)
static char unified_status[256] = "";
static char unified_detail[256] = "";
static int unified_status_type = 0;
static char pending_import_path[FS_PATH_MAX] = "";
static DataImportInfo pending_import_info;
/* Helper functions for unified status system */
void settings_screen_set_status_success(const char *message, const char *detail) {
@@ -190,6 +192,109 @@ settings_screen_clear_status(void)
unified_status_type = 0;
}
static void
settings_clear_pending_import(void)
{
pending_import_path[0] = '\0';
memset(&pending_import_info, 0, sizeof(pending_import_info));
}
static void
settings_import_success(InbeApp *app, int imported_settings)
{
app_reload_after_import(app, imported_settings);
settings_screen_set_status_success(locale_get("imported_data"), NULL);
TraceLog(LOG_INFO, "DATA: Import successful");
}
static int
settings_perform_import(InbeApp *app, const char *path, DataImportMode mode)
{
if(app == NULL || path == NULL || path[0] == '\0') {
settings_screen_set_status_error(locale_get("import_invalid_file"));
return 0;
}
if(data_import_with_mode(path, mode)) {
settings_import_success(app, mode == DATA_IMPORT_DATA_AND_SETTINGS);
return 1;
}
settings_screen_set_status_error(locale_get("import_failed"));
TraceLog(LOG_ERROR, "DATA: Import failed");
return 0;
}
static void
settings_begin_import_for_path(InbeApp *app, const char *path)
{
DataImportInfo info;
if(app == NULL || path == NULL || path[0] == '\0') {
settings_screen_set_status_error(locale_get("import_invalid_file"));
return;
}
memset(&info, 0, sizeof(info));
if(!data_inspect_import(path, &info) || !info.valid) {
settings_screen_set_status_error(locale_get("import_invalid_file"));
TraceLog(LOG_WARNING, "DATA: Invalid import file selected");
return;
}
if((info.has_sessions || info.has_habits) && info.has_settings) {
snprintf(pending_import_path, sizeof(pending_import_path), "%s", path);
pending_import_info = info;
app->modal.active = 1;
app->modal.type = UIModalConfirmImportDataSettings;
app->modal.selected_button = 0;
settings_screen_clear_status();
return;
}
settings_perform_import(app, path, DATA_IMPORT_DATA_ONLY);
}
static int
settings_draw_import_choice_modal(InbeApp *app)
{
FlintUIPanelFrame frame;
int font = flint_ui_font();
int msg_y;
int msg_x;
const char *message = locale_get("import_choice_message");
int row_gap = flint_px(10);
int btn_h = flint_px(36);
int btn_y;
int btn_w;
int hover = 0;
(void)app;
frame = ui_draw_modal_frame(flint_px(320), flint_px(232),
locale_get("import_choice_title"),
(Texture2D){0}, (Texture2D){0});
msg_x = frame.content_x;
msg_y = frame.content_y;
flint_text_draw(message, msg_x, msg_y, font, theme_get_text());
btn_y = frame.y + frame.h - flint_px(24) - btn_h * 2 - row_gap;
btn_w = (frame.content_w - row_gap) / 2;
if(ui_draw_generic_button(frame.content_x, btn_y, btn_w, btn_h,
locale_get("cancel_button"),
UI_BUTTON_STYLE_SECONDARY, 0, &hover))
return 1;
if(ui_draw_generic_button(frame.content_x + btn_w + row_gap, btn_y, btn_w, btn_h,
locale_get("import_data_only_button"),
UI_BUTTON_STYLE_PRIMARY, 0, &hover))
return 2;
if(ui_draw_generic_button(frame.content_x, btn_y + btn_h + row_gap,
frame.content_w, btn_h,
locale_get("import_data_settings_button"),
UI_BUTTON_STYLE_PRIMARY, 0, &hover))
return 3;
return 0;
}
static void
settings_draw_status(int x, int *y)
{
@@ -362,7 +467,7 @@ settings_apply_file_dialog_theme(InbeApp *app)
#if defined(PLATFORM_ANDROID) || defined(__ANDROID__) || defined(ANDROID)
static void
settings_screen_handle_android_import(void)
settings_screen_handle_android_import(InbeApp *app)
{
char import_path[FS_PATH_MAX];
int import_result = android_import_poll_result(import_path, sizeof(import_path));
@@ -380,15 +485,7 @@ settings_screen_handle_android_import(void)
return;
}
if(data_import(import_path)) {
char import_message[128];
locale_format(import_message, sizeof(import_message), "imported_sessions", data_get_session_count());
settings_screen_set_status_success(import_message, NULL);
TraceLog(LOG_INFO, "DATA: Android import successful");
} else {
settings_screen_set_status_error(locale_get("import_failed"));
TraceLog(LOG_ERROR, "DATA: Android import failed");
}
settings_begin_import_for_path(app, import_path);
}
#endif
@@ -472,16 +569,7 @@ settings_draw_pending_file_dialog(InbeApp *app)
if(result == 1) {
const char *path = flint_file_dialog_get_path(&import_dlg);
if(path != NULL && path[0] != '\0') {
if(data_import(path)) {
char import_message[128];
locale_format(import_message, sizeof(import_message),
"imported_sessions", data_get_session_count());
settings_screen_set_status_success(import_message, NULL);
TraceLog(LOG_INFO, "DATA: Import successful");
} else {
settings_screen_set_status_error(locale_get("import_failed"));
TraceLog(LOG_ERROR, "DATA: Import failed");
}
settings_begin_import_for_path(app, path);
} else {
settings_screen_set_status_error(locale_get("import_invalid_file"));
TraceLog(LOG_WARNING, "DATA: No file selected for import");
@@ -749,8 +837,6 @@ practice_config_screen_draw(InbeApp *app)
int scroll_y;
int scroll_h;
int content_h;
int max_scroll;
int scroll_bounds_w;
int scrollbar_x;
int controls_w;
int y;
@@ -804,27 +890,32 @@ practice_config_screen_draw(InbeApp *app)
scroll_h = view_height - scroll_y;
if(scroll_h < 0)
scroll_h = 0;
scroll_bounds_w = view_width - content_x;
if(scroll_bounds_w < content_w)
scroll_bounds_w = content_w;
scrollbar_x = view_width - flint_px(12);
scrollbar_x = view_width - flint_px(8);
controls_w = content_w;
for(int i = 0; i < 3; i++) {
int next_controls_w;
FlintUIScrollView measured;
content_h = practice_config_content_height(app, controls_w);
max_scroll = content_h - scroll_h;
if(max_scroll < 0)
max_scroll = 0;
next_controls_w = ui_scrollbar_safe_content_width(content_x, content_w,
scrollbar_x, max_scroll);
if(next_controls_w == controls_w)
scroll_area = (FlintUIScrollArea){
.bounds = {0.0f, (float)scroll_y, (float)view_width, (float)scroll_h},
.content_height = content_h,
.content_x = content_x,
.content_width = content_w,
.scroll_offset = &app->settings_scroll,
.wheel_step = flint_px(42),
.scrollbar_x = scrollbar_x
};
measured = ui_scroll_container_measure(scroll_area);
if(measured.content_w == controls_w)
break;
controls_w = next_controls_w;
controls_w = measured.content_w;
}
content_h = practice_config_content_height(app, controls_w);
scroll_area = (FlintUIScrollArea){
.bounds = {(float)content_x, (float)scroll_y, (float)scroll_bounds_w, (float)scroll_h},
.bounds = {0.0f, (float)scroll_y, (float)view_width, (float)scroll_h},
.content_height = content_h,
.content_x = content_x,
.content_width = content_w,
.scroll_offset = &app->settings_scroll,
.wheel_step = flint_px(42),
.scrollbar_x = scrollbar_x
@@ -832,10 +923,12 @@ practice_config_screen_draw(InbeApp *app)
scroll_view = ui_scroll_container_begin(scroll_area);
if(app->exercise_type == EXERCISE_MEDITATION)
y = meditation_config_draw_content(app, content_x, controls_w, scroll_view.content_y,
y = meditation_config_draw_content(app, scroll_view.content_x, scroll_view.content_w,
scroll_view.content_y,
&draw_meditation_music_menu);
else
y = wim_hof_config_draw_content(app, content_x, controls_w, scroll_view.content_y,
y = wim_hof_config_draw_content(app, scroll_view.content_x, scroll_view.content_w,
scroll_view.content_y,
&draw_breath_animation_menu);
(void)y;
ui_scroll_container_end(scroll_area, scroll_view);
@@ -919,7 +1012,7 @@ settings_screen_draw(InbeApp *app)
#endif
#if defined(PLATFORM_ANDROID) || defined(__ANDROID__) || defined(ANDROID)
settings_screen_handle_android_import();
settings_screen_handle_android_import(app);
#endif
if(content_viewport_h < 0)
@@ -933,42 +1026,50 @@ settings_screen_draw(InbeApp *app)
settings_screen_clear_status();
}
flint_clip_begin((int)app->camera.offset.x,
(int)(app->camera.offset.y + tab_content_start_y * app->camera.zoom),
(int)(view_width * app->camera.zoom),
(int)(content_viewport_h * app->camera.zoom));
{
int planned_content_w = content_w - flint_px(16);
int draw_w = content_w;
int app_content_h;
if(planned_content_w < flint_px(160))
planned_content_w = content_w;
if(app->settings_tab == SETTINGS_TAB_THEME) {
app_content_h = flint_px(76) + ui_theme_picker_height(planned_content_w) + flint_px(60);
} else if(app->settings_tab == SETTINGS_TAB_DEVICE) {
app_content_h = flint_px(74) + flint_px(74) + flint_px(76) + flint_px(40);
FlintUIScrollArea scroll_area;
for(int pass = 0; pass < 3; pass++) {
int planned_content_w = draw_w - flint_px(16);
FlintUIScrollView measured;
if(planned_content_w < flint_px(160))
planned_content_w = draw_w;
if(app->settings_tab == SETTINGS_TAB_THEME) {
app_content_h = flint_px(76) + ui_theme_picker_height(planned_content_w) + flint_px(60);
} else if(app->settings_tab == SETTINGS_TAB_DEVICE) {
app_content_h = flint_px(74) + flint_px(74) + flint_px(76) + flint_px(40);
#if defined(PLATFORM_ANDROID) || defined(__ANDROID__) || defined(ANDROID)
app_content_h += flint_px(76);
app_content_h += flint_px(76);
#endif
#if !defined(PLATFORM_ANDROID) && !defined(__ANDROID__) && !defined(ANDROID) && !defined(PLATFORM_WEB)
app_content_h += flint_px(50);
app_content_h += flint_px(50);
#endif
app_content_h += flint_px(72);
} else {
app_content_h = settings_data_content_height(content_w);
app_content_h += flint_px(72);
} else {
app_content_h = settings_data_content_height(draw_w);
}
scroll_area = (FlintUIScrollArea){
.bounds = {0.0f, (float)tab_content_start_y,
(float)view_width, (float)content_viewport_h},
.content_height = app_content_h,
.content_x = content_x,
.content_width = content_w,
.scroll_offset = &app->settings_scroll,
.wheel_step = flint_px(42),
.scrollbar_x = view_width - flint_px(8)
};
measured = ui_scroll_container_measure(scroll_area);
if(measured.content_w == draw_w)
break;
draw_w = measured.content_w;
}
int content_h = app_content_h;
int y;
FlintUIScrollArea scroll_area = {
.bounds = {(float)content_x, (float)tab_content_start_y,
(float)content_w, (float)content_viewport_h},
.content_height = content_h,
.scroll_offset = &app->settings_scroll,
.wheel_step = flint_px(42)
};
FlintUIScrollView scroll_view = ui_scroll_container_begin(scroll_area);
int draw_x = scroll_view.content_x;
int draw_w = scroll_view.content_w;
draw_w = scroll_view.content_w;
y = scroll_view.content_y;
if(app->settings_tab == SETTINGS_TAB_THEME) {
@@ -1089,7 +1190,6 @@ settings_screen_draw(InbeApp *app)
y += flint_px(40);
ui_scroll_container_end(scroll_area, scroll_view);
}
flint_clip_end();
ui_set_dropdown_clip_top(tab_content_start_y);
if(draw_language_menu && language_dropdown_menu(app, 101))
@@ -1116,6 +1216,26 @@ settings_screen_draw(InbeApp *app)
}
ui_set_dropdown_clip_top(0);
if(app->modal.active && app->modal.type == UIModalConfirmImportDataSettings) {
int modal_result = settings_draw_import_choice_modal(app);
if(modal_result == 1) {
app->modal.active = 0;
app->modal.type = UIModalNone;
settings_clear_pending_import();
settings_screen_set_status_error(locale_get("import_cancelled"));
} else if(modal_result == 2 || modal_result == 3) {
char import_path[FS_PATH_MAX];
DataImportMode mode = modal_result == 3
? DATA_IMPORT_DATA_AND_SETTINGS
: DATA_IMPORT_DATA_ONLY;
snprintf(import_path, sizeof(import_path), "%s", pending_import_path);
app->modal.active = 0;
app->modal.type = UIModalNone;
settings_clear_pending_import();
settings_perform_import(app, import_path, mode);
}
}
if(app->modal.active && app->modal.type == UIModalConfirmDeleteData) {
int modal_result = ui_draw_modal(locale_get("delete_all_data_title"),
locale_get("delete_all_data_message"),
+51 -1
View File
@@ -63,6 +63,20 @@ safe_archive_member(const char *path)
return 1;
}
static int
known_track_archive_member(const char *path)
{
if(path == NULL)
return 0;
for(int i = 0; i < MEDITATION_MUSIC_TRACK_COUNT; i++) {
if(strcmp(path, g_tracks[i].file) == 0)
return 1;
}
return 0;
}
static int
copy_text_checked(char *out, size_t out_size, const char *text)
{
@@ -134,6 +148,30 @@ set_status(InbeApp *app, const char *message)
message);
}
static int
is_network_download_error(const FlintRuntimeAssetDownload *download)
{
const char *error;
if(download == NULL)
return 0;
error = download->error;
if(error == NULL || error[0] == '\0')
return 0;
if(strcmp(error, "NETWORK_UNAVAILABLE") == 0)
return 1;
if(strstr(error, "Unable to resolve host") != NULL ||
strstr(error, "No address associated with hostname") != NULL ||
strstr(error, "Could not resolve host") != NULL ||
strstr(error, "Couldn't resolve host") != NULL ||
strstr(error, "Name or service not known") != NULL ||
strstr(error, "Temporary failure in name resolution") != NULL)
return 1;
return 0;
}
static void
format_download_status(char *out, size_t out_size,
const FlintRuntimeAssetDownload *download)
@@ -284,6 +322,8 @@ extract_audio_archive(InbeApp *app, const char *archive_path)
continue;
if(!safe_archive_member(stat.m_filename))
continue;
if(!known_track_archive_member(stat.m_filename))
continue;
if(!join_path2(out_path, sizeof(out_path), app->meditation_music_cache_dir, "/audio/") ||
!append_text_checked(out_path, sizeof(out_path), stat.m_filename)) {
@@ -492,8 +532,17 @@ meditation_music_update(InbeApp *app)
extract_audio_archive(app, archive_path);
} else if(app->meditation_music_download.status == FLINT_RUNTIME_ASSET_ERROR ||
app->meditation_music_download.status == FLINT_RUNTIME_ASSET_UNSUPPORTED) {
if(app->meditation_music_download.error[0] != '\0')
if(is_network_download_error(&app->meditation_music_download)) {
set_status(app, locale_get("meditation_music_network_error_title"));
if(!app->meditation_music_network_error_notified && !app->modal.active) {
app->modal.active = 1;
app->modal.type = UIModalMeditationNetworkError;
app->modal.selected_button = 0;
app->meditation_music_network_error_notified = 1;
}
} else if(app->meditation_music_download.error[0] != '\0') {
set_status(app, app->meditation_music_download.error);
}
}
if(app->meditation_music_loaded) {
@@ -512,6 +561,7 @@ start_download(InbeApp *app)
music_archive_path(app, archive_path, sizeof(archive_path));
app->meditation_music_archive_extracted = 0;
app->meditation_music_network_error_notified = 0;
set_status(app, "Downloading audio...");
flint_runtime_asset_download(&app->meditation_music_download,
INBE_MEDITATION_AUDIO_URL,
+33 -1
View File
@@ -235,9 +235,41 @@ data_validate_import_file(const char *path)
int
data_import(const char *path)
{
return data_import_with_mode(path, DATA_IMPORT_DATA_ONLY);
}
int
data_import_with_mode(const char *path, DataImportMode mode)
{
data_init();
return inbe_storage_import_zip(path);
return inbe_storage_import_zip_ex(
path,
mode == DATA_IMPORT_DATA_AND_SETTINGS
? INBE_STORAGE_IMPORT_DATA_AND_SETTINGS
: INBE_STORAGE_IMPORT_DATA_ONLY);
}
int
data_inspect_import(const char *path, DataImportInfo *info)
{
InbeStorageImportInfo storage_info;
data_init();
if(info != NULL)
memset(info, 0, sizeof(*info));
if(!inbe_storage_inspect_import(path, &storage_info))
return 0;
if(info != NULL) {
info->valid = storage_info.valid;
info->has_sessions = storage_info.has_sessions;
info->has_habits = storage_info.has_habits;
info->has_settings = storage_info.has_settings;
info->session_count = storage_info.session_count;
info->habit_count = storage_info.habit_count;
info->setting_count = storage_info.setting_count;
}
return 1;
}
typedef struct DbListSessionContext {
+17
View File
@@ -4,6 +4,21 @@
#include <stddef.h>
#include "breath_engine.h"
typedef enum DataImportMode {
DATA_IMPORT_DATA_ONLY = 0,
DATA_IMPORT_DATA_AND_SETTINGS = 1
} DataImportMode;
typedef struct DataImportInfo {
int valid;
int has_sessions;
int has_habits;
int has_settings;
int session_count;
int habit_count;
int setting_count;
} DataImportInfo;
void data_init(void);
const char *data_root(void);
const char *data_today_dir(void);
@@ -22,6 +37,8 @@ long long data_delete_all(void);
void data_default_export_filename(char *out, size_t out_size);
int data_export(const char *path);
int data_import(const char *path);
int data_import_with_mode(const char *path, DataImportMode mode);
int data_inspect_import(const char *path, DataImportInfo *info);
int data_validate_import_file(const char *path);
typedef void (*data_session_callback)(const char *date, const char *time,
int rounds, int best, void *user);
+261 -12
View File
@@ -198,6 +198,100 @@ source_table_has_column(sqlite3 *db, const char *table, const char *column)
return found;
}
static int
source_table_exists(sqlite3 *db, const char *table)
{
sqlite3_stmt *stmt = NULL;
int found = 0;
if(db == NULL || table == NULL)
return 0;
if(sqlite3_prepare_v2(db,
"SELECT 1 FROM sqlite_master WHERE type='table' AND name=?1 LIMIT 1",
-1, &stmt, NULL) != SQLITE_OK)
return 0;
sqlite3_bind_text(stmt, 1, table, -1, SQLITE_TRANSIENT);
found = sqlite3_step(stmt) == SQLITE_ROW;
sqlite3_finalize(stmt);
return found;
}
static int
source_count_rows(sqlite3 *db, const char *sql)
{
sqlite3_stmt *stmt = NULL;
int count = 0;
if(db == NULL || sql == NULL)
return 0;
if(sqlite3_prepare_v2(db, sql, -1, &stmt, NULL) != SQLITE_OK)
return 0;
if(sqlite3_step(stmt) == SQLITE_ROW)
count = sqlite3_column_int(stmt, 0);
sqlite3_finalize(stmt);
return count;
}
static const char *const importable_setting_keys[] = {
"speed",
"max_rounds",
"max_breaths",
"pause_seconds",
"sound_volume",
"tutorial_seen",
"exercise_manual_seen_mask",
"theme",
"dark_mode",
"theme_mode",
"orientation_mode",
"main_tab",
"fullscreen",
"on_screen_keyboard",
"progressive_speed",
"progressive_start_speed",
"breath_animation",
"advanced_session_controls",
"hold_display_mode",
"exercise_type",
"meditation_music_enabled",
"meditation_music_shuffle",
"meditation_music_track",
"play_in_background",
"language",
"practice_category_tab"
};
static int
setting_key_importable(const char *key)
{
if(key == NULL || key[0] == '\0')
return 0;
for(size_t i = 0; i < sizeof(importable_setting_keys) / sizeof(importable_setting_keys[0]); i++) {
if(strcmp(key, importable_setting_keys[i]) == 0)
return 1;
}
return 0;
}
static int
source_count_importable_settings(sqlite3 *db)
{
sqlite3_stmt *stmt = NULL;
int count = 0;
if(db == NULL || !source_table_exists(db, "settings"))
return 0;
if(sqlite3_prepare_v2(db, "SELECT DISTINCT key FROM settings", -1, &stmt, NULL) != SQLITE_OK)
return 0;
while(sqlite3_step(stmt) == SQLITE_ROW) {
const char *key = (const char *)sqlite3_column_text(stmt, 0);
if(setting_key_importable(key))
count++;
}
sqlite3_finalize(stmt);
return count;
}
static long long
now_seconds(void)
{
@@ -1339,13 +1433,11 @@ migrate_legacy_file_sessions_in_dir(const char *dir_path)
static void
migrate_legacy_file_sessions_once(void)
{
int imported;
if(g_storage.db == NULL || g_storage.root[0] == '\0')
return;
if(meta_equals("legacy_file_sessions_migrated", "1"))
return;
imported = migrate_legacy_file_sessions_in_dir(g_storage.root);
migrate_legacy_file_sessions_in_dir(g_storage.root);
set_meta("legacy_file_sessions_migrated", "1");
storage_schedule_persist();
}
@@ -1450,12 +1542,94 @@ import_tickmate_db(sqlite3 *src)
}
static int
import_sqlite_db_file(const char *db_path)
import_settings_from_source(sqlite3 *src)
{
sqlite3_stmt *stmt = NULL;
sqlite3_stmt *write_stmt = NULL;
int imported = 0;
long long imported_at = now_seconds();
if(src == NULL || g_storage.db == NULL || !source_table_exists(src, "settings"))
return 0;
if(sqlite3_prepare_v2(src, "SELECT key,value FROM settings", -1, &stmt, NULL) != SQLITE_OK)
return 0;
exec_sql("BEGIN IMMEDIATE");
while(sqlite3_step(stmt) == SQLITE_ROW) {
const char *key = (const char *)sqlite3_column_text(stmt, 0);
const char *value = (const char *)sqlite3_column_text(stmt, 1);
if(!setting_key_importable(key))
continue;
if(sqlite3_prepare_v2(g_storage.db,
"INSERT INTO settings(user_id,key,value,updated_at) VALUES(?1,?2,?3,?4) "
"ON CONFLICT(user_id,key) DO UPDATE SET value=excluded.value,updated_at=excluded.updated_at",
-1, &write_stmt, NULL) != SQLITE_OK)
continue;
bind_text(write_stmt, 1, g_storage.user_id);
bind_text(write_stmt, 2, key);
bind_text(write_stmt, 3, value != NULL ? value : "");
sqlite3_bind_int64(write_stmt, 4, imported_at);
if(sqlite3_step(write_stmt) == SQLITE_DONE)
imported++;
sqlite3_finalize(write_stmt);
write_stmt = NULL;
}
sqlite3_finalize(stmt);
sqlite3_finalize(write_stmt);
exec_sql("COMMIT");
return imported;
}
static int
inspect_sqlite_db_file(const char *db_path, InbeStorageImportInfo *info)
{
sqlite3 *src = NULL;
int ok = 0;
if(info != NULL)
memset(info, 0, sizeof(*info));
if(db_path == NULL || db_path[0] == '\0' || info == NULL)
return 0;
if(sqlite3_open(db_path, &src) != SQLITE_OK)
goto done;
if(source_table_exists(src, "sessions") && source_table_exists(src, "session_rounds")) {
info->session_count = source_count_rows(src, "SELECT COUNT(*) FROM sessions WHERE deleted_at=0");
info->habit_count = source_table_exists(src, "habits")
? source_count_rows(src, "SELECT COUNT(*) FROM habits WHERE deleted_at=0")
: 0;
info->setting_count = source_count_importable_settings(src);
info->has_sessions = info->session_count > 0;
info->has_habits = info->habit_count > 0;
info->has_settings = info->setting_count > 0;
info->valid = info->has_sessions || info->has_habits || info->has_settings;
ok = info->valid;
goto done;
}
if(source_table_has_column(src, "tracks", "name") &&
source_table_has_column(src, "ticks", "_track_id")) {
info->habit_count = source_count_rows(src, "SELECT COUNT(*) FROM tracks WHERE enabled!=0");
info->has_habits = info->habit_count > 0;
info->valid = info->has_habits;
ok = info->valid;
}
done:
if(src != NULL)
sqlite3_close(src);
return ok;
}
static int
import_sqlite_db_file(const char *db_path, InbeStorageImportMode mode)
{
sqlite3 *src = NULL;
sqlite3_stmt *stmt = NULL;
sqlite3_stmt *hstmt = NULL;
int ok = 0;
int imported_settings = 0;
if(db_path == NULL || db_path[0] == '\0')
return 0;
@@ -1496,15 +1670,21 @@ import_sqlite_db_file(const char *db_path)
sqlite3_finalize(stmt);
stmt = NULL;
if(sqlite3_prepare_v2(src,
"SELECT id,name,color_r,color_g,color_b,sync_mode,sync_activity,sort_order "
"FROM habits WHERE deleted_at=0 ORDER BY sort_order,id",
-1, &stmt, NULL) == SQLITE_OK) {
if(source_table_exists(src, "habits")) {
int has_sync_activity = source_table_has_column(src, "habits", "sync_activity");
const char *habit_sql =
has_sync_activity
? "SELECT id,name,color_r,color_g,color_b,sync_mode,sync_activity,sort_order FROM habits WHERE deleted_at=0 ORDER BY sort_order,id"
: "SELECT id,name,color_r,color_g,color_b,sync_mode,sort_order FROM habits WHERE deleted_at=0 ORDER BY sort_order,id";
if(sqlite3_prepare_v2(src, habit_sql, -1, &stmt, NULL) != SQLITE_OK)
goto after_habits;
exec_sql("BEGIN IMMEDIATE");
while(sqlite3_step(stmt) == SQLITE_ROW) {
const char *import_habit_id = (const char *)sqlite3_column_text(stmt, 0);
const char *name = (const char *)sqlite3_column_text(stmt, 1);
char local_habit_id[INBE_STORAGE_ID_SIZE];
int sync_activity = has_sync_activity ? sqlite3_column_int(stmt, 6) : 0;
int sort_order = has_sync_activity ? sqlite3_column_int(stmt, 7) : sqlite3_column_int(stmt, 6);
if(import_habit_id == NULL || import_habit_id[0] == '\0' ||
name == NULL || name[0] == '\0')
@@ -1524,8 +1704,8 @@ import_sqlite_db_file(const char *db_path)
sqlite3_bind_int(hstmt, 5, sqlite3_column_int(stmt, 3));
sqlite3_bind_int(hstmt, 6, sqlite3_column_int(stmt, 4));
sqlite3_bind_int(hstmt, 7, sqlite3_column_int(stmt, 5));
sqlite3_bind_int(hstmt, 8, sqlite3_column_int(stmt, 6));
sqlite3_bind_int(hstmt, 9, sqlite3_column_int(stmt, 7));
sqlite3_bind_int(hstmt, 8, sync_activity);
sqlite3_bind_int(hstmt, 9, sort_order);
if(sqlite3_step(hstmt) == SQLITE_DONE)
ok = 1;
sqlite3_finalize(hstmt);
@@ -1555,6 +1735,12 @@ import_sqlite_db_file(const char *db_path)
}
exec_sql("COMMIT");
}
after_habits:
if(mode == INBE_STORAGE_IMPORT_DATA_AND_SETTINGS)
imported_settings = import_settings_from_source(src);
if(imported_settings > 0)
ok = 1;
goto done;
@@ -1577,6 +1763,12 @@ done:
int
inbe_storage_import_zip(const char *path)
{
return inbe_storage_import_zip_ex(path, INBE_STORAGE_IMPORT_DATA_ONLY);
}
int
inbe_storage_import_zip_ex(const char *path, InbeStorageImportMode mode)
{
mz_zip_archive archive;
int ok = 0;
@@ -1591,7 +1783,7 @@ inbe_storage_import_zip(const char *path)
}
memset(&archive, 0, sizeof(archive));
if(!mz_zip_reader_init_file(&archive, path, 0)) {
return import_sqlite_db_file(path);
return import_sqlite_db_file(path, mode);
}
if(mz_zip_reader_locate_file(&archive, "inbe-data/inbe.db", NULL, 0) >= 0) {
char *db_bytes;
@@ -1604,7 +1796,7 @@ inbe_storage_import_zip(const char *path)
if(db_bytes != NULL && fp != NULL && fwrite(db_bytes, 1, db_size, fp) == db_size) {
fclose(fp);
fp = NULL;
ok = import_sqlite_db_file(temp_path);
ok = import_sqlite_db_file(temp_path, mode);
remove(temp_path);
if(!ok)
TraceLog(LOG_ERROR, "DATA: archive contained inbe-data/inbe.db but sqlite import failed");
@@ -1623,6 +1815,63 @@ inbe_storage_import_zip(const char *path)
return ok;
}
int
inbe_storage_inspect_import(const char *path, InbeStorageImportInfo *info)
{
mz_zip_archive archive;
int ok = 0;
if(info != NULL)
memset(info, 0, sizeof(*info));
if(path == NULL || path[0] == '\0' || info == NULL || !path_exists(path))
return 0;
memset(&archive, 0, sizeof(archive));
if(!mz_zip_reader_init_file(&archive, path, 0))
return inspect_sqlite_db_file(path, info);
if(mz_zip_reader_locate_file(&archive, "inbe-data/inbe.db", NULL, 0) >= 0) {
char *db_bytes;
size_t db_size = 0;
char temp_path[INBE_STORAGE_PATH_SIZE];
FILE *fp;
db_bytes = mz_zip_reader_extract_file_to_heap(&archive, "inbe-data/inbe.db", &db_size, 0);
snprintf(temp_path, sizeof(temp_path), "%s/import-inspect-inbe.db", g_storage.root);
fp = fopen(temp_path, "wb");
if(db_bytes != NULL && fp != NULL && fwrite(db_bytes, 1, db_size, fp) == db_size) {
fclose(fp);
fp = NULL;
ok = inspect_sqlite_db_file(temp_path, info);
remove(temp_path);
}
if(fp != NULL)
fclose(fp);
free(db_bytes);
} else {
mz_uint file_count = mz_zip_reader_get_num_files(&archive);
for(mz_uint i = 0; i < file_count; i++) {
mz_zip_archive_file_stat stat;
int year;
int month;
int day;
int hour;
int minute;
int second;
if(!mz_zip_reader_file_stat(&archive, i, &stat) || stat.m_is_directory)
continue;
if(parse_legacy_session_filename(stat.m_filename, &year, &month, &day,
&hour, &minute, &second))
info->session_count++;
}
info->has_sessions = info->session_count > 0;
info->valid = info->has_sessions;
ok = info->valid;
}
mz_zip_reader_end(&archive);
return ok;
}
int
inbe_storage_init(const char *root)
{
+17
View File
@@ -16,6 +16,21 @@ typedef void (*InbeStorageSessionRecordCallback)(const char *id,
const int *rounds, int round_count,
void *user);
typedef enum InbeStorageImportMode {
INBE_STORAGE_IMPORT_DATA_ONLY = 0,
INBE_STORAGE_IMPORT_DATA_AND_SETTINGS = 1
} InbeStorageImportMode;
typedef struct InbeStorageImportInfo {
int valid;
int has_sessions;
int has_habits;
int has_settings;
int session_count;
int habit_count;
int setting_count;
} InbeStorageImportInfo;
int inbe_storage_init(const char *root);
void inbe_storage_close(void);
const char *inbe_storage_db_path(void);
@@ -53,5 +68,7 @@ void inbe_storage_mark_habits_initialized(void);
int inbe_storage_export_zip(const char *path);
int inbe_storage_import_zip(const char *path);
int inbe_storage_import_zip_ex(const char *path, InbeStorageImportMode mode);
int inbe_storage_inspect_import(const char *path, InbeStorageImportInfo *info);
#endif
+181
View File
@@ -0,0 +1,181 @@
#include <dirent.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
enum {
MAX_KEYS = 1024,
MAX_KEY_LEN = 128,
MAX_PATH_LEN = 512
};
typedef struct LocaleKeys {
char keys[MAX_KEYS][MAX_KEY_LEN];
int count;
} LocaleKeys;
static int failures = 0;
static void
trim_newline(char *text)
{
size_t len;
if(text == NULL)
return;
len = strlen(text);
while(len > 0 && (text[len - 1] == '\n' || text[len - 1] == '\r')) {
text[len - 1] = '\0';
len--;
}
}
static int
parse_key_line(const char *line, char *out, size_t out_size)
{
const char *end;
size_t len;
if(line == NULL || out == NULL || out_size == 0 || line[0] != '[')
return 0;
end = strchr(line, ']');
if(end == NULL || end == line + 1)
return 0;
len = (size_t)(end - line - 1);
if(len >= out_size)
len = out_size - 1;
memcpy(out, line + 1, len);
out[len] = '\0';
return 1;
}
static int
keys_contains(const LocaleKeys *keys, const char *key)
{
if(keys == NULL || key == NULL)
return 0;
for(int i = 0; i < keys->count; i++) {
if(strcmp(keys->keys[i], key) == 0)
return 1;
}
return 0;
}
static void
keys_add(LocaleKeys *keys, const char *key)
{
if(keys == NULL || key == NULL || key[0] == '\0')
return;
if(keys_contains(keys, key))
return;
if(keys->count >= MAX_KEYS) {
fprintf(stderr, "FAIL too many locale keys\n");
failures++;
return;
}
snprintf(keys->keys[keys->count], sizeof(keys->keys[keys->count]), "%s", key);
keys->count++;
}
static int
line_has_value(const char *line)
{
if(line == NULL)
return 0;
while(*line == ' ' || *line == '\t')
line++;
return line[0] != '\0' && strcmp(line, "---") != 0;
}
static int
load_locale_keys(const char *path, LocaleKeys *keys)
{
FILE *fp;
char line[512];
char pending_key[MAX_KEY_LEN] = "";
int ok = 1;
if(keys == NULL)
return 0;
memset(keys, 0, sizeof(*keys));
fp = fopen(path, "rb");
if(fp == NULL) {
fprintf(stderr, "FAIL open %s\n", path);
failures++;
return 0;
}
while(fgets(line, sizeof(line), fp) != NULL) {
char key[MAX_KEY_LEN];
trim_newline(line);
if(parse_key_line(line, key, sizeof(key))) {
if(pending_key[0] != '\0') {
fprintf(stderr, "FAIL %s key [%s] has no value\n", path, pending_key);
failures++;
ok = 0;
}
keys_add(keys, key);
snprintf(pending_key, sizeof(pending_key), "%s", key);
} else if(pending_key[0] != '\0' && line_has_value(line)) {
pending_key[0] = '\0';
}
}
if(pending_key[0] != '\0') {
fprintf(stderr, "FAIL %s key [%s] has no value\n", path, pending_key);
failures++;
ok = 0;
}
fclose(fp);
return ok;
}
static void
check_locale_file(const LocaleKeys *english, const char *path)
{
LocaleKeys translated;
load_locale_keys(path, &translated);
for(int i = 0; i < english->count; i++) {
if(!keys_contains(&translated, english->keys[i])) {
fprintf(stderr, "FAIL %s missing [%s]\n", path, english->keys[i]);
failures++;
}
}
}
int
main(void)
{
LocaleKeys english;
DIR *dir;
struct dirent *entry;
if(!load_locale_keys("locales/en.txt", &english))
return 1;
dir = opendir("locales");
if(dir == NULL) {
fprintf(stderr, "FAIL open locales directory\n");
return 1;
}
while((entry = readdir(dir)) != NULL) {
char path[MAX_PATH_LEN];
const char *name = entry->d_name;
size_t len = strlen(name);
if(len <= 4 || strcmp(name + len - 4, ".txt") != 0)
continue;
if(strcmp(name, "en.txt") == 0 || strcmp(name, "index.txt") == 0)
continue;
snprintf(path, sizeof(path), "locales/%s", name);
check_locale_file(&english, path);
}
closedir(dir);
if(failures != 0) {
fprintf(stderr, "%d locale key test failure(s)\n", failures);
return 1;
}
printf("locale key tests passed\n");
return 0;
}
+121
View File
@@ -42,6 +42,18 @@ check_true(const char *label, int ok)
g_failures++;
}
static void
check_str(const char *label, const char *got, const char *want)
{
if(got == NULL && want == NULL)
return;
if(got != NULL && want != NULL && strcmp(got, want) == 0)
return;
fprintf(stderr, "FAIL %s: got %s, want %s\n",
label, got != NULL ? got : "(null)", want != NULL ? want : "(null)");
g_failures++;
}
static int
ascii_equal_ci(const char *a, const char *b)
{
@@ -326,6 +338,114 @@ test_habit_name_merge_import(void)
remove_tree(dest);
}
static void
write_multi_habit_source_database(const char *root, const char *zip_path)
{
int rounds[] = {77};
InbeHabits habits;
check_true("init multi habit source", inbe_storage_init(root));
check_true("save multi habit source session",
inbe_storage_save_session_for_activity(rounds, 1, 0, 1, NULL, 0));
memset(&habits, 0, sizeof(habits));
check_int("add meditation habit",
inbe_habits_add_custom(&habits, "Meditation",
(Color){224, 124, 104, 255},
INBE_HABIT_SYNC_ACTIVITIES,
(1 << 0) | (1 << 1)),
0);
check_int("add push ups habit",
inbe_habits_add_custom(&habits, "Push ups",
(Color){180, 132, 220, 255},
INBE_HABIT_SYNC_NONE, 0),
1);
check_int("add cold shower habit",
inbe_habits_add_custom(&habits, "Cold Shower",
(Color){99, 196, 165, 255},
INBE_HABIT_SYNC_NONE, 0),
2);
inbe_habit_set_day(&habits, 0, 20260617, 1);
inbe_habit_set_day(&habits, 1, 20260617, 1);
inbe_habit_set_day(&habits, 2, 20260617, 1);
inbe_storage_set_setting_int("speed", 7);
inbe_storage_set_setting_text("language", "en");
inbe_storage_set_setting_text("future_unknown_key", "ignore-me");
check_true("export multi habit source", inbe_storage_export_zip(zip_path));
inbe_storage_close();
}
static void
assert_multi_habits_imported(const char *root, int want_speed)
{
InbeHabits habits;
InbeHabit *habit;
check_true("init multi habit import db", inbe_storage_init(root));
check_int("multi habit imported sessions", inbe_storage_session_count(), 1);
memset(&habits, 0, sizeof(habits));
check_true("multi habit load", inbe_storage_habits_load(&habits));
check_int("multi habit count", habits.count, 3);
habit = find_habit_ci(&habits, "Meditation");
check_true("multi meditation exists", habit != NULL);
check_int("multi meditation sync mode",
habit != NULL ? habit->sync_mode : -1,
INBE_HABIT_SYNC_ACTIVITIES);
check_int("multi meditation sync activity",
habit != NULL ? habit->sync_activity : -1,
(1 << 0) | (1 << 1));
check_true("multi meditation day",
habit != NULL && inbe_habit_completed_day(habit, 20260617));
habit = find_habit_ci(&habits, "Push ups");
check_true("multi push ups day",
habit != NULL && inbe_habit_completed_day(habit, 20260617));
habit = find_habit_ci(&habits, "Cold Shower");
check_true("multi cold shower day",
habit != NULL && inbe_habit_completed_day(habit, 20260617));
check_int("multi import speed setting",
inbe_storage_get_setting_int("speed", -1), want_speed);
check_str("multi import unknown setting",
inbe_storage_get_setting_text("future_unknown_key"), NULL);
inbe_storage_close();
}
static void
test_import_modes_preserve_habits_and_settings_choice(void)
{
char source[512], dest_data[512], dest_settings[512], zip_path[512];
InbeStorageImportInfo info;
make_clean_root(source, sizeof(source), "multi-source");
make_clean_root(dest_data, sizeof(dest_data), "multi-dest-data");
make_clean_root(dest_settings, sizeof(dest_settings), "multi-dest-settings");
make_path(zip_path, sizeof(zip_path), source, "multi-export.zip");
write_multi_habit_source_database(source, zip_path);
check_true("init inspect dest", inbe_storage_init(dest_data));
memset(&info, 0, sizeof(info));
check_true("inspect multi export", inbe_storage_inspect_import(zip_path, &info));
check_true("inspect valid", info.valid);
check_true("inspect sessions", info.has_sessions);
check_true("inspect habits", info.has_habits);
check_true("inspect settings", info.has_settings);
check_int("inspect habit count", info.habit_count, 3);
inbe_storage_set_setting_int("speed", 1);
check_true("multi data only import",
inbe_storage_import_zip_ex(zip_path, INBE_STORAGE_IMPORT_DATA_ONLY));
inbe_storage_close();
assert_multi_habits_imported(dest_data, 1);
check_true("init settings import dest", inbe_storage_init(dest_settings));
inbe_storage_set_setting_int("speed", 1);
check_true("multi data settings import",
inbe_storage_import_zip_ex(zip_path, INBE_STORAGE_IMPORT_DATA_AND_SETTINGS));
inbe_storage_close();
assert_multi_habits_imported(dest_settings, 7);
remove_tree(source);
remove_tree(dest_data);
remove_tree(dest_settings);
}
static void
write_legacy_zip(const char *path, const char *prefix)
{
@@ -469,6 +589,7 @@ main(void)
test_raw_db_import();
test_zip_db_import();
test_habit_name_merge_import();
test_import_modes_preserve_habits_and_settings_choice();
test_legacy_zip_import();
test_legacy_file_startup_migration();
test_tickmate_db_import();
+4 -4
View File
@@ -3,8 +3,8 @@
IDI_APP_ICON ICON "inbe.ico"
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,3,1,0
PRODUCTVERSION 1,3,1,0
FILEVERSION 1,3,3,0
PRODUCTVERSION 1,3,3,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@@ -21,11 +21,11 @@ BEGIN
BEGIN
VALUE "CompanyName", "waozi"
VALUE "FileDescription", "Inner Breeze"
VALUE "FileVersion", "1.3.1"
VALUE "FileVersion", "1.3.3"
VALUE "InternalName", "inbe"
VALUE "OriginalFilename", "inbe-windows-x86_64.exe"
VALUE "ProductName", "Inner Breeze"
VALUE "ProductVersion", "1.3.1"
VALUE "ProductVersion", "1.3.3"
END
END
BLOCK "VarFileInfo"