diff --git a/package.json b/package.json
index 2d44c1b..b5169db 100644
--- a/package.json
+++ b/package.json
@@ -5,16 +5,18 @@
"cordova": {
"id": "com.lukemiles.screenshot",
"platforms": [
+ "android",
"ios"
]
},
"repository": {
"type": "git",
- "url": "https://github.com/restocks/cordova-plugin-detect-screenshot"
+ "url": "https://github.com/AlejandroOrozco/cordova-plugin-detect-screenshot"
},
"keywords": [
"cordova",
"ecosystem:cordova",
+ "cordova-android",
"cordova-ios"
],
"author": "Restocks",
diff --git a/plugin.xml b/plugin.xml
index 6e8d07a..d8d20cc 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -1,17 +1,31 @@
- cordova-plugin-screenshot
-
+ cordova-plugin-screenshot
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/android/plugin.gradle b/src/android/plugin.gradle
new file mode 100644
index 0000000..f7dd34f
--- /dev/null
+++ b/src/android/plugin.gradle
@@ -0,0 +1,10 @@
+repositories {
+ maven {
+ url "http://dl.bintray.com/piasy/maven"
+ }
+}
+
+dependencies {
+ compile 'com.github.piasy:rxscreenshotdetector:1.2.0'
+ compile 'com.trello.rxlifecycle2:rxlifecycle-components:2.0.1'
+}
\ No newline at end of file
diff --git a/src/android/screenshot.java b/src/android/screenshot.java
new file mode 100644
index 0000000..bb1977c
--- /dev/null
+++ b/src/android/screenshot.java
@@ -0,0 +1,68 @@
+package org.android.screenshot;
+
+ import android.app.Activity;
+ import android.net.Uri;
+ import android.os.Bundle;
+ import com.github.piasy.rxscreenshotdetector.RxScreenshotDetector;
+ import com.google.android.gms.appindexing.Action;
+ import com.google.android.gms.appindexing.AppIndex;
+ import com.google.android.gms.appindexing.Thing;
+ import com.google.android.gms.common.api.GoogleApiClient;
+ import com.trello.rxlifecycle2.LifecycleProvider;
+ import com.trello.rxlifecycle2.LifecycleTransformer;
+ import com.trello.rxlifecycle2.RxLifecycle;
+ import com.trello.rxlifecycle2.android.ActivityEvent;
+ import com.trello.rxlifecycle2.android.RxLifecycleAndroid;
+
+ import io.reactivex.Observable;
+ import io.reactivex.android.schedulers.AndroidSchedulers;
+ import io.reactivex.functions.Consumer;
+ import io.reactivex.schedulers.Schedulers;
+ import io.reactivex.subjects.BehaviorSubject;
+
+ import android.os.Bundle;
+ import android.view.Gravity;
+ import android.widget.Toast;
+
+ import org.apache.cordova.*;
+
+ import java.lang.reflect.Method;
+
+ import javax.annotation.Nonnull;
+
+ import static android.icu.lang.UCharacter.GraphemeClusterBreak.T;
+
+ public class PrivacyScreenPlugin extends CordovaPlugin implements LifecycleProvider {
+
+ private final BehaviorSubject lifecycleSubject = BehaviorSubject.create();
+
+ public void initialize(CordovaInterface cordova, CordovaWebView webView) {
+ super.initialize(cordova, webView);
+ Activity activity = this.cordova.getActivity();
+ RxScreenshotDetector.start(activity).compose(this.bindToLifecycle()).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Consumer() {
+ @Override
+ public void accept(String s) throws Exception {
+ webView.loadUrl("javascript: alert('Screenshot');");
+ }
+ });
+ }
+
+ @Nonnull
+ @Override
+ public Observable lifecycle() {
+ return lifecycleSubject.hide();
+ }
+
+ @Nonnull
+ @Override
+ public LifecycleTransformer bindUntilEvent(@Nonnull ActivityEvent event) {
+ return RxLifecycle.bindUntilEvent(lifecycleSubject, event);
+ }
+
+ @Nonnull
+ @Override
+ public LifecycleTransformer bindToLifecycle() {
+ return RxLifecycleAndroid.bindActivity(lifecycleSubject);
+ }
+
+ }
\ No newline at end of file