New app version based on native Kotlin implementation

This commit is contained in:
Fabio Manganiello 2021-04-24 01:27:23 +02:00
parent 691511f5ac
commit 78f5b73bf2
57 changed files with 1540 additions and 1099 deletions

34
.gitignore vendored
View File

@ -1,24 +1,12 @@
*.iml
.gradle
/local.properties
/.idea
.DS_Store
node_modules
/dist
/npm
# local env files
.env.local
.env.*.local
# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
/build
/captures
.externalNativeBuild
.cxx
local.properties
/platypush/build
/app/release

View File

@ -1,7 +1,15 @@
# Changelog
All notable changes to this project will be documented in this file.
## [Unreleased]
## [1.0.1] - 2021-04-28
### Added
- Support for saved/favourite hosts and services.
### Changed
- App migrated from AndroidJS to native Kotlin+webview (and APK size dropped to ~4MB).
### Fixed
- Improved speed and stability of services scan.
## [1.0.0] - 2021-02-26
### Added

1
app/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/build

46
app/build.gradle Normal file
View File

@ -0,0 +1,46 @@
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-android-extensions'
}
android {
compileSdkVersion 29
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "tech.platypush.platypush"
minSdkVersion 23
targetSdkVersion 29
versionCode 1000100
versionName "1.0.1"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5'
implementation 'androidx.navigation:navigation-ui-ktx:2.3.5'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}

21
app/proguard-rules.pro vendored Normal file
View File

@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="tech.platypush.platypush">
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Platypush"
android:usesCleartextTraffic="true">
<activity
android:name="tech.platypush.platypush.MainActivity"
android:label="@string/app_name"
android:theme="@style/Theme.Platypush.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

View File

@ -0,0 +1,292 @@
html, body {
width: 100%;
height: 100%;
margin: 0;
}
#app {
width: 100%;
height: 100%;
background: #e0eae8;
font-size: 20px;
display: flex;
justify-content: center;
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
color: #2c3e50;
}
.services {
width: 60%;
height: max-content;
min-width: 17em;
max-width: 22.5em;
background: white;
margin-top: 2em;
box-shadow: 1px 1px 2px 2px #bbb;
border-radius: 1.5em;
}
.services h3 {
width: 100%;
text-align: center;
}
.no-items {
text-align: center;
padding: 2em 1em;
}
.service {
width: 100%;
padding: 1em .5em;
border-bottom: 1px solid #ccc;
cursor: pointer;
position: relative;
}
.service:first-child {
border-radius: 1.5em 1.5em 0 0;
}
.service:last-child {
border-radius: 0 0 1.5em 1.5em;
}
.service:hover {
background: #bef6da;
}
.service .remove {
position: absolute;
right: 1.5em;
}
.service .remove img {
width: 1.2em;
height: 1.2em;
}
.name {
font-weight: bold;
}
.add-btn {
width: 2.5em;
height: 2.5em;
background: url('../icon/plus.svg');
position: fixed;
bottom: 1em;
right: 1em;
cursor: pointer;
}
.add-btn:hover {
opacity: .75;
}
/* Add host modal */
.add-modal-container {
width: 100%;
height: 100%;
position: fixed;
display: flex;
justify-content: center;
align-items: center;
z-index: 2;
}
.add-modal-background {
width: 100%;
height: 100%;
background: black;
position: absolute;
opacity: .87;
}
.add-modal {
width: 80%;
height: max-content;
max-width: 22.5em;
background: #f0f0f0;
display: flex;
flex-direction: column;
font-size: 1.2em;
padding: 1em;
border-radius: 1em;
z-index: 3;
}
.add-modal .header {
display: flex;
align-items: center;
justify-content: center;
padding-bottom: .5em;
}
.add-modal form,
.add-modal form label {
width: 100%;
}
.add-modal form input {
border-radius: .25em;
padding: .25em;
}
.add-modal form input[type=text],
.add-modal form input[type=number] {
width: 95%;
font-size: 1.05em;
margin-bottom: .5em;
}
.add-modal form input[type=submit] {
font-size: 1.05em;
}
.add-modal .buttons {
width: 100%;
display: flex;
align-items: center;
}
.add-modal .buttons .button {
width: 50%;
}
/* Splash screen */
.splash {
width: 100vw;
height: 100vh;
position: absolute;
background: white;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
font-size: 1.2em;
z-index: 1000;
}
.splash .icon {
width: 150px;
height: 150px;
display: flex;
margin-bottom: .5em;
}
.splash .icon img {
width: 100%;
height: 100%;
}
/* Fade in/out animations */
.fade-in {
animation-duration: 0.5s;
-webkit-animation-duration: 0.5s;
animation-fill-mode: both;
animation-name: fadeIn;
-webkit-animation-name: fadeIn;
}
.fade-out {
animation-duration: 0.5s;
-webkit-animation-duration: 0.5s;
animation-fill-mode: both;
animation-name: fadeOut;
-webkit-animation-name: fadeOut;
}
@keyframes fadeIn {
0% {opacity: 0;}
100% {opacity: 1;}
}
@keyframes fadeOut {
0% {opacity: 1;}
100% {
opacity: 0;
display: none;
}
}
/* Loading animation */
.loading {
display: flex;
align-items: center;
justify-content: center;
font-size: 3em;
position: absolute;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
background: #909090;
opacity: 0.5;
}
.icon {
display: inline-block;
position: relative;
width: 80px;
height: 80px;
}
.icon div {
position: absolute;
top: 33px;
width: 13px;
height: 13px;
border-radius: 50%;
background: #fff;
animation-timing-function: cubic-bezier(0, 1, 1, 0);
}
.icon div:nth-child(1) {
left: 8px;
animation: lds-ellipsis1 0.6s infinite;
}
.icon div:nth-child(2) {
left: 8px;
animation: lds-ellipsis2 0.6s infinite;
}
.icon div:nth-child(3) {
left: 32px;
animation: lds-ellipsis2 0.6s infinite;
}
.icon div:nth-child(4) {
left: 56px;
animation: lds-ellipsis3 0.6s infinite;
}
@keyframes lds-ellipsis1 {
0% {
transform: scale(0);
}
100% {
transform: scale(1);
}
}
@keyframes lds-ellipsis3 {
0% {
transform: scale(1);
}
100% {
transform: scale(0);
}
}
@keyframes lds-ellipsis2 {
0% {
transform: translate(0, 0);
}
100% {
transform: translate(24px, 0);
}
}

View File

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View File

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@ -0,0 +1 @@
../../../res/mipmap-xxxhdpi/ic_launcher.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

View File

