Leon Scroggins | 571b376 | 2010-05-26 10:25:01 -0400 | [diff] [blame] | 1 | /* |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 2 | * Copyright (C) 2011 The Android Open Source Project |
Leon Scroggins | 571b376 | 2010-05-26 10:25:01 -0400 | [diff] [blame] | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
Leon Scroggins | 571b376 | 2010-05-26 10:25:01 -0400 | [diff] [blame] | 16 | package com.android.browser; |
| 17 | |
Michael Kolb | de46376 | 2011-07-14 15:25:45 -0700 | [diff] [blame] | 18 | import android.animation.Animator; |
| 19 | import android.animation.AnimatorListenerAdapter; |
| 20 | import android.animation.AnimatorSet; |
| 21 | import android.animation.ObjectAnimator; |
Leon Scroggins | 571b376 | 2010-05-26 10:25:01 -0400 | [diff] [blame] | 22 | import android.content.Context; |
John Reck | a60fffa | 2011-09-06 16:30:29 -0700 | [diff] [blame] | 23 | import android.content.Intent; |
Michael Kolb | de46376 | 2011-07-14 15:25:45 -0700 | [diff] [blame] | 24 | import android.content.res.Configuration; |
Leon Scroggins | 571b376 | 2010-05-26 10:25:01 -0400 | [diff] [blame] | 25 | import android.content.res.Resources; |
John Reck | 034637c | 2011-08-11 11:34:44 -0700 | [diff] [blame] | 26 | import android.graphics.Bitmap; |
Leon Scroggins | 571b376 | 2010-05-26 10:25:01 -0400 | [diff] [blame] | 27 | import android.graphics.drawable.Drawable; |
Michael Kolb | 1ce7813 | 2010-09-23 15:50:53 -0700 | [diff] [blame] | 28 | import android.text.TextUtils; |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 29 | import android.util.AttributeSet; |
Leon Scroggins | 571b376 | 2010-05-26 10:25:01 -0400 | [diff] [blame] | 30 | import android.view.View; |
Michael Kolb | 5a72f18 | 2011-01-13 20:35:06 -0800 | [diff] [blame] | 31 | import android.widget.ImageButton; |
Leon Scroggins | 571b376 | 2010-05-26 10:25:01 -0400 | [diff] [blame] | 32 | import android.widget.ImageView; |
Leon Scroggins | 571b376 | 2010-05-26 10:25:01 -0400 | [diff] [blame] | 33 | |
Michael Kolb | 315d502 | 2011-10-13 12:47:11 -0700 | [diff] [blame] | 34 | import com.android.browser.UI.ComboViews; |
Michael Kolb | 0b12912 | 2012-06-04 16:31:58 -0700 | [diff] [blame] | 35 | import com.android.browser.UrlInputView.StateListener; |
Michael Kolb | 315d502 | 2011-10-13 12:47:11 -0700 | [diff] [blame] | 36 | |
Michael Kolb | 0b12912 | 2012-06-04 16:31:58 -0700 | [diff] [blame] | 37 | public class NavigationBarTablet extends NavigationBarBase implements StateListener { |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 38 | |
Michael Kolb | a2b2ba8 | 2010-08-04 17:54:03 -0700 | [diff] [blame] | 39 | private Drawable mStopDrawable; |
| 40 | private Drawable mReloadDrawable; |
Michael Kolb | 30adae6 | 2011-07-29 13:37:05 -0700 | [diff] [blame] | 41 | private String mStopDescription; |
| 42 | private String mRefreshDescription; |
Michael Kolb | c7485ae | 2010-09-03 10:10:58 -0700 | [diff] [blame] | 43 | |
Michael Kolb | 11d1978 | 2011-03-20 10:17:40 -0700 | [diff] [blame] | 44 | private View mUrlContainer; |
Michael Kolb | 5a72f18 | 2011-01-13 20:35:06 -0800 | [diff] [blame] | 45 | private ImageButton mBackButton; |
| 46 | private ImageButton mForwardButton; |
Michael Kolb | 31d469b | 2010-12-09 20:49:54 -0800 | [diff] [blame] | 47 | private ImageView mStar; |
Michael Kolb | e3524d8 | 2011-03-02 14:53:15 -0800 | [diff] [blame] | 48 | private ImageView mUrlIcon; |
| 49 | private ImageView mSearchButton; |
Michael Kolb | a2b2ba8 | 2010-08-04 17:54:03 -0700 | [diff] [blame] | 50 | private ImageView mStopButton; |
Michael Kolb | a2b2ba8 | 2010-08-04 17:54:03 -0700 | [diff] [blame] | 51 | private View mAllButton; |
Michael Kolb | b7b115e | 2010-09-25 16:59:37 -0700 | [diff] [blame] | 52 | private View mClearButton; |
Michael Kolb | 0b12912 | 2012-06-04 16:31:58 -0700 | [diff] [blame] | 53 | private View mVoiceButton; |
Michael Kolb | de46376 | 2011-07-14 15:25:45 -0700 | [diff] [blame] | 54 | private View mNavButtons; |
Michael Kolb | cfa3af5 | 2010-12-14 10:36:11 -0800 | [diff] [blame] | 55 | private Drawable mFocusDrawable; |
| 56 | private Drawable mUnfocusDrawable; |
Michael Kolb | de46376 | 2011-07-14 15:25:45 -0700 | [diff] [blame] | 57 | private boolean mHideNavButtons; |
John Reck | 034637c | 2011-08-11 11:34:44 -0700 | [diff] [blame] | 58 | private Drawable mFaviconDrawable; |
Michael Kolb | 81b6f83 | 2010-12-12 12:44:27 -0800 | [diff] [blame] | 59 | |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 60 | public NavigationBarTablet(Context context) { |
| 61 | super(context); |
| 62 | init(context); |
| 63 | } |
| 64 | |
| 65 | public NavigationBarTablet(Context context, AttributeSet attrs) { |
| 66 | super(context, attrs); |
| 67 | init(context); |
| 68 | } |
| 69 | |
| 70 | public NavigationBarTablet(Context context, AttributeSet attrs, int defStyle) { |
| 71 | super(context, attrs, defStyle); |
| 72 | init(context); |
| 73 | } |
| 74 | |
| 75 | private void init(Context context) { |
| 76 | Resources resources = context.getResources(); |
Michael Kolb | 5a72f18 | 2011-01-13 20:35:06 -0800 | [diff] [blame] | 77 | mStopDrawable = resources.getDrawable(R.drawable.ic_stop_holo_dark); |
| 78 | mReloadDrawable = resources.getDrawable(R.drawable.ic_refresh_holo_dark); |
Michael Kolb | 30adae6 | 2011-07-29 13:37:05 -0700 | [diff] [blame] | 79 | mStopDescription = resources.getString(R.string.accessibility_button_stop); |
| 80 | mRefreshDescription = resources.getString(R.string.accessibility_button_refresh); |
Michael Kolb | cfa3af5 | 2010-12-14 10:36:11 -0800 | [diff] [blame] | 81 | mFocusDrawable = resources.getDrawable( |
| 82 | R.drawable.textfield_active_holo_dark); |
| 83 | mUnfocusDrawable = resources.getDrawable( |
| 84 | R.drawable.textfield_default_holo_dark); |
Michael Kolb | de46376 | 2011-07-14 15:25:45 -0700 | [diff] [blame] | 85 | mHideNavButtons = resources.getBoolean(R.bool.hide_nav_buttons); |
Michael Kolb | fe25199 | 2010-07-08 15:41:55 -0700 | [diff] [blame] | 86 | } |
Leon Scroggins | 571b376 | 2010-05-26 10:25:01 -0400 | [diff] [blame] | 87 | |
Michael Kolb | 7cdc490 | 2011-02-03 17:54:40 -0800 | [diff] [blame] | 88 | @Override |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 89 | protected void onFinishInflate() { |
| 90 | super.onFinishInflate(); |
Michael Kolb | fe25199 | 2010-07-08 15:41:55 -0700 | [diff] [blame] | 91 | mAllButton = findViewById(R.id.all_btn); |
| 92 | // TODO: Change enabled states based on whether you can go |
Leon Scroggins | 571b376 | 2010-05-26 10:25:01 -0400 | [diff] [blame] | 93 | // back/forward. Probably should be done inside onPageStarted. |
Michael Kolb | de46376 | 2011-07-14 15:25:45 -0700 | [diff] [blame] | 94 | mNavButtons = findViewById(R.id.navbuttons); |
Michael Kolb | 5a72f18 | 2011-01-13 20:35:06 -0800 | [diff] [blame] | 95 | mBackButton = (ImageButton) findViewById(R.id.back); |
| 96 | mForwardButton = (ImageButton) findViewById(R.id.forward); |
Michael Kolb | e3524d8 | 2011-03-02 14:53:15 -0800 | [diff] [blame] | 97 | mUrlIcon = (ImageView) findViewById(R.id.url_icon); |
Michael Kolb | 31d469b | 2010-12-09 20:49:54 -0800 | [diff] [blame] | 98 | mStar = (ImageView) findViewById(R.id.star); |
Michael Kolb | a2b2ba8 | 2010-08-04 17:54:03 -0700 | [diff] [blame] | 99 | mStopButton = (ImageView) findViewById(R.id.stop); |
Michael Kolb | e3524d8 | 2011-03-02 14:53:15 -0800 | [diff] [blame] | 100 | mSearchButton = (ImageView) findViewById(R.id.search); |
Michael Kolb | b7b115e | 2010-09-25 16:59:37 -0700 | [diff] [blame] | 101 | mClearButton = findViewById(R.id.clear); |
Michael Kolb | 0b12912 | 2012-06-04 16:31:58 -0700 | [diff] [blame] | 102 | mVoiceButton = findViewById(R.id.voice); |
Michael Kolb | 31d469b | 2010-12-09 20:49:54 -0800 | [diff] [blame] | 103 | mUrlContainer = findViewById(R.id.urlbar_focused); |
Michael Kolb | a2b2ba8 | 2010-08-04 17:54:03 -0700 | [diff] [blame] | 104 | mBackButton.setOnClickListener(this); |
| 105 | mForwardButton.setOnClickListener(this); |
| 106 | mStar.setOnClickListener(this); |
| 107 | mAllButton.setOnClickListener(this); |
| 108 | mStopButton.setOnClickListener(this); |
| 109 | mSearchButton.setOnClickListener(this); |
Michael Kolb | b7b115e | 2010-09-25 16:59:37 -0700 | [diff] [blame] | 110 | mClearButton.setOnClickListener(this); |
Michael Kolb | 0b12912 | 2012-06-04 16:31:58 -0700 | [diff] [blame] | 111 | mVoiceButton.setOnClickListener(this); |
Michael Kolb | 31d469b | 2010-12-09 20:49:54 -0800 | [diff] [blame] | 112 | mUrlInput.setContainer(mUrlContainer); |
Michael Kolb | 0b12912 | 2012-06-04 16:31:58 -0700 | [diff] [blame] | 113 | mUrlInput.setStateListener(this); |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 114 | } |
| 115 | |
Michael Kolb | de46376 | 2011-07-14 15:25:45 -0700 | [diff] [blame] | 116 | public void onConfigurationChanged(Configuration config) { |
| 117 | super.onConfigurationChanged(config); |
| 118 | Resources res = mContext.getResources(); |
| 119 | mHideNavButtons = res.getBoolean(R.bool.hide_nav_buttons); |
| 120 | if (mUrlInput.hasFocus()) { |
| 121 | if (mHideNavButtons && (mNavButtons.getVisibility() == View.VISIBLE)) { |
| 122 | int aw = mNavButtons.getMeasuredWidth(); |
| 123 | mNavButtons.setVisibility(View.GONE); |
| 124 | mNavButtons.setAlpha(0f); |
| 125 | mNavButtons.setTranslationX(-aw); |
| 126 | } else if (!mHideNavButtons && (mNavButtons.getVisibility() == View.GONE)) { |
| 127 | mNavButtons.setVisibility(View.VISIBLE); |
| 128 | mNavButtons.setAlpha(1f); |
| 129 | mNavButtons.setTranslationX(0); |
| 130 | } |
| 131 | } |
| 132 | } |
| 133 | |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 134 | @Override |
| 135 | public void setTitleBar(TitleBar titleBar) { |
| 136 | super.setTitleBar(titleBar); |
Michael Kolb | dc2ee1b | 2011-02-14 14:34:40 -0800 | [diff] [blame] | 137 | setFocusState(false); |
Michael Kolb | 31d469b | 2010-12-09 20:49:54 -0800 | [diff] [blame] | 138 | } |
| 139 | |
Michael Kolb | 5a72f18 | 2011-01-13 20:35:06 -0800 | [diff] [blame] | 140 | void updateNavigationState(Tab tab) { |
John Reck | ef654f1 | 2011-07-12 16:42:08 -0700 | [diff] [blame] | 141 | if (tab != null) { |
| 142 | mBackButton.setImageResource(tab.canGoBack() |
Michael Kolb | 5a72f18 | 2011-01-13 20:35:06 -0800 | [diff] [blame] | 143 | ? R.drawable.ic_back_holo_dark |
| 144 | : R.drawable.ic_back_disabled_holo_dark); |
John Reck | ef654f1 | 2011-07-12 16:42:08 -0700 | [diff] [blame] | 145 | mForwardButton.setImageResource(tab.canGoForward() |
Michael Kolb | 5a72f18 | 2011-01-13 20:35:06 -0800 | [diff] [blame] | 146 | ? R.drawable.ic_forward_holo_dark |
| 147 | : R.drawable.ic_forward_disabled_holo_dark); |
| 148 | } |
John Reck | b8b2af8 | 2011-05-20 15:58:33 -0700 | [diff] [blame] | 149 | updateUrlIcon(); |
Michael Kolb | 5a72f18 | 2011-01-13 20:35:06 -0800 | [diff] [blame] | 150 | } |
| 151 | |
Michael Kolb | 31d469b | 2010-12-09 20:49:54 -0800 | [diff] [blame] | 152 | @Override |
George Mount | 387d45d | 2011-10-07 15:57:53 -0700 | [diff] [blame] | 153 | public void onTabDataChanged(Tab tab) { |
| 154 | super.onTabDataChanged(tab); |
| 155 | showHideStar(tab); |
| 156 | } |
| 157 | |
| 158 | @Override |
Leon Scroggins | 4cd9779 | 2010-12-03 15:31:56 -0500 | [diff] [blame] | 159 | public void setCurrentUrlIsBookmark(boolean isBookmark) { |
Michael Kolb | 31d469b | 2010-12-09 20:49:54 -0800 | [diff] [blame] | 160 | mStar.setActivated(isBookmark); |
Leon Scroggins | 4cd9779 | 2010-12-03 15:31:56 -0500 | [diff] [blame] | 161 | } |
| 162 | |
Michael Kolb | a2b2ba8 | 2010-08-04 17:54:03 -0700 | [diff] [blame] | 163 | @Override |
| 164 | public void onClick(View v) { |
Michael Kolb | c832e5e | 2012-03-09 15:08:23 -0800 | [diff] [blame] | 165 | if ((mBackButton == v) && (mUiController.getCurrentTab() != null)) { |
John Reck | ef654f1 | 2011-07-12 16:42:08 -0700 | [diff] [blame] | 166 | mUiController.getCurrentTab().goBack(); |
Michael Kolb | c832e5e | 2012-03-09 15:08:23 -0800 | [diff] [blame] | 167 | } else if ((mForwardButton == v) && (mUiController.getCurrentTab() != null)) { |
John Reck | ef654f1 | 2011-07-12 16:42:08 -0700 | [diff] [blame] | 168 | mUiController.getCurrentTab().goForward(); |
Michael Kolb | a2b2ba8 | 2010-08-04 17:54:03 -0700 | [diff] [blame] | 169 | } else if (mStar == v) { |
John Reck | a60fffa | 2011-09-06 16:30:29 -0700 | [diff] [blame] | 170 | Intent intent = mUiController.createBookmarkCurrentPageIntent(true); |
| 171 | if (intent != null) { |
| 172 | getContext().startActivity(intent); |
| 173 | } |
Michael Kolb | a2b2ba8 | 2010-08-04 17:54:03 -0700 | [diff] [blame] | 174 | } else if (mAllButton == v) { |
Michael Kolb | 315d502 | 2011-10-13 12:47:11 -0700 | [diff] [blame] | 175 | mUiController.bookmarksOrHistoryPicker(ComboViews.Bookmarks); |
Michael Kolb | a2b2ba8 | 2010-08-04 17:54:03 -0700 | [diff] [blame] | 176 | } else if (mSearchButton == v) { |
Michael Kolb | 5ff5c8b | 2012-05-03 11:37:58 -0700 | [diff] [blame] | 177 | mBaseUi.editUrl(true, true); |
Michael Kolb | a2b2ba8 | 2010-08-04 17:54:03 -0700 | [diff] [blame] | 178 | } else if (mStopButton == v) { |
| 179 | stopOrRefresh(); |
Michael Kolb | b7b115e | 2010-09-25 16:59:37 -0700 | [diff] [blame] | 180 | } else if (mClearButton == v) { |
Michael Kolb | 31d469b | 2010-12-09 20:49:54 -0800 | [diff] [blame] | 181 | clearOrClose(); |
Michael Kolb | 0b12912 | 2012-06-04 16:31:58 -0700 | [diff] [blame] | 182 | } else if (mVoiceButton == v) { |
| 183 | mUiController.startVoiceRecognizer(); |
Michael Kolb | 11d1978 | 2011-03-20 10:17:40 -0700 | [diff] [blame] | 184 | } else { |
| 185 | super.onClick(v); |
Michael Kolb | fe25199 | 2010-07-08 15:41:55 -0700 | [diff] [blame] | 186 | } |
| 187 | } |
| 188 | |
Michael Kolb | 31d469b | 2010-12-09 20:49:54 -0800 | [diff] [blame] | 189 | private void clearOrClose() { |
Narayan Kamath | f3174a5 | 2011-11-17 14:43:32 +0000 | [diff] [blame] | 190 | if (TextUtils.isEmpty(mUrlInput.getText())) { |
Michael Kolb | 31d469b | 2010-12-09 20:49:54 -0800 | [diff] [blame] | 191 | // close |
Michael Kolb | 7cdc490 | 2011-02-03 17:54:40 -0800 | [diff] [blame] | 192 | mUrlInput.clearFocus(); |
Michael Kolb | 31d469b | 2010-12-09 20:49:54 -0800 | [diff] [blame] | 193 | } else { |
| 194 | // clear |
| 195 | mUrlInput.setText(""); |
| 196 | } |
| 197 | } |
| 198 | |
John Reck | 034637c | 2011-08-11 11:34:44 -0700 | [diff] [blame] | 199 | @Override |
| 200 | public void setFavicon(Bitmap icon) { |
| 201 | mFaviconDrawable = mBaseUi.getFaviconDrawable(icon); |
| 202 | updateUrlIcon(); |
| 203 | } |
| 204 | |
John Reck | b8b2af8 | 2011-05-20 15:58:33 -0700 | [diff] [blame] | 205 | void updateUrlIcon() { |
John Reck | 034637c | 2011-08-11 11:34:44 -0700 | [diff] [blame] | 206 | if (mUrlInput.hasFocus()) { |
| 207 | mUrlIcon.setImageResource(R.drawable.ic_search_holo_dark); |
| 208 | } else { |
Michael Kolb | 5ff5c8b | 2012-05-03 11:37:58 -0700 | [diff] [blame] | 209 | if (mFaviconDrawable == null) { |
| 210 | mFaviconDrawable = mBaseUi.getFaviconDrawable(null); |
John Reck | 034637c | 2011-08-11 11:34:44 -0700 | [diff] [blame] | 211 | } |
Michael Kolb | 5ff5c8b | 2012-05-03 11:37:58 -0700 | [diff] [blame] | 212 | mUrlIcon.setImageDrawable(mFaviconDrawable); |
John Reck | 034637c | 2011-08-11 11:34:44 -0700 | [diff] [blame] | 213 | } |
John Reck | b8b2af8 | 2011-05-20 15:58:33 -0700 | [diff] [blame] | 214 | } |
| 215 | |
Michael Kolb | 11d1978 | 2011-03-20 10:17:40 -0700 | [diff] [blame] | 216 | @Override |
| 217 | protected void setFocusState(boolean focus) { |
| 218 | super.setFocusState(focus); |
Michael Kolb | dc2ee1b | 2011-02-14 14:34:40 -0800 | [diff] [blame] | 219 | if (focus) { |
Michael Kolb | de46376 | 2011-07-14 15:25:45 -0700 | [diff] [blame] | 220 | if (mHideNavButtons) { |
| 221 | hideNavButtons(); |
| 222 | } |
Michael Kolb | b7b115e | 2010-09-25 16:59:37 -0700 | [diff] [blame] | 223 | mSearchButton.setVisibility(View.GONE); |
Michael Kolb | 31d469b | 2010-12-09 20:49:54 -0800 | [diff] [blame] | 224 | mStar.setVisibility(View.GONE); |
Michael Kolb | e3524d8 | 2011-03-02 14:53:15 -0800 | [diff] [blame] | 225 | mUrlIcon.setImageResource(R.drawable.ic_search_holo_dark); |
Michael Kolb | b7b115e | 2010-09-25 16:59:37 -0700 | [diff] [blame] | 226 | } else { |
Michael Kolb | de46376 | 2011-07-14 15:25:45 -0700 | [diff] [blame] | 227 | if (mHideNavButtons) { |
| 228 | showNavButtons(); |
| 229 | } |
George Mount | 387d45d | 2011-10-07 15:57:53 -0700 | [diff] [blame] | 230 | showHideStar(mUiController.getCurrentTab()); |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 231 | if (mTitleBar.useQuickControls()) { |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 232 | mSearchButton.setVisibility(View.GONE); |
| 233 | } else { |
| 234 | mSearchButton.setVisibility(View.VISIBLE); |
| 235 | } |
John Reck | b8b2af8 | 2011-05-20 15:58:33 -0700 | [diff] [blame] | 236 | updateUrlIcon(); |
Michael Kolb | b7b115e | 2010-09-25 16:59:37 -0700 | [diff] [blame] | 237 | } |
John Reck | 7e5b8b5 | 2011-06-22 13:46:25 -0700 | [diff] [blame] | 238 | mUrlContainer.setBackgroundDrawable(focus |
| 239 | ? mFocusDrawable : mUnfocusDrawable); |
Michael Kolb | b7b115e | 2010-09-25 16:59:37 -0700 | [diff] [blame] | 240 | } |
| 241 | |
Michael Kolb | a2b2ba8 | 2010-08-04 17:54:03 -0700 | [diff] [blame] | 242 | private void stopOrRefresh() { |
Michael Kolb | 1392b83 | 2011-09-07 13:02:59 -0700 | [diff] [blame] | 243 | if (mUiController == null) return; |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 244 | if (mTitleBar.isInLoad()) { |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 245 | mUiController.stopLoading(); |
Michael Kolb | a2b2ba8 | 2010-08-04 17:54:03 -0700 | [diff] [blame] | 246 | } else { |
Michael Kolb | 6645084 | 2011-12-15 15:01:19 -0800 | [diff] [blame] | 247 | if (mUiController.getCurrentTopWebView() != null) { |
| 248 | mUiController.getCurrentTopWebView().reload(); |
| 249 | } |
Michael Kolb | a2b2ba8 | 2010-08-04 17:54:03 -0700 | [diff] [blame] | 250 | } |
Leon Scroggins | 571b376 | 2010-05-26 10:25:01 -0400 | [diff] [blame] | 251 | } |
| 252 | |
Michael Kolb | fe25199 | 2010-07-08 15:41:55 -0700 | [diff] [blame] | 253 | @Override |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 254 | public void onProgressStarted() { |
Michael Kolb | 46f987e | 2011-04-05 10:39:10 -0700 | [diff] [blame] | 255 | mStopButton.setImageDrawable(mStopDrawable); |
Michael Kolb | 30adae6 | 2011-07-29 13:37:05 -0700 | [diff] [blame] | 256 | mStopButton.setContentDescription(mStopDescription); |
Michael Kolb | 46f987e | 2011-04-05 10:39:10 -0700 | [diff] [blame] | 257 | } |
| 258 | |
| 259 | @Override |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 260 | public void onProgressStopped() { |
Michael Kolb | 46f987e | 2011-04-05 10:39:10 -0700 | [diff] [blame] | 261 | mStopButton.setImageDrawable(mReloadDrawable); |
Michael Kolb | 30adae6 | 2011-07-29 13:37:05 -0700 | [diff] [blame] | 262 | mStopButton.setContentDescription(mRefreshDescription); |
Michael Kolb | fe25199 | 2010-07-08 15:41:55 -0700 | [diff] [blame] | 263 | } |
| 264 | |
Michael Kolb | bae0cb2 | 2012-05-29 11:15:27 -0700 | [diff] [blame] | 265 | private AnimatorSet mAnimation; |
| 266 | |
Michael Kolb | de46376 | 2011-07-14 15:25:45 -0700 | [diff] [blame] | 267 | private void hideNavButtons() { |
Michael Kolb | bae0cb2 | 2012-05-29 11:15:27 -0700 | [diff] [blame] | 268 | if (mBaseUi.blockFocusAnimations()) { |
| 269 | mNavButtons.setVisibility(View.GONE); |
| 270 | return; |
| 271 | } |
Michael Kolb | de46376 | 2011-07-14 15:25:45 -0700 | [diff] [blame] | 272 | int awidth = mNavButtons.getMeasuredWidth(); |
| 273 | Animator anim1 = ObjectAnimator.ofFloat(mNavButtons, View.TRANSLATION_X, 0, - awidth); |
| 274 | Animator anim2 = ObjectAnimator.ofInt(mUrlContainer, "left", mUrlContainer.getLeft(), |
| 275 | mUrlContainer.getPaddingLeft()); |
| 276 | Animator anim3 = ObjectAnimator.ofFloat(mNavButtons, View.ALPHA, 1f, 0f); |
Michael Kolb | bae0cb2 | 2012-05-29 11:15:27 -0700 | [diff] [blame] | 277 | mAnimation = new AnimatorSet(); |
| 278 | mAnimation.playTogether(anim1, anim2, anim3); |
| 279 | mAnimation.addListener(new AnimatorListenerAdapter() { |
Michael Kolb | de46376 | 2011-07-14 15:25:45 -0700 | [diff] [blame] | 280 | @Override |
| 281 | public void onAnimationEnd(Animator animation) { |
| 282 | mNavButtons.setVisibility(View.GONE); |
Michael Kolb | bae0cb2 | 2012-05-29 11:15:27 -0700 | [diff] [blame] | 283 | mAnimation = null; |
Michael Kolb | de46376 | 2011-07-14 15:25:45 -0700 | [diff] [blame] | 284 | } |
| 285 | }); |
Michael Kolb | bae0cb2 | 2012-05-29 11:15:27 -0700 | [diff] [blame] | 286 | mAnimation.setDuration(150); |
| 287 | mAnimation.start(); |
Michael Kolb | de46376 | 2011-07-14 15:25:45 -0700 | [diff] [blame] | 288 | } |
| 289 | |
| 290 | private void showNavButtons() { |
Michael Kolb | bae0cb2 | 2012-05-29 11:15:27 -0700 | [diff] [blame] | 291 | if (mAnimation != null) { |
| 292 | mAnimation.cancel(); |
| 293 | } |
Michael Kolb | de46376 | 2011-07-14 15:25:45 -0700 | [diff] [blame] | 294 | mNavButtons.setVisibility(View.VISIBLE); |
Michael Kolb | 0b12912 | 2012-06-04 16:31:58 -0700 | [diff] [blame] | 295 | mNavButtons.setTranslationX(0); |
Michael Kolb | bae0cb2 | 2012-05-29 11:15:27 -0700 | [diff] [blame] | 296 | if (!mBaseUi.blockFocusAnimations()) { |
| 297 | int awidth = mNavButtons.getMeasuredWidth(); |
| 298 | Animator anim1 = ObjectAnimator.ofFloat(mNavButtons, |
| 299 | View.TRANSLATION_X, -awidth, 0); |
| 300 | Animator anim2 = ObjectAnimator.ofInt(mUrlContainer, "left", 0, |
| 301 | awidth); |
| 302 | Animator anim3 = ObjectAnimator.ofFloat(mNavButtons, View.ALPHA, |
| 303 | 0f, 1f); |
| 304 | AnimatorSet combo = new AnimatorSet(); |
| 305 | combo.playTogether(anim1, anim2, anim3); |
| 306 | combo.setDuration(150); |
| 307 | combo.start(); |
| 308 | } |
Michael Kolb | de46376 | 2011-07-14 15:25:45 -0700 | [diff] [blame] | 309 | } |
| 310 | |
George Mount | 387d45d | 2011-10-07 15:57:53 -0700 | [diff] [blame] | 311 | private void showHideStar(Tab tab) { |
| 312 | // hide the bookmark star for data URLs |
| 313 | if (tab != null && tab.inForeground()) { |
| 314 | int starVisibility = View.VISIBLE; |
| 315 | String url = tab.getUrl(); |
| 316 | if (DataUri.isDataUri(url)) { |
| 317 | starVisibility = View.GONE; |
| 318 | } |
| 319 | mStar.setVisibility(starVisibility); |
| 320 | } |
| 321 | } |
| 322 | |
Michael Kolb | 0b12912 | 2012-06-04 16:31:58 -0700 | [diff] [blame] | 323 | @Override |
| 324 | public void onStateChanged(int state) { |
Michael Kolb | e721cc3 | 2012-06-26 15:26:59 -0700 | [diff] [blame^] | 325 | mVoiceButton.setVisibility(View.GONE); |
Michael Kolb | 0b12912 | 2012-06-04 16:31:58 -0700 | [diff] [blame] | 326 | switch(state) { |
| 327 | case STATE_NORMAL: |
| 328 | mClearButton.setVisibility(View.GONE); |
Michael Kolb | 0b12912 | 2012-06-04 16:31:58 -0700 | [diff] [blame] | 329 | break; |
| 330 | case STATE_HIGHLIGHTED: |
| 331 | mClearButton.setVisibility(View.GONE); |
Michael Kolb | e721cc3 | 2012-06-26 15:26:59 -0700 | [diff] [blame^] | 332 | if ((mUiController != null) && mUiController.supportsVoice()) { |
| 333 | mVoiceButton.setVisibility(View.VISIBLE); |
| 334 | } |
Michael Kolb | 0b12912 | 2012-06-04 16:31:58 -0700 | [diff] [blame] | 335 | break; |
| 336 | case STATE_EDITED: |
| 337 | mClearButton.setVisibility(View.VISIBLE); |
Michael Kolb | 0b12912 | 2012-06-04 16:31:58 -0700 | [diff] [blame] | 338 | break; |
| 339 | } |
| 340 | } |
| 341 | |
Leon Scroggins | 571b376 | 2010-05-26 10:25:01 -0400 | [diff] [blame] | 342 | } |