Skip to content

Commit

Permalink
Widget
Browse files Browse the repository at this point in the history
  • Loading branch information
l-korous committed Mar 25, 2017
1 parent 245095c commit 8f3c6d1
Show file tree
Hide file tree
Showing 28 changed files with 542 additions and 41 deletions.
11 changes: 11 additions & 0 deletions build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"android": {
"release": {
"keystore": "",
"storePassword": "",
"alias": "",
"password" : "",
"keystoreType": ""
}
}
}
69 changes: 39 additions & 30 deletions config.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version='1.0' encoding='utf-8'?>
<?xml version='1.0' encoding='utf-8'?>
<widget id="org.apache.cordova.SCHEDULOGY" version="2.6.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>Schedulogy</name>
<description>
Expand All @@ -7,33 +7,42 @@
<author email="info@schedulogy.com" href="https://www.schedulogy.com">
SCHEDULOGY
</author>
<icon src="icons/icon.png"/>
<icon src="icons/icon36.png" platform="android" density="ldpi"/>
<icon src="icons/icon48.png" platform="android" density="mdpi"/>
<icon src="icons/icon72.png" platform="android" density="hdpi"/>
<icon src="icons/icon96.png" platform="android" density="xhdpi"/>
<icon src="icons/icon144.png" platform="android" density="xxhdpi"/>
<icon src="icons/icon.png" platform="android" density="xxxhdpi"/>
<content src="index.html" />
<plugin name="cordova-plugin-whitelist" spec="1" />
<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<preference name="AndroidLaunchMode" value="singleTask"/>
<allow-intent href="geo:*" />
<platform name="android">
<allow-intent href="market:*" />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
<engine name="android" spec="~5.2.2" />
<feature name="InAppBrowser">
<param name="ios-package" value="CDVInAppBrowser" />
<content src="index.html" />
<access origin="*" />
<allow-intent href="http://schedulogy/*" />
<icon src="icons/icon.png"/>
<platform name="android">
<icon src="icons/icon36.png" density="ldpi"/>
<icon src="icons/icon48.png" density="mdpi"/>
<icon src="icons/icon72.png" density="hdpi"/>
<icon src="icons/icon96.png" density="xhdpi"/>
<icon src="icons/icon144.png" density="xxhdpi"/>
<icon src="icons/icon.png" density="xxxhdpi"/>

