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