@ -0,0 +1,101 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Platypush</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script type="text/javascript" src="js/vue.min.js"></script>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<div id="app">
<div class="splash" v-if="splash">
<div class="icon">
<img src="img/icon.png" alt="">
</div>
<div class="app-name">
Platypush
</div>
</div>
<div class="loading" v-if="loading">
<div class="icon">
<div v-for="n in 4" :key="n"></div>
</div>
</div>
<div class="services">
<div class="saved" v-if="services.saved?.length">
<h3>Saved services</h3>
<div class="service" v-for="(service, i) in services.saved" :key="i"
@click="onServiceClick(service)">
<span class="name" v-text="service.name" v-if="service.name"></span>
<span v-if="service.name"> on </span>
<span class="address" v-text="service.host"></span>:<span class="port" v-text="service.port"></span>
<span class="remove" @click="removeService(i, $event)">
<img src="img/trash.png" alt="Remove">
</span>
</div>
</div>
<div class="scanned">
<h3>Scanned services</h3>
<div class="no-items" v-if="!services.scanned?.length">
<div class="empty">No Platypush web services found on the network</div>
</div>
<div class="service" v-for="(service, i) in services.scanned" :key="i"
@click="onServiceClick(service)">
<span class="name" v-text="service.name" v-if="service.name"></span>
<span v-if="service.name"> on </span>
<span class="address" v-text="service.host"></span>:<span class="port" v-text="service.port"></span>
</div>
</div>
</div>
<div class="add-modal-container" @click="addModal.visible = false" v-if="addModal.visible">
<div class="add-modal-background"></div>
<div class="add-modal" @click="$event.stopPropagation()">
<div class="header">
Connect to a Platypush web service
</div>
<div class="body">
<form @submit.prevent="onServiceConnect">
<label>
<input type="text" placeholder="IP or hostname" v-model="addModal.host">
</label>
<label>
<input type="number" placeholder="Port" v-model="addModal.port">
</label>
<label v-if="addModal.save">
<input type="text" placeholder="Name" v-model="addModal.name">
</label>
<div class="buttons">
<div class="button">
<input type="submit" value="Connect">
</div>
<div class="button">
<label>
Remember this host
<input type="checkbox" v-model="addModal.save">
</label>
</div>
</div>
</form>
</div>
</div>
</div>
<div class="add-btn" @click="addModal.visible = true"></div>
</div>
<script type="text/javascript" src="js/main.js"></script>
</body>
</html>

View File

@ -0,0 +1,167 @@
new Vue({
el: '#app',
data: function() {
return {
loading: false,
splash: false,
services: {
scanned: [],
saved: [],
},
addModal: {
visible: false,
host: undefined,
port: 8008,
name: undefined,
save: false,
},
}
},
computed: {
servicesByName: function() {
return Object.values(this.services).reduce((obj, services) =>
services.reduce((obj2, srv) => {
obj2[srv.name] = srv
return obj2
}, obj), {})
},
servicesByHostAndPort: function() {
return Object.values(this.services).reduce((obj, services) =>
services.reduce((obj2, srv) => {
obj2[`${srv.host}:${srv.port}`] = srv
return obj2
}, obj), {})
},
},
methods: {
refresh: function() {
this.services.scanned = [
...this.services.scanned,
...JSON.parse(app.pollServices()).filter((srv) => !(srv.name in this.servicesByName)),
]
},
onServiceClick: function(service) {
this.connect(service.host, service.port)
},
onServiceConnect: function() {
if (!this.addModal.host?.length) {
app.alert('Please specify a host name or IP address')
return
}
if (this.addModal.save) {
if (!this.saveService(this.addModal.host, this.addModal.port, this.addModal.name || ''))
return
}
this.connect(this.addModal.host, this.addModal.port)
},
saveService: function(host, port, name) {
name = this.addModal.name.trim()
if (!name.length) {
app.alert('Please specify a name')
return false
}
let overwrite = false
if (name in this.servicesByName) {
if (!confirm(`A service named ${name} already exists. ` +
`Do you want to overwrite it?`))
return false
overwrite = true
} else if (`${host}:${port}` in this.servicesByHostAndPort) {
if (!confirm(`A service on ${host}:${port} already exists. ` +
`Do you want to overwrite it?`))
return false
overwrite = true
}
this.loading = true
try {
const rs = app.saveService(host, port, name, overwrite)
if (rs?.error)
throw rs.error
this.loadServices()
return true
} finally {
this.loading = false
}
},
removeService: function(savedIndex, event) {
event.stopPropagation()
const srv = this.services.saved[savedIndex]
if (!(srv && confirm('Are you sure that you want to remove this service?')))
return false
this.loading = true
try {
const rs = app.removeService(srv.host, srv.port, srv.name)
if (rs?.error)
throw rs.error
this.loadServices()
return true
} finally {
this.loading = false
}
},
connect: function(host, port) {
this.loading = true
app.stopServicesPoll()
window.location.href = `http://${host}:${port}/`
},
splashScreen: function(duration) {
const self = this
this.splash = true
setTimeout(() => {
self.splash = false
}, duration)
},
resetAddModal: function() {
this.addModal = {
host: undefined,
port: 8008,
name: undefined,
save: false,
}
},
loadServices: function() {
this.services = {
...this.services,
...JSON.parse(app.loadServices())
}
},
},
mounted: function() {
this.splashScreen(1500)
this.$watch(() => this.addModal.visible, (newValue) => {
if (!newValue)
this.resetAddModal()
})
this.$watch(() => this.addModal.save, (newValue) => {
if (newValue)
this.addModal.name = this.addModal.host
})
this.loadServices()
app.startServicesPoll()
setInterval(this.refresh, 500)
}
})

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

View File

@ -0,0 +1,54 @@
package tech.platypush.platypush
import org.json.JSONArray
import org.json.JSONObject
import java.util.*
import kotlin.collections.HashMap
class JSON {
companion object {
private fun toMap(obj: JSONObject): Map<String, Any?> {
val ret = HashMap<String, Any?>()
val keys = obj.keys()
while (keys.hasNext()) {
val key = keys.next()
var value = obj[key]
if (value is JSONObject)
value = toMap(value)
else if (value is JSONArray)
value = toList(value)
ret[key] = value
}
return ret
}
private fun toList(arr: JSONArray): List<Any?> {
val ret = LinkedList<Any?>()
for (i in 0 until arr.length()) {
var value = arr[i]
if (value is JSONObject)
value = toMap(value)
else if (value is JSONArray)
value = toList(value)
ret.add(value)
}
return ret
}
fun load(str: String): Map<String, Any?> {
return toMap(JSONObject(str))
}
fun dump(obj: Map<String, Any?>): String {
return JSONObject(obj).toString()
}
}
}

View File

@ -0,0 +1,30 @@
package tech.platypush.platypush
import android.annotation.SuppressLint
import android.os.Bundle
import android.webkit.WebChromeClient
import androidx.appcompat.app.AppCompatActivity
import kotlinx.android.synthetic.main.activity_main.*
class MainActivity : AppCompatActivity() {
@SuppressLint("SetJavaScriptEnabled")
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
webview.webViewClient = WebView()
webview.webChromeClient = WebChromeClient()
webview.settings.javaScriptEnabled = true
webview.settings.javaScriptCanOpenWindowsAutomatically = true
webview.clearCache(true)
webview.addJavascriptInterface(WebAppInterface(this), "app")
webview.loadUrl("file:///android_asset/web/index.html")
}
override fun onBackPressed() {
if (webview != null && webview.canGoBack())
webview.goBack()
else
super.onBackPressed()
}
}

View File

