summaryrefslogtreecommitdiffstats
path: root/src/com/android/browser/PhoneUi.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/browser/PhoneUi.java')
-rw-r--r--src/com/android/browser/PhoneUi.java110
1 files changed, 70 insertions, 40 deletions
diff --git a/src/com/android/browser/PhoneUi.java b/src/com/android/browser/PhoneUi.java
index f5a76b9..25a7d4a 100644
--- a/src/com/android/browser/PhoneUi.java
+++ b/src/com/android/browser/PhoneUi.java
@@ -26,6 +26,7 @@ import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.util.Log;
+import android.util.TypedValue;
import android.view.ActionMode;
import android.view.Gravity;
import android.view.KeyEvent;
@@ -35,7 +36,6 @@ import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityEvent;
-import android.view.animation.DecelerateInterpolator;
import android.webkit.WebView;
import android.widget.FrameLayout;
import android.widget.ImageView;
@@ -52,6 +52,7 @@ public class PhoneUi extends BaseUi {
private PieControlPhone mPieControl;
private NavScreen mNavScreen;
private NavigationBarPhone mNavigationBar;
+ private int mActionBarHeight;
boolean mExtendedMenuOpen;
boolean mOptionsMenuOpen;
@@ -63,9 +64,13 @@ public class PhoneUi extends BaseUi {
*/
public PhoneUi(Activity browser, UiController controller) {
super(browser, controller);
- mActivity.getActionBar().hide();
setUseQuickControls(BrowserSettings.getInstance().useQuickControls());
mNavigationBar = (NavigationBarPhone) mTitleBar.getNavigationBar();
+ TypedValue heightValue = new TypedValue();
+ browser.getTheme().resolveAttribute(
+ com.android.internal.R.attr.actionBarSize, heightValue, true);
+ mActionBarHeight = TypedValue.complexToDimensionPixelSize(heightValue.data,
+ browser.getResources().getDisplayMetrics());
}
@Override
@@ -84,7 +89,7 @@ public class PhoneUi extends BaseUi {
@Override
public boolean onBackKey() {
if (mNavScreen != null) {
- mNavScreen.close();
+ mNavScreen.close(mUiController.getTabControl().getCurrentPosition());
return true;
}
return super.onBackKey();
@@ -162,7 +167,6 @@ public class PhoneUi extends BaseUi {
@Override
public void updateMenuState(Tab tab, Menu menu) {
- menu.setGroupVisible(R.id.NAV_MENU, (mNavScreen == null));
MenuItem bm = menu.findItem(R.id.bookmarks_menu_id);
if (bm != null) {
bm.setVisible(mNavScreen == null);
@@ -173,14 +177,20 @@ public class PhoneUi extends BaseUi {
}
MenuItem abm = menu.findItem(R.id.add_bookmark_menu_id);
if (abm != null) {
- abm.setVisible((tab != null) && !tab.isSnapshot());
+ abm.setVisible((tab != null) && !tab.isSnapshot() && mNavScreen == null);
+ }
+ if (mNavScreen != null) {
+ menu.setGroupVisible(R.id.LIVE_MENU, false);
+ menu.setGroupVisible(R.id.SNAPSHOT_MENU, false);
+ menu.findItem(R.id.page_info_menu_id).setVisible(false);
+ menu.setGroupVisible(R.id.NAV_MENU, false);
}
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (mNavScreen != null) {
- hideNavScreen(false);
+ hideNavScreen(mUiController.getTabControl().getCurrentPosition(), false);
}
return false;
}
@@ -203,18 +213,20 @@ public class PhoneUi extends BaseUi {
public void onActionModeStarted(ActionMode mode) {
if (!isEditingUrl()) {
hideTitleBar();
+ } else {
+ mTitleBar.animate().translationY(mActionBarHeight);
}
}
@Override
public void onActionModeFinished(boolean inLoad) {
+ mTitleBar.animate().translationY(0);
if (inLoad) {
if (mUseQuickControls) {
mTitleBar.setShowProgressOnly(true);
}
showTitleBar();
}
- mActivity.getActionBar().hide();
}
@Override
@@ -265,7 +277,7 @@ public class PhoneUi extends BaseUi {
@Override
public void showWeb(boolean animate) {
super.showWeb(animate);
- hideNavScreen(animate);
+ hideNavScreen(mUiController.getTabControl().getCurrentPosition(), animate);
}
void showNavScreen() {
@@ -279,20 +291,21 @@ public class PhoneUi extends BaseUi {
mCustomViewContainer.addView(animView, COVER_SCREEN_PARAMS);
mCustomViewContainer.setVisibility(View.VISIBLE);
mCustomViewContainer.bringToFront();
- View target = ((NavTabView) mNavScreen.mScroller.getSelectedView()).mImage;
int fromLeft = 0;
int fromTop = getTitleBar().getHeight();
int fromRight = mContentView.getWidth();
int fromBottom = mContentView.getHeight();
- int width = target.getWidth();
- int height = target.getHeight();
+ int width = mActivity.getResources().getDimensionPixelSize(R.dimen.nav_tab_width);
+ int height = mActivity.getResources().getDimensionPixelSize(R.dimen.nav_tab_height);
+ int ntth = mActivity.getResources().getDimensionPixelSize(R.dimen.nav_tab_titleheight);
int toLeft = (mContentView.getWidth() - width) / 2;
- int toTop = fromTop + (mContentView.getHeight() - fromTop - height) / 2;
+ int toTop = ((fromBottom - (ntth + height)) / 2 + ntth);
int toRight = toLeft + width;
int toBottom = toTop + height;
float scaleFactor = width / (float) mContentView.getWidth();
detachTab(mActiveTab);
mContentView.setVisibility(View.GONE);
+ AnimatorSet set1 = new AnimatorSet();
AnimatorSet inanim = new AnimatorSet();
ObjectAnimator tx = ObjectAnimator.ofInt(ascreen.mContent, "left",
fromLeft, toLeft);
@@ -304,12 +317,14 @@ public class PhoneUi extends BaseUi {
fromBottom, toBottom);
ObjectAnimator title = ObjectAnimator.ofFloat(ascreen.mTitle, "alpha",
1f, 0f);
- ObjectAnimator content = ObjectAnimator.ofFloat(ascreen.mContent, "alpha",
- 1f, 0f);
ObjectAnimator sx = ObjectAnimator.ofFloat(ascreen, "scaleFactor",
1f, scaleFactor);
- inanim.playTogether(tx, ty, tr, tb, title, content, sx);
- inanim.addListener(new AnimatorListenerAdapter() {
+ ObjectAnimator blend1 = ObjectAnimator.ofFloat(ascreen.mMain, "alpha", 1, 0);
+ blend1.setDuration(100);
+
+ inanim.playTogether(tx, ty, tr, tb, sx, title);
+ inanim.setDuration(200);
+ set1.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator anim) {
mCustomViewContainer.removeView(animView);
@@ -317,9 +332,8 @@ public class PhoneUi extends BaseUi {
mUiController.setBlockEvents(false);
}
});
- inanim.setInterpolator(new DecelerateInterpolator(2f));
- inanim.setDuration(300);
- inanim.start();
+ set1.playSequentially(inanim, blend1);
+ set1.start();
}
private void finishAnimationIn() {
@@ -330,9 +344,9 @@ public class PhoneUi extends BaseUi {
}
}
- void hideNavScreen(boolean animate) {
+ void hideNavScreen(int position, boolean animate) {
if (mNavScreen == null) return;
- final Tab tab = mNavScreen.getSelectedTab();
+ final Tab tab = mUiController.getTabControl().getTab(position);
if ((tab == null) || !animate) {
if (tab != null) {
setActiveTab(tab);
@@ -344,7 +358,7 @@ public class PhoneUi extends BaseUi {
finishAnimateOut();
return;
}
- NavTabView tabview = (NavTabView) mNavScreen.getSelectedTabView();
+ NavTabView tabview = (NavTabView) mNavScreen.getTabView(position);
if (tabview == null) {
if (mTabControl.getTabCount() > 0) {
// use a fallback tab
@@ -358,23 +372,36 @@ public class PhoneUi extends BaseUi {
mUiController.setActiveTab(tab);
mContentView.setVisibility(View.VISIBLE);
final AnimScreen screen = new AnimScreen(mActivity, tab.getScreenshot());
- View target = ((NavTabView) mNavScreen.mScroller.getSelectedView()).mImage;
+ mCustomViewContainer.addView(screen.mMain, COVER_SCREEN_PARAMS);
+ screen.mMain.layout(0, 0, mContentView.getWidth(),
+ mContentView.getHeight());
+ mNavScreen.mScroller.finishScroller();
+ ImageView target = tabview.mImage;
int toLeft = 0;
int toTop = getTitleBar().getHeight();
int toRight = mContentView.getWidth();
- int width = target.getWidth();
- int height = target.getHeight();
- int[] pos = new int[2];
- tabview.mImage.getLocationInWindow(pos);
- int fromLeft = pos[0];
- int fromTop = pos[1];
+ int width = target.getDrawable().getIntrinsicWidth();
+ int height = target.getDrawable().getIntrinsicHeight();
+ int fromLeft = tabview.getLeft() + target.getLeft() - mNavScreen.mScroller.getScrollX();
+ int fromTop = tabview.getTop() + target.getTop() - mNavScreen.mScroller.getScrollY();
int fromRight = fromLeft + width;
int fromBottom = fromTop + height;
float scaleFactor = mContentView.getWidth() / (float) width;
- int toBottom = (int) (height * scaleFactor);
- screen.mMain.setAlpha(0f);
- mCustomViewContainer.addView(screen.mMain, COVER_SCREEN_PARAMS);
- AnimatorSet animSet = new AnimatorSet();
+ int toBottom = toTop + (int) (height * scaleFactor);
+ ObjectAnimator l1 = ObjectAnimator.ofInt(screen.mContent, "left",
+ fromLeft, fromLeft);
+ ObjectAnimator t1 = ObjectAnimator.ofInt(screen.mContent, "top",
+ fromTop, fromTop);
+ ObjectAnimator r1 = ObjectAnimator.ofInt(screen.mContent, "right",
+ fromRight, fromRight);
+ ObjectAnimator b1 = ObjectAnimator.ofInt(screen.mContent, "bottom",
+ fromBottom, fromBottom);
+ AnimatorSet set1 = new AnimatorSet();
+ ObjectAnimator fade2 = ObjectAnimator.ofFloat(screen.mMain, "alpha", 0f, 1f);
+ ObjectAnimator fade1 = ObjectAnimator.ofFloat(mNavScreen, "alpha", 1f, 0f);
+ set1.playTogether(l1, t1, r1, b1, fade1, fade2);
+ set1.setDuration(100);
+ AnimatorSet set2 = new AnimatorSet();
ObjectAnimator l = ObjectAnimator.ofInt(screen.mContent, "left",
fromLeft, toLeft);
ObjectAnimator t = ObjectAnimator.ofInt(screen.mContent, "top",
@@ -385,11 +412,13 @@ public class PhoneUi extends BaseUi {
fromBottom, toBottom);
ObjectAnimator scale = ObjectAnimator.ofFloat(screen, "scaleFactor",
1f, scaleFactor);
- ObjectAnimator alpha = ObjectAnimator.ofFloat(screen.mMain, "alpha", 1f, 1f);
ObjectAnimator otheralpha = ObjectAnimator.ofFloat(mCustomViewContainer, "alpha", 1f, 0f);
- alpha.setStartDelay(100);
- animSet.playTogether(l, t, r, b, scale, alpha, otheralpha);
- animSet.addListener(new AnimatorListenerAdapter() {
+ otheralpha.setDuration(100);
+ set2.playTogether(l, t, r, b, scale);
+ set2.setDuration(200);
+ AnimatorSet combo = new AnimatorSet();
+ combo.playSequentially(set1, set2, otheralpha);
+ combo.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator anim) {
mCustomViewContainer.removeView(screen.mMain);
@@ -397,8 +426,7 @@ public class PhoneUi extends BaseUi {
mUiController.setBlockEvents(false);
}
});
- animSet.setDuration(250);
- animSet.start();
+ combo.start();
}
private void finishAnimateOut() {
@@ -418,7 +446,7 @@ public class PhoneUi extends BaseUi {
if (mNavScreen == null) {
showNavScreen();
} else {
- hideNavScreen(false);
+ hideNavScreen(mUiController.getTabControl().getCurrentPosition(), false);
}
}
@@ -464,6 +492,8 @@ public class PhoneUi extends BaseUi {
public AnimScreen(Context ctx, Bitmap image) {
mMain = LayoutInflater.from(ctx).inflate(R.layout.anim_screen,
null);
+ mTitle = (ImageView) mMain.findViewById(R.id.title);
+ mTitle.setVisibility(View.GONE);
mContent = (ImageView) mMain.findViewById(R.id.content);
mContent.setImageBitmap(image);
mContent.setScaleType(ImageView.ScaleType.MATRIX);