summaryrefslogtreecommitdiffstats
path: root/src/com/android/browser/NavigationBarTablet.java
diff options
context:
space:
mode:
authorMichael Kolb <kolby@google.com>2011-07-14 15:25:45 -0700
committerMichael Kolb <kolby@google.com>2011-07-14 15:42:57 -0700
commitde463761d9f92f665ac6158eba041ed89319426b (patch)
treef749e057b93d722744f7c1be3f3149889c26b16a /src/com/android/browser/NavigationBarTablet.java
parente9e1d4af4971e09392627e8e53d69d1b70bcb572 (diff)
downloadandroid_packages_apps_Gello-de463761d9f92f665ac6158eba041ed89319426b.tar.gz
android_packages_apps_Gello-de463761d9f92f665ac6158eba041ed89319426b.tar.bz2
android_packages_apps_Gello-de463761d9f92f665ac6158eba041ed89319426b.zip
adjust url bar for portrait large screen
Bug: 4515354 Original bug: 4335356 hand picked the changes into the new code Change-Id: I54b69a35660a5a38f41486c974c1cea171ee5d5e
Diffstat (limited to 'src/com/android/browser/NavigationBarTablet.java')
-rw-r--r--src/com/android/browser/NavigationBarTablet.java64
1 files changed, 63 insertions, 1 deletions
diff --git a/src/com/android/browser/NavigationBarTablet.java b/src/com/android/browser/NavigationBarTablet.java
index 45c1e75a..1aeb35bd 100644
--- a/src/com/android/browser/NavigationBarTablet.java
+++ b/src/com/android/browser/NavigationBarTablet.java
@@ -15,13 +15,17 @@
*/
package com.android.browser;
+import android.animation.Animator;
+import android.animation.AnimatorListenerAdapter;
+import android.animation.AnimatorSet;
+import android.animation.ObjectAnimator;
import android.content.Context;
+import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.View;
-import android.webkit.WebView;
import android.widget.ImageButton;
import android.widget.ImageView;
@@ -43,8 +47,10 @@ public class NavigationBarTablet extends NavigationBarBase {
private View mAllButton;
private View mClearButton;
private ImageView mVoiceSearch;
+ private View mNavButtons;
private Drawable mFocusDrawable;
private Drawable mUnfocusDrawable;
+ private boolean mHideNavButtons;
public NavigationBarTablet(Context context) {
super(context);
@@ -69,6 +75,7 @@ public class NavigationBarTablet extends NavigationBarBase {
R.drawable.textfield_active_holo_dark);
mUnfocusDrawable = resources.getDrawable(
R.drawable.textfield_default_holo_dark);
+ mHideNavButtons = resources.getBoolean(R.bool.hide_nav_buttons);
}
@Override
@@ -77,6 +84,7 @@ public class NavigationBarTablet extends NavigationBarBase {
mAllButton = findViewById(R.id.all_btn);
// TODO: Change enabled states based on whether you can go
// back/forward. Probably should be done inside onPageStarted.
+ mNavButtons = findViewById(R.id.navbuttons);
mBackButton = (ImageButton) findViewById(R.id.back);
mForwardButton = (ImageButton) findViewById(R.id.forward);
mUrlIcon = (ImageView) findViewById(R.id.url_icon);
@@ -100,6 +108,24 @@ public class NavigationBarTablet extends NavigationBarBase {
mUrlInput.setContainer(mUrlContainer);
}
+ public void onConfigurationChanged(Configuration config) {
+ super.onConfigurationChanged(config);
+ Resources res = mContext.getResources();
+ mHideNavButtons = res.getBoolean(R.bool.hide_nav_buttons);
+ if (mUrlInput.hasFocus()) {
+ if (mHideNavButtons && (mNavButtons.getVisibility() == View.VISIBLE)) {
+ int aw = mNavButtons.getMeasuredWidth();
+ mNavButtons.setVisibility(View.GONE);
+ mNavButtons.setAlpha(0f);
+ mNavButtons.setTranslationX(-aw);
+ } else if (!mHideNavButtons && (mNavButtons.getVisibility() == View.GONE)) {
+ mNavButtons.setVisibility(View.VISIBLE);
+ mNavButtons.setAlpha(1f);
+ mNavButtons.setTranslationX(0);
+ }
+ }
+ }
+
@Override
public void setTitleBar(TitleBar titleBar) {
super.setTitleBar(titleBar);
@@ -171,12 +197,18 @@ public class NavigationBarTablet extends NavigationBarBase {
protected void setFocusState(boolean focus) {
super.setFocusState(focus);
if (focus) {
+ if (mHideNavButtons) {
+ hideNavButtons();
+ }
mSearchButton.setVisibility(View.GONE);
mStar.setVisibility(View.GONE);
mClearButton.setVisibility(View.VISIBLE);
mUrlIcon.setImageResource(R.drawable.ic_search_holo_dark);
updateSearchMode(false);
} else {
+ if (mHideNavButtons) {
+ showNavButtons();
+ }
mGoButton.setVisibility(View.GONE);
mVoiceSearch.setVisibility(View.GONE);
mStar.setVisibility(View.VISIBLE);
@@ -232,4 +264,34 @@ public class NavigationBarTablet extends NavigationBarBase {
}
}
+ private void hideNavButtons() {
+ int awidth = mNavButtons.getMeasuredWidth();
+ Animator anim1 = ObjectAnimator.ofFloat(mNavButtons, View.TRANSLATION_X, 0, - awidth);
+ Animator anim2 = ObjectAnimator.ofInt(mUrlContainer, "left", mUrlContainer.getLeft(),
+ mUrlContainer.getPaddingLeft());
+ Animator anim3 = ObjectAnimator.ofFloat(mNavButtons, View.ALPHA, 1f, 0f);
+ AnimatorSet combo = new AnimatorSet();
+ combo.playTogether(anim1, anim2, anim3);
+ combo.addListener(new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ mNavButtons.setVisibility(View.GONE);
+ }
+ });
+ combo.setDuration(150);
+ combo.start();
+ }
+
+ private void showNavButtons() {
+ int awidth = mNavButtons.getMeasuredWidth();
+ Animator anim1 = ObjectAnimator.ofFloat(mNavButtons, View.TRANSLATION_X, -awidth, 0);
+ Animator anim2 = ObjectAnimator.ofInt(mUrlContainer, "left", 0, awidth);
+ Animator anim3 = ObjectAnimator.ofFloat(mNavButtons, View.ALPHA, 0f, 1f);
+ AnimatorSet combo = new AnimatorSet();
+ combo.playTogether(anim1, anim2, anim3);
+ mNavButtons.setVisibility(View.VISIBLE);
+ combo.setDuration(150);
+ combo.start();
+ }
+
}