Merge "Import revised translations" into froyo
diff --git a/src/com/android/browser/BrowserActivity.java b/src/com/android/browser/BrowserActivity.java
index 17c66c5..8a61c3e 100644
--- a/src/com/android/browser/BrowserActivity.java
+++ b/src/com/android/browser/BrowserActivity.java
@@ -2797,6 +2797,36 @@
onDownloadStartNoStream(url, userAgent, contentDisposition, mimetype, contentLength);
}
+ // This is to work around the fact that java.net.URI throws Exceptions
+ // instead of just encoding URL's properly
+ // Helper method for onDownloadStartNoStream
+ private static String encodePath(String path) {
+ char[] chars = path.toCharArray();
+
+ boolean needed = false;
+ for (char c : chars) {
+ if (c == '[' || c == ']') {
+ needed = true;
+ break;
+ }
+ }
+ if (needed == false) {
+ return path;
+ }
+
+ StringBuilder sb = new StringBuilder("");
+ for (char c : chars) {
+ if (c == '[' || c == ']') {
+ sb.append('%');
+ sb.append(Integer.toHexString(c));
+ } else {
+ sb.append(c);
+ }
+ }
+
+ return sb.toString();
+ }
+
/**
* Notify the host application a download should be done, even if there
* is a streaming viewer available for thise type.
@@ -2836,35 +2866,16 @@
return;
}
- // java.net.URI is a lot stricter than KURL so we have to undo
- // KURL's percent-encoding and redo the encoding using java.net.URI.
- URI uri = null;
+ // java.net.URI is a lot stricter than KURL so we have to encode some
+ // extra characters. Fix for b 2538060 and b 1634719
+ WebAddress webAddress;
try {
- // Undo the percent-encoding that KURL may have done.
- String newUrl = new String(URLUtil.decode(url.getBytes()));
- // Parse the url into pieces
- WebAddress w = new WebAddress(newUrl);
- String frag = null;
- String query = null;
- String path = w.mPath;
- // Break the path into path, query, and fragment
- if (path.length() > 0) {
- // Strip the fragment
- int idx = path.lastIndexOf('#');
- if (idx != -1) {
- frag = path.substring(idx + 1);
- path = path.substring(0, idx);
- }
- idx = path.lastIndexOf('?');
- if (idx != -1) {
- query = path.substring(idx + 1);
- path = path.substring(0, idx);
- }
- }
- uri = new URI(w.mScheme, w.mAuthInfo, w.mHost, w.mPort, path,
- query, frag);
+ webAddress = new WebAddress(url);
+ webAddress.mPath = encodePath(webAddress.mPath);
} catch (Exception e) {
- Log.e(LOGTAG, "Could not parse url for download: " + url, e);
+ // This only happens for very bad urls, we want to chatch the
+ // exception here
+ Log.e(LOGTAG, "Exception trying to parse url:" + url);
return;
}
@@ -2873,7 +2884,7 @@
String cookies = CookieManager.getInstance().getCookie(url);
ContentValues values = new ContentValues();
- values.put(Downloads.Impl.COLUMN_URI, uri.toString());
+ values.put(Downloads.Impl.COLUMN_URI, webAddress.toString());
values.put(Downloads.Impl.COLUMN_COOKIE_DATA, cookies);
values.put(Downloads.Impl.COLUMN_USER_AGENT, userAgent);
values.put(Downloads.Impl.COLUMN_NOTIFICATION_PACKAGE,
@@ -2884,7 +2895,7 @@
Downloads.Impl.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
values.put(Downloads.Impl.COLUMN_MIME_TYPE, mimetype);
values.put(Downloads.Impl.COLUMN_FILE_NAME_HINT, filename);
- values.put(Downloads.Impl.COLUMN_DESCRIPTION, uri.getHost());
+ values.put(Downloads.Impl.COLUMN_DESCRIPTION, webAddress.mHost);
if (contentLength > 0) {
values.put(Downloads.Impl.COLUMN_TOTAL_BYTES, contentLength);
}
diff --git a/src/com/android/browser/BrowserSettings.java b/src/com/android/browser/BrowserSettings.java
index 39c2f1e..51b4eaa 100644
--- a/src/com/android/browser/BrowserSettings.java
+++ b/src/com/android/browser/BrowserSettings.java
@@ -207,8 +207,6 @@
s.setNeedInitialFocus(false);
// Browser supports multiple windows
s.setSupportMultipleWindows(true);
- // Use internal pattern for over scroll background
- s.setUseWebViewBackgroundForOverscrollBackground(false);
// HTML5 API flags
s.setAppCacheEnabled(b.appCacheEnabled);
@@ -252,19 +250,18 @@
// Set the default value for the Geolocation database path.
geolocationDatabasePath = ctx.getDir("geolocation", 0).getPath();
- homeUrl = getFactoryResetHomeUrl(ctx);
+ if (p.getString(PREF_HOMEPAGE, "") == "") {
+ // No home page preferences is set, set it to default.
+ setHomePage(ctx, getFactoryResetHomeUrl(ctx));
+ }
// the cost of one cached page is ~3M (measured using nytimes.com). For
// low end devices, we only cache one page. For high end devices, we try
// to cache more pages, currently choose 5.
- //
- // Note: the page cache is disabled on high-end devices due to an
- // incompatibility with V8. TODO: re-enable the page cache once the
- // problem with V8 is solved.
ActivityManager am = (ActivityManager) ctx
.getSystemService(Context.ACTIVITY_SERVICE);
if (am.getMemoryClass() > 16) {
- pageCacheCapacity = 0;
+ pageCacheCapacity = 5;
} else {
pageCacheCapacity = 1;
}