org.apache.cordova.Config Java Examples

The following examples show how to use org.apache.cordova.Config. 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: CordovaWebViewTestActivity.java    From crosswalk-cordova-android with Apache License 2.0 6 votes vote down vote up
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.main);

    //CB-7238: This has to be added now, because it got removed from somewhere else
    Config.init(this);
    
    cordovaWebView = (CordovaWebView) findViewById(R.id.cordovaWebView);
    cordovaWebView.init(this, new CordovaWebViewClient(this, cordovaWebView), new CordovaChromeClient(this, cordovaWebView),
            Config.getPluginEntries(), Config.getWhitelist(), Config.getExternalWhitelist(), Config.getPreferences());

    cordovaWebView.loadUrl("file:///android_asset/www/index.html");

}
 
Example #2
Source File: CordovaGeckoViewChrome.java    From cordova-mozillaview-engine with Apache License 2.0 5 votes vote down vote up
public void onReady(GeckoView view) {
    Log.i(LOGTAG, "Gecko is ready");

    PrefsHelper.setPref("devtools.debugger.remote-enabled", true);

    /* Load URL does nothing, we have to wait unitl things are ready before loading */
    view.addBrowser(Config.getStartUrl());
    //Make sure this is visible regardless of what Cordova does.
    view.setVisibility(View.VISIBLE);
}
 
Example #3
Source File: SabotagedActivity.java    From cordova-amazon-fireos with Apache License 2.0 5 votes vote down vote up
@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);        
        
//        copyErrorAsset();
        super.init();
        super.loadUrl(Config.getStartUrl());
    }
 
Example #4
Source File: CordovaWebViewTestActivity.java    From cordova-amazon-fireos with Apache License 2.0 5 votes vote down vote up
/** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
//        AWV Factory should be initialized before setting the layout  
        if (!sFactoryInit) {
           factory = AmazonWebKitFactories.getDefaultFactory();
           if (factory.isRenderProcess(this)) {
               return; // Do nothing if this is on render process
           }
          factory.initialize(this);
           
           sFactoryInit = true;
       } else {
           factory = AmazonWebKitFactories.getDefaultFactory();
       }

        setContentView(R.layout.main);

        //CB-7238: This has to be added now, because it got removed from somewhere else
        Config.init(this);
        
        cordovaWebView = (CordovaWebView) findViewById(R.id.cordovaWebView);
        factory.initializeWebView(cordovaWebView, 0xFFFFFF, false, null);
        cordovaWebView.init(this, new CordovaWebViewClient(this, cordovaWebView), new CordovaChromeClient(this, cordovaWebView),
                Config.getPluginEntries(), Config.getWhitelist(), Config.getExternalWhitelist(), Config.getPreferences());

        cordovaWebView.loadUrl("file:///android_asset/www/index.html");

    }
 
Example #5
Source File: CordovaWebView.java    From phonegapbootcampsite with MIT License 5 votes vote down vote up
/**
 * Load URL in webview.
 *
 * @param url
 */
void loadUrlNow(String url) {
    if (LOG.isLoggable(LOG.DEBUG) && !url.startsWith("javascript:")) {
        LOG.d(TAG, ">>> loadUrlNow()");
    }
    if (url.startsWith("file://") || url.startsWith("javascript:") || Config.isUrlWhiteListed(url)) {
        super.loadUrl(url);
    }
}
 
Example #6
Source File: CordovaWebView.java    From phonegapbootcampsite with MIT License 5 votes vote down vote up
/**
 * Load the specified URL in the Cordova webview or a new browser instance.
 *
 * NOTE: If openExternal is false, only URLs listed in whitelist can be loaded.
 *
 * @param url           The url to load.
 * @param openExternal  Load url in browser instead of Cordova webview.
 * @param clearHistory  Clear the history stack, so new page becomes top of history
 * @param params        Parameters for new app
 */
public void showWebPage(String url, boolean openExternal, boolean clearHistory, HashMap<String, Object> params) {
    LOG.d(TAG, "showWebPage(%s, %b, %b, HashMap", url, openExternal, clearHistory);

    // If clearing history
    if (clearHistory) {
        this.clearHistory();
    }

    // If loading into our webview
    if (!openExternal) {

        // Make sure url is in whitelist
        if (url.startsWith("file://") || Config.isUrlWhiteListed(url)) {
            // TODO: What about params?
            // Load new URL
            this.loadUrl(url);
            return;
        }
        // Load in default viewer if not
        LOG.w(TAG, "showWebPage: Cannot load URL into webview since it is not in white list.  Loading into browser instead. (URL=" + url + ")");
    }
    try {
        // Omitting the MIME type for file: URLs causes "No Activity found to handle Intent".
        // Adding the MIME type to http: URLs causes them to not be handled by the downloader.
        Intent intent = new Intent(Intent.ACTION_VIEW);
        Uri uri = Uri.parse(url);
        if ("file".equals(uri.getScheme())) {
            intent.setDataAndType(uri, resourceApi.getMimeType(uri));
        } else {
            intent.setData(uri);
        }
        cordova.getActivity().startActivity(intent);
    } catch (android.content.ActivityNotFoundException e) {
        LOG.e(TAG, "Error loading url " + url, e);
    }
}
 
Example #7
Source File: CordovaWebView.java    From CordovaYoutubeVideoPlayer with MIT License 5 votes vote down vote up
/**
 * Load URL in webview.
 *
 * @param url
 */
void loadUrlNow(String url) {
    if (LOG.isLoggable(LOG.DEBUG) && !url.startsWith("javascript:")) {
        LOG.d(TAG, ">>> loadUrlNow()");
    }
    if (url.startsWith("file://") || url.startsWith("javascript:") || Config.isUrlWhiteListed(url)) {
        super.loadUrl(url);
    }
}
 