@ -0,0 +1,249 @@
package tech.platypush.platypush
import android.content.ContentValues.TAG
import android.content.Context
import android.net.nsd.NsdManager
import android.net.nsd.NsdServiceInfo
import android.util.Log
import java.io.File
import java.io.FileWriter
import java.lang.RuntimeException
import java.util.*
import java.util.concurrent.locks.ReentrantLock
import kotlin.concurrent.withLock
/**
* Service data class
*/
data class Service(val host: String, val port: Int, val name: String?) {
fun toMap(): Map<String, Any?> {
return mapOf(
"host" to host,
"port" to port,
"name" to name
)
}
override fun toString(): String {
return JSON.dump(toMap())
}
companion object {
fun load(obj: Map<String, Any?>): Service {
return Service(
host = obj["host"] as String,
port = obj["port"] as Int,
name = obj["name"] as String?
)
}
}
}
/**
* ZeroConf/Bonjour/mDNS event listener
*/
class Listener(private val scanner: Scanner): NsdManager.DiscoveryListener {
val serviceType = "_platypush-http._tcp."
override fun onDiscoveryStarted(regType: String) {
Log.d(TAG, "Service discovery started")
}
override fun onServiceFound(service: NsdServiceInfo) {
Log.d(TAG, "Service discovery succeeded: $service")
if (service.serviceType != serviceType) {
Log.d(TAG, "Unknown service type: ${service.serviceType}")
return
}
scanner.resolveService(service)
}
override fun onServiceLost(service: NsdServiceInfo) {
Log.w(TAG, "Service lost: $service")
}
override fun onDiscoveryStopped(serviceType: String) {
Log.i(TAG, "Discovery stopped: $serviceType")
}
override fun onStartDiscoveryFailed(serviceType: String, errorCode: Int) {
Log.e(TAG, "Discovery start failed: Error code: $errorCode")
scanner.stopScan()
}
override fun onStopDiscoveryFailed(serviceType: String, errorCode: Int) {
Log.e(TAG, "Discovery stop failed: Error code: $errorCode")
scanner.stopScan()
}
}
/**
* ZeroConf/Bonjour/mDNS service scanner and resolver
*/
class Scanner(context: Context) {
private val nsdManager = context.getSystemService(Context.NSD_SERVICE) as NsdManager
private val listener = Listener(this)
private val services = HashMap<Pair<String, Int>, Service>()
private val resolverLock = ReentrantLock()
fun startScan() {
nsdManager.discoverServices(listener.serviceType, NsdManager.PROTOCOL_DNS_SD, listener)
}
fun stopScan() {
nsdManager.stopServiceDiscovery(listener)
}
fun getServices(): Collection<Service> {
return services.values
}
fun resolveService(service: NsdServiceInfo) {
// Service resolution is a critical section
resolverLock.lock()
val scanner = this
nsdManager.resolveService(service, object : NsdManager.ResolveListener {
override fun onResolveFailed(serviceInfo: NsdServiceInfo, errorCode: Int) {
resolverLock.unlock()
val msg = "Resolve of service ${serviceInfo.serviceName} failed"
// Retry logic
when (errorCode) {
NsdManager.FAILURE_ALREADY_ACTIVE -> {
Thread.sleep(100)
scanner.resolveService(serviceInfo)
Log.w(TAG, "$msg: Resolver already active")
}
NsdManager.FAILURE_MAX_LIMIT -> {
Thread.sleep(5000)
scanner.resolveService(serviceInfo)
Log.e(TAG, "$msg: Maximum number of resolve requests reached")
}
NsdManager.FAILURE_INTERNAL_ERROR -> {
Log.e(TAG, "$msg: Internal error")
}
}
}
override fun onServiceResolved(serviceInfo: NsdServiceInfo) {
services[Pair(serviceInfo.host.hostAddress, serviceInfo.port)] = Service(
serviceInfo.host.hostAddress, serviceInfo.port, serviceInfo.serviceName)
resolverLock.unlock()
Log.i(TAG, "Resolve succeeded: $serviceInfo")
}
})
}
}
/**
* Services manager class
*/
class Manager(context: Context) {
private val servicesFile = File(context.filesDir, "services.json")
private val servicesFileLock = ReentrantLock()
private val emptyServices = mapOf<String, List<Service>>(
"saved" to emptyList(),
"lastConnected" to emptyList()
)
private fun initServicesFile(reset: Boolean = false) {
if (reset || !servicesFile.exists())
saveServices(emptyServices)
}
fun loadServices(): Map<String, List<Service>> {
initServicesFile()
var services: Map<String, List<Service>> = emptyServices
try {
services = deserializeServices(servicesFile.readText())
} catch (e: Exception) {
Log.e(TAG, "Error while parsing $servicesFile: resetting it", e)
initServicesFile(reset = true)
}
return services
}
private fun saveServices(services: Map<String, List<Service>>) {
servicesFileLock.withLock {
FileWriter(servicesFile).use {
it.write(serializeServices(services))
}
}
}
fun saveService(host: String, port: Int, name: String, overwrite: Boolean = false) {
val service = Service(host, port, name)
val services = this.loadServices().toMutableMap()
val savedServices = services["saved"]?.toMutableList() ?: ArrayList()
val dupIndex = getSavedServiceIndex(service, savedServices)
if (dupIndex != null && !overwrite)
throw DuplicateServiceException(service)
savedServices.add(service)
services["saved"] = savedServices
saveServices(services)
}
fun removeService(host: String? = null, port: Int? = null, name: String? = null) {
val service = Service(host=host ?: "", port=port ?: 0, name=name)
val services = this.loadServices().toMutableMap()
val savedServices = ArrayList<Service>(services["saved"] ?: emptyList<Service>())
val srvIndex = getSavedServiceIndex(service, savedServices)
?: throw NoSuchServiceException(host, port, name)
savedServices.removeAt(srvIndex)
services["saved"] = savedServices
saveServices(services)
}
private fun getSavedServiceIndex(service: Service, services: List<Service>): Int? {
val matchingSrvIndexes = services.indices.filter {
(services[it].host == service.host && services[it].port == service.port) ||
services[it].name == service.name
}
return if (matchingSrvIndexes.isNotEmpty()) matchingSrvIndexes[0] else null
}
fun serializeServices(services: Map<String, List<Service>>): String {
val parsedServices = HashMap<String, List<Map<String, Any?>>>()
for (srvType in listOf("saved", "lastConnected")) {
val outputList = LinkedList<Map<String, Any?>>()
for (srv in services[srvType] ?: emptyList())
outputList.add(srv.toMap())
parsedServices[srvType] = outputList.toList()
}
return JSON.dump(parsedServices)
}
private fun deserializeServices(servicesJson: String): Map<String, List<Service>> {
@Suppress("UNCHECKED_CAST")
val services = JSON.load(servicesJson) as Map<String, List<Map<String, Any?>>>
val parsedServices = HashMap<String, List<Service>>()
for (srvType in listOf("saved", "lastConnected")) {
val outputList = LinkedList<Service>()
for (srv in services[srvType] ?: emptyList())
outputList.add(Service.load(srv))
parsedServices[srvType] = outputList
}
return parsedServices
}
}
class DuplicateServiceException(service: Service) : RuntimeException("Duplicate service: $service")
class NoSuchServiceException(host: String? = null, port: Int? = null, name: String? = null):
RuntimeException("No such host: host=$host, port=$port, name=$name")

View File

@ -0,0 +1,67 @@
package tech.platypush.platypush
import android.content.ContentValues.TAG
import android.content.Context
import android.util.Log
import android.webkit.JavascriptInterface
import org.json.JSONArray
import java.util.*
class WebAppInterface(context: Context) {
private val serviceScanner = Scanner(context)
private val serviceManager = Manager(context)
@Suppress("unused")
@JavascriptInterface
fun startServicesPoll() {
serviceScanner.startScan()
}
@Suppress("unused")
@JavascriptInterface
fun stopServicesPoll() {
serviceScanner.stopScan()
}
@Suppress("unused")
@JavascriptInterface
fun pollServices(): String {
val services = LinkedList<Map<String, Any?>>()
for (srv in serviceScanner.getServices())
services.add(srv.toMap())
return JSONArray(services).toString()
}
@Suppress("unused")
@JavascriptInterface
fun loadServices(): String {
return serviceManager.serializeServices(serviceManager.loadServices())
}
@Suppress("unused")
@JavascriptInterface
fun saveService(host: String, port: Int, name: String, overwrite: Boolean = false): String? {
try {
serviceManager.saveService(host, port, name, overwrite=overwrite)
} catch (e: Exception) {
Log.e(TAG, e.toString())
return JSON.dump(mapOf("error" to e.toString()))
}
return null
}
@Suppress("unused")
@JavascriptInterface
fun removeService(host: String, port: Int, name: String): String? {
try {
serviceManager.removeService(host, port, name)
} catch (e: Exception) {
Log.e(TAG, e.toString())
return JSON.dump(mapOf("error" to e.toString()))
}
return null
}
}

