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 | cfa3af5 | 2010-12-14 10:36:11 -0800 | [diff] [blame] | 34 | import java.util.List; |
| 35 | |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 36 | public class NavigationBarTablet extends NavigationBarBase { |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 37 | |
Michael Kolb | a2b2ba8 | 2010-08-04 17:54:03 -0700 | [diff] [blame] | 38 | private Drawable mStopDrawable; |
| 39 | private Drawable mReloadDrawable; |
Michael Kolb | 30adae6 | 2011-07-29 13:37:05 -0700 | [diff] [blame] | 40 | private String mStopDescription; |
| 41 | private String mRefreshDescription; |
Michael Kolb | c7485ae | 2010-09-03 10:10:58 -0700 | [diff] [blame] | 42 | |
Michael Kolb | 11d1978 | 2011-03-20 10:17:40 -0700 | [diff] [blame] | 43 | private View mUrlContainer; |
Michael Kolb | 5a72f18 | 2011-01-13 20:35:06 -0800 | [diff] [blame] | 44 | private ImageButton mBackButton; |
| 45 | private ImageButton mForwardButton; |
Michael Kolb | 31d469b | 2010-12-09 20:49:54 -0800 | [diff] [blame] | 46 | private ImageView mStar; |
Michael Kolb | e3524d8 | 2011-03-02 14:53:15 -0800 | [diff] [blame] | 47 | private ImageView mUrlIcon; |
| 48 | private ImageView mSearchButton; |
Michael Kolb | 513286f | 2010-09-09 12:55:12 -0700 | [diff] [blame] | 49 | private View mGoButton; |
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 | e3524d8 | 2011-03-02 14:53:15 -0800 | [diff] [blame] | 53 | private ImageView mVoiceSearch; |
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 | 513286f | 2010-09-09 12:55:12 -0700 | [diff] [blame] | 101 | mGoButton = findViewById(R.id.go); |
Michael Kolb | b7b115e | 2010-09-25 16:59:37 -0700 | [diff] [blame] | 102 | mClearButton = findViewById(R.id.clear); |
Michael Kolb | e3524d8 | 2011-03-02 14:53:15 -0800 | [diff] [blame] | 103 | mVoiceSearch = (ImageView) findViewById(R.id.voicesearch); |
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 | 513286f | 2010-09-09 12:55:12 -0700 | [diff] [blame] | 111 | mGoButton.setOnClickListener(this); |
Michael Kolb | b7b115e | 2010-09-25 16:59:37 -0700 | [diff] [blame] | 112 | mClearButton.setOnClickListener(this); |
Michael Kolb | cfa3af5 | 2010-12-14 10:36:11 -0800 | [diff] [blame] | 113 | mVoiceSearch.setOnClickListener(this); |
Michael Kolb | 31d469b | 2010-12-09 20:49:54 -0800 | [diff] [blame] | 114 | mUrlInput.setContainer(mUrlContainer); |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 115 | } |
| 116 | |
Michael Kolb | de46376 | 2011-07-14 15:25:45 -0700 | [diff] [blame] | 117 | public void onConfigurationChanged(Configuration config) { |
| 118 | super.onConfigurationChanged(config); |
| 119 | Resources res = mContext.getResources(); |
| 120 | mHideNavButtons = res.getBoolean(R.bool.hide_nav_buttons); |
| 121 | if (mUrlInput.hasFocus()) { |
| 122 | if (mHideNavButtons && (mNavButtons.getVisibility() == View.VISIBLE)) { |
| 123 | int aw = mNavButtons.getMeasuredWidth(); |
| 124 | mNavButtons.setVisibility(View.GONE); |
| 125 | mNavButtons.setAlpha(0f); |
| 126 | mNavButtons.setTranslationX(-aw); |
| 127 | } else if (!mHideNavButtons && (mNavButtons.getVisibility() == View.GONE)) { |
| 128 | mNavButtons.setVisibility(View.VISIBLE); |
| 129 | mNavButtons.setAlpha(1f); |
| 130 | mNavButtons.setTranslationX(0); |
| 131 | } |
| 132 | } |
| 133 | } |
| 134 | |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 135 | @Override |
| 136 | public void setTitleBar(TitleBar titleBar) { |
| 137 | super.setTitleBar(titleBar); |
Michael Kolb | dc2ee1b | 2011-02-14 14:34:40 -0800 | [diff] [blame] | 138 | setFocusState(false); |
Michael Kolb | 31d469b | 2010-12-09 20:49:54 -0800 | [diff] [blame] | 139 | } |
| 140 | |
Michael Kolb | 5a72f18 | 2011-01-13 20:35:06 -0800 | [diff] [blame] | 141 | void updateNavigationState(Tab tab) { |
John Reck | ef654f1 | 2011-07-12 16:42:08 -0700 | [diff] [blame] | 142 | if (tab != null) { |
| 143 | mBackButton.setImageResource(tab.canGoBack() |
Michael Kolb | 5a72f18 | 2011-01-13 20:35:06 -0800 | [diff] [blame] | 144 | ? R.drawable.ic_back_holo_dark |
| 145 | : R.drawable.ic_back_disabled_holo_dark); |
John Reck | ef654f1 | 2011-07-12 16:42:08 -0700 | [diff] [blame] | 146 | mForwardButton.setImageResource(tab.canGoForward() |
Michael Kolb | 5a72f18 | 2011-01-13 20:35:06 -0800 | [diff] [blame] | 147 | ? R.drawable.ic_forward_holo_dark |
| 148 | : R.drawable.ic_forward_disabled_holo_dark); |
| 149 | } |
John Reck | b8b2af8 | 2011-05-20 15:58:33 -0700 | [diff] [blame] | 150 | updateUrlIcon(); |
Michael Kolb | 5a72f18 | 2011-01-13 20:35:06 -0800 | [diff] [blame] | 151 | } |
| 152 | |
Michael Kolb | 31d469b | 2010-12-09 20:49:54 -0800 | [diff] [blame] | 153 | @Override |
Leon Scroggins | 4cd9779 | 2010-12-03 15:31:56 -0500 | [diff] [blame] | 154 | public void setCurrentUrlIsBookmark(boolean isBookmark) { |
Michael Kolb | 31d469b | 2010-12-09 20:49:54 -0800 | [diff] [blame] | 155 | mStar.setActivated(isBookmark); |
Leon Scroggins | 4cd9779 | 2010-12-03 15:31:56 -0500 | [diff] [blame] | 156 | } |
| 157 | |
Michael Kolb | a2b2ba8 | 2010-08-04 17:54:03 -0700 | [diff] [blame] | 158 | @Override |
| 159 | public void onClick(View v) { |
Michael Kolb | 7cdc490 | 2011-02-03 17:54:40 -0800 | [diff] [blame] | 160 | if (mBackButton == v) { |
John Reck | ef654f1 | 2011-07-12 16:42:08 -0700 | [diff] [blame] | 161 | mUiController.getCurrentTab().goBack(); |
Michael Kolb | a2b2ba8 | 2010-08-04 17:54:03 -0700 | [diff] [blame] | 162 | } else if (mForwardButton == v) { |
John Reck | ef654f1 | 2011-07-12 16:42:08 -0700 | [diff] [blame] | 163 | mUiController.getCurrentTab().goForward(); |
Michael Kolb | a2b2ba8 | 2010-08-04 17:54:03 -0700 | [diff] [blame] | 164 | } else if (mStar == v) { |
John Reck | a60fffa | 2011-09-06 16:30:29 -0700 | [diff] [blame] | 165 | Intent intent = mUiController.createBookmarkCurrentPageIntent(true); |
| 166 | if (intent != null) { |
| 167 | getContext().startActivity(intent); |
| 168 | } |
Michael Kolb | a2b2ba8 | 2010-08-04 17:54:03 -0700 | [diff] [blame] | 169 | } else if (mAllButton == v) { |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 170 | mUiController.bookmarksOrHistoryPicker(false); |
Michael Kolb | a2b2ba8 | 2010-08-04 17:54:03 -0700 | [diff] [blame] | 171 | } else if (mSearchButton == v) { |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 172 | mBaseUi.editUrl(true); |
Michael Kolb | a2b2ba8 | 2010-08-04 17:54:03 -0700 | [diff] [blame] | 173 | } else if (mStopButton == v) { |
| 174 | stopOrRefresh(); |
Michael Kolb | 513286f | 2010-09-09 12:55:12 -0700 | [diff] [blame] | 175 | } else if (mGoButton == v) { |
Michael Kolb | 31d469b | 2010-12-09 20:49:54 -0800 | [diff] [blame] | 176 | if (!TextUtils.isEmpty(mUrlInput.getText())) { |
| 177 | onAction(mUrlInput.getText().toString(), null, |
Michael Kolb | 257cc2c | 2010-12-09 09:45:52 -0800 | [diff] [blame] | 178 | UrlInputView.TYPED); |
Michael Kolb | 1ce7813 | 2010-09-23 15:50:53 -0700 | [diff] [blame] | 179 | } |
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 | cfa3af5 | 2010-12-14 10:36:11 -0800 | [diff] [blame] | 182 | } else if (mVoiceSearch == v) { |
| 183 | mUiController.startVoiceSearch(); |
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 | 5119edd | 2011-02-23 15:49:17 +0000 | [diff] [blame] | 190 | if (TextUtils.isEmpty(mUrlInput.getUserText())) { |
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 { |
| 209 | if (mInVoiceMode) { |
| 210 | mUrlIcon.setImageResource(R.drawable.ic_search_holo_dark); |
| 211 | } else { |
| 212 | if (mFaviconDrawable == null) { |
| 213 | mFaviconDrawable = mBaseUi.getFaviconDrawable(null); |
| 214 | } |
| 215 | mUrlIcon.setImageDrawable(mFaviconDrawable); |
| 216 | } |
| 217 | } |
John Reck | b8b2af8 | 2011-05-20 15:58:33 -0700 | [diff] [blame] | 218 | } |
| 219 | |
Michael Kolb | 11d1978 | 2011-03-20 10:17:40 -0700 | [diff] [blame] | 220 | @Override |
| 221 | protected void setFocusState(boolean focus) { |
| 222 | super.setFocusState(focus); |
Michael Kolb | dc2ee1b | 2011-02-14 14:34:40 -0800 | [diff] [blame] | 223 | if (focus) { |
Michael Kolb | de46376 | 2011-07-14 15:25:45 -0700 | [diff] [blame] | 224 | if (mHideNavButtons) { |
| 225 | hideNavButtons(); |
| 226 | } |
Michael Kolb | b7b115e | 2010-09-25 16:59:37 -0700 | [diff] [blame] | 227 | mSearchButton.setVisibility(View.GONE); |
Michael Kolb | 31d469b | 2010-12-09 20:49:54 -0800 | [diff] [blame] | 228 | mStar.setVisibility(View.GONE); |
| 229 | mClearButton.setVisibility(View.VISIBLE); |
Michael Kolb | e3524d8 | 2011-03-02 14:53:15 -0800 | [diff] [blame] | 230 | mUrlIcon.setImageResource(R.drawable.ic_search_holo_dark); |
Michael Kolb | 60a68f5 | 2011-02-24 11:02:52 -0800 | [diff] [blame] | 231 | updateSearchMode(false); |
Michael Kolb | b7b115e | 2010-09-25 16:59:37 -0700 | [diff] [blame] | 232 | } else { |
Michael Kolb | de46376 | 2011-07-14 15:25:45 -0700 | [diff] [blame] | 233 | if (mHideNavButtons) { |
| 234 | showNavButtons(); |
| 235 | } |
Michael Kolb | b7b115e | 2010-09-25 16:59:37 -0700 | [diff] [blame] | 236 | mGoButton.setVisibility(View.GONE); |
Michael Kolb | 31d469b | 2010-12-09 20:49:54 -0800 | [diff] [blame] | 237 | mVoiceSearch.setVisibility(View.GONE); |
| 238 | mStar.setVisibility(View.VISIBLE); |
| 239 | mClearButton.setVisibility(View.GONE); |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 240 | if (mTitleBar.useQuickControls()) { |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 241 | mSearchButton.setVisibility(View.GONE); |
| 242 | } else { |
| 243 | mSearchButton.setVisibility(View.VISIBLE); |
| 244 | } |
John Reck | b8b2af8 | 2011-05-20 15:58:33 -0700 | [diff] [blame] | 245 | updateUrlIcon(); |
Michael Kolb | b7b115e | 2010-09-25 16:59:37 -0700 | [diff] [blame] | 246 | } |
John Reck | 7e5b8b5 | 2011-06-22 13:46:25 -0700 | [diff] [blame] | 247 | mUrlContainer.setBackgroundDrawable(focus |
| 248 | ? mFocusDrawable : mUnfocusDrawable); |
Michael Kolb | b7b115e | 2010-09-25 16:59:37 -0700 | [diff] [blame] | 249 | } |
| 250 | |
Michael Kolb | a2b2ba8 | 2010-08-04 17:54:03 -0700 | [diff] [blame] | 251 | private void stopOrRefresh() { |
Michael Kolb | 1392b83 | 2011-09-07 13:02:59 -0700 | [diff] [blame] | 252 | if (mUiController == null) return; |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 253 | if (mTitleBar.isInLoad()) { |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 254 | mUiController.stopLoading(); |
Michael Kolb | a2b2ba8 | 2010-08-04 17:54:03 -0700 | [diff] [blame] | 255 | } else { |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 256 | mUiController.getCurrentTopWebView().reload(); |
Michael Kolb | a2b2ba8 | 2010-08-04 17:54:03 -0700 | [diff] [blame] | 257 | } |
Leon Scroggins | 571b376 | 2010-05-26 10:25:01 -0400 | [diff] [blame] | 258 | } |
| 259 | |
Michael Kolb | fe25199 | 2010-07-08 15:41:55 -0700 | [diff] [blame] | 260 | @Override |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 261 | public void onProgressStarted() { |
Michael Kolb | 46f987e | 2011-04-05 10:39:10 -0700 | [diff] [blame] | 262 | mStopButton.setImageDrawable(mStopDrawable); |
Michael Kolb | 30adae6 | 2011-07-29 13:37:05 -0700 | [diff] [blame] | 263 | mStopButton.setContentDescription(mStopDescription); |
Michael Kolb | 46f987e | 2011-04-05 10:39:10 -0700 | [diff] [blame] | 264 | } |
| 265 | |
| 266 | @Override |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 267 | public void onProgressStopped() { |
Michael Kolb | 46f987e | 2011-04-05 10:39:10 -0700 | [diff] [blame] | 268 | mStopButton.setImageDrawable(mReloadDrawable); |
Michael Kolb | 30adae6 | 2011-07-29 13:37:05 -0700 | [diff] [blame] | 269 | mStopButton.setContentDescription(mRefreshDescription); |
Michael Kolb | fe25199 | 2010-07-08 15:41:55 -0700 | [diff] [blame] | 270 | } |
| 271 | |
Michael Kolb | 11d1978 | 2011-03-20 10:17:40 -0700 | [diff] [blame] | 272 | protected void updateSearchMode(boolean userEdited) { |
Narayan Kamath | 5119edd | 2011-02-23 15:49:17 +0000 | [diff] [blame] | 273 | setSearchMode(!userEdited || TextUtils.isEmpty(mUrlInput.getUserText())); |
Michael Kolb | 31d469b | 2010-12-09 20:49:54 -0800 | [diff] [blame] | 274 | } |
| 275 | |
Michael Kolb | 11d1978 | 2011-03-20 10:17:40 -0700 | [diff] [blame] | 276 | @Override |
| 277 | protected void setSearchMode(boolean voiceSearchEnabled) { |
Michael Kolb | 793e05e | 2011-01-11 15:17:31 -0800 | [diff] [blame] | 278 | boolean showvoicebutton = voiceSearchEnabled && |
Michael Kolb | 736990c | 2011-03-20 10:01:20 -0700 | [diff] [blame] | 279 | mUiController.supportsVoiceSearch(); |
Michael Kolb | 793e05e | 2011-01-11 15:17:31 -0800 | [diff] [blame] | 280 | mVoiceSearch.setVisibility(showvoicebutton ? View.VISIBLE : |
Michael Kolb | 31d469b | 2010-12-09 20:49:54 -0800 | [diff] [blame] | 281 | View.GONE); |
| 282 | mGoButton.setVisibility(voiceSearchEnabled ? View.GONE : |
| 283 | View.VISIBLE); |
| 284 | } |
| 285 | |
Michael Kolb | fe25199 | 2010-07-08 15:41:55 -0700 | [diff] [blame] | 286 | @Override |
Michael Kolb | cfa3af5 | 2010-12-14 10:36:11 -0800 | [diff] [blame] | 287 | public void setInVoiceMode(boolean voicemode, List<String> voiceResults) { |
Michael Kolb | 11d1978 | 2011-03-20 10:17:40 -0700 | [diff] [blame] | 288 | super.setInVoiceMode(voicemode, voiceResults); |
Michael Kolb | 3aaef25 | 2011-03-09 18:13:56 -0800 | [diff] [blame] | 289 | if (voicemode) { |
| 290 | mUrlIcon.setImageDrawable(mSearchButton.getDrawable()); |
| 291 | } |
Michael Kolb | cfa3af5 | 2010-12-14 10:36:11 -0800 | [diff] [blame] | 292 | } |
| 293 | |
Michael Kolb | de46376 | 2011-07-14 15:25:45 -0700 | [diff] [blame] | 294 | private void hideNavButtons() { |
| 295 | int awidth = mNavButtons.getMeasuredWidth(); |
| 296 | Animator anim1 = ObjectAnimator.ofFloat(mNavButtons, View.TRANSLATION_X, 0, - awidth); |
| 297 | Animator anim2 = ObjectAnimator.ofInt(mUrlContainer, "left", mUrlContainer.getLeft(), |
| 298 | mUrlContainer.getPaddingLeft()); |
| 299 | Animator anim3 = ObjectAnimator.ofFloat(mNavButtons, View.ALPHA, 1f, 0f); |
| 300 | AnimatorSet combo = new AnimatorSet(); |
| 301 | combo.playTogether(anim1, anim2, anim3); |
| 302 | combo.addListener(new AnimatorListenerAdapter() { |
| 303 | @Override |
| 304 | public void onAnimationEnd(Animator animation) { |
| 305 | mNavButtons.setVisibility(View.GONE); |
| 306 | } |
| 307 | }); |
| 308 | combo.setDuration(150); |
| 309 | combo.start(); |
| 310 | } |
| 311 | |
| 312 | private void showNavButtons() { |
| 313 | int awidth = mNavButtons.getMeasuredWidth(); |
| 314 | Animator anim1 = ObjectAnimator.ofFloat(mNavButtons, View.TRANSLATION_X, -awidth, 0); |
| 315 | Animator anim2 = ObjectAnimator.ofInt(mUrlContainer, "left", 0, awidth); |
| 316 | Animator anim3 = ObjectAnimator.ofFloat(mNavButtons, View.ALPHA, 0f, 1f); |
| 317 | AnimatorSet combo = new AnimatorSet(); |
| 318 | combo.playTogether(anim1, anim2, anim3); |
| 319 | mNavButtons.setVisibility(View.VISIBLE); |
| 320 | combo.setDuration(150); |
| 321 | combo.start(); |
| 322 | } |
| 323 | |
Leon Scroggins | 571b376 | 2010-05-26 10:25:01 -0400 | [diff] [blame] | 324 | } |