platform/bb/rhodes/src/rhomobile/RhodesApplication.java in rhodes-2.0.3 vs platform/bb/rhodes/src/rhomobile/RhodesApplication.java in rhodes-2.1.0

- old
+ new

@@ -196,16 +196,10 @@ return false; } public void navigateBack() { - if ( RHODESAPP().isCloseBack() ) - { - _mainScreen.close(); - return; - } - String url = ""; if ( _history.size() <= 1 ) { if ( RhoConf.getInstance().getBool("bb_disable_closebyback")) return; @@ -306,27 +300,27 @@ } private boolean m_bOpenLink = false; private String m_strGetLink, m_strEmailMenu, m_strCallMenu; boolean openLink(){ - LOG.INFO("openLink"); + LOG.TRACE("openLink"); try{ m_bOpenLink = true; //TODO: catch by ID? if (m_strGetLink==null) { Version.SoftVersion ver = Version.getSoftVersion(); if ( ver.nMajor > 4 ) - m_strGetLink = RhoRuby.getMessageText("open_link_menu"); + m_strGetLink = RhoAppAdapter.getMessageText("open_link_menu"); else - m_strGetLink = RhoRuby.getMessageText("get_link_menu"); + m_strGetLink = RhoAppAdapter.getMessageText("get_link_menu"); } if (m_strEmailMenu==null) - m_strEmailMenu = RhoRuby.getMessageText("email_menu"); + m_strEmailMenu = RhoAppAdapter.getMessageText("email_menu"); if (m_strCallMenu==null) - m_strCallMenu = RhoRuby.getMessageText("call_menu"); + m_strCallMenu = RhoAppAdapter.getMessageText("call_menu"); Menu menu = _mainScreen.getMenu(0); int size = menu.getSize(); for(int i=0; i<size; i++) { @@ -466,11 +460,15 @@ private static Object m_eventRubyInit = new Object(); private static boolean m_bRubyInit = false; public void activate() { - rhodes_activate(); + if (!m_bActivate) + rhodes_activate(); + else + RhoRuby.rho_ruby_activateApp(); + super.activate(); } private boolean m_bActivate = false; private void rhodes_activate() @@ -610,11 +608,11 @@ super( new VerticalFieldManager( Manager.NO_VERTICAL_SCROLL | Manager.NO_VERTICAL_SCROLLBAR) ); add(_labelStatus = new LabelField(status != null ? status : "", Field.FIELD_HCENTER)); add(new LabelField("")); - ButtonField hideButton = new ButtonField( RhoRuby.getMessageText("hide"), Field.FIELD_HCENTER ); + ButtonField hideButton = new ButtonField( RhoAppAdapter.getMessageText("hide"), Field.FIELD_HCENTER ); hideButton.setChangeListener( new HideListener(this) ); add(hideButton); } public void showStatus(String status) { @@ -665,18 +663,21 @@ { m_nOrientation = nOrientation; return; } - if ( m_nOrientation != nOrientation ) - { + if ( m_nOrientation != nOrientation && m_bRubyInit ) + { try{ RhodesApp.getInstance().callScreenRotationCallback(x, y, m_nOrientation==1 ? 90 : -90); }catch(Exception exc) { LOG.ERROR("Screen rotation callback failed.", exc); } + + //this.invalidate(); + //this.updateDisplay(); } m_nOrientation = nOrientation; } @@ -781,16 +782,19 @@ public void addCustomMenuItem(String label, final String value) { final String _label = label; // Is this a default item? If so, use the existing menu item we have. - if (value.equalsIgnoreCase(RhodesApplication.LABEL_HOME)) { + + if (value.equalsIgnoreCase(RhodesApplication.LABEL_BACK)) { + setDefaultItemToMenuItems(label, backItem); + }else if ( label.equalsIgnoreCase("back") ){ + RHODESAPP().setAppBackUrl(value); + }else if (value.equalsIgnoreCase(RhodesApplication.LABEL_HOME)) { setDefaultItemToMenuItems(label, homeItem); } else if (value.equalsIgnoreCase(RhodesApplication.LABEL_REFRESH)) { setDefaultItemToMenuItems(label, refreshItem); - } else if (value.equalsIgnoreCase(RhodesApplication.LABEL_BACK)) { - setDefaultItemToMenuItems(label, backItem); } else if (value.equalsIgnoreCase(RhodesApplication.LABEL_SYNC)) { setDefaultItemToMenuItems(label, syncItem); } else if (value.equalsIgnoreCase(RhodesApplication.LABEL_OPTIONS)) { setDefaultItemToMenuItems(label, optionsItem); } else if (value.equalsIgnoreCase(RhodesApplication.LABEL_LOG)) { @@ -802,25 +806,20 @@ value.equalsIgnoreCase(RhodesApplication.LABEL_EXIT)) { setDefaultItemToMenuItems(label, closeItem); } else if (label.equalsIgnoreCase(RhodesApplication.LABEL_NONE)) { menuItems = null; } else { - if ( label.equalsIgnoreCase("back") ) - //m_strAppBackUrl = value; - RHODESAPP().setAppBackUrl(value); - else - { - MenuItem itemToAdd = new MenuItem(label, 200000, 10) + MenuItem itemToAdd = new MenuItem(label, 200000, 10) + { + public void run() { - public void run() + try{ + RHODESAPP().loadUrl(value); + }catch(Exception exc) { - try{ - RHODESAPP().loadUrl(value); - }catch(Exception exc) - { - LOG.ERROR("Execute menu item: '" + _label + "' failed.", exc); - } + LOG.ERROR("Execute menu item: '" + _label + "' failed.", exc); + } /* if (value != null && value.startsWith("callback:") ) { String url = RHODESAPP().canonicalizeRhoUrl(value.substring(9)); RhoRubyHelper helper = new RhoRubyHelper(); helper.postUrl(url, ""); @@ -828,25 +827,24 @@ { String url = RHODESAPP().canonicalizeRhoUrl(value); addToHistory(url, null ); navigateUrl(url); }*/ - } - }; - menuItems.addElement(itemToAdd); - } + } + }; + menuItems.addElement(itemToAdd); } } void updateMenuItemsLabel() { - homeItem.setText(RhoRuby.getMessageText("home_menu")); - refreshItem.setText(RhoRuby.getMessageText("refresh_menu")); - backItem.setText(RhoRuby.getMessageText("back_menu")); - syncItem.setText(RhoRuby.getMessageText("sync_menu")); - optionsItem.setText(RhoRuby.getMessageText("options_menu")); - logItem.setText(RhoRuby.getMessageText("log_menu")); - closeItem.setText(RhoRuby.getMessageText("close_menu")); + homeItem.setText(RhoAppAdapter.getMessageText("home_menu")); + refreshItem.setText(RhoAppAdapter.getMessageText("refresh_menu")); + backItem.setText(RhoAppAdapter.getMessageText("back_menu")); + syncItem.setText(RhoAppAdapter.getMessageText("sync_menu")); + optionsItem.setText(RhoAppAdapter.getMessageText("options_menu")); + logItem.setText(RhoAppAdapter.getMessageText("log_menu")); + closeItem.setText(RhoAppAdapter.getMessageText("close_menu")); } private void setDefaultItemToMenuItems(String label, MenuItem item) { item.setText(label); menuItems.addElement(item);