Example #8
Source File: CordovaWebView.java    From CordovaYoutubeVideoPlayer with MIT License 5 votes vote down vote up
/**
 * Load the specified URL in the Cordova webview or a new browser instance.
 *
 * NOTE: If openExternal is false, only URLs listed in whitelist can be loaded.
 *
 * @param url           The url to load.
 * @param openExternal  Load url in browser instead of Cordova webview.
 * @param clearHistory  Clear the history stack, so new page becomes top of history
 * @param params        Parameters for new app
 */
public void showWebPage(String url, boolean openExternal, boolean clearHistory, HashMap<String, Object> params) {
    LOG.d(TAG, "showWebPage(%s, %b, %b, HashMap", url, openExternal, clearHistory);

    // If clearing history
    if (clearHistory) {
        this.clearHistory();
    }

    // If loading into our webview
    if (!openExternal) {

        // Make sure url is in whitelist
        if (url.startsWith("file://") || Config.isUrlWhiteListed(url)) {
            // TODO: What about params?
            // Load new URL
            this.loadUrl(url);
            return;
        }
        // Load in default viewer if not
        LOG.w(TAG, "showWebPage: Cannot load URL into webview since it is not in white list.  Loading into browser instead. (URL=" + url + ")");
    }
    try {
        // Omitting the MIME type for file: URLs causes "No Activity found to handle Intent".
        // Adding the MIME type to http: URLs causes them to not be handled by the downloader.
        Intent intent = new Intent(Intent.ACTION_VIEW);
        Uri uri = Uri.parse(url);
        if ("file".equals(uri.getScheme())) {
            intent.setDataAndType(uri, resourceApi.getMimeType(uri));
        } else {
            intent.setData(uri);
        }
        cordova.getActivity().startActivity(intent);
    } catch (android.content.ActivityNotFoundException e) {
        LOG.e(TAG, "Error loading url " + url, e);
    }
}
 
Example #9
Source File: CordovaWebView.java    From cordova-android-chromeview with Apache License 2.0 5 votes vote down vote up
/**
 * Load URL in webview.
 *
 * @param url
 */
void loadUrlNow(String url) {
    if (LOG.isLoggable(LOG.DEBUG) && !url.startsWith("javascript:")) {
        LOG.d(TAG, ">>> loadUrlNow()");
    }
    if (url.startsWith("file://") || url.startsWith("javascript:") || Config.isUrlWhiteListed(url)) {
        super.loadUrl(url);
    }
}
 
Example #10
Source File: CordovaWebView.java    From wildfly-samples with MIT License 5 votes vote down vote up
/**
 * Load URL in webview.
 *
 * @param url
 */
void loadUrlNow(String url) {
    if (LOG.isLoggable(LOG.DEBUG) && !url.startsWith("javascript:")) {
        LOG.d(TAG, ">>> loadUrlNow()");
    }
    if (url.startsWith("file://") || url.startsWith("javascript:") || Config.isUrlWhiteListed(url)) {
        super.loadUrl(url);
    }
}
 
Example #11
Source File: CordovaWebView.java    From wildfly-samples with MIT License 5 votes vote down vote up
/**
 * Load the specified URL in the Cordova webview or a new browser instance.
 *
 * NOTE: If openExternal is false, only URLs listed in whitelist can be loaded.
 *
 * @param url           The url to load.
 * @param openExternal  Load url in browser instead of Cordova webview.
 * @param clearHistory  Clear the history stack, so new page becomes top of history
 * @param params        Parameters for new app
 */
public void showWebPage(String url, boolean openExternal, boolean clearHistory, HashMap<String, Object> params) {
    LOG.d(TAG, "showWebPage(%s, %b, %b, HashMap", url, openExternal, clearHistory);

    // If clearing history
    if (clearHistory) {
        this.clearHistory();
    }

    // If loading into our webview
    if (!openExternal) {

        // Make sure url is in whitelist
        if (url.startsWith("file://") || Config.isUrlWhiteListed(url)) {
            // TODO: What about params?
            // Load new URL
            this.loadUrl(url);
            return;
        }
        // Load in default viewer if not
        LOG.w(TAG, "showWebPage: Cannot load URL into webview since it is not in white list.  Loading into browser instead. (URL=" + url + ")");
    }
    try {
        // Omitting the MIME type for file: URLs causes "No Activity found to handle Intent".
        // Adding the MIME type to http: URLs causes them to not be handled by the downloader.
        Intent intent = new Intent(Intent.ACTION_VIEW);
        Uri uri = Uri.parse(url);
        if ("file".equals(uri.getScheme())) {
            intent.setDataAndType(uri, resourceApi.getMimeType(uri));
        } else {
            intent.setData(uri);
        }
        cordova.getActivity().startActivity(intent);
    } catch (android.content.ActivityNotFoundException e) {
        LOG.e(TAG, "Error loading url " + url, e);
    }
}
 
Example #12
Source File: CordovaWebView.java    From phonegap-plugin-loading-spinner with Apache License 2.0 5 votes vote down vote up
/**
 * Load URL in webview.
 *
 * @param url
 */
void loadUrlNow(String url) {
    if (LOG.isLoggable(LOG.DEBUG) && !url.startsWith("javascript:")) {
        LOG.d(TAG, ">>> loadUrlNow()");
    }
    if (url.startsWith("file://") || url.startsWith("javascript:") || Config.isUrlWhiteListed(url)) {
        super.loadUrl(url);
    }
}
 
Example #13
Source File: SabotagedActivity.java    From crosswalk-cordova-android with Apache License 2.0 5 votes vote down vote up
@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);        
        
//        copyErrorAsset();
        super.init();
        super.loadUrl(Config.getStartUrl());
    }