View File

@ -0,0 +1,27 @@
package tech.platypush.platypush
import android.webkit.WebResourceRequest
import android.webkit.WebView
import android.webkit.WebViewClient
class WebView : WebViewClient() {
private fun shouldOverrideUrlLoadingInner(view: WebView, url: String): Boolean {
view.loadUrl(url)
return true
}
override fun shouldOverrideUrlLoading(view: WebView?, request: WebResourceRequest?): Boolean {
if (view == null || request == null)
return super.shouldOverrideUrlLoading(view, request)
return this.shouldOverrideUrlLoadingInner(view, request.url.toString())
}
override fun shouldOverrideUrlLoading(view: WebView?, url: String?): Boolean {
@Suppress("DEPRECATION")
if (view == null || url == null)
return super.shouldOverrideUrlLoading(view, url)
return this.shouldOverrideUrlLoadingInner(view, url)
}
}

View File

@ -0,0 +1,26 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<group android:scaleX="0.5016"
android:scaleY="0.5016"
android:translateX="28.92"
android:translateY="28.92">
<path
android:pathData="M0,50l0,-50 50,0 50,0 0,50 0,50 -50,0 -50,0 0,-50zM73.2,86.2c0.9,-1 0.6,-1.1 -1.6,-0.2 -4.8,1.8 -10.2,1.2 -13.3,-1.4 -2.6,-2.2 -2.8,-3 -2.8,-9.6 0,-9.2 1.8,-11 10.5,-11 7.8,0 10,2.5 10,11.4 0,3.4 -0.5,6.7 -1.2,7.4 -0.9,0.9 -0.4,0.9 2.3,0.2 1.8,-0.6 3.5,-1 3.7,-1 0.1,0 -0.5,-1.1 -1.4,-2.5 -1.2,-1.9 -1.5,-4.1 -1.2,-9l0.4,-6.5 -2.8,0c-3.4,0 -7.8,-2.6 -7.8,-4.6 0,-1.9 -1,-1.8 -2.5,0.2 -0.7,1 -3.2,1.9 -6.2,2.1l-5.1,0.5 -0.4,6.5c-0.3,4.8 -0.9,6.8 -2.1,7.5 -2.1,1.1 -2.2,2.8 -0.3,2.8 2.1,0 5.6,5.4 5.6,8.7 0,2.8 0.1,2.8 6.7,2.9 4.7,0.1 6.9,0.6 7.2,1.5 0.3,0.8 0.7,0.1 0.9,-1.6 0.2,-1.6 0.9,-3.6 1.4,-4.3zM34.2,61.3c0.6,-0.7 2.8,-1.3 4.9,-1.3 2.1,0 4.1,0.6 4.6,1.3 0.5,0.7 1,-0.7 1.3,-3.8l0.5,-5 4.7,0 4.7,0 -2,-2.1c-3.8,-4.1 -2,-10.8 3.3,-12l3.3,-0.7 -3.5,-1.5c-1.9,-0.8 -3.8,-1.9 -4.2,-2.6 -1.3,-1.9 -0.9,-7 0.7,-9.3 1.5,-2.1 1.4,-2.2 -2.7,-2.5l-4.3,-0.3 -0.6,-5c-0.3,-2.7 -0.7,-4.4 -0.7,-3.7 -0.2,0.9 -1.7,1.2 -5.4,1 -5,-0.3 -5.3,-0.5 -5.9,-3.3 -0.6,-3.1 -1,-2.7 -2.5,2.3 -0.4,1.5 -8.5,1.7 -10,0.2 -0.7,-0.7 -0.9,0.2 -0.6,2.5 0.6,4.7 -1.1,6.5 -6.1,6.5 -3.8,0 -3.9,0.1 -2.4,1.8 2,2.2 2.3,9.5 0.5,10.9 -0.7,0.6 -2.6,1.4 -4.3,1.8l-3,0.7 4,1.2c3.8,1.1 4,1.4 4.3,5.3 0.2,2.3 -0.2,5.1 -0.8,6.3 -1,1.8 -0.8,2 2.3,2 4.1,0 5.7,1.5 5.7,5.5 0,3 0.1,3 5.2,3 5,0 5.2,0.1 6.2,3.5 0.9,3.2 1,3.3 1.4,1 0.2,-1.4 0.9,-3.1 1.4,-3.7zM82.4,33.2l11.4,-7.9 -11.3,-7.6c-6.3,-4.2 -11.6,-7.7 -11.9,-7.7 -0.3,0 -0.6,7 -0.6,15.5 0,8.5 0.2,15.5 0.5,15.5 0.3,0 5.7,-3.5 11.9,-7.8z"
android:fillColor="#ffffff"/>
<path
android:pathData="M25.1,51.7c-6.2,-3.2 -8.9,-13.7 -5.6,-22.2 2.1,-5.7 5.4,-7.5 13.3,-7.5 10,0 13.8,5.1 13,17.7 -0.4,6 -0.7,6.8 -4.1,9.9 -3.2,3 -4.3,3.4 -8.9,3.4 -2.9,0 -6.4,-0.6 -7.7,-1.3z"
android:fillColor="#ffffff"/>
<path
android:pathData="M69.3,96.7c-2.9,-3.7 -7.2,-4.1 -10.5,-1 -2.4,2.3 -3,2.4 -4.4,1.3 -1.2,-1.1 -1.4,-2.4 -1,-5.3 0.8,-4.8 -2,-9.2 -6.4,-10.2 -4.1,-0.9 -4.1,-4.7 0,-7.2 3.4,-2 4.9,-7.1 3.1,-10.6 -1,-2 -1,-1.9 -0.5,1 0.4,2.5 0.1,3.4 -1.6,4.3 -1.9,1 -2.6,0.7 -5.5,-2.7 -3.9,-4.5 -5.3,-3.9 -7,3 -0.8,3.5 -1.4,4.2 -3.4,4.2 -2.2,0 -2.6,-0.7 -3.5,-4.9 -0.6,-2.7 -1.7,-5.1 -2.5,-5.4 -0.8,-0.3 -2.8,1.3 -4.6,3.4 -3.2,3.8 -3.3,3.8 -5.3,2.1 -1.8,-1.7 -1.9,-2.1 -0.6,-6.4 1.5,-5.1 0.5,-8 -2.5,-6.7 -5.8,2.3 -7.2,2.3 -8.3,-0.1 -0.9,-2.1 -0.7,-2.9 2.1,-6.1 4,-4.5 3.7,-6.5 -1.1,-7.9 -2.1,-0.5 -4.2,-1.5 -4.9,-2.2 -2,-2 -0.1,-5.1 3.8,-6 5.6,-1.3 6.3,-3.4 2.5,-7.7 -3.5,-4.1 -3.9,-5.8 -1.7,-7.6 1.1,-0.9 2.2,-0.9 5,0 5.4,1.8 6.7,0.3 5,-6.1 -1.2,-4.6 -1.2,-5 0.7,-6 1.7,-0.9 2.5,-0.6 5.3,2.1 1.8,1.8 3.9,3 4.6,2.8 0.8,-0.3 1.8,-2.4 2.4,-4.9 0.9,-3.7 1.5,-4.5 3.7,-4.7 2.3,-0.3 2.6,0.1 3.4,4.5 1.1,6 3.2,6.6 7.3,2.1 2.5,-2.8 3.3,-3.1 4.8,-2.2 1.3,0.8 1.7,2 1.4,4 -0.2,1.6 -0.5,4.3 -0.5,5.9 -0.1,3.3 0.8,3.5 7.1,2.1 2.9,-0.7 3.3,-0.5 3.9,1.8 0.5,2 -0.1,3.4 -2.5,6.1 -1.7,1.9 -2.8,4.1 -2.5,4.9 0.3,0.8 2.4,2.1 4.7,2.9 3.3,1.1 4.3,1.9 4.5,3.9 0.3,2.2 -0.2,2.8 -3.5,3.8 -6.1,1.9 -6.8,3.6 -3.3,7.9 5.1,6.1 3.5,9.9 -3.2,7.5 -4.8,-1.6 -5.8,-1.2 -5.7,2.4 0,2.6 0.1,2.6 0.9,0.5 1,-2.4 3.9,-3 5.7,-1.2 0.7,0.7 2.4,0.8 4.2,0.4 2.3,-0.5 3.7,-1.7 5.2,-4.6 2.5,-4.9 4.9,-4.8 6.2,0.1 1.2,5 4.3,7.2 8.9,6.4 4.7,-0.7 5.8,1.3 3.4,6.2 -2.3,4.9 -2,7.9 1.2,11.6 3.7,4.3 3.1,6.5 -1.8,7.3 -4.6,0.8 -6.7,3.5 -7.2,9.1 -0.4,4.7 -2.7,5.6 -5.5,2.1zM71.2,80.7c3.9,-4.9 0.6,-13.7 -5.2,-13.7 -4.6,0 -7.5,3.1 -7.5,8 0,7.9 8.1,11.6 12.7,5.7zM38.4,46.9c5.9,-5.1 5.8,-15.2 -0.1,-19.8 -8.1,-6.5 -19.3,2.8 -16.4,13.6 2.4,8.8 10.2,11.8 16.5,6.2z"
android:fillColor="#000000"/>
<path
android:pathData="M67,25.6c0,-11.8 0.4,-21.7 0.8,-22 0.4,-0.2 3.5,1.4 6.8,3.7 5.4,3.7 6.1,4.6 6.2,7.7 0.1,1.9 0.4,6.6 0.8,10.4 0.5,5.5 1,6.9 2.5,7.3 1.1,0.3 1.9,1.1 1.9,1.8 0,1.4 -15.7,12.5 -17.7,12.5 -1,0 -1.3,-5 -1.3,-21.4z"
android:fillColor="#7bc448"/>
<path
android:pathData="M81.3,36c-1.3,-0.5 -2.3,-1.5 -2.3,-2.3 0,-0.7 -0.5,-6.2 -1.1,-12.1 -0.6,-5.9 -0.8,-11 -0.5,-11.3 0.8,-0.8 22.6,13.8 22.6,15.1 0,0.9 -13.8,10.6 -15.9,11.3 -0.3,0.1 -1.6,-0.2 -2.8,-0.7z"
android:fillColor="#60b64f"/>
</group>
</vector>

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<LinearLayout
android:id="@+id/relativeLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<WebView
android:id="@+id/webview"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
</adaptive-icon>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
</adaptive-icon>

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/nav_graph">
</navigation>