<splash src="icons/iconsplash.png" density="port-ldpi"/>
<splash src="icons/iconsplash.png" density="port-mdpi"/>
<splash src="icons/iconsplash.png" density="port-hdpi"/>
<splash src="icons/iconsplash.png" density="port-xhdpi"/>
<splash src="icons/iconsplash.png" density="port-xhdpi"/>
<splash src="icons/iconsplash.png" density="port-xxxhdpi"/>
<splash src="icons/iconsplash.png" density="land-ldpi"/>
<splash src="icons/iconsplash.png" density="land-mdpi"/>
<splash src="icons/iconsplash.png" density="land-hdpi"/>
<splash src="icons/iconsplash.png" density="land-xhdpi"/>
<splash src="icons/iconsplash.png" density="land-xhdpi"/>
<splash src="icons/iconsplash.png" density="land-xxxhdpi"/>
</platform>
<preference name="SplashScreen" value="screen" />
<preference name="SplashMaintainAspectRatio" value="true" />
<preference name="ShowSplashScreenSpinner" value="false"/>
<preference name="SplashScreenDelay" value="5000" />
<preference name="KeepRunning" value="True" />
<preference name="ShowTitle" value="True" />
<engine name="android" spec="~5.2.2" />
<plugin name="cordova-plugin-whitelist" spec="1" />
<plugin name="cordova-plugin-ace" spec="https://github.com/adnathan/ace.git" />
<vs:plugin name="cordova-plugin-ace" version="0.0.4" src="https://github.com/adnathan/ace.git" xmlns:vs="http://schemas.microsoft.com/appx/2014/htmlapps" />
<feature name="InAppBrowser">
<param name="android-package" value="org.apache.cordova.inappbrowser.InAppBrowser" />
</feature>
</widget>
</feature>
</widget>
Binary file added icons/iconsplash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 30 additions & 0 deletions merges/android/scripts/android2.3-jscompat.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Polyfill for Function.prototype.bind() support on Android 2.3
(function () {
if (!Function.prototype.bind) {
Function.prototype.bind = function (thisValue) {
if (typeof this !== "function") {
throw new TypeError(this + " cannot be bound as it is not a function");
}

// bind() also permits prepending arguments to the call
var preArgs = Array.prototype.slice.call(arguments, 1);

// The actual function to bind the "this" value and arguments to
var functionToBind = this;
var noOpFunction = function () { };

// The "this" argument to use
var thisArg = this instanceof noOpFunction && thisValue ? this : thisValue;

// The resulting bound function
var boundFunction = function () {
return functionToBind.apply(thisArg, preArgs.concat(Array.prototype.slice.call(arguments)));
};

noOpFunction.prototype = this.prototype;
boundFunction.prototype = new noOpFunction();

return boundFunction;
};
}
}());
10 changes: 10 additions & 0 deletions merges/android/scripts/platformOverrides.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
(function () {
// Append the bind() polyfill
var scriptElem = document.createElement('script');
scriptElem.setAttribute('src', 'scripts/android2.3-jscompat.js');
if (document.body) {
document.body.appendChild(scriptElem);
} else {
document.head.appendChild(scriptElem);
}
}());
10 changes: 10 additions & 0 deletions merges/windows/scripts/platformOverrides.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
(function () {
// Append the safeHTML polyfill
var scriptElem = document.createElement('script');
scriptElem.setAttribute('src', 'scripts/winstore-jscompat.js');
if (document.body) {
document.body.appendChild(scriptElem);
} else {
document.head.appendChild(scriptElem);
}
}());
176 changes: 176 additions & 0 deletions merges/windows/scripts/winstore-jscompat.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0.
// See http://www.apache.org/licenses/LICENSE-2.0.html.
// JavaScript Dynamic Content shim for Windows Store apps
(function () {

if (window.MSApp && MSApp.execUnsafeLocalFunction) {

// Some nodes will have an "attributes" property which shadows the Node.prototype.attributes property
// and means we don't actually see the attributes of the Node (interestingly the VS debug console
// appears to suffer from the same issue).
//
var Element_setAttribute = Object.getOwnPropertyDescriptor(Element.prototype, "setAttribute").value;
var Element_removeAttribute = Object.getOwnPropertyDescriptor(Element.prototype, "removeAttribute").value;
var HTMLElement_insertAdjacentHTMLPropertyDescriptor = Object.getOwnPropertyDescriptor(HTMLElement.prototype, "insertAdjacentHTML");
var Node_get_attributes = Object.getOwnPropertyDescriptor(Node.prototype, "attributes").get;
var Node_get_childNodes = Object.getOwnPropertyDescriptor(Node.prototype, "childNodes").get;
var detectionDiv = document.createElement("div");

function getAttributes(element) {
return Node_get_attributes.call(element);
}

function setAttribute(element, attribute, value) {
try {
Element_setAttribute.call(element, attribute, value);
} catch (e) {
// ignore
}
}

function removeAttribute(element, attribute) {
Element_removeAttribute.call(element, attribute);
}

function childNodes(element) {
return Node_get_childNodes.call(element);
}

function empty(element) {
while (element.childNodes.length) {
element.removeChild(element.lastChild);
}
}

function insertAdjacentHTML(element, position, html) {
HTMLElement_insertAdjacentHTMLPropertyDescriptor.value.call(element, position, html);
}

function inUnsafeMode() {
var isUnsafe = true;
try {
detectionDiv.innerHTML = "<test/>";
}
catch (ex) {
isUnsafe = false;
}

return isUnsafe;
}

function cleanse(html, targetElement) {
var cleaner = document.implementation.createHTMLDocument("cleaner");
empty(cleaner.documentElement);
MSApp.execUnsafeLocalFunction(function () {
insertAdjacentHTML(cleaner.documentElement, "afterbegin", html);
});

var scripts = cleaner.documentElement.querySelectorAll("script");
Array.prototype.forEach.call(scripts, function (script) {
switch (script.type.toLowerCase()) {
case "":
script.type = "text/inert";
break;
case "text/javascript":
case "text/ecmascript":
case "text/x-javascript":
case "text/jscript":
case "text/livescript":
case "text/javascript1.1":
case "text/javascript1.2":
case "text/javascript1.3":
script.type = "text/inert-" + script.type.slice("text/".length);
break;
case "application/javascript":
case "application/ecmascript":
case "application/x-javascript":
script.type = "application/inert-" + script.type.slice("application/".length);
break;

default:
break;
}
});

function cleanseAttributes(element) {
var attributes = getAttributes(element);
if (attributes && attributes.length) {
// because the attributes collection is live it is simpler to queue up the renames
var events;
for (var i = 0, len = attributes.length; i < len; i++) {
var attribute = attributes[i];
var name = attribute.name;
if ((name[0] === "o" || name[0] === "O") &&
(name[1] === "n" || name[1] === "N")) {
events = events || [];
events.push({ name: attribute.name, value: attribute.value });
}
}
if (events) {
for (var i = 0, len = events.length; i < len; i++) {
var attribute = events[i];
removeAttribute(element, attribute.name);
setAttribute(element, "x-" + attribute.name, attribute.value);
}
}
}
var children = childNodes(element);
for (var i = 0, len = children.length; i < len; i++) {
cleanseAttributes(children[i]);
}
}
cleanseAttributes(cleaner.documentElement);

var cleanedNodes = [];

if (targetElement.tagName === 'HTML') {
cleanedNodes = Array.prototype.slice.call(document.adoptNode(cleaner.documentElement).childNodes);
} else {
if (cleaner.head) {
cleanedNodes = cleanedNodes.concat(Array.prototype.slice.call(document.adoptNode(cleaner.head).childNodes));
}
if (cleaner.body) {
cleanedNodes = cleanedNodes.concat(Array.prototype.slice.call(document.adoptNode(cleaner.body).childNodes));
}
}

return cleanedNodes;
}

function cleansePropertySetter(property, setter) {
var propertyDescriptor = Object.getOwnPropertyDescriptor(HTMLElement.prototype, property);
var originalSetter = propertyDescriptor.set;
Object.defineProperty(HTMLElement.prototype, property, {
get: propertyDescriptor.get,
set: function (value) {
if (window.WinJS && window.WinJS._execUnsafe && inUnsafeMode()) {
originalSetter.call(this, value);
} else {
var that = this;
var nodes = cleanse(value, that);
MSApp.execUnsafeLocalFunction(function () {
setter(propertyDescriptor, that, nodes);
});
}
},
enumerable: propertyDescriptor.enumerable,
configurable: propertyDescriptor.configurable,
});
}
cleansePropertySetter("innerHTML", function (propertyDescriptor, target, elements) {
empty(target);
for (var i = 0, len = elements.length; i < len; i++) {
target.appendChild(elements[i]);
}
});
cleansePropertySetter("outerHTML", function (propertyDescriptor, target, elements) {
for (var i = 0, len = elements.length; i < len; i++) {
target.insertAdjacentElement("afterend", elements[i]);
}
target.parentNode.removeChild(target);
});

}

}());
42 changes: 42 additions & 0 deletions native/android/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="1" android:versionName="2.6.0" package="org.apache.cordova.SCHEDULOGY" xmlns:android="http://schemas.android.com/apk/res/android">
<supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<application android:hardwareAccelerated="true" android:icon="@drawable/icon" android:label="@string/app_name" android:supportsRtl="true">
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:windowSoftInputMode="adjustResize">
<intent-filter android:label="@string/launcher_name">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:label="List" android:name="org.apache.cordova.SCHEDULOGY.ListWidgetProvider">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data android:name="android.appwidget.provider" android:resource="@xml/list_widget_info" />
</receiver>

<receiver android:label="List" android:name="org.apache.cordova.SCHEDULOGY.StackWidgetProvider">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data android:name="android.appwidget.provider" android:resource="@xml/stack_widget_info" />
</receiver>

<receiver android:label="List" android:name="org.apache.cordova.SCHEDULOGY.GridWidgetProvider">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data android:name="android.appwidget.provider" android:resource="@xml/grid_widget_info" />
</receiver>

<service android:exported="false" android:name="run.ace.AppWidgetService" android:permission="android.permission.BIND_REMOTEVIEWS" />
<activity android:name="run.ace.AceActivity" xmlns:android="http://schemas.android.com/apk/res/android" />
</application>
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="22" />
</manifest>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions native/android/res/layout/grid_widget_item.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/grid_widget_item"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/grid_widget_item_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:textColor="#ffffff"
android:textSize="40px" />
</FrameLayout>
7 changes: 7 additions & 0 deletions native/android/res/layout/grid_widget_layout.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/grid_widget_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:loopViews="true" />
Loading

0 comments on commit 8f3c6d1

Please sign in to comment.