summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2011-09-09 11:14:16 -0700
committerJohn Reck <jreck@google.com>2011-09-09 11:41:28 -0700
commit83c0151b266f4789cb1728294eac98e3dba0ed53 (patch)
treeb4a462df30b0ab1ceede47372298a8f552e4a1ea
parentd7dd9b2ecb12da278c053291b684b885ee574301 (diff)
downloadpackages_apps_browser-83c0151b266f4789cb1728294eac98e3dba0ed53.zip
packages_apps_browser-83c0151b266f4789cb1728294eac98e3dba0ed53.tar.gz
packages_apps_browser-83c0151b266f4789cb1728294eac98e3dba0ed53.tar.bz2
Cleanup history perf + UI
Bug: 5283880 Change-Id: Id2868335d308b8dabf79fe33e177a2d0babd66d9
-rw-r--r--res/layout/history_item.xml16
-rw-r--r--src/com/android/browser/BookmarkItem.java83
-rw-r--r--src/com/android/browser/BrowserBookmarksPage.java1
-rw-r--r--src/com/android/browser/BrowserHistoryPage.java2
-rw-r--r--src/com/android/browser/BrowserSnapshotPage.java1
5 files changed, 75 insertions, 28 deletions
diff --git a/res/layout/history_item.xml b/res/layout/history_item.xml
index f6076a0..ad07280 100644
--- a/res/layout/history_item.xml
+++ b/res/layout/history_item.xml
@@ -19,7 +19,8 @@
android:layout_height="wrap_content"
android:minHeight="?android:attr/listPreferredItemHeight"
android:orientation="horizontal"
- android:paddingLeft="20dip"
+ android:paddingLeft="12dip"
+ android:paddingRight="8dip"
>
<ImageView android:id="@+id/favicon"
android:layout_width="32dip"
@@ -33,7 +34,8 @@
android:layout_weight="1"
android:layout_height="wrap_content"
android:orientation="vertical"
- android:paddingLeft="16dip"
+ android:paddingLeft="8dip"
+ android:paddingRight="8dip"
android:layout_gravity="center_vertical"
>
<TextView android:id="@+id/title"
@@ -42,8 +44,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
- android:ellipsize="marquee"
- android:marqueeRepeatLimit="marquee_forever"
+ android:ellipsize="end"
/>
<TextView android:id="@+id/url"
android:textAppearance="?android:attr/textAppearanceSmall"
@@ -51,8 +52,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
- android:ellipsize="marquee"
- android:marqueeRepeatLimit="marquee_forever"
+ android:ellipsize="middle"
/>
</LinearLayout>
<CheckBox android:id="@+id/star"
@@ -60,8 +60,8 @@
android:layout_height="wrap_content"
android:paddingTop="16dip"
android:paddingBottom="16dip"
- android:paddingRight="20dip"
- android:paddingLeft="16dip"
+ android:paddingRight="8dip"
+ android:paddingLeft="8dip"
android:focusable="false"
android:button="@drawable/btn_checkbox_star"
android:layout_gravity="center_vertical"
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 72aa1b9..22c2cb2 100644
--- a/src/com/android/browser/BrowserSnapshotPage.java
+++ b/src/com/android/browser/BrowserSnapshotPage.java
@@ -148,6 +148,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);