View File

@ -0,0 +1,16 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.Platypush" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/purple_200</item>
<item name="colorPrimaryVariant">@color/purple_700</item>
<item name="colorOnPrimary">@color/black</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">@color/teal_200</item>
<item name="colorSecondaryVariant">@color/teal_200</item>
<item name="colorOnSecondary">@color/black</item>
<!-- Status bar color. -->
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
<!-- Customize your theme here. -->
</style>
</resources>

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="purple_200">#FFBB86FC</color>
<color name="purple_500">#FF6200EE</color>
<color name="purple_700">#FF3700B3</color>
<color name="teal_200">#FF03DAC5</color>
<color name="teal_700">#FF018786</color>
<color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color>
</resources>

View File

@ -0,0 +1,3 @@
<resources>
<dimen name="fab_margin">16dp</dimen>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ic_launcher_background">#FFFFFF</color>
</resources>

View File

@ -0,0 +1,6 @@
<resources>
<string name="app_name">Platypush</string>
<string name="action_settings">Settings</string>
<string name="next">Next</string>
<string name="previous">Previous</string>
</resources>

View File

@ -0,0 +1,25 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.Platypush" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/purple_500</item>
<item name="colorPrimaryVariant">@color/purple_700</item>
<item name="colorOnPrimary">@color/white</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">@color/teal_200</item>
<item name="colorSecondaryVariant">@color/teal_700</item>
<item name="colorOnSecondary">@color/black</item>
<!-- Status bar color. -->
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
<!-- Customize your theme here. -->
</style>
<style name="Theme.Platypush.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="Theme.Platypush.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="Theme.Platypush.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
</resources>

View File

