屏幕截屏
diff --git a/platforms/android/android.json b/platforms/android/android.json
index eb6d7bb..8d319b4 100644
--- a/platforms/android/android.json
+++ b/platforms/android/android.json
@@ -63,6 +63,10 @@
{
"xml": "<feature name=\"Fingerprint\"><param name=\"android-package\" value=\"de.niklasmerz.cordova.biometric.Fingerprint\" /></feature>",
"count": 1
+ },
+ {
+ "xml": "<feature name=\"screenshotName\"><param name=\"android-package\" value=\"com.coffice.ScreenshotBlocker\" /><param name=\"onload\" value=\"true\" /></feature>",
+ "count": 1
}
]
}
@@ -322,6 +326,9 @@
},
"cordova-plugin-fingerprint-aio": {
"PACKAGE_NAME": "com.dalipolice.app"
+ },
+ "cordova-plugin-prevent-screenshot-coffice": {
+ "PACKAGE_NAME": "com.dalipolice.app"
}
},
"dependent_plugins": {},
@@ -669,6 +676,14 @@
"clobbers": [
"Fingerprint"
]
+ },
+ {
+ "id": "cordova-plugin-prevent-screenshot-coffice.screenshot",
+ "file": "plugins/cordova-plugin-prevent-screenshot-coffice/www/screenshot.js",
+ "pluginId": "cordova-plugin-prevent-screenshot-coffice",
+ "clobbers": [
+ "window.plugins.preventscreenshot"
+ ]
}
],
"plugin_metadata": {
@@ -689,6 +704,7 @@
"cordova-plugin-app-version": "0.1.9",
"cordova-plugin-wkwebview-engine": "1.2.1",
"cordova-plugin-brightness": "0.1.5",
- "cordova-plugin-fingerprint-aio": "3.0.1"
+ "cordova-plugin-fingerprint-aio": "3.0.1",
+ "cordova-plugin-prevent-screenshot-coffice": "1.0.1"
}
}
diff --git a/platforms/android/app/build.gradle b/platforms/android/app/build.gradle
index 31d4b5c..e758e33 100644
--- a/platforms/android/app/build.gradle
+++ b/platforms/android/app/build.gradle
@@ -174,8 +174,8 @@
ndk {
abiFilters "armeabi"
}
- versionCode 14
- versionName '1.4.1'
+ versionCode 15
+ versionName '1.4.2'
targetSdkVersion 28
}
lintOptions {
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 dbec6c3..a989701 100644
--- a/platforms/android/app/src/main/assets/www/cordova_plugins.js
+++ b/platforms/android/app/src/main/assets/www/cordova_plugins.js
@@ -343,6 +343,14 @@
"clobbers": [
"Fingerprint"
]
+ },
+ {
+ "id": "cordova-plugin-prevent-screenshot-coffice.screenshot",
+ "file": "plugins/cordova-plugin-prevent-screenshot-coffice/www/screenshot.js",
+ "pluginId": "cordova-plugin-prevent-screenshot-coffice",
+ "clobbers": [
+ "window.plugins.preventscreenshot"
+ ]
}
];
module.exports.metadata = {
@@ -363,6 +371,7 @@
"cordova-plugin-app-version": "0.1.9",
"cordova-plugin-wkwebview-engine": "1.2.1",
"cordova-plugin-brightness": "0.1.5",
- "cordova-plugin-fingerprint-aio": "3.0.1"
+ "cordova-plugin-fingerprint-aio": "3.0.1",
+ "cordova-plugin-prevent-screenshot-coffice": "1.0.1"
};
});
\ No newline at end of file
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 78b896f..f302033 100644
--- a/platforms/android/app/src/main/assets/www/js/main.js
+++ b/platforms/android/app/src/main/assets/www/js/main.js
@@ -44,6 +44,7 @@
}
});
var uid = window.localStorage.getItem("uid");
+
window.JPush.setAlias({ sequence: 1, alias: uid },
(result) => {
var sequence = result.sequence
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 2b06b32..016f2d7 100644
--- a/platforms/android/app/src/main/assets/www/js/qrcode.js
+++ b/platforms/android/app/src/main/assets/www/js/qrcode.js
@@ -26,6 +26,8 @@
e.preventDefault();
app.backTo();
}, false);
+
+ window.plugins.preventscreenshot.disable(function(ret){}, function(ret){});
},
loadQrcode: function() {
$.showLoading("加载中");
diff --git a/platforms/android/app/src/main/java/com/coffice/ScreenshotBlocker.java b/platforms/android/app/src/main/java/com/coffice/ScreenshotBlocker.java
new file mode 100644
index 0000000..fe9cde3
--- /dev/null
+++ b/platforms/android/app/src/main/java/com/coffice/ScreenshotBlocker.java
@@ -0,0 +1,63 @@
+package com.coffice;
+
+import android.app.Activity;
+import android.view.WindowManager;
+
+import org.apache.cordova.*;
+import org.json.JSONArray;
+import org.json.JSONException;
+
+public class ScreenshotBlocker extends CordovaPlugin{
+ private com.coffice.ScreenshotBlocker mContext;
+
+ @Override
+ public void initialize(CordovaInterface cordova, CordovaWebView webView) {
+ super.initialize(cordova, webView);
+ Activity activity = this.cordova.getActivity();
+ activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
+ }
+
+ @Override
+ public boolean execute(String action, JSONArray data, final CallbackContext callbackContext) throws JSONException {
+ mContext = this;
+ if (action.equals("enable")) {
+ mContext.cordova.getActivity().runOnUiThread(new Runnable() {
+ public void run() {
+ try{
+ // Allow to make screenshots removing the FLAG_SECURE
+ if(android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
+ mContext.cordova.getActivity().getWindow().clearFlags(WindowManager.LayoutParams.FLAG_SECURE);
+ }
+ callbackContext.success("Success");
+ }catch(Exception e){
+ callbackContext.error(e.toString());
+ }
+ }
+ });
+
+ return true;
+ }else if (action.equals("disable")) {
+ mContext.cordova.getActivity().runOnUiThread(new Runnable() {
+ public void run() {
+ try{
+ // Allow to make screenshots removing the FLAG_SECURE
+ // Disable the creation of screenshots adding the FLAG_SECURE to the window
+ if(android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
+ mContext.cordova.getActivity().getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE,
+ WindowManager.LayoutParams.FLAG_SECURE);
+ }
+ callbackContext.success("Success");
+ }catch(Exception e){
+ callbackContext.error(e.toString());
+ }
+ }
+ });
+ return true;
+ }
+ else{
+ return false;
+ }
+
+ }
+
+}
diff --git a/platforms/android/app/src/main/res/xml/config.xml b/platforms/android/app/src/main/res/xml/config.xml
index ca7b3a0..019dfb6 100644
--- a/platforms/android/app/src/main/res/xml/config.xml
+++ b/platforms/android/app/src/main/res/xml/config.xml
@@ -43,6 +43,10 @@
<feature name="Fingerprint">
<param name="android-package" value="de.niklasmerz.cordova.biometric.Fingerprint" />
</feature>
+ <feature name="screenshotName">
+ <param name="android-package" value="com.coffice.ScreenshotBlocker" />
+ <param name="onload" value="true" />
+ </feature>
<name short="大理智警">dlapp</name>
<description>
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 dbec6c3..a989701 100644
--- a/platforms/android/platform_www/cordova_plugins.js
+++ b/platforms/android/platform_www/cordova_plugins.js
@@ -343,6 +343,14 @@
"clobbers": [
"Fingerprint"
]
+ },
+ {
+ "id": "cordova-plugin-prevent-screenshot-coffice.screenshot",
+ "file": "plugins/cordova-plugin-prevent-screenshot-coffice/www/screenshot.js",
+ "pluginId": "cordova-plugin-prevent-screenshot-coffice",
+ "clobbers": [
+ "window.plugins.preventscreenshot"
+ ]
}
];
module.exports.metadata = {
@@ -363,6 +371,7 @@
"cordova-plugin-app-version": "0.1.9",
"cordova-plugin-wkwebview-engine": "1.2.1",
"cordova-plugin-brightness": "0.1.5",
- "cordova-plugin-fingerprint-aio": "3.0.1"
+ "cordova-plugin-fingerprint-aio": "3.0.1",
+ "cordova-plugin-prevent-screenshot-coffice": "1.0.1"
};
});
\ No newline at end of file
diff --git a/platforms/android/platform_www/js/ourcodeworldpreventscreenshots.js b/platforms/android/platform_www/js/ourcodeworldpreventscreenshots.js
new file mode 100644
index 0000000..027f152
--- /dev/null
+++ b/platforms/android/platform_www/js/ourcodeworldpreventscreenshots.js
@@ -0,0 +1,42 @@
+/*global cordova, module*/
+(function(module){
+ function PreventScreenshots(){
+ var core = {};
+ var isEnabled = true;
+
+ var callFunctionIfExists = function(fn,params){
+ if(typeof(fn) !== "function"){
+ return false;
+ }
+
+ fn.call();
+ return true;
+ };
+
+ core.enable = function(success,error){
+ cordova.exec(function(data){
+ isEnabled = true;
+ callFunctionIfExists(success);
+ }, function(err){
+ callFunctionIfExists(error);
+ }, "OurCodeWorldpreventscreenshots", "enable", []);
+ };
+
+ core.disable = function(success,error){
+ cordova.exec(function(data){
+ isEnabled = false;
+ callFunctionIfExists(success);
+ }, function(err){
+ callFunctionIfExists(error);
+ }, "OurCodeWorldpreventscreenshots", "disable", []);
+ };
+
+ core.isEnabled = function(){
+ return isEnabled;
+ };
+
+ return core;
+ }
+
+ module.exports = new PreventScreenshots();
+})(module);
diff --git a/platforms/android/platform_www/plugins/com.ourcodeworld.preventscreenshots/www/ourcodeworldpreventscreenshots.js b/platforms/android/platform_www/plugins/com.ourcodeworld.preventscreenshots/www/ourcodeworldpreventscreenshots.js
new file mode 100644
index 0000000..e6e6879
--- /dev/null
+++ b/platforms/android/platform_www/plugins/com.ourcodeworld.preventscreenshots/www/ourcodeworldpreventscreenshots.js
@@ -0,0 +1,45 @@
+cordova.define("com.ourcodeworld.preventscreenshots.OurCodeWorldpreventscreenshots", function(require, exports, module) {
+/*global cordova, module*/
+(function(module){
+ function PreventScreenshots(){
+ var core = {};
+ var isEnabled = true;
+
+ var callFunctionIfExists = function(fn,params){
+ if(typeof(fn) !== "function"){
+ return false;
+ }
+
+ fn.call();
+ return true;
+ };
+
+ core.enable = function(success,error){
+ cordova.exec(function(data){
+ isEnabled = true;
+ callFunctionIfExists(success);
+ }, function(err){
+ callFunctionIfExists(error);
+ }, "OurCodeWorldpreventscreenshots", "enable", []);
+ };
+
+ core.disable = function(success,error){
+ cordova.exec(function(data){
+ isEnabled = false;
+ callFunctionIfExists(success);
+ }, function(err){
+ callFunctionIfExists(error);
+ }, "OurCodeWorldpreventscreenshots", "disable", []);
+ };
+
+ core.isEnabled = function(){
+ return isEnabled;
+ };
+
+ return core;
+ }
+
+ module.exports = new PreventScreenshots();
+})(module);
+
+});
diff --git a/platforms/android/platform_www/plugins/cordova-plugin-prevent-screenshot-coffice/www/screenshot.js b/platforms/android/platform_www/plugins/cordova-plugin-prevent-screenshot-coffice/www/screenshot.js
new file mode 100644
index 0000000..eaf17d5
--- /dev/null
+++ b/platforms/android/platform_www/plugins/cordova-plugin-prevent-screenshot-coffice/www/screenshot.js
@@ -0,0 +1,40 @@
+cordova.define("cordova-plugin-prevent-screenshot-coffice.screenshot", function(require, exports, module) {
+var screenshot = {
+ enable: function (successCallback, errorCallback) {
+ cordova.exec(successCallback, errorCallback, 'screenshotName', 'enable', []);
+ },
+ disable: function (successCallback, errorCallback) {
+ cordova.exec(successCallback, errorCallback, 'screenshotName', 'disable', []);
+ },
+ registerListener : function(callback) {
+ cordova.exec(callback, callback, 'screenshotName', 'listen', []);
+
+ }
+}
+
+cordova.addConstructor(function () {
+ if (!window.plugins) {window.plugins = {};}
+
+ window.plugins.preventscreenshot = screenshot;
+ document.addEventListener("onTookScreenshot",function(){
+ console.log('tookScreenshot');
+ });
+ document.addEventListener("onGoingBackground",function(){
+ console.log('BackgroundCalled');
+ });
+ screenshot.registerListener(function(me) {
+ console.log('received listener:',me);
+ if(me === "background") {
+ var event = new Event('onGoingBackground');
+ document.dispatchEvent(event);
+ return;
+ }
+ if(me === "tookScreenshot") {
+ var event = new Event('onTookScreenshot');
+ document.dispatchEvent(event);
+ return;
+ }
+ });
+ return window.plugins.preventscreenshot;
+});
+});