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