From: qiaowei Date: Mon, 2 Dec 2019 08:13:33 +0000 (+0800) Subject: 修改屏幕亮度和图标 X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=08e9068a6f2a8221ae9a06ce0f35afa2e30ee1c1;p=dali_platform%2Fmobile.git 修改屏幕亮度和图标 --- diff --git a/package-lock.json b/package-lock.json index ad4f7f6..78076a9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,5 +1,5 @@ { - "name": "com.supwisdom.dlapp", + "name": "com.dalicitycard.app", "version": "1.0.3", "lockfileVersion": 1, "requires": true, @@ -274,6 +274,11 @@ "resolved": "https://registry.npmjs.org/cordova-plugin-app-version/-/cordova-plugin-app-version-0.1.9.tgz", "integrity": "sha1-nbBgeGMzenEEiTAuX1CpBPFEm9s=" }, + "cordova-plugin-brightness": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/cordova-plugin-brightness/-/cordova-plugin-brightness-0.2.0.tgz", + "integrity": "sha512-ujW4v58jArPxPf8CjEppl9hM2/9jep1+nflzAOGoT4yc5UIuLja6j6+wxK2fv6+UWqVEWEKB3JkfnijVUl6HjQ==" + }, "cordova-plugin-camera": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/cordova-plugin-camera/-/cordova-plugin-camera-4.0.3.tgz", diff --git a/package.json b/package.json index 323d848..7f29550 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "cordova-ios": "^5.0.1", "cordova-plugin-advanced-http": "^2.1.1", "cordova-plugin-app-version": "^0.1.9", + "cordova-plugin-brightness": "^0.2.0", "cordova-plugin-camera": "^4.0.3", "cordova-plugin-device": "^2.0.2", "cordova-plugin-disable-ios11-statusbar": "^1.0.0", @@ -54,7 +55,8 @@ "CHANNEL": "developer-default" }, "cordova-plugin-app-version": {}, - "cordova-plugin-wkwebview-engine": {} + "cordova-plugin-wkwebview-engine": {}, + "cordova-plugin-brightness": {} }, "platforms": [ "android", diff --git a/platforms/android/android.json b/platforms/android/android.json index 476c50e..2b20a7d 100644 --- a/platforms/android/android.json +++ b/platforms/android/android.json @@ -59,6 +59,10 @@ { "xml": "", "count": 1 + }, + { + "xml": "", + "count": 1 } ] } @@ -307,6 +311,9 @@ }, "cordova-plugin-wkwebview-engine": { "PACKAGE_NAME": "com.dalicitycard.app" + }, + "cordova-plugin-brightness": { + "PACKAGE_NAME": "com.dalicitycard.app" } }, "dependent_plugins": {}, @@ -646,6 +653,14 @@ "clobbers": [ "cordova.getAppVersion" ] + }, + { + "id": "cordova-plugin-brightness.Brightness", + "file": "plugins/cordova-plugin-brightness/www/brightness.js", + "pluginId": "cordova-plugin-brightness", + "clobbers": [ + "cordova.plugins.brightness" + ] } ], "plugin_metadata": { @@ -665,6 +680,7 @@ "cordova-plugin-jcore": "1.3.0", "jpush-phonegap-plugin": "3.7.2", "cordova-plugin-app-version": "0.1.9", - "cordova-plugin-wkwebview-engine": "1.2.1" + "cordova-plugin-wkwebview-engine": "1.2.1", + "cordova-plugin-brightness": "0.1.5" } } diff --git a/platforms/android/app/build.gradle b/platforms/android/app/build.gradle index 5b518d8..41524d3 100644 --- a/platforms/android/app/build.gradle +++ b/platforms/android/app/build.gradle @@ -268,9 +268,9 @@ android { dependencies { implementation fileTree(include: '*.jar', dir: 'libs') // SUB-PROJECT DEPENDENCIES START - implementation project(path: ':CordovaLib') - implementation 'com.squareup.okhttp3:okhttp-urlconnection:3.10.0' - implementation 'com.android.support:support-v4:24.1.1+' + implementation(project(path: ":CordovaLib")) + implementation "com.squareup.okhttp3:okhttp-urlconnection:3.10.0" + implementation "com.android.support:support-v4:24.1.1+" // SUB-PROJECT DEPENDENCIES END } diff --git a/platforms/android/app/release/app-release.apk b/platforms/android/app/release/app-release.apk index 64af5de..be551b3 100644 Binary files a/platforms/android/app/release/app-release.apk and b/platforms/android/app/release/app-release.apk differ diff --git a/platforms/android/app/src/main/AndroidManifest.xml b/platforms/android/app/src/main/AndroidManifest.xml index 9b5f879..93b3137 100644 --- a/platforms/android/app/src/main/AndroidManifest.xml +++ b/platforms/android/app/src/main/AndroidManifest.xml @@ -1,6 +1,5 @@ - + @@ -58,8 +57,7 @@ - + @@ -105,4 +103,5 @@ + diff --git a/platforms/android/app/src/main/assets/www/cordova_plugins.js b/platforms/android/app/src/main/assets/www/cordova_plugins.js index ee6832d..951ded8 100644 --- a/platforms/android/app/src/main/assets/www/cordova_plugins.js +++ b/platforms/android/app/src/main/assets/www/cordova_plugins.js @@ -335,6 +335,14 @@ cordova.define('cordova/plugin_list', function(require, exports, module) { "clobbers": [ "cordova.getAppVersion" ] + }, + { + "id": "cordova-plugin-brightness.Brightness", + "file": "plugins/cordova-plugin-brightness/www/brightness.js", + "pluginId": "cordova-plugin-brightness", + "clobbers": [ + "cordova.plugins.brightness" + ] } ]; module.exports.metadata = { @@ -354,6 +362,7 @@ cordova.define('cordova/plugin_list', function(require, exports, module) { "cordova-plugin-jcore": "1.3.0", "jpush-phonegap-plugin": "3.7.2", "cordova-plugin-app-version": "0.1.9", - "cordova-plugin-wkwebview-engine": "1.2.1" + "cordova-plugin-wkwebview-engine": "1.2.1", + "cordova-plugin-brightness": "0.1.5" }; }); \ No newline at end of file diff --git a/platforms/android/app/src/main/assets/www/js/bindcard.js b/platforms/android/app/src/main/assets/www/js/bindcard.js index 27a0817..f7e91a2 100644 --- a/platforms/android/app/src/main/assets/www/js/bindcard.js +++ b/platforms/android/app/src/main/assets/www/js/bindcard.js @@ -19,6 +19,7 @@ var app = { dict = ret.idtypes; let keys = Object.keys(dict); let vals = Object.values(dict); + console.log(keys, vals) var items=[]; var selectItem=items[0]; for(var key of keys){ @@ -28,7 +29,7 @@ var app = { } if(key == 'idcard'){ selectItem=bean; - } + } items.push(bean) } $("#idtype").val(selectItem.title) @@ -61,6 +62,7 @@ var app = { cardnum = cardnum.trim(); name = name.trim(); idno = idno.trim(); + $.showLoading("正在处理"); var param = { "cardno": cardnum, @@ -77,7 +79,6 @@ var app = { window.localStorage.setItem("cardno", cardnum); window.localStorage.setItem("idtype", idtype); window.localStorage.setItem("idno", idno); - window.localStorage.setItem("phoneX",ret.phonex); window.localStorage.setItem("personid", ret.personid); window.localStorage.setItem("signed", ret.signed); diff --git a/platforms/android/app/src/main/assets/www/js/main.js b/platforms/android/app/src/main/assets/www/js/main.js index c5ba03b..e0a358f 100644 --- a/platforms/android/app/src/main/assets/www/js/main.js +++ b/platforms/android/app/src/main/assets/www/js/main.js @@ -44,16 +44,15 @@ var app = { } }); var uid = window.localStorage.getItem("uid"); - console.log(uid); window.JPush.setAlias({ sequence: 1, alias: uid }, (result) => { var sequence = result.sequence var alias = result.alias - console.log(alias) + //alert(JSON.stringify(result)) }, (error) => { - console.log(JSON.stringify(error)) var sequence = error.sequence var errorCode = error.code + //alert(JSON.stringify(error)) }) }, @@ -93,13 +92,18 @@ var app = { }) }); $('#secBtn').click(function() { - window.location = "security.html"; - /*app.checkBefore(function() { + //window.location = "security.html"; + app.checkBefore(function() { app.checkOther(function() { window.location = "security.html"; }) - })*/ + }) }); + /*$("#doorBtn").click(function(){ + app.checkBefore(function() { + showRet(DOOR_URl); + }) + })*/ $('#usersec').click(function() { app.checkBefore(function() { app.checkOther(function() { @@ -111,11 +115,11 @@ var app = { this.backBtn(); }, backBtn: function(){ - document.addEventListener("backbutton", function(e){ - e.preventDefault(); - navigator.app.exitApp(); - }, false); - }, + document.addEventListener("backbutton", function(e){ + e.preventDefault(); + navigator.app.exitApp(); + }, false); + }, initTab: function() { $("#maincontent").css("top", $("#maintop").height()) var tab = new auiTab({ @@ -324,11 +328,50 @@ var app = { } else { window.location = 'cardinfor.html' } - }, - logout:function(){ - window.localStorage.removeItem("token"); - window.location = "login.html"; } - }; app.initialize(); + +function showRet(url) { + if(isEmpty(url)){ + return; + } + var userid = window.localStorage.getItem("userid"); + //if (url.indexOf("yy.dlsmk.cn")>=0) { + if(url.indexOf("?")>0){ + url=url+'&userid='+userid; + }else{ + url=url+'?userid='+userid; + } + //} + console.log(url) + var inAppBrowserRef = cordova.ThemeableBrowser.open(url, '_blank', { + statusbar: { + color: '#03a9f4ff' + }, + toolbar: { + height: 44, + color: '#03a9f4ff' + }, + title: { + color: '#ffffffff', + showPageTitle: true + }, + backButton: { + image: 'back.png', + imagePressed: 'back.png', + align: 'left', + event: 'backPressed' + }, + closeButton: { + image: 'close.png', + imagePressed: 'close.png', + align: 'left', + event: 'closePressed' + }, + backButtonCanClose: true + }).addEventListener('closePressed', function(params){ + inAppBrowserRef.close(); + //window.location = "main.html" + }); + } diff --git a/platforms/android/app/src/main/assets/www/js/qrcode.js b/platforms/android/app/src/main/assets/www/js/qrcode.js index 1b5a036..79ae312 100644 --- a/platforms/android/app/src/main/assets/www/js/qrcode.js +++ b/platforms/android/app/src/main/assets/www/js/qrcode.js @@ -1,16 +1,27 @@ +var brightness; +var bvalue; +var setted= false; var app = { // Application Constructor initialize: function() { document.addEventListener('deviceready', this.onDeviceReady.bind(this), false); }, - onDeviceReady: function() { var uid = window.localStorage.getItem("token"); - this.loadQrcode(); + app.loadQrcode(); setInterval(function () { window.location.reload(); },100000); + + brightness = cordova.plugins.brightness; + if(brightness){ + brightness.getBrightness(function(val){ + bvalue = val; + }, function(err){ + console.log(err); + }); + } }, loadQrcode: function() { $.showLoading("加载中"); @@ -27,6 +38,15 @@ var app = { colorLight: "#ffffff", correctLevel: QRCode.CorrectLevel.L }); + if(!setted&&brightness){ + brightness.setBrightness(1, function(ret){ + console.log(ret); + setted = true; + brightness.setKeepScreenOn(true); + }, function(e){ + console.log(e) + }); + } } else { $.hideLoading(); $.alert("请求失败,请稍后再试", "错误"); @@ -44,8 +64,8 @@ var app = { $.hideLoading(); var qrcode = new QRCode(document.getElementById("qrcode"), { text: ret.qrcode, - width: 150, - height: 150, + width: 200, + height: 200, colorDark: "#000000", colorLight: "#ffffff", correctLevel: QRCode.CorrectLevel.L @@ -59,6 +79,16 @@ var app = { $.alert("请求失败了:" + ret.status + "请稍后再试", "错误"); } }) + }, + backTo:function(){ + if(brightness&&bvalue){ + brightness.setBrightness(bvalue, function(ret){ + brightness.setKeepScreenOn(false); + }, function(e){ + console.log(e) + }); + } + window,location.href='main.html'; } }; app.initialize(); \ No newline at end of file diff --git a/platforms/android/app/src/main/assets/www/js/register.js b/platforms/android/app/src/main/assets/www/js/register.js index d10558e..f53220a 100644 --- a/platforms/android/app/src/main/assets/www/js/register.js +++ b/platforms/android/app/src/main/assets/www/js/register.js @@ -27,7 +27,6 @@ var app = { "platform":device.name+","+device.platform+","+device.version, "uuid":device.uuid } - console.log(param) ICheckCode(param,function(ok,ret){ if(ok){ $.hideLoading(); diff --git a/platforms/android/app/src/main/assets/www/js/server.js b/platforms/android/app/src/main/assets/www/js/server.js index c8eb688..64a6da6 100644 --- a/platforms/android/app/src/main/assets/www/js/server.js +++ b/platforms/android/app/src/main/assets/www/js/server.js @@ -1,10 +1,11 @@ var dev = false; var SERVER = "https://yy.dlsmk.cn/payapi/mobileapi"; +var DOOR_URl = "http://172.28.43.8:8099/door/app/appMintUIindex";//门禁服务地址 var GLOBAL_TODAY=""; var GLOBAL_YESTERDAY=""; var CURRENT_INDEX=1; if (dev) { - SERVER = "http://172.28.201.70:10010/payapi/mobileapi"; + SERVER = "http://172.28.43.7:8099/payapi/mobileapi"; } function V1Qrcode(callback) { diff --git a/platforms/android/app/src/main/assets/www/main.html b/platforms/android/app/src/main/assets/www/main.html index 6d43efa..3ade7e7 100644 --- a/platforms/android/app/src/main/assets/www/main.html +++ b/platforms/android/app/src/main/assets/www/main.html @@ -44,6 +44,10 @@
账户安全
+ @@ -189,7 +193,7 @@ - diff --git a/platforms/android/app/src/main/java/org/apache/cordova/plugin/Brightness/BrightnessPlugin.java b/platforms/android/app/src/main/java/org/apache/cordova/plugin/Brightness/BrightnessPlugin.java new file mode 100644 index 0000000..6a42ff4 --- /dev/null +++ b/platforms/android/app/src/main/java/org/apache/cordova/plugin/Brightness/BrightnessPlugin.java @@ -0,0 +1,158 @@ +package org.apache.cordova.plugin.Brightness; + +import org.apache.cordova.CallbackContext; +import org.apache.cordova.CordovaPlugin; +import org.json.JSONArray; +import org.json.JSONException; + +import android.app.Activity; +import android.view.WindowManager.LayoutParams; +import android.view.WindowManager; +import android.view.Window; + +/** + * @author Evgeniy Lukovsky + * + */ +public class BrightnessPlugin extends CordovaPlugin { + public enum Action{ + setBrightness, + getBrightness, + setKeepScreenOn + } + + private class SetTask implements Runnable{ + private Activity target = null; + private LayoutParams lp = null; + @Override + public void run() { + target.getWindow().setAttributes(lp); + } + public void setParams(Activity act, LayoutParams params){ + this.target = act; + this.lp = params; + } + } + + private class KeepOnTask implements Runnable{ + private Window win = null; + private boolean state = false; + @Override + public void run() { + if(state){ + win.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); + } else { + win.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); + } + } + public void setParams(Window win, boolean state){ + this.win = win; + this.state = state; + } + } + + + /* (non-Javadoc) + * @see org.apache.cordova.CordovaPlugin#execute(java.lang.String, org.json.JSONArray, org.apache.cordova.CallbackContext) + */ + @Override + public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { + System.out.println("plugin has been started"); + boolean result = false; + + switch(Action.valueOf(action)){ + case setBrightness: result = true; + setBrightness(args, callbackContext); + break; + case getBrightness: result = true; + getBrightness(args, callbackContext); + break; + case setKeepScreenOn: result = true; + setKeepScreenOn(args, callbackContext); + break; + } + return result; + } + + /** + * @param args + * @param callbackContext + * @return + */ + private boolean setBrightness(JSONArray args, CallbackContext callbackContext) { + try { + Activity activity = cordova.getActivity(); + WindowManager.LayoutParams layoutParams = activity.getWindow().getAttributes(); + String value = args.getString(0); + double brightness = Double.parseDouble(value); + layoutParams.screenBrightness = (float) brightness; + SetTask task = new SetTask(); + task.setParams(activity, layoutParams); + activity.runOnUiThread(task); + callbackContext.success("OK"); + + } catch (NullPointerException e) { + System.out.println("Null pointer exception"); + System.out.println(e.getMessage()); + callbackContext.error(e.getMessage()); + return false; + } catch (JSONException e) { + System.out.println("JSONException exception"); + System.out.println(e.getMessage()); + callbackContext.error(e.getMessage()); + return false; + } + System.out.println("All went fine."); + return true; + } + + /** + * @param args + * @param callbackContext + * @return + */ + private boolean getBrightness(JSONArray args, CallbackContext callbackContext) { + try { + Activity activity = cordova.getActivity(); + WindowManager.LayoutParams layoutParams = activity.getWindow().getAttributes(); + Double brightness = (double) layoutParams.screenBrightness; + callbackContext.success(brightness.toString()); + + } catch (NullPointerException e) { + System.out.println("Null pointer exception"); + System.out.println(e.getMessage()); + callbackContext.error(e.getMessage()); + return false; + } + System.out.println("All went fine."); + return true; + } + /** + * @param args + * @param callbackContext + * @return + */ + private boolean setKeepScreenOn(JSONArray args, CallbackContext callbackContext){ + try { + boolean value = args.getBoolean(0); + Activity activity = cordova.getActivity(); + KeepOnTask task = new KeepOnTask(); + task.setParams(activity.getWindow(), value); + activity.runOnUiThread(task); + callbackContext.success("OK"); + + } catch (NullPointerException e) { + System.out.println("Null pointer exception"); + System.out.println(e.getMessage()); + callbackContext.error(e.getMessage()); + return false; + } catch (JSONException e) { + System.out.println("JSONException"); + System.out.println(e.getMessage()); + callbackContext.error(e.getMessage()); + return false; + } + System.out.println("All went fine."); + return true; + } +} diff --git a/platforms/android/app/src/main/res/drawable-hdpi/icon.png b/platforms/android/app/src/main/res/drawable-hdpi/icon.png index 4edb4c6..1769fc5 100644 Binary files a/platforms/android/app/src/main/res/drawable-hdpi/icon.png and b/platforms/android/app/src/main/res/drawable-hdpi/icon.png differ diff --git a/platforms/android/app/src/main/res/drawable-ldpi/icon.png b/platforms/android/app/src/main/res/drawable-ldpi/icon.png index 0508de6..1769fc5 100644 Binary files a/platforms/android/app/src/main/res/drawable-ldpi/icon.png and b/platforms/android/app/src/main/res/drawable-ldpi/icon.png differ diff --git a/platforms/android/app/src/main/res/drawable-mdpi/icon.png b/platforms/android/app/src/main/res/drawable-mdpi/icon.png index ed81661..92a3334 100644 Binary files a/platforms/android/app/src/main/res/drawable-mdpi/icon.png and b/platforms/android/app/src/main/res/drawable-mdpi/icon.png differ diff --git a/platforms/android/app/src/main/res/drawable-xhdpi/icon.png b/platforms/android/app/src/main/res/drawable-xhdpi/icon.png index b764a7e..4f54d23 100644 Binary files a/platforms/android/app/src/main/res/drawable-xhdpi/icon.png and b/platforms/android/app/src/main/res/drawable-xhdpi/icon.png differ diff --git a/platforms/android/app/src/main/res/drawable-xxhdpi/icon.png b/platforms/android/app/src/main/res/drawable-xxhdpi/icon.png index 3c7efa4..ea73508 100644 Binary files a/platforms/android/app/src/main/res/drawable-xxhdpi/icon.png and b/platforms/android/app/src/main/res/drawable-xxhdpi/icon.png differ diff --git a/platforms/android/app/src/main/res/drawable-xxxhdpi/icon.png b/platforms/android/app/src/main/res/drawable-xxxhdpi/icon.png index 8c027a7..8b754c8 100644 Binary files a/platforms/android/app/src/main/res/drawable-xxxhdpi/icon.png and b/platforms/android/app/src/main/res/drawable-xxxhdpi/icon.png differ diff --git a/platforms/android/app/src/main/res/drawable/icon.png b/platforms/android/app/src/main/res/drawable/icon.png index b764a7e..1769fc5 100644 Binary files a/platforms/android/app/src/main/res/drawable/icon.png and b/platforms/android/app/src/main/res/drawable/icon.png differ diff --git a/platforms/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/platforms/android/app/src/main/res/mipmap-hdpi/ic_launcher.png index 4edb4c6..1769fc5 100644 Binary files a/platforms/android/app/src/main/res/mipmap-hdpi/ic_launcher.png and b/platforms/android/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/platforms/android/app/src/main/res/mipmap-ldpi/ic_launcher.png b/platforms/android/app/src/main/res/mipmap-ldpi/ic_launcher.png index 0508de6..530c91d 100644 Binary files a/platforms/android/app/src/main/res/mipmap-ldpi/ic_launcher.png and b/platforms/android/app/src/main/res/mipmap-ldpi/ic_launcher.png differ diff --git a/platforms/android/app/src/main/res/mipmap-mdpi-v26/ic_launcher_foreground.png b/platforms/android/app/src/main/res/mipmap-mdpi-v26/ic_launcher_foreground.png index ed81661..92a3334 100644 Binary files a/platforms/android/app/src/main/res/mipmap-mdpi-v26/ic_launcher_foreground.png and b/platforms/android/app/src/main/res/mipmap-mdpi-v26/ic_launcher_foreground.png differ diff --git a/platforms/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/platforms/android/app/src/main/res/mipmap-mdpi/ic_launcher.png index ed81661..92a3334 100644 Binary files a/platforms/android/app/src/main/res/mipmap-mdpi/ic_launcher.png and b/platforms/android/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/platforms/android/app/src/main/res/mipmap-xhdpi-v26/ic_launcher_foreground.png b/platforms/android/app/src/main/res/mipmap-xhdpi-v26/ic_launcher_foreground.png index b764a7e..4f54d23 100644 Binary files a/platforms/android/app/src/main/res/mipmap-xhdpi-v26/ic_launcher_foreground.png and b/platforms/android/app/src/main/res/mipmap-xhdpi-v26/ic_launcher_foreground.png differ diff --git a/platforms/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/platforms/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png index b764a7e..4f54d23 100644 Binary files a/platforms/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png and b/platforms/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/platforms/android/app/src/main/res/mipmap-xxhdpi-v26/ic_launcher_foreground.png b/platforms/android/app/src/main/res/mipmap-xxhdpi-v26/ic_launcher_foreground.png index 3c7efa4..ea73508 100644 Binary files a/platforms/android/app/src/main/res/mipmap-xxhdpi-v26/ic_launcher_foreground.png and b/platforms/android/app/src/main/res/mipmap-xxhdpi-v26/ic_launcher_foreground.png differ diff --git a/platforms/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/platforms/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png index 3c7efa4..ea73508 100644 Binary files a/platforms/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png and b/platforms/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/platforms/android/app/src/main/res/mipmap-xxxhdpi-v26/ic_launcher_foreground.png b/platforms/android/app/src/main/res/mipmap-xxxhdpi-v26/ic_launcher_foreground.png index 8c027a7..8b754c8 100644 Binary files a/platforms/android/app/src/main/res/mipmap-xxxhdpi-v26/ic_launcher_foreground.png and b/platforms/android/app/src/main/res/mipmap-xxxhdpi-v26/ic_launcher_foreground.png differ diff --git a/platforms/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/platforms/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png index 8c027a7..8b754c8 100644 Binary files a/platforms/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png and b/platforms/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/platforms/android/app/src/main/res/xml/config.xml b/platforms/android/app/src/main/res/xml/config.xml index cda74bc..59faded 100644 --- a/platforms/android/app/src/main/res/xml/config.xml +++ b/platforms/android/app/src/main/res/xml/config.xml @@ -1,5 +1,5 @@ - + @@ -40,6 +40,9 @@ + + + dlapp A sample Apache Cordova application that responds to the deviceready event. diff --git a/platforms/android/platform_www/cordova_plugins.js b/platforms/android/platform_www/cordova_plugins.js index ee6832d..951ded8 100644 --- a/platforms/android/platform_www/cordova_plugins.js +++ b/platforms/android/platform_www/cordova_plugins.js @@ -335,6 +335,14 @@ cordova.define('cordova/plugin_list', function(require, exports, module) { "clobbers": [ "cordova.getAppVersion" ] + }, + { + "id": "cordova-plugin-brightness.Brightness", + "file": "plugins/cordova-plugin-brightness/www/brightness.js", + "pluginId": "cordova-plugin-brightness", + "clobbers": [ + "cordova.plugins.brightness" + ] } ]; module.exports.metadata = { @@ -354,6 +362,7 @@ cordova.define('cordova/plugin_list', function(require, exports, module) { "cordova-plugin-jcore": "1.3.0", "jpush-phonegap-plugin": "3.7.2", "cordova-plugin-app-version": "0.1.9", - "cordova-plugin-wkwebview-engine": "1.2.1" + "cordova-plugin-wkwebview-engine": "1.2.1", + "cordova-plugin-brightness": "0.1.5" }; }); \ No newline at end of file diff --git a/platforms/android/platform_www/plugins/cordova-plugin-brightness/www/brightness.js b/platforms/android/platform_www/plugins/cordova-plugin-brightness/www/brightness.js new file mode 100644 index 0000000..c1111d6 --- /dev/null +++ b/platforms/android/platform_www/plugins/cordova-plugin-brightness/www/brightness.js @@ -0,0 +1,18 @@ +cordova.define("cordova-plugin-brightness.Brightness", function(require, exports, module) { +'use strict'; + +var exec = require('cordova/exec'); + +exports.getBrightness = function( success, error) { + exec(success, error, 'Brightness', 'getBrightness', []); +}; + +exports.setBrightness = function(value, success, error) { + exec(success, error, 'Brightness', 'setBrightness', [value]); +}; + +exports.setKeepScreenOn = function(value, success, error) { + exec(success, error, 'Brightness', 'setKeepScreenOn', [value]); +}; + +}); diff --git a/platforms/browser/browser.json b/platforms/browser/browser.json index 13a6fc8..fb5ae44 100644 --- a/platforms/browser/browser.json +++ b/platforms/browser/browser.json @@ -102,6 +102,9 @@ }, "cordova-plugin-wkwebview-engine": { "PACKAGE_NAME": "com.supwisdom.dlapp" + }, + "cordova-plugin-brightness": { + "PACKAGE_NAME": "com.dalicitycard.app" } }, "dependent_plugins": {}, @@ -467,6 +470,14 @@ "clobbers": [ "cordova.getAppVersion" ] + }, + { + "file": "plugins/cordova-plugin-brightness/www/brightness.js", + "id": "cordova-plugin-brightness.Brightness", + "pluginId": "cordova-plugin-brightness", + "clobbers": [ + "cordova.plugins.brightness" + ] } ], "plugin_metadata": { @@ -486,6 +497,7 @@ "cordova-plugin-jcore": "1.3.0", "jpush-phonegap-plugin": "3.7.2", "cordova-plugin-app-version": "0.1.9", - "cordova-plugin-wkwebview-engine": "1.2.1" + "cordova-plugin-wkwebview-engine": "1.2.1", + "cordova-plugin-brightness": "0.1.5" } } diff --git a/platforms/browser/platform_www/cordova_plugins.js b/platforms/browser/platform_www/cordova_plugins.js index 3f30e69..5aef346 100644 --- a/platforms/browser/platform_www/cordova_plugins.js +++ b/platforms/browser/platform_www/cordova_plugins.js @@ -361,6 +361,14 @@ module.exports = [ "clobbers": [ "cordova.getAppVersion" ] + }, + { + "file": "plugins/cordova-plugin-brightness/www/brightness.js", + "id": "cordova-plugin-brightness.Brightness", + "pluginId": "cordova-plugin-brightness", + "clobbers": [ + "cordova.plugins.brightness" + ] } ]; module.exports.metadata = @@ -382,7 +390,8 @@ module.exports.metadata = "cordova-plugin-jcore": "1.3.0", "jpush-phonegap-plugin": "3.7.2", "cordova-plugin-app-version": "0.1.9", - "cordova-plugin-wkwebview-engine": "1.2.1" + "cordova-plugin-wkwebview-engine": "1.2.1", + "cordova-plugin-brightness": "0.1.5" } // BOTTOM OF METADATA }); \ No newline at end of file diff --git a/platforms/browser/platform_www/plugins/cordova-plugin-brightness/www/brightness.js b/platforms/browser/platform_www/plugins/cordova-plugin-brightness/www/brightness.js new file mode 100644 index 0000000..87048a1 --- /dev/null +++ b/platforms/browser/platform_www/plugins/cordova-plugin-brightness/www/brightness.js @@ -0,0 +1,17 @@ +cordova.define("cordova-plugin-brightness.Brightness", function(require, exports, module) { 'use strict'; + +var exec = require('cordova/exec'); + +exports.getBrightness = function( success, error) { + exec(success, error, 'Brightness', 'getBrightness', []); +}; + +exports.setBrightness = function(value, success, error) { + exec(success, error, 'Brightness', 'setBrightness', [value]); +}; + +exports.setKeepScreenOn = function(value, success, error) { + exec(success, error, 'Brightness', 'setKeepScreenOn', [value]); +}; + +}); diff --git a/platforms/ios/dlapp.xcodeproj/project.pbxproj b/platforms/ios/dlapp.xcodeproj/project.pbxproj index d2839b7..50e0385 100644 --- a/platforms/ios/dlapp.xcodeproj/project.pbxproj +++ b/platforms/ios/dlapp.xcodeproj/project.pbxproj @@ -5,7 +5,6 @@ }; objectVersion = 46; objects = { - /* Begin PBXBuildFile section */ 0207DA581B56EA530066E2B4 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0207DA571B56EA530066E2B4 /* Images.xcassets */; }; 04347BD0ABAC4EE0B4CDDDB6 /* jcore-ios-2.1.1.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 444DBF371D8346D7BC7EE35D /* jcore-ios-2.1.1.a */; }; @@ -65,6 +64,7 @@ F68EA21E51A3463A8FE2EE92 /* CDVWKWebViewUIDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 3B73EA28E46846FF84E6AF02 /* CDVWKWebViewUIDelegate.m */; }; F939AD8D22BB769B006B371B /* libsqlite3.0.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = F939AD8C22BB769B006B371B /* libsqlite3.0.tbd */; }; FDE92C386167415E8040F8AB /* AFURLResponseSerialization.m in Sources */ = {isa = PBXBuildFile; fileRef = FDEE8379D7A34C55A616F700 /* AFURLResponseSerialization.m */; }; + C0A6FD40F47B434496535606 /* Brightness.m in Sources */ = {isa = PBXBuildFile; fileRef = 1E4D2B8A1F474D9883C50B86 /* Brightness.m */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -196,6 +196,8 @@ FCC7E279D80D4FB9BCF2530A /* Bridging-Header.h */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 4; includeInIndex = 0; lastKnownFileType = sourcecode.c.h; name = "Bridging-Header.h"; path = "cordova-plugin-fingerprint-aio/Bridging-Header.h"; sourceTree = ""; }; FDEE8379D7A34C55A616F700 /* AFURLResponseSerialization.m */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 4; includeInIndex = 0; lastKnownFileType = sourcecode.c.objc; name = AFURLResponseSerialization.m; path = "cordova-plugin-advanced-http/AFURLResponseSerialization.m"; sourceTree = ""; }; FE0B455916A4481681D59FE0 /* WebKit.framework */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = System/Library/Frameworks/WebKit.framework; sourceTree = SDKROOT; }; + 1E4D2B8A1F474D9883C50B86 /* Brightness.m */ = {isa = PBXFileReference; name = "Brightness.m"; path = "cordova-plugin-brightness/Brightness.m"; sourceTree = ""; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; explicitFileType = undefined; includeInIndex = 0; }; + 817A61F7D48245FA9567B115 /* Brightness.h */ = {isa = PBXFileReference; name = "Brightness.h"; path = "cordova-plugin-brightness/Brightness.h"; sourceTree = ""; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; explicitFileType = undefined; includeInIndex = 0; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -405,6 +407,8 @@ 648BD3182CD64A77AD2D447B /* CDVWKWebViewEngine.h */, 1E5CB6025B2E4D14ABFDB037 /* CDVWKWebViewUIDelegate.h */, 7DC7711D3C76485B9E422E3A /* CDVWKProcessPoolFactory.h */, + 1E4D2B8A1F474D9883C50B86 /* Brightness.m */, + 817A61F7D48245FA9567B115 /* Brightness.h */, ); name = Plugins; path = dlapp/Plugins; @@ -597,6 +601,7 @@ 562D29FCB1FB4F86B95BB2BC /* CDVWKWebViewEngine.m in Sources */, F68EA21E51A3463A8FE2EE92 /* CDVWKWebViewUIDelegate.m in Sources */, 1F969D21D7EF4CF1A547A1DF /* CDVWKProcessPoolFactory.m in Sources */, + C0A6FD40F47B434496535606 /* Brightness.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/platforms/ios/dlapp/Images.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png b/platforms/ios/dlapp/Images.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png index ccdc491..93f7d4b 100644 Binary files a/platforms/ios/dlapp/Images.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png and b/platforms/ios/dlapp/Images.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png differ diff --git a/platforms/ios/dlapp/Images.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png b/platforms/ios/dlapp/Images.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png index 5b1a340..338c489 100644 Binary files a/platforms/ios/dlapp/Images.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png and b/platforms/ios/dlapp/Images.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png differ diff --git a/platforms/ios/dlapp/Images.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png b/platforms/ios/dlapp/Images.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png index d233176..26304e4 100644 Binary files a/platforms/ios/dlapp/Images.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png and b/platforms/ios/dlapp/Images.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png differ diff --git a/platforms/ios/dlapp/Images.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png b/platforms/ios/dlapp/Images.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png index 908f73c..3179c09 100644 Binary files a/platforms/ios/dlapp/Images.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png and b/platforms/ios/dlapp/Images.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png differ diff --git a/platforms/ios/dlapp/Images.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png b/platforms/ios/dlapp/Images.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png index 7716580..6807263 100644 Binary files a/platforms/ios/dlapp/Images.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png and b/platforms/ios/dlapp/Images.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png differ diff --git a/platforms/ios/dlapp/Images.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png b/platforms/ios/dlapp/Images.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png index 0d3a8dc..3f765b9 100644 Binary files a/platforms/ios/dlapp/Images.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png and b/platforms/ios/dlapp/Images.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png differ diff --git a/platforms/ios/dlapp/Images.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png b/platforms/ios/dlapp/Images.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png index 5b1a340..338c489 100644 Binary files a/platforms/ios/dlapp/Images.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png and b/platforms/ios/dlapp/Images.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png differ diff --git a/platforms/ios/dlapp/Images.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png b/platforms/ios/dlapp/Images.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png index d0ec9ec..5159c6d 100644 Binary files a/platforms/ios/dlapp/Images.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png and b/platforms/ios/dlapp/Images.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png differ diff --git a/platforms/ios/dlapp/Images.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png b/platforms/ios/dlapp/Images.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png index 35bb3ba..a5394ab 100644 Binary files a/platforms/ios/dlapp/Images.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png and b/platforms/ios/dlapp/Images.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png differ diff --git a/platforms/ios/dlapp/Images.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png b/platforms/ios/dlapp/Images.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png index 35bb3ba..a5394ab 100644 Binary files a/platforms/ios/dlapp/Images.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png and b/platforms/ios/dlapp/Images.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png differ diff --git a/platforms/ios/dlapp/Images.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png b/platforms/ios/dlapp/Images.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png index cb4580a..28db6a7 100644 Binary files a/platforms/ios/dlapp/Images.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png and b/platforms/ios/dlapp/Images.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png differ diff --git a/platforms/ios/dlapp/Images.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png b/platforms/ios/dlapp/Images.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png index 65bf622..ee96b32 100644 Binary files a/platforms/ios/dlapp/Images.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png and b/platforms/ios/dlapp/Images.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png differ diff --git a/platforms/ios/dlapp/Images.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png b/platforms/ios/dlapp/Images.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png index 6b6e1b1..f4e7346 100644 Binary files a/platforms/ios/dlapp/Images.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png and b/platforms/ios/dlapp/Images.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png differ diff --git a/platforms/ios/dlapp/Images.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png b/platforms/ios/dlapp/Images.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png index 3a0d3be..86c995d 100644 Binary files a/platforms/ios/dlapp/Images.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png and b/platforms/ios/dlapp/Images.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png differ diff --git a/platforms/ios/dlapp/Images.xcassets/AppIcon.appiconset/ItunesArtwork@2x.png b/platforms/ios/dlapp/Images.xcassets/AppIcon.appiconset/ItunesArtwork@2x.png index e347795..eb0ca49 100644 Binary files a/platforms/ios/dlapp/Images.xcassets/AppIcon.appiconset/ItunesArtwork@2x.png and b/platforms/ios/dlapp/Images.xcassets/AppIcon.appiconset/ItunesArtwork@2x.png differ diff --git a/platforms/ios/dlapp/Images.xcassets/iTunesArtwork@1x.png b/platforms/ios/dlapp/Images.xcassets/iTunesArtwork@1x.png new file mode 100644 index 0000000..cfd1080 Binary files /dev/null and b/platforms/ios/dlapp/Images.xcassets/iTunesArtwork@1x.png differ diff --git a/platforms/ios/dlapp/Images.xcassets/iTunesArtwork@2x.png b/platforms/ios/dlapp/Images.xcassets/iTunesArtwork@2x.png new file mode 100644 index 0000000..eb0ca49 Binary files /dev/null and b/platforms/ios/dlapp/Images.xcassets/iTunesArtwork@2x.png differ diff --git a/platforms/ios/dlapp/Images.xcassets/iTunesArtwork@3x.png b/platforms/ios/dlapp/Images.xcassets/iTunesArtwork@3x.png new file mode 100644 index 0000000..d6e68b2 Binary files /dev/null and b/platforms/ios/dlapp/Images.xcassets/iTunesArtwork@3x.png differ diff --git a/platforms/ios/dlapp/Plugins/cordova-plugin-brightness/Brightness.h b/platforms/ios/dlapp/Plugins/cordova-plugin-brightness/Brightness.h new file mode 100644 index 0000000..af7f99b --- /dev/null +++ b/platforms/ios/dlapp/Plugins/cordova-plugin-brightness/Brightness.h @@ -0,0 +1,15 @@ +/** + * @author Evgeniy Lukovsky + * + */ + + +#import + +@interface Brightness : CDVPlugin + +- (void)getBrightness:(CDVInvokedUrlCommand*)command; +- (void)setBrightness:(CDVInvokedUrlCommand*)command; +- (void)setKeepScreenOn:(CDVInvokedUrlCommand*)command; + +@end diff --git a/platforms/ios/dlapp/Plugins/cordova-plugin-brightness/Brightness.m b/platforms/ios/dlapp/Plugins/cordova-plugin-brightness/Brightness.m new file mode 100644 index 0000000..be09832 --- /dev/null +++ b/platforms/ios/dlapp/Plugins/cordova-plugin-brightness/Brightness.m @@ -0,0 +1,39 @@ +/** + * @author Evgeniy Lukovsky + * + */ + +#import +#import "Brightness.h" + +@implementation Brightness : CDVPlugin + +- (void)getBrightness:(CDVInvokedUrlCommand *)command +{ + CDVPluginResult * pluginResult = nil; + float brightness = [UIScreen mainScreen].brightness; + NSString *result = [NSString stringWithFormat:@"%f", brightness]; + pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:result]; + [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; +} + +- (void)setBrightness:(CDVInvokedUrlCommand *)command +{ + CDVPluginResult * pluginResult = nil; + NSString *value = [command.arguments objectAtIndex:0]; + float brightness = [value floatValue]; + [UIScreen mainScreen].brightness = brightness; + pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsBool:YES]; + [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; +} + +-(void)setKeepScreenOn:(CDVInvokedUrlCommand *)command +{ + CDVPluginResult* pluginResult = nil; + BOOL value = [[command.arguments objectAtIndex:0] boolValue]; + [UIApplication sharedApplication].idleTimerDisabled = value; + pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsBool:YES]; + [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; +} + +@end diff --git a/platforms/ios/dlapp/config.xml b/platforms/ios/dlapp/config.xml index 14bae9c..a06aded 100755 --- a/platforms/ios/dlapp/config.xml +++ b/platforms/ios/dlapp/config.xml @@ -64,6 +64,9 @@ + + + dlapp A sample Apache Cordova application that responds to the deviceready event. diff --git a/platforms/ios/frameworks.json b/platforms/ios/frameworks.json index c15fc84..71928cb 100644 --- a/platforms/ios/frameworks.json +++ b/platforms/ios/frameworks.json @@ -9,7 +9,7 @@ "CoreFoundation.framework": 1, "CoreTelephony.framework": 1, "Foundation.framework": 1, - "UIKit.framework": 1, + "UIKit.framework": 2, "libz.tbd": 1, "AdSupport.framework": 1, "UserNotifications.framework": 1, diff --git a/platforms/ios/ios.json b/platforms/ios/ios.json index 3a70ab7..7b9d86f 100644 --- a/platforms/ios/ios.json +++ b/platforms/ios/ios.json @@ -79,6 +79,10 @@ { "xml": "", "count": 1 + }, + { + "xml": "", + "count": 1 } ] } @@ -206,6 +210,9 @@ }, "cordova-plugin-wkwebview-engine": { "PACKAGE_NAME": "$(PRODUCT_BUNDLE_IDENTIFIER)" + }, + "cordova-plugin-brightness": { + "PACKAGE_NAME": "$(PRODUCT_BUNDLE_IDENTIFIER)" } }, "dependent_plugins": {}, @@ -561,6 +568,14 @@ "clobbers": [ "window.WkWebView" ] + }, + { + "id": "cordova-plugin-brightness.Brightness", + "file": "plugins/cordova-plugin-brightness/www/brightness.js", + "pluginId": "cordova-plugin-brightness", + "clobbers": [ + "cordova.plugins.brightness" + ] } ], "plugin_metadata": { @@ -580,6 +595,7 @@ "cordova-plugin-jcore": "1.3.0", "jpush-phonegap-plugin": "3.7.2", "cordova-plugin-app-version": "0.1.9", - "cordova-plugin-wkwebview-engine": "1.2.1" + "cordova-plugin-wkwebview-engine": "1.2.1", + "cordova-plugin-brightness": "0.1.5" } } diff --git a/platforms/ios/platform_www/cordova_plugins.js b/platforms/ios/platform_www/cordova_plugins.js index 99f7689..eca1f34 100644 --- a/platforms/ios/platform_www/cordova_plugins.js +++ b/platforms/ios/platform_www/cordova_plugins.js @@ -351,6 +351,14 @@ cordova.define('cordova/plugin_list', function(require, exports, module) { "clobbers": [ "window.WkWebView" ] + }, + { + "id": "cordova-plugin-brightness.Brightness", + "file": "plugins/cordova-plugin-brightness/www/brightness.js", + "pluginId": "cordova-plugin-brightness", + "clobbers": [ + "cordova.plugins.brightness" + ] } ]; module.exports.metadata = { @@ -370,6 +378,7 @@ cordova.define('cordova/plugin_list', function(require, exports, module) { "cordova-plugin-jcore": "1.3.0", "jpush-phonegap-plugin": "3.7.2", "cordova-plugin-app-version": "0.1.9", - "cordova-plugin-wkwebview-engine": "1.2.1" + "cordova-plugin-wkwebview-engine": "1.2.1", + "cordova-plugin-brightness": "0.1.5" }; }); \ No newline at end of file diff --git a/platforms/ios/platform_www/plugins/cordova-plugin-brightness/www/brightness.js b/platforms/ios/platform_www/plugins/cordova-plugin-brightness/www/brightness.js new file mode 100644 index 0000000..c1111d6 --- /dev/null +++ b/platforms/ios/platform_www/plugins/cordova-plugin-brightness/www/brightness.js @@ -0,0 +1,18 @@ +cordova.define("cordova-plugin-brightness.Brightness", function(require, exports, module) { +'use strict'; + +var exec = require('cordova/exec'); + +exports.getBrightness = function( success, error) { + exec(success, error, 'Brightness', 'getBrightness', []); +}; + +exports.setBrightness = function(value, success, error) { + exec(success, error, 'Brightness', 'setBrightness', [value]); +}; + +exports.setKeepScreenOn = function(value, success, error) { + exec(success, error, 'Brightness', 'setKeepScreenOn', [value]); +}; + +}); diff --git a/plugins/android.json b/plugins/android.json index 3736fc4..5cd402b 100644 --- a/plugins/android.json +++ b/plugins/android.json @@ -51,6 +51,9 @@ }, "cordova-plugin-wkwebview-engine": { "PACKAGE_NAME": "com.dalicitycard.app" + }, + "cordova-plugin-brightness": { + "PACKAGE_NAME": "com.dalicitycard.app" } }, "dependent_plugins": { diff --git a/plugins/browser.json b/plugins/browser.json index 4315c7b..1eb645a 100644 --- a/plugins/browser.json +++ b/plugins/browser.json @@ -50,6 +50,9 @@ }, "cordova-plugin-wkwebview-engine": { "PACKAGE_NAME": "com.supwisdom.dlapp" + }, + "cordova-plugin-brightness": { + "PACKAGE_NAME": "com.dalicitycard.app" } }, "dependent_plugins": { diff --git a/plugins/cordova-plugin-brightness/package.json b/plugins/cordova-plugin-brightness/package.json new file mode 100644 index 0000000..af91d83 --- /dev/null +++ b/plugins/cordova-plugin-brightness/package.json @@ -0,0 +1,61 @@ +{ + "_from": "cordova-plugin-brightness", + "_id": "cordova-plugin-brightness@0.2.0", + "_inBundle": false, + "_integrity": "sha512-ujW4v58jArPxPf8CjEppl9hM2/9jep1+nflzAOGoT4yc5UIuLja6j6+wxK2fv6+UWqVEWEKB3JkfnijVUl6HjQ==", + "_location": "/cordova-plugin-brightness", + "_phantomChildren": {}, + "_requested": { + "type": "tag", + "registry": true, + "raw": "cordova-plugin-brightness", + "name": "cordova-plugin-brightness", + "escapedName": "cordova-plugin-brightness", + "rawSpec": "", + "saveSpec": null, + "fetchSpec": "latest" + }, + "_requiredBy": [ + "#USER", + "/" + ], + "_resolved": "https://registry.npmjs.org/cordova-plugin-brightness/-/cordova-plugin-brightness-0.2.0.tgz", + "_shasum": "af2b57d5f8054828a54f86bd6886d015d00293bc", + "_spec": "cordova-plugin-brightness", + "_where": "/Users/shuwei/works2/cordova/dlapp", + "author": { + "name": "Evgeniy Lukovsky" + }, + "bugs": { + "url": "https://github.com/mgcrea/cordova-plugin-brightness/issues" + }, + "bundleDependencies": false, + "cordova": { + "id": "cordova-plugin-brightness", + "platforms": [ + "ios" + ] + }, + "deprecated": false, + "description": "Cordova Brightness Control Plugin", + "engines": [ + { + "name": "cordova-ios", + "version": ">=3.6.0" + } + ], + "homepage": "https://github.com/mgcrea/cordova-plugin-brightness#readme", + "keywords": [ + "cordova", + "unity", + "ecosystem:cordova", + "cordova-ios" + ], + "license": "MIT", + "name": "cordova-plugin-brightness", + "repository": { + "type": "git", + "url": "git+https://github.com/mgcrea/cordova-plugin-brightness.git" + }, + "version": "0.2.0" +} diff --git a/plugins/cordova-plugin-brightness/plugin.xml b/plugins/cordova-plugin-brightness/plugin.xml new file mode 100644 index 0000000..9b56025 --- /dev/null +++ b/plugins/cordova-plugin-brightness/plugin.xml @@ -0,0 +1,52 @@ + + + + Brightness + + Evgeniy Lukovsky + + MIT + + + This plugin gives you the ability to get and set the screen brightness + + + + + + + + This plugin gives you the ability to get and set the screen brightness. Also recently I have added the function for keep screen on. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/plugins/cordova-plugin-brightness/src/android/BrightnessPlugin.java b/plugins/cordova-plugin-brightness/src/android/BrightnessPlugin.java new file mode 100644 index 0000000..6a42ff4 --- /dev/null +++ b/plugins/cordova-plugin-brightness/src/android/BrightnessPlugin.java @@ -0,0 +1,158 @@ +package org.apache.cordova.plugin.Brightness; + +import org.apache.cordova.CallbackContext; +import org.apache.cordova.CordovaPlugin; +import org.json.JSONArray; +import org.json.JSONException; + +import android.app.Activity; +import android.view.WindowManager.LayoutParams; +import android.view.WindowManager; +import android.view.Window; + +/** + * @author Evgeniy Lukovsky + * + */ +public class BrightnessPlugin extends CordovaPlugin { + public enum Action{ + setBrightness, + getBrightness, + setKeepScreenOn + } + + private class SetTask implements Runnable{ + private Activity target = null; + private LayoutParams lp = null; + @Override + public void run() { + target.getWindow().setAttributes(lp); + } + public void setParams(Activity act, LayoutParams params){ + this.target = act; + this.lp = params; + } + } + + private class KeepOnTask implements Runnable{ + private Window win = null; + private boolean state = false; + @Override + public void run() { + if(state){ + win.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); + } else { + win.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); + } + } + public void setParams(Window win, boolean state){ + this.win = win; + this.state = state; + } + } + + + /* (non-Javadoc) + * @see org.apache.cordova.CordovaPlugin#execute(java.lang.String, org.json.JSONArray, org.apache.cordova.CallbackContext) + */ + @Override + public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { + System.out.println("plugin has been started"); + boolean result = false; + + switch(Action.valueOf(action)){ + case setBrightness: result = true; + setBrightness(args, callbackContext); + break; + case getBrightness: result = true; + getBrightness(args, callbackContext); + break; + case setKeepScreenOn: result = true; + setKeepScreenOn(args, callbackContext); + break; + } + return result; + } + + /** + * @param args + * @param callbackContext + * @return + */ + private boolean setBrightness(JSONArray args, CallbackContext callbackContext) { + try { + Activity activity = cordova.getActivity(); + WindowManager.LayoutParams layoutParams = activity.getWindow().getAttributes(); + String value = args.getString(0); + double brightness = Double.parseDouble(value); + layoutParams.screenBrightness = (float) brightness; + SetTask task = new SetTask(); + task.setParams(activity, layoutParams); + activity.runOnUiThread(task); + callbackContext.success("OK"); + + } catch (NullPointerException e) { + System.out.println("Null pointer exception"); + System.out.println(e.getMessage()); + callbackContext.error(e.getMessage()); + return false; + } catch (JSONException e) { + System.out.println("JSONException exception"); + System.out.println(e.getMessage()); + callbackContext.error(e.getMessage()); + return false; + } + System.out.println("All went fine."); + return true; + } + + /** + * @param args + * @param callbackContext + * @return + */ + private boolean getBrightness(JSONArray args, CallbackContext callbackContext) { + try { + Activity activity = cordova.getActivity(); + WindowManager.LayoutParams layoutParams = activity.getWindow().getAttributes(); + Double brightness = (double) layoutParams.screenBrightness; + callbackContext.success(brightness.toString()); + + } catch (NullPointerException e) { + System.out.println("Null pointer exception"); + System.out.println(e.getMessage()); + callbackContext.error(e.getMessage()); + return false; + } + System.out.println("All went fine."); + return true; + } + /** + * @param args + * @param callbackContext + * @return + */ + private boolean setKeepScreenOn(JSONArray args, CallbackContext callbackContext){ + try { + boolean value = args.getBoolean(0); + Activity activity = cordova.getActivity(); + KeepOnTask task = new KeepOnTask(); + task.setParams(activity.getWindow(), value); + activity.runOnUiThread(task); + callbackContext.success("OK"); + + } catch (NullPointerException e) { + System.out.println("Null pointer exception"); + System.out.println(e.getMessage()); + callbackContext.error(e.getMessage()); + return false; + } catch (JSONException e) { + System.out.println("JSONException"); + System.out.println(e.getMessage()); + callbackContext.error(e.getMessage()); + return false; + } + System.out.println("All went fine."); + return true; + } +} diff --git a/plugins/cordova-plugin-brightness/src/ios/Brightness.h b/plugins/cordova-plugin-brightness/src/ios/Brightness.h new file mode 100644 index 0000000..af7f99b --- /dev/null +++ b/plugins/cordova-plugin-brightness/src/ios/Brightness.h @@ -0,0 +1,15 @@ +/** + * @author Evgeniy Lukovsky + * + */ + + +#import + +@interface Brightness : CDVPlugin + +- (void)getBrightness:(CDVInvokedUrlCommand*)command; +- (void)setBrightness:(CDVInvokedUrlCommand*)command; +- (void)setKeepScreenOn:(CDVInvokedUrlCommand*)command; + +@end diff --git a/plugins/cordova-plugin-brightness/src/ios/Brightness.m b/plugins/cordova-plugin-brightness/src/ios/Brightness.m new file mode 100644 index 0000000..be09832 --- /dev/null +++ b/plugins/cordova-plugin-brightness/src/ios/Brightness.m @@ -0,0 +1,39 @@ +/** + * @author Evgeniy Lukovsky + * + */ + +#import +#import "Brightness.h" + +@implementation Brightness : CDVPlugin + +- (void)getBrightness:(CDVInvokedUrlCommand *)command +{ + CDVPluginResult * pluginResult = nil; + float brightness = [UIScreen mainScreen].brightness; + NSString *result = [NSString stringWithFormat:@"%f", brightness]; + pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:result]; + [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; +} + +- (void)setBrightness:(CDVInvokedUrlCommand *)command +{ + CDVPluginResult * pluginResult = nil; + NSString *value = [command.arguments objectAtIndex:0]; + float brightness = [value floatValue]; + [UIScreen mainScreen].brightness = brightness; + pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsBool:YES]; + [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; +} + +-(void)setKeepScreenOn:(CDVInvokedUrlCommand *)command +{ + CDVPluginResult* pluginResult = nil; + BOOL value = [[command.arguments objectAtIndex:0] boolValue]; + [UIApplication sharedApplication].idleTimerDisabled = value; + pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsBool:YES]; + [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; +} + +@end diff --git a/plugins/cordova-plugin-brightness/www/brightness.js b/plugins/cordova-plugin-brightness/www/brightness.js new file mode 100644 index 0000000..4b9ea4b --- /dev/null +++ b/plugins/cordova-plugin-brightness/www/brightness.js @@ -0,0 +1,15 @@ +'use strict'; + +var exec = require('cordova/exec'); + +exports.getBrightness = function( success, error) { + exec(success, error, 'Brightness', 'getBrightness', []); +}; + +exports.setBrightness = function(value, success, error) { + exec(success, error, 'Brightness', 'setBrightness', [value]); +}; + +exports.setKeepScreenOn = function(value, success, error) { + exec(success, error, 'Brightness', 'setKeepScreenOn', [value]); +}; diff --git a/plugins/fetch.json b/plugins/fetch.json index c8f43cc..ebfe8ce 100644 --- a/plugins/fetch.json +++ b/plugins/fetch.json @@ -143,5 +143,13 @@ }, "is_top_level": true, "variables": {} + }, + "cordova-plugin-brightness": { + "source": { + "type": "registry", + "id": "cordova-plugin-brightness" + }, + "is_top_level": true, + "variables": {} } } \ No newline at end of file diff --git a/plugins/ios.json b/plugins/ios.json index 26cc800..1ec3afc 100644 --- a/plugins/ios.json +++ b/plugins/ios.json @@ -52,6 +52,9 @@ }, "cordova-plugin-wkwebview-engine": { "PACKAGE_NAME": "$(PRODUCT_BUNDLE_IDENTIFIER)" + }, + "cordova-plugin-brightness": { + "PACKAGE_NAME": "$(PRODUCT_BUNDLE_IDENTIFIER)" } }, "dependent_plugins": { diff --git a/www/js/qrcode.js b/www/js/qrcode.js index 1b5a036..79ae312 100644 --- a/www/js/qrcode.js +++ b/www/js/qrcode.js @@ -1,16 +1,27 @@ +var brightness; +var bvalue; +var setted= false; var app = { // Application Constructor initialize: function() { document.addEventListener('deviceready', this.onDeviceReady.bind(this), false); }, - onDeviceReady: function() { var uid = window.localStorage.getItem("token"); - this.loadQrcode(); + app.loadQrcode(); setInterval(function () { window.location.reload(); },100000); + + brightness = cordova.plugins.brightness; + if(brightness){ + brightness.getBrightness(function(val){ + bvalue = val; + }, function(err){ + console.log(err); + }); + } }, loadQrcode: function() { $.showLoading("加载中"); @@ -27,6 +38,15 @@ var app = { colorLight: "#ffffff", correctLevel: QRCode.CorrectLevel.L }); + if(!setted&&brightness){ + brightness.setBrightness(1, function(ret){ + console.log(ret); + setted = true; + brightness.setKeepScreenOn(true); + }, function(e){ + console.log(e) + }); + } } else { $.hideLoading(); $.alert("请求失败,请稍后再试", "错误"); @@ -44,8 +64,8 @@ var app = { $.hideLoading(); var qrcode = new QRCode(document.getElementById("qrcode"), { text: ret.qrcode, - width: 150, - height: 150, + width: 200, + height: 200, colorDark: "#000000", colorLight: "#ffffff", correctLevel: QRCode.CorrectLevel.L @@ -59,6 +79,16 @@ var app = { $.alert("请求失败了:" + ret.status + "请稍后再试", "错误"); } }) + }, + backTo:function(){ + if(brightness&&bvalue){ + brightness.setBrightness(bvalue, function(ret){ + brightness.setKeepScreenOn(false); + }, function(e){ + console.log(e) + }); + } + window,location.href='main.html'; } }; app.initialize(); \ No newline at end of file diff --git a/www/qrcode.html b/www/qrcode.html index ca6cb07..48e9b69 100644 --- a/www/qrcode.html +++ b/www/qrcode.html @@ -15,7 +15,7 @@
- +
付款码