org.apache.cordova.CordovaPreferences Java Examples

The following examples show how to use org.apache.cordova.CordovaPreferences. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: XWalkCordovaView.java    From cordova-crosswalk-engine with Apache License 2.0 6 votes vote down vote up
private static Context setGlobalPrefs(Context context, CordovaPreferences preferences) {
    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);
    }
    return context;
}
 
Example #2
Source File: WebSocket.java    From WebSocket-for-Android with Apache License 2.0 5 votes vote down vote up
private static int getLogLevel(CordovaPreferences preferences) {
   String logLevel = preferences.getString("LogLevel", "ERROR");

   if ("VERBOSE".equals(logLevel)) {
       return android.util.Log.VERBOSE;
   } else if ("DEBUG".equals(logLevel)) {
       return android.util.Log.DEBUG;
   } else if ("INFO".equals(logLevel)) {
       return android.util.Log.INFO;
   } else if ("WARN".equals(logLevel)) {
       return android.util.Log.WARN;
   } else {
       return android.util.Log.ERROR;
   }
}
 
Example #3
Source File: MockCordovaWebViewImpl.java    From OsmGo with MIT License 5 votes vote down vote up
public void init(CordovaInterface cordova, List<PluginEntry> pluginEntries, CordovaPreferences preferences, WebView webView) {
  this.cordova = cordova;
  this.webView = webView;
  this.preferences = preferences;
  this.pluginManager = new PluginManager(this, this.cordova, pluginEntries);
  this.resourceApi = new CordovaResourceApi(this.context, this.pluginManager);
  nativeToJsMessageQueue = new NativeToJsMessageQueue();
  nativeToJsMessageQueue.addBridgeMode(new CapacitorEvalBridgeMode(webView, this.cordova));
  nativeToJsMessageQueue.setBridgeMode(0);
  this.cookieManager = new CapacitorCordovaCookieManager(webView);
  this.pluginManager.init();
}
 
Example #4
Source File: MockCordovaWebViewImpl.java    From OsmGo with MIT License 5 votes vote down vote up
@Override
public void init(CordovaInterface cordova, List<PluginEntry> pluginEntries, CordovaPreferences preferences) {
  this.cordova = cordova;
  this.preferences = preferences;
  this.pluginManager = new PluginManager(this, this.cordova, pluginEntries);
  this.resourceApi = new CordovaResourceApi(this.context, this.pluginManager);
  this.pluginManager.init();
}
 
Example #5
Source File: Bridge.java    From OsmGo with MIT License 5 votes vote down vote up
/**
 * Create the Bridge with a reference to the main {@link Activity} for the
 * app, and a reference to the {@link WebView} our app will use.
 * @param context
 * @param webView
 */
public Bridge(Activity context, WebView webView, List<Class<? extends Plugin>> initialPlugins, CordovaInterfaceImpl cordovaInterface, PluginManager pluginManager, CordovaPreferences preferences) {
  this.context = context;
  this.webView = webView;
  this.initialPlugins = initialPlugins;
  this.cordovaInterface = cordovaInterface;
  this.preferences = preferences;

  // Start our plugin execution threads and handlers
  handlerThread.start();
  taskHandler = new Handler(handlerThread.getLooper());

  Config.load(getActivity());

  // Initialize web view and message handler for it
  this.initWebView();
  this.msgHandler = new MessageHandler(this, webView, pluginManager);

  // Grab any intent info that our app was launched with
  Intent intent = context.getIntent();
  Uri intentData = intent.getData();
  this.intentUri = intentData;

  // Register our core plugins
  this.registerAllPlugins();

  this.loadWebView();
}
 
Example #6
Source File: CordovaGeckoViewEngine.java    From cordova-mozillaview-engine with Apache License 2.0 5 votes vote down vote up
/** Used when created via reflection. */
public CordovaGeckoViewEngine(Context context, CordovaPreferences preferences) {
    mCtx = context;
    webView = new CordovaGeckoView(this);
    //testView = new SystemWebView(context);
    prefs = preferences;
}
 
Example #7
Source File: StandardActivityTest.java    From keemob with MIT License 5 votes vote down vote up
@Test
public void checkBackgroundIntentCheck() {
    StandardActivity activity = (StandardActivity) mActivityRule.getActivity();
    final SystemWebView webView = (SystemWebView) activity.getWindow().getCurrentFocus();
    CordovaWebView webInterface = webView.getCordovaWebView();
    CordovaPreferences prefs = webInterface.getPreferences();
    assertFalse(prefs.getInteger("backgroundcolor", Color.BLACK) == Color.GREEN);
}
 
