From 9d57a79c66f6fb9aa1209ea0775a73379a7e0e26 Mon Sep 17 00:00:00 2001 From: soraefir Date: Thu, 24 Sep 2026 20:45:16 +0200 Subject: [PATCH] init --- .github/images/apk.png | Bin 0 -> 6538 bytes .github/images/fdroid.png | Bin 0 -> 14272 bytes .github/images/izzy.png | Bin 0 -> 20993 bytes .github/images/playstore.png | Bin 0 -> 4904 bytes .github/workflows/build.yml | 103 +++ .gitignore | 25 + LICENSE | 674 ++++++++++++++++++ PRIVACY.md | 86 +++ README.md | 85 +++ app/.gitignore | 1 + app/build.gradle | 120 ++++ app/proguard-rules.pro | 21 + app/src/main/AndroidManifest.xml | 52 ++ .../net/helcel/owu/activity/BackupSection.kt | 238 +++++++ .../helcel/owu/activity/BluetoothAction.kt | 71 ++ .../net/helcel/owu/activity/IdentityScreen.kt | 365 ++++++++++ .../helcel/owu/activity/IouDetailScreen.kt | 315 ++++++++ .../net/helcel/owu/activity/IouListScreen.kt | 226 ++++++ .../java/net/helcel/owu/activity/IouLists.kt | 112 +++ .../net/helcel/owu/activity/IssueScreen.kt | 326 +++++++++ .../net/helcel/owu/activity/MainScreen.kt | 206 ++++++ .../net/helcel/owu/activity/OutcomeBanner.kt | 134 ++++ .../java/net/helcel/owu/activity/OwuFace.kt | 129 ++++ .../net/helcel/owu/activity/PeerScreen.kt | 316 ++++++++ .../net/helcel/owu/activity/PendingAsk.kt | 90 +++ .../net/helcel/owu/activity/RedeemPrompt.kt | 85 +++ .../net/helcel/owu/activity/SettingsScreen.kt | 232 ++++++ .../helcel/owu/activity/TemplatesScreen.kt | 81 +++ .../java/net/helcel/owu/activity/Theme.kt | 140 ++++ .../net/helcel/owu/activity/TradeIntent.kt | 26 + .../net/helcel/owu/activity/TradePrompt.kt | 65 ++ .../java/net/helcel/owu/activity/Widgets.kt | 602 ++++++++++++++++ .../helcel/owu/activity/sub/AboutScreen.kt | 78 ++ app/src/main/java/net/helcel/owu/ble/Ble.kt | 55 ++ .../main/java/net/helcel/owu/ble/Frames.kt | 60 ++ app/src/main/java/net/helcel/owu/ble/Link.kt | 446 ++++++++++++ .../java/net/helcel/owu/crypto/Canonical.kt | 70 ++ .../main/java/net/helcel/owu/crypto/Hash.kt | 16 + .../java/net/helcel/owu/crypto/Identity.kt | 140 ++++ .../main/java/net/helcel/owu/crypto/Keys.kt | 120 ++++ .../main/java/net/helcel/owu/crypto/Signer.kt | 13 + app/src/main/java/net/helcel/owu/demo/Demo.kt | 122 ++++ .../java/net/helcel/owu/helper/Android.kt | 25 + .../main/java/net/helcel/owu/helper/Gates.kt | 20 + .../java/net/helcel/owu/helper/Identity.kt | 25 + .../java/net/helcel/owu/helper/Locator.kt | 79 ++ .../main/java/net/helcel/owu/helper/Prefs.kt | 12 + .../java/net/helcel/owu/ledger/IouJson.kt | 22 + .../main/java/net/helcel/owu/ledger/Ledger.kt | 160 +++++ .../main/java/net/helcel/owu/ledger/Model.kt | 290 ++++++++ .../java/net/helcel/owu/ledger/Verifier.kt | 113 +++ .../main/java/net/helcel/owu/peer/Outcome.kt | 21 + .../java/net/helcel/owu/peer/PeerEngine.kt | 565 +++++++++++++++ .../java/net/helcel/owu/peer/PeerManager.kt | 186 +++++ .../java/net/helcel/owu/peer/PeerMessage.kt | 101 +++ .../java/net/helcel/owu/peer/PeerSession.kt | 250 +++++++ .../java/net/helcel/owu/peer/PeerTable.kt | 101 +++ .../main/java/net/helcel/owu/store/Backup.kt | 114 +++ .../java/net/helcel/owu/store/IouStore.kt | 193 +++++ .../main/java/net/helcel/owu/store/Repo.kt | 67 ++ .../res/drawable/ic_launcher_background.xml | 11 + .../res/drawable/ic_launcher_foreground.xml | 29 + .../res/drawable/ic_launcher_monochrome.xml | 25 + .../main/res/mipmap-anydpi/ic_launcher.xml | 6 + .../res/mipmap-anydpi/ic_launcher_round.xml | 6 + app/src/main/res/values-night/themes.xml | 10 + app/src/main/res/values/colors.xml | 6 + app/src/main/res/values/en.xml | 178 +++++ app/src/main/res/values/themes.xml | 18 + app/src/main/res/xml/backup_rules.xml | 13 + .../main/res/xml/data_extraction_rules.xml | 19 + .../java/net/helcel/owu/ble/FramesTest.kt | 49 ++ .../net/helcel/owu/crypto/CanonicalTest.kt | 44 ++ .../java/net/helcel/owu/crypto/JvmSigner.kt | 50 ++ .../java/net/helcel/owu/crypto/KeysTest.kt | 95 +++ .../java/net/helcel/owu/ledger/LedgerTest.kt | 393 ++++++++++ .../net/helcel/owu/peer/PeerEngineTest.kt | 670 +++++++++++++++++ .../net/helcel/owu/peer/PeerSessionTest.kt | 163 +++++ .../java/net/helcel/owu/peer/PeerTableTest.kt | 74 ++ .../java/net/helcel/owu/store/BackupTest.kt | 82 +++ .../java/net/helcel/owu/tools/DevTools.kt | 87 +++ build.gradle | 6 + docs/SPEC.md | 215 ++++++ gradle.properties | 9 + gradle/gradle-daemon-jvm.properties | 12 + gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 48462 bytes gradle/wrapper/gradle-wrapper.properties | 9 + gradlew | 248 +++++++ gradlew.bat | 82 +++ metadata/en-US/full_description.txt | 14 + .../en-US/images/phoneScreenshots/1_home.png | Bin 0 -> 63752 bytes .../images/phoneScreenshots/2_detail.png | Bin 0 -> 73908 bytes .../images/phoneScreenshots/3_profile.png | Bin 0 -> 71024 bytes .../images/phoneScreenshots/4_settings.png | Bin 0 -> 50901 bytes metadata/en-US/short_description.txt | 1 + metadata/en-US/title.txt | 1 + renovate.json | 4 + settings.gradle | 21 + 98 files changed, 11040 insertions(+) create mode 100644 .github/images/apk.png create mode 100644 .github/images/fdroid.png create mode 100644 .github/images/izzy.png create mode 100644 .github/images/playstore.png create mode 100644 .github/workflows/build.yml create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 PRIVACY.md create mode 100644 README.md create mode 100644 app/.gitignore create mode 100644 app/build.gradle create mode 100644 app/proguard-rules.pro create mode 100644 app/src/main/AndroidManifest.xml create mode 100644 app/src/main/java/net/helcel/owu/activity/BackupSection.kt create mode 100644 app/src/main/java/net/helcel/owu/activity/BluetoothAction.kt create mode 100644 app/src/main/java/net/helcel/owu/activity/IdentityScreen.kt create mode 100644 app/src/main/java/net/helcel/owu/activity/IouDetailScreen.kt create mode 100644 app/src/main/java/net/helcel/owu/activity/IouListScreen.kt create mode 100644 app/src/main/java/net/helcel/owu/activity/IouLists.kt create mode 100644 app/src/main/java/net/helcel/owu/activity/IssueScreen.kt create mode 100644 app/src/main/java/net/helcel/owu/activity/MainScreen.kt create mode 100644 app/src/main/java/net/helcel/owu/activity/OutcomeBanner.kt create mode 100644 app/src/main/java/net/helcel/owu/activity/OwuFace.kt create mode 100644 app/src/main/java/net/helcel/owu/activity/PeerScreen.kt create mode 100644 app/src/main/java/net/helcel/owu/activity/PendingAsk.kt create mode 100644 app/src/main/java/net/helcel/owu/activity/RedeemPrompt.kt create mode 100644 app/src/main/java/net/helcel/owu/activity/SettingsScreen.kt create mode 100644 app/src/main/java/net/helcel/owu/activity/TemplatesScreen.kt create mode 100644 app/src/main/java/net/helcel/owu/activity/Theme.kt create mode 100644 app/src/main/java/net/helcel/owu/activity/TradeIntent.kt create mode 100644 app/src/main/java/net/helcel/owu/activity/TradePrompt.kt create mode 100644 app/src/main/java/net/helcel/owu/activity/Widgets.kt create mode 100644 app/src/main/java/net/helcel/owu/activity/sub/AboutScreen.kt create mode 100644 app/src/main/java/net/helcel/owu/ble/Ble.kt create mode 100644 app/src/main/java/net/helcel/owu/ble/Frames.kt create mode 100644 app/src/main/java/net/helcel/owu/ble/Link.kt create mode 100644 app/src/main/java/net/helcel/owu/crypto/Canonical.kt create mode 100644 app/src/main/java/net/helcel/owu/crypto/Hash.kt create mode 100644 app/src/main/java/net/helcel/owu/crypto/Identity.kt create mode 100644 app/src/main/java/net/helcel/owu/crypto/Keys.kt create mode 100644 app/src/main/java/net/helcel/owu/crypto/Signer.kt create mode 100644 app/src/main/java/net/helcel/owu/demo/Demo.kt create mode 100644 app/src/main/java/net/helcel/owu/helper/Android.kt create mode 100644 app/src/main/java/net/helcel/owu/helper/Gates.kt create mode 100644 app/src/main/java/net/helcel/owu/helper/Identity.kt create mode 100644 app/src/main/java/net/helcel/owu/helper/Locator.kt create mode 100644 app/src/main/java/net/helcel/owu/helper/Prefs.kt create mode 100644 app/src/main/java/net/helcel/owu/ledger/IouJson.kt create mode 100644 app/src/main/java/net/helcel/owu/ledger/Ledger.kt create mode 100644 app/src/main/java/net/helcel/owu/ledger/Model.kt create mode 100644 app/src/main/java/net/helcel/owu/ledger/Verifier.kt create mode 100644 app/src/main/java/net/helcel/owu/peer/Outcome.kt create mode 100644 app/src/main/java/net/helcel/owu/peer/PeerEngine.kt create mode 100644 app/src/main/java/net/helcel/owu/peer/PeerManager.kt create mode 100644 app/src/main/java/net/helcel/owu/peer/PeerMessage.kt create mode 100644 app/src/main/java/net/helcel/owu/peer/PeerSession.kt create mode 100644 app/src/main/java/net/helcel/owu/peer/PeerTable.kt create mode 100644 app/src/main/java/net/helcel/owu/store/Backup.kt create mode 100644 app/src/main/java/net/helcel/owu/store/IouStore.kt create mode 100644 app/src/main/java/net/helcel/owu/store/Repo.kt create mode 100644 app/src/main/res/drawable/ic_launcher_background.xml create mode 100644 app/src/main/res/drawable/ic_launcher_foreground.xml create mode 100644 app/src/main/res/drawable/ic_launcher_monochrome.xml create mode 100644 app/src/main/res/mipmap-anydpi/ic_launcher.xml create mode 100644 app/src/main/res/mipmap-anydpi/ic_launcher_round.xml create mode 100644 app/src/main/res/values-night/themes.xml create mode 100644 app/src/main/res/values/colors.xml create mode 100644 app/src/main/res/values/en.xml create mode 100644 app/src/main/res/values/themes.xml create mode 100644 app/src/main/res/xml/backup_rules.xml create mode 100644 app/src/main/res/xml/data_extraction_rules.xml create mode 100644 app/src/test/java/net/helcel/owu/ble/FramesTest.kt create mode 100644 app/src/test/java/net/helcel/owu/crypto/CanonicalTest.kt create mode 100644 app/src/test/java/net/helcel/owu/crypto/JvmSigner.kt create mode 100644 app/src/test/java/net/helcel/owu/crypto/KeysTest.kt create mode 100644 app/src/test/java/net/helcel/owu/ledger/LedgerTest.kt create mode 100644 app/src/test/java/net/helcel/owu/peer/PeerEngineTest.kt create mode 100644 app/src/test/java/net/helcel/owu/peer/PeerSessionTest.kt create mode 100644 app/src/test/java/net/helcel/owu/peer/PeerTableTest.kt create mode 100644 app/src/test/java/net/helcel/owu/store/BackupTest.kt create mode 100644 app/src/test/java/net/helcel/owu/tools/DevTools.kt create mode 100644 build.gradle create mode 100644 docs/SPEC.md create mode 100644 gradle.properties create mode 100644 gradle/gradle-daemon-jvm.properties create mode 100644 gradle/wrapper/gradle-wrapper.jar create mode 100644 gradle/wrapper/gradle-wrapper.properties create mode 100755 gradlew create mode 100644 gradlew.bat create mode 100644 metadata/en-US/full_description.txt create mode 100644 metadata/en-US/images/phoneScreenshots/1_home.png create mode 100644 metadata/en-US/images/phoneScreenshots/2_detail.png create mode 100644 metadata/en-US/images/phoneScreenshots/3_profile.png create mode 100644 metadata/en-US/images/phoneScreenshots/4_settings.png create mode 100644 metadata/en-US/short_description.txt create mode 100644 metadata/en-US/title.txt create mode 100644 renovate.json create mode 100644 settings.gradle diff --git a/.github/images/apk.png b/.github/images/apk.png new file mode 100644 index 0000000000000000000000000000000000000000..d7850af9fe6cf1d3ac35d4f08d6fd9dd398e2b45 GIT binary patch literal 6538 zcmd^EXIxX;mPZ9eF@l2a07@4SNFfPbg;1pz>4*UmLPAdvq$(v8r3-@803uzAsB|HU zR1F}#iGcJX3P^RrefQosGr#wH^I_)OoDW%h?X3T5d#!!;IVW6CM-6lWIKjZc0Mbxb zHeg^lOs0>wnUBzaS+3q4pp%Ov6;qO-3zp=GcE>O%+PTU+U}lPD@LAy z;Rv6DktxYkTT9l~#YqBvAS2=BcWj=+@lru(Afqs(;#|a|(Po63JB-4EFT&l<<_4aB;T>LuF)S4s^g^;&cgd z;yq^)+DqJ-$p4oHWem~Q-NBXQ;Nr}4pb>53;z3g2qkH;~5S(1Kwf|P^O#CxZ^pt_U z(5_&p1O)8lbP(4c(nOL0=AUl-OKGCfJy#6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NPVmS;Dt{$CjOK@^3yXZVMw^hVJQ$JdYHS!m~dnU7I z@25Ydo(c5G_qg6X+7Gcwol)L;Fw?*8J27uyWk_DuWH90ZCx5kk9g%=1WbBCFUbmVz zIroaoTfvZ@UUiAL@NbU*M@E7d_oax$T;`=Efvzf)M)kc=vUw*CB&J z)#A=fCSIZ#9PjH9BD&Qk354VavGH_pXZm`+I1Wkdl~K-N_gyd*&F+g?W(n^R>r@_@K$DDef$4Q|otJXf|OeWZwRE z!@_p{)RX~Hg$O7Jz->a>uUGIWJ~smq!lip;PgS&h>f1!{Tk7g;$ZGLG6-`Y>mr>_u zmzS4BH+KlGH3pPJy$sFF>PWGI=<6yg-+opvTtD3`Nu_j4fnxH}B&oOLq@+|MBO|HV zL9V$1pJe6a1dgaL({*rtArA`|w%g*uFEl)MdV6~h>9Ij#&zzn4Gt$!&G>EQ-=BijB zz1d~!B(E1A-g)UR?gjes7)guDDO+zcpgK>G#`F1OW?6V_FqMgM!vgt&BeP<9ci&N% z$#SC>12E;)+7T2AZpO3k86-f=bZqlc_cq>qYq3ozNxkouVo4TmW?cx_UK|c?2Qhj@w{=gwIlMEDO zro6LjpC8wIz`AiK!sT~c+ZVAd&BRP{Phx{+8DqubU literal 0 HcmV?d00001 diff --git a/.github/images/izzy.png b/.github/images/izzy.png new file mode 100644 index 0000000000000000000000000000000000000000..af5bf5bdac29faa8f8acc07518fd5867bdf0f009 GIT binary patch literal 20993 zcmdqJ^;=Zm7dA|HNvB9iNOuYdigbrGh;(;%i3o_KbOXv-e(mt$W?;UK6dR@)j415(@zV0asq`wFUwLk}-I{gMkKK-8L2f zfIn#O72m!_Kt%9GuzUNw?;H38(^*c>4SWOkcpyr%WO#!Q(cR^h-=J@xAQO|)bVjh$ zBOp9OkbnJ3%X@Bb(Z`=;bMfH;Cg7H`hp9JXk?oCIt^u-|j9#W5+4d zOlhRQf0nbO6jxhIE7O6zx22ucrjwjX&_1`MU%2SKa*kS3^xrY9#yRG5iiU zC(f=s=l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E+3l1%XUMPsq)wzzgnD~>8=IPV%67pD>wgnu*j1=yXxE})t zFM(_DXA{BD+?e`519z%i1M^HYVqfAMdmT(4RL_K)EASH3ZskAaMfCLaGPvhdQf}U~ zTIm-^%A+LGR^xaPV`Jn08r(nIw>Gv%8}pcig=ysEWZ!_`XF=72UhPyl(SZTBA=_ie zBzY3(bTu<`^JAHClYdvhHPd`T3=Iw2rK8+Wp_4rkJi^_@N8uKjv2BXs9OpYxPnLZ#mUp-v{iwm z(IsKV(8=TM!k%jK>5N(B_~gvGA;LR&>w;uM8D|jvVT%oD4kSxJn5~5&x|R}i_aTj zFD~wgCX6E*Kx&jVjFy0%Ehe8T;PJDGcm;*qSy_Q;{9muhHAi2$A~|3_vViA^^X2`? zVqL`~{ETF42a5wttO3N&3?n=~9}DFpBzagXDpn^ng|)}`dVT#S$>4;Si3G9Qm2Lx( zI^UHpsUwsA>cWUoI3&yXC#TmLfZSbxkB3PtK2vm1N4C6o-Q`o-Er>_yTApRW{lE(q zX}(lcwq=34>K-#ZqVoAX88&B83ftiLO-xPYzkZ$Tpo+oVezdZ_{vP_D+?0;X)tWT_ zCXnQJi$){;z*`=g-!qfjJGY8M+;~g^$>pV`@1QRlHr^rvWR<*U&xAZm?-kHeQck|j zdGu&>YDxfBD4(F9g1WkJ(@inG-I|zda%6B7YjM7}zSK9xzDtC=mIcy6Y-4^?HzYxN z9sZS!Vta{q+gL2N^_tv3gpJBu2XBmnL`-n?kjgbV#vb-DqzSbV{#+b`8O*Xo3XvTV zc8=U0B^Ha7DmzKrC;KgHAJL)oPr&We{NQqwsj)Ff9}lgH Y%|lTp0i7XQuvsH=ifC(5X6AeCFS(pD;{X5v literal 0 HcmV?d00001 diff --git a/.github/images/playstore.png b/.github/images/playstore.png new file mode 100644 index 0000000000000000000000000000000000000000..131f3acaa252a863c3b694d0f522ea750aebd81c GIT binary patch literal 4904 zcmZu#X*kqj*B?vC^fxJqAzKJz8HNyL8$|XkODM@MO?I+mn~{BA$1;lSl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Qu?=^Xf`jUHt~g4A>3^F^`QwuC zwS7#v>^`Zx-vjfi>vDBl7VCIM9b@5<5gGJs-tJL6%sq9 g6#x5Mf{gz51&^3@tr*$xbpPY1t7t2iD?JVV5121yGXMYp literal 0 HcmV?d00001 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..c552c75 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,103 @@ +#file: noinspection SpellCheckingInspection + +name: CI-Android APK + +env: + main_project_module: app + playstore_name: IOweU + +on: + push: + branches: [main] + tags: + - "**" + pull_request: + branches: [main] + workflow_dispatch: + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: write + + steps: + - uses: actions/checkout@v7 + with: + fetch-depth: 0 + + - name: set up secrets + run: | + echo "${{ secrets.RELEASE_KEYSTORE }}" > keystore.asc + echo "${{ secrets.RELEASE_KEY}}" > key.asc + gpg -d --passphrase "${{ secrets.RELEASE_KEYSTORE_PASSWORD }}" --batch keystore.asc > app/keystore.properties + gpg -d --passphrase "${{ secrets.RELEASE_KEYSTORE_PASSWORD }}" --batch key.asc > app/key.jks + + - name: Generate Dynamic Release Notes + run: | + mkdir -p tmp/whatsnew + echo "Various improvements for you to experience..." > tmp/whatsnew/whatsnew-en-US + + - name: create and checkout branch + if: github.event_name == 'pull_request' + env: + BRANCH: ${{ github.head_ref }} + run: git checkout -B "$BRANCH" + + - name: set up JDK + uses: actions/setup-java@v6 + with: + java-version: 21 + distribution: "temurin" + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v6 + + - name: Lint and unit tests + run: ./gradlew lintDebug testDebugUnitTest + + - name: Build APK + run: | + VERSION_CODE=$(git rev-list --count HEAD) + VERSION_BASE=$(git describe --tags --abbrev=0 | sed 's/^v//') + VERSION_DEV=$(git rev-list --count $(git describe --tags --abbrev=0)..HEAD) + if [ $VERSION_DEV -gt 0 ]; then + VERSION_NAME="${VERSION_BASE}.${VERSION_DEV}" + else + VERSION_NAME="${VERSION_BASE}" + fi + ./gradlew bundleSignedRelease assembleSignedRelease -PVERSION_CODE=$VERSION_CODE -PVERSION_NAME=$VERSION_NAME + # ./gradlew assembleSignedRelease -PVERSION_CODE=$VERSION_CODE -PVERSION_NAME=$VERSION_NAME + # ./gradlew bundleSignedRelease -PVERSION_CODE=$VERSION_CODE -PVERSION_NAME=$VERSION_NAME + + - name: Upload APK + uses: actions/upload-artifact@v7 + with: + path: app/build/outputs/apk/signedRelease/app-signedRelease.apk + compression-level: 0 + archive: false + + - name: Release + uses: softprops/action-gh-release@v3 + if: startsWith(github.ref, 'refs/tags/') + with: + files: | + app/build/outputs/apk/signedRelease/app-signedRelease.apk + prerelease: | + if [[ ${{ github.ref }} =~ ^refs/tags/[0-9]+\.[0-9]+[a-z]+$ ]]; then + echo "false" + else + echo "true" + fi + + - name: Upload to Google Play + uses: r0adkll/upload-google-play@v1 + if: startsWith(github.ref, 'refs/tags/') + with: + serviceAccountJsonPlainText: ${{ secrets.SERVICE_ACCOUNT_JSON }} + packageName: net.helcel.owu + releaseFiles: app/build/outputs/bundle/signedRelease/app-signedRelease.aab + tracks: "alpha" # ${{ startsWith(github.ref, 'refs/tags/') && 'production' || 'alpha' }} + status: completed + whatsNewDirectory: tmp/whatsnew diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6b0375d --- /dev/null +++ b/.gitignore @@ -0,0 +1,25 @@ +*.iml +.idea/ +node_modules/ +temp/ +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +.yarn +app/build/ +app/debug/ +app/release/ +captures/ +local.properties +keystore.properties +key.jks diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..b94ef7c --- /dev/null +++ b/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) 2026 Helcel + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) 2026 Helcel + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/PRIVACY.md b/PRIVACY.md new file mode 100644 index 0000000..2a85d0f --- /dev/null +++ b/PRIVACY.md @@ -0,0 +1,86 @@ +# Privacy Policy for iOweU + +**App:** iOweU (`net.helcel.owu`) +**Developer:** Helcel +**Effective date:** 25 September 2026 + +## Data collection + +iOweU does not collect, transmit, or share any personal or sensitive user data. +The app has no internet access, contains no analytics, advertising, or +crash-reporting libraries, and requires no account. + +It asks for three permissions, each only at the moment it is needed: + +- **Location**, when an OwU is tied to a place. The reading is compared with + that place on your device and then discarded. It is not stored, not written + into the OwU, and not sent anywhere. +- **Camera**, while you scan another person's identity QR code. No image is + stored. +- **Nearby devices (Bluetooth)**, while the app is open, to find and trade with + a phone next to you. Bluetooth is never used to work out where you are. + +Two phones find each other by advertising a short code (a hash of the public +key, not the key itself) that any phone in range can hear. The exchange +itself goes over a connection to the phone you picked, so only that phone +receives what you trade. It is not encrypted, so treat an OwU's contents as +readable by whoever you are trading with, and by anyone who can listen to +that connection. Nothing else on your device is ever put on the air. + +## Data stored on your device + +Everything you enter in the app - your OwUs, your address book of contacts' +public keys and the names you give them, and your display preferences - is +saved only in the app's private storage on your device. This data is never +sent to us or to any third party. An OwU is only ever sent to another person +when you choose to share it. + +Your signing key is generated on your device and stored in the app's private +storage, sealed with a key held in the Android Keystore - a copy +of the file is useless on any other device. + +You can export everything, including that key, to a backup file you choose the +location of (Settings › Backup). That file is encrypted with a passphrase you +pick, and nobody - including us - can open it without that passphrase. It is +also the one thing that can make another phone _be_ you, so keep it as you +would keep a key to your home. + +If Android's system backup is enabled on your device, your operating system may +include this data in your device backup. That is handled by Android under your +device vendor's privacy policy, not by iOweU. + +## Data sharing + +None. No data leaves your device, so there is nothing to share, sell, or +disclose to third parties. + +## Data retention and deletion + +Your data remains on your device until you delete it. Clearing the app's data +in Android Settings, or uninstalling iOweU, permanently removes everything the +app has stored. + +## Children + +iOweU is suitable for all ages and collects no data from any user, including +children. + +## Security + +Because no data is transmitted or stored on any server, there is no remote data +to secure. On-device data is protected by Android's app sandbox. + +## Open source + +iOweU is released under the GNU General Public License, version 3 or later. The full source is +available at https://github.com/helcel-net/iOweU, so these statements can be +independently verified. + +## Changes + +Any change affecting privacy will be published in this document before or with +the release that introduces it. + +## Contact + +Issues: https://github.com/helcel-net/iOweU/issues diff --git a/README.md b/README.md new file mode 100644 index 0000000..34b014b --- /dev/null +++ b/README.md @@ -0,0 +1,85 @@ + +
+

