summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2009-07-28 11:07:10 +0100
committerSteve Block <steveblock@google.com>2009-07-28 13:49:55 +0100
commit1ad98cf1e4fb36e7164024f8c1a1098ac2ecaed6 (patch)
treef4399cda9dc4e0173b4393ad81559d0be1e4d681
parentfe6792cd1bd7835c212df8aab039b004bb97bbf3 (diff)
downloadpackages_apps_Browser-1ad98cf1e4fb36e7164024f8c1a1098ac2ecaed6.zip
packages_apps_Browser-1ad98cf1e4fb36e7164024f8c1a1098ac2ecaed6.tar.gz
packages_apps_Browser-1ad98cf1e4fb36e7164024f8c1a1098ac2ecaed6.tar.bz2
Improves appearance of website URLs in browser 'Website settings' menu.
- If an explicit title is set, we show it and use the origin as a subtitle. - If no explicit title is set, we show use the origin as a title. - We hide the origin's scheme if it's 'http'.
-rw-r--r--src/com/android/browser/WebsiteSettingsActivity.java29
1 files changed, 19 insertions, 10 deletions
diff --git a/src/com/android/browser/WebsiteSettingsActivity.java b/src/com/android/browser/WebsiteSettingsActivity.java
index c9042cd..4a9eb55 100644
--- a/src/com/android/browser/WebsiteSettingsActivity.java
+++ b/src/com/android/browser/WebsiteSettingsActivity.java
@@ -59,10 +59,10 @@ public class WebsiteSettingsActivity extends ListActivity {
private String mTitle;
private Bitmap mIcon;
- public Site(String origin, String title, Bitmap icon) {
+ public Site(String origin) {
mOrigin = origin;
- mTitle = title;
- mIcon = icon;
+ mTitle = null;
+ mIcon = null;
}
public String getOrigin() {
@@ -73,10 +73,6 @@ public class WebsiteSettingsActivity extends ListActivity {
mTitle = title;
}
- public String getTitle() {
- return mTitle;
- }
-
public void setIcon(Bitmap icon) {
mIcon = icon;
}
@@ -84,6 +80,19 @@ public class WebsiteSettingsActivity extends ListActivity {
public Bitmap getIcon() {
return mIcon;
}
+
+ public String getPrettyOrigin() {
+ return mTitle == null ? null : hideHttp(mOrigin);
+ }
+
+ public String getPrettyTitle() {
+ return mTitle == null ? hideHttp(mOrigin) : mTitle;
+ }
+
+ private String hideHttp(String str) {
+ Uri uri = Uri.parse(str);
+ return "http".equals(uri.getScheme()) ? str.substring(7) : str;
+ }
}
class SiteAdapter extends ArrayAdapter<Site>
@@ -113,7 +122,7 @@ public class WebsiteSettingsActivity extends ListActivity {
Iterator<String> iter = origins.iterator();
while (iter.hasNext()) {
String origin = iter.next();
- Site site = new Site(origin, origin, null);
+ Site site = new Site(origin);
uris.put(Uri.parse(origin).getHost(), site);
}
}
@@ -211,8 +220,8 @@ public class WebsiteSettingsActivity extends ListActivity {
if (mCurrentSite == null) {
Site site = getItem(position);
- title.setText(site.getTitle());
- subtitle.setText(site.getOrigin());
+ title.setText(site.getPrettyTitle());
+ subtitle.setText(site.getPrettyOrigin());
icon.setVisibility(View.VISIBLE);
Bitmap bmp = site.getIcon();
if (bmp == null) {