Skip to content

Commit

Permalink
Add setup guide. Bundled dev main.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Reckless-Satoshi committed Jul 14, 2022
1 parent ad97183 commit b4fac4c
Show file tree
Hide file tree
Showing 6 changed files with 10,183 additions and 166 deletions.
45 changes: 39 additions & 6 deletions .github/workflows/android-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,61 @@ on:
pull_request:
branches: [ "main" , "android-webview-app-ts"]
paths: [ "mobile", "frontend" ]

jobs:
build-android:
runs-on: ubuntu-latest
steps:
- name: 'Checkout'
uses: actions/checkout@v3

- name: 'Download main.js Artifact'
uses: dawidd6/action-download-artifact@v2
with:
workflow: frontend-build.yml
workflow_conclusion: success
name: main-js
path: mobile/html/Web.bundle/js/
- name: 'Install npm dependencies'

- name: 'Install npm Dependencies'
run: |
cd mobile
npm install
- name: 'Build Android Release'
run: |
cd android && ./gradlew assembleRelease
- name: 'Upload .apk Artifact'
cd mobile/android
./gradlew assembleRelease
- name: 'Get Commit Hash'
id: commit
uses: pr-mpt/actions-commit-hash@v1

- name: 'Upload APK Artifact'
uses: actions/upload-artifact@v3
with:
name: app-release.apk
path: android/app/build/outputs/apk/release/
name: robosats-${{ steps.commit.outputs.short }}.zip
path: mobile/android/app/build/outputs/apk/release/

- name: 'Create Pre-release'
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: android-${{ steps.commit.outputs.short }}
release_name: robosats-alpha-${{ steps.commit.outputs.short }}
body_path: CHANGELOG.md
draft: false
prerelease: true

- name: 'Upload Pre-release APK Asset'
id: upload-release-asset
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-release.apk
asset_name: robosats-${{ steps.commit.outputs.short }}.apk
asset_content_type: application/apk
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Android Pre-release
To be prepared for Android releases.

App should not be used as of now. It uses the clearnet unsafe tor2web bridge.
3 changes: 3 additions & 0 deletions mobile/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,6 @@ buck-out/
# Ruby / CocoaPods
/ios/Pods/
/vendor/bundle/

# frontend js
/html/Web.bundle/js*
18 changes: 13 additions & 5 deletions mobile/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,23 @@ import {SafeAreaView, Text, Platform} from 'react-native';
const App = () => {
// Webview with local html/js in a single location for andrid/iOS
// https://yelotofu.com/react-native-load-local-static-site-inside-webview-2b93eb1c4225
const htmlPath = (Platform.OS === 'android' ? 'file:///android_asset/' : '') + 'Web.bundle/index.html?';
const htmlPath = (Platform.OS === 'android' ? 'file:///android_asset/' : '') + 'Web.bundle/index.html';

const uri = 'https://robosats.onion.moe'
const onion = 'http://robosats6tkf3eva7x2voqso3a5wcorsnw34jveyxfqi2fu7oyheasid.onion'

const runFirst = `
// document.body.style.backgroundColor = 'red';
// const currentLocation = window.location;
// setTimeout(function() { window.alert(currentLocation) }, 000);
// true; // note: this is required, or you'll sometimes get silent failures
`;

return (
<SafeAreaView style={{ flex: 1 }}>
<WebView
source={{
uri: uri,
//baseUrl: uri,
}}
source={{ uri: uri }}
// source={{ baseUrl: 'file:///android_asset/Web.bundle/' }}
javaScriptEnabled={true}
domStorageEnabled={true}
sharedCookiesEnabled={true}
Expand All @@ -47,6 +54,7 @@ const App = () => {
allowsBackForwardNavigationGestures={false}
mediaPlaybackRequiresUserAction={false}
allowsLinkPreview={false}
injectedJavaScript={runFirst}
renderLoading={() => <Text>Loading RoboSats</Text>}
onError={(syntheticEvent) => <Text>{syntheticEvent}</Text>}
/>
Expand Down
10,231 changes: 10,076 additions & 155 deletions mobile/html/Web.bundle/js/main.js

Large diffs are not rendered by default.

48 changes: 48 additions & 0 deletions mobile/setup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
Tested on Ubuntu 20.04

# Install JDK
```
sudo apt update
sudo apt install default-jdk
java -version
```
# Install Android Studio
```
sudo add-apt-repository ppa:maarten-fonville/android-studio
sudo apt update
sudo apt install android-studio
```
# Install watchman
```
wget https://github.com/facebook/watchman/releases/download/v2022.06.20.00/watchman-v2022.06.20.00-linux.zip
unzip watchman-v2022.06.20.00-linux.zip
cd watchman-v2022.06.20.00-linux
sudo mkdir -p /usr/local/{bin,lib} /usr/local/var/run/watchman
sudo cp bin/* /usr/local/bin
sudo cp lib/* /usr/local/lib
sudo chmod 755 /usr/local/bin/watchman
sudo chmod 2777 /usr/local/var/run/watchman
```
# (If in VMware linux environment)
```
sudo apt install -y open-vm-tools-desktop
sudo apt install -y qemu-kvm libvirt-bin ubuntu-vm-builder bridge-utils
sudo usermod -aG kvm $(whoami)
reboot
```
# Create Emulator (or connect Android phone and install adb)
Use the GUI of Android studio to create a new virtual devide. As of 23/06/2022 we are using a Pixel 5 as template and System image R API level 30 Android 11.0

If using a phone, start the USB debugging mode.

Go to /robosats/mobile/android/local.properties and add `sdk.dir = /home/USERNAME/Android/Sdk` (create the file local.properties if it does not exist)

# Launch app builder and
Point a terminal to /robosats/mobile/
```
npm start
```
on another temrinal also in /robosats/mobile/
```
npx react-native run-android
```

0 comments on commit b4fac4c

Please sign in to comment.