Example #8
Source File: InjectWebViewEngine.java    From cordova-plugin-fastrde-injectview with MIT License 5 votes vote down vote up
/** Used when created via reflection. */
public InjectWebViewEngine(Context context, CordovaPreferences preferences) {
    this(new InjectWebView(context));
    //super(context, preferences);
    Log.w("inject", "InjectWebViewEngine");

}
 
Example #9
Source File: SystemWebViewEngine.java    From cordova-plugin-app-update-demo with MIT License 4 votes vote down vote up
/** Used when created via reflection. */
public SystemWebViewEngine(Context context, CordovaPreferences preferences) {
    this(new SystemWebView(context), preferences);
}
 
Example #10
Source File: SystemWebViewEngine.java    From app-icon with MIT License 4 votes vote down vote up
public SystemWebViewEngine(SystemWebView webView, CordovaPreferences preferences) {
    this.preferences = preferences;
    this.webView = webView;
    cookieManager = new SystemCookieManager(webView);
}
 
Example #11
Source File: SystemWebViewEngine.java    From cordova-plugin-app-update-demo with MIT License 4 votes vote down vote up
public SystemWebViewEngine(SystemWebView webView, CordovaPreferences preferences) {
    this.preferences = preferences;
    this.webView = webView;
    cookieManager = new SystemCookieManager(webView);
}
 
Example #12
Source File: SystemWebViewEngine.java    From a2cardboard with Apache License 2.0 4 votes vote down vote up
/** Used when created via reflection. */
public SystemWebViewEngine(Context context, CordovaPreferences preferences) {
    this(new SystemWebView(context), preferences);
}
 
Example #13
Source File: SystemWebViewEngine.java    From a2cardboard with Apache License 2.0 4 votes vote down vote up
public SystemWebViewEngine(SystemWebView webView, CordovaPreferences preferences) {
    this.preferences = preferences;
    this.webView = webView;
    cookieManager = new SystemCookieManager(webView);
}
 
Example #14
Source File: SystemWebViewEngine.java    From cordova-plugin-intent with MIT License 4 votes vote down vote up
/** Used when created via reflection. */
public SystemWebViewEngine(Context context, CordovaPreferences preferences) {
    this(new SystemWebView(context), preferences);
}
 
Example #15
Source File: SystemWebViewEngine.java    From cordova-plugin-intent with MIT License 4 votes vote down vote up
public SystemWebViewEngine(SystemWebView webView, CordovaPreferences preferences) {
    this.preferences = preferences;
    this.webView = webView;
    cookieManager = new SystemCookieManager(webView);
}
 
Example #16
Source File: SystemWebViewEngine.java    From chappiecast with Mozilla Public License 2.0 4 votes vote down vote up
/** Used when created via reflection. */
public SystemWebViewEngine(Context context, CordovaPreferences preferences) {
    this(new SystemWebView(context));
}
 
Example #17
Source File: SystemWebViewEngine.java    From pychat with MIT License 4 votes vote down vote up
/** Used when created via reflection. */
public SystemWebViewEngine(Context context, CordovaPreferences preferences) {
    this(new SystemWebView(context), preferences);
}
 
Example #18
Source File: SystemWebViewEngine.java    From pychat with MIT License 4 votes vote down vote up
public SystemWebViewEngine(SystemWebView webView, CordovaPreferences preferences) {
    this.preferences = preferences;
    this.webView = webView;
    cookieManager = new SystemCookieManager(webView);
}
 
Example #19
Source File: XWalkCordovaView.java    From cordova-crosswalk-engine with Apache License 2.0 4 votes vote down vote up
public XWalkCordovaView(Context context, CordovaPreferences preferences) {
    super(setGlobalPrefs(context, preferences), (AttributeSet)null);
}
 
