修改屏幕亮度和图标
authorqiaowei <jov123@163.com>
Mon, 2 Dec 2019 08:13:33 +0000 (16:13 +0800)
committerqiaowei <jov123@163.com>
Mon, 2 Dec 2019 08:13:33 +0000 (16:13 +0800)
77 files changed:
package-lock.json
package.json
platforms/android/android.json
platforms/android/app/build.gradle
platforms/android/app/release/app-release.apk
platforms/android/app/src/main/AndroidManifest.xml
platforms/android/app/src/main/assets/www/cordova_plugins.js
platforms/android/app/src/main/assets/www/js/bindcard.js
platforms/android/app/src/main/assets/www/js/main.js
platforms/android/app/src/main/assets/www/js/qrcode.js
platforms/android/app/src/main/assets/www/js/register.js
platforms/android/app/src/main/assets/www/js/server.js
platforms/android/app/src/main/assets/www/main.html
platforms/android/app/src/main/assets/www/qrcode.html
platforms/android/app/src/main/assets/www/security.html
platforms/android/app/src/main/java/org/apache/cordova/plugin/Brightness/BrightnessPlugin.java [new file with mode: 0644]
platforms/android/app/src/main/res/drawable-hdpi/icon.png
platforms/android/app/src/main/res/drawable-ldpi/icon.png
platforms/android/app/src/main/res/drawable-mdpi/icon.png
platforms/android/app/src/main/res/drawable-xhdpi/icon.png
platforms/android/app/src/main/res/drawable-xxhdpi/icon.png
platforms/android/app/src/main/res/drawable-xxxhdpi/icon.png
platforms/android/app/src/main/res/drawable/icon.png
platforms/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
platforms/android/app/src/main/res/mipmap-ldpi/ic_launcher.png
platforms/android/app/src/main/res/mipmap-mdpi-v26/ic_launcher_foreground.png
platforms/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
platforms/android/app/src/main/res/mipmap-xhdpi-v26/ic_launcher_foreground.png
platforms/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
platforms/android/app/src/main/res/mipmap-xxhdpi-v26/ic_launcher_foreground.png
platforms/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
platforms/android/app/src/main/res/mipmap-xxxhdpi-v26/ic_launcher_foreground.png
platforms/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
platforms/android/app/src/main/res/xml/config.xml
platforms/android/platform_www/cordova_plugins.js
platforms/android/platform_www/plugins/cordova-plugin-brightness/www/brightness.js [new file with mode: 0644]
platforms/browser/browser.json
platforms/browser/platform_www/cordova_plugins.js
platforms/browser/platform_www/plugins/cordova-plugin-brightness/www/brightness.js [new file with mode: 0644]
platforms/ios/dlapp.xcodeproj/project.pbxproj
platforms/ios/dlapp/Images.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png
platforms/ios/dlapp/Images.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png
platforms/ios/dlapp/Images.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png
platforms/ios/dlapp/Images.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png
platforms/ios/dlapp/Images.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png
platforms/ios/dlapp/Images.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png
platforms/ios/dlapp/Images.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png
platforms/ios/dlapp/Images.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png
platforms/ios/dlapp/Images.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png
platforms/ios/dlapp/Images.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png
platforms/ios/dlapp/Images.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png
platforms/ios/dlapp/Images.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png
platforms/ios/dlapp/Images.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png
platforms/ios/dlapp/Images.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png
platforms/ios/dlapp/Images.xcassets/AppIcon.appiconset/ItunesArtwork@2x.png
platforms/ios/dlapp/Images.xcassets/iTunesArtwork@1x.png [new file with mode: 0644]
platforms/ios/dlapp/Images.xcassets/iTunesArtwork@2x.png [new file with mode: 0644]
platforms/ios/dlapp/Images.xcassets/iTunesArtwork@3x.png [new file with mode: 0644]
platforms/ios/dlapp/Plugins/cordova-plugin-brightness/Brightness.h [new file with mode: 0644]
platforms/ios/dlapp/Plugins/cordova-plugin-brightness/Brightness.m [new file with mode: 0644]
platforms/ios/dlapp/config.xml
platforms/ios/frameworks.json
platforms/ios/ios.json
platforms/ios/platform_www/cordova_plugins.js
platforms/ios/platform_www/plugins/cordova-plugin-brightness/www/brightness.js [new file with mode: 0644]
plugins/android.json
plugins/browser.json
plugins/cordova-plugin-brightness/package.json [new file with mode: 0644]
plugins/cordova-plugin-brightness/plugin.xml [new file with mode: 0644]
plugins/cordova-plugin-brightness/src/android/BrightnessPlugin.java [new file with mode: 0644]
plugins/cordova-plugin-brightness/src/ios/Brightness.h [new file with mode: 0644]
plugins/cordova-plugin-brightness/src/ios/Brightness.m [new file with mode: 0644]
plugins/cordova-plugin-brightness/www/brightness.js [new file with mode: 0644]
plugins/fetch.json
plugins/ios.json
www/js/qrcode.js
www/qrcode.html

