diff --git a/config.xml b/config.xml index 5114dda..d88e6ba 100644 --- a/config.xml +++ b/config.xml @@ -1,5 +1,5 @@ - + Business Mobile client for the Netsyms Business Apps. @@ -26,6 +26,10 @@ + + + + @@ -43,6 +47,10 @@ + + + + @@ -72,5 +80,8 @@ - + + + + diff --git a/nbproject/plugins.properties b/nbproject/plugins.properties index 4f68809..06e33ad 100644 --- a/nbproject/plugins.properties +++ b/nbproject/plugins.properties @@ -9,4 +9,7 @@ cordova-plugin-headercolor=https://github.com/tomloprod/cordova-plugin-headercol cordova-plugin-inappbrowser=https://github.com/apache/cordova-plugin-inappbrowser.git cordova-plugin-app-version=https://github.com/whiteoctober/cordova-plugin-app-version.git cordova-plugin-zeroconf=https://github.com/becvert/cordova-plugin-zeroconf.git -cordova-plugin-file=https://github.com/apache/cordova-plugin-file.git \ No newline at end of file +cordova-plugin-file=https://github.com/apache/cordova-plugin-file.git +cordova-plugin-local-notification=https://github.com/katzer/cordova-plugin-local-notifications.git +cordova-plugin-background-fetch=https://github.com/transistorsoft/cordova-plugin-background-fetch.git +cordova-plugin-nativestorage=https://github.com/TheCocoaProject/cordova-plugin-nativestorage.git \ No newline at end of file diff --git a/package.json b/package.json index 24605b9..a960e04 100644 --- a/package.json +++ b/package.json @@ -1,15 +1,17 @@ { "name": "com.netsyms.BusinessMobile", "displayName": "Business for Mobile", - "version": "1.6.0", + "version": "1.7.0", "description": "Mobile client for the Netsyms Business Apps.", "main": "index.html", "author": "Netsyms Technologies", "license": "MPL-2.0", "dependencies": { - "cordova-android": "^7.1.0", + "cordova-android": "^7.1.1", "cordova-plugin-add-swift-support": "^1.7.1", "cordova-plugin-app-version": "^0.1.9", + "cordova-plugin-background-fetch": "^5.4.1", + "cordova-plugin-badge": "^0.8.7", "cordova-plugin-console": "^1.1.0", "cordova-plugin-device": "^2.0.1", "cordova-plugin-dialog": "0.0.1", @@ -17,6 +19,8 @@ "cordova-plugin-file": "^6.0.1", "cordova-plugin-headercolor": "^1.0.0", "cordova-plugin-inappbrowser": "^2.0.2", + "cordova-plugin-local-notification": "^0.9.0-beta.2", + "cordova-plugin-nativestorage": "^2.3.2", "cordova-plugin-splashscreen": "^5.0.2", "cordova-plugin-statusbar": "^2.4.1", "cordova-plugin-whitelist": "^1.3.2", @@ -39,7 +43,10 @@ "cordova-plugin-device": {}, "cordova-plugin-dialogs": {}, "cordova-plugin-inappbrowser": {}, - "cordova-plugin-splashscreen": {} + "cordova-plugin-splashscreen": {}, + "cordova-plugin-nativestorage": {}, + "cordova-plugin-background-fetch": {}, + "cordova-plugin-local-notification": {} }, "platforms": [ "android" diff --git a/res/android/drawable-hdpi/ic_action_next_item.png b/res/android/drawable-hdpi/ic_action_next_item.png new file mode 100644 index 0000000..fa469d8 Binary files /dev/null and b/res/android/drawable-hdpi/ic_action_next_item.png differ diff --git a/res/android/drawable-hdpi/ic_action_previous_item.png b/res/android/drawable-hdpi/ic_action_previous_item.png new file mode 100644 index 0000000..e861ecc Binary files /dev/null and b/res/android/drawable-hdpi/ic_action_previous_item.png differ diff --git a/res/android/drawable-hdpi/ic_action_remove.png b/res/android/drawable-hdpi/ic_action_remove.png new file mode 100644 index 0000000..f889617 Binary files /dev/null and b/res/android/drawable-hdpi/ic_action_remove.png differ diff --git a/res/android/drawable-hdpi/ic_notification.png b/res/android/drawable-hdpi/ic_notification.png new file mode 100644 index 0000000..547428c Binary files /dev/null and b/res/android/drawable-hdpi/ic_notification.png differ diff --git a/res/android/drawable-land-hdpi/screen.png b/res/android/drawable-land-hdpi/screen.png new file mode 100644 index 0000000..6e43098 Binary files /dev/null and b/res/android/drawable-land-hdpi/screen.png differ diff --git a/res/android/drawable-land-ldpi/screen.png b/res/android/drawable-land-ldpi/screen.png new file mode 100644 index 0000000..277dcff Binary files /dev/null and b/res/android/drawable-land-ldpi/screen.png differ diff --git a/res/android/drawable-land-mdpi/screen.png b/res/android/drawable-land-mdpi/screen.png new file mode 100644 index 0000000..0f8bd63 Binary files /dev/null and b/res/android/drawable-land-mdpi/screen.png differ diff --git a/res/android/drawable-land-xhdpi/screen.png b/res/android/drawable-land-xhdpi/screen.png new file mode 100644 index 0000000..253d618 Binary files /dev/null and b/res/android/drawable-land-xhdpi/screen.png differ diff --git a/res/android/drawable-land-xxhdpi/screen.png b/res/android/drawable-land-xxhdpi/screen.png new file mode 100644 index 0000000..367eae0 Binary files /dev/null and b/res/android/drawable-land-xxhdpi/screen.png differ diff --git a/res/android/drawable-land-xxxhdpi/screen.png b/res/android/drawable-land-xxxhdpi/screen.png new file mode 100644 index 0000000..6fbe662 Binary files /dev/null and b/res/android/drawable-land-xxxhdpi/screen.png differ diff --git a/res/android/drawable-mdpi/ic_action_next_item.png b/res/android/drawable-mdpi/ic_action_next_item.png new file mode 100644 index 0000000..47365a3 Binary files /dev/null and b/res/android/drawable-mdpi/ic_action_next_item.png differ diff --git a/res/android/drawable-mdpi/ic_action_previous_item.png b/res/android/drawable-mdpi/ic_action_previous_item.png new file mode 100644 index 0000000..4ad2df4 Binary files /dev/null and b/res/android/drawable-mdpi/ic_action_previous_item.png differ diff --git a/res/android/drawable-mdpi/ic_action_remove.png b/res/android/drawable-mdpi/ic_action_remove.png new file mode 100644 index 0000000..e84853e Binary files /dev/null and b/res/android/drawable-mdpi/ic_action_remove.png differ diff --git a/res/android/drawable-mdpi/ic_notification.png b/res/android/drawable-mdpi/ic_notification.png new file mode 100644 index 0000000..d6378a8 Binary files /dev/null and b/res/android/drawable-mdpi/ic_notification.png differ diff --git a/res/android/drawable-port-hdpi/screen.png b/res/android/drawable-port-hdpi/screen.png new file mode 100644 index 0000000..9db5b69 Binary files /dev/null and b/res/android/drawable-port-hdpi/screen.png differ diff --git a/res/android/drawable-port-ldpi/screen.png b/res/android/drawable-port-ldpi/screen.png new file mode 100644 index 0000000..bbe499d Binary files /dev/null and b/res/android/drawable-port-ldpi/screen.png differ diff --git a/res/android/drawable-port-mdpi/screen.png b/res/android/drawable-port-mdpi/screen.png new file mode 100644 index 0000000..0309d61 Binary files /dev/null and b/res/android/drawable-port-mdpi/screen.png differ diff --git a/res/android/drawable-port-xhdpi/screen.png b/res/android/drawable-port-xhdpi/screen.png new file mode 100644 index 0000000..18f3ea9 Binary files /dev/null and b/res/android/drawable-port-xhdpi/screen.png differ diff --git a/res/android/drawable-port-xxhdpi/screen.png b/res/android/drawable-port-xxhdpi/screen.png new file mode 100644 index 0000000..9d44814 Binary files /dev/null and b/res/android/drawable-port-xxhdpi/screen.png differ diff --git a/res/android/drawable-port-xxxhdpi/screen.png b/res/android/drawable-port-xxxhdpi/screen.png new file mode 100644 index 0000000..94ae0f0 Binary files /dev/null and b/res/android/drawable-port-xxxhdpi/screen.png differ diff --git a/res/android/drawable-xhdpi/ic_action_next_item.png b/res/android/drawable-xhdpi/ic_action_next_item.png new file mode 100644 index 0000000..5f30474 Binary files /dev/null and b/res/android/drawable-xhdpi/ic_action_next_item.png differ diff --git a/res/android/drawable-xhdpi/ic_action_previous_item.png b/res/android/drawable-xhdpi/ic_action_previous_item.png new file mode 100644 index 0000000..ed8ac91 Binary files /dev/null and b/res/android/drawable-xhdpi/ic_action_previous_item.png differ diff --git a/res/android/drawable-xhdpi/ic_action_remove.png b/res/android/drawable-xhdpi/ic_action_remove.png new file mode 100644 index 0000000..4cd0458 Binary files /dev/null and b/res/android/drawable-xhdpi/ic_action_remove.png differ diff --git a/res/android/drawable-xhdpi/ic_notification.png b/res/android/drawable-xhdpi/ic_notification.png new file mode 100644 index 0000000..00b37df Binary files /dev/null and b/res/android/drawable-xhdpi/ic_notification.png differ diff --git a/res/android/drawable-xxhdpi/ic_action_next_item.png b/res/android/drawable-xxhdpi/ic_action_next_item.png new file mode 100644 index 0000000..51479d8 Binary files /dev/null and b/res/android/drawable-xxhdpi/ic_action_next_item.png differ diff --git a/res/android/drawable-xxhdpi/ic_action_previous_item.png b/res/android/drawable-xxhdpi/ic_action_previous_item.png new file mode 100644 index 0000000..bc8ff12 Binary files /dev/null and b/res/android/drawable-xxhdpi/ic_action_previous_item.png differ diff --git a/res/android/drawable-xxhdpi/ic_action_remove.png b/res/android/drawable-xxhdpi/ic_action_remove.png new file mode 100644 index 0000000..331c545 Binary files /dev/null and b/res/android/drawable-xxhdpi/ic_action_remove.png differ diff --git a/res/android/drawable-xxhdpi/ic_notification.png b/res/android/drawable-xxhdpi/ic_notification.png new file mode 100644 index 0000000..28ecc5e Binary files /dev/null and b/res/android/drawable-xxhdpi/ic_notification.png differ diff --git a/res/android/values/strings.xml b/res/android/values/strings.xml new file mode 100644 index 0000000..c1bccc3 --- /dev/null +++ b/res/android/values/strings.xml @@ -0,0 +1,6 @@ + + + Business + @string/app_name + @string/launcher_name + diff --git a/www/js/accounts.js b/www/js/accounts.js index c4c3831..41e0bdb 100644 --- a/www/js/accounts.js +++ b/www/js/accounts.js @@ -30,6 +30,7 @@ function getaccounts() { function saveaccounts(accounts) { localStorage.setItem("accounts", JSON.stringify(accounts)); + NativeStorage.setItem("accounts", JSON.stringify(accounts)); } /** diff --git a/www/js/app.js b/www/js/app.js index da47127..1fe914b 100644 --- a/www/js/app.js +++ b/www/js/app.js @@ -2,6 +2,8 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +var shown_notifications = []; + /** * Switches the app to the given screen. * @param {String} screenname The name of the screen to show. @@ -198,6 +200,42 @@ function restartApplication() { }, 3000); } +function displayNotifications(callback) { + $.post(localStorage.getItem("syncurl"), { + username: localStorage.getItem("username"), + key: localStorage.getItem("key"), + password: localStorage.getItem("password"), + action: "checknotifications" + }, function (data) { + if (data.status === 'OK') { + for (var i = 0; i < data.notifications.length; i++) { + var n = data.notifications[i]; + if (n.seen || shown_notifications.includes(n.id)) { + continue; + } + + cordova.plugins.notification.local.schedule([{ + title: n.title, + text: n.content, + actions: [ + {id: 'mark_read', title: "Mark Read"} + ], + id: n.id + }]); + + shown_notifications.push(n.id); + } + } + if (typeof callback == 'function') { + callback(); + } + }, "json").fail(function () { + if (typeof callback == 'function') { + callback(); + } + }); +} + // Handle back button to close things document.addEventListener("backbutton", function (event) { if (isconfigvalid()) { @@ -225,6 +263,20 @@ document.addEventListener("deviceready", function () { StatusBar.backgroundColorByHexString("#1976d2"); } + cordova.plugins.notification.local.setDefaults({ + led: {color: '#2196F3'}, + smallIcon: "res://ic_notification" + }); + cordova.plugins.notification.local.on("mark_read", function (notification) { + $.post(localStorage.getItem("syncurl"), { + username: localStorage.getItem("username"), + key: localStorage.getItem("key"), + password: localStorage.getItem("password"), + action: "readnotification", + id: notification.id + }); + }); + // Enable/disable jQuery animations depending on user preference $.fx.off = !(localStorage.getItem("animations") === null || localStorage.getItem("animations") === "true"); @@ -236,6 +288,32 @@ document.addEventListener("deviceready", function () { if (isconfigvalid()) { getuserinfo(function () { openscreen("home"); + + setInterval(displayNotifications, 30 * 1000); + if (typeof cordova.plugins.notification.local.launchDetails === 'undefined') { + displayNotifications(); + } + + var BackgroundFetch = window.BackgroundFetch; + + // Your background-fetch handler. + var fetchCallback = function () { + console.log('[js] BackgroundFetch event received'); + displayNotifications(function () { + BackgroundFetch.finish(); + }); + }; + + var failureCallback = function (error) { + console.log('- BackgroundFetch failed', error); + }; + + BackgroundFetch.configure(fetchCallback, failureCallback, { + minimumFetchInterval: 1, + stopOnTerminate: false, + startOnBoot: true, + forceReload: true + }); }); } else { openscreen("setup1");