Remove old anroid app
288
.github/workflows/android-build.yml
vendored
@ -30,165 +30,165 @@ jobs:
|
||||
- name: 'Checkout'
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: 'Download Android Web.bundle Artifact (built frontend)'
|
||||
if: inputs.semver == '' # Only if workflow fired from frontend-build.yml
|
||||
uses: dawidd6/action-download-artifact@v11
|
||||
with:
|
||||
workflow: frontend-build.yml
|
||||
workflow_conclusion: success
|
||||
name: mobile-web.bundle
|
||||
path: mobile/html/Web.bundle
|
||||
# - name: 'Download Android Web.bundle Artifact (built frontend)'
|
||||
# if: inputs.semver == '' # Only if workflow fired from frontend-build.yml
|
||||
# uses: dawidd6/action-download-artifact@v11
|
||||
# with:
|
||||
# workflow: frontend-build.yml
|
||||
# workflow_conclusion: success
|
||||
# name: mobile-web.bundle
|
||||
# path: mobile/html/Web.bundle
|
||||
|
||||
- name: 'Download main.js Artifact for a release'
|
||||
if: inputs.semver != '' # Only if fired as job in release.yml
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: mobile-web.bundle
|
||||
path: mobile/html/Web.bundle
|
||||
# - name: 'Download main.js Artifact for a release'
|
||||
# if: inputs.semver != '' # Only if fired as job in release.yml
|
||||
# uses: actions/download-artifact@v4
|
||||
# with:
|
||||
# name: mobile-web.bundle
|
||||
# path: mobile/html/Web.bundle
|
||||
|
||||
- name: 'Install npm Dependencies'
|
||||
run: |
|
||||
cd mobile
|
||||
npm install
|
||||
# - name: 'Install npm Dependencies'
|
||||
# run: |
|
||||
# cd mobile
|
||||
# npm install
|
||||
|
||||
- name: 'Patch modules' # react-native-tor and react-native-encrypted-storage rely on deprecated jcenter repositories. We patch the modules temporarily
|
||||
run: |
|
||||
cd mobile
|
||||
cp -r patch_modules/* node_modules/
|
||||
- uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: 11
|
||||
# - name: 'Patch modules' # react-native-tor and react-native-encrypted-storage rely on deprecated jcenter repositories. We patch the modules temporarily
|
||||
# run: |
|
||||
# cd mobile
|
||||
# cp -r patch_modules/* node_modules/
|
||||
# - uses: actions/setup-java@v4
|
||||
# with:
|
||||
# distribution: temurin
|
||||
# java-version: 11
|
||||
|
||||
- name: Setup Gradle
|
||||
uses: gradle/gradle-build-action@v3
|
||||
# - name: Setup Gradle
|
||||
# uses: gradle/gradle-build-action@v3
|
||||
|
||||
- name: Decode Keystore
|
||||
id: decode_keystore
|
||||
uses: timheuer/base64-to-file@v1.2
|
||||
with:
|
||||
fileName: 'keystore.jks'
|
||||
fileDir: './'
|
||||
encodedString: ${{ secrets.KEYSTORE }}
|
||||
# - name: Decode Keystore
|
||||
# id: decode_keystore
|
||||
# uses: timheuer/base64-to-file@v1.2
|
||||
# with:
|
||||
# fileName: 'keystore.jks'
|
||||
# fileDir: './'
|
||||
# encodedString: ${{ secrets.KEYSTORE }}
|
||||
|
||||
- name: 'Build Android Release'
|
||||
run: |
|
||||
cd mobile/android
|
||||
./gradlew assembleRelease
|
||||
env:
|
||||
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
|
||||
KEY_PASS: ${{ secrets.KEY_PASS }}
|
||||
KEY_STORE_PASS: ${{ secrets.KEY_STORE_PASS }}
|
||||
# - name: 'Build Android Release'
|
||||
# run: |
|
||||
# cd mobile/android
|
||||
# ./gradlew assembleRelease
|
||||
# env:
|
||||
# KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
|
||||
# KEY_PASS: ${{ secrets.KEY_PASS }}
|
||||
# KEY_STORE_PASS: ${{ secrets.KEY_STORE_PASS }}
|
||||
|
||||
|
||||
- name: 'Check for non-FOSS libraries'
|
||||
run: |
|
||||
wget https://github.com/iBotPeaches/Apktool/releases/download/v2.7.0/apktool_2.7.0.jar
|
||||
wget https://github.com/iBotPeaches/Apktool/raw/master/scripts/linux/apktool
|
||||
# clone the repo
|
||||
git clone https://gitlab.com/IzzyOnDroid/repo.git
|
||||
# create a directory for Apktool and move the apktool* files there
|
||||
mkdir -p repo/lib/radar/tool
|
||||
mv apktool* repo/lib/radar/tool
|
||||
# create an alias for ease of use
|
||||
chmod u+x repo/lib/radar/tool/apktool
|
||||
mv repo/lib/radar/tool/apktool_2.7.0.jar repo/lib/radar/tool/apktool.jar
|
||||
repo/bin/scanapk.php mobile/android/app/build/outputs/apk/release/app-universal-release.apk
|
||||
# - name: 'Check for non-FOSS libraries'
|
||||
# run: |
|
||||
# wget https://github.com/iBotPeaches/Apktool/releases/download/v2.7.0/apktool_2.7.0.jar
|
||||
# wget https://github.com/iBotPeaches/Apktool/raw/master/scripts/linux/apktool
|
||||
# # clone the repo
|
||||
# git clone https://gitlab.com/IzzyOnDroid/repo.git
|
||||
# # create a directory for Apktool and move the apktool* files there
|
||||
# mkdir -p repo/lib/radar/tool
|
||||
# mv apktool* repo/lib/radar/tool
|
||||
# # create an alias for ease of use
|
||||
# chmod u+x repo/lib/radar/tool/apktool
|
||||
# mv repo/lib/radar/tool/apktool_2.7.0.jar repo/lib/radar/tool/apktool.jar
|
||||
# repo/bin/scanapk.php mobile/android/app/build/outputs/apk/release/app-universal-release.apk
|
||||
|
||||
- name: 'Get Commit Hash'
|
||||
id: commit
|
||||
uses: pr-mpt/actions-commit-hash@v3
|
||||
# - name: 'Get Commit Hash'
|
||||
# id: commit
|
||||
# uses: pr-mpt/actions-commit-hash@v3
|
||||
|
||||
# Create artifacts (only for Release)
|
||||
# Create app-universal-release APK artifact asset for Release
|
||||
- name: 'Upload universal .apk Release Artifact (for Release)'
|
||||
uses: actions/upload-artifact@v4
|
||||
if: inputs.semver != '' # If this workflow is called from release.yml
|
||||
with:
|
||||
name: robosats-${{ inputs.semver }}-universal.apk
|
||||
path: mobile/android/app/build/outputs/apk/release/app-universal-release.apk
|
||||
# # Create artifacts (only for Release)
|
||||
# # Create app-universal-release APK artifact asset for Release
|
||||
# - name: 'Upload universal .apk Release Artifact (for Release)'
|
||||
# uses: actions/upload-artifact@v4
|
||||
# if: inputs.semver != '' # If this workflow is called from release.yml
|
||||
# with:
|
||||
# name: robosats-${{ inputs.semver }}-universal.apk
|
||||
# path: mobile/android/app/build/outputs/apk/release/app-universal-release.apk
|
||||
|
||||
# Create app-arm64-v8a-release APK artifact asset for Release
|
||||
- name: 'Upload arm64-v8a .apk Release Artifact (for Release)'
|
||||
uses: actions/upload-artifact@v4
|
||||
if: inputs.semver != '' # If this workflow is called from release.yml
|
||||
with:
|
||||
name: robosats-${{ inputs.semver }}-arm64-v8a.apk
|
||||
path: mobile/android/app/build/outputs/apk/release/app-arm64-v8a-release.apk
|
||||
# # Create app-arm64-v8a-release APK artifact asset for Release
|
||||
# - name: 'Upload arm64-v8a .apk Release Artifact (for Release)'
|
||||
# uses: actions/upload-artifact@v4
|
||||
# if: inputs.semver != '' # If this workflow is called from release.yml
|
||||
# with:
|
||||
# name: robosats-${{ inputs.semver }}-arm64-v8a.apk
|
||||
# path: mobile/android/app/build/outputs/apk/release/app-arm64-v8a-release.apk
|
||||
|
||||
# Create app-armeabi-v7a-release APK artifact asset for Release
|
||||
- name: 'Upload armeabi-v7a .apk Release Artifact (for Release)'
|
||||
uses: actions/upload-artifact@v4
|
||||
if: inputs.semver != '' # If this workflow is called from release.yml
|
||||
with:
|
||||
name: robosats-${{ inputs.semver }}-armeabi-v7a.apk
|
||||
path: mobile/android/app/build/outputs/apk/release/app-armeabi-v7a-release.apk
|
||||
# # Create app-armeabi-v7a-release APK artifact asset for Release
|
||||
# - name: 'Upload armeabi-v7a .apk Release Artifact (for Release)'
|
||||
# uses: actions/upload-artifact@v4
|
||||
# if: inputs.semver != '' # If this workflow is called from release.yml
|
||||
# with:
|
||||
# name: robosats-${{ inputs.semver }}-armeabi-v7a.apk
|
||||
# path: mobile/android/app/build/outputs/apk/release/app-armeabi-v7a-release.apk
|
||||
|
||||
# Create app-x86_64-release APK artifact asset for Release
|
||||
- name: 'Upload x86_64 .apk Release Artifact (for Release)'
|
||||
uses: actions/upload-artifact@v4
|
||||
if: inputs.semver != '' # If this workflow is called from release.yml
|
||||
with:
|
||||
name: robosats-${{ inputs.semver }}-x86_64.apk
|
||||
path: mobile/android/app/build/outputs/apk/release/app-x86_64-release.apk
|
||||
# # Create app-x86_64-release APK artifact asset for Release
|
||||
# - name: 'Upload x86_64 .apk Release Artifact (for Release)'
|
||||
# uses: actions/upload-artifact@v4
|
||||
# if: inputs.semver != '' # If this workflow is called from release.yml
|
||||
# with:
|
||||
# name: robosats-${{ inputs.semver }}-x86_64.apk
|
||||
# path: mobile/android/app/build/outputs/apk/release/app-x86_64-release.apk
|
||||
|
||||
- name: 'Create Pre-release'
|
||||
id: create_release
|
||||
if: inputs.semver == '' # only if this workflow is not called from a push to tag (a Release)
|
||||
uses: ncipollo/release-action@v1.18.0
|
||||
with:
|
||||
tag: android-${{ steps.commit.outputs.short }}
|
||||
name: robosats-android-${{ steps.commit.outputs.short }}
|
||||
prerelease: true
|
||||
# - name: 'Create Pre-release'
|
||||
# id: create_release
|
||||
# if: inputs.semver == '' # only if this workflow is not called from a push to tag (a Release)
|
||||
# uses: ncipollo/release-action@v1.18.0
|
||||
# with:
|
||||
# tag: android-${{ steps.commit.outputs.short }}
|
||||
# name: robosats-android-${{ steps.commit.outputs.short }}
|
||||
# prerelease: true
|
||||
|
||||
# Upload universal APK to pre-release
|
||||
- name: 'Upload universal Pre-release APK Asset'
|
||||
id: upload-release-universal-apk-asset
|
||||
if: inputs.semver == '' # only if this workflow is not called from a push to tag (a Release)
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: ./mobile/android/app/build/outputs/apk/release/app-universal-release.apk
|
||||
asset_name: robosats-${{ steps.commit.outputs.short }}-universal.apk
|
||||
asset_content_type: application/apk
|
||||
# # Upload universal APK to pre-release
|
||||
# - name: 'Upload universal Pre-release APK Asset'
|
||||
# id: upload-release-universal-apk-asset
|
||||
# if: inputs.semver == '' # only if this workflow is not called from a push to tag (a Release)
|
||||
# uses: actions/upload-release-asset@v1
|
||||
# env:
|
||||
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
# with:
|
||||
# upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
# asset_path: ./mobile/android/app/build/outputs/apk/release/app-universal-release.apk
|
||||
# asset_name: robosats-${{ steps.commit.outputs.short }}-universal.apk
|
||||
# asset_content_type: application/apk
|
||||
|
||||
# Upload arm64-v8a APK to pre-release
|
||||
- name: 'Upload arm64-v8a Pre-release APK Asset'
|
||||
id: upload-release-arm64-v8a-apk-asset
|
||||
if: inputs.semver == '' # only if this workflow is not called from a push to tag (a Release)
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: ./mobile/android/app/build/outputs/apk/release/app-arm64-v8a-release.apk
|
||||
asset_name: robosats-${{ steps.commit.outputs.short }}-arm64-v8a.apk
|
||||
asset_content_type: application/apk
|
||||
# # Upload arm64-v8a APK to pre-release
|
||||
# - name: 'Upload arm64-v8a Pre-release APK Asset'
|
||||
# id: upload-release-arm64-v8a-apk-asset
|
||||
# if: inputs.semver == '' # only if this workflow is not called from a push to tag (a Release)
|
||||
# uses: actions/upload-release-asset@v1
|
||||
# env:
|
||||
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
# with:
|
||||
# upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
# asset_path: ./mobile/android/app/build/outputs/apk/release/app-arm64-v8a-release.apk
|
||||
# asset_name: robosats-${{ steps.commit.outputs.short }}-arm64-v8a.apk
|
||||
# asset_content_type: application/apk
|
||||
|
||||
# Upload armeabi-v7a APK to pre-release
|
||||
- name: 'Upload armeabi-v7a Pre-release APK Asset'
|
||||
id: upload-release-armeabi-v7a-apk-asset
|
||||
if: inputs.semver == '' # only if this workflow is not called from a push to tag (a Release)
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: ./mobile/android/app/build/outputs/apk/release/app-armeabi-v7a-release.apk
|
||||
asset_name: robosats-${{ steps.commit.outputs.short }}-armeabi-v7a.apk
|
||||
asset_content_type: application/apk
|
||||
# # Upload armeabi-v7a APK to pre-release
|
||||
# - name: 'Upload armeabi-v7a Pre-release APK Asset'
|
||||
# id: upload-release-armeabi-v7a-apk-asset
|
||||
# if: inputs.semver == '' # only if this workflow is not called from a push to tag (a Release)
|
||||
# uses: actions/upload-release-asset@v1
|
||||
# env:
|
||||
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
# with:
|
||||
# upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
# asset_path: ./mobile/android/app/build/outputs/apk/release/app-armeabi-v7a-release.apk
|
||||
# asset_name: robosats-${{ steps.commit.outputs.short }}-armeabi-v7a.apk
|
||||
# asset_content_type: application/apk
|
||||
|
||||
# Upload x86_64 APK to pre-release
|
||||
- name: 'Upload x86_64 Pre-release APK Asset'
|
||||
id: upload-release-x86_64-apk-asset
|
||||
if: inputs.semver == '' # only if this workflow is not called from a push to tag (a Release)
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: ./mobile/android/app/build/outputs/apk/release/app-x86_64-release.apk
|
||||
asset_name: robosats-${{ steps.commit.outputs.short }}-x86_64.apk
|
||||
asset_content_type: application/apk
|
||||
# # Upload x86_64 APK to pre-release
|
||||
# - name: 'Upload x86_64 Pre-release APK Asset'
|
||||
# id: upload-release-x86_64-apk-asset
|
||||
# if: inputs.semver == '' # only if this workflow is not called from a push to tag (a Release)
|
||||
# uses: actions/upload-release-asset@v1
|
||||
# env:
|
||||
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
# with:
|
||||
# upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
# asset_path: ./mobile/android/app/build/outputs/apk/release/app-x86_64-release.apk
|
||||
# asset_name: robosats-${{ steps.commit.outputs.short }}-x86_64.apk
|
||||
# asset_content_type: application/apk
|
||||
|
||||
10
.github/workflows/frontend-build.yml
vendored
@ -73,11 +73,11 @@ jobs:
|
||||
path: |
|
||||
web/static
|
||||
web/*.html
|
||||
- name: 'Archive Mobile Build Results'
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: mobile-web.bundle
|
||||
path: mobile/html/Web.bundle
|
||||
# - name: 'Archive Mobile Build Results'
|
||||
# uses: actions/upload-artifact@v4
|
||||
# with:
|
||||
# name: mobile-web.bundle
|
||||
# path: mobile/html/Web.bundle
|
||||
|
||||
# Invoke pre-release image build if this was not a tag push
|
||||
# Docker images tagged only with short commit hash
|
||||
|
||||
1
.gitignore
vendored
@ -650,7 +650,6 @@ desktopApp/release-builds
|
||||
|
||||
# frontend statics
|
||||
frontend/templates/frontend/*.html
|
||||
mobile/html/Web.bundle
|
||||
frontend/*.html
|
||||
desktopApp/static
|
||||
desktopApp/*.html
|
||||
|
||||
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 3.6 KiB |
|
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 4.6 KiB |
|
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 4.7 KiB |
|
Before Width: | Height: | Size: 6.1 KiB After Width: | Height: | Size: 6.1 KiB |
0
mobile_new/gradlew → android/gradlew
vendored
15
frontend/package-lock.json
generated
@ -68,6 +68,7 @@
|
||||
"@types/jest": "^29.5.14",
|
||||
"@types/latlon-geohash": "^2.0.4",
|
||||
"@types/leaflet": "^1.9.18",
|
||||
"@types/node": "^24.0.14",
|
||||
"@types/react": "^19.1.6",
|
||||
"@types/react-dom": "^19.1.5",
|
||||
"@types/webpack": "^5.28.5",
|
||||
@ -4511,13 +4512,13 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "22.15.23",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.15.23.tgz",
|
||||
"integrity": "sha512-7Ec1zaFPF4RJ0eXu1YT/xgiebqwqoJz8rYPDi/O2BcZ++Wpt0Kq9cl0eg6NN6bYbPnR67ZLo7St5Q3UK0SnARw==",
|
||||
"version": "24.0.14",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-24.0.14.tgz",
|
||||
"integrity": "sha512-4zXMWD91vBLGRtHK3YbIoFMia+1nqEz72coM42C5ETjnNCa/heoj7NT1G67iAfOqMmcfhuCZ4uNpyz8EjlAejw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"undici-types": "~6.21.0"
|
||||
"undici-types": "~7.8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/parse-json": {
|
||||
@ -16240,9 +16241,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/undici-types": {
|
||||
"version": "6.21.0",
|
||||
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz",
|
||||
"integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==",
|
||||
"version": "7.8.0",
|
||||
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.8.0.tgz",
|
||||
"integrity": "sha512-9UJ2xGDvQ43tYyVMpuHlsgApydB8ZKfVYTsLDhXkFL/6gfkp+U8xTGdh8pMJv1SpZna0zxG1DwsKZsreLbXBxw==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
|
||||
@ -27,6 +27,7 @@
|
||||
"@types/jest": "^29.5.14",
|
||||
"@types/latlon-geohash": "^2.0.4",
|
||||
"@types/leaflet": "^1.9.18",
|
||||
"@types/node": "^24.0.14",
|
||||
"@types/react": "^19.1.6",
|
||||
"@types/react-dom": "^19.1.5",
|
||||
"@types/webpack": "^5.28.5",
|
||||
|
||||
@ -32,7 +32,7 @@ interface NotificationMessage {
|
||||
|
||||
const path =
|
||||
getSettings().client == 'mobile'
|
||||
? 'file:///android_asset/Web.bundle/assets/sounds'
|
||||
? 'file:///android_asset/static/assets/sounds'
|
||||
: '/static/assets/sounds';
|
||||
|
||||
const audio = {
|
||||
|
||||
@ -70,7 +70,7 @@ const RobotAvatar: React.FC<Props> = ({
|
||||
const coordinatorAvatar =
|
||||
client !== 'mobile'
|
||||
? `${hostUrl}/static/federation/avatars/${shortAlias}${small ? '.small' : ''}.webp`
|
||||
: `file:///android_asset/Web.bundle/assets/federation/avatars/${shortAlias}.webp`;
|
||||
: `file:///android_asset/static/assets/federation/avatars/${shortAlias}.webp`;
|
||||
setAvatarSrc(coordinatorAvatar);
|
||||
} else {
|
||||
setActiveBackground(true);
|
||||
|
||||
@ -21,7 +21,7 @@ import { Send } from '@mui/icons-material';
|
||||
|
||||
const audioPath =
|
||||
getSettings().client == 'mobile'
|
||||
? 'file:///android_asset/Web.bundle/assets/sounds'
|
||||
? 'file:///android_asset//static/assets/sounds'
|
||||
: '/static/assets/sounds';
|
||||
|
||||
interface Props {
|
||||
|
||||
@ -37,7 +37,7 @@ interface Props {
|
||||
|
||||
const audioPath =
|
||||
getSettings().client == 'mobile'
|
||||
? 'file:///android_asset/Web.bundle/assets/sounds'
|
||||
? 'file:///android_asset/static/assets/sounds'
|
||||
: '/static/assets/sounds';
|
||||
|
||||
const EncryptedTurtleChat: React.FC<Props> = ({
|
||||
|
||||
@ -17,6 +17,6 @@
|
||||
"typeRoots": ["./node_modules/@types"],
|
||||
"allowImportingTsExtensions": true
|
||||
},
|
||||
"include": ["src/**/*"],
|
||||
"include": ["src/**/*", "webpack.config.ts"],
|
||||
"exclude": ["node_modules", "**/*.spec.ts"]
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@ import { Configuration } from 'webpack';
|
||||
import CopyWebpackPlugin from 'copy-webpack-plugin';
|
||||
import HtmlWebpackPlugin from 'html-webpack-plugin';
|
||||
import { version } from './package.json';
|
||||
import { Buffer } from 'buffer';
|
||||
|
||||
// Declare __dirname for TypeScript
|
||||
declare const __dirname: string;
|
||||
@ -143,89 +144,6 @@ const configNode: Configuration = {
|
||||
],
|
||||
};
|
||||
|
||||
const configNative: Configuration = {
|
||||
...config,
|
||||
module: {
|
||||
...config.module,
|
||||
rules: [
|
||||
...(config?.module?.rules || []),
|
||||
{
|
||||
test: path.resolve(__dirname, 'src/i18n/Web.js'),
|
||||
loader: 'file-replace-loader',
|
||||
options: {
|
||||
condition: 'if-replacement-exists',
|
||||
replacement: path.resolve(__dirname, 'src/i18n/Mobile.js'),
|
||||
async: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
test: path.resolve(__dirname, 'src/geo/Web.js'),
|
||||
loader: 'file-replace-loader',
|
||||
options: {
|
||||
condition: 'if-replacement-exists',
|
||||
replacement: path.resolve(__dirname, 'src/geo/Mobile.js'),
|
||||
async: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
test: path.resolve(__dirname, 'src/services/Roboidentities/Web.ts'),
|
||||
loader: 'file-replace-loader',
|
||||
options: {
|
||||
condition: 'if-replacement-exists',
|
||||
replacement: path.resolve(__dirname, 'src/services/Roboidentities/Native.ts'),
|
||||
async: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
test: path.resolve(__dirname, 'src/components/RobotAvatar/placeholder.json'),
|
||||
loader: 'file-replace-loader',
|
||||
options: {
|
||||
condition: 'if-replacement-exists',
|
||||
replacement: path.resolve(
|
||||
__dirname,
|
||||
'src/components/RobotAvatar/placeholder_highres.json',
|
||||
),
|
||||
async: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
output: {
|
||||
path: path.resolve(__dirname, '../mobile/html/Web.bundle/static/frontend'),
|
||||
filename: `main.v${version}.[contenthash].js`,
|
||||
clean: true,
|
||||
publicPath: './static/frontend/',
|
||||
},
|
||||
plugins: [
|
||||
new HtmlWebpackPlugin({
|
||||
template: path.resolve(__dirname, 'templates/frontend/index.ejs'),
|
||||
templateParameters: {
|
||||
pro: false,
|
||||
},
|
||||
filename: path.resolve(__dirname, '../mobile/html/Web.bundle/index.html'),
|
||||
inject: 'body',
|
||||
robosatsSettings: 'mobile-basic',
|
||||
basePath: './',
|
||||
}),
|
||||
new CopyWebpackPlugin({
|
||||
patterns: [
|
||||
{
|
||||
from: path.resolve(__dirname, 'static/css'),
|
||||
to: path.resolve(__dirname, '../mobile/html/Web.bundle/static/css'),
|
||||
},
|
||||
{
|
||||
from: path.resolve(__dirname, 'static/assets/sounds'),
|
||||
to: path.resolve(__dirname, '../mobile/html/Web.bundle/assets/sounds'),
|
||||
},
|
||||
{
|
||||
from: path.resolve(__dirname, 'static/federation'),
|
||||
to: path.resolve(__dirname, '../mobile/html/Web.bundle/assets/federation'),
|
||||
},
|
||||
],
|
||||
}),
|
||||
],
|
||||
};
|
||||
|
||||
const configAndroid: Configuration = {
|
||||
...config,
|
||||
module: {
|
||||
@ -274,7 +192,7 @@ const configAndroid: Configuration = {
|
||||
],
|
||||
},
|
||||
output: {
|
||||
path: path.resolve(__dirname, '../mobile_new/app/src/main/assets/static/frontend'),
|
||||
path: path.resolve(__dirname, '../android/app/src/main/assets/static/frontend'),
|
||||
filename: `main.v${version}.[contenthash].js`,
|
||||
clean: true,
|
||||
publicPath: './static/frontend/',
|
||||
@ -285,35 +203,43 @@ const configAndroid: Configuration = {
|
||||
templateParameters: {
|
||||
pro: false,
|
||||
},
|
||||
filename: path.resolve(__dirname, '../mobile_new/app/src/main/assets/index.html'),
|
||||
filename: path.resolve(__dirname, '../android/app/src/main/assets/index.html'),
|
||||
inject: 'body',
|
||||
robosatsSettings: 'mobile-basic',
|
||||
basePath: 'file:///android_asset/Web.bundle/',
|
||||
basePath: 'file:///android_asset/',
|
||||
}),
|
||||
new CopyWebpackPlugin({
|
||||
patterns: [
|
||||
{
|
||||
from: path.resolve(__dirname, 'static/css'),
|
||||
to: path.resolve(__dirname, '../mobile_new/app/src/main/assets/Web.bundle/static/css'),
|
||||
to: path.resolve(__dirname, '../android/app/src/main/assets/static/css'),
|
||||
transform(content, path) {
|
||||
if (path.endsWith('.css')) {
|
||||
let cssContent = content.toString();
|
||||
cssContent = cssContent.replace(
|
||||
/url\(\/static\/css\/fonts\/roboto/g,
|
||||
'url(file:///android_asset/static/css/fonts/roboto',
|
||||
);
|
||||
return Buffer.from(cssContent);
|
||||
}
|
||||
return content;
|
||||
},
|
||||
},
|
||||
{
|
||||
from: path.resolve(__dirname, 'static/assets/sounds'),
|
||||
to: path.resolve(__dirname, '../mobile_new/app/src/main/assets/Web.bundle/assets/sounds'),
|
||||
to: path.resolve(__dirname, '../android/app/src/main/assets/static/assets/sounds'),
|
||||
},
|
||||
{
|
||||
from: path.resolve(__dirname, 'static/assets/images/favicon-*'),
|
||||
to: path.resolve(__dirname, '../android/app/src/main/assets'),
|
||||
},
|
||||
{
|
||||
from: path.resolve(__dirname, 'static/federation'),
|
||||
to: path.resolve(
|
||||
__dirname,
|
||||
'../mobile_new/app/src/main/assets/Web.bundle/assets/federation',
|
||||
),
|
||||
},
|
||||
{
|
||||
from: path.resolve(__dirname, '../mobile/html/Web.bundle/static/frontend'),
|
||||
to: path.resolve(__dirname, '../mobile_new/app/src/main/assets/static/frontend'),
|
||||
to: path.resolve(__dirname, '../android/app/src/main/assets/static/assets/federation'),
|
||||
},
|
||||
],
|
||||
}),
|
||||
],
|
||||
};
|
||||
|
||||
export default [configNode, configNative, configAndroid];
|
||||
export default [configNode, configAndroid];
|
||||
|
||||
@ -1,6 +0,0 @@
|
||||
|
||||
[android]
|
||||
target = Google Inc.:Google APIs:23
|
||||
|
||||
[maven_repositories]
|
||||
central = https://repo1.maven.org/maven2
|
||||
@ -1,2 +0,0 @@
|
||||
BUNDLE_PATH: "vendor/bundle"
|
||||
BUNDLE_FORCE_RUBY_PLATFORM: 1
|
||||
@ -1,40 +0,0 @@
|
||||
{
|
||||
"env": {
|
||||
"browser": true,
|
||||
"es2021": true,
|
||||
"jest": true
|
||||
},
|
||||
"extends": [
|
||||
"eslint:recommended",
|
||||
"plugin:react/recommended",
|
||||
"plugin:@typescript-eslint/recommended",
|
||||
"prettier"
|
||||
],
|
||||
"overrides": [],
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"parserOptions": {
|
||||
"ecmaVersion": "latest",
|
||||
"ecmaFeatures": {
|
||||
"jsx": true
|
||||
},
|
||||
"sourceType": "module",
|
||||
"project": "./tsconfig.json",
|
||||
"tsconfigRootDir": "./"
|
||||
},
|
||||
"plugins": ["react", "react-hooks", "@typescript-eslint", "prettier"],
|
||||
"rules": {
|
||||
"react-hooks/rules-of-hooks": "off",
|
||||
"react-hooks/exhaustive-deps": "warn",
|
||||
"react/prop-types": "off",
|
||||
"react/react-in-jsx-scope": "off"
|
||||
},
|
||||
"settings": {
|
||||
"import/resolver": {
|
||||
"typescript": {}
|
||||
},
|
||||
"react": {
|
||||
"version": "detect"
|
||||
}
|
||||
},
|
||||
"ignorePatterns": ["html/*", "android/app/build/*"]
|
||||
}
|
||||
66
mobile/.gitignore
vendored
@ -1,66 +0,0 @@
|
||||
# OSX
|
||||
#
|
||||
.DS_Store
|
||||
|
||||
# Xcode
|
||||
#
|
||||
build/
|
||||
*.pbxuser
|
||||
!default.pbxuser
|
||||
*.mode1v3
|
||||
!default.mode1v3
|
||||
*.mode2v3
|
||||
!default.mode2v3
|
||||
*.perspectivev3
|
||||
!default.perspectivev3
|
||||
xcuserdata
|
||||
*.xccheckout
|
||||
*.moved-aside
|
||||
DerivedData
|
||||
*.hmap
|
||||
*.ipa
|
||||
*.xcuserstate
|
||||
ios/.xcode.env.local
|
||||
|
||||
# Android/IntelliJ
|
||||
#
|
||||
build/
|
||||
.idea
|
||||
.gradle
|
||||
local.properties
|
||||
*.iml
|
||||
*.hprof
|
||||
|
||||
# node.js
|
||||
#
|
||||
node_modules/
|
||||
npm-debug.log
|
||||
yarn-error.log
|
||||
|
||||
# BUCK
|
||||
buck-out/
|
||||
\.buckd/
|
||||
*.keystore
|
||||
!debug.keystore
|
||||
|
||||
# fastlane
|
||||
#
|
||||
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
|
||||
# screenshots whenever they are needed.
|
||||
# For more information about the recommended setup visit:
|
||||
# https://docs.fastlane.tools/best-practices/source-control/
|
||||
|
||||
**/fastlane/report.xml
|
||||
**/fastlane/Preview.html
|
||||
**/fastlane/screenshots
|
||||
**/fastlane/test_output
|
||||
|
||||
# Bundle artifact
|
||||
*.jsbundle
|
||||
|
||||
# Ruby / CocoaPods
|
||||
/ios/Pods/
|
||||
/vendor/bundle/
|
||||
|
||||
# frontend js
|
||||
/html/Web.bundle/static*
|
||||
@ -1,2 +0,0 @@
|
||||
html/**
|
||||
android/app/build/**
|
||||
@ -1,9 +0,0 @@
|
||||
{
|
||||
"semi": true,
|
||||
"tabWidth": 2,
|
||||
"printWidth": 100,
|
||||
"singleQuote": true,
|
||||
"trailingComma": "all",
|
||||
"jsxSingleQuote": true,
|
||||
"bracketSpacing": true
|
||||
}
|
||||
@ -1 +0,0 @@
|
||||
2.7.4
|
||||
@ -1 +0,0 @@
|
||||
{}
|
||||
263
mobile/App.tsx
@ -1,263 +0,0 @@
|
||||
import React, { useEffect, useRef } from 'react';
|
||||
import { WebView, WebViewMessageEvent } from 'react-native-webview';
|
||||
import { SafeAreaView, Text, Platform, Appearance, DeviceEventEmitter } from 'react-native';
|
||||
import TorClient from './services/Tor';
|
||||
import Clipboard from '@react-native-clipboard/clipboard';
|
||||
import EncryptedStorage from 'react-native-encrypted-storage';
|
||||
import { name as app_name, version as app_version } from './package.json';
|
||||
import TorModule from './native/TorModule';
|
||||
import RoboIdentitiesModule from './native/RoboIdentitiesModule';
|
||||
import NotificationsModule from './native/NotificationsModule';
|
||||
import SystemModule from './native/SystemModule';
|
||||
|
||||
const backgroundColors = {
|
||||
light: 'white',
|
||||
dark: 'black',
|
||||
};
|
||||
|
||||
export type TorStatus = 'ON' | 'STARTING' | 'STOPPING' | 'OFF';
|
||||
|
||||
const App = () => {
|
||||
const colorScheme = Appearance.getColorScheme() ?? 'light';
|
||||
const torClient = new TorClient();
|
||||
const webViewRef = useRef<WebView>();
|
||||
const uri = (Platform.OS === 'android' ? 'file:///android_asset/' : '') + 'Web.bundle/index.html';
|
||||
|
||||
useEffect(() => {
|
||||
TorModule.start();
|
||||
DeviceEventEmitter.addListener('navigateToPage', (payload) => {
|
||||
window.navigateToPage = payload;
|
||||
injectMessage({
|
||||
category: 'system',
|
||||
type: 'navigateToPage',
|
||||
detail: payload,
|
||||
});
|
||||
});
|
||||
DeviceEventEmitter.addListener('TorStatus', (payload) => {
|
||||
if (payload.torStatus === 'OFF') TorModule.restart();
|
||||
injectMessage({
|
||||
category: 'system',
|
||||
type: 'torStatus',
|
||||
detail: payload.torStatus,
|
||||
});
|
||||
});
|
||||
DeviceEventEmitter.addListener('WsMessage', (payload) => {
|
||||
injectMessage({
|
||||
category: 'ws',
|
||||
type: 'wsMessage',
|
||||
detail: payload,
|
||||
});
|
||||
});
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const interval = setInterval(() => {
|
||||
TorModule.getTorStatus();
|
||||
}, 2000);
|
||||
return () => clearInterval(interval);
|
||||
}, []);
|
||||
|
||||
const injectMessageResolve = (id: string, data?: object) => {
|
||||
const json = JSON.stringify(data || {});
|
||||
webViewRef.current?.injectJavaScript(
|
||||
`(function() {window.NativeRobosats.onMessageResolve(${id}, ${json});})();`,
|
||||
);
|
||||
};
|
||||
|
||||
const injectMessage = (message: object) => {
|
||||
const json = JSON.stringify(message);
|
||||
webViewRef.current?.injectJavaScript(
|
||||
`(function() {window.NativeRobosats?.onMessage(${json});})();`,
|
||||
);
|
||||
};
|
||||
|
||||
const onLoadEnd = () => {
|
||||
if (window.navigateToPage) {
|
||||
injectMessage({
|
||||
category: 'system',
|
||||
type: 'navigateToPage',
|
||||
detail: window.navigateToPage,
|
||||
});
|
||||
window.navigateToPage = undefined;
|
||||
}
|
||||
};
|
||||
|
||||
const init = (responseId: string) => {
|
||||
const loadCookie = async (key: string) => {
|
||||
return await EncryptedStorage.getItem(key).then((value) => {
|
||||
if (value) {
|
||||
const json = JSON.stringify({ key, value });
|
||||
webViewRef.current?.injectJavaScript(
|
||||
`(function() {window.NativeRobosats?.loadCookie(${json});})();`,
|
||||
);
|
||||
return value;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
loadCookie('settings_fontsize_basic');
|
||||
loadCookie('settings_language');
|
||||
loadCookie('settings_mode');
|
||||
loadCookie('settings_light_qr');
|
||||
loadCookie('settings_network');
|
||||
loadCookie('settings_connection');
|
||||
loadCookie('settings_use_proxy').then((useProxy: string | undefined) => {
|
||||
SystemModule.useProxy(useProxy ?? 'true');
|
||||
});
|
||||
loadCookie('settings_stop_notifications').then((stopNotifications: string | undefined) => {
|
||||
SystemModule.stopNotifications(stopNotifications ?? 'false');
|
||||
});
|
||||
loadCookie('garage_slots').then((slots) => {
|
||||
NotificationsModule.monitorOrders(slots ?? '{}');
|
||||
injectMessageResolve(responseId);
|
||||
});
|
||||
};
|
||||
|
||||
const onCatch = (dataId: string, event: unknown) => {
|
||||
let json = '{}';
|
||||
let code = 500;
|
||||
if (event.message) {
|
||||
const reponse = /Request Response Code \((?<code>\d*)\): (?<json>\{.*\})/.exec(event.message);
|
||||
json = reponse?.groups?.json ?? '{}';
|
||||
code = reponse?.groups?.code ? parseInt(reponse?.groups?.code) : 500;
|
||||
}
|
||||
injectMessageResolve(dataId, {
|
||||
headers: {},
|
||||
respCode: code,
|
||||
json: JSON.parse(json),
|
||||
});
|
||||
};
|
||||
|
||||
const onMessage = async (event: WebViewMessageEvent) => {
|
||||
const data = JSON.parse(event.nativeEvent.data);
|
||||
if (data.category === 'ws') {
|
||||
TorModule.getTorStatus();
|
||||
if (data.type === 'open') {
|
||||
torClient
|
||||
.wsOpen(data.path)
|
||||
.then((connection: boolean) => {
|
||||
injectMessageResolve(data.id, { connection });
|
||||
})
|
||||
.catch((e) => onCatch(data.id, e))
|
||||
.finally(TorModule.getTorStatus);
|
||||
} else if (data.type === 'send') {
|
||||
torClient
|
||||
.wsSend(data.path, data.message)
|
||||
.catch((e) => onCatch(data.id, e))
|
||||
.finally(TorModule.getTorStatus);
|
||||
} else if (data.type === 'close') {
|
||||
torClient
|
||||
.wsClose(data.path)
|
||||
.then((connection: boolean) => {
|
||||
injectMessageResolve(data.id, { connection });
|
||||
})
|
||||
.finally(TorModule.getTorStatus);
|
||||
}
|
||||
} else if (data.category === 'http') {
|
||||
TorModule.getTorStatus();
|
||||
if (data.type === 'get') {
|
||||
torClient
|
||||
.get(data.baseUrl, data.path, data.headers)
|
||||
.then((response: object) => {
|
||||
injectMessageResolve(data.id, response);
|
||||
})
|
||||
.catch((e) => onCatch(data.id, e))
|
||||
.finally(TorModule.getTorStatus);
|
||||
} else if (data.type === 'post') {
|
||||
torClient
|
||||
.post(data.baseUrl, data.path, data.body, data.headers)
|
||||
.then((response: object) => {
|
||||
injectMessageResolve(data.id, response);
|
||||
})
|
||||
.catch((e) => onCatch(data.id, e))
|
||||
.finally(TorModule.getTorStatus);
|
||||
} else if (data.type === 'delete') {
|
||||
torClient
|
||||
.delete(data.baseUrl, data.path, data.headers)
|
||||
.then((response: object) => {
|
||||
injectMessageResolve(data.id, response);
|
||||
})
|
||||
.catch((e) => onCatch(data.id, e))
|
||||
.finally(TorModule.getTorStatus);
|
||||
}
|
||||
} else if (data.category === 'system') {
|
||||
if (data.type === 'init') {
|
||||
init(data.id);
|
||||
} else if (data.type === 'copyToClipboardString') {
|
||||
Clipboard.setString(data.detail);
|
||||
} else if (data.type === 'setCookie') {
|
||||
setCookie(data.key, data.detail);
|
||||
if (data.key === 'federation') {
|
||||
SystemModule.setFederation(data.detail ?? '{}');
|
||||
} else if (data.key === 'garage_slots') {
|
||||
NotificationsModule.monitorOrders(data.detail ?? '{}');
|
||||
} else if (data.key === 'settings_use_proxy') {
|
||||
SystemModule.useProxy(data.detail ?? 'true');
|
||||
} else if (data.key === 'settings_stop_notifications') {
|
||||
SystemModule.stopNotifications(data.detail ?? 'false');
|
||||
}
|
||||
} else if (data.type === 'deleteCookie') {
|
||||
EncryptedStorage.removeItem(data.key);
|
||||
}
|
||||
} else if (data.category === 'roboidentities') {
|
||||
if (data.type === 'roboname') {
|
||||
const roboname = await RoboIdentitiesModule.generateRoboname(data.detail);
|
||||
injectMessageResolve(data.id, { roboname });
|
||||
} else if (data.type === 'robohash') {
|
||||
const robohash = await RoboIdentitiesModule.generateRobohash(data.detail);
|
||||
injectMessageResolve(data.id, { robohash });
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const setCookie = async (key: string, value: string) => {
|
||||
try {
|
||||
await EncryptedStorage.setItem(key, value);
|
||||
const storedValue = await EncryptedStorage.getItem(key);
|
||||
injectMessage({
|
||||
category: 'system',
|
||||
type: 'setCookie',
|
||||
key,
|
||||
detail: storedValue,
|
||||
});
|
||||
} catch (e) {
|
||||
console.log('setCookie', e);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<SafeAreaView style={{ flex: 1, backgroundColor: backgroundColors[colorScheme] }}>
|
||||
<WebView
|
||||
source={{
|
||||
uri,
|
||||
}}
|
||||
onMessage={onMessage}
|
||||
userAgent={`${app_name} v${app_version} Android`}
|
||||
style={{ backgroundColor: backgroundColors[colorScheme] }}
|
||||
ref={(ref) => (webViewRef.current = ref)}
|
||||
overScrollMode='never'
|
||||
javaScriptEnabled={true}
|
||||
domStorageEnabled={true}
|
||||
sharedCookiesEnabled={true}
|
||||
thirdPartyCookiesEnabled={true}
|
||||
originWhitelist={[uri]}
|
||||
scalesPageToFit={true}
|
||||
startInLoadingState={true}
|
||||
mixedContentMode={'always'}
|
||||
allowsInlineMediaPlayback={true}
|
||||
allowsFullscreenVideo={false}
|
||||
setBuiltInZoomControls={false}
|
||||
allowingReadAccessToURL={uri}
|
||||
allowFileAccess={true}
|
||||
allowsBackForwardNavigationGestures={true}
|
||||
mediaPlaybackRequiresUserAction={false} // Allow autoplay
|
||||
allowsLinkPreview={false}
|
||||
renderLoading={() => <Text></Text>}
|
||||
onError={(syntheticEvent) => <Text>{syntheticEvent.type}</Text>}
|
||||
onLoadEnd={() => setTimeout(onLoadEnd, 3000)}
|
||||
/>
|
||||
</SafeAreaView>
|
||||
);
|
||||
};
|
||||
|
||||
export default App;
|
||||
@ -1,5 +0,0 @@
|
||||
# Android Pre-release
|
||||
|
||||
Android pre-release for testing. This pre-releases has @KoalaSats #247 torified requests through webview. While the app is not fully functioional (no cookies, therefore no permanent robot and no authenticated requests are possible), it would be great to start testing Tor requests in different systems.
|
||||
|
||||
This releases has two assets. A release-like APK and a debug APK (it will show logs for errors).
|
||||
@ -1,6 +0,0 @@
|
||||
source 'https://rubygems.org'
|
||||
|
||||
# You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
|
||||
ruby '2.7.5'
|
||||
|
||||
gem 'cocoapods', '~> 1.11', '>= 1.11.2'
|
||||
@ -1,14 +0,0 @@
|
||||
/**
|
||||
* @format
|
||||
*/
|
||||
|
||||
import 'react-native';
|
||||
import React from 'react';
|
||||
import App from '../App';
|
||||
|
||||
// Note: test renderer must be required after react-native.
|
||||
import renderer from 'react-test-renderer';
|
||||
|
||||
it('renders correctly', () => {
|
||||
renderer.create(<App />);
|
||||
});
|
||||
@ -1,55 +0,0 @@
|
||||
# To learn about Buck see [Docs](https://buckbuild.com/).
|
||||
# To run your application with Buck:
|
||||
# - install Buck
|
||||
# - `npm start` - to start the packager
|
||||
# - `cd android`
|
||||
# - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"`
|
||||
# - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck
|
||||
# - `buck install -r android/app` - compile, install and run application
|
||||
#
|
||||
|
||||
load(":build_defs.bzl", "create_aar_targets", "create_jar_targets")
|
||||
|
||||
lib_deps = []
|
||||
|
||||
create_aar_targets(glob(["libs/*.aar"]))
|
||||
|
||||
create_jar_targets(glob(["libs/*.jar"]))
|
||||
|
||||
android_library(
|
||||
name = "all-libs",
|
||||
exported_deps = lib_deps,
|
||||
)
|
||||
|
||||
android_library(
|
||||
name = "app-code",
|
||||
srcs = glob([
|
||||
"src/main/java/**/*.java",
|
||||
]),
|
||||
deps = [
|
||||
":all-libs",
|
||||
":build_config",
|
||||
":res",
|
||||
],
|
||||
)
|
||||
|
||||
android_build_config(
|
||||
name = "build_config",
|
||||
package = "com.robosats",
|
||||
)
|
||||
|
||||
android_resource(
|
||||
name = "res",
|
||||
package = "com.robosats",
|
||||
res = "src/main/res",
|
||||
)
|
||||
|
||||
android_binary(
|
||||
name = "app",
|
||||
keystore = "//android/keystores:debug",
|
||||
manifest = "src/main/AndroidManifest.xml",
|
||||
package_type = "debug",
|
||||
deps = [
|
||||
":app-code",
|
||||
],
|
||||
)
|
||||
@ -1,345 +0,0 @@
|
||||
apply plugin: "com.android.application"
|
||||
apply plugin: "com.facebook.react"
|
||||
|
||||
import com.android.build.OutputFile
|
||||
|
||||
/**
|
||||
* The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
|
||||
* and bundleReleaseJsAndAssets).
|
||||
* These basically call `react-native bundle` with the correct arguments during the Android build
|
||||
* cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
|
||||
* bundle directly from the development server. Below you can see all the possible configurations
|
||||
* and their defaults. If you decide to add a configuration block, make sure to add it before the
|
||||
* `apply from: "../../node_modules/react-native/react.gradle"` line.
|
||||
*
|
||||
* project.ext.react = [
|
||||
* // the name of the generated asset file containing your JS bundle
|
||||
* bundleAssetName: "index.android.bundle",
|
||||
*
|
||||
* // the entry file for bundle generation. If none specified and
|
||||
* // "index.android.js" exists, it will be used. Otherwise "index.js" is
|
||||
* // default. Can be overridden with ENTRY_FILE environment variable.
|
||||
* entryFile: "index.android.js",
|
||||
*
|
||||
* // https://reactnative.dev/docs/performance#enable-the-ram-format
|
||||
* bundleCommand: "ram-bundle",
|
||||
*
|
||||
* // whether to bundle JS and assets in debug mode
|
||||
* bundleInDebug: false,
|
||||
*
|
||||
* // whether to bundle JS and assets in release mode
|
||||
* bundleInRelease: true,
|
||||
*
|
||||
* // whether to bundle JS and assets in another build variant (if configured).
|
||||
* // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
|
||||
* // The configuration property can be in the following formats
|
||||
* // 'bundleIn${productFlavor}${buildType}'
|
||||
* // 'bundleIn${buildType}'
|
||||
* // bundleInFreeDebug: true,
|
||||
* // bundleInPaidRelease: true,
|
||||
* // bundleInBeta: true,
|
||||
*
|
||||
* // whether to disable dev mode in custom build variants (by default only disabled in release)
|
||||
* // for example: to disable dev mode in the staging build type (if configured)
|
||||
* devDisabledInStaging: true,
|
||||
* // The configuration property can be in the following formats
|
||||
* // 'devDisabledIn${productFlavor}${buildType}'
|
||||
* // 'devDisabledIn${buildType}'
|
||||
*
|
||||
* // the root of your project, i.e. where "package.json" lives
|
||||
* root: "../../",
|
||||
*
|
||||
* // where to put the JS bundle asset in debug mode
|
||||
* jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
|
||||
*
|
||||
* // where to put the JS bundle asset in release mode
|
||||
* jsBundleDirRelease: "$buildDir/intermediates/assets/release",
|
||||
*
|
||||
* // where to put drawable resources / React Native assets, e.g. the ones you use via
|
||||
* // require('./image.png')), in debug mode
|
||||
* resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
|
||||
*
|
||||
* // where to put drawable resources / React Native assets, e.g. the ones you use via
|
||||
* // require('./image.png')), in release mode
|
||||
* resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
|
||||
*
|
||||
* // by default the gradle tasks are skipped if none of the JS files or assets change; this means
|
||||
* // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
|
||||
* // date; if you have any other folders that you want to ignore for performance reasons (gradle
|
||||
* // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
|
||||
* // for example, you might want to remove it from here.
|
||||
* inputExcludes: ["android/**", "ios/**"],
|
||||
*
|
||||
* // override which node gets called and with what additional arguments
|
||||
* nodeExecutableAndArgs: ["node"],
|
||||
*
|
||||
* // supply additional arguments to the packager
|
||||
* extraPackagerArgs: []
|
||||
* ]
|
||||
*/
|
||||
|
||||
project.ext.react = [
|
||||
enableHermes: false, // clean and rebuild if changing
|
||||
]
|
||||
|
||||
/**
|
||||
* Set this to true to create two separate APKs instead of one:
|
||||
* - An APK that only works on ARM devices
|
||||
* - An APK that only works on x86 devices
|
||||
* The advantage is the size of the APK is reduced by about 4MB.
|
||||
* Upload all the APKs to the Play Store and people will download
|
||||
* the correct one based on the CPU architecture of their device.
|
||||
*/
|
||||
def enableSeparateBuildPerCPUArchitecture = true
|
||||
|
||||
/**
|
||||
* Run Proguard to shrink the Java bytecode in release builds.
|
||||
*/
|
||||
def enableProguardInReleaseBuilds = true
|
||||
|
||||
/**
|
||||
* The preferred build flavor of JavaScriptCore.
|
||||
*
|
||||
* For example, to use the international variant, you can use:
|
||||
* `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
|
||||
*
|
||||
* The international variant includes ICU i18n library and necessary data
|
||||
* allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
|
||||
* give correct results when using with locales other than en-US. Note that
|
||||
* this variant is about 6MiB larger per architecture than default.
|
||||
*/
|
||||
def jscFlavor = 'org.webkit:android-jsc:+'
|
||||
|
||||
/**
|
||||
* Whether to enable the Hermes VM.
|
||||
*
|
||||
* This should be set on project.ext.react and that value will be read here. If it is not set
|
||||
* on project.ext.react, JavaScript will not be compiled to Hermes Bytecode
|
||||
* and the benefits of using Hermes will therefore be sharply reduced.
|
||||
*/
|
||||
def enableHermes = project.ext.react.get("enableHermes", false);
|
||||
|
||||
/**
|
||||
* Architectures to build native code for.
|
||||
*/
|
||||
def reactNativeArchitectures() {
|
||||
def value = project.getProperties().get("reactNativeArchitectures")
|
||||
return value ? value.split(",") : ["armeabi-v7a", "x86_64", "arm64-v8a"]
|
||||
}
|
||||
|
||||
android {
|
||||
configurations {
|
||||
all*.exclude group: 'com.facebook.fbjni', module: 'fbjni-java-only'
|
||||
}
|
||||
|
||||
ndkVersion rootProject.ext.ndkVersion
|
||||
|
||||
compileSdkVersion rootProject.ext.compileSdkVersion
|
||||
|
||||
sourceSets {
|
||||
main { assets.srcDirs = ['src/main/assets', '../../html'] }
|
||||
}
|
||||
|
||||
packagingOptions {
|
||||
pickFirst 'lib/armeabi-v7a/libruntimeexecutor.so'
|
||||
pickFirst 'lib/arm64-v8a/libruntimeexecutor.so'
|
||||
pickFirst 'lib/x86_64/libruntimeexecutor.so'
|
||||
}
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.robosats"
|
||||
minSdkVersion rootProject.ext.minSdkVersion
|
||||
targetSdkVersion rootProject.ext.targetSdkVersion
|
||||
versionCode 14
|
||||
versionName "0.8.0-alpha"
|
||||
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
|
||||
|
||||
if (isNewArchitectureEnabled()) {
|
||||
// We configure the NDK build only if you decide to opt-in for the New Architecture.
|
||||
externalNativeBuild {
|
||||
ndkBuild {
|
||||
arguments "APP_PLATFORM=android-21",
|
||||
"APP_STL=c++_shared",
|
||||
"NDK_TOOLCHAIN_VERSION=clang",
|
||||
"GENERATED_SRC_DIR=$buildDir/generated/source",
|
||||
"PROJECT_BUILD_DIR=$buildDir",
|
||||
"REACT_ANDROID_DIR=$rootDir/../node_modules/react-native/ReactAndroid",
|
||||
"REACT_ANDROID_BUILD_DIR=$rootDir/../node_modules/react-native/ReactAndroid/build",
|
||||
"NODE_MODULES_DIR=$rootDir/../node_modules"
|
||||
cFlags "-Wall", "-Werror", "-fexceptions", "-frtti", "-DWITH_INSPECTOR=1"
|
||||
cppFlags "-std=c++17"
|
||||
// Make sure this target name is the same you specify inside the
|
||||
// src/main/jni/Android.mk file for the `LOCAL_MODULE` variable.
|
||||
targets "robosats_appmodules"
|
||||
}
|
||||
}
|
||||
if (!enableSeparateBuildPerCPUArchitecture) {
|
||||
ndk {
|
||||
abiFilters (*reactNativeArchitectures())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isNewArchitectureEnabled()) {
|
||||
// We configure the NDK build only if you decide to opt-in for the New Architecture.
|
||||
externalNativeBuild {
|
||||
ndkBuild {
|
||||
path "$projectDir/src/main/jni/Android.mk"
|
||||
}
|
||||
}
|
||||
def reactAndroidProjectDir = project(':ReactAndroid').projectDir
|
||||
def packageReactNdkDebugLibs = tasks.register("packageReactNdkDebugLibs", Copy) {
|
||||
dependsOn(":ReactAndroid:packageReactNdkDebugLibsForBuck")
|
||||
from("$reactAndroidProjectDir/src/main/jni/prebuilt/lib")
|
||||
into("$buildDir/react-ndk/exported")
|
||||
}
|
||||
def packageReactNdkReleaseLibs = tasks.register("packageReactNdkReleaseLibs", Copy) {
|
||||
dependsOn(":ReactAndroid:packageReactNdkReleaseLibsForBuck")
|
||||
from("$reactAndroidProjectDir/src/main/jni/prebuilt/lib")
|
||||
into("$buildDir/react-ndk/exported")
|
||||
}
|
||||
afterEvaluate {
|
||||
// If you wish to add a custom TurboModule or component locally,
|
||||
// you should uncomment this line.
|
||||
// preBuild.dependsOn("generateCodegenArtifactsFromSchema")
|
||||
preDebugBuild.dependsOn(packageReactNdkDebugLibs)
|
||||
preReleaseBuild.dependsOn(packageReactNdkReleaseLibs)
|
||||
|
||||
// Due to a bug inside AGP, we have to explicitly set a dependency
|
||||
// between configureNdkBuild* tasks and the preBuild tasks.
|
||||
// This can be removed once this is solved: https://issuetracker.google.com/issues/207403732
|
||||
configureNdkBuildRelease.dependsOn(preReleaseBuild)
|
||||
configureNdkBuildDebug.dependsOn(preDebugBuild)
|
||||
reactNativeArchitectures().each { architecture ->
|
||||
tasks.findByName("configureNdkBuildDebug[${architecture}]")?.configure {
|
||||
dependsOn("preDebugBuild")
|
||||
}
|
||||
tasks.findByName("configureNdkBuildRelease[${architecture}]")?.configure {
|
||||
dependsOn("preReleaseBuild")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
splits {
|
||||
abi {
|
||||
reset()
|
||||
enable enableSeparateBuildPerCPUArchitecture
|
||||
universalApk true // If true, also generate a universal APK
|
||||
include (*reactNativeArchitectures())
|
||||
}
|
||||
}
|
||||
signingConfigs {
|
||||
debug {
|
||||
storeFile file('debug.keystore')
|
||||
storePassword 'android'
|
||||
keyAlias 'androiddebugkey'
|
||||
keyPassword 'android'
|
||||
}
|
||||
release {
|
||||
storeFile file("../../../keystore.jks")
|
||||
keyAlias System.getenv("KEY_ALIAS")
|
||||
storePassword System.getenv("KEY_STORE_PASS")
|
||||
keyPassword System.getenv("KEY_PASS")
|
||||
}
|
||||
}
|
||||
buildTypes {
|
||||
debug {
|
||||
signingConfig signingConfigs.debug
|
||||
}
|
||||
release {
|
||||
// Caution! In production, you need to generate your own keystore file.
|
||||
// see https://reactnative.dev/docs/signed-apk-android.
|
||||
signingConfig signingConfigs.release
|
||||
minifyEnabled enableProguardInReleaseBuilds
|
||||
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
|
||||
}
|
||||
}
|
||||
|
||||
// applicationVariants are e.g. debug, release
|
||||
applicationVariants.all { variant ->
|
||||
variant.outputs.each { output ->
|
||||
// For each separate APK per architecture, set a unique version code as described here:
|
||||
// https://developer.android.com/studio/build/configure-apk-splits.html
|
||||
// Example: versionCode 1 will generate 1001 for armeabi-v7a, 1002 for x86, etc.
|
||||
def versionCodes = ["armeabi-v7a": 1, "arm64-v8a": 3, "x86_64": 4]
|
||||
def abi = output.getFilter(OutputFile.ABI)
|
||||
if (abi != null) { // null for the universal-debug, universal-release variants
|
||||
output.versionCodeOverride =
|
||||
defaultConfig.versionCode * 1000 + versionCodes.get(abi)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
packagingOptions {
|
||||
// Make sure libjsc.so does not packed in APK
|
||||
exclude "**/libjsc.so"
|
||||
jniLibs.useLegacyPackaging = true
|
||||
}
|
||||
|
||||
dependenciesInfo {
|
||||
// Disables dependency metadata when building APKs.
|
||||
includeInApk = false
|
||||
// Disables dependency metadata when building Android App Bundles.
|
||||
includeInBundle = false
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: "libs", include: ["*.jar"])
|
||||
|
||||
//noinspection GradleDynamicVersion
|
||||
implementation "com.facebook.react:react-native:+" // From node_modules
|
||||
|
||||
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
|
||||
|
||||
implementation "io.matthewnelson.kotlin-components:kmp-tor:4.8.6-0-1.4.4"
|
||||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.10.2"
|
||||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2"
|
||||
|
||||
if (enableHermes) {
|
||||
//noinspection GradleDynamicVersion
|
||||
implementation("com.facebook.react:hermes-engine:+") { // From node_modules
|
||||
exclude group:'com.facebook.fbjni'
|
||||
}
|
||||
} else {
|
||||
implementation jscFlavor
|
||||
}
|
||||
}
|
||||
|
||||
if (isNewArchitectureEnabled()) {
|
||||
// If new architecture is enabled, we let you build RN from source
|
||||
// Otherwise we fallback to a prebuilt .aar bundled in the NPM package.
|
||||
// This will be applied to all the imported transtitive dependency.
|
||||
configurations.all {
|
||||
resolutionStrategy.dependencySubstitution {
|
||||
substitute(module("com.facebook.react:react-native"))
|
||||
.using(project(":ReactAndroid"))
|
||||
.because("On New Architecture we're building React Native from source")
|
||||
substitute(module("com.facebook.react:hermes-engine"))
|
||||
.using(project(":ReactAndroid:hermes-engine"))
|
||||
.because("On New Architecture we're building Hermes from source")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Run this once to be able to run the application with BUCK
|
||||
// puts all compile dependencies into folder libs for BUCK to use
|
||||
task copyDownloadableDepsToLibs(type: Copy) {
|
||||
from configurations.implementation
|
||||
into 'libs'
|
||||
}
|
||||
|
||||
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
|
||||
|
||||
def isNewArchitectureEnabled() {
|
||||
// To opt-in for the New Architecture, you can either:
|
||||
// - Set `newArchEnabled` to true inside the `gradle.properties` file
|
||||
// - Invoke gradle with `-newArchEnabled=true`
|
||||
// - Set an environment variable `ORG_GRADLE_PROJECT_newArchEnabled=true`
|
||||
return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
|
||||
}
|
||||
|
||||
apply plugin: 'kotlin-android'
|
||||
@ -1,19 +0,0 @@
|
||||
"""Helper definitions to glob .aar and .jar targets"""
|
||||
|
||||
def create_aar_targets(aarfiles):
|
||||
for aarfile in aarfiles:
|
||||
name = "aars__" + aarfile[aarfile.rindex("/") + 1:aarfile.rindex(".aar")]
|
||||
lib_deps.append(":" + name)
|
||||
android_prebuilt_aar(
|
||||
name = name,
|
||||
aar = aarfile,
|
||||
)
|
||||
|
||||
def create_jar_targets(jarfiles):
|
||||
for jarfile in jarfiles:
|
||||
name = "jars__" + jarfile[jarfile.rindex("/") + 1:jarfile.rindex(".jar")]
|
||||
lib_deps.append(":" + name)
|
||||
prebuilt_jar(
|
||||
name = name,
|
||||
binary_jar = jarfile,
|
||||
)
|
||||
15
mobile/android/app/proguard-rules.pro
vendored
@ -1,15 +0,0 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt
|
||||
# You can edit the include path and order by changing the proguardFiles
|
||||
# directive in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# Add any project specific keep options here:
|
||||
|
||||
# Keep some of the react-native-tor classes
|
||||
-keep class com.sifir.tor.TorServiceParam { *; }
|
||||
-keep class com.sifir.tor.TcpSocksStream { *; }
|
||||
-keep class com.sifir.tor.OwnedTorService { *; }
|
||||
@ -1,33 +0,0 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.robosats">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
|
||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||
|
||||
<application
|
||||
android:name=".MainApplication"
|
||||
android:label="@string/app_name"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:allowBackup="false"
|
||||
android:usesCleartextTraffic="true"
|
||||
android:theme="@style/AppTheme"
|
||||
android:extractNativeLibs="true"
|
||||
>
|
||||
<service android:name=".NotificationsService" />
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:label="@string/app_name"
|
||||
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode"
|
||||
android:launchMode="singleTask"
|
||||
android:windowSoftInputMode="adjustResize"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
</manifest>
|
||||
@ -1,138 +0,0 @@
|
||||
package com.robosats;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import com.facebook.react.ReactActivity;
|
||||
import com.facebook.react.ReactActivityDelegate;
|
||||
import com.facebook.react.ReactRootView;
|
||||
import com.facebook.react.bridge.Arguments;
|
||||
import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.facebook.react.bridge.ReactContext;
|
||||
import com.facebook.react.bridge.WritableMap;
|
||||
import com.facebook.react.modules.core.DeviceEventManagerModule;
|
||||
|
||||
public class MainActivity extends ReactActivity {
|
||||
private static final int REQUEST_CODE_POST_NOTIFICATIONS = 1;
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
if (ContextCompat.checkSelfPermission(this, Manifest.permission.POST_NOTIFICATIONS) != PackageManager.PERMISSION_GRANTED) {
|
||||
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.POST_NOTIFICATIONS}, REQUEST_CODE_POST_NOTIFICATIONS);
|
||||
} else {
|
||||
String PREFS_NAME = "System";
|
||||
String KEY_DATA = "Notifications";
|
||||
|
||||
SharedPreferences sharedPreferences =
|
||||
getApplicationContext()
|
||||
.getSharedPreferences(PREFS_NAME, ReactApplicationContext.MODE_PRIVATE);
|
||||
String stop_notifications = sharedPreferences.getString(KEY_DATA, "false");
|
||||
if (!Boolean.parseBoolean(stop_notifications)) {
|
||||
Intent serviceIntent = new Intent(getApplicationContext(), NotificationsService.class);
|
||||
getApplicationContext().startService(serviceIntent);
|
||||
}
|
||||
}
|
||||
|
||||
Intent intent = getIntent();
|
||||
if (intent != null) {
|
||||
String coordinator = intent.getStringExtra("coordinator");
|
||||
int order_id = intent.getIntExtra("order_id", 0);
|
||||
if (order_id > 0) {
|
||||
navigateToPage(coordinator, order_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNewIntent(Intent intent) {
|
||||
super.onNewIntent(intent);
|
||||
if (intent != null) {
|
||||
String coordinator = intent.getStringExtra("coordinator");
|
||||
int order_id = intent.getIntExtra("order_id", 0);
|
||||
if (order_id > 0) {
|
||||
navigateToPage(coordinator, order_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the main component registered from JavaScript. This is used to schedule
|
||||
* rendering of the component.
|
||||
*/
|
||||
@Override
|
||||
protected String getMainComponentName() {
|
||||
return "RoboSats";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the instance of the {@link ReactActivityDelegate}. There the RootView is created and
|
||||
* you can specify the renderer you wish to use - the new renderer (Fabric) or the old renderer
|
||||
* (Paper).
|
||||
*/
|
||||
@Override
|
||||
protected ReactActivityDelegate createReactActivityDelegate() {
|
||||
return new MainActivityDelegate(this, getMainComponentName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
if (requestCode == REQUEST_CODE_POST_NOTIFICATIONS) {
|
||||
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||
String PREFS_NAME = "System";
|
||||
String KEY_DATA = "Notifications";
|
||||
|
||||
SharedPreferences sharedPreferences =
|
||||
getApplicationContext()
|
||||
.getSharedPreferences(PREFS_NAME, ReactApplicationContext.MODE_PRIVATE);
|
||||
String stop_notifications = sharedPreferences.getString(KEY_DATA, "false");
|
||||
if (!Boolean.parseBoolean(stop_notifications)) {
|
||||
Intent serviceIntent = new Intent(getApplicationContext(), NotificationsService.class);
|
||||
getApplicationContext().startService(serviceIntent);
|
||||
}
|
||||
} else {
|
||||
// Permission denied, handle accordingly
|
||||
// Maybe show a message to the user explaining why the permission is necessary
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void navigateToPage(String coordinator, Integer order_id) {
|
||||
ReactContext reactContext = getReactInstanceManager().getCurrentReactContext();
|
||||
if (reactContext != null) {
|
||||
WritableMap payload = Arguments.createMap();
|
||||
payload.putString("coordinator", coordinator);
|
||||
payload.putInt("order_id", order_id);
|
||||
reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
|
||||
.emit("navigateToPage", payload);
|
||||
}
|
||||
}
|
||||
|
||||
public static class MainActivityDelegate extends ReactActivityDelegate {
|
||||
public MainActivityDelegate(ReactActivity activity, String mainComponentName) {
|
||||
super(activity, mainComponentName);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReactRootView createRootView() {
|
||||
ReactRootView reactRootView = new ReactRootView(getContext());
|
||||
// If you opted-in for the New Architecture, we enable the Fabric Renderer.
|
||||
reactRootView.setIsFabric(BuildConfig.IS_NEW_ARCHITECTURE_ENABLED);
|
||||
return reactRootView;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isConcurrentRootEnabled() {
|
||||
// If you opted-in for the New Architecture, we enable Concurrent Root (i.e. React 18).
|
||||
// More on this on https://reactjs.org/blog/2022/03/29/react-v18.html
|
||||
return BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,61 +0,0 @@
|
||||
package com.robosats;
|
||||
|
||||
import android.app.Application;
|
||||
import com.facebook.react.PackageList;
|
||||
import com.facebook.react.ReactApplication;
|
||||
import com.facebook.react.ReactNativeHost;
|
||||
import com.facebook.react.ReactPackage;
|
||||
import com.facebook.react.config.ReactFeatureFlags;
|
||||
import com.facebook.soloader.SoLoader;
|
||||
import android.webkit.WebView;
|
||||
import com.robosats.newarchitecture.MainApplicationReactNativeHost;
|
||||
import java.util.List;
|
||||
|
||||
public class MainApplication extends Application implements ReactApplication {
|
||||
|
||||
private final ReactNativeHost mReactNativeHost =
|
||||
new ReactNativeHost(this) {
|
||||
@Override
|
||||
public boolean getUseDeveloperSupport() {
|
||||
return BuildConfig.DEBUG;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<ReactPackage> getPackages() {
|
||||
@SuppressWarnings("UnnecessaryLocalVariable")
|
||||
List<ReactPackage> packages = new PackageList(this).getPackages();
|
||||
// Packages that cannot be autolinked yet can be added manually here, for example:
|
||||
// packages.add(new MyReactNativePackage());
|
||||
packages.add(new RobosatsPackage());
|
||||
|
||||
return packages;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getJSMainModuleName() {
|
||||
return "index";
|
||||
}
|
||||
};
|
||||
|
||||
private final ReactNativeHost mNewArchitectureNativeHost =
|
||||
new MainApplicationReactNativeHost(this);
|
||||
|
||||
@Override
|
||||
public ReactNativeHost getReactNativeHost() {
|
||||
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
|
||||
return mNewArchitectureNativeHost;
|
||||
} else {
|
||||
return mReactNativeHost;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
// If you opted-in for the New Architecture, we enable the TurboModule system
|
||||
ReactFeatureFlags.useTurboModules = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
|
||||
SoLoader.init(this, /* native exopackage */ false);
|
||||
// For debugging, open in Chrome chrome://inspect/#devices -> inspect
|
||||
WebView.setWebContentsDebuggingEnabled(true);
|
||||
}
|
||||
}
|
||||
@ -1,326 +0,0 @@
|
||||
package com.robosats;
|
||||
|
||||
import android.app.Application;
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.app.Service;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.app.NotificationCompat;
|
||||
|
||||
import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.robosats.tor.TorKmp;
|
||||
import com.robosats.tor.TorKmpManager;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZoneOffset;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.Iterator;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import kotlin.UninitializedPropertyAccessException;
|
||||
import okhttp3.Call;
|
||||
import okhttp3.Callback;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
|
||||
public class NotificationsService extends Service {
|
||||
private Handler handler;
|
||||
private Runnable periodicTask;
|
||||
private static final String CHANNEL_ID = "robosats_notifications";
|
||||
private static final int NOTIFICATION_ID = 76453;
|
||||
private static final long INTERVAL_MS = 5 * 60 * 1000; // 5 minutes
|
||||
private static final String PREFS_NAME_NOTIFICATION = "Notifications";
|
||||
private static final String PREFS_NAME_SYSTEM = "System";
|
||||
private static final String KEY_DATA_SLOTS = "Slots";
|
||||
private static final String KEY_DATA_PROXY = "UsePoxy";
|
||||
private static final String KEY_DATA_FEDERATION = "Federation";
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
createNotificationChannel();
|
||||
startForeground(NOTIFICATION_ID, buildServiceNotification());
|
||||
|
||||
handler = new Handler();
|
||||
periodicTask = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Log.d("NotificationsService", "Running periodic task");
|
||||
executeBackgroundTask();
|
||||
handler.postDelayed(periodicTask, INTERVAL_MS);
|
||||
}
|
||||
};
|
||||
|
||||
Log.d("NotificationsService", "Squeduling periodic task");
|
||||
handler.postDelayed(periodicTask, 5000);
|
||||
return START_STICKY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
if (handler != null && periodicTask != null) {
|
||||
handler.removeCallbacks(periodicTask);
|
||||
}
|
||||
|
||||
stopForeground(true);
|
||||
}
|
||||
|
||||
private void createNotificationChannel() {
|
||||
NotificationManager manager = getSystemService(NotificationManager.class);
|
||||
NotificationChannel channel = new NotificationChannel(
|
||||
CHANNEL_ID,
|
||||
"Robosats",
|
||||
NotificationManager.IMPORTANCE_DEFAULT
|
||||
);
|
||||
manager.createNotificationChannel(channel);
|
||||
}
|
||||
|
||||
private void executeBackgroundTask() {
|
||||
ExecutorService executor = Executors.newSingleThreadExecutor();
|
||||
executor.submit(this::checkNotifications);
|
||||
executor.shutdown();
|
||||
}
|
||||
|
||||
private Notification buildServiceNotification() {
|
||||
Intent intent = new Intent(this, MainActivity.class);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
||||
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_IMMUTABLE);
|
||||
|
||||
NotificationCompat.Builder builder = new NotificationCompat.Builder(this, CHANNEL_ID)
|
||||
.setContentTitle("Tor Notifications")
|
||||
.setContentText("Running in the background every 5 minutes to check for notifications.")
|
||||
.setSmallIcon(R.mipmap.ic_icon)
|
||||
.setTicker("Robosats")
|
||||
.setPriority(NotificationCompat.PRIORITY_MIN)
|
||||
.setOngoing(true)
|
||||
.setAutoCancel(false)
|
||||
.setContentIntent(pendingIntent);
|
||||
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
public void checkNotifications() {
|
||||
Log.d("NotificationsService", "checkNotifications");
|
||||
SharedPreferences sharedPreferences =
|
||||
getApplicationContext()
|
||||
.getSharedPreferences(PREFS_NAME_NOTIFICATION, ReactApplicationContext.MODE_PRIVATE);
|
||||
String slotsJson = sharedPreferences.getString(KEY_DATA_SLOTS, null);
|
||||
|
||||
try {
|
||||
assert slotsJson != null;
|
||||
JSONObject slots = new JSONObject(slotsJson);
|
||||
Iterator<String> it = slots.keys();
|
||||
|
||||
while (it.hasNext()) {
|
||||
String robotToken = it.next();
|
||||
Log.d("NotificationsService", "Checking Slot");
|
||||
JSONObject slot = (JSONObject) slots.get(robotToken);
|
||||
JSONObject robots = slot.getJSONObject("robots");
|
||||
JSONObject coordinatorRobot;
|
||||
String shortAlias = "";
|
||||
if (slot.has("activeShortAlias")) {
|
||||
shortAlias = slot.getString("activeShortAlias");
|
||||
} else if (slot.has("activeOrder") && !slot.isNull("activeOrder")) {
|
||||
JSONObject activeOrder = slot.getJSONObject("activeOrder");
|
||||
shortAlias = activeOrder.getString("shortAlias");
|
||||
}
|
||||
if (!shortAlias.isBlank()) {
|
||||
coordinatorRobot = robots.getJSONObject(shortAlias);
|
||||
fetchNotifications(coordinatorRobot, shortAlias);
|
||||
}
|
||||
}
|
||||
} catch (JSONException | InterruptedException e) {
|
||||
Log.d("NotificationsService", "Error reading garage: " + e);
|
||||
}
|
||||
}
|
||||
|
||||
private void fetchNotifications(JSONObject robot, String coordinator) throws JSONException, InterruptedException {
|
||||
String token = robot.getString("tokenSHA256");
|
||||
SharedPreferences sharedPreferences =
|
||||
getApplicationContext()
|
||||
.getSharedPreferences(PREFS_NAME_SYSTEM, ReactApplicationContext.MODE_PRIVATE);
|
||||
boolean useProxy = Objects.equals(sharedPreferences.getString(KEY_DATA_PROXY, null), "true");
|
||||
JSONObject federation = new JSONObject(sharedPreferences.getString(KEY_DATA_FEDERATION, "{}"));
|
||||
long unix_time_millis = sharedPreferences.getLong(token, 0);
|
||||
String url = federation.getString(coordinator) + "/api/notifications";
|
||||
if (unix_time_millis > 0) {
|
||||
String last_created_at = String
|
||||
.valueOf(LocalDateTime.ofInstant(Instant.ofEpochMilli(unix_time_millis), ZoneId.of("UTC")));
|
||||
url += "?created_at=" + last_created_at;
|
||||
}
|
||||
|
||||
OkHttpClient.Builder builder = new OkHttpClient.Builder()
|
||||
.connectTimeout(60, TimeUnit.SECONDS) // Set connection timeout
|
||||
.readTimeout(30, TimeUnit.SECONDS); // Set read timeout
|
||||
|
||||
if (useProxy) {
|
||||
TorKmp tor = this.getTorKmp();
|
||||
builder.proxy(tor.getProxy());
|
||||
}
|
||||
|
||||
OkHttpClient client = builder.build();
|
||||
Request.Builder requestBuilder = new Request.Builder().url(url);
|
||||
String header = String.format("Token %s", token);
|
||||
try {
|
||||
String pubKey = robot.getString("pubKey");
|
||||
String parsedPubKey = String.join("\\", pubKey.split("\n"));
|
||||
String encPrivKey = robot.getString("encPrivKey");
|
||||
String parsedEncPrivKey = String.join("\\", encPrivKey.split("\n"));
|
||||
header += String.format(" | Public %s | Private %s", parsedPubKey, parsedEncPrivKey);
|
||||
} catch (JSONException e) {
|
||||
Log.e("NotificationsService", "Error obtaining PGP keys");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
String nostrPubKey = robot.getString("nostrPubKey");
|
||||
header += String.format(" | Nostr %s", nostrPubKey);
|
||||
} catch (JSONException e) {
|
||||
Log.d("NotificationsService", "Nostr key not found");
|
||||
}
|
||||
requestBuilder
|
||||
.addHeader("Authorization", header);
|
||||
|
||||
requestBuilder.get();
|
||||
Request request = requestBuilder.build();
|
||||
client.newCall(request).enqueue(new Callback() {
|
||||
@Override
|
||||
public void onFailure(@NonNull Call call, @NonNull IOException e) {
|
||||
displayErrorNotification();
|
||||
Log.d("NotificationsService", "Error fetching coordinator: " + e.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(Call call, Response response) throws IOException {
|
||||
String body = response.body() != null ? response.body().string() : "{}";
|
||||
JSONObject headersJson = new JSONObject();
|
||||
response.headers().names().forEach(name -> {
|
||||
try {
|
||||
headersJson.put(name, response.header(name));
|
||||
} catch (JSONException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
});
|
||||
try {
|
||||
JSONArray results = new JSONArray(body);
|
||||
for (int i=0; i < results.length(); i++) {
|
||||
JSONObject notification = results.getJSONObject(i);
|
||||
Integer order_id = notification.getInt("order_id");
|
||||
String title = notification.getString("title");
|
||||
|
||||
if (title.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
displayOrderNotification(order_id, title, coordinator);
|
||||
|
||||
long milliseconds;
|
||||
try {
|
||||
String created_at = notification.getString("created_at");
|
||||
LocalDateTime datetime = LocalDateTime.parse(created_at, DateTimeFormatter.ISO_DATE_TIME);
|
||||
milliseconds = datetime.toInstant(ZoneOffset.UTC).toEpochMilli() + 1000;
|
||||
} catch (JSONException e) {
|
||||
milliseconds = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||
editor.putLong(token, milliseconds);
|
||||
editor.apply();
|
||||
break;
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void displayOrderNotification(Integer order_id, String message, String coordinator) {
|
||||
NotificationManager notificationManager = (NotificationManager)
|
||||
getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
|
||||
Intent intent = new Intent(this.getApplicationContext(), MainActivity.class);
|
||||
intent.putExtra("coordinator", coordinator);
|
||||
intent.putExtra("order_id", order_id);
|
||||
PendingIntent pendingIntent = PendingIntent.getActivity(this.getApplicationContext(), 0,
|
||||
intent, PendingIntent.FLAG_IMMUTABLE);
|
||||
|
||||
NotificationCompat.Builder builder =
|
||||
new NotificationCompat.Builder(getApplicationContext(), CHANNEL_ID)
|
||||
.setContentTitle("Order #" + order_id)
|
||||
.setContentText(message)
|
||||
.setSmallIcon(R.mipmap.ic_icon)
|
||||
.setPriority(NotificationCompat.PRIORITY_HIGH)
|
||||
.setContentIntent(pendingIntent)
|
||||
.setAutoCancel(true);
|
||||
|
||||
notificationManager.notify(order_id, builder.build());
|
||||
}
|
||||
|
||||
private void displayErrorNotification() {
|
||||
NotificationManager notificationManager = (NotificationManager)
|
||||
getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
|
||||
NotificationCompat.Builder builder =
|
||||
new NotificationCompat.Builder(getApplicationContext(), CHANNEL_ID)
|
||||
.setContentTitle("Connection Error")
|
||||
.setContentText("There was an error while connecting to the Tor network.")
|
||||
.setSmallIcon(R.mipmap.ic_icon)
|
||||
.setPriority(NotificationCompat.PRIORITY_HIGH)
|
||||
.setAutoCancel(true);
|
||||
|
||||
notificationManager.notify(0, builder.build());
|
||||
}
|
||||
|
||||
private TorKmp getTorKmp() throws InterruptedException {
|
||||
TorKmp torKmp;
|
||||
try {
|
||||
torKmp = TorKmpManager.INSTANCE.getTorKmpObject();
|
||||
} catch (UninitializedPropertyAccessException e) {
|
||||
torKmp = new TorKmp((Application) this.getApplicationContext());
|
||||
}
|
||||
|
||||
int retires = 0;
|
||||
while (!torKmp.isConnected() && retires < 15) {
|
||||
if (!torKmp.isStarting()) {
|
||||
torKmp.getTorOperationManager().startQuietly();
|
||||
}
|
||||
Thread.sleep(2000);
|
||||
retires += 1;
|
||||
}
|
||||
|
||||
if (!torKmp.isConnected()) {
|
||||
displayErrorNotification();
|
||||
}
|
||||
|
||||
return torKmp;
|
||||
}
|
||||
}
|
||||
@ -1,22 +0,0 @@
|
||||
package com.robosats;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
public class RoboIdentities {
|
||||
static {
|
||||
System.loadLibrary("robonames");
|
||||
System.loadLibrary("robohash");
|
||||
}
|
||||
|
||||
public String generateRoboname(String initial_string) {
|
||||
return nativeGenerateRoboname(initial_string);
|
||||
}
|
||||
|
||||
public String generateRobohash(String initial_string) {
|
||||
return nativeGenerateRobohash(initial_string);
|
||||
}
|
||||
|
||||
// Native functions implemented in Rust.
|
||||
private static native String nativeGenerateRoboname(String initial_string);
|
||||
private static native String nativeGenerateRobohash(String initial_string);
|
||||
}
|
||||
@ -1,34 +0,0 @@
|
||||
package com.robosats;
|
||||
|
||||
import com.facebook.react.ReactPackage;
|
||||
import com.facebook.react.bridge.NativeModule;
|
||||
import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.facebook.react.uimanager.ViewManager;
|
||||
import com.robosats.modules.NotificationsModule;
|
||||
import com.robosats.modules.RoboIdentitiesModule;
|
||||
import com.robosats.modules.SystemModule;
|
||||
import com.robosats.modules.TorModule;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class RobosatsPackage implements ReactPackage {
|
||||
@Override
|
||||
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NativeModule> createNativeModules(
|
||||
ReactApplicationContext reactContext) {
|
||||
List<NativeModule> modules = new ArrayList<>();
|
||||
|
||||
modules.add(new SystemModule(reactContext));
|
||||
modules.add(new TorModule(reactContext));
|
||||
modules.add(new NotificationsModule(reactContext));
|
||||
modules.add(new RoboIdentitiesModule(reactContext));
|
||||
|
||||
return modules;
|
||||
}
|
||||
}
|
||||
@ -1,30 +0,0 @@
|
||||
package com.robosats.modules;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
||||
import com.facebook.react.bridge.ReactMethod;
|
||||
|
||||
public class NotificationsModule extends ReactContextBaseJavaModule {
|
||||
public NotificationsModule(ReactApplicationContext reactContext) {
|
||||
super(reactContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "NotificationsModule";
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void monitorOrders(String slots_json) {
|
||||
String PREFS_NAME = "Notifications";
|
||||
String KEY_DATA = "Slots";
|
||||
SharedPreferences sharedPreferences = getReactApplicationContext().getSharedPreferences(PREFS_NAME, ReactApplicationContext.MODE_PRIVATE);
|
||||
|
||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||
editor.putString(KEY_DATA, slots_json);
|
||||
|
||||
editor.apply();
|
||||
}
|
||||
}
|
||||
@ -1,37 +0,0 @@
|
||||
package com.robosats.modules;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.facebook.react.bridge.Arguments;
|
||||
import com.facebook.react.bridge.Promise;
|
||||
import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
||||
import com.facebook.react.bridge.ReactMethod;
|
||||
import com.facebook.react.bridge.WritableMap;
|
||||
import com.facebook.react.modules.core.DeviceEventManagerModule;
|
||||
import com.robosats.RoboIdentities;
|
||||
|
||||
public class RoboIdentitiesModule extends ReactContextBaseJavaModule {
|
||||
private ReactApplicationContext context;
|
||||
|
||||
public RoboIdentitiesModule(ReactApplicationContext reactContext) {
|
||||
context = reactContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "RoboIdentitiesModule";
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void generateRoboname(String initial_string, final Promise promise) {
|
||||
String roboname = new RoboIdentities().generateRoboname(initial_string);
|
||||
promise.resolve(roboname);
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void generateRobohash(String initial_string, final Promise promise) {
|
||||
String robohash = new RoboIdentities().generateRobohash(initial_string);
|
||||
promise.resolve(robohash);
|
||||
}
|
||||
}
|
||||
@ -1,65 +0,0 @@
|
||||
package com.robosats.modules;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
||||
import com.facebook.react.bridge.ReactMethod;
|
||||
import com.robosats.NotificationsService;
|
||||
|
||||
public class SystemModule extends ReactContextBaseJavaModule {
|
||||
public SystemModule(ReactApplicationContext reactContext) {
|
||||
super(reactContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "SystemModule";
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void useProxy(String use_proxy) {
|
||||
String PREFS_NAME = "System";
|
||||
String KEY_DATA = "UsePoxy";
|
||||
SharedPreferences sharedPreferences = getReactApplicationContext().getSharedPreferences(PREFS_NAME, ReactApplicationContext.MODE_PRIVATE);
|
||||
|
||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||
editor.putString(KEY_DATA, use_proxy);
|
||||
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void setFederation(String use_proxy) {
|
||||
String PREFS_NAME = "System";
|
||||
String KEY_DATA = "Federation";
|
||||
SharedPreferences sharedPreferences = getReactApplicationContext().getSharedPreferences(PREFS_NAME, ReactApplicationContext.MODE_PRIVATE);
|
||||
|
||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||
editor.putString(KEY_DATA, use_proxy);
|
||||
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void stopNotifications(String stop_notifications) {
|
||||
String PREFS_NAME = "System";
|
||||
String KEY_DATA = "Notifications";
|
||||
|
||||
ReactApplicationContext context = getReactApplicationContext();
|
||||
Intent intent = new Intent(context, NotificationsService.class);
|
||||
|
||||
if (Boolean.parseBoolean(stop_notifications)) {
|
||||
context.stopService(intent);
|
||||
} else {
|
||||
context.startService(intent);
|
||||
}
|
||||
|
||||
SharedPreferences sharedPreferences = getReactApplicationContext().getSharedPreferences(PREFS_NAME, ReactApplicationContext.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||
editor.putString(KEY_DATA, stop_notifications);
|
||||
|
||||
editor.apply();
|
||||
}
|
||||
}
|
||||
@ -1,260 +0,0 @@
|
||||
package com.robosats.modules;
|
||||
|
||||
import android.app.Application;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.facebook.react.bridge.Arguments;
|
||||
import com.facebook.react.bridge.Promise;
|
||||
import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
||||
import com.facebook.react.bridge.ReactMethod;
|
||||
import com.facebook.react.bridge.WritableMap;
|
||||
import com.facebook.react.modules.core.DeviceEventManagerModule;
|
||||
import com.robosats.tor.TorKmp;
|
||||
import com.robosats.tor.TorKmpManager;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import kotlin.UninitializedPropertyAccessException;
|
||||
import okhttp3.Call;
|
||||
import okhttp3.Callback;
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.RequestBody;
|
||||
import okhttp3.Response;
|
||||
import okhttp3.WebSocket;
|
||||
import okhttp3.WebSocketListener;
|
||||
import okio.ByteString;
|
||||
|
||||
|
||||
public class TorModule extends ReactContextBaseJavaModule {
|
||||
private ReactApplicationContext context;
|
||||
private static final Map<String, WebSocket> webSockets = new HashMap<>();
|
||||
|
||||
public TorModule(ReactApplicationContext reactContext) {
|
||||
context = reactContext;
|
||||
TorKmp torKmpManager = new TorKmp((Application) context.getApplicationContext());
|
||||
TorKmpManager.INSTANCE.updateTorKmpObject(torKmpManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "TorModule";
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void sendWsSend(String path, String message, final Promise promise) {
|
||||
if (webSockets.get(path) != null) {
|
||||
Objects.requireNonNull(webSockets.get(path)).send(message);
|
||||
promise.resolve(true);
|
||||
} else {
|
||||
promise.resolve(false);
|
||||
}
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void sendWsClose(String path, final Promise promise) {
|
||||
if (webSockets.get(path) != null) {
|
||||
Objects.requireNonNull(webSockets.get(path)).close(1000, "Closing connection");
|
||||
promise.resolve(true);
|
||||
} else {
|
||||
promise.resolve(false);
|
||||
}
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void sendWsOpen(String path, final Promise promise) {
|
||||
Log.d("Tormodule", "WebSocket opening: " + path);
|
||||
OkHttpClient client = new OkHttpClient.Builder()
|
||||
.connectTimeout(60, TimeUnit.SECONDS) // Set connection timeout
|
||||
.readTimeout(30, TimeUnit.SECONDS) // Set read timeout
|
||||
.proxy(TorKmpManager.INSTANCE.getTorKmpObject().getProxy())
|
||||
.build();
|
||||
|
||||
// Create a request for the WebSocket connection
|
||||
Request request = new Request.Builder()
|
||||
.url(path) // Replace with your WebSocket URL
|
||||
.build();
|
||||
|
||||
// Create a WebSocket listener
|
||||
WebSocketListener listener = new WebSocketListener() {
|
||||
@Override
|
||||
public void onOpen(@NonNull WebSocket webSocket, Response response) {
|
||||
Log.d("Tormodule", "WebSocket opened: " + response.message());
|
||||
promise.resolve(true);
|
||||
synchronized (webSockets) {
|
||||
webSockets.put(path, webSocket); // Store the WebSocket instance with its URL
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMessage(@NonNull WebSocket webSocket, @NonNull String text) {
|
||||
onWsMessage(path, text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMessage(@NonNull WebSocket webSocket, ByteString bytes) {
|
||||
onWsMessage(path, bytes.hex());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClosing(@NonNull WebSocket webSocket, int code, @NonNull String reason) {
|
||||
Log.d("Tormodule", "WebSocket closing: " + reason);
|
||||
synchronized (webSockets) {
|
||||
webSockets.remove(path); // Remove the WebSocket instance by URL
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull WebSocket webSocket, Throwable t, Response response) {
|
||||
Log.d("Tormodule", "WebSocket error: " + t.getMessage());
|
||||
promise.resolve(false);
|
||||
}
|
||||
};
|
||||
|
||||
client.newWebSocket(request, listener);
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void sendRequest(String action, String url, String headers, String body, final Promise promise) throws JSONException, UninitializedPropertyAccessException {
|
||||
OkHttpClient client = new OkHttpClient.Builder()
|
||||
.connectTimeout(60, TimeUnit.SECONDS) // Set connection timeout
|
||||
.readTimeout(30, TimeUnit.SECONDS) // Set read timeout
|
||||
.proxy(TorKmpManager.INSTANCE.getTorKmpObject().getProxy())
|
||||
.build();
|
||||
|
||||
Request.Builder requestBuilder = new Request.Builder().url(url);
|
||||
|
||||
JSONObject headersObject = new JSONObject(headers);
|
||||
headersObject.keys().forEachRemaining(key -> {
|
||||
String value = headersObject.optString(key);
|
||||
requestBuilder.addHeader(key, value);
|
||||
});
|
||||
|
||||
if (Objects.equals(action, "DELETE")) {
|
||||
requestBuilder.delete();
|
||||
} else if (Objects.equals(action, "POST")) {
|
||||
RequestBody requestBody = RequestBody.create(body, MediaType.get("application/json; charset=utf-8"));
|
||||
requestBuilder.post(requestBody);
|
||||
} else {
|
||||
requestBuilder.get();
|
||||
}
|
||||
|
||||
Request request = requestBuilder.build();
|
||||
client.newCall(request).enqueue(new Callback() {
|
||||
@Override
|
||||
public void onFailure(@NonNull Call call, @NonNull IOException e) {
|
||||
Log.d("RobosatsError", e.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(Call call, Response response) throws IOException {
|
||||
String body = response.body() != null ? response.body().string() : "{}";
|
||||
JSONObject headersJson = new JSONObject();
|
||||
response.headers().names().forEach(name -> {
|
||||
try {
|
||||
headersJson.put(name, response.header(name));
|
||||
} catch (JSONException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
});
|
||||
promise.resolve("{\"json\":" + body + ", \"headers\": " + headersJson +"}");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void getTorStatus() throws UninitializedPropertyAccessException {
|
||||
String torState = TorKmpManager.INSTANCE.getTorKmpObject().getTorState().getState().name();
|
||||
WritableMap payload = Arguments.createMap();
|
||||
payload.putString("torStatus", torState);
|
||||
context
|
||||
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
|
||||
.emit("TorStatus", payload);
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void isConnected() throws UninitializedPropertyAccessException {
|
||||
String isConnected = String.valueOf(TorKmpManager.INSTANCE.getTorKmpObject().isConnected());
|
||||
WritableMap payload = Arguments.createMap();
|
||||
payload.putString("isConnected", isConnected);
|
||||
context
|
||||
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
|
||||
.emit("TorIsConnected", payload);
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void isStarting() throws UninitializedPropertyAccessException {
|
||||
String isStarting = String.valueOf(TorKmpManager.INSTANCE.getTorKmpObject().isStarting());
|
||||
WritableMap payload = Arguments.createMap();
|
||||
payload.putString("isStarting", isStarting);
|
||||
context
|
||||
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
|
||||
.emit("TorIsStarting", payload);
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void stop() throws UninitializedPropertyAccessException {
|
||||
TorKmpManager.INSTANCE.getTorKmpObject().getTorOperationManager().stopQuietly();
|
||||
WritableMap payload = Arguments.createMap();
|
||||
context
|
||||
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
|
||||
.emit("TorStop", payload);
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void start() throws InterruptedException, UninitializedPropertyAccessException {
|
||||
TorKmpManager.INSTANCE.getTorKmpObject().getTorOperationManager().startQuietly();
|
||||
WritableMap payload = Arguments.createMap();
|
||||
context
|
||||
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
|
||||
.emit("TorStart", payload);
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void restart() throws UninitializedPropertyAccessException {
|
||||
TorKmp torKmp = new TorKmp(context.getCurrentActivity().getApplication());
|
||||
TorKmpManager.INSTANCE.updateTorKmpObject(torKmp);
|
||||
TorKmpManager.INSTANCE.getTorKmpObject().getTorOperationManager().restartQuietly();
|
||||
WritableMap payload = Arguments.createMap();
|
||||
context
|
||||
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
|
||||
.emit("TorRestart", payload);
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void newIdentity() throws UninitializedPropertyAccessException {
|
||||
TorKmpManager.INSTANCE.getTorKmpObject().newIdentity(context.getCurrentActivity().getApplication());
|
||||
WritableMap payload = Arguments.createMap();
|
||||
context
|
||||
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
|
||||
.emit("TorNewIdentity", payload);
|
||||
}
|
||||
|
||||
private void onWsMessage(String path, String message) {
|
||||
WritableMap payload = Arguments.createMap();
|
||||
payload.putString("message", message);
|
||||
payload.putString("path", path);
|
||||
context
|
||||
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
|
||||
.emit("WsMessage", payload);
|
||||
}
|
||||
|
||||
private void onWsError(String path) {
|
||||
WritableMap payload = Arguments.createMap();
|
||||
payload.putString("path", path);
|
||||
context
|
||||
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
|
||||
.emit("WsError", payload);
|
||||
}
|
||||
}
|
||||
@ -1,116 +0,0 @@
|
||||
package com.robosats.newarchitecture;
|
||||
|
||||
import android.app.Application;
|
||||
import androidx.annotation.NonNull;
|
||||
import com.facebook.react.PackageList;
|
||||
import com.facebook.react.ReactInstanceManager;
|
||||
import com.facebook.react.ReactNativeHost;
|
||||
import com.facebook.react.ReactPackage;
|
||||
import com.facebook.react.ReactPackageTurboModuleManagerDelegate;
|
||||
import com.facebook.react.bridge.JSIModulePackage;
|
||||
import com.facebook.react.bridge.JSIModuleProvider;
|
||||
import com.facebook.react.bridge.JSIModuleSpec;
|
||||
import com.facebook.react.bridge.JSIModuleType;
|
||||
import com.facebook.react.bridge.JavaScriptContextHolder;
|
||||
import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.facebook.react.bridge.UIManager;
|
||||
import com.facebook.react.fabric.ComponentFactory;
|
||||
import com.facebook.react.fabric.CoreComponentsRegistry;
|
||||
import com.facebook.react.fabric.FabricJSIModuleProvider;
|
||||
import com.facebook.react.fabric.ReactNativeConfig;
|
||||
import com.facebook.react.uimanager.ViewManagerRegistry;
|
||||
import com.robosats.BuildConfig;
|
||||
import com.robosats.newarchitecture.components.MainComponentsRegistry;
|
||||
import com.robosats.newarchitecture.modules.MainApplicationTurboModuleManagerDelegate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A {@link ReactNativeHost} that helps you load everything needed for the New Architecture, both
|
||||
* TurboModule delegates and the Fabric Renderer.
|
||||
*
|
||||
* <p>Please note that this class is used ONLY if you opt-in for the New Architecture (see the
|
||||
* `newArchEnabled` property). Is ignored otherwise.
|
||||
*/
|
||||
public class MainApplicationReactNativeHost extends ReactNativeHost {
|
||||
public MainApplicationReactNativeHost(Application application) {
|
||||
super(application);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getUseDeveloperSupport() {
|
||||
return BuildConfig.DEBUG;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<ReactPackage> getPackages() {
|
||||
List<ReactPackage> packages = new PackageList(this).getPackages();
|
||||
// Packages that cannot be autolinked yet can be added manually here, for example:
|
||||
// packages.add(new MyReactNativePackage());
|
||||
// TurboModules must also be loaded here providing a valid TurboReactPackage implementation:
|
||||
// packages.add(new TurboReactPackage() { ... });
|
||||
// If you have custom Fabric Components, their ViewManagers should also be loaded here
|
||||
// inside a ReactPackage.
|
||||
return packages;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getJSMainModuleName() {
|
||||
return "index";
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected ReactPackageTurboModuleManagerDelegate.Builder
|
||||
getReactPackageTurboModuleManagerDelegateBuilder() {
|
||||
// Here we provide the ReactPackageTurboModuleManagerDelegate Builder. This is necessary
|
||||
// for the new architecture and to use TurboModules correctly.
|
||||
return new MainApplicationTurboModuleManagerDelegate.Builder();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JSIModulePackage getJSIModulePackage() {
|
||||
return new JSIModulePackage() {
|
||||
@Override
|
||||
public List<JSIModuleSpec> getJSIModules(
|
||||
final ReactApplicationContext reactApplicationContext,
|
||||
final JavaScriptContextHolder jsContext) {
|
||||
final List<JSIModuleSpec> specs = new ArrayList<>();
|
||||
|
||||
// Here we provide a new JSIModuleSpec that will be responsible of providing the
|
||||
// custom Fabric Components.
|
||||
specs.add(
|
||||
new JSIModuleSpec() {
|
||||
@Override
|
||||
public JSIModuleType getJSIModuleType() {
|
||||
return JSIModuleType.UIManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSIModuleProvider<UIManager> getJSIModuleProvider() {
|
||||
final ComponentFactory componentFactory = new ComponentFactory();
|
||||
CoreComponentsRegistry.register(componentFactory);
|
||||
|
||||
// Here we register a Components Registry.
|
||||
// The one that is generated with the template contains no components
|
||||
// and just provides you the one from React Native core.
|
||||
MainComponentsRegistry.register(componentFactory);
|
||||
|
||||
final ReactInstanceManager reactInstanceManager = getReactInstanceManager();
|
||||
|
||||
ViewManagerRegistry viewManagerRegistry =
|
||||
new ViewManagerRegistry(
|
||||
reactInstanceManager.getOrCreateViewManagers(reactApplicationContext));
|
||||
|
||||
return new FabricJSIModuleProvider(
|
||||
reactApplicationContext,
|
||||
componentFactory,
|
||||
ReactNativeConfig.DEFAULT_CONFIG,
|
||||
viewManagerRegistry);
|
||||
}
|
||||
});
|
||||
return specs;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -1,36 +0,0 @@
|
||||
package com.robosats.newarchitecture.components;
|
||||
|
||||
import com.facebook.jni.HybridData;
|
||||
import com.facebook.proguard.annotations.DoNotStrip;
|
||||
import com.facebook.react.fabric.ComponentFactory;
|
||||
import com.facebook.soloader.SoLoader;
|
||||
|
||||
/**
|
||||
* Class responsible to load the custom Fabric Components. This class has native methods and needs a
|
||||
* corresponding C++ implementation/header file to work correctly (already placed inside the jni/
|
||||
* folder for you).
|
||||
*
|
||||
* <p>Please note that this class is used ONLY if you opt-in for the New Architecture (see the
|
||||
* `newArchEnabled` property). Is ignored otherwise.
|
||||
*/
|
||||
@DoNotStrip
|
||||
public class MainComponentsRegistry {
|
||||
static {
|
||||
SoLoader.loadLibrary("fabricjni");
|
||||
}
|
||||
|
||||
@DoNotStrip private final HybridData mHybridData;
|
||||
|
||||
@DoNotStrip
|
||||
private native HybridData initHybrid(ComponentFactory componentFactory);
|
||||
|
||||
@DoNotStrip
|
||||
private MainComponentsRegistry(ComponentFactory componentFactory) {
|
||||
mHybridData = initHybrid(componentFactory);
|
||||
}
|
||||
|
||||
@DoNotStrip
|
||||
public static MainComponentsRegistry register(ComponentFactory componentFactory) {
|
||||
return new MainComponentsRegistry(componentFactory);
|
||||
}
|
||||
}
|
||||
@ -1,48 +0,0 @@
|
||||
package com.robosats.newarchitecture.modules;
|
||||
|
||||
import com.facebook.jni.HybridData;
|
||||
import com.facebook.react.ReactPackage;
|
||||
import com.facebook.react.ReactPackageTurboModuleManagerDelegate;
|
||||
import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.facebook.soloader.SoLoader;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Class responsible to load the TurboModules. This class has native methods and needs a
|
||||
* corresponding C++ implementation/header file to work correctly (already placed inside the jni/
|
||||
* folder for you).
|
||||
*
|
||||
* <p>Please note that this class is used ONLY if you opt-in for the New Architecture (see the
|
||||
* `newArchEnabled` property). Is ignored otherwise.
|
||||
*/
|
||||
public class MainApplicationTurboModuleManagerDelegate
|
||||
extends ReactPackageTurboModuleManagerDelegate {
|
||||
|
||||
private static volatile boolean sIsSoLibraryLoaded;
|
||||
|
||||
protected MainApplicationTurboModuleManagerDelegate(
|
||||
ReactApplicationContext reactApplicationContext, List<ReactPackage> packages) {
|
||||
super(reactApplicationContext, packages);
|
||||
}
|
||||
|
||||
protected native HybridData initHybrid();
|
||||
|
||||
native boolean canCreateTurboModule(String moduleName);
|
||||
|
||||
public static class Builder extends ReactPackageTurboModuleManagerDelegate.Builder {
|
||||
protected MainApplicationTurboModuleManagerDelegate build(
|
||||
ReactApplicationContext context, List<ReactPackage> packages) {
|
||||
return new MainApplicationTurboModuleManagerDelegate(context, packages);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected synchronized void maybeLoadOtherSoLibraries() {
|
||||
if (!sIsSoLibraryLoaded) {
|
||||
// If you change the name of your application .so file in the Android.mk file,
|
||||
// make sure you update the name here as well.
|
||||
SoLoader.loadLibrary("robosats_appmodules");
|
||||
sIsSoLibraryLoaded = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,48 +0,0 @@
|
||||
THIS_DIR := $(call my-dir)
|
||||
|
||||
include $(REACT_ANDROID_DIR)/Android-prebuilt.mk
|
||||
|
||||
# If you wish to add a custom TurboModule or Fabric component in your app you
|
||||
# will have to include the following autogenerated makefile.
|
||||
# include $(GENERATED_SRC_DIR)/codegen/jni/Android.mk
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_PATH := $(THIS_DIR)
|
||||
|
||||
# You can customize the name of your application .so file here.
|
||||
LOCAL_MODULE := robosats_appmodules
|
||||
|
||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)
|
||||
LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp)
|
||||
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)
|
||||
|
||||
# If you wish to add a custom TurboModule or Fabric component in your app you
|
||||
# will have to uncomment those lines to include the generated source
|
||||
# files from the codegen (placed in $(GENERATED_SRC_DIR)/codegen/jni)
|
||||
#
|
||||
# LOCAL_C_INCLUDES += $(GENERATED_SRC_DIR)/codegen/jni
|
||||
# LOCAL_SRC_FILES += $(wildcard $(GENERATED_SRC_DIR)/codegen/jni/*.cpp)
|
||||
# LOCAL_EXPORT_C_INCLUDES += $(GENERATED_SRC_DIR)/codegen/jni
|
||||
|
||||
# Here you should add any native library you wish to depend on.
|
||||
LOCAL_SHARED_LIBRARIES := \
|
||||
libfabricjni \
|
||||
libfbjni \
|
||||
libfolly_runtime \
|
||||
libglog \
|
||||
libjsi \
|
||||
libreact_codegen_rncore \
|
||||
libreact_debug \
|
||||
libreact_nativemodule_core \
|
||||
libreact_render_componentregistry \
|
||||
libreact_render_core \
|
||||
libreact_render_debug \
|
||||
libreact_render_graphics \
|
||||
librrc_view \
|
||||
libruntimeexecutor \
|
||||
libturbomodulejsijni \
|
||||
libyoga
|
||||
|
||||
LOCAL_CFLAGS := -DLOG_TAG=\"ReactNative\" -fexceptions -frtti -std=c++17 -Wall
|
||||
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
@ -1,24 +0,0 @@
|
||||
#include "MainApplicationModuleProvider.h"
|
||||
|
||||
#include <rncore.h>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
std::shared_ptr<TurboModule> MainApplicationModuleProvider(
|
||||
const std::string moduleName,
|
||||
const JavaTurboModule::InitParams ¶ms) {
|
||||
// Here you can provide your own module provider for TurboModules coming from
|
||||
// either your application or from external libraries. The approach to follow
|
||||
// is similar to the following (for a library called `samplelibrary`:
|
||||
//
|
||||
// auto module = samplelibrary_ModuleProvider(moduleName, params);
|
||||
// if (module != nullptr) {
|
||||
// return module;
|
||||
// }
|
||||
// return rncore_ModuleProvider(moduleName, params);
|
||||
return rncore_ModuleProvider(moduleName, params);
|
||||
}
|
||||
|
||||
} // namespace react
|
||||
} // namespace facebook
|
||||
@ -1,16 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include <ReactCommon/JavaTurboModule.h>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
std::shared_ptr<TurboModule> MainApplicationModuleProvider(
|
||||
const std::string moduleName,
|
||||
const JavaTurboModule::InitParams ¶ms);
|
||||
|
||||
} // namespace react
|
||||
} // namespace facebook
|
||||
@ -1,45 +0,0 @@
|
||||
#include "MainApplicationTurboModuleManagerDelegate.h"
|
||||
#include "MainApplicationModuleProvider.h"
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
jni::local_ref<MainApplicationTurboModuleManagerDelegate::jhybriddata>
|
||||
MainApplicationTurboModuleManagerDelegate::initHybrid(
|
||||
jni::alias_ref<jhybridobject>) {
|
||||
return makeCxxInstance();
|
||||
}
|
||||
|
||||
void MainApplicationTurboModuleManagerDelegate::registerNatives() {
|
||||
registerHybrid({
|
||||
makeNativeMethod(
|
||||
"initHybrid", MainApplicationTurboModuleManagerDelegate::initHybrid),
|
||||
makeNativeMethod(
|
||||
"canCreateTurboModule",
|
||||
MainApplicationTurboModuleManagerDelegate::canCreateTurboModule),
|
||||
});
|
||||
}
|
||||
|
||||
std::shared_ptr<TurboModule>
|
||||
MainApplicationTurboModuleManagerDelegate::getTurboModule(
|
||||
const std::string name,
|
||||
const std::shared_ptr<CallInvoker> jsInvoker) {
|
||||
// Not implemented yet: provide pure-C++ NativeModules here.
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::shared_ptr<TurboModule>
|
||||
MainApplicationTurboModuleManagerDelegate::getTurboModule(
|
||||
const std::string name,
|
||||
const JavaTurboModule::InitParams ¶ms) {
|
||||
return MainApplicationModuleProvider(name, params);
|
||||
}
|
||||
|
||||
bool MainApplicationTurboModuleManagerDelegate::canCreateTurboModule(
|
||||
std::string name) {
|
||||
return getTurboModule(name, nullptr) != nullptr ||
|
||||
getTurboModule(name, {.moduleName = name}) != nullptr;
|
||||
}
|
||||
|
||||
} // namespace react
|
||||
} // namespace facebook
|
||||
@ -1,38 +0,0 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include <ReactCommon/TurboModuleManagerDelegate.h>
|
||||
#include <fbjni/fbjni.h>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
class MainApplicationTurboModuleManagerDelegate
|
||||
: public jni::HybridClass<
|
||||
MainApplicationTurboModuleManagerDelegate,
|
||||
TurboModuleManagerDelegate> {
|
||||
public:
|
||||
// Adapt it to the package you used for your Java class.
|
||||
static constexpr auto kJavaDescriptor =
|
||||
"Lcom/robosats/newarchitecture/modules/MainApplicationTurboModuleManagerDelegate;";
|
||||
|
||||
static jni::local_ref<jhybriddata> initHybrid(jni::alias_ref<jhybridobject>);
|
||||
|
||||
static void registerNatives();
|
||||
|
||||
std::shared_ptr<TurboModule> getTurboModule(
|
||||
const std::string name,
|
||||
const std::shared_ptr<CallInvoker> jsInvoker) override;
|
||||
std::shared_ptr<TurboModule> getTurboModule(
|
||||
const std::string name,
|
||||
const JavaTurboModule::InitParams ¶ms) override;
|
||||
|
||||
/**
|
||||
* Test-only method. Allows user to verify whether a TurboModule can be
|
||||
* created by instances of this class.
|
||||
*/
|
||||
bool canCreateTurboModule(std::string name);
|
||||
};
|
||||
|
||||
} // namespace react
|
||||
} // namespace facebook
|
||||
@ -1,61 +0,0 @@
|
||||
#include "MainComponentsRegistry.h"
|
||||
|
||||
#include <CoreComponentsRegistry.h>
|
||||
#include <fbjni/fbjni.h>
|
||||
#include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
|
||||
#include <react/renderer/components/rncore/ComponentDescriptors.h>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
MainComponentsRegistry::MainComponentsRegistry(ComponentFactory *delegate) {}
|
||||
|
||||
std::shared_ptr<ComponentDescriptorProviderRegistry const>
|
||||
MainComponentsRegistry::sharedProviderRegistry() {
|
||||
auto providerRegistry = CoreComponentsRegistry::sharedProviderRegistry();
|
||||
|
||||
// Custom Fabric Components go here. You can register custom
|
||||
// components coming from your App or from 3rd party libraries here.
|
||||
//
|
||||
// providerRegistry->add(concreteComponentDescriptorProvider<
|
||||
// AocViewerComponentDescriptor>());
|
||||
return providerRegistry;
|
||||
}
|
||||
|
||||
jni::local_ref<MainComponentsRegistry::jhybriddata>
|
||||
MainComponentsRegistry::initHybrid(
|
||||
jni::alias_ref<jclass>,
|
||||
ComponentFactory *delegate) {
|
||||
auto instance = makeCxxInstance(delegate);
|
||||
|
||||
auto buildRegistryFunction =
|
||||
[](EventDispatcher::Weak const &eventDispatcher,
|
||||
ContextContainer::Shared const &contextContainer)
|
||||
-> ComponentDescriptorRegistry::Shared {
|
||||
auto registry = MainComponentsRegistry::sharedProviderRegistry()
|
||||
->createComponentDescriptorRegistry(
|
||||
{eventDispatcher, contextContainer});
|
||||
|
||||
auto mutableRegistry =
|
||||
std::const_pointer_cast<ComponentDescriptorRegistry>(registry);
|
||||
|
||||
mutableRegistry->setFallbackComponentDescriptor(
|
||||
std::make_shared<UnimplementedNativeViewComponentDescriptor>(
|
||||
ComponentDescriptorParameters{
|
||||
eventDispatcher, contextContainer, nullptr}));
|
||||
|
||||
return registry;
|
||||
};
|
||||
|
||||
delegate->buildRegistryFunction = buildRegistryFunction;
|
||||
return instance;
|
||||
}
|
||||
|
||||
void MainComponentsRegistry::registerNatives() {
|
||||
registerHybrid({
|
||||
makeNativeMethod("initHybrid", MainComponentsRegistry::initHybrid),
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace react
|
||||
} // namespace facebook
|
||||
@ -1,32 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <ComponentFactory.h>
|
||||
#include <fbjni/fbjni.h>
|
||||
#include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
|
||||
#include <react/renderer/componentregistry/ComponentDescriptorRegistry.h>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
class MainComponentsRegistry
|
||||
: public facebook::jni::HybridClass<MainComponentsRegistry> {
|
||||
public:
|
||||
// Adapt it to the package you used for your Java class.
|
||||
constexpr static auto kJavaDescriptor =
|
||||
"Lcom/robosats/newarchitecture/components/MainComponentsRegistry;";
|
||||
|
||||
static void registerNatives();
|
||||
|
||||
MainComponentsRegistry(ComponentFactory *delegate);
|
||||
|
||||
private:
|
||||
static std::shared_ptr<ComponentDescriptorProviderRegistry const>
|
||||
sharedProviderRegistry();
|
||||
|
||||
static jni::local_ref<jhybriddata> initHybrid(
|
||||
jni::alias_ref<jclass>,
|
||||
ComponentFactory *delegate);
|
||||
};
|
||||
|
||||
} // namespace react
|
||||
} // namespace facebook
|
||||
@ -1,11 +0,0 @@
|
||||
#include <fbjni/fbjni.h>
|
||||
#include "MainApplicationTurboModuleManagerDelegate.h"
|
||||
#include "MainComponentsRegistry.h"
|
||||
|
||||
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *) {
|
||||
return facebook::jni::initialize(vm, [] {
|
||||
facebook::react::MainApplicationTurboModuleManagerDelegate::
|
||||
registerNatives();
|
||||
facebook::react::MainComponentsRegistry::registerNatives();
|
||||
});
|
||||
}
|
||||