index ad4f7f6..78076a9 100644 (file)
@@ -1,5 +1,5 @@
 {
-    "name": "com.supwisdom.dlapp",
+    "name": "com.dalicitycard.app",
     "version": "1.0.3",
     "lockfileVersion": 1,
     "requires": true,
             "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",
index 323d848..7f29550 100644 (file)
@@ -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",
index 476c50e..2b20a7d 100644 (file)
             {
               "xml": "<feature name=\"AppVersion\"><param name=\"android-package\" value=\"uk.co.whiteoctober.cordova.AppVersion\" /></feature>",
               "count": 1
+            },
+            {
+              "xml": "<feature name=\"Brightness\"><param name=\"android-package\" value=\"org.apache.cordova.plugin.Brightness.BrightnessPlugin\" /></feature>",
+              "count": 1
             }
           ]
         }
     },
     "cordova-plugin-wkwebview-engine": {
       "PACKAGE_NAME": "com.dalicitycard.app"
+    },
+    "cordova-plugin-brightness": {
+      "PACKAGE_NAME": "com.dalicitycard.app"
     }
   },
   "dependent_plugins": {},
       "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": {
     "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"
   }
 }
index 5b518d8..41524d3 100644 (file)
@@ -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
 }
 
index 64af5de..be551b3 100644 (file)
Binary files a/platforms/android/app/release/app-release.apk and b/platforms/android/app/release/app-release.apk differ
index 9b5f879..93b3137 100644 (file)
@@ -1,6 +1,5 @@
 <?xml version='1.0' encoding='utf-8'?>
-<manifest android:hardwareAccelerated="true" android:versionCode="10004" android:versionName="1.0.4" package="com.dalicitycard.app"
-          xmlns:android="http://schemas.android.com/apk/res/android">
+<manifest android:hardwareAccelerated="true" android:versionCode="10005" android:versionName="1.0.5" package="com.dalicitycard.app" 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" />
     <application android:hardwareAccelerated="true" android:icon="@mipmap/ic_launcher" android:label="@string/launcher_name" android:supportsRtl="true">
         <activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:screenOrientation="portrait" android:theme="@android:style/Theme.DeviceDefault.NoActionBar" android:windowSoftInputMode="adjustResize">
@@ -58,8 +57,7 @@
                 <category android:name="com.dalicitycard.app" />
             </intent-filter>
         </receiver>
-        <activity android:exported="true" android:name="cn.jpush.android.service.JNotifyActivity"
-                  android:taskAffinity="jpush.custom" android:theme="@android:style/Theme.Translucent.NoTitleBar">
+        <activity android:exported="true" android:name="cn.jpush.android.service.JNotifyActivity" android:taskAffinity="jpush.custom" android:theme="@android:style/Theme.Translucent.NoTitleBar">
             <intent-filter>
                 <action android:name="cn.jpush.android.intent.JNotifyActivity" />
                 <category android:name="com.dalicitycard.app" />
     <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
     <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
     <uses-permission android:name="android.permission.GET_TASKS" />
+    <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
 </manifest>
