Backout 751aa72f61a2 (bug 729495) for robocop testAllPagesTab failures

This commit is contained in:
Ed Morley 2012-07-10 12:41:50 +01:00
parent 6c98428b96
commit cfa4aecb75
7 changed files with 10 additions and 51 deletions

View File

@ -529,7 +529,7 @@ public class AboutHomeContent extends ScrollView
String optTitle = entry.optString("title");
if (optTitle.length() == 0)
title = StringUtils.prettyURL(url);
title = url;
else
title = optTitle;
} catch (JSONException e) {
@ -549,7 +549,7 @@ public class AboutHomeContent extends ScrollView
public void run() {
View container = mInflater.inflate(R.layout.abouthome_last_tabs_row, mLastTabs.getItemsContainer(), false);
((TextView) container.findViewById(R.id.last_tab_title)).setText(title);
((TextView) container.findViewById(R.id.last_tab_url)).setText(StringUtils.prettyURL(url));
((TextView) container.findViewById(R.id.last_tab_url)).setText(url);
if (favicon != null)
((ImageView) container.findViewById(R.id.last_tab_favicon)).setImageDrawable(favicon);
@ -616,7 +616,7 @@ public class AboutHomeContent extends ScrollView
break;
final TextView row = (TextView) mInflater.inflate(R.layout.abouthome_remote_tab_row, mRemoteTabs.getItemsContainer(), false);
row.setText(TextUtils.isEmpty(tab.title) ? StringUtils.prettyURL(tab.url) : tab.title);
row.setText(TextUtils.isEmpty(tab.title) ? tab.url : tab.title);
row.setTag(tab.url);
mRemoteTabs.addItem(row);
row.setOnClickListener(mRemoteTabClickListener);
@ -723,7 +723,7 @@ public class AboutHomeContent extends ScrollView
// bar view - this is the equivalent of getDisplayTitle() in Tab.java
if (title == null || title.length() == 0) {
int urlIndex = cursor.getColumnIndexOrThrow(URLColumns.URL);
title = StringUtils.prettyURL(cursor.getString(urlIndex));
title = cursor.getString(urlIndex);
}
titleView.setText(title);

View File

@ -189,7 +189,7 @@ abstract public class BrowserApp extends GeckoApp
@Override
protected void loadRequest(String url, AwesomeBar.Target target, String searchEngine, boolean userEntered) {
mBrowserToolbar.setTitle(StringUtils.prettyURL(url));
mBrowserToolbar.setTitle(url);
super.loadRequest(url, target, searchEngine, userEntered);
}
@ -250,7 +250,7 @@ abstract public class BrowserApp extends GeckoApp
}
if (uri != null && uri.length() > 0) {
mBrowserToolbar.setTitle(StringUtils.prettyURL(uri));
mBrowserToolbar.setTitle(uri);
}
if (!isExternalURL) {

View File

@ -87,7 +87,6 @@ FENNEC_JAVA_FILES = \
RemoteTabs.java \
SetupScreen.java \
SiteIdentityPopup.java \
StringUtils.java \
SuggestClient.java \
SurfaceBits.java \
Tab.java \

View File

@ -1,40 +0,0 @@
/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.gecko;
public final class StringUtils {
private static final String HTTP_PREFIX = "http://";
private static final String PROTOCOL_DELIMITER = "://";
/**
* Gets a display-friendly URL.
* If the URL starts with "http://", this prefix is removed. If the URL
* contains exactly one "/", and it's at the end of the URL, it is removed.
* Examples:
* - http://www.google.com/ -> www.google.com
* - http://mozilla.org/en-US/ -> mozilla.org/en-US/
* - https://www.google.com/ -> https://www.google.com
*/
public static String prettyURL(String url) {
if (url == null)
return url;
// remove http:// prefix from URLs
if (url.startsWith(HTTP_PREFIX))
url = url.substring(HTTP_PREFIX.length());
// remove trailing / on root URLs
int delimiterIndex = url.indexOf(PROTOCOL_DELIMITER);
int fromIndex = (delimiterIndex == -1 ? 0 : delimiterIndex + PROTOCOL_DELIMITER.length());
int firstSlash = url.indexOf('/', fromIndex);
if (firstSlash == url.length() - 1)
url = url.substring(0, firstSlash);
return url;
}
}

View File

@ -136,7 +136,7 @@ public final class Tab {
return mTitle;
}
return StringUtils.prettyURL(mUrl);
return mUrl;
}
public Drawable getFavicon() {

View File

@ -112,7 +112,7 @@ abstract public class AwesomeBarTab {
// bar view - this is the equivalent of getDisplayTitle() in Tab.java
if (TextUtils.isEmpty(title)) {
int urlIndex = cursor.getColumnIndexOrThrow(URLColumns.URL);
title = StringUtils.prettyURL(cursor.getString(urlIndex));
title = cursor.getString(urlIndex);
}
titleView.setText(title);
@ -122,7 +122,7 @@ abstract public class AwesomeBarTab {
int urlIndex = cursor.getColumnIndexOrThrow(URLColumns.URL);
String url = cursor.getString(urlIndex);
urlView.setText(StringUtils.prettyURL(url));
urlView.setText(url);
}
protected boolean hideSoftInput(View view) {

View File

@ -165,7 +165,7 @@ public class HistoryTab extends AwesomeBarTab {
String url = (String) historyItem.get(URLColumns.URL);
if (TextUtils.isEmpty(title))
title = StringUtils.prettyURL(url);
title = url;
viewHolder.titleView.setText(title);
viewHolder.urlView.setText(url);