Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisknepper committed Jun 21, 2018
0 parents commit 793f0e3
Show file tree
Hide file tree
Showing 35 changed files with 12,601 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"presets": [
[
"@babel/env",
{
"targets": {
"browsers": "last 2 Chrome versions",
"node": "current"
}
}
]
],
"plugins": [["transform-object-rest-spread", { "useBuiltIns": true }]]
}
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# editorconfig.org
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
node_modules
.DS_Store
Thumbs.db
*.log

/dist
/temp

# ignore everything in 'app' folder what had been generated from 'src' folder
/app/app.js
/app/background.js
/app/**/*.map
9 changes: 9 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
The MIT License (MIT)

Copyright (c) 2018 Chris Knepper

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
65 changes: 65 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Android Messages™ Desktop

Run Android Messages as a desktop app, a la iMessage. For those of us that prefer not to have a browser tab always open for this sort of thing.

### Disclaimer: I have not tested this at all because Google has still not made the web messages feature available to me.

Inspired by:

* [Google Play Music Desktop Player](https://github.com/MarshallOfSound/Google-Play-Music-Desktop-Player-UNOFFICIAL-)
* [a Reddit post on r/Android]
(https://www.reddit.com/r/Android/comments/8shv6q/web_messages/e106a8r/)

Based on:

* [electron-boilerplate](https://github.com/szwacz/electron-boilerplate)

# Download
Head over to the [releases](releases) page!

**Important note:** I don't have signing certificates yet. It can still run on both Windows and macOS, but the [process to get it running on macOS](https://www.macworld.com/article/3094865/macs/how-to-run-apps-that-are-not-from-the-app-store-in-macos-sierra.html) is cumbersome. I'm working on getting certificates now.

**Important note 2:** We currently have builds for Windows and macOS. I'd love to be able to do Linux releases, but I have little knowledge of Linux packaging.

# Development
Make sure you have [Node.js](https://nodejs.org) installed, then run the following in your terminal:

```
git clone https://github.com/chrisknepper/android-messages-desktop.git
cd android-messages-desktop
npm install
npm start
```

## Starting the app in development mode
```
npm start
```

# Testing
Run all tests:
```
npm test
```

## Unit
```
npm run unit
```
Using [electron-mocha](https://github.com/jprichardson/electron-mocha) test runner with the [Chai](http://chaijs.com/api/assert/) assertion library. You can put your spec files wherever you want within the `src` directory, just name them with the `.spec.js` extension.

## End to end
```
npm run e2e
```
Using [Mocha](https://mochajs.org/) and [Spectron](http://electron.atom.io/spectron/). This task will run all files in `e2e` directory with `.e2e.js` extension.

# Making a release
To package your app into an installer use command:
```
npm run release
```

Once the packaging process finished, the `dist` directory will contain your distributable file.

We use [electron-builder](https://github.com/electron-userland/electron-builder) to handle the packaging process. It has a lot of [customization options](https://www.electron.build/configuration/configuration), which you can declare under `"build"` key in `package.json`.
15 changes: 15 additions & 0 deletions app/app.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Android Messages</title>
</head>
<body>
<div id="app">
<!-- <webview id="androidMessagesWebview" src="https://davidwalsh.name/demo/notifications-api.php" autosize></webview> -->
<webview id="androidMessagesWebview" src="https://messages.android.com/" autosize></webview>
<div id="loader"></div>
</div>
<script src="app.js"></script>
</body>
</html>
20 changes: 20 additions & 0 deletions build/start.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const childProcess = require("child_process");
const electron = require("electron");
const webpack = require("webpack");
const config = require("./webpack.app.config");

const env = "development";
const compiler = webpack(config(env));
let electronStarted = false;

const watching = compiler.watch({}, (err, stats) => {
if (!err && !stats.hasErrors() && !electronStarted) {
electronStarted = true;

childProcess
.spawn(electron, ["."], { stdio: "inherit" })
.on("close", () => {
watching.close();
});
}
});
16 changes: 16 additions & 0 deletions build/webpack.app.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const path = require("path");
const merge = require("webpack-merge");
const base = require("./webpack.base.config");

module.exports = env => {
return merge(base(env), {
entry: {
background: "./src/background.js",
app: "./src/app.js"
},
output: {
filename: "[name].js",
path: path.resolve(__dirname, "../app")
}
});
};
62 changes: 62 additions & 0 deletions build/webpack.base.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
const path = require("path");
const nodeExternals = require("webpack-node-externals");
const FriendlyErrorsWebpackPlugin = require("friendly-errors-webpack-plugin");

const translateEnvToMode = (env) => {
if (env === "production") {
return "production";
}
return "development";
};

module.exports = env => {
return {
target: "electron-renderer",
mode: translateEnvToMode(env),
node: {
__dirname: false,
__filename: false
},
externals: [nodeExternals()],
resolve: {
alias: {
env: path.resolve(__dirname, `../config/env_${env}.json`)
}
},
devtool: "source-map",
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: ["babel-loader"]
},
{
test: /\.css$/,
use: ["style-loader", "css-loader"]
},
{
test: /\.(png|jpg|gif)$/,
use: [
{
loader: 'file-loader',
options: {
useRelativePath: process.env.NODE_ENV !== "production",
emitFile: false,
name (file) {
if (process.env.NODE_ENV !== "production") {
return '[name].[ext]'
}
return '[name].[ext]'
}
}
}
]
}
]
},
plugins: [
new FriendlyErrorsWebpackPlugin({ clearConsole: env === "development" })
]
};
};
29 changes: 29 additions & 0 deletions build/webpack.e2e.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const merge = require("webpack-merge");
const jetpack = require("fs-jetpack");
const base = require("./webpack.base.config");

// Test files are scattered through the whole project. Here we're searching
// for them and generating entry file for webpack.

const e2eDir = jetpack.cwd("e2e");
const tempDir = jetpack.cwd("temp");
const entryFilePath = tempDir.path("e2e_entry.js");

const entryFileContent = e2eDir
.find({ matching: "*.e2e.js" })
.reduce((fileContent, path) => {
const normalizedPath = path.replace(/\\/g, "/");
return `${fileContent}import "../e2e/${normalizedPath}";\n`;
}, "");

jetpack.write(entryFilePath, entryFileContent);

module.exports = env => {
return merge(base(env), {
entry: entryFilePath,
output: {
filename: "e2e.js",
path: tempDir.path()
}
});
};
29 changes: 29 additions & 0 deletions build/webpack.unit.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const merge = require("webpack-merge");
const jetpack = require("fs-jetpack");
const base = require("./webpack.base.config");

// Test files are scattered through the whole project. Here we're searching
// for them and generating entry file for webpack.

const srcDir = jetpack.cwd("src");
const tempDir = jetpack.cwd("temp");
const entryFilePath = tempDir.path("specs_entry.js");

const entryFileContent = srcDir
.find({ matching: "*.spec.js" })
.reduce((fileContent, path) => {
const normalizedPath = path.replace(/\\/g, "/");
return `${fileContent}import "../src/${normalizedPath}";\n`;
}, "");

jetpack.write(entryFilePath, entryFileContent);

module.exports = env => {
return merge(base(env), {
entry: entryFilePath,
output: {
filename: "specs.js",
path: tempDir.path()
}
});
};
4 changes: 4 additions & 0 deletions config/env_development.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "development",
"description": "Add here any environment specific stuff you like."
}
4 changes: 4 additions & 0 deletions config/env_production.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "production",
"description": "Add here any environment specific stuff you like."
}
4 changes: 4 additions & 0 deletions config/env_test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "test",
"description": "Add here any environment specific stuff you like."
}
13 changes: 13 additions & 0 deletions e2e/hello_world.e2e.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { expect } from "chai";
import testUtils from "./utils";

describe("application launch", () => {
beforeEach(testUtils.beforeEach);
afterEach(testUtils.afterEach);

// it("shows hello world text on screen after launch", function() {
// return this.app.client.getText("#greet").then(text => {
// expect(text).to.equal("Hello World!");
// });
// });
});
26 changes: 26 additions & 0 deletions e2e/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import electron from "electron";
import { Application } from "spectron";

const beforeEach = function() {
this.timeout(10000);
this.app = new Application({
path: electron,
args: ["."],
startTimeout: 10000,
waitTimeout: 10000
});
return this.app.start();
};

const afterEach = function() {
this.timeout(10000);
if (this.app && this.app.isRunning()) {
return this.app.stop();
}
return undefined;
};

export default {
beforeEach,
afterEach
};
Loading

0 comments on commit 793f0e3

Please sign in to comment.