diff options
author | Ben Murdoch <benm@google.com> | 2009-10-28 13:22:46 +0000 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2009-10-28 13:22:46 +0000 |
commit | 9907efcdb03d1e038b3923d6c58f907b1fda4c5e (patch) | |
tree | 375253279b74a4ae7000d2f975e245ae67d3f52b /src/com/android/browser/BookmarkItem.java | |
parent | ae59c3f5a5b492f91d72e1d26702a13b91a43fa4 (diff) | |
download | packages_apps_Browser-9907efcdb03d1e038b3923d6c58f907b1fda4c5e.zip packages_apps_Browser-9907efcdb03d1e038b3923d6c58f907b1fda4c5e.tar.gz packages_apps_Browser-9907efcdb03d1e038b3923d6c58f907b1fda4c5e.tar.bz2 |
When displaying a bookmark item, only truncate the Strings that we display in the ListView rather than the ones used to index into the bookmarks database. This caused a crash when bookmarks had titles longer than the text view limit.
Fix for b/2219781
Change-Id: I4ea3cdfbaedce0dea6bd69f560aae9aea71ed7c1
Diffstat (limited to 'src/com/android/browser/BookmarkItem.java')
-rw-r--r-- | src/com/android/browser/BookmarkItem.java | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/src/com/android/browser/BookmarkItem.java b/src/com/android/browser/BookmarkItem.java index a70dd4f..fbb362e 100644 --- a/src/com/android/browser/BookmarkItem.java +++ b/src/com/android/browser/BookmarkItem.java @@ -33,6 +33,7 @@ class BookmarkItem extends LinearLayout { protected TextView mUrlText; protected ImageView mImageView; protected String mUrl; + protected String mTitle; /** * Instantiate a bookmark item, including a default favicon. @@ -65,7 +66,7 @@ class BookmarkItem extends LinearLayout { * Return the name assigned to this bookmark item. */ /* package */ String getName() { - return mTextView.getText().toString(); + return mTitle; } /** @@ -99,6 +100,16 @@ class BookmarkItem extends LinearLayout { * @param name The new name for the bookmark item. */ /* package */ void setName(String name) { + if (name == null) { + return; + } + + mTitle = name; + + if (name.length() > BrowserSettings.MAX_TEXTVIEW_LEN) { + name = name.substring(0, BrowserSettings.MAX_TEXTVIEW_LEN); + } + mTextView.setText(name); } @@ -107,7 +118,16 @@ class BookmarkItem extends LinearLayout { * @param url The new url for the bookmark item. */ /* package */ void setUrl(String url) { - mUrlText.setText(url); + if (url == null) { + return; + } + mUrl = url; + + if (url.length() > BrowserSettings.MAX_TEXTVIEW_LEN) { + url = url.substring(0, BrowserSettings.MAX_TEXTVIEW_LEN); + } + + mUrlText.setText(url); } } |