Exemple #1
0
  public BrowserAdapter(RhoMainScreen oMainScreen, RhodesApplication app, boolean bLoadImageAsync) {
    m_oMainScreen = oMainScreen;
    m_app = app;
    m_bLoadImageAsync = bLoadImageAsync;

    _renderingSession = RenderingSession.getNewInstance();

    // enable javascript
    _renderingSession
        .getRenderingOptions()
        .setProperty(RenderingOptions.CORE_OPTIONS_GUID, RenderingOptions.JAVASCRIPT_ENABLED, true);
    _renderingSession
        .getRenderingOptions()
        .setProperty(
            RenderingOptions.CORE_OPTIONS_GUID, RenderingOptions.JAVASCRIPT_LOCATION_ENABLED, true);
    _renderingSession
        .getRenderingOptions()
        .setProperty(RenderingOptions.CORE_OPTIONS_GUID, RenderingOptions.ENABLE_CSS, true);
    _renderingSession
        .getRenderingOptions()
        .setProperty(
            RenderingOptions.CORE_OPTIONS_GUID, RenderingOptions.DEFAULT_CHARSET_VALUE, "utf-8");
    _renderingSession
        .getRenderingOptions()
        .setProperty(
            RenderingOptions.CORE_OPTIONS_GUID, RenderingOptions.OVERWRITE_CHARSET_MODE, true);
    _renderingSession
        .getRenderingOptions()
        .setProperty(RenderingOptions.CORE_OPTIONS_GUID, RenderingOptions.ALLOW_POPUPS, true);
    _renderingSession
        .getRenderingOptions()
        .setProperty(
            RenderingOptions.CORE_OPTIONS_GUID, RenderingOptions.USE_BACKGROUND_IMAGES, true);

    //
    // _renderingSession.getRenderingOptions().setProperty(RenderingOptions.CORE_OPTIONS_GUID,
    // RenderingOptions.VALUE_THRESHOLD, 100000);
    //
    // _renderingSession.getRenderingOptions().setProperty(RenderingOptions.CORE_OPTIONS_GUID,
    // RenderingOptions.USE_BACKGROUND_IMAGES, true);
    //
    // _renderingSession.getRenderingOptions().setProperty(RenderingOptions.CORE_OPTIONS_GUID,
    // RenderingOptions.SHOW_IMAGE_PLACEHOLDERS, false);
    //
    // _renderingSession.getRenderingOptions().setProperty(RenderingOptions.CORE_OPTIONS_GUID,
    // RenderingOptions.ENABLE_WML, false);
    //
    // _renderingSession.getRenderingOptions().setProperty(RenderingOptions.CORE_OPTIONS_GUID,
    // RenderingOptions.ENABLE_EMBEDDED_RICH_CONTENT, false);
    //
    // _renderingSession.getRenderingOptions().setProperty(RenderingOptions.CORE_OPTIONS_GUID,
    // RenderingOptions.ENABLE_IMAGE_EDITING, false);
    //
    // _renderingSession.getRenderingOptions().setProperty(RenderingOptions.CORE_OPTIONS_GUID,
    // RenderingOptions.NO_SEARCH_MENU_MODE, true);

  }
 private void init(final String url) {
   commandManager = new CommandManager(this);
   _mainScreen = new MainScreen();
   _mainScreen.addKeyListener(new PhoneGapKeyListener(this));
   pushScreen(_mainScreen);
   // Set up the browser/renderer.
   _renderingSession = RenderingSession.getNewInstance();
   _renderingSession
       .getRenderingOptions()
       .setProperty(RenderingOptions.CORE_OPTIONS_GUID, RenderingOptions.JAVASCRIPT_ENABLED, true);
   _renderingSession
       .getRenderingOptions()
       .setProperty(
           RenderingOptions.CORE_OPTIONS_GUID, RenderingOptions.JAVASCRIPT_LOCATION_ENABLED, true);
   // Enable nice-looking BlackBerry browser field.
   _renderingSession
       .getRenderingOptions()
       .setProperty(RenderingOptions.CORE_OPTIONS_GUID, 17000, true);
   PrimaryResourceFetchThread thread = new PrimaryResourceFetchThread(url, null, null, null, this);
   thread.start();
   refreshTimer = new Timer();
   refreshTimer.scheduleAtFixedRate(new TimerRefresh(), 500, 500);
 }
Exemple #3
0
  public void processConnection(HttpConnection connection, Object e) {
    BrowserContent browserContent = null;

    try {
      if (connection.getResponseCode() != HttpConnection.HTTP_NOT_MODIFIED)
        browserContent = _renderingSession.getBrowserContent(connection, this, (Event) e);

      if (browserContent != null) {
        browserContent.finishLoading();

        Field field = browserContent.getDisplayableContent();
        if (field != null) {

          synchronized (Application.getEventLock()) {
            m_oMainScreen.deleteAll();
            m_oMainScreen.add(field);

            /*if ( m_oMainScreen.getFieldCount() > 0 )
            {
            	Field old = m_oMainScreen.getField(0);
            	m_oMainScreen.add(field);
            	m_oMainScreen.delete(old);
            }else
            	m_oMainScreen.add(field);*/
            /*
            _mainScreen.doPaint();
            if ( e == null )
            {//This should awake screen in case of long network response
             KeyCodeEvent inject1 = 	new KeyCodeEvent( KeyCodeEvent.KEY_DOWN, (char)Keypad.KEY_ESCAPE, 0);
             KeyCodeEvent inject2 =  new KeyCodeEvent( KeyCodeEvent.KEY_UP, (char)Keypad.KEY_ESCAPE, 0);
             inject1.post();
             inject2.post();
             m_bSkipKeyPress = true;
            }*/
          }
        }
      }
    } catch (Exception re) {
      LOG.ERROR("processConnection failed.", re);
    } finally {
      SecondaryResourceFetchThread.doneAddingImages();
    }
  }
 /**
  * Processes a new HttpConnection object to instantiate a new browser Field (aka WebView) object,
  * and then resets the screen to the newly-created Field.
  *
  * @param connection
  * @param e
  */
 public void processConnection(HttpConnection connection, Event e) {
   // Cancel previous request.
   if (_currentConnection != null) {
     try {
       _currentConnection.close();
     } catch (IOException e1) {
     }
   }
   // Clear out pending responses.
   synchronized (pendingResponses) {
     pendingResponses.removeAllElements();
   }
   // Cancel any XHRs happening.
   commandManager.stopXHR();
   _currentConnection = connection;
   BrowserContent browserContent = null;
   Field field = null;
   try {
     browserContent = _renderingSession.getBrowserContent(connection, this, e);
     if (browserContent != null) {
       field = browserContent.getDisplayableContent();
       if (field != null) {
         synchronized (Application.getEventLock()) {
           _mainScreen.deleteAll();
           _mainScreen.add(field);
         }
       }
       browserContent.finishLoading();
     }
   } catch (RenderingException re) {
   } finally {
     browserContent = null;
     field = null;
     // Manually call the garbage collector to clean up all of leftover objects and free up the
     // nulled object handles.
     System.gc();
   }
 }
Exemple #5
0
 public void setFullBrowser() {
   // this is the undocumented option to tell the browser to use the 4.6 Rendering Engine
   _renderingSession
       .getRenderingOptions()
       .setProperty(RenderingOptions.CORE_OPTIONS_GUID, 17000, true);
 }