Skip to content

Commit

Permalink
Android on OSX up and running
Browse files Browse the repository at this point in the history
  • Loading branch information
KoalaSat committed Sep 11, 2022
1 parent fef5fed commit 4c9634c
Show file tree
Hide file tree
Showing 9 changed files with 118 additions and 15,850 deletions.
2 changes: 1 addition & 1 deletion frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 15 additions & 4 deletions frontend/webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,21 @@ const config: Configuration = {
resolve: {
extensions: [".tsx", ".ts", ".jsx", ".js"],
},
};

var configWeb = Object.assign({}, config, {
name: "configWeb",
output: {
path: path.resolve(__dirname, "static/frontend"),
filename: "main.js",
path: path.resolve(__dirname, "static/frontend"),
filename: "main.js",
},
};
});
var configMobile = Object.assign({}, config, {
name: "configMobile",
output: {
path: path.resolve(__dirname, "../mobile/html/Web.bundle/js"),
filename: "main.js",
},
});

export default config;
export default [configWeb, configMobile];
1 change: 1 addition & 0 deletions mobile/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,4 @@ buck-out/

# frontend js
/html/Web.bundle/js*
/html/Web.bundle/js*
28 changes: 15 additions & 13 deletions mobile/App.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { WebView, WebViewMessageEvent } from "react-native-webview";
import {WebView, WebViewMessageEvent} from 'react-native-webview';
import {SafeAreaView, Text, Platform} from 'react-native';
// import Tor from "react-native-tor";

Expand All @@ -20,12 +20,13 @@ 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 uri = 'https://robosats.onion.moe'
const onion = 'http://robosats6tkf3eva7x2voqso3a5wcorsnw34jveyxfqi2fu7oyheasid.onion'
var uri =
(Platform.OS === 'android' ? 'file:///android_asset/' : '') +
'Web.bundle/index.html';
const localhost = 'localhost';
// const uri = 'https://robosats.onion.moe';
const onion =
'http://robosats6tkf3eva7x2voqso3a5wcorsnw34jveyxfqi2fu7oyheasid.onion';

const runFirst = `
// document.body.style.backgroundColor = 'red';
Expand All @@ -35,17 +36,18 @@ const App = () => {
`;

return (
<SafeAreaView style={{ flex: 1 }}>
<SafeAreaView style={{flex: 1}}>
<WebView
source={{ uri: uri }}
// source={{ baseUrl: 'file:///android_asset/Web.bundle/' }}
source={{
uri: uri,
}}
javaScriptEnabled={true}
domStorageEnabled={true}
sharedCookiesEnabled={true}
originWhitelist={['*']} //originWhitelist={[uri,uri2]}
originWhitelist={[localhost, uri, onion]}
scalesPageToFit={true}
startInLoadingState={true}
mixedContentMode={"always"}
mixedContentMode={'always'}
allowsInlineMediaPlayback={true}
allowsFullscreenVideo={false}
setBuiltInZoomControls={false}
Expand All @@ -56,7 +58,7 @@ const App = () => {
allowsLinkPreview={false}
injectedJavaScript={runFirst}
renderLoading={() => <Text>Loading RoboSats</Text>}
onError={(syntheticEvent) => <Text>{syntheticEvent}</Text>}
onError={syntheticEvent => <Text>{syntheticEvent}</Text>}
/>
</SafeAreaView>
);
Expand Down
8 changes: 4 additions & 4 deletions mobile/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,11 @@ android {
ndkVersion rootProject.ext.ndkVersion

compileSdkVersion rootProject.ext.compileSdkVersion
sourceSets {
main { assets.srcDirs = ['src/main/assets', '../../html'] }

sourceSets {
main { assets.srcDirs = ['src/main/assets', '../../html'] }
}

defaultConfig {
applicationId "com.robosats"
minSdkVersion rootProject.ext.minSdkVersion
Expand Down
1 change: 1 addition & 0 deletions mobile/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:allowBackup="false"
android:usesCleartextTraffic="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
Expand Down
Loading

0 comments on commit 4c9634c

Please sign in to comment.