diff options
author | John Reck <jreck@google.com> | 2011-09-09 13:36:42 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-09-09 13:36:42 -0700 |
commit | 7883b4453338a00d58707e4fd257492a09b1e824 (patch) | |
tree | 499033e3f14810767c24a0ab05f531704c5d4ff3 /src/com/android | |
parent | b977a32608e08bee7d165ce1447e9db111d27fc8 (diff) | |
parent | 83c0151b266f4789cb1728294eac98e3dba0ed53 (diff) | |
download | packages_apps_Browser-7883b4453338a00d58707e4fd257492a09b1e824.zip packages_apps_Browser-7883b4453338a00d58707e4fd257492a09b1e824.tar.gz packages_apps_Browser-7883b4453338a00d58707e4fd257492a09b1e824.tar.bz2 |
Merge "Cleanup history perf + UI"
Diffstat (limited to 'src/com/android')
-rw-r--r-- | src/com/android/browser/BookmarkItem.java | 83 | ||||
-rw-r--r-- | src/com/android/browser/BrowserBookmarksPage.java | 1 | ||||
-rw-r--r-- | src/com/android/browser/BrowserHistoryPage.java | 2 | ||||
-rw-r--r-- | src/com/android/browser/BrowserSnapshotPage.java | 1 |
4 files changed, 67 insertions, 20 deletions
diff --git a/src/com/android/browser/BookmarkItem.java b/src/com/android/browser/BookmarkItem.java index e7f37a5..85c1fff 100644 --- a/src/com/android/browser/BookmarkItem.java +++ b/src/com/android/browser/BookmarkItem.java @@ -20,15 +20,17 @@ import android.content.Context; import android.graphics.Bitmap; import android.graphics.drawable.Drawable; import android.view.LayoutInflater; +import android.view.MotionEvent; import android.view.View; +import android.view.ViewGroup; +import android.widget.HorizontalScrollView; import android.widget.ImageView; -import android.widget.LinearLayout; import android.widget.TextView; /** * Custom layout for an item representing a bookmark in the browser. */ -class BookmarkItem extends LinearLayout { +class BookmarkItem extends HorizontalScrollView { final static int MAX_TEXTVIEW_LEN = 80; @@ -37,6 +39,7 @@ class BookmarkItem extends LinearLayout { protected ImageView mImageView; protected String mUrl; protected String mTitle; + protected boolean mEnableScrolling = false; /** * Instantiate a bookmark item, including a default favicon. @@ -46,6 +49,8 @@ class BookmarkItem extends LinearLayout { BookmarkItem(Context context) { super(context); + setClickable(false); + setEnableScrolling(false); LayoutInflater factory = LayoutInflater.from(context); factory.inflate(R.layout.history_item, this); mTextView = (TextView) findViewById(R.id.title); @@ -65,16 +70,6 @@ class BookmarkItem extends LinearLayout { item.mImageView.setImageDrawable(mImageView.getDrawable()); } - public void startMarquee() { - mTextView.setSelected(true); - mUrlText.setSelected(true); - } - - public void stopMarquee() { - mTextView.setSelected(false); - mUrlText.setSelected(false); - } - /** * Return the name assigned to this bookmark item. */ @@ -82,13 +77,6 @@ class BookmarkItem extends LinearLayout { return mTitle; } - /** - * Return the TextView which holds the name of this bookmark item. - */ - /* package */ TextView getNameTextView() { - return mTextView; - } - /* package */ String getUrl() { return mUrl; } @@ -141,10 +129,67 @@ class BookmarkItem extends LinearLayout { mUrl = url; + url = UrlUtils.stripUrl(url); if (url.length() > MAX_TEXTVIEW_LEN) { url = url.substring(0, MAX_TEXTVIEW_LEN); } mUrlText.setText(url); } + + void setEnableScrolling(boolean enable) { + mEnableScrolling = enable; + setFocusable(mEnableScrolling); + setFocusableInTouchMode(mEnableScrolling); + requestDisallowInterceptTouchEvent(!mEnableScrolling); + requestLayout(); + } + + @Override + public boolean onTouchEvent(MotionEvent ev) { + if (mEnableScrolling) { + return super.onTouchEvent(ev); + } + return false; + } + + @Override + protected void measureChild(View child, int parentWidthMeasureSpec, + int parentHeightMeasureSpec) { + if (mEnableScrolling) { + super.measureChild(child, parentWidthMeasureSpec, parentHeightMeasureSpec); + return; + } + + final ViewGroup.LayoutParams lp = child.getLayoutParams(); + + final int childWidthMeasureSpec = getChildMeasureSpec(parentWidthMeasureSpec, + mPaddingLeft + mPaddingRight, lp.width); + final int childHeightMeasureSpec = getChildMeasureSpec(parentHeightMeasureSpec, + mPaddingTop + mPaddingBottom, lp.height); + + child.measure(childWidthMeasureSpec, childHeightMeasureSpec); + } + + @Override + protected void measureChildWithMargins(View child, + int parentWidthMeasureSpec, int widthUsed, + int parentHeightMeasureSpec, int heightUsed) { + if (mEnableScrolling) { + super.measureChildWithMargins(child, parentWidthMeasureSpec, + widthUsed, parentHeightMeasureSpec, heightUsed); + return; + } + + final MarginLayoutParams lp = (MarginLayoutParams) child.getLayoutParams(); + + final int childWidthMeasureSpec = getChildMeasureSpec(parentWidthMeasureSpec, + mPaddingLeft + mPaddingRight + lp.leftMargin + lp.rightMargin + + widthUsed, lp.width); + final int childHeightMeasureSpec = getChildMeasureSpec(parentHeightMeasureSpec, + mPaddingTop + mPaddingBottom + lp.topMargin + lp.bottomMargin + + heightUsed, lp.height); + + child.measure(childWidthMeasureSpec, childHeightMeasureSpec); + } } diff --git a/src/com/android/browser/BrowserBookmarksPage.java b/src/com/android/browser/BrowserBookmarksPage.java index e2447e8..27f6ef8 100644 --- a/src/com/android/browser/BrowserBookmarksPage.java +++ b/src/com/android/browser/BrowserBookmarksPage.java @@ -274,6 +274,7 @@ public class BrowserBookmarksPage extends Fragment implements View.OnCreateConte } } BookmarkItem header = new BookmarkItem(activity); + header.setEnableScrolling(true); populateBookmarkItem(cursor, header, isFolder); menu.setHeaderView(header); diff --git a/src/com/android/browser/BrowserHistoryPage.java b/src/com/android/browser/BrowserHistoryPage.java index 09c6f97..8461d77 100644 --- a/src/com/android/browser/BrowserHistoryPage.java +++ b/src/com/android/browser/BrowserHistoryPage.java @@ -357,6 +357,7 @@ public class BrowserHistoryPage extends Fragment // Setup the header if (mContextHeader == null) { mContextHeader = new HistoryItem(parent, false); + mContextHeader.setEnableScrolling(true); } else if (mContextHeader.getParent() != null) { ((ViewGroup) mContextHeader.getParent()).removeView(mContextHeader); } @@ -641,7 +642,6 @@ public class BrowserHistoryPage extends Fragment item.getPaddingRight(), item.getPaddingBottom()); item.setFaviconBackground(mFaviconBackground); - item.startMarquee(); } else { item = (HistoryItem) convertView; } diff --git a/src/com/android/browser/BrowserSnapshotPage.java b/src/com/android/browser/BrowserSnapshotPage.java index dd99771..be4f9af 100644 --- a/src/com/android/browser/BrowserSnapshotPage.java +++ b/src/com/android/browser/BrowserSnapshotPage.java @@ -160,6 +160,7 @@ public class BrowserSnapshotPage extends Fragment implements inflater.inflate(R.menu.snapshots_context, menu); // Create the header, re-use BookmarkItem (has the layout we want) BookmarkItem header = new BookmarkItem(getActivity()); + header.setEnableScrolling(true); AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo; populateBookmarkItem(mAdapter.getItem(info.position), header); menu.setHeaderView(header); |