Compare commits

..
192 Commits
Author SHA1 Message Date
waozixyz ffc7577ddc reduce apk mess 2026-06-18 11:56:47 -03:00
waozixyz b577e8411b fix gituhb action 2026-06-18 11:45:56 -03:00
waozixyz 10103c82a0 Build release artifacts without Nix 2026-06-18 11:04:08 -03:00
waozixyz 4e7c737c1c Run CI tests without Nix 2026-06-18 02:33:08 -03:00
waozixyz 6c96e8a119 split up workflows 2026-06-18 01:59:50 -03:00
waozixyz 87829c5dd6 improve github action 2026-06-18 01:54:01 -03:00
waozixyz e736bb7ec7 improve github actino 2026-06-18 01:44:45 -03:00
waozixyz 3236a6176a fix audio linux 2026-06-18 01:30:30 -03:00
waozixyz fae1cb89bb multi platform build on gh 2026-06-18 01:18:48 -03:00
waozixyz 7b01f675a7 refactor practices 2026-06-18 01:11:15 -03:00
waozixyz beefec7df0 cleanup and refactor 2026-06-17 23:12:37 -03:00
waozixyz f8ee130b45 fix improt web 2026-06-17 19:32:00 -03:00
waozixyz f12ef05421 update version 2026-06-17 18:50:36 -03:00
waozixyz 1732b31031 improve and fix improt 2026-06-17 18:50:24 -03:00
waozixyz b14ca1c8c9 fix issues with runtime assets 2026-06-17 16:43:48 -03:00
waozixyz 9466bf02ed fix no of assets 2026-06-17 16:33:01 -03:00
waozixyz acbd43bc65 bug fixes 2026-06-17 16:30:25 -03:00
waozixyz 06d79002e1 fix appimage 2026-06-17 15:36:27 -03:00
waozixyz 2db5045efb fix merge import 2026-06-17 13:47:05 -03:00
waozixyz 0f6f40cb0a fix orientation change 2026-06-17 13:37:38 -03:00
waozixyz b9ec755e1f bug fixes 2026-06-17 13:21:00 -03:00
waozixyz fc75410dea improve weelky view and dropdowns 2026-06-17 11:46:23 -03:00
waozixyz 4083893ddc fix improt issues and add packaging for appimages 2026-06-17 11:18:21 -03:00
waozixyz 07a2315353 fix font issues mobile 2026-06-17 09:43:41 -03:00
waozixyz 195eef42a9 fix clipping 2026-06-17 09:04:07 -03:00
waozixyz e22ae0f8aa bug fixes, otf chop for 8px 2026-06-17 01:19:52 -03:00
waozixyz 460ac28e0a improve settings page 2026-06-16 23:10:41 -03:00
waozixyz 40b0121c81 improve settings page 2026-06-16 23:04:59 -03:00
waozixyz f49dbc2015 refactor code base 2026-06-16 22:46:15 -03:00
waozixyz bab61346be better tracker managemnt and practice screenr 2026-06-16 22:27:04 -03:00
waozixyz 2c9348c52a refactor tracker and themes 2026-06-16 16:18:45 -03:00
waozixyz 209be9e78b refactor to habits screen 2026-06-16 15:17:06 -03:00
waozixyz 28a5d8fa51 refactor 2026-06-16 11:01:22 -03:00
waozixyz d356cc078f cleaner icon loading 2026-06-16 00:35:29 -03:00
waozixyz e31ff91168 more cleanup 2026-06-14 14:46:27 -03:00
waozixyz 7728a6327e unify icon system 2026-06-14 14:35:54 -03:00
waozixyz 945943dceb simplify play butotn 2026-06-14 12:45:01 -03:00
waozixyz e567ba21c2 cleanup and fixes 2026-06-14 11:40:56 -03:00
waozixyz 0ddb4ddfb8 cleanup 2026-06-14 01:05:09 -03:00
waozixyz 27e1902958 cleanup theme usage 2026-06-14 00:49:25 -03:00
waozixyz 2e83575485 cleanup and add tests 2026-06-13 23:31:30 -03:00
waozixyz bf26a1056f add changelog 2026-06-13 21:47:21 -03:00
waozixyz 3b44d1bc1a improve file browser 2026-06-13 21:43:41 -03:00
waozixyz cafe058420 better data management 2026-06-13 21:11:44 -03:00
waozixyz b0a031136b merge with flint 2026-06-13 21:11:30 -03:00
waozixyz 06d403ed63 add round label 2026-06-12 23:01:59 -03:00
waozixyz 1d0009958d Update Flint web dist packaging 2026-06-12 21:49:08 -03:00
waozixyz 2c0ac20ce3 use latset flint 2026-06-12 11:33:50 -03:00
waozixyz 9181c91a3a fix workflow 2026-06-12 10:34:36 -03:00
waozixyz 63e790f96a fix make 2026-06-12 10:25:56 -03:00
waozixyz aef5f5441b update version 2026-06-12 09:58:40 -03:00
waozixyz 827d5e350b cleanup 2026-06-12 09:56:44 -03:00
waozixyz f64195ec1d clean flint version 2026-06-12 00:42:22 -03:00
waozixyz 60b699f28b flint cli fully working 2026-06-12 00:11:22 -03:00
waozixyz 85b9d3daf5 use flint for cross building 2026-06-12 00:07:56 -03:00
waozixyz 89bb5a63ca clean windows build 2026-06-11 23:45:54 -03:00
waozixyz 94c004b923 Embed runtime assets in desktop builds 2026-06-11 22:20:24 -03:00
waozixyz 9822180288 upload all versions on itch 2026-06-11 16:48:08 -03:00
waozixyz 0976fb82bc update version 2026-06-11 13:06:54 -03:00
waozixyz 8353f49f27 bug fixes and improve setting management 2026-06-11 13:03:51 -03:00
waozixyz 07b46d7bf0 fix versioning 2026-06-10 08:41:39 -03:00
waozixyz 99375c9c4b fix history page 2026-06-10 08:38:18 -03:00
waozixyz 1381311e02 simplify scripts 2026-06-10 00:22:12 -03:00
waozixyz 595f239015 bug fix 2026-06-10 00:18:25 -03:00
waozixyz d43a8de800 fix action 2026-06-09 23:57:51 -03:00
waozixyz 894f8f7da8 Fix web file dialog guard 2026-06-09 23:51:25 -03:00
waozixyz 629aa739f6 Fix font glyphs and web builds 2026-06-09 23:48:13 -03:00
waozixyz 323be33ec4 add submodule 2026-06-09 23:33:40 -03:00
waozixyz 64480683d6 bug fixes and locale fixes 2026-06-09 23:30:10 -03:00
waozixyz 2a4d93f3b6 rm icons 2026-06-09 23:14:59 -03:00
waozixyz 61f5a75634 improve icon setup 2026-06-09 23:14:41 -03:00
waozixyz 085ed5393d import working on linux 2026-06-09 21:55:06 -03:00
waozixyz 015843c4d6 wip file import 2026-06-09 21:41:29 -03:00
waozixyz 5d335ff637 update makefile 2026-06-09 13:36:16 -03:00
waozixyz 61731bd680 add new version 2026-06-09 13:05:43 -03:00
waozixyz e3f6a22d24 fine grained sound, better language support 2026-06-09 11:13:11 -03:00
waozixyz e00245e212 clean text 2026-06-09 00:13:33 -03:00
waozixyz 951309c75f add font loading and asian languages 2026-06-08 23:18:52 -03:00
waozixyz c3d36d8d28 Use Flint UI widgets directly 2026-06-08 15:21:13 -03:00
waozixyz a9b615614b Bump Flint for UI widgets 2026-06-08 15:20:42 -03:00
waozixyz 0fb8630dc9 Bump Flint for DPI cache 2026-06-08 15:09:21 -03:00
waozixyz bda1bf536d Use Flint text layout directly 2026-06-08 15:05:08 -03:00
waozixyz 7e27498379 Bump Flint for text layout 2026-06-08 15:03:28 -03:00
waozixyz 08ef56d788 Move generic UI helpers into flint 2026-06-08 14:57:13 -03:00
waozixyz a3f92aaf5c Update flint theme catalog behavior 2026-06-08 14:21:58 -03:00
waozixyz 447e2b6187 Use flint catalog for theme previews 2026-06-08 14:20:36 -03:00
waozixyz 72fd21dad0 Register themes through flint catalog 2026-06-08 11:04:19 -03:00
waozixyz f9da10204d Use vendored flint UI and themes 2026-06-08 10:54:50 -03:00
waozixyz 1549f5e3bc cleaner makefile 2026-06-08 00:40:01 -03:00
waozixyz 0c650fc94f improved settings page 2026-06-04 22:50:14 -03:00
waozixyz 52716b1edb rm sync 2026-06-04 16:02:20 -03:00
waozixyz 9e40eda25e wip sync data 2026-06-03 00:17:29 -03:00
waozixyz 92985e8a03 fixes for web and version update 2026-06-01 17:00:10 -03:00
waozixyz 5aedde8d80 add on screen keyboard 2026-06-01 16:33:26 -03:00
waozixyz eb25d437a4 improve edit filed 2026-06-01 12:42:01 -03:00
waozixyz 7690e04429 improve tutorial, results saving and statistics 2026-06-01 12:29:36 -03:00
waozixyz 07ca47ee7c add multilingual 2026-05-31 06:08:23 -03:00
waozixyz 7c3275fee3 add progressive speed up for first round 2026-05-30 23:13:41 -03:00
waozixyz 249702ca32 fix for non android plat 2026-05-30 18:59:52 -03:00
waozixyz 2797b3371d implement wakelock 2026-05-30 18:43:50 -03:00
waozixyz bc7514406b implement wakelock 2026-05-30 11:28:58 -03:00
waozixyz 79bcf2c328 rm comments 2026-05-30 00:48:04 -03:00
waozixyz b5962360c1 improve dpi settings 2026-05-30 00:28:07 -03:00
waozixyz 83ecc17423 improve website 2026-05-30 00:19:07 -03:00
waozixyz f01c4d7d81 cleanup code and improve site 2026-05-29 23:57:23 -03:00
waozixyz 03b714aa64 clean up instructions 2026-05-29 20:04:38 -03:00
waozixyz 5f116c29cb fi xscript 2026-05-29 15:07:05 -03:00
waozixyz cdbdcd20cb add copy assets script 2026-05-29 14:57:23 -03:00
waozixyz 6a3362f59e fix padding 2026-05-29 14:53:29 -03:00
waozixyz 43013c64ab massive layout improvements 2026-05-29 14:50:11 -03:00
waozixyz 3f86abb35a update cmake 2026-05-29 13:31:44 -03:00
waozixyz 3e75089266 implement text reflow 2026-05-29 13:29:54 -03:00
waozixyz d51fdea355 update workflow 2026-05-29 12:43:31 -03:00
waozixyz 5bc63e7b13 rm unsigned apk 2026-05-29 12:05:40 -03:00
waozixyz 03e1fccab3 fix gradle for github action 2026-05-29 11:38:47 -03:00
waozixyz ed2e52c13a mistake in workflow 2026-05-29 11:34:46 -03:00
waozixyz 616ef0cb09 fix workflow 2026-05-29 11:33:31 -03:00
waozixyz e7debfc68f update workflow 2026-05-29 11:31:34 -03:00
waozixyz 796f1393de udptae version 2026-05-29 11:27:47 -03:00
waozixyz 99567e68c1 add image fallback 2026-05-29 11:19:29 -03:00
waozixyz f714674e62 bug fix 2026-05-29 09:20:11 -03:00
waozixyz 3d75216483 release fix 2026-05-29 09:14:19 -03:00
waozixyz ac485ea355 fix inset 2026-05-29 09:11:47 -03:00
waozixyz ad59bb0c51 increase inset 2026-05-29 07:50:08 -03:00
waozixyz efbeec104d move scripts 2026-05-29 07:26:04 -03:00
waozixyz f9d109182d fix data issue 2026-05-29 07:23:00 -03:00
waozixyz ccb8c2f2b5 bug fix 2026-05-28 23:58:22 -03:00
waozixyz 2405fb2fcf improve website 2026-05-28 18:48:19 -03:00
waozixyz 8c25a6630b add itch script 2026-05-28 18:14:25 -03:00
waozixyz 97dd375822 rm dependency tracker 2026-05-28 16:31:51 -03:00
waozixyz 93103cc0ea fix bug 2026-05-28 14:44:10 -03:00
waozixyz a0ded8e537 fix script 2026-05-28 14:38:41 -03:00
waozixyz 1f8ada56f9 fastlane changelog 2026-05-28 14:37:35 -03:00
waozixyz e80097fb83 fix versioning 2026-05-28 14:35:31 -03:00
waozixyz 4e0dedf97d add descriptions 2026-05-28 12:37:07 -03:00
waozixyz 675b2c260a fix dropdown passthrough 2026-05-28 10:48:38 -03:00
waozixyz 463c858565 update version 2026-05-28 10:20:02 -03:00
waozixyz 8b739fcbd4 make file sharing work 2026-05-28 10:19:50 -03:00
waozixyz 7b23749f7d implemnet clean zip export 2026-05-28 04:14:31 -03:00
waozixyz 3c3eb9e0f2 wip data management 2026-05-28 02:55:45 -03:00
waozixyz a896ad4f55 refactor code 2026-05-28 02:34:07 -03:00
waozixyz 19ad586e0c add return button func on android 2026-05-28 01:12:11 -03:00
waozixyz bdb1e92a51 new test 2026-05-27 18:38:48 -03:00
waozixyz 8d1cf2b8f9 improve build for fdroid 2026-05-27 18:23:09 -03:00
waozixyz 6547bd9636 cleaner relesae 2026-05-27 15:41:55 -03:00
waozixyz 8d9117bd16 use correct tag 2026-05-27 15:33:30 -03:00
waozixyz 695aafa231 auto tag 2026-05-27 15:29:11 -03:00
waozixyz 88598d830f bug fix 2026-05-27 15:18:55 -03:00
waozixyz 0be5f925a7 enable signing 2026-05-27 15:14:02 -03:00
waozixyz 39096d0dd4 add fastlane metadata 2026-05-27 15:04:40 -03:00
waozixyz 2242553194 prepare for f-droid 2026-05-27 14:24:11 -03:00
waozixyz 5d6985b2b5 finish migration 2026-05-27 14:17:17 -03:00
waozixyz ba216da8e6 bug fixes 2026-05-27 14:01:19 -03:00
waozixyz 13c469166a bug fixes 2026-05-27 13:51:21 -03:00
waozixyz e1298bd262 track drodi stuff correctyl 2026-05-27 13:49:12 -03:00
waozixyz 6c1eb327e3 add waozi icons 2026-05-27 13:12:46 -03:00
waozixyz 3ff05eac4e add flake 2026-05-27 13:03:39 -03:00
waozixyz 93f1bae5b7 add cherry theme andbug fixes 2026-05-27 11:45:27 -03:00
waozixyz 896f0b1c22 implement theming 2026-05-27 00:48:45 -03:00
waozixyz 615e32b0c6 add version upgrade script 2026-05-26 16:15:15 -03:00
waozixyz 77093f27a0 update version 2026-05-26 10:52:06 -03:00
waozixyz c13b7e743d bug fixes 2026-05-26 10:45:01 -03:00
waozixyz 5e61ef5351 improve scaling 2026-05-26 10:18:06 -03:00
waozixyz 79f44d353b add sounds 2026-05-25 21:52:20 -03:00
waozixyz e22e3f98ef fix androdi scaling 2026-05-25 20:24:16 -03:00
waozixyz 14d4594d71 improve mobile view 2026-05-25 14:24:07 -03:00
waozixyz 899500307c finish inbe basic 2026-05-25 12:44:40 -03:00
waozixyz 50527f15b8 cascading windows 2026-05-24 20:57:08 -03:00
waozixyz 94218efc5e fix web shell 2026-05-24 20:27:27 -03:00
waozixyz cf9ff9fb1f improve android inbe 2026-05-24 16:08:10 -03:00
waozixyz 81410ea4ae cleanup 2026-05-23 23:58:31 -03:00
waozixyz 2add9f0f30 unify flake 2026-05-23 23:41:11 -03:00
waozixyz 8bbc5625b7 add lotus 2026-05-23 23:18:56 -03:00
waozixyz ccc2032c50 wip lotus 2026-05-23 18:39:06 -03:00
waozixyz df3d04fa26 cross compile to windows 2026-05-23 13:19:31 -03:00
waozixyz 4c5c76e51e reorg 2026-05-23 10:10:56 -03:00
waozixyz a3db764783 clean and replace with ray 2026-05-23 09:34:33 -03:00
waozixyz 80b2214af3 testray 2026-05-23 08:42:59 -03:00
waozixyz 96ef714ca8 simplify linux version 2026-05-23 00:35:12 -03:00
waozixyz d808bdf985 improve icons 2026-05-22 22:32:32 -03:00
waozixyz c448e5d429 clean bulid and native linux 2026-05-22 22:09:12 -03:00
waozixyz d592c943f0 add banner image for inbe 2026-05-22 10:40:47 -03:00
waozixyz d90336d710 complete basic inner breeze breathing cycle 2026-05-22 09:40:52 -03:00
waozixyz c135464530 drawing primitives, buttons 2026-05-21 23:36:02 -03:00
waozixyz 45a360f498 use liblotus 2026-05-21 22:33:06 -03:00
waozixyz 0fad496a0e stared liblotus 2026-05-21 22:01:57 -03:00
waozixyz 7642a146cc simple android fb manipulation 2026-05-21 16:47:37 -03:00
waozixyz d1633381f4 add results to wasm4 inbe 2026-05-21 14:25:06 -03:00
waozixyz 2825a41d02 cleanup 2026-05-21 10:14:45 -03:00
waozixyz c86d2da631 bug fixes 2026-05-21 02:58:48 -03:00
waozixyz 99d2433283 add subdomains 2026-05-21 02:46:23 -03:00
waozixyz 1650d50c72 rename and refactor 2026-05-21 02:35:11 -03:00
91 changed files with 1836 additions and 10448 deletions

No files matched your search

-12
View File
@@ -1,12 +0,0 @@
build-essential
ca-certificates
curl
libcurl4-openssl-dev
libdrm-dev
libegl1-mesa-dev
libgbm-dev
libgles2-mesa-dev
libsdl2-dev
patchelf
pkg-config
zip
+13 -17
View File
@@ -80,8 +80,6 @@ jobs:
name: Build Linux
runs-on: ubuntu-latest
needs: test
env:
APT_CACHE_DIR: /tmp/apt-cache
steps:
- name: Checkout Repository
@@ -90,24 +88,22 @@ jobs:
submodules: recursive
fetch-depth: 0
- name: Cache Linux apt packages
uses: actions/cache@v4
with:
path: ${{ env.APT_CACHE_DIR }}
key: linux-apt-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('.github/apt/linux-packages.txt') }}
restore-keys: |
linux-apt-${{ runner.os }}-${{ runner.arch }}-
- name: Install Linux Dependencies
run: |
set -euo pipefail
mapfile -t packages < .github/apt/linux-packages.txt
mkdir -p "$APT_CACHE_DIR/partial"
sudo apt-get update
sudo apt-get \
-o Dir::Cache::archives="$APT_CACHE_DIR" \
install -y "${packages[@]}"
sudo chown -R "$USER:$USER" "$APT_CACHE_DIR"
sudo apt-get install -y \
build-essential \
ca-certificates \
curl \
libcurl4-openssl-dev \
libdrm-dev \
libegl1-mesa-dev \
libgbm-dev \
libgles2-mesa-dev \
libsdl2-dev \
patchelf \
pkg-config \
zip
- name: Install AppImage Tools
run: |
-1
View File
@@ -12,7 +12,6 @@
.cache/
*.wasm
build/
vendor-builds/
node_modules
*.nix-defexpr
*.npm
-6
View File
@@ -10,9 +10,3 @@
[submodule "vendor/sqlite"]
path = vendor/sqlite
url = https://github.com/sqlite/sqlite
[submodule "vendor/liboqs"]
path = vendor/liboqs
url = https://github.com/open-quantum-safe/liboqs.git
[submodule "vendor/curl"]
path = vendor/curl
url = https://github.com/curl/curl.git
-29
View File
@@ -1,33 +1,4 @@
# Changelog
## [1.4.3] - 2026-06-20
### Fixed
- Refresh expired native sync auth tokens before sending queued changes.
- Require first-time meditation users to continue through the tutorial before starting.
## [1.4.2] - 2026-06-20
### Fixed
- Improve sync auth, websocket reconnects, and queued habit/session updates.
- Reduce SQLite-related UI flicker and speed up bulk import sync queueing.
- Fixed dropdown menus so temporary option lists cannot crash theme/device selection.
- Fixed Linux test and release builds to link against the vendored curl library path.
## [1.4.1] - 2026-06-19
### Changed
- Improve account management
## [1.4.0] - 2026-06-19
### Added
- optional sync client, offline account creation
- simplify tutorial
## [1.3.6] - 2026-06-18
### Fixed
- Fixed Tickmate `.db` imports so zero-based months map correctly and long habit histories load without dropping later dates.
## [1.3.5] - 2026-06-18
### Fixed
- Improved Android data import for `.db` backups, weekly habit rows, and import conflict handling.
## [1.3.4] - 2026-06-18
### Changed
- Reorganized WHM and Meditation into practice-owned modules for cleaner code boundaries.
+45 -298
View File
@@ -6,7 +6,6 @@ ANDROID_APP_ID := xyz.waozi.inbe
ANDROID_ACTIVITY := xyz.waozi.inbe.MainActivity
CC ?= gcc
CMAKE ?= $(shell if [ -x /usr/bin/cmake ]; then echo /usr/bin/cmake; else command -v cmake; fi)
GRADLE ?= gradle
ARCH := $(shell uname -m)
ANDROID_KEYSTORE ?= $(HOME)/.android/flint-release.keystore
@@ -16,7 +15,6 @@ BUILD_DIR := build
BUILD_OBJ_DIR := $(BUILD_DIR)/obj
BUILD_BIN_DIR := $(BUILD_DIR)/bin
BUILD_DIST_DIR := $(BUILD_DIR)/dist
VENDOR_BUILD_DIR := vendor-builds
LINUX_OBJ_DIR := $(BUILD_OBJ_DIR)/linux
LINUX_BIN_DIR := $(BUILD_BIN_DIR)/linux
LINUX_DIST_DIR := $(BUILD_DIST_DIR)/linux
@@ -32,42 +30,29 @@ WINDOWS_DIST_DIR := $(BUILD_DIST_DIR)/windows
ANDROID_BUILD_DIR := $(BUILD_DIR)/android
WEB_OBJ_DIR := $(BUILD_OBJ_DIR)/web
WEB_DIST_DIR := $(BUILD_DIST_DIR)/web
CHROME_WEB_STORE_DIR := $(BUILD_DIST_DIR)/chrome-web-store
VERSION_FILE := src/core/version.h
APP_VERSION := $(shell sed -n 's/^#define INBE_VERSION_STRING "\([^"]*\)".*/\1/p' $(VERSION_FILE) 2>/dev/null)
RAYLIB_DIR := vendor/raylib/src
RAYLIB_BUILD_DIR := $(VENDOR_BUILD_DIR)/linux/$(ARCH)/raylib
RAYLIB_BUILD_DIR := $(LINUX_OBJ_DIR)/$(ARCH)/native/raylib
RAYLIB_A := $(RAYLIB_BUILD_DIR)/libraylib.a
WIN64_ARCH := x86_64
WIN64_CC ?= $(or $(WIN_CC),x86_64-w64-mingw32-gcc)
WIN64_AR ?= $(or $(WIN_AR),x86_64-w64-mingw32-ar)
WIN64_RANLIB ?= $(or $(WIN_RANLIB),x86_64-w64-mingw32-ranlib)
WIN64_STRIP ?= $(or $(WIN_STRIP),x86_64-w64-mingw32-strip)
WIN64_CC_PATH := $(shell command -v $(WIN64_CC) 2>/dev/null || printf '%s' $(WIN64_CC))
WIN64_AR_PATH := $(shell command -v $(WIN64_AR) 2>/dev/null || printf '%s' $(WIN64_AR))
WIN64_RANLIB_PATH := $(shell command -v $(WIN64_RANLIB) 2>/dev/null || printf '%s' $(WIN64_RANLIB))
WIN32_ARCH := i686
WIN32_CC ?= i686-w64-mingw32-gcc
WIN32_AR ?= i686-w64-mingw32-ar
WIN32_RANLIB ?= i686-w64-mingw32-ranlib
WIN32_STRIP ?= i686-w64-mingw32-strip
WIN32_CC_PATH := $(shell command -v $(WIN32_CC) 2>/dev/null || printf '%s' $(WIN32_CC))
WIN32_AR_PATH := $(shell command -v $(WIN32_AR) 2>/dev/null || printf '%s' $(WIN32_AR))
WIN32_RANLIB_PATH := $(shell command -v $(WIN32_RANLIB) 2>/dev/null || printf '%s' $(WIN32_RANLIB))
WIN64_RAYLIB_BUILD_DIR := $(VENDOR_BUILD_DIR)/windows/$(WIN64_ARCH)/raylib
WIN64_RAYLIB_BUILD_DIR := $(WINDOWS_OBJ_DIR)/$(WIN64_ARCH)/raylib
WIN64_RAYLIB_A := $(WIN64_RAYLIB_BUILD_DIR)/libraylib.a
WIN32_RAYLIB_BUILD_DIR := $(VENDOR_BUILD_DIR)/windows/$(WIN32_ARCH)/raylib
WIN32_RAYLIB_BUILD_DIR := $(WINDOWS_OBJ_DIR)/$(WIN32_ARCH)/raylib
WIN32_RAYLIB_A := $(WIN32_RAYLIB_BUILD_DIR)/libraylib.a
WIN64_CURL_BUILD_DIR := $(VENDOR_BUILD_DIR)/windows/$(WIN64_ARCH)/curl
WIN64_CURL_INCLUDE_DIR := $(WIN64_CURL_BUILD_DIR)/include
WIN64_CURL_A := $(WIN64_CURL_BUILD_DIR)/lib/libcurl.a
WIN32_CURL_BUILD_DIR := $(VENDOR_BUILD_DIR)/windows/$(WIN32_ARCH)/curl
WIN32_CURL_INCLUDE_DIR := $(WIN32_CURL_BUILD_DIR)/include
WIN32_CURL_A := $(WIN32_CURL_BUILD_DIR)/lib/libcurl.a
WEB_RAYLIB_BUILD_DIR := $(VENDOR_BUILD_DIR)/web/raylib
WEB_RAYLIB_BUILD_DIR := $(WEB_OBJ_DIR)/raylib
WEB_RAYLIB_A := $(WEB_RAYLIB_BUILD_DIR)/libraylib.web.a
RAYLIB_SOURCES := $(shell find $(RAYLIB_DIR) -type f \( -name '*.c' -o -name '*.h' \))
RAYLIB_SOURCES := $(wildcard $(RAYLIB_DIR)/*.c) $(wildcard $(RAYLIB_DIR)/*.h)
FLINT_DIR := flint
FLINT_ICON_FILES := $(wildcard $(FLINT_DIR)/icons/*.png)
@@ -76,43 +61,19 @@ FLINT_SRCS := $(filter-out $(FLINT_ICON_ASSETS_C),$(wildcard $(FLINT_DIR)/src/*.
FLINT_WEB_SRCS := $(filter-out $(FLINT_DIR)/src/flint_file_dialog.c,$(FLINT_SRCS))
FLINT_WINDOWS_SRCS := $(filter-out $(FLINT_DIR)/src/flint_file_dialog.c,$(FLINT_SRCS))
FLINT_INCLUDE := -I$(FLINT_DIR)/include
CURL_DIR := vendor/curl
CURL_BUILD_DIR := $(VENDOR_BUILD_DIR)/linux/$(ARCH)/curl
CURL_INCLUDE_DIR := $(CURL_BUILD_DIR)/include
CURL_LIB_DIR := $(CURL_BUILD_DIR)/lib64
CURL_SO := $(CURL_LIB_DIR)/libcurl.so
CURL_PROTOCOL_CHECK := $(CURL_BUILD_DIR)/.protocols-ok
OPENSSL_ROOT_DIR ?= $(shell pkg-config --variable=prefix openssl 2>/dev/null)
OPENSSL_CMAKE_OPT := $(if $(strip $(OPENSSL_ROOT_DIR)),-DOPENSSL_ROOT_DIR=$(OPENSSL_ROOT_DIR),)
OPENSSL_INCLUDE_CMAKE_OPT := $(if $(strip $(OPENSSL_INCLUDE_DIR)),-DOPENSSL_INCLUDE_DIR=$(OPENSSL_INCLUDE_DIR),)
OPENSSL_SSL_CMAKE_OPT := $(if $(strip $(OPENSSL_SSL_LIBRARY)),-DOPENSSL_SSL_LIBRARY=$(OPENSSL_SSL_LIBRARY),)
OPENSSL_CRYPTO_CMAKE_OPT := $(if $(strip $(OPENSSL_CRYPTO_LIBRARY)),-DOPENSSL_CRYPTO_LIBRARY=$(OPENSSL_CRYPTO_LIBRARY),)
OPENSSL_LIB_DIR := $(patsubst %/,%,$(dir $(OPENSSL_SSL_LIBRARY)))
OPENSSL_LDLIBS := $(if $(strip $(OPENSSL_SSL_LIBRARY) $(OPENSSL_CRYPTO_LIBRARY)),-Xlinker -rpath -Xlinker $(OPENSSL_LIB_DIR) $(OPENSSL_SSL_LIBRARY) $(OPENSSL_CRYPTO_LIBRARY),$(or $(shell pkg-config --libs openssl 2>/dev/null),-lssl -lcrypto))
FLINT_CURL_CFLAGS := -I$(CURL_INCLUDE_DIR)
FLINT_CURL_LDLIBS := -L$(CURL_LIB_DIR) -Wl,-rpath,$(abspath $(CURL_LIB_DIR)) -lcurl $(OPENSSL_LDLIBS)
FLINT_CURL_VERSION_NUM ?= $(shell printf '%s\n' '#include <curl/curlver.h>' 'LIBCURL_VERSION_NUM' | $(CC) -I$(CURL_DIR)/include -E -P - 2>/dev/null | tail -n 1)
FLINT_CURL_VERSION_HEX := $(patsubst 0x%,%,$(FLINT_CURL_VERSION_NUM))
FLINT_CURL_CFLAGS ?= $(shell pkg-config --cflags libcurl 2>/dev/null || curl-config --cflags 2>/dev/null)
FLINT_CURL_LDLIBS ?= $(shell pkg-config --libs libcurl 2>/dev/null || curl-config --libs 2>/dev/null)
SQLITE_DIR := vendor/sqlite
SQLITE_BUILD_DIR := $(VENDOR_BUILD_DIR)/sqlite
SQLITE_BUILD_DIR := $(BUILD_OBJ_DIR)/sqlite
SQLITE_AMALGAMATION_C := $(SQLITE_BUILD_DIR)/sqlite3.c
SQLITE_AMALGAMATION_H := $(SQLITE_BUILD_DIR)/sqlite3.h
SQLITE_SRC := $(SQLITE_AMALGAMATION_C)
SQLITE_INCLUDE := -I$(SQLITE_BUILD_DIR)
LIBOQS_DIR := vendor/liboqs
LIBOQS_BUILD_DIR := $(VENDOR_BUILD_DIR)/linux/$(ARCH)/liboqs
LIBOQS_A := $(LIBOQS_BUILD_DIR)/lib/liboqs.a
LIBOQS_INCLUDE := -I$(LIBOQS_BUILD_DIR)/include
WEB_LIBOQS_BUILD_DIR := $(VENDOR_BUILD_DIR)/web/liboqs
WEB_LIBOQS_A := $(WEB_LIBOQS_BUILD_DIR)/lib/liboqs.a
WEB_LIBOQS_INCLUDE := -I$(WEB_LIBOQS_BUILD_DIR)/include
TEST_BIN_DIR := $(BUILD_BIN_DIR)/tests
STORAGE_IMPORT_TEST := $(TEST_BIN_DIR)/storage_import_test
FLINT_TEXT_SCALING_TEST := $(TEST_BIN_DIR)/flint_text_scaling_test
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
FLINT_RUNTIME_ASSET_CFLAGS := $(FLINT_CURL_CFLAGS)
FLINT_RUNTIME_ASSET_CFLAGS := -DFLINT_HAS_LIBCURL=1 $(FLINT_CURL_CFLAGS)
FLINT_RUNTIME_ASSET_LDLIBS := $(FLINT_CURL_LDLIBS)
APP_SRCS := \
@@ -132,21 +93,16 @@ APP_SRCS := \
src/practices/meditation/meditation_config.c \
src/screens/habits_screen.c \
src/practices/meditation/meditation_music.c \
src/core/locale.c \
src/core/theme.c \
src/storage/data.c \
src/storage/storage.c \
src/storage/sync_account.c \
src/storage/sync_client.c \
src/third_party/miniz.c \
src/platform/android/android_device.c \
src/screens/practice_screen.c \
src/screens/language_screen.c \
src/screens/manual_screen.c \
src/screens/settings/settings_screen.c \
src/screens/settings/settings_device.c \
src/screens/settings/settings_theme.c \
src/screens/settings/settings_data.c \
src/screens/settings/settings_sync_account.c
src/screens/settings/settings_screen.c
LOCALE_FILES := $(wildcard locales/*.txt)
IMAGE_FILES := assets/practices/whm/1.jpg assets/practices/whm/2.jpg assets/practices/meditation/1.jpg
@@ -166,7 +122,7 @@ WINDOWS_CFLAGS := -Wall -Wextra -std=c99 -Os -D_DEFAULT_SOURCE -D_GNU_SOURCE -ff
WEB_CFLAGS := $(filter-out -std=c99,$(CFLAGS)) -std=gnu99
LDFLAGS := -Wl,--gc-sections -s
WINDOWS_LDFLAGS := -Wl,--gc-sections -static -static-libgcc -mwindows
WINDOWS_LDLIBS := -lgdi32 -lwinmm -lopengl32 -luser32 -lshell32 -lole32 -lcomdlg32 -lcomctl32 -luuid -lwininet -lws2_32 -liphlpapi -lcrypt32 -lsecur32 -lbcrypt -ladvapi32 -lm
WINDOWS_LDLIBS := -lgdi32 -lwinmm -lopengl32 -luser32 -lshell32 -lole32 -lcomdlg32 -lcomctl32 -luuid -lwininet -lm
ifneq ($(strip $(MCFGTHREADS)),)
WIN64_THREAD_LDFLAGS := -L$(MCFGTHREADS)/lib
else
@@ -190,21 +146,15 @@ APPIMAGE_TARGET := $(LINUX_DIST_DIR)/$(APPIMAGE_NAME)
LINUXDEPLOY ?= linuxdeploy
WEB_CC ?= emcc
WEB_AR ?= emar
WEB_CACHE_BUSTER ?= $(shell if git diff --quiet --ignore-submodules HEAD -- 2>/dev/null; then git rev-parse --short HEAD 2>/dev/null; else date +%s; fi)
WEB_CACHE_BUSTER ?= $(shell git rev-parse --short HEAD 2>/dev/null || date +%s)
WEB_TARGET := $(WEB_DIST_DIR)/index.html
WEB_DIST_ZIP := $(BUILD_DIST_DIR)/$(APP_NAME)-web.zip
WEB_APP_URL ?= https://inbe.waozi.xyz/
CHROME_WEB_STORE_ZIP := $(BUILD_DIST_DIR)/$(APP_NAME)-chrome-web-store.zip
CHROME_WEB_STORE_MANIFEST := packaging/chrome-web-store/manifest.json
CHROME_WEB_STORE_WORKER := packaging/chrome-web-store/service_worker.js
CHROME_WEB_STORE_ICON := web-assets/icons/icon-512x512.png
MAGICK ?= magick
WEB_ASSET_FILES := $(shell find web-assets -type f 2>/dev/null)
UNPACKAGED_AUDIO_DIR := unpackaged_assets/audio
UNPACKAGED_AUDIO_FILES := $(shell find $(UNPACKAGED_AUDIO_DIR) -type f 2>/dev/null)
WEB_AUDIO_FILES := $(shell find $(UNPACKAGED_AUDIO_DIR) -type f 2>/dev/null)
MEDITATION_AUDIO_ZIP := web-assets/dl/inbe-meditation-audio-v1.zip
.PHONY: all native run test dist appimage vendor-prebuilds vendor-prebuilds-native vendor-prebuilds-web vendor-prebuilds-windows clean clean-linux clean-vendor-builds android-check-keystore android-copy-assets android-local-properties android-debug android-release android-bundle android-install android-install-release android-clean package-unpackaged-assets windows-runtime-assets-check windows windows64 windows32 web chrome-web-store
.PHONY: all native run test dist appimage clean clean-linux clean-raylib android-check-keystore android-copy-assets android-debug android-release android-bundle android-install android-install-release android-clean package-unpackaged-assets windows-runtime-assets-check windows windows64 windows32 web
.NOTPARALLEL: dist windows windows64 windows32 android-release android-bundle
all: native
@@ -227,7 +177,6 @@ dist:
$(MAKE) android-check-keystore PASSWORD="$$password" && \
$(MAKE) package-unpackaged-assets && \
$(MAKE) web && \
$(MAKE) chrome-web-store && \
$(MAKE) appimage && \
$(MAKE) windows && \
$(MAKE) android-release PASSWORD="$$password" && \
@@ -235,23 +184,13 @@ dist:
appimage: $(APPIMAGE_TARGET)
vendor-prebuilds: vendor-prebuilds-native vendor-prebuilds-web vendor-prebuilds-windows
vendor-prebuilds-native: $(RAYLIB_A) $(SQLITE_AMALGAMATION_C) $(SQLITE_AMALGAMATION_H) $(LIBOQS_A) $(CURL_PROTOCOL_CHECK)
vendor-prebuilds-web: $(WEB_RAYLIB_A) $(SQLITE_AMALGAMATION_C) $(SQLITE_AMALGAMATION_H) $(WEB_LIBOQS_A)
vendor-prebuilds-windows: $(WIN64_RAYLIB_A) $(WIN32_RAYLIB_A) $(WIN64_CURL_A) $(WIN32_CURL_A) $(SQLITE_AMALGAMATION_C) $(SQLITE_AMALGAMATION_H)
run: $(TARGET)
./$(TARGET)
test: $(STORAGE_IMPORT_TEST) $(FLINT_TEXT_SCALING_TEST) $(LOCALE_KEYS_TEST) $(SYNC_URL_TEST) $(SYNC_ACCOUNT_TEST)
test: $(STORAGE_IMPORT_TEST) $(FLINT_TEXT_SCALING_TEST) $(LOCALE_KEYS_TEST)
$(STORAGE_IMPORT_TEST)
$(FLINT_TEXT_SCALING_TEST)
$(LOCALE_KEYS_TEST)
$(SYNC_URL_TEST)
$(SYNC_ACCOUNT_TEST)
$(STORAGE_IMPORT_TEST): tests/storage_import_test.c src/storage/storage.c src/storage/storage.h src/screens/habits_screen.c src/screens/habits_screen.h src/third_party/miniz.c src/third_party/miniz.h $(SQLITE_SRC) $(SQLITE_AMALGAMATION_H) | $(TEST_BIN_DIR)
$(CC) -Wall -Wextra -std=c99 -D_DEFAULT_SOURCE -D_GNU_SOURCE -DMINIZ_NO_ZLIB_COMPATIBLE_NAMES -ffunction-sections -fdata-sections \
@@ -272,20 +211,7 @@ $(LOCALE_KEYS_TEST): tests/locale_keys_test.c $(LOCALE_FILES) | $(TEST_BIN_DIR)
-o $@ \
tests/locale_keys_test.c
$(SYNC_URL_TEST): tests/sync_url_test.c src/storage/sync_client.c src/storage/sync_client.h $(CURL_PROTOCOL_CHECK) | $(TEST_BIN_DIR)
$(CC) -Wall -Wextra -Wno-unused-function -std=c99 -D_DEFAULT_SOURCE -DINBE_SYNC_CLIENT_TESTS -ffunction-sections -fdata-sections \
-Isrc/storage -Isrc -Ivendor/raylib/src $(FLINT_CURL_CFLAGS) -o $@ \
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/storage.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 $(SQLITE_INCLUDE) \
-o $@ \
tests/sync_account_test.c src/storage/sync_account.c src/storage/storage.c src/third_party/miniz.c $(SQLITE_SRC) \
-Wl,--gc-sections -lm -lpthread -ldl
$(BUILD_OBJ_DIR) $(LINUX_BIN_DIR) $(LINUX_DIST_DIR) $(LINUX_APPIMAGE_BUILD_DIR) $(WINDOWS_DIST_DIR) $(ANDROID_BUILD_DIR) $(TEST_BIN_DIR) $(WEB_OBJ_DIR) $(WEB_DIST_DIR) $(CHROME_WEB_STORE_DIR):
$(BUILD_OBJ_DIR) $(LINUX_BIN_DIR) $(LINUX_DIST_DIR) $(LINUX_APPIMAGE_BUILD_DIR) $(WINDOWS_DIST_DIR) $(ANDROID_BUILD_DIR) $(TEST_BIN_DIR) $(WEB_OBJ_DIR) $(WEB_DIST_DIR):
mkdir -p $@
$(WINDOWS_BIN_DIR)/$(WIN64_ARCH) $(WINDOWS_BIN_DIR)/$(WIN32_ARCH):
@@ -310,10 +236,10 @@ $(FLINT_ICON_ASSETS_C): $(FLINT_ICON_FILES) $(FLINT_DIR)/scripts/embed-icons.sh
sh $(FLINT_DIR)/scripts/embed-icons.sh $(FLINT_DIR)/icons $@
$(RAYLIB_A): $(RAYLIB_SOURCES)
rm -rf $(VENDOR_BUILD_DIR)/linux/$(ARCH)/raylib-src
mkdir -p $(VENDOR_BUILD_DIR)/linux/$(ARCH)/raylib-src $(RAYLIB_BUILD_DIR)
cp -R $(RAYLIB_DIR)/. $(VENDOR_BUILD_DIR)/linux/$(ARCH)/raylib-src/
$(MAKE) -j1 -C $(VENDOR_BUILD_DIR)/linux/$(ARCH)/raylib-src \
rm -rf $(LINUX_OBJ_DIR)/$(ARCH)/native/raylib-src
mkdir -p $(LINUX_OBJ_DIR)/$(ARCH)/native/raylib-src $(RAYLIB_BUILD_DIR)
cp -R $(RAYLIB_DIR)/. $(LINUX_OBJ_DIR)/$(ARCH)/native/raylib-src/
$(MAKE) -j1 -C $(LINUX_OBJ_DIR)/$(ARCH)/native/raylib-src \
PLATFORM=PLATFORM_DESKTOP_SDL \
GRAPHICS=GRAPHICS_API_OPENGL_ES2 \
RAYLIB_LIBTYPE=STATIC \
@@ -325,10 +251,10 @@ $(RAYLIB_A): $(RAYLIB_SOURCES)
CUSTOM_CFLAGS="-DUSING_SDL2_PROJECT $(RAY_CFLAGS) $(APP_RAYLIB_CONFIG) -Os -ffunction-sections -fdata-sections"
$(WEB_RAYLIB_A): $(RAYLIB_SOURCES) | $(WEB_OBJ_DIR)
rm -rf $(VENDOR_BUILD_DIR)/web/raylib-src
mkdir -p $(VENDOR_BUILD_DIR)/web/raylib-src $(WEB_RAYLIB_BUILD_DIR)
cp -R $(RAYLIB_DIR)/. $(VENDOR_BUILD_DIR)/web/raylib-src/
$(MAKE) -j1 -C $(VENDOR_BUILD_DIR)/web/raylib-src \
rm -rf $(WEB_OBJ_DIR)/raylib-src
mkdir -p $(WEB_OBJ_DIR)/raylib-src $(WEB_RAYLIB_BUILD_DIR)
cp -R $(RAYLIB_DIR)/. $(WEB_OBJ_DIR)/raylib-src/
$(MAKE) -j1 -C $(WEB_OBJ_DIR)/raylib-src \
PLATFORM=PLATFORM_WEB \
RAYLIB_LIBTYPE=STATIC \
RAYLIB_RELEASE_PATH=../raylib \
@@ -339,10 +265,10 @@ $(WEB_RAYLIB_A): $(RAYLIB_SOURCES) | $(WEB_OBJ_DIR)
CUSTOM_CFLAGS="$(APP_RAYLIB_CONFIG) -Os -ffunction-sections -fdata-sections"
$(WIN64_RAYLIB_A): $(RAYLIB_SOURCES)
rm -rf $(VENDOR_BUILD_DIR)/windows/$(WIN64_ARCH)/raylib-src
mkdir -p $(VENDOR_BUILD_DIR)/windows/$(WIN64_ARCH)/raylib-src $(WIN64_RAYLIB_BUILD_DIR)
cp -R $(RAYLIB_DIR)/. $(VENDOR_BUILD_DIR)/windows/$(WIN64_ARCH)/raylib-src/
$(MAKE) -j1 -C $(VENDOR_BUILD_DIR)/windows/$(WIN64_ARCH)/raylib-src \
rm -rf $(WINDOWS_OBJ_DIR)/$(WIN64_ARCH)/raylib-src
mkdir -p $(WINDOWS_OBJ_DIR)/$(WIN64_ARCH)/raylib-src $(WIN64_RAYLIB_BUILD_DIR)
cp -R $(RAYLIB_DIR)/. $(WINDOWS_OBJ_DIR)/$(WIN64_ARCH)/raylib-src/
$(MAKE) -j1 -C $(WINDOWS_OBJ_DIR)/$(WIN64_ARCH)/raylib-src \
OS=Windows_NT \
PLATFORM=PLATFORM_DESKTOP_RGFW \
GRAPHICS=GRAPHICS_API_OPENGL_11 \
@@ -356,10 +282,10 @@ $(WIN64_RAYLIB_A): $(RAYLIB_SOURCES)
CUSTOM_CFLAGS="$(APP_RAYLIB_CONFIG) -Os -ffunction-sections -fdata-sections"
$(WIN32_RAYLIB_A): $(RAYLIB_SOURCES)
rm -rf $(VENDOR_BUILD_DIR)/windows/$(WIN32_ARCH)/raylib-src
mkdir -p $(VENDOR_BUILD_DIR)/windows/$(WIN32_ARCH)/raylib-src $(WIN32_RAYLIB_BUILD_DIR)
cp -R $(RAYLIB_DIR)/. $(VENDOR_BUILD_DIR)/windows/$(WIN32_ARCH)/raylib-src/
$(MAKE) -j1 -C $(VENDOR_BUILD_DIR)/windows/$(WIN32_ARCH)/raylib-src \
rm -rf $(WINDOWS_OBJ_DIR)/$(WIN32_ARCH)/raylib-src
mkdir -p $(WINDOWS_OBJ_DIR)/$(WIN32_ARCH)/raylib-src $(WIN32_RAYLIB_BUILD_DIR)
cp -R $(RAYLIB_DIR)/. $(WINDOWS_OBJ_DIR)/$(WIN32_ARCH)/raylib-src/
$(MAKE) -j1 -C $(WINDOWS_OBJ_DIR)/$(WIN32_ARCH)/raylib-src \
OS=Windows_NT \
PLATFORM=PLATFORM_DESKTOP_RGFW \
GRAPHICS=GRAPHICS_API_OPENGL_11 \
@@ -374,150 +300,16 @@ $(WIN32_RAYLIB_A): $(RAYLIB_SOURCES)
$(SQLITE_AMALGAMATION_C) $(SQLITE_AMALGAMATION_H): $(SQLITE_DIR)/configure $(SQLITE_DIR)/manifest | $(BUILD_OBJ_DIR)
mkdir -p $(SQLITE_BUILD_DIR)
cd $(SQLITE_BUILD_DIR) && $(abspath $(SQLITE_DIR))/configure
cd $(SQLITE_BUILD_DIR) && ../../../$(SQLITE_DIR)/configure
$(MAKE) -C $(SQLITE_BUILD_DIR) sqlite3.c sqlite3.h
$(LIBOQS_A): $(LIBOQS_DIR)/CMakeLists.txt | $(BUILD_OBJ_DIR)
$(CMAKE) -S $(LIBOQS_DIR) -B $(LIBOQS_BUILD_DIR) \
-DCMAKE_BUILD_TYPE=MinSizeRel \
-DBUILD_SHARED_LIBS=OFF \
-DOQS_BUILD_ONLY_LIB=ON \
-DOQS_USE_OPENSSL=OFF \
-DOQS_MINIMAL_BUILD=SIG_ml_dsa_44
$(CMAKE) --build $(LIBOQS_BUILD_DIR) --target oqs
$(WEB_LIBOQS_A): $(LIBOQS_DIR)/CMakeLists.txt | $(BUILD_OBJ_DIR)
emcmake $(CMAKE) -S $(LIBOQS_DIR) -B $(WEB_LIBOQS_BUILD_DIR) \
-DCMAKE_BUILD_TYPE=MinSizeRel \
-DBUILD_SHARED_LIBS=OFF \
-DOQS_BUILD_ONLY_LIB=ON \
-DOQS_USE_OPENSSL=OFF \
-DOQS_DIST_BUILD=OFF \
-DOQS_OPT_TARGET=generic \
-DOQS_MINIMAL_BUILD=SIG_ml_dsa_44
$(CMAKE) --build $(WEB_LIBOQS_BUILD_DIR) --target oqs
$(CURL_SO): $(CURL_DIR)/CMakeLists.txt
$(CMAKE) -S $(CURL_DIR) -B $(CURL_BUILD_DIR) \
-DCMAKE_BUILD_TYPE=MinSizeRel \
-DCMAKE_INSTALL_PREFIX=$(abspath $(CURL_BUILD_DIR)) \
-DCMAKE_INSTALL_LIBDIR=lib64 \
-DBUILD_CURL_EXE=OFF \
-DBUILD_SHARED_LIBS=ON \
-DBUILD_STATIC_LIBS=OFF \
-DCURL_USE_OPENSSL=ON \
$(OPENSSL_CMAKE_OPT) \
$(OPENSSL_INCLUDE_CMAKE_OPT) \
$(OPENSSL_SSL_CMAKE_OPT) \
$(OPENSSL_CRYPTO_CMAKE_OPT) \
-DCURL_DISABLE_WEBSOCKETS=OFF \
-DCURL_DISABLE_INSTALL=OFF \
-DCURL_DISABLE_LDAP=ON \
-DCURL_DISABLE_LDAPS=ON \
-DCURL_DISABLE_DICT=ON \
-DCURL_DISABLE_FILE=ON \
-DCURL_DISABLE_FTP=ON \
-DCURL_DISABLE_GOPHER=ON \
-DCURL_DISABLE_IMAP=ON \
-DCURL_DISABLE_MQTT=ON \
-DCURL_DISABLE_POP3=ON \
-DCURL_DISABLE_RTSP=ON \
-DCURL_DISABLE_SMB=ON \
-DCURL_DISABLE_SMTP=ON \
-DCURL_DISABLE_TELNET=ON \
-DCURL_DISABLE_TFTP=ON \
-DCURL_DISABLE_LIBCURL_OPTION=ON \
-DCURL_ZLIB=OFF \
-DCURL_BROTLI=OFF \
-DCURL_ZSTD=OFF \
-DCURL_USE_LIBPSL=OFF \
-DCURL_USE_LIBSSH2=OFF \
-DCURL_USE_GSSAPI=OFF \
-DUSE_NGHTTP2=OFF \
-DUSE_LIBIDN2=OFF \
-DENABLE_CURL_MANUAL=OFF \
-DBUILD_EXAMPLES=OFF \
-DBUILD_LIBCURL_DOCS=OFF \
-DBUILD_MISC_DOCS=OFF \
-DBUILD_TESTING=OFF
$(CMAKE) --build $(CURL_BUILD_DIR) --target install
$(CURL_PROTOCOL_CHECK): $(CURL_SO)
@$(CURL_BUILD_DIR)/bin/curl-config --protocols | grep -Eq '(^|[[:space:]])WS([[:space:]]|$$)' || { echo "vendored libcurl was built without WS protocol support"; exit 1; }
@$(CURL_BUILD_DIR)/bin/curl-config --protocols | grep -Eq '(^|[[:space:]])WSS([[:space:]]|$$)' || { echo "vendored libcurl was built without WSS protocol support"; exit 1; }
@touch $@
$(WIN64_CURL_A): $(CURL_DIR)/CMakeLists.txt
rm -rf $(WIN64_CURL_BUILD_DIR)
$(CMAKE) -S $(CURL_DIR) -B $(WIN64_CURL_BUILD_DIR) \
-DCMAKE_SYSTEM_NAME=Windows \
-DCMAKE_C_COMPILER=$(WIN64_CC_PATH) \
-DCMAKE_AR=$(WIN64_AR_PATH) \
-DCMAKE_RANLIB=$(WIN64_RANLIB_PATH) \
-DCMAKE_EXE_LINKER_FLAGS="$(WIN64_THREAD_LDFLAGS)" \
-DCMAKE_INSTALL_PREFIX=$(abspath $(WIN64_CURL_BUILD_DIR)) \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=OFF \
-DBUILD_STATIC_LIBS=ON \
-DBUILD_CURL_EXE=OFF \
-DCURL_STATICLIB=ON \
-DCURL_USE_SCHANNEL=ON \
-DCURL_USE_OPENSSL=OFF \
-DCURL_USE_LIBPSL=OFF \
-DCURL_USE_LIBSSH2=OFF \
-DCURL_USE_GSSAPI=OFF \
-DUSE_NGHTTP2=OFF \
-DUSE_LIBIDN2=OFF \
-DCURL_DISABLE_LDAP=ON \
-DCURL_DISABLE_LDAPS=ON \
-DCURL_DISABLE_SMB=ON \
-DENABLE_CURL_MANUAL=OFF \
-DBUILD_EXAMPLES=OFF \
-DBUILD_LIBCURL_DOCS=OFF \
-DBUILD_MISC_DOCS=OFF \
-DBUILD_TESTING=OFF
$(CMAKE) --build $(WIN64_CURL_BUILD_DIR) --target install
$(WIN32_CURL_A): $(CURL_DIR)/CMakeLists.txt
rm -rf $(WIN32_CURL_BUILD_DIR)
$(CMAKE) -S $(CURL_DIR) -B $(WIN32_CURL_BUILD_DIR) \
-DCMAKE_SYSTEM_NAME=Windows \
-DCMAKE_C_COMPILER=$(WIN32_CC_PATH) \
-DCMAKE_AR=$(WIN32_AR_PATH) \
-DCMAKE_RANLIB=$(WIN32_RANLIB_PATH) \
-DCMAKE_EXE_LINKER_FLAGS="$(WIN32_THREAD_LDFLAGS)" \
-DCMAKE_INSTALL_PREFIX=$(abspath $(WIN32_CURL_BUILD_DIR)) \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=OFF \
-DBUILD_STATIC_LIBS=ON \
-DBUILD_CURL_EXE=OFF \
-DCURL_STATICLIB=ON \
-DCURL_USE_SCHANNEL=ON \
-DCURL_USE_OPENSSL=OFF \
-DCURL_USE_LIBPSL=OFF \
-DCURL_USE_LIBSSH2=OFF \
-DCURL_USE_GSSAPI=OFF \
-DUSE_NGHTTP2=OFF \
-DUSE_LIBIDN2=OFF \
-DCURL_DISABLE_LDAP=ON \
-DCURL_DISABLE_LDAPS=ON \
-DCURL_DISABLE_SMB=ON \
-DENABLE_CURL_MANUAL=OFF \
-DBUILD_EXAMPLES=OFF \
-DBUILD_LIBCURL_DOCS=OFF \
-DBUILD_MISC_DOCS=OFF \
-DBUILD_TESTING=OFF
$(CMAKE) --build $(WIN32_CURL_BUILD_DIR) --target install
$(TARGET): Makefile $(SRC) $(FLINT_SRCS) $(SQLITE_SRC) $(SQLITE_AMALGAMATION_H) $(FONT_OUTPUTS) $(EMBEDDED_ASSETS_C) $(RAYLIB_A) $(LIBOQS_A) $(CURL_PROTOCOL_CHECK) | $(LINUX_BIN_DIR)
$(TARGET): Makefile $(SRC) $(FLINT_SRCS) $(SQLITE_SRC) $(SQLITE_AMALGAMATION_H) $(FONT_OUTPUTS) $(EMBEDDED_ASSETS_C) $(RAYLIB_A) | $(LINUX_BIN_DIR)
$(CC) $(CFLAGS) \
$(APP_INCLUDE) \
$(FLINT_INCLUDE) \
$(SQLITE_INCLUDE) \
$(LIBOQS_INCLUDE) \
-I$(RAYLIB_DIR) \
$(RAY_CFLAGS) \
-DINBE_HAS_LIBOQS=1 \
-DSUPPORT_MODULE_RAUDIO=1 \
-DSUPPORT_FILEFORMAT_OGG=1 \
-DSUPPORT_FILEFORMAT_MP3=1 \
@@ -526,47 +318,40 @@ $(TARGET): Makefile $(SRC) $(FLINT_SRCS) $(SQLITE_SRC) $(SQLITE_AMALGAMATION_H)
$(FLINT_SRCS) \
$(SQLITE_SRC) \
$(RAYLIB_A) \
$(LIBOQS_A) \
$(RAY_LDLIBS) \
$(FLINT_RUNTIME_ASSET_LDLIBS) \
-lm -lpthread -ldl -lrt \
$(LDFLAGS)
$(WIN64_TARGET): Makefile $(SRC) $(FLINT_WINDOWS_SRCS) $(SQLITE_SRC) $(SQLITE_AMALGAMATION_H) $(FONT_OUTPUTS) $(EMBEDDED_ASSETS_C) $(WIN64_RAYLIB_A) $(WIN64_CURL_A) | $(WINDOWS_BIN_DIR)/$(WIN64_ARCH)
$(WIN64_TARGET): Makefile $(SRC) $(FLINT_WINDOWS_SRCS) $(SQLITE_SRC) $(SQLITE_AMALGAMATION_H) $(FONT_OUTPUTS) $(EMBEDDED_ASSETS_C) $(WIN64_RAYLIB_A) | $(WINDOWS_BIN_DIR)/$(WIN64_ARCH)
$(WIN64_CC) $(WINDOWS_CFLAGS) \
$(APP_INCLUDE) \
$(FLINT_INCLUDE) \
$(SQLITE_INCLUDE) \
-I$(WIN64_CURL_INCLUDE_DIR) \
-I$(RAYLIB_DIR) \
-DPLATFORM_DESKTOP \
-DCURL_STATICLIB \
-o $@ \
$(SRC) \
$(FLINT_WINDOWS_SRCS) \
$(SQLITE_SRC) \
$(WIN64_RAYLIB_A) \
$(WIN64_CURL_A) \
$(WINDOWS_LDLIBS) \
$(WIN64_THREAD_LDFLAGS) \
$(WINDOWS_LDFLAGS)
$(WIN64_STRIP) $@
$(WIN32_TARGET): Makefile $(SRC) $(FLINT_WINDOWS_SRCS) $(SQLITE_SRC) $(SQLITE_AMALGAMATION_H) $(FONT_OUTPUTS) $(EMBEDDED_ASSETS_C) $(WIN32_RAYLIB_A) $(WIN32_CURL_A) | $(WINDOWS_BIN_DIR)/$(WIN32_ARCH)
$(WIN32_TARGET): Makefile $(SRC) $(FLINT_WINDOWS_SRCS) $(SQLITE_SRC) $(SQLITE_AMALGAMATION_H) $(FONT_OUTPUTS) $(EMBEDDED_ASSETS_C) $(WIN32_RAYLIB_A) | $(WINDOWS_BIN_DIR)/$(WIN32_ARCH)
$(WIN32_CC) $(WINDOWS_CFLAGS) \
$(APP_INCLUDE) \
$(FLINT_INCLUDE) \
$(SQLITE_INCLUDE) \
-I$(WIN32_CURL_INCLUDE_DIR) \
-I$(RAYLIB_DIR) \
-DPLATFORM_DESKTOP \
-DCURL_STATICLIB \
-o $@ \
$(SRC) \
$(FLINT_WINDOWS_SRCS) \
$(SQLITE_SRC) \
$(WIN32_RAYLIB_A) \
$(WIN32_CURL_A) \
$(WINDOWS_LDLIBS) \
$(WIN32_THREAD_LDFLAGS) \
$(WINDOWS_LDFLAGS)
@@ -605,15 +390,12 @@ $(APPIMAGE_TARGET): $(TARGET) $(LINUX_APPIMAGE_APPRUN) $(LINUX_APPIMAGE_DESKTOP)
--output appimage
test -f $@
$(WEB_TARGET): Makefile $(SRC) $(FLINT_WEB_SRCS) $(SQLITE_SRC) $(SQLITE_AMALGAMATION_H) $(FONT_OUTPUTS) $(EMBEDDED_ASSETS_C) $(WEB_RAYLIB_A) $(WEB_LIBOQS_A) src/web_shell.html manifest.json $(WEB_ASSET_FILES) $(MEDITATION_AUDIO_ZIP) | $(WEB_DIST_DIR)
rm -f $(WEB_DIST_DIR)/index.data
$(WEB_TARGET): Makefile $(SRC) $(FLINT_WEB_SRCS) $(SQLITE_SRC) $(SQLITE_AMALGAMATION_H) $(FONT_OUTPUTS) $(EMBEDDED_ASSETS_C) $(WEB_RAYLIB_A) src/web_shell.html manifest.json $(WEB_ASSET_FILES) $(WEB_AUDIO_FILES) | $(WEB_DIST_DIR)
$(WEB_CC) $(WEB_CFLAGS) \
$(APP_INCLUDE) \
$(FLINT_INCLUDE) \
$(SQLITE_INCLUDE) \
$(WEB_LIBOQS_INCLUDE) \
-I$(RAYLIB_DIR) \
-DINBE_HAS_LIBOQS=1 \
-DPLATFORM_WEB \
-DSUPPORT_MODULE_RAUDIO=1 \
-DSUPPORT_FILEFORMAT_OGG=1 \
@@ -623,13 +405,12 @@ $(WEB_TARGET): Makefile $(SRC) $(FLINT_WEB_SRCS) $(SQLITE_SRC) $(SQLITE_AMALGAMA
$(FLINT_WEB_SRCS) \
$(SQLITE_SRC) \
$(WEB_RAYLIB_A) \
$(WEB_LIBOQS_A) \
-sUSE_GLFW=3 \
-sASYNCIFY \
-sFORCE_FILESYSTEM=1 \
-sFETCH=1 \
-sALLOW_MEMORY_GROWTH=1 \
-sSTACK_SIZE=8388608 \
--preload-file $(UNPACKAGED_AUDIO_DIR)@$(UNPACKAGED_AUDIO_DIR) \
--shell-file src/web_shell.html \
-lidbfs.js \
-lm
@@ -663,25 +444,13 @@ android-check-keystore:
exit 1; \
fi
android-local-properties:
@if [ -f droid/local.properties ]; then sed -i '/^ndk\.dir=/d' droid/local.properties; fi
@if [ -d /mnt/storage/Android/Sdk/ndk/28.2.13676358 ]; then \
if [ -f droid/local.properties ]; then \
sed -i 's#^sdk\.dir=.*#sdk.dir=/mnt/storage/Android/Sdk#' droid/local.properties; \
sed -i 's#^cmake\.dir=.*#cmake.dir=/mnt/storage/Android/Sdk/cmake/3.22.1#' droid/local.properties; \
else \
printf 'sdk.dir=/mnt/storage/Android/Sdk\ncmake.dir=/mnt/storage/Android/Sdk/cmake/3.22.1\n' > droid/local.properties; \
fi; \
fi
android-debug: android-copy-assets android-local-properties
android-debug: android-copy-assets
unset ANDROID_HOME; $(GRADLE) -p droid assembleDebug
$(MAKE) android-copy-debug-apks
android-release:
$(MAKE) android-check-keystore PASSWORD="$(PASSWORD)"
$(MAKE) android-copy-assets
$(MAKE) android-local-properties
@if [ -n "$(PASSWORD)" ]; then \
unset ANDROID_HOME; $(GRADLE) -p droid assembleRelease -Pkeystore.path="$(ANDROID_KEYSTORE)" -Pkeystore.alias="$(ANDROID_KEY_ALIAS)" -Pkeystore.password="$(PASSWORD)" || exit $$?; \
else \
@@ -693,7 +462,6 @@ android-release:
android-bundle:
$(MAKE) android-check-keystore PASSWORD="$(PASSWORD)"
$(MAKE) android-copy-assets
$(MAKE) android-local-properties
@if [ -n "$(PASSWORD)" ]; then \
unset ANDROID_HOME; $(GRADLE) -p droid bundleRelease -Pkeystore.path="$(ANDROID_KEYSTORE)" -Pkeystore.alias="$(ANDROID_KEY_ALIAS)" -Pkeystore.password="$(PASSWORD)" || exit $$?; \
else \
@@ -771,13 +539,11 @@ android-clean:
$(GRADLE) -p droid clean
rm -rf $(ANDROID_BUILD_DIR)
$(MEDITATION_AUDIO_ZIP): $(UNPACKAGED_AUDIO_FILES)
package-unpackaged-assets:
mkdir -p $(dir $(MEDITATION_AUDIO_ZIP))
rm -f $(MEDITATION_AUDIO_ZIP)
cd $(UNPACKAGED_AUDIO_DIR) && find . -mindepth 2 -type f -name '*.ogg' -exec zip -9 -r $(abspath $(MEDITATION_AUDIO_ZIP)) {} + && zip -9 -r $(abspath $(MEDITATION_AUDIO_ZIP)) LICENSE.md MANIFEST.txt
package-unpackaged-assets: $(MEDITATION_AUDIO_ZIP)
windows-runtime-assets-check:
@:
@@ -800,32 +566,16 @@ web:
rm -f $(WEB_DIST_ZIP)
cd $(WEB_DIST_DIR) && zip -9 -r $(abspath $(WEB_DIST_ZIP)) .
chrome-web-store: $(CHROME_WEB_STORE_ZIP)
$(CHROME_WEB_STORE_ZIP): $(CHROME_WEB_STORE_MANIFEST) $(CHROME_WEB_STORE_WORKER) $(CHROME_WEB_STORE_ICON) | $(CHROME_WEB_STORE_DIR)
rm -rf $(CHROME_WEB_STORE_DIR)
mkdir -p $(CHROME_WEB_STORE_DIR)/icons
sed -e 's#__APP_VERSION__#$(APP_VERSION)#g' \
$(CHROME_WEB_STORE_MANIFEST) > $(CHROME_WEB_STORE_DIR)/manifest.json
sed -e 's#__WEB_APP_URL__#$(WEB_APP_URL)#g' \
$(CHROME_WEB_STORE_WORKER) > $(CHROME_WEB_STORE_DIR)/service_worker.js
$(MAGICK) $(CHROME_WEB_STORE_ICON) -filter point -resize 16x16 $(CHROME_WEB_STORE_DIR)/icons/icon-16.png
$(MAGICK) $(CHROME_WEB_STORE_ICON) -filter point -resize 32x32 $(CHROME_WEB_STORE_DIR)/icons/icon-32.png
$(MAGICK) $(CHROME_WEB_STORE_ICON) -filter point -resize 48x48 $(CHROME_WEB_STORE_DIR)/icons/icon-48.png
$(MAGICK) $(CHROME_WEB_STORE_ICON) -filter point -resize 128x128 $(CHROME_WEB_STORE_DIR)/icons/icon-128.png
rm -f $(CHROME_WEB_STORE_ZIP)
cd $(CHROME_WEB_STORE_DIR) && zip -9 -r $(abspath $(CHROME_WEB_STORE_ZIP)) .
clean:
rm -rf build
clean-linux:
rm -rf $(LINUX_OBJ_DIR) $(LINUX_BIN_DIR) $(LINUX_DIST_DIR)
clean-vendor-builds:
rm -rf $(VENDOR_BUILD_DIR)
clean-raylib:
rm -rf $(RAYLIB_BUILD_DIR) $(LINUX_OBJ_DIR)/*/native/raylib-src vendor/raylib/build
NEEDS_NATIVE_ENV := $(if $(MAKECMDGOALS),$(filter all native run dist appimage vendor-prebuilds vendor-prebuilds-native,$(MAKECMDGOALS)),native)
NEEDS_NATIVE_ENV := $(if $(MAKECMDGOALS),$(filter all native run dist appimage,$(MAKECMDGOALS)),native)
ifneq ($(strip $(NEEDS_NATIVE_ENV)),)
ifeq ($(strip $(RAY_CFLAGS)),)
$(error RAY_CFLAGS is not set. Enter the ray flake shell with 'nix develop')
@@ -843,9 +593,6 @@ ifeq ($(strip $(RAY_RAYLIB_CONFIG)),)
$(error RAY_RAYLIB_CONFIG is not set. Enter the ray flake shell with 'nix develop')
endif
ifeq ($(strip $(FLINT_CURL_LDLIBS)),)
$(error libcurl metadata is missing. Sync is required; enter the flake shell with 'nix develop' or set FLINT_CURL_CFLAGS/FLINT_CURL_LDLIBS explicitly)
endif
ifneq ($(shell v='$(FLINT_CURL_VERSION_HEX)'; if [ "$$v" = 075600 ] || [ "$$v" \> 075600 ]; then echo yes; fi),yes)
$(error libcurl >= 7.86.0 is required for websocket sync; found LIBCURL_VERSION_NUM=$(FLINT_CURL_VERSION_NUM))
$(error libcurl pkg-config metadata is missing. Runtime asset downloads are required; enter the flake shell with 'nix develop' or set FLINT_CURL_CFLAGS/FLINT_CURL_LDLIBS explicitly)
endif
endif
Binary file not shown.
Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.
Binary file not shown.

Before

Width:  |  Height:  |  Size: 67 KiB

After

Width:  |  Height:  |  Size: 72 KiB

+4 -10
View File
@@ -5,7 +5,7 @@ plugins {
android {
namespace 'xyz.waozi.inbe'
compileSdk 35
ndkVersion "28.2.13676358"
ndkVersion "25.1.8937393"
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
@@ -33,10 +33,10 @@ android {
}
defaultConfig {
minSdk 21
minSdk 19
targetSdk 35
versionCode 38
versionName "1.4.3"
versionCode 32
versionName "1.3.4"
}
@@ -69,12 +69,6 @@ android {
dependenciesInfo {
includeInApk = false
}
packaging {
jniLibs {
useLegacyPackaging = false
}
}
}
gradle.taskGraph.whenReady { taskGraph ->
+1 -13
View File
@@ -10,10 +10,6 @@ set(SQLITE_BUILD_DIR "${CMAKE_BINARY_DIR}/sqlite")
set(SQLITE_AMALGAMATION_C "${SQLITE_BUILD_DIR}/sqlite3.c")
set(SQLITE_AMALGAMATION_H "${SQLITE_BUILD_DIR}/sqlite3.h")
set(NATIVE_APP_GLUE_DIR "${ANDROID_NDK}/sources/android/native_app_glue")
set(OQS_BUILD_ONLY_LIB ON CACHE BOOL "" FORCE)
set(OQS_USE_OPENSSL OFF CACHE BOOL "" FORCE)
set(OQS_MINIMAL_BUILD "SIG_ml_dsa_44" CACHE STRING "" FORCE)
add_subdirectory("${REPO_ROOT}/vendor/liboqs" "${CMAKE_BINARY_DIR}/liboqs")
file(GLOB FLINT_SOURCES CONFIGURE_DEPENDS "${FLINT_DIR}/src/*.c")
list(REMOVE_ITEM FLINT_SOURCES "${FLINT_DIR}/src/flint_file_dialog.c")
file(GLOB INBE_LOCALE_ASSETS RELATIVE "${REPO_ROOT}" CONFIGURE_DEPENDS "${REPO_ROOT}/locales/*.txt")
@@ -106,11 +102,10 @@ add_library(main SHARED
"${SRC_DIR}/practices/meditation/meditation_config.c"
"${SRC_DIR}/screens/habits_screen.c"
"${SRC_DIR}/practices/meditation/meditation_music.c"
"${SRC_DIR}/core/locale.c"
"${SRC_DIR}/core/theme.c"
"${SRC_DIR}/storage/data.c"
"${SRC_DIR}/storage/storage.c"
"${SRC_DIR}/storage/sync_account.c"
"${SRC_DIR}/storage/sync_client.c"
"${SRC_DIR}/third_party/miniz.c"
"${SQLITE_AMALGAMATION_C}"
"${SRC_DIR}/platform/android/android_device.c"
@@ -121,10 +116,6 @@ add_library(main SHARED
"${SRC_DIR}/screens/language_screen.c"
"${SRC_DIR}/screens/manual_screen.c"
"${SRC_DIR}/screens/settings/settings_screen.c"
"${SRC_DIR}/screens/settings/settings_device.c"
"${SRC_DIR}/screens/settings/settings_theme.c"
"${SRC_DIR}/screens/settings/settings_data.c"
"${SRC_DIR}/screens/settings/settings_sync_account.c"
"${INBE_EMBEDDED_ASSETS_C}"
${FLINT_SOURCES}
"${SRC_DIR}/platform/android/android_insets.c"
@@ -162,7 +153,6 @@ target_compile_definitions(main PRIVATE
SUPPORT_MODULE_RAUDIO=1
SUPPORT_FILEFORMAT_OGG=1
FLINT_EMBEDDED_ONLY=1
INBE_HAS_LIBOQS=1
)
target_compile_options(main PRIVATE
@@ -175,13 +165,11 @@ target_compile_options(main PRIVATE
target_link_options(main PRIVATE
-Wl,--gc-sections
-Wl,--strip-all
-Wl,-z,max-page-size=16384
-Wl,--wrap=fopen
)
target_link_libraries(main
raylib
oqs
android
log
OpenSLES
@@ -15,7 +15,6 @@ import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.PowerManager;
import android.util.Base64;
import android.util.Log;
import android.view.DisplayCutout;
import android.view.KeyEvent;
@@ -27,17 +26,11 @@ import android.view.inputmethod.InputMethodManager;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.Socket;
import java.net.SocketException;
import java.net.SocketTimeoutException;
import java.net.URI;
import java.net.UnknownHostException;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.security.SecureRandom;
import javax.net.ssl.SSLSocketFactory;
public class MainActivity extends NativeActivity {
private static final String TAG = "InbeMainActivity";
@@ -58,7 +51,6 @@ public class MainActivity extends NativeActivity {
private boolean windowFocused = true;
private boolean backgroundExecutionActive = false;
private boolean autoPausedForLifecycle = false;
private int lastDeleteRepeatCount = -1;
private native void nativeSetInsets(int status, int nav,
int cutoutLeft, int cutoutTop, int cutoutRight, int cutoutBottom);
@@ -157,32 +149,18 @@ public class MainActivity extends NativeActivity {
if (event != null && event.getAction() == KeyEvent.ACTION_DOWN) {
int keyCode = event.getKeyCode();
if (keyCode == KeyEvent.KEYCODE_DEL) {
int repeatCount = event.getRepeatCount();
int deleteCount = lastDeleteRepeatCount < 0
? 1
: Math.max(1, repeatCount - lastDeleteRepeatCount);
lastDeleteRepeatCount = repeatCount;
for (int i = 0; i < deleteCount; i++) {
nativeTextInputBackspace();
}
nativeTextInputBackspace();
} else if (keyCode == KeyEvent.KEYCODE_ENTER ||
keyCode == KeyEvent.KEYCODE_NUMPAD_ENTER) {
lastDeleteRepeatCount = -1;
nativeTextInputEnter();
} else {
lastDeleteRepeatCount = -1;
int unicode = event.getUnicodeChar();
if (unicode >= 32) {
nativeTextInputCommit(unicode);
}
}
} else if (event != null && event.getAction() == KeyEvent.ACTION_UP) {
if (event.getKeyCode() == KeyEvent.KEYCODE_DEL) {
lastDeleteRepeatCount = -1;
}
} else if (event != null && event.getAction() == KeyEvent.ACTION_MULTIPLE &&
event.getCharacters() != null) {
lastDeleteRepeatCount = -1;
String chars = event.getCharacters();
for (int i = 0; i < chars.length();) {
int codepoint = chars.codePointAt(i);
@@ -290,228 +268,7 @@ public class MainActivity extends NativeActivity {
}, "inbe-runtime-asset-download").start();
}
public String syncHttpRequest(String method, String urlText, String body, String[] headers) {
HttpURLConnection connection = null;
int status = 0;
try {
byte[] bodyBytes = body != null ? body.getBytes(StandardCharsets.UTF_8) : new byte[0];
connection = (HttpURLConnection)new URL(urlText).openConnection();
connection.setInstanceFollowRedirects(false);
connection.setConnectTimeout(15000);
connection.setReadTimeout(30000);
connection.setRequestMethod(method);
connection.setRequestProperty("User-Agent", "inbe-sync/1");
if (headers != null) {
for (String header : headers) {
if (header == null) continue;
int colon = header.indexOf(':');
if (colon <= 0) continue;
String key = header.substring(0, colon).trim();
String value = header.substring(colon + 1).trim();
if (!key.isEmpty()) {
connection.setRequestProperty(key, value);
}
}
}
if ("POST".equals(method) || "DELETE".equals(method)) {
connection.setDoOutput(true);
connection.setFixedLengthStreamingMode(bodyBytes.length);
try (OutputStream output = connection.getOutputStream()) {
output.write(bodyBytes);
}
}
status = connection.getResponseCode();
InputStream stream = status >= 400 ? connection.getErrorStream() : connection.getInputStream();
String response = "";
if (stream != null) {
try (InputStream input = stream) {
byte[] bytes = readAllBytesCompat(input);
response = new String(bytes, StandardCharsets.UTF_8);
}
}
return status + "\n" + response;
} catch (Exception e) {
Log.e(TAG, "Sync HTTP request failed", e);
return status + "\n" + (e.getMessage() != null ? e.getMessage() : "request failed");
} finally {
if (connection != null) {
connection.disconnect();
}
}
}
public String syncWebSocketWait(String urlText, String[] headers) {
Socket socket = null;
try {
URI url = new URI(urlText);
String protocol = url.getScheme();
boolean secure = "wss".equals(protocol);
int port = url.getPort();
String path = url.getRawPath();
if (path == null || path.isEmpty()) path = "/";
if (url.getRawQuery() != null && !url.getRawQuery().isEmpty()) {
path += "?" + url.getRawQuery();
}
if (port <= 0) port = secure ? 443 : 80;
if (!secure && !"ws".equals(protocol)) {
return "0\ninvalid websocket url";
}
socket = secure
? SSLSocketFactory.getDefault().createSocket(url.getHost(), port)
: new Socket(url.getHost(), port);
socket.setTcpNoDelay(true);
byte[] keyBytes = new byte[16];
new SecureRandom().nextBytes(keyBytes);
String key = Base64.encodeToString(keyBytes, Base64.NO_WRAP);
StringBuilder request = new StringBuilder();
request.append("GET ").append(path).append(" HTTP/1.1\r\n");
request.append("Host: ").append(url.getHost());
if ((secure && port != 443) || (!secure && port != 80)) {
request.append(":").append(port);
}
request.append("\r\n");
request.append("Upgrade: websocket\r\n");
request.append("Connection: Upgrade\r\n");
request.append("Sec-WebSocket-Version: 13\r\n");
request.append("Sec-WebSocket-Key: ").append(key).append("\r\n");
request.append("User-Agent: inbe-sync/1\r\n");
if (headers != null) {
for (String header : headers) {
if (header != null && !header.isEmpty()) {
request.append(header).append("\r\n");
}
}
}
request.append("\r\n");
socket.getOutputStream().write(request.toString().getBytes(StandardCharsets.US_ASCII));
socket.getOutputStream().flush();
String statusLine = readAsciiLine(socket);
int status = parseHttpStatus(statusLine);
while (true) {
String line = readAsciiLine(socket);
if (line == null || line.isEmpty()) break;
}
if (status != 101) {
return status + "\nwebsocket upgrade failed";
}
Log.i(TAG, "Sync WebSocket connected");
while (true) {
String message = readWebSocketText(socket);
if (message == null) {
return "0\nwebsocket closed";
}
if (message.contains("\"type\":\"sync_changed\"")) {
return "101\n" + message;
}
}
} catch (Exception e) {
Log.w(TAG, "WebSocket wait failed", e);
return "0\n" + (e.getMessage() != null ? e.getMessage() : "websocket failed");
} finally {
if (socket != null) {
try {
socket.close();
} catch (Exception ignored) {
}
}
}
}
private static int parseHttpStatus(String statusLine) {
if (statusLine == null) return 0;
String[] parts = statusLine.split(" ", 3);
if (parts.length < 2) return 0;
try {
return Integer.parseInt(parts[1]);
} catch (NumberFormatException e) {
return 0;
}
}
private static String readAsciiLine(Socket socket) throws java.io.IOException {
StringBuilder line = new StringBuilder();
while (true) {
int b = socket.getInputStream().read();
if (b < 0) {
return line.length() > 0 ? line.toString() : null;
}
if (b == '\n') break;
if (b != '\r') line.append((char)b);
}
return line.toString();
}
private static String readWebSocketText(Socket socket) throws java.io.IOException {
int b0 = socket.getInputStream().read();
int b1 = socket.getInputStream().read();
if (b0 < 0 || b1 < 0) return null;
int opcode = b0 & 0x0f;
boolean masked = (b1 & 0x80) != 0;
long length = b1 & 0x7f;
if (length == 126) {
length = ((long)readByte(socket) << 8) | readByte(socket);
} else if (length == 127) {
length = 0;
for (int i = 0; i < 8; i++) {
length = (length << 8) | readByte(socket);
}
}
if (length < 0 || length > 1024 * 1024) {
throw new java.io.IOException("websocket frame too large");
}
byte[] mask = null;
if (masked) {
mask = readExact(socket, 4);
}
byte[] payload = readExact(socket, (int)length);
if (masked) {
for (int i = 0; i < payload.length; i++) {
payload[i] = (byte)(payload[i] ^ mask[i % 4]);
}
}
if (opcode == 8) return null;
if (opcode != 1) return "";
return new String(payload, StandardCharsets.UTF_8);
}
private static int readByte(Socket socket) throws java.io.IOException {
int b = socket.getInputStream().read();
if (b < 0) throw new java.io.IOException("unexpected eof");
return b;
}
private static byte[] readExact(Socket socket, int count) throws java.io.IOException {
byte[] data = new byte[count];
int offset = 0;
while (offset < count) {
int read = socket.getInputStream().read(data, offset, count - offset);
if (read < 0) throw new java.io.IOException("unexpected eof");
offset += read;
}
return data;
}
private static byte[] readAllBytesCompat(InputStream input) throws java.io.IOException {
byte[] buffer = new byte[8192];
int read;
java.io.ByteArrayOutputStream output = new java.io.ByteArrayOutputStream();
while ((read = input.read(buffer)) != -1) {
output.write(buffer, 0, read);
}
return output.toByteArray();
}
public void openImportPicker(final String mimeTypesCsv) {
public void openImportPicker() {
runOnUiThread(new Runnable() {
@Override
public void run() {
@@ -519,10 +276,13 @@ public class MainActivity extends NativeActivity {
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("*/*");
String[] mimeTypes = parseMimeTypes(mimeTypesCsv);
if (mimeTypes.length > 0) {
intent.putExtra(Intent.EXTRA_MIME_TYPES, mimeTypes);
}
intent.putExtra(Intent.EXTRA_MIME_TYPES, new String[] {
"application/zip",
"application/x-zip-compressed",
"application/vnd.sqlite3",
"application/x-sqlite",
"application/x-sqlite3"
});
startActivityForResult(intent, REQUEST_IMPORT_ZIP);
} catch (Exception e) {
Log.e(TAG, "Failed to open import picker", e);
@@ -532,22 +292,6 @@ public class MainActivity extends NativeActivity {
});
}
private static String[] parseMimeTypes(String mimeTypesCsv) {
if (mimeTypesCsv == null || mimeTypesCsv.trim().isEmpty()) {
return new String[0];
}
String[] raw = mimeTypesCsv.split(",");
java.util.ArrayList<String> result = new java.util.ArrayList<>();
for (String mimeType : raw) {
String trimmed = mimeType.trim();
if (!trimmed.isEmpty()) {
result.add(trimmed);
}
}
return result.toArray(new String[0]);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
@@ -11,40 +11,6 @@ import java.io.FileOutputStream;
public class ShareHelper {
private static final String TAG = "InbeShare";
public static void shareFile(Activity activity, byte[] data, String filename, String mimeType, String chooserTitle) {
if (activity == null || data == null) return;
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
try {
File cacheFile = new File(activity.getCacheDir(), filename);
FileOutputStream fos = new FileOutputStream(cacheFile);
fos.write(data);
fos.close();
Uri contentUri = FileProvider.getUriForFile(
activity,
"xyz.waozi.inbe.fileprovider",
cacheFile
);
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.setType(mimeType != null ? mimeType : "application/octet-stream");
sendIntent.putExtra(Intent.EXTRA_STREAM, contentUri);
sendIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
Intent shareIntent = Intent.createChooser(sendIntent, chooserTitle);
activity.startActivity(shareIntent);
Log.i(TAG, "Share sheet shown");
} catch (Exception e) {
Log.e(TAG, "Share failed", e);
}
}
});
}
public static void shareZipFile(Activity activity, byte[] zipData, String filename, String chooserTitle) {
if (activity == null || zipData == null) return;
-2
View File
@@ -1,4 +1,2 @@
android.useAndroidX=true
android.suppressUnsupportedCompileSdk=35
org.gradle.caching=true
org.gradle.parallel=true
@@ -1,2 +0,0 @@
### Fixed
- Improved Android data import for `.db` backups, weekly habit rows, and import conflict handling.
@@ -1,2 +0,0 @@
### Fixed
- Fixed Tickmate `.db` imports so zero-based months map correctly and long habit histories load without dropping later dates.
@@ -1,2 +0,0 @@
### Added
- optional sync client, offline account creation
@@ -1,2 +0,0 @@
### Changed
- Improve account management
@@ -1,3 +0,0 @@
### Fixed
- Improve sync auth, websocket reconnects, and queued habit/session updates.
- Reduce SQLite-related UI flicker and speed up bulk import sync queueing.
@@ -1,3 +0,0 @@
### Fixed
- Refresh expired native sync auth tokens before sending queued changes.
- Require first-time meditation users to continue through the tutorial before starting.
+4 -13
View File
@@ -64,7 +64,7 @@
buildToolsVersions = [ "34.0.0" ];
platformVersions = [ "34" "35" ];
includeNDK = true;
ndkVersions = [ "28.2.13676358" ];
ndkVersions = [ "25.1.8937393" ];
cmakeVersions = [ "3.22.1" ];
includeEmulator = true;
includeSystemImages = true;
@@ -78,7 +78,6 @@
pkgConfigPath = pkgs.lib.makeSearchPath "lib/pkgconfig" [
sdl2Pkgs.SDL2.dev
pkgs.curl.dev
pkgs.openssl.dev
pkgs.libdrm.dev
pkgs.libgbm
pkgs.libglvnd.dev
@@ -213,8 +212,6 @@ EOF
mesa
ncurses
ninja
openssl
openssl.dev
pkg-config
pipewire
rsync
@@ -232,9 +229,6 @@ EOF
profile = ''
export JAVA_HOME="${pkgs.jdk17.home}"
export OPENSSL_INCLUDE_DIR="${pkgs.openssl.dev}/include"
export OPENSSL_SSL_LIBRARY="${pkgs.openssl.out}/lib/libssl.so"
export OPENSSL_CRYPTO_LIBRARY="${pkgs.openssl.out}/lib/libcrypto.so"
# Android SDK - override any system ANDROID_HOME
export ANDROID_HOME="${sdk}/libexec/android-sdk"
@@ -277,13 +271,10 @@ EOF
for project in inbe; do
if [ -d "$project/droid" ]; then
android_local_sdk="$ANDROID_SDK_ROOT"
if [ -d /mnt/storage/Android/Sdk/ndk/28.2.13676358 ]; then
android_local_sdk="/mnt/storage/Android/Sdk"
fi
cat > "$project/droid/local.properties" <<EOF
sdk.dir=$android_local_sdk
cmake.dir=$android_local_sdk/cmake/3.22.1
sdk.dir=$ANDROID_SDK_ROOT
ndk.dir=$ANDROID_NDK_ROOT
cmake.dir=$ANDROID_SDK_ROOT/cmake/3.22.1
EOF
fi
done
-2
View File
@@ -37,14 +37,12 @@ int flint_file_dialog_save(FlintFileDialog *dlg, const char *title, const char *
/* Load file dialog - returns 1 if file selected, 0 if cancelled */
int flint_file_dialog_load(FlintFileDialog *dlg, const char *title);
int flint_file_dialog_load_filtered(FlintFileDialog *dlg, const char *title, const char *filter);
/* Select folder dialog - returns 1 if folder selected, 0 if cancelled */
int flint_file_dialog_select_folder(FlintFileDialog *dlg, const char *title);
/* Begin non-blocking dialogs. Call flint_file_dialog_update() each frame while active. */
void flint_file_dialog_begin_load(FlintFileDialog *dlg, const char *title);
void flint_file_dialog_begin_load_filtered(FlintFileDialog *dlg, const char *title, const char *filter);
void flint_file_dialog_begin_save(FlintFileDialog *dlg, const char *title, const char *default_filename);
/* Draw/update active dialog: 1 confirmed, 0 cancelled, -1 still active. */
+3 -3
View File
@@ -216,8 +216,6 @@ int ui_draw_slider_vertical_with_marks(int id, int x, int y, int h,
int ui_draw_toggle_switch(int x, int y, int w, int h, int *value,
const char *off_label, const char *on_label);
int ui_draw_checkbox_toggle(int x, int y, const char *label, int *value);
int ui_draw_checkbox_toggle_disabled(int x, int y, const char *label,
int *value, int disabled);
int ui_draw_dropdown_button(int id, int x, int y, int w, int h, const char **options, int option_count, int *selected_index);
int ui_draw_dropdown_menu(int id);
int ui_dropdown_captures_click(Vector2 point);
@@ -232,6 +230,8 @@ typedef struct UITab {
const char *label;
Texture2D icon;
UIIconType icon_type;
void (*on_click)(void *user_data);
void *user_data;
} UITab;
typedef struct UITabBar {
@@ -242,7 +242,7 @@ typedef struct UITabBar {
int ui_nav_button_width(const char *label, int icon_size, int show_label, int font);
int ui_draw_nav_button(int x, int y, int icon_size, Texture2D icon, const char *label, int show_label, int *hover);
int ui_draw_nav_button_expand(int x, int y, int icon_size, int w, Texture2D icon, const char *label, int show_label, int *hover);
int ui_draw_tab_bar(UITab *tabs, int count);
void ui_draw_tab_bar(UITab *tabs, int count);
void ui_draw_tutorial_image_placeholder(const char *label, int x, int y, int w, int h);
void ui_draw_tutorial_image(Texture2D texture, const char *fallback, int x, int y, int w, int h);
int ui_draw_modal(const char *title, const char *message, const char *cancel_btn, const char *confirm_btn);
+9 -31
View File
@@ -38,10 +38,6 @@ void flint_file_dialog_set_theme_scope(const char *scope) {
static FlintFileDialogInternal *create_internal(void) {
FlintFileDialogInternal *internal = calloc(1, sizeof(FlintFileDialogInternal));
if(internal != NULL) {
internal->hover_index = -1;
internal->last_clicked_index = -1;
}
return internal;
}
@@ -218,9 +214,6 @@ static int scan_directory(FlintFileDialogInternal *internal) {
qsort(internal->entries, internal->file_count,
sizeof(DirEntry), compare_entries);
}
internal->hover_index = -1;
internal->last_clicked_index = -1;
internal->last_click_time = 0.0f;
return 1;
}
@@ -313,7 +306,7 @@ static void render_file_list(FlintFileDialog *dlg, Rectangle dialog_rect) {
int list_x = dialog_rect.x + flint_px(16);
int scrollbar_w = flint_px(12);
int list_width = dialog_rect.width - flint_px(32);
int bottom_y = dialog_rect.y + internal->dialog_height - flint_px(112);
int bottom_y = dialog_rect.y + internal->dialog_height - flint_px(72);
int list_height = bottom_y - list_y;
if(list_height < FILE_DIALOG_ITEM_HEIGHT)
list_height = FILE_DIALOG_ITEM_HEIGHT;
@@ -408,11 +401,12 @@ static void render_scrollbar(FlintFileDialog *dlg, Rectangle dialog_rect) {
static void render_filename_input(FlintFileDialog *dlg, Rectangle dialog_rect) {
FlintFileDialogInternal *internal = (FlintFileDialogInternal *)dlg->_internal;
int input_y = dialog_rect.y + internal->dialog_height - flint_px(96);
int input_y = dialog_rect.y + internal->dialog_height - flint_px(58);
int input_x = dialog_rect.x + flint_px(16);
int font = flint_ui_font_small();
int label_width = flint_text_measure("Filename:", font) + flint_px(8);
int input_width = dialog_rect.width - flint_px(32) - label_width;
int button_area_width = flint_px(176);
int input_width = dialog_rect.width - flint_px(32) - label_width - button_area_width;
int input_height = flint_px(24);
if(input_width < flint_px(24))
input_width = flint_px(24);
@@ -581,10 +575,9 @@ static int handle_mouse_input(FlintFileDialog *dlg) {
if(hover_idx >= 0 && hover_idx < internal->file_count) {
float current_time = GetTime();
if(current_time - internal->last_click_time < 0.5 &&
internal->last_clicked_index == hover_idx) {
internal->hover_index == hover_idx) {
if(internal->entries[hover_idx].is_dir) {
navigate_into(internal, internal->entries[hover_idx].name);
internal->last_clicked_index = -1;
} else {
copy_text(internal->selected_file, sizeof(internal->selected_file),
internal->entries[hover_idx].name);
@@ -602,7 +595,6 @@ static int handle_mouse_input(FlintFileDialog *dlg) {
}
internal->last_click_time = current_time;
internal->last_clicked_index = hover_idx;
}
}
@@ -762,7 +754,7 @@ run_dialog(FlintFileDialog *dlg)
}
void
flint_file_dialog_begin_load_filtered(FlintFileDialog *dlg, const char *title, const char *filter)
flint_file_dialog_begin_load(FlintFileDialog *dlg, const char *title)
{
FlintFileDialogInternal *internal;
@@ -770,7 +762,7 @@ flint_file_dialog_begin_load_filtered(FlintFileDialog *dlg, const char *title, c
flint_file_dialog_init(dlg);
dlg->mode = FLINT_FILE_DIALOG_LOAD;
copy_text(dlg->title, sizeof(dlg->title), title);
copy_text(dlg->filter, sizeof(dlg->filter), filter != NULL ? filter : "");
copy_text(dlg->filter, sizeof(dlg->filter), ".db,.zip");
dlg->active = 1;
dlg->confirmed = 0;
@@ -779,23 +771,10 @@ flint_file_dialog_begin_load_filtered(FlintFileDialog *dlg, const char *title, c
scan_directory(internal);
internal->filename_input[0] = '\0';
internal->selected_file[0] = '\0';
internal->hover_index = -1;
internal->last_clicked_index = -1;
internal->hover_index = 0;
internal->focus_area = 0;
}
void
flint_file_dialog_begin_load(FlintFileDialog *dlg, const char *title)
{
flint_file_dialog_begin_load_filtered(dlg, title, NULL);
}
int flint_file_dialog_load_filtered(FlintFileDialog *dlg, const char *title, const char *filter) {
if(!dlg || !title) return 0;
flint_file_dialog_begin_load_filtered(dlg, title, filter);
return run_dialog(dlg);
}
int flint_file_dialog_load(FlintFileDialog *dlg, const char *title) {
if(!dlg || !title) return 0;
flint_file_dialog_begin_load(dlg, title);
@@ -860,8 +839,7 @@ int flint_file_dialog_select_folder(FlintFileDialog *dlg, const char *title) {
FlintFileDialogInternal *internal = (FlintFileDialogInternal *)dlg->_internal;
internal->filename_input[0] = '\0';
internal->selected_file[0] = '\0';
internal->hover_index = -1;
internal->last_clicked_index = -1;
internal->hover_index = 0;
internal->focus_area = 0;
if(run_dialog(dlg)) {
-1
View File
@@ -27,7 +27,6 @@ typedef struct {
DirEntry *entries;
int scroll_offset;
int hover_index;
int last_clicked_index;
int focus_area;
Rectangle breadcrumb_rect;
Rectangle file_list_rect;
+18 -81
View File
@@ -50,7 +50,6 @@ static int g_ui_text_input_codepoints[UI_TEXT_INPUT_QUEUE_MAX];
static int g_ui_text_input_codepoint_count = 0;
static int g_ui_text_input_backspace_count = 0;
static int g_ui_text_input_enter_count = 0;
static double g_ui_backspace_next_repeat_at = 0.0;
#define UI_INPUT_CLIP_STACK_MAX 16
static Rectangle g_ui_input_clip_stack[UI_INPUT_CLIP_STACK_MAX];
@@ -89,32 +88,6 @@ ui_pointer_dx(void)
return (int)mouse.x - g_ui_pointer_start_x;
}
static int
ui_backspace_repeat_count(void)
{
double now;
int count = 0;
if(IsKeyPressed(KEY_BACKSPACE)) {
g_ui_backspace_next_repeat_at = GetTime() + 0.34;
return 1;
}
if(!IsKeyDown(KEY_BACKSPACE)) {
g_ui_backspace_next_repeat_at = 0.0;
return 0;
}
now = GetTime();
if(g_ui_backspace_next_repeat_at <= 0.0) {
g_ui_backspace_next_repeat_at = now + 0.34;
return 0;
}
while(now >= g_ui_backspace_next_repeat_at && count < 8) {
count++;
g_ui_backspace_next_repeat_at += 0.045;
}
return count;
}
static int
ui_pointer_dy(void)
{
@@ -677,8 +650,8 @@ flint_ui_text_edit(FlintUITextEdit edit)
changed = 1;
}
{
int repeat = g_ui_text_input_backspace_count + ui_backspace_repeat_count();
if(IsKeyPressed(KEY_BACKSPACE) || g_ui_text_input_backspace_count > 0) {
int repeat = g_ui_text_input_backspace_count > 0 ? g_ui_text_input_backspace_count : 1;
for(int i = 0; i < repeat; i++) {
int start = ui_utf8_prev_offset(edit.text, *edit.cursor_position);
changed |= ui_text_delete_range(edit.text, edit.text_size,
@@ -1159,7 +1132,6 @@ ui_draw_text_btn(int x, int y, const char *label, int *hover)
Vector2 mouse_world = ui_mouse_world();
int mx = (int)mouse_world.x;
int my = (int)mouse_world.y;
int local_hover = 0;
int mb = IsMouseButtonDown(MOUSE_BUTTON_LEFT);
int released = IsMouseButtonReleased(MOUSE_BUTTON_LEFT);
@@ -1168,8 +1140,6 @@ ui_draw_text_btn(int x, int y, const char *label, int *hover)
int h = flint_clamp_px(30, 26, 34);
x = x - w / 2;
if(!hover)
hover = &local_hover;
int pressed = 0;
@@ -1696,67 +1666,45 @@ ui_draw_toggle_switch(int x, int y, int w, int h, int *value,
}
int
ui_draw_checkbox_toggle_disabled(int x, int y, const char *label,
int *value, int disabled)
ui_draw_checkbox_toggle(int x, int y, const char *label, int *value)
{
int font = flint_ui_font();
int box_size = flint_px(22);
int hover = 0;
Rectangle bounds = {x, y, box_size, box_size};
Vector2 mouse_world = ui_mouse_world();
Color box_color = disabled ? flint_darken(c_button, 18) : c_button;
Color mark_color = disabled ? flint_darken(c_text, 35) : c_text;
Color label_color = disabled ? flint_darken(c_text, 35) : c_text;
if(CheckCollisionPointRec(mouse_world, bounds) && !ui_input_captures_click(mouse_world)) {
if(disabled)
ui_mark_disabled();
else {
hover = 1;
ui_mark_clickable();
}
hover = 1;
ui_mark_clickable();
}
int pressed = hover && IsMouseButtonReleased(MOUSE_BUTTON_LEFT);
if(pressed)
*value = !(*value);
DrawRectangle(x, y, box_size, box_size, box_color);
DrawRectangle(x, y, box_size, box_size, c_button);
ui_draw_bevel(x, y, box_size, box_size, flint_darken(c_bg, 30), flint_lighten(c_bg, 20));
if(*value) {
int padding = flint_px(4);
DrawLine(x + padding, y + padding, x + box_size / 2,
y + box_size - padding, mark_color);
DrawLine(x + box_size / 2, y + box_size - padding,
x + box_size - padding, y + padding, mark_color);
DrawLine(x + padding, y + padding, x + box_size / 2, y + box_size - padding, c_text);
DrawLine(x + box_size / 2, y + box_size - padding, x + box_size - padding, y + padding, c_text);
}
flint_text_draw(label, x + box_size + flint_px(10),
flint_ui_text_y(label, y, box_size, font),
font, label_color);
flint_text_draw(label, x + box_size + flint_px(10), flint_ui_text_y(label, y, box_size, font), font, c_text);
return pressed;
}
int
ui_draw_checkbox_toggle(int x, int y, const char *label, int *value)
{
return ui_draw_checkbox_toggle_disabled(x, y, label, value, 0);
}
/* Per-dropdown state to track open/closed and click handling */
#define MAX_DROPDOWN_OPTIONS 128
#define DROPDOWN_OPTION_TEXT_SIZE 256
typedef struct UIDropdownState {
int id;
int open;
int just_opened;
int scroll_offset;
int x, y, w, h;
const char *options[MAX_DROPDOWN_OPTIONS];
char option_text[MAX_DROPDOWN_OPTIONS][DROPDOWN_OPTION_TEXT_SIZE];
const char **options;
int option_count;
int *selected_index;
int touch_pressed;
@@ -2029,6 +1977,7 @@ get_or_create_dropdown_state(int id)
dropdown_states[dropdown_state_count].open = 0;
dropdown_states[dropdown_state_count].just_opened = 0;
dropdown_states[dropdown_state_count].scroll_offset = 0;
dropdown_states[dropdown_state_count].options = NULL;
dropdown_states[dropdown_state_count].option_count = 0;
dropdown_states[dropdown_state_count].selected_index = NULL;
dropdown_states[dropdown_state_count].touch_pressed = 0;
@@ -2068,17 +2017,9 @@ ui_draw_dropdown_button(int id, int x, int y, int w, int h,
state->y = y;
state->w = w;
state->h = h;
state->selected_index = selected_index;
if(option_count < 0)
option_count = 0;
if(option_count > MAX_DROPDOWN_OPTIONS)
option_count = MAX_DROPDOWN_OPTIONS;
state->options = options;
state->option_count = option_count;
for(int i = 0; i < option_count; i++) {
snprintf(state->option_text[i], sizeof(state->option_text[i]), "%s",
options != NULL && options[i] != NULL ? options[i] : "");
state->options[i] = state->option_text[i];
}
state->selected_index = selected_index;
if(hover)
ui_mark_clickable();
@@ -2097,10 +2038,7 @@ ui_draw_dropdown_button(int id, int x, int y, int w, int h,
DrawRectangleRounded(btn_bounds, 0.3f, 8, flint_darken(c_bg, 8));
/* Draw current selection text, clipped before the X icon. */
int current_index = selected_index != NULL ? *selected_index : 0;
if(current_index < 0 || current_index >= option_count)
current_index = 0;
const char *current_name = option_count > 0 ? state->options[current_index] : "";
const char *current_name = options[*selected_index];
int text_x = x + flint_px(12);
int text_w = arrow_x - arrow_size - flint_px(8) - text_x;
if(text_w > 0) {
@@ -2131,7 +2069,7 @@ ui_draw_dropdown_menu(int id)
UIDropdownState *state = get_or_create_dropdown_state(id);
int changed = 0;
if(!state->open || state->option_count <= 0 || state->selected_index == NULL)
if(!state->open || state->options == NULL || state->selected_index == NULL)
return 0;
int font = flint_ui_font();
@@ -2416,7 +2354,7 @@ ui_draw_nav_button_expand(int x, int y, int icon_size, int w, Texture2D icon,
* TAB BAR
* ================================================================ */
int
void
ui_draw_tab_bar(UITab *tabs, int count)
{
int bar_h = flint_clamp_px(58, 54, 66);
@@ -2473,7 +2411,6 @@ ui_draw_tab_bar(UITab *tabs, int count)
int group_x = side_margin + (available_w - total_w) / 2 + remainder / 2;
int button_y = bar_y + (bar_h - button_h) / 2;
int tab_hover = 0;
int clicked = -1;
DrawRectangle(0, bar_y, ui_view_width, bar_h, flint_darken(c_bg, 10));
DrawLine(0, bar_y, ui_view_width, bar_y, flint_darken(c_bg, 42));
@@ -2485,12 +2422,12 @@ ui_draw_tab_bar(UITab *tabs, int count)
if(ui_draw_nav_button_expand(x, button_y, button_size, w, tabs[i].icon,
tabs[i].label, show_labels, &tab_hover)) {
clicked = i;
if(tabs[i].on_click)
tabs[i].on_click(tabs[i].user_data);
}
x += w + group_gap;
}
return clicked;
}
/* ================================================================
+17 -131
View File
@@ -397,20 +397,21 @@ Nikdy ho nepoužívejte při řízení,
vestoje ani ve vodě.
---
[tutorial_step_method]
Simply follow 3 steps:
Stačí postupovat ve 4 krocích:
1. Breathe in and out 30 times.
2. Exhale and hold.
3. When you feel the urge to breathe, breathe in and hold for 15 seconds.
1. Dýchejte rytmicky.
2. Vydechněte a zadržte dech.
3. Zhluboka se nadechněte a zadržte dech.
4. Vydechněte a opakujte.
Exhale, then repeat the process.
Use the wrench icon %i to adjust rounds, breaths, speed, and pauses.
Pomocí ikony ozubeného kola %i upravíte kola, nádechy, rychlost a pauzy.
---
[tutorial_step_breathe]
Breathe in and out 30 times.
Naplňte plíce úplně a potom nechte dech volně odejít.
Find a rhythm that feels natural to you: steady and quick, while still breathing fully.
Tímto posuvníkem nastavíte tempo dechového kruhu.
Najděte rytmus, který vám připadá přirozený.
---
[tutorial_step_progressive_speed]
Postupná rychlost usnadňuje vstup do prvního kola.
@@ -418,14 +419,17 @@ Postupná rychlost usnadňuje vstup do prvního kola.
Když je zapnutá, první kolo začne rychlostí 1 pro prvních 5 nádechů a potom se postupně zvýší na vámi vybranou rychlost.
---
[tutorial_step_exhale_hold]
After 30 breaths, exhale and hold as long as you can.
Po dechovém kole
normálně vydechněte a zadržte dech.
When you feel the urge to breathe, press the BREATH button.
Uvolněte se, až si tělo řekne
o vzduch. Nenuťte to.
---
[tutorial_step_inhale_hold]
Inhale fully and hold for 15 seconds.
Plně se nadechněte a zadržte dech asi na 15 sekund.
Exhale, and the next round will begin.
Potom vydechněte a začněte další kolo.
Časem může každé kolo působit hlouběji.
---
[tutorial_skip_button]
PŘESKOČIT
@@ -490,121 +494,3 @@ Na šířku
[orientation_sensor]
Senzor
---
[back_button]
Back
---
[close_button]
Close
---
[sync_account_title]
Account
---
[sync_configure_account_button]
Configure Account
---
[sync_create_account_button]
Create Account
---
[sync_account_created]
Account created
---
[sync_account_create_failed]
Could not create account
---
[sync_import_key_button]
Import .key File
---
[sync_import_key_dialog_title]
Import Account Key
---
[sync_private_key_imported]
Account key imported
---
[sync_private_key_import_failed]
Could not import account key
---
[sync_private_key_import_cancelled]
Account key import cancelled
---
[sync_liboqs_unavailable]
liboqs is not built for this target.
---
[sync_public_id_label]
Public ID
---
[sync_copy_id_button]
Copy ID
---
[sync_public_id_copied]
Public ID copied
---
[sync_backup_key_button]
Backup Key
---
[sync_remote_label]
Remote
---
[sync_connect_button]
Connect
---
[sync_connected_button]
Connected
---
[sync_server_url_invalid]
Use https:// or loopback like localhost:8080
---
[sync_server_saved]
Sync server saved
---
[sync_connected]
Remote sync complete
---
[sync_failed]
Remote sync failed
---
[sync_unavailable]
Remote sync is not available on this platform
---
[sync_no_account]
Create an account before connecting
---
[sync_auth_failed]
Remote rejected this account
---
[sync_backup_warning]
Save this private key somewhere you control. Anyone with it can claim this account.
---
[sync_backup_title]
Backup Account Key
---
[sync_save_key_file_button]
Save .key File
---
[sync_save_key_dialog_title]
Save Account Key
---
[sync_private_key_backup_saved]
Account key backup saved
---
[sync_private_key_backup_failed]
Could not save account key backup
---
[sync_private_key_backup_cancelled]
Account key backup cancelled
---
[sync_delete_account_button]
Delete Account
---
[sync_delete_account_title]
Delete Account?
---
[sync_delete_account_message]
Delete this account from the remote server and this device? This cannot be undone.
---
[sync_account_deleted]
Account deleted
---
[sync_account_delete_cancelled]
Account deletion cancelled
---
+17 -131
View File
@@ -397,20 +397,21 @@ Benutzen Sie sie niemals beim Fahren,
Stehen oder im Wasser.
---
[tutorial_step_method]
Simply follow 3 steps:
Folgen Sie einfach 4 Schritten:
1. Breathe in and out 30 times.
2. Exhale and hold.
3. When you feel the urge to breathe, breathe in and hold for 15 seconds.
1. Atmen Sie rhythmisch.
2. Atmen Sie aus und halten Sie.
3. Atmen Sie tief ein und halten Sie.
4. Atmen Sie aus und wiederholen Sie.
Exhale, then repeat the process.
Use the wrench icon %i to adjust rounds, breaths, speed, and pauses.
Nutzen Sie das Schraubenschlüssel-Symbol %i, um Runden, Atemzüge, Geschwindigkeit und Pausen anzupassen.
---
[tutorial_step_breathe]
Breathe in and out 30 times.
Füllen Sie Ihre Lungen vollständig, dann lassen Sie den Atem herausfließen.
Find a rhythm that feels natural to you: steady and quick, while still breathing fully.
Nutzen Sie diesen Schieberegler, um das Tempo des Atemkreises einzustellen.
Finden Sie einen Rhythmus, der sich natürlich für Sie anfühlt.
---
[tutorial_step_progressive_speed]
Progressive Geschwindigkeit macht den Einstieg in die erste Runde leichter.
@@ -418,14 +419,17 @@ Progressive Geschwindigkeit macht den Einstieg in die erste Runde leichter.
Wenn sie aktiviert ist, beginnt die erste Runde bei Geschwindigkeit 1 für die ersten 5 Atemzüge und steigt dann schrittweise auf Ihre gewählte Geschwindigkeit.
---
[tutorial_step_exhale_hold]
After 30 breaths, exhale and hold as long as you can.
Nach der Atemrunde,
atmen Sie normal aus und halten Sie.
When you feel the urge to breathe, press the BREATH button.
Lassen Sie los, wenn Ihr Körper
nach Luft verlangt. Zwängen Sie es nicht.
---
[tutorial_step_inhale_hold]
Inhale fully and hold for 15 seconds.
Atmen Sie vollständig ein und halten Sie etwa 15 Sekunden.
Exhale, and the next round will begin.
Dann atmen Sie aus und beginnen die nächste Runde.
Mit der Zeit kann sich jede Runde tiefer anfühlen.
---
[tutorial_skip_button]
SKIP
@@ -490,121 +494,3 @@ Querformat
[orientation_sensor]
Sensor
---
[back_button]
Back
---
[close_button]
Close
---
[sync_account_title]
Account
---
[sync_configure_account_button]
Configure Account
---
[sync_create_account_button]
Create Account
---
[sync_account_created]
Account created
---
[sync_account_create_failed]
Could not create account
---
[sync_import_key_button]
Import .key File
---
[sync_import_key_dialog_title]
Import Account Key
---
[sync_private_key_imported]
Account key imported
---
[sync_private_key_import_failed]
Could not import account key
---
[sync_private_key_import_cancelled]
Account key import cancelled
---
[sync_liboqs_unavailable]
liboqs is not built for this target.
---
[sync_public_id_label]
Public ID
---
[sync_copy_id_button]
Copy ID
---
[sync_public_id_copied]
Public ID copied
---
[sync_backup_key_button]
Backup Key
---
[sync_remote_label]
Remote
---
[sync_connect_button]
Connect
---
[sync_connected_button]
Connected
---
[sync_server_url_invalid]
Use https:// or loopback like localhost:8080
---
[sync_server_saved]
Sync server saved
---
[sync_connected]
Remote sync complete
---
[sync_failed]
Remote sync failed
---
[sync_unavailable]
Remote sync is not available on this platform
---
[sync_no_account]
Create an account before connecting
---
[sync_auth_failed]
Remote rejected this account
---
[sync_backup_warning]
Save this private key somewhere you control. Anyone with it can claim this account.
---
[sync_backup_title]
Backup Account Key
---
[sync_save_key_file_button]
Save .key File
---
[sync_save_key_dialog_title]
Save Account Key
---
[sync_private_key_backup_saved]
Account key backup saved
---
[sync_private_key_backup_failed]
Could not save account key backup
---
[sync_private_key_backup_cancelled]
Account key backup cancelled
---
[sync_delete_account_button]
Delete Account
---
[sync_delete_account_title]
Delete Account?
---
[sync_delete_account_message]
Delete this account from the remote server and this device? This cannot be undone.
---
[sync_account_deleted]
Account deleted
---
[sync_account_delete_cancelled]
Account deletion cancelled
---
+15 -129
View File
@@ -418,20 +418,21 @@ Never use it while driving,
standing, or in water.
---
[tutorial_step_method]
Simply follow 3 steps:
Simply follow 4 steps:
1. Breathe in and out 30 times.
1. Breathe rhythmically.
2. Exhale and hold.
3. When you feel the urge to breathe, breathe in and hold for 15 seconds.
Exhale, then repeat the process.
3. Inhale deeply and hold.
4. Exhale and repeat.
Use the wrench icon %i to adjust rounds, breaths, speed, and pauses.
---
[tutorial_step_breathe]
Breathe in and out 30 times.
Fill your lungs fully, then let the breath flow out.
Find a rhythm that feels natural to you: steady and quick, while still breathing fully.
Use this slider to set the pace of the breathing circle.
Find a rhythm that feels natural for you.
---
[tutorial_step_progressive_speed]
Progressive speed makes the first round easier to enter.
@@ -439,14 +440,17 @@ Progressive speed makes the first round easier to enter.
When it is on, the first round starts slower, then gradually increases to your selected speed.
---
[tutorial_step_exhale_hold]
After 30 breaths, exhale and hold as long as you can.
Exhale normally and hold.
When you feel the urge to breathe, press the BREATH button.
The center number keeps counting. Circle mode adds layered progress lines.
Release when your body asks for air.
---
[tutorial_step_inhale_hold]
Inhale fully and hold for 15 seconds.
Inhale fully and hold for about 15 seconds.
Exhale, and the next round will begin.
Then exhale and begin the next round.
Over time, each round may feel deeper.
---
[tutorial_skip_button]
SKIP
@@ -490,121 +494,3 @@ Delete this round? This cannot be undone.
[delete_button]
Delete
---
[back_button]
Back
---
[close_button]
Close
---
[sync_account_title]
Account
---
[sync_configure_account_button]
Configure Account
---
[sync_create_account_button]
Create Account
---
[sync_account_created]
Account created
---
[sync_account_create_failed]
Could not create account
---
[sync_import_key_button]
Import .key File
---
[sync_import_key_dialog_title]
Import Account Key
---
[sync_private_key_imported]
Account key imported
---
[sync_private_key_import_failed]
Could not import account key
---
[sync_private_key_import_cancelled]
Account key import cancelled
---
[sync_liboqs_unavailable]
liboqs is not built for this target.
---
[sync_public_id_label]
Public ID
---
[sync_copy_id_button]
Copy ID
---
[sync_public_id_copied]
Public ID copied
---
[sync_backup_key_button]
Backup Key
---
[sync_remote_label]
Remote
---
[sync_connect_button]
Connect
---
[sync_connected_button]
Connected
---
[sync_server_url_invalid]
Use https:// or loopback like localhost:8080
---
[sync_server_saved]
Sync server saved
---
[sync_connected]
Remote sync complete
---
[sync_failed]
Remote sync failed
---
[sync_unavailable]
Remote sync is not available on this platform
---
[sync_no_account]
Create an account before connecting
---
[sync_auth_failed]
Remote rejected this account
---
[sync_backup_warning]
Save this private key somewhere you control. Anyone with it can claim this account.
---
[sync_backup_title]
Backup Account Key
---
[sync_save_key_file_button]
Save .key File
---
[sync_save_key_dialog_title]
Save Account Key
---
[sync_private_key_backup_saved]
Account key backup saved
---
[sync_private_key_backup_failed]
Could not save account key backup
---
[sync_private_key_backup_cancelled]
Account key backup cancelled
---
[sync_delete_account_button]
Delete Account
---
[sync_delete_account_title]
Delete Account?
---
[sync_delete_account_message]
Delete this account from the remote server and this device? This cannot be undone.
---
[sync_account_deleted]
Account deleted
---
[sync_account_delete_cancelled]
Account deletion cancelled
---
+17 -131
View File
@@ -397,20 +397,21 @@ Nunca la use mientras conduce,
de pie o en el agua.
---
[tutorial_step_method]
Simply follow 3 steps:
Simplemente siga 4 pasos:
1. Breathe in and out 30 times.
2. Exhale and hold.
3. When you feel the urge to breathe, breathe in and hold for 15 seconds.
1. Respire rítmicamente.
2. Exhale y retenga.
3. Inhale profundamente y retenga.
4. Exhale y repita.
Exhale, then repeat the process.
Use the wrench icon %i to adjust rounds, breaths, speed, and pauses.
Use el icono de llave %i para ajustar rondas, respiraciones, velocidad y pausas.
---
[tutorial_step_breathe]
Breathe in and out 30 times.
Llene sus pulmones completamente, luego deje que el respiración fluya hacia afuera.
Find a rhythm that feels natural to you: steady and quick, while still breathing fully.
Use este control deslizante para establecer el ritmo del círculo de respiración.
Encuentre un ritmo que se sienta natural para usted.
---
[tutorial_step_progressive_speed]
La velocidad progresiva hace que la primera ronda sea más fácil de empezar.
@@ -418,14 +419,17 @@ La velocidad progresiva hace que la primera ronda sea más fácil de empezar.
Cuando está activada, la primera ronda comienza en velocidad 1 durante las primeras 5 respiraciones y luego aumenta gradualmente hasta la velocidad elegida.
---
[tutorial_step_exhale_hold]
After 30 breaths, exhale and hold as long as you can.
Después de la ronda de respiración,
exhale normalmente y retenga.
When you feel the urge to breathe, press the BREATH button.
Suelte cuando su cuerpo pida
aire. No lo fuerce.
---
[tutorial_step_inhale_hold]
Inhale fully and hold for 15 seconds.
Inhale completamente y retenga unos 15 segundos.
Exhale, and the next round will begin.
Luego exhale y comience la siguiente ronda.
Con el tiempo, cada ronda puede sentirse más profunda.
---
[tutorial_skip_button]
OMITIR
@@ -490,121 +494,3 @@ Horizontal
[orientation_sensor]
Sensor
---
[back_button]
Back
---
[close_button]
Close
---
[sync_account_title]
Account
---
[sync_configure_account_button]
Configure Account
---
[sync_create_account_button]
Create Account
---
[sync_account_created]
Account created
---
[sync_account_create_failed]
Could not create account
---
[sync_import_key_button]
Import .key File
---
[sync_import_key_dialog_title]
Import Account Key
---
[sync_private_key_imported]
Account key imported
---
[sync_private_key_import_failed]
Could not import account key
---
[sync_private_key_import_cancelled]
Account key import cancelled
---
[sync_liboqs_unavailable]
liboqs is not built for this target.
---
[sync_public_id_label]
Public ID
---
[sync_copy_id_button]
Copy ID
---
[sync_public_id_copied]
Public ID copied
---
[sync_backup_key_button]
Backup Key
---
[sync_remote_label]
Remote
---
[sync_connect_button]
Connect
---
[sync_connected_button]
Connected
---
[sync_server_url_invalid]
Use https:// or loopback like localhost:8080
---
[sync_server_saved]
Sync server saved
---
[sync_connected]
Remote sync complete
---
[sync_failed]
Remote sync failed
---
[sync_unavailable]
Remote sync is not available on this platform
---
[sync_no_account]
Create an account before connecting
---
[sync_auth_failed]
Remote rejected this account
---
[sync_backup_warning]
Save this private key somewhere you control. Anyone with it can claim this account.
---
[sync_backup_title]
Backup Account Key
---
[sync_save_key_file_button]
Save .key File
---
[sync_save_key_dialog_title]
Save Account Key
---
[sync_private_key_backup_saved]
Account key backup saved
---
[sync_private_key_backup_failed]
Could not save account key backup
---
[sync_private_key_backup_cancelled]
Account key backup cancelled
---
[sync_delete_account_button]
Delete Account
---
[sync_delete_account_title]
Delete Account?
---
[sync_delete_account_message]
Delete this account from the remote server and this device? This cannot be undone.
---
[sync_account_deleted]
Account deleted
---
[sync_account_delete_cancelled]
Account deletion cancelled
---
+17 -131
View File
@@ -397,20 +397,21 @@ Ne l'utilisez jamais en conduisant,
debout ou dans l'eau.
---
[tutorial_step_method]
Simply follow 3 steps:
Suivez simplement 4 étapes :
1. Breathe in and out 30 times.
2. Exhale and hold.
3. When you feel the urge to breathe, breathe in and hold for 15 seconds.
1. Respirez en rythme.
2. Expirez et retenez.
3. Inspirez profondément et retenez.
4. Expirez et répétez.
Exhale, then repeat the process.
Use the wrench icon %i to adjust rounds, breaths, speed, and pauses.
Utilisez l'icône de clé %i pour régler les cycles, respirations, vitesse et pauses.
---
[tutorial_step_breathe]
Breathe in and out 30 times.
Remplissez complètement vos poumons, puis laissez le souffle sortir.
Find a rhythm that feels natural to you: steady and quick, while still breathing fully.
Utilisez ce curseur pour régler le rythme du cercle de respiration.
Trouvez un rythme naturel pour vous.
---
[tutorial_step_progressive_speed]
La vitesse progressive rend le premier cycle plus facile à commencer.
@@ -418,14 +419,17 @@ La vitesse progressive rend le premier cycle plus facile à commencer.
Quand elle est activée, le premier cycle commence à la vitesse 1 pendant les 5 premières respirations, puis augmente progressivement jusqu'à la vitesse choisie.
---
[tutorial_step_exhale_hold]
After 30 breaths, exhale and hold as long as you can.
Après le cycle de respiration,
expirez normalement et retenez.
When you feel the urge to breathe, press the BREATH button.
Relâchez quand votre corps demande
de l'air. Ne forcez pas.
---
[tutorial_step_inhale_hold]
Inhale fully and hold for 15 seconds.
Inspirez complètement et retenez environ 15 secondes.
Exhale, and the next round will begin.
Puis expirez et commencez le cycle suivant.
Avec le temps, chaque cycle peut sembler plus profond.
---
[tutorial_skip_button]
SKIP
@@ -490,121 +494,3 @@ Paysage
[orientation_sensor]
Capteur
---
[back_button]
Back
---
[close_button]
Close
---
[sync_account_title]
Account
---
[sync_configure_account_button]
Configure Account
---
[sync_create_account_button]
Create Account
---
[sync_account_created]
Account created
---
[sync_account_create_failed]
Could not create account
---
[sync_import_key_button]
Import .key File
---
[sync_import_key_dialog_title]
Import Account Key
---
[sync_private_key_imported]
Account key imported
---
[sync_private_key_import_failed]
Could not import account key
---
[sync_private_key_import_cancelled]
Account key import cancelled
---
[sync_liboqs_unavailable]
liboqs is not built for this target.
---
[sync_public_id_label]
Public ID
---
[sync_copy_id_button]
Copy ID
---
[sync_public_id_copied]
Public ID copied
---
[sync_backup_key_button]
Backup Key
---
[sync_remote_label]
Remote
---
[sync_connect_button]
Connect
---
[sync_connected_button]
Connected
---
[sync_server_url_invalid]
Use https:// or loopback like localhost:8080
---
[sync_server_saved]
Sync server saved
---
[sync_connected]
Remote sync complete
---
[sync_failed]
Remote sync failed
---
[sync_unavailable]
Remote sync is not available on this platform
---
[sync_no_account]
Create an account before connecting
---
[sync_auth_failed]
Remote rejected this account
---
[sync_backup_warning]
Save this private key somewhere you control. Anyone with it can claim this account.
---
[sync_backup_title]
Backup Account Key
---
[sync_save_key_file_button]
Save .key File
---
[sync_save_key_dialog_title]
Save Account Key
---
[sync_private_key_backup_saved]
Account key backup saved
---
[sync_private_key_backup_failed]
Could not save account key backup
---
[sync_private_key_backup_cancelled]
Account key backup cancelled
---
[sync_delete_account_button]
Delete Account
---
[sync_delete_account_title]
Delete Account?
---
[sync_delete_account_message]
Delete this account from the remote server and this device? This cannot be undone.
---
[sync_account_deleted]
Account deleted
---
[sync_account_delete_cancelled]
Account deletion cancelled
---
+17 -131
View File
@@ -397,20 +397,21 @@ Jangan gunakan saat mengemudi,
berdiri, atau di dalam air.
---
[tutorial_step_method]
Simply follow 3 steps:
Ikuti 4 langkah sederhana:
1. Breathe in and out 30 times.
2. Exhale and hold.
3. When you feel the urge to breathe, breathe in and hold for 15 seconds.
1. Bernapas secara ritmis.
2. Buang napas dan tahan.
3. Tarik napas dalam dan tahan.
4. Buang napas dan ulangi.
Exhale, then repeat the process.
Use the wrench icon %i to adjust rounds, breaths, speed, and pauses.
Gunakan ikon kunci pas %i untuk menyesuaikan ronde, nafas, kecepatan, dan jeda.
---
[tutorial_step_breathe]
Breathe in and out 30 times.
Isi paru-paru Anda sepenuhnya, lalu biarkan napas keluar.
Find a rhythm that feels natural to you: steady and quick, while still breathing fully.
Gunakan slider ini untuk mengatur kecepatan lingkaran pernapasan.
Temukan ritme yang terasa alami bagi Anda.
---
[tutorial_step_progressive_speed]
Kecepatan progresif membuat ronde pertama lebih mudah dimulai.
@@ -418,14 +419,17 @@ Kecepatan progresif membuat ronde pertama lebih mudah dimulai.
Saat aktif, ronde pertama dimulai pada kecepatan 1 untuk 5 nafas pertama, lalu bertambah hingga kecepatan yang dipilih.
---
[tutorial_step_exhale_hold]
After 30 breaths, exhale and hold as long as you can.
Setelah ronde pernapasan,
buang napas secara normal dan tahan.
When you feel the urge to breathe, press the BREATH button.
Lepaskan saat tubuh Anda
meminta udara. Jangan dipaksa.
---
[tutorial_step_inhale_hold]
Inhale fully and hold for 15 seconds.
Tarik napas sepenuhnya dan tahan sekitar 15 detik.
Exhale, and the next round will begin.
Lalu buang napas dan mulai ronde berikutnya.
Seiring waktu, setiap ronde mungkin terasa lebih dalam.
---
[tutorial_skip_button]
LEWATI
@@ -490,121 +494,3 @@ Lanskap
[orientation_sensor]
Sensor
---
[back_button]
Back
---
[close_button]
Close
---
[sync_account_title]
Account
---
[sync_configure_account_button]
Configure Account
---
[sync_create_account_button]
Create Account
---
[sync_account_created]
Account created
---
[sync_account_create_failed]
Could not create account
---
[sync_import_key_button]
Import .key File
---
[sync_import_key_dialog_title]
Import Account Key
---
[sync_private_key_imported]
Account key imported
---
[sync_private_key_import_failed]
Could not import account key
---
[sync_private_key_import_cancelled]
Account key import cancelled
---
[sync_liboqs_unavailable]
liboqs is not built for this target.
---
[sync_public_id_label]
Public ID
---
[sync_copy_id_button]
Copy ID
---
[sync_public_id_copied]
Public ID copied
---
[sync_backup_key_button]
Backup Key
---
[sync_remote_label]
Remote
---
[sync_connect_button]
Connect
---
[sync_connected_button]
Connected
---
[sync_server_url_invalid]
Use https:// or loopback like localhost:8080
---
[sync_server_saved]
Sync server saved
---
[sync_connected]
Remote sync complete
---
[sync_failed]
Remote sync failed
---
[sync_unavailable]
Remote sync is not available on this platform
---
[sync_no_account]
Create an account before connecting
---
[sync_auth_failed]
Remote rejected this account
---
[sync_backup_warning]
Save this private key somewhere you control. Anyone with it can claim this account.
---
[sync_backup_title]
Backup Account Key
---
[sync_save_key_file_button]
Save .key File
---
[sync_save_key_dialog_title]
Save Account Key
---
[sync_private_key_backup_saved]
Account key backup saved
---
[sync_private_key_backup_failed]
Could not save account key backup
---
[sync_private_key_backup_cancelled]
Account key backup cancelled
---
[sync_delete_account_button]
Delete Account
---
[sync_delete_account_title]
Delete Account?
---
[sync_delete_account_message]
Delete this account from the remote server and this device? This cannot be undone.
---
[sync_account_deleted]
Account deleted
---
[sync_account_delete_cancelled]
Account deletion cancelled
---
+17 -131
View File
@@ -413,20 +413,21 @@ Non usarla mai mentre guidi,
in piedi o in acqua.
---
[tutorial_step_method]
Simply follow 3 steps:
Segui semplicemente 4 passi:
1. Breathe in and out 30 times.
2. Exhale and hold.
3. When you feel the urge to breathe, breathe in and hold for 15 seconds.
1. Respira ritmicamente.
2. Espira e trattieni.
3. Inspira profondamente e trattieni.
4. Espira e ripeti.
Exhale, then repeat the process.
Use the wrench icon %i to adjust rounds, breaths, speed, and pauses.
Usa l'icona ingranaggio %i per regolare round, respiri, velocità e pause.
---
[tutorial_step_breathe]
Breathe in and out 30 times.
Riempi completamente i polmoni, poi lascia uscire il respiro.
Find a rhythm that feels natural to you: steady and quick, while still breathing fully.
Usa questo slider per impostare il ritmo del cerchio respiratorio.
Trova un ritmo che ti sembri naturale.
---
[tutorial_step_progressive_speed]
La velocità progressiva rende il primo round più facile da affrontare.
@@ -434,14 +435,17 @@ La velocità progressiva rende il primo round più facile da affrontare.
Quando è attiva, il primo round inizia più lentamente, poi aumenta gradualmente fino alla velocità selezionata.
---
[tutorial_step_exhale_hold]
After 30 breaths, exhale and hold as long as you can.
Espira normalmente e trattieni.
When you feel the urge to breathe, press the BREATH button.
Il numero centrale continua a contare. La modalità cerchio aggiunge linee di progresso sovrapposte.
Rilascia quando il corpo richiede aria.
---
[tutorial_step_inhale_hold]
Inhale fully and hold for 15 seconds.
Inspira completamente e trattieni per circa 15 secondi.
Exhale, and the next round will begin.
Poi espira e inizia il prossimo round.
Col tempo, ogni round potrebbe sembrare più profondo.
---
[tutorial_skip_button]
SALTA
@@ -488,121 +492,3 @@ Elimina
[meditation_music_attribution]
Musica di Elijah_K.
---
[back_button]
Back
---
[close_button]
Close
---
[sync_account_title]
Account
---
[sync_configure_account_button]
Configure Account
---
[sync_create_account_button]
Create Account
---
[sync_account_created]
Account created
---
[sync_account_create_failed]
Could not create account
---
[sync_import_key_button]
Import .key File
---
[sync_import_key_dialog_title]
Import Account Key
---
[sync_private_key_imported]
Account key imported
---
[sync_private_key_import_failed]
Could not import account key
---
[sync_private_key_import_cancelled]
Account key import cancelled
---
[sync_liboqs_unavailable]
liboqs is not built for this target.
---
[sync_public_id_label]
Public ID
---
[sync_copy_id_button]
Copy ID
---
[sync_public_id_copied]
Public ID copied
---
[sync_backup_key_button]
Backup Key
---
[sync_remote_label]
Remote
---
[sync_connect_button]
Connect
---
[sync_connected_button]
Connected
---
[sync_server_url_invalid]
Use https:// or loopback like localhost:8080
---
[sync_server_saved]
Sync server saved
---
[sync_connected]
Remote sync complete
---
[sync_failed]
Remote sync failed
---
[sync_unavailable]
Remote sync is not available on this platform
---
[sync_no_account]
Create an account before connecting
---
[sync_auth_failed]
Remote rejected this account
---
[sync_backup_warning]
Save this private key somewhere you control. Anyone with it can claim this account.
---
[sync_backup_title]
Backup Account Key
---
[sync_save_key_file_button]
Save .key File
---
[sync_save_key_dialog_title]
Save Account Key
---
[sync_private_key_backup_saved]
Account key backup saved
---
[sync_private_key_backup_failed]
Could not save account key backup
---
[sync_private_key_backup_cancelled]
Account key backup cancelled
---
[sync_delete_account_button]
Delete Account
---
[sync_delete_account_title]
Delete Account?
---
[sync_delete_account_message]
Delete this account from the remote server and this device? This cannot be undone.
---
[sync_account_deleted]
Account deleted
---
[sync_account_delete_cancelled]
Account deletion cancelled
---
+12 -132
View File
@@ -399,33 +399,31 @@ ON
立っているとき、水中では行わないでください。
---
[tutorial_step_method]
Simply follow 3 steps:
次の 4 つの手順に従います。
1. Breathe in and out 30 times.
2. Exhale and hold.
3. When you feel the urge to breathe, breathe in and hold for 15 seconds.
1. リズミカルに呼吸します。
2. 吐いて止めます。
3. 深く吸って止めます。
4. 吐いて繰り返します。
Exhale, then repeat the process.
Use the wrench icon %i to adjust rounds, breaths, speed, and pauses.
歯車アイコン %i でラウンド数、呼吸数、速度、一時停止を調整できます。
---
[tutorial_step_breathe]
Breathe in and out 30 times.
肺をいっぱいに満たしてから、息を自然に吐き出します。
Find a rhythm that feels natural to you: steady and quick, while still breathing fully.
このスライダーで呼吸のテンポを設定します。
---
[tutorial_step_progressive_speed]
段階的速度は、最初のラウンドに入りやすくします。
---
[tutorial_step_exhale_hold]
After 30 breaths, exhale and hold as long as you can.
呼吸ラウンドの後、
息を吐いて止めます。
When you feel the urge to breathe, press the BREATH button.
吸う必要を感じるまで止めます。
---
[tutorial_step_inhale_hold]
Inhale fully and hold for 15 seconds.
Exhale, and the next round will begin.
深く吸って、約 15 秒止めます。
---
[tutorial_skip_button]
スキップ
@@ -490,121 +488,3 @@ Inner Breeze データ書き出し
[orientation_sensor]
センサー
---
[back_button]
Back
---
[close_button]
Close
---
[sync_account_title]
Account
---
[sync_configure_account_button]
Configure Account
---
[sync_create_account_button]
Create Account
---
[sync_account_created]
Account created
---
[sync_account_create_failed]
Could not create account
---
[sync_import_key_button]
Import .key File
---
[sync_import_key_dialog_title]
Import Account Key
---
[sync_private_key_imported]
Account key imported
---
[sync_private_key_import_failed]
Could not import account key
---
[sync_private_key_import_cancelled]
Account key import cancelled
---
[sync_liboqs_unavailable]
liboqs is not built for this target.
---
[sync_public_id_label]
Public ID
---
[sync_copy_id_button]
Copy ID
---
[sync_public_id_copied]
Public ID copied
---
[sync_backup_key_button]
Backup Key
---
[sync_remote_label]
Remote
---
[sync_connect_button]
Connect
---
[sync_connected_button]
Connected
---
[sync_server_url_invalid]
Use https:// or loopback like localhost:8080
---
[sync_server_saved]
Sync server saved
---
[sync_connected]
Remote sync complete
---
[sync_failed]
Remote sync failed
---
[sync_unavailable]
Remote sync is not available on this platform
---
[sync_no_account]
Create an account before connecting
---
[sync_auth_failed]
Remote rejected this account
---
[sync_backup_warning]
Save this private key somewhere you control. Anyone with it can claim this account.
---
[sync_backup_title]
Backup Account Key
---
[sync_save_key_file_button]
Save .key File
---
[sync_save_key_dialog_title]
Save Account Key
---
[sync_private_key_backup_saved]
Account key backup saved
---
[sync_private_key_backup_failed]
Could not save account key backup
---
[sync_private_key_backup_cancelled]
Account key backup cancelled
---
[sync_delete_account_button]
Delete Account
---
[sync_delete_account_title]
Delete Account?
---
[sync_delete_account_message]
Delete this account from the remote server and this device? This cannot be undone.
---
[sync_account_deleted]
Account deleted
---
[sync_account_delete_cancelled]
Account deletion cancelled
---
+17 -131
View File
@@ -412,20 +412,21 @@ In / Out
운전 중, 서 있거나 물속에서는 사용하지 마세요.
---
[tutorial_step_method]
Simply follow 3 steps:
다음 4단계를 따르세요:
1. Breathe in and out 30 times.
2. Exhale and hold.
3. When you feel the urge to breathe, breathe in and hold for 15 seconds.
1. 리듬적으로 호흡합니다.
2. 내뱉고 참습니다.
3. 깊게 들이마시고 참습니다.
4. 내뱉고 반복합니다.
Exhale, then repeat the process.
Use the wrench icon %i to adjust rounds, breaths, speed, and pauses.
톱니바퀴 아이콘 %i을 사용하여 라운드, 호흡, 속도 및 일시정지를 조정할 수 있습니다.
---
[tutorial_step_breathe]
Breathe in and out 30 times.
폐를 완전히 채운 후 자연스럽게 내뱉으세요.
Find a rhythm that feels natural to you: steady and quick, while still breathing fully.
이 슬라이더로 호흡 원의 속도를 설정합니다.
자연스러운 리듬을 찾아보세요.
---
[tutorial_step_progressive_speed]
점진적 속도는 첫 라운드를 쉽게 시작할 수 있게 해줍니다.
@@ -433,14 +434,17 @@ Find a rhythm that feels natural to you: steady and quick, while still breathing
켜면 첫 라운드가 느리게 시작된 후 점차 선택한 속도까지 증가합니다.
---
[tutorial_step_exhale_hold]
After 30 breaths, exhale and hold as long as you can.
자연스럽게 내뱉고 참습니다.
When you feel the urge to breathe, press the BREATH button.
중앙 숫자가 계속 카운트됩니다. 원형 모드는 여러 진행 막대를 표시합니다.
몸이 공기를 필요로 할 때 놓으세요.
---
[tutorial_step_inhale_hold]
Inhale fully and hold for 15 seconds.
완전히 들이마시고 약 15초간 참으세요.
Exhale, and the next round will begin.
그 후 내뱉고 다음 라운드를 시작하세요.
시간이 지날수록 각 라운드가 더 깊어질 수 있습니다.
---
[tutorial_skip_button]
건너뛰기
@@ -487,121 +491,3 @@ Inner Breeze 데이터 내보내기
[meditation_music_attribution]
음악: Elijah_K.
---
[back_button]
Back
---
[close_button]
Close
---
[sync_account_title]
Account
---
[sync_configure_account_button]
Configure Account
---
[sync_create_account_button]
Create Account
---
[sync_account_created]
Account created
---
[sync_account_create_failed]
Could not create account
---
[sync_import_key_button]
Import .key File
---
[sync_import_key_dialog_title]
Import Account Key
---
[sync_private_key_imported]
Account key imported
---
[sync_private_key_import_failed]
Could not import account key
---
[sync_private_key_import_cancelled]
Account key import cancelled
---
[sync_liboqs_unavailable]
liboqs is not built for this target.
---
[sync_public_id_label]
Public ID
---
[sync_copy_id_button]
Copy ID
---
[sync_public_id_copied]
Public ID copied
---
[sync_backup_key_button]
Backup Key
---
[sync_remote_label]
Remote
---
[sync_connect_button]
Connect
---
[sync_connected_button]
Connected
---
[sync_server_url_invalid]
Use https:// or loopback like localhost:8080
---
[sync_server_saved]
Sync server saved
---
[sync_connected]
Remote sync complete
---
[sync_failed]
Remote sync failed
---
[sync_unavailable]
Remote sync is not available on this platform
---
[sync_no_account]
Create an account before connecting
---
[sync_auth_failed]
Remote rejected this account
---
[sync_backup_warning]
Save this private key somewhere you control. Anyone with it can claim this account.
---
[sync_backup_title]
Backup Account Key
---
[sync_save_key_file_button]
Save .key File
---
[sync_save_key_dialog_title]
Save Account Key
---
[sync_private_key_backup_saved]
Account key backup saved
---
[sync_private_key_backup_failed]
Could not save account key backup
---
[sync_private_key_backup_cancelled]
Account key backup cancelled
---
[sync_delete_account_button]
Delete Account
---
[sync_delete_account_title]
Delete Account?
---
[sync_delete_account_message]
Delete this account from the remote server and this device? This cannot be undone.
---
[sync_account_deleted]
Account deleted
---
[sync_account_delete_cancelled]
Account deletion cancelled
---
+17 -131
View File
@@ -397,20 +397,21 @@ Nunca use enquanto dirige,
em pé ou na água.
---
[tutorial_step_method]
Simply follow 3 steps:
Basta seguir 4 passos:
1. Breathe in and out 30 times.
2. Exhale and hold.
3. When you feel the urge to breathe, breathe in and hold for 15 seconds.
1. Respire ritmicamente.
2. Expire e segure.
3. Inspire profundamente e segure.
4. Expire e repita.
Exhale, then repeat the process.
Use the wrench icon %i to adjust rounds, breaths, speed, and pauses.
Use o ícone de chave inglesa %i para ajustar rodadas, respirações, velocidade e pausas.
---
[tutorial_step_breathe]
Breathe in and out 30 times.
Encha totalmente os pulmões e deixe o ar sair.
Find a rhythm that feels natural to you: steady and quick, while still breathing fully.
Use este controle para definir o ritmo do círculo de respiração.
Encontre um ritmo que pareça natural para você.
---
[tutorial_step_progressive_speed]
A velocidade progressiva torna a primeira rodada mais fácil de começar.
@@ -418,14 +419,17 @@ A velocidade progressiva torna a primeira rodada mais fácil de começar.
Quando ativada, a primeira rodada começa na velocidade 1 nas primeiras 5 respirações e depois aumenta gradualmente até a velocidade escolhida.
---
[tutorial_step_exhale_hold]
After 30 breaths, exhale and hold as long as you can.
Depois da rodada de respiração,
expire normalmente e segure.
When you feel the urge to breathe, press the BREATH button.
Solte quando seu corpo pedir
ar. Não force.
---
[tutorial_step_inhale_hold]
Inhale fully and hold for 15 seconds.
Inspire totalmente e segure por cerca de 15 segundos.
Exhale, and the next round will begin.
Depois expire e comece a próxima rodada.
Com o tempo, cada rodada pode parecer mais profunda.
---
[tutorial_skip_button]
SKIP
@@ -490,121 +494,3 @@ Paisagem
[orientation_sensor]
Sensor
---
[back_button]
Back
---
[close_button]
Close
---
[sync_account_title]
Account
---
[sync_configure_account_button]
Configure Account
---
[sync_create_account_button]
Create Account
---
[sync_account_created]
Account created
---
[sync_account_create_failed]
Could not create account
---
[sync_import_key_button]
Import .key File
---
[sync_import_key_dialog_title]
Import Account Key
---
[sync_private_key_imported]
Account key imported
---
[sync_private_key_import_failed]
Could not import account key
---
[sync_private_key_import_cancelled]
Account key import cancelled
---
[sync_liboqs_unavailable]
liboqs is not built for this target.
---
[sync_public_id_label]
Public ID
---
[sync_copy_id_button]
Copy ID
---
[sync_public_id_copied]
Public ID copied
---
[sync_backup_key_button]
Backup Key
---
[sync_remote_label]
Remote
---
[sync_connect_button]
Connect
---
[sync_connected_button]
Connected
---
[sync_server_url_invalid]
Use https:// or loopback like localhost:8080
---
[sync_server_saved]
Sync server saved
---
[sync_connected]
Remote sync complete
---
[sync_failed]
Remote sync failed
---
[sync_unavailable]
Remote sync is not available on this platform
---
[sync_no_account]
Create an account before connecting
---
[sync_auth_failed]
Remote rejected this account
---
[sync_backup_warning]
Save this private key somewhere you control. Anyone with it can claim this account.
---
[sync_backup_title]
Backup Account Key
---
[sync_save_key_file_button]
Save .key File
---
[sync_save_key_dialog_title]
Save Account Key
---
[sync_private_key_backup_saved]
Account key backup saved
---
[sync_private_key_backup_failed]
Could not save account key backup
---
[sync_private_key_backup_cancelled]
Account key backup cancelled
---
[sync_delete_account_button]
Delete Account
---
[sync_delete_account_title]
Delete Account?
---
[sync_delete_account_message]
Delete this account from the remote server and this device? This cannot be undone.
---
[sync_account_deleted]
Account deleted
---
[sync_account_delete_cancelled]
Account deletion cancelled
---
+12 -132
View File
@@ -397,33 +397,31 @@ Deleted %lld sessions
站立或水中时进行。
---
[tutorial_step_method]
Simply follow 3 steps:
按照 4 个步骤进行:
1. Breathe in and out 30 times.
2. Exhale and hold.
3. When you feel the urge to breathe, breathe in and hold for 15 seconds.
1. 有节奏地呼吸。
2. 呼气并屏息。
3. 深吸气并屏息。
4. 呼气并重复。
Exhale, then repeat the process.
Use the wrench icon %i to adjust rounds, breaths, speed, and pauses.
使用齿轮图标 %i 调整轮次、呼吸次数、速度和暂停时间。
---
[tutorial_step_breathe]
Breathe in and out 30 times.
充分充满肺部,然后让呼吸自然流出。
Find a rhythm that feels natural to you: steady and quick, while still breathing fully.
使用这个滑块设置呼吸圆的节奏。
---
[tutorial_step_progressive_speed]
递进速度会让第一轮更容易进入。
---
[tutorial_step_exhale_hold]
After 30 breaths, exhale and hold as long as you can.
完成一轮呼吸后,
呼气并屏住。
When you feel the urge to breathe, press the BREATH button.
屏息到需要吸气为止。
---
[tutorial_step_inhale_hold]
Inhale fully and hold for 15 seconds.
Exhale, and the next round will begin.
充分吸气并屏住约 15 秒。
---
[tutorial_skip_button]
跳过
@@ -488,121 +486,3 @@ Inner Breeze 数据导出
[orientation_sensor]
传感器
---
[back_button]
Back
---
[close_button]
Close
---
[sync_account_title]
Account
---
[sync_configure_account_button]
Configure Account
---
[sync_create_account_button]
Create Account
---
[sync_account_created]
Account created
---
[sync_account_create_failed]
Could not create account
---
[sync_import_key_button]
Import .key File
---
[sync_import_key_dialog_title]
Import Account Key
---
[sync_private_key_imported]
Account key imported
---
[sync_private_key_import_failed]
Could not import account key
---
[sync_private_key_import_cancelled]
Account key import cancelled
---
[sync_liboqs_unavailable]
liboqs is not built for this target.
---
[sync_public_id_label]
Public ID
---
[sync_copy_id_button]
Copy ID
---
[sync_public_id_copied]
Public ID copied
---
[sync_backup_key_button]
Backup Key
---
[sync_remote_label]
Remote
---
[sync_connect_button]
Connect
---
[sync_connected_button]
Connected
---
[sync_server_url_invalid]
Use https:// or loopback like localhost:8080
---
[sync_server_saved]
Sync server saved
---
[sync_connected]
Remote sync complete
---
[sync_failed]
Remote sync failed
---
[sync_unavailable]
Remote sync is not available on this platform
---
[sync_no_account]
Create an account before connecting
---
[sync_auth_failed]
Remote rejected this account
---
[sync_backup_warning]
Save this private key somewhere you control. Anyone with it can claim this account.
---
[sync_backup_title]
Backup Account Key
---
[sync_save_key_file_button]
Save .key File
---
[sync_save_key_dialog_title]
Save Account Key
---
[sync_private_key_backup_saved]
Account key backup saved
---
[sync_private_key_backup_failed]
Could not save account key backup
---
[sync_private_key_backup_cancelled]
Account key backup cancelled
---
[sync_delete_account_button]
Delete Account
---
[sync_delete_account_title]
Delete Account?
---
[sync_delete_account_message]
Delete this account from the remote server and this device? This cannot be undone.
---
[sync_account_deleted]
Account deleted
---
[sync_account_delete_cancelled]
Account deletion cancelled
---
-25
View File
@@ -1,25 +0,0 @@
{
"manifest_version": 3,
"name": "Inner Breeze",
"short_name": "Inbe",
"version": "__APP_VERSION__",
"description": "Breathing, meditation, habit tracking, and encrypted sync.",
"icons": {
"16": "icons/icon-16.png",
"32": "icons/icon-32.png",
"48": "icons/icon-48.png",
"128": "icons/icon-128.png"
},
"action": {
"default_title": "Open Inner Breeze",
"default_icon": {
"16": "icons/icon-16.png",
"32": "icons/icon-32.png",
"48": "icons/icon-48.png",
"128": "icons/icon-128.png"
}
},
"background": {
"service_worker": "service_worker.js"
}
}
@@ -1,10 +0,0 @@
const appUrl = "__WEB_APP_URL__";
chrome.action.onClicked.addListener(() => {
chrome.tabs.create({ url: appUrl });
});
chrome.runtime.onInstalled.addListener((details) => {
if (details.reason === "install")
chrome.tabs.create({ url: appUrl });
});
+87 -512
View File
@@ -1,14 +1,6 @@
#if defined(_WIN32)
#define WIN32_LEAN_AND_MEAN
#define NOGDI
#define NOUSER
#define MMNOSOUND
#define NOMINMAX
#endif
#include "app.h"
#include "data.h"
#include "flint_locale.h"
#include "locale.h"
#include "screens/language_screen.h"
#include "screens/manual_screen.h"
#include "screens/settings/settings_screen.h"
@@ -16,8 +8,6 @@
#include "practices/practice_registry.h"
#include "device_preferences.h"
#include "storage.h"
#include "sync_account.h"
#include "sync_client.h"
#include "theme.h"
#include "version.h"
#include "flint_clip.h"
@@ -35,11 +25,6 @@
#if defined(PLATFORM_WEB)
#include <emscripten.h>
#elif defined(_WIN32)
#include <windows.h>
#else
#include <pthread.h>
#include <unistd.h>
#endif
#ifdef __ANDROID__
@@ -51,8 +36,6 @@ void set_global_inbe_app(InbeApp *app);
#define INBE_DEFAULT_WIDTH 320
#define INBE_DEFAULT_HEIGHT 560
#define INBE_SYNC_SERVER_URL_KEY "sync_server_url"
#define INBE_SYNC_INPUT_QUIET_SECONDS 0.45
InbeConfig config = {
.title = "Inner Breeze",
@@ -62,413 +45,6 @@ InbeConfig config = {
.title_custom = 1
};
static double g_dirty_sync_at = 0.0;
static double g_last_sync_input_at = 0.0;
static int g_sync_running = 0;
static int g_sync_refresh_pending = 0;
static int g_remote_sync_due = 0;
#if !defined(PLATFORM_WEB)
typedef struct InbeSyncWorkerArgs {
char url[256];
} InbeSyncWorkerArgs;
#if defined(_WIN32)
#define sync_thread_return DWORD WINAPI
#define sync_thread_done 0
#define sync_sleep(seconds) Sleep((DWORD)((seconds) * 1000))
#define sync_lock() AcquireSRWLockExclusive(&g_sync_mutex)
#define sync_unlock() ReleaseSRWLockExclusive(&g_sync_mutex)
typedef HANDLE SyncThread;
static SRWLOCK g_sync_mutex = SRWLOCK_INIT;
static int
sync_thread_start(SyncThread *thread, LPTHREAD_START_ROUTINE func, void *arg)
{
*thread = CreateThread(NULL, 0, func, arg, 0, NULL);
return *thread != NULL;
}
static void
sync_thread_detach(SyncThread thread)
{
CloseHandle(thread);
}
#else
#define sync_thread_return void *
#define sync_thread_done NULL
#define sync_sleep(seconds) sleep(seconds)
#define sync_lock() pthread_mutex_lock(&g_sync_mutex)
#define sync_unlock() pthread_mutex_unlock(&g_sync_mutex)
typedef pthread_t SyncThread;
static pthread_mutex_t g_sync_mutex = PTHREAD_MUTEX_INITIALIZER;
static int
sync_thread_start(SyncThread *thread, void *(*func)(void *), void *arg)
{
return pthread_create(thread, NULL, func, arg) == 0;
}
static void
sync_thread_detach(SyncThread thread)
{
pthread_detach(thread);
}
#endif
static int g_sync_finished = 0;
static int g_sync_finished_result = INBE_SYNC_CLIENT_OK;
static int g_sync_finished_changed = 0;
static int g_sync_events_running = 0;
static char g_sync_events_url[256];
static sync_thread_return
app_sync_worker(void *userdata)
{
InbeSyncWorkerArgs *args = userdata;
InbeSyncClientResult result = INBE_SYNC_CLIENT_INVALID_URL;
int changed = 0;
if(args != NULL) {
result = sync_client_sync(args->url);
changed = result == INBE_SYNC_CLIENT_OK && storage_last_sync_changed();
free(args);
}
sync_lock();
g_sync_finished_result = result;
g_sync_finished_changed = changed;
g_sync_finished = 1;
g_sync_running = 0;
sync_unlock();
return sync_thread_done;
}
static void
app_collect_finished_sync(void)
{
int finished;
int result;
int changed;
sync_lock();
finished = g_sync_finished;
result = g_sync_finished_result;
changed = g_sync_finished_changed;
g_sync_finished = 0;
sync_unlock();
if(!finished)
return;
if(result == INBE_SYNC_CLIENT_OK) {
TraceLog(LOG_INFO, "SYNC: background sync complete changed=%d", changed);
if(changed)
g_sync_refresh_pending = 1;
} else {
TraceLog(LOG_WARNING, "SYNC: background sync failed result=%d name=%s",
result, sync_client_result_name(result));
}
}
static sync_thread_return
app_sync_events_worker(void *userdata)
{
InbeSyncWorkerArgs *args = userdata;
if(args == NULL)
return sync_thread_done;
for(;;) {
InbeSyncClientResult result;
sync_lock();
if(g_sync_running) {
sync_unlock();
sync_sleep(1);
continue;
}
sync_unlock();
result = sync_client_wait_for_remote_event(args->url);
sync_lock();
if(result == INBE_SYNC_CLIENT_OK)
g_remote_sync_due = 1;
sync_unlock();
if(result != INBE_SYNC_CLIENT_OK)
sync_sleep(2);
}
return sync_thread_done;
}
static void
app_ensure_sync_events(const char *url)
{
SyncThread thread;
InbeSyncWorkerArgs *args;
if(url == NULL || url[0] == '\0')
return;
sync_lock();
if(g_sync_events_running && strcmp(g_sync_events_url, url) == 0) {
sync_unlock();
return;
}
if(g_sync_events_running) {
sync_unlock();
return;
}
g_sync_events_running = 1;
g_remote_sync_due = 1;
snprintf(g_sync_events_url, sizeof(g_sync_events_url), "%s", url);
sync_unlock();
args = malloc(sizeof(*args));
if(args == NULL) {
sync_lock();
g_sync_events_running = 0;
g_sync_events_url[0] = '\0';
sync_unlock();
return;
}
snprintf(args->url, sizeof(args->url), "%s", url);
if(!sync_thread_start(&thread, app_sync_events_worker, args)) {
free(args);
sync_lock();
g_sync_events_running = 0;
g_sync_events_url[0] = '\0';
sync_unlock();
TraceLog(LOG_WARNING, "SYNC: failed to start websocket event thread");
return;
}
sync_thread_detach(thread);
TraceLog(LOG_INFO, "SYNC: websocket event listener started");
}
#else
static char g_sync_events_url[256];
static double g_sync_events_retry_at = 0.0;
static void
app_collect_finished_sync(void)
{
InbeSyncClientResult result;
int changed = 0;
if(sync_client_web_poll_remote_event())
g_remote_sync_due = 1;
if(!g_sync_running)
return;
if(!sync_client_web_sync_poll(&result, &changed))
return;
g_sync_running = 0;
if(result == INBE_SYNC_CLIENT_OK) {
TraceLog(LOG_INFO, "SYNC: background sync complete changed=%d", changed);
if(changed)
g_sync_refresh_pending = 1;
} else {
TraceLog(LOG_WARNING, "SYNC: background sync failed result=%d name=%s",
result, sync_client_result_name(result));
}
}
static void
app_ensure_sync_events(const char *url)
{
double now;
if(url == NULL || url[0] == '\0')
return;
if(strcmp(g_sync_events_url, url) == 0) {
sync_client_web_start_remote_events(url);
return;
}
now = GetTime();
if(now < g_sync_events_retry_at)
return;
if(!sync_client_web_start_remote_events(url)) {
g_sync_events_retry_at = now + 2.0;
return;
}
g_remote_sync_due = 1;
snprintf(g_sync_events_url, sizeof(g_sync_events_url), "%s", url);
TraceLog(LOG_INFO, "SYNC: websocket event listener started");
}
#endif
static int
app_background_sync_safe(const InbeApp *app)
{
if(app == NULL)
return 0;
if(app->modal.active)
return 0;
if(app->inbe.screen == InbeScreenPracticeSession ||
app->inbe.screen == InbeScreenMeditation)
return 0;
return 1;
}
static int
app_input_active(void)
{
return IsMouseButtonDown(MOUSE_BUTTON_LEFT) ||
IsMouseButtonPressed(MOUSE_BUTTON_LEFT) ||
IsMouseButtonReleased(MOUSE_BUTTON_LEFT) ||
IsMouseButtonDown(MOUSE_BUTTON_RIGHT) ||
IsMouseButtonPressed(MOUSE_BUTTON_RIGHT) ||
IsMouseButtonReleased(MOUSE_BUTTON_RIGHT);
}
static void
app_apply_pending_sync_refresh(InbeApp *app)
{
if(!g_sync_refresh_pending || !app_background_sync_safe(app))
return;
g_sync_refresh_pending = 0;
TraceLog(LOG_INFO, "SYNC: applying remote refresh");
app_reload_after_import(app, 0);
}
static int
app_sync_url(char *url, size_t url_size)
{
const char *saved_url;
InbeSyncAccount account;
if(url == NULL || url_size == 0)
return 0;
url[0] = '\0';
if(!sync_account_load(&account))
return 0;
saved_url = storage_get_setting_text(INBE_SYNC_SERVER_URL_KEY);
if(!sync_client_normalize_url(saved_url != NULL && saved_url[0] != '\0'
? saved_url
: "https://api.waozi.xyz",
url, url_size))
return 0;
return 1;
}
static int
app_sync_now(InbeApp *app)
{
char url[256];
if(app == NULL || !app_sync_url(url, sizeof(url)))
return 0;
#if !defined(PLATFORM_WEB)
{
SyncThread thread;
InbeSyncWorkerArgs *args;
sync_lock();
if(g_sync_running) {
sync_unlock();
return 0;
}
g_sync_running = 1;
sync_unlock();
args = malloc(sizeof(*args));
if(args == NULL) {
sync_lock();
g_sync_running = 0;
sync_unlock();
return 0;
}
snprintf(args->url, sizeof(args->url), "%s", url);
TraceLog(LOG_INFO, "SYNC: starting background sync");
if(!sync_thread_start(&thread, app_sync_worker, args)) {
free(args);
sync_lock();
g_sync_running = 0;
sync_unlock();
TraceLog(LOG_WARNING, "SYNC: failed to start background sync thread");
return 0;
}
sync_thread_detach(thread);
return 1;
}
#else
if(g_sync_running)
return 0;
g_sync_running = 1;
TraceLog(LOG_INFO, "SYNC: starting background sync");
if(!sync_client_web_sync_start(url)) {
g_sync_running = 0;
TraceLog(LOG_WARNING, "SYNC: failed to start background sync");
return 0;
}
return 1;
#endif
}
int
app_auto_sync(InbeApp *app)
{
double due;
double now;
char url[256];
if(app == NULL || !app_sync_url(url, sizeof(url)))
return 0;
now = GetTime();
g_last_sync_input_at = now;
due = now + INBE_SYNC_INPUT_QUIET_SECONDS;
if(g_dirty_sync_at <= 0.0 || due < g_dirty_sync_at)
g_dirty_sync_at = due;
TraceLog(LOG_INFO, "SYNC: queued local changes");
return 1;
}
static void
app_pump_sync(InbeApp *app)
{
double now;
int should_sync = 0;
int dirty_due = 0;
char url[256];
if(app == NULL)
return;
app_collect_finished_sync();
app_apply_pending_sync_refresh(app);
if(!app_sync_url(url, sizeof(url)))
return;
app_ensure_sync_events(url);
now = GetTime();
if(app_input_active())
g_last_sync_input_at = now;
if(g_dirty_sync_at > 0.0 && now >= g_dirty_sync_at) {
should_sync = 1;
dirty_due = 1;
}
#if !defined(PLATFORM_WEB)
sync_lock();
#endif
if(g_remote_sync_due) {
should_sync = 1;
g_remote_sync_due = 0;
}
#if !defined(PLATFORM_WEB)
sync_unlock();
#endif
if(!should_sync)
return;
if(now < g_last_sync_input_at + INBE_SYNC_INPUT_QUIET_SECONDS) {
if(g_dirty_sync_at <= 0.0)
g_dirty_sync_at = g_last_sync_input_at + INBE_SYNC_INPUT_QUIET_SECONDS;
return;
}
if(!app_background_sync_safe(app)) {
TraceLog(LOG_INFO, "SYNC: delayed; app is active");
if(g_dirty_sync_at <= 0.0)
g_dirty_sync_at = now + 1.0;
return;
}
if(app_sync_now(app)) {
if(dirty_due)
g_dirty_sync_at = 0.0;
TraceLog(LOG_INFO, "SYNC: dispatched");
} else if(dirty_due) {
g_dirty_sync_at = now + INBE_SYNC_INPUT_QUIET_SECONDS;
}
app_apply_pending_sync_refresh(app);
}
int view_width = INBE_DEFAULT_WIDTH;
int view_height = INBE_DEFAULT_HEIGHT;
/* Theme colors are now accessed via theme accessor functions */
@@ -593,14 +169,17 @@ app_flush_deferred_settings(InbeApp *app)
static int
app_should_draw_bottom_nav(const InbeApp *app)
{
if(app == NULL || app->modal.active || app->habit_session_edit.active)
if(app == NULL || app->modal.active)
return 0;
switch(app->inbe.screen) {
case InbeScreenStart:
case InbeScreenSettings:
case InbeScreenHabits:
case InbeScreenHabitEdit:
return 1;
return !app->habit_session_edit_active;
case InbeScreenHabitSessionEdit:
return 0;
default:
return 0;
}
@@ -637,10 +216,24 @@ mark_exercise_manual_seen(InbeApp *app, int exercise_type)
}
}
/* ================================================================
* TAB BAR DEFINITIONS
* ================================================================ */
static void on_habits_tab_click(void *user_data) {
InbeApp *app = user_data;
app_request_bottom_tab(app, APP_BOTTOM_TAB_HABITS);
}
static void on_settings_screen_click(void *user_data) {
InbeApp *app = user_data;
app_request_bottom_tab(app, APP_BOTTOM_TAB_SETTINGS);
}
static UITab g_tabs[] = {
{NULL, {0}, UI_ICON_TYPE_HOME},
{NULL, {0}, UI_ICON_TYPE_AMEN},
{NULL, {0}, UI_ICON_TYPE_GEAR}
{NULL, {0}, UI_ICON_TYPE_HOME, on_habits_tab_click, NULL},
{NULL, {0}, UI_ICON_TYPE_AMEN, NULL, NULL},
{NULL, {0}, UI_ICON_TYPE_GEAR, on_settings_screen_click, NULL}
};
static UITabBar g_tab_bar = {g_tabs, 3};
@@ -648,17 +241,8 @@ static UITabBar g_tab_bar = {g_tabs, 3};
static void
app_draw_bottom_nav(InbeApp *app)
{
int tab;
if(!app_should_draw_bottom_nav(app))
return;
tab = ui_draw_tab_bar(g_tab_bar.tabs, g_tab_bar.count);
if(tab == 0)
app_request_bottom_tab(app, APP_BOTTOM_TAB_HABITS);
else if(tab == 1)
app_request_bottom_tab(app, APP_BOTTOM_TAB_PRACTICE);
else if(tab == 2)
app_request_bottom_tab(app, APP_BOTTOM_TAB_SETTINGS);
if(app_should_draw_bottom_nav(app))
ui_draw_tab_bar(g_tab_bar.tabs, g_tab_bar.count);
}
static int
@@ -863,32 +447,9 @@ int_from_count(const char src[CountSize])
void
app_reload_after_import(InbeApp *app, int reload_settings)
{
char selected_habit_id[INBE_HABIT_ID_SIZE] = "";
char detail_habit_id[INBE_HABIT_ID_SIZE] = "";
int selected = -1;
int detail_index = -1;
int view_mode = HABIT_VIEW_CALENDAR;
int month_offset = 0;
int scroll = 0;
int weekly_days = 0;
if(app == NULL)
return;
if(!reload_settings) {
if(app->habits.selected >= 0 && app->habits.selected < app->habits.count)
snprintf(selected_habit_id, sizeof(selected_habit_id), "%s",
app->habits.items[app->habits.selected].id);
if(app->habit_detail_index >= 0 && app->habit_detail_index < app->habits.count)
snprintf(detail_habit_id, sizeof(detail_habit_id), "%s",
app->habits.items[app->habit_detail_index].id);
selected = app->habits.selected;
detail_index = app->habit_detail_index;
view_mode = app->habits.view_mode;
month_offset = app->habits.month_offset;
scroll = app->habits.scroll;
weekly_days = app->habits.weekly_days;
}
if(reload_settings) {
if(app_load_settings(app))
save_settings(app);
@@ -896,39 +457,13 @@ app_reload_after_import(InbeApp *app, int reload_settings)
practice_update_session_sounds(app);
}
habits_init(&app->habits);
if(!reload_settings) {
app->habits.selected = -1;
for(int i = 0; i < app->habits.count; i++) {
if(selected_habit_id[0] != '\0' &&
strcmp(app->habits.items[i].id, selected_habit_id) == 0) {
app->habits.selected = i;
break;
}
}
if(app->habits.selected < 0 && selected >= 0 && selected < app->habits.count)
app->habits.selected = selected;
app->habit_detail_index = -1;
for(int i = 0; i < app->habits.count; i++) {
if(detail_habit_id[0] != '\0' &&
strcmp(app->habits.items[i].id, detail_habit_id) == 0) {
app->habit_detail_index = i;
break;
}
}
if(app->habit_detail_index < 0 && detail_index >= 0 && detail_index < app->habits.count)
app->habit_detail_index = detail_index;
app->habits.view_mode = view_mode;
app->habits.month_offset = month_offset;
app->habits.scroll = scroll;
app->habits.weekly_days = weekly_days;
}
inbe_habits_init(&app->habits);
if(app->habit_detail_index >= app->habits.count)
app->habit_detail_index = -1;
if(app->habits.selected < 0 || app->habits.selected >= app->habits.count)
app->habits.selected = app->habits.count > 0 ? 0 : -1;
app->habit_session_edit.active = 0;
app->habit_edit.active = 0;
app->habit_session_edit_active = 0;
app->habit_edit_active = 0;
}
static Texture2D
@@ -1055,7 +590,7 @@ init_audio(InbeApp *app)
}
void
app_init(void *vapp) {
inbe_app_init(void *vapp) {
InbeApp *app = vapp;
if(app == 0)
return;
@@ -1093,6 +628,7 @@ app_init(void *vapp) {
#endif
inbeinit(&app->inbe);
practice_update_circle_bounds(app, flint_px(48), flint_px(56) + flint_px(80));
data_init();
if(app_load_settings(app))
save_settings(app);
@@ -1100,10 +636,18 @@ app_init(void *vapp) {
save_settings(app);
app->language_needs_save = 0;
}
practice_update_circle_bounds(app, flint_px(48), flint_px(56) + flint_px(80));
habits_init(&app->habits);
practice_update_circle_bounds(app, flint_px(48), flint_px(56) + 80);
inbe_habits_init(&app->habits);
app->habit_detail_index = -1;
app->habit_session_edit = (HabitSessionEditState){.round = -1};
app->habit_detail_day = 0;
app->habit_detail_session_path[0] = '\0';
app->habit_session_edit_scroll = 0;
app->habit_session_edit_active = 0;
app->habit_session_edit_kind = 0;
app->habit_session_edit_round = -1;
app->habit_session_edit_cursor = 0;
app->habit_session_edit_path[0] = '\0';
app->habit_session_edit_text[0] = '\0';
app->pending_bottom_tab = APP_BOTTOM_TAB_NONE;
app_open_main_tab(app, app->main_tab, 0);
init_audio(app);
@@ -1117,15 +661,38 @@ app_init(void *vapp) {
app->cursor_disabled = 0;
app->play_circle_hover = 0;
app->play_circle_scale = 1.0f;
app->settings_scroll = 0;
app->settings_drag_slider = 0;
app->settings_drag_scrollbar = 0;
app->settings_drag_content = 0;
app->settings_drag_content_y = 0;
app->settings_dirty = 0;
app->settings_save_delay_ticks = 0;
app->settings_tab = SETTINGS_TAB_DEVICE;
app->habit_edit = (HabitEditState){
.index = -1,
.color = {99, 196, 165, 255},
.sync_mode = INBE_HABIT_SYNC_NONE
};
app->practice_config_tab = 0;
app->practice_coming_soon_ticks = 0;
app->habit_edit_active = 0;
app->habit_edit_is_new = 0;
app->habit_edit_index = -1;
app->habit_edit_cursor = 0;
app->habit_edit_focused = 0;
app->habit_edit_text[0] = '\0';
app->habit_edit_color = (Color){99, 196, 165, 255};
app->habit_edit_sync_mode = INBE_HABIT_SYNC_NONE;
app->habit_edit_sync_activity = 0;
app->manual_scroll = 0;
app->manual_drag_scrollbar = 0;
app->manual_drag_content = 0;
app->manual_drag_content_y = 0;
app->tutorial_step = 0;
app->session_paused = 0;
app->backgrounded = 0;
app->results_saved = 0;
app->results_path[0] = '\0';
practice_update_session_sounds(app);
reset_settings_preview(app);
inbeinit(&app->start_speed_preview);
app->start_speed_preview_speed = 0;
// Load all icons
flint_load_all_icons(app->icons);
@@ -1133,10 +700,16 @@ app_init(void *vapp) {
/* Update tab bar icons */
g_tabs[0].icon = app->icons[UI_ICON_TYPE_HABIT];
g_tabs[0].icon_type = UI_ICON_TYPE_NONE;
g_tabs[0].user_data = app;
g_tabs[1].icon = app->icons[UI_ICON_TYPE_AMEN];
g_tabs[1].icon_type = UI_ICON_TYPE_AMEN;
g_tabs[1].user_data = app;
g_tabs[1].on_click = on_practice_tab_click;
g_tabs[2].icon = app->icons[UI_ICON_TYPE_GEAR];
g_tabs[2].icon_type = UI_ICON_TYPE_GEAR;
g_tabs[2].user_data = app;
app->volume_popup_active = 0;
ui_set_icons(app->icons[UI_ICON_TYPE_GEAR], app->icons[UI_ICON_TYPE_X]);
@@ -1145,11 +718,13 @@ app_init(void *vapp) {
else
app->inbe.screen = InbeScreenStart;
app->modal = (UIModal){0};
/* Reset modal state */
app->modal.active = 0;
app->modal.type = UIModalNone;
app->modal.selected_button = 0;
app->meditation.duration_seconds = 0;
app->meditation.remaining_seconds = 0;
app->meditation.frame_ticks = 0;
app_auto_sync(app);
}
static void
@@ -1199,7 +774,7 @@ handle_back_button(InbeApp *app)
case InbeScreenResults:
practice_ensure_results_saved(app);
app_init(app);
inbe_app_init(app);
break;
case InbeScreenSession:
@@ -1211,7 +786,7 @@ handle_back_button(InbeApp *app)
android_timer_stop();
}
#endif
app_init(app);
inbe_app_init(app);
} else {
/* Show confirmation modal */
app->modal.active = 1;
@@ -1270,7 +845,10 @@ updateapp(InbeApp *app)
if(app->practice_coming_soon_ticks > 0)
app->practice_coming_soon_ticks--;
if(IsKeyPressed(KEY_BACK)) {
if(IsKeyPressed(KEY_BACK) ||
(IsKeyPressed(KEY_BACKSPACE) &&
!(app->inbe.screen == InbeScreenHabitEdit && app->habit_edit_active) &&
!(app->inbe.screen == InbeScreenHabitSessionEdit && app->habit_session_edit_active))) {
if(app->modal.active) {
app->modal.active = 0;
app->modal.type = UIModalNone;
@@ -1450,7 +1028,7 @@ finish_frame:
}
void
app_update_draw(void *vapp, Rectangle viewport) {
inbe_app_update_draw(void *vapp, Rectangle viewport) {
InbeApp *app = vapp;
if(app == 0 || viewport.width <= 0 || viewport.height <= 0)
return;
@@ -1483,8 +1061,6 @@ app_update_draw(void *vapp, Rectangle viewport) {
updateapp(app);
EndMode2D();
flint_clip_end();
habits_flush_save(app);
app_pump_sync(app);
}
void
@@ -1501,14 +1077,13 @@ static void SafeUnloadSound(Sound sound) {
}
void
app_destroy(void *vapp)
inbe_app_destroy(void *vapp)
{
InbeApp *app = vapp;
if (app == NULL) return;
if(app->settings_dirty || app->settings_save_delay_ticks > 0)
save_settings(app);
habits_flush_save(app);
// Unload all icons
flint_unload_all_icons(app->icons);
+19 -41
View File
@@ -61,8 +61,6 @@ typedef enum {
UIModalEditProgressiveStartSpeed,
UIModalMeditationNetworkError,
UIModalConfirmImportDataSettings,
UIModalSyncAccountBackup,
UIModalConfirmDeleteSyncAccount,
} UIModalType;
typedef struct {
@@ -140,29 +138,6 @@ typedef struct MeditationPracticeState {
char music_status[128];
} MeditationPracticeState;
typedef struct HabitSessionEditState {
int scroll;
int active;
int kind;
int round;
int cursor;
char path[FS_PATH_MAX];
char text[16];
} HabitSessionEditState;
typedef struct HabitEditState {
int active;
int is_new;
int index;
int cursor;
int focused;
char text[INBE_HABIT_NAME_SIZE];
Color color;
int sync_mode;
int sync_activity;
int counter_enabled;
} HabitEditState;
struct InbeApp {
Inbe inbe;
Inbe settings_preview;
@@ -195,10 +170,6 @@ struct InbeApp {
int settings_dirty;
int settings_save_delay_ticks;
int settings_tab;
int settings_data_view;
int sync_server_url_cursor;
int sync_server_url_focused;
char sync_server_url[256];
int device_picker_open;
int device_picker_scroll;
int fullscreen_enabled;
@@ -226,14 +197,22 @@ struct InbeApp {
int habit_detail_index;
int habit_detail_day;
char habit_detail_session_path[FS_PATH_MAX];
HabitSessionEditState habit_session_edit;
HabitEditState habit_edit;
int habit_counter_press_day;
int habit_counter_press_index;
int habit_counter_press_frames;
int habit_counter_press_long_done;
int habit_counter_press_start_x;
int habit_counter_press_start_y;
int habit_session_edit_scroll;
int habit_session_edit_active;
int habit_session_edit_kind;
int habit_session_edit_round;
int habit_session_edit_cursor;
char habit_session_edit_path[FS_PATH_MAX];
char habit_session_edit_text[16];
int habit_edit_active;
int habit_edit_is_new;
int habit_edit_index;
int habit_edit_cursor;
int habit_edit_focused;
char habit_edit_text[INBE_HABIT_NAME_SIZE];
Color habit_edit_color;
int habit_edit_sync_mode;
int habit_edit_sync_activity;
int advanced_session_controls;
int hold_display_mode;
int exercise_type;
@@ -252,10 +231,9 @@ struct InbeApp {
float play_circle_scale;
};
void app_init(void *app);
void app_update_draw(void *app, Rectangle viewport);
void app_destroy(void *app);
int app_auto_sync(InbeApp *app);
void inbe_app_init(void *app);
void inbe_app_update_draw(void *app, Rectangle viewport);
void inbe_app_destroy(void *app);
void app_play_sound(InbeApp *app, Sound sound, float scale);
Texture2D app_load_asset_texture(const char *name);
void app_unload_texture(Texture2D texture);
+34 -15
View File
@@ -2,7 +2,7 @@
#include "app.h"
#include "device_preferences.h"
#include "flint_locale.h"
#include "locale.h"
#include "practices/meditation/meditation_music.h"
#include "practices/whm/whm_session.h"
#include "storage.h"
@@ -55,8 +55,27 @@ static void
sync_web_storage(void)
{
EM_ASM({
if(typeof Module.__inbeScheduleStorageSync === 'function')
Module.__inbeScheduleStorageSync(250, true);
if(typeof FS !== 'undefined' && typeof FS.syncfs === 'function') {
if(Module.inbeSyncfsTimer)
clearTimeout(Module.inbeSyncfsTimer);
Module.__inbeStorageSyncPending = true;
Module.inbeSyncfsTimer = setTimeout(function() {
Module.inbeSyncfsTimer = 0;
Module.__inbeStorageSyncing = true;
try {
FS.syncfs(false, function(err) {
Module.__inbeStorageSyncing = false;
Module.__inbeStorageSyncPending = false;
if(err) console.error("IDBFS save failed:", err);
else console.log("IDBFS synced");
});
} catch(e) {
Module.__inbeStorageSyncing = false;
Module.__inbeStorageSyncPending = false;
console.error("IDBFS sync error:", e);
}
}, 250);
}
});
}
#endif
@@ -65,14 +84,14 @@ static void
save_int_settings(const IntSetting *settings, size_t count)
{
for(size_t i = 0; i < count; i++)
storage_set_setting_int(settings[i].key, settings[i].value);
inbe_storage_set_setting_int(settings[i].key, settings[i].value);
}
static void
load_int_settings(const LoadedIntSetting *settings, size_t count)
{
for(size_t i = 0; i < count; i++)
*settings[i].dst = storage_get_setting_int(settings[i].key,
*settings[i].dst = inbe_storage_get_setting_int(settings[i].key,
settings[i].fallback);
}
@@ -80,7 +99,7 @@ static void
load_bool_settings(const LoadedBoolSetting *settings, size_t count)
{
for(size_t i = 0; i < count; i++)
*settings[i].dst = storage_get_setting_int(settings[i].key,
*settings[i].dst = inbe_storage_get_setting_int(settings[i].key,
settings[i].fallback) != 0;
}
@@ -88,7 +107,7 @@ static void
load_clamped_settings(const LoadedClampedSetting *settings, size_t count)
{
for(size_t i = 0; i < count; i++) {
int value = storage_get_setting_int(settings[i].key, settings[i].fallback);
int value = inbe_storage_get_setting_int(settings[i].key, settings[i].fallback);
*settings[i].dst = clampi(value, settings[i].min_value, settings[i].max_value);
}
}
@@ -98,7 +117,7 @@ apply_settings(Inbe *inbe, int speed, int max_rounds, int max_breaths, int pause
{
speed = clampi(speed, SETTINGS_SPEED_MIN, SETTINGS_SPEED_MAX);
inbe->speed_level = speed;
inbe->breath_half_ticks = breath_half_ticks_for_speed(speed);
inbe->breath_half_ticks = inbe_breath_half_ticks_for_speed(speed);
inbe->breath_animation = clampi(inbe->breath_animation,
InbeBreathAnimationLinear,
InbeBreathAnimationCount - 1);
@@ -165,12 +184,12 @@ save_settings(InbeApp *app)
{"practice_category_tab", app->practice_category_tab},
};
storage_settings_begin_write();
inbe_storage_settings_begin_write();
save_int_settings(int_settings, sizeof(int_settings) / sizeof(int_settings[0]));
storage_set_setting_text("language",
inbe_storage_set_setting_text("language",
(app->language_selected && app->language[0] != '\0') ?
app->language : "");
storage_settings_end_write();
inbe_storage_settings_end_write();
#if defined(PLATFORM_WEB)
sync_web_storage();
#endif
@@ -181,7 +200,7 @@ save_settings(InbeApp *app)
static void
load_language_setting(InbeApp *app, int settings_missing)
{
const char *language = storage_get_setting_text("language");
const char *language = inbe_storage_get_setting_text("language");
app->language_needs_save = 0;
if(language != NULL && language[0] != '\0') {
@@ -216,7 +235,7 @@ app_load_settings(InbeApp *app)
if(app == NULL)
return 0;
settings_missing = storage_settings_empty();
settings_missing = inbe_storage_settings_empty();
{
LoadedIntSetting settings[] = {
@@ -273,7 +292,7 @@ app_load_settings(InbeApp *app)
load_clamped_settings(settings, sizeof(settings) / sizeof(settings[0]));
}
manual_seen_mask = storage_get_setting_int("exercise_manual_seen_mask", -1);
manual_seen_mask = inbe_storage_get_setting_int("exercise_manual_seen_mask", -1);
if(manual_seen_mask < 0)
manual_seen_mask = app->tutorial_seen ? exercise_manual_bit(EXERCISE_WIM_HOF) : 0;
app->exercise_manual_seen_mask = manual_seen_mask & ((1 << EXERCISE_COUNT) - 1);
@@ -282,7 +301,7 @@ app_load_settings(InbeApp *app)
#ifdef __ANDROID__
app->inbe.play_in_background =
storage_get_setting_int("play_in_background", 1) != 0;
inbe_storage_get_setting_int("play_in_background", 1) != 0;
TraceLog(LOG_INFO, "INBE: Loaded play_in_background setting = %d",
app->inbe.play_in_background);
#else
+6 -6
View File
@@ -17,7 +17,7 @@ count_value(const char v[CountSize])
}
int
breath_half_ticks_for_speed(int speed)
inbe_breath_half_ticks_for_speed(int speed)
{
static const int breath_half_ticks[] = {180, 160, 144, 132, 120, 108, 93, 74};
@@ -62,7 +62,7 @@ inccount(char v[CountSize])
}
int
get_play_in_background(Inbe *inbe)
inbe_get_play_in_background(Inbe *inbe)
{
return inbe->play_in_background;
}
@@ -124,7 +124,7 @@ lerp_int(int a, int b, int num, int den)
static int
effective_breath_half_ticks(const Inbe *l)
{
int target_ticks = breath_half_ticks_for_speed(l->speed_level);
int target_ticks = inbe_breath_half_ticks_for_speed(l->speed_level);
int start_speed = l->progressive_start_speed;
if(!l->progressive_speed || l->round != 0)
@@ -138,13 +138,13 @@ effective_breath_half_ticks(const Inbe *l)
int completed_breaths = count_value(l->count);
if(completed_breaths < 5)
return breath_half_ticks_for_speed(start_speed);
return inbe_breath_half_ticks_for_speed(start_speed);
if(completed_breaths >= 10)
return target_ticks;
return lerp_int(
breath_half_ticks_for_speed(start_speed),
inbe_breath_half_ticks_for_speed(start_speed),
target_ticks,
completed_breaths - 4,
5
@@ -182,7 +182,7 @@ animated_span(const Inbe *l, int span, int frame, int half_ticks)
}
float
draw_radius(const Inbe *l)
inbe_draw_radius(const Inbe *l)
{
if(l == 0)
return 0.0f;
+3 -4
View File
@@ -32,7 +32,6 @@ enum {
enum {
InbeScreenStart = 0,
InbeScreenSession,
InbeScreenPracticeSession = InbeScreenSession,
InbeScreenMeditation,
InbeScreenResults,
InbeScreenSettings,
@@ -92,10 +91,10 @@ struct Inbe {
void inbeinit(Inbe *l);
void inbestep(Inbe *l);
float draw_radius(const Inbe *l);
float inbe_draw_radius(const Inbe *l);
void inccount(char v[CountSize]);
void cpcount(char dst[CountSize], const char src[CountSize]);
int breath_half_ticks_for_speed(int speed);
int get_play_in_background(Inbe *inbe);
int inbe_breath_half_ticks_for_speed(int speed);
int inbe_get_play_in_background(Inbe *inbe);
#endif
+6
View File
@@ -0,0 +1,6 @@
#include "locale.h"
/*
* Locale implementation now lives in flint/src/flint_locale.c.
* This file stays as a compatibility stub so the legacy include path keeps working.
*/
+6
View File
@@ -0,0 +1,6 @@
#ifndef INBE_LOCALE_H
#define INBE_LOCALE_H
#include "flint_locale.h"
#endif
+3 -3
View File
@@ -2,8 +2,8 @@
#define INBE_VERSION_H
#define INBE_VERSION_MAJOR 1
#define INBE_VERSION_MINOR 4
#define INBE_VERSION_PATCH 3
#define INBE_VERSION_STRING "1.4.3"
#define INBE_VERSION_MINOR 3
#define INBE_VERSION_PATCH 4
#define INBE_VERSION_STRING "1.3.4"
#endif
+5 -6
View File
@@ -3,7 +3,6 @@
#include "flint_clip.h"
#include "flint_dpi.h"
#include "flint_web.h"
#include "theme.h"
#include <stdarg.h>
#include <stddef.h>
#include <stdio.h>
@@ -222,9 +221,9 @@ frame(void)
int content_height = android_clamp_content_size(height, safe_top, safe_bottom);
BeginDrawing();
ClearBackground(theme_get_bg());
ClearBackground(BLACK);
flint_clip_begin(content_x, content_y, content_width, content_height);
app_update_draw(&inbe_app, (Rectangle){
inbe_app_update_draw(&inbe_app, (Rectangle){
(float)content_x,
(float)content_y,
(float)content_width,
@@ -233,8 +232,8 @@ frame(void)
flint_clip_end();
#else
BeginDrawing();
ClearBackground(theme_get_bg());
app_update_draw(&inbe_app, (Rectangle){
ClearBackground(BLACK);
inbe_app_update_draw(&inbe_app, (Rectangle){
0,
0,
(float)width,
@@ -298,7 +297,7 @@ int main(int argc, char **argv) {
}
flint_dpi_init();
app_init(&inbe_app);
inbe_app_init(&inbe_app);
set_global_inbe_app(&inbe_app);
TraceLog(LOG_INFO, "INBE: Global app pointer set");
+4 -14
View File
@@ -31,7 +31,7 @@ android_import_set_result(int result, const char *path)
}
int
android_import_open_picker(const char *mime_types)
android_import_open_picker(void)
{
struct android_app *app = GetAndroidApp();
if(app == NULL || app->activity == NULL) {
@@ -55,23 +55,14 @@ android_import_open_picker(const char *mime_types)
return 0;
}
jmethodID method = (*env)->GetMethodID(env, activity_class, "openImportPicker",
"(Ljava/lang/String;)V");
jmethodID method = (*env)->GetMethodID(env, activity_class, "openImportPicker", "()V");
if(method == NULL) {
TraceLog(LOG_ERROR, "ANDROID_IMPORT: openImportPicker method not found");
(*jvm)->DetachCurrentThread(jvm);
return 0;
}
jstring mime_string = (*env)->NewStringUTF(env, mime_types != NULL ? mime_types : "");
if(mime_string == NULL) {
TraceLog(LOG_ERROR, "ANDROID_IMPORT: failed to allocate MIME string");
(*jvm)->DetachCurrentThread(jvm);
return 0;
}
(*env)->CallVoidMethod(env, activity->clazz, method, mime_string);
(*env)->DeleteLocalRef(env, mime_string);
(*env)->CallVoidMethod(env, activity->clazz, method);
if((*env)->ExceptionCheck(env)) {
(*env)->ExceptionDescribe(env);
(*env)->ExceptionClear(env);
@@ -133,9 +124,8 @@ android_import_poll_result(char *path, size_t path_size)
#else
int
android_import_open_picker(const char *mime_types)
android_import_open_picker(void)
{
(void)mime_types;
return 0;
}
+1 -1
View File
@@ -3,7 +3,7 @@
#include <stddef.h>
int android_import_open_picker(const char *mime_types);
int android_import_open_picker(void);
int android_import_poll_result(char *path, size_t path_size);
enum {
+1 -1
View File
@@ -81,7 +81,7 @@ static jint nativeGetPlayInBackground(JNIEnv *env, jobject thiz)
__android_log_write(ANDROID_LOG_INFO, "INBE_JNI", msg);
if (app != NULL) {
InbeApp *inbe_app = (InbeApp*)app;
jint result = get_play_in_background(&inbe_app->inbe);
jint result = inbe_get_play_in_background(&inbe_app->inbe);
char msg[128];
snprintf(msg, sizeof(msg), "nativeGetPlayInBackground: returning %d", result);
__android_log_write(ANDROID_LOG_INFO, "INBE_JNI", msg);
+2 -97
View File
@@ -1,6 +1,6 @@
#include "android_share.h"
#include "data.h"
#include "flint_locale.h"
#include "locale.h"
#include "storage.h"
#include "version.h"
#include "raylib.h"
@@ -17,93 +17,6 @@
extern struct android_app *GetAndroidApp(void);
static jclass
android_share_helper_class(JNIEnv *env, jobject activity)
{
jclass activity_class;
jmethodID get_class_loader;
jobject class_loader;
jclass class_loader_class;
jmethodID load_class;
jstring class_name;
jclass share_helper_class;
activity_class = (*env)->FindClass(env, "android/app/Activity");
if(!activity_class)
return NULL;
get_class_loader = (*env)->GetMethodID(env, activity_class, "getClassLoader",
"()Ljava/lang/ClassLoader;");
if(!get_class_loader)
return NULL;
class_loader = (*env)->CallObjectMethod(env, activity, get_class_loader);
if(!class_loader)
return NULL;
class_loader_class = (*env)->FindClass(env, "java/lang/ClassLoader");
if(!class_loader_class)
return NULL;
load_class = (*env)->GetMethodID(env, class_loader_class, "loadClass",
"(Ljava/lang/String;)Ljava/lang/Class;");
if(!load_class)
return NULL;
class_name = (*env)->NewStringUTF(env, "xyz.waozi.inbe.ShareHelper");
share_helper_class = (jclass)(*env)->CallObjectMethod(env, class_loader, load_class, class_name);
(*env)->DeleteLocalRef(env, class_name);
(*env)->DeleteLocalRef(env, class_loader);
return share_helper_class;
}
int
android_share_bytes(const unsigned char *data, size_t data_size, const char *filename,
const char *mime_type)
{
struct android_app *app = GetAndroidApp();
ANativeActivity *native_activity;
JavaVM *jvm;
JNIEnv *env = NULL;
jclass share_helper_class;
jmethodID method;
jbyteArray jarr;
jstring jname;
jstring jmime;
jstring jtitle;
if(app == NULL || app->activity == NULL || data == NULL || data_size == 0 ||
filename == NULL || filename[0] == '\0')
return 0;
native_activity = app->activity;
jvm = native_activity->vm;
if((*jvm)->AttachCurrentThread(jvm, &env, NULL) != JNI_OK)
return 0;
share_helper_class = android_share_helper_class(env, native_activity->clazz);
if(!share_helper_class) {
(*jvm)->DetachCurrentThread(jvm);
return 0;
}
method = (*env)->GetStaticMethodID(env, share_helper_class, "shareFile",
"(Landroid/app/Activity;[BLjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V");
if(!method) {
(*jvm)->DetachCurrentThread(jvm);
return 0;
}
jarr = (*env)->NewByteArray(env, data_size);
(*env)->SetByteArrayRegion(env, jarr, 0, data_size, (const jbyte *)data);
jname = (*env)->NewStringUTF(env, filename);
jmime = (*env)->NewStringUTF(env, mime_type != NULL ? mime_type : "application/octet-stream");
jtitle = (*env)->NewStringUTF(env, locale_get("share_sheet_title"));
(*env)->CallStaticVoidMethod(env, share_helper_class, method, native_activity->clazz,
jarr, jname, jmime, jtitle);
(*env)->DeleteLocalRef(env, jarr);
(*env)->DeleteLocalRef(env, jname);
(*env)->DeleteLocalRef(env, jmime);
(*env)->DeleteLocalRef(env, jtitle);
(*jvm)->DetachCurrentThread(jvm);
return 1;
}
int android_share_export(const char *filename)
{
struct android_app *app;
@@ -125,7 +38,7 @@ int android_share_export(const char *filename)
}
snprintf(export_path, sizeof(export_path), "%s/%s", data_root(), filename);
if(!storage_export_zip(export_path)) {
if(!inbe_storage_export_zip(export_path)) {
TraceLog(LOG_ERROR, "ANDROID_SHARE: failed to export SQLite ZIP");
return 0;
}
@@ -250,12 +163,4 @@ int android_share_export(const char *filename) {
(void)filename;
return 0;
}
int android_share_bytes(const unsigned char *data, size_t data_size, const char *filename,
const char *mime_type) {
(void)data;
(void)data_size;
(void)filename;
(void)mime_type;
return 0;
}
#endif
-4
View File
@@ -1,12 +1,8 @@
#ifndef ANDROID_SHARE_H
#define ANDROID_SHARE_H
#include <stddef.h>
/* Export data using Android share sheet
* Returns: 1 on success (share sheet shown), 0 on failure */
int android_share_export(const char *filename);
int android_share_bytes(const unsigned char *data, size_t data_size, const char *filename,
const char *mime_type);
#endif
+1 -1
View File
@@ -2,7 +2,7 @@
#include "app.h"
#include "meditation_music.h"
#include "flint_locale.h"
#include "locale.h"
#include "theme.h"
#include "flint_ui.h"
#include "raylib.h"
+11 -16
View File
@@ -1,7 +1,7 @@
#include "meditation_practice.h"
#include "app.h"
#include "flint_locale.h"
#include "locale.h"
#include "meditation_music.h"
#include "theme.h"
#include "flint_ui.h"
@@ -183,29 +183,24 @@ meditation_manual_draw(InbeApp *app)
{
int gap = flint_px(10);
int manual_seen = exercise_manual_seen(app, EXERCISE_MEDITATION);
int show_left = page > 0 || manual_seen;
int button_w = show_left ? (content_w - gap) / 2 : content_w;
int right_x = show_left ? content_x + button_w + gap : content_x;
int button_w = (content_w - gap) / 2;
int hover = 0;
const char *left = page == 0 ? locale_get("tutorial_skip_button")
: locale_get("tutorial_back_button");
const char *right = page == 0 ? locale_get("tutorial_next_button")
: locale_get("tutorial_start_button");
if(show_left) {
if(ui_draw_generic_button(content_x, footer_y, button_w, button_h,
left, UI_BUTTON_STYLE_PRIMARY, 0, &hover)) {
if(page == 0)
meditation_manual_start(app);
else {
app->tutorial_step = 0;
app->manual_scroll = 0;
}
if(ui_draw_generic_button(content_x, footer_y, button_w, button_h,
left, UI_BUTTON_STYLE_PRIMARY, 0, &hover)) {
if(page == 0)
meditation_manual_start(app);
else {
app->tutorial_step = 0;
app->manual_scroll = 0;
}
}
if(ui_draw_generic_button(right_x, footer_y, button_w, button_h, right,
UI_BUTTON_STYLE_PRIMARY, 0, &hover)) {
if(ui_draw_generic_button(content_x + button_w + gap, footer_y, button_w,
button_h, right, UI_BUTTON_STYLE_PRIMARY, 0, &hover)) {
if(page == 0) {
app->tutorial_step = 1;
app->manual_scroll = 0;
+1 -5
View File
@@ -1,7 +1,7 @@
#include "meditation_music.h"
#include "app.h"
#include "flint_locale.h"
#include "locale.h"
#include "theme.h"
#include "miniz.h"
#include "flint_color.h"
@@ -306,11 +306,7 @@ music_track_path(InbeApp *app, int track, char *out, size_t out_size)
file_exists(out))
return;
#if defined(PLATFORM_WEB)
out[0] = '\0';
#else
snprintf(out, out_size, "unpackaged_assets/audio/%s", g_tracks[track].file);
#endif
}
static int
@@ -2,7 +2,7 @@
#include "app.h"
#include "data.h"
#include "flint_locale.h"
#include "locale.h"
#include "meditation_music.h"
#include "theme.h"
#include "flint_ui.h"
@@ -58,7 +58,6 @@ meditation_finish(InbeApp *app)
if(data_save_session_path_for_activity(&session_duration, 1, 0, EXERCISE_MEDITATION,
NULL, 0)) {
sync_habits_for_activity(app, EXERCISE_MEDITATION);
app_auto_sync(app);
}
}
app_play_sound(app, app->bell_sound, 1.0f);
@@ -98,7 +97,6 @@ meditation_save_elapsed(InbeApp *app)
return 0;
if(data_save_session_path_for_activity(&elapsed, 1, 0, EXERCISE_MEDITATION, NULL, 0)) {
sync_habits_for_activity(app, EXERCISE_MEDITATION);
app_auto_sync(app);
return 1;
}
return 0;
+1 -1
View File
@@ -1,7 +1,7 @@
#include "practice_registry.h"
#include "app.h"
#include "flint_locale.h"
#include "locale.h"
#include "practices/whm/whm_practice.h"
#include "practices/whm/whm_session.h"
#include "practices/meditation/meditation_practice.h"
+1 -1
View File
@@ -1,7 +1,7 @@
#include "whm_practice.h"
#include "app.h"
#include "flint_locale.h"
#include "locale.h"
#include "whm_session.h"
#include "theme.h"
#include "flint_ui.h"
+48 -21
View File
@@ -1,7 +1,7 @@
#include "whm_practice.h"
#include "app.h"
#include "whm_session.h"
#include "flint_locale.h"
#include "locale.h"
#include "theme.h"
#include "flint_clip.h"
#include "flint_ui.h"
@@ -18,6 +18,7 @@ extern int view_height;
static const char *const TUTORIAL_KEYS[] = {
"tutorial_step_intro",
"tutorial_step_method",
"tutorial_step_progressive_speed",
"tutorial_step_breathe",
"tutorial_step_exhale_hold",
"tutorial_step_inhale_hold"
@@ -103,27 +104,31 @@ manual_tutorial_content_height(InbeApp *app, int step, int content_w, int body_f
} else if(step == 1) {
actual_content_h += tutorial_paragraph_height(app, 1, content_w, body_font);
} else if(step == 2) {
actual_content_h += tutorial_paragraph_height(app, 2, content_w, body_font) + flint_px(68);
if(app->inbe.progressive_speed)
actual_content_h += flint_px(66);
} else if(step == 3) {
int preview_span;
int preview_rmax;
int slider_h = flint_px(40);
actual_content_h += tutorial_paragraph_height(app, 2, content_w, body_font) + flint_px(20);
actual_content_h += tutorial_paragraph_height(app, 3, content_w, body_font) + flint_px(20);
preview_span = (content_w < flint_px(132)) ? content_w : flint_px(132);
preview_rmax = preview_span / 2;
if(preview_rmax < flint_px(60)) preview_rmax = flint_px(60);
if(preview_rmax > flint_px(120)) preview_rmax = flint_px(120);
actual_content_h += flint_px(40) + (int)((float)preview_rmax * 0.72f) + flint_px(14);
actual_content_h += slider_h + flint_px(8);
} else if(step == 3) {
} else if(step == 4) {
int hold_preview_radius = flint_px(54);
int hold_preview_extent = hold_preview_radius + flint_px(8) + flint_px(5);
actual_content_h += hold_preview_extent * 2 + flint_px(24) +
flint_px(42) + flint_px(18);
actual_content_h += tutorial_paragraph_height(app, 3, content_w, body_font);
actual_content_h += flint_px(26) + flint_px(36) + flint_px(20);
actual_content_h += hold_preview_extent * 2 + flint_px(24);
actual_content_h += tutorial_paragraph_height(app, 4, content_w, body_font);
} else {
actual_content_h += flint_px(80) +
tutorial_paragraph_height(app, 4, content_w, body_font);
actual_content_h += flint_px(200) + flint_px(22) +
tutorial_paragraph_height(app, 5, content_w, body_font);
}
return actual_content_h;
@@ -190,9 +195,10 @@ whm_manual_draw(InbeApp *app)
switch(step) {
case 1: title = locale_get("tutorial_method_title"); break;
case 2: title = locale_get("tutorial_step1_title"); break;
case 3: title = locale_get("tutorial_step2_title"); break;
case 4: title = locale_get("tutorial_step3_title"); break;
case 2: title = locale_get("tutorial_progressive_speed_title"); break;
case 3: title = locale_get("tutorial_step1_title"); break;
case 4: title = locale_get("tutorial_step2_title"); break;
case 5: title = locale_get("tutorial_step3_title"); break;
default: break;
}
@@ -261,8 +267,27 @@ whm_manual_draw(InbeApp *app)
} else if(step == 1) {
draw_tutorial_paragraph(app, 1, content_x, &y, content_w, body_font);
} else if(step == 2) {
int speed = app->inbe.speed_level;
draw_tutorial_paragraph(app, 2, content_x, &y, content_w, body_font);
y += flint_px(18);
{
int progressive_speed = app->inbe.progressive_speed;
int toggle_w = flint_px(56);
int toggle_h = flint_px(30);
flint_text_draw(locale_get("progressive_speed_label"), content_x, y,
flint_ui_font(), theme_get_text());
y += flint_px(26);
if(ui_draw_toggle_switch(content_x, y, toggle_w, toggle_h,
&progressive_speed, locale_get("toggle_off"),
locale_get("toggle_on"))) {
app->inbe.progressive_speed = progressive_speed;
app->settings_preview.progressive_speed = progressive_speed;
app->settings_dirty = 1;
}
y += toggle_h + flint_px(20);
}
} else if(step == 3) {
int speed = app->inbe.speed_level;
draw_tutorial_paragraph(app, 3, content_x, &y, content_w, body_font);
y += flint_px(20); /* Increased spacing between text and circle */
update_preview_bounds(&app->settings_preview, content_w, flint_px(132));
@@ -289,19 +314,21 @@ whm_manual_draw(InbeApp *app)
app->settings_preview.progressive_speed = 0;
app->settings_dirty = 1;
}
} else if(step == 3) {
} else if(step == 4) {
int hold_preview_radius = flint_px(54);
int hold_preview_extent = hold_preview_radius + flint_px(8) + flint_px(5);
int breath_button_hover = 0;
int center_x = content_x + content_w / 2;
y += hold_preview_extent;
draw_tutorial_hold_preview(app, center_x, y, hold_preview_radius);
flint_text_draw(locale_get("hold_display_label"), content_x, y, flint_ui_font(), theme_get_text());
y += flint_px(26);
draw_hold_display_mode_selector(app, content_x, y, content_w);
y += flint_px(36) + flint_px(20) + hold_preview_extent;
draw_tutorial_hold_preview(app, content_x + content_w / 2, y, hold_preview_radius);
y += hold_preview_extent + flint_px(24);
ui_draw_text_btn(center_x, y, locale_get("breath_button"), &breath_button_hover);
y += flint_px(42) + flint_px(18);
draw_tutorial_paragraph(app, 3, content_x, &y, content_w, body_font);
} else {
draw_tutorial_paragraph(app, 4, content_x, &y, content_w, body_font);
} else {
int img_h = flint_px(200);
ui_draw_tutorial_image(app->whm.image_2, "practices/whm/2.jpg", content_x, y, content_w, img_h);
y += img_h + flint_px(22);
draw_tutorial_paragraph(app, 5, content_x, &y, content_w, body_font);
}
}
ui_scroll_container_end(scroll_area, scroll_view);
+11 -12
View File
@@ -1,7 +1,7 @@
#include "whm_session.h"
#include "data.h"
#include "flint_locale.h"
#include "locale.h"
#include "theme.h"
#include "flint_dpi.h"
#include "flint_ui.h"
@@ -280,7 +280,6 @@ session_ensure_results_saved(InbeApp *app)
app->results_path, sizeof(app->results_path))) {
app->results_saved = 1;
sync_habits_for_activity(app, app->exercise_type);
app_auto_sync(app);
TraceLog(LOG_INFO, "INBE: session saved successfully");
return 1;
}
@@ -342,7 +341,7 @@ finish_round(InbeApp *app)
#endif
app->inbe.screen = InbeScreenResults;
} else {
app_init(app);
inbe_app_init(app);
}
}
}
@@ -527,7 +526,7 @@ draw_hold_progress_outline(InbeApp *app, int center_x, int center_y)
void
session_draw_inbe(InbeApp *app, int center_x, int center_y)
{
float radius = draw_radius(&app->inbe);
float radius = inbe_draw_radius(&app->inbe);
if(app->inbe.phase == InbePhaseHold && app->hold_display_mode == HOLD_DISPLAY_CIRCLE) {
draw_hold_progress_outline(app, center_x, center_y);
@@ -653,7 +652,7 @@ draw_session_round_label(InbeApp *app)
void
draw_preview_inbe(Inbe *inbe, int center_x, int center_y)
{
float r = draw_radius(inbe) * 0.72f;
float r = inbe_draw_radius(inbe) * 0.72f;
DrawCircleV((Vector2){(float)center_x, (float)center_y}, r, theme_get_circle());
DrawRing((Vector2){(float)center_x, (float)center_y}, r - 0.75f, r + 0.75f,
0.0f, 360.0f, 96, theme_get_text());
@@ -693,7 +692,7 @@ session_update_screen(InbeApp *app, int center_x, int center_y, int *hover)
flint_px(10), app->icons[UI_ICON_TYPE_RETURN], &return_hover)) {
if(app->session_paused) {
stop_android_background_session(app);
app_init(app);
inbe_app_init(app);
} else {
app->modal.active = 1;
app->modal.type = UIModalConfirmExitSession;
@@ -752,12 +751,12 @@ session_update_screen(InbeApp *app, int center_x, int center_y, int *hover)
stop_android_background_session(app);
app->modal.active = 0;
app->modal.type = UIModalNone;
app_init(app);
inbe_app_init(app);
} else if(modal_result == 3) {
stop_android_background_session(app);
app->modal.active = 0;
app->modal.type = UIModalNone;
app_init(app);
inbe_app_init(app);
}
} else {
modal_result = ui_draw_modal(locale_get("exit_session_title"),
@@ -771,7 +770,7 @@ session_update_screen(InbeApp *app, int center_x, int center_y, int *hover)
stop_android_background_session(app);
app->modal.active = 0;
app->modal.type = UIModalNone;
app_init(app);
inbe_app_init(app);
}
}
return;
@@ -884,7 +883,7 @@ session_draw_results_screen(InbeApp *app, int center_x, int center_y, int *hover
(void)center_y;
if(rounds <= 0) {
app_init(app);
inbe_app_init(app);
return;
}
@@ -956,11 +955,11 @@ session_draw_results_screen(InbeApp *app, int center_x, int center_y, int *hover
if(ui_draw_text_btn(center_x - box_w / 4, action_y, locale_get("discard_button"), &discard_hover)) {
session_discard_saved_results(app);
app_init(app);
inbe_app_init(app);
}
if(ui_draw_text_btn(center_x + box_w / 4, action_y, locale_get("save_results_button"), &save_hover)) {
if(session_ensure_results_saved(app))
app_init(app);
inbe_app_init(app);
}
if(discard_hover || save_hover)
*hover = 1;
File diff suppressed because it is too large. Load diff
+15 -24
View File
@@ -17,6 +17,7 @@ enum {
INBE_HABIT_MAX = 10,
INBE_HABIT_ID_SIZE = 32,
INBE_HABIT_NAME_SIZE = 40,
INBE_HABIT_MAX_DAYS = 366,
HABIT_LINKED_ENTRY_MAX = 128,
HABIT_LINKED_PATH_SIZE = 80
};
@@ -36,7 +37,6 @@ typedef enum InbeHabitSyncMode {
typedef struct InbeHabitDay {
int day_index;
int completed;
int count;
} InbeHabitDay;
typedef struct InbeHabit {
@@ -45,10 +45,8 @@ typedef struct InbeHabit {
Color color;
int sync_mode;
int sync_activity;
int counter_enabled;
InbeHabitDay *days;
InbeHabitDay days[INBE_HABIT_MAX_DAYS];
int day_count;
int day_capacity;
} InbeHabit;
typedef struct InbeHabits {
@@ -61,7 +59,6 @@ typedef struct InbeHabits {
int view_mode;
int weekly_days;
int loaded;
int dirty;
} InbeHabits;
/* Additional structures */
@@ -91,25 +88,19 @@ typedef struct HabitLinkedContext {
} HabitLinkedContext;
/* Core habits functions */
void habits_init(InbeHabits *habits);
void habits_free(InbeHabits *habits);
void habits_save(InbeHabits *habits);
void habits_flush_save(InbeApp *app);
int habits_clear_days(InbeHabits *habits);
int habit_reserve_days(InbeHabit *habit, int capacity);
int habits_today_index(void);
int habit_completed_day(const InbeHabit *habit, int day_index);
int habit_completed_today(const InbeHabit *habit);
void habit_set_day(InbeHabits *habits, int index, int day_index, int completed);
void habit_set_day_count(InbeHabits *habits, int index, int day_index, int count);
int habit_day_count(const InbeHabit *habit, int day_index);
void habit_toggle_day(InbeHabits *habits, int index, int day_index);
void habit_increment_day(InbeHabits *habits, int index, int day_index, int delta);
void habit_toggle_today(InbeHabits *habits, int index);
void habits_add_default(InbeHabits *habits);
void habits_add_default_set(InbeHabits *habits);
void habits_delete(InbeHabits *habits, int index);
int habits_add_custom(InbeHabits *habits, const char *name, Color color,
void inbe_habits_init(InbeHabits *habits);
void inbe_habits_save(const InbeHabits *habits);
int inbe_habits_clear_days(InbeHabits *habits);
int inbe_habits_today_index(void);
int inbe_habit_completed_day(const InbeHabit *habit, int day_index);
int inbe_habit_completed_today(const InbeHabit *habit);
void inbe_habit_set_day(InbeHabits *habits, int index, int day_index, int completed);
void inbe_habit_toggle_day(InbeHabits *habits, int index, int day_index);
void inbe_habit_toggle_today(InbeHabits *habits, int index);
void inbe_habits_add_default(InbeHabits *habits);
void inbe_habits_add_default_set(InbeHabits *habits);
void inbe_habits_delete(InbeHabits *habits, int index);
int inbe_habits_add_custom(InbeHabits *habits, const char *name, Color color,
int sync_mode, int sync_activity);
int habit_activity_mask_for(int exercise);
int habit_matches_activity(const InbeHabit *habit, int exercise_type);
+1 -1
View File
@@ -1,7 +1,7 @@
#include "language_screen.h"
#include "app.h"
#include "flint_locale.h"
#include "locale.h"
#include "theme.h"
#include "flint_ui.h"
#include "raylib.h"
+9
View File
@@ -2,6 +2,15 @@
#include "app.h"
#include "practices/practice_registry.h"
void
on_practice_tab_click(void *user_data)
{
InbeApp *app = user_data;
extern void app_request_bottom_tab(InbeApp *app, int bottom_tab);
enum { APP_BOTTOM_TAB_PRACTICE = 1 };
app_request_bottom_tab(app, APP_BOTTOM_TAB_PRACTICE);
}
int
practice_activity_count_for_tab(int tab)
{
+1
View File
@@ -14,6 +14,7 @@ const char *practice_activity_label(int exercise);
int practice_activity_index_for_tab(int tab, int exercise);
void practice_clamp_activity_to_tab(InbeApp *app);
void on_practice_tab_click(void *user_data);
void app_request_bottom_tab(InbeApp *app, int bottom_tab);
#endif
-863
View File
@@ -1,863 +0,0 @@
#include "settings_data.h"
#include "settings_screen.h"
#include "settings_sync_account.h"
#include "app.h"
#include "data.h"
#include "flint_locale.h"
#include "storage.h"
#include "sync_account.h"
#include "theme.h"
#include "version.h"
#include "flint_theme_meta.h"
#include "flint_ui.h"
#if !defined(PLATFORM_ANDROID) && !defined(__ANDROID__) && !defined(ANDROID) && !defined(_WIN32) && !defined(PLATFORM_WEB)
#define INBE_HAS_FLINT_FILE_DIALOG 1
#include "flint_file_dialog.h"
#endif
#if defined(PLATFORM_ANDROID) || defined(__ANDROID__) || defined(ANDROID)
#include "android_import.h"
#endif
#if defined(PLATFORM_WEB)
#include <emscripten.h>
#endif
#include "raylib.h"
#include <stdio.h>
#include <string.h>
enum {
SETTINGS_DATA_ACTION_NONE = 0,
SETTINGS_DATA_ACTION_IMPORT,
SETTINGS_DATA_ACTION_EXPORT,
SETTINGS_DATA_ACTION_SYNC_KEY_EXPORT,
SETTINGS_DATA_ACTION_SYNC_KEY_IMPORT
};
enum {
SETTINGS_DATA_VIEW_MAIN = 0,
SETTINGS_DATA_VIEW_SYNC_ACCOUNT = 1
};
#define INBE_SYNC_SERVER_URL_KEY "sync_server_url"
#define INBE_SYNC_SERVER_URL_DEFAULT "https://api.waozi.xyz"
#define SETTINGS_DATA_IMPORT_FILTER ".db,.zip"
#define SETTINGS_SYNC_KEY_IMPORT_FILTER ".key"
#define SETTINGS_ANDROID_DATA_IMPORT_MIME_TYPES "application/zip,application/x-zip-compressed,application/vnd.sqlite3,application/x-sqlite,application/x-sqlite3,application/octet-stream"
#define SETTINGS_ANDROID_SYNC_KEY_IMPORT_MIME_TYPES "*/*"
#if defined(INBE_HAS_FLINT_FILE_DIALOG)
static FlintFileDialog export_dlg;
static FlintFileDialog import_dlg;
#endif
static int data_file_dialog_action = SETTINGS_DATA_ACTION_NONE;
typedef struct SettingsFileDialogOrigin {
int active;
int screen;
int settings_tab;
int settings_data_view;
int settings_scroll;
} SettingsFileDialogOrigin;
static SettingsFileDialogOrigin file_dialog_origin;
static char pending_import_path[FS_PATH_MAX] = "";
static DataImportInfo pending_import_info;
static void settings_import_data(InbeApp *app);
static void settings_export_data(InbeApp *app);
static void settings_request_delete_all_data(InbeApp *app);
static void settings_sync_server_load(InbeApp *app);
static int settings_import_sync_key_path(InbeApp *app, const char *path);
static void
settings_clear_pending_import(void)
{
pending_import_path[0] = '\0';
memset(&pending_import_info, 0, sizeof(pending_import_info));
}
static void
settings_file_dialog_begin(InbeApp *app, int action)
{
if(app == NULL)
return;
data_file_dialog_action = action;
file_dialog_origin.active = 1;
file_dialog_origin.screen = app->inbe.screen;
file_dialog_origin.settings_tab = app->settings_tab;
file_dialog_origin.settings_data_view = app->settings_data_view;
file_dialog_origin.settings_scroll = app->settings_scroll;
}
static int
settings_file_dialog_finish(InbeApp *app)
{
int action = data_file_dialog_action;
if(app != NULL && file_dialog_origin.active) {
app->inbe.screen = file_dialog_origin.screen;
app->settings_tab = file_dialog_origin.settings_tab;
app->settings_data_view = file_dialog_origin.settings_data_view;
app->settings_scroll = file_dialog_origin.settings_scroll;
}
file_dialog_origin.active = 0;
data_file_dialog_action = SETTINGS_DATA_ACTION_NONE;
return action;
}
static void
settings_import_success(InbeApp *app, int imported_settings)
{
app_reload_after_import(app, imported_settings);
settings_screen_set_status_success(locale_get("imported_data"), NULL);
TraceLog(LOG_INFO, "DATA: Import successful");
}
static int
settings_perform_import(InbeApp *app, const char *path, DataImportMode mode)
{
if(app == NULL || path == NULL || path[0] == '\0') {
settings_screen_set_status_error(locale_get("import_invalid_file"));
return 0;
}
if(data_import_with_mode(path, mode)) {
settings_import_success(app, mode == DATA_IMPORT_DATA_AND_SETTINGS);
return 1;
}
settings_screen_set_status_error(locale_get("import_failed"));
TraceLog(LOG_ERROR, "DATA: Import failed");
return 0;
}
static void
settings_begin_import_for_path(InbeApp *app, const char *path)
{
DataImportInfo info;
if(app == NULL || path == NULL || path[0] == '\0') {
settings_screen_set_status_error(locale_get("import_invalid_file"));
return;
}
memset(&info, 0, sizeof(info));
if(!data_inspect_import(path, &info) || !info.valid) {
settings_screen_set_status_error(locale_get("import_invalid_file"));
TraceLog(LOG_WARNING, "DATA: Invalid import file selected");
return;
}
if((info.has_sessions || info.has_habits) && info.has_settings) {
snprintf(pending_import_path, sizeof(pending_import_path), "%s", path);
pending_import_info = info;
app->modal.active = 1;
app->modal.type = UIModalConfirmImportDataSettings;
app->modal.selected_button = 0;
settings_screen_clear_status();
return;
}
settings_perform_import(app, path, DATA_IMPORT_DATA_ONLY);
}
static int
settings_draw_import_choice_modal(InbeApp *app)
{
FlintUIPanelFrame frame;
int font = flint_ui_font();
int msg_y;
int msg_x;
const char *message = locale_get("import_choice_message");
int row_gap = flint_px(10);
int btn_h = flint_px(36);
int btn_y;
int btn_w;
int hover = 0;
(void)app;
frame = ui_draw_modal_frame(flint_px(320), flint_px(232),
locale_get("import_choice_title"),
(Texture2D){0}, (Texture2D){0});
msg_x = frame.content_x;
msg_y = frame.content_y;
flint_text_draw(message, msg_x, msg_y, font, theme_get_text());
btn_y = frame.y + frame.h - flint_px(24) - btn_h * 2 - row_gap;
btn_w = (frame.content_w - row_gap) / 2;
if(ui_draw_generic_button(frame.content_x, btn_y, btn_w, btn_h,
locale_get("cancel_button"),
UI_BUTTON_STYLE_SECONDARY, 0, &hover))
return 1;
if(ui_draw_generic_button(frame.content_x + btn_w + row_gap, btn_y, btn_w, btn_h,
locale_get("import_data_only_button"),
UI_BUTTON_STYLE_PRIMARY, 0, &hover))
return 2;
if(ui_draw_generic_button(frame.content_x, btn_y + btn_h + row_gap,
frame.content_w, btn_h,
locale_get("import_data_settings_button"),
UI_BUTTON_STYLE_PRIMARY, 0, &hover))
return 3;
return 0;
}
static int
settings_link_icon_columns(int content_w)
{
int max_columns = 5;
int min_columns = 2;
int icon_size = flint_px(32);
int icon_padding = flint_px(4);
int icon_spacing = flint_px(20);
int icon_btn_w = icon_size + icon_padding * 2;
for(int columns = max_columns; columns > min_columns; columns--) {
int total_w = icon_btn_w * columns + icon_spacing * (columns - 1);
if(total_w <= content_w)
return columns;
}
return min_columns;
}
static int
settings_link_icons_height(int content_w)
{
int link_count = 5;
int icon_size = flint_px(32);
int icon_padding = flint_px(4);
int row_spacing = flint_px(16);
int icon_btn_w = icon_size + icon_padding * 2;
int columns = settings_link_icon_columns(content_w);
int rows = (link_count + columns - 1) / columns;
return flint_px(8) + rows * icon_btn_w + (rows - 1) * row_spacing;
}
int
settings_data_content_height(int content_w)
{
int data_button_h = flint_px(36);
return data_button_h + flint_px(12) +
data_button_h + flint_px(12) +
data_button_h + flint_px(12) +
data_button_h + flint_px(12) +
flint_px(42) +
settings_link_icons_height(content_w) +
flint_px(8) + flint_px(22) +
flint_px(40);
}
int
settings_data_is_configuring(const InbeApp *app)
{
return app != NULL && app->settings_tab == SETTINGS_TAB_DATA &&
app->settings_data_view == SETTINGS_DATA_VIEW_SYNC_ACCOUNT;
}
static void
settings_sync_server_load(InbeApp *app)
{
const char *saved;
if(app == NULL)
return;
saved = storage_get_setting_text(INBE_SYNC_SERVER_URL_KEY);
snprintf(app->sync_server_url, sizeof(app->sync_server_url), "%s",
saved != NULL && saved[0] != '\0'
? saved
: INBE_SYNC_SERVER_URL_DEFAULT);
app->sync_server_url_cursor = (int)strlen(app->sync_server_url);
}
static void
settings_open_sync_account_config(InbeApp *app)
{
if(app == NULL)
return;
settings_sync_server_load(app);
app->settings_data_view = SETTINGS_DATA_VIEW_SYNC_ACCOUNT;
app->settings_scroll = 0;
app->sync_server_url_focused = 0;
settings_screen_clear_status();
}
#if defined(INBE_HAS_FLINT_FILE_DIALOG)
static void
settings_apply_file_dialog_theme(InbeApp *app)
{
int theme_id = app != NULL ? app->theme_id : FLINT_THEME_SKY;
int dark_mode = app != NULL && app->dark_mode != 0;
if(theme_id < 0 || theme_id >= FLINT_THEME_COUNT)
theme_id = FLINT_THEME_SKY;
flint_file_dialog_set_theme_scope(flint_theme_scope_for((FlintThemeId)theme_id,
dark_mode != 0));
}
#endif
static int
settings_start_sync_key_export_dialog(InbeApp *app, const char *filename)
{
settings_file_dialog_begin(app, SETTINGS_DATA_ACTION_SYNC_KEY_EXPORT);
#if defined(INBE_HAS_FLINT_FILE_DIALOG)
settings_apply_file_dialog_theme(app);
flint_file_dialog_begin_save(&export_dlg, locale_get("sync_save_key_dialog_title"), filename);
return 4;
#else
(void)filename;
settings_file_dialog_finish(app);
return 0;
#endif
}
static int
settings_start_sync_key_import_dialog(InbeApp *app)
{
settings_file_dialog_begin(app, SETTINGS_DATA_ACTION_SYNC_KEY_IMPORT);
#if defined(PLATFORM_WEB)
(void)app;
EM_ASM({
const importPath = UTF8ToString($0);
const accept = UTF8ToString($1);
Module.__inbeSyncKeyImportResult = 0;
const input = document.createElement("input");
input.type = "file";
input.accept = accept;
input.style.display = "none";
input.onchange = async function() {
try {
if(!input.files || input.files.length === 0) {
Module.__inbeSyncKeyImportResult = 2;
return;
}
const file = input.files[0];
const bytes = new Uint8Array(await file.arrayBuffer());
try {
FS.mkdirTree("/tmp");
} catch(e) {}
try {
FS.unlink(importPath);
} catch(e) {}
FS.writeFile(importPath, bytes);
Module.__inbeSyncKeyImportResult = 1;
} catch(e) {
console.error("Inbe sync key import failed:", e);
Module.__inbeSyncKeyImportResult = 3;
} finally {
input.remove();
}
};
document.body.appendChild(input);
input.click();
}, "/tmp/inbe-sync-key-import.key", SETTINGS_SYNC_KEY_IMPORT_FILTER);
settings_screen_set_status_success(locale_get("sync_import_key_dialog_title"), NULL);
return 1;
#elif defined(PLATFORM_ANDROID) || defined(__ANDROID__) || defined(ANDROID)
(void)app;
if(android_import_open_picker(SETTINGS_ANDROID_SYNC_KEY_IMPORT_MIME_TYPES)) {
settings_screen_set_status_success(locale_get("sync_import_key_dialog_title"), NULL);
return 1;
}
settings_file_dialog_finish(app);
return 0;
#elif defined(INBE_HAS_FLINT_FILE_DIALOG)
settings_apply_file_dialog_theme(app);
flint_file_dialog_begin_load_filtered(&import_dlg, locale_get("sync_import_key_dialog_title"),
SETTINGS_SYNC_KEY_IMPORT_FILTER);
return 1;
#else
settings_file_dialog_finish(app);
return 0;
#endif
}
static void
settings_draw_link_icons(InbeApp *app, int content_x, int content_w, int *y)
{
int link_count = 5;
int icon_size = flint_px(32);
int icon_padding = flint_px(4);
int icon_spacing = flint_px(20);
int icon_btn_w = icon_size + icon_padding * 2;
int columns = settings_link_icon_columns(content_w);
int grid_w = icon_btn_w * columns + icon_spacing * (columns - 1);
int links_start_x = content_x + (content_w - grid_w) / 2;
int row_spacing = flint_px(16);
Texture2D icons[5] = {
app->icons[UI_ICON_TYPE_DISCORD],
app->icons[UI_ICON_TYPE_TELEGRAM],
app->icons[UI_ICON_TYPE_GITHUB],
app->icons[UI_ICON_TYPE_BTC],
app->icons[UI_ICON_TYPE_MONERO]
};
const char *urls[5] = {
"https://discord.com/invite/JbGZ4yENDt",
"https://t.me/lotusinbe",
"https://github.com/waozixyz/inbe",
"https://trocador.app/en/anonpay/?ticker_to=btc&network_to=Mainnet&address=bc1qxzcetg50f6epgddc09n82xqn3zswlmk44235y5&donation=True&simple_mode=True&amount=0.001&name=Inner+Breeze&[email protected]&ticker_from=btc&network_from=Mainnet&buttonbgcolor=445588&textcolor=ffffff&bgcolor=eaeaffff",
"https://trocador.app/en/anonpay/?ticker_to=xmr&network_to=Mainnet&address=86CbC3d4a2GhT9auh6X99JhmhTMFKVVk8Q9cLrKTHkBu8LLkoNWgkBeAT3YZrvDM6NczYe8brUJNsTiFmwpWDZYnFG5kzSH&donation=True&simple_mode=True&amount=0.1&name=Inner+Breeze&[email protected]&ticker_from=xmr&network_from=Mainnet&buttonbgcolor=445588&textcolor=ffffff&bgcolor=eaeaffff"
};
*y += flint_px(8);
for(int i = 0; i < link_count; i++) {
int col = i % columns;
int row = i / columns;
int icon_x = links_start_x + col * (icon_btn_w + icon_spacing) + icon_padding;
int icon_y = *y + row * (icon_btn_w + row_spacing);
ui_draw_icon_link(icon_x, icon_y, icon_size, icons[i], urls[i]);
}
*y += settings_link_icons_height(content_w) - flint_px(8);
}
static void
settings_draw_version_centered(int x, int w, int *y)
{
char version_text[32];
int font = flint_ui_font_small();
int text_w;
snprintf(version_text, sizeof(version_text), "v%s", INBE_VERSION_STRING);
text_w = flint_text_measure(version_text, font);
flint_text_draw(version_text, x + (w - text_w) / 2, *y, font,
flint_darken(theme_get_text(), 40));
*y += flint_px(22);
}
void
settings_data_draw(InbeApp *app, int x, int w, int *y)
{
int data_button_h = flint_px(36);
int hover_account = 0;
int hover_import = 0;
int hover_export = 0;
int hover_delete = 0;
settings_sync_account_set_save_dialog(settings_start_sync_key_export_dialog);
settings_sync_account_set_import_dialog(settings_start_sync_key_import_dialog);
if(app != NULL && app->settings_data_view == SETTINGS_DATA_VIEW_SYNC_ACCOUNT) {
settings_sync_account_draw_config(app, x, w, y);
return;
}
if(ui_draw_generic_button(x, *y, w, data_button_h,
locale_get("sync_configure_account_button"),
UI_BUTTON_STYLE_PRIMARY, 0, &hover_account))
settings_open_sync_account_config(app);
*y += data_button_h + flint_px(12);
if(ui_draw_generic_button(x, *y, w, data_button_h,
locale_get("import_data_button"),
UI_BUTTON_STYLE_PRIMARY, 0, &hover_import))
settings_import_data(app);
*y += data_button_h + flint_px(12);
if(ui_draw_generic_button(x, *y, w, data_button_h,
locale_get("export_data_button"),
UI_BUTTON_STYLE_PRIMARY, 0, &hover_export))
settings_export_data(app);
*y += data_button_h + flint_px(12);
if(ui_draw_generic_button(x, *y, w, data_button_h,
locale_get("delete_all_data_button"),
UI_BUTTON_STYLE_DANGER, 0, &hover_delete))
settings_request_delete_all_data(app);
*y += data_button_h + flint_px(12);
settings_screen_draw_status_reserved(x, y, flint_px(42));
settings_draw_link_icons(app, x, w, y);
*y += flint_px(8);
settings_draw_version_centered(x, w, y);
}
#if defined(PLATFORM_ANDROID) || defined(__ANDROID__) || defined(ANDROID)
void
settings_data_handle_android_import(InbeApp *app)
{
char import_path[FS_PATH_MAX];
int import_result = android_import_poll_result(import_path, sizeof(import_path));
int action;
if(import_result == ANDROID_IMPORT_RESULT_NONE)
return;
action = settings_file_dialog_finish(app);
if(import_result == ANDROID_IMPORT_RESULT_CANCELLED) {
if(action == SETTINGS_DATA_ACTION_SYNC_KEY_IMPORT)
settings_screen_set_status_error(locale_get("sync_private_key_import_cancelled"));
else
settings_screen_set_status_error(locale_get("import_cancelled"));
return;
}
if(import_path[0] == '\0') {
if(action == SETTINGS_DATA_ACTION_SYNC_KEY_IMPORT)
settings_screen_set_status_error(locale_get("sync_private_key_import_failed"));
else
settings_screen_set_status_error(locale_get("import_invalid_file"));
return;
}
if(action == SETTINGS_DATA_ACTION_SYNC_KEY_IMPORT)
settings_import_sync_key_path(app, import_path);
else
settings_begin_import_for_path(app, import_path);
}
#else
void settings_data_handle_android_import(InbeApp *app) { (void)app; }
#endif
#if defined(PLATFORM_WEB)
#define SETTINGS_WEB_IMPORT_PATH "/tmp/inbe-web-import.zip"
#define SETTINGS_WEB_SYNC_KEY_IMPORT_PATH "/tmp/inbe-sync-key-import.key"
static void
settings_web_import_open_picker(void)
{
EM_ASM({
const importPath = UTF8ToString($0);
Module.__inbeImportResult = 0;
const input = document.createElement("input");
input.type = "file";
input.accept = ".zip,.db,application/zip,application/x-sqlite3,application/octet-stream";
input.style.display = "none";
input.onchange = async function() {
try {
if(!input.files || input.files.length === 0) {
Module.__inbeImportResult = 2;
return;
}
const file = input.files[0];
const bytes = new Uint8Array(await file.arrayBuffer());
try {
FS.mkdirTree("/tmp");
} catch(e) {}
try {
FS.unlink(importPath);
} catch(e) {}
FS.writeFile(importPath, bytes);
Module.__inbeImportResult = 1;
} catch(e) {
console.error("Inbe web import failed:", e);
Module.__inbeImportResult = 3;
} finally {
input.remove();
}
};
document.body.appendChild(input);
input.click();
}, SETTINGS_WEB_IMPORT_PATH);
}
void
settings_data_handle_web_import(InbeApp *app)
{
int import_result = EM_ASM_INT({
const result = Module.__inbeImportResult || 0;
if(result !== 0)
Module.__inbeImportResult = 0;
return result;
});
if(import_result != 0)
settings_file_dialog_finish(app);
if(import_result == 2) {
settings_screen_set_status_error(locale_get("import_cancelled"));
} else if(import_result != 0 && import_result != 1) {
settings_screen_set_status_error(locale_get("import_failed"));
} else if(import_result == 1) {
settings_begin_import_for_path(app, SETTINGS_WEB_IMPORT_PATH);
}
import_result = EM_ASM_INT({
const result = Module.__inbeSyncKeyImportResult || 0;
if(result !== 0)
Module.__inbeSyncKeyImportResult = 0;
return result;
});
if(import_result == 0)
return;
settings_file_dialog_finish(app);
if(import_result == 2) {
settings_screen_set_status_error(locale_get("sync_private_key_import_cancelled"));
return;
}
if(import_result != 1) {
settings_screen_set_status_error(locale_get("sync_private_key_import_failed"));
return;
}
settings_import_sync_key_path(app, SETTINGS_WEB_SYNC_KEY_IMPORT_PATH);
}
#else
void settings_data_handle_web_import(InbeApp *app) { (void)app; }
#endif
static void
settings_import_data(InbeApp *app)
{
settings_file_dialog_begin(app, SETTINGS_DATA_ACTION_IMPORT);
#if defined(PLATFORM_ANDROID) || defined(__ANDROID__) || defined(ANDROID)
if(android_import_open_picker(SETTINGS_ANDROID_DATA_IMPORT_MIME_TYPES))
settings_screen_set_status_success(locale_get("import_data_dialog_title"), NULL);
else {
settings_file_dialog_finish(app);
settings_screen_set_status_error(locale_get("import_failed"));
}
#elif defined(PLATFORM_WEB)
(void)app;
settings_web_import_open_picker();
settings_screen_set_status_success(locale_get("import_data_dialog_title"), NULL);
#elif defined(INBE_HAS_FLINT_FILE_DIALOG)
settings_apply_file_dialog_theme(app);
flint_file_dialog_begin_load_filtered(&import_dlg, locale_get("import_data_dialog_title"),
SETTINGS_DATA_IMPORT_FILTER);
#else
settings_file_dialog_finish(app);
settings_screen_set_status_error(locale_get("import_failed"));
#endif
}
static int
settings_import_sync_key_path(InbeApp *app, const char *path)
{
InbeSyncAccount account;
if(path != NULL && path[0] != '\0' &&
sync_account_import_private_key(&account, path)) {
const char *saved = storage_get_setting_text(INBE_SYNC_SERVER_URL_KEY);
if(saved == NULL || saved[0] == '\0')
storage_set_setting_text(INBE_SYNC_SERVER_URL_KEY, INBE_SYNC_SERVER_URL_DEFAULT);
settings_screen_set_status_success(locale_get("sync_private_key_imported"), NULL);
TraceLog(LOG_INFO, "SYNC: Private key imported from %s", path);
app_auto_sync(app);
return 1;
}
settings_screen_set_status_error(locale_get("sync_private_key_import_failed"));
TraceLog(LOG_ERROR, "SYNC: Private key import failed");
(void)app;
return 0;
}
static void
settings_export_data(InbeApp *app)
{
char export_filename[64];
data_default_export_filename(export_filename, sizeof(export_filename));
if(!data_has_any()) {
settings_screen_set_status_error(locale_get("no_data_to_export"));
return;
}
#if defined(PLATFORM_ANDROID) || defined(__ANDROID__) || defined(ANDROID)
settings_file_dialog_begin(app, SETTINGS_DATA_ACTION_EXPORT);
if(data_export(export_filename)) {
settings_file_dialog_finish(app);
settings_screen_set_status_success(locale_get("exported_label"), NULL);
TraceLog(LOG_INFO, "DATA: Export successful (share sheet shown)");
} else {
settings_file_dialog_finish(app);
settings_screen_set_status_error(locale_get("export_failed"));
TraceLog(LOG_ERROR, "DATA: Export failed");
}
#elif defined(INBE_HAS_FLINT_FILE_DIALOG)
settings_file_dialog_begin(app, SETTINGS_DATA_ACTION_EXPORT);
settings_apply_file_dialog_theme(app);
flint_file_dialog_begin_save(&export_dlg, locale_get("export_data_dialog_title"), export_filename);
#else
(void)app;
settings_screen_set_status_error(locale_get("export_failed"));
#endif
}
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;
} else {
settings_screen_set_status_error(locale_get("no_data_to_delete"));
}
}
#if defined(INBE_HAS_FLINT_FILE_DIALOG)
int
settings_data_draw_pending_file_dialog(InbeApp *app)
{
FlintFileDialog *dlg;
int result;
if(data_file_dialog_action == SETTINGS_DATA_ACTION_NONE)
return 0;
settings_apply_file_dialog_theme(app);
dlg = (data_file_dialog_action == SETTINGS_DATA_ACTION_IMPORT ||
data_file_dialog_action == SETTINGS_DATA_ACTION_SYNC_KEY_IMPORT)
? &import_dlg
: &export_dlg;
result = flint_file_dialog_update(dlg);
if(result < 0)
return 1;
if(data_file_dialog_action == SETTINGS_DATA_ACTION_IMPORT) {
if(result == 1) {
const char *path = flint_file_dialog_get_path(&import_dlg);
if(path != NULL && path[0] != '\0') {
settings_begin_import_for_path(app, path);
} else {
settings_screen_set_status_error(locale_get("import_invalid_file"));
TraceLog(LOG_WARNING, "DATA: No file selected for import");
}
} else {
settings_screen_set_status_error(locale_get("import_cancelled"));
}
} else if(data_file_dialog_action == SETTINGS_DATA_ACTION_EXPORT) {
if(result == 1) {
const char *path = flint_file_dialog_get_path(&export_dlg);
if(path != NULL && data_export(path)) {
const char *filename = GetFileName(path);
settings_screen_set_status_success(locale_get("exported_label"), filename);
TraceLog(LOG_INFO, "DATA: Export successful to %s", path);
} else {
settings_screen_set_status_error(locale_get("export_failed"));
TraceLog(LOG_ERROR, "DATA: Export failed");
}
} else {
settings_screen_set_status_error(locale_get("export_cancelled"));
}
} else if(data_file_dialog_action == SETTINGS_DATA_ACTION_SYNC_KEY_EXPORT) {
if(result == 1) {
InbeSyncAccount account;
const char *path = flint_file_dialog_get_path(&export_dlg);
if(path != NULL && path[0] != '\0' &&
sync_account_load(&account) &&
sync_account_export_private_key(&account, path)) {
settings_screen_set_status_success(locale_get("sync_private_key_backup_saved"), GetFileName(path));
TraceLog(LOG_INFO, "SYNC: Private key backup saved to %s", path);
} else {
settings_screen_set_status_error(locale_get("sync_private_key_backup_failed"));
TraceLog(LOG_ERROR, "SYNC: Private key backup failed");
}
} else {
settings_screen_set_status_error(locale_get("sync_private_key_backup_cancelled"));
}
} else if(data_file_dialog_action == SETTINGS_DATA_ACTION_SYNC_KEY_IMPORT) {
if(result == 1) {
const char *path = flint_file_dialog_get_path(&import_dlg);
settings_import_sync_key_path(app, path);
} else {
settings_screen_set_status_error(locale_get("sync_private_key_import_cancelled"));
}
}
settings_file_dialog_finish(app);
return 1;
}
#else
int settings_data_draw_pending_file_dialog(InbeApp *app) { (void)app; return 0; }
#endif
int
settings_data_draw_modals(InbeApp *app)
{
if(app == NULL || !app->modal.active)
return 0;
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;
settings_clear_pending_import();
settings_screen_set_status_error(locale_get("import_cancelled"));
} else if(modal_result == 2 || modal_result == 3) {
char import_path[FS_PATH_MAX];
DataImportMode mode = modal_result == 3
? DATA_IMPORT_DATA_AND_SETTINGS
: DATA_IMPORT_DATA_ONLY;
snprintf(import_path, sizeof(import_path), "%s", pending_import_path);
app->modal.active = 0;
app->modal.type = UIModalNone;
settings_clear_pending_import();
settings_perform_import(app, import_path, mode);
}
return 1;
}
if(app->modal.type == UIModalConfirmDeleteData) {
int modal_result = ui_draw_modal(locale_get("delete_all_data_title"),
locale_get("delete_all_data_message"),
locale_get("cancel_button"),
locale_get("delete_button"));
if(modal_result == 1) {
app->modal.active = 0;
app->modal.type = UIModalNone;
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;
if(deleted > 0) {
char deleted_message[128];
habits_free(&app->habits);
memset(&app->habits, 0, sizeof(app->habits));
app->habits.loaded = 1;
locale_format(deleted_message, sizeof(deleted_message),
"deleted_sessions", deleted);
settings_screen_set_status_success(deleted_message, NULL);
} else {
int cleared = habits_clear_days(&app->habits);
if(cleared > 0) {
char deleted_message[128];
habits_save(&app->habits);
locale_format(deleted_message, sizeof(deleted_message),
"deleted_sessions", cleared);
settings_screen_set_status_success(deleted_message, NULL);
} else {
settings_screen_set_status_error(locale_get("no_data_to_delete"));
}
}
}
return 1;
}
if(app->modal.type == UIModalConfirmDeleteSyncAccount) {
int modal_result = ui_draw_modal(locale_get("sync_delete_account_title"),
locale_get("sync_delete_account_message"),
locale_get("cancel_button"),
locale_get("delete_button"));
if(modal_result == 1) {
app->modal.active = 0;
app->modal.type = UIModalNone;
settings_screen_set_status_error(locale_get("sync_account_delete_cancelled"));
} else if(modal_result == 2) {
app->modal.active = 0;
app->modal.type = UIModalNone;
settings_sync_account_delete_confirmed(app);
}
return 1;
}
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;
if(modal_result == 2)
settings_screen_set_status_success(locale_get("sync_private_key_backup_saved"), NULL);
else if(modal_result == 3)
settings_screen_set_status_error(locale_get("sync_private_key_backup_failed"));
}
return 1;
}
return 0;
}
-14
View File
@@ -1,14 +0,0 @@
#ifndef INBE_SETTINGS_DATA_H
#define INBE_SETTINGS_DATA_H
#include "app_fwd.h"
int settings_data_content_height(int content_w);
int settings_data_is_configuring(const InbeApp *app);
void settings_data_draw(InbeApp *app, int x, int w, int *y);
int settings_data_draw_pending_file_dialog(InbeApp *app);
int settings_data_draw_modals(InbeApp *app);
void settings_data_handle_android_import(InbeApp *app);
void settings_data_handle_web_import(InbeApp *app);
#endif
-142
View File
@@ -1,142 +0,0 @@
#include "settings_device.h"
#include "app.h"
#include "app_settings.h"
#include "device_preferences.h"
#include "language_screen.h"
#include "flint_locale.h"
#include "theme.h"
#include "flint_ui.h"
static int
settings_device_orientation_option_count(void)
{
#if defined(PLATFORM_ANDROID) || defined(__ANDROID__) || defined(ANDROID)
return 4;
#else
return 3;
#endif
}
int
settings_device_content_height(void)
{
int height = flint_px(74) + flint_px(74) + flint_px(76) + flint_px(40);
#if defined(PLATFORM_ANDROID) || defined(__ANDROID__) || defined(ANDROID)
height += flint_px(76);
#endif
#if !defined(PLATFORM_ANDROID) && !defined(__ANDROID__) && !defined(ANDROID) && !defined(PLATFORM_WEB)
height += flint_px(50);
#endif
height += flint_px(72);
return height;
}
void
settings_device_draw(InbeApp *app, int x, int w, int *y, SettingsDeviceState *state)
{
int sound_volume;
int keyboard_toggle;
int toggle_w = flint_px(56);
int toggle_h = flint_px(30);
const char *orientation_options[] = {
locale_get("orientation_system"),
locale_get("orientation_portrait"),
locale_get("orientation_landscape"),
locale_get("orientation_sensor")
};
int orientation_option_count = settings_device_orientation_option_count();
if(app == NULL || y == NULL || state == NULL)
return;
sound_volume = app->sound_volume;
keyboard_toggle = app->on_screen_keyboard_enabled;
if(language_dropdown_button(app, 101, x, *y, w, flint_px(36), &app->language_index))
state->language_menu_changed = 1;
state->draw_language_menu = 1;
*y += flint_px(74);
if(ui_draw_slider(6, x, *y, w, locale_get("volume_label"),
SETTINGS_VOLUME_MIN, SETTINGS_VOLUME_MAX, &sound_volume, "")) {
app->sound_volume = sound_volume;
app->settings_dirty = 1;
save_settings(app);
}
*y += flint_px(74);
#ifdef __ANDROID__
{
int play_in_background = app->inbe.play_in_background;
flint_text_draw(locale_get("play_in_background_label"), x, *y,
flint_ui_font(), theme_get_text());
if(ui_draw_toggle_switch(x, *y + flint_px(26), toggle_w, toggle_h,
&play_in_background, locale_get("toggle_off"),
locale_get("toggle_on"))) {
app->inbe.play_in_background = play_in_background;
app->settings_dirty = 1;
}
*y += flint_px(76);
}
#endif
{
int orientation_max = orientation_option_count - 1;
app->orientation_mode = clampi(app->orientation_mode,
APP_ORIENTATION_SYSTEM,
orientation_max);
flint_text_draw(locale_get("orientation_label"), x, *y,
flint_ui_font(), theme_get_text());
ui_draw_dropdown_button(103, x, *y + flint_px(26), w, flint_px(36),
orientation_options, orientation_option_count,
&app->orientation_mode);
state->draw_orientation_menu = 1;
*y += flint_px(76);
}
#if !defined(PLATFORM_ANDROID) && !defined(__ANDROID__) && !defined(ANDROID) && !defined(PLATFORM_WEB)
if(ui_draw_checkbox_toggle(x, *y, locale_get("fullscreen_label"), &app->fullscreen_enabled)) {
if(app->fullscreen_enabled && !IsWindowFullscreen())
ToggleFullscreen();
else if(!app->fullscreen_enabled && IsWindowFullscreen())
ToggleFullscreen();
app->settings_dirty = 1;
}
*y += flint_px(50);
#endif
flint_text_draw(locale_get("on_screen_keyboard_label"), x, *y,
flint_ui_font(), theme_get_text());
if(ui_draw_toggle_switch(x, *y + flint_px(26), toggle_w, toggle_h,
&keyboard_toggle, locale_get("toggle_off"),
locale_get("toggle_on"))) {
app->on_screen_keyboard_enabled = keyboard_toggle;
app->settings_dirty = 1;
}
*y += flint_px(76);
}
void
settings_device_handle_overlays(InbeApp *app, SettingsDeviceState *state)
{
int orientation_option_count = settings_device_orientation_option_count();
if(app == NULL || state == NULL)
return;
if(state->draw_language_menu && language_dropdown_menu(app, 101))
state->language_menu_changed = 1;
if(state->draw_orientation_menu && ui_draw_dropdown_menu(103))
state->orientation_changed = 1;
if(state->language_menu_changed)
apply_language_selection(app, app->language_index, 1);
if(state->orientation_changed) {
int orientation_max = orientation_option_count - 1;
app->orientation_mode = clampi(app->orientation_mode, APP_ORIENTATION_SYSTEM,
orientation_max);
app_apply_orientation_preference(app);
app->settings_dirty = 1;
save_settings(app);
}
}
-17
View File
@@ -1,17 +0,0 @@
#ifndef INBE_SETTINGS_DEVICE_H
#define INBE_SETTINGS_DEVICE_H
#include "app_fwd.h"
typedef struct SettingsDeviceState {
int draw_language_menu;
int language_menu_changed;
int draw_orientation_menu;
int orientation_changed;
} SettingsDeviceState;
int settings_device_content_height(void);
void settings_device_draw(InbeApp *app, int x, int w, int *y, SettingsDeviceState *state);
void settings_device_handle_overlays(InbeApp *app, SettingsDeviceState *state);
#endif
+745 -108
View File
@@ -1,13 +1,24 @@
#include "settings_screen.h"
#include "app.h"
#include "app_settings.h"
#include "flint_locale.h"
#include "settings_data.h"
#include "settings_device.h"
#include "settings_theme.h"
#include "device_preferences.h"
#include "language_screen.h"
#include "locale.h"
#include "theme.h"
#include "flint_theme_meta.h"
#include "flint_clip.h"
#include "flint_ui.h"
#if !defined(PLATFORM_ANDROID) && !defined(__ANDROID__) && !defined(ANDROID) && !defined(_WIN32) && !defined(PLATFORM_WEB)
#define INBE_HAS_FLINT_FILE_DIALOG 1
#include "flint_file_dialog.h"
#endif
#if defined(PLATFORM_ANDROID) || defined(__ANDROID__) || defined(ANDROID)
#include "android_import.h"
#endif
#if defined(PLATFORM_WEB)
#include <emscripten.h>
#endif
#include "version.h"
#include "data.h"
#include "raylib.h"
#include <stdio.h>
#include <string.h>
@@ -15,9 +26,17 @@
extern int view_width;
extern int view_height;
static char unified_status[256] = "";
static char unified_detail[256] = "";
static int unified_status_type = 0;
enum {
SETTINGS_DATA_ACTION_NONE = 0,
SETTINGS_DATA_ACTION_IMPORT,
SETTINGS_DATA_ACTION_EXPORT
};
#if defined(INBE_HAS_FLINT_FILE_DIALOG)
static FlintFileDialog export_dlg;
static FlintFileDialog import_dlg;
static int data_file_dialog_action = SETTINGS_DATA_ACTION_NONE;
#endif
static int
settings_draw_subtab_bar(int y, int h, const char **tab_names, int tab_count,
@@ -43,16 +62,22 @@ settings_draw_subtab_bar(int y, int h, const char **tab_names, int tab_count,
});
}
void
settings_screen_set_status_success(const char *message, const char *detail)
{
if(message != NULL) {
/* Unified status system variables */
static char unified_status[256] = "";
static char unified_detail[256] = "";
static int unified_status_type = 0;
static char pending_import_path[FS_PATH_MAX] = "";
static DataImportInfo pending_import_info;
/* Helper functions for unified status system */
void settings_screen_set_status_success(const char *message, const char *detail) {
if(message) {
strncpy(unified_status, message, sizeof(unified_status) - 1);
unified_status[sizeof(unified_status) - 1] = '\0';
} else {
unified_status[0] = '\0';
}
if(detail != NULL) {
if(detail) {
strncpy(unified_detail, detail, sizeof(unified_detail) - 1);
unified_detail[sizeof(unified_detail) - 1] = '\0';
} else {
@@ -61,10 +86,8 @@ settings_screen_set_status_success(const char *message, const char *detail)
unified_status_type = 1;
}
void
settings_screen_set_status_error(const char *message)
{
if(message != NULL) {
void settings_screen_set_status_error(const char *message) {
if(message) {
strncpy(unified_status, message, sizeof(unified_status) - 1);
unified_status[sizeof(unified_status) - 1] = '\0';
} else {
@@ -82,30 +105,129 @@ settings_screen_clear_status(void)
unified_status_type = 0;
}
static void
settings_clear_pending_import(void)
{
pending_import_path[0] = '\0';
memset(&pending_import_info, 0, sizeof(pending_import_info));
}
static void
settings_import_success(InbeApp *app, int imported_settings)
{
app_reload_after_import(app, imported_settings);
settings_screen_set_status_success(locale_get("imported_data"), NULL);
TraceLog(LOG_INFO, "DATA: Import successful");
}
static int
settings_perform_import(InbeApp *app, const char *path, DataImportMode mode)
{
if(app == NULL || path == NULL || path[0] == '\0') {
settings_screen_set_status_error(locale_get("import_invalid_file"));
return 0;
}
if(data_import_with_mode(path, mode)) {
settings_import_success(app, mode == DATA_IMPORT_DATA_AND_SETTINGS);
return 1;
}
settings_screen_set_status_error(locale_get("import_failed"));
TraceLog(LOG_ERROR, "DATA: Import failed");
return 0;
}
static void
settings_begin_import_for_path(InbeApp *app, const char *path)
{
DataImportInfo info;
if(app == NULL || path == NULL || path[0] == '\0') {
settings_screen_set_status_error(locale_get("import_invalid_file"));
return;
}
memset(&info, 0, sizeof(info));
if(!data_inspect_import(path, &info) || !info.valid) {
settings_screen_set_status_error(locale_get("import_invalid_file"));
TraceLog(LOG_WARNING, "DATA: Invalid import file selected");
return;
}
if((info.has_sessions || info.has_habits) && info.has_settings) {
snprintf(pending_import_path, sizeof(pending_import_path), "%s", path);
pending_import_info = info;
app->modal.active = 1;
app->modal.type = UIModalConfirmImportDataSettings;
app->modal.selected_button = 0;
settings_screen_clear_status();
return;
}
settings_perform_import(app, path, DATA_IMPORT_DATA_ONLY);
}
static int
settings_draw_import_choice_modal(InbeApp *app)
{
FlintUIPanelFrame frame;
int font = flint_ui_font();
int msg_y;
int msg_x;
const char *message = locale_get("import_choice_message");
int row_gap = flint_px(10);
int btn_h = flint_px(36);
int btn_y;
int btn_w;
int hover = 0;
(void)app;
frame = ui_draw_modal_frame(flint_px(320), flint_px(232),
locale_get("import_choice_title"),
(Texture2D){0}, (Texture2D){0});
msg_x = frame.content_x;
msg_y = frame.content_y;
flint_text_draw(message, msg_x, msg_y, font, theme_get_text());
btn_y = frame.y + frame.h - flint_px(24) - btn_h * 2 - row_gap;
btn_w = (frame.content_w - row_gap) / 2;
if(ui_draw_generic_button(frame.content_x, btn_y, btn_w, btn_h,
locale_get("cancel_button"),
UI_BUTTON_STYLE_SECONDARY, 0, &hover))
return 1;
if(ui_draw_generic_button(frame.content_x + btn_w + row_gap, btn_y, btn_w, btn_h,
locale_get("import_data_only_button"),
UI_BUTTON_STYLE_PRIMARY, 0, &hover))
return 2;
if(ui_draw_generic_button(frame.content_x, btn_y + btn_h + row_gap,
frame.content_w, btn_h,
locale_get("import_data_settings_button"),
UI_BUTTON_STYLE_PRIMARY, 0, &hover))
return 3;
return 0;
}
static void
settings_draw_status(int x, int *y)
{
int status_font;
Color status_color;
if(unified_status[0] == '\0')
return;
status_font = flint_ui_font_small();
status_color = (unified_status_type == 2) ? RED : theme_get_text();
int status_font = flint_ui_font_small();
Color status_color = (unified_status_type == 2) ? RED : theme_get_text();
flint_text_draw(unified_status, x, *y, status_font, status_color);
*y += flint_px(18);
if(unified_detail[0] != '\0') {
flint_text_draw(unified_detail, x, *y, status_font,
flint_darken(theme_get_text(), 40));
flint_text_draw(unified_detail, x, *y, status_font, flint_darken(theme_get_text(), 40));
*y += flint_px(18);
}
}
void
settings_screen_draw_status_reserved(int x, int *y, int reserved_h)
static void
settings_draw_status_reserved(int x, int *y, int reserved_h)
{
int status_y = *y;
@@ -113,49 +235,368 @@ settings_screen_draw_status_reserved(int x, int *y, int reserved_h)
*y += reserved_h;
}
static int
settings_tab_content_height(InbeApp *app, int tab, int content_w)
static void
settings_draw_version_centered(int x, int w, int *y)
{
if(tab == SETTINGS_TAB_THEME)
return settings_theme_content_height(content_w);
if(tab == SETTINGS_TAB_DEVICE)
return settings_device_content_height();
if(settings_data_is_configuring(app))
return flint_px(430);
return settings_data_content_height(content_w);
char version_text[32];
int font = flint_ui_font_small();
int text_w;
snprintf(version_text, sizeof(version_text), "v%s", INBE_VERSION_STRING);
text_w = flint_text_measure(version_text, font);
flint_text_draw(version_text, x + (w - text_w) / 2, *y, font, flint_darken(theme_get_text(), 40));
*y += flint_px(22);
}
static int
settings_link_icon_columns(int content_w)
{
int max_columns = 5;
int icon_size = flint_px(32);
int icon_padding = flint_px(4);
int icon_spacing = flint_px(20);
int icon_btn_w = icon_size + icon_padding * 2;
int total_w = icon_btn_w * max_columns + icon_spacing * (max_columns - 1);
return total_w <= content_w ? max_columns : 2;
}
static int
settings_link_icons_height(int content_w)
{
int link_count = 5;
int icon_size = flint_px(32);
int icon_padding = flint_px(4);
int row_spacing = flint_px(16);
int icon_btn_w = icon_size + icon_padding * 2;
int columns = settings_link_icon_columns(content_w);
int rows = (link_count + columns - 1) / columns;
return flint_px(8) + rows * icon_btn_w + (rows - 1) * row_spacing;
}
static int
settings_data_content_height(int content_w)
{
int data_button_h = flint_px(36);
return flint_px(98) +
data_button_h + flint_px(12) +
data_button_h + flint_px(12) +
data_button_h + flint_px(12) +
flint_px(42) +
settings_link_icons_height(content_w) +
flint_px(8) + flint_px(22) +
flint_px(40);
}
static void
settings_draw_link_icons(InbeApp *app, int content_x, int content_w, int *y)
{
int link_count = 5;
int icon_size = flint_px(32);
int icon_padding = flint_px(4);
int icon_spacing = flint_px(20);
int icon_btn_w = icon_size + icon_padding * 2;
int columns = settings_link_icon_columns(content_w);
int grid_w = icon_btn_w * columns + icon_spacing * (columns - 1);
int links_start_x = content_x + (content_w - grid_w) / 2;
int row_spacing = flint_px(16);
Texture2D icons[5] = {
app->icons[UI_ICON_TYPE_DISCORD],
app->icons[UI_ICON_TYPE_TELEGRAM],
app->icons[UI_ICON_TYPE_GITHUB],
app->icons[UI_ICON_TYPE_BTC],
app->icons[UI_ICON_TYPE_MONERO]
};
const char *urls[5] = {
"https://discord.com/invite/JbGZ4yENDt",
"https://t.me/lotusinbe",
"https://github.com/waozixyz/inbe",
"https://trocador.app/en/anonpay/?ticker_to=btc&network_to=Mainnet&address=bc1qxzcetg50f6epgddc09n82xqn3zswlmk44235y5&donation=True&simple_mode=True&amount=0.001&name=Inner+Breeze&[email protected]&ticker_from=btc&network_from=Mainnet&buttonbgcolor=445588&textcolor=ffffff&bgcolor=eaeaffff",
"https://trocador.app/en/anonpay/?ticker_to=xmr&network_to=Mainnet&address=86CbC3d4a2GhT9auh6X99JhmhTMFKVVk8Q9cLrKTHkBu8LLkoNWgkBeAT3YZrvDM6NczYe8brUJNsTiFmwpWDZYnFG5kzSH&donation=True&simple_mode=True&amount=0.1&name=Inner+Breeze&[email protected]&ticker_from=xmr&network_from=Mainnet&buttonbgcolor=445588&textcolor=ffffff&bgcolor=eaeaffff"
};
*y += flint_px(8);
for(int i = 0; i < link_count; i++) {
int col = i % columns;
int row = i / columns;
int icon_x = links_start_x + col * (icon_btn_w + icon_spacing) + icon_padding;
int icon_y = *y + row * (icon_btn_w + row_spacing);
ui_draw_icon_link(icon_x, icon_y, icon_size, icons[i], urls[i]);
}
*y += settings_link_icons_height(content_w) - flint_px(8);
}
static void
settings_format_data_size(char *dst, size_t dst_size, long long data_size)
{
if(data_size < 1024)
snprintf(dst, dst_size, "%lld B", data_size);
else if(data_size < 1024 * 1024)
snprintf(dst, dst_size, "%.1f KB", (float)data_size / 1024);
else
snprintf(dst, dst_size, "%.1f MB", (float)data_size / (1024 * 1024));
}
static void
settings_draw_data_stats(int x, int y, int w)
{
int font = flint_ui_font();
int session_count = data_get_session_count();
long long data_size = data_get_total_size();
char size_str[32];
char stat_text[64];
int stats_box_h = flint_px(66);
int stat_x = x + flint_px(16);
int stat_y = y + flint_px(16);
settings_format_data_size(size_str, sizeof(size_str), data_size);
DrawRectangle(x, y, w, stats_box_h, flint_darken(theme_get_bg(), 8));
ui_draw_bevel(x, y, w, stats_box_h, flint_lighten(theme_get_bg(), 35), flint_darken(theme_get_bg(), 45));
locale_format(stat_text, sizeof(stat_text), "total_sessions_label", session_count);
flint_text_draw(stat_text, stat_x, stat_y, font, theme_get_text());
stat_y += flint_px(22);
locale_format(stat_text, sizeof(stat_text), "data_size_label", size_str);
flint_text_draw(stat_text, stat_x, stat_y, font, theme_get_text());
}
#if defined(INBE_HAS_FLINT_FILE_DIALOG)
static void
settings_apply_file_dialog_theme(InbeApp *app)
{
int theme_id = app != NULL ? app->theme_id : FLINT_THEME_SKY;
int dark_mode = app != NULL && app->dark_mode != 0;
if(theme_id < 0 || theme_id >= FLINT_THEME_COUNT)
theme_id = FLINT_THEME_SKY;
flint_file_dialog_set_theme_scope(flint_theme_scope_for((FlintThemeId)theme_id,
dark_mode != 0));
}
#endif
#if defined(PLATFORM_ANDROID) || defined(__ANDROID__) || defined(ANDROID)
static void
settings_screen_handle_android_import(InbeApp *app)
{
char import_path[FS_PATH_MAX];
int import_result = android_import_poll_result(import_path, sizeof(import_path));
if(import_result == ANDROID_IMPORT_RESULT_NONE)
return;
if(import_result == ANDROID_IMPORT_RESULT_CANCELLED) {
settings_screen_set_status_error(locale_get("import_cancelled"));
return;
}
if(import_path[0] == '\0') {
settings_screen_set_status_error(locale_get("import_invalid_file"));
return;
}
settings_begin_import_for_path(app, import_path);
}
#endif
#if defined(PLATFORM_WEB)
#define SETTINGS_WEB_IMPORT_PATH "/tmp/inbe-web-import.zip"
static void
settings_web_import_open_picker(void)
{
EM_ASM({
const importPath = UTF8ToString($0);
Module.__inbeImportResult = 0;
const input = document.createElement("input");
input.type = "file";
input.accept = ".zip,.db,application/zip,application/x-sqlite3,application/octet-stream";
input.style.display = "none";
input.onchange = async function() {
try {
if(!input.files || input.files.length === 0) {
Module.__inbeImportResult = 2;
return;
}
const file = input.files[0];
const bytes = new Uint8Array(await file.arrayBuffer());
try {
FS.mkdir("/tmp");
} catch(e) {}
FS.writeFile(importPath, bytes);
Module.__inbeImportResult = 1;
} catch(e) {
console.error("Inbe web import failed:", e);
Module.__inbeImportResult = 3;
} finally {
input.remove();
}
};
document.body.appendChild(input);
input.click();
}, SETTINGS_WEB_IMPORT_PATH);
}
static void
settings_screen_handle_web_import(InbeApp *app)
{
int import_result = EM_ASM_INT({
const result = Module.__inbeImportResult || 0;
if(result !== 0)
Module.__inbeImportResult = 0;
return result;
});
if(import_result == 0)
return;
if(import_result == 2) {
settings_screen_set_status_error(locale_get("import_cancelled"));
return;
}
if(import_result != 1) {
settings_screen_set_status_error(locale_get("import_failed"));
return;
}
settings_begin_import_for_path(app, SETTINGS_WEB_IMPORT_PATH);
}
#endif
static void
settings_import_data(InbeApp *app)
{
#if defined(PLATFORM_ANDROID) || defined(__ANDROID__) || defined(ANDROID)
if(android_import_open_picker())
settings_screen_set_status_success(locale_get("import_data_dialog_title"), NULL);
else
settings_screen_set_status_error(locale_get("import_failed"));
#elif defined(PLATFORM_WEB)
(void)app;
settings_web_import_open_picker();
settings_screen_set_status_success(locale_get("import_data_dialog_title"), NULL);
#elif defined(INBE_HAS_FLINT_FILE_DIALOG)
settings_apply_file_dialog_theme(app);
flint_file_dialog_begin_load(&import_dlg, locale_get("import_data_dialog_title"));
data_file_dialog_action = SETTINGS_DATA_ACTION_IMPORT;
#else
(void)app;
settings_screen_set_status_error(locale_get("import_failed"));
#endif
}
static void
settings_export_data(InbeApp *app)
{
char export_filename[64];
data_default_export_filename(export_filename, sizeof(export_filename));
if(!data_has_any()) {
settings_screen_set_status_error(locale_get("no_data_to_export"));
return;
}
#if defined(PLATFORM_ANDROID) || defined(__ANDROID__) || defined(ANDROID)
(void)app;
if(data_export(export_filename)) {
settings_screen_set_status_success(locale_get("exported_label"), NULL);
TraceLog(LOG_INFO, "DATA: Export successful (share sheet shown)");
} else {
settings_screen_set_status_error(locale_get("export_failed"));
TraceLog(LOG_ERROR, "DATA: Export failed");
}
#elif defined(INBE_HAS_FLINT_FILE_DIALOG)
settings_apply_file_dialog_theme(app);
flint_file_dialog_begin_save(&export_dlg, locale_get("export_data_dialog_title"), export_filename);
data_file_dialog_action = SETTINGS_DATA_ACTION_EXPORT;
#else
(void)app;
settings_screen_set_status_error(locale_get("export_failed"));
#endif
}
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;
} else {
settings_screen_set_status_error(locale_get("no_data_to_delete"));
}
}
#if defined(INBE_HAS_FLINT_FILE_DIALOG)
static int
settings_draw_pending_file_dialog(InbeApp *app)
{
FlintFileDialog *dlg;
int result;
if(data_file_dialog_action == SETTINGS_DATA_ACTION_NONE)
return 0;
settings_apply_file_dialog_theme(app);
dlg = data_file_dialog_action == SETTINGS_DATA_ACTION_IMPORT ? &import_dlg : &export_dlg;
result = flint_file_dialog_update(dlg);
if(result < 0)
return 1;
if(data_file_dialog_action == SETTINGS_DATA_ACTION_IMPORT) {
if(result == 1) {
const char *path = flint_file_dialog_get_path(&import_dlg);
if(path != NULL && path[0] != '\0') {
settings_begin_import_for_path(app, path);
} else {
settings_screen_set_status_error(locale_get("import_invalid_file"));
TraceLog(LOG_WARNING, "DATA: No file selected for import");
}
} else {
settings_screen_set_status_error(locale_get("import_cancelled"));
}
} else {
if(result == 1) {
const char *path = flint_file_dialog_get_path(&export_dlg);
if(path != NULL && data_export(path)) {
const char *filename = GetFileName(path);
settings_screen_set_status_success(locale_get("exported_label"), filename);
TraceLog(LOG_INFO, "DATA: Export successful to %s", path);
} else {
settings_screen_set_status_error(locale_get("export_failed"));
TraceLog(LOG_ERROR, "DATA: Export failed");
}
} else {
settings_screen_set_status_error(locale_get("export_cancelled"));
}
}
data_file_dialog_action = SETTINGS_DATA_ACTION_NONE;
return 1;
}
#endif
int
settings_screen_draw(InbeApp *app)
{
int top_margin = 0;
int content_x;
int content_w;
int responsive_max_w = (int)(view_width * 0.96f);
int max_content_w = flint_px(CONTENT_MAX_W);
int min_content_w = flint_px(320);
int side_padding;
int detail_header_h;
int top_tab_h;
int top_tab_y;
int tab_gap;
int tab_content_start_y;
int content_viewport_h;
int clicked_top_tab = -1;
const char *settings_tabs[] = {
locale_get("settings_tab_device"),
locale_get("settings_tab_theme"),
locale_get("settings_tab_data"),
};
SettingsThemeState theme_state = {0};
SettingsDeviceState device_state = {0};
if(responsive_max_w > max_content_w)
responsive_max_w = max_content_w;
if(responsive_max_w < min_content_w)
responsive_max_w = min_content_w;
side_padding = flint_page_side_padding();
int side_padding = flint_page_side_padding();
flint_centered_column(responsive_max_w, side_padding, &content_x, &content_w);
if(IsMouseButtonReleased(MOUSE_BUTTON_LEFT))
@@ -164,47 +605,60 @@ settings_screen_draw(InbeApp *app)
if(app->settings_tab < SETTINGS_TAB_DEVICE || app->settings_tab >= SETTINGS_TAB_COUNT)
app->settings_tab = SETTINGS_TAB_DEVICE;
if(settings_data_draw_pending_file_dialog(app))
#if defined(INBE_HAS_FLINT_FILE_DIALOG)
if(settings_draw_pending_file_dialog(app))
return 1;
detail_header_h = settings_data_is_configuring(app) ? flint_px(58) : 0;
if(detail_header_h > 0) {
FlintUIHeader header = ui_draw_title_header(detail_header_h,
locale_get("sync_configure_account_button"),
app->icons[UI_ICON_TYPE_RETURN],
(Texture2D){0});
if(header.left_clicked) {
app->settings_data_view = 0;
app->settings_scroll = 0;
app->sync_server_url_focused = 0;
settings_screen_clear_status();
}
}
top_tab_h = detail_header_h > 0 ? 0 : flint_px(40);
top_tab_y = top_margin + detail_header_h;
tab_gap = top_tab_h > 0 ? flint_px(14) : 0;
tab_content_start_y = top_tab_y + top_tab_h + tab_gap;
content_viewport_h = view_height - tab_content_start_y - flint_px(TAB_BAR_H);
#if defined(PLATFORM_ANDROID) || defined(__ANDROID__) || defined(ANDROID)
settings_data_handle_android_import(app);
#elif defined(PLATFORM_WEB)
settings_data_handle_web_import(app);
#endif
ui_set_input_blocked(app->modal.active);
int top_tab_h = flint_px(40);
int top_tab_y = top_margin;
int tab_gap = flint_px(14);
int tab_content_start_y = top_tab_y + top_tab_h + tab_gap;
int content_viewport_h = view_height - tab_content_start_y - flint_px(TAB_BAR_H);
int clicked_top_tab = -1;
const char *settings_tabs[] = {
locale_get("settings_tab_device"),
locale_get("settings_tab_theme"),
locale_get("settings_tab_data"),
};
int language_menu_changed = 0;
int draw_language_menu = 0;
int draw_theme_mode_menu = 0;
int draw_orientation_menu = 0;
int theme_mode_changed = 0;
int orientation_changed = 0;
const char *theme_mode_options[] = {
locale_get("theme_system"),
locale_get("theme_light"),
locale_get("theme_dark")
};
const char *orientation_options[] = {
locale_get("orientation_system"),
locale_get("orientation_portrait"),
locale_get("orientation_landscape"),
locale_get("orientation_sensor")
};
int orientation_option_count =
#if defined(PLATFORM_ANDROID) || defined(__ANDROID__) || defined(ANDROID)
4;
#else
3;
#endif
#if defined(PLATFORM_ANDROID) || defined(__ANDROID__) || defined(ANDROID)
settings_screen_handle_android_import(app);
#elif defined(PLATFORM_WEB)
settings_screen_handle_web_import(app);
#endif
if(content_viewport_h < 0)
content_viewport_h = 0;
if(top_tab_h > 0)
clicked_top_tab = settings_draw_subtab_bar(top_tab_y, top_tab_h, settings_tabs,
SETTINGS_TAB_COUNT, app->settings_tab);
clicked_top_tab = settings_draw_subtab_bar(top_tab_y, top_tab_h, settings_tabs,
SETTINGS_TAB_COUNT, app->settings_tab);
if(clicked_top_tab != -1) {
app->settings_tab = clicked_top_tab;
app->settings_scroll = 0;
app->settings_data_view = 0;
settings_screen_clear_status();
}
@@ -219,7 +673,20 @@ settings_screen_draw(InbeApp *app)
if(planned_content_w < flint_px(160))
planned_content_w = draw_w;
app_content_h = settings_tab_content_height(app, app->settings_tab, planned_content_w);
if(app->settings_tab == SETTINGS_TAB_THEME) {
app_content_h = flint_px(76) + ui_theme_picker_height(planned_content_w) + flint_px(60);
} else if(app->settings_tab == SETTINGS_TAB_DEVICE) {
app_content_h = flint_px(74) + flint_px(74) + flint_px(76) + flint_px(40);
#if defined(PLATFORM_ANDROID) || defined(__ANDROID__) || defined(ANDROID)
app_content_h += flint_px(76);
#endif
#if !defined(PLATFORM_ANDROID) && !defined(__ANDROID__) && !defined(ANDROID) && !defined(PLATFORM_WEB)
app_content_h += flint_px(50);
#endif
app_content_h += flint_px(72);
} else {
app_content_h = settings_data_content_height(draw_w);
}
scroll_area = (FlintUIScrollArea){
.bounds = {0.0f, (float)tab_content_start_y,
(float)view_width, (float)content_viewport_h},
@@ -235,39 +702,209 @@ settings_screen_draw(InbeApp *app)
break;
draw_w = measured.content_w;
}
int y;
FlintUIScrollView scroll_view = ui_scroll_container_begin(scroll_area);
int draw_x = scroll_view.content_x;
draw_w = scroll_view.content_w;
y = scroll_view.content_y;
{
int y;
FlintUIScrollView scroll_view = ui_scroll_container_begin(scroll_area);
int draw_x = scroll_view.content_x;
if(app->settings_tab == SETTINGS_TAB_THEME) {
draw_w = scroll_view.content_w;
y = scroll_view.content_y;
app->theme_mode = clampi(app->theme_mode, APP_THEME_SYSTEM, APP_THEME_DARK);
flint_text_draw(locale_get("theme_mode_label"), draw_x, y, flint_ui_font(), theme_get_text());
ui_draw_dropdown_button(102, draw_x, y + flint_px(26), draw_w,
flint_px(36), theme_mode_options, 3, &app->theme_mode);
draw_theme_mode_menu = 1;
y += flint_px(76);
if(ui_draw_theme_picker(draw_x, y, draw_w, locale_get("theme_label"),
app->dark_mode, &app->theme_id)) {
app->theme_id = clampi(app->theme_id, 0, FLINT_THEME_COUNT - 1);
app_refresh_theme(app);
app->settings_dirty = 1;
save_settings(app);
}
y += ui_theme_picker_height(draw_w) + flint_px(20);
if(app->settings_tab == SETTINGS_TAB_THEME)
settings_theme_draw(app, draw_x, draw_w, &y, &theme_state);
else if(app->settings_tab == SETTINGS_TAB_DEVICE)
settings_device_draw(app, draw_x, draw_w, &y, &device_state);
else
settings_data_draw(app, draw_x, draw_w, &y);
} else if(app->settings_tab == SETTINGS_TAB_DEVICE) {
y += flint_px(40);
ui_scroll_container_end(scroll_area, scroll_view);
int sound_volume = app->sound_volume;
int keyboard_toggle = app->on_screen_keyboard_enabled;
int toggle_w = flint_px(56);
int toggle_h = flint_px(30);
if(language_dropdown_button(app, 101, draw_x, y, draw_w, flint_px(36), &app->language_index))
language_menu_changed = 1;
draw_language_menu = 1;
y += flint_px(74);
if(ui_draw_slider(6, draw_x, y, draw_w, locale_get("volume_label"),
SETTINGS_VOLUME_MIN, SETTINGS_VOLUME_MAX, &sound_volume, "")) {
app->sound_volume = sound_volume;
app->settings_dirty = 1;
save_settings(app);
}
y += flint_px(74);
#ifdef __ANDROID__
{
int play_in_background = app->inbe.play_in_background;
flint_text_draw(locale_get("play_in_background_label"), draw_x, y, flint_ui_font(), theme_get_text());
if(ui_draw_toggle_switch(draw_x, y + flint_px(26), toggle_w, toggle_h,
&play_in_background, locale_get("toggle_off"), locale_get("toggle_on"))) {
app->inbe.play_in_background = play_in_background;
app->settings_dirty = 1;
}
y += flint_px(76);
}
#endif
{
int orientation_max = orientation_option_count - 1;
app->orientation_mode = clampi(app->orientation_mode,
APP_ORIENTATION_SYSTEM,
orientation_max);
flint_text_draw(locale_get("orientation_label"), draw_x, y,
flint_ui_font(), theme_get_text());
ui_draw_dropdown_button(103, draw_x, y + flint_px(26), draw_w,
flint_px(36), orientation_options, orientation_option_count,
&app->orientation_mode);
draw_orientation_menu = 1;
y += flint_px(76);
}
#if !defined(PLATFORM_ANDROID) && !defined(__ANDROID__) && !defined(ANDROID) && !defined(PLATFORM_WEB)
if(ui_draw_checkbox_toggle(draw_x, y, locale_get("fullscreen_label"), &app->fullscreen_enabled)) {
if(app->fullscreen_enabled && !IsWindowFullscreen())
ToggleFullscreen();
else if(!app->fullscreen_enabled && IsWindowFullscreen())
ToggleFullscreen();
app->settings_dirty = 1;
}
y += flint_px(50);
#endif
flint_text_draw(locale_get("on_screen_keyboard_label"), draw_x, y, flint_ui_font(), theme_get_text());
if(ui_draw_toggle_switch(draw_x, y + flint_px(26), toggle_w, toggle_h,
&keyboard_toggle, locale_get("toggle_off"), locale_get("toggle_on"))) {
app->on_screen_keyboard_enabled = keyboard_toggle;
app->settings_dirty = 1;
}
y += flint_px(76);
} else {
int data_button_h = flint_px(36);
int hover_import = 0;
int hover_export = 0;
int hover_delete = 0;
settings_draw_data_stats(draw_x, y, draw_w);
y += flint_px(98);
if(ui_draw_generic_button(draw_x, y, draw_w, data_button_h,
locale_get("import_data_button"),
UI_BUTTON_STYLE_PRIMARY, 0, &hover_import))
settings_import_data(app);
y += data_button_h + flint_px(12);
if(ui_draw_generic_button(draw_x, y, draw_w, data_button_h,
locale_get("export_data_button"),
UI_BUTTON_STYLE_PRIMARY, 0, &hover_export))
settings_export_data(app);
y += data_button_h + flint_px(12);
if(ui_draw_generic_button(draw_x, y, draw_w, data_button_h,
locale_get("delete_all_data_button"),
UI_BUTTON_STYLE_DANGER, 0, &hover_delete))
settings_request_delete_all_data(app);
y += data_button_h + flint_px(12);
settings_draw_status_reserved(draw_x, &y, flint_px(42));
settings_draw_link_icons(app, draw_x, draw_w, &y);
y += flint_px(8);
settings_draw_version_centered(draw_x, draw_w, &y);
}
y += flint_px(40);
ui_scroll_container_end(scroll_area, scroll_view);
}
ui_set_dropdown_clip_top(tab_content_start_y);
if(app->settings_tab == SETTINGS_TAB_THEME)
settings_theme_handle_overlays(app, &theme_state);
else if(app->settings_tab == SETTINGS_TAB_DEVICE)
settings_device_handle_overlays(app, &device_state);
if(draw_language_menu && language_dropdown_menu(app, 101))
language_menu_changed = 1;
if(draw_theme_mode_menu && ui_draw_dropdown_menu(102))
theme_mode_changed = 1;
if(draw_orientation_menu && ui_draw_dropdown_menu(103))
orientation_changed = 1;
if(language_menu_changed)
apply_language_selection(app, app->language_index, 1);
if(theme_mode_changed) {
app->theme_mode = clampi(app->theme_mode, APP_THEME_SYSTEM, APP_THEME_DARK);
app_refresh_theme(app);
app->settings_dirty = 1;
save_settings(app);
}
if(orientation_changed) {
int orientation_max = orientation_option_count - 1;
app->orientation_mode = clampi(app->orientation_mode, APP_ORIENTATION_SYSTEM,
orientation_max);
app_apply_orientation_preference(app);
app->settings_dirty = 1;
save_settings(app);
}
ui_set_dropdown_clip_top(0);
ui_set_input_blocked(0);
settings_data_draw_modals(app);
if(app->modal.active && app->modal.type == UIModalConfirmImportDataSettings) {
int modal_result = settings_draw_import_choice_modal(app);
if(modal_result == 1) {
app->modal.active = 0;
app->modal.type = UIModalNone;
settings_clear_pending_import();
settings_screen_set_status_error(locale_get("import_cancelled"));
} else if(modal_result == 2 || modal_result == 3) {
char import_path[FS_PATH_MAX];
DataImportMode mode = modal_result == 3
? DATA_IMPORT_DATA_AND_SETTINGS
: DATA_IMPORT_DATA_ONLY;
snprintf(import_path, sizeof(import_path), "%s", pending_import_path);
app->modal.active = 0;
app->modal.type = UIModalNone;
settings_clear_pending_import();
settings_perform_import(app, import_path, mode);
}
}
if(IsMouseButtonReleased(MOUSE_BUTTON_LEFT) && app->settings_dirty)
save_settings(app);
if(app->modal.active && app->modal.type == UIModalConfirmDeleteData) {
int modal_result = ui_draw_modal(locale_get("delete_all_data_title"),
locale_get("delete_all_data_message"),
locale_get("cancel_button"),
locale_get("delete_button"));
if(modal_result == 1) {
app->modal.active = 0;
app->modal.type = UIModalNone;
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;
if(deleted > 0) {
char deleted_message[128];
inbe_habits_clear_days(&app->habits);
inbe_habits_save(&app->habits);
locale_format(deleted_message, sizeof(deleted_message), "deleted_sessions", deleted);
settings_screen_set_status_success(deleted_message, NULL);
} else {
int cleared = inbe_habits_clear_days(&app->habits);
if(cleared > 0) {
char deleted_message[128];
inbe_habits_save(&app->habits);
locale_format(deleted_message, sizeof(deleted_message), "deleted_sessions", cleared);
settings_screen_set_status_success(deleted_message, NULL);
} else {
settings_screen_set_status_error(locale_get("no_data_to_delete"));
}
}
}
}
if(IsMouseButtonReleased(MOUSE_BUTTON_LEFT)) {
if(app->settings_dirty)
save_settings(app);
}
return 0;
}
-1
View File
@@ -9,6 +9,5 @@ int settings_screen_draw(InbeApp *app);
void settings_screen_clear_status(void);
void settings_screen_set_status_success(const char *message, const char *detail);
void settings_screen_set_status_error(const char *message);
void settings_screen_draw_status_reserved(int x, int *y, int reserved_h);
#endif
@@ -1,439 +0,0 @@
#include "settings_sync_account.h"
#include "settings_screen.h"
#include "app.h"
#include "flint_locale.h"
#include "storage.h"
#include "sync_account.h"
#include "sync_client.h"
#include "theme.h"
#include "flint_ui.h"
#include "raylib.h"
#include <ctype.h>
#include <stdio.h>
#include <string.h>
#define INBE_SYNC_SERVER_URL_KEY "sync_server_url"
#define INBE_SYNC_SERVER_URL_DEFAULT "https://api.waozi.xyz"
static SettingsSyncKeySaveDialog save_dialog_callback = NULL;
static SettingsSyncKeyImportDialog import_dialog_callback = NULL;
void
settings_sync_account_set_save_dialog(SettingsSyncKeySaveDialog callback)
{
save_dialog_callback = callback;
}
void
settings_sync_account_set_import_dialog(SettingsSyncKeyImportDialog callback)
{
import_dialog_callback = callback;
}
static void
settings_draw_hex_groups(const char *text, int x, int *y, int font, Color color,
int groups, int group_chars)
{
char line[128];
int offset = 0;
if(text == NULL || y == NULL)
return;
for(int i = 0; i < groups && text[offset] != '\0'; i++) {
int len = group_chars;
if((int)strlen(text + offset) < len)
len = (int)strlen(text + offset);
snprintf(line, sizeof(line), "%.*s", len, text + offset);
flint_text_draw(line, x, *y, font, color);
*y += flint_px(17);
offset += len;
}
}
static void
settings_backup_filename(char *out, size_t out_size)
{
if(out == NULL || out_size == 0)
return;
snprintf(out, out_size, "inbe-sync.key");
}
static int
settings_start_sync_key_export(InbeApp *app, const InbeSyncAccount *account)
{
char filename[64];
settings_backup_filename(filename, sizeof(filename));
#if defined(PLATFORM_ANDROID) || defined(__ANDROID__) || defined(ANDROID) || defined(PLATFORM_WEB)
(void)app;
return sync_account_export_private_key(account, filename) ? 2 : 3;
#else
if(save_dialog_callback != NULL)
return save_dialog_callback(app, filename);
return sync_account_export_private_key(account, filename) ? 2 : 3;
#endif
}
static int
settings_start_sync_key_import(InbeApp *app)
{
if(import_dialog_callback != NULL)
return import_dialog_callback(app);
return 0;
}
static int
settings_sync_url_filter(int codepoint, void *user_data)
{
(void)user_data;
return codepoint >= 33 && codepoint <= 126 && !isspace(codepoint);
}
static int
settings_sync_server_normalize(InbeApp *app, char *out, size_t out_size)
{
if(app == NULL || out == NULL || out_size == 0)
return 0;
if(!sync_client_normalize_url(app->sync_server_url, out, out_size))
return 0;
snprintf(app->sync_server_url, sizeof(app->sync_server_url), "%s", out);
app->sync_server_url_cursor = (int)strlen(app->sync_server_url);
return 1;
}
static void
settings_sync_server_save(InbeApp *app)
{
char url[sizeof(app->sync_server_url)];
if(app == NULL)
return;
if(!settings_sync_server_normalize(app, url, sizeof(url))) {
settings_screen_set_status_error(locale_get("sync_server_url_invalid"));
return;
}
storage_set_setting_text(INBE_SYNC_SERVER_URL_KEY, url);
settings_screen_set_status_success(locale_get("sync_server_saved"), url);
}
static int
settings_sync_server_connected(InbeApp *app)
{
char url[sizeof(app->sync_server_url)];
const char *saved_url;
char saved_normalized[sizeof(app->sync_server_url)];
InbeSyncAccount account;
if(app == NULL || !sync_account_load(&account))
return 0;
if(!sync_client_normalize_url(app->sync_server_url, url, sizeof(url)))
return 0;
saved_url = storage_get_setting_text(INBE_SYNC_SERVER_URL_KEY);
if(!sync_client_normalize_url(saved_url, saved_normalized, sizeof(saved_normalized)))
return 0;
return strcmp(saved_normalized, url) == 0;
}
static const char *
settings_sync_result_key(InbeSyncClientResult result)
{
switch(result) {
case INBE_SYNC_CLIENT_OK:
return "sync_connected";
case INBE_SYNC_CLIENT_INVALID_URL:
return "sync_server_url_invalid";
case INBE_SYNC_CLIENT_NO_ACCOUNT:
return "sync_no_account";
case INBE_SYNC_CLIENT_AUTH_FAILED:
return "sync_auth_failed";
case INBE_SYNC_CLIENT_PAYLOAD_FAILED:
case INBE_SYNC_CLIENT_CHALLENGE_FAILED:
case INBE_SYNC_CLIENT_SIGN_FAILED:
case INBE_SYNC_CLIENT_REQUEST_FAILED:
default:
return "sync_failed";
}
}
static void
settings_sync_run_connect(InbeApp *app)
{
InbeSyncClientResult result;
char url[sizeof(app->sync_server_url)];
if(app == NULL)
return;
if(!settings_sync_server_normalize(app, url, sizeof(url))) {
settings_screen_set_status_error(locale_get("sync_server_url_invalid"));
return;
}
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);
} else {
settings_screen_set_status_error(locale_get(settings_sync_result_key(result)));
}
}
void
settings_sync_account_delete_confirmed(InbeApp *app)
{
InbeSyncAccount account;
InbeSyncClientResult result;
char url[sizeof(app->sync_server_url)];
if(app == NULL)
return;
if(!sync_account_load(&account)) {
settings_screen_set_status_error(locale_get("sync_no_account"));
return;
}
if(settings_sync_server_normalize(app, url, sizeof(url))) {
result = sync_client_delete_account(url);
if(result != INBE_SYNC_CLIENT_OK)
TraceLog(LOG_WARNING, "SYNC: remote account delete failed: %d", result);
} else {
TraceLog(LOG_WARNING, "SYNC: remote account delete skipped due to invalid URL");
}
sync_account_clear();
settings_screen_set_status_success(locale_get("sync_account_deleted"), NULL);
}
static FlintUITextInputStyle
settings_sync_text_style(void)
{
return (FlintUITextInputStyle){
.background = flint_darken(theme_get_bg(), 4),
.border = theme_get_button(),
.focus_border = theme_get_button_hover(),
.text = theme_get_text(),
.cursor = theme_get_text(),
.radius = 0.08f,
.padding_x = flint_px(10)
};
}
void
settings_sync_account_draw(InbeApp *app, int x, int w, int *y)
{
InbeSyncAccount account;
int has_account = sync_account_load(&account);
int font = flint_ui_font();
int small_font = flint_ui_font_small();
int btn_h = flint_px(36);
int gap = flint_px(10);
int half_w = (w - gap) / 2;
int hover = 0;
flint_text_draw(locale_get("sync_account_title"), x, *y, font, theme_get_text());
*y += flint_px(26);
if(!sync_account_available()) {
flint_text_draw(locale_get("sync_liboqs_unavailable"), x, *y, small_font,
flint_darken(theme_get_text(), 35));
*y += flint_px(32);
return;
}
if(!has_account) {
if(ui_draw_generic_button(x, *y, w, btn_h, locale_get("sync_create_account_button"),
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;
} else {
settings_screen_set_status_error(locale_get("sync_account_create_failed"));
}
}
*y += btn_h + flint_px(18);
return;
}
flint_text_draw(locale_get("sync_public_id_label"), x, *y, small_font,
flint_darken(theme_get_text(), 30));
*y += flint_px(18);
settings_draw_hex_groups(account.public_id, x, y, small_font, theme_get_text(), 2, 32);
*y += flint_px(4);
if(ui_draw_generic_button(x, *y, half_w, btn_h, locale_get("sync_copy_id_button"),
UI_BUTTON_STYLE_SECONDARY, 0, &hover)) {
SetClipboardText(account.public_id);
settings_screen_set_status_success(locale_get("sync_public_id_copied"), NULL);
}
if(ui_draw_generic_button(x + half_w + gap, *y, half_w, btn_h,
locale_get("sync_backup_key_button"),
UI_BUTTON_STYLE_PRIMARY, 0, &hover)) {
app->modal.active = 1;
app->modal.type = UIModalSyncAccountBackup;
app->modal.selected_button = 0;
}
*y += btn_h + flint_px(16);
}
void
settings_sync_account_draw_config(InbeApp *app, int x, int w, int *y)
{
InbeSyncAccount account;
int has_account = sync_account_load(&account);
int font = flint_ui_font();
int small_font = flint_ui_font_small();
int btn_h = flint_px(36);
int gap = flint_px(10);
int half_w = (w - gap) / 2;
int hover = 0;
int commit = 0;
FlintUITextInputStyle input_style = settings_sync_text_style();
if(!sync_account_available()) {
flint_text_draw(locale_get("sync_liboqs_unavailable"), x, *y, small_font,
flint_darken(theme_get_text(), 35));
*y += flint_px(32);
return;
}
if(!has_account) {
*y += flint_px(12);
if(ui_draw_generic_button(x, *y, half_w, btn_h, locale_get("sync_create_account_button"),
UI_BUTTON_STYLE_PRIMARY, 0, &hover)) {
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;
} else {
settings_screen_set_status_error(locale_get("sync_account_create_failed"));
}
}
if(ui_draw_generic_button(x + half_w + gap, *y, half_w, btn_h,
locale_get("sync_import_key_button"),
UI_BUTTON_STYLE_PRIMARY, 0, &hover)) {
if(!settings_start_sync_key_import(app))
settings_screen_set_status_error(locale_get("sync_private_key_import_failed"));
}
*y += btn_h + flint_px(18);
}
if(!has_account) {
settings_screen_draw_status_reserved(x, y, flint_px(42));
(void)font;
return;
}
flint_text_draw(locale_get("sync_public_id_label"), x, *y, small_font,
flint_darken(theme_get_text(), 30));
*y += flint_px(18);
settings_draw_hex_groups(account.public_id, x, y, small_font, theme_get_text(), 2, 32);
*y += flint_px(8);
flint_text_draw(locale_get("sync_remote_label"), x, *y, small_font,
flint_darken(theme_get_text(), 30));
*y += flint_px(18);
flint_ui_text_field((FlintUITextField){
.bounds = {(float)x, (float)*y, (float)w, (float)btn_h},
.text = app->sync_server_url,
.text_size = sizeof(app->sync_server_url),
.cursor_position = &app->sync_server_url_cursor,
.focused = &app->sync_server_url_focused,
.max_codepoints = 255,
.font = small_font,
.style = input_style,
.filter = settings_sync_url_filter,
.commit_pressed = &commit
});
if(commit)
settings_sync_server_save(app);
*y += btn_h + flint_px(12);
if(ui_draw_generic_button(x, *y, w, btn_h,
settings_sync_server_connected(app)
? locale_get("sync_connected_button")
: locale_get("sync_connect_button"),
UI_BUTTON_STYLE_PRIMARY, 0, &hover))
settings_sync_run_connect(app);
*y += btn_h + flint_px(12);
if(ui_draw_generic_button(x, *y, half_w, btn_h, locale_get("sync_copy_id_button"),
UI_BUTTON_STYLE_SECONDARY, 0, &hover)) {
SetClipboardText(account.public_id);
settings_screen_set_status_success(locale_get("sync_public_id_copied"), NULL);
}
if(ui_draw_generic_button(x + half_w + gap, *y, half_w, btn_h,
locale_get("sync_backup_key_button"),
UI_BUTTON_STYLE_SECONDARY, 0, &hover)) {
app->modal.active = 1;
app->modal.type = UIModalSyncAccountBackup;
app->modal.selected_button = 0;
}
*y += btn_h + flint_px(12);
if(ui_draw_generic_button(x, *y, w, btn_h, locale_get("sync_delete_account_button"),
UI_BUTTON_STYLE_DANGER, 0, &hover)) {
app->modal.active = 1;
app->modal.type = UIModalConfirmDeleteSyncAccount;
app->modal.selected_button = 0;
}
*y += btn_h + flint_px(12);
settings_screen_draw_status_reserved(x, y, flint_px(42));
(void)font;
}
int
settings_sync_account_draw_backup_modal(InbeApp *app)
{
FlintUIPanelFrame frame;
InbeSyncAccount account;
int font = flint_ui_font_small();
int btn_h = flint_px(36);
int gap = flint_px(10);
int pad_bottom = flint_px(24);
int text_button_gap = flint_px(40);
int hover = 0;
int y;
int modal_h;
int button_y;
FlintUIParagraph warning;
memset(&account, 0, sizeof(account));
sync_account_load(&account);
warning = (FlintUIParagraph){
.text = locale_get("sync_backup_warning"),
.width = flint_px(336) - flint_px(36),
.font = font,
.line_gap = flint_px(4),
.color = theme_get_text()
};
modal_h = flint_px(58) +
flint_ui_paragraph_height(warning) +
text_button_gap +
btn_h * 2 + gap +
pad_bottom;
if(modal_h < flint_px(224))
modal_h = flint_px(224);
frame = ui_draw_modal_frame(flint_px(336), modal_h, locale_get("sync_backup_title"),
(Texture2D){0}, (Texture2D){0});
y = frame.content_y;
warning.width = frame.content_w;
flint_ui_paragraph_draw(warning, frame.content_x, &y);
button_y = y + text_button_gap;
if(button_y + btn_h * 2 + gap + pad_bottom > frame.y + frame.h)
button_y = frame.y + frame.h - pad_bottom - btn_h * 2 - gap;
if(ui_draw_generic_button(frame.content_x, button_y, frame.content_w, btn_h,
locale_get("sync_save_key_file_button"), UI_BUTTON_STYLE_PRIMARY, 0, &hover))
return settings_start_sync_key_export(app, &account);
if(ui_draw_generic_button(frame.content_x, button_y + btn_h + gap, frame.content_w,
btn_h, locale_get("close_button"), UI_BUTTON_STYLE_SECONDARY, 0, &hover))
return 1;
return 0;
}
@@ -1,16 +0,0 @@
#ifndef INBE_SETTINGS_SYNC_ACCOUNT_H
#define INBE_SETTINGS_SYNC_ACCOUNT_H
#include "app_fwd.h"
typedef int (*SettingsSyncKeySaveDialog)(InbeApp *app, const char *filename);
typedef int (*SettingsSyncKeyImportDialog)(InbeApp *app);
void settings_sync_account_set_save_dialog(SettingsSyncKeySaveDialog callback);
void settings_sync_account_set_import_dialog(SettingsSyncKeyImportDialog callback);
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_delete_confirmed(InbeApp *app);
int settings_sync_account_draw_backup_modal(InbeApp *app);
#endif
-60
View File
@@ -1,60 +0,0 @@
#include "settings_theme.h"
#include "app.h"
#include "app_settings.h"
#include "device_preferences.h"
#include "flint_locale.h"
#include "theme.h"
#include "flint_theme_meta.h"
#include "flint_ui.h"
int
settings_theme_content_height(int content_w)
{
return flint_px(76) + ui_theme_picker_height(content_w) + flint_px(60);
}
void
settings_theme_draw(InbeApp *app, int x, int w, int *y, SettingsThemeState *state)
{
const char *theme_mode_options[3];
if(app == NULL || y == NULL || state == NULL)
return;
theme_mode_options[0] = locale_get("theme_system");
theme_mode_options[1] = locale_get("theme_light");
theme_mode_options[2] = locale_get("theme_dark");
app->theme_mode = clampi(app->theme_mode, APP_THEME_SYSTEM, APP_THEME_DARK);
flint_text_draw(locale_get("theme_mode_label"), x, *y, flint_ui_font(), theme_get_text());
ui_draw_dropdown_button(102, x, *y + flint_px(26), w, flint_px(36),
theme_mode_options, 3, &app->theme_mode);
state->draw_theme_mode_menu = 1;
*y += flint_px(76);
if(ui_draw_theme_picker(x, *y, w, locale_get("theme_label"),
app->dark_mode, &app->theme_id)) {
app->theme_id = clampi(app->theme_id, 0, FLINT_THEME_COUNT - 1);
app_refresh_theme(app);
app->settings_dirty = 1;
save_settings(app);
}
*y += ui_theme_picker_height(w) + flint_px(20);
}
void
settings_theme_handle_overlays(InbeApp *app, const SettingsThemeState *state)
{
int theme_mode_changed = 0;
if(app == NULL || state == NULL)
return;
if(state->draw_theme_mode_menu && ui_draw_dropdown_menu(102))
theme_mode_changed = 1;
if(theme_mode_changed) {
app->theme_mode = clampi(app->theme_mode, APP_THEME_SYSTEM, APP_THEME_DARK);
app_refresh_theme(app);
app->settings_dirty = 1;
save_settings(app);
}
}
-14
View File
@@ -1,14 +0,0 @@
#ifndef INBE_SETTINGS_THEME_H
#define INBE_SETTINGS_THEME_H
#include "app_fwd.h"
typedef struct SettingsThemeState {
int draw_theme_mode_menu;
} SettingsThemeState;
int settings_theme_content_height(int content_w);
void settings_theme_draw(InbeApp *app, int x, int w, int *y, SettingsThemeState *state);
void settings_theme_handle_overlays(InbeApp *app, const SettingsThemeState *state);
#endif
+15 -15
View File
@@ -93,7 +93,7 @@ data_init(void)
{
if(g_data_ready)
return;
g_data_ready = storage_init(data_root());
g_data_ready = inbe_storage_init(data_root());
}
const char *
@@ -113,7 +113,7 @@ int
data_save_session_path(const int *round_times, int round_count, char *out_path, size_t out_path_size)
{
data_init();
return storage_save_session(round_times, round_count, out_path, out_path_size);
return inbe_storage_save_session(round_times, round_count, out_path, out_path_size);
}
int
@@ -122,7 +122,7 @@ data_save_session_path_for_activity(const int *round_times, int round_count,
char *out_path, size_t out_path_size)
{
data_init();
return storage_save_session_for_activity(round_times, round_count, topic, activity,
return inbe_storage_save_session_for_activity(round_times, round_count, topic, activity,
out_path, out_path_size);
}
@@ -136,7 +136,7 @@ int
data_replace_session(const char *path, const int *round_times, int round_count)
{
data_init();
return storage_replace_session(path, round_times, round_count);
return inbe_storage_replace_session(path, round_times, round_count);
}
int
@@ -152,42 +152,42 @@ data_rename_session(const char *old_path, const char *new_path)
if(name == NULL || sscanf(name, "inbe-%2d%2d%2d", &hour, &minute, &second) != 3)
return 0;
(void)second;
return storage_rename_session_time(old_path, hour, minute);
return inbe_storage_rename_session_time(old_path, hour, minute);
}
int
data_delete_session(const char *path)
{
data_init();
return storage_delete_session(path);
return inbe_storage_delete_session(path);
}
int
data_has_any(void)
{
data_init();
return storage_has_any();
return inbe_storage_has_any();
}
long long
data_get_total_size(void)
{
data_init();
return storage_total_size();
return inbe_storage_total_size();
}
int
data_get_session_count(void)
{
data_init();
return storage_session_count();
return inbe_storage_session_count();
}
long long
data_delete_all(void)
{
data_init();
return storage_delete_all_sessions();
return inbe_storage_delete_all_sessions();
}
void
@@ -216,7 +216,7 @@ data_export(const char *path)
data_default_export_filename(filename, sizeof(filename));
return android_share_export(filename);
#else
return storage_export_zip(path);
return inbe_storage_export_zip(path);
#endif
}
@@ -243,7 +243,7 @@ int
data_import_with_mode(const char *path, DataImportMode mode)
{
data_init();
return storage_import_zip_ex(
return inbe_storage_import_zip_ex(
path,
mode == DATA_IMPORT_DATA_AND_SETTINGS
? INBE_STORAGE_IMPORT_DATA_AND_SETTINGS
@@ -258,7 +258,7 @@ data_inspect_import(const char *path, DataImportInfo *info)
data_init();
if(info != NULL)
memset(info, 0, sizeof(*info));
if(!storage_inspect_import(path, &storage_info))
if(!inbe_storage_inspect_import(path, &storage_info))
return 0;
if(info != NULL) {
info->valid = storage_info.valid;
@@ -314,7 +314,7 @@ data_list_session_records(data_session_record_callback callback, void *user)
{
data_init();
if(callback != NULL)
storage_list_session_records((InbeStorageSessionRecordCallback)callback, user);
inbe_storage_list_session_records((InbeStorageSessionRecordCallback)callback, user);
}
int
@@ -323,6 +323,6 @@ data_load_session(const char *path, int *round_times, int max_rounds,
int *hour, int *minute, int *second)
{
data_init();
return storage_load_session(path, round_times, max_rounds,
return inbe_storage_load_session(path, round_times, max_rounds,
year, month, day, hour, minute, second);
}
+153 -1520
View File
File diff suppressed because it is too large. Load diff
+30 -38
View File
@@ -31,52 +31,44 @@ typedef struct InbeStorageImportInfo {
int setting_count;
} InbeStorageImportInfo;
int storage_init(const char *root);
void storage_close(void);
const char *storage_db_path(void);
int inbe_storage_init(const char *root);
void inbe_storage_close(void);
const char *inbe_storage_db_path(void);
int storage_get_setting_int(const char *key, int fallback);
const char *storage_get_setting_text(const char *key);
void storage_set_setting_int(const char *key, int value);
void storage_set_setting_text(const char *key, const char *value);
void storage_settings_begin_write(void);
void storage_settings_end_write(void);
int storage_settings_empty(void);
int inbe_storage_get_setting_int(const char *key, int fallback);
const char *inbe_storage_get_setting_text(const char *key);
void inbe_storage_set_setting_int(const char *key, int value);
void inbe_storage_set_setting_text(const char *key, const char *value);
void inbe_storage_settings_begin_write(void);
void inbe_storage_settings_end_write(void);
int inbe_storage_settings_empty(void);
int storage_save_session(const int *round_times, int round_count,
int inbe_storage_save_session(const int *round_times, int round_count,
char *out_id, size_t out_id_size);
int storage_save_session_for_activity(const int *round_times, int round_count,
int inbe_storage_save_session_for_activity(const int *round_times, int round_count,
int topic, int activity,
char *out_id, size_t out_id_size);
int storage_replace_session(const char *id, const int *round_times, int round_count);
int storage_rename_session_time(const char *id, int hour, int minute);
int storage_delete_session(const char *id);
int storage_load_session(const char *id, int *round_times, int max_rounds,
int inbe_storage_replace_session(const char *id, const int *round_times, int round_count);
int inbe_storage_rename_session_time(const char *id, int hour, int minute);
int inbe_storage_delete_session(const char *id);
int inbe_storage_load_session(const char *id, int *round_times, int max_rounds,
int *year, int *month, int *day,
int *hour, int *minute, int *second);
void storage_list_session_records(InbeStorageSessionRecordCallback callback, void *user);
int storage_has_any(void);
int storage_session_count(void);
int storage_habit_count(void);
long long storage_total_size(void);
long long storage_delete_all_sessions(void);
char *storage_build_sync_payload_json(const char *user_id_hash,
const char *public_key_hex);
void storage_free_sync_payload_json(char *payload);
int storage_apply_sync_response_json(const char *response_json);
int storage_last_sync_changed(void);
void storage_purge_synced_deleted_data(void);
const char *storage_sync_client_id(void);
void storage_reset_sync_state(void);
void inbe_storage_list_session_records(InbeStorageSessionRecordCallback callback, void *user);
int inbe_storage_has_any(void);
int inbe_storage_session_count(void);
int inbe_storage_habit_count(void);
long long inbe_storage_total_size(void);
long long inbe_storage_delete_all_sessions(void);
int storage_habits_empty(void);
int storage_habits_load(void *habits);
void storage_habits_save(const void *habits);
void storage_mark_habits_initialized(void);
int inbe_storage_habits_empty(void);
int inbe_storage_habits_load(void *habits);
void inbe_storage_habits_save(const void *habits);
void inbe_storage_mark_habits_initialized(void);
int storage_export_zip(const char *path);
int storage_import_zip(const char *path);
int storage_import_zip_ex(const char *path, InbeStorageImportMode mode);
int storage_inspect_import(const char *path, InbeStorageImportInfo *info);
int inbe_storage_export_zip(const char *path);
int inbe_storage_import_zip(const char *path);
int inbe_storage_import_zip_ex(const char *path, InbeStorageImportMode mode);
int inbe_storage_inspect_import(const char *path, InbeStorageImportInfo *info);
#endif
-605
View File
@@ -1,605 +0,0 @@
#include "sync_account.h"
#include "data.h"
#include "storage.h"
#include "sync_client.h"
#include "raylib.h"
#if defined(PLATFORM_ANDROID) || defined(__ANDROID__) || defined(ANDROID)
#include "android_share.h"
#endif
#if defined(INBE_HAS_LIBOQS)
#include <oqs/oqs.h>
#endif
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define SYNC_PUBLIC_ID_KEY "sync_public_id"
#define SYNC_PUBLIC_KEY_KEY "sync_public_key"
#define SYNC_PRIVATE_KEY_KEY "sync_private_key"
typedef struct Sha256Ctx {
uint32_t state[8];
uint64_t bit_len;
uint8_t data[64];
size_t data_len;
} Sha256Ctx;
static int account_has_values(const InbeSyncAccount *account);
static const uint32_t sha256_k[64] = {
0x428a2f98U, 0x71374491U, 0xb5c0fbcfU, 0xe9b5dba5U, 0x3956c25bU, 0x59f111f1U,
0x923f82a4U, 0xab1c5ed5U, 0xd807aa98U, 0x12835b01U, 0x243185beU, 0x550c7dc3U,
0x72be5d74U, 0x80deb1feU, 0x9bdc06a7U, 0xc19bf174U, 0xe49b69c1U, 0xefbe4786U,
0x0fc19dc6U, 0x240ca1ccU, 0x2de92c6fU, 0x4a7484aaU, 0x5cb0a9dcU, 0x76f988daU,
0x983e5152U, 0xa831c66dU, 0xb00327c8U, 0xbf597fc7U, 0xc6e00bf3U, 0xd5a79147U,
0x06ca6351U, 0x14292967U, 0x27b70a85U, 0x2e1b2138U, 0x4d2c6dfcU, 0x53380d13U,
0x650a7354U, 0x766a0abbU, 0x81c2c92eU, 0x92722c85U, 0xa2bfe8a1U, 0xa81a664bU,
0xc24b8b70U, 0xc76c51a3U, 0xd192e819U, 0xd6990624U, 0xf40e3585U, 0x106aa070U,
0x19a4c116U, 0x1e376c08U, 0x2748774cU, 0x34b0bcb5U, 0x391c0cb3U, 0x4ed8aa4aU,
0x5b9cca4fU, 0x682e6ff3U, 0x748f82eeU, 0x78a5636fU, 0x84c87814U, 0x8cc70208U,
0x90befffaU, 0xa4506cebU, 0xbef9a3f7U, 0xc67178f2U
};
static uint32_t
rotr32(uint32_t value, uint32_t bits)
{
return (value >> bits) | (value << (32U - bits));
}
static void
sha256_transform(Sha256Ctx *ctx, const uint8_t data[64])
{
uint32_t m[64];
uint32_t a, b, c, d, e, f, g, h;
for(int i = 0; i < 16; i++) {
m[i] = ((uint32_t)data[i * 4] << 24) |
((uint32_t)data[i * 4 + 1] << 16) |
((uint32_t)data[i * 4 + 2] << 8) |
(uint32_t)data[i * 4 + 3];
}
for(int i = 16; i < 64; i++) {
uint32_t s0 = rotr32(m[i - 15], 7) ^ rotr32(m[i - 15], 18) ^ (m[i - 15] >> 3);
uint32_t s1 = rotr32(m[i - 2], 17) ^ rotr32(m[i - 2], 19) ^ (m[i - 2] >> 10);
m[i] = m[i - 16] + s0 + m[i - 7] + s1;
}
a = ctx->state[0];
b = ctx->state[1];
c = ctx->state[2];
d = ctx->state[3];
e = ctx->state[4];
f = ctx->state[5];
g = ctx->state[6];
h = ctx->state[7];
for(int i = 0; i < 64; i++) {
uint32_t s1 = rotr32(e, 6) ^ rotr32(e, 11) ^ rotr32(e, 25);
uint32_t ch = (e & f) ^ ((~e) & g);
uint32_t temp1 = h + s1 + ch + sha256_k[i] + m[i];
uint32_t s0 = rotr32(a, 2) ^ rotr32(a, 13) ^ rotr32(a, 22);
uint32_t maj = (a & b) ^ (a & c) ^ (b & c);
uint32_t temp2 = s0 + maj;
h = g;
g = f;
f = e;
e = d + temp1;
d = c;
c = b;
b = a;
a = temp1 + temp2;
}
ctx->state[0] += a;
ctx->state[1] += b;
ctx->state[2] += c;
ctx->state[3] += d;
ctx->state[4] += e;
ctx->state[5] += f;
ctx->state[6] += g;
ctx->state[7] += h;
}
static void
sha256_init(Sha256Ctx *ctx)
{
memset(ctx, 0, sizeof(*ctx));
ctx->state[0] = 0x6a09e667U;
ctx->state[1] = 0xbb67ae85U;
ctx->state[2] = 0x3c6ef372U;
ctx->state[3] = 0xa54ff53aU;
ctx->state[4] = 0x510e527fU;
ctx->state[5] = 0x9b05688cU;
ctx->state[6] = 0x1f83d9abU;
ctx->state[7] = 0x5be0cd19U;
}
static void
sha256_update(Sha256Ctx *ctx, const uint8_t *data, size_t len)
{
for(size_t i = 0; i < len; i++) {
ctx->data[ctx->data_len++] = data[i];
if(ctx->data_len == 64) {
sha256_transform(ctx, ctx->data);
ctx->bit_len += 512;
ctx->data_len = 0;
}
}
}
static void
sha256_final(Sha256Ctx *ctx, uint8_t hash[32])
{
size_t i = ctx->data_len;
ctx->data[i++] = 0x80;
if(i > 56) {
while(i < 64)
ctx->data[i++] = 0;
sha256_transform(ctx, ctx->data);
i = 0;
}
while(i < 56)
ctx->data[i++] = 0;
ctx->bit_len += ctx->data_len * 8;
for(int j = 0; j < 8; j++)
ctx->data[63 - j] = (uint8_t)(ctx->bit_len >> (j * 8));
sha256_transform(ctx, ctx->data);
for(i = 0; i < 4; i++) {
for(int j = 0; j < 8; j++)
hash[j * 4 + i] = (uint8_t)(ctx->state[j] >> (24 - i * 8));
}
}
static void
bytes_to_hex(const uint8_t *bytes, size_t len, char *out, size_t out_size)
{
static const char hex[] = "0123456789abcdef";
size_t needed = len * 2 + 1;
if(out == NULL || out_size < needed)
return;
for(size_t i = 0; i < len; i++) {
out[i * 2] = hex[bytes[i] >> 4];
out[i * 2 + 1] = hex[bytes[i] & 0x0f];
}
out[len * 2] = '\0';
}
static int
hex_to_bytes(const char *hex, uint8_t *out, size_t out_len)
{
size_t len;
if(hex == NULL || out == NULL)
return 0;
len = strlen(hex);
if(len != out_len * 2)
return 0;
for(size_t i = 0; i < out_len; i++) {
unsigned int value;
if(sscanf(hex + i * 2, "%2x", &value) != 1)
return 0;
out[i] = (uint8_t)value;
}
return 1;
}
static int
hex_string_valid(const char *hex, size_t expected_len)
{
if(hex == NULL || strlen(hex) != expected_len)
return 0;
for(size_t i = 0; i < expected_len; i++) {
char c = hex[i];
if(!((c >= '0' && c <= '9') ||
(c >= 'a' && c <= 'f') ||
(c >= 'A' && c <= 'F')))
return 0;
}
return 1;
}
static void
copy_key_value(char *out, size_t out_size, const char *value, size_t value_len)
{
if(out == NULL || out_size == 0)
return;
if(value_len >= out_size)
value_len = out_size - 1;
memcpy(out, value, value_len);
out[value_len] = '\0';
}
static void
parse_sync_key_line(InbeSyncAccount *account, const char *line, size_t line_len)
{
const char *value;
size_t value_len;
if(account == NULL || line == NULL)
return;
if(line_len > 0 && line[line_len - 1] == '\r')
line_len--;
if(line_len > 10 && strncmp(line, "public_id=", 10) == 0) {
value = line + 10;
value_len = line_len - 10;
copy_key_value(account->public_id, sizeof(account->public_id), value, value_len);
} else if(line_len > 11 && strncmp(line, "public_key=", 11) == 0) {
value = line + 11;
value_len = line_len - 11;
copy_key_value(account->public_key_hex, sizeof(account->public_key_hex), value, value_len);
} else if(line_len > 12 && strncmp(line, "private_key=", 12) == 0) {
value = line + 12;
value_len = line_len - 12;
copy_key_value(account->private_key_hex, sizeof(account->private_key_hex), value, value_len);
} else if(line_len > 11 && strncmp(line, "secret_key=", 11) == 0) {
value = line + 11;
value_len = line_len - 11;
copy_key_value(account->private_key_hex, sizeof(account->private_key_hex), value, value_len);
}
}
static int
extract_json_string_field(const char *json, const char *field, char *out, size_t out_size)
{
char key[64];
const char *p;
char *dst;
char *end;
if(json == NULL || field == NULL || out == NULL || out_size == 0)
return 0;
out[0] = '\0';
if(strlen(field) + 3 > sizeof(key))
return 0;
snprintf(key, sizeof(key), "\"%s\"", field);
p = strstr(json, key);
if(p == NULL)
return 0;
p += strlen(key);
while(*p == ' ' || *p == '\t' || *p == '\r' || *p == '\n')
p++;
if(*p != ':')
return 0;
p++;
while(*p == ' ' || *p == '\t' || *p == '\r' || *p == '\n')
p++;
if(*p != '"')
return 0;
p++;
dst = out;
end = out + out_size - 1;
while(*p != '\0' && *p != '"' && dst < end) {
if(*p == '\\') {
p++;
if(*p == 'n')
*dst++ = '\n';
else if(*p == 'r')
*dst++ = '\r';
else if(*p == 't')
*dst++ = '\t';
else if(*p == '\\' || *p == '"')
*dst++ = *p;
else
return 0;
if(*p != '\0')
p++;
continue;
}
*dst++ = *p++;
}
*dst = '\0';
return *p == '"';
}
static int
parse_sync_key_text(const char *text, InbeSyncAccount *account)
{
const char *line;
const char *next;
char exported_key[8200];
if(text == NULL || account == NULL)
return 0;
if(extract_json_string_field(text, "exported_key", exported_key, sizeof(exported_key)))
text = exported_key;
memset(account, 0, sizeof(*account));
line = text;
if((unsigned char)line[0] == 0xef &&
(unsigned char)line[1] == 0xbb &&
(unsigned char)line[2] == 0xbf)
line += 3;
while(*line != '\0') {
next = strchr(line, '\n');
if(next == NULL) {
parse_sync_key_line(account, line, strlen(line));
break;
}
parse_sync_key_line(account, line, (size_t)(next - line));
line = next + 1;
}
return account->public_key_hex[0] != '\0' &&
account->private_key_hex[0] != '\0';
}
static int
sync_account_validate_import(InbeSyncAccount *account)
{
uint8_t public_key[1312];
char expected_public_id[65];
if(account == NULL)
return 0;
if(!hex_string_valid(account->public_key_hex, 2624) ||
!hex_string_valid(account->private_key_hex, 5120))
return 0;
if(!hex_to_bytes(account->public_key_hex, public_key, sizeof(public_key)))
return 0;
sync_sha256_hex(public_key, sizeof(public_key), expected_public_id);
if(account->public_id[0] == '\0') {
snprintf(account->public_id, sizeof(account->public_id), "%s", expected_public_id);
return 1;
}
if(!hex_string_valid(account->public_id, 64))
return 0;
return strcmp(account->public_id, expected_public_id) == 0;
}
void
sync_sha256_hex(const uint8_t *data, size_t len, char out_hex[65])
{
uint8_t digest[32];
Sha256Ctx sha;
if(out_hex == NULL)
return;
out_hex[0] = '\0';
if(data == NULL && len > 0)
return;
sha256_init(&sha);
sha256_update(&sha, data, len);
sha256_final(&sha, digest);
bytes_to_hex(digest, sizeof(digest), out_hex, 65);
}
static int
account_has_values(const InbeSyncAccount *account)
{
return account != NULL &&
account->public_id[0] != '\0' &&
account->public_key_hex[0] != '\0' &&
account->private_key_hex[0] != '\0';
}
int
sync_account_available(void)
{
#if defined(INBE_HAS_LIBOQS)
return 1;
#else
return 0;
#endif
}
int
sync_account_load(InbeSyncAccount *account)
{
const char *public_id;
const char *public_key;
const char *private_key;
data_init();
if(account == NULL)
return 0;
memset(account, 0, sizeof(*account));
public_id = storage_get_setting_text(SYNC_PUBLIC_ID_KEY);
if(public_id != NULL)
snprintf(account->public_id, sizeof(account->public_id), "%s", public_id);
public_key = storage_get_setting_text(SYNC_PUBLIC_KEY_KEY);
if(public_key != NULL)
snprintf(account->public_key_hex, sizeof(account->public_key_hex), "%s", public_key);
private_key = storage_get_setting_text(SYNC_PRIVATE_KEY_KEY);
if(private_key != NULL)
snprintf(account->private_key_hex, sizeof(account->private_key_hex), "%s", private_key);
return account_has_values(account);
}
int
sync_account_create(InbeSyncAccount *account)
{
#if defined(INBE_HAS_LIBOQS)
OQS_SIG *sig;
uint8_t public_key[1312];
uint8_t private_key[2560];
uint8_t digest[32];
Sha256Ctx sha;
InbeSyncAccount generated;
data_init();
if(account == NULL)
return 0;
memset(&generated, 0, sizeof(generated));
sig = OQS_SIG_new(OQS_SIG_alg_ml_dsa_44);
if(sig == NULL ||
sig->length_public_key != sizeof(public_key) ||
sig->length_secret_key != sizeof(private_key)) {
if(sig != NULL)
OQS_SIG_free(sig);
return 0;
}
if(OQS_SIG_keypair(sig, public_key, private_key) != OQS_SUCCESS) {
OQS_SIG_free(sig);
return 0;
}
OQS_SIG_free(sig);
sha256_init(&sha);
sha256_update(&sha, public_key, sizeof(public_key));
sha256_final(&sha, digest);
bytes_to_hex(digest, sizeof(digest), generated.public_id, sizeof(generated.public_id));
bytes_to_hex(public_key, sizeof(public_key), generated.public_key_hex,
sizeof(generated.public_key_hex));
bytes_to_hex(private_key, sizeof(private_key), generated.private_key_hex,
sizeof(generated.private_key_hex));
storage_settings_begin_write();
storage_set_setting_text(SYNC_PUBLIC_ID_KEY, generated.public_id);
storage_set_setting_text(SYNC_PUBLIC_KEY_KEY, generated.public_key_hex);
storage_set_setting_text(SYNC_PRIVATE_KEY_KEY, generated.private_key_hex);
sync_client_clear_auth_token();
storage_reset_sync_state();
storage_settings_end_write();
*account = generated;
return 1;
#else
(void)account;
return 0;
#endif
}
int
sync_account_import_private_key(InbeSyncAccount *account, const char *filename)
{
char *body;
InbeSyncAccount imported;
data_init();
if(account == NULL || filename == NULL || filename[0] == '\0')
return 0;
body = LoadFileText(filename);
if(body == NULL)
return 0;
if(!parse_sync_key_text(body, &imported)) {
TraceLog(LOG_WARNING, "SYNC: Private key import failed: missing public_key/private_key fields");
UnloadFileText(body);
return 0;
}
if(!sync_account_validate_import(&imported)) {
TraceLog(LOG_WARNING, "SYNC: Private key import failed: invalid key values");
UnloadFileText(body);
return 0;
}
UnloadFileText(body);
storage_settings_begin_write();
storage_set_setting_text(SYNC_PUBLIC_ID_KEY, imported.public_id);
storage_set_setting_text(SYNC_PUBLIC_KEY_KEY, imported.public_key_hex);
storage_set_setting_text(SYNC_PRIVATE_KEY_KEY, imported.private_key_hex);
sync_client_clear_auth_token();
storage_reset_sync_state();
storage_settings_end_write();
*account = imported;
return 1;
}
int
sync_account_clear(void)
{
data_init();
storage_settings_begin_write();
storage_set_setting_text(SYNC_PUBLIC_ID_KEY, "");
storage_set_setting_text(SYNC_PUBLIC_KEY_KEY, "");
storage_set_setting_text(SYNC_PRIVATE_KEY_KEY, "");
sync_client_clear_auth_token();
storage_reset_sync_state();
storage_settings_end_write();
return 1;
}
int
sync_account_export_private_key(const InbeSyncAccount *account, const char *filename)
{
char body[8200];
int len;
if(!account_has_values(account) || filename == NULL || filename[0] == '\0')
return 0;
len = snprintf(body, sizeof(body),
"inbe-sync-key-v1\nalgorithm=ML-DSA-44\npublic_id=%s\npublic_key=%s\nprivate_key=%s\n",
account->public_id, account->public_key_hex, account->private_key_hex);
if(len <= 0 || (size_t)len >= sizeof(body))
return 0;
#if defined(PLATFORM_ANDROID) || defined(__ANDROID__) || defined(ANDROID)
return android_share_bytes((const unsigned char *)body, (size_t)len, filename,
"application/octet-stream");
#else
if(strchr(filename, '/') != NULL || strchr(filename, '\\') != NULL)
return SaveFileData(filename, body, len);
{
char path[512];
snprintf(path, sizeof(path), "%s/%s", data_root(), filename);
return SaveFileData(path, body, len);
}
#endif
}
int
sync_account_sign_hex(const uint8_t *message, size_t message_len,
char *out_signature_hex, size_t out_size)
{
#if defined(INBE_HAS_LIBOQS)
InbeSyncAccount account;
OQS_SIG *sig;
uint8_t private_key[2560];
uint8_t signature[2420];
size_t signature_len = 0;
if(out_signature_hex == NULL || out_size < sizeof(signature) * 2 + 1 ||
(message == NULL && message_len > 0))
return 0;
out_signature_hex[0] = '\0';
if(!sync_account_load(&account))
return 0;
if(!hex_to_bytes(account.private_key_hex, private_key, sizeof(private_key)))
return 0;
sig = OQS_SIG_new(OQS_SIG_alg_ml_dsa_44);
if(sig == NULL ||
sig->length_secret_key != sizeof(private_key) ||
sig->length_signature != sizeof(signature)) {
if(sig != NULL)
OQS_SIG_free(sig);
return 0;
}
if(OQS_SIG_sign(sig, signature, &signature_len, message, message_len,
private_key) != OQS_SUCCESS ||
signature_len != sizeof(signature)) {
OQS_SIG_free(sig);
return 0;
}
OQS_SIG_free(sig);
bytes_to_hex(signature, sizeof(signature), out_signature_hex, out_size);
return out_signature_hex[0] != '\0';
#else
(void)message;
(void)message_len;
(void)out_signature_hex;
(void)out_size;
return 0;
#endif
}
-29
View File
@@ -1,29 +0,0 @@
#ifndef INBE_SYNC_ACCOUNT_H
#define INBE_SYNC_ACCOUNT_H
#include <stddef.h>
#include <stdint.h>
enum {
INBE_SYNC_PUBLIC_ID_HEX_SIZE = 65,
INBE_SYNC_PUBLIC_KEY_HEX_SIZE = 2625,
INBE_SYNC_PRIVATE_KEY_HEX_SIZE = 5121
};
typedef struct InbeSyncAccount {
char public_id[INBE_SYNC_PUBLIC_ID_HEX_SIZE];
char public_key_hex[INBE_SYNC_PUBLIC_KEY_HEX_SIZE];
char private_key_hex[INBE_SYNC_PRIVATE_KEY_HEX_SIZE];
} InbeSyncAccount;
int sync_account_available(void);
int sync_account_load(InbeSyncAccount *account);
int sync_account_create(InbeSyncAccount *account);
int sync_account_import_private_key(InbeSyncAccount *account, const char *filename);
int sync_account_clear(void);
int sync_account_export_private_key(const InbeSyncAccount *account, const char *filename);
void sync_sha256_hex(const uint8_t *data, size_t len, char out_hex[65]);
int sync_account_sign_hex(const uint8_t *message, size_t message_len,
char *out_signature_hex, size_t out_size);
#endif
File diff suppressed because it is too large. Load diff
-31
View File
@@ -1,31 +0,0 @@
#ifndef INBE_SYNC_CLIENT_H
#define INBE_SYNC_CLIENT_H
#include <stddef.h>
typedef enum InbeSyncClientResult {
INBE_SYNC_CLIENT_OK = 0,
INBE_SYNC_CLIENT_INVALID_URL,
INBE_SYNC_CLIENT_NO_ACCOUNT,
INBE_SYNC_CLIENT_PAYLOAD_FAILED,
INBE_SYNC_CLIENT_CHALLENGE_FAILED,
INBE_SYNC_CLIENT_SIGN_FAILED,
INBE_SYNC_CLIENT_REQUEST_FAILED,
INBE_SYNC_CLIENT_AUTH_FAILED
} 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_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);
void sync_client_clear_auth_token(void);
#if defined(__EMSCRIPTEN__)
int sync_client_web_start_remote_events(const char *base_url);
int sync_client_web_poll_remote_event(void);
int sync_client_web_sync_start(const char *base_url);
int sync_client_web_sync_poll(InbeSyncClientResult *result, int *changed);
#endif
#endif
+11 -148
View File
@@ -28,6 +28,11 @@
overflow: hidden;
}
#status,
#progress {
display: none;
}
.canvas-stage {
width: 100%;
height: 100vh;
@@ -38,9 +43,7 @@
}
body {
background: #f4f1e8;
color: #f7fbf9;
font-family: ui-monospace, "SFMono-Regular", "Roboto Mono", "Cascadia Mono", "Liberation Mono", monospace;
background: #1a1a2e;
}
.canvas-frame {
@@ -58,7 +61,6 @@
max-width: none !important;
max-height: none !important;
border: 0;
background: #f4f1e8;
image-rendering: auto;
}
@@ -67,149 +69,22 @@
width: 100vw;
height: 100vh;
}
.loading-screen {
position: fixed;
inset: 0;
z-index: 10;
display: flex;
align-items: center;
justify-content: center;
padding: max(24px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
box-sizing: border-box;
background:
radial-gradient(circle at 50% 38%, rgba(132, 184, 172, 0.24), transparent 36%),
linear-gradient(180deg, #222640 0%, #17172a 58%, #10131f 100%);
opacity: 1;
transition: opacity 360ms ease, visibility 360ms ease;
}
.loading-screen.is-hidden {
opacity: 0;
visibility: hidden;
pointer-events: none;
}
.loading-panel {
width: min(360px, 100%);
display: grid;
justify-items: center;
gap: 18px;
text-align: center;
}
.loading-mark {
width: 76px;
height: 76px;
border-radius: 18px;
box-shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
}
.loading-title {
margin: 0;
font-size: 20px;
line-height: 1.25;
font-weight: 700;
}
#status {
min-height: 1.35em;
color: #c9deda;
font-size: 13px;
line-height: 1.35;
}
#progress {
width: min(280px, 100%);
height: 8px;
overflow: hidden;
border: 0;
border-radius: 999px;
background: rgba(255, 255, 255, 0.18);
}
#progress::-webkit-progress-bar {
border-radius: 999px;
background: rgba(255, 255, 255, 0.18);
}
#progress::-webkit-progress-value {
border-radius: 999px;
background: #8fcfc2;
}
#progress::-moz-progress-bar {
border-radius: 999px;
background: #8fcfc2;
}
</style>
</head>
<body>
<div class="loading-screen" id="loading-screen" role="status" aria-live="polite">
<div class="loading-panel">
<img class="loading-mark" src="/web-assets/icons/icon-192x192.png" alt="" width="76" height="76">
<h1 class="loading-title">Inner Breeze</h1>
<div id="status">Downloading...</div>
<progress value="0" max="100" id="progress" hidden></progress>
</div>
</div>
<div id="status">Downloading...</div>
<progress value="0" max="100" id="progress" hidden></progress>
<div class="canvas-stage">
<div class="canvas-frame" id="canvas-frame">
<canvas class="emscripten" id="canvas" width="320" height="560" tabindex="-1"></canvas>
<canvas class="emscripten" id="canvas" width="320" height="560" oncontextmenu="event.preventDefault()" tabindex="-1"></canvas>
</div>
</div>
<script>
var statusElement = document.querySelector('#status');
var progressElement = document.querySelector('#progress');
var loadingScreen = document.querySelector('#loading-screen');
function hideLoadingScreen() {
if (!loadingScreen) return;
window.requestAnimationFrame(function() {
loadingScreen.classList.add('is-hidden');
});
}
function scheduleStorageSync(delay, logSuccess) {
if (typeof FS === 'undefined' || typeof FS.syncfs !== 'function') return;
Module.__inbeStorageSyncPending = true;
Module.__inbeStorageSyncLogSuccess = Module.__inbeStorageSyncLogSuccess || !!logSuccess;
if (Module.__inbeStorageSyncTimer) clearTimeout(Module.__inbeStorageSyncTimer);
Module.__inbeStorageSyncTimer = setTimeout(function runStorageSync() {
Module.__inbeStorageSyncTimer = 0;
if (Module.__inbeStorageSyncing) return;
Module.__inbeStorageSyncing = true;
Module.__inbeStorageSyncPending = false;
var shouldLog = !!Module.__inbeStorageSyncLogSuccess;
Module.__inbeStorageSyncLogSuccess = false;
try {
FS.syncfs(false, function(err) {
Module.__inbeStorageSyncing = false;
if (err) console.error('IDBFS save failed:', err);
else if (shouldLog) console.log('IDBFS synced');
if (Module.__inbeStorageSyncPending) {
if (Module.__inbeStorageSyncTimer) clearTimeout(Module.__inbeStorageSyncTimer);
Module.__inbeStorageSyncTimer = setTimeout(runStorageSync, delay);
}
});
} catch (e) {
Module.__inbeStorageSyncing = false;
console.error('IDBFS sync error:', e);
if (Module.__inbeStorageSyncPending) {
if (Module.__inbeStorageSyncTimer) clearTimeout(Module.__inbeStorageSyncTimer);
Module.__inbeStorageSyncTimer = setTimeout(runStorageSync, delay);
}
}
}, delay);
}
var Module = {
__inbeScheduleStorageSync: scheduleStorageSync,
preRun: [function() {
if (typeof FS === 'undefined' || typeof IDBFS === 'undefined') {
console.error('IDBFS unavailable');
@@ -236,7 +111,7 @@
removeRunDependency('inbe-idbfs');
});
}],
postRun: [hideLoadingScreen],
postRun: [],
locateFile: function(path, prefix) {
if (path === 'index.wasm' || path === 'index.data') {
return prefix + path + '?v=WEB_CACHE_BUSTER';
@@ -257,18 +132,6 @@
alert('WebGL context lost. Reload the page to continue.');
e.preventDefault();
}, false);
canvas.addEventListener('contextmenu', function(e) {
var rect = canvas.getBoundingClientRect();
var width = canvas.width || rect.width || 1;
var height = canvas.height || rect.height || 1;
e.preventDefault();
Module.__inbeContextClick = {
x: Math.round((e.clientX - rect.left) * width / Math.max(1, rect.width)),
y: Math.round((e.clientY - rect.top) * height / Math.max(1, rect.height)),
time: Date.now()
};
}, false);
return canvas;
})(),
setStatus: function(text) {
@@ -290,7 +153,7 @@
} else {
statusElement.textContent = text;
progressElement.hidden = true;
if (!text) hideLoadingScreen();
if (!text) statusElement.style.display = 'none';
}
},
totalDependencies: 0,
+94 -629
View File
@@ -11,7 +11,6 @@
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <time.h>
#include <unistd.h>
static int g_failures = 0;
@@ -151,326 +150,13 @@ write_source_database(const char *root)
int rounds[] = {45, 60, 75};
InbeHabits habits;
check_true("init source db", storage_init(root));
check_true("save source session", storage_save_session(rounds, 3, NULL, 0));
check_true("init source db", inbe_storage_init(root));
check_true("save source session", inbe_storage_save_session(rounds, 3, NULL, 0));
memset(&habits, 0, sizeof(habits));
habits_add_default_set(&habits);
habit_set_day(&habits, 0, 20260613, 1);
habits_save(&habits);
check_int("source sessions", storage_session_count(), 1);
storage_close();
}
static void
insert_raw_habit_day(const char *root, const char *habit_id, int local_date, int completed)
{
char db_path[512];
sqlite3 *db = NULL;
sqlite3_stmt *stmt = NULL;
make_path(db_path, sizeof(db_path), root, "inbe.db");
check_true("open raw habit day db", sqlite3_open(db_path, &db) == SQLITE_OK);
if(db == NULL)
return;
if(sqlite3_prepare_v2(db,
"INSERT OR REPLACE INTO habit_days(habit_id,local_date,completed,updated_at) "
"VALUES(?1,?2,?3,0)",
-1, &stmt, NULL) == SQLITE_OK) {
sqlite3_bind_text(stmt, 1, habit_id, -1, SQLITE_TRANSIENT);
sqlite3_bind_int(stmt, 2, local_date);
sqlite3_bind_int(stmt, 3, completed ? 1 : 0);
check_true("insert raw habit day", sqlite3_step(stmt) == SQLITE_DONE);
} else {
check_true("prepare raw habit day", 0);
}
sqlite3_finalize(stmt);
sqlite3_close(db);
}
static int
read_raw_habit_day_count(const char *root, const char *habit_id, int local_date)
{
char db_path[512];
sqlite3 *db = NULL;
sqlite3_stmt *stmt = NULL;
int count = -1;
make_path(db_path, sizeof(db_path), root, "inbe.db");
check_true("open raw count db", sqlite3_open(db_path, &db) == SQLITE_OK);
if(db == NULL)
return count;
if(sqlite3_prepare_v2(db,
"SELECT count FROM habit_days WHERE habit_id=?1 AND local_date=?2",
-1, &stmt, NULL) == SQLITE_OK) {
sqlite3_bind_text(stmt, 1, habit_id, -1, SQLITE_TRANSIENT);
sqlite3_bind_int(stmt, 2, local_date);
if(sqlite3_step(stmt) == SQLITE_ROW)
count = sqlite3_column_int(stmt, 0);
} else {
check_true("prepare raw count", 0);
}
sqlite3_finalize(stmt);
sqlite3_close(db);
return count;
}
static void
test_sync_payload_omits_uploaded_state_after_upload_marker(void)
{
char root[512];
InbeHabits habits;
char *payload;
make_clean_root(root, sizeof(root), "sync-full-local-state");
check_true("init sync watermark db", storage_init(root));
memset(&habits, 0, sizeof(habits));
habits_add_default_set(&habits);
habit_set_day_count(&habits, 0, 20260612, 12);
habits_save(&habits);
storage_close();
{
char db_path[512];
sqlite3 *db = NULL;
sqlite3_stmt *stmt = NULL;
long long updated_at = 0;
make_path(db_path, sizeof(db_path), root, "inbe.db");
check_true("open sync watermark raw db", sqlite3_open(db_path, &db) == SQLITE_OK);
if(db != NULL) {
if(sqlite3_prepare_v2(db,
"SELECT updated_at FROM habit_days WHERE local_date=20260612",
-1, &stmt, NULL) == SQLITE_OK &&
sqlite3_step(stmt) == SQLITE_ROW)
updated_at = sqlite3_column_int64(stmt, 0);
if(stmt != NULL)
sqlite3_finalize(stmt);
check_true("set sync watermark raw meta",
updated_at > 0 &&
sqlite3_exec(db,
"INSERT OR REPLACE INTO meta(key,value) VALUES('sync_full_upload_done','1');",
NULL, NULL, NULL) == SQLITE_OK);
if(updated_at > 0) {
char sql[192];
snprintf(sql, sizeof(sql),
"INSERT OR REPLACE INTO meta(key,value) VALUES('sync_last_upload_at','%lld');",
updated_at);
check_true("set sync same second upload marker",
sqlite3_exec(db, sql, NULL, NULL, NULL) == SQLITE_OK);
}
check_true("clear uploaded outbox raw meta",
sqlite3_exec(db, "DELETE FROM sync_outbox;", NULL, NULL, NULL) == SQLITE_OK);
sqlite3_close(db);
}
}
check_true("reopen sync watermark db", storage_init(root));
payload = storage_build_sync_payload_json("test-hash", "test-public-key");
check_true("habit day omitted from sync payload after upload marker",
payload != NULL &&
strstr(payload, "\"local_date\":20260612") == NULL &&
strstr(payload, "\"count\":12") == NULL);
storage_free_sync_payload_json(payload);
storage_close();
remove_tree(root);
}
static void
test_sync_payload_includes_queued_current_edits(void)
{
char root[512];
InbeHabits habits;
char *payload;
make_clean_root(root, sizeof(root), "sync-queued-edit");
check_true("init queued sync db", storage_init(root));
memset(&habits, 0, sizeof(habits));
habits_add_default_set(&habits);
habit_set_day_count(&habits, 0, 20260617, 7);
habits_save(&habits);
payload = storage_build_sync_payload_json("test-hash", "test-public-key");
check_true("queued habit day included in sync payload",
payload != NULL &&
strstr(payload, "\"local_date\":20260617") != NULL &&
strstr(payload, "\"count\":7") != NULL);
storage_free_sync_payload_json(payload);
storage_close();
remove_tree(root);
}
static void
test_sync_outbox_preserves_edits_after_snapshot(void)
{
char root[512];
InbeHabits habits;
char *payload;
const char *empty_response =
"{\"server_version\":1,\"changes\":{\"habits\":[],\"habit_days\":[],\"sessions\":[]}}";
make_clean_root(root, sizeof(root), "sync-outbox-snapshot");
check_true("init outbox snapshot db", storage_init(root));
memset(&habits, 0, sizeof(habits));
habits_add_default_set(&habits);
habit_set_day_count(&habits, 0, 20260618, 1);
habits_save(&habits);
payload = storage_build_sync_payload_json("test-hash", "test-public-key");
check_true("first queued edit in payload",
payload != NULL && strstr(payload, "\"local_date\":20260618") != NULL);
storage_free_sync_payload_json(payload);
habit_set_day_count(&habits, 0, 20260619, 2);
habits_save(&habits);
check_true("apply response clears only snapshotted outbox",
storage_apply_sync_response_json(empty_response));
payload = storage_build_sync_payload_json("test-hash", "test-public-key");
check_true("later edit remains queued after snapshot clear",
payload != NULL &&
strstr(payload, "\"local_date\":20260619") != NULL &&
strstr(payload, "\"count\":2") != NULL);
check_true("earlier edit was cleared after snapshot success",
payload != NULL && strstr(payload, "\"local_date\":20260618") == NULL);
storage_free_sync_payload_json(payload);
storage_close();
remove_tree(root);
}
static void
test_sync_apply_preserves_counter_counts(void)
{
char root[512];
const char *habit_id = "counter-habit";
const char *lower_count_response =
"{\"server_version\":1,\"changes\":{\"habits\":[],\"habit_days\":["
"{\"habit_id\":\"counter-habit\",\"local_date\":20260619,"
"\"completed\":true,\"count\":1,\"updated_at\":\"2026-06-19T21:00:00Z\"}"
"],\"sessions\":[]}}";
const char *higher_count_response =
"{\"server_version\":2,\"changes\":{\"habits\":[],\"habit_days\":["
"{\"habit_id\":\"counter-habit\",\"local_date\":20260619,"
"\"completed\":true,\"count\":5,\"updated_at\":\"2026-06-19T21:00:00Z\"}"
"],\"sessions\":[]}}";
make_clean_root(root, sizeof(root), "sync-counter");
check_true("init sync counter db", storage_init(root));
storage_close();
{
char db_path[512];
sqlite3 *db = NULL;
make_path(db_path, sizeof(db_path), root, "inbe.db");
check_true("open sync counter raw db", sqlite3_open(db_path, &db) == SQLITE_OK);
if(db != NULL) {
check_true("insert sync counter habit",
sqlite3_exec(db,
"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('counter-habit','default','Counter',255,255,255,0,0,1,0,0,1781902800);"
"INSERT INTO habit_days(habit_id,local_date,completed,count,updated_at) "
"VALUES('counter-habit',20260619,1,4,1781902800);",
NULL, NULL, NULL) == SQLITE_OK);
sqlite3_close(db);
}
}
check_true("reopen sync counter db", storage_init(root));
check_true("apply lower equal counter", storage_apply_sync_response_json(lower_count_response));
storage_close();
check_int("lower equal sync does not reset counter",
read_raw_habit_day_count(root, habit_id, 20260619), 4);
check_true("reopen sync counter db for repair", storage_init(root));
check_true("apply higher equal counter", storage_apply_sync_response_json(higher_count_response));
storage_close();
check_int("higher equal sync repairs counter",
read_raw_habit_day_count(root, habit_id, 20260619), 5);
remove_tree(root);
}
static void
test_session_linked_counts_materialize_for_sync(void)
{
char root[512];
char first_id[INBE_STORAGE_ID_SIZE + 4];
char second_id[INBE_STORAGE_ID_SIZE + 4];
int first_rounds[] = {30};
int second_rounds[] = {45};
int today = habits_today_index();
InbeHabits habits;
char *payload;
make_clean_root(root, sizeof(root), "session-linked-count");
check_true("init linked counter db", storage_init(root));
memset(&habits, 0, sizeof(habits));
habits_add_default_set(&habits);
check_true("save linked session one",
storage_save_session_for_activity(first_rounds, 1, 0, 1,
first_id, sizeof(first_id)));
check_true("save linked session two",
storage_save_session_for_activity(second_rounds, 1, 0, 1,
second_id, sizeof(second_id)));
memset(&habits, 0, sizeof(habits));
check_true("load linked counter habits", storage_habits_load(&habits));
check_int("linked sessions materialize count",
habit_day_count(&habits.items[0], today), 2);
payload = storage_build_sync_payload_json("test-hash", "test-public-key");
check_true("linked session count is in sync payload",
payload != NULL && strstr(payload, "\"count\":2") != NULL);
storage_free_sync_payload_json(payload);
check_true("delete linked session one", storage_delete_session(first_id));
memset(&habits, 0, sizeof(habits));
check_true("reload linked counter after delete", storage_habits_load(&habits));
check_int("linked session delete lowers derived count",
habit_day_count(&habits.items[0], today), 1);
habit_set_day_count(&habits, 0, today, 4);
habits_save(&habits);
check_true("delete linked session two", storage_delete_session(second_id));
memset(&habits, 0, sizeof(habits));
check_true("reload linked counter after manual override", storage_habits_load(&habits));
check_int("linked session delete preserves manual count",
habit_day_count(&habits.items[0], today), 4);
storage_close();
remove_tree(root);
}
static void
test_existing_sessions_materialize_after_habit_save(void)
{
char root[512];
int rounds[] = {30};
int today = habits_today_index();
InbeHabits habits;
char *payload;
make_clean_root(root, sizeof(root), "existing-session-linked-count");
check_true("init existing linked counter db", storage_init(root));
check_true("save existing linked session",
storage_save_session_for_activity(rounds, 1, 0, 1, NULL, 0));
memset(&habits, 0, sizeof(habits));
habits_add_default_set(&habits);
memset(&habits, 0, sizeof(habits));
check_true("load existing linked counter habits", storage_habits_load(&habits));
check_int("existing linked session materializes after habit save",
habit_day_count(&habits.items[0], today), 1);
payload = storage_build_sync_payload_json("test-hash", "test-public-key");
check_true("existing linked session count is in sync payload",
payload != NULL && strstr(payload, "\"count\":1") != NULL);
storage_free_sync_payload_json(payload);
storage_close();
remove_tree(root);
inbe_habits_add_default_set(&habits);
inbe_habit_set_day(&habits, 0, 20260613, 1);
check_int("source sessions", inbe_storage_session_count(), 1);
inbe_storage_close();
}
static void
@@ -520,15 +206,15 @@ test_session_metadata(void)
int rounds[] = {30, 45};
make_clean_root(root, sizeof(root), "metadata");
check_true("init metadata db", storage_init(root));
check_true("init metadata db", inbe_storage_init(root));
check_true("save metadata session",
storage_save_session_for_activity(rounds, 2, 2, 3, NULL, 0));
inbe_storage_save_session_for_activity(rounds, 2, 2, 3, NULL, 0));
g_seen_topic = -1;
g_seen_activity = -1;
storage_list_session_records(metadata_history_callback, NULL);
inbe_storage_list_session_records(metadata_history_callback, NULL);
check_int("metadata topic", g_seen_topic, 2);
check_int("metadata activity", g_seen_activity, 3);
storage_close();
inbe_storage_close();
remove_tree(root);
}
@@ -537,13 +223,13 @@ assert_imported_database(const char *root)
{
InbeHabits habits;
check_true("init imported db", storage_init(root));
check_int("imported sessions", storage_session_count(), 1);
check_true("init imported db", inbe_storage_init(root));
check_int("imported sessions", inbe_storage_session_count(), 1);
memset(&habits, 0, sizeof(habits));
check_true("imported habits load", storage_habits_load(&habits));
check_true("imported habits load", inbe_storage_habits_load(&habits));
check_int("imported habit count", habits.count, 1);
check_true("imported habit day", habit_completed_day(&habits.items[0], 20260613));
storage_close();
check_true("imported habit day", inbe_habit_completed_day(&habits.items[0], 20260613));
inbe_storage_close();
}
static void
@@ -556,9 +242,9 @@ test_raw_db_import(void)
write_source_database(source);
make_path(db_path, sizeof(db_path), source, "inbe.db");
check_true("init raw import dest", storage_init(dest));
check_true("raw db import", storage_import_zip(db_path));
storage_close();
check_true("init raw import dest", inbe_storage_init(dest));
check_true("raw db import", inbe_storage_import_zip(db_path));
inbe_storage_close();
assert_imported_database(dest);
remove_tree(source);
@@ -575,13 +261,13 @@ test_zip_db_import(void)
write_source_database(source);
make_path(zip_path, sizeof(zip_path), source, "export.zip");
check_true("init export source", storage_init(source));
check_true("export zip", storage_export_zip(zip_path));
storage_close();
check_true("init export source", inbe_storage_init(source));
check_true("export zip", inbe_storage_export_zip(zip_path));
inbe_storage_close();
check_true("init zip import dest", storage_init(dest));
check_true("zip db import", storage_import_zip(zip_path));
storage_close();
check_true("init zip import dest", inbe_storage_init(dest));
check_true("zip db import", inbe_storage_import_zip(zip_path));
inbe_storage_close();
assert_imported_database(dest);
remove_tree(source);
@@ -599,188 +285,93 @@ test_habit_name_merge_import(void)
make_clean_root(dest, sizeof(dest), "habit-name-dest");
make_path(zip_path, sizeof(zip_path), source, "export.zip");
check_true("init habit merge source", storage_init(source));
check_true("init habit merge source", inbe_storage_init(source));
memset(&habits, 0, sizeof(habits));
check_int("add imported meditation",
habits_add_custom(&habits, "meditation",
inbe_habits_add_custom(&habits, "meditation",
(Color){224, 124, 104, 255},
INBE_HABIT_SYNC_NONE, 0),
0);
habit_set_day(&habits, 0, 20260613, 1);
habits_save(&habits);
inbe_habit_set_day(&habits, 0, 20260613, 1);
check_int("add imported push ups",
habits_add_custom(&habits, "Push ups",
inbe_habits_add_custom(&habits, "Push ups",
(Color){180, 132, 220, 255},
INBE_HABIT_SYNC_NONE, 0),
1);
habit_set_day(&habits, 1, 20260614, 1);
habits_save(&habits);
inbe_habit_set_day(&habits, 1, 20260614, 1);
check_int("add imported cold shower",
habits_add_custom(&habits, "Cold Shower",
inbe_habits_add_custom(&habits, "Cold Shower",
(Color){99, 196, 165, 255},
INBE_HABIT_SYNC_NONE, 0),
2);
habit_set_day(&habits, 2, 20260615, 1);
habits_save(&habits);
check_true("habit merge export", storage_export_zip(zip_path));
storage_close();
inbe_habit_set_day(&habits, 2, 20260615, 1);
check_true("habit merge export", inbe_storage_export_zip(zip_path));
inbe_storage_close();
check_true("init habit merge dest", storage_init(dest));
check_true("init habit merge dest", inbe_storage_init(dest));
memset(&habits, 0, sizeof(habits));
habits_add_default_set(&habits);
habit_set_day(&habits, 0, 20260612, 1);
habits_save(&habits);
check_true("habit merge import", storage_import_zip(zip_path));
inbe_habits_add_default_set(&habits);
inbe_habit_set_day(&habits, 0, 20260612, 1);
check_true("habit merge import", inbe_storage_import_zip(zip_path));
memset(&habits, 0, sizeof(habits));
check_true("habit merge load", storage_habits_load(&habits));
check_true("habit merge load", inbe_storage_habits_load(&habits));
check_int("habit merge count", habits.count, 3);
habit = find_habit_ci(&habits, "Meditation");
check_true("habit merge meditation exists", habit != NULL);
check_true("habit merge preserves local case",
habit != NULL && strcmp(habit->name, "Meditation") == 0);
check_true("habit merge keeps local day",
habit != NULL && habit_completed_day(habit, 20260612));
habit != NULL && inbe_habit_completed_day(habit, 20260612));
check_true("habit merge imports day",
habit != NULL && habit_completed_day(habit, 20260613));
habit != NULL && inbe_habit_completed_day(habit, 20260613));
habit = find_habit_ci(&habits, "Push ups");
check_true("habit merge push ups exists", habit != NULL);
check_true("habit merge push ups day",
habit != NULL && habit_completed_day(habit, 20260614));
habit != NULL && inbe_habit_completed_day(habit, 20260614));
habit = find_habit_ci(&habits, "Cold Shower");
check_true("habit merge cold shower exists", habit != NULL);
check_true("habit merge cold shower day",
habit != NULL && habit_completed_day(habit, 20260615));
storage_close();
habit != NULL && inbe_habit_completed_day(habit, 20260615));
inbe_storage_close();
remove_tree(source);
remove_tree(dest);
}
static void
test_import_conflict_prefers_data_over_empty(void)
{
char source[512], dest[512], zip_path[512];
InbeHabits habits;
InbeHabit *habit;
make_clean_root(source, sizeof(source), "conflict-source");
make_clean_root(dest, sizeof(dest), "conflict-dest");
make_path(zip_path, sizeof(zip_path), source, "conflict-export.zip");
check_true("init conflict source", storage_init(source));
memset(&habits, 0, sizeof(habits));
check_int("add conflict source habit",
habits_add_custom(&habits, "Meditation",
(Color){224, 124, 104, 255},
INBE_HABIT_SYNC_NONE, 0),
0);
storage_set_setting_text("language", "");
storage_close();
insert_raw_habit_day(source, "habit-1", 20260618, 0);
check_true("reopen conflict source", storage_init(source));
check_true("conflict source export", storage_export_zip(zip_path));
storage_close();
check_true("init conflict dest", storage_init(dest));
memset(&habits, 0, sizeof(habits));
check_int("add conflict dest habit",
habits_add_custom(&habits, "Meditation",
(Color){126, 183, 230, 255},
INBE_HABIT_SYNC_NONE, 0),
0);
habit_set_day(&habits, 0, 20260618, 1);
habits_save(&habits);
storage_set_setting_text("language", "en");
check_true("conflict import",
storage_import_zip_ex(zip_path, INBE_STORAGE_IMPORT_DATA_AND_SETTINGS));
memset(&habits, 0, sizeof(habits));
check_true("conflict habits load", storage_habits_load(&habits));
habit = find_habit_ci(&habits, "Meditation");
check_true("conflict keeps completed day",
habit != NULL && habit_completed_day(habit, 20260618));
check_str("conflict keeps non-empty setting",
storage_get_setting_text("language"), "en");
storage_close();
remove_tree(source);
remove_tree(dest);
}
static void
test_delete_all_resets_habits_to_empty_storage(void)
{
char root[512];
InbeHabits habits;
long long deleted;
make_clean_root(root, sizeof(root), "delete-all");
check_true("init delete all db", storage_init(root));
memset(&habits, 0, sizeof(habits));
check_int("add delete all habit",
habits_add_custom(&habits, "Work out",
(Color){99, 196, 165, 255},
INBE_HABIT_SYNC_NONE, 0),
0);
habit_set_day(&habits, 0, 20260618, 1);
habits_save(&habits);
check_int("delete all habit count before", storage_habit_count(), 1);
check_true("delete all sees habit-only data", storage_has_any());
deleted = storage_delete_all_sessions();
check_true("delete all removed habit data", deleted >= 2);
check_int("delete all habit count after", storage_habit_count(), 0);
check_true("delete all hides active data", !storage_has_any());
habits_add_default_set(&habits);
memset(&habits, 0, sizeof(habits));
check_true("load default habit after delete all", storage_habits_load(&habits));
check_int("default habit count after delete all", habits.count, 1);
check_true("default meditation after delete all",
strcmp(habits.items[0].name, "Meditation") == 0);
check_true("old workout day removed",
!habit_completed_day(&habits.items[0], 20260618));
storage_close();
remove_tree(root);
}
static void
write_multi_habit_source_database(const char *root, const char *zip_path)
{
int rounds[] = {77};
InbeHabits habits;
check_true("init multi habit source", storage_init(root));
check_true("init multi habit source", inbe_storage_init(root));
check_true("save multi habit source session",
storage_save_session_for_activity(rounds, 1, 0, 1, NULL, 0));
inbe_storage_save_session_for_activity(rounds, 1, 0, 1, NULL, 0));
memset(&habits, 0, sizeof(habits));
check_int("add meditation habit",
habits_add_custom(&habits, "Meditation",
inbe_habits_add_custom(&habits, "Meditation",
(Color){224, 124, 104, 255},
INBE_HABIT_SYNC_ACTIVITIES,
(1 << 0) | (1 << 1)),
0);
check_int("add push ups habit",
habits_add_custom(&habits, "Push ups",
inbe_habits_add_custom(&habits, "Push ups",
(Color){180, 132, 220, 255},
INBE_HABIT_SYNC_NONE, 0),
1);
check_int("add cold shower habit",
habits_add_custom(&habits, "Cold Shower",
inbe_habits_add_custom(&habits, "Cold Shower",
(Color){99, 196, 165, 255},
INBE_HABIT_SYNC_NONE, 0),
2);
habit_set_day(&habits, 0, 20260617, 1);
habits_save(&habits);
habit_set_day(&habits, 1, 20260617, 1);
habits_save(&habits);
habit_set_day(&habits, 2, 20260617, 1);
habits_save(&habits);
storage_set_setting_int("speed", 7);
storage_set_setting_text("language", "en");
storage_set_setting_text("future_unknown_key", "ignore-me");
check_true("export multi habit source", storage_export_zip(zip_path));
storage_close();
inbe_habit_set_day(&habits, 0, 20260617, 1);
inbe_habit_set_day(&habits, 1, 20260617, 1);
inbe_habit_set_day(&habits, 2, 20260617, 1);
inbe_storage_set_setting_int("speed", 7);
inbe_storage_set_setting_text("language", "en");
inbe_storage_set_setting_text("future_unknown_key", "ignore-me");
check_true("export multi habit source", inbe_storage_export_zip(zip_path));
inbe_storage_close();
}
static void
@@ -789,10 +380,10 @@ assert_multi_habits_imported(const char *root, int want_speed)
InbeHabits habits;
InbeHabit *habit;
check_true("init multi habit import db", storage_init(root));
check_int("multi habit imported sessions", storage_session_count(), 1);
check_true("init multi habit import db", inbe_storage_init(root));
check_int("multi habit imported sessions", inbe_storage_session_count(), 1);
memset(&habits, 0, sizeof(habits));
check_true("multi habit load", storage_habits_load(&habits));
check_true("multi habit load", inbe_storage_habits_load(&habits));
check_int("multi habit count", habits.count, 3);
habit = find_habit_ci(&habits, "Meditation");
check_true("multi meditation exists", habit != NULL);
@@ -803,18 +394,18 @@ assert_multi_habits_imported(const char *root, int want_speed)
habit != NULL ? habit->sync_activity : -1,
(1 << 0) | (1 << 1));
check_true("multi meditation day",
habit != NULL && habit_completed_day(habit, 20260617));
habit != NULL && inbe_habit_completed_day(habit, 20260617));
habit = find_habit_ci(&habits, "Push ups");
check_true("multi push ups day",
habit != NULL && habit_completed_day(habit, 20260617));
habit != NULL && inbe_habit_completed_day(habit, 20260617));
habit = find_habit_ci(&habits, "Cold Shower");
check_true("multi cold shower day",
habit != NULL && habit_completed_day(habit, 20260617));
habit != NULL && inbe_habit_completed_day(habit, 20260617));
check_int("multi import speed setting",
storage_get_setting_int("speed", -1), want_speed);
inbe_storage_get_setting_int("speed", -1), want_speed);
check_str("multi import unknown setting",
storage_get_setting_text("future_unknown_key"), NULL);
storage_close();
inbe_storage_get_setting_text("future_unknown_key"), NULL);
inbe_storage_close();
}
static void
@@ -829,25 +420,25 @@ test_import_modes_preserve_habits_and_settings_choice(void)
make_path(zip_path, sizeof(zip_path), source, "multi-export.zip");
write_multi_habit_source_database(source, zip_path);
check_true("init inspect dest", storage_init(dest_data));
check_true("init inspect dest", inbe_storage_init(dest_data));
memset(&info, 0, sizeof(info));
check_true("inspect multi export", storage_inspect_import(zip_path, &info));
check_true("inspect multi export", inbe_storage_inspect_import(zip_path, &info));
check_true("inspect valid", info.valid);
check_true("inspect sessions", info.has_sessions);
check_true("inspect habits", info.has_habits);
check_true("inspect settings", info.has_settings);
check_int("inspect habit count", info.habit_count, 3);
storage_set_setting_int("speed", 1);
inbe_storage_set_setting_int("speed", 1);
check_true("multi data only import",
storage_import_zip_ex(zip_path, INBE_STORAGE_IMPORT_DATA_ONLY));
storage_close();
inbe_storage_import_zip_ex(zip_path, INBE_STORAGE_IMPORT_DATA_ONLY));
inbe_storage_close();
assert_multi_habits_imported(dest_data, 1);
check_true("init settings import dest", storage_init(dest_settings));
storage_set_setting_int("speed", 1);
check_true("init settings import dest", inbe_storage_init(dest_settings));
inbe_storage_set_setting_int("speed", 1);
check_true("multi data settings import",
storage_import_zip_ex(zip_path, INBE_STORAGE_IMPORT_DATA_AND_SETTINGS));
storage_close();
inbe_storage_import_zip_ex(zip_path, INBE_STORAGE_IMPORT_DATA_AND_SETTINGS));
inbe_storage_close();
assert_multi_habits_imported(dest_settings, 7);
remove_tree(source);
@@ -886,15 +477,15 @@ test_legacy_zip_import(void)
make_path(zip_path, sizeof(zip_path), source, "legacy.zip");
write_legacy_zip(zip_path, "custom-root");
check_true("init legacy import dest", storage_init(dest));
check_true("legacy zip import", storage_import_zip(zip_path));
check_int("legacy imported sessions", storage_session_count(), 1);
check_true("init legacy import dest", inbe_storage_init(dest));
check_true("legacy zip import", inbe_storage_import_zip(zip_path));
check_int("legacy imported sessions", inbe_storage_session_count(), 1);
g_seen_round_count = -1;
g_seen_first_round = -1;
storage_list_session_records(legacy_history_callback, NULL);
inbe_storage_list_session_records(legacy_history_callback, NULL);
check_int("legacy round count", g_seen_round_count, 4);
check_int("legacy first round", g_seen_first_round, 31);
storage_close();
inbe_storage_close();
remove_tree(source);
remove_tree(dest);
@@ -923,18 +514,18 @@ test_legacy_file_startup_migration(void)
make_path(session_path, sizeof(session_path), root, "2026/06/13/inbe-010203");
write_text_file(session_path, "31\n35\n39\n27\n");
check_true("init legacy file migration db", storage_init(root));
check_int("legacy file migrated sessions", storage_session_count(), 1);
check_true("init legacy file migration db", inbe_storage_init(root));
check_int("legacy file migrated sessions", inbe_storage_session_count(), 1);
g_seen_round_count = -1;
g_seen_first_round = -1;
storage_list_session_records(legacy_history_callback, NULL);
inbe_storage_list_session_records(legacy_history_callback, NULL);
check_int("legacy file round count", g_seen_round_count, 4);
check_int("legacy file first round", g_seen_first_round, 31);
storage_close();
inbe_storage_close();
check_true("reopen migrated db", storage_init(root));
check_int("legacy file migration one session", storage_session_count(), 1);
storage_close();
check_true("reopen migrated db", inbe_storage_init(root));
check_int("legacy file migration one session", inbe_storage_session_count(), 1);
inbe_storage_close();
remove_tree(root);
}
@@ -942,7 +533,6 @@ static void
write_tickmate_database(const char *path)
{
sqlite3 *db = NULL;
sqlite3_stmt *stmt = NULL;
char *error = NULL;
check_true("open tickmate db", sqlite3_open(path, &db) == SQLITE_OK);
@@ -957,56 +547,15 @@ write_tickmate_database(const char *path)
"CREATE TABLE ticks(_id integer primary key autoincrement,"
"_track_id integer,year integer,month integer,day integer,"
"hour integer,minute integer,second integer,has_time_info integer DEFAULT 0);"
"INSERT INTO tracks(_id,name,description,icon,enabled,multiple_entries_per_day,color,\"order\") "
"VALUES(1,'Meditation','Silenced my mind','',1,1,8925,0);"
"INSERT INTO tracks(_id,name,description,icon,enabled,color,\"order\") "
"VALUES(1,'Meditation','Silenced my mind','',1,8925,0);"
"INSERT INTO ticks(_track_id,year,month,day,hour,minute,second,has_time_info) "
"VALUES(1,2026,0,1,0,0,0,0),"
"(1,2026,1,2,0,0,0,0),"
"(1,2026,2,3,0,0,0,0),"
"(1,2026,3,4,0,0,0,0),"
"(1,2026,4,5,0,0,0,0),"
"(1,2026,5,6,0,0,0,0),"
"(1,2026,6,7,0,0,0,0),"
"(1,2026,7,8,0,0,0,0),"
"(1,2026,8,9,0,0,0,0),"
"(1,2026,9,10,0,0,0,0),"
"(1,2026,10,11,0,0,0,0),"
"(1,2026,11,12,0,0,0,0),"
"(1,2025,0,1,0,0,0,0),"
"(1,2025,0,1,0,0,0,0);",
"VALUES(1,2026,6,13,0,0,0,0);",
NULL, NULL, &error) == SQLITE_OK);
if(error != NULL) {
fprintf(stderr, "tickmate setup SQL error: %s\n", error);
sqlite3_free(error);
}
check_true("prepare large tickmate insert",
sqlite3_prepare_v2(db,
"INSERT INTO ticks(_track_id,year,month,day,hour,minute,second,has_time_info) "
"VALUES(1,?1,?2,?3,0,0,0,0)",
-1, &stmt, NULL) == SQLITE_OK);
if(stmt != NULL) {
struct tm day;
check_true("begin large tickmate insert", sqlite3_exec(db, "BEGIN", NULL, NULL, NULL) == SQLITE_OK);
memset(&day, 0, sizeof(day));
day.tm_year = 2025 - 1900;
day.tm_mon = 0;
day.tm_mday = 1;
day.tm_hour = 12;
mktime(&day);
for(int i = 0; i < 12000; i++) {
sqlite3_reset(stmt);
sqlite3_clear_bindings(stmt);
sqlite3_bind_int(stmt, 1, day.tm_year + 1900);
sqlite3_bind_int(stmt, 2, day.tm_mon);
sqlite3_bind_int(stmt, 3, day.tm_mday);
check_true("large tickmate insert row", sqlite3_step(stmt) == SQLITE_DONE);
day.tm_mday++;
mktime(&day);
}
check_true("commit large tickmate insert", sqlite3_exec(db, "COMMIT", NULL, NULL, NULL) == SQLITE_OK);
sqlite3_finalize(stmt);
}
sqlite3_close(db);
}
@@ -1021,113 +570,29 @@ test_tickmate_db_import(void)
make_path(db_path, sizeof(db_path), source, "tickmate.db");
write_tickmate_database(db_path);
check_true("init tickmate import dest", storage_init(dest));
check_true("tickmate db import", storage_import_zip(db_path));
check_true("init tickmate import dest", inbe_storage_init(dest));
check_true("tickmate db import", inbe_storage_import_zip(db_path));
memset(&habits, 0, sizeof(habits));
check_true("tickmate habits load", storage_habits_load(&habits));
check_true("tickmate habits load", inbe_storage_habits_load(&habits));
check_int("tickmate habit count", habits.count, 1);
check_true("tickmate january day", habit_completed_day(&habits.items[0], 20260101));
check_true("tickmate february day", habit_completed_day(&habits.items[0], 20260202));
check_true("tickmate march day", habit_completed_day(&habits.items[0], 20260303));
check_true("tickmate april day", habit_completed_day(&habits.items[0], 20260404));
check_true("tickmate may day", habit_completed_day(&habits.items[0], 20260505));
check_true("tickmate june day", habit_completed_day(&habits.items[0], 20260606));
check_true("tickmate july day", habit_completed_day(&habits.items[0], 20260707));
check_true("tickmate august day", habit_completed_day(&habits.items[0], 20260808));
check_true("tickmate september day", habit_completed_day(&habits.items[0], 20260909));
check_true("tickmate october day", habit_completed_day(&habits.items[0], 20261010));
check_true("tickmate november day", habit_completed_day(&habits.items[0], 20261111));
check_true("tickmate december day", habit_completed_day(&habits.items[0], 20261212));
check_true("tickmate loads thousands of days",
habit_completed_day(&habits.items[0], 20571108));
check_true("tickmate habit day", inbe_habit_completed_day(&habits.items[0], 20260613));
check_true("tickmate habit name", strcmp(habits.items[0].name, "Meditation") == 0);
check_int("tickmate enables counter habit", habits.items[0].counter_enabled, 1);
check_int("tickmate imports count", habit_day_count(&habits.items[0], 20250101), 3);
storage_close();
inbe_storage_close();
remove_tree(source);
remove_tree(dest);
}
static void
test_tickmate_reimport_recovers_counter_data(void)
{
char source[512], dest[512], db_path[512];
InbeHabits habits;
make_clean_root(source, sizeof(source), "tickmate-reimport-source");
make_clean_root(dest, sizeof(dest), "tickmate-reimport-dest");
make_path(db_path, sizeof(db_path), source, "tickmate.db");
write_tickmate_database(db_path);
check_true("init tickmate reimport dest", storage_init(dest));
memset(&habits, 0, sizeof(habits));
check_int("add old boolean meditation",
habits_add_custom(&habits, "Meditation",
(Color){99, 196, 165, 255},
INBE_HABIT_SYNC_NONE, 0),
0);
habit_set_day(&habits, 0, 20250101, 1);
habits_save(&habits);
check_true("tickmate reimport", storage_import_zip(db_path));
memset(&habits, 0, sizeof(habits));
check_true("tickmate reimport load", storage_habits_load(&habits));
check_int("tickmate reimport habit count", habits.count, 1);
check_int("tickmate reimport enables counter", habits.items[0].counter_enabled, 1);
check_int("tickmate reimport restores count",
habit_day_count(&habits.items[0], 20250101), 3);
storage_close();
remove_tree(source);
remove_tree(dest);
}
static void
test_external_tickmate_db_import(void)
{
const char *db_path = getenv("INBE_TICKMATE_IMPORT_FIXTURE");
char dest[512];
InbeStorageImportInfo info;
InbeHabits habits;
if(db_path == NULL || db_path[0] == '\0')
return;
make_clean_root(dest, sizeof(dest), "external-tickmate-dest");
check_true("init external tickmate import dest", storage_init(dest));
memset(&info, 0, sizeof(info));
check_true("inspect external tickmate db", storage_inspect_import(db_path, &info));
check_true("external tickmate db valid", info.valid);
check_true("external tickmate db has habits", info.has_habits);
check_true("external tickmate db import", storage_import_zip(db_path));
memset(&habits, 0, sizeof(habits));
check_true("external tickmate habits load", storage_habits_load(&habits));
check_true("external tickmate habit count", habits.count > 0);
storage_close();
remove_tree(dest);
}
int
main(void)
{
test_raw_db_import();
test_zip_db_import();
test_habit_name_merge_import();
test_import_conflict_prefers_data_over_empty();
test_delete_all_resets_habits_to_empty_storage();
test_import_modes_preserve_habits_and_settings_choice();
test_legacy_zip_import();
test_legacy_file_startup_migration();
test_tickmate_db_import();
test_tickmate_reimport_recovers_counter_data();
test_external_tickmate_db_import();
test_sync_payload_omits_uploaded_state_after_upload_marker();
test_sync_payload_includes_queued_current_edits();
test_sync_outbox_preserves_edits_after_snapshot();
test_sync_apply_preserves_counter_counts();
test_session_linked_counts_materialize_for_sync();
test_existing_sessions_materialize_after_habit_save();
test_session_metadata();
if(g_failures != 0) {
-321
View File
@@ -1,321 +0,0 @@
#include "sync_account.h"
#include "storage.h"
#include <dirent.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.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_str(const char *label, const char *got, const char *want)
{
if(got != NULL && want != NULL && strcmp(got, want) == 0)
return;
fprintf(stderr, "FAIL %s: got %s, want %s\n",
label, got != NULL ? got : "(null)", want != NULL ? want : "(null)");
g_failures++;
}
static int
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-account-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 void
bytes_to_hex_local(const unsigned char *bytes, size_t len, char *out, size_t out_size)
{
static const char hex[] = "0123456789abcdef";
check_true("hex output size", out_size >= len * 2 + 1);
for(size_t i = 0; i < len; i++) {
out[i * 2] = hex[bytes[i] >> 4];
out[i * 2 + 1] = hex[bytes[i] & 0x0f];
}
out[len * 2] = '\0';
}
static void
write_key_file(const char *path, const char *public_id,
const char *public_key, const char *private_key)
{
FILE *file = fopen(path, "wb");
check_true("open key file", file != NULL);
if(file == NULL)
return;
fprintf(file,
"inbe-sync-key-v1\nalgorithm=ML-DSA-44\npublic_id=%s\npublic_key=%s\nprivate_key=%s\n",
public_id, public_key, private_key);
fclose(file);
}
static void
make_account_values(char public_id[65], char public_key_hex[2625],
char private_key_hex[5121])
{
unsigned char public_key[1312];
unsigned char private_key[2560];
for(size_t i = 0; i < sizeof(public_key); i++)
public_key[i] = (unsigned char)(i * 31U + 7U);
for(size_t i = 0; i < sizeof(private_key); i++)
private_key[i] = (unsigned char)(i * 17U + 3U);
sync_sha256_hex(public_key, sizeof(public_key), public_id);
bytes_to_hex_local(public_key, sizeof(public_key), public_key_hex, 2625);
bytes_to_hex_local(private_key, sizeof(private_key), private_key_hex, 5121);
}
static void
test_import_export_clear(void)
{
char root[512];
char key_path[1024];
char export_path[1024];
char public_id[65];
char public_key[2625];
char private_key[5121];
InbeSyncAccount account;
char *exported;
FILE *file;
make_clean_root(root, sizeof(root), "roundtrip");
snprintf(key_path, sizeof(key_path), "%s/inbe-sync.key", root);
snprintf(export_path, sizeof(export_path), "%s/exported.key", root);
make_account_values(public_id, public_key, private_key);
write_key_file(key_path, public_id, public_key, private_key);
check_true("init storage", storage_init(root));
check_true("import key", sync_account_import_private_key(&account, key_path));
check_str("import public id", account.public_id, public_id);
check_true("load imported key", sync_account_load(&account));
check_str("load public key", account.public_key_hex, public_key);
check_str("load private key", account.private_key_hex, private_key);
check_true("export key", sync_account_export_private_key(&account, export_path));
exported = LoadFileText(export_path);
check_true("read exported key", exported != NULL);
if(exported != NULL) {
check_true("export includes public key", strstr(exported, "\npublic_key=") != NULL);
UnloadFileText(exported);
}
check_true("clear key", sync_account_clear());
check_false("load after clear", sync_account_load(&account));
check_true("import exported key", sync_account_import_private_key(&account, export_path));
check_str("reimport public id", account.public_id, public_id);
file = fopen(key_path, "wb");
check_true("open secret key alias file", file != NULL);
if(file != NULL) {
fprintf(file,
"inbe-sync-key-v1\nalgorithm=ML-DSA-44\npublic_key=%s\nsecret_key=%s\n",
public_key, private_key);
fclose(file);
}
check_true("import secret key alias", sync_account_import_private_key(&account, key_path));
check_str("derive public id", account.public_id, public_id);
file = fopen(key_path, "wb");
check_true("open exported key json file", file != NULL);
if(file != NULL) {
fprintf(file,
"{\"exported_key\":\"inbe-sync-key-v1\\nalgorithm=ML-DSA-44\\npublic_id=%s\\npublic_key=%s\\nprivate_key=%s\\n\"}\n",
public_id, public_key, private_key);
fclose(file);
}
check_true("import exported key json", sync_account_import_private_key(&account, key_path));
check_str("json public key", account.public_key_hex, public_key);
storage_close();
remove_tree(root);
}
static void
test_reject_invalid_keys(void)
{
char root[512];
char key_path[1024];
char public_id[65];
char public_key[2625];
char private_key[5121];
InbeSyncAccount account;
FILE *file;
make_clean_root(root, sizeof(root), "invalid");
snprintf(key_path, sizeof(key_path), "%s/inbe-sync.key", root);
make_account_values(public_id, public_key, private_key);
check_true("init invalid storage", storage_init(root));
public_id[0] = public_id[0] == '0' ? '1' : '0';
write_key_file(key_path, public_id, public_key, private_key);
check_false("reject mismatched public id",
sync_account_import_private_key(&account, key_path));
file = fopen(key_path, "wb");
check_true("open missing public key file", file != NULL);
if(file != NULL) {
fprintf(file,
"inbe-sync-key-v1\nalgorithm=ML-DSA-44\npublic_id=%s\nprivate_key=%s\n",
public_id, private_key);
fclose(file);
}
check_false("reject missing public key",
sync_account_import_private_key(&account, key_path));
check_false("no account after rejected imports", sync_account_load(&account));
storage_close();
remove_tree(root);
}
int
main(void)
{
test_import_export_clear();
test_reject_invalid_keys();
if(g_failures != 0) {
fprintf(stderr, "%d sync account test failure(s)\n", g_failures);
return 1;
}
printf("sync account tests passed\n");
return 0;
}
-80
View File
@@ -1,80 +0,0 @@
#include "sync_client.h"
#include <stdio.h>
#include <string.h>
int sync_client_test_response_buffer(const char *first, const char *second,
char *out, size_t out_size);
static int failures = 0;
static void
check_valid(const char *input, const char *normalized)
{
char out[256];
if(!sync_client_url_valid(input)) {
fprintf(stderr, "FAIL valid %s\n", input);
failures++;
return;
}
if(!sync_client_normalize_url(input, out, sizeof(out)) ||
strcmp(out, normalized) != 0) {
fprintf(stderr, "FAIL normalize %s: got %s, want %s\n",
input, out, normalized);
failures++;
}
}
static void
check_invalid(const char *input)
{
char out[256];
if(sync_client_url_valid(input)) {
fprintf(stderr, "FAIL invalid accepted %s\n", input);
failures++;
}
if(sync_client_normalize_url(input, out, sizeof(out))) {
fprintf(stderr, "FAIL invalid normalized %s to %s\n", input, out);
failures++;
}
}
static void
check_response_buffer(void)
{
char out[64];
if(!sync_client_test_response_buffer("{\"nonce\":\"", "abc\"}", out, sizeof(out)) ||
strcmp(out, "{\"nonce\":\"abc\"}") != 0) {
fprintf(stderr, "FAIL response buffer append: got %s\n", out);
failures++;
}
}
int
main(void)
{
check_valid("https://api.waozi.xyz", "https://api.waozi.xyz");
check_valid("http://localhost:8080", "http://localhost:8080");
check_valid("localhost:8080", "http://localhost:8080");
check_valid("localhost:3000", "http://localhost:3000");
check_valid("127.0.0.1:8080", "http://127.0.0.1:8080");
check_valid("127.0.0.1:49152", "http://127.0.0.1:49152");
check_valid("10.0.2.2:8080", "http://10.0.2.2:8080");
check_invalid("");
check_invalid("localhost.evil.test:8080");
check_invalid("http://localhost.evil.test");
check_invalid("http://example.com");
check_response_buffer();
if(failures != 0) {
fprintf(stderr, "%d sync URL test failure(s)\n", failures);
return 1;
}
printf("sync URL tests passed\n");
return 0;
}
Vendored
-1
Submodule vendor/curl deleted from bb837dda23.
-1
Submodule vendor/liboqs deleted from d95fc734f5.
+4 -4
View File
@@ -3,8 +3,8 @@
IDI_APP_ICON ICON "inbe.ico"
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,4,3,0
PRODUCTVERSION 1,4,3,0
FILEVERSION 1,3,4,0
PRODUCTVERSION 1,3,4,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@@ -21,11 +21,11 @@ BEGIN
BEGIN
VALUE "CompanyName", "waozi"
VALUE "FileDescription", "Inner Breeze"
VALUE "FileVersion", "1.4.3"
VALUE "FileVersion", "1.3.4"
VALUE "InternalName", "inbe"
VALUE "OriginalFilename", "inbe-windows-x86_64.exe"
VALUE "ProductName", "Inner Breeze"
VALUE "ProductVersion", "1.4.3"
VALUE "ProductVersion", "1.3.4"
END
END
BLOCK "VarFileInfo"