Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f12ef05421 | ||
|
|
1732b31031 | ||
|
|
b14ca1c8c9 | ||
|
|
9466bf02ed | ||
|
|
acbd43bc65 | ||
|
|
06d79002e1 | ||
|
|
2db5045efb | ||
|
|
0f6f40cb0a | ||
|
|
b9ec755e1f | ||
|
|
fc75410dea | ||
|
|
4083893ddc | ||
|
|
07a2315353 | ||
|
|
195eef42a9 | ||
|
|
e22ae0f8aa | ||
|
|
460ac28e0a | ||
|
|
40b0121c81 | ||
|
|
f49dbc2015 | ||
|
|
bab61346be | ||
|
|
2c9348c52a | ||
|
|
209be9e78b | ||
|
|
28a5d8fa51 | ||
|
|
d356cc078f | ||
|
|
e31ff91168 | ||
|
|
7728a6327e | ||
|
|
945943dceb | ||
|
|
e567ba21c2 | ||
|
|
0ddb4ddfb8 | ||
|
|
27e1902958 | ||
|
|
2e83575485 | ||
|
|
bf26a1056f | ||
|
|
3b44d1bc1a | ||
|
|
cafe058420 | ||
|
|
b0a031136b | ||
|
|
06d403ed63 | ||
|
|
1d0009958d | ||
|
|
2c0ac20ce3 | ||
|
|
9181c91a3a | ||
|
|
63e790f96a | ||
|
|
aef5f5441b | ||
|
|
827d5e350b | ||
|
|
f64195ec1d | ||
|
|
60b699f28b | ||
|
|
85b9d3daf5 | ||
|
|
89bb5a63ca | ||
|
|
94c004b923 | ||
|
|
9822180288 | ||
|
|
0976fb82bc | ||
|
|
8353f49f27 | ||
|
|
07b46d7bf0 | ||
|
|
99375c9c4b | ||
|
|
1381311e02 | ||
|
|
595f239015 | ||
|
|
d43a8de800 | ||
|
|
894f8f7da8 | ||
|
|
629aa739f6 | ||
|
|
323be33ec4 | ||
|
|
64480683d6 | ||
|
|
2a4d93f3b6 | ||
|
|
61f5a75634 | ||
|
|
085ed5393d | ||
|
|
015843c4d6 | ||
|
|
5d335ff637 | ||
|
|
61731bd680 | ||
|
|
e3f6a22d24 | ||
|
|
e00245e212 | ||
|
|
951309c75f | ||
|
|
c3d36d8d28 | ||
|
|
a9b615614b | ||
|
|
0fb8630dc9 | ||
|
|
bda1bf536d | ||
|
|
7e27498379 | ||
|
|
08ef56d788 | ||
|
|
a3f92aaf5c | ||
|
|
447e2b6187 | ||
|
|
72fd21dad0 | ||
|
|
f9da10204d | ||
|
|
1549f5e3bc | ||
|
|
0c650fc94f | ||
|
|
52716b1edb | ||
|
|
9e40eda25e | ||
|
|
92985e8a03 | ||
|
|
5aedde8d80 | ||
|
|
eb25d437a4 | ||
|
|
7690e04429 | ||
|
|
07ca47ee7c | ||
|
|
7c3275fee3 | ||
|
|
249702ca32 | ||
|
|
2797b3371d | ||
|
|
bc7514406b | ||
|
|
79bcf2c328 | ||
|
|
b5962360c1 | ||
|
|
83ecc17423 | ||
|
|
f01c4d7d81 | ||
|
|
03b714aa64 | ||
|
|
5f116c29cb | ||
|
|
cdbdcd20cb | ||
|
|
6a3362f59e | ||
|
|
43013c64ab | ||
|
|
3f86abb35a | ||
|
|
3e75089266 | ||
|
|
d51fdea355 | ||
|
|
5bc63e7b13 | ||
|
|
03e1fccab3 | ||
|
|
ed2e52c13a | ||
|
|
616ef0cb09 | ||
|
|
e7debfc68f | ||
|
|
796f1393de | ||
|
|
99567e68c1 | ||
|
|
f714674e62 | ||
|
|
3d75216483 | ||
|
|
ac485ea355 | ||
|
|
ad59bb0c51 | ||
|
|
efbeec104d | ||
|
|
f9d109182d | ||
|
|
ccb8c2f2b5 | ||
|
|
2405fb2fcf | ||
|
|
8c25a6630b | ||
|
|
97dd375822 | ||
|
|
93103cc0ea | ||
|
|
a0ded8e537 | ||
|
|
1f8ada56f9 | ||
|
|
e80097fb83 | ||
|
|
4e0dedf97d | ||
|
|
675b2c260a | ||
|
|
463c858565 | ||
|
|
8b739fcbd4 | ||
|
|
7b23749f7d | ||
|
|
3c3eb9e0f2 | ||
|
|
a896ad4f55 | ||
|
|
19ad586e0c | ||
|
|
bdb1e92a51 | ||
|
|
8d1cf2b8f9 | ||
|
|
6547bd9636 | ||
|
|
8d9117bd16 | ||
|
|
695aafa231 | ||
|
|
88598d830f | ||
|
|
0be5f925a7 | ||
|
|
39096d0dd4 | ||
|
|
2242553194 | ||
|
|
5d6985b2b5 | ||
|
|
ba216da8e6 | ||
|
|
13c469166a | ||
|
|
e1298bd262 | ||
|
|
6c1eb327e3 | ||
|
|
3ff05eac4e | ||
|
|
93f1bae5b7 | ||
|
|
896f0b1c22 | ||
|
|
615e32b0c6 | ||
|
|
77093f27a0 | ||
|
|
c13b7e743d | ||
|
|
5e61ef5351 | ||
|
|
79f44d353b | ||
|
|
e22e3f98ef | ||
|
|
14d4594d71 | ||
|
|
899500307c | ||
|
|
50527f15b8 | ||
|
|
94218efc5e | ||
|
|
cf9ff9fb1f | ||
|
|
81410ea4ae | ||
|
|
2add9f0f30 | ||
|
|
8bbc5625b7 | ||
|
|
ccc2032c50 | ||
|
|
df3d04fa26 | ||
|
|
4c5c76e51e | ||
|
|
a3db764783 | ||
|
|
80b2214af3 | ||
|
|
96ef714ca8 | ||
|
|
d808bdf985 | ||
|
|
c448e5d429 | ||
|
|
d592c943f0 | ||
|
|
d90336d710 | ||
|
|
c135464530 | ||
|
|
45a360f498 | ||
|
|
0fad496a0e | ||
|
|
7642a146cc | ||
|
|
d1633381f4 | ||
|
|
2825a41d02 | ||
|
|
c86d2da631 | ||
|
|
99d2433283 | ||
|
|
1650d50c72 |
No files matched your search
@@ -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
|
||||
@@ -0,0 +1,106 @@
|
||||
name: Android Build
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
release:
|
||||
name: Build Release APK
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up JDK 21
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: '21'
|
||||
|
||||
- name: Setup Gradle
|
||||
uses: gradle/actions/setup-gradle@v3
|
||||
|
||||
- name: Grant execute permission for gradlew
|
||||
run: chmod +x droid/gradlew
|
||||
|
||||
- name: Create keystore directory
|
||||
run: mkdir -p ~/.android
|
||||
|
||||
- name: Decode Keystore
|
||||
env:
|
||||
KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE64 }}
|
||||
run: |
|
||||
echo "$KEYSTORE_BASE64" | base64 -d > ~/.android/inbe-release.keystore
|
||||
echo "Keystore decoded successfully"
|
||||
|
||||
- name: Copy Assets to Android Project
|
||||
run: ./scripts/copy-android-assets.sh
|
||||
|
||||
- name: Run Tests
|
||||
run: make test
|
||||
|
||||
- name: Build Release APK
|
||||
working-directory: ./droid
|
||||
env:
|
||||
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
|
||||
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
|
||||
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
|
||||
run: |
|
||||
./gradlew assembleRelease \
|
||||
-Pkeystore.password="$KEYSTORE_PASSWORD" \
|
||||
-Pkeystore.path="/home/runner/.android/inbe-release.keystore" \
|
||||
--stacktrace
|
||||
|
||||
- name: Rename APK
|
||||
run: |
|
||||
VERSION=$(grep "versionName" droid/app/build.gradle | awk '{print $2}' | tr -d '"')
|
||||
find droid/app/build/outputs/apk/release -name "*-universal-release.apk" -exec cp {} inbe-$VERSION.apk \; 2>/dev/null || true
|
||||
|
||||
- name: Upload APK to Artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: release-apk
|
||||
path: inbe-*.apk
|
||||
if-no-files-found: warn
|
||||
|
||||
- name: Create and Push Tag (if new version)
|
||||
id: tag_version
|
||||
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
|
||||
run: |
|
||||
VERSION=$(grep "versionName" droid/app/build.gradle | awk '{print $2}' | tr -d '"')
|
||||
TAG="v$VERSION"
|
||||
if git rev-parse "$TAG" >/dev/null 2>&1; then
|
||||
echo "Tag $TAG exists, skipping"
|
||||
echo "tag_pushed=false" >> $GITHUB_OUTPUT
|
||||
else
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||
git tag -a "$TAG" -m "Release $VERSION"
|
||||
git push origin "$TAG"
|
||||
echo "tag_pushed=true" >> $GITHUB_OUTPUT
|
||||
echo "tag_name=$TAG" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
- name: Create GitHub Release
|
||||
if: steps.tag_version.outputs.tag_pushed == 'true'
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
tag_name: ${{ steps.tag_version.outputs.tag_name }}
|
||||
files: inbe-*.apk
|
||||
generate_release_notes: true
|
||||
draft: false
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -1,37 +0,0 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
test:
|
||||
name: Test
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Install Test Dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y build-essential zlib1g-dev
|
||||
|
||||
- name: Run Tests
|
||||
run: make test
|
||||
@@ -1,320 +0,0 @@
|
||||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
test:
|
||||
name: Test
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Install Test Dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y build-essential zlib1g-dev
|
||||
|
||||
- name: Run Tests
|
||||
run: make test
|
||||
|
||||
build-web:
|
||||
name: Build Web
|
||||
runs-on: ubuntu-latest
|
||||
needs: test
|
||||
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Install Web Dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y build-essential zlib1g-dev zip
|
||||
|
||||
- name: Set up Emscripten
|
||||
run: |
|
||||
set -euo pipefail
|
||||
git clone --depth 1 https://github.com/emscripten-core/emsdk.git "$HOME/emsdk"
|
||||
"$HOME/emsdk/emsdk" install latest
|
||||
"$HOME/emsdk/emsdk" activate latest
|
||||
echo "EMSDK=$HOME/emsdk" >> "$GITHUB_ENV"
|
||||
echo "EM_CONFIG=$HOME/emsdk/.emscripten" >> "$GITHUB_ENV"
|
||||
echo "$HOME/emsdk" >> "$GITHUB_PATH"
|
||||
echo "$HOME/emsdk/upstream/emscripten" >> "$GITHUB_PATH"
|
||||
|
||||
- name: Build Web ZIP
|
||||
run: |
|
||||
set -euo pipefail
|
||||
make package-unpackaged-assets
|
||||
make web
|
||||
mkdir -p build/release/web
|
||||
cp build/dist/inbe-web.zip build/release/web/
|
||||
|
||||
- name: Upload Web Artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: release-web
|
||||
path: build/release/web/*
|
||||
if-no-files-found: error
|
||||
|
||||
build-linux:
|
||||
name: Build Linux
|
||||
runs-on: ubuntu-latest
|
||||
needs: test
|
||||
env:
|
||||
APT_CACHE_DIR: /tmp/apt-cache
|
||||
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
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"
|
||||
|
||||
- name: Install AppImage Tools
|
||||
run: |
|
||||
set -euo pipefail
|
||||
mkdir -p "$HOME/.local/bin"
|
||||
curl -L -o "$HOME/.local/bin/linuxdeploy" \
|
||||
https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage
|
||||
curl -L -o "$HOME/.local/bin/linuxdeploy-plugin-appimage" \
|
||||
https://github.com/linuxdeploy/linuxdeploy-plugin-appimage/releases/download/1-alpha-20250213-1/linuxdeploy-plugin-appimage-x86_64.AppImage
|
||||
curl -L -o "$HOME/.local/bin/appimagetool" \
|
||||
https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage
|
||||
chmod +x "$HOME/.local/bin/linuxdeploy" "$HOME/.local/bin/linuxdeploy-plugin-appimage" "$HOME/.local/bin/appimagetool"
|
||||
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
|
||||
|
||||
- name: Build Linux AppImage
|
||||
env:
|
||||
APPIMAGE_EXTRACT_AND_RUN: "1"
|
||||
RAY_RAYLIB_CONFIG: -DSUPPORT_SCREEN_CAPTURE=0 -DSUPPORT_COMPRESSION_API=0 -DSUPPORT_AUTOMATION_EVENTS=0 -DSUPPORT_CLIPBOARD_IMAGE=0 -DSUPPORT_FILEFORMAT_BMP=0 -DSUPPORT_FILEFORMAT_GIF=0 -DSUPPORT_FILEFORMAT_QOI=0 -DSUPPORT_FILEFORMAT_DDS=0 -DSUPPORT_FILEFORMAT_TTF=0
|
||||
run: |
|
||||
set -euo pipefail
|
||||
RAY_SDL_INCLUDE_DIR="$(pkg-config --variable=includedir sdl2 | sed 's,/SDL2$,,')"
|
||||
RAY_CFLAGS="$(pkg-config --cflags sdl2 libdrm gbm egl glesv2)"
|
||||
RAY_LDLIBS="$(pkg-config --libs sdl2 libdrm gbm egl glesv2)"
|
||||
RAY_SDL_LDLIBS="$(pkg-config --libs sdl2)"
|
||||
export RAY_SDL_INCLUDE_DIR RAY_CFLAGS RAY_LDLIBS RAY_SDL_LDLIBS
|
||||
make appimage
|
||||
mkdir -p build/release/linux
|
||||
find build/dist/linux -maxdepth 1 -type f -name '*.AppImage' -exec cp {} build/release/linux/ \;
|
||||
test -n "$(find build/release/linux -type f -print -quit)"
|
||||
|
||||
- name: Upload Linux Artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: release-linux
|
||||
path: build/release/linux/*
|
||||
if-no-files-found: error
|
||||
|
||||
build-windows:
|
||||
name: Build Windows
|
||||
runs-on: ubuntu-latest
|
||||
needs: test
|
||||
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Install Windows Dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y \
|
||||
build-essential \
|
||||
gcc-mingw-w64-i686-win32 \
|
||||
gcc-mingw-w64-x86-64-win32 \
|
||||
zlib1g-dev \
|
||||
zip
|
||||
if [ -x /usr/bin/x86_64-w64-mingw32-gcc-win32 ]; then
|
||||
sudo update-alternatives --set x86_64-w64-mingw32-gcc /usr/bin/x86_64-w64-mingw32-gcc-win32
|
||||
fi
|
||||
if [ -x /usr/bin/i686-w64-mingw32-gcc-win32 ]; then
|
||||
sudo update-alternatives --set i686-w64-mingw32-gcc /usr/bin/i686-w64-mingw32-gcc-win32
|
||||
fi
|
||||
|
||||
- name: Build Windows ZIP
|
||||
run: |
|
||||
set -euo pipefail
|
||||
make windows
|
||||
mkdir -p build/release/windows
|
||||
find build/dist/windows -maxdepth 1 -type f -name '*.zip' -exec cp {} build/release/windows/ \;
|
||||
test -n "$(find build/release/windows -type f -print -quit)"
|
||||
|
||||
- name: Upload Windows Artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: release-windows
|
||||
path: build/release/windows/*
|
||||
if-no-files-found: error
|
||||
|
||||
build-android:
|
||||
name: Build Android
|
||||
runs-on: ubuntu-latest
|
||||
needs: test
|
||||
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up JDK 21
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: '21'
|
||||
|
||||
- name: Setup Gradle
|
||||
uses: gradle/actions/setup-gradle@v3
|
||||
|
||||
- name: Install Android SDK Components
|
||||
run: |
|
||||
set -euo pipefail
|
||||
SDKMANAGER="$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager"
|
||||
yes | "$SDKMANAGER" --licenses >/dev/null || true
|
||||
"$SDKMANAGER" "platforms;android-35" "build-tools;34.0.0" "ndk;25.1.8937393" "cmake;3.22.1"
|
||||
|
||||
- name: Prepare Android signing key
|
||||
env:
|
||||
KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE64 }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
mkdir -p ~/.android
|
||||
echo "$KEYSTORE_BASE64" | base64 -d > ~/.android/inbe-release.keystore
|
||||
|
||||
- name: Copy Android Assets
|
||||
run: ./scripts/copy-android-assets.sh
|
||||
|
||||
- name: Build Android APK
|
||||
env:
|
||||
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
|
||||
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
chmod +x droid/gradlew
|
||||
./droid/gradlew -p droid assembleRelease \
|
||||
-Pkeystore.path="$HOME/.android/inbe-release.keystore" \
|
||||
-Pkeystore.alias="$KEY_ALIAS" \
|
||||
-Pkeystore.password="$KEYSTORE_PASSWORD" \
|
||||
--stacktrace
|
||||
make android-copy-release-apks
|
||||
|
||||
- name: Collect Android Release Files
|
||||
run: |
|
||||
set -euo pipefail
|
||||
mkdir -p build/release/android
|
||||
VERSION=$(sed -n 's/^#define INBE_VERSION_STRING "\([^"]*\)".*/\1/p' src/core/version.h)
|
||||
if [ -z "$VERSION" ]; then
|
||||
echo "Could not read INBE_VERSION_STRING"
|
||||
exit 1
|
||||
fi
|
||||
cp "build/android/inbe-$VERSION.apk" build/release/android/
|
||||
|
||||
- name: Upload Android Artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: release-android
|
||||
path: build/release/android/*
|
||||
if-no-files-found: error
|
||||
|
||||
release:
|
||||
name: Release
|
||||
runs-on: ubuntu-latest
|
||||
needs:
|
||||
- build-web
|
||||
- build-linux
|
||||
- build-windows
|
||||
- build-android
|
||||
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Download Release Artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
pattern: release-*
|
||||
path: build/release
|
||||
merge-multiple: true
|
||||
|
||||
- name: Verify Release Artifacts
|
||||
run: |
|
||||
set -euo pipefail
|
||||
test -n "$(find build/release -type f -print -quit)"
|
||||
|
||||
- name: Create and Push Tag If Version Is New
|
||||
id: tag_version
|
||||
run: |
|
||||
set -euo pipefail
|
||||
VERSION=$(sed -n 's/^#define INBE_VERSION_STRING "\([^"]*\)".*/\1/p' src/core/version.h)
|
||||
if [ -z "$VERSION" ]; then
|
||||
echo "Could not read INBE_VERSION_STRING"
|
||||
exit 1
|
||||
fi
|
||||
TAG="v$VERSION"
|
||||
if git rev-parse "$TAG" >/dev/null 2>&1; then
|
||||
echo "Tag $TAG exists, skipping release"
|
||||
echo "tag_pushed=false" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||
git tag -a "$TAG" -m "Release $VERSION"
|
||||
git push origin "$TAG"
|
||||
echo "tag_pushed=true" >> "$GITHUB_OUTPUT"
|
||||
echo "tag_name=$TAG" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
- name: Create GitHub Release
|
||||
if: steps.tag_version.outputs.tag_pushed == 'true'
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
tag_name: ${{ steps.tag_version.outputs.tag_name }}
|
||||
files: build/release/*
|
||||
generate_release_notes: true
|
||||
draft: false
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -12,7 +12,6 @@
|
||||
.cache/
|
||||
*.wasm
|
||||
build/
|
||||
vendor-builds/
|
||||
node_modules
|
||||
*.nix-defexpr
|
||||
*.npm
|
||||
|
||||
@@ -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
|
||||
@@ -1,39 +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.
|
||||
- Split the meditation manual into an image intro page and a shorter music/gong setup page.
|
||||
- Expanded release automation to build Web, Linux AppImage, Windows, APK, and AAB artifacts after tests pass.
|
||||
|
||||
## [1.3.3] - 2026-06-17
|
||||
### Fixed
|
||||
- Import now restores habits, habit sync settings, and optionally app settings from Inbe SQLite exports.
|
||||
|
||||
@@ -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,80 +61,42 @@ 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 := \
|
||||
src/main.c \
|
||||
src/core/breath_engine.c \
|
||||
src/app/app.c \
|
||||
src/app/app_settings.c \
|
||||
src/app/device_preferences.c \
|
||||
src/practices/practice_registry.c \
|
||||
src/practices/whm/whm_practice.c \
|
||||
src/practices/whm/whm_session.c \
|
||||
src/practices/whm/whm_manual.c \
|
||||
src/practices/whm/whm_config.c \
|
||||
src/practices/meditation/meditation_practice.c \
|
||||
src/practices/meditation/meditation_session.c \
|
||||
src/practices/meditation/meditation_manual.c \
|
||||
src/practices/meditation/meditation_config.c \
|
||||
src/session/session.c \
|
||||
src/screens/habits_screen.c \
|
||||
src/practices/meditation/meditation_music.c \
|
||||
src/session/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
|
||||
IMAGE_FILES := assets/whm/1.jpg assets/whm/2.jpg
|
||||
SOUND_FILES := $(wildcard assets/sounds/*.ogg)
|
||||
FONT_OUTPUTS := assets/fonts/locales.png assets/fonts/locales.dat assets/fonts/locales-8.png assets/fonts/locales-8.dat
|
||||
OTFCHOP_DIR ?= vendor/otfchop
|
||||
@@ -159,14 +106,14 @@ EMBEDDED_ASSETS_C := $(BUILD_OBJ_DIR)/$(APP_NAME)_embedded_assets.c
|
||||
EMBEDDED_ASSET_FILES := $(LOCALE_FILES) $(IMAGE_FILES) $(SOUND_FILES) $(FONT_OUTPUTS)
|
||||
SRC := $(APP_SRCS) $(EMBEDDED_ASSETS_C)
|
||||
|
||||
APP_INCLUDE := -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
|
||||
APP_INCLUDE := -Isrc -Isrc/app -Isrc/core -Isrc/screens -Isrc/screens/settings -Isrc/session -Isrc/storage -Isrc/platform/android -Isrc/third_party
|
||||
APP_RAYLIB_CONFIG := $(filter-out -DSUPPORT_MODULE_RAUDIO=0 -DSUPPORT_FILEFORMAT_PNG=0 -DSUPPORT_FILEFORMAT_JPG=0 -DSUPPORT_FILEFORMAT_OGG=0 -DSUPPORT_FILEFORMAT_MP3=0,$(RAY_RAYLIB_CONFIG)) -DSUPPORT_MODULE_RAUDIO=1 -DSUPPORT_FILEFORMAT_JPG=1 -DSUPPORT_FILEFORMAT_OGG=1 -DSUPPORT_FILEFORMAT_MP3=1
|
||||
CFLAGS := -Wall -Wextra -std=c99 -Os -D_DEFAULT_SOURCE -D_GNU_SOURCE -ffunction-sections -fdata-sections -DSUPPORT_FILEFORMAT_JPG=1 -DMINIZ_NO_ZLIB_COMPATIBLE_NAMES -DFLINT_EMBEDDED_ONLY=1 $(FLINT_RUNTIME_ASSET_CFLAGS)
|
||||
WINDOWS_CFLAGS := -Wall -Wextra -std=c99 -Os -D_DEFAULT_SOURCE -D_GNU_SOURCE -ffunction-sections -fdata-sections -DSUPPORT_FILEFORMAT_JPG=1 -DMINIZ_NO_ZLIB_COMPATIBLE_NAMES -DFLINT_EMBEDDED_ONLY=1
|
||||
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 +137,13 @@ 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)
|
||||
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 +166,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,27 +173,17 @@ 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 \
|
||||
-Isrc -Isrc/app -Isrc/core -Isrc/screens -Isrc/screens/settings -Isrc/practices -Isrc/practices/whm -Isrc/practices/meditation -Isrc/storage -Isrc/platform/android -Isrc/third_party -Ivendor/raylib/src $(FLINT_INCLUDE) $(SQLITE_INCLUDE) \
|
||||
-Isrc -Isrc/app -Isrc/core -Isrc/screens -Isrc/screens/settings -Isrc/session -Isrc/storage -Isrc/platform/android -Isrc/third_party -Ivendor/raylib/src $(FLINT_INCLUDE) $(SQLITE_INCLUDE) \
|
||||
-o $@ \
|
||||
tests/storage_import_test.c src/storage/storage.c src/screens/habits_screen.c src/third_party/miniz.c $(SQLITE_SRC) \
|
||||
-Wl,--gc-sections -lm -lpthread -ldl
|
||||
@@ -272,20 +200,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 +225,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 +240,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 +254,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 +271,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 +289,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 +307,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 +379,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_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 +394,11 @@ $(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 \
|
||||
--shell-file src/web_shell.html \
|
||||
-lidbfs.js \
|
||||
-lm
|
||||
@@ -663,25 +432,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 +450,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 +527,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:
|
||||
@:
|
||||
|
||||
@@ -797,24 +551,6 @@ windows:
|
||||
|
||||
web:
|
||||
$(MAKE) $(WEB_TARGET)
|
||||
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
|
||||
@@ -822,10 +558,10 @@ clean:
|
||||
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 +579,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
|
||||
|
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 40 KiB |
|
Before Width: | Height: | Size: 67 KiB After Width: | Height: | Size: 76 KiB |
|
Before Width: | Height: | Size: 51 KiB |
|
Before Width: | Height: | Size: 61 KiB |
|
Before Width: | Height: | Size: 56 KiB After Width: | Height: | Size: 56 KiB |
|
After Width: | Height: | Size: 54 KiB |
@@ -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 31
|
||||
versionName "1.3.3"
|
||||
}
|
||||
|
||||
|
||||
@@ -69,12 +69,6 @@ android {
|
||||
dependenciesInfo {
|
||||
includeInApk = false
|
||||
}
|
||||
|
||||
packaging {
|
||||
jniLibs {
|
||||
useLegacyPackaging = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gradle.taskGraph.whenReady { taskGraph ->
|
||||
|
||||
@@ -10,19 +10,14 @@ 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")
|
||||
file(GLOB INBE_SOUND_ASSETS RELATIVE "${REPO_ROOT}" CONFIGURE_DEPENDS "${REPO_ROOT}/assets/sounds/*.ogg")
|
||||
set(INBE_EMBEDDED_INPUTS
|
||||
${INBE_LOCALE_ASSETS}
|
||||
assets/practices/whm/1.jpg
|
||||
assets/practices/whm/2.jpg
|
||||
assets/practices/meditation/1.jpg
|
||||
assets/whm/1.jpg
|
||||
assets/whm/2.jpg
|
||||
assets/fonts/locales.png
|
||||
assets/fonts/locales.dat
|
||||
assets/fonts/locales-8.png
|
||||
@@ -93,24 +88,14 @@ add_library(main SHARED
|
||||
"${SRC_DIR}/main.c"
|
||||
"${SRC_DIR}/core/breath_engine.c"
|
||||
"${SRC_DIR}/app/app.c"
|
||||
"${SRC_DIR}/app/app_settings.c"
|
||||
"${SRC_DIR}/app/device_preferences.c"
|
||||
"${SRC_DIR}/practices/practice_registry.c"
|
||||
"${SRC_DIR}/practices/whm/whm_practice.c"
|
||||
"${SRC_DIR}/practices/whm/whm_session.c"
|
||||
"${SRC_DIR}/practices/whm/whm_manual.c"
|
||||
"${SRC_DIR}/practices/whm/whm_config.c"
|
||||
"${SRC_DIR}/practices/meditation/meditation_practice.c"
|
||||
"${SRC_DIR}/practices/meditation/meditation_session.c"
|
||||
"${SRC_DIR}/practices/meditation/meditation_manual.c"
|
||||
"${SRC_DIR}/practices/meditation/meditation_config.c"
|
||||
"${SRC_DIR}/session/session.c"
|
||||
"${SRC_DIR}/screens/habits_screen.c"
|
||||
"${SRC_DIR}/practices/meditation/meditation_music.c"
|
||||
"${SRC_DIR}/session/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 +106,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"
|
||||
@@ -139,9 +120,7 @@ target_include_directories(main PRIVATE
|
||||
"${SRC_DIR}/core"
|
||||
"${SRC_DIR}/screens"
|
||||
"${SRC_DIR}/screens/settings"
|
||||
"${SRC_DIR}/practices"
|
||||
"${SRC_DIR}/practices/whm"
|
||||
"${SRC_DIR}/practices/meditation"
|
||||
"${SRC_DIR}/session"
|
||||
"${SRC_DIR}/storage"
|
||||
"${SRC_DIR}/platform/android"
|
||||
"${SRC_DIR}/third_party"
|
||||
@@ -162,7 +141,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 +153,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;
|
||||
|
||||
|
||||
@@ -1,4 +1,2 @@
|
||||
android.useAndroidX=true
|
||||
android.suppressUnsupportedCompileSdk=35
|
||||
org.gradle.caching=true
|
||||
org.gradle.parallel=true
|
||||
@@ -1,3 +0,0 @@
|
||||
### Changed
|
||||
- Reorganized WHM and Meditation into practice-owned modules for cleaner code boundaries.
|
||||
- Split the meditation manual into an image intro page and a shorter music/gong setup page.
|
||||
@@ -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.
|
||||
@@ -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
|
||||
@@ -205,18 +204,13 @@ EOF
|
||||
libgbm
|
||||
libglvnd
|
||||
libglvnd.dev
|
||||
alsa-lib
|
||||
appimagetool
|
||||
libpulseaudio
|
||||
linuxdeploy
|
||||
linuxdeployPluginAppImage
|
||||
mesa
|
||||
ncurses
|
||||
ninja
|
||||
openssl
|
||||
openssl.dev
|
||||
pkg-config
|
||||
pipewire
|
||||
rsync
|
||||
zlib
|
||||
zip
|
||||
@@ -232,9 +226,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 +268,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
|
||||
|
||||
@@ -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. */
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
/* ================================================================
|
||||
|
||||
@@ -40,11 +40,8 @@ Meditace
|
||||
[meditation_manual_title]
|
||||
Meditace
|
||||
---
|
||||
[meditation_manual_intro_text]
|
||||
Settle into a quiet seat and let this session be simple: arrive, breathe, and begin.
|
||||
---
|
||||
[meditation_manual_text]
|
||||
Vyberte hudbu, pokud chcete. Gong oznaci zacatek a konec.
|
||||
Vyberte hudbu, pokud pomáhá sezení zklidnit, a pohodlně se posaďte. Nechte pozornost spočinout na dechu. Když vás myšlenky odvedou, jasně si toho všimněte a vraťte se bez úsilí. Gong označí začátek i konec.
|
||||
---
|
||||
[meditation_music_settings_title]
|
||||
Meditační hudba
|
||||
@@ -397,20 +394,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 +416,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 +491,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
|
||||
---
|
||||
@@ -40,11 +40,8 @@ Meditation
|
||||
[meditation_manual_title]
|
||||
Meditation
|
||||
---
|
||||
[meditation_manual_intro_text]
|
||||
Settle into a quiet seat and let this session be simple: arrive, breathe, and begin.
|
||||
---
|
||||
[meditation_manual_text]
|
||||
Wahlen Sie Musik, wenn Sie mochten. Ein Gong markiert Anfang und Ende.
|
||||
Wähle Musik, wenn sie die Sitzung ruhiger macht, und setze dich bequem hin. Lass die Aufmerksamkeit auf dem Atem ruhen. Wenn Gedanken dich wegziehen, bemerke es klar und kehre ohne Druck zurück. Ein Gong markiert Anfang und Ende.
|
||||
---
|
||||
[meditation_music_settings_title]
|
||||
Meditationsmusik
|
||||
@@ -397,20 +394,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 +416,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 +491,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
|
||||
---
|
||||
@@ -40,11 +40,8 @@ Meditation
|
||||
[meditation_manual_title]
|
||||
Meditation
|
||||
---
|
||||
[meditation_manual_intro_text]
|
||||
Settle into a quiet seat and let this session be simple: arrive, breathe, and begin.
|
||||
---
|
||||
[meditation_manual_text]
|
||||
Choose music if you want it. A gong marks the beginning and end.
|
||||
Choose music if it helps the session feel steady, then sit comfortably. Let attention rest on the breath. When thoughts pull you away, notice that clearly and return without force. A gong marks the beginning and end.
|
||||
---
|
||||
[meditation_music_settings_title]
|
||||
Meditation Music
|
||||
@@ -418,20 +415,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 +437,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 +491,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
|
||||
---
|
||||
@@ -40,11 +40,8 @@ Meditación
|
||||
[meditation_manual_title]
|
||||
Meditación
|
||||
---
|
||||
[meditation_manual_intro_text]
|
||||
Settle into a quiet seat and let this session be simple: arrive, breathe, and begin.
|
||||
---
|
||||
[meditation_manual_text]
|
||||
Elige musica si quieres. Un gong marca el inicio y el final.
|
||||
Elige música si ayuda a que la sesión se sienta estable y siéntate cómodamente. Deja que la atención descanse en la respiración. Cuando los pensamientos te arrastren, obsérvalo con claridad y vuelve sin forzar. Un gong marca el inicio y el final.
|
||||
---
|
||||
[meditation_music_settings_title]
|
||||
Música de meditación
|
||||
@@ -397,20 +394,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 +416,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 +491,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
|
||||
---
|
||||
@@ -40,11 +40,8 @@ Méditation
|
||||
[meditation_manual_title]
|
||||
Méditation
|
||||
---
|
||||
[meditation_manual_intro_text]
|
||||
Settle into a quiet seat and let this session be simple: arrive, breathe, and begin.
|
||||
---
|
||||
[meditation_manual_text]
|
||||
Choisissez de la musique si vous le souhaitez. Un gong marque le debut et la fin.
|
||||
Choisissez une musique si elle aide la séance à rester stable, puis asseyez-vous confortablement. Laissez l’attention se poser sur le souffle. Quand les pensées vous emportent, voyez-le clairement et revenez sans forcer. Un gong marque le début et la fin.
|
||||
---
|
||||
[meditation_music_settings_title]
|
||||
Musique de méditation
|
||||
@@ -397,20 +394,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 +416,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 +491,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
|
||||
---
|
||||
@@ -40,11 +40,8 @@ Meditasi
|
||||
[meditation_manual_title]
|
||||
Meditasi
|
||||
---
|
||||
[meditation_manual_intro_text]
|
||||
Settle into a quiet seat and let this session be simple: arrive, breathe, and begin.
|
||||
---
|
||||
[meditation_manual_text]
|
||||
Pilih musik jika Anda mau. Gong menandai awal dan akhir.
|
||||
Pilih musik jika membantu sesi terasa stabil, lalu duduk dengan nyaman. Biarkan perhatian beristirahat pada napas. Saat pikiran menarikmu pergi, sadari dengan jelas dan kembali tanpa memaksa. Gong menandai awal dan akhir.
|
||||
---
|
||||
[meditation_music_settings_title]
|
||||
Musik meditasi
|
||||
@@ -397,20 +394,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 +416,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 +491,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
|
||||
---
|
||||
@@ -40,11 +40,8 @@ Meditazione
|
||||
[meditation_manual_title]
|
||||
Meditazione
|
||||
---
|
||||
[meditation_manual_intro_text]
|
||||
Settle into a quiet seat and let this session be simple: arrive, breathe, and begin.
|
||||
---
|
||||
[meditation_manual_text]
|
||||
Scegli la musica se vuoi. Un gong segna l inizio e la fine.
|
||||
Scegli la musica se aiuta la sessione a sentirsi stabile, poi siediti comodamente. Lascia che l'attenzione riposi sul respiro. Quando i pensieri ti portano via, notalo con chiarezza e torna senza forzare. Un gong segna l'inizio e la fine.
|
||||
---
|
||||
[meditation_music_settings_title]
|
||||
Musica Meditazione
|
||||
@@ -413,20 +410,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 +432,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 +489,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
|
||||
---
|
||||
@@ -40,11 +40,8 @@
|
||||
[meditation_manual_title]
|
||||
瞑想
|
||||
---
|
||||
[meditation_manual_intro_text]
|
||||
Settle into a quiet seat and let this session be simple: arrive, breathe, and begin.
|
||||
---
|
||||
[meditation_manual_text]
|
||||
必要なら音楽を選んでください。ゴングが始まりと終わりを知らせます。
|
||||
音楽が集中を支えてくれるなら選び、楽な姿勢で座ります。注意を呼吸に置きます。思考に引かれたら、はっきり気づき、力まず戻ります。ゴングが始まりと終わりを知らせます。
|
||||
---
|
||||
[meditation_music_settings_title]
|
||||
瞑想音楽
|
||||
@@ -399,33 +396,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 +485,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
|
||||
---
|
||||
@@ -40,11 +40,8 @@ Inner Breeze
|
||||
[meditation_manual_title]
|
||||
명상
|
||||
---
|
||||
[meditation_manual_intro_text]
|
||||
Settle into a quiet seat and let this session be simple: arrive, breathe, and begin.
|
||||
---
|
||||
[meditation_manual_text]
|
||||
원하면 음악을 선택하세요. 징 소리가 시작과 끝을 알립니다.
|
||||
음악이 세션을 안정되게 해 준다면 선택한 뒤 편안하게 앉으세요. 주의를 호흡에 둡니다. 생각에 끌려가면 분명히 알아차리고 힘주지 말고 돌아오세요. 공 소리가 시작과 끝을 알립니다.
|
||||
---
|
||||
[meditation_music_settings_title]
|
||||
명상 음악
|
||||
@@ -412,20 +409,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 +431,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 +488,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
|
||||
---
|
||||
@@ -40,11 +40,8 @@ Meditação
|
||||
[meditation_manual_title]
|
||||
Meditação
|
||||
---
|
||||
[meditation_manual_intro_text]
|
||||
Settle into a quiet seat and let this session be simple: arrive, breathe, and begin.
|
||||
---
|
||||
[meditation_manual_text]
|
||||
Escolha musica se quiser. Um gongo marca o inicio e o fim.
|
||||
Escolha uma música se ela ajudar a sessão a ficar estável e sente-se confortavelmente. Deixe a atenção repousar na respiração. Quando os pensamentos puxarem você, perceba com clareza e volte sem forçar. Um gongo marca o começo e o fim.
|
||||
---
|
||||
[meditation_music_settings_title]
|
||||
Música de meditação
|
||||
@@ -397,20 +394,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 +416,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 +491,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
|
||||
---
|
||||
@@ -40,11 +40,8 @@ Wim Hof 呼吸
|
||||
[meditation_manual_title]
|
||||
冥想
|
||||
---
|
||||
[meditation_manual_intro_text]
|
||||
Settle into a quiet seat and let this session be simple: arrive, breathe, and begin.
|
||||
---
|
||||
[meditation_manual_text]
|
||||
如果需要,可以选择音乐。锣声会提示开始和结束。
|
||||
如果音乐能让练习更安稳,就先选择音乐,然后舒适地坐下。把注意力放在呼吸上。被念头带走时,清楚地觉察,再不费力地回来。钟声会提示开始和结束。
|
||||
---
|
||||
[meditation_music_settings_title]
|
||||
冥想音乐
|
||||
@@ -397,33 +394,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 +483,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
|
||||
---
|
||||
@@ -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 });
|
||||
});
|
||||
@@ -41,9 +41,8 @@ fi
|
||||
mkdir -p build
|
||||
sh flint/scripts/embed-assets.sh build/inbe_embedded_assets.c \
|
||||
locales/*.txt \
|
||||
assets/practices/whm/1.jpg \
|
||||
assets/practices/whm/2.jpg \
|
||||
assets/practices/meditation/1.jpg \
|
||||
assets/whm/1.jpg \
|
||||
assets/whm/2.jpg \
|
||||
assets/fonts/locales.png \
|
||||
assets/fonts/locales.dat \
|
||||
assets/fonts/locales-8.png \
|
||||
|
||||
@@ -61,8 +61,6 @@ typedef enum {
|
||||
UIModalEditProgressiveStartSpeed,
|
||||
UIModalMeditationNetworkError,
|
||||
UIModalConfirmImportDataSettings,
|
||||
UIModalSyncAccountBackup,
|
||||
UIModalConfirmDeleteSyncAccount,
|
||||
} UIModalType;
|
||||
|
||||
typedef struct {
|
||||
@@ -81,6 +79,15 @@ typedef struct InbeConfig {
|
||||
|
||||
extern InbeConfig config;
|
||||
|
||||
typedef struct LotusAppApi {
|
||||
const char *id;
|
||||
void *(*create)(void);
|
||||
void (*init)(void *state);
|
||||
void (*init_args)(void *state, int argc, char **argv);
|
||||
void (*update_draw)(void *state, Rectangle viewport);
|
||||
void (*destroy)(void *state);
|
||||
} LotusAppApi;
|
||||
|
||||
typedef enum HoldDisplayMode {
|
||||
HOLD_DISPLAY_CIRCLE = 0,
|
||||
HOLD_DISPLAY_STOPWATCH = 1,
|
||||
@@ -89,7 +96,7 @@ typedef enum HoldDisplayMode {
|
||||
typedef enum ExerciseType {
|
||||
EXERCISE_WIM_HOF = 0,
|
||||
EXERCISE_MEDITATION = 1,
|
||||
EXERCISE_COUNT = 2
|
||||
EXERCISE_COUNT
|
||||
} ExerciseType;
|
||||
|
||||
typedef enum AppThemeMode {
|
||||
@@ -116,53 +123,6 @@ typedef enum AppMainTab {
|
||||
APP_MAIN_TAB_PRACTICE = 1,
|
||||
} AppMainTab;
|
||||
|
||||
typedef struct WhmPracticeState {
|
||||
Texture2D image_1;
|
||||
Texture2D image_2;
|
||||
} WhmPracticeState;
|
||||
|
||||
typedef struct MeditationPracticeState {
|
||||
Texture2D image_1;
|
||||
int duration_seconds;
|
||||
int remaining_seconds;
|
||||
int frame_ticks;
|
||||
int music_enabled;
|
||||
int music_shuffle;
|
||||
int music_track;
|
||||
int music_loaded;
|
||||
int music_playing;
|
||||
int music_test_playing;
|
||||
int music_archive_extracted;
|
||||
int music_network_error_notified;
|
||||
Music music;
|
||||
FlintRuntimeAssetDownload music_download;
|
||||
char music_cache_dir[FS_PATH_MAX];
|
||||
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;
|
||||
@@ -173,8 +133,8 @@ struct InbeApp {
|
||||
int cursor_disabled;
|
||||
Texture2D icons[UI_ICON_TYPE_COUNT];
|
||||
|
||||
WhmPracticeState whm;
|
||||
MeditationPracticeState meditation;
|
||||
Texture2D whm_1_image;
|
||||
Texture2D whm_2_image;
|
||||
Texture2D font_shapes_texture;
|
||||
Font locale_font;
|
||||
Font locale_font_8;
|
||||
@@ -195,10 +155,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;
|
||||
@@ -222,18 +178,29 @@ struct InbeApp {
|
||||
int android_orientation;
|
||||
int main_tab;
|
||||
int pending_bottom_tab;
|
||||
#if defined(LOTUS_BUILD)
|
||||
unsigned int lotus_settings_version;
|
||||
#endif
|
||||
InbeHabits habits;
|
||||
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;
|
||||
@@ -247,24 +214,40 @@ struct InbeApp {
|
||||
char results_path[FS_PATH_MAX];
|
||||
int saved_pause_seconds;
|
||||
int volume_popup_active;
|
||||
int meditation_duration_seconds;
|
||||
int meditation_remaining_seconds;
|
||||
int meditation_frame_ticks;
|
||||
int meditation_music_enabled;
|
||||
int meditation_music_shuffle;
|
||||
int meditation_music_track;
|
||||
int meditation_music_loaded;
|
||||
int meditation_music_playing;
|
||||
int meditation_music_test_playing;
|
||||
int meditation_music_archive_extracted;
|
||||
int meditation_music_network_error_notified;
|
||||
Music meditation_music;
|
||||
FlintRuntimeAssetDownload meditation_music_download;
|
||||
char meditation_music_cache_dir[FS_PATH_MAX];
|
||||
char meditation_music_status[128];
|
||||
UIModal modal;
|
||||
int play_circle_hover;
|
||||
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 update_session_sounds(InbeApp *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);
|
||||
|
||||
int clampi(int x, int min, int max);
|
||||
int int_from_count(const char src[4]);
|
||||
void count_from_int(char dst[4], int value);
|
||||
void save_settings(InbeApp *app);
|
||||
void app_reload_after_import(InbeApp *app, int reload_settings);
|
||||
void reset_settings_preview(InbeApp *app);
|
||||
void update_preview_bounds(Inbe *inbe, int content_w, int max_h);
|
||||
void apply_settings(Inbe *inbe, int speed, int max_rounds, int max_breaths, int pause_seconds);
|
||||
void refresh_theme_colors(int theme_id, int dark_mode);
|
||||
void refresh_locale_dependent_text(InbeApp *app);
|
||||
void apply_language_selection(InbeApp *app, int language_index, int save_now);
|
||||
@@ -272,7 +255,7 @@ int exercise_manual_seen(InbeApp *app, int exercise_type);
|
||||
void mark_exercise_manual_seen(InbeApp *app, int exercise_type);
|
||||
void sync_habits_for_activity(InbeApp *app, int exercise_type);
|
||||
void draw_preview_inbe(Inbe *inbe, int center_x, int center_y);
|
||||
|
||||
#include "app_settings.h"
|
||||
int draw_hold_display_mode_selector(InbeApp *app, int x, int y, int w);
|
||||
void settings_draw_progressive_start_speed_editor(InbeApp *app);
|
||||
|
||||
#endif
|
||||
@@ -1,298 +0,0 @@
|
||||
#include "app_settings.h"
|
||||
|
||||
#include "app.h"
|
||||
#include "device_preferences.h"
|
||||
#include "flint_locale.h"
|
||||
#include "practices/meditation/meditation_music.h"
|
||||
#include "practices/whm/whm_session.h"
|
||||
#include "storage.h"
|
||||
#include "theme.h"
|
||||
#include "flint_dpi.h"
|
||||
#include "flint_ui.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#if defined(PLATFORM_WEB)
|
||||
#include <emscripten.h>
|
||||
#endif
|
||||
|
||||
typedef struct IntSetting {
|
||||
const char *key;
|
||||
int value;
|
||||
} IntSetting;
|
||||
|
||||
typedef struct LoadedIntSetting {
|
||||
int *dst;
|
||||
const char *key;
|
||||
int fallback;
|
||||
} LoadedIntSetting;
|
||||
|
||||
typedef struct LoadedBoolSetting {
|
||||
int *dst;
|
||||
const char *key;
|
||||
int fallback;
|
||||
} LoadedBoolSetting;
|
||||
|
||||
typedef struct LoadedClampedSetting {
|
||||
int *dst;
|
||||
const char *key;
|
||||
int fallback;
|
||||
int min_value;
|
||||
int max_value;
|
||||
} LoadedClampedSetting;
|
||||
|
||||
static int
|
||||
exercise_manual_bit(int exercise_type)
|
||||
{
|
||||
if(exercise_type < 0 || exercise_type >= EXERCISE_COUNT)
|
||||
return 0;
|
||||
return 1 << exercise_type;
|
||||
}
|
||||
|
||||
#if defined(PLATFORM_WEB)
|
||||
static void
|
||||
sync_web_storage(void)
|
||||
{
|
||||
EM_ASM({
|
||||
if(typeof Module.__inbeScheduleStorageSync === 'function')
|
||||
Module.__inbeScheduleStorageSync(250, true);
|
||||
});
|
||||
}
|
||||
#endif
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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].fallback);
|
||||
}
|
||||
|
||||
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].fallback) != 0;
|
||||
}
|
||||
|
||||
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);
|
||||
*settings[i].dst = clampi(value, settings[i].min_value, settings[i].max_value);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
apply_settings(Inbe *inbe, int speed, int max_rounds, int max_breaths, int pause_seconds)
|
||||
{
|
||||
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_animation = clampi(inbe->breath_animation,
|
||||
InbeBreathAnimationLinear,
|
||||
InbeBreathAnimationCount - 1);
|
||||
inbe->progressive_start_speed = clampi(inbe->progressive_start_speed,
|
||||
SETTINGS_SPEED_MIN, speed);
|
||||
inbe->max_rounds = clampi(max_rounds, 1, MaxRounds);
|
||||
inbe->pause_seconds = clampi(pause_seconds, SETTINGS_PAUSE_MIN, SETTINGS_PAUSE_MAX);
|
||||
count_from_int(inbe->maxbreaths,
|
||||
clampi(max_breaths, SETTINGS_BREATHS_MIN, SETTINGS_BREATHS_MAX));
|
||||
}
|
||||
|
||||
void
|
||||
reset_settings_preview(InbeApp *app)
|
||||
{
|
||||
int speed = app->inbe.speed_level;
|
||||
int max_rounds = app->inbe.max_rounds;
|
||||
int max_breaths = int_from_count(app->inbe.maxbreaths);
|
||||
int pause_seconds = app->inbe.pause_seconds;
|
||||
int play_in_background = app->inbe.play_in_background;
|
||||
int breath_animation = app->inbe.breath_animation;
|
||||
int content_w;
|
||||
|
||||
inbeinit(&app->settings_preview);
|
||||
app->settings_preview.progressive_speed = 0;
|
||||
app->settings_preview.play_in_background = play_in_background;
|
||||
app->settings_preview.breath_animation = breath_animation;
|
||||
flint_centered_column(CONTENT_MAX_W, CONTENT_SIDE_PAD, NULL, &content_w);
|
||||
update_preview_bounds(&app->settings_preview, content_w, flint_px(132));
|
||||
apply_settings(&app->settings_preview, speed, max_rounds, max_breaths, pause_seconds);
|
||||
session_reset_round_breathe(&app->settings_preview);
|
||||
}
|
||||
|
||||
void
|
||||
save_settings(InbeApp *app)
|
||||
{
|
||||
if(app == NULL)
|
||||
return;
|
||||
|
||||
const IntSetting int_settings[] = {
|
||||
{"speed", app->inbe.speed_level},
|
||||
{"max_rounds", app->inbe.max_rounds},
|
||||
{"max_breaths", int_from_count(app->inbe.maxbreaths)},
|
||||
{"pause_seconds", app->inbe.pause_seconds},
|
||||
{"sound_volume", app->sound_volume},
|
||||
{"tutorial_seen", app->tutorial_seen ? 1 : 0},
|
||||
{"exercise_manual_seen_mask", app->exercise_manual_seen_mask},
|
||||
{"theme", app->theme_id},
|
||||
{"dark_mode", app->dark_mode},
|
||||
{"theme_mode", app->theme_mode},
|
||||
{"orientation_mode", app->orientation_mode},
|
||||
{"main_tab", app->main_tab},
|
||||
{"fullscreen", app->fullscreen_enabled ? 1 : 0},
|
||||
{"on_screen_keyboard", app->on_screen_keyboard_enabled ? 1 : 0},
|
||||
{"progressive_speed", app->inbe.progressive_speed},
|
||||
{"progressive_start_speed", app->inbe.progressive_start_speed},
|
||||
{"breath_animation", app->inbe.breath_animation},
|
||||
{"advanced_session_controls", app->advanced_session_controls ? 1 : 0},
|
||||
{"hold_display_mode", app->hold_display_mode},
|
||||
{"exercise_type", app->exercise_type},
|
||||
{"meditation_music_enabled", app->meditation.music_enabled ? 1 : 0},
|
||||
{"meditation_music_shuffle", app->meditation.music_shuffle ? 1 : 0},
|
||||
{"meditation_music_track", app->meditation.music_track},
|
||||
{"play_in_background", app->inbe.play_in_background},
|
||||
{"practice_category_tab", app->practice_category_tab},
|
||||
};
|
||||
|
||||
storage_settings_begin_write();
|
||||
save_int_settings(int_settings, sizeof(int_settings) / sizeof(int_settings[0]));
|
||||
storage_set_setting_text("language",
|
||||
(app->language_selected && app->language[0] != '\0') ?
|
||||
app->language : "");
|
||||
storage_settings_end_write();
|
||||
#if defined(PLATFORM_WEB)
|
||||
sync_web_storage();
|
||||
#endif
|
||||
app->settings_dirty = 0;
|
||||
app->settings_save_delay_ticks = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
load_language_setting(InbeApp *app, int settings_missing)
|
||||
{
|
||||
const char *language = storage_get_setting_text("language");
|
||||
|
||||
app->language_needs_save = 0;
|
||||
if(language != NULL && language[0] != '\0') {
|
||||
snprintf(app->language, sizeof(app->language), "%s", language);
|
||||
app->language_selected = 1;
|
||||
if(!locale_set(app->language)) {
|
||||
snprintf(app->language, sizeof(app->language), "%s", "en");
|
||||
locale_set(app->language);
|
||||
}
|
||||
} else {
|
||||
snprintf(app->language, sizeof(app->language), "%s", "en");
|
||||
app->language_selected = settings_missing ? 0 : 1;
|
||||
app->language_needs_save = app->language_selected;
|
||||
locale_set(app->language);
|
||||
}
|
||||
|
||||
app->language_index = locale_current_index();
|
||||
if(app->language_index < 0)
|
||||
app->language_index = 0;
|
||||
}
|
||||
|
||||
int
|
||||
app_load_settings(InbeApp *app)
|
||||
{
|
||||
int settings_missing;
|
||||
int speed;
|
||||
int max_rounds;
|
||||
int max_breaths;
|
||||
int pause_seconds;
|
||||
int manual_seen_mask;
|
||||
|
||||
if(app == NULL)
|
||||
return 0;
|
||||
|
||||
settings_missing = storage_settings_empty();
|
||||
|
||||
{
|
||||
LoadedIntSetting settings[] = {
|
||||
{&speed, "speed", DefaultSpeedLevel},
|
||||
{&max_rounds, "max_rounds", DefaultMaxRounds},
|
||||
{&max_breaths, "max_breaths", DefaultMaxBreaths},
|
||||
{&pause_seconds, "pause_seconds", DefaultPauseSeconds},
|
||||
};
|
||||
load_int_settings(settings, sizeof(settings) / sizeof(settings[0]));
|
||||
}
|
||||
|
||||
{
|
||||
LoadedBoolSetting settings[] = {
|
||||
{&app->tutorial_seen, "tutorial_seen", 0},
|
||||
{&app->dark_mode, "dark_mode", 0},
|
||||
{&app->fullscreen_enabled, "fullscreen", 0},
|
||||
#ifdef __ANDROID__
|
||||
{&app->on_screen_keyboard_enabled, "on_screen_keyboard", 1},
|
||||
#else
|
||||
{&app->on_screen_keyboard_enabled, "on_screen_keyboard", 0},
|
||||
#endif
|
||||
{&app->inbe.progressive_speed, "progressive_speed", 1},
|
||||
{&app->advanced_session_controls, "advanced_session_controls", 0},
|
||||
{&app->meditation.music_enabled, "meditation_music_enabled", 1},
|
||||
{&app->meditation.music_shuffle, "meditation_music_shuffle", 0},
|
||||
};
|
||||
load_bool_settings(settings, sizeof(settings) / sizeof(settings[0]));
|
||||
}
|
||||
|
||||
{
|
||||
LoadedClampedSetting settings[] = {
|
||||
{&app->sound_volume, "sound_volume", 100,
|
||||
SETTINGS_VOLUME_MIN, SETTINGS_VOLUME_MAX},
|
||||
{&app->theme_id, "theme", 0, 0, FLINT_THEME_COUNT - 1},
|
||||
{&app->theme_mode, "theme_mode", APP_THEME_SYSTEM,
|
||||
APP_THEME_SYSTEM, APP_THEME_DARK},
|
||||
{&app->orientation_mode, "orientation_mode", APP_ORIENTATION_SYSTEM,
|
||||
APP_ORIENTATION_SYSTEM, APP_ORIENTATION_SENSOR},
|
||||
{&app->main_tab, "main_tab", APP_MAIN_TAB_PRACTICE,
|
||||
APP_MAIN_TAB_HABITS, APP_MAIN_TAB_PRACTICE},
|
||||
{&app->inbe.progressive_start_speed, "progressive_start_speed",
|
||||
DefaultProgressiveStartSpeed, SETTINGS_SPEED_MIN, SETTINGS_SPEED_MAX},
|
||||
{&app->inbe.breath_animation, "breath_animation", InbeBreathAnimationLinear,
|
||||
InbeBreathAnimationLinear, InbeBreathAnimationCount - 1},
|
||||
{&app->hold_display_mode, "hold_display_mode", HOLD_DISPLAY_CIRCLE,
|
||||
HOLD_DISPLAY_CIRCLE, HOLD_DISPLAY_STOPWATCH},
|
||||
{&app->exercise_type, "exercise_type", EXERCISE_WIM_HOF,
|
||||
EXERCISE_WIM_HOF, EXERCISE_COUNT - 1},
|
||||
{&app->meditation.music_track, "meditation_music_track", 0,
|
||||
0, MEDITATION_MUSIC_TRACK_COUNT - 1},
|
||||
{&app->practice_category_tab, "practice_category_tab", PRACTICE_CATEGORY_MIND,
|
||||
0, PRACTICE_CATEGORY_COUNT - 1},
|
||||
};
|
||||
load_clamped_settings(settings, sizeof(settings) / sizeof(settings[0]));
|
||||
}
|
||||
|
||||
manual_seen_mask = 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);
|
||||
|
||||
load_language_setting(app, settings_missing);
|
||||
|
||||
#ifdef __ANDROID__
|
||||
app->inbe.play_in_background =
|
||||
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
|
||||
app->inbe.play_in_background = 0;
|
||||
#endif
|
||||
app->backgrounded = 0;
|
||||
|
||||
app_device_preferences_init(app);
|
||||
apply_settings(&app->inbe, speed, max_rounds, max_breaths, pause_seconds);
|
||||
refresh_locale_dependent_text(app);
|
||||
|
||||
return settings_missing;
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
#ifndef INBE_APP_SETTINGS_H
|
||||
#define INBE_APP_SETTINGS_H
|
||||
|
||||
#include "app_fwd.h"
|
||||
#include "breath_engine.h"
|
||||
|
||||
void save_settings(InbeApp *app);
|
||||
int app_load_settings(InbeApp *app);
|
||||
void reset_settings_preview(InbeApp *app);
|
||||
void apply_settings(Inbe *inbe, int speed, int max_rounds, int max_breaths, int pause_seconds);
|
||||
|
||||
#endif
|
||||
@@ -1,6 +1,9 @@
|
||||
#include "device_preferences.h"
|
||||
#include "theme.h"
|
||||
#include "flint_ui.h"
|
||||
#if defined(LOTUS_BUILD)
|
||||
#include "lotus_settings.h"
|
||||
#endif
|
||||
#if defined(PLATFORM_ANDROID) || defined(__ANDROID__) || defined(ANDROID)
|
||||
#include "android_device.h"
|
||||
#endif
|
||||
@@ -14,9 +17,18 @@ void
|
||||
refresh_theme_colors(int theme_id, int dark_mode)
|
||||
{
|
||||
theme_set_current(theme_id, dark_mode);
|
||||
#if defined(LOTUS_BUILD)
|
||||
(void)theme_id;
|
||||
(void)dark_mode;
|
||||
ui_set_colors(theme_get_text(), theme_get_bg(), theme_get_surface(),
|
||||
theme_get_circle(), theme_get_button(), theme_get_button_hover(),
|
||||
theme_get_icon());
|
||||
return;
|
||||
#else
|
||||
ui_set_colors(theme_get_text(), theme_get_bg(), theme_get_surface(),
|
||||
theme_get_circle(), theme_get_button(), theme_get_button_hover(),
|
||||
theme_get_icon());
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
@@ -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.
|
||||
*/
|
||||
@@ -0,0 +1,6 @@
|
||||
#ifndef INBE_LOCALE_H
|
||||
#define INBE_LOCALE_H
|
||||
|
||||
#include "flint_locale.h"
|
||||
|
||||
#endif
|
||||
@@ -2,8 +2,8 @@
|
||||
#define INBE_VERSION_H
|
||||
|
||||
#define INBE_VERSION_MAJOR 1
|
||||
#define INBE_VERSION_MINOR 4
|
||||
#define INBE_VERSION_MINOR 3
|
||||
#define INBE_VERSION_PATCH 3
|
||||
#define INBE_VERSION_STRING "1.4.3"
|
||||
#define INBE_VERSION_STRING "1.3.3"
|
||||
|
||||
#endif
|
||||
@@ -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");
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
@@ -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,6 +1,5 @@
|
||||
#include "android_timer.h"
|
||||
#include "app.h"
|
||||
#include "practices/practice_registry.h"
|
||||
#include <time.h>
|
||||
|
||||
#include <raylib.h>
|
||||
@@ -42,15 +41,15 @@ timer_thread_func(void *arg) {
|
||||
if (should_run) {
|
||||
// Log every 60 frames (1 second)
|
||||
if (frame_count % 60 == 0) {
|
||||
__android_log_write(ANDROID_LOG_INFO, LOG_TAG, "Timer: Running background practice step + sounds");
|
||||
__android_log_write(ANDROID_LOG_INFO, LOG_TAG, "Timer: Running meditation step + sounds");
|
||||
}
|
||||
frame_count++;
|
||||
|
||||
// Update practice state and sounds with mutex protection
|
||||
// Update meditation state and sounds with mutex protection
|
||||
pthread_mutex_lock(&inbe_state_mutex);
|
||||
InbeApp *app = (InbeApp*)g_app;
|
||||
inbestep(&app->inbe);
|
||||
practice_update_session_sounds(app);
|
||||
update_session_sounds(app);
|
||||
pthread_mutex_unlock(&inbe_state_mutex);
|
||||
|
||||
// Sleep for exact frame time (60fps = ~16.666ms)
|
||||
|
||||
@@ -1,94 +0,0 @@
|
||||
#include "meditation_practice.h"
|
||||
|
||||
#include "app.h"
|
||||
#include "meditation_music.h"
|
||||
#include "flint_locale.h"
|
||||
#include "theme.h"
|
||||
#include "flint_ui.h"
|
||||
#include "raylib.h"
|
||||
|
||||
extern int view_width;
|
||||
extern int view_height;
|
||||
|
||||
static int
|
||||
meditation_config_content_height(InbeApp *app, int content_w)
|
||||
{
|
||||
return meditation_music_measure_settings(app, content_w, 1, 1);
|
||||
}
|
||||
|
||||
void
|
||||
meditation_config_screen_draw(InbeApp *app)
|
||||
{
|
||||
int title_h = ui_screen_header_height();
|
||||
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 scroll_y;
|
||||
int scroll_h;
|
||||
int content_h;
|
||||
int controls_w;
|
||||
FlintUIScrollArea scroll_area;
|
||||
FlintUIScrollView scroll_view;
|
||||
FlintUIHeader header;
|
||||
|
||||
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;
|
||||
flint_centered_column(responsive_max_w, flint_page_side_padding(), &content_x, &content_w);
|
||||
|
||||
header = ui_draw_title_header(title_h, locale_get("exercise_meditation"),
|
||||
(Texture2D){0}, app->icons[UI_ICON_TYPE_X]);
|
||||
if(header.right_clicked) {
|
||||
if(app->settings_dirty)
|
||||
save_settings(app);
|
||||
meditation_practice_leave_config(app);
|
||||
app->settings_scroll = 0;
|
||||
app->inbe.screen = InbeScreenStart;
|
||||
}
|
||||
|
||||
scroll_y = title_h + flint_px(16);
|
||||
scroll_h = view_height - scroll_y;
|
||||
if(scroll_h < 0)
|
||||
scroll_h = 0;
|
||||
|
||||
controls_w = content_w;
|
||||
for(int i = 0; i < 3; i++) {
|
||||
FlintUIScrollView measured;
|
||||
content_h = meditation_config_content_height(app, controls_w);
|
||||
scroll_area = (FlintUIScrollArea){
|
||||
.bounds = {0.0f, (float)scroll_y, (float)view_width, (float)scroll_h},
|
||||
.content_height = content_h,
|
||||
.content_x = content_x,
|
||||
.content_width = content_w,
|
||||
.scroll_offset = &app->settings_scroll,
|
||||
.wheel_step = flint_px(42),
|
||||
.scrollbar_x = view_width - flint_px(8)
|
||||
};
|
||||
measured = ui_scroll_container_measure(scroll_area);
|
||||
if(measured.content_w == controls_w)
|
||||
break;
|
||||
controls_w = measured.content_w;
|
||||
}
|
||||
|
||||
content_h = meditation_config_content_height(app, controls_w);
|
||||
scroll_area = (FlintUIScrollArea){
|
||||
.bounds = {0.0f, (float)scroll_y, (float)view_width, (float)scroll_h},
|
||||
.content_height = content_h,
|
||||
.content_x = content_x,
|
||||
.content_width = content_w,
|
||||
.scroll_offset = &app->settings_scroll,
|
||||
.wheel_step = flint_px(42),
|
||||
.scrollbar_x = view_width - flint_px(8)
|
||||
};
|
||||
scroll_view = ui_scroll_container_begin(scroll_area);
|
||||
{
|
||||
int y = scroll_view.content_y;
|
||||
meditation_music_draw_settings(app, scroll_view.content_x, scroll_view.content_w,
|
||||
&y, 1, 1);
|
||||
}
|
||||
ui_scroll_container_end(scroll_area, scroll_view);
|
||||
meditation_music_draw_dropdown_menu(app);
|
||||
}
|
||||
@@ -1,220 +0,0 @@
|
||||
#include "meditation_practice.h"
|
||||
|
||||
#include "app.h"
|
||||
#include "flint_locale.h"
|
||||
#include "meditation_music.h"
|
||||
#include "theme.h"
|
||||
#include "flint_ui.h"
|
||||
#include "raylib.h"
|
||||
|
||||
extern int view_width;
|
||||
extern int view_height;
|
||||
|
||||
enum {
|
||||
MEDITATION_MANUAL_PAGES = 2
|
||||
};
|
||||
|
||||
static void
|
||||
meditation_manual_start(InbeApp *app)
|
||||
{
|
||||
mark_exercise_manual_seen(app, EXERCISE_MEDITATION);
|
||||
app->tutorial_step = 0;
|
||||
app->manual_scroll = 0;
|
||||
meditation_practice_start(app);
|
||||
}
|
||||
|
||||
void
|
||||
meditation_manual_close(InbeApp *app, int mark_seen)
|
||||
{
|
||||
if(app == NULL)
|
||||
return;
|
||||
if(mark_seen)
|
||||
mark_exercise_manual_seen(app, EXERCISE_MEDITATION);
|
||||
app->tutorial_step = 0;
|
||||
app->manual_scroll = 0;
|
||||
app->inbe.screen = InbeScreenStart;
|
||||
}
|
||||
|
||||
static void
|
||||
draw_intro_page(InbeApp *app, int content_x, int content_w, int *y)
|
||||
{
|
||||
int img_h = flint_px(190);
|
||||
FlintUIParagraph paragraph;
|
||||
|
||||
ui_draw_tutorial_image(app->meditation.image_1, "practices/meditation/1.jpg",
|
||||
content_x, *y, content_w, img_h);
|
||||
*y += img_h + flint_px(22);
|
||||
|
||||
paragraph = (FlintUIParagraph){
|
||||
.text = locale_get("meditation_manual_intro_text"),
|
||||
.icon = (Texture2D){0},
|
||||
.icon_type = UI_ICON_TYPE_NONE,
|
||||
.icon_size = 0,
|
||||
.width = content_w,
|
||||
.font = flint_ui_font(),
|
||||
.line_gap = flint_px(8),
|
||||
.color = theme_get_text(),
|
||||
};
|
||||
flint_ui_paragraph_draw(paragraph, content_x, y);
|
||||
}
|
||||
|
||||
static int
|
||||
intro_page_height(int content_w)
|
||||
{
|
||||
FlintUIParagraph paragraph = {
|
||||
.text = locale_get("meditation_manual_intro_text"),
|
||||
.icon = (Texture2D){0},
|
||||
.icon_type = UI_ICON_TYPE_NONE,
|
||||
.icon_size = 0,
|
||||
.width = content_w,
|
||||
.font = flint_ui_font(),
|
||||
.line_gap = flint_px(8),
|
||||
.color = theme_get_text(),
|
||||
};
|
||||
|
||||
return flint_px(190) + flint_px(22) + flint_ui_paragraph_height(paragraph) +
|
||||
flint_px(20);
|
||||
}
|
||||
|
||||
static int
|
||||
settings_page_height(InbeApp *app, int content_w)
|
||||
{
|
||||
FlintUIParagraph paragraph = {
|
||||
.text = locale_get("meditation_manual_text"),
|
||||
.icon = (Texture2D){0},
|
||||
.icon_type = UI_ICON_TYPE_NONE,
|
||||
.icon_size = 0,
|
||||
.width = content_w,
|
||||
.font = flint_ui_font(),
|
||||
.line_gap = flint_px(8),
|
||||
.color = theme_get_text(),
|
||||
};
|
||||
|
||||
return meditation_music_measure_settings(app, content_w, 0, 1) +
|
||||
flint_px(34) + flint_ui_paragraph_height(paragraph) + flint_px(20);
|
||||
}
|
||||
|
||||
void
|
||||
meditation_manual_draw(InbeApp *app)
|
||||
{
|
||||
int title_h = ui_screen_header_height();
|
||||
int button_h = flint_px(36);
|
||||
int footer_y = view_height - flint_px(42);
|
||||
int content_y = title_h + flint_px(16);
|
||||
int content_h = footer_y - content_y - flint_px(28);
|
||||
int content_x;
|
||||
int content_w;
|
||||
int responsive_max_w = (int)(view_width * 0.90f);
|
||||
int max_content_w = flint_px(520);
|
||||
int page = clampi(app->tutorial_step, 0, MEDITATION_MANUAL_PAGES - 1);
|
||||
int content_total_h;
|
||||
FlintUIScrollArea scroll_area;
|
||||
FlintUIScrollView scroll_view;
|
||||
|
||||
if(responsive_max_w > max_content_w)
|
||||
responsive_max_w = max_content_w;
|
||||
if(responsive_max_w < flint_px(280))
|
||||
responsive_max_w = flint_px(280);
|
||||
flint_centered_column(responsive_max_w, flint_page_side_padding(), &content_x, &content_w);
|
||||
|
||||
app->tutorial_step = page;
|
||||
if(ui_draw_screen_header(locale_get("meditation_manual_title"), 1))
|
||||
meditation_manual_close(app, 0);
|
||||
|
||||
if(content_h < flint_px(120))
|
||||
content_h = flint_px(120);
|
||||
|
||||
for(int pass = 0; pass < 3; pass++) {
|
||||
FlintUIScrollView measured;
|
||||
content_total_h = page == 0 ? intro_page_height(content_w)
|
||||
: settings_page_height(app, content_w);
|
||||
scroll_area = (FlintUIScrollArea){
|
||||
.bounds = {0.0f, (float)content_y, (float)view_width, (float)content_h},
|
||||
.content_height = content_total_h,
|
||||
.content_x = content_x,
|
||||
.content_width = content_w,
|
||||
.scroll_offset = &app->manual_scroll,
|
||||
.wheel_step = flint_px(42),
|
||||
.scrollbar_x = view_width - flint_px(8)
|
||||
};
|
||||
measured = ui_scroll_container_measure(scroll_area);
|
||||
if(measured.content_w == content_w)
|
||||
break;
|
||||
content_w = measured.content_w;
|
||||
}
|
||||
|
||||
content_total_h = page == 0 ? intro_page_height(content_w)
|
||||
: settings_page_height(app, content_w);
|
||||
scroll_area = (FlintUIScrollArea){
|
||||
.bounds = {0.0f, (float)content_y, (float)view_width, (float)content_h},
|
||||
.content_height = content_total_h,
|
||||
.content_x = content_x,
|
||||
.content_width = content_w,
|
||||
.scroll_offset = &app->manual_scroll,
|
||||
.wheel_step = flint_px(42),
|
||||
.scrollbar_x = view_width - flint_px(8)
|
||||
};
|
||||
scroll_view = ui_scroll_container_begin(scroll_area);
|
||||
{
|
||||
int y = scroll_view.content_y;
|
||||
if(page == 0) {
|
||||
draw_intro_page(app, scroll_view.content_x, scroll_view.content_w, &y);
|
||||
} else {
|
||||
FlintUIParagraph paragraph;
|
||||
meditation_music_draw_settings(app, scroll_view.content_x, scroll_view.content_w,
|
||||
&y, 0, 1);
|
||||
y += flint_px(34);
|
||||
paragraph = (FlintUIParagraph){
|
||||
.text = locale_get("meditation_manual_text"),
|
||||
.icon = (Texture2D){0},
|
||||
.icon_type = UI_ICON_TYPE_NONE,
|
||||
.icon_size = 0,
|
||||
.width = scroll_view.content_w,
|
||||
.font = flint_ui_font(),
|
||||
.line_gap = flint_px(8),
|
||||
.color = theme_get_text(),
|
||||
};
|
||||
flint_ui_paragraph_draw(paragraph, scroll_view.content_x, &y);
|
||||
}
|
||||
}
|
||||
ui_scroll_container_end(scroll_area, scroll_view);
|
||||
if(page == 1)
|
||||
meditation_music_draw_dropdown_menu(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 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(right_x, footer_y, button_w, button_h, right,
|
||||
UI_BUTTON_STYLE_PRIMARY, 0, &hover)) {
|
||||
if(page == 0) {
|
||||
app->tutorial_step = 1;
|
||||
app->manual_scroll = 0;
|
||||
} else {
|
||||
meditation_manual_start(app);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(IsMouseButtonReleased(MOUSE_BUTTON_LEFT) && app->settings_dirty)
|
||||
save_settings(app);
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
#include "meditation_practice.h"
|
||||
|
||||
#include "app.h"
|
||||
#include "meditation_music.h"
|
||||
|
||||
void
|
||||
meditation_practice_init(InbeApp *app)
|
||||
{
|
||||
if(app != NULL && app->meditation.image_1.id == 0)
|
||||
app->meditation.image_1 = app_load_asset_texture("practices/meditation/1.jpg");
|
||||
meditation_music_init(app);
|
||||
}
|
||||
|
||||
void
|
||||
meditation_practice_destroy(InbeApp *app)
|
||||
{
|
||||
if(app != NULL)
|
||||
app_unload_texture(app->meditation.image_1);
|
||||
meditation_music_unload(app);
|
||||
}
|
||||
|
||||
void
|
||||
meditation_practice_start(InbeApp *app)
|
||||
{
|
||||
if(app == NULL)
|
||||
return;
|
||||
mark_exercise_manual_seen(app, EXERCISE_MEDITATION);
|
||||
app->modal.active = 1;
|
||||
app->modal.type = UIModalMeditationSetup;
|
||||
app->modal.selected_button = 0;
|
||||
app->inbe.screen = InbeScreenStart;
|
||||
}
|
||||
|
||||
void
|
||||
meditation_practice_update(InbeApp *app)
|
||||
{
|
||||
meditation_music_update(app);
|
||||
}
|
||||
|
||||
void
|
||||
meditation_practice_leave_config(InbeApp *app)
|
||||
{
|
||||
meditation_music_unload(app);
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
#ifndef INBE_MEDITATION_PRACTICE_H
|
||||
#define INBE_MEDITATION_PRACTICE_H
|
||||
|
||||
#include "app_fwd.h"
|
||||
|
||||
void meditation_practice_init(InbeApp *app);
|
||||
void meditation_practice_destroy(InbeApp *app);
|
||||
void meditation_practice_start(InbeApp *app);
|
||||
void meditation_practice_update(InbeApp *app);
|
||||
void meditation_practice_leave_config(InbeApp *app);
|
||||
void meditation_manual_draw(InbeApp *app);
|
||||
void meditation_manual_close(InbeApp *app, int mark_seen);
|
||||
void meditation_config_screen_draw(InbeApp *app);
|
||||
void meditation_draw_setup_modal(InbeApp *app);
|
||||
void meditation_draw_screen(InbeApp *app, int center_x, int center_y);
|
||||
void meditation_request_exit(InbeApp *app);
|
||||
|
||||
#endif
|
||||
@@ -1,342 +0,0 @@
|
||||
#include "meditation_practice.h"
|
||||
|
||||
#include "app.h"
|
||||
#include "data.h"
|
||||
#include "flint_locale.h"
|
||||
#include "meditation_music.h"
|
||||
#include "theme.h"
|
||||
#include "flint_ui.h"
|
||||
#include "raylib.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
extern int view_width;
|
||||
extern int view_height;
|
||||
|
||||
static Texture2D
|
||||
meditation_sound_icon_for_volume(InbeApp *app)
|
||||
{
|
||||
int vol = app->sound_volume;
|
||||
if(vol <= 0)
|
||||
return app->icons[UI_ICON_TYPE_SOUND0];
|
||||
if(vol <= 25)
|
||||
return app->icons[UI_ICON_TYPE_SOUND1];
|
||||
if(vol <= 75)
|
||||
return app->icons[UI_ICON_TYPE_SOUND2];
|
||||
return app->icons[UI_ICON_TYPE_SOUND3];
|
||||
}
|
||||
|
||||
static void
|
||||
meditation_start(InbeApp *app, int seconds)
|
||||
{
|
||||
if(app == NULL)
|
||||
return;
|
||||
|
||||
app->meditation.duration_seconds = seconds;
|
||||
app->meditation.remaining_seconds = seconds;
|
||||
app->meditation.frame_ticks = 0;
|
||||
app->session_paused = 0;
|
||||
app->volume_popup_active = 0;
|
||||
app->modal.active = 0;
|
||||
app->modal.type = UIModalNone;
|
||||
app->inbe.screen = InbeScreenMeditation;
|
||||
app_play_sound(app, app->bell_sound, 1.0f);
|
||||
meditation_music_start_session(app);
|
||||
}
|
||||
|
||||
static void
|
||||
meditation_finish(InbeApp *app)
|
||||
{
|
||||
int duration;
|
||||
|
||||
if(app == NULL)
|
||||
return;
|
||||
|
||||
duration = app->meditation.duration_seconds;
|
||||
if(duration >= 60) {
|
||||
int session_duration = duration;
|
||||
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);
|
||||
app->meditation.duration_seconds = 0;
|
||||
app->meditation.remaining_seconds = 0;
|
||||
app->meditation.frame_ticks = 0;
|
||||
app->session_paused = 0;
|
||||
app->volume_popup_active = 0;
|
||||
meditation_music_stop(app);
|
||||
app->inbe.screen = InbeScreenStart;
|
||||
}
|
||||
|
||||
static int
|
||||
meditation_elapsed_seconds(InbeApp *app)
|
||||
{
|
||||
int elapsed;
|
||||
|
||||
if(app == NULL)
|
||||
return 0;
|
||||
elapsed = app->meditation.duration_seconds - app->meditation.remaining_seconds;
|
||||
if(elapsed < 0)
|
||||
elapsed = 0;
|
||||
if(elapsed > app->meditation.duration_seconds)
|
||||
elapsed = app->meditation.duration_seconds;
|
||||
return elapsed;
|
||||
}
|
||||
|
||||
static int
|
||||
meditation_save_elapsed(InbeApp *app)
|
||||
{
|
||||
int elapsed;
|
||||
|
||||
if(app == NULL)
|
||||
return 0;
|
||||
elapsed = meditation_elapsed_seconds(app);
|
||||
if(elapsed < 60)
|
||||
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;
|
||||
}
|
||||
|
||||
static void
|
||||
meditation_exit_to_start(InbeApp *app)
|
||||
{
|
||||
if(app == NULL)
|
||||
return;
|
||||
meditation_music_stop(app);
|
||||
app->meditation.duration_seconds = 0;
|
||||
app->meditation.remaining_seconds = 0;
|
||||
app->meditation.frame_ticks = 0;
|
||||
app->session_paused = 0;
|
||||
app->volume_popup_active = 0;
|
||||
app->modal.active = 0;
|
||||
app->modal.type = UIModalNone;
|
||||
app->inbe.screen = InbeScreenStart;
|
||||
}
|
||||
|
||||
void
|
||||
meditation_request_exit(InbeApp *app)
|
||||
{
|
||||
if(app == NULL)
|
||||
return;
|
||||
app->modal.active = 1;
|
||||
app->modal.type = UIModalConfirmExitSession;
|
||||
app->modal.selected_button = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
format_meditation_time(char *dst, size_t dst_size, int seconds)
|
||||
{
|
||||
int hours;
|
||||
int minutes;
|
||||
int secs;
|
||||
|
||||
if(dst == NULL || dst_size == 0)
|
||||
return;
|
||||
if(seconds < 0)
|
||||
seconds = 0;
|
||||
|
||||
hours = seconds / 3600;
|
||||
minutes = (seconds / 60) % 60;
|
||||
secs = seconds % 60;
|
||||
|
||||
if(hours > 0)
|
||||
snprintf(dst, dst_size, "%d:%02d:%02d", hours, minutes, secs);
|
||||
else
|
||||
snprintf(dst, dst_size, "%d:%02d", minutes, secs);
|
||||
}
|
||||
|
||||
static int
|
||||
draw_meditation_duration_button(int x, int y, int w, int h, const char *label)
|
||||
{
|
||||
int hover = 0;
|
||||
return ui_draw_generic_button(x, y, w, h, label, UI_BUTTON_STYLE_PRIMARY, 0, &hover);
|
||||
}
|
||||
|
||||
void
|
||||
meditation_draw_setup_modal(InbeApp *app)
|
||||
{
|
||||
static const int durations[] = {5 * 60, 15 * 60, 30 * 60, 60 * 60, 2 * 60 * 60};
|
||||
const char *labels[] = {
|
||||
locale_get("duration_5m"),
|
||||
locale_get("duration_15m"),
|
||||
locale_get("duration_30m"),
|
||||
locale_get("duration_1h"),
|
||||
locale_get("duration_2h")
|
||||
};
|
||||
int modal_w = flint_px(320);
|
||||
int modal_h = flint_px(236);
|
||||
int modal_x;
|
||||
int modal_y;
|
||||
int title_font = flint_px(18);
|
||||
int title_w;
|
||||
int btn_h = flint_px(38);
|
||||
int gap = flint_px(10);
|
||||
int side = flint_px(18);
|
||||
int row_y;
|
||||
int btn_w;
|
||||
int cancel_w = flint_px(120);
|
||||
int cancel_x;
|
||||
int cancel_y;
|
||||
int cancel_hover = 0;
|
||||
|
||||
if(modal_w > view_width - flint_px(24))
|
||||
modal_w = view_width - flint_px(24);
|
||||
if(modal_h > view_height - flint_px(24))
|
||||
modal_h = view_height - flint_px(24);
|
||||
|
||||
modal_x = (view_width - modal_w) / 2;
|
||||
modal_y = (view_height - modal_h) / 2;
|
||||
btn_w = (modal_w - side * 2 - gap * 2) / 3;
|
||||
if(btn_w < flint_px(64))
|
||||
btn_w = flint_px(64);
|
||||
|
||||
DrawRectangle(0, 0, view_width, view_height, (Color){0, 0, 0, 180});
|
||||
DrawRectangle(modal_x, modal_y, modal_w, modal_h, theme_get_surface());
|
||||
ui_draw_bevel(modal_x, modal_y, modal_w, modal_h,
|
||||
flint_lighten(theme_get_surface(), 40), flint_darken(theme_get_surface(), 40));
|
||||
|
||||
title_w = flint_text_measure(locale_get("meditation_title"), title_font);
|
||||
flint_text_draw(locale_get("meditation_title"), modal_x + (modal_w - title_w) / 2,
|
||||
modal_y + flint_px(16), title_font, theme_get_text());
|
||||
|
||||
row_y = modal_y + flint_px(62);
|
||||
for(int i = 0; i < 3; i++) {
|
||||
int x = modal_x + side + i * (btn_w + gap);
|
||||
if(draw_meditation_duration_button(x, row_y, btn_w, btn_h, labels[i]))
|
||||
meditation_start(app, durations[i]);
|
||||
}
|
||||
|
||||
row_y += btn_h + gap;
|
||||
for(int i = 3; i < 5; i++) {
|
||||
int two_w = (modal_w - side * 2 - gap) / 2;
|
||||
int x = modal_x + side + (i - 3) * (two_w + gap);
|
||||
if(draw_meditation_duration_button(x, row_y, two_w, btn_h, labels[i]))
|
||||
meditation_start(app, durations[i]);
|
||||
}
|
||||
|
||||
cancel_y = modal_y + modal_h - btn_h - flint_px(16);
|
||||
cancel_x = modal_x + (modal_w - cancel_w) / 2;
|
||||
if(ui_draw_generic_button(cancel_x, cancel_y, cancel_w, btn_h,
|
||||
locale_get("cancel_button"), UI_BUTTON_STYLE_SECONDARY,
|
||||
0, &cancel_hover)) {
|
||||
app->modal.active = 0;
|
||||
app->modal.type = UIModalNone;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
draw_meditation_sound_controls(InbeApp *app)
|
||||
{
|
||||
int sound_btn_x = view_width - flint_px(56);
|
||||
int sound_btn_y = flint_px(12);
|
||||
int sound_btn_size = flint_px(24);
|
||||
int sound_btn_padding = flint_px(10);
|
||||
int sound_hover = 0;
|
||||
|
||||
if(ui_draw_icon_btn_padded(sound_btn_x, sound_btn_y, sound_btn_size, sound_btn_padding,
|
||||
meditation_sound_icon_for_volume(app), &sound_hover)) {
|
||||
app->volume_popup_active = !app->volume_popup_active;
|
||||
}
|
||||
|
||||
if(app->volume_popup_active) {
|
||||
int popup_w = flint_px(44);
|
||||
int popup_x = sound_btn_x;
|
||||
int popup_y = sound_btn_y + sound_btn_size + sound_btn_padding * 2;
|
||||
int popup_h = flint_px(200);
|
||||
Vector2 mouse = GetMousePosition();
|
||||
|
||||
if(IsMouseButtonPressed(MOUSE_BUTTON_LEFT) &&
|
||||
(mouse.x < popup_x || mouse.x > popup_x + popup_w ||
|
||||
mouse.y < popup_y || mouse.y > popup_y + popup_h)) {
|
||||
app->volume_popup_active = 0;
|
||||
}
|
||||
|
||||
DrawRectangle(popup_x, popup_y, popup_w, popup_h, theme_get_surface());
|
||||
ui_draw_bevel(popup_x, popup_y, popup_w, popup_h,
|
||||
flint_lighten(theme_get_surface(), 40), flint_darken(theme_get_surface(), 40));
|
||||
|
||||
if(ui_draw_slider_vertical(501, popup_x + popup_w / 2, popup_y + flint_px(10),
|
||||
popup_h - flint_px(20), SETTINGS_VOLUME_MIN,
|
||||
SETTINGS_VOLUME_MAX, &app->sound_volume)) {
|
||||
app->settings_dirty = 1;
|
||||
save_settings(app);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
meditation_draw_screen(InbeApp *app, int center_x, int center_y)
|
||||
{
|
||||
char time_text[32];
|
||||
int return_hover = 0;
|
||||
int font = flint_px(48);
|
||||
int max_w;
|
||||
int text_w;
|
||||
|
||||
if(ui_draw_icon_btn_padded(flint_px(12), flint_px(12), flint_px(24),
|
||||
flint_px(10), app->icons[UI_ICON_TYPE_RETURN], &return_hover)) {
|
||||
meditation_request_exit(app);
|
||||
return;
|
||||
}
|
||||
|
||||
draw_meditation_sound_controls(app);
|
||||
|
||||
if(app->modal.active && app->modal.type == UIModalConfirmExitSession) {
|
||||
int elapsed = meditation_elapsed_seconds(app);
|
||||
int modal_result;
|
||||
|
||||
if(elapsed >= 60) {
|
||||
modal_result = ui_draw_modal_3btn(locale_get("exit_session_title"),
|
||||
locale_get("meditation_save_elapsed_message"),
|
||||
locale_get("cancel_button"),
|
||||
locale_get("save_button"),
|
||||
locale_get("discard_button"));
|
||||
if(modal_result == 1) {
|
||||
app->modal.active = 0;
|
||||
app->modal.type = UIModalNone;
|
||||
} else if(modal_result == 2) {
|
||||
meditation_save_elapsed(app);
|
||||
meditation_exit_to_start(app);
|
||||
} else if(modal_result == 3) {
|
||||
meditation_exit_to_start(app);
|
||||
}
|
||||
} else {
|
||||
modal_result = ui_draw_modal(locale_get("exit_session_title"),
|
||||
locale_get("meditation_under_minute_exit_message"),
|
||||
locale_get("cancel_button"),
|
||||
locale_get("exit_button"));
|
||||
if(modal_result == 1) {
|
||||
app->modal.active = 0;
|
||||
app->modal.type = UIModalNone;
|
||||
} else if(modal_result == 2) {
|
||||
meditation_exit_to_start(app);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
format_meditation_time(time_text, sizeof(time_text), app->meditation.remaining_seconds);
|
||||
max_w = view_width - flint_px(48);
|
||||
while(font > flint_px(28) && flint_text_measure(time_text, font) > max_w)
|
||||
font--;
|
||||
text_w = flint_text_measure(time_text, font);
|
||||
flint_text_draw(time_text, center_x - text_w / 2,
|
||||
flint_ui_text_y(time_text, center_y - font, font * 2, font),
|
||||
font, theme_get_text());
|
||||
|
||||
app->meditation.frame_ticks++;
|
||||
if(app->meditation.frame_ticks >= 60) {
|
||||
app->meditation.frame_ticks = 0;
|
||||
if(app->meditation.remaining_seconds > 0)
|
||||
app->meditation.remaining_seconds--;
|
||||
if(app->meditation.remaining_seconds <= 0)
|
||||
meditation_finish(app);
|
||||
}
|
||||
}
|
||||
@@ -1,110 +0,0 @@
|
||||
#include "practice_registry.h"
|
||||
|
||||
#include "app.h"
|
||||
#include "flint_locale.h"
|
||||
#include "practices/whm/whm_practice.h"
|
||||
#include "practices/whm/whm_session.h"
|
||||
#include "practices/meditation/meditation_practice.h"
|
||||
|
||||
static const PracticeDefinition g_practices[PRACTICE_COUNT] = {
|
||||
{
|
||||
.id = PRACTICE_WHM,
|
||||
.label_key = "exercise_wim_hof",
|
||||
.init = whm_practice_init,
|
||||
.destroy = whm_practice_destroy,
|
||||
.start = whm_practice_start,
|
||||
.draw_manual = whm_manual_draw,
|
||||
.close_manual = whm_manual_close,
|
||||
.draw_config = whm_config_screen_draw,
|
||||
.leave_config = whm_practice_leave_config,
|
||||
.update = NULL,
|
||||
.draw_setup_modal = NULL,
|
||||
.draw_active_session = NULL,
|
||||
.request_exit = NULL,
|
||||
},
|
||||
{
|
||||
.id = PRACTICE_MEDITATION,
|
||||
.label_key = "exercise_meditation",
|
||||
.init = meditation_practice_init,
|
||||
.destroy = meditation_practice_destroy,
|
||||
.start = meditation_practice_start,
|
||||
.draw_manual = meditation_manual_draw,
|
||||
.close_manual = meditation_manual_close,
|
||||
.draw_config = meditation_config_screen_draw,
|
||||
.leave_config = meditation_practice_leave_config,
|
||||
.update = meditation_practice_update,
|
||||
.draw_setup_modal = meditation_draw_setup_modal,
|
||||
.draw_active_session = meditation_draw_screen,
|
||||
.request_exit = meditation_request_exit,
|
||||
},
|
||||
};
|
||||
|
||||
const PracticeDefinition *
|
||||
practice_get(int id)
|
||||
{
|
||||
id = practice_clamp_id(id);
|
||||
return &g_practices[id];
|
||||
}
|
||||
|
||||
int
|
||||
practice_count(void)
|
||||
{
|
||||
return PRACTICE_COUNT;
|
||||
}
|
||||
|
||||
int
|
||||
practice_clamp_id(int id)
|
||||
{
|
||||
if(id < 0 || id >= PRACTICE_COUNT)
|
||||
return PRACTICE_WHM;
|
||||
return id;
|
||||
}
|
||||
|
||||
const char *
|
||||
practice_label(int id)
|
||||
{
|
||||
return locale_get(practice_get(id)->label_key);
|
||||
}
|
||||
|
||||
void
|
||||
practice_update_circle_bounds(InbeApp *app, int top_reserve, int bottom_reserve)
|
||||
{
|
||||
if(app != NULL)
|
||||
session_update_circle_bounds_for_view(&app->inbe, top_reserve, bottom_reserve);
|
||||
}
|
||||
|
||||
void
|
||||
practice_update_session_sounds(InbeApp *app)
|
||||
{
|
||||
update_session_sounds(app);
|
||||
}
|
||||
|
||||
int
|
||||
practice_ensure_results_saved(InbeApp *app)
|
||||
{
|
||||
return session_ensure_results_saved(app);
|
||||
}
|
||||
|
||||
int
|
||||
practice_draw_start_preview(InbeApp *app, int center_x, int center_y)
|
||||
{
|
||||
return session_draw_start_preview(app, center_x, center_y);
|
||||
}
|
||||
|
||||
void
|
||||
practice_draw_active_breathing(InbeApp *app, int center_x, int center_y)
|
||||
{
|
||||
session_draw_inbe(app, center_x, center_y);
|
||||
}
|
||||
|
||||
void
|
||||
practice_update_active_breathing(InbeApp *app, int center_x, int center_y, int *hover)
|
||||
{
|
||||
session_update_screen(app, center_x, center_y, hover);
|
||||
}
|
||||
|
||||
void
|
||||
practice_draw_results(InbeApp *app, int center_x, int center_y, int *hover)
|
||||
{
|
||||
session_draw_results_screen(app, center_x, center_y, hover);
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
#ifndef INBE_PRACTICE_REGISTRY_H
|
||||
#define INBE_PRACTICE_REGISTRY_H
|
||||
|
||||
#include "app_fwd.h"
|
||||
|
||||
typedef enum PracticeId {
|
||||
PRACTICE_WHM = 0,
|
||||
PRACTICE_MEDITATION = 1,
|
||||
PRACTICE_COUNT = 2
|
||||
} PracticeId;
|
||||
|
||||
typedef struct PracticeDefinition {
|
||||
PracticeId id;
|
||||
const char *label_key;
|
||||
void (*init)(InbeApp *app);
|
||||
void (*destroy)(InbeApp *app);
|
||||
void (*start)(InbeApp *app);
|
||||
void (*draw_manual)(InbeApp *app);
|
||||
void (*close_manual)(InbeApp *app, int mark_seen);
|
||||
void (*draw_config)(InbeApp *app);
|
||||
void (*leave_config)(InbeApp *app);
|
||||
void (*update)(InbeApp *app);
|
||||
void (*draw_setup_modal)(InbeApp *app);
|
||||
void (*draw_active_session)(InbeApp *app, int center_x, int center_y);
|
||||
void (*request_exit)(InbeApp *app);
|
||||
} PracticeDefinition;
|
||||
|
||||
const PracticeDefinition *practice_get(int id);
|
||||
int practice_count(void);
|
||||
int practice_clamp_id(int id);
|
||||
const char *practice_label(int id);
|
||||
void practice_update_circle_bounds(InbeApp *app, int top_reserve, int bottom_reserve);
|
||||
void practice_update_session_sounds(InbeApp *app);
|
||||
int practice_ensure_results_saved(InbeApp *app);
|
||||
int practice_draw_start_preview(InbeApp *app, int center_x, int center_y);
|
||||
void practice_draw_active_breathing(InbeApp *app, int center_x, int center_y);
|
||||
void practice_update_active_breathing(InbeApp *app, int center_x, int center_y, int *hover);
|
||||
void practice_draw_results(InbeApp *app, int center_x, int center_y, int *hover);
|
||||
|
||||
#endif
|
||||
@@ -1,418 +0,0 @@
|
||||
#include "whm_practice.h"
|
||||
|
||||
#include "app.h"
|
||||
#include "flint_locale.h"
|
||||
#include "whm_session.h"
|
||||
#include "theme.h"
|
||||
#include "flint_ui.h"
|
||||
#include "raylib.h"
|
||||
|
||||
extern int view_width;
|
||||
extern int view_height;
|
||||
|
||||
static void
|
||||
whm_draw_exact_speed_preview(Inbe *preview, int *preview_speed,
|
||||
int speed, int max_rounds, int max_breaths,
|
||||
int pause_seconds, int content_w, int content_h,
|
||||
int center_x, int center_y)
|
||||
{
|
||||
if(preview == NULL || preview_speed == NULL)
|
||||
return;
|
||||
|
||||
if(preview->phase != InbePhaseBreathe) {
|
||||
inbeinit(preview);
|
||||
apply_settings(preview, speed, max_rounds, max_breaths, pause_seconds);
|
||||
preview->progressive_speed = 0;
|
||||
session_reset_round_breathe(preview);
|
||||
} else if(*preview_speed != speed) {
|
||||
apply_settings(preview, speed, max_rounds, max_breaths, pause_seconds);
|
||||
preview->progressive_speed = 0;
|
||||
}
|
||||
|
||||
if(*preview_speed != speed)
|
||||
*preview_speed = speed;
|
||||
|
||||
update_preview_bounds(preview, content_w, content_h);
|
||||
inbestep(preview);
|
||||
draw_preview_inbe(preview, center_x, center_y);
|
||||
}
|
||||
|
||||
static void
|
||||
whm_draw_progressive_start_speed_editor(InbeApp *app)
|
||||
{
|
||||
int modal_w = flint_px(340);
|
||||
int modal_h = flint_px(360);
|
||||
int modal_x;
|
||||
int modal_y;
|
||||
int title_font = flint_ui_font();
|
||||
int title_y;
|
||||
int close_size = flint_px(22);
|
||||
int close_padding = flint_px(8);
|
||||
int close_w = close_size + close_padding * 2;
|
||||
int close_hover = 0;
|
||||
int max_speed = app->inbe.speed_level;
|
||||
int start_speed = clampi(app->inbe.progressive_start_speed, SETTINGS_SPEED_MIN, max_speed);
|
||||
const char *title;
|
||||
int title_w;
|
||||
int title_max_w;
|
||||
|
||||
if(modal_w > view_width - flint_px(24))
|
||||
modal_w = view_width - flint_px(24);
|
||||
if(modal_h > view_height - flint_px(24))
|
||||
modal_h = view_height - flint_px(24);
|
||||
modal_x = (view_width - modal_w) / 2;
|
||||
modal_y = (view_height - modal_h) / 2;
|
||||
title_y = modal_y + flint_px(14);
|
||||
|
||||
DrawRectangle(0, 0, view_width, view_height, (Color){0, 0, 0, 180});
|
||||
DrawRectangle(modal_x, modal_y, modal_w, modal_h, theme_get_surface());
|
||||
ui_draw_bevel(modal_x, modal_y, modal_w, modal_h,
|
||||
flint_lighten(theme_get_surface(), 40), flint_darken(theme_get_surface(), 40));
|
||||
|
||||
title = locale_get("progressive_start_speed_editor_title");
|
||||
title_w = flint_text_measure(title, title_font);
|
||||
title_max_w = modal_w - close_w * 2 - flint_px(24);
|
||||
while(title_font > flint_px(12) && title_w > title_max_w) {
|
||||
title_font--;
|
||||
title_w = flint_text_measure(title, title_font);
|
||||
}
|
||||
flint_text_draw(title, modal_x + (modal_w - title_w) / 2, title_y, title_font, theme_get_text());
|
||||
|
||||
if(ui_draw_icon_btn_padded(modal_x + modal_w - close_w - flint_px(6), modal_y + flint_px(6),
|
||||
close_size, close_padding, app->icons[UI_ICON_TYPE_X], &close_hover)) {
|
||||
app->modal.active = 0;
|
||||
app->modal.type = UIModalNone;
|
||||
return;
|
||||
}
|
||||
|
||||
whm_draw_exact_speed_preview(&app->start_speed_preview,
|
||||
&app->start_speed_preview_speed,
|
||||
start_speed,
|
||||
app->inbe.max_rounds,
|
||||
int_from_count(app->inbe.maxbreaths),
|
||||
app->inbe.pause_seconds,
|
||||
modal_w - flint_px(48),
|
||||
flint_px(210),
|
||||
modal_x + modal_w / 2,
|
||||
modal_y + flint_px(150));
|
||||
|
||||
if(ui_draw_slider(12, modal_x + flint_px(24), modal_y + flint_px(250),
|
||||
modal_w - flint_px(48), locale_get("progressive_start_speed_label"),
|
||||
SETTINGS_SPEED_MIN, max_speed, &start_speed, "")) {
|
||||
app->inbe.progressive_start_speed = start_speed;
|
||||
app->settings_dirty = 1;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
whm_draw_subtab_bar(int y, int h, const char **tab_names, int tab_count,
|
||||
int selected_tab)
|
||||
{
|
||||
enum { WHM_SUBTAB_RENDER_MAX = 8 };
|
||||
FlintUISubtab tabs[WHM_SUBTAB_RENDER_MAX];
|
||||
|
||||
if(tab_count <= 0 || tab_count > WHM_SUBTAB_RENDER_MAX)
|
||||
return -1;
|
||||
for(int i = 0; i < tab_count; i++) {
|
||||
tabs[i].label = tab_names[i];
|
||||
tabs[i].disabled = 0;
|
||||
}
|
||||
return ui_draw_subtab_bar((FlintUISubtabBar){
|
||||
.bounds = {0, (float)y, (float)view_width, (float)h},
|
||||
.tabs = tabs,
|
||||
.count = tab_count,
|
||||
.selected_index = selected_tab,
|
||||
.font = flint_ui_font()
|
||||
});
|
||||
}
|
||||
|
||||
static int
|
||||
whm_config_draw_breathing_tab(InbeApp *app, int content_x, int content_w, int y,
|
||||
int *draw_breath_animation_menu)
|
||||
{
|
||||
static const char *animation_options[InbeBreathAnimationCount];
|
||||
int preview_h = flint_px(240);
|
||||
int preview_radius;
|
||||
int preview_padding = flint_px(12);
|
||||
int speed = app->inbe.speed_level;
|
||||
int max_rounds = app->inbe.max_rounds;
|
||||
int max_breaths = int_from_count(app->inbe.maxbreaths);
|
||||
int pause_seconds = app->inbe.pause_seconds;
|
||||
int progressive_start_speed = app->inbe.progressive_start_speed;
|
||||
int progressive_speed = app->inbe.progressive_speed;
|
||||
int toggle_w = flint_px(56);
|
||||
int toggle_h = flint_px(30);
|
||||
|
||||
animation_options[InbeBreathAnimationLinear] = locale_get("breath_animation_linear");
|
||||
animation_options[InbeBreathAnimationInOut] = locale_get("breath_animation_in_out");
|
||||
app->inbe.breath_animation = clampi(app->inbe.breath_animation,
|
||||
InbeBreathAnimationLinear,
|
||||
InbeBreathAnimationCount - 1);
|
||||
|
||||
flint_text_draw(locale_get("breath_animation_label"), content_x, y, flint_ui_font(), theme_get_text());
|
||||
ui_draw_dropdown_button(104, content_x, y + flint_px(26), content_w, flint_px(36),
|
||||
animation_options, InbeBreathAnimationCount,
|
||||
&app->inbe.breath_animation);
|
||||
if(draw_breath_animation_menu != NULL)
|
||||
*draw_breath_animation_menu = 1;
|
||||
y += flint_px(76);
|
||||
|
||||
update_preview_bounds(&app->settings_preview, content_w, preview_h);
|
||||
apply_settings(&app->settings_preview, speed, max_rounds, max_breaths, pause_seconds);
|
||||
app->settings_preview.progressive_speed = 0;
|
||||
inbestep(&app->settings_preview);
|
||||
if(app->settings_preview.phase != InbePhaseBreathe) {
|
||||
reset_settings_preview(app);
|
||||
update_preview_bounds(&app->settings_preview, content_w, preview_h);
|
||||
apply_settings(&app->settings_preview, speed, max_rounds, max_breaths, pause_seconds);
|
||||
app->settings_preview.progressive_speed = 0;
|
||||
}
|
||||
|
||||
preview_radius = (int)((float)app->settings_preview.rmax * 0.72f + 1.0f);
|
||||
draw_preview_inbe(&app->settings_preview, content_x + content_w / 2,
|
||||
y + preview_padding + preview_radius);
|
||||
if(ui_draw_slider(1, content_x, y + preview_padding + preview_radius * 2 + flint_px(28),
|
||||
content_w, locale_get("speed_label"),
|
||||
SETTINGS_SPEED_MIN, SETTINGS_SPEED_MAX, &speed, "")) {
|
||||
apply_settings(&app->inbe, speed, max_rounds, max_breaths, pause_seconds);
|
||||
apply_settings(&app->settings_preview, speed, max_rounds, max_breaths, pause_seconds);
|
||||
app->settings_preview.progressive_speed = 0;
|
||||
app->settings_dirty = 1;
|
||||
}
|
||||
y += preview_padding + preview_radius * 2 + flint_px(102);
|
||||
|
||||
flint_text_draw(locale_get("progressive_speed_label"), content_x, y, flint_ui_font(), theme_get_text());
|
||||
if(ui_draw_toggle_switch(content_x, y + flint_px(26), 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 = 0;
|
||||
app->settings_dirty = 1;
|
||||
}
|
||||
y += flint_px(66);
|
||||
|
||||
if(app->inbe.progressive_speed) {
|
||||
int modify_w = flint_text_measure(locale_get("modify_start_speed_button"), flint_ui_font()) + flint_px(24);
|
||||
int modify_hover = 0;
|
||||
if(modify_w > content_w)
|
||||
modify_w = content_w;
|
||||
if(progressive_start_speed != clampi(progressive_start_speed, SETTINGS_SPEED_MIN, speed)) {
|
||||
app->inbe.progressive_start_speed = clampi(progressive_start_speed, SETTINGS_SPEED_MIN, speed);
|
||||
app->settings_preview.progressive_start_speed = app->inbe.progressive_start_speed;
|
||||
app->settings_dirty = 1;
|
||||
}
|
||||
if(ui_draw_generic_button(content_x, y, modify_w, flint_px(36),
|
||||
locale_get("modify_start_speed_button"),
|
||||
UI_BUTTON_STYLE_SECONDARY, 0, &modify_hover)) {
|
||||
app->modal.active = 1;
|
||||
app->modal.type = UIModalEditProgressiveStartSpeed;
|
||||
app->modal.selected_button = 0;
|
||||
}
|
||||
y += flint_px(58);
|
||||
}
|
||||
|
||||
return y;
|
||||
}
|
||||
|
||||
static int
|
||||
whm_config_draw_session_tab(InbeApp *app, int content_x, int content_w, int y)
|
||||
{
|
||||
int speed = app->inbe.speed_level;
|
||||
int max_rounds = app->inbe.max_rounds;
|
||||
int max_breaths = int_from_count(app->inbe.maxbreaths);
|
||||
int pause_seconds = app->inbe.pause_seconds;
|
||||
int advanced_session_controls = app->advanced_session_controls;
|
||||
int toggle_w = flint_px(56);
|
||||
int toggle_h = flint_px(30);
|
||||
int reset_w = flint_text_measure(locale_get("reset_to_defaults_label"), flint_ui_font()) + flint_px(24);
|
||||
int reset_h = flint_px(36);
|
||||
int reset_hover = 0;
|
||||
|
||||
if(ui_draw_slider(2, content_x, y, content_w, locale_get("max_rounds_label"),
|
||||
1, MaxRounds, &max_rounds, "")) {
|
||||
apply_settings(&app->inbe, speed, max_rounds, max_breaths, pause_seconds);
|
||||
apply_settings(&app->settings_preview, speed, max_rounds, max_breaths, pause_seconds);
|
||||
app->settings_dirty = 1;
|
||||
}
|
||||
y += flint_px(66);
|
||||
if(ui_draw_slider(3, content_x, y, content_w, locale_get("max_breaths_label"),
|
||||
SETTINGS_BREATHS_MIN, SETTINGS_BREATHS_MAX, &max_breaths, "")) {
|
||||
apply_settings(&app->inbe, speed, max_rounds, max_breaths, pause_seconds);
|
||||
apply_settings(&app->settings_preview, speed, max_rounds, max_breaths, pause_seconds);
|
||||
app->settings_dirty = 1;
|
||||
}
|
||||
y += flint_px(66);
|
||||
if(ui_draw_slider(4, content_x, y, content_w, locale_get("pause_after_round_label"),
|
||||
SETTINGS_PAUSE_MIN, SETTINGS_PAUSE_MAX, &pause_seconds, "s")) {
|
||||
apply_settings(&app->inbe, speed, max_rounds, max_breaths, pause_seconds);
|
||||
apply_settings(&app->settings_preview, speed, max_rounds, max_breaths, pause_seconds);
|
||||
app->settings_dirty = 1;
|
||||
}
|
||||
y += flint_px(66);
|
||||
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(52);
|
||||
flint_text_draw(locale_get("advanced_session_controls_label"), content_x, y, flint_ui_font(), theme_get_text());
|
||||
if(ui_draw_toggle_switch(content_x, y + flint_px(26), toggle_w, toggle_h, &advanced_session_controls,
|
||||
locale_get("toggle_off"), locale_get("toggle_on"))) {
|
||||
app->advanced_session_controls = advanced_session_controls;
|
||||
app->settings_dirty = 1;
|
||||
}
|
||||
y += flint_px(76);
|
||||
if(reset_w > content_w)
|
||||
reset_w = content_w;
|
||||
if(ui_draw_generic_button(content_x + content_w - reset_w, y, reset_w, reset_h,
|
||||
locale_get("reset_to_defaults_label"),
|
||||
UI_BUTTON_STYLE_SECONDARY, 0, &reset_hover)) {
|
||||
speed = DefaultSpeedLevel;
|
||||
max_rounds = DefaultMaxRounds;
|
||||
max_breaths = DefaultMaxBreaths;
|
||||
pause_seconds = DefaultPauseSeconds;
|
||||
app->inbe.progressive_start_speed = DefaultProgressiveStartSpeed;
|
||||
app->settings_preview.progressive_start_speed = DefaultProgressiveStartSpeed;
|
||||
app->inbe.breath_animation = InbeBreathAnimationLinear;
|
||||
app->settings_preview.breath_animation = InbeBreathAnimationLinear;
|
||||
app->advanced_session_controls = 0;
|
||||
app->hold_display_mode = HOLD_DISPLAY_CIRCLE;
|
||||
apply_settings(&app->inbe, speed, max_rounds, max_breaths, pause_seconds);
|
||||
apply_settings(&app->settings_preview, speed, max_rounds, max_breaths, pause_seconds);
|
||||
app->settings_dirty = 1;
|
||||
}
|
||||
y += reset_h + flint_px(28);
|
||||
|
||||
return y;
|
||||
}
|
||||
|
||||
static int
|
||||
whm_config_content_height(InbeApp *app, int content_w)
|
||||
{
|
||||
if(app->practice_config_tab == 0) {
|
||||
int span = content_w < flint_px(240) ? content_w : flint_px(240);
|
||||
int preview_radius = span / 2;
|
||||
int h;
|
||||
if(preview_radius < flint_px(60))
|
||||
preview_radius = flint_px(60);
|
||||
if(preview_radius > flint_px(120))
|
||||
preview_radius = flint_px(120);
|
||||
preview_radius = (int)((float)preview_radius * 0.72f + 1.0f);
|
||||
h = flint_px(12) + preview_radius * 2 + flint_px(102);
|
||||
h += flint_px(66);
|
||||
if(app->inbe.progressive_speed)
|
||||
h += flint_px(58);
|
||||
h += flint_px(76);
|
||||
return h;
|
||||
}
|
||||
|
||||
return flint_px(66) * 3 +
|
||||
flint_px(26) + flint_px(52) +
|
||||
flint_px(76) +
|
||||
flint_px(36) + flint_px(28);
|
||||
}
|
||||
|
||||
void
|
||||
whm_config_screen_draw(InbeApp *app)
|
||||
{
|
||||
int title_h = ui_screen_header_height();
|
||||
int config_tab_h = flint_px(40);
|
||||
int config_tab_gap = flint_px(14);
|
||||
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 scroll_y;
|
||||
int scroll_h;
|
||||
int content_h;
|
||||
int controls_w;
|
||||
int draw_breath_animation_menu = 0;
|
||||
int clicked_config_tab = -1;
|
||||
const char *config_tabs[] = {
|
||||
locale_get("settings_section_breathing"),
|
||||
locale_get("settings_section_session"),
|
||||
};
|
||||
FlintUIScrollArea scroll_area;
|
||||
FlintUIScrollView scroll_view;
|
||||
FlintUIHeader header;
|
||||
|
||||
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;
|
||||
flint_centered_column(responsive_max_w, flint_page_side_padding(), &content_x, &content_w);
|
||||
|
||||
if(IsMouseButtonReleased(MOUSE_BUTTON_LEFT))
|
||||
app->settings_drag_slider = 0;
|
||||
if(app->practice_config_tab < 0 || app->practice_config_tab > 1)
|
||||
app->practice_config_tab = 0;
|
||||
|
||||
header = ui_draw_title_header(title_h, locale_get("exercise_wim_hof"),
|
||||
(Texture2D){0}, app->icons[UI_ICON_TYPE_X]);
|
||||
if(header.right_clicked) {
|
||||
if(app->settings_dirty)
|
||||
save_settings(app);
|
||||
app->settings_scroll = 0;
|
||||
app->inbe.screen = InbeScreenStart;
|
||||
}
|
||||
|
||||
clicked_config_tab = whm_draw_subtab_bar(title_h, config_tab_h, config_tabs, 2,
|
||||
app->practice_config_tab);
|
||||
if(clicked_config_tab >= 0 && clicked_config_tab != app->practice_config_tab) {
|
||||
app->practice_config_tab = clicked_config_tab;
|
||||
app->settings_scroll = 0;
|
||||
}
|
||||
scroll_y = title_h + config_tab_h + config_tab_gap;
|
||||
scroll_h = view_height - scroll_y;
|
||||
if(scroll_h < 0)
|
||||
scroll_h = 0;
|
||||
|
||||
controls_w = content_w;
|
||||
for(int i = 0; i < 3; i++) {
|
||||
FlintUIScrollView measured;
|
||||
content_h = whm_config_content_height(app, controls_w);
|
||||
scroll_area = (FlintUIScrollArea){
|
||||
.bounds = {0.0f, (float)scroll_y, (float)view_width, (float)scroll_h},
|
||||
.content_height = content_h,
|
||||
.content_x = content_x,
|
||||
.content_width = content_w,
|
||||
.scroll_offset = &app->settings_scroll,
|
||||
.wheel_step = flint_px(42),
|
||||
.scrollbar_x = view_width - flint_px(8)
|
||||
};
|
||||
measured = ui_scroll_container_measure(scroll_area);
|
||||
if(measured.content_w == controls_w)
|
||||
break;
|
||||
controls_w = measured.content_w;
|
||||
}
|
||||
|
||||
content_h = whm_config_content_height(app, controls_w);
|
||||
scroll_area = (FlintUIScrollArea){
|
||||
.bounds = {0.0f, (float)scroll_y, (float)view_width, (float)scroll_h},
|
||||
.content_height = content_h,
|
||||
.content_x = content_x,
|
||||
.content_width = content_w,
|
||||
.scroll_offset = &app->settings_scroll,
|
||||
.wheel_step = flint_px(42),
|
||||
.scrollbar_x = view_width - flint_px(8)
|
||||
};
|
||||
scroll_view = ui_scroll_container_begin(scroll_area);
|
||||
if(app->practice_config_tab == 0) {
|
||||
whm_config_draw_breathing_tab(app, scroll_view.content_x, scroll_view.content_w,
|
||||
scroll_view.content_y, &draw_breath_animation_menu);
|
||||
} else {
|
||||
whm_config_draw_session_tab(app, scroll_view.content_x, scroll_view.content_w,
|
||||
scroll_view.content_y);
|
||||
}
|
||||
ui_scroll_container_end(scroll_area, scroll_view);
|
||||
|
||||
if(draw_breath_animation_menu && ui_draw_dropdown_menu(104)) {
|
||||
app->inbe.breath_animation = clampi(app->inbe.breath_animation,
|
||||
InbeBreathAnimationLinear,
|
||||
InbeBreathAnimationCount - 1);
|
||||
app->settings_preview.breath_animation = app->inbe.breath_animation;
|
||||
app->settings_preview.progressive_speed = 0;
|
||||
app->settings_dirty = 1;
|
||||
}
|
||||
|
||||
if(app->modal.active && app->modal.type == UIModalEditProgressiveStartSpeed)
|
||||
whm_draw_progressive_start_speed_editor(app);
|
||||
}
|
||||
@@ -1,355 +0,0 @@
|
||||
#include "whm_practice.h"
|
||||
#include "app.h"
|
||||
#include "whm_session.h"
|
||||
#include "flint_locale.h"
|
||||
#include "theme.h"
|
||||
#include "flint_clip.h"
|
||||
#include "flint_ui.h"
|
||||
#include "flint_theme_meta.h"
|
||||
#include "raylib.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#define CONTENT_MAX_W 800 /* Responsive width for tutorial text reflow */
|
||||
|
||||
extern int view_width;
|
||||
extern int view_height;
|
||||
|
||||
/* Tutorial text content ordered by step */
|
||||
static const char *const TUTORIAL_KEYS[] = {
|
||||
"tutorial_step_intro",
|
||||
"tutorial_step_method",
|
||||
"tutorial_step_breathe",
|
||||
"tutorial_step_exhale_hold",
|
||||
"tutorial_step_inhale_hold"
|
||||
};
|
||||
|
||||
#define TUTORIAL_STEPS_COUNT (sizeof(TUTORIAL_KEYS) / sizeof(TUTORIAL_KEYS[0]))
|
||||
#define TUTORIAL_LINE_SPACING flint_px(8) /* Normal readable line spacing */
|
||||
|
||||
static Color
|
||||
manual_text_color_for_background(Color background)
|
||||
{
|
||||
int luma = background.r * 299 + background.g * 587 + background.b * 114;
|
||||
|
||||
return luma >= 128000 ? BLACK : WHITE;
|
||||
}
|
||||
|
||||
static void
|
||||
draw_tutorial_hold_preview(InbeApp *app, int center_x, int center_y, int radius)
|
||||
{
|
||||
int seconds = (app->inbe.frame / 60) % 60;
|
||||
char text[CountSize];
|
||||
int font = flint_px(16);
|
||||
int thickness = flint_px(5);
|
||||
Color text_color = theme_get_text();
|
||||
|
||||
count_from_int(text, seconds);
|
||||
if(thickness < 3)
|
||||
thickness = 3;
|
||||
|
||||
if(app->hold_display_mode == HOLD_DISPLAY_CIRCLE) {
|
||||
float sweep = 360.0f * (float)((app->inbe.frame % (60 * 60))) / (float)(60 * 60);
|
||||
|
||||
DrawRing((Vector2){center_x, center_y},
|
||||
(float)(radius + flint_px(8) - thickness / 2),
|
||||
(float)(radius + flint_px(8) + thickness / 2),
|
||||
-90.0f, -90.0f + sweep, 96, theme_get_text());
|
||||
text_color = manual_text_color_for_background(theme_get_bg());
|
||||
} else {
|
||||
DrawCircle(center_x, center_y, radius, theme_get_circle());
|
||||
DrawCircleLines(center_x, center_y, radius, theme_get_text());
|
||||
text_color = manual_text_color_for_background(theme_get_circle());
|
||||
}
|
||||
|
||||
flint_ui_draw_text_centered(text, center_x, center_y, font, text_color);
|
||||
}
|
||||
|
||||
static FlintUIParagraph
|
||||
tutorial_paragraph(InbeApp *app, int step, int content_w, int body_font)
|
||||
{
|
||||
int has_icon = step == 1;
|
||||
return (FlintUIParagraph){
|
||||
.text = locale_get(TUTORIAL_KEYS[step]),
|
||||
.icon = has_icon ? app->icons[UI_ICON_TYPE_WRENCH] : (Texture2D){0},
|
||||
.icon_type = has_icon ? UI_ICON_TYPE_WRENCH : UI_ICON_TYPE_NONE,
|
||||
.icon_size = has_icon ? flint_px(14) : 0,
|
||||
.width = content_w,
|
||||
.font = body_font,
|
||||
.line_gap = TUTORIAL_LINE_SPACING,
|
||||
.color = theme_get_text(),
|
||||
};
|
||||
}
|
||||
|
||||
static int
|
||||
tutorial_paragraph_height(InbeApp *app, int step, int content_w, int body_font)
|
||||
{
|
||||
return flint_ui_paragraph_height(tutorial_paragraph(app, step, content_w, body_font));
|
||||
}
|
||||
|
||||
static void
|
||||
draw_tutorial_paragraph(InbeApp *app, int step, int content_x, int *y, int content_w, int body_font)
|
||||
{
|
||||
flint_ui_paragraph_draw(tutorial_paragraph(app, step, content_w, body_font), content_x, y);
|
||||
}
|
||||
|
||||
static int
|
||||
manual_tutorial_content_height(InbeApp *app, int step, int content_w, int body_font)
|
||||
{
|
||||
int actual_content_h = 0;
|
||||
|
||||
if(step == 0) {
|
||||
actual_content_h += flint_px(170) + flint_px(22) +
|
||||
tutorial_paragraph_height(app, 0, content_w, body_font);
|
||||
} else if(step == 1) {
|
||||
actual_content_h += tutorial_paragraph_height(app, 1, content_w, body_font);
|
||||
} else if(step == 2) {
|
||||
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);
|
||||
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) {
|
||||
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);
|
||||
} else {
|
||||
actual_content_h += flint_px(80) +
|
||||
tutorial_paragraph_height(app, 4, content_w, body_font);
|
||||
}
|
||||
|
||||
return actual_content_h;
|
||||
}
|
||||
|
||||
void
|
||||
whm_manual_close(InbeApp *app, int mark_seen)
|
||||
{
|
||||
if(mark_seen)
|
||||
mark_exercise_manual_seen(app, EXERCISE_WIM_HOF);
|
||||
app->tutorial_step = 0;
|
||||
app->manual_scroll = 0;
|
||||
app->inbe.screen = InbeScreenStart;
|
||||
}
|
||||
|
||||
static void
|
||||
manual_screen_start_exercise(InbeApp *app)
|
||||
{
|
||||
mark_exercise_manual_seen(app, EXERCISE_WIM_HOF);
|
||||
app->tutorial_step = 0;
|
||||
app->manual_scroll = 0;
|
||||
session_start(app);
|
||||
}
|
||||
|
||||
void
|
||||
whm_manual_draw(InbeApp *app)
|
||||
{
|
||||
int title_h = ui_screen_header_height();
|
||||
int tab_h = flint_px(56);
|
||||
int viewport_h = view_height - title_h - tab_h;
|
||||
int body_font = flint_ui_font();
|
||||
int footer_content_pad = flint_ui_font() / 2;
|
||||
int content_area_h = viewport_h - footer_content_pad; /* For scissor mode and scroll calculations */
|
||||
int previous_step;
|
||||
int content_x;
|
||||
int content_w;
|
||||
const char *title = locale_get("tutorial_title");
|
||||
char page_label[32];
|
||||
int close_clicked = 0;
|
||||
int step = app->tutorial_step;
|
||||
FlintUIScrollArea scroll_area;
|
||||
FlintUIScrollView scroll_view;
|
||||
|
||||
step = clampi(step, 0, (int)TUTORIAL_STEPS_COUNT - 1);
|
||||
app->tutorial_step = step;
|
||||
previous_step = step;
|
||||
|
||||
if(IsKeyPressed(KEY_RIGHT) || IsKeyPressed(KEY_ENTER)) {
|
||||
if(step < (int)TUTORIAL_STEPS_COUNT - 1)
|
||||
app->tutorial_step++;
|
||||
else
|
||||
manual_screen_start_exercise(app);
|
||||
}
|
||||
if(IsKeyPressed(KEY_LEFT) && step > 0)
|
||||
app->tutorial_step--;
|
||||
if(IsKeyPressed(KEY_ESCAPE))
|
||||
whm_manual_close(app, 0);
|
||||
|
||||
step = app->tutorial_step;
|
||||
if(previous_step != step) {
|
||||
app->manual_scroll = 0;
|
||||
previous_step = step;
|
||||
}
|
||||
|
||||
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;
|
||||
default: break;
|
||||
}
|
||||
|
||||
/* Calculate responsive content width */
|
||||
int responsive_max_w = (int)(view_width * 0.96f);
|
||||
int max_content_w = flint_px(CONTENT_MAX_W);
|
||||
if(responsive_max_w > max_content_w)
|
||||
responsive_max_w = max_content_w;
|
||||
int min_width = flint_px(280);
|
||||
if(responsive_max_w < min_width)
|
||||
responsive_max_w = min_width;
|
||||
|
||||
int side_padding = flint_page_side_padding();
|
||||
flint_centered_column(responsive_max_w, side_padding, &content_x, &content_w);
|
||||
|
||||
close_clicked = ui_draw_screen_header(title, 1);
|
||||
if(close_clicked)
|
||||
whm_manual_close(app, 0);
|
||||
|
||||
{
|
||||
int top_padding = flint_px(16);
|
||||
int total_content_h;
|
||||
|
||||
for(int pass = 0; pass < 3; pass++) {
|
||||
FlintUIScrollView measured;
|
||||
|
||||
total_content_h = manual_tutorial_content_height(app, step, content_w, body_font) +
|
||||
top_padding;
|
||||
scroll_area = (FlintUIScrollArea){
|
||||
.bounds = {0.0f, (float)title_h, (float)view_width, (float)content_area_h},
|
||||
.content_height = total_content_h,
|
||||
.content_x = content_x,
|
||||
.content_width = content_w,
|
||||
.scroll_offset = &app->manual_scroll,
|
||||
.wheel_step = flint_px(42),
|
||||
.scrollbar_x = view_width - flint_px(8)
|
||||
};
|
||||
measured = ui_scroll_container_measure(scroll_area);
|
||||
if(measured.content_w == content_w)
|
||||
break;
|
||||
content_w = measured.content_w;
|
||||
}
|
||||
scroll_area = (FlintUIScrollArea){
|
||||
.bounds = {0.0f, (float)title_h, (float)view_width, (float)content_area_h},
|
||||
.content_height = manual_tutorial_content_height(app, step, content_w, body_font) +
|
||||
top_padding,
|
||||
.content_x = content_x,
|
||||
.content_width = content_w,
|
||||
.scroll_offset = &app->manual_scroll,
|
||||
.wheel_step = flint_px(42),
|
||||
.scrollbar_x = view_width - flint_px(8)
|
||||
};
|
||||
}
|
||||
|
||||
scroll_view = ui_scroll_container_begin(scroll_area);
|
||||
content_x = scroll_view.content_x;
|
||||
content_w = scroll_view.content_w;
|
||||
{
|
||||
int y = scroll_view.content_y + flint_px(16);
|
||||
if(step == 0) {
|
||||
int img_h = flint_px(170);
|
||||
ui_draw_tutorial_image(app->whm.image_1, "practices/whm/1.jpg", content_x, y, content_w, img_h);
|
||||
y += img_h + flint_px(22);
|
||||
|
||||
draw_tutorial_paragraph(app, 0, content_x, &y, content_w, body_font);
|
||||
} 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(20); /* Increased spacing between text and circle */
|
||||
|
||||
update_preview_bounds(&app->settings_preview, content_w, flint_px(132));
|
||||
apply_settings(&app->settings_preview, speed, app->inbe.max_rounds,
|
||||
int_from_count(app->inbe.maxbreaths), app->inbe.pause_seconds);
|
||||
app->settings_preview.progressive_speed = 0;
|
||||
inbestep(&app->settings_preview);
|
||||
if(app->settings_preview.phase != InbePhaseBreathe) {
|
||||
reset_settings_preview(app);
|
||||
update_preview_bounds(&app->settings_preview, content_w, flint_px(132));
|
||||
apply_settings(&app->settings_preview, speed, app->inbe.max_rounds,
|
||||
int_from_count(app->inbe.maxbreaths), app->inbe.pause_seconds);
|
||||
app->settings_preview.progressive_speed = 0;
|
||||
}
|
||||
draw_preview_inbe(&app->settings_preview, content_x + content_w / 2, y + flint_px(40));
|
||||
y += (int)(app->settings_preview.rmax * 0.72f) + flint_px(54);
|
||||
|
||||
if(ui_draw_slider(10, content_x, y, content_w, locale_get("speed_label"), SETTINGS_SPEED_MIN,
|
||||
SETTINGS_SPEED_MAX, &speed, "")) {
|
||||
apply_settings(&app->inbe, speed, app->inbe.max_rounds,
|
||||
int_from_count(app->inbe.maxbreaths), app->inbe.pause_seconds);
|
||||
apply_settings(&app->settings_preview, speed, app->inbe.max_rounds,
|
||||
int_from_count(app->inbe.maxbreaths), app->inbe.pause_seconds);
|
||||
app->settings_preview.progressive_speed = 0;
|
||||
app->settings_dirty = 1;
|
||||
}
|
||||
} else if(step == 3) {
|
||||
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);
|
||||
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);
|
||||
}
|
||||
}
|
||||
ui_scroll_container_end(scroll_area, scroll_view);
|
||||
|
||||
locale_format(page_label, sizeof(page_label), "tutorial_page_label",
|
||||
step + 1, (int)TUTORIAL_STEPS_COUNT);
|
||||
|
||||
int left_hover = 0;
|
||||
int right_hover = 0;
|
||||
const char *left_label = step == 0 ? locale_get("tutorial_skip_button") : locale_get("tutorial_back_button");
|
||||
const char *right_label = step == (int)TUTORIAL_STEPS_COUNT - 1 ? locale_get("tutorial_start_button") : locale_get("tutorial_next_button");
|
||||
int footer_gap = flint_px(10);
|
||||
int page_font = flint_ui_font();
|
||||
int button_h = flint_px(34);
|
||||
int button_w = (content_w - footer_gap) / 2;
|
||||
int footer_y = view_height - flint_px(38);
|
||||
int counter_gap = flint_px(6);
|
||||
|
||||
|
||||
flint_text_draw(page_label,
|
||||
view_width / 2 - flint_text_measure(page_label, page_font) / 2,
|
||||
footer_y - page_font - counter_gap, page_font, theme_get_text());
|
||||
|
||||
if(step == 0) {
|
||||
if(ui_draw_generic_button(content_x, footer_y, button_w, button_h,
|
||||
left_label, UI_BUTTON_STYLE_PRIMARY, 0, &left_hover))
|
||||
manual_screen_start_exercise(app);
|
||||
} else {
|
||||
if(ui_draw_generic_button(content_x, footer_y, button_w, button_h,
|
||||
left_label, UI_BUTTON_STYLE_PRIMARY, 0, &left_hover)) {
|
||||
app->tutorial_step--;
|
||||
app->manual_scroll = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if(ui_draw_generic_button(content_x + button_w + footer_gap, footer_y, button_w, button_h,
|
||||
right_label, UI_BUTTON_STYLE_PRIMARY, 0, &right_hover)) {
|
||||
if(step == (int)TUTORIAL_STEPS_COUNT - 1)
|
||||
manual_screen_start_exercise(app);
|
||||
else {
|
||||
app->tutorial_step++;
|
||||
app->manual_scroll = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if(IsMouseButtonReleased(MOUSE_BUTTON_LEFT)) {
|
||||
app->settings_drag_slider = 0;
|
||||
if(app->settings_dirty)
|
||||
save_settings(app);
|
||||
}
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
#include "whm_practice.h"
|
||||
|
||||
#include "app.h"
|
||||
#include "whm_session.h"
|
||||
|
||||
void
|
||||
whm_practice_init(InbeApp *app)
|
||||
{
|
||||
if(app == NULL)
|
||||
return;
|
||||
if(app->whm.image_1.id == 0)
|
||||
app->whm.image_1 = app_load_asset_texture("practices/whm/1.jpg");
|
||||
if(app->whm.image_2.id == 0)
|
||||
app->whm.image_2 = app_load_asset_texture("practices/whm/2.jpg");
|
||||
}
|
||||
|
||||
void
|
||||
whm_practice_destroy(InbeApp *app)
|
||||
{
|
||||
if(app == NULL)
|
||||
return;
|
||||
app_unload_texture(app->whm.image_1);
|
||||
app_unload_texture(app->whm.image_2);
|
||||
}
|
||||
|
||||
void
|
||||
whm_practice_start(InbeApp *app)
|
||||
{
|
||||
if(app == NULL)
|
||||
return;
|
||||
mark_exercise_manual_seen(app, EXERCISE_WIM_HOF);
|
||||
session_start(app);
|
||||
}
|
||||
|
||||
void
|
||||
whm_practice_leave_config(InbeApp *app)
|
||||
{
|
||||
(void)app;
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
#ifndef INBE_WHM_PRACTICE_H
|
||||
#define INBE_WHM_PRACTICE_H
|
||||
|
||||
#include "app_fwd.h"
|
||||
|
||||
void whm_practice_init(InbeApp *app);
|
||||
void whm_practice_destroy(InbeApp *app);
|
||||
void whm_practice_start(InbeApp *app);
|
||||
void whm_practice_leave_config(InbeApp *app);
|
||||
void whm_manual_draw(InbeApp *app);
|
||||
void whm_manual_close(InbeApp *app, int mark_seen);
|
||||
void whm_config_screen_draw(InbeApp *app);
|
||||
|
||||
#endif
|
||||
@@ -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 */
|
||||
@@ -90,26 +87,23 @@ typedef struct HabitLinkedContext {
|
||||
int best_seconds;
|
||||
} HabitLinkedContext;
|
||||
|
||||
/* External functions */
|
||||
void save_settings(InbeApp *app);
|
||||
|
||||
/* 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,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"
|
||||
|
||||
@@ -1,36 +1,510 @@
|
||||
#include "manual_screen.h"
|
||||
|
||||
#include "app.h"
|
||||
#include "practices/practice_registry.h"
|
||||
#include "session.h"
|
||||
#include "locale.h"
|
||||
#include "meditation_music.h"
|
||||
#include "theme.h"
|
||||
#include "flint_clip.h"
|
||||
#include "flint_ui.h"
|
||||
#include "flint_theme_meta.h"
|
||||
#include "raylib.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#define CONTENT_MAX_W 800 /* Responsive width for tutorial text reflow */
|
||||
|
||||
extern int view_width;
|
||||
extern int view_height;
|
||||
|
||||
/* Tutorial text content ordered by step */
|
||||
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"
|
||||
};
|
||||
|
||||
#define TUTORIAL_STEPS_COUNT (sizeof(TUTORIAL_KEYS) / sizeof(TUTORIAL_KEYS[0]))
|
||||
#define TUTORIAL_LINE_SPACING flint_px(8) /* Normal readable line spacing */
|
||||
|
||||
static Color
|
||||
manual_text_color_for_background(Color background)
|
||||
{
|
||||
int luma = background.r * 299 + background.g * 587 + background.b * 114;
|
||||
|
||||
return luma >= 128000 ? BLACK : WHITE;
|
||||
}
|
||||
|
||||
static void
|
||||
draw_tutorial_hold_preview(InbeApp *app, int center_x, int center_y, int radius)
|
||||
{
|
||||
int seconds = (app->inbe.frame / 60) % 60;
|
||||
char text[CountSize];
|
||||
int font = flint_px(16);
|
||||
int thickness = flint_px(5);
|
||||
Color text_color = theme_get_text();
|
||||
|
||||
count_from_int(text, seconds);
|
||||
if(thickness < 3)
|
||||
thickness = 3;
|
||||
|
||||
if(app->hold_display_mode == HOLD_DISPLAY_CIRCLE) {
|
||||
float sweep = 360.0f * (float)((app->inbe.frame % (60 * 60))) / (float)(60 * 60);
|
||||
|
||||
DrawRing((Vector2){center_x, center_y},
|
||||
(float)(radius + flint_px(8) - thickness / 2),
|
||||
(float)(radius + flint_px(8) + thickness / 2),
|
||||
-90.0f, -90.0f + sweep, 96, theme_get_text());
|
||||
text_color = manual_text_color_for_background(theme_get_bg());
|
||||
} else {
|
||||
DrawCircle(center_x, center_y, radius, theme_get_circle());
|
||||
DrawCircleLines(center_x, center_y, radius, theme_get_text());
|
||||
text_color = manual_text_color_for_background(theme_get_circle());
|
||||
}
|
||||
|
||||
flint_ui_draw_text_centered(text, center_x, center_y, font, text_color);
|
||||
}
|
||||
|
||||
static FlintUIParagraph
|
||||
tutorial_paragraph(InbeApp *app, int step, int content_w, int body_font)
|
||||
{
|
||||
int has_icon = step == 1;
|
||||
return (FlintUIParagraph){
|
||||
.text = locale_get(TUTORIAL_KEYS[step]),
|
||||
.icon = has_icon ? app->icons[UI_ICON_TYPE_WRENCH] : (Texture2D){0},
|
||||
.icon_type = has_icon ? UI_ICON_TYPE_WRENCH : UI_ICON_TYPE_NONE,
|
||||
.icon_size = has_icon ? flint_px(14) : 0,
|
||||
.width = content_w,
|
||||
.font = body_font,
|
||||
.line_gap = TUTORIAL_LINE_SPACING,
|
||||
.color = theme_get_text(),
|
||||
};
|
||||
}
|
||||
|
||||
static int
|
||||
tutorial_paragraph_height(InbeApp *app, int step, int content_w, int body_font)
|
||||
{
|
||||
return flint_ui_paragraph_height(tutorial_paragraph(app, step, content_w, body_font));
|
||||
}
|
||||
|
||||
static void
|
||||
draw_tutorial_paragraph(InbeApp *app, int step, int content_x, int *y, int content_w, int body_font)
|
||||
{
|
||||
flint_ui_paragraph_draw(tutorial_paragraph(app, step, content_w, body_font), content_x, y);
|
||||
}
|
||||
|
||||
static int
|
||||
manual_tutorial_content_height(InbeApp *app, int step, int content_w, int body_font)
|
||||
{
|
||||
int actual_content_h = 0;
|
||||
|
||||
if(step == 0) {
|
||||
actual_content_h += flint_px(170) + flint_px(22) +
|
||||
tutorial_paragraph_height(app, 0, content_w, body_font);
|
||||
} else if(step == 1) {
|
||||
actual_content_h += tutorial_paragraph_height(app, 1, content_w, body_font);
|
||||
} else if(step == 2) {
|
||||
actual_content_h += tutorial_paragraph_height(app, 2, content_w, body_font) + flint_px(68);
|
||||
if(app->inbe.progressive_speed)
|
||||
actual_content_h += flint_px(66);
|
||||
} else if(step == 3) {
|
||||
int preview_span;
|
||||
int preview_rmax;
|
||||
int slider_h = flint_px(40);
|
||||
|
||||
actual_content_h += tutorial_paragraph_height(app, 3, content_w, body_font) + flint_px(20);
|
||||
preview_span = (content_w < flint_px(132)) ? content_w : flint_px(132);
|
||||
preview_rmax = preview_span / 2;
|
||||
if(preview_rmax < flint_px(60)) preview_rmax = flint_px(60);
|
||||
if(preview_rmax > flint_px(120)) preview_rmax = flint_px(120);
|
||||
actual_content_h += flint_px(40) + (int)((float)preview_rmax * 0.72f) + flint_px(14);
|
||||
actual_content_h += slider_h + flint_px(8);
|
||||
} else if(step == 4) {
|
||||
int hold_preview_radius = flint_px(54);
|
||||
int hold_preview_extent = hold_preview_radius + flint_px(8) + flint_px(5);
|
||||
|
||||
actual_content_h += flint_px(26) + flint_px(36) + flint_px(20);
|
||||
actual_content_h += hold_preview_extent * 2 + flint_px(24);
|
||||
actual_content_h += tutorial_paragraph_height(app, 4, content_w, body_font);
|
||||
} else {
|
||||
actual_content_h += flint_px(200) + flint_px(22) +
|
||||
tutorial_paragraph_height(app, 5, content_w, body_font);
|
||||
}
|
||||
|
||||
return actual_content_h;
|
||||
}
|
||||
|
||||
void
|
||||
manual_screen_reset_layouts(InbeApp *app)
|
||||
{
|
||||
if(app == NULL)
|
||||
return;
|
||||
|
||||
app->manual_scroll = 0;
|
||||
}
|
||||
|
||||
void
|
||||
manual_screen_close_tutorial(InbeApp *app, int mark_seen)
|
||||
{
|
||||
const PracticeDefinition *practice;
|
||||
if(mark_seen)
|
||||
mark_exercise_manual_seen(app, app->exercise_type);
|
||||
app->tutorial_step = 0;
|
||||
app->manual_scroll = 0;
|
||||
app->inbe.screen = InbeScreenStart;
|
||||
}
|
||||
|
||||
if(app == NULL)
|
||||
static void
|
||||
manual_screen_start_exercise(InbeApp *app)
|
||||
{
|
||||
mark_exercise_manual_seen(app, app->exercise_type);
|
||||
app->tutorial_step = 0;
|
||||
app->manual_scroll = 0;
|
||||
|
||||
if(app->exercise_type == EXERCISE_MEDITATION) {
|
||||
app->modal.active = 1;
|
||||
app->modal.type = UIModalMeditationSetup;
|
||||
app->modal.selected_button = 0;
|
||||
app->inbe.screen = InbeScreenStart;
|
||||
return;
|
||||
practice = practice_get(app->exercise_type);
|
||||
if(practice->close_manual != NULL)
|
||||
practice->close_manual(app, mark_seen);
|
||||
}
|
||||
|
||||
session_start(app);
|
||||
}
|
||||
|
||||
static void
|
||||
meditation_manual_draw(InbeApp *app)
|
||||
{
|
||||
int title_h = ui_screen_header_height();
|
||||
int body_font = flint_ui_font();
|
||||
int content_x;
|
||||
int content_w;
|
||||
int responsive_max_w = (int)(view_width * 0.90f);
|
||||
int max_content_w = flint_px(520);
|
||||
int y;
|
||||
int button_w;
|
||||
int button_h = flint_px(36);
|
||||
int button_y = view_height - flint_px(52);
|
||||
int content_y = title_h + flint_px(20);
|
||||
int content_h = button_y - content_y - flint_px(16);
|
||||
int content_total_h;
|
||||
FlintUIScrollArea scroll_area;
|
||||
FlintUIScrollView scroll_view;
|
||||
FlintUIParagraph paragraph;
|
||||
|
||||
if(responsive_max_w > max_content_w)
|
||||
responsive_max_w = max_content_w;
|
||||
if(responsive_max_w < flint_px(280))
|
||||
responsive_max_w = flint_px(280);
|
||||
|
||||
flint_centered_column(responsive_max_w, flint_page_side_padding(), &content_x, &content_w);
|
||||
|
||||
if(ui_draw_screen_header(locale_get("meditation_manual_title"), 1))
|
||||
manual_screen_close_tutorial(app, 0);
|
||||
|
||||
if(content_h < flint_px(120))
|
||||
content_h = flint_px(120);
|
||||
|
||||
paragraph = (FlintUIParagraph){
|
||||
.text = locale_get("meditation_manual_text"),
|
||||
.icon = (Texture2D){0},
|
||||
.icon_type = UI_ICON_TYPE_NONE,
|
||||
.icon_size = 0,
|
||||
.width = content_w,
|
||||
.font = body_font,
|
||||
.line_gap = TUTORIAL_LINE_SPACING,
|
||||
.color = theme_get_text(),
|
||||
};
|
||||
for(int pass = 0; pass < 3; pass++) {
|
||||
FlintUIScrollView measured;
|
||||
|
||||
paragraph.width = content_w;
|
||||
content_total_h = meditation_music_measure_settings(app, content_w, 0, 1) +
|
||||
flint_px(34) +
|
||||
flint_ui_paragraph_height(paragraph) +
|
||||
flint_px(20);
|
||||
scroll_area = (FlintUIScrollArea){
|
||||
.bounds = {0.0f, (float)content_y,
|
||||
(float)view_width, (float)content_h},
|
||||
.content_height = content_total_h,
|
||||
.content_x = content_x,
|
||||
.content_width = content_w,
|
||||
.scroll_offset = &app->manual_scroll,
|
||||
.wheel_step = flint_px(42),
|
||||
.scrollbar_x = view_width - flint_px(8)
|
||||
};
|
||||
measured = ui_scroll_container_measure(scroll_area);
|
||||
if(measured.content_w == content_w)
|
||||
break;
|
||||
content_w = measured.content_w;
|
||||
}
|
||||
paragraph.width = content_w;
|
||||
content_total_h = meditation_music_measure_settings(app, content_w, 0, 1) +
|
||||
flint_px(34) +
|
||||
flint_ui_paragraph_height(paragraph) +
|
||||
flint_px(20);
|
||||
scroll_area = (FlintUIScrollArea){
|
||||
.bounds = {0.0f, (float)content_y,
|
||||
(float)view_width, (float)content_h},
|
||||
.content_height = content_total_h,
|
||||
.content_x = content_x,
|
||||
.content_width = content_w,
|
||||
.scroll_offset = &app->manual_scroll,
|
||||
.wheel_step = flint_px(42),
|
||||
.scrollbar_x = view_width - flint_px(8)
|
||||
};
|
||||
scroll_view = ui_scroll_container_begin(scroll_area);
|
||||
y = scroll_view.content_y;
|
||||
meditation_music_draw_guide_settings(app, scroll_view.content_x, scroll_view.content_w, &y);
|
||||
y += flint_px(34);
|
||||
paragraph.width = scroll_view.content_w;
|
||||
flint_ui_paragraph_draw(paragraph, scroll_view.content_x, &y);
|
||||
ui_scroll_container_end(scroll_area, scroll_view);
|
||||
meditation_music_draw_dropdown_menu(app);
|
||||
|
||||
{
|
||||
int hover = 0;
|
||||
|
||||
button_w = content_w;
|
||||
if(button_w > flint_px(260))
|
||||
button_w = flint_px(260);
|
||||
|
||||
if(ui_draw_generic_button(content_x + (content_w - button_w) / 2, button_y,
|
||||
button_w, button_h, locale_get("tutorial_start_button"),
|
||||
UI_BUTTON_STYLE_PRIMARY, 0, &hover))
|
||||
manual_screen_start_exercise(app);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
manual_screen_draw(InbeApp *app)
|
||||
{
|
||||
const PracticeDefinition *practice;
|
||||
int title_h = ui_screen_header_height();
|
||||
int tab_h = flint_px(56);
|
||||
int viewport_h = view_height - title_h - tab_h;
|
||||
int body_font = flint_ui_font();
|
||||
int footer_content_pad = flint_ui_font() / 2;
|
||||
int content_area_h = viewport_h - footer_content_pad; /* For scissor mode and scroll calculations */
|
||||
int previous_step;
|
||||
int content_x;
|
||||
int content_w;
|
||||
const char *title = locale_get("tutorial_title");
|
||||
char page_label[32];
|
||||
int close_clicked = 0;
|
||||
int step = app->tutorial_step;
|
||||
FlintUIScrollArea scroll_area;
|
||||
FlintUIScrollView scroll_view;
|
||||
|
||||
if(app == NULL)
|
||||
if(app->exercise_type == EXERCISE_MEDITATION) {
|
||||
meditation_manual_draw(app);
|
||||
return;
|
||||
practice = practice_get(app->exercise_type);
|
||||
if(practice->draw_manual != NULL)
|
||||
practice->draw_manual(app);
|
||||
}
|
||||
|
||||
step = clampi(step, 0, (int)TUTORIAL_STEPS_COUNT - 1);
|
||||
app->tutorial_step = step;
|
||||
previous_step = step;
|
||||
|
||||
if(IsKeyPressed(KEY_RIGHT) || IsKeyPressed(KEY_ENTER)) {
|
||||
if(step < (int)TUTORIAL_STEPS_COUNT - 1)
|
||||
app->tutorial_step++;
|
||||
else
|
||||
manual_screen_start_exercise(app);
|
||||
}
|
||||
if(IsKeyPressed(KEY_LEFT) && step > 0)
|
||||
app->tutorial_step--;
|
||||
if(IsKeyPressed(KEY_ESCAPE))
|
||||
manual_screen_close_tutorial(app, 0);
|
||||
|
||||
step = app->tutorial_step;
|
||||
if(previous_step != step) {
|
||||
app->manual_scroll = 0;
|
||||
previous_step = step;
|
||||
}
|
||||
|
||||
switch(step) {
|
||||
case 1: title = locale_get("tutorial_method_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;
|
||||
}
|
||||
|
||||
/* Calculate responsive content width */
|
||||
int responsive_max_w = (int)(view_width * 0.96f);
|
||||
int max_content_w = flint_px(CONTENT_MAX_W);
|
||||
if(responsive_max_w > max_content_w)
|
||||
responsive_max_w = max_content_w;
|
||||
int min_width = flint_px(280);
|
||||
if(responsive_max_w < min_width)
|
||||
responsive_max_w = min_width;
|
||||
|
||||
int side_padding = flint_page_side_padding();
|
||||
flint_centered_column(responsive_max_w, side_padding, &content_x, &content_w);
|
||||
|
||||
close_clicked = ui_draw_screen_header(title, 1);
|
||||
if(close_clicked)
|
||||
manual_screen_close_tutorial(app, 0);
|
||||
|
||||
{
|
||||
int top_padding = flint_px(16);
|
||||
int total_content_h;
|
||||
|
||||
for(int pass = 0; pass < 3; pass++) {
|
||||
FlintUIScrollView measured;
|
||||
|
||||
total_content_h = manual_tutorial_content_height(app, step, content_w, body_font) +
|
||||
top_padding;
|
||||
scroll_area = (FlintUIScrollArea){
|
||||
.bounds = {0.0f, (float)title_h, (float)view_width, (float)content_area_h},
|
||||
.content_height = total_content_h,
|
||||
.content_x = content_x,
|
||||
.content_width = content_w,
|
||||
.scroll_offset = &app->manual_scroll,
|
||||
.wheel_step = flint_px(42),
|
||||
.scrollbar_x = view_width - flint_px(8)
|
||||
};
|
||||
measured = ui_scroll_container_measure(scroll_area);
|
||||
if(measured.content_w == content_w)
|
||||
break;
|
||||
content_w = measured.content_w;
|
||||
}
|
||||
scroll_area = (FlintUIScrollArea){
|
||||
.bounds = {0.0f, (float)title_h, (float)view_width, (float)content_area_h},
|
||||
.content_height = manual_tutorial_content_height(app, step, content_w, body_font) +
|
||||
top_padding,
|
||||
.content_x = content_x,
|
||||
.content_width = content_w,
|
||||
.scroll_offset = &app->manual_scroll,
|
||||
.wheel_step = flint_px(42),
|
||||
.scrollbar_x = view_width - flint_px(8)
|
||||
};
|
||||
}
|
||||
|
||||
scroll_view = ui_scroll_container_begin(scroll_area);
|
||||
content_x = scroll_view.content_x;
|
||||
content_w = scroll_view.content_w;
|
||||
{
|
||||
int y = scroll_view.content_y + flint_px(16);
|
||||
if(step == 0) {
|
||||
int img_h = flint_px(170);
|
||||
ui_draw_tutorial_image(app->whm_1_image, "whm/1.jpg", content_x, y, content_w, img_h);
|
||||
y += img_h + flint_px(22);
|
||||
|
||||
draw_tutorial_paragraph(app, 0, content_x, &y, content_w, body_font);
|
||||
} else if(step == 1) {
|
||||
draw_tutorial_paragraph(app, 1, content_x, &y, content_w, body_font);
|
||||
} else if(step == 2) {
|
||||
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));
|
||||
apply_settings(&app->settings_preview, speed, app->inbe.max_rounds,
|
||||
int_from_count(app->inbe.maxbreaths), app->inbe.pause_seconds);
|
||||
app->settings_preview.progressive_speed = 0;
|
||||
inbestep(&app->settings_preview);
|
||||
if(app->settings_preview.phase != InbePhaseBreathe) {
|
||||
reset_settings_preview(app);
|
||||
update_preview_bounds(&app->settings_preview, content_w, flint_px(132));
|
||||
apply_settings(&app->settings_preview, speed, app->inbe.max_rounds,
|
||||
int_from_count(app->inbe.maxbreaths), app->inbe.pause_seconds);
|
||||
app->settings_preview.progressive_speed = 0;
|
||||
}
|
||||
draw_preview_inbe(&app->settings_preview, content_x + content_w / 2, y + flint_px(40));
|
||||
y += (int)(app->settings_preview.rmax * 0.72f) + flint_px(54);
|
||||
|
||||
if(ui_draw_slider(10, content_x, y, content_w, locale_get("speed_label"), SETTINGS_SPEED_MIN,
|
||||
SETTINGS_SPEED_MAX, &speed, "")) {
|
||||
apply_settings(&app->inbe, speed, app->inbe.max_rounds,
|
||||
int_from_count(app->inbe.maxbreaths), app->inbe.pause_seconds);
|
||||
apply_settings(&app->settings_preview, speed, app->inbe.max_rounds,
|
||||
int_from_count(app->inbe.maxbreaths), app->inbe.pause_seconds);
|
||||
app->settings_preview.progressive_speed = 0;
|
||||
app->settings_dirty = 1;
|
||||
}
|
||||
} else if(step == 4) {
|
||||
int hold_preview_radius = flint_px(54);
|
||||
int hold_preview_extent = hold_preview_radius + flint_px(8) + flint_px(5);
|
||||
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);
|
||||
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_2_image, "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);
|
||||
|
||||
locale_format(page_label, sizeof(page_label), "tutorial_page_label",
|
||||
step + 1, (int)TUTORIAL_STEPS_COUNT);
|
||||
|
||||
int left_hover = 0;
|
||||
int right_hover = 0;
|
||||
const char *left_label = step == 0 ? locale_get("tutorial_skip_button") : locale_get("tutorial_back_button");
|
||||
const char *right_label = step == (int)TUTORIAL_STEPS_COUNT - 1 ? locale_get("tutorial_start_button") : locale_get("tutorial_next_button");
|
||||
int footer_gap = flint_px(10);
|
||||
int page_font = flint_ui_font();
|
||||
int button_h = flint_px(34);
|
||||
int button_w = (content_w - footer_gap) / 2;
|
||||
int footer_y = view_height - flint_px(38);
|
||||
int counter_gap = flint_px(6);
|
||||
|
||||
|
||||
flint_text_draw(page_label,
|
||||
view_width / 2 - flint_text_measure(page_label, page_font) / 2,
|
||||
footer_y - page_font - counter_gap, page_font, theme_get_text());
|
||||
|
||||
if(step == 0) {
|
||||
if(ui_draw_generic_button(content_x, footer_y, button_w, button_h,
|
||||
left_label, UI_BUTTON_STYLE_PRIMARY, 0, &left_hover))
|
||||
manual_screen_start_exercise(app);
|
||||
} else {
|
||||
if(ui_draw_generic_button(content_x, footer_y, button_w, button_h,
|
||||
left_label, UI_BUTTON_STYLE_PRIMARY, 0, &left_hover)) {
|
||||
app->tutorial_step--;
|
||||
app->manual_scroll = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if(ui_draw_generic_button(content_x + button_w + footer_gap, footer_y, button_w, button_h,
|
||||
right_label, UI_BUTTON_STYLE_PRIMARY, 0, &right_hover)) {
|
||||
if(step == (int)TUTORIAL_STEPS_COUNT - 1)
|
||||
manual_screen_start_exercise(app);
|
||||
else {
|
||||
app->tutorial_step++;
|
||||
app->manual_scroll = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if(IsMouseButtonReleased(MOUSE_BUTTON_LEFT)) {
|
||||
app->settings_drag_slider = 0;
|
||||
if(app->settings_dirty)
|
||||
save_settings(app);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,21 @@
|
||||
#include "practice_screen.h"
|
||||
#include "app.h"
|
||||
#include "practices/practice_registry.h"
|
||||
#include "locale.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)
|
||||
{
|
||||
(void)tab;
|
||||
return practice_count();
|
||||
return EXERCISE_COUNT;
|
||||
}
|
||||
|
||||
int
|
||||
@@ -15,22 +24,30 @@ practice_activity_for_tab(int tab, int index)
|
||||
(void)tab;
|
||||
if(index < 0)
|
||||
return EXERCISE_WIM_HOF;
|
||||
if(index >= practice_count())
|
||||
return practice_count() - 1;
|
||||
if(index >= EXERCISE_COUNT)
|
||||
return EXERCISE_COUNT - 1;
|
||||
return index;
|
||||
}
|
||||
|
||||
const char *
|
||||
practice_activity_label(int exercise)
|
||||
{
|
||||
return practice_label(exercise);
|
||||
switch(exercise) {
|
||||
case EXERCISE_MEDITATION:
|
||||
return locale_get("exercise_meditation");
|
||||
case EXERCISE_WIM_HOF:
|
||||
default:
|
||||
return locale_get("exercise_wim_hof");
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
practice_activity_index_for_tab(int tab, int exercise)
|
||||
{
|
||||
(void)tab;
|
||||
return practice_clamp_id(exercise);
|
||||
if(exercise < 0 || exercise >= EXERCISE_COUNT)
|
||||
return EXERCISE_WIM_HOF;
|
||||
return exercise;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -38,5 +55,6 @@ practice_clamp_activity_to_tab(InbeApp *app)
|
||||
{
|
||||
if(app == NULL)
|
||||
return;
|
||||
app->exercise_type = practice_clamp_id(app->exercise_type);
|
||||
if(app->exercise_type < 0 || app->exercise_type >= EXERCISE_COUNT)
|
||||
app->exercise_type = EXERCISE_WIM_HOF;
|
||||
}
|
||||
@@ -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
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
@@ -6,9 +6,9 @@
|
||||
|
||||
/* Draw the settings screen. Returns non-zero when it consumed the whole frame. */
|
||||
int settings_screen_draw(InbeApp *app);
|
||||
void practice_config_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
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
@@ -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"
|
||||
@@ -143,31 +143,11 @@ set_status(InbeApp *app, const char *message)
|
||||
{
|
||||
if(app == NULL)
|
||||
return;
|
||||
copy_text_checked(app->meditation.music_status,
|
||||
sizeof(app->meditation.music_status),
|
||||
copy_text_checked(app->meditation_music_status,
|
||||
sizeof(app->meditation_music_status),
|
||||
message);
|
||||
}
|
||||
|
||||
static int
|
||||
download_supported(void)
|
||||
{
|
||||
#if defined(PLATFORM_WEB)
|
||||
return 0;
|
||||
#else
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
static const char *
|
||||
missing_audio_message(void)
|
||||
{
|
||||
#if defined(PLATFORM_WEB)
|
||||
return "Audio is unavailable";
|
||||
#else
|
||||
return "Download audio before playing music";
|
||||
#endif
|
||||
}
|
||||
|
||||
static int
|
||||
is_network_download_error(const FlintRuntimeAssetDownload *download)
|
||||
{
|
||||
@@ -227,7 +207,7 @@ draw_download_progress(InbeApp *app, int x, int y, int w)
|
||||
if(app == NULL || w <= 0)
|
||||
return;
|
||||
|
||||
download = &app->meditation.music_download;
|
||||
download = &app->meditation_music_download;
|
||||
if(download->status != FLINT_RUNTIME_ASSET_DOWNLOADING)
|
||||
return;
|
||||
|
||||
@@ -284,7 +264,7 @@ draw_music_attribution(int content_x, int content_w, int *y)
|
||||
static void
|
||||
music_archive_path(InbeApp *app, char *out, size_t out_size)
|
||||
{
|
||||
if(!join_path2(out, out_size, app->meditation.music_cache_dir,
|
||||
if(!join_path2(out, out_size, app->meditation_music_cache_dir,
|
||||
"/inbe-meditation-audio-v1.zip"))
|
||||
set_status(app, "Audio cache path is too long");
|
||||
}
|
||||
@@ -301,16 +281,12 @@ music_track_path(InbeApp *app, int track, char *out, size_t out_size)
|
||||
return;
|
||||
#endif
|
||||
|
||||
if(join_path2(out, out_size, app->meditation.music_cache_dir, "/audio/") &&
|
||||
if(join_path2(out, out_size, app->meditation_music_cache_dir, "/audio/") &&
|
||||
append_text_checked(out, out_size, g_tracks[track].file) &&
|
||||
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
|
||||
@@ -326,10 +302,10 @@ extract_audio_archive(InbeApp *app, const char *archive_path)
|
||||
return 0;
|
||||
}
|
||||
|
||||
flint_runtime_asset_ensure_dir(app->meditation.music_cache_dir);
|
||||
flint_runtime_asset_ensure_dir(app->meditation_music_cache_dir);
|
||||
{
|
||||
char audio_dir[FS_PATH_MAX];
|
||||
if(join_path2(audio_dir, sizeof(audio_dir), app->meditation.music_cache_dir, "/audio"))
|
||||
if(join_path2(audio_dir, sizeof(audio_dir), app->meditation_music_cache_dir, "/audio"))
|
||||
flint_runtime_asset_ensure_dir(audio_dir);
|
||||
else
|
||||
set_status(app, "Audio cache path is too long");
|
||||
@@ -349,7 +325,7 @@ extract_audio_archive(InbeApp *app, const char *archive_path)
|
||||
if(!known_track_archive_member(stat.m_filename))
|
||||
continue;
|
||||
|
||||
if(!join_path2(out_path, sizeof(out_path), app->meditation.music_cache_dir, "/audio/") ||
|
||||
if(!join_path2(out_path, sizeof(out_path), app->meditation_music_cache_dir, "/audio/") ||
|
||||
!append_text_checked(out_path, sizeof(out_path), stat.m_filename)) {
|
||||
set_status(app, "Audio file path is too long");
|
||||
continue;
|
||||
@@ -370,7 +346,7 @@ extract_audio_archive(InbeApp *app, const char *archive_path)
|
||||
}
|
||||
|
||||
mz_zip_reader_end(&archive);
|
||||
snprintf(app->meditation.music_status, sizeof(app->meditation.music_status),
|
||||
snprintf(app->meditation_music_status, sizeof(app->meditation_music_status),
|
||||
"Installed %d audio files", extracted);
|
||||
return extracted > 0;
|
||||
}
|
||||
@@ -398,7 +374,7 @@ meditation_music_selected_label(InbeApp *app)
|
||||
int track;
|
||||
if(app == NULL)
|
||||
return "";
|
||||
track = app->meditation.music_track;
|
||||
track = app->meditation_music_track;
|
||||
if(track < 0 || track >= MEDITATION_MUSIC_TRACK_COUNT)
|
||||
track = 0;
|
||||
return g_tracks[track].title;
|
||||
@@ -411,18 +387,18 @@ meditation_music_init(InbeApp *app)
|
||||
return;
|
||||
|
||||
flint_runtime_assets_init("inbe");
|
||||
if(!flint_runtime_asset_cache_root("inbe", app->meditation.music_cache_dir,
|
||||
sizeof(app->meditation.music_cache_dir))) {
|
||||
snprintf(app->meditation.music_cache_dir, sizeof(app->meditation.music_cache_dir),
|
||||
if(!flint_runtime_asset_cache_root("inbe", app->meditation_music_cache_dir,
|
||||
sizeof(app->meditation_music_cache_dir))) {
|
||||
snprintf(app->meditation_music_cache_dir, sizeof(app->meditation_music_cache_dir),
|
||||
"runtime-assets");
|
||||
flint_runtime_asset_ensure_dir(app->meditation.music_cache_dir);
|
||||
flint_runtime_asset_ensure_dir(app->meditation_music_cache_dir);
|
||||
}
|
||||
|
||||
if(app->meditation.music_track < 0 ||
|
||||
app->meditation.music_track >= MEDITATION_MUSIC_TRACK_COUNT)
|
||||
app->meditation.music_track = 0;
|
||||
if(app->meditation_music_track < 0 ||
|
||||
app->meditation_music_track >= MEDITATION_MUSIC_TRACK_COUNT)
|
||||
app->meditation_music_track = 0;
|
||||
|
||||
if(app->meditation.music_status[0] == '\0') {
|
||||
if(app->meditation_music_status[0] == '\0') {
|
||||
set_status(app, meditation_music_available(app) ? "Audio installed" : "Audio not installed");
|
||||
}
|
||||
}
|
||||
@@ -432,13 +408,13 @@ meditation_music_unload(InbeApp *app)
|
||||
{
|
||||
if(app == NULL)
|
||||
return;
|
||||
if(app->meditation.music_loaded) {
|
||||
StopMusicStream(app->meditation.music);
|
||||
UnloadMusicStream(app->meditation.music);
|
||||
app->meditation.music_loaded = 0;
|
||||
if(app->meditation_music_loaded) {
|
||||
StopMusicStream(app->meditation_music);
|
||||
UnloadMusicStream(app->meditation_music);
|
||||
app->meditation_music_loaded = 0;
|
||||
}
|
||||
app->meditation.music_playing = 0;
|
||||
app->meditation.music_test_playing = 0;
|
||||
app->meditation_music_playing = 0;
|
||||
app->meditation_music_test_playing = 0;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -446,10 +422,10 @@ meditation_music_stop(InbeApp *app)
|
||||
{
|
||||
if(app == NULL)
|
||||
return;
|
||||
if(app->meditation.music_loaded)
|
||||
StopMusicStream(app->meditation.music);
|
||||
app->meditation.music_playing = 0;
|
||||
app->meditation.music_test_playing = 0;
|
||||
if(app->meditation_music_loaded)
|
||||
StopMusicStream(app->meditation_music);
|
||||
app->meditation_music_playing = 0;
|
||||
app->meditation_music_test_playing = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -459,27 +435,25 @@ meditation_music_test_track(InbeApp *app)
|
||||
|
||||
if(app == NULL)
|
||||
return;
|
||||
if(app->meditation.music_playing) {
|
||||
if(app->meditation_music_playing) {
|
||||
meditation_music_unload(app);
|
||||
set_status(app, "Test audio stopped");
|
||||
return;
|
||||
}
|
||||
if(!meditation_music_available(app)) {
|
||||
set_status(app, missing_audio_message());
|
||||
set_status(app, "Download audio before testing");
|
||||
return;
|
||||
}
|
||||
|
||||
track = app->meditation.music_track;
|
||||
track = app->meditation_music_track;
|
||||
if(track < 0 || track >= MEDITATION_MUSIC_TRACK_COUNT)
|
||||
track = 0;
|
||||
if(!load_track(app, track))
|
||||
return;
|
||||
|
||||
PlayMusicStream(app->meditation.music);
|
||||
if(!IsMusicStreamPlaying(app->meditation.music))
|
||||
TraceLog(LOG_ERROR, "AUDIO: PlayMusicStream returned but test music is not playing");
|
||||
app->meditation.music_playing = 1;
|
||||
app->meditation.music_test_playing = 1;
|
||||
PlayMusicStream(app->meditation_music);
|
||||
app->meditation_music_playing = 1;
|
||||
app->meditation_music_test_playing = 1;
|
||||
set_status(app, "Playing test audio");
|
||||
}
|
||||
|
||||
@@ -488,13 +462,8 @@ load_track(InbeApp *app, int track)
|
||||
{
|
||||
char path[FS_PATH_MAX];
|
||||
|
||||
if(app == NULL)
|
||||
if(app == NULL || !app->audio_ready)
|
||||
return 0;
|
||||
if(!app->audio_ready) {
|
||||
TraceLog(LOG_ERROR, "AUDIO: Cannot load meditation music because audio device is not ready");
|
||||
set_status(app, "Audio device is not ready");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(track < 0 || track >= MEDITATION_MUSIC_TRACK_COUNT)
|
||||
track = 0;
|
||||
@@ -506,18 +475,16 @@ load_track(InbeApp *app, int track)
|
||||
return 0;
|
||||
}
|
||||
|
||||
app->meditation.music = LoadMusicStream(path);
|
||||
if(app->meditation.music.ctxData == NULL) {
|
||||
TraceLog(LOG_ERROR, "AUDIO: Could not load meditation track: %s", path);
|
||||
app->meditation_music = LoadMusicStream(path);
|
||||
if(app->meditation_music.ctxData == NULL) {
|
||||
set_status(app, "Could not load track");
|
||||
app->meditation.music_loaded = 0;
|
||||
app->meditation_music_loaded = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
app->meditation.music_loaded = 1;
|
||||
app->meditation.music_track = track;
|
||||
SetMusicVolume(app->meditation.music, (float)app->sound_volume / 100.0f);
|
||||
TraceLog(LOG_INFO, "AUDIO: Loaded meditation track: %s", path);
|
||||
app->meditation_music_loaded = 1;
|
||||
app->meditation_music_track = track;
|
||||
SetMusicVolume(app->meditation_music, (float)app->sound_volume / 100.0f);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -526,23 +493,21 @@ meditation_music_start_session(InbeApp *app)
|
||||
{
|
||||
int track;
|
||||
|
||||
if(app == NULL || !app->meditation.music_enabled)
|
||||
if(app == NULL || !app->meditation_music_enabled)
|
||||
return;
|
||||
if(!meditation_music_available(app)) {
|
||||
set_status(app, missing_audio_message());
|
||||
set_status(app, "Download audio before playing music");
|
||||
return;
|
||||
}
|
||||
|
||||
track = app->meditation.music_track;
|
||||
if(app->meditation.music_shuffle)
|
||||
track = app->meditation_music_track;
|
||||
if(app->meditation_music_shuffle)
|
||||
track = GetRandomValue(0, MEDITATION_MUSIC_TRACK_COUNT - 1);
|
||||
if(!load_track(app, track))
|
||||
return;
|
||||
PlayMusicStream(app->meditation.music);
|
||||
if(!IsMusicStreamPlaying(app->meditation.music))
|
||||
TraceLog(LOG_ERROR, "AUDIO: PlayMusicStream returned but session music is not playing");
|
||||
app->meditation.music_playing = 1;
|
||||
app->meditation.music_test_playing = 0;
|
||||
PlayMusicStream(app->meditation_music);
|
||||
app->meditation_music_playing = 1;
|
||||
app->meditation_music_test_playing = 0;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -552,7 +517,7 @@ meditation_music_update(InbeApp *app)
|
||||
|
||||
if(app == NULL)
|
||||
return;
|
||||
if(app->meditation.music_test_playing &&
|
||||
if(app->meditation_music_test_playing &&
|
||||
(app->exercise_type != EXERCISE_MEDITATION ||
|
||||
(app->inbe.screen != InbeScreenPracticeConfig &&
|
||||
app->inbe.screen != InbeScreenManual))) {
|
||||
@@ -560,29 +525,29 @@ meditation_music_update(InbeApp *app)
|
||||
return;
|
||||
}
|
||||
|
||||
if(app->meditation.music_download.status == FLINT_RUNTIME_ASSET_READY &&
|
||||
!app->meditation.music_archive_extracted) {
|
||||
if(app->meditation_music_download.status == FLINT_RUNTIME_ASSET_READY &&
|
||||
!app->meditation_music_archive_extracted) {
|
||||
music_archive_path(app, archive_path, sizeof(archive_path));
|
||||
app->meditation.music_archive_extracted = 1;
|
||||
app->meditation_music_archive_extracted = 1;
|
||||
extract_audio_archive(app, archive_path);
|
||||
} else if(app->meditation.music_download.status == FLINT_RUNTIME_ASSET_ERROR ||
|
||||
app->meditation.music_download.status == FLINT_RUNTIME_ASSET_UNSUPPORTED) {
|
||||
if(is_network_download_error(&app->meditation.music_download)) {
|
||||
} else if(app->meditation_music_download.status == FLINT_RUNTIME_ASSET_ERROR ||
|
||||
app->meditation_music_download.status == FLINT_RUNTIME_ASSET_UNSUPPORTED) {
|
||||
if(is_network_download_error(&app->meditation_music_download)) {
|
||||
set_status(app, locale_get("meditation_music_network_error_title"));
|
||||
if(!app->meditation.music_network_error_notified && !app->modal.active) {
|
||||
if(!app->meditation_music_network_error_notified && !app->modal.active) {
|
||||
app->modal.active = 1;
|
||||
app->modal.type = UIModalMeditationNetworkError;
|
||||
app->modal.selected_button = 0;
|
||||
app->meditation.music_network_error_notified = 1;
|
||||
app->meditation_music_network_error_notified = 1;
|
||||
}
|
||||
} else if(app->meditation.music_download.error[0] != '\0') {
|
||||
set_status(app, app->meditation.music_download.error);
|
||||
} else if(app->meditation_music_download.error[0] != '\0') {
|
||||
set_status(app, app->meditation_music_download.error);
|
||||
}
|
||||
}
|
||||
|
||||
if(app->meditation.music_loaded) {
|
||||
SetMusicVolume(app->meditation.music, (float)app->sound_volume / 100.0f);
|
||||
UpdateMusicStream(app->meditation.music);
|
||||
if(app->meditation_music_loaded) {
|
||||
SetMusicVolume(app->meditation_music, (float)app->sound_volume / 100.0f);
|
||||
UpdateMusicStream(app->meditation_music);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -595,17 +560,17 @@ start_download(InbeApp *app)
|
||||
return;
|
||||
|
||||
music_archive_path(app, archive_path, sizeof(archive_path));
|
||||
app->meditation.music_archive_extracted = 0;
|
||||
app->meditation.music_network_error_notified = 0;
|
||||
app->meditation_music_archive_extracted = 0;
|
||||
app->meditation_music_network_error_notified = 0;
|
||||
set_status(app, "Downloading audio...");
|
||||
flint_runtime_asset_download(&app->meditation.music_download,
|
||||
flint_runtime_asset_download(&app->meditation_music_download,
|
||||
INBE_MEDITATION_AUDIO_URL,
|
||||
archive_path);
|
||||
}
|
||||
|
||||
void
|
||||
meditation_music_draw_settings(InbeApp *app, int content_x, int content_w, int *y,
|
||||
int show_installed_download, int show_status)
|
||||
static void
|
||||
draw_music_picker(InbeApp *app, int content_x, int content_w, int *y,
|
||||
int show_installed_download, int show_status)
|
||||
{
|
||||
int toggle_w = flint_px(56);
|
||||
int toggle_h = flint_px(30);
|
||||
@@ -619,29 +584,29 @@ meditation_music_draw_settings(InbeApp *app, int content_x, int content_w, int *
|
||||
if(app == NULL || y == NULL)
|
||||
return;
|
||||
|
||||
if(app->meditation.music_track < 0 ||
|
||||
app->meditation.music_track >= MEDITATION_MUSIC_TRACK_COUNT)
|
||||
app->meditation.music_track = 0;
|
||||
if(app->meditation_music_track < 0 ||
|
||||
app->meditation_music_track >= MEDITATION_MUSIC_TRACK_COUNT)
|
||||
app->meditation_music_track = 0;
|
||||
|
||||
if(!app->meditation.music_enabled) {
|
||||
app->meditation.music_enabled = 1;
|
||||
if(!app->meditation_music_enabled) {
|
||||
app->meditation_music_enabled = 1;
|
||||
app->settings_dirty = 1;
|
||||
}
|
||||
|
||||
flint_text_draw(locale_get("meditation_music_shuffle_label"), content_x, *y, flint_ui_font(), theme_get_text());
|
||||
if(ui_draw_toggle_switch(content_x, *y + flint_px(26), toggle_w, toggle_h,
|
||||
&app->meditation.music_shuffle,
|
||||
&app->meditation_music_shuffle,
|
||||
locale_get("toggle_off"), locale_get("toggle_on"))) {
|
||||
app->settings_dirty = 1;
|
||||
meditation_music_unload(app);
|
||||
}
|
||||
*y += flint_px(76);
|
||||
|
||||
if(!app->meditation.music_shuffle) {
|
||||
if(!app->meditation_music_shuffle) {
|
||||
flint_text_draw(locale_get("meditation_music_track_label"), content_x, *y, flint_ui_font(), theme_get_text());
|
||||
if(ui_draw_dropdown_button(401, content_x, *y + flint_px(24), content_w, flint_px(36),
|
||||
g_track_options, MEDITATION_MUSIC_TRACK_COUNT,
|
||||
&app->meditation.music_track)) {
|
||||
&app->meditation_music_track)) {
|
||||
app->settings_dirty = 1;
|
||||
meditation_music_unload(app);
|
||||
}
|
||||
@@ -650,7 +615,7 @@ meditation_music_draw_settings(InbeApp *app, int content_x, int content_w, int *
|
||||
|
||||
installed = meditation_music_available(app);
|
||||
if(installed) {
|
||||
test_label = app->meditation.music_playing ?
|
||||
test_label = app->meditation_music_playing ?
|
||||
locale_get("meditation_music_stop_test_button") :
|
||||
locale_get("meditation_music_test_button");
|
||||
button_w = flint_text_measure(test_label, flint_ui_font()) + flint_px(24);
|
||||
@@ -663,7 +628,7 @@ meditation_music_draw_settings(InbeApp *app, int content_x, int content_w, int *
|
||||
*y += button_h + flint_px(12);
|
||||
}
|
||||
|
||||
if(download_supported() && (!installed || show_installed_download)) {
|
||||
if(!installed || show_installed_download) {
|
||||
button_w = flint_text_measure(locale_get(installed ? "meditation_music_redownload_button"
|
||||
: "meditation_music_download_button"),
|
||||
flint_ui_font()) + flint_px(24);
|
||||
@@ -677,16 +642,16 @@ meditation_music_draw_settings(InbeApp *app, int content_x, int content_w, int *
|
||||
*y += button_h + flint_px(12);
|
||||
}
|
||||
|
||||
if(show_status && (!installed || app->meditation.music_download.status != FLINT_RUNTIME_ASSET_IDLE)) {
|
||||
if(app->meditation.music_download.status == FLINT_RUNTIME_ASSET_DOWNLOADING) {
|
||||
if(show_status && (!installed || app->meditation_music_download.status != FLINT_RUNTIME_ASSET_IDLE)) {
|
||||
if(app->meditation_music_download.status == FLINT_RUNTIME_ASSET_DOWNLOADING) {
|
||||
format_download_status(download_status, sizeof(download_status),
|
||||
&app->meditation.music_download);
|
||||
&app->meditation_music_download);
|
||||
flint_text_draw(download_status, content_x, *y, flint_ui_font(), theme_get_text());
|
||||
*y += flint_px(28);
|
||||
draw_download_progress(app, content_x, *y, content_w);
|
||||
*y += flint_px(22);
|
||||
} else {
|
||||
flint_text_draw(app->meditation.music_status, content_x, *y, flint_ui_font(), theme_get_text());
|
||||
flint_text_draw(app->meditation_music_status, content_x, *y, flint_ui_font(), theme_get_text());
|
||||
*y += flint_px(34);
|
||||
}
|
||||
}
|
||||
@@ -705,17 +670,17 @@ meditation_music_measure_settings(InbeApp *app, int content_w,
|
||||
if(app == NULL)
|
||||
return 0;
|
||||
|
||||
if(!app->meditation.music_shuffle)
|
||||
if(!app->meditation_music_shuffle)
|
||||
h += flint_px(74);
|
||||
|
||||
installed = meditation_music_available(app);
|
||||
if(installed)
|
||||
h += flint_px(48);
|
||||
if(download_supported() && (!installed || show_installed_download))
|
||||
if(!installed || show_installed_download)
|
||||
h += flint_px(48);
|
||||
|
||||
if(show_status && (!installed || app->meditation.music_download.status != FLINT_RUNTIME_ASSET_IDLE)) {
|
||||
if(app->meditation.music_download.status == FLINT_RUNTIME_ASSET_DOWNLOADING)
|
||||
if(show_status && (!installed || app->meditation_music_download.status != FLINT_RUNTIME_ASSET_IDLE)) {
|
||||
if(app->meditation_music_download.status == FLINT_RUNTIME_ASSET_DOWNLOADING)
|
||||
h += flint_px(50);
|
||||
else
|
||||
h += flint_px(34);
|
||||
@@ -726,6 +691,18 @@ meditation_music_measure_settings(InbeApp *app, int content_w,
|
||||
return h;
|
||||
}
|
||||
|
||||
void
|
||||
meditation_music_draw_settings(InbeApp *app, int content_x, int content_w, int *y)
|
||||
{
|
||||
draw_music_picker(app, content_x, content_w, y, 1, 1);
|
||||
}
|
||||
|
||||
void
|
||||
meditation_music_draw_guide_settings(InbeApp *app, int content_x, int content_w, int *y)
|
||||
{
|
||||
draw_music_picker(app, content_x, content_w, y, 0, 1);
|
||||
}
|
||||
|
||||
int
|
||||
meditation_music_draw_dropdown_menu(InbeApp *app)
|
||||
{
|
||||
@@ -14,8 +14,8 @@ void meditation_music_start_session(InbeApp *app);
|
||||
void meditation_music_stop(InbeApp *app);
|
||||
int meditation_music_measure_settings(InbeApp *app, int content_w,
|
||||
int show_installed_download, int show_status);
|
||||
void meditation_music_draw_settings(InbeApp *app, int content_x, int content_w, int *y,
|
||||
int show_installed_download, int show_status);
|
||||
void meditation_music_draw_settings(InbeApp *app, int content_x, int content_w, int *y);
|
||||
void meditation_music_draw_guide_settings(InbeApp *app, int content_x, int content_w, int *y);
|
||||
int meditation_music_draw_dropdown_menu(InbeApp *app);
|
||||
int meditation_music_available(InbeApp *app);
|
||||
const char *meditation_music_selected_label(InbeApp *app);
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "whm_session.h"
|
||||
#include "session.h"
|
||||
|
||||
#include "data.h"
|
||||
#include "flint_locale.h"
|
||||
#include "locale.h"
|
||||
#include "theme.h"
|
||||
#include "flint_dpi.h"
|
||||
#include "flint_ui.h"
|
||||
@@ -156,6 +156,25 @@ remember_sound_state(InbeApp *app)
|
||||
cpcount(app->sound_last_count, app->inbe.count);
|
||||
}
|
||||
|
||||
static void
|
||||
play_app_sound(InbeApp *app, Sound sound, float scale)
|
||||
{
|
||||
float volume;
|
||||
|
||||
if(app == NULL || !app->audio_ready || sound.frameCount == 0 || app->sound_volume <= 0)
|
||||
return;
|
||||
|
||||
volume = ((float)app->sound_volume / 100.0f) * scale;
|
||||
if(volume < 0.0f)
|
||||
volume = 0.0f;
|
||||
if(volume > 1.0f)
|
||||
volume = 1.0f;
|
||||
|
||||
StopSound(sound);
|
||||
SetSoundVolume(sound, volume);
|
||||
PlaySound(sound);
|
||||
}
|
||||
|
||||
void
|
||||
update_session_sounds(InbeApp *app)
|
||||
{
|
||||
@@ -178,17 +197,17 @@ update_session_sounds(InbeApp *app)
|
||||
if(app->inbe.phase == InbePhaseBreathe) {
|
||||
if(screen_changed || phase_changed || dir_changed) {
|
||||
Sound breath_snd = app->inbe.dir == 0 ? app->breath_in_sound : app->breath_out_sound;
|
||||
app_play_sound(app, breath_snd, 1.0f);
|
||||
play_app_sound(app, breath_snd, 1.0f);
|
||||
}
|
||||
if(count_changed) {
|
||||
int count_value = int_from_count(app->inbe.count);
|
||||
int maxbreaths_value = int_from_count(app->inbe.maxbreaths);
|
||||
if(count_value == maxbreaths_value - 1)
|
||||
app_play_sound(app, app->bell_sound, 0.8f);
|
||||
play_app_sound(app, app->bell_sound, 0.8f);
|
||||
}
|
||||
} else if(phase_changed) {
|
||||
if(app->inbe.phase == InbePhaseNext && app->sound_last_phase == InbePhaseRecover)
|
||||
app_play_sound(app, app->breath_out_sound, 1.0f);
|
||||
play_app_sound(app, app->breath_out_sound, 1.0f);
|
||||
}
|
||||
|
||||
remember_sound_state(app);
|
||||
@@ -280,7 +299,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;
|
||||
}
|
||||
@@ -320,7 +338,7 @@ finish_hold(InbeApp *app)
|
||||
app->inbe.breath_frame = 0;
|
||||
app->inbe.breathtick = 0;
|
||||
app->inbe.sectick = 0;
|
||||
app_play_sound(app, app->breath_in_sound, 1.0f);
|
||||
play_app_sound(app, app->breath_in_sound, 1.0f);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -342,7 +360,7 @@ finish_round(InbeApp *app)
|
||||
#endif
|
||||
app->inbe.screen = InbeScreenResults;
|
||||
} else {
|
||||
app_init(app);
|
||||
inbe_app_init(app);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -527,7 +545,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 +671,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 +711,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 +770,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 +789,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 +902,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 +974,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;
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef INBE_WHM_SESSION_H
|
||||
#define INBE_WHM_SESSION_H
|
||||
#ifndef INBE_APP_SESSION_H
|
||||
#define INBE_APP_SESSION_H
|
||||
|
||||
#include "app.h"
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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
|
||||
@@ -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
|
||||
}
|
||||