package com.hughisaacs2.cordova.plugins.androidscreensaverplugin;

import android.annotation.TargetApi;
import android.service.dreams.DreamService;
import android.webkit.WebView;
import org.apache.cordova.CallbackContext;
import org.apache.cordova.CordovaArgs;
import org.apache.cordova.CordovaInterface;
import org.apache.cordova.CordovaPlugin;
import org.apache.cordova.CordovaWebView;
import org.apache.cordova.*;

@TargetApi(17)
public class ScreensaverProvider extends DreamService implements CordovaInterface {
     @Override
     CordovaWebView cwv;
    public void onAttachedToWindow() {
        super.onAttachedToWindow();
        // Allow user touch
        setInteractive(true);
        // Hide system UI
        setFullscreen(true);
        // Set the dream layout
	
        setContentView(R.layout.cordova_screen_saver);
        cwv = (CordovaWebView) findViewById(R.id.CordovaScreenSaverWebView);

        String screenSaverIndex = preferences.getString("ScreenSaverIndex", "index.html");
        cwv.loadUrl(screenSaverIndex);
    }
}

@@ -100,16 +100,48 @@
 etApi;%0D%0A
+import android.content.Intent;%0D%0A
 import a
@@ -196,23 +196,222 @@
 oid.
-webkit.WebView;
+view.View;%0D%0Aimport android.webkit.WebChromeClient;%0D%0Aimport android.webkit.WebView;%0D%0A%0D%0Aimport android.app.ActivityManager;%0D%0Aimport android.os.Build;%0D%0Aimport android.graphics.Color;%0D%0Aimport android.content.Context;%0D%0A
 %0D%0Aim
@@ -728,36 +728,8 @@
 ice 
-implements CordovaInterface 
 %7B%0D%0A 
@@ -1000,9 +1000,8 @@
 ut%0D%0A
-%09
 %0D%0A  
@@ -1006,16 +1006,444 @@
         
+cwv webview = new CordovaWebView(this);%0D%0A        /*%0D%0A        WebView webView = new WebView(this);%0D%0A        setContentView(webView);%0D%0A        webView.getSettings().setJavaScriptEnabled(true);%0D%0A        webView.getSettings().setGeolocationEnabled(true);%0D%0A        webView.getSettings().setDomStorageEnabled(true);%0D%0A        webView.getSettings().setAllowFileAccess(true);%0D%0A%0D%0A        webView.loadUrl(screenSaverIndex);%0D%0A*/%0D%0A        //
 setConte
@@ -1486,24 +1486,26 @@
 );%0D%0A        
+//
 cwv = (Cordo
@@ -1558,26 +1558,24 @@
 rWebView);%0D%0A
-%0D%0A
         Stri
@@ -1674,32 +1674,60 @@
 loadUrl(
+%22file:///android_asset/www/
 screen
-S
+s
 aver
-Index
+.html%22
 );%0D%0A    

Update ScreensaverProvider.java