Compare commits

...
5 Commits
Author SHA1 Message Date
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
waozixyz 2db5045efb fix merge import 2026-06-17 13:47:05 -03:00
waozixyz 0f6f40cb0a fix orientation change 2026-06-17 13:37:38 -03:00
34 changed files with 659 additions and 226 deletions

No files matched your search

+9
View File
@@ -1,4 +1,13 @@
# Changelog
## [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.
## [1.3.1] - 2026-06-17
### Fixed
- Fixed Android orientation resizing and habit import merging by name.
## [1.3.0] - 2026-06-14
### Added
- Implemented 1-bit habit tracker synced with practice data
+18 -10
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,8 @@ 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)),)
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 \
@@ -147,7 +142,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
@@ -353,11 +348,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 +525,14 @@ 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:
@echo "Windows runtime asset downloads are not wired into this build yet"; \
echo "Refusing to build Windows binaries that cannot download meditation audio."; \
exit 1
windows32: $(WIN32_TARGET)
windows64: windows-runtime-assets-check $(WIN64_TARGET)
windows32: windows-runtime-assets-check $(WIN32_TARGET)
windows:
$(MAKE) windows64
@@ -568,4 +573,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: 39 KiB

Binary file not shown.
Binary file not shown.

Before

Width:  |  Height:  |  Size: 72 KiB

After

Width:  |  Height:  |  Size: 75 KiB

