platform/bb/rhodes/src/rhomobile/RhodesApplication.java in rhodes-2.0.0.beta7 vs platform/bb/rhodes/src/rhomobile/RhodesApplication.java in rhodes-2.0.0.beta8

- old
+ new

@@ -110,38 +110,19 @@ return false; } public boolean trackwheelUnclick(int status, int time) {return false;} } - boolean isExternalUrl(String strUrl) - { - return strUrl.startsWith("http://") || strUrl.startsWith("https://") || - strUrl.startsWith("javascript:") || strUrl.startsWith("mailto:") - || strUrl.startsWith("tel:")|| strUrl.startsWith("wtai:"); - } - - String canonicalizeURL( String url ){ - if ( url == null || url.length() == 0 ) - return ""; - - url.replace('\\', '/'); - if ( !url.startsWith(_httpRoot) && !isExternalUrl(url) ) - url = FilePath.join(_httpRoot,url); - - return url; - } - public void navigateUrl(String url){ PrimaryResourceFetchThread thread = new PrimaryResourceFetchThread( - canonicalizeURL(url), null, null, null); + RHODESAPP().canonicalizeRhoUrl(url), null, null, null); thread.start(); } - public String getPathForMenuItem(String url) { - url = _httpRoot + - url.substring(url.charAt(0) == '\\' || url.charAt(0) == '/' ? 1 : 0 ); - return url; + public String getPathForMenuItem(String url) + { + return RHODESAPP().canonicalizeRhoUrl(url); } public void addMenuItem(String label, String value){ LOG.TRACE("Adding menu item: label: " + label + ", value: " + value); _mainScreen.addCustomMenuItem(label, value); @@ -158,11 +139,11 @@ postUrl(url, body, headers, null); } public void postUrl(String url, String body, HttpHeaders headers, Runnable callback){ PrimaryResourceFetchThread thread = new PrimaryResourceFetchThread( - canonicalizeURL(url), headers, body.getBytes(), null, callback); + RHODESAPP().canonicalizeRhoUrl(url), headers, body.getBytes(), null, callback); thread.setInternalRequest(true); thread.start(); } public static class NetCallback @@ -186,11 +167,11 @@ } } } public void postUrlWithCallback(String url, String body, HttpHeaders headers, NetCallback netCallback){ PrimaryResourceFetchThread thread = new PrimaryResourceFetchThread( - canonicalizeURL(url), headers, body.getBytes(), null); + RHODESAPP().canonicalizeRhoUrl(url), headers, body.getBytes(), null); thread.setNetCallback(netCallback); thread.start(); } void saveCurrentLocation(String url) { @@ -261,12 +242,13 @@ public void addToHistory(String strUrl, String refferer ) { strUrl = removeSemicolon(strUrl); refferer = removeSemicolon(refferer); - if ( !strUrl.startsWith(_httpRoot) && !isExternalUrl(strUrl) ) - strUrl = _httpRoot + (strUrl.startsWith("/") ? strUrl.substring(1) : strUrl); + strUrl = RHODESAPP().canonicalizeRhoUrl(strUrl); +// if ( !strUrl.startsWith(_httpRoot) && !isExternalUrl(strUrl) ) +// strUrl = _httpRoot + (strUrl.startsWith("/") ? strUrl.substring(1) : strUrl); int nPos = -1; for( int i = 0; i < _history.size(); i++ ){ if ( strUrl.equalsIgnoreCase((String)_history.elementAt(i)) ){ nPos = i; @@ -354,12 +336,10 @@ //private HttpConnection _currentConnection; private Vector _history; - private final String _httpRoot = "http://localhost:8080/"; - private static boolean m_isFullBrowser = false; private static PushListeningThread _pushListeningThread = null; private static RhodesApplication _instance; @@ -1107,16 +1087,13 @@ public void refreshCurrentPage(){ navigateUrl((String)_history.lastElement()); } - void navigateHome(){ + void navigateHome() + { String strHomePage = RhoRuby.getStartPage(); - String strStartPage = _httpRoot; - if ( strHomePage != null && strHomePage.length() > 0 ) - { - strStartPage = _httpRoot.substring(0, _httpRoot.length()-1) + strHomePage; - } + String strStartPage = RhodesApp.getInstance().canonicalizeRhoUrl(strHomePage); _history.removeAllElements(); _history.addElement(strStartPage); navigateUrl(strStartPage); }