index ee6832d..951ded8 100644 (file)
@@ -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
index 27a0817..f7e91a2 100644 (file)
@@ -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);
index c5ba03b..e0a358f 100644 (file)
@@ -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"
+         });
+    }
index 1b5a036..79ae312 100644 (file)
@@ -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
index d10558e..f53220a 100644 (file)
@@ -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();
index c8eb688..64a6da6 100644 (file)
@@ -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) {
index 6d43efa..3ade7e7 100644 (file)
                             <div class="center-in"><img src="img/icon_securty.png" style="width:28px;height: 28px"></div>
                             <div class="aui-grid-label" style="margin-top:10px;">账户安全</div>
                         </div>
+                        <!--<div class="aui-col-xs-4" id="doorBtn">
+                            <div class="center-in"><img src="img/icon_door.png" style="width:28px;height: 28px"></div>
+                            <div class="aui-grid-label" style="margin-top:10px;">远程开门</div>
+                        </div>-->
                     </div>
                 </div>
             </section>
                     </div>
                 </div>
             </div>
-            <section class="aui-content aui-grid " style="display:none;">
+            <section class="aui-content aui-grid ">
                 <div class="aui-row aui-margin-t-10">
                     <div class="aui-col-xs-4 aui-border-r">
                         <big class="aui-text-warning" id="user-amount">0.00</big>
                     </div>
                 </li>
             </ul>
-            <div style="padding: 20px;margin-top: 40px;">
-                <a href="javascript:app.logout();" class="weui-btn weui-btn_warn">退出登录</a>
-            </div>
         </section>
     </div>
     <footer class="aui-bar aui-bar-tab aui-border-t" id="footer">
index ca6cb07..48e9b69 100644 (file)
@@ -15,7 +15,7 @@
 </head>
 <body style="background: #fff"  >
     <header class="aui-bar aui-bar-nav" style="padding-top:25px;">
-        <a class="aui-pull-left" href="main.html">
+        <a class="aui-pull-left" href="app.backTo()">
             <span class="aui-iconfont aui-icon-left"></span>
         </a>
         <div class="aui-title">付款码</div>
index f6ddd43..39a40ca 100644 (file)
@@ -50,7 +50,9 @@
                 </div>
             </li>
         </ul>
-
+        <div style="padding: 20px;margin-top: 40px;">
+            <a href="javascript:app.logout();" class="weui-btn weui-btn_warn">退出登录</a>
+        </div>
     </section>
 </body>
 
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 (file)
index 0000000..6a42ff4
--- /dev/null
@@ -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;
+       }
+}
index 4edb4c6..1769fc5 100644 (file)
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
index 0508de6..1769fc5 100644 (file)
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
index ed81661..92a3334 100644 (file)
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
index b764a7e..4f54d23 100644 (file)
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
index 3c7efa4..ea73508 100644 (file)
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
index 8c027a7..8b754c8 100644 (file)
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
index b764a7e..1769fc5 100644 (file)
Binary files a/platforms/android/app/src/main/res/drawable/icon.png and b/platforms/android/app/src/main/res/drawable/icon.png differ
index 4edb4c6..1769fc5 100644 (file)
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
index 0508de6..530c91d 100644 (file)
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
index ed81661..92a3334 100644 (file)
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
index ed81661..92a3334 100644 (file)
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
index b764a7e..4f54d23 100644 (file)
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
index b764a7e..4f54d23 100644 (file)
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
index 3c7efa4..ea73508 100644 (file)
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
index 3c7efa4..ea73508 100644 (file)
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
index 8c027a7..8b754c8 100644 (file)
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
index 8c027a7..8b754c8 100644 (file)
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
index cda74bc..59faded 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version='1.0' encoding='utf-8'?>
-<widget id="com.dalicitycard.app" version="1.0.4" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
+<widget id="com.dalicitycard.app" version="1.0.5" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
     <feature name="Fingerprint">
         <param name="android-package" value="de.niklasmerz.cordova.fingerprint.Fingerprint" />
     </feature>
@@ -40,6 +40,9 @@
     <feature name="AppVersion">
         <param name="android-package" value="uk.co.whiteoctober.cordova.AppVersion" />
     </feature>
+    <feature name="Brightness">
+        <param name="android-package" value="org.apache.cordova.plugin.Brightness.BrightnessPlugin" />
+    </feature>
     <name short="大理市民卡">dlapp</name>
     <description>
         A sample Apache Cordova application that responds to the deviceready event.
index ee6832d..951ded8 100644 (file)
@@ -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 (file)
index 0000000..c1111d6
--- /dev/null
@@ -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]);
+};
+
+});
index 13a6fc8..fb5ae44 100644 (file)
     },
     "cordova-plugin-wkwebview-engine": {
       "PACKAGE_NAME": "com.supwisdom.dlapp"
+    },
+    "cordova-plugin-brightness": {
+      "PACKAGE_NAME": "com.dalicitycard.app"
     }
   },
   "dependent_plugins": {},
       "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": {
     "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"
   }
 }