OwU

+ +

Owe you - keep track of who owes whom

+ + Built for Android + Built with love +
+ + Build Status + +
+ +## ⭐ Features + +- Signed IOUs: each OwU is a chain of custody, signed with a P-256 key held by the app and sealed by the phone's keystore +- Back it all up - identity, OwUs, templates, contacts - to one passphrase-encrypted file, and restore it on your next phone +- Write, trade (each side puts in an OwU or nothing; a swap is atomic) and redeem OwUs in person, over Bluetooth with nothing to pair. No server. +- Being asked to trade, and being asked to redeem, reach the other person wherever they are in the app - and a "no" is sent back rather than left as silence +- Tie an OwU to a place or a time window +- Identities exchanged by QR code (the only thing codes are used for) +- Small & Fast +- 100% Free and Open Source software, with no proprietary dependencies + +See [docs/SPEC.md](docs/SPEC.md) for the protocol. + +## 🤝 How it works + +Every OwU is a promise from one person (the debtor) to another (the holder), signed with a key that never leaves the debtor's phone. Nothing happens on a server; OwUs move only when two people meet. + +1. **Your identity** is a key pair, and a name you choose for yourself that travels with it. You meet somebody by scanning the code on their profile, which stores their key under whatever you decide to call them - and that key is what lets an OwU they owe be recognised as theirs even when it reaches you through somebody else. OwUs owed by people you have not met say so. +2. **The table** is how anything moves. Tap the trade arrow beside somebody in your contacts and they are asked to the table wherever they are in the app; then each of you puts one OwU on your side of it, or nothing. You both see what is there and what you would each walk away with; it happens when you have both confirmed. A gift is your OwU against their nothing; a swap is an OwU on each side, and it is atomic - neither side can end up short. Nothing is paired: the phones find each other by advertisement and open a connection that lasts as long as the trade. You can only trade with somebody you have named, which is the point of naming them. +3. **`+`** writes a promise you are _ready_ to make, and keeps it. Nothing is signed and nobody is owed anything yet. Each time you put it on a table, a fresh OwU is minted and signed from it - so one "1 Beer" serves every round you ever buy. Delete it when you are done with it. +4. **Redeeming** is the same table, pointed the other way, and it needs no screen: press Redeem on an OwU and the person who owes it gets a prompt, wherever they are. They accept, or they say not now and you are told so. If they are not around the ask waits and goes out by itself when they turn up. OwUs can be tied to a place or a time window, and that is shown in red when it has passed or you are elsewhere - never enforced, because only the person who wrote the promise can say whether it still counts. + +**Forging an OwU is not possible** without the private key of the person who owes it, and keys never leave the phone that made them. **Copying one cannot be prevented** - no offline system can stop someone signing the same OwU over to two people - so OwU catches it instead: the moment an OwU is put on the table it is checked against the copy you already hold, and a history that contradicts yours, or one that has already moved on, cannot be accepted. Failing that, the debtor is the final arbiter: whichever copy they honour wins and the other is dead. + +## 📳 Installation + + + +## ⚙️ Permissions + +- **Location** - only when you redeem an OwU that is tied to a place, to check you are there. Never stored or sent. +- **Camera** - only while scanning a contact's QR code. +- **Nearby devices (Bluetooth)** - while the app is open, to find and talk to other phones running OwU next to you, so that a trade or a redeem can reach you on any screen. It stops the moment the app is not the one in use. + +## 📝 Contribute + +OwU is a user-driven project. We welcome any contribution, big or small. + +- **🖥️ Development:** Fix bugs, implement features, or research issues. Open a PR for review. +- **🍥 Design:** Improve interfaces, including accessibility and usability. +- **📂 Issue Reporting:** Report bugs and edge cases with relevant info. +- **🌍 Localization:** Translate if it doesn't support your language. + +## ✏️ Acknowledgements + +Thanks to all contributors, the developers of our dependencies, and our users. + +## 📝 License + +GNU GPL v3 or later. The full text is in [LICENSE](LICENSE). + +``` +Copyright (C) 2026 Helcel + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +``` diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..42afabf --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..a4fd2f4 --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,120 @@ +plugins { + id 'com.android.application' + id 'org.jetbrains.kotlin.plugin.serialization' version '2.4.20' + id 'org.jetbrains.kotlin.plugin.compose' version '2.4.20' +} + +android { + namespace 'net.helcel.owu' + compileSdk = 37 + + defaultConfig { + // Two names for one app: what it calls itself on its own screens, and + // what it is called out in the world - the launcher, the store listing + // and the About page. + buildConfigField("String", "PUBLIC_NAME", "\"iOweU\"") + manifestPlaceholders["PUBLIC_NAME"] = "iOweU" + applicationId 'net.helcel.owu' + minSdk = 28 + targetSdk = 37 + versionName project.hasProperty('VERSION_NAME') ? project.property('VERSION_NAME') : "0.1" + versionCode project.hasProperty('VERSION_CODE') ? project.property('VERSION_CODE').toInteger() : 1 + } + signingConfigs { + register("release") { + try { + def keystorePropertiesFile = rootProject.file("app/keystore.properties") + def keystoreProperties = new Properties() + keystoreProperties.load(new FileInputStream(keystorePropertiesFile)) + + keyAlias keystoreProperties['keyAlias'] + keyPassword keystoreProperties['keyPassword'] + storeFile file(keystoreProperties['storeFile']) + storePassword keystoreProperties['storePassword'] + } catch (FileNotFoundException e) { + println("File not found: ${e.message}") + } + } + } + buildTypes { + debug { + debuggable true + applicationIdSuffix ".debug" + } + release { + minifyEnabled true + shrinkResources true + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + signedRelease { + minifyEnabled true + shrinkResources true + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + signingConfig = signingConfigs.getByName("release") + } + } + compileOptions { + coreLibraryDesugaringEnabled true + + sourceCompatibility JavaVersion.VERSION_21 + targetCompatibility JavaVersion.VERSION_21 + encoding 'utf-8' + } + + buildFeatures { + compose true + buildConfig true + } + + dependenciesInfo { + // Disables dependency metadata when building APKs. + includeInApk = false + // Disables dependency metadata when building Android App Bundles. + includeInBundle = false + } + androidResources { + // The app ships English strings only; without this the libraries drag + // in some eighty locales of their own. + localeFilters += ["en"] + } + + testOptions { + // IouStore logs through android.util.Log on unreadable files; the JVM has no Log. + unitTests.returnDefaultValues = true + } + + lint { + disable 'UsingMaterialAndMaterial3Libraries' + // Strings looked up inside click handlers, where stringResource() is + // not available; the context captured at composition is the right one. + disable 'LocalContextGetResourceValueCall' + } + +} + +dependencies { + implementation 'androidx.compose.material3:material3:1.4.0' + implementation "androidx.compose.material:material:1.12.1" + implementation 'androidx.compose.material:material-icons-extended:1.7.8' + implementation 'androidx.navigation:navigation-compose:2.10.1' + coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs_nio:2.1.5' + + implementation 'org.jetbrains.kotlinx:kotlinx-serialization-json:1.11.0' + + // QR codes for exchanging identities. Both Apache-2.0, no Play Services. + implementation 'com.google.zxing:core:3.5.4' + implementation 'com.journeyapps:zxing-android-embedded:4.3.0' + + testImplementation 'junit:junit:4.13.2' + testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.9.0' + testImplementation 'org.jetbrains.kotlin:kotlin-test-junit:2.4.20' + + implementation 'androidx.compose.ui:ui' + implementation "androidx.activity:activity-ktx:1.13.0" + + implementation 'androidx.compose.ui:ui-tooling-preview' + + + implementation platform('androidx.compose:compose-bom:2026.09.00') + debugImplementation 'androidx.compose.ui:ui-tooling:1.12.1' +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..b91a6a0 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/java/net/helcel/owu/activity/BackupSection.kt b/app/src/main/java/net/helcel/owu/activity/BackupSection.kt new file mode 100644 index 0000000..4ad07dc --- /dev/null +++ b/app/src/main/java/net/helcel/owu/activity/BackupSection.kt @@ -0,0 +1,238 @@ +package net.helcel.owu.activity + +import android.net.Uri +import androidx.activity.compose.rememberLauncherForActivityResult +import androidx.activity.result.contract.ActivityResultContracts +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.text.KeyboardOptions +import androidx.compose.material.AlertDialog +import androidx.compose.material.MaterialTheme +import androidx.compose.material.OutlinedButton +import androidx.compose.material.OutlinedTextField +import androidx.compose.material.Text +import androidx.compose.material.TextButton +import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.rememberCoroutineScope +import androidx.compose.runtime.setValue +import androidx.compose.foundation.layout.padding +import androidx.compose.ui.Modifier +import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.input.PasswordVisualTransformation +import androidx.compose.ui.unit.dp +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.launch +import kotlinx.coroutines.withContext +import net.helcel.owu.R +import net.helcel.owu.crypto.Identity +import net.helcel.owu.crypto.Keys +import net.helcel.owu.helper.toast +import net.helcel.owu.peer.PeerManager +import net.helcel.owu.store.Backup +import net.helcel.owu.store.BackupException +import net.helcel.owu.store.Repo +import java.time.LocalDate +import java.util.Base64 + +/** + * Settings' backup corner: write everything this phone is to a file, and read + * one back - on this phone or the next one. + */ +@Composable +fun BackupSection() { + val context = LocalContext.current + val scope = rememberCoroutineScope() + var passphraseFor by remember { mutableStateOf(null) } // writing + var restoreFrom by remember { mutableStateOf(null) } // reading + var takeOver by remember { mutableStateOf(null) } + + val create = rememberLauncherForActivityResult(ActivityResultContracts.CreateDocument("application/json")) { uri -> + passphraseFor = uri + } + val pick = rememberLauncherForActivityResult(ActivityResultContracts.OpenDocument()) { uri -> + restoreFrom = uri + } + + fun write(uri: Uri, passphrase: String) { + scope.launch { + val trouble = withContext(Dispatchers.IO) { + runCatching { + val (priv, pub) = Repo.signer.export() + val contents = Backup.Contents( + privateKey = Base64.getEncoder().encodeToString(priv), + publicKey = Base64.getEncoder().encodeToString(pub), + name = Repo.myName(context), + ious = Repo.store.ious.value.values.toList(), + templates = Repo.store.templates.value.values.toList(), + contacts = Repo.store.contacts.value, + ) + val bytes = Backup.seal(contents, passphrase.toCharArray()) + context.contentResolver.openOutputStream(uri, "wt")?.use { it.write(bytes) } + ?: error("could not write there") + }.exceptionOrNull() + } + context.toast( + if (trouble == null) context.getString(R.string.backup_written) + else trouble.message ?: context.getString(R.string.backup_failed) + ) + } + } + + fun read(uri: Uri, passphrase: String) { + scope.launch { + val result = withContext(Dispatchers.IO) { + runCatching { + val bytes = context.contentResolver.openInputStream(uri)?.use { it.readBytes() } + ?: error("could not read that file") + Backup.open(bytes, passphrase.toCharArray()) + } + } + result.fold( + onSuccess = { contents -> + // OwUs, templates and names come back whatever happens; + // the identity is a separate question, since taking it on + // means giving up the one this phone has. + restore(contents) + val mine = Keys.decode(contents.publicKey)?.let { Base64.getEncoder().encodeToString(it.encoded) } + if (mine == Repo.me) context.toast(context.getString(R.string.backup_restored)) + else takeOver = contents + }, + onFailure = { + context.toast( + (it as? BackupException)?.message ?: context.getString(R.string.backup_failed) + ) + }, + ) + } + } + + // --- dialogs ----------------------------------------------------------- + + passphraseFor?.let { uri -> + PassphraseDialog( + title = stringResource(R.string.backup_export), + hint = stringResource(R.string.backup_passphrase_hint), + confirmTwice = true, + onDismiss = { passphraseFor = null }, + ) { passphrase -> + passphraseFor = null + write(uri, passphrase) + } + } + restoreFrom?.let { uri -> + PassphraseDialog( + title = stringResource(R.string.backup_restore), + hint = stringResource(R.string.backup_passphrase_ask), + confirmTwice = false, + onDismiss = { restoreFrom = null }, + ) { passphrase -> + restoreFrom = null + read(uri, passphrase) + } + } + takeOver?.let { contents -> + AlertDialog( + onDismissRequest = { takeOver = null }, + title = { Text(stringResource(R.string.backup_identity_title)) }, + text = { Text(stringResource(R.string.backup_identity_text, Keys.fingerprint(contents.publicKey))) }, + confirmButton = { + TextButton(onClick = { + takeOver = null + runCatching { + PeerManager.stop() + Repo.adopt( + Identity.replace( + context, + Base64.getDecoder().decode(contents.privateKey), + Base64.getDecoder().decode(contents.publicKey), + ) + ) + Repo.setMyName(context, contents.name) + }.fold( + onSuccess = { context.toast(context.getString(R.string.backup_identity_taken)) }, + onFailure = { context.toast(it.message ?: context.getString(R.string.backup_failed)) }, + ) + }) { Text(stringResource(R.string.backup_identity_take)) } + }, + dismissButton = { + TextButton(onClick = { takeOver = null }) { Text(stringResource(R.string.backup_identity_keep)) } + }, + ) + } + + // --- the two buttons, side by side ------------------------------------- + + Row(modifier = Modifier.fillMaxWidth().padding(top = 8.dp)) { + OutlinedButton( + onClick = { create.launch("owu-backup-${LocalDate.now()}.json") }, + modifier = Modifier.weight(1f), + ) { Text(stringResource(R.string.backup_export)) } + Spacer(Modifier.size(12.dp)) + OutlinedButton( + onClick = { pick.launch(arrayOf("application/json", "application/octet-stream", "*/*")) }, + modifier = Modifier.weight(1f), + ) { Text(stringResource(R.string.backup_restore)) } + } +} + +/** Puts back everything but the identity, through the ordinary merge rules. */ +private fun restore(contents: Backup.Contents) { + contents.ious.forEach { Repo.store.merge(it) } + contents.templates.forEach { Repo.store.putTemplate(it) } + contents.contacts.forEach { Repo.store.putContact(it) } +} + +/** Asks for a passphrase, twice when one is being chosen rather than recalled. */ +@Composable +private fun PassphraseDialog( + title: String, + hint: String, + confirmTwice: Boolean, + onDismiss: () -> Unit, + onConfirm: (String) -> Unit, +) { + var first by remember { mutableStateOf("") } + var again by remember { mutableStateOf("") } + val ready = first.length >= 8 && (!confirmTwice || first == again) + AlertDialog( + onDismissRequest = onDismiss, + title = { Text(title) }, + text = { + Column { + Text( + hint, style = MaterialTheme.typography.body2, + color = MaterialTheme.colors.onSurface.copy(alpha = 0.7f) + ) + OutlinedTextField( + value = first, onValueChange = { first = it }, + label = { Text(stringResource(R.string.backup_passphrase)) }, + singleLine = true, + visualTransformation = PasswordVisualTransformation(), + keyboardOptions = KeyboardOptions(keyboardType = androidx.compose.ui.text.input.KeyboardType.Password), + modifier = Modifier.padding(top = 12.dp), + ) + if (confirmTwice) { + OutlinedTextField( + value = again, onValueChange = { again = it }, + label = { Text(stringResource(R.string.backup_passphrase_again)) }, + singleLine = true, + visualTransformation = PasswordVisualTransformation(), + keyboardOptions = KeyboardOptions(keyboardType = androidx.compose.ui.text.input.KeyboardType.Password), + modifier = Modifier.padding(top = 8.dp), + ) + } + } + }, + confirmButton = { + TextButton(enabled = ready, onClick = { onConfirm(first) }) { Text(stringResource(R.string.ok)) } + }, + dismissButton = { TextButton(onClick = onDismiss) { Text(stringResource(R.string.cancel)) } }, + ) +} diff --git a/app/src/main/java/net/helcel/owu/activity/BluetoothAction.kt b/app/src/main/java/net/helcel/owu/activity/BluetoothAction.kt new file mode 100644 index 0000000..c91c3af --- /dev/null +++ b/app/src/main/java/net/helcel/owu/activity/BluetoothAction.kt @@ -0,0 +1,71 @@ +package net.helcel.owu.activity + +import android.bluetooth.BluetoothAdapter +import android.content.Intent +import android.provider.Settings +import androidx.activity.compose.rememberLauncherForActivityResult +import androidx.activity.result.contract.ActivityResultContracts +import androidx.compose.material.Icon +import androidx.compose.material.IconButton +import androidx.compose.material.LocalContentColor +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.filled.Bluetooth +import androidx.compose.material.icons.filled.BluetoothDisabled +import androidx.compose.material.icons.automirrored.filled.BluetoothSearching +import androidx.compose.runtime.Composable +import androidx.compose.runtime.collectAsState +import androidx.compose.runtime.getValue +import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.res.stringResource +import net.helcel.owu.R +import net.helcel.owu.ble.BlePermissions +import net.helcel.owu.helper.toast +import net.helcel.owu.peer.PeerManager +import net.helcel.owu.peer.PeerManager.Radio + +/** Top-bar Bluetooth state. Tap: request permission, or ask the system to enable. */ +@Composable +fun BluetoothAction() { + val context = LocalContext.current + val radio by PeerManager.radio.collectAsState() + val onAir by PeerManager.state.collectAsState() + + // Result unused: the adapter broadcast starts us. + val enable = rememberLauncherForActivityResult(ActivityResultContracts.StartActivityForResult()) {} + val permissions = rememberLauncherForActivityResult( + ActivityResultContracts.RequestMultiplePermissions() + ) { granted -> + PeerManager.resume(context) + if (granted.values.all { it } && PeerManager.radio.value == Radio.OFF) { + enable.launch(Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE)) + } + } + + val live = radio == Radio.ON && onAir.active + val (icon, label) = when { + live -> Icons.Default.Bluetooth to R.string.bluetooth_on + radio == Radio.ON || radio == Radio.TURNING_ON -> + Icons.AutoMirrored.Filled.BluetoothSearching to R.string.bluetooth_starting + else -> Icons.Default.BluetoothDisabled to R.string.bluetooth_off + } + IconButton(onClick = { + when (radio) { + Radio.UNSUPPORTED -> context.toast(context.getString(R.string.bluetooth_unsupported)) + Radio.NO_PERMISSION -> permissions.launch(BlePermissions.required().toTypedArray()) + Radio.OFF -> runCatching { enable.launch(Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE)) } + // Fallback when the enable prompt is missing. + .onFailure { context.startActivity(Intent(Settings.ACTION_BLUETOOTH_SETTINGS)) } + Radio.TURNING_ON -> Unit + Radio.ON -> { + if (!live) PeerManager.resume(context) + context.toast(onAir.error ?: context.getString(label)) + } + } + }) { + Icon( + icon, + contentDescription = stringResource(label), + tint = LocalContentColor.current.copy(alpha = if (live) 1f else 0.6f), + ) + } +} diff --git a/app/src/main/java/net/helcel/owu/activity/IdentityScreen.kt b/app/src/main/java/net/helcel/owu/activity/IdentityScreen.kt new file mode 100644 index 0000000..cded9b6 --- /dev/null +++ b/app/src/main/java/net/helcel/owu/activity/IdentityScreen.kt @@ -0,0 +1,365 @@ +package net.helcel.owu.activity + +import androidx.activity.compose.rememberLauncherForActivityResult +import androidx.compose.foundation.background +import androidx.compose.foundation.clickable +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.rememberScrollState +import androidx.compose.foundation.verticalScroll +import androidx.compose.material.AlertDialog +import androidx.compose.material.Card +import androidx.compose.material.Divider +import androidx.compose.material.Icon +import androidx.compose.material.IconButton +import androidx.compose.material.MaterialTheme +import androidx.compose.material.OutlinedTextField +import androidx.compose.material.Scaffold +import androidx.compose.material.Text +import androidx.compose.material.TextButton +import androidx.compose.material.TopAppBar +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.automirrored.filled.ArrowBack +import androidx.compose.material.icons.filled.ContentCopy +import androidx.compose.material.icons.filled.Delete +import androidx.compose.material.icons.filled.Circle +import androidx.compose.material.icons.filled.SwapHoriz +import androidx.compose.material.icons.filled.QrCode2 +import androidx.compose.material.icons.filled.Add +import androidx.compose.material.icons.filled.PhotoCamera +import androidx.compose.runtime.Composable +import androidx.compose.runtime.collectAsState +import androidx.compose.runtime.getValue +import androidx.compose.runtime.key +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.window.Dialog +import androidx.compose.ui.text.font.FontFamily +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.unit.dp +import androidx.navigation.NavHostController +import com.journeyapps.barcodescanner.ScanContract +import com.journeyapps.barcodescanner.ScanOptions +import net.helcel.owu.R +import net.helcel.owu.ble.Ble +import net.helcel.owu.crypto.Keys +import net.helcel.owu.peer.PeerManager +import net.helcel.owu.peer.PeerSession +import net.helcel.owu.helper.IdentityCard +import net.helcel.owu.helper.clipboardText +import net.helcel.owu.helper.copyToClipboard +import net.helcel.owu.helper.toast +import net.helcel.owu.store.Contact +import net.helcel.owu.store.Repo + +@Composable +fun IdentityScreen(nav: NavHostController) { + val context = LocalContext.current + val contacts by Repo.store.contacts.collectAsState() + val onAir by PeerManager.state.collectAsState() + var name by remember { mutableStateOf(Repo.myName(context)) } + val card = remember(name) { IdentityCard(name = name.trim(), key = Repo.me).encode() } + + // A scanned or pasted card is confirmed (and named) before it is kept. + var pending by remember { mutableStateOf(null) } + var showManual by remember { mutableStateOf(false) } + // A name is yours to choose and yours to change; the pencil on the row + // opens it, since the row itself now goes to their table. + var renaming by remember { mutableStateOf(null) } + // Passing one on: the same card this screen shows for yourself, for them. + var showing by remember { mutableStateOf(null) } + + fun offer(text: String?) { + val c = text?.let { IdentityCard.decode(it) } + ?: text?.trim()?.takeIf { Keys.decode(it) != null }?.let { IdentityCard(name = "", key = it) } + if (c == null) context.toast(context.getString(R.string.contact_unreadable)) + else if (c.key == Repo.me) context.toast(context.getString(R.string.contact_is_you)) + else pending = c + } + + val scanner = rememberLauncherForActivityResult(ScanContract()) { result -> result.contents?.let { offer(it) } } + fun scan() = scanner.launch(ScanOptions().apply { + setDesiredBarcodeFormats(ScanOptions.QR_CODE) + setPrompt(context.getString(R.string.scan_prompt)) + setBeepEnabled(false) + // Held the way the app is held. Unlocked, it follows the sensor and + // turns sideways while you are lining a code up. + setOrientationLocked(true) + }) + + pending?.let { c -> + var contactName by remember(c) { mutableStateOf(c.name) } + AlertDialog( + onDismissRequest = { pending = null }, + title = { Text(stringResource(R.string.contact_add)) }, + text = { + Column { + Text(Keys.fingerprint(c.key), fontFamily = FontFamily.Monospace) + OutlinedTextField( + value = contactName, onValueChange = { contactName = it }, + label = { Text(stringResource(R.string.name)) }, + singleLine = true, modifier = Modifier.fillMaxWidth().padding(top = 8.dp), + ) + } + }, + confirmButton = { + TextButton(enabled = contactName.isNotBlank(), onClick = { + Repo.store.putContact(Contact(c.key, contactName.trim())) + pending = null + }) { Text(stringResource(R.string.ok)) } + }, + dismissButton = { TextButton(onClick = { pending = null }) { Text(stringResource(R.string.cancel)) } }, + ) + } + renaming?.let { c -> + var name by remember(c) { mutableStateOf(c.name) } + AlertDialog( + onDismissRequest = { renaming = null }, + title = { Text(stringResource(R.string.contact_rename)) }, + text = { + Column { + Text(Keys.fingerprint(c.publicKey), fontFamily = FontFamily.Monospace) + OutlinedTextField( + value = name, onValueChange = { name = it }, + label = { Text(stringResource(R.string.name)) }, + singleLine = true, modifier = Modifier.fillMaxWidth().padding(top = 8.dp), + ) + } + }, + confirmButton = { + TextButton(enabled = name.isNotBlank(), onClick = { + Repo.store.putContact(Contact(c.publicKey, name.trim())) + renaming = null + }) { Text(stringResource(R.string.ok)) } + }, + dismissButton = { TextButton(onClick = { renaming = null }) { Text(stringResource(R.string.cancel)) } }, + ) + } + // A contact's card for somebody else to scan, the same shape as your own. + // The name travels as a suggestion; the key is what checks their signatures. + // + // A plain Dialog, not an AlertDialog: M2's lays its text slot out by first + // and last text baseline, and a QR code has neither, so a slot starting + // with one measures to a negative height and throws. + showing?.let { c -> + Dialog(onDismissRequest = { showing = null }) { + Card(shape = MaterialTheme.shapes.medium, elevation = 8.dp) { + Column( + horizontalAlignment = Alignment.CenterHorizontally, + modifier = Modifier.padding(24.dp), + ) { + Text(c.name, style = MaterialTheme.typography.h6) + QrCode( + remember(c) { IdentityCard(name = c.name, key = c.publicKey).encode() }, + modifier = Modifier.padding(top = 16.dp).size(240.dp), + ) + Text( + Keys.fingerprint(c.publicKey), + style = MaterialTheme.typography.caption, + fontFamily = FontFamily.Monospace, + color = MaterialTheme.colors.onSurface.copy(alpha = 0.6f), + modifier = Modifier.padding(top = 8.dp), + ) + TextButton( + onClick = { showing = null }, + modifier = Modifier.align(Alignment.End).padding(top = 8.dp), + ) { Text(stringResource(R.string.ok)) } + } + } + } + } + if (showManual) { + var key by remember { mutableStateOf("") } + AlertDialog( + onDismissRequest = { showManual = false }, + title = { Text(stringResource(R.string.contact_add_manually)) }, + text = { + OutlinedTextField( + value = key, onValueChange = { key = it }, + label = { Text(stringResource(R.string.field_key)) }, + modifier = Modifier.fillMaxWidth(), + ) + }, + confirmButton = { + TextButton(onClick = { showManual = false; offer(key) }) { Text(stringResource(R.string.ok)) } + }, + dismissButton = { + TextButton(onClick = { showManual = false; offer(context.clipboardText()) }) { + Text(stringResource(R.string.contact_from_clipboard)) + } + }, + ) + } + + Scaffold( + topBar = { + TopAppBar( + title = { Text(stringResource(R.string.identity_title)) }, + navigationIcon = { + IconButton(onClick = { nav.up() }) { + Icon(Icons.AutoMirrored.Filled.ArrowBack, contentDescription = null) + } + } + ) + } + ) { innerPadding -> + Column( + modifier = Modifier + .padding(innerPadding) + .fillMaxSize() + .background(MaterialTheme.colors.background) + .verticalScroll(rememberScrollState()) + .padding(16.dp), + horizontalAlignment = Alignment.CenterHorizontally, + ) { + OutlinedTextField( + value = name, + onValueChange = { name = it; Repo.setMyName(context, it.trim()) }, + label = { Text(stringResource(R.string.field_your_name)) }, + singleLine = true, modifier = Modifier.fillMaxWidth(), + ) + QrCode(card, modifier = Modifier.padding(top = 16.dp).size(240.dp)) + Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier.padding(top = 8.dp)) { + Text( + Keys.fingerprint(Repo.me), + style = MaterialTheme.typography.h6, + fontFamily = FontFamily.Monospace, + ) + IconButton(onClick = { + context.copyToClipboard("iou key", Repo.me) + context.toast(context.getString(R.string.copied)) + }) { + Icon(Icons.Default.ContentCopy, contentDescription = stringResource(R.string.action_copy_key)) + } + } + // The two ways to become a contact, at the head of the list they + // join rather than below however many people you already know. + Row( + verticalAlignment = Alignment.CenterVertically, + modifier = Modifier.fillMaxWidth().padding(top = 24.dp, bottom = 4.dp), + ) { + Text( + stringResource(R.string.contacts), + style = MaterialTheme.typography.h6, + modifier = Modifier.weight(1f), + ) + // A camera and a plus. A QR glyph here was indistinguishable + // from the one on every row below, which *shows* a code rather + // than reads one; a key says "key" only to us. + IconButton(onClick = { scan() }) { + Icon(Icons.Default.PhotoCamera, contentDescription = stringResource(R.string.contact_scan)) + } + IconButton(onClick = { showManual = true }) { + Icon(Icons.Default.Add, contentDescription = stringResource(R.string.contact_add_manually)) + } + } + Divider() + if (contacts.isEmpty()) { + Text( + stringResource(R.string.no_contacts), + style = MaterialTheme.typography.body2, + color = MaterialTheme.colors.onSurface.copy(alpha = 0.6f), + modifier = Modifier.fillMaxWidth().padding(vertical = 12.dp), + ) + } + // Who is on the air, read once: the rows say it and the sort uses + // it, and two readings of the same thing drift apart. + val here = onAir.peers.mapNotNull { (hex, session) -> + key(hex) { + val ss by session.state.collectAsState() + hex.takeIf { ss.phase != PeerSession.Phase.GONE } + } + }.toSet() + // Here now first, then the rest, alphabetical within each, so a + // name does not wander far when somebody arrives or leaves. + contacts.sortedWith( + compareByDescending { Ble.beaconHex(it.publicKey) in here } + .thenBy { it.name.lowercase() } + ).forEach { c -> + ContactRow( + contact = c, + here = Ble.beaconHex(c.publicKey) in here, + onTrade = { nav.navigate("peer/${Ble.beaconHex(c.publicKey)}") }, + onShare = { showing = c }, + onRename = { renaming = c }, + onDelete = { Repo.store.removeContact(c.publicKey) }, + ) + Divider() + } + } + } +} + +/** + * One person you have named: name, key, whether they are in earshot, and the + * button that opens the table with them. + * + * The only door to a trade: you cannot hand a promise to somebody you have not + * named. Redeeming is not a trade and does not come through here - what + * somebody owes you is asked for from the OwU itself, on any screen. + */ +@Composable +private fun ContactRow( + contact: Contact, + here: Boolean, + onTrade: () -> Unit, + onShare: () -> Unit, + onRename: () -> Unit, + onDelete: () -> Unit, +) { + Row( + modifier = Modifier + .fillMaxWidth() + .clickable(onClick = onRename) + .padding(vertical = 8.dp), + verticalAlignment = Alignment.CenterVertically, + ) { + Column(modifier = Modifier.weight(1f)) { + // A dot beside the name rather than a line of prose under it: + // being here is a property of the person, and it reads at a + // glance down a list where three lines apiece did not. Lit in the + // theme's own colour when they are on the air, all but out when + // they are not - and it keeps its words for the screen reader. + Row(verticalAlignment = Alignment.CenterVertically) { + Text(contact.name, style = MaterialTheme.typography.subtitle1, fontWeight = FontWeight.Bold) + Icon( + Icons.Default.Circle, + contentDescription = stringResource(if (here) R.string.contact_here else R.string.contact_away), + tint = if (here) MaterialTheme.colors.primary + else MaterialTheme.colors.onSurface.copy(alpha = 0.2f), + modifier = Modifier.padding(start = 8.dp).size(10.dp), + ) + } + Text( + Keys.fingerprint(contact.publicKey), + style = MaterialTheme.typography.caption, fontFamily = FontFamily.Monospace, + color = MaterialTheme.colors.onSurface.copy(alpha = 0.6f), + ) + } + // Greyed and dead until they are actually on the air: a table needs + // both of you, and there is nothing useful to open without them. + IconButton(onClick = onTrade, enabled = here) { + Icon( + Icons.Default.SwapHoriz, + contentDescription = stringResource(R.string.contact_trade), + tint = if (here) MaterialTheme.colors.primary + else MaterialTheme.colors.onSurface.copy(alpha = 0.3f), + ) + } + IconButton(onClick = onShare) { + Icon(Icons.Default.QrCode2, contentDescription = stringResource(R.string.contact_share)) + } + IconButton(onClick = onDelete) { + Icon(Icons.Default.Delete, contentDescription = stringResource(R.string.delete)) + } + } +} diff --git a/app/src/main/java/net/helcel/owu/activity/IouDetailScreen.kt b/app/src/main/java/net/helcel/owu/activity/IouDetailScreen.kt new file mode 100644 index 0000000..331cf78 --- /dev/null +++ b/app/src/main/java/net/helcel/owu/activity/IouDetailScreen.kt @@ -0,0 +1,315 @@ +package net.helcel.owu.activity + +import androidx.compose.foundation.background +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.rememberScrollState +import androidx.compose.foundation.verticalScroll +import androidx.compose.material.AlertDialog +import androidx.compose.material.Button +import androidx.compose.material.ButtonDefaults +import androidx.compose.material.CircularProgressIndicator +import androidx.compose.material.Divider +import androidx.compose.material.Icon +import androidx.compose.material.IconButton +import androidx.compose.material.MaterialTheme +import androidx.compose.material.Scaffold +import androidx.compose.material.Text +import androidx.compose.material.TextButton +import androidx.compose.material.TopAppBar +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.automirrored.filled.ArrowBack +import androidx.compose.material.icons.filled.Delete +import androidx.compose.runtime.Composable +import androidx.compose.runtime.collectAsState +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.unit.dp +import androidx.navigation.NavHostController +import net.helcel.owu.R +import net.helcel.owu.ble.Ble +import net.helcel.owu.peer.PeerManager +import net.helcel.owu.peer.PeerSession +import net.helcel.owu.helper.Gates +import net.helcel.owu.helper.formatTime +import net.helcel.owu.ledger.Block +import net.helcel.owu.ledger.Iou +import net.helcel.owu.ledger.Status +import net.helcel.owu.ledger.TimeGate +import net.helcel.owu.ledger.Verdict +import net.helcel.owu.ledger.Verifier +import net.helcel.owu.store.Repo + +/** One OwU: what it is, where it stands, its history - and, when somebody + * else owes it, the button that asks them to redeem it. */ +@Composable +fun IouDetailScreen(nav: NavHostController, id: String) { + val context = LocalContext.current + val ious by Repo.store.ious.collectAsState() + // Subscribed, never read: Repo.nameOf() is a plain lookup, so without this + // nothing here would notice a contact being renamed. + @Suppress("UNUSED_VARIABLE") val contacts by Repo.store.contacts.collectAsState() + val iou = ious[id] + if (iou == null) { + // Gone. Leaving is an effect, not part of drawing: popping from + // composition ran again next frame and took the screen underneath too, + // leaving an empty NavHost and a blank screen. + LaunchedEffect(id) { nav.up() } + return + } + val verdict = remember(iou) { Verifier.verify(iou) } + val state = verdict.stateOrNull + val me = Repo.me + + var showDelete by remember { mutableStateOf(false) } + + // --- dialogs ----------------------------------------------------------- + + if (showDelete) { + AlertDialog( + onDismissRequest = { showDelete = false }, + title = { Text(stringResource(R.string.delete)) }, + text = { Text(stringResource(R.string.delete_iou_confirm)) }, + confirmButton = { + // Removing is enough: the screen sees it gone and leaves. + // Popping here too was the second pop that emptied the stack. + TextButton(onClick = { Repo.store.remove(iou.id); showDelete = false }) { + Text(stringResource(R.string.delete)) + } + }, + dismissButton = { TextButton(onClick = { showDelete = false }) { Text(stringResource(R.string.cancel)) } }, + ) + } + + // --- screen ------------------------------------------------------------ + + Scaffold( + topBar = { + TopAppBar( + title = { Text(iou.metadata.title) }, + navigationIcon = { + IconButton(onClick = { nav.up() }) { + Icon(Icons.AutoMirrored.Filled.ArrowBack, contentDescription = null) + } + }, + actions = { + IconButton(onClick = { showDelete = true }) { + Icon(Icons.Default.Delete, contentDescription = stringResource(R.string.delete)) + } + } + ) + } + ) { innerPadding -> + Column( + modifier = Modifier + .padding(innerPadding) + .fillMaxSize() + .background(MaterialTheme.colors.background) + .verticalScroll(rememberScrollState()) + .padding(16.dp) + ) { + if (state == null) { + val v = verdict as Verdict.Invalid + Text(stringResource(R.string.invalid_chain, v.sequence, v.reason), color = MaterialTheme.colors.error) + return@Column + } + + // What was written with it, before the bookkeeping: the part read. + iou.metadata.description?.takeIf { it.isNotBlank() }?.let { + Text( + it, + style = MaterialTheme.typography.body1, + modifier = Modifier.fillMaxWidth().padding(bottom = 16.dp), + ) + } + Field(stringResource(R.string.field_status), statusLabel(state.status)) + Field(stringResource(R.string.role_debtor), Repo.nameOf(state.debtor), verified = state.debtor) + Field(stringResource(R.string.role_holder), Repo.nameOf(state.holder)) + if (iou.metadata.hasWindow) { + Field( + stringResource(R.string.field_window), + listOfNotNull( + iou.metadata.notBefore?.let { stringResource(R.string.window_from, formatTime(it)) }, + iou.metadata.notAfter?.let { stringResource(R.string.window_until, formatTime(it)) }, + ).joinToString(" "), + ) + } + iou.metadata.geoloc?.let { g -> + Field( + stringResource(R.string.field_geoloc), + (g.label?.let { "$it · " } ?: "") + "%.5f, %.5f · %d m".format(g.latitude, g.longitude, g.radiusM), + ) + } + + // Redeeming is handing it back to whoever wrote it. Your own + // promise closes itself on coming home, so this is only ever + // somebody else's, in your hands. + if (state.status == Status.ACTIVE && state.holder == me && state.debtor != me) { + // Greyed when late, early or elsewhere, and still pressable: + // none of that decides anything. Only the one who wrote it can. + var away by remember(iou.id) { mutableStateOf(false) } + LaunchedEffect(iou.id) { away = Gates.outOfPlace(context, iou) } + val off = iou.metadata.timeGate() != TimeGate.Open || away + + // An ask already out: show it rather than a button that would + // only ask again. Silence is the one thing not to do. + val onAir by PeerManager.state.collectAsState() + val session = onAir.peers[Ble.beaconHex(state.debtor)] + val ask = askOutstanding(session, iou.id) + // Asked for, kept until it is on their table: until then they + // are still to be found. Its own state, and it must look like + // one, or the button appears to have done nothing. + val parked = TradeIntent.offer?.takeIf { it.iouId == iou.id } != null + if (ask != null || parked) { + AskStatus( + who = Repo.nameOf(state.debtor), + looking = ask == null, + undelivered = ask?.undelivered != null, + onStop = { + TradeIntent.offer = null + session?.put() + }, + ) + } else Button( + // Earshot is not this button's business: the ask is written + // down and [PendingAsk] finds them, connects and sends it. + // Nowhere to go, nothing to arrange. + onClick = { TradeIntent.offer = TradeIntent.Offer(state.debtor, iou.id) }, + colors = if (!off) ButtonDefaults.buttonColors() else ButtonDefaults.buttonColors( + backgroundColor = MaterialTheme.colors.onSurface.copy(alpha = 0.12f), + contentColor = MaterialTheme.colors.onSurface.copy(alpha = 0.38f), + ), + elevation = if (off) ButtonDefaults.elevation(0.dp, 0.dp, 0.dp) else ButtonDefaults.elevation(), + modifier = Modifier.fillMaxWidth().padding(top = 24.dp), + ) { Text(stringResource(R.string.action_redeem)) } + } + + Text( + stringResource(R.string.history), + style = MaterialTheme.typography.h6, + modifier = Modifier.padding(top = 24.dp, bottom = 4.dp), + ) + Divider() + // Handing an OwU back to its author and the author closing it are + // one thing happening - redeeming - so the pair is shown once. + iou.chain.filterIndexed { i, block -> + !(block is Block.Transfer && block.transferee == debtorOf(iou) && iou.chain.getOrNull(i + 1) is Block.Redeemed) + }.forEach { block -> + HistoryRow(iou, block) + Divider() + } + Text( + iou.id, + style = MaterialTheme.typography.caption, + color = MaterialTheme.colors.onSurface.copy(alpha = 0.4f), + modifier = Modifier.padding(top = 16.dp), + ) + } + } +} + +@Composable +private fun Field(label: String, value: String, verified: String? = null) { + Row(modifier = Modifier.fillMaxWidth().padding(vertical = 4.dp), verticalAlignment = Alignment.CenterVertically) { + Text( + label, + style = MaterialTheme.typography.body2, + color = MaterialTheme.colors.onSurface.copy(alpha = 0.6f), + modifier = Modifier.size(width = 96.dp, height = 20.dp), + ) + Text(value, style = MaterialTheme.typography.body1, fontWeight = FontWeight.Medium) + verified?.let { KnownMark(it) } + } +} + +/** The one who made the promise, and so the only one who can close it. */ +private fun debtorOf(iou: Iou): String? = (iou.chain.firstOrNull() as? Block.Issue)?.debtor + +@Composable +private fun HistoryRow(iou: Iou, block: Block) { + // A promise is always written to oneself, so there is no "to" worth + // saying; and giving it back to its author is redeeming it, which is the + // name this and the closing that follows it go by. + val debtor = debtorOf(iou) + val handedBack = iou.chain.getOrNull(block.sequence - 1) as? Block.Transfer + val line = when (block) { + is Block.Issue -> stringResource(R.string.hist_issued, Repo.nameOf(block.debtor)) + // A swap says so; a plain hand-over reads by where it went. + is Block.Transfer -> when { + block.agreement != null -> + stringResource(R.string.hist_exchanged, Repo.nameOf(block.transferor), Repo.nameOf(block.transferee)) + + block.transferee == debtor -> stringResource(R.string.hist_redeemed, Repo.nameOf(block.transferor)) + else -> + stringResource(R.string.hist_transferred, Repo.nameOf(block.transferor), Repo.nameOf(block.transferee)) + } + // Normally this closes a hand-back and takes its name; a chain that + // reaches this state another way still gets a line of its own. + is Block.Redeemed -> + if (handedBack != null && handedBack.transferee == debtor) + stringResource(R.string.hist_redeemed, Repo.nameOf(handedBack.transferor)) + else stringResource(R.string.hist_closed, Repo.nameOf(block.debtor)) + } + Column(modifier = Modifier.padding(vertical = 8.dp)) { + Text(line, style = MaterialTheme.typography.body1) + Text( + "#${block.sequence} · ${formatTime(block.timestamp)}", + style = MaterialTheme.typography.caption, + color = MaterialTheme.colors.onSurface.copy(alpha = 0.6f), + ) + } +} + +/** + * The state of an ask already sent to this OwU's debtor, or null when there + * is none: my side of their table holds exactly this OwU, and I have said + * yes, so the only thing left is their answer. + */ +@Composable +private fun askOutstanding(session: PeerSession?, iouId: String): PeerSession.State? { + if (session == null) return null + val ss by session.state.collectAsState() + val mine = ss.table.mine + return ss.takeIf { mine.size == 1 && mine[0].id == iouId && ss.table.accepted } +} + +/** Looking for them, waiting on them, or unable to reach them - and a way to stop any of it. */ +@Composable +private fun AskStatus(who: String, looking: Boolean, undelivered: Boolean, onStop: () -> Unit) { + Column(modifier = Modifier.fillMaxWidth().padding(top = 24.dp)) { + Row(verticalAlignment = Alignment.CenterVertically) { + if (looking) { + CircularProgressIndicator(modifier = Modifier.size(16.dp), strokeWidth = 2.dp) + Spacer(Modifier.size(12.dp)) + } + Text( + stringResource( + when { + looking -> R.string.redeem_looking + undelivered -> R.string.redeem_unreachable + else -> R.string.redeem_waiting + }, + who, + ), + style = MaterialTheme.typography.body1, + color = if (undelivered && !looking) MaterialTheme.colors.error else MaterialTheme.colors.onSurface, + ) + } + TextButton(onClick = onStop, modifier = Modifier.padding(top = 4.dp)) { + Text(stringResource(R.string.redeem_stop)) + } + } +} diff --git a/app/src/main/java/net/helcel/owu/activity/IouListScreen.kt b/app/src/main/java/net/helcel/owu/activity/IouListScreen.kt new file mode 100644 index 0000000..1791502 --- /dev/null +++ b/app/src/main/java/net/helcel/owu/activity/IouListScreen.kt @@ -0,0 +1,226 @@ +package net.helcel.owu.activity + +import androidx.compose.foundation.background +import androidx.compose.foundation.clickable +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.lazy.LazyColumn +import androidx.compose.material.Card +import androidx.compose.material.FloatingActionButton +import androidx.compose.material.Icon +import androidx.compose.material.IconButton +import androidx.compose.material.MaterialTheme +import androidx.compose.material.Scaffold +import androidx.compose.material.Text +import androidx.compose.material.TopAppBar +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.filled.Add +import androidx.compose.material.icons.filled.Person +import androidx.compose.material.icons.filled.Settings +import androidx.compose.runtime.Composable +import androidx.compose.runtime.collectAsState +import androidx.compose.runtime.getValue +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.res.pluralStringResource +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.unit.dp +import androidx.navigation.NavHostController +import net.helcel.owu.BuildConfig +import net.helcel.owu.R +import net.helcel.owu.ledger.Block +import net.helcel.owu.ledger.Iou +import net.helcel.owu.ledger.IouState +import net.helcel.owu.ledger.Status +import net.helcel.owu.ledger.Verifier +import net.helcel.owu.store.Template +import net.helcel.owu.store.Repo + +@Composable +fun IouListScreen(nav: NavHostController) { + val ious by Repo.store.ious.collectAsState() + // Subscribed, never read: names come from contacts through Repo.nameOf(), + // which is a plain lookup, so without this nothing here would notice a + // contact being added or renamed. + @Suppress("UNUSED_VARIABLE") val contacts by Repo.store.contacts.collectAsState() + + val me = Repo.me + val verified = remember(ious) { + ious.values.mapNotNull { iou -> Verifier.verify(iou).stateOrNull?.let { iou to it } } + .sortedByDescending { it.first.head.timestamp } + } + // OwUs that are over live under Settings; this screen is what is live. + // Anything in your hands is held - including a promise of your own that + // is on its way somewhere, which says "not given yet" for itself. One + // somebody else holds and you wrote is a debt. + val open = verified.filterNot { it.second.status == Status.REDEEMED } + val held = open.filter { it.second.holder == me } + // OwUs you can do nothing about from here - what you owe, what is spent, + // and the promises you keep ready - are all under Settings. + val other = open.filterNot { it.second.holder == me || it.second.debtor == me } + + val titleOther = stringResource(R.string.section_other) + + Scaffold( + topBar = { + TopAppBar( + // The outward name, the same one on the launcher: this bar is + // the first thing anybody sees of the app. + title = { Text(BuildConfig.PUBLIC_NAME) }, + actions = { + // No trade icon here any more. Trading is something you do + // with a person, not with the app, so it starts from the + // person - tap them under your own profile and their table + // opens. One fewer thing in the bar, and one fewer screen + // between wanting to trade and trading. + BluetoothAction() + IconButton(onClick = { nav.navigate("identity") }) { + Icon(Icons.Default.Person, contentDescription = stringResource(R.string.identity_title)) + } + IconButton(onClick = { nav.navigate("settings") }) { + Icon(Icons.Default.Settings, contentDescription = stringResource(R.string.action_settings)) + } + } + ) + }, + floatingActionButton = { + FloatingActionButton(onClick = { nav.navigate("issue") }) { + Icon(Icons.Default.Add, contentDescription = stringResource(R.string.action_new)) + } + } + ) { innerPadding -> + Box( + modifier = Modifier + .padding(innerPadding) + .fillMaxSize() + .background(MaterialTheme.colors.background) + ) { + if (open.isEmpty()) { + Text( + stringResource(R.string.list_empty), + style = MaterialTheme.typography.body1, + color = MaterialTheme.colors.onSurface.copy(alpha = 0.6f), + modifier = Modifier.align(Alignment.Center).padding(32.dp), + ) + } + LazyColumn(modifier = Modifier.fillMaxSize().padding(horizontal = 16.dp)) { + // What you hold needs no heading: it is what this screen is. + section(null, held, nav) + section(titleOther, other, nav) + item { Spacer(Modifier.size(80.dp)) } // room under the FAB + } + } + } +} + +private fun androidx.compose.foundation.lazy.LazyListScope.section( + title: String?, + rows: List>, + nav: NavHostController, +) { + if (rows.isEmpty()) return + if (title != null) item { SectionHeader(title) } + items(rows.size) { i -> + val (iou, state) = rows[i] + IouRow(iou, state) { nav.navigate("iou/${iou.id}") } + } +} + +@Composable +fun SectionHeader(text: String) { + Text( + text, + style = MaterialTheme.typography.subtitle2, + color = MaterialTheme.colors.primary, + modifier = Modifier.padding(top = 16.dp, bottom = 4.dp), + ) +} + +/** + * "from Alice" when you hold it, "to Bob" when you owe it, and for an OwU + * sitting with the person who made it, what that means: not given yet, back + * with them, or spent. + */ +@Composable +fun counterpartyLine(state: IouState): String = when { + state.debtor == state.holder -> when { + state.status == Status.REDEEMED -> stringResource(R.string.closed_by_x, Repo.nameOf(state.debtor)) + state.debtor == Repo.me -> stringResource(R.string.yours_to_give) + else -> stringResource(R.string.back_with_x, Repo.nameOf(state.debtor)) + } + + state.debtor == Repo.me -> stringResource(R.string.to_x, Repo.nameOf(state.holder)) + state.holder == Repo.me -> stringResource(R.string.from_x, Repo.nameOf(state.debtor)) + else -> "${Repo.nameOf(state.debtor)} → ${Repo.nameOf(state.holder)}" +} + +@Composable +fun IouRow(iou: Iou, state: IouState, onClick: () -> Unit) { + Card( + modifier = Modifier + .fillMaxWidth() + .padding(vertical = 4.dp) + .clickable(onClick = onClick), + elevation = 2.dp, + ) { + Row(modifier = Modifier.padding(12.dp), verticalAlignment = Alignment.CenterVertically) { + Column(modifier = Modifier.weight(1f)) { + Text(iou.metadata.title, style = MaterialTheme.typography.subtitle1, fontWeight = FontWeight.Bold) + Text( + counterpartyLine(state), + style = MaterialTheme.typography.body2, + color = MaterialTheme.colors.onSurface.copy(alpha = 0.7f), + ) + MetaGates(iou.metadata) + } + // No status here: every row on a list is the same status as the + // list it is on, so the label only ever repeated the screen. + } + } +} + +@Composable +fun TemplateRow(template: Template, onClick: () -> Unit) { + Card( + modifier = Modifier + .fillMaxWidth() + .padding(vertical = 4.dp) + .clickable(onClick = onClick), + elevation = 2.dp, + ) { + Row(modifier = Modifier.padding(12.dp), verticalAlignment = Alignment.CenterVertically) { + Column(modifier = Modifier.weight(1f)) { + Text( + template.metadata.title.ifBlank { stringResource(R.string.untitled) }, + style = MaterialTheme.typography.subtitle1, fontWeight = FontWeight.Bold, + ) + Text( + stringResource(R.string.template_ready), + style = MaterialTheme.typography.body2, + color = MaterialTheme.colors.onSurface.copy(alpha = 0.7f), + ) + } + // How many are out there, so a preset shows what it has done. + val given = Repo.store.ious.collectAsState().value.values.count { + it.metadata == template.metadata && (it.chain.firstOrNull() as? Block.Issue)?.debtor == Repo.me && it.chain.size > 1 + } + if (given > 0) { + Text( + pluralStringResource(R.plurals.template_given, given, given), + style = MaterialTheme.typography.caption, + color = MaterialTheme.colors.onSurface.copy(alpha = 0.6f), + ) + } + } + } +} + diff --git a/app/src/main/java/net/helcel/owu/activity/IouLists.kt b/app/src/main/java/net/helcel/owu/activity/IouLists.kt new file mode 100644 index 0000000..0634bd3 --- /dev/null +++ b/app/src/main/java/net/helcel/owu/activity/IouLists.kt @@ -0,0 +1,112 @@ +package net.helcel.owu.activity + +import androidx.compose.foundation.background +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.lazy.LazyColumn +import androidx.compose.material.Icon +import androidx.compose.material.IconButton +import androidx.compose.material.MaterialTheme +import androidx.compose.material.Scaffold +import androidx.compose.material.Text +import androidx.compose.material.TopAppBar +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.automirrored.filled.ArrowBack +import androidx.compose.runtime.Composable +import androidx.compose.runtime.collectAsState +import androidx.compose.runtime.getValue +import androidx.compose.runtime.remember +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.unit.dp +import androidx.navigation.NavHostController +import net.helcel.owu.R +import net.helcel.owu.ledger.Iou +import net.helcel.owu.ledger.IouState +import net.helcel.owu.ledger.Status +import net.helcel.owu.ledger.Verifier +import net.helcel.owu.store.Repo + +/** + * OwUs that are over. They are kept - a spent promise is the proof it was + * kept - but they are history, so they live here rather than among the OwUs + * that still mean something. + */ +@Composable +fun RedeemedScreen(nav: NavHostController) = IouListPage( + nav = nav, + title = stringResource(R.string.redeemed_title), + empty = stringResource(R.string.redeemed_empty), +) { _, state -> isSpent(state) } + +/** + * What you owe: promises of yours that somebody else is holding. They are + * somebody else's to bring back, so they are not among the OwUs you can act + * on - but you should be able to look them in the eye. + */ +@Composable +fun OwedScreen(nav: NavHostController) = IouListPage( + nav = nav, + title = stringResource(R.string.owed_title), + empty = stringResource(R.string.owed_empty), +) { _, state -> owedByMe(state) } + +/** A promise of mine that somebody else is holding. */ +internal fun owedByMe(state: IouState): Boolean = + state.status != Status.REDEEMED && state.debtor == Repo.me && state.holder != Repo.me + +/** A promise that has been kept, and is now only a record. */ +internal fun isSpent(state: IouState): Boolean = state.status == Status.REDEEMED + +/** A screen that is one filtered list of OwUs and nothing else. */ +@Composable +private fun IouListPage( + nav: NavHostController, + title: String, + empty: String, + include: (Iou, IouState) -> Boolean, +) { + val ious by Repo.store.ious.collectAsState() + val rows = remember(ious, title) { + ious.values.mapNotNull { iou -> Verifier.verify(iou).stateOrNull?.let { iou to it } } + .filter { include(it.first, it.second) } + .sortedByDescending { it.first.head.timestamp } + } + + Scaffold( + topBar = { + TopAppBar( + title = { Text(title) }, + navigationIcon = { + IconButton(onClick = { nav.up() }) { + Icon(Icons.AutoMirrored.Filled.ArrowBack, contentDescription = null) + } + } + ) + } + ) { innerPadding -> + Box( + modifier = Modifier + .padding(innerPadding) + .fillMaxSize() + .background(MaterialTheme.colors.background) + ) { + if (rows.isEmpty()) { + Text( + empty, + style = MaterialTheme.typography.body1, + color = MaterialTheme.colors.onSurface.copy(alpha = 0.6f), + modifier = Modifier.align(Alignment.Center).padding(32.dp), + ) + } + LazyColumn(modifier = Modifier.fillMaxSize().padding(horizontal = 16.dp)) { + items(rows.size) { i -> + val (iou, state) = rows[i] + IouRow(iou, state) { nav.navigate("iou/${iou.id}") } + } + } + } + } +} diff --git a/app/src/main/java/net/helcel/owu/activity/IssueScreen.kt b/app/src/main/java/net/helcel/owu/activity/IssueScreen.kt new file mode 100644 index 0000000..9f6b84e --- /dev/null +++ b/app/src/main/java/net/helcel/owu/activity/IssueScreen.kt @@ -0,0 +1,326 @@ +package net.helcel.owu.activity + +import androidx.activity.compose.rememberLauncherForActivityResult +import androidx.activity.result.contract.ActivityResultContracts +import androidx.compose.foundation.background +import androidx.compose.foundation.clickable +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.rememberScrollState +import androidx.compose.foundation.text.KeyboardActions +import androidx.compose.foundation.text.KeyboardOptions +import androidx.compose.foundation.verticalScroll +import androidx.compose.material.Button +import androidx.compose.material.Icon +import androidx.compose.material.IconButton +import androidx.compose.material.MaterialTheme +import androidx.compose.material.OutlinedButton +import androidx.compose.material.OutlinedTextField +import androidx.compose.material.Scaffold +import androidx.compose.material.Switch +import androidx.compose.material.Text +import androidx.compose.material.TopAppBar +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.automirrored.filled.ArrowBack +import androidx.compose.material.icons.filled.Delete +import androidx.compose.runtime.Composable +import androidx.compose.runtime.DisposableEffect +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.rememberCoroutineScope +import androidx.compose.runtime.setValue +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.focus.FocusDirection +import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.platform.LocalFocusManager +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.input.ImeAction +import androidx.compose.ui.text.input.KeyboardType +import androidx.compose.ui.unit.dp +import androidx.navigation.NavHostController +import kotlinx.coroutines.launch +import net.helcel.owu.R +import net.helcel.owu.peer.PeerManager +import net.helcel.owu.helper.Locator +import net.helcel.owu.helper.toast +import net.helcel.owu.ledger.GeoLoc +import net.helcel.owu.ledger.Ledger +import net.helcel.owu.ledger.Metadata +import net.helcel.owu.store.Template +import net.helcel.owu.store.Repo +import java.util.UUID + +/** + * Write a promise. Two jobs, differing in what is left behind. + * + * A **template** ([asTemplate]) is kept as written and signs nothing; an OwU is + * minted from it each time it goes on a table. [templateId] is null for a new + * one, else the one being edited. + * + * A **one-off** is signed there and then and nothing is filed: into your own + * hands from the home screen, onto the table if written at one. + */ +@Composable +fun IssueScreen(nav: NavHostController, templateId: String? = null, asTemplate: Boolean = false) { + val context = LocalContext.current + val scope = rememberCoroutineScope() + val template = remember(templateId) { templateId?.let { Repo.store.templates.value[it] } } + val id = remember { template?.id ?: UUID.randomUUID().toString() } + + var title by remember { mutableStateOf(template?.metadata?.title ?: "") } + var description by remember { mutableStateOf(template?.metadata?.description ?: "") } + val geo = template?.metadata?.geoloc + var hasGeo by remember { mutableStateOf(geo != null) } + var geoLabel by remember { mutableStateOf(geo?.label ?: "") } + var lat by remember { mutableStateOf(geo?.latitude?.toString() ?: "") } + var lon by remember { mutableStateOf(geo?.longitude?.toString() ?: "") } + var radius by remember { mutableStateOf(geo?.radiusM?.toString() ?: "200") } + var locating by remember { mutableStateOf(false) } + // Backing out of a trade's new promise leaves nothing pending. + DisposableEffect(Unit) { onDispose { TradeIntent.pending = null } } + var notBefore by remember { mutableStateOf(template?.metadata?.notBefore) } + var notAfter by remember { mutableStateOf(template?.metadata?.notAfter) } + var hasWindow by remember { mutableStateOf(template?.metadata?.hasWindow == true) } + + // The keyboard walks through the form: every field offers "next" and + // moves focus on, and the last one offers "done" and puts the keyboard + // away. Next, not Down: latitude and longitude sit side by side, and + // "down" from latitude skipped past longitude to the radius below. + val focus = LocalFocusManager.current + val onwards = KeyboardActions( + onNext = { focus.moveFocus(FocusDirection.Next) }, + onDone = { focus.clearFocus() }, + ) + + fun stepping(last: Boolean, type: KeyboardType = KeyboardType.Text) = KeyboardOptions( + keyboardType = type, + imeAction = if (last) ImeAction.Done else ImeAction.Next, + ) + + fun parsedGeo(): GeoLoc? { + if (!hasGeo) return null + val la = lat.replace(',', '.').toDoubleOrNull() ?: return null + val lo = lon.replace(',', '.').toDoubleOrNull() ?: return null + val r = radius.toIntOrNull() ?: return null + if (la !in -90.0..90.0 || lo !in -180.0..180.0 || r <= 0) return null + return GeoLoc.of(la, lo, r, geoLabel.ifBlank { null }) + } + + fun metadata() = Metadata( + title = title.trim(), + description = description.trim().ifBlank { null }, + geoloc = parsedGeo(), + notBefore = notBefore.takeIf { hasWindow }, + notAfter = notAfter.takeIf { hasWindow }, + ) + + fun save() { + if (title.isBlank()) { + context.toast(context.getString(R.string.issue_need_title)); return + } + if (hasGeo && parsedGeo() == null) { + context.toast(context.getString(R.string.issue_bad_geo)); return + } + if (hasWindow && notBefore != null && notAfter != null && notBefore!! > notAfter!!) { + context.toast(context.getString(R.string.issue_bad_window)); return + } + val saved = metadata() + if (asTemplate) { + Repo.store.putTemplate(Template(id, saved, template?.createdAt ?: Ledger.now())) + } else { + // A one-off is signed now. At a table it is minted straight onto + // it; otherwise it is minted here, into my own hands, and shows on + // the home screen as mine to give. + val trading = TradeIntent.take() + if (trading != null) PeerManager.readySession(trading.peerKey)?.putNew(saved) + else Repo.store.put(Ledger.issue(Repo.signer, saved)) + } + nav.up() + } + + fun locate() { + locating = true + scope.launch { + val loc = Locator.current(context) + locating = false + if (loc == null) { + context.toast(context.getString(R.string.geo_unavailable)) + } else { + lat = "%.6f".format(loc.latitude) + lon = "%.6f".format(loc.longitude) + } + } + } + + val permission = rememberLauncherForActivityResult(ActivityResultContracts.RequestPermission()) { granted -> + if (granted) locate() else context.toast(context.getString(R.string.geo_permission_denied)) + } + + Scaffold( + topBar = { + TopAppBar( + // The title says which of the two this is: a promise being + // made once, or one being kept for next time. + title = { + Text( + stringResource( + when { + !asTemplate -> R.string.action_new + template == null -> R.string.template_new + else -> R.string.edit_template + } + ) + ) + }, + navigationIcon = { + IconButton(onClick = { nav.up() }) { + Icon(Icons.AutoMirrored.Filled.ArrowBack, contentDescription = null) + } + }, + actions = { + if (template != null) { + IconButton(onClick = { Repo.store.removeTemplate(template.id); nav.up() }) { + Icon(Icons.Default.Delete, contentDescription = stringResource(R.string.delete)) + } + } + } + ) + } + ) { innerPadding -> + Column( + modifier = Modifier + .padding(innerPadding) + .fillMaxSize() + .background(MaterialTheme.colors.background) + .verticalScroll(rememberScrollState()) + .padding(16.dp) + ) { + OutlinedTextField( + value = title, onValueChange = { title = it }, + label = { Text(stringResource(R.string.field_title)) }, + singleLine = true, modifier = Modifier.fillMaxWidth(), + keyboardOptions = stepping(last = false), keyboardActions = onwards, + ) + // Room for the terms, or the occasion, or the joke. Signed with + // the rest, so neither side can rewrite it afterwards. + OutlinedTextField( + value = description, onValueChange = { description = it }, + label = { Text(stringResource(R.string.field_description)) }, + placeholder = { Text(stringResource(R.string.field_description_hint)) }, + minLines = 2, maxLines = 4, + modifier = Modifier.fillMaxWidth().padding(top = 8.dp), + keyboardOptions = stepping(last = false), keyboardActions = onwards, + ) + // Only worth saying when it is going somewhere the moment it is written. + TradeIntent.pending?.let { + Text( + stringResource(R.string.issue_onto_table, Repo.nameOf(it.peerKey)), + style = MaterialTheme.typography.body2, + color = MaterialTheme.colors.onSurface.copy(alpha = 0.6f), + modifier = Modifier.padding(top = 12.dp), + ) + } + + Row( + verticalAlignment = Alignment.CenterVertically, + modifier = Modifier.fillMaxWidth().padding(top = 16.dp).clickable { hasGeo = !hasGeo }, + ) { + Column(modifier = Modifier.weight(1f)) { + Text(stringResource(R.string.field_geoloc), style = MaterialTheme.typography.subtitle1) + Text( + stringResource(R.string.field_geoloc_desc), + style = MaterialTheme.typography.body2, + color = MaterialTheme.colors.onSurface.copy(alpha = 0.6f), + ) + } + Switch(checked = hasGeo, onCheckedChange = { hasGeo = it }) + } + if (hasGeo) { + OutlinedTextField( + value = geoLabel, onValueChange = { geoLabel = it }, + label = { Text(stringResource(R.string.field_geo_label)) }, + singleLine = true, modifier = Modifier.fillMaxWidth().padding(top = 8.dp), + keyboardOptions = stepping(last = false), keyboardActions = onwards, + ) + Row(modifier = Modifier.fillMaxWidth().padding(top = 8.dp)) { + OutlinedTextField( + value = lat, + onValueChange = { lat = it }, + label = { Text(stringResource(R.string.field_lat)) }, + singleLine = true, + modifier = Modifier.weight(1f), + keyboardOptions = stepping(last = false, type = KeyboardType.Decimal), + keyboardActions = onwards, + ) + Spacer(Modifier.size(8.dp)) + OutlinedTextField( + value = lon, + onValueChange = { lon = it }, + label = { Text(stringResource(R.string.field_lon)) }, + singleLine = true, + modifier = Modifier.weight(1f), + keyboardOptions = stepping(last = false, type = KeyboardType.Decimal), + keyboardActions = onwards, + ) + } + Row( + modifier = Modifier.fillMaxWidth().padding(top = 8.dp), + verticalAlignment = Alignment.CenterVertically + ) { + OutlinedTextField( + value = radius, onValueChange = { radius = it }, + label = { Text(stringResource(R.string.field_radius)) }, + singleLine = true, modifier = Modifier.weight(1f), + keyboardOptions = stepping(last = true, type = KeyboardType.Number), keyboardActions = onwards, + ) + Spacer(Modifier.size(8.dp)) + OutlinedButton( + enabled = !locating, + onClick = { if (Locator.hasPermission(context)) locate() else permission.launch(Locator.PERMISSION) }, + ) { + Text(stringResource(if (locating) R.string.geo_locating else R.string.geo_use_current)) + } + } + } + + Row( + verticalAlignment = Alignment.CenterVertically, + modifier = Modifier.fillMaxWidth().padding(top = 16.dp).clickable { hasWindow = !hasWindow }, + ) { + Column(modifier = Modifier.weight(1f)) { + Text(stringResource(R.string.field_window), style = MaterialTheme.typography.subtitle1) + Text( + stringResource(R.string.field_window_desc), + style = MaterialTheme.typography.body2, + color = MaterialTheme.colors.onSurface.copy(alpha = 0.6f), + ) + } + Switch(checked = hasWindow, onCheckedChange = { hasWindow = it }) + } + if (hasWindow) { + DateTimeField( + label = stringResource(R.string.field_not_before), + value = notBefore, onChange = { notBefore = it }, + modifier = Modifier.fillMaxWidth().padding(top = 8.dp), + ) + DateTimeField( + label = stringResource(R.string.field_not_after), + value = notAfter, onChange = { notAfter = it }, + modifier = Modifier.fillMaxWidth().padding(top = 8.dp), + ) + } + + Button(onClick = { save() }, modifier = Modifier.fillMaxWidth().padding(top = 24.dp)) { + Text(stringResource(if (TradeIntent.pending != null) R.string.action_save_and_offer else R.string.action_save)) + } + } + } +} + diff --git a/app/src/main/java/net/helcel/owu/activity/MainScreen.kt b/app/src/main/java/net/helcel/owu/activity/MainScreen.kt new file mode 100644 index 0000000..d1b70ab --- /dev/null +++ b/app/src/main/java/net/helcel/owu/activity/MainScreen.kt @@ -0,0 +1,206 @@ +package net.helcel.owu.activity + +import android.os.Bundle +import android.app.Activity +import androidx.activity.ComponentActivity +import androidx.activity.compose.rememberLauncherForActivityResult +import androidx.activity.SystemBarStyle +import androidx.activity.enableEdgeToEdge +import androidx.activity.compose.setContent +import androidx.activity.result.contract.ActivityResultContracts +import androidx.compose.foundation.background +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.WindowInsets +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.statusBars +import androidx.compose.foundation.layout.systemBarsPadding +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.layout.windowInsetsTopHeight +import androidx.compose.material.AppBarDefaults +import androidx.compose.material.CircularProgressIndicator +import androidx.compose.material.LocalElevationOverlay +import androidx.compose.material.MaterialTheme +import androidx.compose.material.primarySurface +import androidx.compose.runtime.Composable +import androidx.compose.runtime.DisposableEffect +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.SideEffect +import androidx.compose.runtime.collectAsState +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.saveable.rememberSaveable +import androidx.compose.runtime.setValue +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.luminance +import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.platform.LocalView +import androidx.compose.ui.unit.dp +import androidx.navigation.NavHostController +import androidx.navigation.compose.NavHost +import androidx.navigation.compose.composable +import androidx.navigation.compose.rememberNavController +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.withContext +import androidx.core.view.WindowCompat +import androidx.lifecycle.Lifecycle +import androidx.lifecycle.LifecycleEventObserver +import androidx.lifecycle.compose.LocalLifecycleOwner +import net.helcel.owu.ble.BlePermissions +import net.helcel.owu.peer.PeerManager +import net.helcel.owu.store.Repo + + +class MainScreen : ComponentActivity() { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + actionBar?.hide() + // Draw behind the system bars: no colour named in a file can match a + // Material You bar chosen from the wallpaper. Both fully transparent, + // since the default scrims the navigation bar a shade darker and looks + // like a second mismatch; [SystemBars] gives the icons their contrast. + enableEdgeToEdge( + statusBarStyle = SystemBarStyle.dark(android.graphics.Color.TRANSPARENT), + navigationBarStyle = SystemBarStyle.dark(android.graphics.Color.TRANSPARENT), + ) + + setContent { + SysTheme { + // What a Material 2 app bar paints itself: primarySurface + // *plus* the dark theme's elevation overlay, which lifts a 4dp + // bar off the background. Miss the overlay and the strip above + // it is a near miss, which reads worse than a plain difference. + val bar = MaterialTheme.colors.primarySurface + val barPainted = LocalElevationOverlay.current + ?.apply(bar, AppBarDefaults.TopAppBarElevation) ?: bar + SystemBars(status = barPainted, navigation = MaterialTheme.colors.background) + Box(modifier = Modifier.fillMaxSize().background(MaterialTheme.colors.background)) { + // Status bar in the top bar's colour, the rest in the + // content's. Inside both insets, or the system buttons sit + // on whatever is at the foot of a screen. + Spacer( + Modifier + .align(Alignment.TopCenter) + .fillMaxWidth() + .windowInsetsTopHeight(WindowInsets.statusBars) + .background(barPainted) + ) + Box(modifier = Modifier.fillMaxSize().systemBarsPadding()) { + Root() + } + } + } + } + } + + // BLE only while resumed. Rotation is exempt so trades survive it. + override fun onPause() { + super.onPause() + if (!isChangingConfigurations) PeerManager.pause() + } + + /** Bar icons legible against what is behind them. The colour is a Material + * You one chosen on the device, so it is measured, not assumed. */ + @Composable + private fun SystemBars(status: Color, navigation: Color) { + val view = LocalView.current + val paleStatus = status.luminance() > 0.5f + val paleNavigation = navigation.luminance() > 0.5f + SideEffect { + val window = (view.context as Activity).window + WindowCompat.getInsetsController(window, view).apply { + isAppearanceLightStatusBars = paleStatus + isAppearanceLightNavigationBars = paleNavigation + } + } + } + + /** Opens the store and the Keystore key off the main thread, then shows the app. */ + @Composable + fun Root() { + val context = LocalContext.current + val ready by Repo.ready.collectAsState() + LaunchedEffect(Unit) { + withContext(Dispatchers.IO) { Repo.init(context.applicationContext) } + } + if (!ready) { + Box( + modifier = Modifier.fillMaxSize().background(MaterialTheme.colors.background), + contentAlignment = Alignment.Center, + ) { + CircularProgressIndicator( + color = MaterialTheme.colors.primary, + strokeWidth = 4.dp, + modifier = Modifier.size(50.dp), + ) + } + } else { + // BLE on while the app is in use. + val permissions = rememberLauncherForActivityResult( + ActivityResultContracts.RequestMultiplePermissions() + ) { granted -> if (granted.values.all { it }) PeerManager.resume(context) } + var askedFor by rememberSaveable { mutableStateOf(false) } + val lifecycle = LocalLifecycleOwner.current.lifecycle + DisposableEffect(lifecycle) { + // Runs only once the store has opened, which on a cold start is + // after ON_RESUME has gone by, and an observer hears only what + // comes next. So ask where the lifecycle is, not just where it goes. + fun begin() { + // Always: keeps the icon current without permission. + PeerManager.resume(context) + if (!BlePermissions.granted(context) && !askedFor) { + askedFor = true + permissions.launch(BlePermissions.required().toTypedArray()) + } + } + if (lifecycle.currentState.isAtLeast(Lifecycle.State.RESUMED)) begin() + val observer = LifecycleEventObserver { _, event -> + if (event == Lifecycle.Event.ON_RESUME) begin() + } + lifecycle.addObserver(observer) + onDispose { lifecycle.removeObserver(observer) } + } + // Hoisted out of the nav host: one of the prompts below navigates. + val nav = rememberNavController() + AppNavHost(nav) + // Being asked to pay is worth interrupting for, wherever you are. + RedeemPrompt() + // Somebody opening a table with you is worth interrupting for too. + TradePrompt(nav) + PendingAsk() + // And what came of it: a table can finish with neither side looking. + OutcomeBanner() + } + } + + @Composable + fun AppNavHost(nav: NavHostController) { + NavHost(nav, startDestination = "main") { + composable("main") { IouListScreen(nav) } + // Two ways to write a promise: once, or as a template to reuse. + composable("issue") { IssueScreen(nav) } + composable("template") { IssueScreen(nav, asTemplate = true) } + composable("template/{id}") { + IssueScreen(nav, templateId = it.arguments?.getString("id"), asTemplate = true) + } + composable("iou/{id}") { IouDetailScreen(nav, it.arguments?.getString("id") ?: "") } + composable("identity") { IdentityScreen(nav) } + composable("peer/{beacon}") { PeerScreen(nav, it.arguments?.getString("beacon") ?: "") } + composable("settings") { + SettingsMainScreen( + onExit = { nav.up() }, + onRedeemed = { nav.navigate("redeemed") }, + onOwed = { nav.navigate("owed") }, + onTemplates = { nav.navigate("templates") }, + ) + } + composable("redeemed") { RedeemedScreen(nav) } + composable("owed") { OwedScreen(nav) } + composable("templates") { TemplatesScreen(nav) } + } + } +} diff --git a/app/src/main/java/net/helcel/owu/activity/OutcomeBanner.kt b/app/src/main/java/net/helcel/owu/activity/OutcomeBanner.kt new file mode 100644 index 0000000..27f975e --- /dev/null +++ b/app/src/main/java/net/helcel/owu/activity/OutcomeBanner.kt @@ -0,0 +1,134 @@ +package net.helcel.owu.activity + +import androidx.compose.animation.AnimatedVisibility +import androidx.compose.animation.fadeIn +import androidx.compose.animation.fadeOut +import androidx.compose.animation.slideInVertically +import androidx.compose.animation.slideOutVertically +import androidx.compose.foundation.background +import androidx.compose.foundation.clickable +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.shape.CircleShape +import androidx.compose.material.Card +import androidx.compose.material.Icon +import androidx.compose.material.MaterialTheme +import androidx.compose.material.Text +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.filled.Check +import androidx.compose.material.icons.filled.Close +import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.unit.dp +import kotlinx.coroutines.delay +import net.helcel.owu.R +import net.helcel.owu.peer.Outcome +import net.helcel.owu.peer.PeerMessage +import net.helcel.owu.peer.PeerManager +import net.helcel.owu.store.Repo + +/** + * What just happened, said out loud. A table used to finish by quietly + * emptying itself, and a redeem answered from a prompt finished with no screen + * at all. This lives at the app root and speaks wherever you are. + */ +@Composable +fun OutcomeBanner() { + // Two states, not one: the card keeps saying what it said while it slides + // away, so the words outlive the showing. + var outcome by remember { mutableStateOf(null) } + var visible by remember { mutableStateOf(false) } + + LaunchedEffect(Unit) { + PeerManager.outcomes.collect { + outcome = it + visible = true + } + } + LaunchedEffect(outcome) { + if (outcome == null) return@LaunchedEffect + delay(SHOW_MS) + visible = false + } + + Box(modifier = Modifier.fillMaxSize().padding(16.dp), contentAlignment = Alignment.BottomCenter) { + AnimatedVisibility( + visible = visible, + enter = slideInVertically { it } + fadeIn(), + exit = slideOutVertically { it } + fadeOut(), + ) { + outcome?.let { Banner(it) { visible = false } } + } + } +} + +@Composable +private fun Banner(outcome: Outcome, onDismiss: () -> Unit) { + // A refusal is no failure, and must not look like a success either. + val no = outcome.declined != null + val paper = if (no) MaterialTheme.colors.surface else MaterialTheme.colors.primary + val ink = if (no) MaterialTheme.colors.onSurface else MaterialTheme.colors.onPrimary + Card( + modifier = Modifier.fillMaxWidth().clickable(onClick = onDismiss), + elevation = 8.dp, + backgroundColor = paper, + ) { + Row(modifier = Modifier.padding(16.dp), verticalAlignment = Alignment.CenterVertically) { + Icon( + if (no) Icons.Default.Close else Icons.Default.Check, + contentDescription = null, + tint = paper, + modifier = Modifier + .size(32.dp) + .clip(CircleShape) + .background(ink.copy(alpha = if (no) 0.5f else 1f)) + .padding(4.dp), + ) + Column(modifier = Modifier.padding(start = 16.dp)) { + Text( + headline(outcome), + style = MaterialTheme.typography.body1, + fontWeight = FontWeight.Medium, + color = ink, + ) + outcome.peer?.let { + Text( + stringResource(if (no) R.string.from_x else R.string.done_with, Repo.nameOf(it)), + style = MaterialTheme.typography.caption, + color = ink.copy(alpha = 0.7f), + ) + } + } + } + } +} + +/** The one sentence for it: redeeming first, since that is what ends a loop. */ +@Composable +private fun headline(outcome: Outcome): String = when { + outcome.declined == PeerMessage.Asked.INVITE -> stringResource(R.string.done_declined_trade) + outcome.declined != null -> stringResource(R.string.done_declined_ask) + outcome.redeemed.isNotEmpty() -> stringResource(R.string.done_redeemed, bundleLine(outcome.redeemed)) + outcome.gave.isNotEmpty() && outcome.got.isNotEmpty() -> + stringResource(R.string.done_traded, bundleLine(outcome.gave), bundleLine(outcome.got)) + + outcome.gave.isNotEmpty() -> stringResource(R.string.done_gave, bundleLine(outcome.gave)) + else -> stringResource(R.string.done_got, bundleLine(outcome.got)) +} + +/** Long enough to read, short enough not to be in the way. */ +private const val SHOW_MS = 4_000L diff --git a/app/src/main/java/net/helcel/owu/activity/OwuFace.kt b/app/src/main/java/net/helcel/owu/activity/OwuFace.kt new file mode 100644 index 0000000..1407f6d --- /dev/null +++ b/app/src/main/java/net/helcel/owu/activity/OwuFace.kt @@ -0,0 +1,129 @@ +package net.helcel.owu.activity + +import androidx.compose.animation.core.Animatable +import androidx.compose.animation.core.tween +import androidx.compose.foundation.Canvas +import androidx.compose.foundation.clickable +import androidx.compose.foundation.interaction.MutableInteractionSource +import androidx.compose.material.MaterialTheme +import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.remember +import androidx.compose.runtime.rememberCoroutineScope +import androidx.compose.ui.Modifier +import androidx.compose.ui.geometry.Offset +import androidx.compose.ui.geometry.Rect +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.Path +import androidx.compose.ui.graphics.StrokeCap +import androidx.compose.ui.graphics.StrokeJoin +import androidx.compose.ui.graphics.drawscope.DrawScope +import androidx.compose.ui.graphics.drawscope.Stroke +import androidx.compose.ui.graphics.drawscope.scale +import androidx.compose.ui.semantics.contentDescription +import androidx.compose.ui.semantics.semantics +import kotlinx.coroutines.delay +import kotlinx.coroutines.launch +import kotlin.random.Random + +/** + * The app's face, drawn rather than stamped from the launcher icon so it can + * do the one thing an icon cannot: now and then the left eye closes and OwU + * becomes UwU. Both eyes are one shape ([eye]) at different points of the same + * animation. Tapping winks on demand; left alone it winks rarely. + */ +@Composable +fun OwuFace(modifier: Modifier = Modifier) { + val lid = remember { Animatable(0f) } // 0 = open (O), 1 = shut (U) + val scope = rememberCoroutineScope() + + suspend fun wink() { + lid.animateTo(1f, tween(160)) + delay(340) + lid.animateTo(0f, tween(240)) + } + + // Rarely, and never on a schedule anyone could set a watch by. + LaunchedEffect(Unit) { + while (true) { + delay(Random.nextLong(9_000, 24_000)) + wink() + } + } + + val face = MaterialTheme.colors.onPrimary + val disc = MaterialTheme.colors.primary + Canvas( + modifier + .clickable( + interactionSource = remember { MutableInteractionSource() }, + indication = null, + ) { scope.launch { wink() } } + .semantics { contentDescription = "OwU" }, + ) { + val unit = size.minDimension / 108f + fun p(v: Float) = v * unit + val width = p(5f) + + // One colour, edge to edge, and the face on it - what the launcher + // icon is, minus the shape the launcher itself decides. + drawRect(disc) + + scale(0.88f, pivot = Offset(p(54f), p(52f))) { + // Both eyes stand on the same baseline, y = 60, and reach y = 44. + eye(cx = p(32f), cy = p(52f), r = p(8f), shut = lid.value, color = face, width = width) + eye(cx = p(76f), cy = p(52f), r = p(8f), shut = 1f, color = face, width = width) + + // The mouth stands on the same baseline as the eyes, with a gap + // either side so the three glyphs read as three. + drawPath( + path = Path().apply { + moveTo(p(47f), p(50f)) + lineTo(p(50.5f), p(60f)) + lineTo(p(54f), p(52f)) + lineTo(p(57.5f), p(60f)) + lineTo(p(61f), p(50f)) + }, + color = face, + style = Stroke(width = width, cap = StrokeCap.Round, join = StrokeJoin.Round), + ) + } + } +} + +/** + * One eye between open and shut, in two strokes: the U - bottom half-circle + * and two vertical stems - and the lid arcing over it. Closing raises the + * stems and lets the lid sink onto them, fading. The bottom never moves, the + * sides stay vertical, and [shut] = 1 is exactly the other eye's U: an eye + * shuts, it does not shrink or square off. + */ +private fun DrawScope.eye(cx: Float, cy: Float, r: Float, shut: Float, color: Color, width: Float) { + val stroke = Stroke(width = width, cap = StrokeCap.Round, join = StrokeJoin.Round) + // Up fast, so the U is there before the lid has finished leaving. + val stem = r * (1f - (1f - shut) * (1f - shut)) + drawPath( + Path().apply { + moveTo(cx - r, cy - stem) + lineTo(cx - r, cy) + // Left, round the bottom, to the right. + arcTo(Rect(cx - r, cy - r, cx + r, cy + r), 180f, -180f, false) + lineTo(cx + r, cy - stem) + }, + color, + style = stroke, + ) + if (shut >= 1f) return + val bulge = r * (1f - shut) + drawPath( + Path().apply { + moveTo(cx - r, cy - stem) + // Handles four thirds of the bulge up: the usual approximation of + // a half circle, and a shallower arc as the lid comes down. + cubicTo(cx - r, cy - stem - bulge * 4f / 3f, cx + r, cy - stem - bulge * 4f / 3f, cx + r, cy - stem) + }, + color, + alpha = (1f - shut) * (1f - shut), + style = stroke, + ) +} diff --git a/app/src/main/java/net/helcel/owu/activity/PeerScreen.kt b/app/src/main/java/net/helcel/owu/activity/PeerScreen.kt new file mode 100644 index 0000000..0a78136 --- /dev/null +++ b/app/src/main/java/net/helcel/owu/activity/PeerScreen.kt @@ -0,0 +1,316 @@ +package net.helcel.owu.activity + +import androidx.activity.compose.rememberLauncherForActivityResult +import androidx.activity.result.contract.ActivityResultContracts +import androidx.compose.foundation.background +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.rememberScrollState +import androidx.compose.foundation.verticalScroll +import androidx.compose.material.AlertDialog +import androidx.compose.material.Card +import androidx.compose.material.CircularProgressIndicator +import androidx.compose.material.Divider +import androidx.compose.material.Icon +import androidx.compose.material.IconButton +import androidx.compose.material.LocalContentColor +import androidx.compose.material.MaterialTheme +import androidx.compose.material.OutlinedButton +import androidx.compose.material.OutlinedTextField +import androidx.compose.material.Scaffold +import androidx.compose.material.Text +import androidx.compose.material.TextButton +import androidx.compose.material.TopAppBar +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.filled.Check +import androidx.compose.material.icons.automirrored.filled.ArrowBack +import androidx.compose.runtime.Composable +import androidx.compose.runtime.DisposableEffect +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.collectAsState +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.rememberCoroutineScope +import androidx.compose.runtime.setValue +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.font.FontFamily +import androidx.compose.ui.unit.dp +import androidx.navigation.NavHostController +import kotlinx.coroutines.launch +import net.helcel.owu.R +import net.helcel.owu.ble.Ble +import net.helcel.owu.helper.Gates +import net.helcel.owu.helper.Locator +import net.helcel.owu.helper.toast +import net.helcel.owu.ledger.Status +import net.helcel.owu.ledger.Verifier +import net.helcel.owu.peer.PeerManager +import net.helcel.owu.peer.PeerSession +import net.helcel.owu.store.Contact +import net.helcel.owu.store.Repo + +/** One person, once picked: the table between us. Opening this screen opens + * the connection and leaving it hangs up again. */ +@Composable +fun PeerScreen(nav: NavHostController, beaconHex: String) { + val context = LocalContext.current + val scope = rememberCoroutineScope() + val st by PeerManager.state.collectAsState() + val session = st.peers[beaconHex] + if (session == null) { + // They walked away while we were looking at them. + LaunchedEffect(Unit) { nav.up() } + return + } + val ss by session.state.collectAsState() + val ious by Repo.store.ious.collectAsState() + val contacts by Repo.store.contacts.collectAsState() + val templates by Repo.store.templates.collectAsState() + val peer = ss.peer + val known = peer != null && contacts.any { it.publicKey == peer.key } + // Until the handshake finishes there is no identity to read a name from, + // and you arrived here by tapping somebody by name: say their name. The + // beacon is derived from their key, so this is the contact you picked, + // not a guess - it is only the *proof* that is still a second away. + val who = peerLabel(peer, known).ifBlank { + contacts.firstOrNull { Ble.beacon(it.publicKey).contentEquals(session.beacon) }?.name.orEmpty() + } + + var connecting by remember { mutableStateOf(true) } + var linkError by remember { mutableStateOf(false) } + LaunchedEffect(beaconHex) { + connecting = true + linkError = !PeerManager.select(session.beacon) + connecting = false + } + // Once we are known to each other, tell them we are here: they get a + // prompt wherever they are, rather than having to guess that somebody is + // standing at a table waiting for them. + LaunchedEffect(beaconHex, ss.phase) { + if (ss.phase == PeerSession.Phase.READY) session.invite() + } + DisposableEffect(beaconHex) { + onDispose { PeerManager.release(session.beacon) } + } + + var addName by remember { mutableStateOf(null) } + var pickMine by remember { mutableStateOf(false) } + // OwUs on the table we are not at the place of, so the table can say so + // in red. It is never a bar - the one who owes it decides. + var outOfPlace by remember { mutableStateOf(emptySet()) } + + val ready = ss.phase == PeerSession.Phase.READY && !connecting + // Verified, connected and nothing in the way: the state the tick stands for. + val settled = ready && !linkError + // Everything I could put down, minted ious for this table included: the + // picker shows what is already down as chosen rather than hiding it. + val mineHeld = remember(ious) { + ious.values.filter { + Verifier.verify(it).stateOrNull?.let { s -> s.holder == Repo.me && s.status == Status.ACTIVE } == true + } + } + // Putting ious back on the table with the person who owes them *is* + // redeeming: they go home and they close them. + val redeeming = ss.table.mine.isNotEmpty() && + ss.table.mine.all { Verifier.verify(it).stateOrNull?.debtor == peer?.key } + + // A redeem begun from the OwU itself: put it down as soon as this table + // can take it, so the holder does not have to find it again in the picker. + LaunchedEffect(ready, peer?.key) { + val key = peer?.key + if (ready && key != null) { + TradeIntent.takeOffer(key)?.let { offer -> + Repo.store.ious.value[offer.iouId]?.let { session.put(held = listOf(it)) } + } + } + } + + val tableIds = (ss.table.mine + ss.table.theirs).joinToString(",") { it.id } + LaunchedEffect(tableIds) { + outOfPlace = (ss.table.mine + ss.table.theirs) + .filter { Gates.outOfPlace(context, it) } + .map { it.id } + .toSet() + } + val locationPermission = rememberLauncherForActivityResult(ActivityResultContracts.RequestPermission()) { granted -> + if (!granted) context.toast(context.getString(R.string.geo_permission_denied)) + } + + // --- dialogs ----------------------------------------------------------- + + addName?.let { name -> + AlertDialog( + onDismissRequest = { addName = null }, + title = { Text(stringResource(R.string.contact_name_this)) }, + text = { + Column { + OutlinedTextField( + value = name, onValueChange = { addName = it }, + label = { Text(stringResource(R.string.name)) }, singleLine = true + ) + Text( + stringResource(R.string.contact_name_hint), + style = MaterialTheme.typography.caption, + color = MaterialTheme.colors.onSurface.copy(alpha = 0.6f), + modifier = Modifier.padding(top = 8.dp), + ) + } + }, + confirmButton = { + TextButton(enabled = name.isNotBlank(), onClick = { + Repo.store.putContact(Contact(peer!!.key, name.trim())) + addName = null + }) { Text(stringResource(R.string.ok)) } + }, + dismissButton = { TextButton(onClick = { addName = null }) { Text(stringResource(R.string.cancel)) } }, + ) + } + if (pickMine) TablePicker( + templates = templates.values.sortedByDescending { it.createdAt }, + held = mineHeld, + onTable = ss.table.mine, + onDismiss = { pickMine = false }, + onWrite = { + pickMine = false + TradeIntent.pending = TradeIntent.Pending(peer!!.key) + nav.navigate("issue") + }, + onPut = { ious, mint -> + pickMine = false + session.put(held = ious, mint = mint) + // Judging a place gate needs the permission; ask while there is + // still time, not at the moment of saying yes. + val placed = ious.any { it.metadata.geoloc != null } || mint.any { it.geoloc != null } + if (placed && !Locator.hasPermission(context)) locationPermission.launch(Locator.PERMISSION) + }, + ) + + // --- screen ------------------------------------------------------------ + + Scaffold( + topBar = { + TopAppBar( + // The tick belongs beside whoever they are, which is the name + // when you have one and the key when you do not - and that is + // the title either way. + title = { + Row(verticalAlignment = Alignment.CenterVertically) { + Text(who.ifBlank { stringResource(R.string.peer_unknown) }) + if (settled) { + Icon( + Icons.Default.Check, + contentDescription = stringResource(R.string.peer_verified), + tint = LocalContentColor.current, + modifier = Modifier.padding(start = 8.dp).size(20.dp), + ) + } + } + }, + navigationIcon = { + IconButton(onClick = { nav.up() }) { + Icon(Icons.AutoMirrored.Filled.ArrowBack, contentDescription = null) + } + } + ) + } + ) { innerPadding -> + Column( + modifier = Modifier + .padding(innerPadding) + .fillMaxSize() + .background(MaterialTheme.colors.background) + .verticalScroll(rememberScrollState()) + .padding(16.dp) + ) { + // The key under the name, when the name is not the key already. + peerFingerprint(peer, who)?.let { + Text( + it, style = MaterialTheme.typography.caption, + fontFamily = FontFamily.Monospace, color = MaterialTheme.colors.onSurface.copy(alpha = 0.6f) + ) + } + impersonating(peer)?.let { + Text( + it, style = MaterialTheme.typography.body2, color = MaterialTheme.colors.error, + modifier = Modifier.padding(top = 4.dp) + ) + } + // Only for somebody you have not named yet: this is the one place + // a peer met over the air can become a contact. Renaming one you + // already have belongs on the identity screen, where they live. + if (peer != null && !known) { + OutlinedButton( + onClick = { addName = peer.name }, + modifier = Modifier.padding(top = 8.dp), + ) { + Text(stringResource(R.string.contact_name_this)) + } + } + // Only while something is still in the way; once it is settled the + // tick above says so and this row goes. + if (!settled) { + Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier.padding(top = 4.dp)) { + if (connecting || ss.phase == PeerSession.Phase.HANDSHAKE) { + CircularProgressIndicator(modifier = Modifier.size(16.dp), strokeWidth = 2.dp) + Spacer(Modifier.size(8.dp)) + } + Text( + when { + linkError -> stringResource(R.string.peer_no_link) + connecting -> stringResource(R.string.peer_connecting) + ss.phase == PeerSession.Phase.GONE -> stringResource(R.string.peer_gone) + else -> stringResource(R.string.peer_verifying) + }, + style = MaterialTheme.typography.body2, + color = if (linkError || ss.phase == PeerSession.Phase.GONE) MaterialTheme.colors.error + else MaterialTheme.colors.primary, + ) + } + } + + Card(modifier = Modifier.fillMaxWidth().padding(top = 16.dp), elevation = 2.dp) { + TradeTable( + table = ss.table, + theirName = who, + theirKey = peer?.key, + enabled = ready, + redeeming = redeeming, + outOfPlace = outOfPlace, + onPut = { pickMine = true }, + onAccept = { session.accept() }, + modifier = Modifier.padding(12.dp), + ) + } + + if (ss.waiting != null) { + Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier.padding(top = 8.dp)) { + Text( + stringResource(R.string.peer_waiting, ss.waiting ?: ""), style = MaterialTheme.typography.body2, + color = MaterialTheme.colors.onSurface.copy(alpha = 0.6f), modifier = Modifier.weight(1f) + ) + TextButton(onClick = { session.stopWaiting() }) { Text(stringResource(R.string.peer_stop_waiting)) } + } + } + + if (ss.log.isNotEmpty()) { + Divider(modifier = Modifier.padding(vertical = 12.dp)) + ss.log.takeLast(8).forEach { + Text( + it, + style = MaterialTheme.typography.caption, + color = MaterialTheme.colors.onSurface.copy(alpha = 0.7f) + ) + } + } + } + } +} diff --git a/app/src/main/java/net/helcel/owu/activity/PendingAsk.kt b/app/src/main/java/net/helcel/owu/activity/PendingAsk.kt new file mode 100644 index 0000000..dd941a8 --- /dev/null +++ b/app/src/main/java/net/helcel/owu/activity/PendingAsk.kt @@ -0,0 +1,90 @@ +package net.helcel.owu.activity + +import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.ui.platform.LocalContext +import kotlinx.coroutines.delay +import kotlinx.coroutines.flow.first +import kotlinx.coroutines.withTimeoutOrNull +import net.helcel.owu.R +import net.helcel.owu.ble.Ble +import net.helcel.owu.helper.toast +import net.helcel.owu.ledger.Status +import net.helcel.owu.ledger.Verifier +import net.helcel.owu.peer.PeerManager +import net.helcel.owu.peer.PeerMessage +import net.helcel.owu.peer.PeerSession +import net.helcel.owu.store.Repo + +/** + * Every ask to redeem, from the tap onward. The button writes down who is + * asked for what; finding them, connecting, the handshake and the sending all + * happen here at the app root, whatever screen the user went on to. The other + * phone need not have been found, or even be switched on. + * + * The ask keeps until it is *on their table*, not until sent: two phones can + * disagree about having been introduced, and putting that right costs the + * table it carried. + */ +@Composable +fun PendingAsk() { + val context = LocalContext.current + val waiting = TradeIntent.offer + + // A "no" ends it, or the loop below re-asks every few seconds and the two + // phones refuse each other for as long as they share a room. + LaunchedEffect(Unit) { + PeerManager.outcomes.collect { outcome -> + if (outcome.declined == PeerMessage.Asked.TABLE && outcome.peer == TradeIntent.offer?.peerKey) { + TradeIntent.offer = null + } + } + } + + // Keyed on *what* is asked, not the session: a peer already in the list + // never changes that object, so an effect keyed on it never runs. + LaunchedEffect(waiting?.peerKey, waiting?.iouId) { + val offer = waiting ?: return@LaunchedEffect + val hex = Ble.beaconHex(offer.peerKey) + var told = false + while (true) { + if (TradeIntent.offer != offer) return@LaunchedEffect + // Redeemed, given away or deleted: not ours to ask about any more. + val iou = Repo.store.ious.value[offer.iouId] + val state = iou?.let { Verifier.verify(it).stateOrNull } + if (state == null || state.holder != Repo.me || state.status != Status.ACTIVE) { + TradeIntent.offer = null + return@LaunchedEffect + } + val session = PeerManager.state.value.peers[hex] + if (session != null && !onTheTable(session, offer.iouId)) { + val ready = withTimeoutOrNull(ASK_WAIT_MS) { + PeerManager.select(session.beacon) && + session.state.first { it.phase == PeerSession.Phase.READY }.let { true } + } == true + if (ready) { + session.offer(listOf(iou)) + // Once per ask: the loop may send twice, the user asked once. + if (!told) { + context.toast(context.getString(R.string.redeem_asked, Repo.nameOf(offer.peerKey))) + told = true + } + } + } + delay(RETRY_MS) + } + } +} + +/** Down on our side of their table, and accepted: the ask is with them. */ +private fun onTheTable(session: PeerSession, iouId: String): Boolean { + val table = session.state.value.table + return table.mine.size == 1 && table.mine[0].id == iouId && table.accepted +} + +/** Long enough for two phones to say hello over a fresh connection. */ +private const val ASK_WAIT_MS = 12_000L + +/** How often to look again. Short: usually the peer is right there and simply + * had not been heard from when the button was pressed. */ +private const val RETRY_MS = 3_000L diff --git a/app/src/main/java/net/helcel/owu/activity/RedeemPrompt.kt b/app/src/main/java/net/helcel/owu/activity/RedeemPrompt.kt new file mode 100644 index 0000000..7120170 --- /dev/null +++ b/app/src/main/java/net/helcel/owu/activity/RedeemPrompt.kt @@ -0,0 +1,85 @@ +package net.helcel.owu.activity + +import androidx.compose.foundation.layout.Column +import androidx.compose.material.AlertDialog +import androidx.compose.material.MaterialTheme +import androidx.compose.material.Text +import androidx.compose.material.TextButton +import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.collectAsState +import androidx.compose.runtime.getValue +import androidx.compose.runtime.key +import androidx.compose.runtime.mutableStateListOf +import androidx.compose.runtime.remember +import androidx.compose.ui.res.stringResource +import net.helcel.owu.R +import net.helcel.owu.ledger.Iou +import net.helcel.owu.ledger.Verifier +import net.helcel.owu.peer.PeerManager +import net.helcel.owu.peer.PeerMessage +import net.helcel.owu.peer.PeerSession +import net.helcel.owu.store.Repo + +/** + * Somebody is asking to redeem a promise of yours. It is the table like + * anything else, but with nothing to choose: they have put it down and said + * yes, so the only question is whether to accept. Asked here, wherever the + * debtor is, rather than on a trade screen holding one thing. + */ +@Composable +fun RedeemPrompt() { + val st by PeerManager.state.collectAsState() + // Asks turned down stay down until the table changes. + val refused = remember { mutableStateListOf() } + + var asking: Pair>? = null + val live = mutableListOf() + st.peers.forEach { (hex, session) -> + key(hex) { + val ss by session.state.collectAsState() + val theirs = ss.table.theirs + // Theirs alone, all of them mine, their yes given: a redemption. + val isAsk = theirs.isNotEmpty() && ss.table.mine.isEmpty() && + ss.table.theyAccepted && !ss.table.accepted && !ss.table.conflict && + theirs.all { Verifier.verify(it).stateOrNull?.debtor == Repo.me } + if (isAsk) { + live += ticket(hex, theirs) + if (ticket(hex, theirs) !in refused && asking == null) asking = session to theirs + } + } + } + // A refusal lasts as long as the ask it refused. Held for good, "Not now" + // would swallow every later attempt at the same promise. + LaunchedEffect(live.joinToString("|")) { refused.retainAll(live) } + + asking?.let { (session, ious) -> + // The key checks the ious, so an ask stands with or without a name. + val who = session.state.value.peer?.let { Repo.nameOf(it.key) } ?: stringResource(R.string.peer_unknown) + AlertDialog( + onDismissRequest = { refused += ticket(net.helcel.owu.ble.Ble.hex(session.beacon), ious) }, + title = { Text(stringResource(R.string.redeem_ask, who)) }, + text = { + Column { + Text(bundleLine(ious), style = MaterialTheme.typography.h6) + ious.firstOrNull()?.let { MetaGates(it.metadata, homecoming = true) } + } + }, + confirmButton = { + TextButton(onClick = { session.accept() }) { Text(stringResource(R.string.action_accept)) } + }, + dismissButton = { + TextButton(onClick = { + refused += ticket(net.helcel.owu.ble.Ble.hex(session.beacon), ious) + // Say so: their side clears the ask with ours, so they get + // the Redeem button back instead of waiting on you. + session.decline(PeerMessage.Asked.TABLE) + }) { Text(stringResource(R.string.redeem_later)) } + }, + ) + } +} + +/** What was refused: this peer asking for exactly these ious. */ +private fun ticket(hex: String, ious: List): String = + hex + ious.map { it.id }.sorted().joinToString(",") diff --git a/app/src/main/java/net/helcel/owu/activity/SettingsScreen.kt b/app/src/main/java/net/helcel/owu/activity/SettingsScreen.kt new file mode 100644 index 0000000..b99701e --- /dev/null +++ b/app/src/main/java/net/helcel/owu/activity/SettingsScreen.kt @@ -0,0 +1,232 @@ +package net.helcel.owu.activity + +import androidx.compose.foundation.background +import androidx.compose.foundation.border +import androidx.compose.foundation.clickable +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.rememberScrollState +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.foundation.verticalScroll +import androidx.compose.material.Button +import androidx.compose.material.Icon +import androidx.compose.material.IconButton +import androidx.compose.material.MaterialTheme +import androidx.compose.material.Scaffold +import androidx.compose.material.Text +import androidx.compose.material.TopAppBar +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.automirrored.filled.ArrowBack +import androidx.compose.material.icons.automirrored.filled.KeyboardArrowRight +import androidx.compose.runtime.Composable +import androidx.compose.runtime.collectAsState +import androidx.compose.runtime.getValue +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.dp +import androidx.navigation.NavHostController +import androidx.navigation.compose.NavHost +import androidx.navigation.compose.composable +import androidx.navigation.compose.rememberNavController +import net.helcel.owu.R +import net.helcel.owu.activity.sub.AboutScreen +import net.helcel.owu.ledger.Verifier +import net.helcel.owu.store.Repo + + +@Preview +@Composable +fun SettingsMainScreen( + onExit: () -> Unit = {}, + onRedeemed: () -> Unit = {}, + onOwed: () -> Unit = {}, + onTemplates: () -> Unit = {}, +) { + val nav: NavHostController = rememberNavController() + SysTheme { + Scaffold( + topBar = { + TopAppBar( + title = { Text(stringResource(R.string.action_settings)) }, + navigationIcon = { + IconButton(onClick = { + if (!nav.popBackStack()) + onExit() + }) { + Icon( + Icons.AutoMirrored.Filled.ArrowBack, + contentDescription = null + ) + } + } + ) + } + ) { innerPadding -> + // One host, inside the scaffold. Building it here and again as a + // default argument left two of them: settings drawn twice, and + // only the inner one ever navigating. + Box(modifier = Modifier.padding(innerPadding)) { + NavHost(nav, startDestination = "settings") { + composable("settings") { SettingsScreen(nav, onRedeemed, onOwed, onTemplates) } + composable("about") { AboutScreen() } + } + } + } + } +} + +/** + * Four kinds of thing in one screen - lists to open, a switch, a choice, and + * two actions - so each kind gets one shape and keeps it: rows that open + * something look like rows, and only the backup buttons look like buttons. + */ +@Composable +fun SettingsScreen( + navController: NavHostController, + onRedeemed: () -> Unit = {}, + onOwed: () -> Unit = {}, + onTemplates: () -> Unit = {}, +) { + val context = LocalContext.current + // What each list holds, counted the same way the list itself filters. + val ious by Repo.store.ious.collectAsState() + val templates by Repo.store.templates.collectAsState() + val (owed, spent) = remember(ious) { + val states = ious.values.mapNotNull { Verifier.verify(it).stateOrNull } + states.count(::owedByMe) to states.count(::isSpent) + } + + Column( + modifier = Modifier + .fillMaxSize() + .background(MaterialTheme.colors.background) + .verticalScroll(rememberScrollState()) + .padding(horizontal = 16.dp) + .padding(bottom = 24.dp) + ) { + // OwUs you cannot act on from the home screen - what you keep ready, + // what you owe, and what is spent - are worth looking up. + Section(stringResource(R.string.pref_category_notes)) { + NavRow(stringResource(R.string.section_templates), templates.size, onTemplates) + NavRow(stringResource(R.string.owed_title), owed, onOwed) + NavRow(stringResource(R.string.redeemed_title), spent, onRedeemed) + } + + Section(stringResource(R.string.key_theme)) { + Segmented( + listOf( + stringResource(R.string.system), + stringResource(R.string.light), + stringResource(R.string.dark), + ), + ThemeChoice.current(context), + ) { picked -> ThemeChoice.set(context, picked) } + } + + Section(stringResource(R.string.pref_category_data)) { + BackupSection() + } + + Spacer(Modifier.height(16.dp)) + PreferenceButton(stringResource(R.string.about)) { + if (navController.currentDestination?.route != "about") + navController.navigate("about") + } + } +} + +/** A heading in the app's own section style, and whatever belongs under it. */ +@Composable +private fun Section(title: String, content: @Composable () -> Unit) { + SectionHeader(title) + content() +} + +/** A row that opens a list: what it is, how much is in it, and a chevron. */ +@Composable +private fun NavRow(title: String, count: Int, onClick: () -> Unit) { + Row( + verticalAlignment = Alignment.CenterVertically, + modifier = Modifier + .fillMaxWidth() + .clickable(onClick = onClick) + .padding(vertical = 14.dp), + ) { + Text( + title, + style = MaterialTheme.typography.body1, + color = MaterialTheme.colors.onBackground, + modifier = Modifier.weight(1f), + ) + // An empty list says so when you open it; no need for a nought here. + if (count > 0) { + Text( + count.toString(), + style = MaterialTheme.typography.body2, + color = MaterialTheme.colors.onSurface.copy(alpha = 0.6f), + ) + } + Icon( + Icons.AutoMirrored.Filled.KeyboardArrowRight, + contentDescription = null, + tint = MaterialTheme.colors.onSurface.copy(alpha = 0.4f), + modifier = Modifier.padding(start = 8.dp).size(20.dp), + ) + } +} + +/** One of a few, side by side: shorter than a stack of radio buttons. */ +@Composable +private fun Segmented(options: List, selected: String, onSelect: (String) -> Unit) { + val shape = RoundedCornerShape(8.dp) + Row( + modifier = Modifier + .fillMaxWidth() + .padding(vertical = 4.dp) + .clip(shape) + .border(1.dp, MaterialTheme.colors.primary.copy(alpha = 0.4f), shape) + ) { + options.forEach { option -> + val on = option == selected + Box( + contentAlignment = Alignment.Center, + modifier = Modifier + .weight(1f) + .height(44.dp) + .background(if (on) MaterialTheme.colors.primary else Color.Transparent) + .clickable { onSelect(option) }, + ) { + Text( + option, + style = MaterialTheme.typography.button, + color = if (on) MaterialTheme.colors.onPrimary else MaterialTheme.colors.onBackground, + ) + } + } + } +} + +/** The one thing here that is not a setting, and so is not a row. */ +@Composable +fun PreferenceButton(text: String, onClick: () -> Unit) { + Button( + onClick = onClick, + modifier = Modifier + .fillMaxWidth() + .padding(vertical = 8.dp), + ) { Text(text) } +} diff --git a/app/src/main/java/net/helcel/owu/activity/TemplatesScreen.kt b/app/src/main/java/net/helcel/owu/activity/TemplatesScreen.kt new file mode 100644 index 0000000..a8b7eab --- /dev/null +++ b/app/src/main/java/net/helcel/owu/activity/TemplatesScreen.kt @@ -0,0 +1,81 @@ +package net.helcel.owu.activity + +import androidx.compose.foundation.background +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.lazy.LazyColumn +import androidx.compose.material.FloatingActionButton +import androidx.compose.material.Icon +import androidx.compose.material.IconButton +import androidx.compose.material.MaterialTheme +import androidx.compose.material.Scaffold +import androidx.compose.material.Text +import androidx.compose.material.TopAppBar +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.automirrored.filled.ArrowBack +import androidx.compose.material.icons.filled.Add +import androidx.compose.runtime.Composable +import androidx.compose.runtime.collectAsState +import androidx.compose.runtime.getValue +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.unit.dp +import androidx.navigation.NavHostController +import net.helcel.owu.R +import net.helcel.owu.store.Repo + +/** + * The promises you keep ready to make. Nothing here is owed to anybody: each + * is a form waiting to be signed, and putting one on a table mints an OwU + * from it. + */ +@Composable +fun TemplatesScreen(nav: NavHostController) { + val templates by Repo.store.templates.collectAsState() + val rows = templates.values.sortedByDescending { it.createdAt } + + Scaffold( + topBar = { + TopAppBar( + title = { Text(stringResource(R.string.section_templates)) }, + navigationIcon = { + IconButton(onClick = { nav.up() }) { + Icon(Icons.AutoMirrored.Filled.ArrowBack, contentDescription = null) + } + } + ) + }, + floatingActionButton = { + FloatingActionButton(onClick = { nav.navigate("template") }) { + Icon(Icons.Default.Add, contentDescription = stringResource(R.string.template_new)) + } + } + ) { innerPadding -> + Box( + modifier = Modifier + .padding(innerPadding) + .fillMaxSize() + .background(MaterialTheme.colors.background) + ) { + if (rows.isEmpty()) { + Text( + stringResource(R.string.templates_empty), + style = MaterialTheme.typography.body1, + color = MaterialTheme.colors.onSurface.copy(alpha = 0.6f), + modifier = Modifier.align(Alignment.Center).padding(32.dp), + ) + } + LazyColumn(modifier = Modifier.fillMaxSize().padding(horizontal = 16.dp)) { + items(rows.size) { i -> + val template = rows[i] + TemplateRow(template) { nav.navigate("template/${template.id}") } + } + item { Spacer(Modifier.size(80.dp)) } // room under the FAB + } + } + } +} diff --git a/app/src/main/java/net/helcel/owu/activity/Theme.kt b/app/src/main/java/net/helcel/owu/activity/Theme.kt new file mode 100644 index 0000000..d42d060 --- /dev/null +++ b/app/src/main/java/net/helcel/owu/activity/Theme.kt @@ -0,0 +1,140 @@ +package net.helcel.owu.activity + +import android.app.WallpaperManager +import android.content.Context +import android.os.Build +import android.graphics.Color as AndroidColor +import androidx.compose.foundation.isSystemInDarkTheme +import androidx.compose.material.Colors +import androidx.compose.material.MaterialTheme +import androidx.compose.material3.ColorScheme +import androidx.compose.material3.darkColorScheme +import androidx.compose.material3.dynamicDarkColorScheme +import androidx.compose.material3.dynamicLightColorScheme +import androidx.compose.material3.lightColorScheme +import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.setValue +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.toArgb +import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.res.stringResource +import androidx.core.content.edit +import net.helcel.owu.R +import net.helcel.owu.helper.defaultPreferences + +/** + * Which theme the user picked. It is state as well as a preference, because + * picking one has to repaint the screen it was picked on, and a preference + * read during composition never comes back to say it has changed. + */ +object ThemeChoice { + private var chosen by mutableStateOf(null) + + fun current(context: Context): String = chosen ?: stored(context) + + fun set(context: Context, value: String) { + defaultPreferences(context).edit { putString(context.getString(R.string.key_theme), value) } + chosen = value + } + + private fun stored(context: Context): String = defaultPreferences(context).getString( + context.getString(R.string.key_theme), + context.getString(R.string.system), + )!! +} + +/** + * The wallpaper's accent, where the platform will not give us a palette. + * `getWallpaperColors` has been there since API 27 - below our own minimum - + * and asks no permission, while Material You only arrives at 31. Null if + * there is nothing to read. + */ +private fun wallpaperAccent(context: Context): Color? { + val argb = runCatching { + WallpaperManager.getInstance(context) + .getWallpaperColors(WallpaperManager.FLAG_SYSTEM)?.primaryColor?.toArgb() + }.getOrNull() ?: return null + return Color(argb) +} + +/** + * The baseline scheme with its primary family re-hued to [seed]. + * + * Not a tonal palette - that wants a library this app does without - so only + * the hue and some of the saturation are the wallpaper's. Brightness is forced + * into the band Material uses for the theme, which is what keeps text legible + * on it whatever the wallpaper happens to be. + */ +private fun ColorScheme.accented(seed: Color, dark: Boolean): ColorScheme { + val hsv = FloatArray(3) + AndroidColor.colorToHSV(seed.toArgb(), hsv) + fun of(saturation: Float, value: Float) = + Color(AndroidColor.HSVToColor(floatArrayOf(hsv[0], saturation.coerceIn(0f, 1f), value))) + + val s = hsv[1] + return if (dark) copy( + primary = of(s.coerceIn(0.10f, 0.55f), 0.92f), + onPrimary = Color.Black, + primaryContainer = of(s.coerceIn(0.15f, 0.70f), 0.35f), + onPrimaryContainer = of(s * 0.3f, 0.95f), + secondary = of(s * 0.4f, 0.85f), + ) else copy( + primary = of(s.coerceIn(0.25f, 0.90f), 0.55f), + onPrimary = Color.White, + primaryContainer = of(s * 0.25f, 0.96f), + onPrimaryContainer = of(s.coerceIn(0.25f, 0.90f), 0.25f), + secondary = of(s * 0.4f, 0.50f), + ) +} + +@Composable +fun SysTheme( + content: @Composable () -> Unit +) { + val context = LocalContext.current + val themeKey = ThemeChoice.current(context) + val darkTheme = when (themeKey) { + stringResource(R.string.system) -> isSystemInDarkTheme() + stringResource(R.string.light) -> false + stringResource(R.string.dark) -> true + else -> isSystemInDarkTheme() + } + val colorScheme = when { + // Material You: the platform hands us a whole palette from the wallpaper. + Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> + if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context) + // Below that there is no palette to ask for, but the wallpaper's own + // accent is still readable, so the app is at least the right colour. + else -> { + val baseline = if (darkTheme) darkColorScheme() else lightColorScheme() + wallpaperAccent(context)?.let { baseline.accented(it, darkTheme) } ?: baseline + } + } + val m2colors = Colors( + primary = colorScheme.primary, + primaryVariant = colorScheme.primaryContainer, + secondary = colorScheme.secondary, + background = colorScheme.background, + surface = colorScheme.surface, + onPrimary = colorScheme.onPrimary, + onSecondary = colorScheme.onSecondary, + onBackground = colorScheme.onBackground, + onSurface = colorScheme.onSurface, + secondaryVariant = colorScheme.secondary, + error = colorScheme.error, + onError = colorScheme.onError, + isLight = !darkTheme, + ) + + // Both, because the app mixes the two: most of it is Material 2, while the + // dividers are Material 3 and would otherwise fall back to the default + // light scheme. + androidx.compose.material3.MaterialTheme(colorScheme = colorScheme) { + MaterialTheme( + colors = m2colors, + content = content + ) + } +} diff --git a/app/src/main/java/net/helcel/owu/activity/TradeIntent.kt b/app/src/main/java/net/helcel/owu/activity/TradeIntent.kt new file mode 100644 index 0000000..b2f1369 --- /dev/null +++ b/app/src/main/java/net/helcel/owu/activity/TradeIntent.kt @@ -0,0 +1,26 @@ +package net.helcel.owu.activity + +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.setValue + +/** What a screen was opened for, on the way to somebody's table. Gone once claimed. */ +object TradeIntent { + /** The new promise being written belongs on this peer's table. */ + data class Pending(val peerKey: String) + + // Compose state, not plain fields: a plain var gives screens no reason to look again. + var pending: Pending? by mutableStateOf(null) + + fun take(): Pending? = pending.also { pending = null } + + /** An OwU to put down once the table with [peerKey] opens: how a redeem + * begun from the OwU finds its table without hunting in the picker. */ + data class Offer(val peerKey: String, val iouId: String) + + var offer: Offer? by mutableStateOf(null) + + /** Claims the waiting offer, if it is for this peer. */ + fun takeOffer(peerKey: String): Offer? = + offer?.takeIf { it.peerKey == peerKey }?.also { offer = null } +} diff --git a/app/src/main/java/net/helcel/owu/activity/TradePrompt.kt b/app/src/main/java/net/helcel/owu/activity/TradePrompt.kt new file mode 100644 index 0000000..32cc313 --- /dev/null +++ b/app/src/main/java/net/helcel/owu/activity/TradePrompt.kt @@ -0,0 +1,65 @@ +package net.helcel.owu.activity + +import androidx.compose.material.AlertDialog +import androidx.compose.material.Text +import androidx.compose.material.TextButton +import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.collectAsState +import androidx.compose.runtime.getValue +import androidx.compose.runtime.key +import androidx.compose.ui.res.stringResource +import androidx.navigation.NavHostController +import androidx.navigation.compose.currentBackStackEntryAsState +import net.helcel.owu.R +import net.helcel.owu.peer.PeerManager +import net.helcel.owu.peer.PeerMessage +import net.helcel.owu.peer.PeerSession +import net.helcel.owu.store.Repo + +/** + * Somebody has opened a table with you; without this they would have to be on + * the right screen at the right moment to find out. Same shape as + * [RedeemPrompt]. Only from people you have named: trading is contacts-only, + * and a dialog any passer-by could raise on your phone is a nuisance. + */ +@Composable +fun TradePrompt(nav: NavHostController) { + val st by PeerManager.state.collectAsState() + val contacts by Repo.store.contacts.collectAsState() + val route = nav.currentBackStackEntryAsState().value?.destination?.route + + var asking: Pair? = null + st.peers.forEach { (hex, session) -> + key(hex) { + val ss by session.state.collectAsState() + val known = ss.peer?.key?.let { k -> contacts.any { it.publicKey == k } } == true + // Already at their table: being there is the answer. + val attending = route == "peer/{beacon}" && + nav.currentBackStackEntry?.arguments?.getString("beacon") == hex + if (ss.invited && attending) LaunchedEffect(hex) { session.inviteAnswered() } + else if (ss.invited && known && asking == null) asking = hex to session + } + } + + asking?.let { (hex, session) -> + val who = session.state.value.peer?.let { Repo.nameOf(it.key) } ?: stringResource(R.string.peer_unknown) + AlertDialog( + // Dismissing is not a refusal to report; only "Not now" tells them. + onDismissRequest = { session.inviteAnswered() }, + title = { Text(stringResource(R.string.trade_ask, who)) }, + confirmButton = { + TextButton(onClick = { + session.inviteAnswered() + nav.navigate("peer/$hex") + }) { Text(stringResource(R.string.trade_accept)) } + }, + dismissButton = { + TextButton(onClick = { + session.inviteAnswered() + session.decline(PeerMessage.Asked.INVITE) + }) { Text(stringResource(R.string.redeem_later)) } + }, + ) + } +} diff --git a/app/src/main/java/net/helcel/owu/activity/Widgets.kt b/app/src/main/java/net/helcel/owu/activity/Widgets.kt new file mode 100644 index 0000000..033ff2e --- /dev/null +++ b/app/src/main/java/net/helcel/owu/activity/Widgets.kt @@ -0,0 +1,602 @@ +package net.helcel.owu.activity + +import android.app.DatePickerDialog +import android.app.TimePickerDialog +import android.text.format.DateFormat +import androidx.compose.foundation.Canvas +import androidx.compose.foundation.background +import androidx.compose.foundation.clickable +import androidx.compose.foundation.rememberScrollState +import androidx.compose.foundation.verticalScroll +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.layout.width +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.heightIn +import androidx.compose.foundation.layout.padding +import androidx.compose.material.Button +import androidx.compose.material.Divider +import androidx.compose.material.Icon +import androidx.compose.material.LocalContentColor +import androidx.compose.material.IconButton +import androidx.compose.material.MaterialTheme +import androidx.compose.material.OutlinedTextField +import androidx.compose.material.Text +import androidx.compose.material.TextButton +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.filled.Add +import androidx.compose.material.icons.filled.Check +import androidx.compose.material.icons.filled.CheckCircle +import androidx.compose.material.icons.filled.Remove +import androidx.compose.material.icons.filled.Clear +import androidx.compose.material.icons.filled.Place +import androidx.compose.material.icons.filled.Schedule +import androidx.compose.material.icons.automirrored.filled.Send +import androidx.compose.material.icons.outlined.ContentCopy +import androidx.compose.material.icons.outlined.Edit +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.ModalBottomSheet +import androidx.compose.material3.rememberModalBottomSheetState +import androidx.compose.runtime.Composable +import androidx.compose.runtime.CompositionLocalProvider +import androidx.compose.runtime.collectAsState +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateListOf +import androidx.compose.runtime.mutableStateMapOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.geometry.Offset +import androidx.compose.ui.geometry.Size +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.vector.ImageVector +import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.res.pluralStringResource +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.style.TextAlign +import androidx.compose.ui.unit.dp +import com.google.zxing.BarcodeFormat +import com.google.zxing.EncodeHintType +import com.google.zxing.qrcode.QRCodeWriter +import androidx.navigation.NavHostController +import net.helcel.owu.R +import net.helcel.owu.crypto.Keys +import net.helcel.owu.helper.IdentityCard +import net.helcel.owu.helper.formatTime +import net.helcel.owu.peer.PeerEngine +import net.helcel.owu.ledger.Iou +import net.helcel.owu.ledger.Metadata +import net.helcel.owu.ledger.Status +import net.helcel.owu.ledger.TimeGate +import net.helcel.owu.ledger.Verifier +import net.helcel.owu.store.Repo +import net.helcel.owu.store.Template +import java.time.Instant +import java.time.ZoneId +import java.time.ZonedDateTime + +// Pieces shared by more than one screen. + +@Composable +fun statusLabel(status: Status): String = when (status) { + Status.ACTIVE -> stringResource(R.string.status_active) + Status.REDEEMED -> stringResource(R.string.status_redeemed) +} + +@Composable +fun peerLabel(peer: IdentityCard?, known: Boolean): String = when { + peer == null -> "" + known -> Repo.nameOf(peer.key) + else -> peer.name.ifBlank { Keys.fingerprint(peer.key) } +} + +/** Set when a peer calls itself a name you know somebody else by. Names are + * self-asserted, keys are not: the one place a stranger can try to pass. */ +@Composable +fun impersonating(peer: IdentityCard?): String? { + if (peer == null || peer.name.isBlank()) return null + val contacts by Repo.store.contacts.collectAsState() + val clash = contacts.firstOrNull { it.name.equals(peer.name.trim(), ignoreCase = true) && it.publicKey != peer.key } + return clash?.let { stringResource(R.string.peer_name_clash, it.name) } +} + +/** A tick beside a name whose key we keep: that person's promise, not merely + * a valid signature by a stranger. A missing tick is the whole message. */ +@Composable +fun KnownMark(publicKey: String, modifier: Modifier = Modifier) { + if (!Repo.knows(publicKey)) return + Icon( + Icons.Default.Check, + contentDescription = stringResource(R.string.in_your_contacts), + tint = MaterialTheme.colors.primary, + modifier = modifier.padding(start = 4.dp).size(14.dp), + ) +} + +/** The key under a name, unless the name *is* the key already. */ +@Composable +fun peerFingerprint(peer: IdentityCard?, label: String): String? = + peer?.let { Keys.fingerprint(it.key) }?.takeIf { it != label } + +/** + * What to put on the table: nothing, promises minted from templates, or OwUs + * you hold - any number, in one bundle. + * + * A sheet, not a dialog: the list has no known length, and as a dialog it grew + * to fill the screen badly. Writing a new promise leads, being the one entry + * that is an action; templates follow, the common case being the same beer. + */ +@OptIn(ExperimentalMaterial3Api::class) +@Composable +fun TablePicker( + templates: List