// This needs to run before the super's constructor.
 private static Context setGlobalPrefs(Context context, CordovaPreferences preferences) {
   LOG.d(TAG, "*** XWalkCordovaView.setGlobalPrefs start");
   if (!hasSetStaticPref) {
     hasSetStaticPref = true;
     ApplicationInfo ai = null;
     try {
       ai =
           context
               .getPackageManager()
               .getApplicationInfo(
                   context.getApplicationContext().getPackageName(), PackageManager.GET_META_DATA);
     } catch (PackageManager.NameNotFoundException e) {
       throw new RuntimeException(e);
     }
     boolean prefAnimatable =
         preferences == null ? false : preferences.getBoolean("CrosswalkAnimatable", false);
     boolean manifestAnimatable =
         ai.metaData == null ? false : ai.metaData.getBoolean("CrosswalkAnimatable");
     // Selects between a TextureView (obeys framework transforms applied to view) or a SurfaceView
     // (better performance).
     XWalkPreferences.setValue(
         XWalkPreferences.ANIMATABLE_XWALK_VIEW, prefAnimatable || manifestAnimatable);
     if ((ai.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) {
       XWalkPreferences.setValue(XWalkPreferences.REMOTE_DEBUGGING, true);
     }
     XWalkPreferences.setValue(XWalkPreferences.JAVASCRIPT_CAN_OPEN_WINDOW, true);
     XWalkPreferences.setValue(XWalkPreferences.ALLOW_UNIVERSAL_ACCESS_FROM_FILE, true);
   }
   LOG.d(TAG, "*** XWalkCordovaView.setGlobalPrefs");
   return context;
 }
  @SuppressWarnings({"deprecation", "ResourceType"})
  protected void createViews() {
    // Why are we setting a constant as the ID? This should be investigated
    webView.getView().setId(1000);
    RelativeLayout.LayoutParams p =
        new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    webView.getView().setLayoutParams(p);

    if (preferences.contains("BackgroundColor")) {
      int backgroundColor = preferences.getInteger("BackgroundColor", Color.BLACK);
      // Background of activity:
      webView.getView().setBackgroundColor(backgroundColor);
    }

    webView.getView().requestFocusFromTouch();
  }
 @SuppressWarnings("deprecation")
 protected void loadConfig() {
   ConfigXmlParser parser = new ConfigXmlParser();
   parser.parse(getActivity());
   preferences = parser.getPreferences();
   preferences.setPreferencesBundle(getActivity().getIntent().getExtras());
   // preferences.set("webview", "io.syng.cordova.plugin.WebViewEngine");
   pluginEntries = parser.getPluginEntries();
   Config.init(getActivity());
 }
  private void loadUrl() {
    if (url == null || url.isEmpty()) {
      url = DEFAULT_DAPP;
    }

    if (webView == null) {
      init();
    }

    // If keepRunning
    this.keepRunning = preferences.getBoolean("KeepRunning", true);

    if (url.indexOf("dapp://") == 0) {
      url = url.replace("dapp://", "http://");
    }

    webView.loadUrlIntoView(url, true);
  }
  protected void init() {
    webView = makeWebView();
    createViews();
    if (!webView.isInitialized()) {
      webView.init(cordovaInterface, pluginEntries, preferences);
    }
    webView.getView().requestFocusFromTouch();
    cordovaInterface.onCordovaInit(webView.getPluginManager());
    // webView.clearCache();
    android.webkit.CookieManager.getInstance().removeAllCookie();

    // Wire the hardware volume controls to control media if desired.
    String volumePref = preferences.getString("DefaultVolumeStream", "");
    if ("media".equals(volumePref.toLowerCase(Locale.ENGLISH))) {
      getActivity().setVolumeControlStream(AudioManager.STREAM_MUSIC);
    }
    BaseActivity activity = (BaseActivity) getActivity();
    activity.hideToolbar(2);
    gestureDetector = new GestureDetector(webView.getContext(), this);
    webView.getView().setOnTouchListener(this);
  }