屏幕截屏
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;
+});
+});
diff --git a/platforms/browser/browser.json b/platforms/browser/browser.json
index 4b3e322..0661c52 100644
--- a/platforms/browser/browser.json
+++ b/platforms/browser/browser.json
@@ -105,6 +105,9 @@
},
"cordova-plugin-fingerprint-aio": {
"PACKAGE_NAME": "com.dalicitycard.app"
+ },
+ "cordova-plugin-prevent-screenshot-coffice": {
+ "PACKAGE_NAME": "com.dalipolice.app"
}
},
"dependent_plugins": {},
@@ -478,6 +481,14 @@
"clobbers": [
"Fingerprint"
]
+ },
+ {
+ "file": "plugins/cordova-plugin-prevent-screenshot-coffice/www/screenshot.js",
+ "id": "cordova-plugin-prevent-screenshot-coffice.screenshot",
+ "pluginId": "cordova-plugin-prevent-screenshot-coffice",
+ "clobbers": [
+ "window.plugins.preventscreenshot"
+ ]
}
],
"plugin_metadata": {
@@ -498,6 +509,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/browser/platform_www/cordova_plugins.js b/platforms/browser/platform_www/cordova_plugins.js
index 41eda28..aca6ac1 100644
--- a/platforms/browser/platform_www/cordova_plugins.js
+++ b/platforms/browser/platform_www/cordova_plugins.js
@@ -369,6 +369,14 @@
"clobbers": [
"Fingerprint"
]
+ },
+ {
+ "file": "plugins/cordova-plugin-prevent-screenshot-coffice/www/screenshot.js",
+ "id": "cordova-plugin-prevent-screenshot-coffice.screenshot",
+ "pluginId": "cordova-plugin-prevent-screenshot-coffice",
+ "clobbers": [
+ "window.plugins.preventscreenshot"
+ ]
}
];
module.exports.metadata =
@@ -391,7 +399,8 @@
"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"
}
// BOTTOM OF METADATA
});
\ No newline at end of file
diff --git a/platforms/browser/platform_www/plugins/cordova-plugin-prevent-screenshot-coffice/www/screenshot.js b/platforms/browser/platform_www/plugins/cordova-plugin-prevent-screenshot-coffice/www/screenshot.js
new file mode 100644
index 0000000..120688f
--- /dev/null
+++ b/platforms/browser/platform_www/plugins/cordova-plugin-prevent-screenshot-coffice/www/screenshot.js
@@ -0,0 +1,39 @@
+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;
+});
+});
diff --git a/platforms/ios/dlapp.xcodeproj/project.pbxproj b/platforms/ios/dlapp.xcodeproj/project.pbxproj
index a0dceb2..361fbf5 100644
--- a/platforms/ios/dlapp.xcodeproj/project.pbxproj
+++ b/platforms/ios/dlapp.xcodeproj/project.pbxproj
@@ -65,6 +65,8 @@
F939AD8D22BB769B006B371B /* libsqlite3.0.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = F939AD8C22BB769B006B371B /* libsqlite3.0.tbd */; };
FDE92C386167415E8040F8AB /* AFURLResponseSerialization.m in Sources */ = {isa = PBXBuildFile; fileRef = FDEE8379D7A34C55A616F700 /* AFURLResponseSerialization.m */; };
81B8C05354704A02AE1560A0 /* Fingerprint.swift in Sources */ = {isa = PBXBuildFile; fileRef = 39BDB5993A0D495C9E97E995 /* Fingerprint.swift */; };
+ F70AC332CD71455D9E103429 /* ScreenshotBlocker.m in Sources */ = {isa = PBXBuildFile; fileRef = 8BD5959A12D340C3AB8685C0 /* ScreenshotBlocker.m */; };
+ 1ED02270B4D74F8BB970350D /* ScreenRecordingDetector.m in Sources */ = {isa = PBXBuildFile; fileRef = E806644FDDDD4DB9B0A7D6E4 /* ScreenRecordingDetector.m */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@@ -198,6 +200,10 @@
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; };
39BDB5993A0D495C9E97E995 /* Fingerprint.swift */ = {isa = PBXFileReference; name = "Fingerprint.swift"; path = "cordova-plugin-fingerprint-aio/Fingerprint.swift"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.swift; explicitFileType = undefined; includeInIndex = 0; };
705239B1B7D9402DA8A9FDA7 /* Bridging-Header.h */ = {isa = PBXFileReference; name = "Bridging-Header.h"; path = "cordova-plugin-fingerprint-aio/Bridging-Header.h"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; explicitFileType = undefined; includeInIndex = 0; };
+ 8BD5959A12D340C3AB8685C0 /* ScreenshotBlocker.m */ = {isa = PBXFileReference; name = "ScreenshotBlocker.m"; path = "cordova-plugin-prevent-screenshot-coffice/ScreenshotBlocker.m"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; explicitFileType = undefined; includeInIndex = 0; };
+ E806644FDDDD4DB9B0A7D6E4 /* ScreenRecordingDetector.m */ = {isa = PBXFileReference; name = "ScreenRecordingDetector.m"; path = "cordova-plugin-prevent-screenshot-coffice/ScreenRecordingDetector.m"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; explicitFileType = undefined; includeInIndex = 0; };
+ 5FA4467FDA284333A275FA08 /* ScreenshotBlocker.h */ = {isa = PBXFileReference; name = "ScreenshotBlocker.h"; path = "cordova-plugin-prevent-screenshot-coffice/ScreenshotBlocker.h"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; explicitFileType = undefined; includeInIndex = 0; };
+ 6C8C62629761432796084184 /* ScreenRecordingDetector.h */ = {isa = PBXFileReference; name = "ScreenRecordingDetector.h"; path = "cordova-plugin-prevent-screenshot-coffice/ScreenRecordingDetector.h"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; explicitFileType = undefined; includeInIndex = 0; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -409,6 +415,10 @@
817A61F7D48245FA9567B115 /* Brightness.h */,
39BDB5993A0D495C9E97E995 /* Fingerprint.swift */,
705239B1B7D9402DA8A9FDA7 /* Bridging-Header.h */,
+ 8BD5959A12D340C3AB8685C0 /* ScreenshotBlocker.m */,
+ E806644FDDDD4DB9B0A7D6E4 /* ScreenRecordingDetector.m */,
+ 5FA4467FDA284333A275FA08 /* ScreenshotBlocker.h */,
+ 6C8C62629761432796084184 /* ScreenRecordingDetector.h */,
);
name = Plugins;
path = dlapp/Plugins;
@@ -602,6 +612,8 @@
1F969D21D7EF4CF1A547A1DF /* CDVWKProcessPoolFactory.m in Sources */,
C0A6FD40F47B434496535606 /* Brightness.m in Sources */,
81B8C05354704A02AE1560A0 /* Fingerprint.swift in Sources */,
+ F70AC332CD71455D9E103429 /* ScreenshotBlocker.m in Sources */,
+ 1ED02270B4D74F8BB970350D /* ScreenRecordingDetector.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
diff --git a/platforms/ios/dlapp/Plugins/cordova-plugin-prevent-screenshot-coffice/ScreenRecordingDetector.h b/platforms/ios/dlapp/Plugins/cordova-plugin-prevent-screenshot-coffice/ScreenRecordingDetector.h
new file mode 100644
index 0000000..15e0a26
--- /dev/null
+++ b/platforms/ios/dlapp/Plugins/cordova-plugin-prevent-screenshot-coffice/ScreenRecordingDetector.h
@@ -0,0 +1,21 @@
+//
+// ScreenRecordingDetector.h
+//
+
+/*
+ScreenRecordingDetector checks for screen capturing as well as airplay mirroring
+*/
+
+#import <Foundation/Foundation.h>
+#import <UIKit/UIKit.h>
+
+extern NSString *kScreenRecordingDetectorRecordingStatusChangedNotification;
+
+@interface ScreenRecordingDetector : NSObject
+
++(instancetype)sharedInstance;
++ (void)triggerDetectorTimer;
++ (void)stopDetectorTimer;
+- (BOOL)isRecording;
+
+@end
\ No newline at end of file
diff --git a/platforms/ios/dlapp/Plugins/cordova-plugin-prevent-screenshot-coffice/ScreenRecordingDetector.m b/platforms/ios/dlapp/Plugins/cordova-plugin-prevent-screenshot-coffice/ScreenRecordingDetector.m
new file mode 100644
index 0000000..a7252e8
--- /dev/null
+++ b/platforms/ios/dlapp/Plugins/cordova-plugin-prevent-screenshot-coffice/ScreenRecordingDetector.m
@@ -0,0 +1,80 @@
+//
+// ScreenRecordingDetector.m
+// ScreenCaptureDetector
+//
+//
+
+#import "ScreenRecordingDetector.h"
+float const kScreenRecordingDetectorTimerInterval = 1.0;
+NSString *kScreenRecordingDetectorRecordingStatusChangedNotification = @"kScreenRecordingDetectorRecordingStatusChangedNotification";
+
+@interface ScreenRecordingDetector()
+
+@property BOOL lastRecordingState;
+@property NSTimer *timer;
+
+@end
+@implementation ScreenRecordingDetector
+
+
++ (instancetype)sharedInstance {
+ static ScreenRecordingDetector *sharedInstance = nil;
+ static dispatch_once_t onceToken;
+ dispatch_once(&onceToken, ^{
+ sharedInstance = [[self alloc] init];
+ });
+ return sharedInstance;
+}
+- (id)init {
+ if (self = [super init]) {
+ // do some init stuff here..
+ self.lastRecordingState = NO; // initially the recording state is 'NO'. This is the default state.
+ self.timer = NULL;
+ }
+ return self;
+}
+- (BOOL)isRecording {
+ for (UIScreen *screen in UIScreen.screens) {
+ if ([screen respondsToSelector:@selector(isCaptured)]) {
+ // iOS 11+ has isCaptured method.
+ if ([screen performSelector:@selector(isCaptured)]) {
+ return YES; // screen capture is active
+ } else if (screen.mirroredScreen) {
+ return YES; // mirroring is active
+ }
+ } else {
+ // iOS version below 11.0
+ if (screen.mirroredScreen)
+ return YES;
+ }
+ }
+ return NO;
+}
++ (void)triggerDetectorTimer {
+
+ ScreenRecordingDetector *detector = [ScreenRecordingDetector sharedInstance];
+ if (detector.timer) {
+ [self stopDetectorTimer];
+ }
+ detector.timer = [NSTimer scheduledTimerWithTimeInterval:kScreenRecordingDetectorTimerInterval
+ target:detector
+ selector:@selector(checkCurrentRecordingStatus:)
+ userInfo:nil
+ repeats:YES];
+}
+- (void)checkCurrentRecordingStatus:(NSTimer *)timer {
+ BOOL isRecording = [self isRecording];
+ if (isRecording != self.lastRecordingState) {
+ NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
+ [center postNotificationName: kScreenRecordingDetectorRecordingStatusChangedNotification object:nil];
+ }
+ self.lastRecordingState = isRecording;
+}
++ (void)stopDetectorTimer {
+ ScreenRecordingDetector *detector = [ScreenRecordingDetector sharedInstance];
+ if (detector.timer) {
+ [detector.timer invalidate];
+ detector.timer = NULL;
+ }
+}
+@end
\ No newline at end of file
diff --git a/platforms/ios/dlapp/Plugins/cordova-plugin-prevent-screenshot-coffice/ScreenshotBlocker.h b/platforms/ios/dlapp/Plugins/cordova-plugin-prevent-screenshot-coffice/ScreenshotBlocker.h
new file mode 100644
index 0000000..a1db059
--- /dev/null
+++ b/platforms/ios/dlapp/Plugins/cordova-plugin-prevent-screenshot-coffice/ScreenshotBlocker.h
@@ -0,0 +1,10 @@
+#import <Cordova/CDV.h>
+#import "ScreenRecordingDetector.h"
+
+
+@interface ScreenshotBlocker : CDVPlugin
+
+- (void)enable:(CDVInvokedUrlCommand*)command;
+-(void)listen:(CDVInvokedUrlCommand*)command;
+
+@end
diff --git a/platforms/ios/dlapp/Plugins/cordova-plugin-prevent-screenshot-coffice/ScreenshotBlocker.m b/platforms/ios/dlapp/Plugins/cordova-plugin-prevent-screenshot-coffice/ScreenshotBlocker.m
new file mode 100644
index 0000000..8397d55
--- /dev/null
+++ b/platforms/ios/dlapp/Plugins/cordova-plugin-prevent-screenshot-coffice/ScreenshotBlocker.m
@@ -0,0 +1,119 @@
+#import "ScreenshotBlocker.h"
+@interface ScreenshotBlocker() {
+ CDVInvokedUrlCommand * _eventCommand;
+}
+@end
+
+@implementation ScreenshotBlocker
+UIImageView* cover;
+- (void)pluginInitialize {
+ NSLog(@"Starting ScreenshotBlocker plugin");
+
+ [[NSNotificationCenter defaultCenter]addObserver:self
+ selector:@selector(appDidBecomeActive)
+ name:UIApplicationDidBecomeActiveNotification
+ object:nil];
+ [[NSNotificationCenter defaultCenter]addObserver:self
+ selector:@selector(applicationWillResignActive)
+ name:UIApplicationWillResignActiveNotification
+ object:nil];
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(tookScreeshot)
+ name:UIApplicationUserDidTakeScreenshotNotification
+ object:nil];
+
+ [[NSNotificationCenter defaultCenter]addObserver:self
+ selector:@selector(goingBackground)
+ name:UIApplicationWillResignActiveNotification
+ object:nil];
+
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(screenCaptureStatusChanged)
+ name:kScreenRecordingDetectorRecordingStatusChangedNotification
+ object:nil];
+
+ /*
+ userDidTakeScreenshotNotification
+ */
+
+}
+
+- (void)enable:(CDVInvokedUrlCommand *)command
+{
+ CDVPluginResult* pluginResult = nil;
+ NSLog(@"Abilita observers");
+ /*
+ [[NSNotificationCenter defaultCenter]addObserver:self
+ selector:@selector(appDidBecomeActive)
+ name:UIApplicationDidBecomeActiveNotification
+ object:nil];
+ [[NSNotificationCenter defaultCenter]addObserver:self
+ selector:@selector(applicationWillResignActive)
+ name:UIApplicationWillResignActiveNotification
+ object:nil];
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(screenCaptureStatusChanged)
+ name:kScreenRecordingDetectorRecordingStatusChangedNotification
+ object:nil];
+ pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
+ */
+}
+-(void)listen:(CDVInvokedUrlCommand*)command {
+ _eventCommand = command;
+}
+
+
+-(void) goingBackground {
+ NSLog(@"Me la scattion in bck");
+ if(_eventCommand!=nil) {
+ CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:@"background"];
+ [pluginResult setKeepCallbackAsBool:YES];
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:_eventCommand.callbackId];
+ }
+}
+-(void)tookScreeshot {
+ NSLog(@"fatta la foto?");
+ if(_eventCommand!=nil) {
+ CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:@"tookScreenshot"];
+ [pluginResult setKeepCallbackAsBool:YES];
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:_eventCommand.callbackId];
+ }
+
+}
+
+-(void)setupView {
+ BOOL isCaptured = [[UIScreen mainScreen] isCaptured];
+ NSLog(@"Is screen captured? %@", (isCaptured?@"SI":@"NO"));
+
+ if ([[ScreenRecordingDetector sharedInstance] isRecording]) {
+ [self webView].alpha = 0.f;
+ NSLog(@"Registro o prendo screenshots");
+ } else {
+ [self webView].alpha = 1.f;
+ NSLog(@"Non registro");
+
+ }
+}
+
+-(void)appDidBecomeActive {
+ [ScreenRecordingDetector triggerDetectorTimer];
+ if(cover!=nil) {
+ [cover removeFromSuperview];
+ cover = nil;
+ }
+}
+-(void)applicationWillResignActive {
+ [ScreenRecordingDetector stopDetectorTimer];
+ if(cover == nil) {
+ cover = [[UIImageView alloc] initWithFrame:[self.webView frame]];
+ cover.backgroundColor = [UIColor blackColor];
+ [self.webView addSubview:cover];
+ }
+}
+-(void)screenCaptureStatusChanged {
+ [self setupView];
+}
+
+
+@end
diff --git a/platforms/ios/dlapp/config.xml b/platforms/ios/dlapp/config.xml
index 90986af..8fb53bc 100755
--- a/platforms/ios/dlapp/config.xml
+++ b/platforms/ios/dlapp/config.xml
@@ -67,6 +67,10 @@
<feature name="Fingerprint">
<param name="ios-package" value="Fingerprint" />
</feature>
+ <feature name="screenshotName">
+ <param name="ios-package" value="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/ios/ios.json b/platforms/ios/ios.json
index 8247df1..2cc797d 100644
--- a/platforms/ios/ios.json
+++ b/platforms/ios/ios.json
@@ -83,6 +83,10 @@
{
"xml": "<feature name=\"Fingerprint\"><param name=\"ios-package\" value=\"Fingerprint\" /></feature>",
"count": 1
+ },
+ {
+ "xml": "<feature name=\"screenshotName\"><param name=\"ios-package\" value=\"ScreenshotBlocker\" /><param name=\"onload\" value=\"true\" /></feature>",
+ "count": 1
}
]
}
@@ -209,6 +213,9 @@
"cordova-plugin-fingerprint-aio": {
"FACEID_USAGE_DESCRIPTION": " ",
"PACKAGE_NAME": "$(PRODUCT_BUNDLE_IDENTIFIER)"
+ },
+ "cordova-plugin-prevent-screenshot-coffice": {
+ "PACKAGE_NAME": "$(PRODUCT_BUNDLE_IDENTIFIER)"
}
},
"dependent_plugins": {},
@@ -572,6 +579,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": {
@@ -592,6 +607,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/ios/platform_www/cordova_plugins.js b/platforms/ios/platform_www/cordova_plugins.js
index ed613ac..b4d865e 100644
--- a/platforms/ios/platform_www/cordova_plugins.js
+++ b/platforms/ios/platform_www/cordova_plugins.js
@@ -359,6 +359,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 = {
@@ -379,6 +387,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/ios/platform_www/plugins/cordova-plugin-prevent-screenshot-coffice/www/screenshot.js b/platforms/ios/platform_www/plugins/cordova-plugin-prevent-screenshot-coffice/www/screenshot.js
new file mode 100644
index 0000000..eaf17d5
--- /dev/null
+++ b/platforms/ios/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;
+});
+});