index 3f30e69..5aef346 100644 (file)
@@ -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 (file)
index 0000000..87048a1
--- /dev/null
@@ -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]);
+};
+
+});
index d2839b7..50e0385 100644 (file)
@@ -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 */
                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 = "<group>"; };
                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 = "<group>"; };
                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 = "<group>"; 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 = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; explicitFileType = undefined; includeInIndex = 0; };
 /* End PBXFileReference section */
 
 /* Begin PBXFrameworksBuildPhase section */
                                648BD3182CD64A77AD2D447B /* CDVWKWebViewEngine.h */,
                                1E5CB6025B2E4D14ABFDB037 /* CDVWKWebViewUIDelegate.h */,
                                7DC7711D3C76485B9E422E3A /* CDVWKProcessPoolFactory.h */,
+                               1E4D2B8A1F474D9883C50B86 /* Brightness.m */,
+                               817A61F7D48245FA9567B115 /* Brightness.h */,
                        );
                        name = Plugins;
                        path = dlapp/Plugins;
                                562D29FCB1FB4F86B95BB2BC /* CDVWKWebViewEngine.m in Sources */,
                                F68EA21E51A3463A8FE2EE92 /* CDVWKWebViewUIDelegate.m in Sources */,
                                1F969D21D7EF4CF1A547A1DF /* CDVWKProcessPoolFactory.m in Sources */,
+                               C0A6FD40F47B434496535606 /* Brightness.m in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index ccdc491..93f7d4b 100644 (file)
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
index 5b1a340..338c489 100644 (file)
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
index d233176..26304e4 100644 (file)
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
index 908f73c..3179c09 100644 (file)
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
index 7716580..6807263 100644 (file)
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
index 0d3a8dc..3f765b9 100644 (file)
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
index 5b1a340..338c489 100644 (file)
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
index d0ec9ec..5159c6d 100644 (file)
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
index 35bb3ba..a5394ab 100644 (file)
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
index 35bb3ba..a5394ab 100644 (file)
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
index cb4580a..28db6a7 100644 (file)
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
index 65bf622..ee96b32 100644 (file)
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
index 6b6e1b1..f4e7346 100644 (file)
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
index 3a0d3be..86c995d 100644 (file)
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
index e347795..eb0ca49 100644 (file)
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 (file)
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 (file)
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 (file)
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 (file)
index 0000000..af7f99b
--- /dev/null
@@ -0,0 +1,15 @@
+/**
+ * @author Evgeniy Lukovsky
+ *
+ */
+
+
+#import <Cordova/CDV.h>
+
+@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 (file)
index 0000000..be09832
--- /dev/null
@@ -0,0 +1,39 @@
+/**
+ * @author Evgeniy Lukovsky
+ *
+ */
+
+#import <UIKit/UIScreen.h>
+#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
index 14bae9c..a06aded 100755 (executable)
@@ -64,6 +64,9 @@
     <feature name="CDVWKWebViewEngine">
         <param name="ios-package" value="CDVWKWebViewEngine" />
     </feature>
+    <feature name="Brightness">
+        <param name="ios-package" value="Brightness" />
+    </feature>
     <name short="大理市民卡">dlapp</name>
     <description>
         A sample Apache Cordova application that responds to the deviceready event.
index c15fc84..71928cb 100644 (file)
@@ -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,
index 3a70ab7..7b9d86f 100644 (file)
             {
               "xml": "<preference name=\"CordovaWebViewEngine\" value=\"CDVWKWebViewEngine\" />",
               "count": 1
+            },
+            {
+              "xml": "<feature name=\"Brightness\"><param name=\"ios-package\" value=\"Brightness\" /></feature>",
+              "count": 1
             }
           ]
         }
     },
     "cordova-plugin-wkwebview-engine": {
       "PACKAGE_NAME": "$(PRODUCT_BUNDLE_IDENTIFIER)"
+    },
+    "cordova-plugin-brightness": {
+      "PACKAGE_NAME": "$(PRODUCT_BUNDLE_IDENTIFIER)"
     }
   },
   "dependent_plugins": {},
       "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": {
     "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"
   }
 }