@ -1,121 +0,0 @@
html, body {
width: 100%;
height: 100%;
margin: 0;
}
#app {
width: 100%;
height: 100%;
background: #e0eae8;
font-size: 20px;
display: flex;
justify-content: center;
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
color: #2c3e50;
}
.services {
width: 50%;
height: max-content;
min-width: 15em;
max-width: 22.5em;
background: white;
margin-top: 3em;
box-shadow: 1px 1px 2px 2px #bbb;
border-radius: 1.5em;
}
.no-items {
text-align: center;
padding: 2em 1em;
}
.service {
padding: 1em .5em;
border-bottom: 1px solid #ccc;
cursor: pointer;
}
.service:first-child {
border-radius: 1.5em 1.5em 0 0;
}
.service:last-child {
border-radius: 0 0 1.5em 1.5em;
}
.service:hover {
background: #bef6da;
}
.name {
font-weight: bold;
}
.add-btn {
width: 2.5em;
height: 2.5em;
background: url('../icon/plus.svg');
position: fixed;
bottom: 1em;
right: 1em;
cursor: pointer;
}
.add-btn:hover {
opacity: .75;
}
.add-modal-container {
width: 100%;
height: 100%;
position: fixed;
display: flex;
justify-content: center;
z-index: 2;
}
.add-modal-background {
width: 100%;
height: 100%;
background: black;
position: absolute;
opacity: .87;
}
.add-modal {
width: 90%;
height: max-content;
max-width: 22.5em;
background: #f0f0f0;
display: flex;
flex-direction: column;
margin-top: 3em;
padding: 1em;
border-radius: 1em;
z-index: 3;
}
.add-modal .header {
display: flex;
align-items: center;
justify-content: center;
padding-bottom: .5em;
}
.add-modal form,
.add-modal form label {
width: 100%;
}
.add-modal form input[type=text],
.add-modal form input[type=number] {
width: 95%;
}
.add-modal form input[type=submit] {
margin-top: .5em;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.3 KiB

File diff suppressed because one or more lines are too long

26
build.gradle Normal file
View File

@ -0,0 +1,26 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = "1.3.72"
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:4.1.3"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

View File

@ -0,0 +1,3 @@
- App migrated to a native Kotlin+webview implementation instead of the AndroidJS build pipeline
- Improved speed and stability of services search
- Added support for preferrer/memorized hosts and services

21
gradle.properties Normal file
View File

@ -0,0 +1,21 @@
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app"s APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official

BIN
gradle/wrapper/gradle-wrapper.jar vendored Normal file

Binary file not shown.

View File

@ -0,0 +1,6 @@
#Tue Apr 20 00:07:38 CEST 2021
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip

172
gradlew vendored Executable file
View File

@ -0,0 +1,172 @@
#!/usr/bin/env sh
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi
exec "$JAVACMD" "$@"

84
gradlew.bat vendored Normal file
View File

@ -0,0 +1,84 @@
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

21
main.js
View File

@ -1,21 +0,0 @@
const back = require('androidjs').back;
const bonjour = require('bonjour')();
const services = {}
// Zeroconf/Bonjour service
function discoverServices() {
bonjour.find({type: 'platypush-http'}, (service) => {
services[service.fqdn] = service;
back.send('services', service);
});
}
back.on('get-services', () => {
for (const service of Object.values(services)) {
back.send('services', service);
}
})
discoverServices()

501
package-lock.json generated
View File

@ -1,501 +0,0 @@
{
"name": "platypush",
"version": "1.0.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"Buffer": {
"version": "0.0.0",
"resolved": "https://registry.npmjs.org/Buffer/-/Buffer-0.0.0.tgz",
"integrity": "sha1-gs+OmGohCf9tHW8cQ25H0HEnrqQ="
},
"accepts": {
"version": "1.3.7",
"resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz",
"integrity": "sha512-Il80Qs2WjYlJIBNzNkK6KYqlVMTbZLXgHx2oT0pU/fjRHyEp+PEfEPY0R3WCwAGVOtauxh1hOxNgIf5bv7dQpA==",
"requires": {
"mime-types": "~2.1.24",
"negotiator": "0.6.2"
}
},
"after": {
"version": "0.8.2",
"resolved": "https://registry.npmjs.org/after/-/after-0.8.2.tgz",
"integrity": "sha1-/ts5T58OAqqXaOcCvaI7UF+ufh8="
},
"androidjs": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/androidjs/-/androidjs-2.0.2.tgz",
"integrity": "sha512-buHZBhz7A6Mv3NaI9wJTSS79feI9/spj7kbZWYvh7iOq9s1EyP+Ve1T4KM27P112aYQXj0t938bBFZUva4XaKA==",
"requires": {
"Buffer": "0.0.0",
"socket.io": "^2.2.0",
"socket.io-client": "^2.2.0"
}
},
"array-flatten": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-2.1.2.tgz",
"integrity": "sha512-hNfzcOV8W4NdualtqBFPyVO+54DSJuZGY9qT4pRroB6S9e3iiido2ISIC5h9R2sPJ8H3FHCIiEnsv1lPXO3KtQ=="
},
"arraybuffer.slice": {
"version": "0.0.7",
"resolved": "https://registry.npmjs.org/arraybuffer.slice/-/arraybuffer.slice-0.0.7.tgz",
"integrity": "sha512-wGUIVQXuehL5TCqQun8OW81jGzAWycqzFF8lFp+GOM5BXLYj3bKNsYC4daB7n6XjCqxQA/qgTJ+8ANR3acjrog=="
},
"async-limiter": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.1.tgz",
"integrity": "sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ=="
},
"backo2": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/backo2/-/backo2-1.0.2.tgz",
"integrity": "sha1-MasayLEpNjRj41s+u2n038+6eUc="
},
"base64-arraybuffer": {
"version": "0.1.5",
"resolved": "https://registry.npmjs.org/base64-arraybuffer/-/base64-arraybuffer-0.1.5.tgz",
"integrity": "sha1-c5JncZI7Whl0etZmqlzUv5xunOg="
},
"base64id": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/base64id/-/base64id-2.0.0.tgz",
"integrity": "sha512-lGe34o6EHj9y3Kts9R4ZYs/Gr+6N7MCaMlIFA3F1R2O5/m7K06AxfSeO5530PEERE6/WyEg3lsuyw4GHlPZHog=="
},
"better-assert": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/better-assert/-/better-assert-1.0.2.tgz",
"integrity": "sha1-QIZrnhueC1W0gYlDEeaPr/rrxSI=",
"requires": {
"callsite": "1.0.0"
}
},
"blob": {
"version": "0.0.5",
"resolved": "https://registry.npmjs.org/blob/-/blob-0.0.5.tgz",
"integrity": "sha512-gaqbzQPqOoamawKg0LGVd7SzLgXS+JH61oWprSLH+P+abTczqJbhTR8CmJ2u9/bUYNmHTGJx/UEmn6doAvvuig=="
},
"bonjour": {
"version": "3.5.0",
"resolved": "https://registry.npmjs.org/bonjour/-/bonjour-3.5.0.tgz",
"integrity": "sha1-jokKGD2O6aI5OzhExpGkK897yfU=",
"requires": {
"array-flatten": "^2.1.0",
"deep-equal": "^1.0.1",
"dns-equal": "^1.0.0",
"dns-txt": "^2.0.2",
"multicast-dns": "^6.0.1",
"multicast-dns-service-types": "^1.1.0"
}
},
"buffer-indexof": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/buffer-indexof/-/buffer-indexof-1.1.1.tgz",
"integrity": "sha512-4/rOEg86jivtPTeOUUT61jJO1Ya1TrR/OkqCSZDyq84WJh3LuuiphBYJN+fm5xufIk4XAFcEwte/8WzC8If/1g=="
},
"call-bind": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz",
"integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==",
"requires": {
"function-bind": "^1.1.1",
"get-intrinsic": "^1.0.2"
}
},
"callsite": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/callsite/-/callsite-1.0.0.tgz",
"integrity": "sha1-KAOY5dZkvXQDi28JBRU+borxvCA="
},
"component-bind": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/component-bind/-/component-bind-1.0.0.tgz",
"integrity": "sha1-AMYIq33Nk4l8AAllGx06jh5zu9E="
},
"component-emitter": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.2.1.tgz",
"integrity": "sha1-E3kY1teCg/ffemt8WmPhQOaUJeY="
},
"component-inherit": {
"version": "0.0.3",
"resolved": "https://registry.npmjs.org/component-inherit/-/component-inherit-0.0.3.tgz",
"integrity": "sha1-ZF/ErfWLcrZJ1crmUTVhnbJv8UM="
},
"cookie": {
"version": "0.3.1",
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.3.1.tgz",
"integrity": "sha1-5+Ch+e9DtMi6klxcWpboBtFoc7s="
},
"debug": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz",
"integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==",
"requires": {
"ms": "^2.1.1"
}
},
"deep-equal": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-1.1.1.tgz",
"integrity": "sha512-yd9c5AdiqVcR+JjcwUQb9DkhJc8ngNr0MahEBGvDiJw8puWab2yZlh+nkasOnZP+EGTAP6rRp2JzJhJZzvNF8g==",
"requires": {
"is-arguments": "^1.0.4",
"is-date-object": "^1.0.1",
"is-regex": "^1.0.4",
"object-is": "^1.0.1",
"object-keys": "^1.1.1",
"regexp.prototype.flags": "^1.2.0"
}
},
"define-properties": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz",
"integrity": "sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==",
"requires": {
"object-keys": "^1.0.12"
}
},
"dns-equal": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/dns-equal/-/dns-equal-1.0.0.tgz",
"integrity": "sha1-s55/HabrCnW6nBcySzR1PEfgZU0="
},
"dns-packet": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/dns-packet/-/dns-packet-1.3.1.tgz",
"integrity": "sha512-0UxfQkMhYAUaZI+xrNZOz/as5KgDU0M/fQ9b6SpkyLbk3GEswDi6PADJVaYJradtRVsRIlF1zLyOodbcTCDzUg==",
"requires": {
"ip": "^1.1.0",
"safe-buffer": "^5.0.1"
}
},
"dns-txt": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/dns-txt/-/dns-txt-2.0.2.tgz",
"integrity": "sha1-uR2Ab10nGI5Ks+fRB9iBocxGQrY=",
"requires": {
"buffer-indexof": "^1.0.0"
}
},
"engine.io": {
"version": "3.4.0",
"resolved": "https://registry.npmjs.org/engine.io/-/engine.io-3.4.0.tgz",
"integrity": "sha512-XCyYVWzcHnK5cMz7G4VTu2W7zJS7SM1QkcelghyIk/FmobWBtXE7fwhBusEKvCSqc3bMh8fNFMlUkCKTFRxH2w==",
"requires": {
"accepts": "~1.3.4",
"base64id": "2.0.0",
"cookie": "0.3.1",
"debug": "~4.1.0",
"engine.io-parser": "~2.2.0",
"ws": "^7.1.2"
}
},
"engine.io-client": {
"version": "3.4.0",
"resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-3.4.0.tgz",
"integrity": "sha512-a4J5QO2k99CM2a0b12IznnyQndoEvtA4UAldhGzKqnHf42I3Qs2W5SPnDvatZRcMaNZs4IevVicBPayxYt6FwA==",
"requires": {
"component-emitter": "1.2.1",
"component-inherit": "0.0.3",
"debug": "~4.1.0",
"engine.io-parser": "~2.2.0",
"has-cors": "1.1.0",
"indexof": "0.0.1",
"parseqs": "0.0.5",
"parseuri": "0.0.5",
"ws": "~6.1.0",
"xmlhttprequest-ssl": "~1.5.4",
"yeast": "0.1.2"
},
"dependencies": {
"ws": {
"version": "6.1.4",
"resolved": "https://registry.npmjs.org/ws/-/ws-6.1.4.tgz",
"integrity": "sha512-eqZfL+NE/YQc1/ZynhojeV8q+H050oR8AZ2uIev7RU10svA9ZnJUddHcOUZTJLinZ9yEfdA2kSATS2qZK5fhJA==",
"requires": {
"async-limiter": "~1.0.0"
}
}
}
},
"engine.io-parser": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-2.2.0.tgz",
"integrity": "sha512-6I3qD9iUxotsC5HEMuuGsKA0cXerGz+4uGcXQEkfBidgKf0amsjrrtwcbwK/nzpZBxclXlV7gGl9dgWvu4LF6w==",
"requires": {
"after": "0.8.2",
"arraybuffer.slice": "~0.0.7",
"base64-arraybuffer": "0.1.5",
"blob": "0.0.5",
"has-binary2": "~1.0.2"
}
},
"function-bind": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
"integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A=="
},
"get-intrinsic": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.1.1.tgz",
"integrity": "sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q==",
"requires": {
"function-bind": "^1.1.1",
"has": "^1.0.3",
"has-symbols": "^1.0.1"
}
},
"has": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz",
"integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==",
"requires": {
"function-bind": "^1.1.1"
}
},
"has-binary2": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/has-binary2/-/has-binary2-1.0.3.tgz",
"integrity": "sha512-G1LWKhDSvhGeAQ8mPVQlqNcOB2sJdwATtZKl2pDKKHfpf/rYj24lkinxf69blJbnsvtqqNU+L3SL50vzZhXOnw==",
"requires": {
"isarray": "2.0.1"
}
},
"has-cors": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/has-cors/-/has-cors-1.1.0.tgz",
"integrity": "sha1-XkdHk/fqmEPRu5nCPu9J/xJv/zk="
},
"has-symbols": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.1.tgz",
"integrity": "sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg=="
},
"indexof": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/indexof/-/indexof-0.0.1.tgz",
"integrity": "sha1-gtwzbSMrkGIXnQWrMpOmYFn9Q10="
},
"ip": {
"version": "1.1.5",
"resolved": "https://registry.npmjs.org/ip/-/ip-1.1.5.tgz",
"integrity": "sha1-vd7XARQpCCjAoDnnLvJfWq7ENUo="
},
"is-arguments": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/is-arguments/-/is-arguments-1.1.0.tgz",
"integrity": "sha512-1Ij4lOMPl/xB5kBDn7I+b2ttPMKa8szhEIrXDuXQD/oe3HJLTLhqhgGspwgyGd6MOywBUqVvYicF72lkgDnIHg==",
"requires": {
"call-bind": "^1.0.0"
}
},
"is-date-object": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.2.tgz",
"integrity": "sha512-USlDT524woQ08aoZFzh3/Z6ch9Y/EWXEHQ/AaRN0SkKq4t2Jw2R2339tSXmwuVoY7LLlBCbOIlx2myP/L5zk0g=="
},
"is-regex": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.2.tgz",
"integrity": "sha512-axvdhb5pdhEVThqJzYXwMlVuZwC+FF2DpcOhTS+y/8jVq4trxyPgfcwIxIKiyeuLlSQYKkmUaPQJ8ZE4yNKXDg==",
"requires": {
"call-bind": "^1.0.2",
"has-symbols": "^1.0.1"
}
},
"isarray": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.1.tgz",
"integrity": "sha1-o32U7ZzaLVmGXJ92/llu4fM4dB4="
},
"mime-db": {
"version": "1.43.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.43.0.tgz",
"integrity": "sha512-+5dsGEEovYbT8UY9yD7eE4XTc4UwJ1jBYlgaQQF38ENsKR3wj/8q8RFZrF9WIZpB2V1ArTVFUva8sAul1NzRzQ=="
},
"mime-types": {
"version": "2.1.26",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.26.tgz",
"integrity": "sha512-01paPWYgLrkqAyrlDorC1uDwl2p3qZT7yl806vW7DvDoxwXi46jsjFbg+WdwotBIk6/MbEhO/dh5aZ5sNj/dWQ==",
"requires": {
"mime-db": "1.43.0"
}
},
"ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
},
"multicast-dns": {
"version": "6.2.3",
"resolved": "https://registry.npmjs.org/multicast-dns/-/multicast-dns-6.2.3.tgz",
"integrity": "sha512-ji6J5enbMyGRHIAkAOu3WdV8nggqviKCEKtXcOqfphZZtQrmHKycfynJ2V7eVPUA4NhJ6V7Wf4TmGbTwKE9B6g==",
"requires": {
"dns-packet": "^1.3.1",
"thunky": "^1.0.2"
}
},
"multicast-dns-service-types": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/multicast-dns-service-types/-/multicast-dns-service-types-1.1.0.tgz",
"integrity": "sha1-iZ8R2WhuXgXLkbNdXw5jt3PPyQE="
},
"negotiator": {
"version": "0.6.2",
"resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz",
"integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw=="
},
"object-component": {
"version": "0.0.3",
"resolved": "https://registry.npmjs.org/object-component/-/object-component-0.0.3.tgz",
"integrity": "sha1-8MaapQ78lbhmwYb0AKM3acsvEpE="
},
"object-is": {
"version": "1.1.5",
"resolved": "https://registry.npmjs.org/object-is/-/object-is-1.1.5.tgz",
"integrity": "sha512-3cyDsyHgtmi7I7DfSSI2LDp6SK2lwvtbg0p0R1e0RvTqF5ceGx+K2dfSjm1bKDMVCFEDAQvy+o8c6a7VujOddw==",
"requires": {
"call-bind": "^1.0.2",
"define-properties": "^1.1.3"
}
},
"object-keys": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz",
"integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA=="
},
"parseqs": {
"version": "0.0.5",
"resolved": "https://registry.npmjs.org/parseqs/-/parseqs-0.0.5.tgz",
"integrity": "sha1-1SCKNzjkZ2bikbouoXNoSSGouJ0=",
"requires": {
"better-assert": "~1.0.0"
}
},
"parseuri": {
"version": "0.0.5",
"resolved": "https://registry.npmjs.org/parseuri/-/parseuri-0.0.5.tgz",
"integrity": "sha1-gCBKUNTbt3m/3G6+J3jZDkvOMgo=",
"requires": {
"better-assert": "~1.0.0"
}
},
"regexp.prototype.flags": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.3.1.tgz",
"integrity": "sha512-JiBdRBq91WlY7uRJ0ds7R+dU02i6LKi8r3BuQhNXn+kmeLN+EfHhfjqMRis1zJxnlu88hq/4dx0P2OP3APRTOA==",
"requires": {
"call-bind": "^1.0.2",
"define-properties": "^1.1.3"
}
},
"safe-buffer": {
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
"integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ=="
},
"socket.io": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/socket.io/-/socket.io-2.3.0.tgz",
"integrity": "sha512-2A892lrj0GcgR/9Qk81EaY2gYhCBxurV0PfmmESO6p27QPrUK1J3zdns+5QPqvUYK2q657nSj0guoIil9+7eFg==",
"requires": {
"debug": "~4.1.0",
"engine.io": "~3.4.0",
"has-binary2": "~1.0.2",
"socket.io-adapter": "~1.1.0",
"socket.io-client": "2.3.0",
"socket.io-parser": "~3.4.0"
}
},
"socket.io-adapter": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/socket.io-adapter/-/socket.io-adapter-1.1.2.tgz",
"integrity": "sha512-WzZRUj1kUjrTIrUKpZLEzFZ1OLj5FwLlAFQs9kuZJzJi5DKdU7FsWc36SNmA8iDOtwBQyT8FkrriRM8vXLYz8g=="
},
"socket.io-client": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/socket.io-client/-/socket.io-client-2.3.0.tgz",
"integrity": "sha512-cEQQf24gET3rfhxZ2jJ5xzAOo/xhZwK+mOqtGRg5IowZsMgwvHwnf/mCRapAAkadhM26y+iydgwsXGObBB5ZdA==",
"requires": {
"backo2": "1.0.2",
"base64-arraybuffer": "0.1.5",
"component-bind": "1.0.0",
"component-emitter": "1.2.1",
"debug": "~4.1.0",
"engine.io-client": "~3.4.0",
"has-binary2": "~1.0.2",
"has-cors": "1.1.0",
"indexof": "0.0.1",
"object-component": "0.0.3",
"parseqs": "0.0.5",
"parseuri": "0.0.5",
"socket.io-parser": "~3.3.0",
"to-array": "0.1.4"
},
"dependencies": {
"ms": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
},
"socket.io-parser": {
"version": "3.3.0",
"resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-3.3.0.tgz",
"integrity": "sha512-hczmV6bDgdaEbVqhAeVMM/jfUfzuEZHsQg6eOmLgJht6G3mPKMxYm75w2+qhAQZ+4X+1+ATZ+QFKeOZD5riHng==",
"requires": {
"component-emitter": "1.2.1",
"debug": "~3.1.0",
"isarray": "2.0.1"
},
"dependencies": {
"debug": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz",
"integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==",
"requires": {
"ms": "2.0.0"
}
}
}
}
}
},
"socket.io-parser": {
"version": "3.4.0",
"resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-3.4.0.tgz",
"integrity": "sha512-/G/VOI+3DBp0+DJKW4KesGnQkQPFmUCbA/oO2QGT6CWxU7hLGWqU3tyuzeSK/dqcyeHsQg1vTe9jiZI8GU9SCQ==",
"requires": {
"component-emitter": "1.2.1",
"debug": "~4.1.0",
"isarray": "2.0.1"
}
},
"thunky": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/thunky/-/thunky-1.1.0.tgz",
"integrity": "sha512-eHY7nBftgThBqOyHGVN+l8gF0BucP09fMo0oO/Lb0w1OF80dJv+lDVpXG60WMQvkcxAkNybKsrEIE3ZtKGmPrA=="
},
"to-array": {
"version": "0.1.4",
"resolved": "https://registry.npmjs.org/to-array/-/to-array-0.1.4.tgz",
"integrity": "sha1-F+bBH3PdTz10zaek/zI46a2b+JA="
},
"ws": {
"version": "7.2.1",
"resolved": "https://registry.npmjs.org/ws/-/ws-7.2.1.tgz",
"integrity": "sha512-sucePNSafamSKoOqoNfBd8V0StlkzJKL2ZAhGQinCfNQ+oacw+Pk7lcdAElecBF2VkLNZRiIb5Oi1Q5lVUVt2A=="
},
"xmlhttprequest-ssl": {
"version": "1.5.5",
"resolved": "https://registry.npmjs.org/xmlhttprequest-ssl/-/xmlhttprequest-ssl-1.5.5.tgz",
"integrity": "sha1-wodrBhaKrcQOV9l+gRkayPQ5iz4="
},
"yeast": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/yeast/-/yeast-0.1.2.tgz",
"integrity": "sha1-AI4G2AlDIMNy28L47XagymyKxBk="
}
}
}

