Improve meditation configuration
This commit is contained in:
1 parent
c023738180
commit
8aca590fdb
32 files changed
+570
-613
No files matched your search
@@ -393,7 +393,7 @@ jobs:
|
||||
- name: Copy Android Assets
|
||||
run: ./scripts/copy-android-assets.sh
|
||||
|
||||
- name: Build Android APK
|
||||
- name: Build Android APK and AAB
|
||||
env:
|
||||
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
|
||||
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
|
||||
@@ -405,7 +405,13 @@ jobs:
|
||||
-Pkeystore.alias="$KEY_ALIAS" \
|
||||
-Pkeystore.password="$KEYSTORE_PASSWORD" \
|
||||
--stacktrace
|
||||
./droid/gradlew -p droid bundleRelease \
|
||||
-Pkeystore.path="$HOME/.android/inbe-release.keystore" \
|
||||
-Pkeystore.alias="$KEY_ALIAS" \
|
||||
-Pkeystore.password="$KEYSTORE_PASSWORD" \
|
||||
--stacktrace
|
||||
make android-copy-release-apks
|
||||
make android-copy-bundle
|
||||
|
||||
- name: Collect Android Release Files
|
||||
run: |
|
||||
@@ -417,6 +423,12 @@ jobs:
|
||||
exit 1
|
||||
fi
|
||||
cp "build/android/inbe-$VERSION.apk" build/release/android/
|
||||
aab="$(find droid/app/build/outputs/bundle/release build/android -type f -name '*.aab' | head -n 1)"
|
||||
if [ -z "$aab" ]; then
|
||||
echo "No release AAB was produced"
|
||||
exit 1
|
||||
fi
|
||||
cp "$aab" "build/release/android/inbe-$VERSION.aab"
|
||||
|
||||
- name: Upload Android Artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
@@ -557,3 +569,37 @@ jobs:
|
||||
butler push "$android_apk" waozi/inbe:android --userversion "$VERSION"
|
||||
butler push "$windows_zip" waozi/inbe:windows --userversion "$VERSION"
|
||||
butler push "$linux_appimage" waozi/inbe:linux --userversion "$VERSION"
|
||||
|
||||
publish-google-play:
|
||||
name: Publish Google Play Alpha
|
||||
runs-on: ubuntu-latest
|
||||
needs:
|
||||
- build-android
|
||||
- release
|
||||
if: needs.release.outputs.tag_pushed == 'true'
|
||||
|
||||
steps:
|
||||
- name: Check Google Play Secret
|
||||
env:
|
||||
PLAY_STORE_JSON_KEY: ${{ secrets.PLAY_STORE_JSON_KEY }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
if [ -z "${PLAY_STORE_JSON_KEY:-}" ]; then
|
||||
echo "PLAY_STORE_JSON_KEY secret is required to publish Google Play"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Download Android Release Artifact
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: release-android
|
||||
path: build/release/android
|
||||
|
||||
- name: Publish AAB to Closed Testing Alpha
|
||||
uses: r0adkll/upload-google-play@v1
|
||||
with:
|
||||
serviceAccountJsonPlainText: ${{ secrets.PLAY_STORE_JSON_KEY }}
|
||||
packageName: xyz.waozi.inbe
|
||||
releaseFiles: build/release/android/*.aab
|
||||
track: alpha
|
||||
status: completed
|
||||
@@ -4,12 +4,6 @@
|
||||
[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
|
||||
[submodule "vendor/flint"]
|
||||
path = vendor/flint
|
||||
url = [email protected]:waozixyz/flint.git
|
||||
@@ -102,22 +102,37 @@ 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_VENDOR_BUILD_DIR := $(VENDOR_BUILD_DIR)/linux/$(ARCH)
|
||||
FLINT_LIBOQS_BUILD_DIR := $(FLINT_VENDOR_BUILD_DIR)/liboqs
|
||||
FLINT_WEB_LIBOQS_BUILD_DIR := $(VENDOR_BUILD_DIR)/web/liboqs
|
||||
FLINT_CURL_BUILD_DIR := $(FLINT_VENDOR_BUILD_DIR)/curl
|
||||
FLINT_CURL_REQUIRE_WEBSOCKETS := 1
|
||||
FLINT_CURL_EXTRA_CMAKE_FLAGS := \
|
||||
-DCURL_DISABLE_WEBSOCKETS=OFF \
|
||||
-DCURL_DISABLE_INSTALL=OFF \
|
||||
-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_SMTP=ON \
|
||||
-DCURL_DISABLE_TELNET=ON \
|
||||
-DCURL_DISABLE_TFTP=ON \
|
||||
-DCURL_DISABLE_LIBCURL_OPTION=ON \
|
||||
-DCURL_ZLIB=OFF \
|
||||
-DCURL_BROTLI=OFF \
|
||||
-DCURL_ZSTD=OFF
|
||||
include $(FLINT_DIR)/mk/vendor.mk
|
||||
CURL_DIR := $(FLINT_CURL_DIR)
|
||||
CURL_BUILD_DIR := $(FLINT_CURL_BUILD_DIR)
|
||||
CURL_INCLUDE_DIR := $(FLINT_CURL_INCLUDE_DIR)
|
||||
CURL_LIB_DIR := $(FLINT_CURL_LIB_DIR)
|
||||
CURL_SO := $(FLINT_CURL_SO)
|
||||
CURL_PROTOCOL_CHECK := $(FLINT_CURL_PROTOCOL_CHECK)
|
||||
FLINT_CURL_VERSION_NUM ?= $(shell printf '%s\n' '#include <curl/curlver.h>' 'LIBCURL_VERSION_NUM' | $(CC) -I$(FLINT_CURL_DIR)/include -E -P - 2>/dev/null | tail -n 1)
|
||||
FLINT_CURL_VERSION_HEX := $(patsubst 0x%,%,$(FLINT_CURL_VERSION_NUM))
|
||||
SQLITE_DIR := vendor/sqlite
|
||||
SQLITE_BUILD_DIR := $(VENDOR_BUILD_DIR)/sqlite
|
||||
@@ -125,12 +140,12 @@ 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
|
||||
LIBOQS_DIR := $(FLINT_LIBOQS_DIR)
|
||||
LIBOQS_BUILD_DIR := $(FLINT_LIBOQS_BUILD_DIR)
|
||||
LIBOQS_A := $(FLINT_LIBOQS_A)
|
||||
LIBOQS_INCLUDE := $(FLINT_LIBOQS_INCLUDE)
|
||||
WEB_LIBOQS_BUILD_DIR := $(FLINT_WEB_LIBOQS_BUILD_DIR)
|
||||
WEB_LIBOQS_A := $(FLINT_WEB_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
|
||||
@@ -353,11 +368,11 @@ $(SYNC_URL_TEST): tests/sync_url_test.c src/storage/sync_client.c src/storage/sy
|
||||
tests/sync_url_test.c src/storage/sync_client.c \
|
||||
-Wl,--gc-sections $(FLINT_CURL_LDLIBS)
|
||||
|
||||
$(SYNC_ACCOUNT_TEST): tests/sync_account_test.c src/storage/sync_account.c src/storage/sync_account.h src/storage/storage.c src/storage/sync_review.c src/storage/db.c src/storage/import.c src/storage/storage.h src/storage/db.h src/storage/import.h src/third_party/miniz.c src/third_party/miniz.h $(SQLITE_SRC) $(SQLITE_AMALGAMATION_H) | $(TEST_BIN_DIR)
|
||||
$(SYNC_ACCOUNT_TEST): tests/sync_account_test.c src/storage/sync_account.c src/storage/sync_account.h $(FLINT_DIR)/src/flint_lyra_account.c $(FLINT_DIR)/include/flint_lyra_account.h src/storage/storage.c src/storage/sync_review.c src/storage/db.c src/storage/import.c src/storage/storage.h src/storage/db.h src/storage/import.h src/third_party/miniz.c src/third_party/miniz.h $(SQLITE_SRC) $(SQLITE_AMALGAMATION_H) | $(TEST_BIN_DIR)
|
||||
$(CC) -Wall -Wextra -std=c99 -D_DEFAULT_SOURCE -D_GNU_SOURCE -DMINIZ_NO_ZLIB_COMPATIBLE_NAMES -ffunction-sections -fdata-sections \
|
||||
-Isrc -Isrc/app -Isrc/core -Isrc/screens -Isrc/screens/settings -Isrc/practices -Isrc/practices/whm -Isrc/practices/meditation -Isrc/storage -Isrc/platform/android -Isrc/third_party $(FLINT_INCLUDE) -I$(RAYLIB_DIR) $(SQLITE_INCLUDE) \
|
||||
-o $@ \
|
||||
tests/sync_account_test.c src/storage/sync_account.c src/storage/storage.c src/storage/sync_review.c src/storage/db.c src/storage/import.c src/third_party/miniz.c $(SQLITE_SRC) \
|
||||
tests/sync_account_test.c src/storage/sync_account.c $(FLINT_DIR)/src/flint_lyra_account.c src/storage/storage.c src/storage/sync_review.c src/storage/db.c src/storage/import.c src/third_party/miniz.c $(SQLITE_SRC) \
|
||||
-Wl,--gc-sections -lm -lpthread -ldl
|
||||
|
||||
$(SYNC_REVIEW_TEST): tests/sync_review_test.c src/storage/storage.c src/storage/sync_review.c src/storage/db.c src/storage/import.c src/storage/storage.h src/storage/db.h src/storage/import.h src/third_party/miniz.c src/third_party/miniz.h $(SQLITE_SRC) $(SQLITE_AMALGAMATION_H) | $(TEST_BIN_DIR)
|
||||
@@ -492,76 +507,6 @@ $(SQLITE_AMALGAMATION_C) $(SQLITE_AMALGAMATION_H): $(SQLITE_DIR)/configure $(SQL
|
||||
cd $(SQLITE_BUILD_DIR) && $(abspath $(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) \
|
||||
@@ -632,7 +577,7 @@ $(TARGET): Makefile $(SRC) $(FLINT_SRCS) $(FLINT_ICON_STAMP) $(SQLITE_SRC) $(SQL
|
||||
$(LIBOQS_INCLUDE) \
|
||||
-I$(RAYLIB_DIR) \
|
||||
$(RAY_CFLAGS) \
|
||||
-DINBE_HAS_LIBOQS=1 \
|
||||
-DFLINT_HAS_LIBOQS=1 \
|
||||
-DSUPPORT_MODULE_RAUDIO=1 \
|
||||
-DSUPPORT_FILEFORMAT_OGG=1 \
|
||||
-DSUPPORT_FILEFORMAT_MP3=0 \
|
||||
@@ -819,7 +764,7 @@ $(WEB_TARGET): Makefile $(SRC) $(FLINT_WEB_SRCS) $(FLINT_ICON_STAMP) $(SQLITE_SR
|
||||
$(SQLITE_INCLUDE) \
|
||||
$(WEB_LIBOQS_INCLUDE) \
|
||||
-I$(RAYLIB_DIR) \
|
||||
-DINBE_HAS_LIBOQS=1 \
|
||||
-DFLINT_HAS_LIBOQS=1 \
|
||||
-DPLATFORM_WEB \
|
||||
-DSUPPORT_MODULE_RAUDIO=1 \
|
||||
-DSUPPORT_FILEFORMAT_OGG=1 \
|
||||
|
||||
@@ -21,7 +21,7 @@ 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")
|
||||
add_subdirectory("${FLINT_DIR}/vendor/liboqs" "${CMAKE_BINARY_DIR}/liboqs")
|
||||
file(GLOB FLINT_SOURCES CONFIGURE_DEPENDS "${FLINT_DIR}/src/*.c" "${FLINT_DIR}/src/ui/*.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")
|
||||
|
||||
@@ -157,6 +157,21 @@ Nelze načíst soubor s meditační hudbou. Zkontrolujte připojení k internetu
|
||||
[duration_2h]
|
||||
2 h
|
||||
---
|
||||
[meditation_duration_setting]
|
||||
Meditation length
|
||||
---
|
||||
[meditation_duration_custom]
|
||||
Custom
|
||||
---
|
||||
[meditation_custom_minutes]
|
||||
Custom time
|
||||
---
|
||||
[meditation_extend_controls_label]
|
||||
Show add-time buttons during meditation
|
||||
---
|
||||
[finish_button]
|
||||
Finish
|
||||
---
|
||||
[breath_button]
|
||||
DÝCHAT
|
||||
---
|
||||
|
||||
@@ -157,6 +157,21 @@ Der Meditations-Musikserver konnte nicht erreicht werden. Prüfe die Android-Net
|
||||
[duration_2h]
|
||||
2 Std.
|
||||
---
|
||||
[meditation_duration_setting]
|
||||
Meditation length
|
||||
---
|
||||
[meditation_duration_custom]
|
||||
Custom
|
||||
---
|
||||
[meditation_custom_minutes]
|
||||
Custom time
|
||||
---
|
||||
[meditation_extend_controls_label]
|
||||
Show add-time buttons during meditation
|
||||
---
|
||||
[finish_button]
|
||||
Finish
|
||||
---
|
||||
[breath_button]
|
||||
ATEM
|
||||
---
|
||||
|
||||
@@ -160,6 +160,21 @@ Music by Elijah_K.
|
||||
[duration_2h]
|
||||
2h
|
||||
---
|
||||
[meditation_duration_setting]
|
||||
Meditation length
|
||||
---
|
||||
[meditation_duration_custom]
|
||||
Custom
|
||||
---
|
||||
[meditation_custom_minutes]
|
||||
Custom time
|
||||
---
|
||||
[meditation_extend_controls_label]
|
||||
Show add-time buttons during meditation
|
||||
---
|
||||
[finish_button]
|
||||
Finish
|
||||
---
|
||||
[breath_button]
|
||||
BREATH
|
||||
---
|
||||
|
||||
@@ -157,6 +157,21 @@ No se pudo acceder al archivo de música de meditación. Revisa tu conexión a i
|
||||
[duration_2h]
|
||||
2 h
|
||||
---
|
||||
[meditation_duration_setting]
|
||||
Meditation length
|
||||
---
|
||||
[meditation_duration_custom]
|
||||
Custom
|
||||
---
|
||||
[meditation_custom_minutes]
|
||||
Custom time
|
||||
---
|
||||
[meditation_extend_controls_label]
|
||||
Show add-time buttons during meditation
|
||||
---
|
||||
[finish_button]
|
||||
Finish
|
||||
---
|
||||
[breath_button]
|
||||
RESPIRACIÓN
|
||||
---
|
||||
|
||||
@@ -157,6 +157,21 @@ Impossible de joindre le fichier de musique de méditation. Vérifiez votre conn
|
||||
[duration_2h]
|
||||
2 h
|
||||
---
|
||||
[meditation_duration_setting]
|
||||
Meditation length
|
||||
---
|
||||
[meditation_duration_custom]
|
||||
Custom
|
||||
---
|
||||
[meditation_custom_minutes]
|
||||
Custom time
|
||||
---
|
||||
[meditation_extend_controls_label]
|
||||
Show add-time buttons during meditation
|
||||
---
|
||||
[finish_button]
|
||||
Finish
|
||||
---
|
||||
[breath_button]
|
||||
RESPIRER
|
||||
---
|
||||
|
||||
@@ -157,6 +157,21 @@ Tidak dapat membuka file musik meditasi. Periksa koneksi internetmu, lalu coba l
|
||||
[duration_2h]
|
||||
2j
|
||||
---
|
||||
[meditation_duration_setting]
|
||||
Meditation length
|
||||
---
|
||||
[meditation_duration_custom]
|
||||
Custom
|
||||
---
|
||||
[meditation_custom_minutes]
|
||||
Custom time
|
||||
---
|
||||
[meditation_extend_controls_label]
|
||||
Show add-time buttons during meditation
|
||||
---
|
||||
[finish_button]
|
||||
Finish
|
||||
---
|
||||
[breath_button]
|
||||
NAFAS
|
||||
---
|
||||
|
||||
@@ -157,6 +157,21 @@ Impossibile raggiungere il file musicale per la meditazione. Controlla la connes
|
||||
[duration_2h]
|
||||
2 ore
|
||||
---
|
||||
[meditation_duration_setting]
|
||||
Meditation length
|
||||
---
|
||||
[meditation_duration_custom]
|
||||
Custom
|
||||
---
|
||||
[meditation_custom_minutes]
|
||||
Custom time
|
||||
---
|
||||
[meditation_extend_controls_label]
|
||||
Show add-time buttons during meditation
|
||||
---
|
||||
[finish_button]
|
||||
Finish
|
||||
---
|
||||
[breath_button]
|
||||
RESPIRO
|
||||
---
|
||||
|
||||
@@ -157,6 +157,21 @@ Sun Salutation
|
||||
[duration_2h]
|
||||
2時間
|
||||
---
|
||||
[meditation_duration_setting]
|
||||
Meditation length
|
||||
---
|
||||
[meditation_duration_custom]
|
||||
Custom
|
||||
---
|
||||
[meditation_custom_minutes]
|
||||
Custom time
|
||||
---
|
||||
[meditation_extend_controls_label]
|
||||
Show add-time buttons during meditation
|
||||
---
|
||||
[finish_button]
|
||||
Finish
|
||||
---
|
||||
[breath_button]
|
||||
呼吸
|
||||
---
|
||||
|
||||
@@ -157,6 +157,21 @@ Sun Salutation
|
||||
[duration_2h]
|
||||
2시간
|
||||
---
|
||||
[meditation_duration_setting]
|
||||
Meditation length
|
||||
---
|
||||
[meditation_duration_custom]
|
||||
Custom
|
||||
---
|
||||
[meditation_custom_minutes]
|
||||
Custom time
|
||||
---
|
||||
[meditation_extend_controls_label]
|
||||
Show add-time buttons during meditation
|
||||
---
|
||||
[finish_button]
|
||||
Finish
|
||||
---
|
||||
[breath_button]
|
||||
호흡
|
||||
---
|
||||
|
||||
@@ -157,6 +157,21 @@ Não foi possível acessar o arquivo de música de meditação. Verifique sua co
|
||||
[duration_2h]
|
||||
2 h
|
||||
---
|
||||
[meditation_duration_setting]
|
||||
Meditation length
|
||||
---
|
||||
[meditation_duration_custom]
|
||||
Custom
|
||||
---
|
||||
[meditation_custom_minutes]
|
||||
Custom time
|
||||
---
|
||||
[meditation_extend_controls_label]
|
||||
Show add-time buttons during meditation
|
||||
---
|
||||
[finish_button]
|
||||
Finish
|
||||
---
|
||||
[breath_button]
|
||||
RESPIRAR
|
||||
---
|
||||
|
||||
@@ -160,6 +160,21 @@ Sun Salutation
|
||||
[duration_2h]
|
||||
2 ч
|
||||
---
|
||||
[meditation_duration_setting]
|
||||
Meditation length
|
||||
---
|
||||
[meditation_duration_custom]
|
||||
Custom
|
||||
---
|
||||
[meditation_custom_minutes]
|
||||
Custom time
|
||||
---
|
||||
[meditation_extend_controls_label]
|
||||
Show add-time buttons during meditation
|
||||
---
|
||||
[finish_button]
|
||||
Finish
|
||||
---
|
||||
[breath_button]
|
||||
ДЫШАТЬ
|
||||
---
|
||||
|
||||
@@ -157,6 +157,21 @@ Sun Salutation
|
||||
[duration_2h]
|
||||
2小时
|
||||
---
|
||||
[meditation_duration_setting]
|
||||
Meditation length
|
||||
---
|
||||
[meditation_duration_custom]
|
||||
Custom
|
||||
---
|
||||
[meditation_custom_minutes]
|
||||
Custom time
|
||||
---
|
||||
[meditation_extend_controls_label]
|
||||
Show add-time buttons during meditation
|
||||
---
|
||||
[finish_button]
|
||||
Finish
|
||||
---
|
||||
[breath_button]
|
||||
呼吸
|
||||
---
|
||||
|
||||
@@ -131,13 +131,15 @@
|
||||
form.addEventListener("submit", async (event) => {
|
||||
event.preventDefault();
|
||||
const exportedKey = keyText.value.trim();
|
||||
if (!exportedKey.startsWith("inbe-sync-key-v1")) {
|
||||
setStatus("error", "Upload the exported inbe-sync.key file.");
|
||||
if (!exportedKey.startsWith("lyra-account-key-v1") &&
|
||||
!exportedKey.startsWith("inbe-sync-key-v1") &&
|
||||
!exportedKey.startsWith("account-key-v1")) {
|
||||
setStatus("error", "Upload the exported account key file.");
|
||||
return;
|
||||
}
|
||||
const userID = keyField(exportedKey, "public_id").toLowerCase();
|
||||
if (!/^[0-9a-f]{64}$/.test(userID)) {
|
||||
setStatus("error", "This key file does not include public_id. Export a new inbe-sync.key from the current Inner Breeze app.");
|
||||
setStatus("error", "This key file does not include public_id. Export a new account key from the current app.");
|
||||
return;
|
||||
}
|
||||
button.disabled = true;
|
||||
|
||||
@@ -131,13 +131,15 @@
|
||||
form.addEventListener("submit", async (event) => {
|
||||
event.preventDefault();
|
||||
const exportedKey = keyText.value.trim();
|
||||
if (!exportedKey.startsWith("inbe-sync-key-v1")) {
|
||||
setStatus("error", "Upload the exported inbe-sync.key file.");
|
||||
if (!exportedKey.startsWith("lyra-account-key-v1") &&
|
||||
!exportedKey.startsWith("inbe-sync-key-v1") &&
|
||||
!exportedKey.startsWith("account-key-v1")) {
|
||||
setStatus("error", "Upload the exported account key file.");
|
||||
return;
|
||||
}
|
||||
const userID = keyField(exportedKey, "public_id").toLowerCase();
|
||||
if (!/^[0-9a-f]{64}$/.test(userID)) {
|
||||
setStatus("error", "This key file does not include public_id. Export a new inbe-sync.key from the current Inner Breeze app.");
|
||||
setStatus("error", "This key file does not include public_id. Export a new account key from the current app.");
|
||||
return;
|
||||
}
|
||||
button.disabled = true;
|
||||
|
||||
@@ -163,6 +163,10 @@ typedef struct MeditationPracticeState {
|
||||
int duration_seconds;
|
||||
int remaining_seconds;
|
||||
int frame_ticks;
|
||||
int complete_waiting;
|
||||
int duration_mode;
|
||||
int custom_minutes;
|
||||
int show_extend_controls;
|
||||
int music_enabled;
|
||||
int music_shuffle;
|
||||
int music_track;
|
||||
|
||||
@@ -190,6 +190,9 @@ save_settings(InbeApp *app)
|
||||
{"sun_salutation_repetitions", app->sun_salutation.repetitions},
|
||||
{"sun_salutation_start_seconds", app->sun_salutation.start_seconds},
|
||||
{"sun_salutation_end_seconds", app->sun_salutation.end_seconds},
|
||||
{"meditation_duration_mode", app->meditation.duration_mode},
|
||||
{"meditation_custom_minutes", app->meditation.custom_minutes},
|
||||
{"meditation_show_extend_controls", app->meditation.show_extend_controls ? 1 : 0},
|
||||
{"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},
|
||||
@@ -275,6 +278,7 @@ app_load_settings(InbeApp *app)
|
||||
{&app->advanced_session_controls, "advanced_session_controls", 0},
|
||||
{&app->double_tap_to_breathe, "double_tap_to_breathe", 0},
|
||||
{&app->show_session_volume_control, "show_session_volume_control", 0},
|
||||
{&app->meditation.show_extend_controls, "meditation_show_extend_controls", 1},
|
||||
{&app->meditation.music_enabled, "meditation_music_enabled", 1},
|
||||
{&app->meditation.music_shuffle, "meditation_music_shuffle", 0},
|
||||
};
|
||||
@@ -324,6 +328,10 @@ app_load_settings(InbeApp *app)
|
||||
3, 12},
|
||||
{&app->sun_salutation.end_seconds, "sun_salutation_end_seconds", 5,
|
||||
3, 12},
|
||||
{&app->meditation.duration_mode, "meditation_duration_mode", 1,
|
||||
0, 5},
|
||||
{&app->meditation.custom_minutes, "meditation_custom_minutes", 20,
|
||||
1, 240},
|
||||
{&app->meditation.music_track, "meditation_music_track", 0,
|
||||
0, MEDITATION_MUSIC_TRACK_COUNT - 1},
|
||||
{&app->practice_category_tab, "practice_category_tab", PRACTICE_CATEGORY_MIND,
|
||||
|
||||
@@ -7,16 +7,132 @@
|
||||
#include "flint_ui.h"
|
||||
#include "raylib.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
extern int view_width;
|
||||
extern int view_height;
|
||||
|
||||
static const int meditation_config_preset_count = 5;
|
||||
|
||||
static int
|
||||
meditation_config_duration_height(int content_w)
|
||||
{
|
||||
int columns = content_w >= flint_px(520) ? 3 : 2;
|
||||
int count = meditation_config_preset_count + 1;
|
||||
int rows = (count + columns - 1) / columns;
|
||||
|
||||
return flint_px(30) + rows * flint_px(42) + (rows - 1) * flint_px(8) +
|
||||
flint_px(96) + flint_px(78) + flint_px(18);
|
||||
}
|
||||
|
||||
static int
|
||||
meditation_config_content_height(InbeApp *app, int content_w)
|
||||
{
|
||||
return meditation_music_measure_settings(app, content_w, 1, 1) +
|
||||
return meditation_config_duration_height(content_w) +
|
||||
meditation_music_measure_settings(app, content_w, 1, 1) +
|
||||
app_content_bottom_reserved(app) + flint_px(24);
|
||||
}
|
||||
|
||||
static void
|
||||
meditation_config_save(InbeApp *app)
|
||||
{
|
||||
if(app == NULL)
|
||||
return;
|
||||
app->settings_dirty = 1;
|
||||
save_settings(app);
|
||||
}
|
||||
|
||||
static void
|
||||
meditation_config_draw_duration(InbeApp *app, int x, int w, int *y)
|
||||
{
|
||||
const char *labels[] = {
|
||||
locale_get("duration_5m"),
|
||||
locale_get("duration_15m"),
|
||||
locale_get("duration_30m"),
|
||||
locale_get("duration_1h"),
|
||||
locale_get("duration_2h"),
|
||||
locale_get("meditation_duration_custom")
|
||||
};
|
||||
int mode;
|
||||
int columns;
|
||||
int gap = flint_px(8);
|
||||
int btn_h = flint_px(36);
|
||||
int btn_w;
|
||||
int row_y;
|
||||
int custom_row_y;
|
||||
int toggle_value;
|
||||
int hover = 0;
|
||||
char custom_text[64];
|
||||
|
||||
if(app == NULL || y == NULL)
|
||||
return;
|
||||
|
||||
mode = clampi(app->meditation.duration_mode, 0, meditation_config_preset_count);
|
||||
app->meditation.duration_mode = mode;
|
||||
app->meditation.custom_minutes = clampi(app->meditation.custom_minutes, 1, 240);
|
||||
|
||||
flint_text_draw(locale_get("meditation_duration_setting"), x, *y,
|
||||
flint_ui_font(), flint_theme_get_text());
|
||||
*y += flint_px(30);
|
||||
|
||||
columns = w >= flint_px(520) ? 3 : 2;
|
||||
btn_w = (w - gap * (columns - 1)) / columns;
|
||||
for(int i = 0; i < meditation_config_preset_count + 1; i++) {
|
||||
int col = i % columns;
|
||||
int row = i / columns;
|
||||
int bx = x + col * (btn_w + gap);
|
||||
int by = *y + row * (btn_h + gap);
|
||||
int style = i == mode ? UI_BUTTON_STYLE_PRIMARY : UI_BUTTON_STYLE_SECONDARY;
|
||||
|
||||
if(ui_draw_generic_button(bx, by, btn_w, btn_h, labels[i], style, 0, &hover)) {
|
||||
app->meditation.duration_mode = i;
|
||||
meditation_config_save(app);
|
||||
}
|
||||
}
|
||||
|
||||
row_y = *y + ((meditation_config_preset_count + 1 + columns - 1) / columns) *
|
||||
(btn_h + gap);
|
||||
*y = row_y + flint_px(8);
|
||||
|
||||
custom_row_y = *y;
|
||||
snprintf(custom_text, sizeof(custom_text), "%s: %d min",
|
||||
locale_get("meditation_custom_minutes"), app->meditation.custom_minutes);
|
||||
flint_text_draw(custom_text, x, custom_row_y,
|
||||
flint_ui_font(), flint_theme_get_text());
|
||||
|
||||
{
|
||||
const char *adjust_labels[] = {"-5", "-1", "+1", "+5"};
|
||||
const int adjust_values[] = {-5, -1, 1, 5};
|
||||
int adjust_w = flint_px(50);
|
||||
int adjust_total = adjust_w * 4 + gap * 3;
|
||||
int adjust_x = x + (w - adjust_total) / 2;
|
||||
int adjust_y = custom_row_y + flint_px(34);
|
||||
|
||||
for(int i = 0; i < 4; i++) {
|
||||
if(ui_draw_generic_button(adjust_x + i * (adjust_w + gap), adjust_y,
|
||||
adjust_w, btn_h, adjust_labels[i],
|
||||
UI_BUTTON_STYLE_SECONDARY, 0, &hover)) {
|
||||
app->meditation.custom_minutes =
|
||||
clampi(app->meditation.custom_minutes + adjust_values[i], 1, 240);
|
||||
app->meditation.duration_mode = meditation_config_preset_count;
|
||||
meditation_config_save(app);
|
||||
}
|
||||
}
|
||||
}
|
||||
*y += flint_px(96);
|
||||
|
||||
flint_text_draw(locale_get("meditation_extend_controls_label"), x, *y,
|
||||
flint_ui_font(), flint_theme_get_text());
|
||||
toggle_value = app->meditation.show_extend_controls;
|
||||
if(ui_draw_toggle_switch(x, *y + flint_px(26), flint_px(56), flint_px(30),
|
||||
&toggle_value, locale_get("toggle_off"),
|
||||
locale_get("toggle_on"))) {
|
||||
app->meditation.show_extend_controls = toggle_value;
|
||||
meditation_config_save(app);
|
||||
}
|
||||
*y += flint_px(78);
|
||||
}
|
||||
|
||||
typedef struct MeditationConfigScrollPageContext {
|
||||
InbeApp *app;
|
||||
} MeditationConfigScrollPageContext;
|
||||
@@ -68,6 +184,7 @@ meditation_config_screen_draw(InbeApp *app)
|
||||
});
|
||||
int y = page.content_y;
|
||||
|
||||
meditation_config_draw_duration(app, page.content_x, page.content_w, &y);
|
||||
meditation_music_draw_settings(app, page.content_x, page.content_w,
|
||||
&y, 1, 1);
|
||||
ui_scroll_page_end(page);
|
||||
|
||||
@@ -25,8 +25,7 @@ meditation_practice_start(InbeApp *app)
|
||||
if(app == NULL)
|
||||
return;
|
||||
mark_exercise_manual_seen(app, EXERCISE_MEDITATION);
|
||||
app_open_modal(app, UIModalMeditationSetup);
|
||||
app_switch_screen(app, InbeScreenStart);
|
||||
meditation_start_configured(app);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -8,6 +8,8 @@ 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);
|
||||
int meditation_configured_duration_seconds(const InbeApp *app);
|
||||
void meditation_start_configured(InbeApp *app);
|
||||
void meditation_manual_draw(InbeApp *app);
|
||||
void meditation_manual_close(InbeApp *app, int mark_seen);
|
||||
void meditation_config_screen_draw(InbeApp *app);
|
||||
|
||||
@@ -16,6 +16,16 @@ extern int view_height;
|
||||
|
||||
static int meditation_background_remainder_ms = 0;
|
||||
|
||||
static const int meditation_duration_presets[] = {
|
||||
5 * 60,
|
||||
15 * 60,
|
||||
30 * 60,
|
||||
60 * 60,
|
||||
2 * 60 * 60
|
||||
};
|
||||
|
||||
static void meditation_timer_complete(InbeApp *app);
|
||||
|
||||
static Texture2D
|
||||
meditation_sound_icon_for_volume(InbeApp *app)
|
||||
{
|
||||
@@ -35,9 +45,13 @@ meditation_start(InbeApp *app, int seconds)
|
||||
if(app == NULL)
|
||||
return;
|
||||
|
||||
if(seconds < 60)
|
||||
seconds = 60;
|
||||
|
||||
app->meditation.duration_seconds = seconds;
|
||||
app->meditation.remaining_seconds = seconds;
|
||||
app->meditation.frame_ticks = 0;
|
||||
app->meditation.complete_waiting = 0;
|
||||
meditation_background_remainder_ms = 0;
|
||||
app->session_paused = 0;
|
||||
app->volume_popup_active = 0;
|
||||
@@ -48,6 +62,28 @@ meditation_start(InbeApp *app, int seconds)
|
||||
practice_background_start(app, PRACTICE_MEDITATION);
|
||||
}
|
||||
|
||||
int
|
||||
meditation_configured_duration_seconds(const InbeApp *app)
|
||||
{
|
||||
int mode;
|
||||
|
||||
if(app == NULL)
|
||||
return meditation_duration_presets[1];
|
||||
|
||||
mode = app->meditation.duration_mode;
|
||||
if(mode >= 0 && mode < (int)(sizeof(meditation_duration_presets) /
|
||||
sizeof(meditation_duration_presets[0])))
|
||||
return meditation_duration_presets[mode];
|
||||
|
||||
return clampi(app->meditation.custom_minutes, 1, 240) * 60;
|
||||
}
|
||||
|
||||
void
|
||||
meditation_start_configured(InbeApp *app)
|
||||
{
|
||||
meditation_start(app, meditation_configured_duration_seconds(app));
|
||||
}
|
||||
|
||||
static void
|
||||
meditation_finish(InbeApp *app)
|
||||
{
|
||||
@@ -65,10 +101,12 @@ meditation_finish(InbeApp *app)
|
||||
app_auto_sync(app);
|
||||
}
|
||||
}
|
||||
app_play_sound(app, app->bell_sound, 1.0f);
|
||||
if(!app->meditation.complete_waiting)
|
||||
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->meditation.complete_waiting = 0;
|
||||
meditation_background_remainder_ms = 0;
|
||||
app->session_paused = 0;
|
||||
app->volume_popup_active = 0;
|
||||
@@ -77,6 +115,25 @@ meditation_finish(InbeApp *app)
|
||||
app_switch_screen(app, InbeScreenStart);
|
||||
}
|
||||
|
||||
static void
|
||||
meditation_timer_complete(InbeApp *app)
|
||||
{
|
||||
if(app == NULL)
|
||||
return;
|
||||
|
||||
if(app->meditation.show_extend_controls) {
|
||||
app->meditation.remaining_seconds = 0;
|
||||
app->meditation.frame_ticks = 0;
|
||||
if(!app->meditation.complete_waiting) {
|
||||
app->meditation.complete_waiting = 1;
|
||||
app_play_sound(app, app->bell_sound, 1.0f);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
meditation_finish(app);
|
||||
}
|
||||
|
||||
void
|
||||
meditation_advance_elapsed(InbeApp *app, int elapsed_ms)
|
||||
{
|
||||
@@ -103,7 +160,7 @@ meditation_advance_elapsed(InbeApp *app, int elapsed_ms)
|
||||
app->meditation.frame_ticks = 0;
|
||||
|
||||
if(app->meditation.remaining_seconds <= 0)
|
||||
meditation_finish(app);
|
||||
meditation_timer_complete(app);
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -148,6 +205,7 @@ meditation_exit_to_start(InbeApp *app)
|
||||
app->meditation.duration_seconds = 0;
|
||||
app->meditation.remaining_seconds = 0;
|
||||
app->meditation.frame_ticks = 0;
|
||||
app->meditation.complete_waiting = 0;
|
||||
meditation_background_remainder_ms = 0;
|
||||
app->session_paused = 0;
|
||||
app->volume_popup_active = 0;
|
||||
@@ -193,6 +251,18 @@ draw_meditation_duration_button(int x, int y, int w, int h, const char *label)
|
||||
return ui_draw_generic_button(x, y, w, h, label, UI_BUTTON_STYLE_PRIMARY, 0, &hover);
|
||||
}
|
||||
|
||||
static void
|
||||
meditation_extend_session(InbeApp *app, int seconds)
|
||||
{
|
||||
if(app == NULL || seconds <= 0)
|
||||
return;
|
||||
|
||||
app->meditation.duration_seconds += seconds;
|
||||
app->meditation.remaining_seconds += seconds;
|
||||
app->meditation.complete_waiting = 0;
|
||||
app->meditation.frame_ticks = 0;
|
||||
}
|
||||
|
||||
void
|
||||
meditation_draw_setup_modal(InbeApp *app)
|
||||
{
|
||||
@@ -294,6 +364,49 @@ draw_meditation_sound_controls(InbeApp *app)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
draw_meditation_extend_controls(InbeApp *app, int center_x, int y)
|
||||
{
|
||||
static const int add_seconds[] = {60, 5 * 60, 10 * 60};
|
||||
const char *labels[] = {"+1", "+5", "+10"};
|
||||
int gap = flint_px(8);
|
||||
int btn_h = flint_px(34);
|
||||
int btn_w = flint_px(58);
|
||||
int finish_w = flint_px(96);
|
||||
int total_w = btn_w * 3 + gap * 2;
|
||||
int x = center_x - total_w / 2;
|
||||
int hover = 0;
|
||||
|
||||
if(app == NULL || !app->meditation.show_extend_controls)
|
||||
return;
|
||||
|
||||
if(x < flint_px(12))
|
||||
x = flint_px(12);
|
||||
if(x + total_w > view_width - flint_px(12))
|
||||
x = view_width - flint_px(12) - total_w;
|
||||
|
||||
for(int i = 0; i < 3; i++) {
|
||||
if(ui_draw_generic_button(x + i * (btn_w + gap), y, btn_w, btn_h, labels[i],
|
||||
UI_BUTTON_STYLE_SECONDARY, 0, &hover))
|
||||
meditation_extend_session(app, add_seconds[i]);
|
||||
}
|
||||
|
||||
if(app->meditation.complete_waiting) {
|
||||
int finish_x = center_x - finish_w / 2;
|
||||
int finish_y = y + btn_h + flint_px(10);
|
||||
|
||||
if(finish_x < flint_px(12))
|
||||
finish_x = flint_px(12);
|
||||
if(finish_x + finish_w > view_width - flint_px(12))
|
||||
finish_x = view_width - flint_px(12) - finish_w;
|
||||
|
||||
if(ui_draw_generic_button(finish_x, finish_y, finish_w, btn_h,
|
||||
locale_get("finish_button"), UI_BUTTON_STYLE_PRIMARY,
|
||||
0, &hover))
|
||||
meditation_finish(app);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
meditation_draw_screen(InbeApp *app, int center_x, int center_y)
|
||||
{
|
||||
@@ -352,6 +465,10 @@ meditation_draw_screen(InbeApp *app, int center_x, int center_y)
|
||||
flint_ui_text_y(time_text, center_y - font, font * 2, font),
|
||||
font, flint_theme_get_text());
|
||||
|
||||
draw_meditation_extend_controls(app, center_x, center_y + flint_px(42));
|
||||
if(app->meditation.complete_waiting)
|
||||
return;
|
||||
|
||||
if((
|
||||
#if defined(PLATFORM_WEB)
|
||||
!app->backgrounded
|
||||
@@ -365,7 +482,7 @@ meditation_draw_screen(InbeApp *app, int center_x, int center_y)
|
||||
if(app->meditation.remaining_seconds > 0)
|
||||
app->meditation.remaining_seconds--;
|
||||
if(app->meditation.remaining_seconds <= 0)
|
||||
meditation_finish(app);
|
||||
meditation_timer_complete(app);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -94,6 +94,9 @@ static const char *const importable_setting_keys[] = {
|
||||
"advanced_session_controls",
|
||||
"hold_display_mode",
|
||||
"exercise_type",
|
||||
"meditation_duration_mode",
|
||||
"meditation_custom_minutes",
|
||||
"meditation_show_extend_controls",
|
||||
"meditation_music_enabled",
|
||||
"meditation_music_shuffle",
|
||||
"meditation_music_track",
|
||||
|
||||
+25
-481
@@ -13,390 +13,41 @@
|
||||
#include <emscripten.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)
|
||||
account_has_values(const InbeSyncAccount *account)
|
||||
{
|
||||
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;
|
||||
return flint_lyra_account_has_values(account);
|
||||
}
|
||||
|
||||
static void
|
||||
copy_key_value(char *out, size_t out_size, const char *value, size_t value_len)
|
||||
sync_account_save_and_reset(const InbeSyncAccount *account)
|
||||
{
|
||||
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;
|
||||
storage_settings_begin_write();
|
||||
storage_set_setting_text(SYNC_PUBLIC_ID_KEY, account != NULL ? account->public_id : "");
|
||||
storage_set_setting_text(SYNC_PUBLIC_KEY_KEY, account != NULL ? account->public_key_hex : "");
|
||||
storage_set_setting_text(SYNC_PRIVATE_KEY_KEY, account != NULL ? account->private_key_hex : "");
|
||||
sync_client_clear_auth_token();
|
||||
storage_reset_sync_state();
|
||||
storage_settings_end_write();
|
||||
}
|
||||
|
||||
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';
|
||||
flint_lyra_sha256_hex(data, len, out_hex);
|
||||
}
|
||||
|
||||
int
|
||||
sync_account_available(void)
|
||||
{
|
||||
#if defined(INBE_HAS_LIBOQS)
|
||||
return 1;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
return flint_lyra_account_available();
|
||||
}
|
||||
|
||||
int
|
||||
@@ -426,93 +77,31 @@ sync_account_load(InbeSyncAccount *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);
|
||||
if(!flint_lyra_account_create(&generated))
|
||||
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();
|
||||
|
||||
sync_account_save_and_reset(&generated);
|
||||
*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);
|
||||
if(!flint_lyra_account_import_file(filename, &imported)) {
|
||||
TraceLog(LOG_WARNING, "SYNC: Private key import failed: invalid key file");
|
||||
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();
|
||||
|
||||
sync_account_save_and_reset(&imported);
|
||||
*account = imported;
|
||||
return 1;
|
||||
}
|
||||
@@ -521,30 +110,21 @@ 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();
|
||||
sync_account_save_and_reset(NULL);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
sync_account_export_private_key(const InbeSyncAccount *account, const char *filename)
|
||||
{
|
||||
char body[8200];
|
||||
char body[FLINT_LYRA_ACCOUNT_EXPORT_TEXT_SIZE];
|
||||
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))
|
||||
if(!flint_lyra_account_export_text(account, body, sizeof(body)))
|
||||
return 0;
|
||||
len = (int)strlen(body);
|
||||
|
||||
#if ANDROID_BUILD
|
||||
return android_share_bytes((const unsigned char *)body, (size_t)len, filename,
|
||||
@@ -559,7 +139,7 @@ sync_account_export_private_key(const InbeSyncAccount *account, const char *file
|
||||
const url = URL.createObjectURL(blob);
|
||||
const a = document.createElement("a");
|
||||
a.href = url;
|
||||
a.download = filename || "inbe-sync.key";
|
||||
a.download = filename || "lyra-account.key";
|
||||
a.style.display = "none";
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
@@ -580,48 +160,12 @@ sync_account_export_private_key(const InbeSyncAccount *account, const char *file
|
||||
|
||||
int
|
||||
sync_account_sign_hex(const uint8_t *message, size_t message_len,
|
||||
char *out_signature_hex, size_t out_size)
|
||||
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
|
||||
return flint_lyra_account_sign_hex(&account, message, message_len, out_signature_hex,
|
||||
out_size);
|
||||
}
|
||||
@@ -4,17 +4,15 @@
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "flint_lyra_account.h"
|
||||
|
||||
enum {
|
||||
INBE_SYNC_PUBLIC_ID_HEX_SIZE = 65,
|
||||
INBE_SYNC_PUBLIC_KEY_HEX_SIZE = 2625,
|
||||
INBE_SYNC_PRIVATE_KEY_HEX_SIZE = 5121
|
||||
INBE_SYNC_PUBLIC_ID_HEX_SIZE = FLINT_LYRA_PUBLIC_ID_HEX_SIZE,
|
||||
INBE_SYNC_PUBLIC_KEY_HEX_SIZE = FLINT_LYRA_PUBLIC_KEY_HEX_SIZE,
|
||||
INBE_SYNC_PRIVATE_KEY_HEX_SIZE = FLINT_LYRA_PRIVATE_KEY_HEX_SIZE
|
||||
};
|
||||
|
||||
typedef struct InbeSyncAccount {
|
||||
char public_id[INBE_SYNC_PUBLIC_ID_HEX_SIZE];
|
||||
char public_key_hex[INBE_SYNC_PUBLIC_KEY_HEX_SIZE];
|
||||
char private_key_hex[INBE_SYNC_PRIVATE_KEY_HEX_SIZE];
|
||||
} InbeSyncAccount;
|
||||
typedef FlintLyraAccount InbeSyncAccount;
|
||||
|
||||
int sync_account_available(void);
|
||||
int sync_account_load(InbeSyncAccount *account);
|
||||
|
||||
@@ -1656,7 +1656,6 @@ sync_client_delete_account(const char *base_url)
|
||||
SyncBuffer response = {0};
|
||||
const char *headers[1] = {"Content-Type: application/json"};
|
||||
long status = 0;
|
||||
int len;
|
||||
int ok;
|
||||
|
||||
if(!sync_client_url_valid(base_url))
|
||||
@@ -1664,10 +1663,7 @@ sync_client_delete_account(const char *base_url)
|
||||
if(!sync_account_load(&account))
|
||||
return INBE_SYNC_CLIENT_NO_ACCOUNT;
|
||||
|
||||
len = snprintf(exported_key, sizeof(exported_key),
|
||||
"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(exported_key))
|
||||
if(!flint_lyra_account_export_text(&account, exported_key, sizeof(exported_key)))
|
||||
return INBE_SYNC_CLIENT_PAYLOAD_FAILED;
|
||||
|
||||
if(!sync_buffer_append(&body, "{\"user_id_hash\":", strlen("{\"user_id_hash\":")) ||
|
||||
|
||||
@@ -251,6 +251,8 @@ test_import_export_clear(void)
|
||||
exported = LoadFileText(export_path);
|
||||
check_true("read exported key", exported != NULL);
|
||||
if(exported != NULL) {
|
||||
check_true("export uses generic key header",
|
||||
strstr(exported, "lyra-account-key-v1\n") == exported);
|
||||
check_true("export includes public key", strstr(exported, "\npublic_key=") != NULL);
|
||||
UnloadFileText(exported);
|
||||
}
|
||||
|
||||
Vendored
-1
Submodule vendor/curl deleted from bb837dda23.
Vendored
+1
-1
Submodule vendor/flint updated: 382749a229...81e6ecdb48.
Vendored
-1
Submodule vendor/liboqs deleted from d95fc734f5.
Reference in new issue
Block a user