Merge "Updated Browser launcher icon Bug: 5286988"
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.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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
}
}
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 @@
// 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 @@
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..be4f9af 100644
--- a/src/com/android/browser/BrowserSnapshotPage.java
+++ b/src/com/android/browser/BrowserSnapshotPage.java
@@ -15,6 +15,10 @@
*/
package com.android.browser;
+import android.animation.Animator;
+import android.animation.Animator.AnimatorListener;
+import android.animation.AnimatorSet;
+import android.animation.ObjectAnimator;
import android.app.Fragment;
import android.app.LoaderManager.LoaderCallbacks;
import android.content.ContentResolver;
@@ -63,6 +67,7 @@
Snapshots.URL,
Snapshots.DATE_CREATED,
};
+ private static final int SNAPSHOT_ID = 0;
private static final int SNAPSHOT_TITLE = 1;
private static final int SNAPSHOT_VIEWSTATE_LENGTH = 2;
private static final int SNAPSHOT_THUMBNAIL = 3;
@@ -74,11 +79,13 @@
View mEmpty;
SnapshotAdapter mAdapter;
CombinedBookmarksCallbacks mCallback;
+ long mAnimateId;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mCallback = (CombinedBookmarksCallbacks) getActivity();
+ mAnimateId = getArguments().getLong(EXTRA_ANIMATE_ID);
}
@Override
@@ -131,6 +138,11 @@
} else {
mAdapter.changeCursor(data);
}
+ if (mAnimateId > 0) {
+ mAdapter.animateIn(mAnimateId);
+ mAnimateId = 0;
+ getArguments().remove(EXTRA_ANIMATE_ID);
+ }
boolean empty = mAdapter.isEmpty();
mGrid.setVisibility(empty ? View.GONE : View.VISIBLE);
mEmpty.setVisibility(empty ? View.VISIBLE : View.GONE);
@@ -148,6 +160,7 @@
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);
@@ -196,13 +209,65 @@
}
private static class SnapshotAdapter extends ResourceCursorAdapter {
+ private long mAnimateId;
+ private AnimatorSet mAnimation;
+ private View mAnimationTarget;
public SnapshotAdapter(Context context, Cursor c) {
super(context, R.layout.snapshot_item, c, 0);
+ mAnimation = new AnimatorSet();
+ mAnimation.playTogether(
+ ObjectAnimator.ofFloat(null, View.SCALE_X, 0f, 1f),
+ ObjectAnimator.ofFloat(null, View.SCALE_Y, 0f, 1f));
+ mAnimation.setStartDelay(100);
+ mAnimation.setDuration(400);
+ mAnimation.addListener(new AnimatorListener() {
+
+ @Override
+ public void onAnimationStart(Animator animation) {
+ }
+
+ @Override
+ public void onAnimationRepeat(Animator animation) {
+ }
+
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ mAnimateId = 0;
+ mAnimationTarget = null;
+ }
+
+ @Override
+ public void onAnimationCancel(Animator animation) {
+ }
+ });
+ }
+
+ public void animateIn(long id) {
+ mAnimateId = id;
}
@Override
public void bindView(View view, Context context, Cursor cursor) {
+ long id = cursor.getLong(SNAPSHOT_ID);
+ if (id == mAnimateId) {
+ if (mAnimationTarget != view) {
+ float scale = 0f;
+ if (mAnimationTarget != null) {
+ scale = mAnimationTarget.getScaleX();
+ mAnimationTarget.setScaleX(1f);
+ mAnimationTarget.setScaleY(1f);
+ }
+ view.setScaleX(scale);
+ view.setScaleY(scale);
+ }
+ mAnimation.setTarget(view);
+ mAnimationTarget = view;
+ if (!mAnimation.isRunning()) {
+ mAnimation.start();
+ }
+
+ }
ImageView thumbnail = (ImageView) view.findViewById(R.id.thumb);
byte[] thumbBlob = cursor.getBlob(SNAPSHOT_THUMBNAIL);
if (thumbBlob == null) {