Add vertical scrolling for displaying URL.
When viewing a long url in by performing
a long press in the Bookmark View.It used to get
trimmed out at 80 characters.
This change adds a vertical scrolling so that
the first 3 lines each 40 characters long are being shown to
the user and rest of them can viewed by scrolling up.
Change-Id: Ide8c5d2595d11d7b72e605319a07e2bb861937bf
diff --git a/src/com/android/browser/BookmarkItem.java b/src/com/android/browser/BookmarkItem.java
index eccc438..8573290 100644
--- a/src/com/android/browser/BookmarkItem.java
+++ b/src/com/android/browser/BookmarkItem.java
@@ -21,18 +21,19 @@
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
+import android.text.method.ScrollingMovementMethod;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
-import android.widget.HorizontalScrollView;
+import android.widget.ScrollView;
import android.widget.ImageView;
import android.widget.TextView;
/**
* Custom layout for an item representing a bookmark in the browser.
*/
-class BookmarkItem extends HorizontalScrollView {
+class BookmarkItem extends ScrollView {
final static int MAX_TEXTVIEW_LEN = 80;
@@ -132,8 +133,28 @@
mUrl = url;
url = UrlUtils.stripUrl(url);
+
+ /*
+ * Since there are more than 80 characters
+ * in the URL this is formatting the url
+ * to a vertical Scroll View.
+ */
if (url.length() > MAX_TEXTVIEW_LEN) {
- url = url.substring(0, MAX_TEXTVIEW_LEN);
+
+ // url cannot exceed max length
+ if (url.length() > UrlInputView.URL_MAX_LENGTH) {
+ url = url.substring(0, UrlInputView.URL_MAX_LENGTH);
+ }
+
+ mUrlText.setHorizontallyScrolling(false);
+ mUrlText.setSingleLine(false);
+ mUrlText.setVerticalScrollBarEnabled(true);
+ /*
+ * Only the first 3 lines of the URL will be visible
+ * Rest of it will be scrollable.
+ */
+ mUrlText.setMaxLines(3);
+ mUrlText.setMovementMethod(new ScrollingMovementMethod());
}
mUrlText.setText(url);