Example #20
Source File: XWalkWebViewEngine.java    From cordova-crosswalk-engine with Apache License 2.0 4 votes vote down vote up
/** Used when created via reflection. */
public XWalkWebViewEngine(Context context, CordovaPreferences preferences) {
    this.preferences = preferences;
    Runnable cancelCommand = new Runnable() {
        @Override
        public void run() {
            cordova.getActivity().finish();
        }
    };
    Runnable completeCommand = new Runnable() {
        @Override
        public void run() {
            cookieManager = new XWalkCordovaCookieManager();

            initWebViewSettings();
            exposeJsInterface(webView, bridge);
            loadExtensions();

            CordovaPlugin notifPlugin = new CordovaPlugin() {
                @Override
                public void onNewIntent(Intent intent) {
                    Log.i(TAG, "notifPlugin route onNewIntent() to XWalkView: " + intent.toString());
                    XWalkWebViewEngine.this.webView.onNewIntent(intent);
                }

                @Override
                public Object onMessage(String id, Object data) {
                    if (id.equals("captureXWalkBitmap")) {
                        // Capture bitmap on UI thread.
                        XWalkWebViewEngine.this.cordova.getActivity().runOnUiThread(new Runnable() {
                            public void run() {
                                XWalkWebViewEngine.this.webView.captureBitmapAsync(
                                        new XWalkGetBitmapCallback() {
                                    @Override
                                    public void onFinishGetBitmap(Bitmap bitmap,
                                            int response) {
                                        pluginManager.postMessage(
                                                "onGotXWalkBitmap", bitmap);
                                    }
                                });
                            }
                        });
                    }
                    return null;
                }
            };
            pluginManager.addService(new PluginEntry("XWalkNotif", notifPlugin));

            // Send the massage of xwalk's ready to plugin.
            if (pluginManager != null) {
                pluginManager.postMessage("onXWalkReady", this);
            }

            if (startUrl != null) {
                webView.load(startUrl, null);
            }
        }
    };
    activityDelegate = new XWalkActivityDelegate((Activity) context, cancelCommand, completeCommand);

    webView = new XWalkCordovaView(context, preferences);
}
 
Example #21
Source File: SystemWebViewEngine.java    From lona with GNU General Public License v3.0 4 votes vote down vote up
/** Used when created via reflection. */
public SystemWebViewEngine(Context context, CordovaPreferences preferences) {
    this(new SystemWebView(context), preferences);
}
 
Example #22
Source File: SystemWebViewEngine.java    From lona with GNU General Public License v3.0 4 votes vote down vote up
public SystemWebViewEngine(SystemWebView webView, CordovaPreferences preferences) {
    this.preferences = preferences;
    this.webView = webView;
    cookieManager = new SystemCookieManager(webView);
}
 
Example #23
Source File: SystemWebViewEngine.java    From countly-sdk-cordova with MIT License 4 votes vote down vote up
/** Used when created via reflection. */
public SystemWebViewEngine(Context context, CordovaPreferences preferences) {
    this(new SystemWebView(context), preferences);
}
 
Example #24
Source File: SystemWebViewEngine.java    From countly-sdk-cordova with MIT License 4 votes vote down vote up
public SystemWebViewEngine(SystemWebView webView, CordovaPreferences preferences) {
    this.preferences = preferences;
    this.webView = webView;
    cookieManager = new SystemCookieManager(webView);
}
 
Example #25
Source File: SystemWebViewEngine.java    From keemob with MIT License 4 votes vote down vote up
/** Used when created via reflection. */
public SystemWebViewEngine(Context context, CordovaPreferences preferences) {
    this(new SystemWebView(context), preferences);
}
 
Example #26
Source File: SystemWebViewEngine.java    From BigDataPlatform with GNU General Public License v3.0 4 votes vote down vote up
public SystemWebViewEngine(SystemWebView webView, CordovaPreferences preferences) {
    this.preferences = preferences;
    this.webView = webView;
    cookieManager = new SystemCookieManager(webView);
}
 
Example #27
Source File: SystemWebViewEngine.java    From xmall with MIT License 4 votes vote down vote up
/** Used when created via reflection. */
public SystemWebViewEngine(Context context, CordovaPreferences preferences) {
    this(new SystemWebView(context), preferences);
}
 
Example #28
Source File: SystemWebViewEngine.java    From xmall with MIT License 4 votes vote down vote up
public SystemWebViewEngine(SystemWebView webView, CordovaPreferences preferences) {
    this.preferences = preferences;
    this.webView = webView;
    cookieManager = new SystemCookieManager(webView);
}
 
Example #29
Source File: SystemWebViewEngine.java    From ultimate-cordova-webview-app with MIT License 4 votes vote down vote up
/** Used when created via reflection. */
public SystemWebViewEngine(Context context, CordovaPreferences preferences) {
    this(new SystemWebView(context), preferences);
}
 
Example #30
Source File: SystemWebViewEngine.java    From ultimate-cordova-webview-app with MIT License 4 votes vote down vote up
public SystemWebViewEngine(SystemWebView webView, CordovaPreferences preferences) {
    this.preferences = preferences;
    this.webView = webView;
    cookieManager = new SystemCookieManager(webView);
}