+2 -2
View File
@@ -35,8 +35,8 @@ android {
defaultConfig {
minSdk 19
targetSdk 35
versionCode 28
versionName "1.3.0"
versionCode 30
versionName "1.3.2"
}
@@ -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 {
@@ -177,10 +180,10 @@ public class MainActivity extends NativeActivity {
int requested = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
switch (mode) {
case 1:
requested = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
requested = ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT;
break;
case 2:
requested = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
requested = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE;
break;
case 3:
requested = ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR;
@@ -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,2 @@
### Fixed
- Fixed Android orientation changes so forced landscape and portrait resize the app viewport correctly.
@@ -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.
+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);
+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,
+9
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
---
+9
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
---
+9
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
---
+9
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
---
+9
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
---
+9
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
---
+9
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
---
+9
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]
保存
---
+9
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]
저장
---
+9
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
---
+9
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]
保存
---
+21
View File
@@ -1322,6 +1322,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 +1525,7 @@ updateapp(InbeApp *app)
}
finish_frame:
draw_global_modal(app);
app_flush_deferred_settings(app);
app->inbe.frame++;
}
+2
View File
@@ -59,6 +59,7 @@ typedef enum {
UIModalConfirmDeleteData,
UIModalConfirmDeleteHabit,
UIModalEditProgressiveStartSpeed,
UIModalMeditationNetworkError,
} UIModalType;
typedef struct {
@@ -222,6 +223,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];
+2 -2
View File
@@ -3,7 +3,7 @@
#define INBE_VERSION_MAJOR 1
#define INBE_VERSION_MINOR 3
#define INBE_VERSION_PATCH 0
#define INBE_VERSION_STRING "1.3.0"
#define INBE_VERSION_PATCH 2
#define INBE_VERSION_STRING "1.3.2"
#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);
+56 -44
View File
@@ -749,8 +749,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 +802,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 +835,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);
@@ -933,42 +938,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 +1102,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))
+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,
+117 -37
View File
@@ -250,6 +250,84 @@ bind_text(sqlite3_stmt *stmt, int index, const char *text)
return sqlite3_bind_text(stmt, index, text != NULL ? text : "", -1, SQLITE_TRANSIENT) == SQLITE_OK;
}
static long long now_seconds(void);
static int
local_habit_id_by_name(const char *name, char *out, size_t out_size)
{
sqlite3_stmt *stmt = NULL;
int found = 0;
if(name == NULL || name[0] == '\0' || out == NULL || out_size == 0 ||
g_storage.db == NULL)
return 0;
if(sqlite3_prepare_v2(g_storage.db,
"SELECT id FROM habits WHERE name=?1 COLLATE NOCASE AND deleted_at=0 ORDER BY sort_order,id LIMIT 1",
-1, &stmt, NULL) != SQLITE_OK)
return 0;
bind_text(stmt, 1, name);
if(sqlite3_step(stmt) == SQLITE_ROW) {
const char *id = (const char *)sqlite3_column_text(stmt, 0);
if(id != NULL && id[0] != '\0') {
snprintf(out, out_size, "%s", id);
found = out[0] != '\0';
}
}
sqlite3_finalize(stmt);
return found;
}
static int
local_habit_id_exists(const char *id)
{
sqlite3_stmt *stmt = NULL;
int found = 0;
if(id == NULL || id[0] == '\0' || g_storage.db == NULL)
return 0;
if(sqlite3_prepare_v2(g_storage.db,
"SELECT 1 FROM habits WHERE id=?1 LIMIT 1",
-1, &stmt, NULL) != SQLITE_OK)
return 0;
bind_text(stmt, 1, id);
found = sqlite3_step(stmt) == SQLITE_ROW;
sqlite3_finalize(stmt);
return found;
}
static void
make_import_habit_id(char *out, size_t out_size)
{
static unsigned int counter = 0;
if(out == NULL || out_size == 0)
return;
do {
snprintf(out, out_size, "import-%lld-%u", now_seconds(), counter++);
} while(local_habit_id_exists(out));
}
static int
resolve_import_habit_id(const char *import_id, const char *name,
char *out, size_t out_size)
{
if(out == NULL || out_size == 0)
return 0;
out[0] = '\0';
if(local_habit_id_by_name(name, out, out_size))
return 1;
if(import_id != NULL && import_id[0] != '\0' && !local_habit_id_exists(import_id)) {
snprintf(out, out_size, "%s", import_id);
return out[0] != '\0';
}
make_import_habit_id(out, out_size);
return out[0] != '\0';
}
static int
schema_create(void)
{
@@ -1139,7 +1217,6 @@ import_legacy_session_zip(mz_zip_archive *archive)
if(archive == NULL)
return 0;
file_count = mz_zip_reader_get_num_files(archive);
TraceLog(LOG_INFO, "DATA: checking legacy session archive with %u files", file_count);
for(mz_uint i = 0; i < file_count; i++) {
mz_zip_archive_file_stat stat;
int year;
@@ -1169,9 +1246,7 @@ import_legacy_session_zip(mz_zip_archive *archive)
imported++;
free(text);
}
if(imported > 0)
TraceLog(LOG_INFO, "DATA: imported %d legacy sessions", imported);
else
if(imported <= 0)
TraceLog(LOG_WARNING, "DATA: no legacy sessions found in archive");
return imported > 0;
}
@@ -1264,18 +1339,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;
TraceLog(LOG_INFO, "DATA: checking for legacy session files in %s", g_storage.root);
imported = migrate_legacy_file_sessions_in_dir(g_storage.root);
if(imported > 0)
TraceLog(LOG_INFO, "DATA: migrated %d legacy file sessions", imported);
else
TraceLog(LOG_INFO, "DATA: no legacy file sessions found");
migrate_legacy_file_sessions_in_dir(g_storage.root);
set_meta("legacy_file_sessions_migrated", "1");
storage_schedule_persist();
}
@@ -1301,7 +1369,8 @@ import_tickmate_db(sqlite3 *src)
exec_sql("BEGIN IMMEDIATE");
while(sqlite3_step(stmt) == SQLITE_ROW) {
char habit_id[64];
char import_habit_id[64];
char local_habit_id[INBE_STORAGE_ID_SIZE];
const char *name = (const char *)sqlite3_column_text(stmt, 1);
int track_id = sqlite3_column_int(stmt, 0);
int sort_order = sqlite3_column_int(stmt, 3);
@@ -1309,13 +1378,16 @@ import_tickmate_db(sqlite3 *src)
if(name == NULL || name[0] == '\0')
continue;
snprintf(habit_id, sizeof(habit_id), "tickmate-%d", track_id);
snprintf(import_habit_id, sizeof(import_habit_id), "tickmate-%d", track_id);
if(!resolve_import_habit_id(import_habit_id, name, local_habit_id,
sizeof(local_habit_id)))
continue;
if(sqlite3_prepare_v2(g_storage.db,
"INSERT OR REPLACE INTO habits(id,user_id,name,color_r,color_g,color_b,sync_mode,sync_activity,sort_order,deleted_at) "
"VALUES(?1,?2,?3,?4,?5,?6,?7,?8,?9,0)",
"VALUES(?1,?2,COALESCE((SELECT name FROM habits WHERE id=?1),?3),?4,?5,?6,?7,?8,?9,0)",
-1, &write_stmt, NULL) != SQLITE_OK)
continue;
bind_text(write_stmt, 1, habit_id);
bind_text(write_stmt, 1, local_habit_id);
bind_text(write_stmt, 2, g_storage.user_id);
bind_text(write_stmt, 3, name);
sqlite3_bind_int(write_stmt, 4, color.r);
@@ -1333,26 +1405,34 @@ import_tickmate_db(sqlite3 *src)
stmt = NULL;
if(sqlite3_prepare_v2(src,
"SELECT _track_id,year,month,day FROM ticks",
"SELECT ticks._track_id,tracks.name,ticks.year,ticks.month,ticks.day "
"FROM ticks JOIN tracks ON tracks._id=ticks._track_id",
-1, &stmt, NULL) == SQLITE_OK) {
while(sqlite3_step(stmt) == SQLITE_ROW) {
char habit_id[64];
char import_habit_id[64];
char local_habit_id[INBE_STORAGE_ID_SIZE];
int track_id = sqlite3_column_int(stmt, 0);
int year = sqlite3_column_int(stmt, 1);
int month = sqlite3_column_int(stmt, 2);
int day = sqlite3_column_int(stmt, 3);
const char *name = (const char *)sqlite3_column_text(stmt, 1);
int year = sqlite3_column_int(stmt, 2);
int month = sqlite3_column_int(stmt, 3);
int day = sqlite3_column_int(stmt, 4);
int local_date;
if(name == NULL || name[0] == '\0')
continue;
if(year <= 0 || month <= 0 || month > 12 || day <= 0 || day > 31)
continue;
local_date = year * 10000 + month * 100 + day;
snprintf(habit_id, sizeof(habit_id), "tickmate-%d", track_id);
snprintf(import_habit_id, sizeof(import_habit_id), "tickmate-%d", track_id);
if(!resolve_import_habit_id(import_habit_id, name, local_habit_id,
sizeof(local_habit_id)))
continue;
if(sqlite3_prepare_v2(g_storage.db,
"INSERT OR REPLACE INTO habit_days(habit_id,local_date,completed,updated_at) "
"VALUES(?1,?2,1,?3)",
-1, &write_stmt, NULL) != SQLITE_OK)
continue;
bind_text(write_stmt, 1, habit_id);
bind_text(write_stmt, 1, local_habit_id);
sqlite3_bind_int(write_stmt, 2, local_date);
sqlite3_bind_int64(write_stmt, 3, imported_at);
if(sqlite3_step(write_stmt) == SQLITE_DONE)
@@ -1384,7 +1464,6 @@ import_sqlite_db_file(const char *db_path)
if(sqlite3_prepare_v2(src,
"SELECT id,started_at,local_date,topic,activity,source FROM sessions WHERE deleted_at=0",
-1, &stmt, NULL) != SQLITE_OK) {
TraceLog(LOG_INFO, "DATA: sqlite import is not new Inbe schema, trying Tickmate");
goto try_tickmate;
}
@@ -1421,18 +1500,24 @@ import_sqlite_db_file(const char *db_path)
-1, &stmt, NULL) == SQLITE_OK) {
exec_sql("BEGIN IMMEDIATE");
while(sqlite3_step(stmt) == SQLITE_ROW) {
const char *habit_id = (const char *)sqlite3_column_text(stmt, 0);
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];
if(habit_id == NULL || habit_id[0] == '\0')
if(import_habit_id == NULL || import_habit_id[0] == '\0' ||
name == NULL || name[0] == '\0')
continue;
if(!resolve_import_habit_id(import_habit_id, name, local_habit_id,
sizeof(local_habit_id)))
continue;
if(sqlite3_prepare_v2(g_storage.db,
"INSERT OR REPLACE INTO habits(id,user_id,name,color_r,color_g,color_b,sync_mode,sync_activity,sort_order,deleted_at) "
"VALUES(?1,?2,?3,?4,?5,?6,?7,?8,?9,0)",
"VALUES(?1,?2,COALESCE((SELECT name FROM habits WHERE id=?1),?3),?4,?5,?6,?7,?8,?9,0)",
-1, &hstmt, NULL) != SQLITE_OK)
continue;
bind_text(hstmt, 1, habit_id);
bind_text(hstmt, 1, local_habit_id);
bind_text(hstmt, 2, g_storage.user_id);
bind_text(hstmt, 3, (const char *)sqlite3_column_text(stmt, 1));
bind_text(hstmt, 3, name);
sqlite3_bind_int(hstmt, 4, sqlite3_column_int(stmt, 2));
sqlite3_bind_int(hstmt, 5, sqlite3_column_int(stmt, 3));
sqlite3_bind_int(hstmt, 6, sqlite3_column_int(stmt, 4));
@@ -1447,7 +1532,7 @@ import_sqlite_db_file(const char *db_path)
if(sqlite3_prepare_v2(src,
"SELECT local_date,completed FROM habit_days WHERE habit_id=?1",
-1, &hstmt, NULL) == SQLITE_OK) {
sqlite3_bind_text(hstmt, 1, habit_id, -1, SQLITE_TRANSIENT);
sqlite3_bind_text(hstmt, 1, import_habit_id, -1, SQLITE_TRANSIENT);
while(sqlite3_step(hstmt) == SQLITE_ROW) {
sqlite3_stmt *day_stmt = NULL;
if(sqlite3_prepare_v2(g_storage.db,
@@ -1455,7 +1540,7 @@ import_sqlite_db_file(const char *db_path)
"VALUES(?1,?2,?3,?4)",
-1, &day_stmt, NULL) != SQLITE_OK)
continue;
bind_text(day_stmt, 1, habit_id);
bind_text(day_stmt, 1, local_habit_id);
sqlite3_bind_int(day_stmt, 2, sqlite3_column_int(hstmt, 0));
sqlite3_bind_int(day_stmt, 3, sqlite3_column_int(hstmt, 1) != 0);
sqlite3_bind_int64(day_stmt, 4, now_seconds());
@@ -1502,10 +1587,8 @@ inbe_storage_import_zip(const char *path)
TraceLog(LOG_ERROR, "DATA: import path does not exist: %s", path);
return 0;
}
TraceLog(LOG_INFO, "DATA: importing %s", path);
memset(&archive, 0, sizeof(archive));
if(!mz_zip_reader_init_file(&archive, path, 0)) {
TraceLog(LOG_INFO, "DATA: import is not a zip archive, trying sqlite db");
return import_sqlite_db_file(path);
}
if(mz_zip_reader_locate_file(&archive, "inbe-data/inbe.db", NULL, 0) >= 0) {
@@ -1521,9 +1604,7 @@ inbe_storage_import_zip(const char *path)
fp = NULL;
ok = import_sqlite_db_file(temp_path);
remove(temp_path);
if(ok)
TraceLog(LOG_INFO, "DATA: imported sqlite archive");
else
if(!ok)
TraceLog(LOG_ERROR, "DATA: archive contained inbe-data/inbe.db but sqlite import failed");
} else {
TraceLog(LOG_ERROR, "DATA: failed to extract inbe-data/inbe.db from archive");
@@ -1532,7 +1613,6 @@ inbe_storage_import_zip(const char *path)
fclose(fp);
free(db_bytes);
} else {
TraceLog(LOG_INFO, "DATA: archive has no inbe-data/inbe.db, trying legacy sessions");
ok = import_legacy_session_zip(&archive);
}
mz_zip_reader_end(&archive);
+98
View File
@@ -42,6 +42,39 @@ check_true(const char *label, int ok)
g_failures++;
}
static int
ascii_equal_ci(const char *a, const char *b)
{
unsigned char ca;
unsigned char cb;
if(a == NULL || b == NULL)
return 0;
while(*a != '\0' && *b != '\0') {
ca = (unsigned char)*a++;
cb = (unsigned char)*b++;
if(ca >= 'A' && ca <= 'Z')
ca = (unsigned char)(ca - 'A' + 'a');
if(cb >= 'A' && cb <= 'Z')
cb = (unsigned char)(cb - 'A' + 'a');
if(ca != cb)
return 0;
}
return *a == '\0' && *b == '\0';
}
static InbeHabit *
find_habit_ci(InbeHabits *habits, const char *name)
{
if(habits == NULL || name == NULL)
return NULL;
for(int i = 0; i < habits->count; i++) {
if(ascii_equal_ci(habits->items[i].name, name))
return &habits->items[i];
}
return NULL;
}
static int
ensure_dir(const char *path)
{
@@ -229,6 +262,70 @@ test_zip_db_import(void)
remove_tree(dest);
}
static void
test_habit_name_merge_import(void)
{
char source[512], dest[512], zip_path[512];
InbeHabits habits;
InbeHabit *habit;
make_clean_root(source, sizeof(source), "habit-name-source");
make_clean_root(dest, sizeof(dest), "habit-name-dest");
make_path(zip_path, sizeof(zip_path), source, "export.zip");
check_true("init habit merge source", inbe_storage_init(source));
memset(&habits, 0, sizeof(habits));
check_int("add imported meditation",
inbe_habits_add_custom(&habits, "meditation",
(Color){224, 124, 104, 255},
INBE_HABIT_SYNC_NONE, 0),
0);
inbe_habit_set_day(&habits, 0, 20260613, 1);
check_int("add imported push ups",
inbe_habits_add_custom(&habits, "Push ups",
(Color){180, 132, 220, 255},
INBE_HABIT_SYNC_NONE, 0),
1);
inbe_habit_set_day(&habits, 1, 20260614, 1);
check_int("add imported cold shower",
inbe_habits_add_custom(&habits, "Cold Shower",
(Color){99, 196, 165, 255},
INBE_HABIT_SYNC_NONE, 0),
2);
inbe_habit_set_day(&habits, 2, 20260615, 1);
check_true("habit merge export", inbe_storage_export_zip(zip_path));
inbe_storage_close();
check_true("init habit merge dest", inbe_storage_init(dest));
memset(&habits, 0, sizeof(habits));
inbe_habits_add_default_set(&habits);
inbe_habit_set_day(&habits, 0, 20260612, 1);
check_true("habit merge import", inbe_storage_import_zip(zip_path));
memset(&habits, 0, sizeof(habits));
check_true("habit merge load", inbe_storage_habits_load(&habits));
check_int("habit merge count", habits.count, 3);
habit = find_habit_ci(&habits, "Meditation");
check_true("habit merge meditation exists", habit != NULL);
check_true("habit merge preserves local case",
habit != NULL && strcmp(habit->name, "Meditation") == 0);
check_true("habit merge keeps local day",
habit != NULL && inbe_habit_completed_day(habit, 20260612));
check_true("habit merge imports day",
habit != NULL && inbe_habit_completed_day(habit, 20260613));
habit = find_habit_ci(&habits, "Push ups");
check_true("habit merge push ups exists", habit != NULL);
check_true("habit merge push ups day",
habit != NULL && inbe_habit_completed_day(habit, 20260614));
habit = find_habit_ci(&habits, "Cold Shower");
check_true("habit merge cold shower exists", habit != NULL);
check_true("habit merge cold shower day",
habit != NULL && inbe_habit_completed_day(habit, 20260615));
inbe_storage_close();
remove_tree(source);
remove_tree(dest);
}
static void
write_legacy_zip(const char *path, const char *prefix)
{
@@ -371,6 +468,7 @@ main(void)
{
test_raw_db_import();
test_zip_db_import();
test_habit_name_merge_import();
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,0,0
PRODUCTVERSION 1,3,0,0
FILEVERSION 1,3,2,0
PRODUCTVERSION 1,3,2,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@@ -21,11 +21,11 @@ BEGIN
BEGIN
VALUE "CompanyName", "waozi"
VALUE "FileDescription", "Inner Breeze"
VALUE "FileVersion", "1.3.0"
VALUE "FileVersion", "1.3.2"
VALUE "InternalName", "inbe"
VALUE "OriginalFilename", "inbe-windows-x86_64.exe"
VALUE "ProductName", "Inner Breeze"
VALUE "ProductVersion", "1.3.0"
VALUE "ProductVersion", "1.3.2"
END
END
BLOCK "VarFileInfo"