/** Used when created via reflection. */ public X5WebViewEngine(Context context, CordovaPreferences preferences) { if(!isInit) { QbSdk.PreInitCallback cb = new QbSdk.PreInitCallback() { @Override public void onViewInitFinished(boolean arg0) { } @Override public void onCoreInitFinished() { isInit = true; } }; QbSdk.initX5Environment(context, cb); } this.preferences = preferences; this.webView = new X5WebView(context); cookieManager = new X5CookieManager(webView); }
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; }
@Override public void init(CordovaInterface cordova, List<PluginEntry> pluginEntries, Whitelist whitelist, CordovaPreferences preferences) { if (this.cordova != null) { throw new IllegalStateException(); } this.cordova = cordova; this.whitelist = whitelist; this.preferences = preferences; pluginManager = new PluginManager(this, this.cordova, pluginEntries); resourceApi = new CordovaResourceApi(webview.getContext(), pluginManager); bridge = new CordovaBridge(pluginManager, new NativeToJsMessageQueue(this, cordova)); pluginManager.addService("App", "org.apache.cordova.CoreAndroid"); initWebViewSettings(); webview.init(this); exposeJsInterface(); }
/** * * @param prefs * the preference values form config.xml with the configuration/credentials * for the Nuance SpeechKit service * * @throws RuntimeError if prefs is missing require Nuance configuration/credential values */ protected Credentials(CordovaPreferences prefs) throws RuntimeException { this.serverUrl = prefs.getString(NUANCE_SERVER_URL, null); this.port = prefs.getInteger(NUANCE_SERVER_PORT, -1); this.useSsl = prefs.getBoolean(NUANCE_SERVER_SSL, true); this.certSummary = prefs.getString(NUANCE_CERT_SUMMARY, null); this.certData = prefs.getString(NUANCE_CERT_DATA, null); this.appId = prefs.getString(NUANCE_APP_ID, null); this.appKey = parseToByteArray(prefs.getString(NUANCE_APP_KEY, null)); RuntimeException ex = verify(prefs); if(ex != null){ throw ex; } }
private RuntimeException verify(CordovaPreferences prefs){ String err = ""; if(this.serverUrl == null){ err += NUANCE_SERVER_URL+" is missing! "; } if(this.port == -1){ err += NUANCE_SERVER_PORT+" is missing! "; } if(this.appId == null){ err += NUANCE_APP_ID+" is missing! "; } if(this.appKey == null){ String keyVal = prefs.getString(NUANCE_APP_KEY, null); if(keyVal != null) err += NUANCE_APP_KEY+" has wrong data: \""+keyVal+"\" "; else err += NUANCE_APP_KEY+" is missing! "; } if(err.length() > 0){ return new RuntimeException("Missing config.xml preferences value(s): "+err); } return null; }
public static boolean createInstance(Context ctx, CordovaPreferences prefs) { boolean isRecreated = false; if(instance == null){ instance = new NuanceEngine(ctx, prefs); isRecreated = true; } else if(ctx != instance._context){ instance.releaseResources(); instance = new NuanceEngine(ctx, prefs); isRecreated = true; } else if(!instance.isInitializedResources()){ instance.initializeResources(); isRecreated = true; } return isRecreated; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setupSimplePreferencesScreen(); Preference button = (Preference)findPreference("clearCache"); button.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { ConfigXmlParser parser = new ConfigXmlParser(); parser.parse(SettingsActivity.this); CordovaPreferences preferences = parser.getPreferences(); preferences.setPreferencesBundle(SettingsActivity.this.getIntent().getExtras()); CordovaWebView webView = new CordovaWebViewImpl(CordovaWebViewImpl.createEngine(SettingsActivity.this, preferences)); webView.clearCache(); return true; } }); }
@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); }
/** 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); loadUrl(startUrl, true); // Send the massage of xwalk's ready to plugin. if (pluginManager != null) { pluginManager.postMessage("onXWalkReady", this); } } }; activityDelegate = new XWalkActivityDelegate((Activity) context, cancelCommand, completeCommand); webView = new XWalkCordovaView(context, preferences); }
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; } }
/** Used when created via reflection. */ public InjectWebViewEngine(Context context, CordovaPreferences preferences) { this(new InjectWebView(context)); //super(context, preferences); Log.w("inject", "InjectWebViewEngine"); }
/** Used when created via reflection. */ public CordovaGeckoViewEngine(Context context, CordovaPreferences preferences) { mCtx = context; webView = new CordovaGeckoView(this); //testView = new SystemWebView(context); prefs = preferences; }
/** Used when created via reflection. */ public SystemWebViewEngine(Context context, CordovaPreferences preferences) { this(new SystemWebView(context), preferences); }
public SystemWebViewEngine(SystemWebView webView, CordovaPreferences preferences) { this.preferences = preferences; this.webView = webView; cookieManager = new SystemCookieManager(webView); }
/** Used when created via reflection. */ public X5WebViewEngine(Context context, CordovaPreferences preferences) { this(new X5WebView(context), preferences); }
public X5WebViewEngine(X5WebView webView, CordovaPreferences preferences) { this.preferences = preferences; this.webView = webView; cookieManager = new X5CookieManager(webView); }
/** * Used when created via reflection. */ public X5WebViewEngine(Context context, CordovaPreferences preferences) { this(new X5WebView(context), preferences); }