index 99f7689..eca1f34 100644 (file)
@@ -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 (file)
index 0000000..c1111d6
--- /dev/null
@@ -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]);
+};
+
+});
index 3736fc4..5cd402b 100644 (file)
@@ -51,6 +51,9 @@
     },
     "cordova-plugin-wkwebview-engine": {
       "PACKAGE_NAME": "com.dalicitycard.app"
+    },
+    "cordova-plugin-brightness": {
+      "PACKAGE_NAME": "com.dalicitycard.app"
     }
   },
   "dependent_plugins": {
index 4315c7b..1eb645a 100644 (file)
@@ -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 (file)
index 0000000..af91d83
--- /dev/null
@@ -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 (file)
index 0000000..9b56025
--- /dev/null
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<plugin xmlns="http://www.phonegap.com/ns/plugins/1.0"
+               xmlns:android="http://schemas.android.com/apk/res/android"
+           id="cordova-plugin-brightness"
+      version="0.1.5">
+    <name>Brightness</name>
+
+       <author>Evgeniy Lukovsky</author>
+
+       <license>MIT</license>
+
+       <description>
+               This plugin gives you the ability to get and set the screen brightness
+       </description>
+
+    <js-module src="www/brightness.js" name="Brightness">
+        <clobbers target="cordova.plugins.brightness" />
+    </js-module>
+
+       <info>
+               This plugin gives you the ability to get and set the screen brightness. Also recently I have added the function for keep screen on.
+       </info>
+
+    <!-- android -->
+    <platform name="android">
+        <config-file target="res/xml/config.xml" parent="/*">
+            <feature name="Brightness">
+                <param name="android-package" value="org.apache.cordova.plugin.Brightness.BrightnessPlugin"/>
+            </feature>
+        </config-file>
+
+       <source-file src="src/android/BrightnessPlugin.java" target-dir="src/org/apache/cordova/plugin/Brightness" />
+
+     </platform>
+
+     <!-- ios -->
+     <platform name="ios">
+         <config-file target="config.xml" parent="/*">
+             <feature name="Brightness">
+                 <param name="ios-package" value="Brightness" />
+             </feature>
+         </config-file>
+
+         <header-file src="src/ios/Brightness.h" />
+         <source-file src="src/ios/Brightness.m" />
+
+        <framework src="UIKit.framework" weak="true" />
+
+     </platform>
+
+</plugin>
diff --git a/plugins/cordova-plugin-brightness/src/android/BrightnessPlugin.java b/plugins/cordova-plugin-brightness/src/android/BrightnessPlugin.java
new file mode 100644 (file)
index 0000000..6a42ff4
--- /dev/null
@@ -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 (file)
index 0000000..af7f99b
--- /dev/null
@@ -0,0 +1,15 @@
+/**
+ * @author Evgeniy Lukovsky
+ *
+ */
+
+
+#import <Cordova/CDV.h>
+
+@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 (file)
index 0000000..be09832
--- /dev/null
@@ -0,0 +1,39 @@
+/**
+ * @author Evgeniy Lukovsky
+ *
+ */
+
+#import <UIKit/UIScreen.h>
+#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 (file)
index 0000000..4b9ea4b
--- /dev/null
@@ -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]);
+};
index c8f43cc..ebfe8ce 100644 (file)
     },
     "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
index 26cc800..1ec3afc 100644 (file)
@@ -52,6 +52,9 @@
     },
     "cordova-plugin-wkwebview-engine": {
       "PACKAGE_NAME": "$(PRODUCT_BUNDLE_IDENTIFIER)"
+    },
+    "cordova-plugin-brightness": {
+      "PACKAGE_NAME": "$(PRODUCT_BUNDLE_IDENTIFIER)"
     }
   },
   "dependent_plugins": {
index 1b5a036..79ae312 100644 (file)
@@ -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
index ca6cb07..48e9b69 100644 (file)
@@ -15,7 +15,7 @@
 </head>
 <body style="background: #fff"  >
     <header class="aui-bar aui-bar-nav" style="padding-top:25px;">
-        <a class="aui-pull-left" href="main.html">
+        <a class="aui-pull-left" href="app.backTo()">
             <span class="aui-iconfont aui-icon-left"></span>
         </a>
         <div class="aui-title">付款码</div>