View File

@ -1,30 +0,0 @@
{
"version": "1.0.0",
"version-code": 1000032,
"name": "platypush",
"app-name": "Platypush",
"package-name": "tech.platypush.platypush",
"project-type": "webview",
"icon": "./assets/icon/icon.png",
"dist-path": "./dist",
"permission": [
"android.permission.INTERNET"
],
"description": "Manage your Platypush instances and smart devices from your mobile",
"main": "main.js",
"scripts": {
"start:dev": "node .",
"build": "androidjs build",
"build:release": "androidjs build --release"
},
"author": "Fabio Manganiello",
"license": "ISC",
"dependencies": {
"androidjs": "^2.0.2",
"bonjour": "^3.5.0"
},
"project-name": "platypush",
"theme": {
"fullScreen": true
}
}

2
settings.gradle Normal file
View File

@ -0,0 +1,2 @@
include ':app'
rootProject.name = "Platypush"

View File

@ -1,96 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Platypush</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script type="text/javascript" src="../assets/js/vue.min.js"></script>
<script type="text/javascript" src="../assets/js/androidjs.js"></script>
<link rel="stylesheet" href="../assets/css/style.css">
</head>
<body>
<div id="app">
<div class="services">
<div class="no-items" v-if="loading || !Object.keys(services).length">
<div class="loading" v-if="loading">Loading...</div>
<div class="empty" v-else>No Platypush web services found on the network</div>
</div>
<div class="service" v-for="service in services" :key="service.fqdn" @click="onClick(service)">
<span class="name" v-text="service.name"></span>
on
<span class="address" v-text="service.addresses[0]"></span>:<span class="port" v-text="service.port"></span>
</div>
</div>
<div class="add-modal-container" @click="addModalVisible = false" v-if="addModalVisible">
<div class="add-modal-background"></div>
<div class="add-modal" @click="$event.stopPropagation()">
<div class="header">
Connect to a Platypush web service
</div>
<div class="body">
<form @submit.prevent="onConnect">
<label>
<input type="text" placeholder="IP or hostname" v-model="addModalHost">
</label>
<label>
<input type="number" placeholder="Port" v-model="addModalPort">
</label>
<input type="submit" value="Connect">
</form>
</div>
</div>
</div>
<div class="add-btn" @click="addModalVisible = true"></div>
</div>
<script>
new Vue({
el: '#app',
data: function() {
return {
loading: false,
services: {},
addModalVisible: false,
addModalHost: undefined,
addModalPort: 8008,
}
},
methods: {
refresh: function() {
front.send('get-services')
},
onClick: function(service) {
window.location.href = `http://${service.addresses[0]}:${service.port}/`
},
onConnect: function() {
window.location.href = `http://${this.addModalHost}:${this.addModalPort}/`
},
},
mounted: function() {
const self = this
this.loading = true
front.on('services', function(service) {
self.loading = false
Vue.set(self.services, service.fqdn, service)
})
this.refresh()
window.setInterval(this.refresh, 5000)
window.setTimeout(() => self.loading = false, 10000)
}
})
</script>
</body>
</html>