Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d87a9fd7e7 | ||
|
|
6396281b9c | ||
|
|
cac8afab9e | ||
|
|
39c11965ca | ||
|
|
2f45dc30a1 | ||
|
|
0b85606f98 | ||
|
|
2b3183eb38 | ||
|
|
810436f3bb | ||
|
|
c51911383f | ||
|
|
a0ea5d987c | ||
|
|
b7b470ca1c | ||
|
|
63acc477e5 | ||
|
|
aebc742384 | ||
|
|
37856cef75 | ||
|
|
240ae3345f | ||
|
|
8b314ef21f | ||
|
|
604f1adc0b | ||
|
|
05d55bf845 | ||
|
|
393f62e5f0 | ||
|
|
a12cdac763 | ||
|
|
5da72c3710 | ||
|
|
73b6e5a2dc | ||
|
|
9930131571 | ||
|
|
8f8114b8d7 | ||
|
|
cfd92e587a | ||
|
|
e6aa9b1d84 | ||
|
|
e625044648 | ||
|
|
f28daf7668 |
No files matched your search
@@ -169,7 +169,7 @@ jobs:
|
||||
|
||||
build-linux:
|
||||
name: Build Linux
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-22.04
|
||||
needs: test
|
||||
env:
|
||||
APT_CACHE_DIR: /tmp/apt-cache
|
||||
@@ -229,6 +229,37 @@ jobs:
|
||||
find build/dist/linux -maxdepth 1 -type f -name '*.AppImage' -exec cp {} build/release/linux/ \;
|
||||
test -n "$(find build/release/linux -type f -print -quit)"
|
||||
|
||||
- name: Smoke Test Linux AppImage
|
||||
env:
|
||||
APPIMAGE_EXTRACT_AND_RUN: "1"
|
||||
DISPLAY: ":99"
|
||||
run: |
|
||||
set -euo pipefail
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y xvfb x11-utils
|
||||
appimage="$(find build/release/linux -maxdepth 1 -type f -name '*.AppImage' | head -n 1)"
|
||||
chmod +x "$appimage"
|
||||
Xvfb "$DISPLAY" -screen 0 800x600x24 >/tmp/inbe-xvfb.log 2>&1 &
|
||||
xvfb_pid=$!
|
||||
trap 'kill "$app_pid" "$xvfb_pid" >/dev/null 2>&1 || true' EXIT
|
||||
sleep 2
|
||||
"$appimage" >/tmp/inbe-appimage.log 2>&1 &
|
||||
app_pid=$!
|
||||
for _ in $(seq 1 30); do
|
||||
if xwininfo -tree -root | grep -q 'Inner Breeze'; then
|
||||
exit 0
|
||||
fi
|
||||
if ! kill -0 "$app_pid" >/dev/null 2>&1; then
|
||||
echo "AppImage exited before opening a window"
|
||||
cat /tmp/inbe-appimage.log || true
|
||||
exit 1
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
echo "AppImage did not open an X11 window within 30 seconds"
|
||||
cat /tmp/inbe-appimage.log || true
|
||||
exit 1
|
||||
|
||||
- name: Upload Linux Artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
@@ -403,6 +434,10 @@ jobs:
|
||||
- build-linux
|
||||
- build-windows
|
||||
- build-android
|
||||
outputs:
|
||||
tag_pushed: ${{ steps.tag_version.outputs.tag_pushed }}
|
||||
tag_name: ${{ steps.tag_version.outputs.tag_name }}
|
||||
version: ${{ steps.tag_version.outputs.version }}
|
||||
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
@@ -432,6 +467,8 @@ jobs:
|
||||
exit 1
|
||||
fi
|
||||
TAG="v$VERSION"
|
||||
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
|
||||
echo "tag_name=$TAG" >> "$GITHUB_OUTPUT"
|
||||
if git rev-parse "$TAG" >/dev/null 2>&1; then
|
||||
echo "Tag $TAG exists, skipping release"
|
||||
echo "tag_pushed=false" >> "$GITHUB_OUTPUT"
|
||||
@@ -441,7 +478,6 @@ jobs:
|
||||
git tag -a "$TAG" -m "Release $VERSION"
|
||||
git push origin "$TAG"
|
||||
echo "tag_pushed=true" >> "$GITHUB_OUTPUT"
|
||||
echo "tag_name=$TAG" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
- name: Create GitHub Release
|
||||
@@ -454,3 +490,62 @@ jobs:
|
||||
draft: false
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
publish-itch:
|
||||
name: Publish itch.io
|
||||
runs-on: ubuntu-latest
|
||||
needs:
|
||||
- build-web
|
||||
- release
|
||||
if: needs.release.outputs.tag_pushed == 'true'
|
||||
env:
|
||||
BUTLER_API_KEY: ${{ secrets.ITCH_API_KEY }}
|
||||
|
||||
steps:
|
||||
- name: Check itch.io Secret
|
||||
run: |
|
||||
set -euo pipefail
|
||||
if [ -z "${BUTLER_API_KEY:-}" ]; then
|
||||
echo "ITCH_API_KEY secret is required to publish itch.io"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Download Release Artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
pattern: release-*
|
||||
path: build/release
|
||||
merge-multiple: true
|
||||
|
||||
- name: Install Butler
|
||||
run: |
|
||||
set -euo pipefail
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y unzip
|
||||
curl -L -o butler.zip https://broth.itch.ovh/butler/linux-amd64/LATEST/archive/default
|
||||
unzip -q butler.zip -d butler
|
||||
chmod +x butler/butler
|
||||
./butler/butler -V
|
||||
|
||||
- name: Publish Release Builds to itch.io
|
||||
run: |
|
||||
set -euo pipefail
|
||||
VERSION="${{ needs.release.outputs.version }}"
|
||||
|
||||
web_zip="build/release/inbe-web.zip"
|
||||
android_apk="build/release/inbe-$VERSION.apk"
|
||||
windows_zip="build/release/inbe-windows.zip"
|
||||
linux_appimage="build/release/inbe-linux-x86_64.AppImage"
|
||||
|
||||
test -f "$web_zip"
|
||||
test -f "$android_apk"
|
||||
test -f "$windows_zip"
|
||||
test -f "$linux_appimage"
|
||||
|
||||
mkdir -p build/itch/inbe-web
|
||||
unzip -q "$web_zip" -d build/itch/inbe-web
|
||||
|
||||
./butler/butler push build/itch/inbe-web waozi/inbe:html5 --userversion "$VERSION"
|
||||
./butler/butler push "$android_apk" waozi/inbe:android --userversion "$VERSION"
|
||||
./butler/butler push "$windows_zip" waozi/inbe:windows --userversion "$VERSION"
|
||||
./butler/butler push "$linux_appimage" waozi/inbe:linux --userversion "$VERSION"
|
||||
@@ -4,9 +4,6 @@
|
||||
[submodule "vendor/rini"]
|
||||
path = vendor/rini
|
||||
url = https://github.com/raysan5/rini.git
|
||||
[submodule "vendor/otfchop"]
|
||||
path = vendor/otfchop
|
||||
url = https://github.com/waozixyz/otfchop
|
||||
[submodule "vendor/sqlite"]
|
||||
path = vendor/sqlite
|
||||
url = https://github.com/sqlite/sqlite
|
||||
|
||||
@@ -1,4 +1,24 @@
|
||||
# Changelog
|
||||
## [1.5.6] - 2026-06-24
|
||||
### Fixed
|
||||
- Modal button issue
|
||||
|
||||
## [1.5.5] - 2026-06-24
|
||||
### Fixed
|
||||
- modal capture bug
|
||||
- fix sync diff
|
||||
|
||||
## [1.5.4] - 2026-06-24
|
||||
### Changed
|
||||
- Use Flint-managed modal handling so modal dialogs block background input consistently.
|
||||
- Add optional sync account aliases, with compact public ID display and full ID reveal modal.
|
||||
- Make sync state tracking more robust with snapshot hash checks and review flow for unresolved differences.
|
||||
- Use Flint's built-in font chopping pipeline and verify multilingual locale glyph coverage.
|
||||
|
||||
## [1.5.3] - 2026-06-23
|
||||
### Fixed
|
||||
- modal issues
|
||||
|
||||
## [1.5.2] - 2026-06-23
|
||||
### Changed
|
||||
- let you disable screen transitions
|
||||
|
||||
@@ -137,7 +137,10 @@ STORAGE_IMPORT_TEST := $(TEST_BIN_DIR)/storage_import_test
|
||||
LOCALE_KEYS_TEST := $(TEST_BIN_DIR)/locale_keys_test
|
||||
SYNC_URL_TEST := $(TEST_BIN_DIR)/sync_url_test
|
||||
SYNC_ACCOUNT_TEST := $(TEST_BIN_DIR)/sync_account_test
|
||||
SYNC_REVIEW_TEST := $(TEST_BIN_DIR)/sync_review_test
|
||||
FONT_LOCALE_TEST := $(TEST_BIN_DIR)/font_locale_test
|
||||
GUIDE_OVERLAY_TEST := $(TEST_BIN_DIR)/guide_overlay_test
|
||||
TESTS := $(STORAGE_IMPORT_TEST) $(LOCALE_KEYS_TEST) $(SYNC_URL_TEST) $(SYNC_ACCOUNT_TEST) $(SYNC_REVIEW_TEST) $(FONT_LOCALE_TEST) $(GUIDE_OVERLAY_TEST)
|
||||
FLINT_RUNTIME_ASSET_CFLAGS := $(FLINT_CURL_CFLAGS)
|
||||
FLINT_RUNTIME_ASSET_LDLIBS := $(FLINT_CURL_LDLIBS)
|
||||
|
||||
@@ -165,6 +168,7 @@ APP_SRCS := \
|
||||
src/storage/db.c \
|
||||
src/storage/import.c \
|
||||
src/storage/storage.c \
|
||||
src/storage/sync_review.c \
|
||||
src/storage/sync_account.c \
|
||||
src/storage/sync_client.c \
|
||||
src/third_party/miniz.c \
|
||||
@@ -182,7 +186,7 @@ LOCALE_FILES := $(wildcard locales/*.txt)
|
||||
IMAGE_FILES := assets/practices/whm/1.jpg assets/practices/whm/2.jpg assets/practices/meditation/1.jpg
|
||||
SOUND_FILES := $(wildcard assets/sounds/*.ogg)
|
||||
FONT_OUTPUTS := assets/fonts/locales.png assets/fonts/locales.dat
|
||||
OTFCHOP_DIR ?= vendor/otfchop
|
||||
OTFCHOP_DIR ?= $(FLINT_DIR)/tools/otfchop
|
||||
FONT_TOOL := $(OTFCHOP_DIR)/otfchop
|
||||
FONT_SOURCE := $(OTFCHOP_DIR)/unifont-17.0.04.otf
|
||||
EMBEDDED_ASSETS_C := $(BUILD_OBJ_DIR)/$(APP_NAME)_embedded_assets.c
|
||||
@@ -301,18 +305,38 @@ screenshot: $(TARGET)
|
||||
./scripts/generate-screenshots.sh "$(TARGET)"
|
||||
|
||||
|
||||
test: $(STORAGE_IMPORT_TEST) $(LOCALE_KEYS_TEST) $(SYNC_URL_TEST) $(SYNC_ACCOUNT_TEST) $(GUIDE_OVERLAY_TEST)
|
||||
$(STORAGE_IMPORT_TEST)
|
||||
$(LOCALE_KEYS_TEST)
|
||||
$(SYNC_URL_TEST)
|
||||
$(SYNC_ACCOUNT_TEST)
|
||||
$(GUIDE_OVERLAY_TEST)
|
||||
.SILENT: test $(TESTS)
|
||||
|
||||
$(STORAGE_IMPORT_TEST): tests/storage_import_test.c src/storage/storage.c src/storage/db.c src/storage/import.c src/storage/storage.h src/storage/db.h src/storage/import.h src/screens/habits_screen.c src/screens/habits/edit.c src/screens/habits/session.c src/screens/habits_screen.h src/screens/habits/habits.h src/third_party/miniz.c src/third_party/miniz.h $(SQLITE_SRC) $(SQLITE_AMALGAMATION_H) | $(TEST_BIN_DIR)
|
||||
test: $(TESTS)
|
||||
echo "== Inbe tests =="; \
|
||||
status=0; \
|
||||
for test_bin in $(TESTS); do \
|
||||
name=$$(basename "$$test_bin"); \
|
||||
log=$$(mktemp /tmp/inbe-test.XXXXXX); \
|
||||
printf "%-28s" "$$name"; \
|
||||
if "$$test_bin" >"$$log" 2>&1; then \
|
||||
echo "PASS"; \
|
||||
rm -f "$$log"; \
|
||||
else \
|
||||
echo "FAIL"; \
|
||||
cat "$$log"; \
|
||||
rm -f "$$log"; \
|
||||
status=1; \
|
||||
break; \
|
||||
fi; \
|
||||
done; \
|
||||
if [ "$$status" -eq 0 ]; then \
|
||||
echo "== PASS: all Inbe tests =="; \
|
||||
else \
|
||||
echo "== FAIL: Inbe tests =="; \
|
||||
fi; \
|
||||
exit "$$status"
|
||||
|
||||
$(STORAGE_IMPORT_TEST): tests/storage_import_test.c src/storage/storage.c src/storage/sync_review.c src/storage/db.c src/storage/import.c src/storage/storage.h src/storage/db.h src/storage/import.h src/screens/habits_screen.c src/screens/habits/edit.c src/screens/habits/session.c src/screens/habits_screen.h src/screens/habits/habits.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 \
|
||||
-Isrc -Isrc/app -Isrc/core -Isrc/screens -Isrc/screens/settings -Isrc/practices -Isrc/practices/whm -Isrc/practices/meditation -Isrc/storage -Isrc/platform/android -Isrc/third_party -Ivendor/raylib/src $(FLINT_INCLUDE) $(SQLITE_INCLUDE) \
|
||||
-o $@ \
|
||||
tests/storage_import_test.c src/storage/storage.c src/storage/db.c src/storage/import.c src/screens/habits_screen.c src/screens/habits/edit.c src/screens/habits/session.c src/third_party/miniz.c $(SQLITE_SRC) \
|
||||
tests/storage_import_test.c src/storage/storage.c src/storage/sync_review.c src/storage/db.c src/storage/import.c src/screens/habits_screen.c src/screens/habits/edit.c src/screens/habits/session.c src/third_party/miniz.c $(SQLITE_SRC) \
|
||||
-Wl,--gc-sections -lm -lpthread -ldl
|
||||
|
||||
$(LOCALE_KEYS_TEST): tests/locale_keys_test.c $(LOCALE_FILES) | $(TEST_BIN_DIR)
|
||||
@@ -326,13 +350,25 @@ $(SYNC_URL_TEST): tests/sync_url_test.c src/storage/sync_client.c src/storage/sy
|
||||
tests/sync_url_test.c src/storage/sync_client.c \
|
||||
-Wl,--gc-sections $(FLINT_CURL_LDLIBS)
|
||||
|
||||
$(SYNC_ACCOUNT_TEST): tests/sync_account_test.c src/storage/sync_account.c src/storage/sync_account.h src/storage/storage.c src/storage/db.c src/storage/import.c src/storage/storage.h src/storage/db.h src/storage/import.h src/third_party/miniz.c src/third_party/miniz.h $(SQLITE_SRC) $(SQLITE_AMALGAMATION_H) | $(TEST_BIN_DIR)
|
||||
$(SYNC_ACCOUNT_TEST): tests/sync_account_test.c src/storage/sync_account.c src/storage/sync_account.h src/storage/storage.c src/storage/sync_review.c src/storage/db.c src/storage/import.c src/storage/storage.h src/storage/db.h src/storage/import.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 \
|
||||
-Isrc -Isrc/app -Isrc/core -Isrc/screens -Isrc/screens/settings -Isrc/practices -Isrc/practices/whm -Isrc/practices/meditation -Isrc/storage -Isrc/platform/android -Isrc/third_party -Ivendor/flint/include -Ivendor/raylib/src $(SQLITE_INCLUDE) \
|
||||
-o $@ \
|
||||
tests/sync_account_test.c src/storage/sync_account.c src/storage/storage.c src/storage/db.c src/storage/import.c src/third_party/miniz.c $(SQLITE_SRC) \
|
||||
tests/sync_account_test.c src/storage/sync_account.c src/storage/storage.c src/storage/sync_review.c src/storage/db.c src/storage/import.c src/third_party/miniz.c $(SQLITE_SRC) \
|
||||
-Wl,--gc-sections -lm -lpthread -ldl
|
||||
|
||||
$(SYNC_REVIEW_TEST): tests/sync_review_test.c src/storage/storage.c src/storage/sync_review.c src/storage/db.c src/storage/import.c src/storage/storage.h src/storage/db.h src/storage/import.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 \
|
||||
-Isrc -Isrc/app -Isrc/core -Isrc/screens -Isrc/screens/settings -Isrc/practices -Isrc/practices/whm -Isrc/practices/meditation -Isrc/storage -Isrc/platform/android -Isrc/third_party -Ivendor/flint/include -Ivendor/raylib/src $(SQLITE_INCLUDE) \
|
||||
-o $@ \
|
||||
tests/sync_review_test.c src/storage/storage.c src/storage/sync_review.c src/storage/db.c src/storage/import.c src/third_party/miniz.c $(SQLITE_SRC) \
|
||||
-Wl,--gc-sections -lm -lpthread -ldl
|
||||
|
||||
$(FONT_LOCALE_TEST): tests/font_locale_test.c $(FONT_OUTPUTS) | $(TEST_BIN_DIR)
|
||||
$(CC) -Wall -Wextra -std=c99 -D_DEFAULT_SOURCE \
|
||||
-o $@ \
|
||||
tests/font_locale_test.c
|
||||
|
||||
$(GUIDE_OVERLAY_TEST): tests/guide_overlay_test.c vendor/flint/src/ui/guide.c vendor/flint/include/flint_ui.h | $(TEST_BIN_DIR)
|
||||
$(CC) -Wall -Wextra -std=c99 -D_DEFAULT_SOURCE \
|
||||
-Ivendor/flint/include -Ivendor/raylib/src \
|
||||
@@ -350,8 +386,8 @@ assets/fonts:
|
||||
|
||||
FORCE:
|
||||
|
||||
$(FONT_TOOL): vendor/otfchop/otfchop.c vendor/otfchop/stb_truetype.h vendor/otfchop/stb_image_write.h
|
||||
$(MAKE) -C vendor/otfchop otfchop
|
||||
$(FONT_TOOL): $(OTFCHOP_DIR)/otfchop.c $(OTFCHOP_DIR)/stb_truetype.h $(OTFCHOP_DIR)/stb_image_write.h
|
||||
$(MAKE) -C $(OTFCHOP_DIR) otfchop
|
||||
|
||||
assets/fonts/locales.png assets/fonts/locales.dat: $(LOCALE_FILES) $(FONT_TOOL) | assets/fonts
|
||||
$(FONT_TOOL) $(FONT_SOURCE) $(LOCALE_FILES) assets/fonts/locales
|
||||
@@ -720,7 +756,7 @@ $(APPIMAGE_TARGET): $(TARGET) $(LINUX_APPIMAGE_APPRUN) $(LINUX_APPIMAGE_DESKTOP)
|
||||
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/lib $(LINUX_APPDIR)/usr/share/applications $(LINUX_APPDIR)/usr/share/icons/hicolor/512x512/apps $(LINUX_APPDIR)/usr/share/metainfo
|
||||
mkdir -p $(LINUX_APPDIR)/usr/bin $(LINUX_APPDIR)/usr/lib $(LINUX_APPDIR)/usr/share/applications $(LINUX_APPDIR)/usr/share/icons/hicolor/512x512/apps $(LINUX_APPDIR)/usr/share/metainfo $(LINUX_APPDIR)/usr/share/appdata
|
||||
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
|
||||
@@ -743,6 +779,7 @@ $(APPIMAGE_TARGET): $(TARGET) $(LINUX_APPIMAGE_APPRUN) $(LINUX_APPIMAGE_DESKTOP)
|
||||
cp $(LINUX_APPIMAGE_DESKTOP) $(LINUX_APPDIR)/$(APP_NAME).desktop
|
||||
cp $(LINUX_APPIMAGE_DESKTOP) $(LINUX_APPDIR)/usr/share/applications/$(APP_NAME).desktop
|
||||
cp $(LINUX_APPIMAGE_APPDATA) $(LINUX_APPDIR)/usr/share/metainfo/$(ANDROID_APP_ID).metainfo.xml
|
||||
cp $(LINUX_APPIMAGE_APPDATA) $(LINUX_APPDIR)/usr/share/appdata/$(ANDROID_APP_ID).appdata.xml
|
||||
cp $(LINUX_APPIMAGE_ICON) $(LINUX_APPDIR)/$(APP_NAME).png
|
||||
cp $(LINUX_APPIMAGE_ICON) $(LINUX_APPDIR)/usr/share/icons/hicolor/512x512/apps/$(APP_NAME).png
|
||||
@# Manually copy critical X11/OpenGL libraries that linuxdeploy might miss
|
||||
|
||||
@@ -44,6 +44,17 @@ make android-debug
|
||||
make android-release PASSWORD=your-keystore-password
|
||||
```
|
||||
|
||||
## Release Automation
|
||||
|
||||
GitHub Actions builds release artifacts for web, Linux, Windows, Android, and
|
||||
the Chrome extension. When a new version tag is created by the release workflow,
|
||||
the web, Android, Windows, and Linux builds are also published to itch.io.
|
||||
|
||||
Required repository secrets:
|
||||
|
||||
- `ITCH_API_KEY` - itch.io Butler API key for publishing `waozi/inbe:html5`,
|
||||
`waozi/inbe:android`, `waozi/inbe:windows`, and `waozi/inbe:linux`
|
||||
|
||||
### Android Emulator Testing
|
||||
|
||||
For automated testing with camera notch (cutout) support:
|
||||
@@ -78,11 +89,23 @@ The AVD is configured with:
|
||||
|
||||
- `src/` - Inbe application code
|
||||
- `vendor/` - external third-party dependencies
|
||||
- `vendor/flint/` - first-party UI/runtime support code used directly by Inbe
|
||||
- `vendor/flint/` - **git submodule** for first-party UI/runtime support code used directly by Inbe
|
||||
- `wasm4/` - Standalone WASM-4 version
|
||||
- `assets/` - Images and sounds
|
||||
- `droid/` - Android build configuration
|
||||
|
||||
## Flint submodule workflow
|
||||
|
||||
`vendor/flint` is a source submodule (not a one-off copied sync). To update Inbe after a Flint change:
|
||||
|
||||
1. Push changes in the Flint repo.
|
||||
2. In Inbe, update the submodule pointer:
|
||||
- `git submodule update --init --recursive vendor/flint`
|
||||
- `git -C vendor/flint pull`
|
||||
3. Commit Inbe with the updated `vendor/flint` submodule reference.
|
||||
|
||||
When updating other projects that vendor Flint as a submodule, this keeps UI behavior and API docs aligned.
|
||||
|
||||
## License
|
||||
|
||||
MIT - see [LICENSE](LICENSE)
|
||||
|
Before Width: | Height: | Size: 98 KiB After Width: | Height: | Size: 98 KiB |
|
Before Width: | Height: | Size: 249 B After Width: | Height: | Size: 1021 B |
|
Before Width: | Height: | Size: 235 B After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 323 B After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 265 B After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 294 B After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 295 B |
@@ -35,8 +35,8 @@ android {
|
||||
defaultConfig {
|
||||
minSdk 21
|
||||
targetSdk 35
|
||||
versionCode 48
|
||||
versionName "1.5.2"
|
||||
versionCode 52
|
||||
versionName "1.5.6"
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -2,8 +2,11 @@ cmake_minimum_required(VERSION 3.22)
|
||||
project(Inbe C)
|
||||
|
||||
find_program(CCACHE_PROGRAM ccache)
|
||||
if(CCACHE_PROGRAM)
|
||||
if(CCACHE_PROGRAM AND EXISTS "${CCACHE_PROGRAM}")
|
||||
set(CMAKE_C_COMPILER_LAUNCHER "${CCACHE_PROGRAM}")
|
||||
else()
|
||||
set(CMAKE_C_COMPILER_LAUNCHER "")
|
||||
set(CMAKE_C_COMPILER_LAUNCHER "" CACHE STRING "" FORCE)
|
||||
endif()
|
||||
|
||||
set(REPO_ROOT "${CMAKE_CURRENT_LIST_DIR}/../../../../..")
|
||||
@@ -116,6 +119,7 @@ add_library(main SHARED
|
||||
"${SRC_DIR}/storage/db.c"
|
||||
"${SRC_DIR}/storage/import.c"
|
||||
"${SRC_DIR}/storage/storage.c"
|
||||
"${SRC_DIR}/storage/sync_review.c"
|
||||
"${SRC_DIR}/storage/sync_account.c"
|
||||
"${SRC_DIR}/storage/sync_client.c"
|
||||
"${SRC_DIR}/third_party/miniz.c"
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
Fixed
|
||||
---
|
||||
- modal issues
|
||||
@@ -0,0 +1,6 @@
|
||||
Changed
|
||||
---
|
||||
- Use Flint-managed modal handling so modal dialogs block background input consistently.
|
||||
- Add optional sync account aliases, with compact public ID display and full ID reveal modal.
|
||||
- Make sync state tracking more robust with snapshot hash checks and review flow for unresolved differences.
|
||||
- Use Flint's built-in font chopping pipeline and verify multilingual locale glyph coverage.
|
||||
@@ -0,0 +1,3 @@
|
||||
Fixed
|
||||
---
|
||||
- modal capture bug
|
||||
@@ -0,0 +1,3 @@
|
||||
Fixed
|
||||
---
|
||||
- Modal button issue
|
||||
@@ -247,6 +247,12 @@ Pauza po kole
|
||||
[advanced_session_controls_label]
|
||||
Pokročilé ovládání sezení
|
||||
---
|
||||
[double_tap_to_breathe_label]
|
||||
Double tap to breathe
|
||||
---
|
||||
[double_tap_to_breathe_hint]
|
||||
Double tap screen to breathe
|
||||
---
|
||||
[hold_display_label]
|
||||
Zobrazeni zadrze
|
||||
---
|
||||
@@ -675,10 +681,10 @@ Název
|
||||
Podtržení
|
||||
---
|
||||
[habit_practice_list_title]
|
||||
Seznam cvičení
|
||||
Session Data From
|
||||
---
|
||||
[habit_practice_list_info]
|
||||
Propojte tento návyk se cvičeními. Dny s odpovídajícími záznamy se zobrazí jako splněné a mohou otevřít editor sezení.
|
||||
Choose which practice sessions count for this habit. Matching days show as completed and can open the session editor.
|
||||
---
|
||||
[habit_counting_title]
|
||||
Počítání
|
||||
@@ -815,3 +821,45 @@ None
|
||||
Fade
|
||||
[theme_picker_title]
|
||||
Choose Theme
|
||||
[skip_button]
|
||||
Skip
|
||||
---
|
||||
[sync_public_id_full_title]
|
||||
Full Public ID
|
||||
---
|
||||
[sync_public_id_full_message]
|
||||
Use this if you need the full account identifier.
|
||||
---
|
||||
[sync_alias_button]
|
||||
Alias
|
||||
---
|
||||
[sync_alias_title]
|
||||
Choose Alias
|
||||
---
|
||||
[sync_alias_message]
|
||||
Pick a short alias for this account on the current sync server.
|
||||
---
|
||||
[sync_alias_rule]
|
||||
4-32 characters: lowercase letters, numbers, or underscore.
|
||||
---
|
||||
[sync_alias_register_button]
|
||||
Register Alias
|
||||
---
|
||||
[sync_alias_registered]
|
||||
Alias registered.
|
||||
---
|
||||
[sync_alias_failed]
|
||||
Could not register alias.
|
||||
---
|
||||
[sync_alias_change_title]
|
||||
Change Alias
|
||||
---
|
||||
[sync_alias_change_message]
|
||||
Change the short name for this account on this sync server.
|
||||
---
|
||||
[sync_alias_save_button]
|
||||
Save Alias
|
||||
---
|
||||
[sync_alias_saved]
|
||||
Alias saved
|
||||
---
|
||||
@@ -247,6 +247,12 @@ Pause nach Runde
|
||||
[advanced_session_controls_label]
|
||||
Erweiterte Sitzungssteuerung
|
||||
---
|
||||
[double_tap_to_breathe_label]
|
||||
Double tap to breathe
|
||||
---
|
||||
[double_tap_to_breathe_hint]
|
||||
Double tap screen to breathe
|
||||
---
|
||||
[hold_display_label]
|
||||
Atemhalteanzeige
|
||||
---
|
||||
@@ -675,10 +681,10 @@ Bezeichnung
|
||||
Unterstreichung
|
||||
---
|
||||
[habit_practice_list_title]
|
||||
Übungsliste
|
||||
Session Data From
|
||||
---
|
||||
[habit_practice_list_info]
|
||||
Verknüpfe diese Gewohnheit mit Übungssitzungen. Tage mit passenden Sitzungen werden als erledigt angezeigt und können den Sitzungseditor öffnen.
|
||||
Choose which practice sessions count for this habit. Matching days show as completed and can open the session editor.
|
||||
---
|
||||
[habit_counting_title]
|
||||
Zählen
|
||||
@@ -815,3 +821,45 @@ None
|
||||
Fade
|
||||
[theme_picker_title]
|
||||
Choose Theme
|
||||
[skip_button]
|
||||
Skip
|
||||
---
|
||||
[sync_public_id_full_title]
|
||||
Full Public ID
|
||||
---
|
||||
[sync_public_id_full_message]
|
||||
Use this if you need the full account identifier.
|
||||
---
|
||||
[sync_alias_button]
|
||||
Alias
|
||||
---
|
||||
[sync_alias_title]
|
||||
Choose Alias
|
||||
---
|
||||
[sync_alias_message]
|
||||
Pick a short alias for this account on the current sync server.
|
||||
---
|
||||
[sync_alias_rule]
|
||||
4-32 characters: lowercase letters, numbers, or underscore.
|
||||
---
|
||||
[sync_alias_register_button]
|
||||
Register Alias
|
||||
---
|
||||
[sync_alias_registered]
|
||||
Alias registered.
|
||||
---
|
||||
[sync_alias_failed]
|
||||
Could not register alias.
|
||||
---
|
||||
[sync_alias_change_title]
|
||||
Change Alias
|
||||
---
|
||||
[sync_alias_change_message]
|
||||
Change the short name for this account on this sync server.
|
||||
---
|
||||
[sync_alias_save_button]
|
||||
Save Alias
|
||||
---
|
||||
[sync_alias_saved]
|
||||
Alias saved
|
||||
---
|
||||
@@ -121,6 +121,9 @@ Save completed rounds before exit?
|
||||
[cancel_button]
|
||||
Cancel
|
||||
---
|
||||
[skip_button]
|
||||
Skip
|
||||
---
|
||||
[ok_button]
|
||||
OK
|
||||
---
|
||||
@@ -304,6 +307,12 @@ Pause after round
|
||||
[advanced_session_controls_label]
|
||||
Advanced session controls
|
||||
---
|
||||
[double_tap_to_breathe_label]
|
||||
Double tap to breathe
|
||||
---
|
||||
[double_tap_to_breathe_hint]
|
||||
Double tap screen to breathe
|
||||
---
|
||||
[hold_display_label]
|
||||
Hold display
|
||||
---
|
||||
@@ -575,6 +584,45 @@ Copy ID
|
||||
[sync_public_id_copied]
|
||||
Public ID copied
|
||||
---
|
||||
[sync_public_id_full_title]
|
||||
Full Public ID
|
||||
---
|
||||
[sync_public_id_full_message]
|
||||
This is the full account identifier.
|
||||
---
|
||||
[sync_alias_button]
|
||||
Alias
|
||||
---
|
||||
[sync_alias_title]
|
||||
Account Alias
|
||||
---
|
||||
[sync_alias_message]
|
||||
Choose a short name for this account. This is optional.
|
||||
---
|
||||
[sync_alias_change_title]
|
||||
Change Alias
|
||||
---
|
||||
[sync_alias_change_message]
|
||||
Change the short name for this account on this sync server.
|
||||
---
|
||||
[sync_alias_rule]
|
||||
4-32 letters, numbers, or underscore.
|
||||
---
|
||||
[sync_alias_register_button]
|
||||
Register
|
||||
---
|
||||
[sync_alias_save_button]
|
||||
Save Alias
|
||||
---
|
||||
[sync_alias_saved]
|
||||
Alias saved
|
||||
---
|
||||
[sync_alias_registered]
|
||||
Alias registered
|
||||
---
|
||||
[sync_alias_failed]
|
||||
Alias unavailable or remote failed
|
||||
---
|
||||
[sync_backup_key_button]
|
||||
Backup Key
|
||||
---
|
||||
@@ -678,7 +726,7 @@ Underline
|
||||
Practice list
|
||||
---
|
||||
[habit_practice_list_info]
|
||||
Link this habit to practice sessions. Days with matching sessions will show as completed and can open the session editor.
|
||||
Choose which practice sessions count for this habit. Matching days show as completed and can open the session editor.
|
||||
---
|
||||
[habit_counting_title]
|
||||
Counting
|
||||
|
||||
@@ -247,6 +247,12 @@ Pausa después de ronda
|
||||
[advanced_session_controls_label]
|
||||
Controles avanzados de sesión
|
||||
---
|
||||
[double_tap_to_breathe_label]
|
||||
Double tap to breathe
|
||||
---
|
||||
[double_tap_to_breathe_hint]
|
||||
Double tap screen to breathe
|
||||
---
|
||||
[hold_display_label]
|
||||
Visualizacion de retencion
|
||||
---
|
||||
@@ -675,10 +681,10 @@ Nombre
|
||||
Subrayado
|
||||
---
|
||||
[habit_practice_list_title]
|
||||
Lista de prácticas
|
||||
Session Data From
|
||||
---
|
||||
[habit_practice_list_info]
|
||||
Vincula este hábito con sesiones de práctica. Los días con sesiones coincidentes aparecerán como completados y podrán abrir el editor de sesión.
|
||||
Choose which practice sessions count for this habit. Matching days show as completed and can open the session editor.
|
||||
---
|
||||
[habit_counting_title]
|
||||
Conteo
|
||||
@@ -815,3 +821,45 @@ None
|
||||
Fade
|
||||
[theme_picker_title]
|
||||
Choose Theme
|
||||
[skip_button]
|
||||
Skip
|
||||
---
|
||||
[sync_public_id_full_title]
|
||||
Full Public ID
|
||||
---
|
||||
[sync_public_id_full_message]
|
||||
Use this if you need the full account identifier.
|
||||
---
|
||||
[sync_alias_button]
|
||||
Alias
|
||||
---
|
||||
[sync_alias_title]
|
||||
Choose Alias
|
||||
---
|
||||
[sync_alias_message]
|
||||
Pick a short alias for this account on the current sync server.
|
||||
---
|
||||
[sync_alias_rule]
|
||||
4-32 characters: lowercase letters, numbers, or underscore.
|
||||
---
|
||||
[sync_alias_register_button]
|
||||
Register Alias
|
||||
---
|
||||
[sync_alias_registered]
|
||||
Alias registered.
|
||||
---
|
||||
[sync_alias_failed]
|
||||
Could not register alias.
|
||||
---
|
||||
[sync_alias_change_title]
|
||||
Change Alias
|
||||
---
|
||||
[sync_alias_change_message]
|
||||
Change the short name for this account on this sync server.
|
||||
---
|
||||
[sync_alias_save_button]
|
||||
Save Alias
|
||||
---
|
||||
[sync_alias_saved]
|
||||
Alias saved
|
||||
---
|
||||
@@ -118,6 +118,9 @@ Enregistrer les cycles terminés avant de quitter ?
|
||||
[cancel_button]
|
||||
Annuler
|
||||
---
|
||||
[skip_button]
|
||||
Ignorer
|
||||
---
|
||||
[ok_button]
|
||||
OK
|
||||
---
|
||||
@@ -247,6 +250,12 @@ Pause après cycle
|
||||
[advanced_session_controls_label]
|
||||
Contrôles avancés de séance
|
||||
---
|
||||
[double_tap_to_breathe_label]
|
||||
Double tap to breathe
|
||||
---
|
||||
[double_tap_to_breathe_hint]
|
||||
Double tap screen to breathe
|
||||
---
|
||||
[hold_display_label]
|
||||
Affichage de la retention
|
||||
---
|
||||
@@ -575,6 +584,45 @@ Copier l’ID
|
||||
[sync_public_id_copied]
|
||||
ID public copié
|
||||
---
|
||||
[sync_public_id_full_title]
|
||||
ID public complet
|
||||
---
|
||||
[sync_public_id_full_message]
|
||||
Voici l’identifiant complet du compte.
|
||||
---
|
||||
[sync_alias_button]
|
||||
Alias
|
||||
---
|
||||
[sync_alias_title]
|
||||
Alias du compte
|
||||
---
|
||||
[sync_alias_message]
|
||||
Choisissez un nom court pour ce compte. C’est facultatif.
|
||||
---
|
||||
[sync_alias_change_title]
|
||||
Modifier l’alias
|
||||
---
|
||||
[sync_alias_change_message]
|
||||
Modifiez le nom court de ce compte sur ce serveur de synchronisation.
|
||||
---
|
||||
[sync_alias_rule]
|
||||
4 à 32 lettres, chiffres ou tiret bas.
|
||||
---
|
||||
[sync_alias_register_button]
|
||||
Enregistrer
|
||||
---
|
||||
[sync_alias_save_button]
|
||||
Enregistrer l’alias
|
||||
---
|
||||
[sync_alias_saved]
|
||||
Alias enregistré
|
||||
---
|
||||
[sync_alias_registered]
|
||||
Alias enregistré
|
||||
---
|
||||
[sync_alias_failed]
|
||||
Alias indisponible ou échec distant
|
||||
---
|
||||
[sync_backup_key_button]
|
||||
Sauvegarder la clé
|
||||
---
|
||||
@@ -675,10 +723,10 @@ Nom
|
||||
Soulignement
|
||||
---
|
||||
[habit_practice_list_title]
|
||||
Liste des pratiques
|
||||
Session Data From
|
||||
---
|
||||
[habit_practice_list_info]
|
||||
Associez cette habitude aux séances de pratique. Les jours avec des séances correspondantes apparaîtront comme terminés et pourront ouvrir l'éditeur de séance.
|
||||
Choose which practice sessions count for this habit. Matching days show as completed and can open the session editor.
|
||||
---
|
||||
[habit_counting_title]
|
||||
Comptage
|
||||
|
||||
@@ -247,6 +247,12 @@ Jeda setelah ronde
|
||||
[advanced_session_controls_label]
|
||||
Kontrol sesi lanjutan
|
||||
---
|
||||
[double_tap_to_breathe_label]
|
||||
Double tap to breathe
|
||||
---
|
||||
[double_tap_to_breathe_hint]
|
||||
Double tap screen to breathe
|
||||
---
|
||||
[hold_display_label]
|
||||
Tampilan tahan napas
|
||||
---
|
||||
@@ -675,10 +681,10 @@ Nama
|
||||
Garis bawah
|
||||
---
|
||||
[habit_practice_list_title]
|
||||
Daftar latihan
|
||||
Session Data From
|
||||
---
|
||||
[habit_practice_list_info]
|
||||
Hubungkan kebiasaan ini ke sesi latihan. Hari dengan sesi yang cocok akan tampil selesai dan dapat membuka editor sesi.
|
||||
Choose which practice sessions count for this habit. Matching days show as completed and can open the session editor.
|
||||
---
|
||||
[habit_counting_title]
|
||||
Penghitungan
|
||||
@@ -815,3 +821,45 @@ None
|
||||
Fade
|
||||
[theme_picker_title]
|
||||
Choose Theme
|
||||
[skip_button]
|
||||
Skip
|
||||
---
|
||||
[sync_public_id_full_title]
|
||||
Full Public ID
|
||||
---
|
||||
[sync_public_id_full_message]
|
||||
Use this if you need the full account identifier.
|
||||
---
|
||||
[sync_alias_button]
|
||||
Alias
|
||||
---
|
||||
[sync_alias_title]
|
||||
Choose Alias
|
||||
---
|
||||
[sync_alias_message]
|
||||
Pick a short alias for this account on the current sync server.
|
||||
---
|
||||
[sync_alias_rule]
|
||||
4-32 characters: lowercase letters, numbers, or underscore.
|
||||
---
|
||||
[sync_alias_register_button]
|
||||
Register Alias
|
||||
---
|
||||
[sync_alias_registered]
|
||||
Alias registered.
|
||||
---
|
||||
[sync_alias_failed]
|
||||
Could not register alias.
|
||||
---
|
||||
[sync_alias_change_title]
|
||||
Change Alias
|
||||
---
|
||||
[sync_alias_change_message]
|
||||
Change the short name for this account on this sync server.
|
||||
---
|
||||
[sync_alias_save_button]
|
||||
Save Alias
|
||||
---
|
||||
[sync_alias_saved]
|
||||
Alias saved
|
||||
---
|
||||
@@ -301,6 +301,12 @@ Pausa dopo round
|
||||
[advanced_session_controls_label]
|
||||
Controlli avanzati sessione
|
||||
---
|
||||
[double_tap_to_breathe_label]
|
||||
Double tap to breathe
|
||||
---
|
||||
[double_tap_to_breathe_hint]
|
||||
Double tap screen to breathe
|
||||
---
|
||||
[hold_display_label]
|
||||
Visualizzazione trattenuta
|
||||
---
|
||||
@@ -675,10 +681,10 @@ Nome
|
||||
Sottolineatura
|
||||
---
|
||||
[habit_practice_list_title]
|
||||
Elenco pratiche
|
||||
Session Data From
|
||||
---
|
||||
[habit_practice_list_info]
|
||||
Collega questa abitudine alle sessioni di pratica. I giorni con sessioni corrispondenti verranno mostrati come completati e potranno aprire l'editor della sessione.
|
||||
Choose which practice sessions count for this habit. Matching days show as completed and can open the session editor.
|
||||
---
|
||||
[habit_counting_title]
|
||||
Conteggio
|
||||
@@ -815,3 +821,45 @@ None
|
||||
Fade
|
||||
[theme_picker_title]
|
||||
Choose Theme
|
||||
[skip_button]
|
||||
Skip
|
||||
---
|
||||
[sync_public_id_full_title]
|
||||
Full Public ID
|
||||
---
|
||||
[sync_public_id_full_message]
|
||||
Use this if you need the full account identifier.
|
||||
---
|
||||
[sync_alias_button]
|
||||
Alias
|
||||
---
|
||||
[sync_alias_title]
|
||||
Choose Alias
|
||||
---
|
||||
[sync_alias_message]
|
||||
Pick a short alias for this account on the current sync server.
|
||||
---
|
||||
[sync_alias_rule]
|
||||
4-32 characters: lowercase letters, numbers, or underscore.
|
||||
---
|
||||
[sync_alias_register_button]
|
||||
Register Alias
|
||||
---
|
||||
[sync_alias_registered]
|
||||
Alias registered.
|
||||
---
|
||||
[sync_alias_failed]
|
||||
Could not register alias.
|
||||
---
|
||||
[sync_alias_change_title]
|
||||
Change Alias
|
||||
---
|
||||
[sync_alias_change_message]
|
||||
Change the short name for this account on this sync server.
|
||||
---
|
||||
[sync_alias_save_button]
|
||||
Save Alias
|
||||
---
|
||||
[sync_alias_saved]
|
||||
Alias saved
|
||||
---
|
||||
@@ -247,6 +247,12 @@ OK
|
||||
[advanced_session_controls_label]
|
||||
詳細なセッション設定
|
||||
---
|
||||
[double_tap_to_breathe_label]
|
||||
Double tap to breathe
|
||||
---
|
||||
[double_tap_to_breathe_hint]
|
||||
Double tap screen to breathe
|
||||
---
|
||||
[hold_display_label]
|
||||
ホールド表示
|
||||
---
|
||||
@@ -675,10 +681,10 @@ https:// または localhost:8080 のようなループバックを使用して
|
||||
下線
|
||||
---
|
||||
[habit_practice_list_title]
|
||||
練習リスト
|
||||
Session Data From
|
||||
---
|
||||
[habit_practice_list_info]
|
||||
この習慣を練習セッションに関連付けます。一致するセッションがある日は完了として表示され、セッション編集画面を開けます。
|
||||
Choose which practice sessions count for this habit. Matching days show as completed and can open the session editor.
|
||||
---
|
||||
[habit_counting_title]
|
||||
カウント
|
||||
@@ -815,3 +821,45 @@ None
|
||||
Fade
|
||||
[theme_picker_title]
|
||||
Choose Theme
|
||||
[skip_button]
|
||||
Skip
|
||||
---
|
||||
[sync_public_id_full_title]
|
||||
Full Public ID
|
||||
---
|
||||
[sync_public_id_full_message]
|
||||
Use this if you need the full account identifier.
|
||||
---
|
||||
[sync_alias_button]
|
||||
Alias
|
||||
---
|
||||
[sync_alias_title]
|
||||
Choose Alias
|
||||
---
|
||||
[sync_alias_message]
|
||||
Pick a short alias for this account on the current sync server.
|
||||
---
|
||||
[sync_alias_rule]
|
||||
4-32 characters: lowercase letters, numbers, or underscore.
|
||||
---
|
||||
[sync_alias_register_button]
|
||||
Register Alias
|
||||
---
|
||||
[sync_alias_registered]
|
||||
Alias registered.
|
||||
---
|
||||
[sync_alias_failed]
|
||||
Could not register alias.
|
||||
---
|
||||
[sync_alias_change_title]
|
||||
Change Alias
|
||||
---
|
||||
[sync_alias_change_message]
|
||||
Change the short name for this account on this sync server.
|
||||
---
|
||||
[sync_alias_save_button]
|
||||
Save Alias
|
||||
---
|
||||
[sync_alias_saved]
|
||||
Alias saved
|
||||
---
|
||||
@@ -301,6 +301,12 @@ Inner Breeze
|
||||
[advanced_session_controls_label]
|
||||
고급 세션 제어
|
||||
---
|
||||
[double_tap_to_breathe_label]
|
||||
Double tap to breathe
|
||||
---
|
||||
[double_tap_to_breathe_hint]
|
||||
Double tap screen to breathe
|
||||
---
|
||||
[hold_display_label]
|
||||
홀드 표시
|
||||
---
|
||||
@@ -674,10 +680,10 @@ https:// 또는 localhost:8080 같은 루프백을 사용하세요
|
||||
밑줄
|
||||
---
|
||||
[habit_practice_list_title]
|
||||
연습 목록
|
||||
Session Data From
|
||||
---
|
||||
[habit_practice_list_info]
|
||||
이 습관을 연습 세션에 연결합니다. 일치하는 세션이 있는 날은 완료로 표시되며 세션 편집기를 열 수 있습니다.
|
||||
Choose which practice sessions count for this habit. Matching days show as completed and can open the session editor.
|
||||
---
|
||||
[habit_counting_title]
|
||||
횟수
|
||||
@@ -814,3 +820,45 @@ None
|
||||
Fade
|
||||
[theme_picker_title]
|
||||
Choose Theme
|
||||
[skip_button]
|
||||
Skip
|
||||
---
|
||||
[sync_public_id_full_title]
|
||||
Full Public ID
|
||||
---
|
||||
[sync_public_id_full_message]
|
||||
Use this if you need the full account identifier.
|
||||
---
|
||||
[sync_alias_button]
|
||||
Alias
|
||||
---
|
||||
[sync_alias_title]
|
||||
Choose Alias
|
||||
---
|
||||
[sync_alias_message]
|
||||
Pick a short alias for this account on the current sync server.
|
||||
---
|
||||
[sync_alias_rule]
|
||||
4-32 characters: lowercase letters, numbers, or underscore.
|
||||
---
|
||||
[sync_alias_register_button]
|
||||
Register Alias
|
||||
---
|
||||
[sync_alias_registered]
|
||||
Alias registered.
|
||||
---
|
||||
[sync_alias_failed]
|
||||
Could not register alias.
|
||||
---
|
||||
[sync_alias_change_title]
|
||||
Change Alias
|
||||
---
|
||||
[sync_alias_change_message]
|
||||
Change the short name for this account on this sync server.
|
||||
---
|
||||
[sync_alias_save_button]
|
||||
Save Alias
|
||||
---
|
||||
[sync_alias_saved]
|
||||
Alias saved
|
||||
---
|
||||
@@ -247,6 +247,12 @@ Pausa após rodada
|
||||
[advanced_session_controls_label]
|
||||
Controles avançados da sessão
|
||||
---
|
||||
[double_tap_to_breathe_label]
|
||||
Double tap to breathe
|
||||
---
|
||||
[double_tap_to_breathe_hint]
|
||||
Double tap screen to breathe
|
||||
---
|
||||
[hold_display_label]
|
||||
Exibicao da retencao
|
||||
---
|
||||
@@ -675,10 +681,10 @@ Nome
|
||||
Sublinhado
|
||||
---
|
||||
[habit_practice_list_title]
|
||||
Lista de práticas
|
||||
Session Data From
|
||||
---
|
||||
[habit_practice_list_info]
|
||||
Vincule este hábito às sessões de prática. Dias com sessões correspondentes aparecerão como concluídos e poderão abrir o editor de sessão.
|
||||
Choose which practice sessions count for this habit. Matching days show as completed and can open the session editor.
|
||||
---
|
||||
[habit_counting_title]
|
||||
Contagem
|
||||
@@ -815,3 +821,45 @@ None
|
||||
Fade
|
||||
[theme_picker_title]
|
||||
Choose Theme
|
||||
[skip_button]
|
||||
Skip
|
||||
---
|
||||
[sync_public_id_full_title]
|
||||
Full Public ID
|
||||
---
|
||||
[sync_public_id_full_message]
|
||||
Use this if you need the full account identifier.
|
||||
---
|
||||
[sync_alias_button]
|
||||
Alias
|
||||
---
|
||||
[sync_alias_title]
|
||||
Choose Alias
|
||||
---
|
||||
[sync_alias_message]
|
||||
Pick a short alias for this account on the current sync server.
|
||||
---
|
||||
[sync_alias_rule]
|
||||
4-32 characters: lowercase letters, numbers, or underscore.
|
||||
---
|
||||
[sync_alias_register_button]
|
||||
Register Alias
|
||||
---
|
||||
[sync_alias_registered]
|
||||
Alias registered.
|
||||
---
|
||||
[sync_alias_failed]
|
||||
Could not register alias.
|
||||
---
|
||||
[sync_alias_change_title]
|
||||
Change Alias
|
||||
---
|
||||
[sync_alias_change_message]
|
||||
Change the short name for this account on this sync server.
|
||||
---
|
||||
[sync_alias_save_button]
|
||||
Save Alias
|
||||
---
|
||||
[sync_alias_saved]
|
||||
Alias saved
|
||||
---
|
||||
@@ -304,6 +304,12 @@ OK
|
||||
[advanced_session_controls_label]
|
||||
Расширенное управление сессией
|
||||
---
|
||||
[double_tap_to_breathe_label]
|
||||
Double tap to breathe
|
||||
---
|
||||
[double_tap_to_breathe_hint]
|
||||
Double tap screen to breathe
|
||||
---
|
||||
[hold_display_label]
|
||||
Отображение задержки
|
||||
---
|
||||
@@ -675,10 +681,10 @@ liboqs не собран для этой платформы.
|
||||
Подчеркивание
|
||||
---
|
||||
[habit_practice_list_title]
|
||||
Список практик
|
||||
Session Data From
|
||||
---
|
||||
[habit_practice_list_info]
|
||||
Свяжите эту привычку с сеансами практики. Дни с подходящими сеансами будут отмечены как выполненные и смогут открыть редактор сеанса.
|
||||
Choose which practice sessions count for this habit. Matching days show as completed and can open the session editor.
|
||||
---
|
||||
[habit_counting_title]
|
||||
Подсчет
|
||||
@@ -815,3 +821,45 @@ None
|
||||
Fade
|
||||
[theme_picker_title]
|
||||
Choose Theme
|
||||
[skip_button]
|
||||
Skip
|
||||
---
|
||||
[sync_public_id_full_title]
|
||||
Full Public ID
|
||||
---
|
||||
[sync_public_id_full_message]
|
||||
Use this if you need the full account identifier.
|
||||
---
|
||||
[sync_alias_button]
|
||||
Alias
|
||||
---
|
||||
[sync_alias_title]
|
||||
Choose Alias
|
||||
---
|
||||
[sync_alias_message]
|
||||
Pick a short alias for this account on the current sync server.
|
||||
---
|
||||
[sync_alias_rule]
|
||||
4-32 characters: lowercase letters, numbers, or underscore.
|
||||
---
|
||||
[sync_alias_register_button]
|
||||
Register Alias
|
||||
---
|
||||
[sync_alias_registered]
|
||||
Alias registered.
|
||||
---
|
||||
[sync_alias_failed]
|
||||
Could not register alias.
|
||||
---
|
||||
[sync_alias_change_title]
|
||||
Change Alias
|
||||
---
|
||||
[sync_alias_change_message]
|
||||
Change the short name for this account on this sync server.
|
||||
---
|
||||
[sync_alias_save_button]
|
||||
Save Alias
|
||||
---
|
||||
[sync_alias_saved]
|
||||
Alias saved
|
||||
---
|
||||
@@ -247,6 +247,12 @@ Wim Hof 呼吸
|
||||
[advanced_session_controls_label]
|
||||
高级练习控制
|
||||
---
|
||||
[double_tap_to_breathe_label]
|
||||
Double tap to breathe
|
||||
---
|
||||
[double_tap_to_breathe_hint]
|
||||
Double tap screen to breathe
|
||||
---
|
||||
[hold_display_label]
|
||||
屏息显示
|
||||
---
|
||||
@@ -673,10 +679,10 @@ liboqs 未为此目标构建。
|
||||
下划线
|
||||
---
|
||||
[habit_practice_list_title]
|
||||
练习列表
|
||||
Session Data From
|
||||
---
|
||||
[habit_practice_list_info]
|
||||
将此习惯关联到练习会话。有匹配会话的日期会显示为已完成,并可打开会话编辑器。
|
||||
Choose which practice sessions count for this habit. Matching days show as completed and can open the session editor.
|
||||
---
|
||||
[habit_counting_title]
|
||||
计数
|
||||
@@ -813,3 +819,45 @@ None
|
||||
Fade
|
||||
[theme_picker_title]
|
||||
Choose Theme
|
||||
[skip_button]
|
||||
Skip
|
||||
---
|
||||
[sync_public_id_full_title]
|
||||
Full Public ID
|
||||
---
|
||||
[sync_public_id_full_message]
|
||||
Use this if you need the full account identifier.
|
||||
---
|
||||
[sync_alias_button]
|
||||
Alias
|
||||
---
|
||||
[sync_alias_title]
|
||||
Choose Alias
|
||||
---
|
||||
[sync_alias_message]
|
||||
Pick a short alias for this account on the current sync server.
|
||||
---
|
||||
[sync_alias_rule]
|
||||
4-32 characters: lowercase letters, numbers, or underscore.
|
||||
---
|
||||
[sync_alias_register_button]
|
||||
Register Alias
|
||||
---
|
||||
[sync_alias_registered]
|
||||
Alias registered.
|
||||
---
|
||||
[sync_alias_failed]
|
||||
Could not register alias.
|
||||
---
|
||||
[sync_alias_change_title]
|
||||
Change Alias
|
||||
---
|
||||
[sync_alias_change_message]
|
||||
Change the short name for this account on this sync server.
|
||||
---
|
||||
[sync_alias_save_button]
|
||||
Save Alias
|
||||
---
|
||||
[sync_alias_saved]
|
||||
Alias saved
|
||||
---
|
||||
@@ -12,6 +12,8 @@
|
||||
#include "screens/language_screen.h"
|
||||
#include "screens/manual_screen.h"
|
||||
#include "screens/settings/settings_screen.h"
|
||||
#include "screens/settings/settings_data.h"
|
||||
#include "screens/settings/settings_sync_account.h"
|
||||
#include "screens/settings/settings_theme.h"
|
||||
#include "screens/practice_screen.h"
|
||||
#include "practices/practice_registry.h"
|
||||
@@ -320,6 +322,32 @@ app_background_sync_safe(const InbeApp *app)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const char *
|
||||
app_modal_type_name(UIModalType type)
|
||||
{
|
||||
switch(type) {
|
||||
case UIModalNone: return "none";
|
||||
case UIModalConfirmExitSession: return "confirm_exit_session";
|
||||
case UIModalMeditationSetup: return "meditation_setup";
|
||||
case UIModalConfirmDeleteData: return "confirm_delete_data";
|
||||
case UIModalConfirmDeleteHabit: return "confirm_delete_habit";
|
||||
case UIModalEditProgressiveStartSpeed: return "edit_progressive_start_speed";
|
||||
case UIModalMeditationNetworkError: return "meditation_network_error";
|
||||
case UIModalConfirmImportDataSettings: return "confirm_import_data_settings";
|
||||
case UIModalSyncAccountBackup: return "sync_account_backup";
|
||||
case UIModalConfirmDeleteSyncAccount: return "confirm_delete_sync_account";
|
||||
case UIModalHabitPracticeListInfo: return "habit_practice_list_info";
|
||||
case UIModalHabitCountingInfo: return "habit_counting_info";
|
||||
case UIModalBottomNavConfig: return "bottom_nav_config";
|
||||
case UIModalThemePicker: return "theme_picker";
|
||||
case UIModalSyncReview: return "sync_review";
|
||||
case UIModalSyncAlias: return "sync_alias";
|
||||
case UIModalSyncPublicId: return "sync_public_id";
|
||||
default: break;
|
||||
}
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
static int
|
||||
app_input_active(void)
|
||||
{
|
||||
@@ -444,6 +472,13 @@ app_pump_sync(InbeApp *app)
|
||||
if(app == NULL)
|
||||
return;
|
||||
app_collect_finished_sync();
|
||||
if(storage_sync_review_pending() && !app->modal.active) {
|
||||
if(storage_sync_review_clear_if_no_visible_diff()) {
|
||||
app_reload_after_import(app, 0);
|
||||
} else {
|
||||
app_open_modal(app, UIModalSyncReview);
|
||||
}
|
||||
}
|
||||
app_apply_pending_sync_refresh(app);
|
||||
if(!app_sync_url(url, sizeof(url)))
|
||||
return;
|
||||
@@ -473,7 +508,14 @@ app_pump_sync(InbeApp *app)
|
||||
return;
|
||||
}
|
||||
if(!app_background_sync_safe(app)) {
|
||||
TraceLog(LOG_INFO, "SYNC: delayed; app is active");
|
||||
TraceLog(LOG_INFO,
|
||||
"SYNC: delayed; modal=%d type=%s screen=%d pending_review=%d tutorial_seen=%d habits_guide_seen=%d",
|
||||
app->modal.active,
|
||||
app_modal_type_name(app->modal.type),
|
||||
app->inbe.screen,
|
||||
storage_sync_review_pending(),
|
||||
app->tutorial_seen,
|
||||
app->habits_guide_seen);
|
||||
if(g_dirty_sync_at <= 0.0)
|
||||
g_dirty_sync_at = now + 1.0;
|
||||
return;
|
||||
@@ -521,6 +563,13 @@ app_switch_screen(InbeApp *app, int screen)
|
||||
if(screen == InbeScreenHabits && app->inbe.screen != InbeScreenHabits)
|
||||
app->habits.focus_selected_tab = 1;
|
||||
|
||||
if(app->transition_mode == APP_TRANSITION_NONE) {
|
||||
flint_transition_reset(&app->screen_transition);
|
||||
app->inbe.screen = screen;
|
||||
app->screen_transition_target = screen;
|
||||
return;
|
||||
}
|
||||
|
||||
app->screen_transition_target = screen;
|
||||
if(app->screen_transition.active) {
|
||||
if(app->inbe.screen != screen)
|
||||
@@ -552,6 +601,11 @@ app_observe_direct_screen_change(InbeApp *app, int before_screen)
|
||||
before_screen == app->inbe.screen)
|
||||
return;
|
||||
|
||||
if(app->transition_mode == APP_TRANSITION_NONE) {
|
||||
app->screen_transition_target = app->inbe.screen;
|
||||
return;
|
||||
}
|
||||
|
||||
app->screen_transition = (FlintTransition){
|
||||
.active = 1,
|
||||
.phase = FLINT_TRANSITION_IN,
|
||||
@@ -788,6 +842,25 @@ app_nav_route_label(int route)
|
||||
return "";
|
||||
}
|
||||
|
||||
void
|
||||
app_open_modal(InbeApp *app, UIModalType type)
|
||||
{
|
||||
if(app == NULL)
|
||||
return;
|
||||
app->modal.active = 1;
|
||||
app->modal.type = type;
|
||||
app->modal_open_frame = app->inbe.frame;
|
||||
}
|
||||
|
||||
void
|
||||
app_close_modal(InbeApp *app)
|
||||
{
|
||||
if(app == NULL)
|
||||
return;
|
||||
app->modal.active = 0;
|
||||
app->modal.type = UIModalNone;
|
||||
}
|
||||
|
||||
static Texture2D
|
||||
app_nav_route_icon(InbeApp *app, int route)
|
||||
{
|
||||
@@ -1669,9 +1742,7 @@ handle_back_button(InbeApp *app)
|
||||
app_init(app);
|
||||
} else {
|
||||
/* Show confirmation modal */
|
||||
app->modal.active = 1;
|
||||
app->modal.type = UIModalConfirmExitSession;
|
||||
app->modal.selected_button = 0;
|
||||
app_open_modal(app, UIModalConfirmExitSession);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1737,8 +1808,7 @@ app_draw_bottom_nav_config_modal(InbeApp *app)
|
||||
.close_icon = app->icons[UI_ICON_TYPE_X]
|
||||
});
|
||||
if(result.action == 1) {
|
||||
app->modal.active = 0;
|
||||
app->modal.type = UIModalNone;
|
||||
app_close_modal(app);
|
||||
} else if(result.action == 2) {
|
||||
app->bottom_nav_count = app->bottom_nav_draft_count;
|
||||
for(int i = 0; i < APP_BOTTOM_NAV_MAX_ITEMS; i++)
|
||||
@@ -1748,8 +1818,7 @@ app_draw_bottom_nav_config_modal(InbeApp *app)
|
||||
app_bottom_nav_normalize(app);
|
||||
app->settings_dirty = 1;
|
||||
save_settings(app);
|
||||
app->modal.active = 0;
|
||||
app->modal.type = UIModalNone;
|
||||
app_close_modal(app);
|
||||
} else if(result.action == 3) {
|
||||
app_bottom_nav_default_routes(app->bottom_nav_draft_routes,
|
||||
&app->bottom_nav_draft_count);
|
||||
@@ -1766,20 +1835,46 @@ draw_global_modal(InbeApp *app)
|
||||
if(app->modal_open_frame == app->inbe.frame)
|
||||
return;
|
||||
|
||||
if(settings_data_draw_modals(app))
|
||||
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;
|
||||
app_close_modal(app);
|
||||
}
|
||||
}
|
||||
if(app->modal.type == UIModalBottomNavConfig)
|
||||
app_draw_bottom_nav_config_modal(app);
|
||||
if(app->modal.type == UIModalThemePicker)
|
||||
settings_screen_draw_theme_picker_modal(app);
|
||||
if(app->modal.type == UIModalSyncAlias) {
|
||||
modal_result = settings_sync_account_draw_alias_modal(app);
|
||||
if(modal_result == 1) {
|
||||
int then_backup = app->sync_alias_then_backup;
|
||||
app->sync_alias_then_backup = 0;
|
||||
app_close_modal(app);
|
||||
settings_screen_set_status_success(locale_get("sync_alias_saved"), NULL);
|
||||
if(then_backup)
|
||||
app_open_modal(app, UIModalSyncAccountBackup);
|
||||
} else if(modal_result == 2) {
|
||||
settings_screen_set_status_error(locale_get("sync_alias_failed"));
|
||||
} else if(modal_result == 3) {
|
||||
int then_backup = app->sync_alias_then_backup;
|
||||
app->sync_alias_then_backup = 0;
|
||||
app_close_modal(app);
|
||||
if(then_backup)
|
||||
app_open_modal(app, UIModalSyncAccountBackup);
|
||||
}
|
||||
}
|
||||
if(app->modal.type == UIModalSyncPublicId) {
|
||||
modal_result = settings_sync_account_draw_public_id_modal(app);
|
||||
if(modal_result != 0)
|
||||
app_close_modal(app);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1791,7 +1886,6 @@ updateapp(InbeApp *app)
|
||||
int frame_screen = app->inbe.screen;
|
||||
int first_run_guide_active = 0;
|
||||
int habits_guide_active = 0;
|
||||
int guide_active = 0;
|
||||
|
||||
app_apply_pending_sidebar_route(app);
|
||||
for(int i = 0; i < practice_count(); i++) {
|
||||
@@ -1805,8 +1899,7 @@ updateapp(InbeApp *app)
|
||||
habits_screen_prepare_first_run_guide(app);
|
||||
first_run_guide_active = practice_screen_first_run_guide_active(app);
|
||||
habits_guide_active = habits_screen_first_run_guide_active(app);
|
||||
guide_active = first_run_guide_active || habits_guide_active;
|
||||
ui_set_input_blocked(guide_active);
|
||||
ui_set_input_blocked(app->modal.active);
|
||||
|
||||
if(IsKeyPressed(KEY_BACK)) {
|
||||
if(first_run_guide_active || habits_guide_active) {
|
||||
@@ -1815,8 +1908,7 @@ updateapp(InbeApp *app)
|
||||
app->habits_guide_step = 0;
|
||||
habits_screen_prepare_first_run_guide(app);
|
||||
} else if(app->modal.active) {
|
||||
app->modal.active = 0;
|
||||
app->modal.type = UIModalNone;
|
||||
app_close_modal(app);
|
||||
} else {
|
||||
handle_back_button(app);
|
||||
}
|
||||
@@ -1881,7 +1973,9 @@ updateapp(InbeApp *app)
|
||||
|
||||
practice_screen_draw_top_bar(app, 1);
|
||||
}
|
||||
if(app->modal.active && app->modal.type == UIModalMeditationSetup) {
|
||||
// Skip drawing on the same frame modal opens to prevent click propagation
|
||||
if(app->modal.active && app->modal.type == UIModalMeditationSetup &&
|
||||
app->modal_open_frame != app->inbe.frame) {
|
||||
const PracticeDefinition *practice = practice_get(PRACTICE_MEDITATION);
|
||||
if(practice->draw_setup_modal != NULL)
|
||||
practice->draw_setup_modal(app);
|
||||
@@ -1908,12 +2002,10 @@ updateapp(InbeApp *app)
|
||||
|
||||
finish_frame:
|
||||
app_draw_bottom_nav(app);
|
||||
if(guide_active)
|
||||
ui_set_input_blocked(0);
|
||||
ui_set_input_blocked(0);
|
||||
practice_screen_draw_first_run_guide(app);
|
||||
habits_screen_draw_first_run_guide(app);
|
||||
if(!guide_active)
|
||||
ui_set_input_blocked(0);
|
||||
ui_set_input_blocked(0);
|
||||
draw_global_modal(app);
|
||||
app_flush_deferred_settings(app);
|
||||
app_observe_direct_screen_change(app, frame_screen);
|
||||
|
||||
@@ -76,12 +76,14 @@ typedef enum {
|
||||
UIModalHabitCountingInfo,
|
||||
UIModalBottomNavConfig,
|
||||
UIModalThemePicker,
|
||||
UIModalSyncReview,
|
||||
UIModalSyncAlias,
|
||||
UIModalSyncPublicId,
|
||||
} UIModalType;
|
||||
|
||||
typedef struct {
|
||||
int active;
|
||||
UIModalType type;
|
||||
int selected_button;
|
||||
} UIModal;
|
||||
|
||||
typedef struct InbeConfig {
|
||||
@@ -233,6 +235,10 @@ struct InbeApp {
|
||||
int sync_server_url_cursor;
|
||||
int sync_server_url_focused;
|
||||
char sync_server_url[256];
|
||||
int sync_alias_cursor;
|
||||
int sync_alias_focused;
|
||||
int sync_alias_then_backup;
|
||||
char sync_alias_input[40];
|
||||
int device_picker_open;
|
||||
int device_picker_scroll;
|
||||
int fullscreen_enabled;
|
||||
@@ -279,6 +285,8 @@ struct InbeApp {
|
||||
int habit_counter_press_start_y;
|
||||
int advanced_session_controls;
|
||||
int show_session_volume_control;
|
||||
int double_tap_to_breathe;
|
||||
double breath_tap_last_time;
|
||||
int hold_display_mode;
|
||||
int exercise_type;
|
||||
int practice_tab;
|
||||
@@ -316,6 +324,9 @@ void app_play_sound(InbeApp *app, Sound sound, float scale);
|
||||
Texture2D app_load_asset_texture(const char *name);
|
||||
void app_unload_texture(Texture2D texture);
|
||||
|
||||
void app_open_modal(InbeApp *app, UIModalType type);
|
||||
void app_close_modal(InbeApp *app);
|
||||
|
||||
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);
|
||||
|
||||
@@ -183,6 +183,7 @@ save_settings(InbeApp *app)
|
||||
{"progressive_start_speed", app->inbe.progressive_start_speed},
|
||||
{"breath_animation", app->inbe.breath_animation},
|
||||
{"advanced_session_controls", app->advanced_session_controls ? 1 : 0},
|
||||
{"double_tap_to_breathe", app->double_tap_to_breathe ? 1 : 0},
|
||||
{"show_session_volume_control", app->show_session_volume_control ? 1 : 0},
|
||||
{"hold_display_mode", app->hold_display_mode},
|
||||
{"exercise_type", app->exercise_type},
|
||||
@@ -269,6 +270,7 @@ app_load_settings(InbeApp *app)
|
||||
#endif
|
||||
{&app->inbe.progressive_speed, "progressive_speed", 1},
|
||||
{&app->advanced_session_controls, "advanced_session_controls", 0},
|
||||
{&app->double_tap_to_breathe, "double_tap_to_breathe", 0},
|
||||
{&app->show_session_volume_control, "show_session_volume_control", 0},
|
||||
{&app->meditation.music_enabled, "meditation_music_enabled", 1},
|
||||
{&app->meditation.music_shuffle, "meditation_music_shuffle", 0},
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
#define INBE_VERSION_MAJOR 1
|
||||
#define INBE_VERSION_MINOR 5
|
||||
#define INBE_VERSION_PATCH 2
|
||||
#define INBE_VERSION_STRING "1.5.2"
|
||||
#define INBE_VERSION_PATCH 6
|
||||
#define INBE_VERSION_STRING "1.5.6"
|
||||
|
||||
#endif
|
||||
@@ -496,7 +496,7 @@ setup_screenshot_scene(InbeApp *app, const ScreenshotRequest *request)
|
||||
return;
|
||||
|
||||
app->language_selected = 1;
|
||||
app->modal.active = 0;
|
||||
app_close_modal(app);
|
||||
app->settings_scroll = 0;
|
||||
app->manual_scroll = 0;
|
||||
app->tutorial_step = 0;
|
||||
|
||||
@@ -566,9 +566,7 @@ meditation_music_update(InbeApp *app)
|
||||
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_open_modal(app, UIModalMeditationNetworkError);
|
||||
app->meditation.music_network_error_notified = 1;
|
||||
}
|
||||
} else if(app->meditation.music_download.error[0] != '\0') {
|
||||
|
||||
@@ -25,9 +25,7 @@ meditation_practice_start(InbeApp *app)
|
||||
if(app == NULL)
|
||||
return;
|
||||
mark_exercise_manual_seen(app, EXERCISE_MEDITATION);
|
||||
app->modal.active = 1;
|
||||
app->modal.type = UIModalMeditationSetup;
|
||||
app->modal.selected_button = 0;
|
||||
app_open_modal(app, UIModalMeditationSetup);
|
||||
app_switch_screen(app, InbeScreenStart);
|
||||
}
|
||||
|
||||
|
||||
@@ -37,8 +37,7 @@ meditation_start(InbeApp *app, int seconds)
|
||||
app->meditation.frame_ticks = 0;
|
||||
app->session_paused = 0;
|
||||
app->volume_popup_active = 0;
|
||||
app->modal.active = 0;
|
||||
app->modal.type = UIModalNone;
|
||||
app_close_modal(app);
|
||||
app_switch_screen(app, InbeScreenMeditation);
|
||||
app_play_sound(app, app->bell_sound, 1.0f);
|
||||
meditation_music_start_session(app);
|
||||
@@ -139,8 +138,7 @@ meditation_exit_to_start(InbeApp *app)
|
||||
app->meditation.frame_ticks = 0;
|
||||
app->session_paused = 0;
|
||||
app->volume_popup_active = 0;
|
||||
app->modal.active = 0;
|
||||
app->modal.type = UIModalNone;
|
||||
app_close_modal(app);
|
||||
app_switch_screen(app, InbeScreenStart);
|
||||
}
|
||||
|
||||
@@ -149,9 +147,7 @@ meditation_request_exit(InbeApp *app)
|
||||
{
|
||||
if(app == NULL)
|
||||
return;
|
||||
app->modal.active = 1;
|
||||
app->modal.type = UIModalConfirmExitSession;
|
||||
app->modal.selected_button = 0;
|
||||
app_open_modal(app, UIModalConfirmExitSession);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -221,6 +217,9 @@ meditation_draw_setup_modal(InbeApp *app)
|
||||
if(btn_w < flint_px(64))
|
||||
btn_w = flint_px(64);
|
||||
|
||||
ui_set_modal_capture((Rectangle){
|
||||
(float)modal_x, (float)modal_y, (float)modal_w, (float)modal_h
|
||||
});
|
||||
DrawRectangle(0, 0, view_width, view_height, (Color){0, 0, 0, 180});
|
||||
DrawRectangle(modal_x, modal_y, modal_w, modal_h, flint_theme_get_surface());
|
||||
ui_draw_bevel(modal_x, modal_y, modal_w, modal_h,
|
||||
@@ -251,8 +250,7 @@ meditation_draw_setup_modal(InbeApp *app)
|
||||
if(ui_draw_generic_button(cancel_x, cancel_y, cancel_w, btn_h,
|
||||
locale_get("cancel_button"), UI_BUTTON_STYLE_SECONDARY,
|
||||
0, &cancel_hover)) {
|
||||
app->modal.active = 0;
|
||||
app->modal.type = UIModalNone;
|
||||
app_close_modal(app);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -310,8 +308,7 @@ meditation_draw_screen(InbeApp *app, int center_x, int center_y)
|
||||
locale_get("save_button"),
|
||||
locale_get("discard_button"));
|
||||
if(modal_result == 1) {
|
||||
app->modal.active = 0;
|
||||
app->modal.type = UIModalNone;
|
||||
app_close_modal(app);
|
||||
} else if(modal_result == 2) {
|
||||
meditation_save_elapsed(app);
|
||||
meditation_exit_to_start(app);
|
||||
@@ -324,8 +321,7 @@ meditation_draw_screen(InbeApp *app, int center_x, int center_y)
|
||||
locale_get("cancel_button"),
|
||||
locale_get("exit_button"));
|
||||
if(modal_result == 1) {
|
||||
app->modal.active = 0;
|
||||
app->modal.type = UIModalNone;
|
||||
app_close_modal(app);
|
||||
} else if(modal_result == 2) {
|
||||
meditation_exit_to_start(app);
|
||||
}
|
||||
|
||||
@@ -64,6 +64,9 @@ whm_draw_progressive_start_speed_editor(InbeApp *app)
|
||||
modal_y = (view_height - modal_h) / 2;
|
||||
title_y = modal_y + flint_px(14);
|
||||
|
||||
ui_set_modal_capture((Rectangle){
|
||||
(float)modal_x, (float)modal_y, (float)modal_w, (float)modal_h
|
||||
});
|
||||
DrawRectangle(0, 0, view_width, view_height, (Color){0, 0, 0, 180});
|
||||
DrawRectangle(modal_x, modal_y, modal_w, modal_h, flint_theme_get_surface());
|
||||
ui_draw_bevel(modal_x, modal_y, modal_w, modal_h,
|
||||
@@ -80,8 +83,7 @@ whm_draw_progressive_start_speed_editor(InbeApp *app)
|
||||
|
||||
if(ui_draw_icon_btn_padded(modal_x + modal_w - close_w - flint_px(6), modal_y + flint_px(6),
|
||||
close_size, close_padding, app->icons[UI_ICON_TYPE_X], &close_hover)) {
|
||||
app->modal.active = 0;
|
||||
app->modal.type = UIModalNone;
|
||||
app_close_modal(app);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -203,9 +205,7 @@ whm_config_draw_breathing_tab(InbeApp *app, int content_x, int content_w, int y,
|
||||
if(ui_draw_generic_button(content_x, y, modify_w, flint_px(36),
|
||||
locale_get("modify_start_speed_button"),
|
||||
UI_BUTTON_STYLE_SECONDARY, 0, &modify_hover)) {
|
||||
app->modal.active = 1;
|
||||
app->modal.type = UIModalEditProgressiveStartSpeed;
|
||||
app->modal.selected_button = 0;
|
||||
app_open_modal(app, UIModalEditProgressiveStartSpeed);
|
||||
}
|
||||
y += flint_px(58);
|
||||
}
|
||||
@@ -220,6 +220,7 @@ whm_config_draw_session_tab(InbeApp *app, int content_x, int content_w, int y)
|
||||
int max_rounds = app->inbe.max_rounds;
|
||||
int max_breaths = int_from_count(app->inbe.maxbreaths);
|
||||
int pause_seconds = app->inbe.pause_seconds;
|
||||
int double_tap_to_breathe = app->double_tap_to_breathe;
|
||||
int advanced_session_controls = app->advanced_session_controls;
|
||||
int toggle_w = flint_px(56);
|
||||
int toggle_h = flint_px(30);
|
||||
@@ -252,6 +253,13 @@ whm_config_draw_session_tab(InbeApp *app, int content_x, int content_w, int y)
|
||||
y += flint_px(26);
|
||||
draw_hold_display_mode_selector(app, content_x, y, content_w);
|
||||
y += flint_px(52);
|
||||
flint_text_draw(locale_get("double_tap_to_breathe_label"), content_x, y, flint_ui_font(), flint_theme_get_text());
|
||||
if(ui_draw_toggle_switch(content_x, y + flint_px(26), toggle_w, toggle_h, &double_tap_to_breathe,
|
||||
locale_get("toggle_off"), locale_get("toggle_on"))) {
|
||||
app->double_tap_to_breathe = double_tap_to_breathe;
|
||||
app->settings_dirty = 1;
|
||||
}
|
||||
y += flint_px(76);
|
||||
flint_text_draw(locale_get("advanced_session_controls_label"), content_x, y, flint_ui_font(), flint_theme_get_text());
|
||||
if(ui_draw_toggle_switch(content_x, y + flint_px(26), toggle_w, toggle_h, &advanced_session_controls,
|
||||
locale_get("toggle_off"), locale_get("toggle_on"))) {
|
||||
@@ -273,6 +281,7 @@ whm_config_draw_session_tab(InbeApp *app, int content_x, int content_w, int y)
|
||||
app->inbe.breath_animation = InbeBreathAnimationLinear;
|
||||
app->settings_preview.breath_animation = InbeBreathAnimationLinear;
|
||||
app->advanced_session_controls = 0;
|
||||
app->double_tap_to_breathe = 0;
|
||||
app->hold_display_mode = HOLD_DISPLAY_CIRCLE;
|
||||
apply_settings(&app->inbe, speed, max_rounds, max_breaths, pause_seconds);
|
||||
apply_settings(&app->settings_preview, speed, max_rounds, max_breaths, pause_seconds);
|
||||
@@ -308,6 +317,7 @@ whm_config_content_height(InbeApp *app, int content_w)
|
||||
return flint_px(66) * 3 +
|
||||
flint_px(26) + flint_px(52) +
|
||||
flint_px(76) +
|
||||
flint_px(76) +
|
||||
flint_px(36) + flint_px(28) +
|
||||
bottom_padding;
|
||||
}
|
||||
|
||||
@@ -632,9 +632,6 @@ draw_session_round_label(InbeApp *app)
|
||||
int text_y;
|
||||
int font = FLINT_TEXT_16;
|
||||
|
||||
if(app->inbe.phase != InbePhaseBreathe)
|
||||
return;
|
||||
|
||||
locale_format(max_text, sizeof(max_text), "session_round_label", MaxRounds);
|
||||
max_text_w = flint_text_measure(max_text, font);
|
||||
locale_format(text, sizeof(text), "session_round_label", app->inbe.round + 1);
|
||||
@@ -692,9 +689,7 @@ session_update_screen(InbeApp *app, int center_x, int center_y, int *hover)
|
||||
stop_android_background_session(app);
|
||||
app_init(app);
|
||||
} else {
|
||||
app->modal.active = 1;
|
||||
app->modal.type = UIModalConfirmExitSession;
|
||||
app->modal.selected_button = 0;
|
||||
app_open_modal(app, UIModalConfirmExitSession);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -729,18 +724,15 @@ session_update_screen(InbeApp *app, int center_x, int center_y, int *hover)
|
||||
locale_get("save_button"),
|
||||
locale_get("discard_button"));
|
||||
if(modal_result == 1) {
|
||||
app->modal.active = 0;
|
||||
app->modal.type = UIModalNone;
|
||||
app_close_modal(app);
|
||||
} else if(modal_result == 2) {
|
||||
session_ensure_results_saved(app);
|
||||
stop_android_background_session(app);
|
||||
app->modal.active = 0;
|
||||
app->modal.type = UIModalNone;
|
||||
app_close_modal(app);
|
||||
app_init(app);
|
||||
} else if(modal_result == 3) {
|
||||
stop_android_background_session(app);
|
||||
app->modal.active = 0;
|
||||
app->modal.type = UIModalNone;
|
||||
app_close_modal(app);
|
||||
app_init(app);
|
||||
}
|
||||
} else {
|
||||
@@ -749,12 +741,10 @@ session_update_screen(InbeApp *app, int center_x, int center_y, int *hover)
|
||||
locale_get("cancel_button"),
|
||||
locale_get("exit_button"));
|
||||
if(modal_result == 1) {
|
||||
app->modal.active = 0;
|
||||
app->modal.type = UIModalNone;
|
||||
app_close_modal(app);
|
||||
} else if(modal_result == 2) {
|
||||
stop_android_background_session(app);
|
||||
app->modal.active = 0;
|
||||
app->modal.type = UIModalNone;
|
||||
app_close_modal(app);
|
||||
app_init(app);
|
||||
}
|
||||
}
|
||||
@@ -819,15 +809,41 @@ session_update_screen(InbeApp *app, int center_x, int center_y, int *hover)
|
||||
}
|
||||
}
|
||||
|
||||
if(app->inbe.phase != InbePhaseHold)
|
||||
app->breath_tap_last_time = 0.0;
|
||||
|
||||
if(app->inbe.phase == InbePhaseHold) {
|
||||
const char *breath_label = locale_get("breath_button");
|
||||
int breath_font = FLINT_TEXT_16;
|
||||
int breath_w = flint_text_measure(breath_label, breath_font) + flint_px(72);
|
||||
int breath_h = flint_text_line_height(breath_font) + flint_px(28);
|
||||
int breath_y = center_y + app->inbe.rmax + flint_px(10);
|
||||
int breath_y = center_y + app->inbe.rmax - flint_px(2);
|
||||
int breath_x;
|
||||
int breath_hover = 0;
|
||||
|
||||
if(app->double_tap_to_breathe) {
|
||||
const char *hint = locale_get("double_tap_to_breathe_hint");
|
||||
int hint_font = flint_ui_font();
|
||||
int hint_w = flint_text_measure(hint, hint_font);
|
||||
int hint_y = center_y + app->inbe.rmax + flint_px(12);
|
||||
|
||||
if(hint_y > breath_max_y)
|
||||
hint_y = breath_max_y;
|
||||
flint_text_draw(hint, center_x - hint_w / 2, hint_y, hint_font,
|
||||
flint_theme_get_text());
|
||||
if(IsMouseButtonReleased(MOUSE_BUTTON_LEFT)) {
|
||||
double now = GetTime();
|
||||
if(app->breath_tap_last_time > 0.0 &&
|
||||
now - app->breath_tap_last_time <= 0.35) {
|
||||
app->breath_tap_last_time = 0.0;
|
||||
finish_hold(app);
|
||||
} else {
|
||||
app->breath_tap_last_time = now;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if(breath_w < flint_px(184))
|
||||
breath_w = flint_px(184);
|
||||
if(breath_w > view_width - flint_px(24))
|
||||
|
||||
@@ -370,8 +370,7 @@ draw_habit_edit_screen(InbeApp *app)
|
||||
if(app->modal.active && app->modal.type == UIModalHabitPracticeListInfo) {
|
||||
if(habit_edit_info_modal(locale_get("habit_practice_list_title"),
|
||||
locale_get("habit_practice_list_info"))) {
|
||||
app->modal.active = 0;
|
||||
app->modal.type = UIModalNone;
|
||||
app_close_modal(app);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -379,8 +378,7 @@ draw_habit_edit_screen(InbeApp *app)
|
||||
if(app->modal.active && app->modal.type == UIModalHabitCountingInfo) {
|
||||
if(habit_edit_info_modal(locale_get("habit_counting_title"),
|
||||
locale_get("habit_counting_info"))) {
|
||||
app->modal.active = 0;
|
||||
app->modal.type = UIModalNone;
|
||||
app_close_modal(app);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -391,12 +389,10 @@ draw_habit_edit_screen(InbeApp *app)
|
||||
locale_get("cancel_button"),
|
||||
locale_get("delete_button"));
|
||||
if(modal_result == 1) {
|
||||
app->modal.active = 0;
|
||||
app->modal.type = UIModalNone;
|
||||
app_close_modal(app);
|
||||
} else if(modal_result == 2) {
|
||||
int index = app->habit_edit.index;
|
||||
app->modal.active = 0;
|
||||
app->modal.type = UIModalNone;
|
||||
app_close_modal(app);
|
||||
habit_edit_cancel(app);
|
||||
if(index >= 0 && index < app->habits.count) {
|
||||
habits_delete(&app->habits, index);
|
||||
@@ -464,9 +460,7 @@ draw_habit_edit_screen(InbeApp *app)
|
||||
.info_button = 1,
|
||||
.color = flint_darken(flint_theme_get_text(), 34)
|
||||
}, content_x, y)) {
|
||||
app->modal.active = 1;
|
||||
app->modal.type = UIModalHabitPracticeListInfo;
|
||||
app->modal.selected_button = 0;
|
||||
app_open_modal(app, UIModalHabitPracticeListInfo);
|
||||
}
|
||||
y += ui_section_label_height((FlintUISectionLabel){0});
|
||||
for(int i = 0; i < EXERCISE_COUNT; i++) {
|
||||
@@ -492,9 +486,7 @@ draw_habit_edit_screen(InbeApp *app)
|
||||
.info_button = 1,
|
||||
.color = flint_darken(flint_theme_get_text(), 34)
|
||||
}, content_x, y)) {
|
||||
app->modal.active = 1;
|
||||
app->modal.type = UIModalHabitCountingInfo;
|
||||
app->modal.selected_button = 0;
|
||||
app_open_modal(app, UIModalHabitCountingInfo);
|
||||
}
|
||||
y += ui_section_label_height((FlintUISectionLabel){0});
|
||||
if(ui_draw_checkbox_row((FlintUICheckboxRow){
|
||||
@@ -535,9 +527,7 @@ draw_habit_edit_screen(InbeApp *app)
|
||||
.count = action_count
|
||||
});
|
||||
if(!app->habit_edit.is_new && clicked_action == 0) {
|
||||
app->modal.active = 1;
|
||||
app->modal.type = UIModalConfirmDeleteHabit;
|
||||
app->modal.selected_button = 0;
|
||||
app_open_modal(app, UIModalConfirmDeleteHabit);
|
||||
} else if((app->habit_edit.is_new && clicked_action == 0) ||
|
||||
(!app->habit_edit.is_new && clicked_action == 1)) {
|
||||
ui_scroll_page_end(page);
|
||||
|
||||
@@ -793,8 +793,7 @@ habit_open_linked_edit_page(InbeApp *app, int habit_index, int day_index)
|
||||
app->habit_detail_day = day_index;
|
||||
app->habit_detail_session_path[0] = '\0';
|
||||
app->habit_session_edit = (HabitSessionEditState){.round = -1};
|
||||
app->modal.active = 0;
|
||||
app->modal.type = 0;
|
||||
app_close_modal(app);
|
||||
app_switch_screen(app, InbeScreenHabitSessionEdit);
|
||||
}
|
||||
|
||||
@@ -1626,12 +1625,9 @@ draw_habits_screen(InbeApp *app)
|
||||
int scroll_y;
|
||||
int scroll_h;
|
||||
int weekly_days = HABIT_WEEKLY_INITIAL_DAYS;
|
||||
int screen_input_blocked;
|
||||
|
||||
if(app == NULL)
|
||||
return;
|
||||
screen_input_blocked = app->modal.active ||
|
||||
habits_screen_first_run_guide_active(app);
|
||||
|
||||
if(app->habits.tab < HABIT_TAB_WEEKLY || app->habits.tab >= HABIT_TAB_COUNT) {
|
||||
app->habits.tab = app->habits.view_mode == HABIT_VIEW_WEEKLY
|
||||
@@ -1765,12 +1761,10 @@ draw_habits_screen(InbeApp *app)
|
||||
y = page.content_y + flint_px(8);
|
||||
|
||||
if(app->habits.view_mode == HABIT_VIEW_WEEKLY) {
|
||||
ui_set_input_blocked(screen_input_blocked);
|
||||
draw_habits_weekly_view(app, active, selected, linked_ctx,
|
||||
content_x, content_w, y, weekly_days);
|
||||
ui_scroll_page_end(page);
|
||||
free(linked_ctx);
|
||||
ui_set_input_blocked(screen_input_blocked);
|
||||
draw_habits_top_bar(app, 0);
|
||||
if(app->inbe.screen == InbeScreenHabits)
|
||||
draw_habits_top_bar(app, 1);
|
||||
@@ -1778,7 +1772,6 @@ draw_habits_screen(InbeApp *app)
|
||||
}
|
||||
|
||||
forward_disabled = app->habits.month_offset >= 0;
|
||||
ui_set_input_blocked(screen_input_blocked);
|
||||
if(ui_draw_generic_button(content_x, y, flint_px(44), month_h, "<",
|
||||
UI_BUTTON_STYLE_SECONDARY, 0, &hover)) {
|
||||
app->habits.month_offset--;
|
||||
@@ -1893,7 +1886,6 @@ draw_habits_screen(InbeApp *app)
|
||||
ui_scroll_page_end(page);
|
||||
}
|
||||
free(linked_ctx);
|
||||
ui_set_input_blocked(screen_input_blocked);
|
||||
draw_habits_top_bar(app, 0);
|
||||
if(app->inbe.screen == InbeScreenHabits)
|
||||
draw_habits_top_bar(app, 1);
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#endif
|
||||
#include "raylib.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
enum {
|
||||
@@ -150,9 +151,7 @@ settings_begin_import_for_path(InbeApp *app, const char *path)
|
||||
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;
|
||||
app_open_modal(app, UIModalConfirmImportDataSettings);
|
||||
settings_screen_clear_status();
|
||||
return;
|
||||
}
|
||||
@@ -200,6 +199,112 @@ settings_draw_import_choice_modal(InbeApp *app)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
settings_draw_sync_review_modal(InbeApp *app)
|
||||
{
|
||||
FlintUIPanelFrame frame;
|
||||
char *diff_detail = NULL;
|
||||
FlintUIParagraph intro;
|
||||
int intro_h;
|
||||
int modal_w = ui_view_width >= flint_px(620) ? flint_px(560) : flint_px(336);
|
||||
int modal_h = ui_view_height >= flint_px(520) ? flint_px(440) : ui_view_height - flint_px(32);
|
||||
int btn_h = flint_px(36);
|
||||
int gap = flint_px(10);
|
||||
int btn_y;
|
||||
int diff_y;
|
||||
int diff_h;
|
||||
int legend_y;
|
||||
int hover = 0;
|
||||
static int diff_scroll = 0;
|
||||
int diff_content_h = flint_px(40);
|
||||
|
||||
(void)app;
|
||||
if(modal_h < flint_px(320))
|
||||
modal_h = flint_px(320);
|
||||
if(!storage_sync_review_diff(&diff_detail)) {
|
||||
free(diff_detail);
|
||||
return 0;
|
||||
}
|
||||
frame = ui_draw_modal_frame(modal_w, modal_h, "Sync needs review",
|
||||
(Texture2D){0}, (Texture2D){0});
|
||||
intro = (FlintUIParagraph){
|
||||
.text = "Review data differences. Deleted remote rows are ignored.",
|
||||
.width = frame.content_w,
|
||||
.font = flint_ui_font_small(),
|
||||
.line_gap = flint_px(2),
|
||||
.color = flint_theme_get_text()
|
||||
};
|
||||
intro_h = flint_ui_paragraph_height(intro);
|
||||
{
|
||||
int intro_y = frame.content_y;
|
||||
flint_ui_paragraph_draw(intro, frame.content_x, &intro_y);
|
||||
}
|
||||
diff_y = frame.content_y + intro_h + flint_px(12);
|
||||
btn_y = frame.y + frame.h - flint_px(24) - btn_h;
|
||||
legend_y = btn_y - flint_px(24);
|
||||
diff_h = legend_y - diff_y - flint_px(8);
|
||||
if(diff_h < flint_px(150))
|
||||
diff_h = flint_px(150);
|
||||
{
|
||||
const char *p = diff_detail;
|
||||
diff_content_h = flint_px(20);
|
||||
while(p != NULL && *p != '\0') {
|
||||
diff_content_h += flint_px(20);
|
||||
p = strchr(p, '\n');
|
||||
if(p != NULL)
|
||||
p++;
|
||||
}
|
||||
}
|
||||
|
||||
FlintUIScrollView diff_view = ui_scroll_container_begin((FlintUIScrollArea){
|
||||
.bounds = {(float)frame.content_x, (float)diff_y, (float)frame.content_w, (float)diff_h},
|
||||
.content_height = diff_content_h,
|
||||
.content_x = frame.content_x + flint_px(10),
|
||||
.content_width = frame.content_w - flint_px(20),
|
||||
.scroll_offset = &diff_scroll,
|
||||
.wheel_step = flint_px(24)
|
||||
});
|
||||
{
|
||||
char *line = strtok(diff_detail, "\n");
|
||||
int line_y = diff_view.content_y;
|
||||
while(line != NULL) {
|
||||
Color color = flint_theme_get_text();
|
||||
if(line[0] == '-')
|
||||
color = (Color){215, 88, 88, 255};
|
||||
else if(line[0] == '+')
|
||||
color = (Color){74, 170, 112, 255};
|
||||
flint_text_draw(line, diff_view.content_x, line_y,
|
||||
flint_ui_font_small(), color);
|
||||
line_y += flint_px(20);
|
||||
line = strtok(NULL, "\n");
|
||||
}
|
||||
}
|
||||
ui_scroll_container_end((FlintUIScrollArea){
|
||||
.bounds = {(float)frame.content_x, (float)diff_y, (float)frame.content_w, (float)diff_h},
|
||||
.scroll_offset = &diff_scroll
|
||||
}, diff_view);
|
||||
|
||||
flint_text_draw("- Local only", frame.content_x, legend_y,
|
||||
flint_ui_font_small(), (Color){215, 88, 88, 255});
|
||||
flint_text_draw("+ Remote only", frame.content_x + flint_px(112), legend_y,
|
||||
flint_ui_font_small(), (Color){74, 170, 112, 255});
|
||||
|
||||
if(ui_draw_generic_button(frame.content_x, btn_y,
|
||||
(frame.content_w - gap) / 2, btn_h,
|
||||
"Keep local", UI_BUTTON_STYLE_SECONDARY, 0, &hover)) {
|
||||
free(diff_detail);
|
||||
return 1;
|
||||
}
|
||||
if(ui_draw_generic_button(frame.content_x + (frame.content_w + gap) / 2, btn_y,
|
||||
(frame.content_w - gap) / 2, btn_h,
|
||||
"Use remote", UI_BUTTON_STYLE_PRIMARY, 0, &hover)) {
|
||||
free(diff_detail);
|
||||
return 2;
|
||||
}
|
||||
free(diff_detail);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
settings_link_icon_columns(int content_w)
|
||||
{
|
||||
@@ -722,9 +827,7 @@ static void
|
||||
settings_request_delete_all_data(InbeApp *app)
|
||||
{
|
||||
if(data_has_any()) {
|
||||
app->modal.active = 1;
|
||||
app->modal.type = UIModalConfirmDeleteData;
|
||||
app->modal.selected_button = 0;
|
||||
app_open_modal(app, UIModalConfirmDeleteData);
|
||||
} else {
|
||||
settings_screen_set_status_error(locale_get("no_data_to_delete"));
|
||||
}
|
||||
@@ -816,8 +919,7 @@ settings_data_draw_modals(InbeApp *app)
|
||||
if(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;
|
||||
app_close_modal(app);
|
||||
settings_clear_pending_import();
|
||||
settings_screen_set_status_error(locale_get("import_cancelled"));
|
||||
} else if(modal_result == 2 || modal_result == 3) {
|
||||
@@ -826,8 +928,7 @@ settings_data_draw_modals(InbeApp *app)
|
||||
? 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;
|
||||
app_close_modal(app);
|
||||
settings_clear_pending_import();
|
||||
settings_perform_import(app, import_path, mode);
|
||||
}
|
||||
@@ -840,13 +941,11 @@ settings_data_draw_modals(InbeApp *app)
|
||||
locale_get("cancel_button"),
|
||||
locale_get("clear_button"));
|
||||
if(modal_result == 1) {
|
||||
app->modal.active = 0;
|
||||
app->modal.type = UIModalNone;
|
||||
app_close_modal(app);
|
||||
settings_screen_set_status_error(locale_get("delete_cancelled"));
|
||||
} else if(modal_result == 2) {
|
||||
long long deleted = data_delete_all();
|
||||
app->modal.active = 0;
|
||||
app->modal.type = UIModalNone;
|
||||
app_close_modal(app);
|
||||
if(deleted > 0) {
|
||||
char deleted_message[128];
|
||||
habits_free(&app->habits);
|
||||
@@ -877,12 +976,10 @@ settings_data_draw_modals(InbeApp *app)
|
||||
locale_get("cancel_button"),
|
||||
locale_get("clear_button"));
|
||||
if(modal_result == 1) {
|
||||
app->modal.active = 0;
|
||||
app->modal.type = UIModalNone;
|
||||
app_close_modal(app);
|
||||
settings_screen_set_status_error(locale_get("sync_clear_remote_data_cancelled"));
|
||||
} else if(modal_result == 2) {
|
||||
app->modal.active = 0;
|
||||
app->modal.type = UIModalNone;
|
||||
app_close_modal(app);
|
||||
settings_sync_account_clear_remote_confirmed(app);
|
||||
}
|
||||
return 1;
|
||||
@@ -891,8 +988,7 @@ settings_data_draw_modals(InbeApp *app)
|
||||
if(app->modal.type == UIModalSyncAccountBackup) {
|
||||
int modal_result = settings_sync_account_draw_backup_modal(app);
|
||||
if(modal_result == 1 || modal_result == 2 || modal_result == 3 || modal_result == 4) {
|
||||
app->modal.active = 0;
|
||||
app->modal.type = UIModalNone;
|
||||
app_close_modal(app);
|
||||
if(modal_result == 2)
|
||||
settings_screen_set_status_success(locale_get("sync_private_key_backup_saved"), NULL);
|
||||
else if(modal_result == 3)
|
||||
@@ -901,5 +997,23 @@ settings_data_draw_modals(InbeApp *app)
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(app->modal.type == UIModalSyncReview) {
|
||||
int modal_result = settings_draw_sync_review_modal(app);
|
||||
if(modal_result == 1 || modal_result == 2) {
|
||||
int use_remote = modal_result == 2;
|
||||
if(storage_apply_pending_sync_review(use_remote)) {
|
||||
app_close_modal(app);
|
||||
if(use_remote)
|
||||
app_reload_after_import(app, 0);
|
||||
else
|
||||
app_auto_sync(app);
|
||||
settings_screen_set_status_success(use_remote ? "Using remote data" : "Keeping local data", NULL);
|
||||
} else {
|
||||
settings_screen_set_status_error("Sync review failed");
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -205,8 +205,6 @@ settings_screen_draw(InbeApp *app)
|
||||
settings_data_handle_web_import(app);
|
||||
#endif
|
||||
|
||||
ui_set_input_blocked(app->modal.active);
|
||||
|
||||
if(content_viewport_h < 0)
|
||||
content_viewport_h = 0;
|
||||
|
||||
@@ -218,8 +216,7 @@ settings_screen_draw(InbeApp *app)
|
||||
app->settings_scroll = 0;
|
||||
app->settings_data_view = 0;
|
||||
if(app->modal.type == UIModalThemePicker) {
|
||||
app->modal.active = 0;
|
||||
app->modal.type = UIModalNone;
|
||||
app_close_modal(app);
|
||||
}
|
||||
settings_screen_clear_status();
|
||||
}
|
||||
@@ -254,9 +251,6 @@ settings_screen_draw(InbeApp *app)
|
||||
settings_device_handle_overlays(app, &device_state);
|
||||
ui_set_dropdown_clip_top(0);
|
||||
|
||||
ui_set_input_blocked(0);
|
||||
settings_data_draw_modals(app);
|
||||
|
||||
if(IsMouseButtonReleased(MOUSE_BUTTON_LEFT) && app->settings_dirty)
|
||||
save_settings(app);
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
|
||||
#define INBE_SYNC_SERVER_URL_KEY "sync_server_url"
|
||||
#define INBE_SYNC_SERVER_URL_DEFAULT "https://api.waozi.xyz"
|
||||
#define INBE_SYNC_ACCOUNT_ALIAS_KEY "sync_account_alias"
|
||||
|
||||
static SettingsSyncKeySaveDialog save_dialog_callback = NULL;
|
||||
static SettingsSyncKeyImportDialog import_dialog_callback = NULL;
|
||||
@@ -31,85 +32,43 @@ settings_sync_account_set_import_dialog(SettingsSyncKeyImportDialog callback)
|
||||
import_dialog_callback = callback;
|
||||
}
|
||||
|
||||
static void
|
||||
static int
|
||||
settings_draw_public_id_field(const char *text, int x, int w, int *y, int font,
|
||||
FlintUITextInputStyle style)
|
||||
{
|
||||
char line[128];
|
||||
int text_len;
|
||||
int pad_x;
|
||||
int pad_y = flint_px(8);
|
||||
int line_h = flint_text_line_height(font);
|
||||
int content_w;
|
||||
int line_count = 0;
|
||||
int offset = 0;
|
||||
int field_h;
|
||||
int draw_y;
|
||||
int clicked = 0;
|
||||
|
||||
if(text == NULL || y == NULL)
|
||||
return;
|
||||
|
||||
text_len = (int)strlen(text);
|
||||
pad_x = style.padding_x > 0 ? style.padding_x : flint_px(10);
|
||||
content_w = w - pad_x * 2;
|
||||
if(content_w < flint_px(24))
|
||||
content_w = flint_px(24);
|
||||
|
||||
while(offset < text_len) {
|
||||
int len;
|
||||
|
||||
if(flint_text_measure(text + offset, font) <= content_w) {
|
||||
offset = text_len;
|
||||
line_count++;
|
||||
break;
|
||||
}
|
||||
|
||||
len = 1;
|
||||
while(offset + len < text_len && len + 1 < (int)sizeof(line)) {
|
||||
snprintf(line, sizeof(line), "%.*s", len + 1, text + offset);
|
||||
if(flint_text_measure(line, font) > content_w)
|
||||
break;
|
||||
len++;
|
||||
}
|
||||
offset += len;
|
||||
line_count++;
|
||||
}
|
||||
if(line_count < 1)
|
||||
line_count = 1;
|
||||
|
||||
field_h = line_count * line_h + pad_y * 2;
|
||||
DrawRectangleRounded((Rectangle){(float)x, (float)*y, (float)w, (float)field_h},
|
||||
style.radius > 0.0f ? style.radius : 0.08f, 8,
|
||||
style.background);
|
||||
DrawRectangleRoundedLines((Rectangle){(float)x, (float)*y, (float)w, (float)field_h},
|
||||
style.radius > 0.0f ? style.radius : 0.08f, 8,
|
||||
style.border);
|
||||
|
||||
offset = 0;
|
||||
draw_y = *y + pad_y;
|
||||
while(offset < text_len) {
|
||||
int len;
|
||||
|
||||
if(flint_text_measure(text + offset, font) <= content_w) {
|
||||
snprintf(line, sizeof(line), "%s", text + offset);
|
||||
flint_text_draw(line, x + pad_x, draw_y, font, style.text);
|
||||
break;
|
||||
}
|
||||
|
||||
len = 1;
|
||||
while(offset + len < text_len && len + 1 < (int)sizeof(line)) {
|
||||
snprintf(line, sizeof(line), "%.*s", len + 1, text + offset);
|
||||
if(flint_text_measure(line, font) > content_w)
|
||||
break;
|
||||
len++;
|
||||
}
|
||||
snprintf(line, sizeof(line), "%.*s", len, text + offset);
|
||||
flint_text_draw(line, x + pad_x, draw_y, font, style.text);
|
||||
draw_y += line_h;
|
||||
offset += len;
|
||||
}
|
||||
return 0;
|
||||
|
||||
field_h = flint_ui_readonly_text_box_height(text, font, w, style, 0);
|
||||
clicked = flint_ui_readonly_text_box((FlintUIReadonlyTextBox){
|
||||
.bounds = {(float)x, (float)*y, (float)w, (float)field_h},
|
||||
.text = text,
|
||||
.font = font,
|
||||
.style = style
|
||||
});
|
||||
*y += field_h;
|
||||
return clicked;
|
||||
}
|
||||
|
||||
static void
|
||||
settings_compact_public_id(const char *public_id, char *out, size_t out_size)
|
||||
{
|
||||
size_t len;
|
||||
|
||||
if(out == NULL || out_size == 0)
|
||||
return;
|
||||
out[0] = '\0';
|
||||
if(public_id == NULL)
|
||||
return;
|
||||
len = strlen(public_id);
|
||||
if(len <= 12) {
|
||||
snprintf(out, out_size, "%s", public_id);
|
||||
return;
|
||||
}
|
||||
snprintf(out, out_size, "%.*s...%.*s", 4, public_id, 4, public_id + len - 4);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -151,6 +110,56 @@ settings_sync_url_filter(int codepoint, void *user_data)
|
||||
return codepoint >= 33 && codepoint <= 126 && !isspace(codepoint);
|
||||
}
|
||||
|
||||
static int
|
||||
settings_sync_alias_filter(int codepoint, void *user_data)
|
||||
{
|
||||
(void)user_data;
|
||||
return (codepoint >= 'a' && codepoint <= 'z') ||
|
||||
(codepoint >= 'A' && codepoint <= 'Z') ||
|
||||
(codepoint >= '0' && codepoint <= '9') ||
|
||||
codepoint == '_';
|
||||
}
|
||||
|
||||
static void
|
||||
settings_sync_alias_normalize(char *text)
|
||||
{
|
||||
char out[40];
|
||||
int n = 0;
|
||||
|
||||
if(text == NULL)
|
||||
return;
|
||||
for(int i = 0; text[i] != '\0' && n < (int)sizeof(out) - 1; i++) {
|
||||
unsigned char ch = (unsigned char)text[i];
|
||||
if(ch == '@' && n == 0)
|
||||
continue;
|
||||
if(ch >= 'A' && ch <= 'Z')
|
||||
ch = (unsigned char)(ch - 'A' + 'a');
|
||||
if((ch >= 'a' && ch <= 'z') || (ch >= '0' && ch <= '9') || ch == '_')
|
||||
out[n++] = (char)ch;
|
||||
}
|
||||
out[n] = '\0';
|
||||
snprintf(text, 40, "%s", out);
|
||||
}
|
||||
|
||||
static int
|
||||
settings_sync_alias_valid(const char *text)
|
||||
{
|
||||
size_t len;
|
||||
|
||||
if(text == NULL)
|
||||
return 0;
|
||||
len = strlen(text);
|
||||
if(len < 4 || len > 32)
|
||||
return 0;
|
||||
for(size_t i = 0; i < len; i++) {
|
||||
char ch = text[i];
|
||||
if((ch >= 'a' && ch <= 'z') || (ch >= '0' && ch <= '9') || ch == '_')
|
||||
continue;
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
settings_sync_server_normalize(InbeApp *app, char *out, size_t out_size)
|
||||
{
|
||||
@@ -178,6 +187,41 @@ settings_sync_server_save(InbeApp *app)
|
||||
settings_screen_set_status_success(locale_get("sync_server_saved"), url);
|
||||
}
|
||||
|
||||
static void
|
||||
settings_sync_open_alias_modal(InbeApp *app, int then_backup)
|
||||
{
|
||||
const char *alias;
|
||||
|
||||
if(app == NULL)
|
||||
return;
|
||||
alias = storage_get_setting_text(INBE_SYNC_ACCOUNT_ALIAS_KEY);
|
||||
snprintf(app->sync_alias_input, sizeof(app->sync_alias_input), "%s",
|
||||
alias != NULL ? alias : "");
|
||||
settings_sync_alias_normalize(app->sync_alias_input);
|
||||
app->sync_alias_cursor = (int)strlen(app->sync_alias_input);
|
||||
app->sync_alias_focused = 1;
|
||||
app->sync_alias_then_backup = then_backup;
|
||||
app_open_modal(app, UIModalSyncAlias);
|
||||
}
|
||||
|
||||
static void
|
||||
settings_sync_draw_account_id(InbeApp *app, const InbeSyncAccount *account,
|
||||
int x, int w, int *y, int small_font,
|
||||
FlintUITextInputStyle style)
|
||||
{
|
||||
const char *alias = storage_get_setting_text(INBE_SYNC_ACCOUNT_ALIAS_KEY);
|
||||
char display[96];
|
||||
|
||||
if(account == NULL)
|
||||
return;
|
||||
if(alias != NULL && alias[0] != '\0')
|
||||
snprintf(display, sizeof(display), "@%s", alias);
|
||||
else
|
||||
settings_compact_public_id(account->public_id, display, sizeof(display));
|
||||
if(settings_draw_public_id_field(display, x, w, y, small_font, style) && app != NULL)
|
||||
app_open_modal(app, UIModalSyncPublicId);
|
||||
}
|
||||
|
||||
static int
|
||||
settings_sync_server_connected(InbeApp *app)
|
||||
{
|
||||
@@ -232,8 +276,16 @@ settings_sync_run_connect(InbeApp *app)
|
||||
storage_set_setting_text(INBE_SYNC_SERVER_URL_KEY, url);
|
||||
result = sync_client_sync(url);
|
||||
if(result == INBE_SYNC_CLIENT_OK) {
|
||||
app_reload_after_import(app, 0);
|
||||
settings_screen_set_status_success(locale_get(settings_sync_result_key(result)), NULL);
|
||||
if(storage_sync_review_clear_if_no_visible_diff()) {
|
||||
app_reload_after_import(app, 0);
|
||||
settings_screen_set_status_success(locale_get(settings_sync_result_key(result)), NULL);
|
||||
} else if(storage_sync_review_pending()) {
|
||||
app_open_modal(app, UIModalSyncReview);
|
||||
settings_screen_set_status_error("Sync needs review");
|
||||
} else {
|
||||
app_reload_after_import(app, 0);
|
||||
settings_screen_set_status_success(locale_get(settings_sync_result_key(result)), NULL);
|
||||
}
|
||||
} else {
|
||||
settings_screen_set_status_error(locale_get(settings_sync_result_key(result)));
|
||||
}
|
||||
@@ -314,9 +366,7 @@ settings_sync_account_draw(InbeApp *app, int x, int w, int *y)
|
||||
UI_BUTTON_STYLE_PRIMARY, 0, &hover)) {
|
||||
if(sync_account_create(&account)) {
|
||||
settings_screen_set_status_success(locale_get("sync_account_created"), NULL);
|
||||
app->modal.active = 1;
|
||||
app->modal.type = UIModalSyncAccountBackup;
|
||||
app->modal.selected_button = 0;
|
||||
settings_sync_open_alias_modal(app, 1);
|
||||
} else {
|
||||
settings_screen_set_status_error(locale_get("sync_account_create_failed"));
|
||||
}
|
||||
@@ -328,13 +378,14 @@ settings_sync_account_draw(InbeApp *app, int x, int w, int *y)
|
||||
flint_text_draw(locale_get("sync_public_id_label"), x, *y, small_font,
|
||||
flint_darken(flint_theme_get_text(), 30));
|
||||
*y += flint_px(18);
|
||||
settings_draw_public_id_field(account.public_id, x, w, y, small_font,
|
||||
settings_sync_draw_account_id(app, &account, x, w, y, small_font,
|
||||
settings_sync_text_style());
|
||||
*y += flint_px(4);
|
||||
|
||||
{
|
||||
FlintUIButtonRowItem buttons[2] = {
|
||||
FlintUIButtonRowItem buttons[3] = {
|
||||
{locale_get("sync_copy_id_button"), UI_BUTTON_STYLE_SECONDARY, 0},
|
||||
{locale_get("sync_alias_button"), UI_BUTTON_STYLE_SECONDARY, 0},
|
||||
{locale_get("sync_backup_key_button"), UI_BUTTON_STYLE_PRIMARY, 0}
|
||||
};
|
||||
int clicked = ui_draw_button_row((FlintUIButtonRow){
|
||||
@@ -344,16 +395,16 @@ settings_sync_account_draw(InbeApp *app, int x, int w, int *y)
|
||||
.height = btn_h,
|
||||
.gap = gap,
|
||||
.items = buttons,
|
||||
.count = 2
|
||||
.count = 3
|
||||
});
|
||||
|
||||
if(clicked == 0) {
|
||||
SetClipboardText(account.public_id);
|
||||
settings_screen_set_status_success(locale_get("sync_public_id_copied"), NULL);
|
||||
} else if(clicked == 1) {
|
||||
app->modal.active = 1;
|
||||
app->modal.type = UIModalSyncAccountBackup;
|
||||
app->modal.selected_button = 0;
|
||||
settings_sync_open_alias_modal(app, 0);
|
||||
} else if(clicked == 2) {
|
||||
app_open_modal(app, UIModalSyncAccountBackup);
|
||||
}
|
||||
}
|
||||
*y += btn_h + flint_px(16);
|
||||
@@ -400,9 +451,7 @@ settings_sync_account_draw_config(InbeApp *app, int x, int w, int *y)
|
||||
if(sync_account_create(&account)) {
|
||||
has_account = 1;
|
||||
settings_screen_set_status_success(locale_get("sync_account_created"), NULL);
|
||||
app->modal.active = 1;
|
||||
app->modal.type = UIModalSyncAccountBackup;
|
||||
app->modal.selected_button = 0;
|
||||
settings_sync_open_alias_modal(app, 1);
|
||||
} else {
|
||||
settings_screen_set_status_error(locale_get("sync_account_create_failed"));
|
||||
}
|
||||
@@ -422,7 +471,7 @@ settings_sync_account_draw_config(InbeApp *app, int x, int w, int *y)
|
||||
flint_text_draw(locale_get("sync_public_id_label"), x, *y, small_font,
|
||||
flint_darken(flint_theme_get_text(), 30));
|
||||
*y += flint_px(18);
|
||||
settings_draw_public_id_field(account.public_id, x, w, y, small_font, input_style);
|
||||
settings_sync_draw_account_id(app, &account, x, w, y, small_font, input_style);
|
||||
*y += flint_px(8);
|
||||
|
||||
flint_text_draw(locale_get("sync_remote_label"), x, *y, small_font,
|
||||
@@ -453,8 +502,9 @@ settings_sync_account_draw_config(InbeApp *app, int x, int w, int *y)
|
||||
*y += btn_h + flint_px(12);
|
||||
|
||||
{
|
||||
FlintUIButtonRowItem buttons[2] = {
|
||||
FlintUIButtonRowItem buttons[3] = {
|
||||
{locale_get("sync_copy_id_button"), UI_BUTTON_STYLE_SECONDARY, 0},
|
||||
{locale_get("sync_alias_button"), UI_BUTTON_STYLE_SECONDARY, 0},
|
||||
{locale_get("sync_backup_key_button"), UI_BUTTON_STYLE_SECONDARY, 0}
|
||||
};
|
||||
int clicked = ui_draw_button_row((FlintUIButtonRow){
|
||||
@@ -464,16 +514,16 @@ settings_sync_account_draw_config(InbeApp *app, int x, int w, int *y)
|
||||
.height = btn_h,
|
||||
.gap = gap,
|
||||
.items = buttons,
|
||||
.count = 2
|
||||
.count = 3
|
||||
});
|
||||
|
||||
if(clicked == 0) {
|
||||
SetClipboardText(account.public_id);
|
||||
settings_screen_set_status_success(locale_get("sync_public_id_copied"), NULL);
|
||||
} else if(clicked == 1) {
|
||||
app->modal.active = 1;
|
||||
app->modal.type = UIModalSyncAccountBackup;
|
||||
app->modal.selected_button = 0;
|
||||
settings_sync_open_alias_modal(app, 0);
|
||||
} else if(clicked == 2) {
|
||||
app_open_modal(app, UIModalSyncAccountBackup);
|
||||
}
|
||||
}
|
||||
*y += btn_h + flint_px(12);
|
||||
@@ -495,9 +545,7 @@ settings_sync_account_draw_config(InbeApp *app, int x, int w, int *y)
|
||||
if(clicked == 0) {
|
||||
settings_sync_account_logout(app);
|
||||
} else if(clicked == 1) {
|
||||
app->modal.active = 1;
|
||||
app->modal.type = UIModalConfirmDeleteSyncAccount;
|
||||
app->modal.selected_button = 0;
|
||||
app_open_modal(app, UIModalConfirmDeleteSyncAccount);
|
||||
}
|
||||
}
|
||||
*y += btn_h + flint_px(12);
|
||||
@@ -553,3 +601,165 @@ settings_sync_account_draw_backup_modal(InbeApp *app)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
settings_sync_account_draw_alias_modal(InbeApp *app)
|
||||
{
|
||||
FlintUIPanelFrame frame;
|
||||
FlintUITextInputStyle input_style = settings_sync_text_style();
|
||||
int btn_h = flint_px(36);
|
||||
int gap = flint_px(10);
|
||||
int y;
|
||||
int at_w;
|
||||
int commit = 0;
|
||||
int result = 0;
|
||||
char url[256];
|
||||
char current_alias[40];
|
||||
const char *stored_alias;
|
||||
int has_alias;
|
||||
int unchanged_alias;
|
||||
|
||||
if(app == NULL)
|
||||
return 3;
|
||||
stored_alias = storage_get_setting_text(INBE_SYNC_ACCOUNT_ALIAS_KEY);
|
||||
snprintf(current_alias, sizeof(current_alias), "%s", stored_alias != NULL ? stored_alias : "");
|
||||
settings_sync_alias_normalize(current_alias);
|
||||
has_alias = current_alias[0] != '\0';
|
||||
|
||||
frame = ui_draw_modal_frame(flint_px(336), flint_px(238),
|
||||
locale_get(has_alias ? "sync_alias_change_title" : "sync_alias_title"),
|
||||
(Texture2D){0}, (Texture2D){0});
|
||||
y = frame.content_y;
|
||||
|
||||
flint_text_draw(locale_get(has_alias ? "sync_alias_change_message" : "sync_alias_message"),
|
||||
frame.content_x, y,
|
||||
flint_ui_font_small(), flint_darken(flint_theme_get_text(), 20));
|
||||
y += flint_px(40);
|
||||
|
||||
at_w = flint_text_measure("@", flint_ui_font()) + flint_px(12);
|
||||
flint_text_draw("@", frame.content_x, flint_ui_text_y("@", y, btn_h, flint_ui_font()),
|
||||
flint_ui_font(), flint_theme_get_text());
|
||||
flint_ui_text_field((FlintUITextField){
|
||||
.bounds = {(float)(frame.content_x + at_w), (float)y,
|
||||
(float)(frame.content_w - at_w), (float)btn_h},
|
||||
.text = app->sync_alias_input,
|
||||
.text_size = sizeof(app->sync_alias_input),
|
||||
.cursor_position = &app->sync_alias_cursor,
|
||||
.focused = &app->sync_alias_focused,
|
||||
.max_codepoints = 32,
|
||||
.font = flint_ui_font_small(),
|
||||
.style = input_style,
|
||||
.filter = settings_sync_alias_filter,
|
||||
.commit_pressed = &commit
|
||||
});
|
||||
settings_sync_alias_normalize(app->sync_alias_input);
|
||||
y += btn_h + flint_px(12);
|
||||
|
||||
flint_text_draw(locale_get("sync_alias_rule"), frame.content_x, y,
|
||||
flint_ui_font_small(), flint_darken(flint_theme_get_text(), 35));
|
||||
y += flint_px(34);
|
||||
unchanged_alias = has_alias && strcmp(app->sync_alias_input, current_alias) == 0;
|
||||
|
||||
{
|
||||
FlintUIButtonRowItem buttons[2] = {
|
||||
{locale_get(app->sync_alias_then_backup ? "skip_button" : "close_button"),
|
||||
UI_BUTTON_STYLE_SECONDARY, 0},
|
||||
{locale_get(has_alias ? "sync_alias_save_button" : "sync_alias_register_button"),
|
||||
UI_BUTTON_STYLE_PRIMARY,
|
||||
!settings_sync_alias_valid(app->sync_alias_input) || unchanged_alias}
|
||||
};
|
||||
int clicked = ui_draw_button_row((FlintUIButtonRow){
|
||||
.x = frame.content_x,
|
||||
.y = y,
|
||||
.width = frame.content_w,
|
||||
.height = btn_h,
|
||||
.gap = gap,
|
||||
.items = buttons,
|
||||
.count = 2
|
||||
});
|
||||
if(clicked == 0)
|
||||
return 3;
|
||||
if(clicked == 1 || (commit && settings_sync_alias_valid(app->sync_alias_input) && !unchanged_alias)) {
|
||||
if(settings_sync_server_normalize(app, url, sizeof(url))) {
|
||||
InbeSyncClientResult alias_result;
|
||||
TraceLog(LOG_INFO, "SYNC: saving alias @%s with %s",
|
||||
app->sync_alias_input, url);
|
||||
alias_result = sync_client_register_alias(url, app->sync_alias_input);
|
||||
if(alias_result == INBE_SYNC_CLIENT_OK) {
|
||||
TraceLog(LOG_INFO, "SYNC: alias saved @%s", app->sync_alias_input);
|
||||
result = 1;
|
||||
} else {
|
||||
TraceLog(LOG_WARNING, "SYNC: alias register failed result=%d alias=@%s",
|
||||
(int)alias_result, app->sync_alias_input);
|
||||
result = 2;
|
||||
}
|
||||
} else {
|
||||
TraceLog(LOG_WARNING, "SYNC: alias register failed invalid server url");
|
||||
result = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
int
|
||||
settings_sync_account_draw_public_id_modal(InbeApp *app)
|
||||
{
|
||||
FlintUIPanelFrame frame;
|
||||
InbeSyncAccount account;
|
||||
FlintUITextInputStyle input_style = settings_sync_text_style();
|
||||
int btn_h = flint_px(36);
|
||||
int gap = flint_px(10);
|
||||
int y;
|
||||
int hover = 0;
|
||||
int result = 0;
|
||||
|
||||
(void)app;
|
||||
memset(&account, 0, sizeof(account));
|
||||
if(!sync_account_load(&account))
|
||||
return 1;
|
||||
|
||||
frame = ui_draw_modal_frame(flint_px(356), flint_px(274),
|
||||
locale_get("sync_public_id_full_title"),
|
||||
(Texture2D){0}, (Texture2D){0});
|
||||
y = frame.content_y;
|
||||
|
||||
flint_text_draw(locale_get("sync_public_id_full_message"), frame.content_x, y,
|
||||
flint_ui_font_small(), flint_darken(flint_theme_get_text(), 25));
|
||||
y += flint_px(34);
|
||||
|
||||
settings_draw_public_id_field(account.public_id, frame.content_x, frame.content_w,
|
||||
&y, flint_ui_font_small(), input_style);
|
||||
y += flint_px(18);
|
||||
|
||||
{
|
||||
FlintUIButtonRowItem buttons[2] = {
|
||||
{locale_get("sync_copy_id_button"), UI_BUTTON_STYLE_PRIMARY, 0},
|
||||
{locale_get("close_button"), UI_BUTTON_STYLE_SECONDARY, 0}
|
||||
};
|
||||
int clicked = ui_draw_button_row((FlintUIButtonRow){
|
||||
.x = frame.content_x,
|
||||
.y = y,
|
||||
.width = frame.content_w,
|
||||
.height = btn_h,
|
||||
.gap = gap,
|
||||
.items = buttons,
|
||||
.count = 2
|
||||
});
|
||||
if(clicked == 0) {
|
||||
SetClipboardText(account.public_id);
|
||||
settings_screen_set_status_success(locale_get("sync_public_id_copied"), NULL);
|
||||
} else if(clicked == 1) {
|
||||
result = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if(ui_draw_generic_button(frame.content_x, frame.y + frame.h - btn_h - flint_px(18),
|
||||
frame.content_w, btn_h,
|
||||
locale_get("sync_alias_button"), UI_BUTTON_STYLE_SECONDARY,
|
||||
0, &hover)) {
|
||||
app_close_modal(app);
|
||||
settings_sync_open_alias_modal(app, 0);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -12,5 +12,7 @@ void settings_sync_account_draw(InbeApp *app, int x, int w, int *y);
|
||||
void settings_sync_account_draw_config(InbeApp *app, int x, int w, int *y);
|
||||
void settings_sync_account_clear_remote_confirmed(InbeApp *app);
|
||||
int settings_sync_account_draw_backup_modal(InbeApp *app);
|
||||
int settings_sync_account_draw_alias_modal(InbeApp *app);
|
||||
int settings_sync_account_draw_public_id_modal(InbeApp *app);
|
||||
|
||||
#endif
|
||||
@@ -94,9 +94,7 @@ settings_theme_draw(InbeApp *app, int x, int w, int *y, SettingsThemeState *stat
|
||||
app->inbe.frame - app->modal_open_frame > 1) {
|
||||
ui_mark_clickable();
|
||||
if(IsMouseButtonReleased(MOUSE_BUTTON_LEFT)) {
|
||||
app->modal.active = 1;
|
||||
app->modal.type = UIModalThemePicker;
|
||||
app->modal_open_frame = app->inbe.frame;
|
||||
app_open_modal(app, UIModalThemePicker);
|
||||
}
|
||||
}
|
||||
*y += circle_size + flint_px(20);
|
||||
@@ -151,8 +149,7 @@ settings_screen_draw_theme_picker_modal(InbeApp *app)
|
||||
app->icons[UI_ICON_TYPE_X]);
|
||||
|
||||
if(frame.right_clicked) {
|
||||
app->modal.active = 0;
|
||||
app->modal.type = UIModalNone;
|
||||
app_close_modal(app);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -163,7 +160,6 @@ settings_screen_draw_theme_picker_modal(InbeApp *app)
|
||||
app_refresh_theme(app);
|
||||
app->settings_dirty = 1;
|
||||
save_settings(app);
|
||||
app->modal.active = 0;
|
||||
app->modal.type = UIModalNone;
|
||||
app_close_modal(app);
|
||||
}
|
||||
}
|
||||
@@ -450,11 +450,9 @@ draw_statistics_content(InbeApp *app, int content_top)
|
||||
.content_height = statistics_scroll_page_content_height,
|
||||
.user_data = &page_ctx
|
||||
});
|
||||
ui_set_input_blocked(app->modal.active);
|
||||
statistics_draw_view(app, active, linked_ctx, page.content_x,
|
||||
page.content_w, page.content_y + flint_px(8));
|
||||
ui_scroll_page_end(page);
|
||||
ui_set_input_blocked(0);
|
||||
}
|
||||
free(linked_ctx);
|
||||
}
|
||||
@@ -295,6 +295,25 @@ meta_equals(const char *key, const char *value)
|
||||
return ok;
|
||||
}
|
||||
|
||||
const char *
|
||||
get_meta_text(const char *key)
|
||||
{
|
||||
sqlite3_stmt *stmt = NULL;
|
||||
g_storage.text_value[0] = '\0';
|
||||
|
||||
if(g_storage.db == NULL || key == NULL)
|
||||
return NULL;
|
||||
if(sqlite3_prepare_v2(g_storage.db, "SELECT value FROM meta WHERE key=?1", -1, &stmt, NULL) != SQLITE_OK)
|
||||
return NULL;
|
||||
bind_text(stmt, 1, key);
|
||||
if(sqlite3_step(stmt) == SQLITE_ROW) {
|
||||
const char *text = (const char *)sqlite3_column_text(stmt, 0);
|
||||
snprintf(g_storage.text_value, sizeof(g_storage.text_value), "%s", text != NULL ? text : "");
|
||||
}
|
||||
sqlite3_finalize(stmt);
|
||||
return g_storage.text_value[0] != '\0' ? g_storage.text_value : NULL;
|
||||
}
|
||||
|
||||
void
|
||||
set_meta(const char *key, const char *value)
|
||||
{
|
||||
|
||||
@@ -31,6 +31,7 @@ int schema_create(void);
|
||||
int migrate_schema(void);
|
||||
int load_or_create_user(void);
|
||||
int meta_equals(const char *key, const char *value);
|
||||
const char *get_meta_text(const char *key);
|
||||
void set_meta(const char *key, const char *value);
|
||||
long long get_meta_int64(const char *key, long long fallback);
|
||||
void set_meta_int64(const char *key, long long value);
|
||||
@@ -38,6 +39,8 @@ void set_meta_int64(const char *key, long long value);
|
||||
void storage_schedule_persist(void);
|
||||
void storage_enqueue_all_sync_state(void);
|
||||
int storage_materialize_session_habit_days(void);
|
||||
int storage_sync_review_write_json(const char *json);
|
||||
void storage_sync_review_delete_json(void);
|
||||
int insert_session_at_ex(long long started_at, int local_date, const int *round_times,
|
||||
int round_count, int topic, int activity, const char *source,
|
||||
char *out_id, size_t out_id_size);
|
||||
|
||||
@@ -90,6 +90,7 @@ static const char *const importable_setting_keys[] = {
|
||||
"progressive_speed",
|
||||
"progressive_start_speed",
|
||||
"breath_animation",
|
||||
"double_tap_to_breathe",
|
||||
"advanced_session_controls",
|
||||
"hold_display_mode",
|
||||
"exercise_type",
|
||||
|
||||
@@ -31,6 +31,11 @@ static int storage_json_array_count(const char *json, const char *path);
|
||||
#define STORAGE_SYNC_PUBLIC_ID_KEY "sync_public_id"
|
||||
#define STORAGE_SYNC_PUBLIC_KEY_KEY "sync_public_key"
|
||||
#define STORAGE_SYNC_PRIVATE_KEY_KEY "sync_private_key"
|
||||
#define STORAGE_SYNC_LAST_SERVER_HASH_KEY "sync_last_server_state_hash"
|
||||
#define STORAGE_SYNC_PENDING_REVIEW_KEY "sync_pending_review_pending"
|
||||
#define STORAGE_SYNC_APPLY_REVIEW_KEY "sync_apply_pending_review"
|
||||
#define STORAGE_SYNC_FULL_REPLACE_KEY "sync_full_replace_requested"
|
||||
#define STORAGE_SYNC_ACCOUNT_ALIAS_KEY "sync_account_alias"
|
||||
|
||||
static long long
|
||||
storage_next_change_time(void)
|
||||
@@ -359,6 +364,10 @@ storage_reset_sync_state(void)
|
||||
set_meta_int64("sync_last_server_version", 0);
|
||||
set_meta_int64("sync_last_upload_at", 0);
|
||||
set_meta_int64("sync_full_upload_done", 0);
|
||||
set_meta(STORAGE_SYNC_LAST_SERVER_HASH_KEY, "");
|
||||
set_meta(STORAGE_SYNC_PENDING_REVIEW_KEY, "");
|
||||
set_meta_int64(STORAGE_SYNC_FULL_REPLACE_KEY, 0);
|
||||
storage_sync_review_delete_json();
|
||||
set_meta_int64(STORAGE_SYNC_BACKFILL_KEY, 0);
|
||||
set_meta_int64(STORAGE_SYNC_HABIT_NAME_REPAIR_KEY, 0);
|
||||
exec_sql("DELETE FROM sync_outbox");
|
||||
@@ -1228,6 +1237,15 @@ storage_build_sync_payload_json(const char *user_id_hash, const char *public_key
|
||||
json_append(&json, ",");
|
||||
json_append_key_string(&json, "client_id", storage_sync_client_id());
|
||||
json_appendf(&json, ",\"since_server_version\":%lld", since_server_version);
|
||||
if(get_meta_int64(STORAGE_SYNC_FULL_REPLACE_KEY, 0) != 0)
|
||||
json_append(&json, ",\"full_sync_requested\":true");
|
||||
{
|
||||
const char *last_server_hash = get_meta_text(STORAGE_SYNC_LAST_SERVER_HASH_KEY);
|
||||
if(last_server_hash != NULL && last_server_hash[0] != '\0') {
|
||||
json_append(&json, ",");
|
||||
json_append_key_string(&json, "last_server_state_hash", last_server_hash);
|
||||
}
|
||||
}
|
||||
if(since_server_version <= 0 || !full_upload_done)
|
||||
json_append(&json, ",\"bootstrap\":true");
|
||||
if(public_key_hex != NULL && public_key_hex[0] != '\0') {
|
||||
@@ -1298,6 +1316,33 @@ storage_json_extract_int64(const char *json, const char *path, long long fallbac
|
||||
return value;
|
||||
}
|
||||
|
||||
static int
|
||||
storage_json_extract_text(const char *json, const char *path, char *out, size_t out_size)
|
||||
{
|
||||
sqlite3_stmt *stmt = NULL;
|
||||
const unsigned char *text;
|
||||
int ok = 0;
|
||||
|
||||
if(out == NULL || out_size == 0)
|
||||
return 0;
|
||||
out[0] = '\0';
|
||||
if(g_storage.db == NULL || json == NULL || path == NULL)
|
||||
return 0;
|
||||
if(sqlite3_prepare_v2(g_storage.db, "SELECT COALESCE(json_extract(?1,?2),'')", -1, &stmt, NULL) != SQLITE_OK)
|
||||
return 0;
|
||||
bind_text(stmt, 1, json);
|
||||
bind_text(stmt, 2, path);
|
||||
if(sqlite3_step(stmt) == SQLITE_ROW) {
|
||||
text = sqlite3_column_text(stmt, 0);
|
||||
if(text != NULL) {
|
||||
snprintf(out, out_size, "%s", (const char *)text);
|
||||
ok = out[0] != '\0';
|
||||
}
|
||||
}
|
||||
sqlite3_finalize(stmt);
|
||||
return ok;
|
||||
}
|
||||
|
||||
static long long
|
||||
storage_max_sync_outbox_seq(void)
|
||||
{
|
||||
@@ -1644,6 +1689,8 @@ storage_apply_sync_response_json(const char *response_json)
|
||||
" WHERE entity_type='session' AND entity_id=COALESCE(json_extract(s.value,'$.id'),'') AND local_date=0)))";
|
||||
long long server_version;
|
||||
long long old_server_version;
|
||||
char server_hash[80];
|
||||
char account_alias[40];
|
||||
|
||||
if(g_storage.db == NULL || response_json == NULL || response_json[0] == '\0')
|
||||
return 0;
|
||||
@@ -1652,6 +1699,28 @@ storage_apply_sync_response_json(const char *response_json)
|
||||
g_storage.last_sync_changed = 0;
|
||||
if(!storage_json_valid(response_json))
|
||||
return 0;
|
||||
if(storage_json_extract_text(response_json, "$.account_alias", account_alias, sizeof(account_alias)))
|
||||
storage_set_setting_text(STORAGE_SYNC_ACCOUNT_ALIAS_KEY, account_alias);
|
||||
if(storage_json_extract_int64(response_json, "$.full_snapshot_required", 0) != 0 &&
|
||||
get_meta_int64(STORAGE_SYNC_APPLY_REVIEW_KEY, 0) == 0) {
|
||||
if(!storage_sync_review_json_has_visible_diff(response_json)) {
|
||||
char *copy = strdup(response_json);
|
||||
int ok;
|
||||
if(copy == NULL)
|
||||
return 0;
|
||||
set_meta_int64(STORAGE_SYNC_APPLY_REVIEW_KEY, 1);
|
||||
ok = storage_apply_sync_response_json(copy);
|
||||
free(copy);
|
||||
return ok;
|
||||
}
|
||||
if(!storage_sync_review_write_json(response_json))
|
||||
return 0;
|
||||
set_meta(STORAGE_SYNC_PENDING_REVIEW_KEY, "1");
|
||||
g_storage.pending_sync_outbox_seq = 0;
|
||||
storage_schedule_persist();
|
||||
TraceLog(LOG_WARNING, "SYNC: full snapshot review required");
|
||||
return 1;
|
||||
}
|
||||
old_server_version = get_meta_int64("sync_last_server_version", 0);
|
||||
if(!exec_sql("BEGIN IMMEDIATE"))
|
||||
return 0;
|
||||
@@ -1680,6 +1749,12 @@ storage_apply_sync_response_json(const char *response_json)
|
||||
g_storage.last_sync_changed = 1;
|
||||
if(server_version > 0)
|
||||
set_meta_int64("sync_last_server_version", server_version);
|
||||
if(storage_json_extract_text(response_json, "$.server_state_hash", server_hash, sizeof(server_hash)))
|
||||
set_meta(STORAGE_SYNC_LAST_SERVER_HASH_KEY, server_hash);
|
||||
set_meta(STORAGE_SYNC_PENDING_REVIEW_KEY, "");
|
||||
storage_sync_review_delete_json();
|
||||
set_meta_int64(STORAGE_SYNC_APPLY_REVIEW_KEY, 0);
|
||||
set_meta_int64(STORAGE_SYNC_FULL_REPLACE_KEY, 0);
|
||||
storage_clear_uploaded_outbox(g_storage.pending_sync_outbox_seq);
|
||||
g_storage.pending_sync_outbox_seq = 0;
|
||||
set_meta_int64("sync_full_upload_done", 1);
|
||||
@@ -2149,6 +2224,26 @@ storage_habits_save(const void *habits_ptr)
|
||||
sqlite3_finalize(stmt);
|
||||
stmt = NULL;
|
||||
for(int i = 0; i < deleted_count; i++) {
|
||||
if(sqlite3_prepare_v2(g_storage.db,
|
||||
"SELECT local_date FROM habit_days "
|
||||
"WHERE habit_id=?1 AND (completed!=0 OR count>0 OR session_count>0)",
|
||||
-1, &stmt, NULL) == SQLITE_OK) {
|
||||
bind_text(stmt, 1, deleted_ids[i]);
|
||||
while(sqlite3_step(stmt) == SQLITE_ROW)
|
||||
storage_enqueue_sync_habit_day(deleted_ids[i], sqlite3_column_int(stmt, 0));
|
||||
sqlite3_finalize(stmt);
|
||||
stmt = NULL;
|
||||
}
|
||||
if(sqlite3_prepare_v2(g_storage.db,
|
||||
"UPDATE habit_days SET completed=0,count=0,session_count=0,updated_at=?2 "
|
||||
"WHERE habit_id=?1 AND (completed!=0 OR count>0 OR session_count>0)",
|
||||
-1, &stmt, NULL) == SQLITE_OK) {
|
||||
bind_text(stmt, 1, deleted_ids[i]);
|
||||
sqlite3_bind_int64(stmt, 2, changed_at);
|
||||
sqlite3_step(stmt);
|
||||
sqlite3_finalize(stmt);
|
||||
stmt = NULL;
|
||||
}
|
||||
if(sqlite3_prepare_v2(g_storage.db,
|
||||
"UPDATE habits SET deleted_at=?2,updated_at=?2 WHERE id=?1",
|
||||
-1, &stmt, NULL) != SQLITE_OK)
|
||||
|
||||
@@ -69,6 +69,13 @@ char *storage_build_sync_payload_json(const char *user_id_hash,
|
||||
void storage_free_sync_payload_json(char *payload);
|
||||
int storage_apply_sync_response_json(const char *response_json);
|
||||
int storage_last_sync_changed(void);
|
||||
int storage_sync_review_pending(void);
|
||||
int storage_sync_review_details(char **local_out, char **remote_out);
|
||||
int storage_sync_review_diff(char **diff_out);
|
||||
int storage_sync_review_has_visible_diff(void);
|
||||
int storage_sync_review_json_has_visible_diff(const char *json);
|
||||
int storage_sync_review_clear_if_no_visible_diff(void);
|
||||
int storage_apply_pending_sync_review(int use_remote);
|
||||
void storage_purge_synced_deleted_data(void);
|
||||
const char *storage_sync_client_id(void);
|
||||
void storage_reset_sync_state(void);
|
||||
|
||||
@@ -36,6 +36,7 @@ extern struct android_app *GetAndroidApp(void);
|
||||
#define INBE_SYNC_WS_PATH "/api/v1/sync/ws"
|
||||
#define INBE_CHALLENGE_PATH "/api/v1/sync/challenge"
|
||||
#define INBE_LOGIN_PATH "/api/v1/sync/login"
|
||||
#define INBE_ACCOUNT_ALIAS_PATH "/api/v1/account/alias"
|
||||
#define INBE_ACCOUNT_DELETE_WITH_KEY_PATH "/api/v1/account/delete-with-key"
|
||||
#define INBE_SYNC_WEB_RESPONSE_MAX (4 * 1024 * 1024)
|
||||
#define INBE_SYNC_AUTH_TOKEN_KEY "sync_auth_token"
|
||||
@@ -1420,6 +1421,86 @@ sync_client_sync(const char *base_url)
|
||||
return result;
|
||||
}
|
||||
|
||||
InbeSyncClientResult
|
||||
sync_client_register_alias(const char *base_url, const char *alias)
|
||||
{
|
||||
#if defined(__EMSCRIPTEN__)
|
||||
(void)base_url;
|
||||
(void)alias;
|
||||
return INBE_SYNC_CLIENT_REQUEST_FAILED;
|
||||
#else
|
||||
InbeSyncAccount account;
|
||||
char token[4096];
|
||||
char url[768];
|
||||
char user_header[96];
|
||||
char auth_header[4200];
|
||||
const char *headers[3];
|
||||
SyncBuffer body = {0};
|
||||
SyncBuffer response = {0};
|
||||
long status = 0;
|
||||
InbeSyncClientResult result;
|
||||
int ok;
|
||||
char saved_alias[40];
|
||||
|
||||
if(!sync_client_url_valid(base_url))
|
||||
return INBE_SYNC_CLIENT_INVALID_URL;
|
||||
if(alias == NULL || alias[0] == '\0')
|
||||
return INBE_SYNC_CLIENT_PAYLOAD_FAILED;
|
||||
if(!sync_account_load(&account))
|
||||
return INBE_SYNC_CLIENT_NO_ACCOUNT;
|
||||
|
||||
TraceLog(LOG_INFO, "SYNC: alias login refresh started");
|
||||
result = sync_login(base_url, &account);
|
||||
if(result != INBE_SYNC_CLIENT_OK) {
|
||||
TraceLog(LOG_WARNING, "SYNC: alias login refresh failed result=%d", (int)result);
|
||||
return result;
|
||||
}
|
||||
if(!sync_load_valid_auth_token(token, sizeof(token))) {
|
||||
TraceLog(LOG_WARNING, "SYNC: alias login refresh did not produce token");
|
||||
return INBE_SYNC_CLIENT_AUTH_FAILED;
|
||||
}
|
||||
if(!sync_buffer_append(&body, "{\"user_id_hash\":", strlen("{\"user_id_hash\":")) ||
|
||||
!sync_buffer_append_json_string(&body, account.public_id) ||
|
||||
!sync_buffer_append(&body, ",\"alias\":", strlen(",\"alias\":")) ||
|
||||
!sync_buffer_append_json_string(&body, alias) ||
|
||||
!sync_buffer_append(&body, "}", 1)) {
|
||||
free(body.data);
|
||||
return INBE_SYNC_CLIENT_PAYLOAD_FAILED;
|
||||
}
|
||||
sync_join_url(url, sizeof(url), base_url, INBE_ACCOUNT_ALIAS_PATH);
|
||||
TraceLog(LOG_INFO, "SYNC: alias request url=%s alias=@%s", url, alias);
|
||||
snprintf(user_header, sizeof(user_header), "X-Inbe-User: %s", account.public_id);
|
||||
snprintf(auth_header, sizeof(auth_header), "Authorization: Bearer %s", token);
|
||||
headers[0] = "Content-Type: application/json";
|
||||
headers[1] = user_header;
|
||||
headers[2] = auth_header;
|
||||
ok = sync_http_request("POST", url, body.data, headers, 3, &response, &status);
|
||||
free(body.data);
|
||||
if(!ok) {
|
||||
sync_log_http_failure("alias request", status, response.data);
|
||||
return INBE_SYNC_CLIENT_REQUEST_FAILED;
|
||||
}
|
||||
if(status == 401) {
|
||||
sync_log_http_failure("alias auth", status, response.data);
|
||||
free(response.data);
|
||||
return INBE_SYNC_CLIENT_AUTH_FAILED;
|
||||
}
|
||||
if(status < 200 || status >= 300) {
|
||||
sync_log_http_failure("alias", status, response.data);
|
||||
free(response.data);
|
||||
return INBE_SYNC_CLIENT_REQUEST_FAILED;
|
||||
}
|
||||
if(sync_find_json_string(response.data, "alias", saved_alias, sizeof(saved_alias))) {
|
||||
storage_set_setting_text("sync_account_alias", saved_alias);
|
||||
TraceLog(LOG_INFO, "SYNC: alias response stored @%s", saved_alias);
|
||||
} else {
|
||||
TraceLog(LOG_WARNING, "SYNC: alias response missing alias field");
|
||||
}
|
||||
free(response.data);
|
||||
return INBE_SYNC_CLIENT_OK;
|
||||
#endif
|
||||
}
|
||||
|
||||
InbeSyncClientResult
|
||||
sync_client_wait_for_remote_event(const char *base_url)
|
||||
{
|
||||
|
||||
@@ -17,6 +17,7 @@ typedef enum InbeSyncClientResult {
|
||||
int sync_client_url_valid(const char *url);
|
||||
int sync_client_normalize_url(const char *input, char *out, size_t out_size);
|
||||
InbeSyncClientResult sync_client_sync(const char *base_url);
|
||||
InbeSyncClientResult sync_client_register_alias(const char *base_url, const char *alias);
|
||||
InbeSyncClientResult sync_client_wait_for_remote_event(const char *base_url);
|
||||
InbeSyncClientResult sync_client_delete_account(const char *base_url);
|
||||
const char *sync_client_result_name(InbeSyncClientResult result);
|
||||
|
||||
@@ -0,0 +1,603 @@
|
||||
#include "storage.h"
|
||||
#include "db.h"
|
||||
|
||||
#include <sqlite3.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define STORAGE_SYNC_PENDING_REVIEW_KEY "sync_pending_review_pending"
|
||||
#define STORAGE_SYNC_APPLY_REVIEW_KEY "sync_apply_pending_review"
|
||||
#define STORAGE_SYNC_FULL_REPLACE_KEY "sync_full_replace_requested"
|
||||
#define STORAGE_SYNC_LAST_SERVER_HASH_KEY "sync_last_server_state_hash"
|
||||
|
||||
typedef struct ReviewText {
|
||||
char *data;
|
||||
size_t len;
|
||||
size_t cap;
|
||||
int ok;
|
||||
} ReviewText;
|
||||
|
||||
static void review_append_local(ReviewText *out);
|
||||
static void review_append_remote(ReviewText *out, const char *json);
|
||||
static void review_append_unique_lines(ReviewText *out, const char *prefix,
|
||||
const char *lines, const char *other);
|
||||
|
||||
static int
|
||||
review_reserve(ReviewText *text, size_t extra)
|
||||
{
|
||||
char *next;
|
||||
size_t next_cap;
|
||||
|
||||
if(text == NULL || !text->ok)
|
||||
return 0;
|
||||
if(extra <= text->cap - text->len)
|
||||
return 1;
|
||||
next_cap = text->cap > 0 ? text->cap : 2048;
|
||||
while(extra > next_cap - text->len)
|
||||
next_cap *= 2;
|
||||
next = (char *)realloc(text->data, next_cap);
|
||||
if(next == NULL) {
|
||||
text->ok = 0;
|
||||
return 0;
|
||||
}
|
||||
text->data = next;
|
||||
text->cap = next_cap;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
review_append(ReviewText *text, const char *value)
|
||||
{
|
||||
size_t len;
|
||||
|
||||
if(text == NULL || value == NULL)
|
||||
return;
|
||||
len = strlen(value);
|
||||
if(!review_reserve(text, len + 1))
|
||||
return;
|
||||
memcpy(text->data + text->len, value, len);
|
||||
text->len += len;
|
||||
text->data[text->len] = '\0';
|
||||
}
|
||||
|
||||
static void
|
||||
review_appendf(ReviewText *text, const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_list copy;
|
||||
int needed;
|
||||
|
||||
if(text == NULL || fmt == NULL || !text->ok)
|
||||
return;
|
||||
va_start(args, fmt);
|
||||
va_copy(copy, args);
|
||||
needed = vsnprintf(NULL, 0, fmt, copy);
|
||||
va_end(copy);
|
||||
if(needed < 0) {
|
||||
text->ok = 0;
|
||||
va_end(args);
|
||||
return;
|
||||
}
|
||||
if(review_reserve(text, (size_t)needed + 1)) {
|
||||
vsnprintf(text->data + text->len, text->cap - text->len, fmt, args);
|
||||
text->len += (size_t)needed;
|
||||
}
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
static void
|
||||
storage_sync_review_path(char *out, size_t out_size)
|
||||
{
|
||||
const char *name = "sync-review.json";
|
||||
size_t root_len;
|
||||
size_t name_len;
|
||||
|
||||
if(out == NULL || out_size == 0)
|
||||
return;
|
||||
root_len = strlen(g_storage.root);
|
||||
name_len = strlen(name);
|
||||
if(root_len + 1 + name_len + 1 > out_size) {
|
||||
out[0] = '\0';
|
||||
return;
|
||||
}
|
||||
snprintf(out, out_size, "%s/%s", g_storage.root, name);
|
||||
}
|
||||
|
||||
int
|
||||
storage_sync_review_write_json(const char *json)
|
||||
{
|
||||
char path[INBE_STORAGE_PATH_SIZE];
|
||||
FILE *file;
|
||||
size_t len;
|
||||
|
||||
if(json == NULL)
|
||||
return 0;
|
||||
storage_sync_review_path(path, sizeof(path));
|
||||
if(path[0] == '\0')
|
||||
return 0;
|
||||
file = fopen(path, "wb");
|
||||
if(file == NULL)
|
||||
return 0;
|
||||
len = strlen(json);
|
||||
if(fwrite(json, 1, len, file) != len) {
|
||||
fclose(file);
|
||||
return 0;
|
||||
}
|
||||
return fclose(file) == 0;
|
||||
}
|
||||
|
||||
static char *
|
||||
storage_sync_review_read_json(void)
|
||||
{
|
||||
char path[INBE_STORAGE_PATH_SIZE];
|
||||
FILE *file;
|
||||
long size;
|
||||
char *data;
|
||||
|
||||
storage_sync_review_path(path, sizeof(path));
|
||||
if(path[0] == '\0')
|
||||
return NULL;
|
||||
file = fopen(path, "rb");
|
||||
if(file == NULL)
|
||||
return NULL;
|
||||
if(fseek(file, 0, SEEK_END) != 0) {
|
||||
fclose(file);
|
||||
return NULL;
|
||||
}
|
||||
size = ftell(file);
|
||||
if(size < 0 || size > 8 * 1024 * 1024) {
|
||||
fclose(file);
|
||||
return NULL;
|
||||
}
|
||||
rewind(file);
|
||||
data = (char *)malloc((size_t)size + 1);
|
||||
if(data == NULL) {
|
||||
fclose(file);
|
||||
return NULL;
|
||||
}
|
||||
if(fread(data, 1, (size_t)size, file) != (size_t)size) {
|
||||
free(data);
|
||||
fclose(file);
|
||||
return NULL;
|
||||
}
|
||||
data[size] = '\0';
|
||||
fclose(file);
|
||||
return data;
|
||||
}
|
||||
|
||||
static int
|
||||
storage_sync_review_diff_for_json(const char *json, int include_empty_message,
|
||||
char **diff_out)
|
||||
{
|
||||
ReviewText local = {0};
|
||||
ReviewText remote = {0};
|
||||
ReviewText diff = {0};
|
||||
|
||||
if(diff_out != NULL)
|
||||
*diff_out = NULL;
|
||||
if(diff_out == NULL)
|
||||
return 0;
|
||||
local.ok = 1;
|
||||
remote.ok = 1;
|
||||
diff.ok = 1;
|
||||
review_append_local(&local);
|
||||
review_append_remote(&remote, json);
|
||||
if(!local.ok || !remote.ok) {
|
||||
free(local.data);
|
||||
free(remote.data);
|
||||
return 0;
|
||||
}
|
||||
review_append_unique_lines(&diff, "- ", local.data != NULL ? local.data : "",
|
||||
remote.data != NULL ? remote.data : "");
|
||||
review_append_unique_lines(&diff, "+ ", remote.data != NULL ? remote.data : "",
|
||||
local.data != NULL ? local.data : "");
|
||||
if(diff.len == 0 && include_empty_message)
|
||||
review_append(&diff, "No visible differences.\n");
|
||||
free(local.data);
|
||||
free(remote.data);
|
||||
if(!diff.ok) {
|
||||
free(diff.data);
|
||||
return 0;
|
||||
}
|
||||
*diff_out = diff.data != NULL ? diff.data : strdup("");
|
||||
return *diff_out != NULL;
|
||||
}
|
||||
|
||||
void
|
||||
storage_sync_review_delete_json(void)
|
||||
{
|
||||
char path[INBE_STORAGE_PATH_SIZE];
|
||||
storage_sync_review_path(path, sizeof(path));
|
||||
if(path[0] != '\0')
|
||||
remove(path);
|
||||
}
|
||||
|
||||
int
|
||||
storage_sync_review_pending(void)
|
||||
{
|
||||
return get_meta_int64(STORAGE_SYNC_PENDING_REVIEW_KEY, 0) != 0;
|
||||
}
|
||||
|
||||
static const char *
|
||||
review_activity_name(int activity)
|
||||
{
|
||||
switch(activity) {
|
||||
case 0: return "Wim Hof";
|
||||
case 1: return "Meditation";
|
||||
default: break;
|
||||
}
|
||||
return "Unknown";
|
||||
}
|
||||
|
||||
static void
|
||||
review_append_activity_heading(ReviewText *out, int activity)
|
||||
{
|
||||
review_append(out, review_activity_name(activity));
|
||||
if(activity != 0 && activity != 1)
|
||||
review_appendf(out, " %d", activity);
|
||||
review_append(out, "\n");
|
||||
}
|
||||
|
||||
static void
|
||||
review_append_local_rounds(ReviewText *out, const char *session_id)
|
||||
{
|
||||
sqlite3_stmt *stmt = NULL;
|
||||
int first = 1;
|
||||
|
||||
if(g_storage.db == NULL || session_id == NULL)
|
||||
return;
|
||||
if(sqlite3_prepare_v2(g_storage.db,
|
||||
"SELECT seconds FROM session_rounds WHERE session_id=?1 ORDER BY round_index",
|
||||
-1, &stmt, NULL) != SQLITE_OK)
|
||||
return;
|
||||
bind_text(stmt, 1, session_id);
|
||||
while(sqlite3_step(stmt) == SQLITE_ROW) {
|
||||
if(!first)
|
||||
review_append(out, ",");
|
||||
first = 0;
|
||||
review_appendf(out, "%ds", sqlite3_column_int(stmt, 0));
|
||||
}
|
||||
sqlite3_finalize(stmt);
|
||||
if(first)
|
||||
review_append(out, "none");
|
||||
}
|
||||
|
||||
static void
|
||||
review_append_local(ReviewText *out)
|
||||
{
|
||||
sqlite3_stmt *stmt = NULL;
|
||||
int rows = 0;
|
||||
int last_activity = -1000000;
|
||||
|
||||
review_append(out, "Sessions\n");
|
||||
if(g_storage.db != NULL &&
|
||||
sqlite3_prepare_v2(g_storage.db,
|
||||
"SELECT id,local_date,strftime('%H:%M',started_at,'unixepoch','localtime'),activity,deleted_at "
|
||||
"FROM sessions WHERE user_id=?1 AND deleted_at=0 ORDER BY activity,local_date DESC,started_at DESC,id",
|
||||
-1, &stmt, NULL) == SQLITE_OK) {
|
||||
bind_text(stmt, 1, g_storage.user_id);
|
||||
while(sqlite3_step(stmt) == SQLITE_ROW) {
|
||||
const char *id = (const char *)sqlite3_column_text(stmt, 0);
|
||||
int local_date = sqlite3_column_int(stmt, 1);
|
||||
const char *time_text = (const char *)sqlite3_column_text(stmt, 2);
|
||||
int activity = sqlite3_column_int(stmt, 3);
|
||||
if(activity != last_activity) {
|
||||
if(rows > 0)
|
||||
review_append(out, "\n");
|
||||
review_append_activity_heading(out, activity);
|
||||
last_activity = activity;
|
||||
}
|
||||
review_appendf(out, "%04d-%02d-%02d %s\n",
|
||||
local_date / 10000, (local_date / 100) % 100,
|
||||
local_date % 100, time_text != NULL ? time_text : "--:--");
|
||||
review_append(out, "rounds ");
|
||||
review_append_local_rounds(out, id);
|
||||
if(sqlite3_column_int64(stmt, 4) != 0)
|
||||
review_append(out, " deleted");
|
||||
review_append(out, "\n");
|
||||
rows++;
|
||||
}
|
||||
sqlite3_finalize(stmt);
|
||||
}
|
||||
if(rows == 0)
|
||||
review_append(out, "No sessions\n");
|
||||
|
||||
rows = 0;
|
||||
review_append(out, "\nHabit days\n");
|
||||
if(g_storage.db != NULL &&
|
||||
sqlite3_prepare_v2(g_storage.db,
|
||||
"SELECT h.name,hd.local_date,hd.count "
|
||||
"FROM habit_days hd JOIN habits h ON h.id=hd.habit_id "
|
||||
"WHERE h.user_id=?1 AND (hd.completed!=0 OR hd.count>0 OR hd.session_count>0) "
|
||||
"ORDER BY h.name,hd.local_date DESC",
|
||||
-1, &stmt, NULL) == SQLITE_OK) {
|
||||
char last_name[256] = "";
|
||||
bind_text(stmt, 1, g_storage.user_id);
|
||||
while(sqlite3_step(stmt) == SQLITE_ROW) {
|
||||
int local_date = sqlite3_column_int(stmt, 1);
|
||||
const char *name = (const char *)sqlite3_column_text(stmt, 0);
|
||||
const char *safe_name = name != NULL && name[0] != '\0' ? name : "(unnamed)";
|
||||
if(strcmp(last_name, safe_name) != 0) {
|
||||
if(rows > 0)
|
||||
review_append(out, "\n");
|
||||
review_append(out, safe_name);
|
||||
review_append(out, "\n");
|
||||
snprintf(last_name, sizeof(last_name), "%s", safe_name);
|
||||
}
|
||||
review_appendf(out, "%04d-%02d-%02d",
|
||||
local_date / 10000, (local_date / 100) % 100,
|
||||
local_date % 100);
|
||||
if(sqlite3_column_int(stmt, 2) > 0)
|
||||
review_appendf(out, " count %d", sqlite3_column_int(stmt, 2));
|
||||
review_append(out, "\n");
|
||||
rows++;
|
||||
}
|
||||
sqlite3_finalize(stmt);
|
||||
}
|
||||
if(rows == 0)
|
||||
review_append(out, "No habit days\n");
|
||||
}
|
||||
|
||||
static void
|
||||
review_append_remote(ReviewText *out, const char *json)
|
||||
{
|
||||
sqlite3_stmt *stmt = NULL;
|
||||
int rows = 0;
|
||||
int last_activity = -1000000;
|
||||
|
||||
review_append(out, "Sessions\n");
|
||||
if(g_storage.db != NULL && json != NULL &&
|
||||
sqlite3_prepare_v2(g_storage.db,
|
||||
"SELECT CAST(COALESCE(json_extract(s.value,'$.local_date'),0) AS INTEGER),"
|
||||
" COALESCE(strftime('%H:%M',json_extract(s.value,'$.started_at'),'localtime'),'--:--'),"
|
||||
" CAST(COALESCE(json_extract(s.value,'$.activity'),0) AS INTEGER),"
|
||||
" CAST(COALESCE(json_extract(s.value,'$.deleted_at'),0) AS INTEGER),"
|
||||
" COALESCE((SELECT group_concat(CAST(COALESCE(json_extract(r.value,'$.hold_seconds'),0) AS INTEGER) || 's', ',') FROM json_each(s.value,'$.rounds') AS r),'none') "
|
||||
"FROM json_each(?1,'$.changes.sessions') AS s "
|
||||
"WHERE CAST(COALESCE(json_extract(s.value,'$.deleted_at'),0) AS INTEGER)=0 "
|
||||
"ORDER BY 3,1 DESC,2 DESC",
|
||||
-1, &stmt, NULL) == SQLITE_OK) {
|
||||
bind_text(stmt, 1, json);
|
||||
while(sqlite3_step(stmt) == SQLITE_ROW) {
|
||||
int local_date = sqlite3_column_int(stmt, 0);
|
||||
const char *time_text = (const char *)sqlite3_column_text(stmt, 1);
|
||||
int activity = sqlite3_column_int(stmt, 2);
|
||||
const char *rounds = (const char *)sqlite3_column_text(stmt, 4);
|
||||
if(activity != last_activity) {
|
||||
if(rows > 0)
|
||||
review_append(out, "\n");
|
||||
review_append_activity_heading(out, activity);
|
||||
last_activity = activity;
|
||||
}
|
||||
review_appendf(out, "%04d-%02d-%02d %s\n",
|
||||
local_date / 10000, (local_date / 100) % 100,
|
||||
local_date % 100, time_text != NULL ? time_text : "--:--");
|
||||
review_appendf(out, "rounds %s", rounds != NULL ? rounds : "none");
|
||||
if(sqlite3_column_int64(stmt, 3) != 0)
|
||||
review_append(out, " deleted");
|
||||
review_append(out, "\n");
|
||||
rows++;
|
||||
}
|
||||
sqlite3_finalize(stmt);
|
||||
}
|
||||
if(rows == 0)
|
||||
review_append(out, "No sessions\n");
|
||||
|
||||
rows = 0;
|
||||
review_append(out, "\nHabit days\n");
|
||||
if(g_storage.db != NULL && json != NULL &&
|
||||
sqlite3_prepare_v2(g_storage.db,
|
||||
"SELECT COALESCE((SELECT COALESCE(json_extract(h.value,'$.name'),'') FROM json_each(?1,'$.changes.habits') AS h WHERE COALESCE(json_extract(h.value,'$.id'),'')=COALESCE(json_extract(d.value,'$.habit_id'),'')),COALESCE(json_extract(d.value,'$.habit_id'),'')),"
|
||||
" CAST(COALESCE(json_extract(d.value,'$.local_date'),0) AS INTEGER),"
|
||||
" CAST(COALESCE(json_extract(d.value,'$.count'),0) AS INTEGER) "
|
||||
"FROM json_each(?1,'$.changes.habit_days') AS d "
|
||||
"WHERE json_extract(d.value,'$.completed') OR CAST(COALESCE(json_extract(d.value,'$.count'),0) AS INTEGER)>0 "
|
||||
"ORDER BY 1,2 DESC",
|
||||
-1, &stmt, NULL) == SQLITE_OK) {
|
||||
char last_name[256] = "";
|
||||
bind_text(stmt, 1, json);
|
||||
while(sqlite3_step(stmt) == SQLITE_ROW) {
|
||||
int local_date = sqlite3_column_int(stmt, 1);
|
||||
const char *name = (const char *)sqlite3_column_text(stmt, 0);
|
||||
const char *safe_name = name != NULL && name[0] != '\0' ? name : "(unknown)";
|
||||
if(strcmp(last_name, safe_name) != 0) {
|
||||
if(rows > 0)
|
||||
review_append(out, "\n");
|
||||
review_append(out, safe_name);
|
||||
review_append(out, "\n");
|
||||
snprintf(last_name, sizeof(last_name), "%s", safe_name);
|
||||
}
|
||||
review_appendf(out, "%04d-%02d-%02d",
|
||||
local_date / 10000, (local_date / 100) % 100,
|
||||
local_date % 100);
|
||||
if(sqlite3_column_int(stmt, 2) > 0)
|
||||
review_appendf(out, " count %d", sqlite3_column_int(stmt, 2));
|
||||
review_append(out, "\n");
|
||||
rows++;
|
||||
}
|
||||
sqlite3_finalize(stmt);
|
||||
}
|
||||
if(rows == 0)
|
||||
review_append(out, "No habit days\n");
|
||||
}
|
||||
|
||||
int
|
||||
storage_sync_review_details(char **local_out, char **remote_out)
|
||||
{
|
||||
char *json = storage_sync_review_read_json();
|
||||
ReviewText local = {0};
|
||||
ReviewText remote = {0};
|
||||
|
||||
if(local_out != NULL)
|
||||
*local_out = NULL;
|
||||
if(remote_out != NULL)
|
||||
*remote_out = NULL;
|
||||
local.ok = 1;
|
||||
remote.ok = 1;
|
||||
review_append_local(&local);
|
||||
review_append_remote(&remote, json);
|
||||
free(json);
|
||||
if(!local.ok || !remote.ok) {
|
||||
free(local.data);
|
||||
free(remote.data);
|
||||
return 0;
|
||||
}
|
||||
if(local_out != NULL)
|
||||
*local_out = local.data != NULL ? local.data : strdup("");
|
||||
else
|
||||
free(local.data);
|
||||
if(remote_out != NULL)
|
||||
*remote_out = remote.data != NULL ? remote.data : strdup("");
|
||||
else
|
||||
free(remote.data);
|
||||
return (local_out == NULL || *local_out != NULL) &&
|
||||
(remote_out == NULL || *remote_out != NULL);
|
||||
}
|
||||
|
||||
static int
|
||||
review_line_equal(const char *line, size_t line_len, const char *other)
|
||||
{
|
||||
const char *p = other;
|
||||
const char *end;
|
||||
size_t len;
|
||||
|
||||
if(line == NULL || other == NULL)
|
||||
return 0;
|
||||
while(*p != '\0') {
|
||||
end = strchr(p, '\n');
|
||||
len = end != NULL ? (size_t)(end - p) : strlen(p);
|
||||
if(len == line_len && strncmp(p, line, line_len) == 0)
|
||||
return 1;
|
||||
if(end == NULL)
|
||||
break;
|
||||
p = end + 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
review_append_unique_lines(ReviewText *out, const char *prefix,
|
||||
const char *lines, const char *other)
|
||||
{
|
||||
const char *p = lines;
|
||||
const char *end;
|
||||
size_t len;
|
||||
|
||||
if(out == NULL || prefix == NULL || lines == NULL)
|
||||
return;
|
||||
while(*p != '\0') {
|
||||
end = strchr(p, '\n');
|
||||
len = end != NULL ? (size_t)(end - p) : strlen(p);
|
||||
if(len > 0 && !review_line_equal(p, len, other)) {
|
||||
review_append(out, prefix);
|
||||
if(!review_reserve(out, len + 2))
|
||||
return;
|
||||
memcpy(out->data + out->len, p, len);
|
||||
out->len += len;
|
||||
out->data[out->len++] = '\n';
|
||||
out->data[out->len] = '\0';
|
||||
}
|
||||
if(end == NULL)
|
||||
break;
|
||||
p = end + 1;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
storage_sync_review_diff(char **diff_out)
|
||||
{
|
||||
char *json = storage_sync_review_read_json();
|
||||
int ok = storage_sync_review_diff_for_json(json, 1, diff_out);
|
||||
|
||||
free(json);
|
||||
return ok;
|
||||
}
|
||||
|
||||
int
|
||||
storage_sync_review_has_visible_diff(void)
|
||||
{
|
||||
char *json = storage_sync_review_read_json();
|
||||
int result = storage_sync_review_json_has_visible_diff(json);
|
||||
|
||||
free(json);
|
||||
return result;
|
||||
}
|
||||
|
||||
int
|
||||
storage_sync_review_clear_if_no_visible_diff(void)
|
||||
{
|
||||
if(!storage_sync_review_pending())
|
||||
return 0;
|
||||
if(storage_sync_review_has_visible_diff())
|
||||
return 0;
|
||||
set_meta(STORAGE_SYNC_PENDING_REVIEW_KEY, "");
|
||||
storage_sync_review_delete_json();
|
||||
set_meta_int64(STORAGE_SYNC_APPLY_REVIEW_KEY, 0);
|
||||
storage_schedule_persist();
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
storage_sync_review_json_has_visible_diff(const char *json)
|
||||
{
|
||||
char *diff = NULL;
|
||||
int has_diff;
|
||||
|
||||
if(!storage_sync_review_diff_for_json(json, 0, &diff)) {
|
||||
free(diff);
|
||||
return 1;
|
||||
}
|
||||
has_diff = diff != NULL && diff[0] != '\0';
|
||||
free(diff);
|
||||
return has_diff;
|
||||
}
|
||||
|
||||
int
|
||||
storage_apply_pending_sync_review(int use_remote)
|
||||
{
|
||||
char *json = storage_sync_review_read_json();
|
||||
char *copy;
|
||||
int ok;
|
||||
|
||||
if(json == NULL || json[0] == '\0') {
|
||||
free(json);
|
||||
return 0;
|
||||
}
|
||||
if(!use_remote) {
|
||||
set_meta(STORAGE_SYNC_PENDING_REVIEW_KEY, "");
|
||||
storage_sync_review_delete_json();
|
||||
set_meta(STORAGE_SYNC_LAST_SERVER_HASH_KEY, "");
|
||||
storage_reset_sync_state();
|
||||
set_meta_int64(STORAGE_SYNC_FULL_REPLACE_KEY, 1);
|
||||
free(json);
|
||||
return 1;
|
||||
}
|
||||
copy = strdup(json);
|
||||
free(json);
|
||||
if(copy == NULL)
|
||||
return 0;
|
||||
if(!exec_sql("BEGIN IMMEDIATE") ||
|
||||
!exec_sql("DELETE FROM session_rounds") ||
|
||||
!exec_sql("DELETE FROM sessions") ||
|
||||
!exec_sql("DELETE FROM habit_days") ||
|
||||
!exec_sql("DELETE FROM habits") ||
|
||||
!exec_sql("DELETE FROM sync_outbox") ||
|
||||
!exec_sql("COMMIT")) {
|
||||
exec_sql("ROLLBACK");
|
||||
free(copy);
|
||||
return 0;
|
||||
}
|
||||
set_meta_int64(STORAGE_SYNC_APPLY_REVIEW_KEY, 1);
|
||||
ok = storage_apply_sync_response_json(copy);
|
||||
free(copy);
|
||||
if(ok) {
|
||||
exec_sql("DELETE FROM sync_outbox");
|
||||
g_storage.pending_sync_outbox_seq = 0;
|
||||
set_meta(STORAGE_SYNC_PENDING_REVIEW_KEY, "");
|
||||
storage_sync_review_delete_json();
|
||||
storage_schedule_persist();
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
typedef struct FlintChoppedGlyph {
|
||||
int32_t value;
|
||||
int32_t x;
|
||||
int32_t y;
|
||||
int32_t w;
|
||||
int32_t h;
|
||||
int32_t offsetX;
|
||||
int32_t offsetY;
|
||||
int32_t advanceX;
|
||||
} FlintChoppedGlyph;
|
||||
|
||||
typedef struct RequiredGlyph {
|
||||
int32_t codepoint;
|
||||
const char *label;
|
||||
} RequiredGlyph;
|
||||
|
||||
static int
|
||||
read_file(const char *path, unsigned char **out_data, size_t *out_size)
|
||||
{
|
||||
FILE *fp;
|
||||
long size;
|
||||
unsigned char *data;
|
||||
|
||||
fp = fopen(path, "rb");
|
||||
if(fp == NULL) {
|
||||
fprintf(stderr, "FAIL open %s\n", path);
|
||||
return 0;
|
||||
}
|
||||
if(fseek(fp, 0, SEEK_END) != 0) {
|
||||
fclose(fp);
|
||||
fprintf(stderr, "FAIL seek %s\n", path);
|
||||
return 0;
|
||||
}
|
||||
size = ftell(fp);
|
||||
if(size <= 0) {
|
||||
fclose(fp);
|
||||
fprintf(stderr, "FAIL empty %s\n", path);
|
||||
return 0;
|
||||
}
|
||||
if(fseek(fp, 0, SEEK_SET) != 0) {
|
||||
fclose(fp);
|
||||
fprintf(stderr, "FAIL rewind %s\n", path);
|
||||
return 0;
|
||||
}
|
||||
data = (unsigned char *)malloc((size_t)size);
|
||||
if(data == NULL) {
|
||||
fclose(fp);
|
||||
fprintf(stderr, "FAIL allocate %ld bytes\n", size);
|
||||
return 0;
|
||||
}
|
||||
if(fread(data, 1, (size_t)size, fp) != (size_t)size) {
|
||||
free(data);
|
||||
fclose(fp);
|
||||
fprintf(stderr, "FAIL read %s\n", path);
|
||||
return 0;
|
||||
}
|
||||
fclose(fp);
|
||||
*out_data = data;
|
||||
*out_size = (size_t)size;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
has_glyph(const FlintChoppedGlyph *glyphs, int32_t glyph_count, int32_t codepoint)
|
||||
{
|
||||
for(int32_t i = 0; i < glyph_count; i++) {
|
||||
if(glyphs[i].value == codepoint)
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
static const RequiredGlyph required[] = {
|
||||
{0x8BBE, "Chinese 设"},
|
||||
{0x5B9A, "Chinese 定"},
|
||||
{0x8A2D, "Japanese 設"},
|
||||
{0xC124, "Korean 설"},
|
||||
{0xC815, "Korean 정"},
|
||||
{0x041D, "Cyrillic Н"},
|
||||
{0x0430, "Cyrillic а"},
|
||||
{0x010D, "Czech č"},
|
||||
{0x00E9, "Latin é"},
|
||||
{0x00E3, "Latin ã"}
|
||||
};
|
||||
unsigned char *data = NULL;
|
||||
size_t size = 0;
|
||||
int32_t glyph_count;
|
||||
size_t glyph_bytes;
|
||||
const FlintChoppedGlyph *glyphs;
|
||||
int failures = 0;
|
||||
|
||||
if(!read_file("assets/fonts/locales.dat", &data, &size))
|
||||
return 1;
|
||||
if(size < sizeof(glyph_count)) {
|
||||
free(data);
|
||||
fprintf(stderr, "FAIL locales.dat too small\n");
|
||||
return 1;
|
||||
}
|
||||
memcpy(&glyph_count, data, sizeof(glyph_count));
|
||||
if(glyph_count <= 0) {
|
||||
free(data);
|
||||
fprintf(stderr, "FAIL locales.dat has no glyphs\n");
|
||||
return 1;
|
||||
}
|
||||
glyph_bytes = (size_t)glyph_count * sizeof(FlintChoppedGlyph);
|
||||
if(size - sizeof(glyph_count) < glyph_bytes) {
|
||||
free(data);
|
||||
fprintf(stderr, "FAIL locales.dat truncated glyph table\n");
|
||||
return 1;
|
||||
}
|
||||
glyphs = (const FlintChoppedGlyph *)(const void *)(data + sizeof(glyph_count));
|
||||
|
||||
for(size_t i = 0; i < sizeof(required) / sizeof(required[0]); i++) {
|
||||
if(!has_glyph(glyphs, glyph_count, required[i].codepoint)) {
|
||||
fprintf(stderr, "FAIL missing %s U+%04X in chopped locale font\n",
|
||||
required[i].label, (unsigned int)required[i].codepoint);
|
||||
failures++;
|
||||
}
|
||||
}
|
||||
|
||||
free(data);
|
||||
if(failures != 0) {
|
||||
fprintf(stderr, "%d chopped locale font failure(s)\n", failures);
|
||||
return 1;
|
||||
}
|
||||
printf("font locale tests passed\n");
|
||||
return 0;
|
||||
}
|
||||
@@ -12,7 +12,7 @@ int ui_view_width = 320;
|
||||
int ui_view_height = 560;
|
||||
|
||||
static int failures = 0;
|
||||
static int input_blocked = 0;
|
||||
int g_ui_input_blocked = 0;
|
||||
static int icon_call_count = 0;
|
||||
static int icon_click_call = 0;
|
||||
static int icon_saw_blocked = 0;
|
||||
@@ -21,7 +21,7 @@ static int pressed_key = 0;
|
||||
void
|
||||
ui_set_input_blocked(int blocked)
|
||||
{
|
||||
input_blocked = blocked != 0;
|
||||
g_ui_input_blocked = blocked != 0;
|
||||
}
|
||||
|
||||
int
|
||||
@@ -29,7 +29,7 @@ flint_ui_icon_button(FlintUIIconButton button)
|
||||
{
|
||||
(void)button;
|
||||
icon_call_count++;
|
||||
if(input_blocked)
|
||||
if(g_ui_input_blocked)
|
||||
icon_saw_blocked = 1;
|
||||
return icon_click_call == icon_call_count;
|
||||
}
|
||||
@@ -37,7 +37,7 @@ flint_ui_icon_button(FlintUIIconButton button)
|
||||
int
|
||||
ui_hover_effects_enabled(void)
|
||||
{
|
||||
return !input_blocked;
|
||||
return !g_ui_input_blocked;
|
||||
}
|
||||
|
||||
int
|
||||
@@ -159,7 +159,7 @@ test_guide(int *step)
|
||||
static void
|
||||
reset_input(void)
|
||||
{
|
||||
input_blocked = 0;
|
||||
g_ui_input_blocked = 0;
|
||||
icon_call_count = 0;
|
||||
icon_click_call = 0;
|
||||
icon_saw_blocked = 0;
|
||||
@@ -185,9 +185,15 @@ test_blocks_passthrough(void)
|
||||
result = flint_ui_draw_guide_overlay(test_guide(&step));
|
||||
expect(!result.closed && !result.finished && !result.changed,
|
||||
"plain draw should not change guide state");
|
||||
expect(input_blocked, "guide should leave screen input blocked");
|
||||
expect(!g_ui_input_blocked, "guide must restore unblocked input after draw");
|
||||
expect(!icon_saw_blocked, "guide buttons should be evaluated while temporarily unblocked");
|
||||
expect(!ui_hover_effects_enabled(), "guide should disable hover effects behind overlay");
|
||||
expect(ui_hover_effects_enabled(), "guide must restore hover effects after draw");
|
||||
|
||||
g_ui_input_blocked = 1;
|
||||
result = flint_ui_draw_guide_overlay(test_guide(&step));
|
||||
expect(!result.closed && !result.finished && !result.changed,
|
||||
"plain draw with preblocked input should not change guide state");
|
||||
expect(g_ui_input_blocked, "guide must restore preblocked input after draw");
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -200,26 +206,26 @@ test_next_back_close_finish(void)
|
||||
icon_click_call = 2;
|
||||
result = flint_ui_draw_guide_overlay(test_guide(&step));
|
||||
expect(result.changed && step == 1, "next button should advance step");
|
||||
expect(input_blocked, "next button should restore blocked input");
|
||||
expect(!g_ui_input_blocked, "next button should restore unblocked input");
|
||||
|
||||
reset_input();
|
||||
icon_click_call = 2;
|
||||
result = flint_ui_draw_guide_overlay(test_guide(&step));
|
||||
expect(result.changed && step == 0, "back button should return to previous step");
|
||||
expect(input_blocked, "back button should restore blocked input");
|
||||
expect(!g_ui_input_blocked, "back button should restore unblocked input");
|
||||
|
||||
reset_input();
|
||||
icon_click_call = 1;
|
||||
result = flint_ui_draw_guide_overlay(test_guide(&step));
|
||||
expect(result.closed, "close button should close guide");
|
||||
expect(input_blocked, "close button should restore blocked input");
|
||||
expect(!g_ui_input_blocked, "close button should restore unblocked input");
|
||||
|
||||
step = 2;
|
||||
reset_input();
|
||||
icon_click_call = 3;
|
||||
result = flint_ui_draw_guide_overlay(test_guide(&step));
|
||||
expect(result.finished, "check button should finish guide on last step");
|
||||
expect(input_blocked, "finish button should restore blocked input");
|
||||
expect(!g_ui_input_blocked, "finish button should restore unblocked input");
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -1228,6 +1228,55 @@ test_delete_all_without_sync_account_does_not_queue_remote_deletes(void)
|
||||
remove_tree(root);
|
||||
}
|
||||
|
||||
static void
|
||||
test_deleted_habit_payload_clears_remote_days(void)
|
||||
{
|
||||
char root[512];
|
||||
InbeHabits habits;
|
||||
char deleted_id[INBE_STORAGE_ID_SIZE];
|
||||
char *payload;
|
||||
|
||||
make_clean_root(root, sizeof(root), "deleted-habit-payload");
|
||||
check_true("init deleted habit payload db", storage_init(root));
|
||||
storage_set_setting_text("sync_public_id", "test-public-id");
|
||||
storage_set_setting_text("sync_public_key", "test-public-key");
|
||||
storage_set_setting_text("sync_private_key", "test-private-key");
|
||||
|
||||
memset(&habits, 0, sizeof(habits));
|
||||
check_int("add deleted payload habit",
|
||||
habits_add_custom(&habits, "Cold shower",
|
||||
(Color){99, 196, 165, 255},
|
||||
INBE_HABIT_SYNC_NONE, 0),
|
||||
0);
|
||||
habit_set_day_count(&habits, 0, 20260618, 3);
|
||||
habits_save(&habits);
|
||||
payload = storage_build_sync_payload_json("test-public-id", "test-public-key");
|
||||
storage_free_sync_payload_json(payload);
|
||||
check_true("apply upload marker before delete",
|
||||
storage_apply_sync_response_json("{\"server_version\":1,\"server_state_hash\":\"h1\",\"changes\":{\"habits\":[],\"habit_days\":[],\"sessions\":[],\"meditation_logs\":[]}}"));
|
||||
|
||||
memset(&habits, 0, sizeof(habits));
|
||||
check_true("reload deleted payload habit", storage_habits_load(&habits));
|
||||
snprintf(deleted_id, sizeof(deleted_id), "%s", habits.items[0].id);
|
||||
habits_delete(&habits, 0);
|
||||
habits_save(&habits);
|
||||
|
||||
payload = storage_build_sync_payload_json("test-public-id", "test-public-key");
|
||||
check_true("deleted habit payload includes tombstone",
|
||||
payload != NULL &&
|
||||
strstr(payload, deleted_id) != NULL &&
|
||||
strstr(payload, "\"deleted_at\":0") == NULL);
|
||||
check_true("deleted habit payload clears habit day",
|
||||
payload != NULL &&
|
||||
strstr(payload, "\"habit_days\":[{\"habit_id\"") != NULL &&
|
||||
strstr(payload, "\"completed\":false") != NULL &&
|
||||
strstr(payload, "\"count\":0") != NULL);
|
||||
storage_free_sync_payload_json(payload);
|
||||
|
||||
storage_close();
|
||||
remove_tree(root);
|
||||
}
|
||||
|
||||
static void
|
||||
test_empty_initialized_habits_seed_meditation_on_startup(void)
|
||||
{
|
||||
@@ -1689,6 +1738,7 @@ main(void)
|
||||
test_import_conflict_prefers_data_over_empty();
|
||||
test_delete_all_resets_habits_to_empty_storage();
|
||||
test_delete_all_without_sync_account_does_not_queue_remote_deletes();
|
||||
test_deleted_habit_payload_clears_remote_days();
|
||||
test_import_modes_preserve_habits_and_settings_choice();
|
||||
test_legacy_zip_import();
|
||||
test_legacy_file_startup_migration();
|
||||
@@ -1725,12 +1775,8 @@ main(void)
|
||||
void
|
||||
TraceLog(int logLevel, const char *text, ...)
|
||||
{
|
||||
va_list args;
|
||||
(void)logLevel;
|
||||
va_start(args, text);
|
||||
vfprintf(stderr, text, args);
|
||||
fputc('\n', stderr);
|
||||
va_end(args);
|
||||
(void)text;
|
||||
}
|
||||
|
||||
bool
|
||||
|
||||
@@ -0,0 +1,463 @@
|
||||
#include "storage.h"
|
||||
|
||||
#include <dirent.h>
|
||||
#include <sqlite3.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static int g_failures = 0;
|
||||
static char g_data_root[1024] = "";
|
||||
|
||||
void
|
||||
data_init(void)
|
||||
{
|
||||
}
|
||||
|
||||
const char *
|
||||
data_root(void)
|
||||
{
|
||||
return g_data_root;
|
||||
}
|
||||
|
||||
void
|
||||
TraceLog(int log_level, const char *text, ...)
|
||||
{
|
||||
(void)log_level;
|
||||
(void)text;
|
||||
}
|
||||
|
||||
void
|
||||
sync_client_clear_auth_token(void)
|
||||
{
|
||||
}
|
||||
|
||||
char *
|
||||
LoadFileText(const char *file_name)
|
||||
{
|
||||
FILE *file;
|
||||
long size;
|
||||
char *text;
|
||||
|
||||
file = fopen(file_name, "rb");
|
||||
if(file == NULL)
|
||||
return NULL;
|
||||
if(fseek(file, 0, SEEK_END) != 0) {
|
||||
fclose(file);
|
||||
return NULL;
|
||||
}
|
||||
size = ftell(file);
|
||||
if(size < 0) {
|
||||
fclose(file);
|
||||
return NULL;
|
||||
}
|
||||
rewind(file);
|
||||
text = (char *)malloc((size_t)size + 1);
|
||||
if(text == NULL) {
|
||||
fclose(file);
|
||||
return NULL;
|
||||
}
|
||||
if(fread(text, 1, (size_t)size, file) != (size_t)size) {
|
||||
free(text);
|
||||
fclose(file);
|
||||
return NULL;
|
||||
}
|
||||
text[size] = '\0';
|
||||
fclose(file);
|
||||
return text;
|
||||
}
|
||||
|
||||
void
|
||||
UnloadFileText(char *text)
|
||||
{
|
||||
free(text);
|
||||
}
|
||||
|
||||
bool
|
||||
SaveFileData(const char *file_name, const void *data, int data_size)
|
||||
{
|
||||
FILE *file;
|
||||
int ok;
|
||||
|
||||
file = fopen(file_name, "wb");
|
||||
if(file == NULL)
|
||||
return 0;
|
||||
ok = fwrite(data, 1, (size_t)data_size, file) == (size_t)data_size;
|
||||
fclose(file);
|
||||
return ok;
|
||||
}
|
||||
|
||||
static void
|
||||
check_true(const char *label, int ok)
|
||||
{
|
||||
if(ok)
|
||||
return;
|
||||
fprintf(stderr, "FAIL %s\n", label);
|
||||
g_failures++;
|
||||
}
|
||||
|
||||
static void
|
||||
check_false(const char *label, int ok)
|
||||
{
|
||||
if(!ok)
|
||||
return;
|
||||
fprintf(stderr, "FAIL %s\n", label);
|
||||
g_failures++;
|
||||
}
|
||||
|
||||
static void
|
||||
check_int(const char *label, int got, int want)
|
||||
{
|
||||
if(got == want)
|
||||
return;
|
||||
fprintf(stderr, "FAIL %s: got %d, want %d\n", label, got, want);
|
||||
g_failures++;
|
||||
}
|
||||
|
||||
static void
|
||||
check_contains(const char *label, const char *text, const char *needle)
|
||||
{
|
||||
if(text != NULL && strstr(text, needle) != NULL)
|
||||
return;
|
||||
fprintf(stderr, "FAIL %s: missing %s in %s\n",
|
||||
label, needle, text != NULL ? text : "(null)");
|
||||
g_failures++;
|
||||
}
|
||||
|
||||
static void
|
||||
check_not_contains(const char *label, const char *text, const char *needle)
|
||||
{
|
||||
if(text == NULL || strstr(text, needle) == NULL)
|
||||
return;
|
||||
fprintf(stderr, "FAIL %s: unexpected %s in %s\n", label, needle, text);
|
||||
g_failures++;
|
||||
}
|
||||
|
||||
static int
|
||||
ensure_dir(const char *path)
|
||||
{
|
||||
struct stat st;
|
||||
if(stat(path, &st) == 0 && S_ISDIR(st.st_mode))
|
||||
return 1;
|
||||
return mkdir(path, 0700) == 0;
|
||||
}
|
||||
|
||||
static void
|
||||
remove_tree(const char *path)
|
||||
{
|
||||
DIR *dir = opendir(path);
|
||||
struct dirent *entry;
|
||||
|
||||
if(dir == NULL) {
|
||||
remove(path);
|
||||
return;
|
||||
}
|
||||
while((entry = readdir(dir)) != NULL) {
|
||||
char child[1024];
|
||||
if(strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0)
|
||||
continue;
|
||||
snprintf(child, sizeof(child), "%s/%s", path, entry->d_name);
|
||||
remove_tree(child);
|
||||
}
|
||||
closedir(dir);
|
||||
rmdir(path);
|
||||
}
|
||||
|
||||
static void
|
||||
make_clean_root(char *out, size_t out_size, const char *name)
|
||||
{
|
||||
snprintf(out, out_size, "/tmp/inbe-sync-review-test-%ld-%s",
|
||||
(long)getpid(), name);
|
||||
remove_tree(out);
|
||||
check_true("create test root", ensure_dir(out));
|
||||
snprintf(g_data_root, sizeof(g_data_root), "%s", out);
|
||||
}
|
||||
|
||||
static int
|
||||
exec_db_sql(const char *root, const char *sql)
|
||||
{
|
||||
char db_path[1024];
|
||||
sqlite3 *db = NULL;
|
||||
char *err = NULL;
|
||||
int ok;
|
||||
|
||||
snprintf(db_path, sizeof(db_path), "%s/inbe.db", root);
|
||||
if(sqlite3_open(db_path, &db) != SQLITE_OK || db == NULL)
|
||||
return 0;
|
||||
ok = sqlite3_exec(db, sql, NULL, NULL, &err) == SQLITE_OK;
|
||||
if(!ok && err != NULL) {
|
||||
fprintf(stderr, "SQL error: %s\n", err);
|
||||
sqlite3_free(err);
|
||||
}
|
||||
sqlite3_close(db);
|
||||
return ok;
|
||||
}
|
||||
|
||||
static int
|
||||
read_db_count(const char *root, const char *sql)
|
||||
{
|
||||
char db_path[1024];
|
||||
sqlite3 *db = NULL;
|
||||
sqlite3_stmt *stmt = NULL;
|
||||
int count = -1;
|
||||
|
||||
snprintf(db_path, sizeof(db_path), "%s/inbe.db", root);
|
||||
if(sqlite3_open(db_path, &db) != SQLITE_OK || db == NULL)
|
||||
return count;
|
||||
if(sqlite3_prepare_v2(db, sql, -1, &stmt, NULL) == SQLITE_OK &&
|
||||
sqlite3_step(stmt) == SQLITE_ROW)
|
||||
count = sqlite3_column_int(stmt, 0);
|
||||
sqlite3_finalize(stmt);
|
||||
sqlite3_close(db);
|
||||
return count;
|
||||
}
|
||||
|
||||
static void
|
||||
seed_local_data(const char *root)
|
||||
{
|
||||
check_true("seed local data",
|
||||
exec_db_sql(root,
|
||||
"INSERT INTO habits(id,user_id,name,color_r,color_g,color_b,"
|
||||
"sync_mode,sync_activity,counter_enabled,sort_order,deleted_at,updated_at)"
|
||||
"VALUES('local-habit',(SELECT id FROM users LIMIT 1),'Local Breath',10,20,30,0,0,1,1,0,1782300000);"
|
||||
"INSERT INTO habit_days(habit_id,local_date,completed,count,session_count,updated_at)"
|
||||
"VALUES('local-habit',20260624,1,4,0,1782300000);"
|
||||
"INSERT INTO sessions(id,user_id,started_at,local_date,topic,activity,source,"
|
||||
"imported_at,rounds_hash,deleted_at,updated_at)"
|
||||
"VALUES('local-session',(SELECT id FROM users LIMIT 1),1782300000,20260624,1,1,'test',1782300000,101,0,1782300000);"
|
||||
"INSERT INTO session_rounds(session_id,round_index,seconds)"
|
||||
"VALUES('local-session',0,40);"));
|
||||
}
|
||||
|
||||
static const char *
|
||||
remote_snapshot_response(void)
|
||||
{
|
||||
return "{"
|
||||
"\"server_version\":12,"
|
||||
"\"server_state_hash\":\"remote-hash-001\","
|
||||
"\"full_snapshot_required\":true,"
|
||||
"\"changes_complete\":false,"
|
||||
"\"changes\":{"
|
||||
"\"habits\":[{\"id\":\"remote-habit\",\"name\":\"Remote Breath\","
|
||||
"\"color_r\":90,\"color_g\":80,\"color_b\":70,\"sync_mode\":0,"
|
||||
"\"sync_activity\":0,\"counter_enabled\":1,\"sort_order\":1,"
|
||||
"\"deleted_at\":0,\"updated_at\":\"2026-06-24T10:00:00Z\"}],"
|
||||
"\"habit_days\":[{\"habit_id\":\"remote-habit\",\"local_date\":20260624,"
|
||||
"\"completed\":true,\"count\":7,\"updated_at\":\"2026-06-24T10:00:00Z\"}],"
|
||||
"\"sessions\":[{\"id\":\"remote-session\",\"started_at\":\"2026-06-24T10:00:00Z\","
|
||||
"\"local_date\":20260624,\"topic\":2,\"activity\":3,\"source\":\"lyra-test\","
|
||||
"\"rounds_hash\":202,\"deleted_at\":0,\"updated_at\":\"2026-06-24T10:00:00Z\","
|
||||
"\"rounds\":[{\"round_index\":0,\"hold_seconds\":55}]}],"
|
||||
"\"meditation_logs\":[]"
|
||||
"}"
|
||||
"}";
|
||||
}
|
||||
|
||||
static const char *
|
||||
deleted_only_remote_snapshot_response(void)
|
||||
{
|
||||
return "{"
|
||||
"\"server_version\":13,"
|
||||
"\"server_state_hash\":\"remote-hash-deleted\","
|
||||
"\"full_snapshot_required\":true,"
|
||||
"\"changes_complete\":false,"
|
||||
"\"changes\":{"
|
||||
"\"habits\":[],"
|
||||
"\"habit_days\":[],"
|
||||
"\"sessions\":[{\"id\":\"deleted-session\",\"started_at\":\"2026-06-24T10:00:00Z\","
|
||||
"\"local_date\":20260624,\"topic\":2,\"activity\":3,\"source\":\"lyra-test\","
|
||||
"\"rounds_hash\":202,\"deleted_at\":1782300000,\"updated_at\":\"2026-06-24T10:00:00Z\","
|
||||
"\"rounds\":[{\"round_index\":0,\"hold_seconds\":55}]}],"
|
||||
"\"meditation_logs\":[]"
|
||||
"}"
|
||||
"}";
|
||||
}
|
||||
|
||||
static void
|
||||
test_full_snapshot_waits_for_review(void)
|
||||
{
|
||||
char root[1024];
|
||||
char *local_detail = NULL;
|
||||
char *remote_detail = NULL;
|
||||
char *diff_detail = NULL;
|
||||
|
||||
make_clean_root(root, sizeof(root), "pending");
|
||||
check_true("init pending db", storage_init(root));
|
||||
seed_local_data(root);
|
||||
|
||||
check_true("apply review response",
|
||||
storage_apply_sync_response_json(remote_snapshot_response()));
|
||||
check_true("review pending", storage_sync_review_pending());
|
||||
check_int("local session preserved",
|
||||
read_db_count(root, "SELECT COUNT(*) FROM sessions WHERE id='local-session'"), 1);
|
||||
check_int("remote session not applied yet",
|
||||
read_db_count(root, "SELECT COUNT(*) FROM sessions WHERE id='remote-session'"), 0);
|
||||
check_int("local habit preserved",
|
||||
read_db_count(root, "SELECT COUNT(*) FROM habits WHERE id='local-habit'"), 1);
|
||||
check_int("remote habit not applied yet",
|
||||
read_db_count(root, "SELECT COUNT(*) FROM habits WHERE id='remote-habit'"), 0);
|
||||
|
||||
check_true("review detail builds",
|
||||
storage_sync_review_details(&local_detail, &remote_detail));
|
||||
check_contains("local detail session line", local_detail,
|
||||
"Meditation\n2026-06-24 11:20\nrounds 40s");
|
||||
check_contains("local detail habit day line", local_detail,
|
||||
"Habit days\nLocal Breath\n2026-06-24 count 4");
|
||||
check_contains("remote detail session line", remote_detail,
|
||||
"Unknown 3\n2026-06-24 10:00\nrounds 55s");
|
||||
check_contains("remote detail habit day line", remote_detail,
|
||||
"Habit days\nRemote Breath\n2026-06-24 count 7");
|
||||
check_true("review diff builds", storage_sync_review_diff(&diff_detail));
|
||||
check_contains("diff local session", diff_detail, "- Meditation");
|
||||
check_contains("diff remote session", diff_detail, "+ Unknown 3");
|
||||
check_contains("diff local habit day", diff_detail, "- Local Breath");
|
||||
check_contains("diff remote habit day", diff_detail, "+ Remote Breath");
|
||||
free(local_detail);
|
||||
free(remote_detail);
|
||||
free(diff_detail);
|
||||
|
||||
storage_close();
|
||||
remove_tree(root);
|
||||
}
|
||||
|
||||
static void
|
||||
test_review_ignores_deleted_remote_rows(void)
|
||||
{
|
||||
char root[1024];
|
||||
char *diff_detail = NULL;
|
||||
|
||||
make_clean_root(root, sizeof(root), "deleted-review");
|
||||
check_true("init deleted review db", storage_init(root));
|
||||
check_true("apply deleted review response",
|
||||
storage_apply_sync_response_json(deleted_only_remote_snapshot_response()));
|
||||
check_false("deleted-only review not pending",
|
||||
storage_sync_review_pending());
|
||||
check_true("deleted review json has no visible diff",
|
||||
!storage_sync_review_json_has_visible_diff(deleted_only_remote_snapshot_response()));
|
||||
check_true("deleted review diff builds",
|
||||
storage_sync_review_diff(&diff_detail));
|
||||
check_not_contains("deleted remote hidden from diff", diff_detail, "deleted-session");
|
||||
check_not_contains("deleted remote marker hidden from diff", diff_detail, "deleted");
|
||||
|
||||
free(diff_detail);
|
||||
storage_close();
|
||||
remove_tree(root);
|
||||
}
|
||||
|
||||
static void
|
||||
test_keep_local_requests_full_replace(void)
|
||||
{
|
||||
char root[1024];
|
||||
char *payload;
|
||||
|
||||
make_clean_root(root, sizeof(root), "keep-local");
|
||||
check_true("init keep local db", storage_init(root));
|
||||
seed_local_data(root);
|
||||
check_true("apply keep local review response",
|
||||
storage_apply_sync_response_json(remote_snapshot_response()));
|
||||
|
||||
check_true("keep local review choice", storage_apply_pending_sync_review(0));
|
||||
check_false("review cleared after keep local", storage_sync_review_pending());
|
||||
check_int("local session still present",
|
||||
read_db_count(root, "SELECT COUNT(*) FROM sessions WHERE id='local-session'"), 1);
|
||||
check_int("remote session still absent",
|
||||
read_db_count(root, "SELECT COUNT(*) FROM sessions WHERE id='remote-session'"), 0);
|
||||
|
||||
payload = storage_build_sync_payload_json("test-public-id", "test-public-key");
|
||||
check_contains("keep local full replace flag", payload, "\"full_sync_requested\":true");
|
||||
check_contains("keep local payload has local session", payload, "local-session");
|
||||
check_contains("keep local payload has local habit", payload, "local-habit");
|
||||
check_not_contains("keep local cleared stale server hash", payload, "last_server_state_hash");
|
||||
storage_free_sync_payload_json(payload);
|
||||
|
||||
storage_close();
|
||||
remove_tree(root);
|
||||
}
|
||||
|
||||
static void
|
||||
test_use_remote_replaces_local_data(void)
|
||||
{
|
||||
char root[1024];
|
||||
char *payload;
|
||||
|
||||
make_clean_root(root, sizeof(root), "use-remote");
|
||||
check_true("init use remote db", storage_init(root));
|
||||
seed_local_data(root);
|
||||
check_true("apply use remote review response",
|
||||
storage_apply_sync_response_json(remote_snapshot_response()));
|
||||
|
||||
check_true("use remote review choice", storage_apply_pending_sync_review(1));
|
||||
check_false("review cleared after use remote", storage_sync_review_pending());
|
||||
check_int("local session removed",
|
||||
read_db_count(root, "SELECT COUNT(*) FROM sessions WHERE id='local-session'"), 0);
|
||||
check_int("remote session applied",
|
||||
read_db_count(root, "SELECT COUNT(*) FROM sessions WHERE id='remote-session'"), 1);
|
||||
check_int("local habit removed",
|
||||
read_db_count(root, "SELECT COUNT(*) FROM habits WHERE id='local-habit'"), 0);
|
||||
check_int("remote habit applied",
|
||||
read_db_count(root, "SELECT COUNT(*) FROM habits WHERE id='remote-habit'"), 1);
|
||||
|
||||
payload = storage_build_sync_payload_json("test-public-id", "test-public-key");
|
||||
check_not_contains("use remote no full replace flag", payload, "full_sync_requested");
|
||||
check_contains("use remote remembers server hash", payload,
|
||||
"\"last_server_state_hash\":\"remote-hash-001\"");
|
||||
storage_free_sync_payload_json(payload);
|
||||
|
||||
storage_close();
|
||||
remove_tree(root);
|
||||
}
|
||||
|
||||
static void
|
||||
test_normal_response_records_server_hash(void)
|
||||
{
|
||||
char root[1024];
|
||||
char *payload;
|
||||
const char *response =
|
||||
"{"
|
||||
"\"server_version\":5,"
|
||||
"\"server_state_hash\":\"normal-hash-001\","
|
||||
"\"account_alias\":\"waozi\","
|
||||
"\"changes\":{\"habits\":[],\"habit_days\":[],\"sessions\":[],\"meditation_logs\":[]}"
|
||||
"}";
|
||||
|
||||
make_clean_root(root, sizeof(root), "normal");
|
||||
check_true("init normal db", storage_init(root));
|
||||
check_true("apply normal response", storage_apply_sync_response_json(response));
|
||||
check_false("normal response no review", storage_sync_review_pending());
|
||||
check_contains("normal response saves alias",
|
||||
storage_get_setting_text("sync_account_alias"), "waozi");
|
||||
|
||||
payload = storage_build_sync_payload_json("test-public-id", "test-public-key");
|
||||
check_contains("normal response hash in next payload", payload,
|
||||
"\"last_server_state_hash\":\"normal-hash-001\"");
|
||||
check_not_contains("normal response no full replace", payload, "full_sync_requested");
|
||||
storage_free_sync_payload_json(payload);
|
||||
|
||||
storage_close();
|
||||
remove_tree(root);
|
||||
}
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
setenv("TZ", "UTC", 1);
|
||||
tzset();
|
||||
|
||||
test_full_snapshot_waits_for_review();
|
||||
test_review_ignores_deleted_remote_rows();
|
||||
test_keep_local_requests_full_replace();
|
||||
test_use_remote_replaces_local_data();
|
||||
test_normal_response_records_server_hash();
|
||||
|
||||
if(g_failures != 0) {
|
||||
fprintf(stderr, "%d failures\n", g_failures);
|
||||
return 1;
|
||||
}
|
||||
printf("sync review tests passed\n");
|
||||
return 0;
|
||||
}
|
||||
@@ -3,8 +3,8 @@
|
||||
IDI_APP_ICON ICON "inbe.ico"
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,5,2,0
|
||||
PRODUCTVERSION 1,5,2,0
|
||||
FILEVERSION 1,5,6,0
|
||||
PRODUCTVERSION 1,5,6,0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
@@ -21,11 +21,11 @@ BEGIN
|
||||
BEGIN
|
||||
VALUE "CompanyName", "waozi"
|
||||
VALUE "FileDescription", "Inner Breeze"
|
||||
VALUE "FileVersion", "1.5.2"
|
||||
VALUE "FileVersion", "1.5.6"
|
||||
VALUE "InternalName", "inbe"
|
||||
VALUE "OriginalFilename", "inbe-windows-x86_64.exe"
|
||||
VALUE "ProductName", "Inner Breeze"
|
||||
VALUE "ProductVersion", "1.5.2"
|
||||
VALUE "ProductVersion", "1.5.6"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
|
||||