${state.translate(
'uploadDropDragMessage'
diff --git a/android/app/src/main/assets/preferences.png b/assets/preferences.png
similarity index 100%
rename from android/app/src/main/assets/preferences.png
rename to assets/preferences.png
diff --git a/build/android_index_plugin.js b/build/android_index_plugin.js
new file mode 100644
index 00000000..7250ae6d
--- /dev/null
+++ b/build/android_index_plugin.js
@@ -0,0 +1,57 @@
+const path = require('path');
+const html = require('choo/html');
+const NAME = 'AndroidIndexPlugin';
+
+function chunkFileNames(compilation) {
+ const names = {};
+ for (const chunk of compilation.chunks) {
+ for (const file of chunk.files) {
+ if (!/\.map$/.test(file)) {
+ names[`${chunk.name}${path.extname(file)}`] = file;
+ }
+ }
+ }
+ return names;
+}
+class AndroidIndexPlugin {
+ apply(compiler) {
+ const assets = {};
+ compiler.hooks.compilation.tap(NAME, compilation => {
+ compilation.hooks.moduleAsset.tap(NAME, (mod, file) => {
+ if (mod.userRequest) {
+ assets[
+ path.join(path.dirname(file), path.basename(mod.userRequest))
+ ] = file;
+ }
+ });
+ });
+ compiler.hooks.emit.tap(NAME, compilation => {
+ const files = chunkFileNames(compilation);
+ const page = html`
+
+
+
Firefox Send
+
+
+
+
+
+
+
+
+ `
+ .toString()
+ .replace(/\n\s{6}/g, '\n');
+ compilation.assets['index.html'] = {
+ source() {
+ return page;
+ },
+ size() {
+ return page.length;
+ }
+ };
+ });
+ }
+}
+
+module.exports = AndroidIndexPlugin;
diff --git a/server/bin/dev.js b/server/bin/dev.js
index d13a54b4..b4ea500b 100644
--- a/server/bin/dev.js
+++ b/server/bin/dev.js
@@ -1,5 +1,3 @@
-const fs = require('fs');
-const path = require('path');
const assets = require('../../common/assets');
const locales = require('../../common/locales');
const routes = require('../routes');
@@ -12,21 +10,6 @@ const config = require('../config');
const ID_REGEX = '([0-9a-fA-F]{10})';
-const androidIndex = fs.readFileSync(
- path.resolve(__dirname, '../../android/app/src/main/assets/index.html'),
- 'utf8'
-);
-
-function android(req, res) {
- res.set('Content-Type', 'text/html');
- res.send(
- androidIndex
- .replace('index.css', '/android_asset/index.css')
- .replace('vendor.js', assets.get('vendor.js'))
- .replace('android.js', assets.get('android.js'))
- );
-}
-
module.exports = function(app, devServer) {
const wsapp = express();
expressWs(wsapp, null, { perMessageDeflate: false });
@@ -36,6 +19,13 @@ module.exports = function(app, devServer) {
assets.setMiddleware(devServer.middleware);
locales.setMiddleware(devServer.middleware);
app.use(morgan('dev', { stream: process.stderr }));
+ function android(req, res) {
+ const index = devServer.middleware.fileSystem.readFileSync(
+ devServer.middleware.getFilenameFromUrl('/index.html')
+ );
+ res.set('Content-Type', 'text/html');
+ res.send(index);
+ }
if (process.env.ANDROID) {
// map all html routes to the android index.html
app.get('/', android);
diff --git a/webpack.config.js b/webpack.config.js
index ee40528a..7dd10331 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -3,6 +3,7 @@ const webpack = require('webpack');
const CopyPlugin = require('copy-webpack-plugin');
const ManifestPlugin = require('webpack-manifest-plugin');
const VersionPlugin = require('./build/version_plugin');
+const AndroidIndexPlugin = require('./build/android_index_plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const webJsOptions = {
@@ -182,11 +183,6 @@ const web = {
{
context: 'public',
from: '*.*'
- },
- {
- context: 'android/app/src/main/assets',
- from: '*.*',
- to: 'android_asset'
}
]),
new webpack.IgnorePlugin(/\.\.\/dist/), // used in common/*.js
@@ -196,6 +192,7 @@ const web = {
filename: '[name].[hash:8].css'
}),
new VersionPlugin(),
+ new AndroidIndexPlugin(),
new ManifestPlugin() // used by server side to resolve hashed assets
],
devtool: 'source-map',