diff --git a/plugin.xml b/plugin.xml index fba5438..e45615d 100644 --- a/plugin.xml +++ b/plugin.xml @@ -10,7 +10,7 @@ - + diff --git a/src/android/screenshot.java b/src/android/ScreenshotPlugin.java similarity index 74% rename from src/android/screenshot.java rename to src/android/ScreenshotPlugin.java index 236e202..4727a5a 100644 --- a/src/android/screenshot.java +++ b/src/android/ScreenshotPlugin.java @@ -1,13 +1,7 @@ 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; @@ -20,29 +14,23 @@ 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 Screenshot extends CordovaPlugin implements LifecycleProvider { + public class ScreenshotPlugin 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(); + final CordovaWebView webView1 = webView; 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');"); + webView1.loadUrl("javascript: alert('Screenshot');"); } }); }