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; |
Michael Kolb | de46376 | 2011-07-14 15:25:45 -0700 | [diff] [blame] | 23 | import android.content.res.Configuration; |
Leon Scroggins | 571b376 | 2010-05-26 10:25:01 -0400 | [diff] [blame] | 24 | import android.content.res.Resources; |
Leon Scroggins | 571b376 | 2010-05-26 10:25:01 -0400 | [diff] [blame] | 25 | import android.graphics.drawable.Drawable; |
Michael Kolb | 1ce7813 | 2010-09-23 15:50:53 -0700 | [diff] [blame] | 26 | import android.text.TextUtils; |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 27 | import android.util.AttributeSet; |
Leon Scroggins | 571b376 | 2010-05-26 10:25:01 -0400 | [diff] [blame] | 28 | import android.view.View; |
Michael Kolb | 5a72f18 | 2011-01-13 20:35:06 -0800 | [diff] [blame] | 29 | import android.widget.ImageButton; |
Leon Scroggins | 571b376 | 2010-05-26 10:25:01 -0400 | [diff] [blame] | 30 | import android.widget.ImageView; |
Leon Scroggins | 571b376 | 2010-05-26 10:25:01 -0400 | [diff] [blame] | 31 | |
Michael Kolb | cfa3af5 | 2010-12-14 10:36:11 -0800 | [diff] [blame] | 32 | import java.util.List; |
| 33 | |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 34 | public class NavigationBarTablet extends NavigationBarBase { |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 35 | |
Michael Kolb | a2b2ba8 | 2010-08-04 17:54:03 -0700 | [diff] [blame] | 36 | private Drawable mStopDrawable; |
| 37 | private Drawable mReloadDrawable; |
Michael Kolb | 30adae6 | 2011-07-29 13:37:05 -0700 | [diff] [blame^] | 38 | private String mStopDescription; |
| 39 | private String mRefreshDescription; |
Michael Kolb | c7485ae | 2010-09-03 10:10:58 -0700 | [diff] [blame] | 40 | |
Michael Kolb | 11d1978 | 2011-03-20 10:17:40 -0700 | [diff] [blame] | 41 | private View mUrlContainer; |
Michael Kolb | 5a72f18 | 2011-01-13 20:35:06 -0800 | [diff] [blame] | 42 | private ImageButton mBackButton; |
| 43 | private ImageButton mForwardButton; |
Michael Kolb | 31d469b | 2010-12-09 20:49:54 -0800 | [diff] [blame] | 44 | private ImageView mStar; |
Michael Kolb | e3524d8 | 2011-03-02 14:53:15 -0800 | [diff] [blame] | 45 | private ImageView mUrlIcon; |
| 46 | private ImageView mSearchButton; |
Michael Kolb | 513286f | 2010-09-09 12:55:12 -0700 | [diff] [blame] | 47 | private View mGoButton; |
Michael Kolb | a2b2ba8 | 2010-08-04 17:54:03 -0700 | [diff] [blame] | 48 | private ImageView mStopButton; |
Michael Kolb | a2b2ba8 | 2010-08-04 17:54:03 -0700 | [diff] [blame] | 49 | private View mAllButton; |
Michael Kolb | b7b115e | 2010-09-25 16:59:37 -0700 | [diff] [blame] | 50 | private View mClearButton; |
Michael Kolb | e3524d8 | 2011-03-02 14:53:15 -0800 | [diff] [blame] | 51 | private ImageView mVoiceSearch; |
Michael Kolb | de46376 | 2011-07-14 15:25:45 -0700 | [diff] [blame] | 52 | private View mNavButtons; |
Michael Kolb | cfa3af5 | 2010-12-14 10:36:11 -0800 | [diff] [blame] | 53 | private Drawable mFocusDrawable; |
| 54 | private Drawable mUnfocusDrawable; |
Michael Kolb | de46376 | 2011-07-14 15:25:45 -0700 | [diff] [blame] | 55 | private boolean mHideNavButtons; |
Michael Kolb | 81b6f83 | 2010-12-12 12:44:27 -0800 | [diff] [blame] | 56 | |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 57 | public NavigationBarTablet(Context context) { |
| 58 | super(context); |
| 59 | init(context); |
| 60 | } |
| 61 | |
| 62 | public NavigationBarTablet(Context context, AttributeSet attrs) { |
| 63 | super(context, attrs); |
| 64 | init(context); |
| 65 | } |
| 66 | |
| 67 | public NavigationBarTablet(Context context, AttributeSet attrs, int defStyle) { |
| 68 | super(context, attrs, defStyle); |
| 69 | init(context); |
| 70 | } |
| 71 | |
| 72 | private void init(Context context) { |
| 73 | Resources resources = context.getResources(); |
Michael Kolb | 5a72f18 | 2011-01-13 20:35:06 -0800 | [diff] [blame] | 74 | mStopDrawable = resources.getDrawable(R.drawable.ic_stop_holo_dark); |
| 75 | mReloadDrawable = resources.getDrawable(R.drawable.ic_refresh_holo_dark); |
Michael Kolb | 30adae6 | 2011-07-29 13:37:05 -0700 | [diff] [blame^] | 76 | mStopDescription = resources.getString(R.string.accessibility_button_stop); |
| 77 | mRefreshDescription = resources.getString(R.string.accessibility_button_refresh); |
Michael Kolb | cfa3af5 | 2010-12-14 10:36:11 -0800 | [diff] [blame] | 78 | mFocusDrawable = resources.getDrawable( |
| 79 | R.drawable.textfield_active_holo_dark); |
| 80 | mUnfocusDrawable = resources.getDrawable( |
| 81 | R.drawable.textfield_default_holo_dark); |
Michael Kolb | de46376 | 2011-07-14 15:25:45 -0700 | [diff] [blame] | 82 | mHideNavButtons = resources.getBoolean(R.bool.hide_nav_buttons); |
Michael Kolb | fe25199 | 2010-07-08 15:41:55 -0700 | [diff] [blame] | 83 | } |
Leon Scroggins | 571b376 | 2010-05-26 10:25:01 -0400 | [diff] [blame] | 84 | |
Michael Kolb | 7cdc490 | 2011-02-03 17:54:40 -0800 | [diff] [blame] | 85 | @Override |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 86 | protected void onFinishInflate() { |
| 87 | super.onFinishInflate(); |
Michael Kolb | fe25199 | 2010-07-08 15:41:55 -0700 | [diff] [blame] | 88 | mAllButton = findViewById(R.id.all_btn); |
| 89 | // TODO: Change enabled states based on whether you can go |
Leon Scroggins | 571b376 | 2010-05-26 10:25:01 -0400 | [diff] [blame] | 90 | // back/forward. Probably should be done inside onPageStarted. |
Michael Kolb | de46376 | 2011-07-14 15:25:45 -0700 | [diff] [blame] | 91 | mNavButtons = findViewById(R.id.navbuttons); |
Michael Kolb | 5a72f18 | 2011-01-13 20:35:06 -0800 | [diff] [blame] | 92 | mBackButton = (ImageButton) findViewById(R.id.back); |
| 93 | mForwardButton = (ImageButton) findViewById(R.id.forward); |
Michael Kolb | e3524d8 | 2011-03-02 14:53:15 -0800 | [diff] [blame] | 94 | mUrlIcon = (ImageView) findViewById(R.id.url_icon); |
Michael Kolb | 31d469b | 2010-12-09 20:49:54 -0800 | [diff] [blame] | 95 | mStar = (ImageView) findViewById(R.id.star); |
Michael Kolb | a2b2ba8 | 2010-08-04 17:54:03 -0700 | [diff] [blame] | 96 | mStopButton = (ImageView) findViewById(R.id.stop); |
Michael Kolb | e3524d8 | 2011-03-02 14:53:15 -0800 | [diff] [blame] | 97 | mSearchButton = (ImageView) findViewById(R.id.search); |
Michael Kolb | 513286f | 2010-09-09 12:55:12 -0700 | [diff] [blame] | 98 | mGoButton = findViewById(R.id.go); |
Michael Kolb | b7b115e | 2010-09-25 16:59:37 -0700 | [diff] [blame] | 99 | mClearButton = findViewById(R.id.clear); |
Michael Kolb | e3524d8 | 2011-03-02 14:53:15 -0800 | [diff] [blame] | 100 | mVoiceSearch = (ImageView) findViewById(R.id.voicesearch); |
Michael Kolb | 31d469b | 2010-12-09 20:49:54 -0800 | [diff] [blame] | 101 | mUrlContainer = findViewById(R.id.urlbar_focused); |
Michael Kolb | a2b2ba8 | 2010-08-04 17:54:03 -0700 | [diff] [blame] | 102 | mBackButton.setOnClickListener(this); |
| 103 | mForwardButton.setOnClickListener(this); |
| 104 | mStar.setOnClickListener(this); |
| 105 | mAllButton.setOnClickListener(this); |
| 106 | mStopButton.setOnClickListener(this); |
| 107 | mSearchButton.setOnClickListener(this); |
Michael Kolb | 513286f | 2010-09-09 12:55:12 -0700 | [diff] [blame] | 108 | mGoButton.setOnClickListener(this); |
Michael Kolb | b7b115e | 2010-09-25 16:59:37 -0700 | [diff] [blame] | 109 | mClearButton.setOnClickListener(this); |
Michael Kolb | cfa3af5 | 2010-12-14 10:36:11 -0800 | [diff] [blame] | 110 | mVoiceSearch.setOnClickListener(this); |
John Reck | 4650033 | 2011-06-07 14:36:10 -0700 | [diff] [blame] | 111 | setUaSwitcher(mUrlIcon); |
Michael Kolb | 31d469b | 2010-12-09 20:49:54 -0800 | [diff] [blame] | 112 | mUrlInput.setContainer(mUrlContainer); |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 113 | } |
| 114 | |
Michael Kolb | de46376 | 2011-07-14 15:25:45 -0700 | [diff] [blame] | 115 | public void onConfigurationChanged(Configuration config) { |
| 116 | super.onConfigurationChanged(config); |
| 117 | Resources res = mContext.getResources(); |
| 118 | mHideNavButtons = res.getBoolean(R.bool.hide_nav_buttons); |
| 119 | if (mUrlInput.hasFocus()) { |
| 120 | if (mHideNavButtons && (mNavButtons.getVisibility() == View.VISIBLE)) { |
| 121 | int aw = mNavButtons.getMeasuredWidth(); |
| 122 | mNavButtons.setVisibility(View.GONE); |
| 123 | mNavButtons.setAlpha(0f); |
| 124 | mNavButtons.setTranslationX(-aw); |
| 125 | } else if (!mHideNavButtons && (mNavButtons.getVisibility() == View.GONE)) { |
| 126 | mNavButtons.setVisibility(View.VISIBLE); |
| 127 | mNavButtons.setAlpha(1f); |
| 128 | mNavButtons.setTranslationX(0); |
| 129 | } |
| 130 | } |
| 131 | } |
| 132 | |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 133 | @Override |
| 134 | public void setTitleBar(TitleBar titleBar) { |
| 135 | super.setTitleBar(titleBar); |
Michael Kolb | dc2ee1b | 2011-02-14 14:34:40 -0800 | [diff] [blame] | 136 | setFocusState(false); |
Michael Kolb | 31d469b | 2010-12-09 20:49:54 -0800 | [diff] [blame] | 137 | } |
| 138 | |
Michael Kolb | 5a72f18 | 2011-01-13 20:35:06 -0800 | [diff] [blame] | 139 | void updateNavigationState(Tab tab) { |
John Reck | ef654f1 | 2011-07-12 16:42:08 -0700 | [diff] [blame] | 140 | if (tab != null) { |
| 141 | mBackButton.setImageResource(tab.canGoBack() |
Michael Kolb | 5a72f18 | 2011-01-13 20:35:06 -0800 | [diff] [blame] | 142 | ? R.drawable.ic_back_holo_dark |
| 143 | : R.drawable.ic_back_disabled_holo_dark); |
John Reck | ef654f1 | 2011-07-12 16:42:08 -0700 | [diff] [blame] | 144 | mForwardButton.setImageResource(tab.canGoForward() |
Michael Kolb | 5a72f18 | 2011-01-13 20:35:06 -0800 | [diff] [blame] | 145 | ? R.drawable.ic_forward_holo_dark |
| 146 | : R.drawable.ic_forward_disabled_holo_dark); |
| 147 | } |
John Reck | b8b2af8 | 2011-05-20 15:58:33 -0700 | [diff] [blame] | 148 | updateUrlIcon(); |
Michael Kolb | 5a72f18 | 2011-01-13 20:35:06 -0800 | [diff] [blame] | 149 | } |
| 150 | |
Michael Kolb | 31d469b | 2010-12-09 20:49:54 -0800 | [diff] [blame] | 151 | @Override |
Leon Scroggins | 4cd9779 | 2010-12-03 15:31:56 -0500 | [diff] [blame] | 152 | public void setCurrentUrlIsBookmark(boolean isBookmark) { |
Michael Kolb | 31d469b | 2010-12-09 20:49:54 -0800 | [diff] [blame] | 153 | mStar.setActivated(isBookmark); |
Leon Scroggins | 4cd9779 | 2010-12-03 15:31:56 -0500 | [diff] [blame] | 154 | } |
| 155 | |
Michael Kolb | a2b2ba8 | 2010-08-04 17:54:03 -0700 | [diff] [blame] | 156 | @Override |
| 157 | public void onClick(View v) { |
Michael Kolb | 7cdc490 | 2011-02-03 17:54:40 -0800 | [diff] [blame] | 158 | if (mBackButton == v) { |
John Reck | ef654f1 | 2011-07-12 16:42:08 -0700 | [diff] [blame] | 159 | mUiController.getCurrentTab().goBack(); |
Michael Kolb | a2b2ba8 | 2010-08-04 17:54:03 -0700 | [diff] [blame] | 160 | } else if (mForwardButton == v) { |
John Reck | ef654f1 | 2011-07-12 16:42:08 -0700 | [diff] [blame] | 161 | mUiController.getCurrentTab().goForward(); |
Michael Kolb | a2b2ba8 | 2010-08-04 17:54:03 -0700 | [diff] [blame] | 162 | } else if (mStar == v) { |
John Reck | d3e4d5b | 2011-07-13 15:48:43 -0700 | [diff] [blame] | 163 | getContext().startActivity(mUiController.createBookmarkCurrentPageIntent(true)); |
Michael Kolb | a2b2ba8 | 2010-08-04 17:54:03 -0700 | [diff] [blame] | 164 | } else if (mAllButton == v) { |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 165 | mUiController.bookmarksOrHistoryPicker(false); |
Michael Kolb | a2b2ba8 | 2010-08-04 17:54:03 -0700 | [diff] [blame] | 166 | } else if (mSearchButton == v) { |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 167 | mBaseUi.editUrl(true); |
Michael Kolb | a2b2ba8 | 2010-08-04 17:54:03 -0700 | [diff] [blame] | 168 | } else if (mStopButton == v) { |
| 169 | stopOrRefresh(); |
Michael Kolb | 513286f | 2010-09-09 12:55:12 -0700 | [diff] [blame] | 170 | } else if (mGoButton == v) { |
Michael Kolb | 31d469b | 2010-12-09 20:49:54 -0800 | [diff] [blame] | 171 | if (!TextUtils.isEmpty(mUrlInput.getText())) { |
| 172 | onAction(mUrlInput.getText().toString(), null, |
Michael Kolb | 257cc2c | 2010-12-09 09:45:52 -0800 | [diff] [blame] | 173 | UrlInputView.TYPED); |
Michael Kolb | 1ce7813 | 2010-09-23 15:50:53 -0700 | [diff] [blame] | 174 | } |
Michael Kolb | b7b115e | 2010-09-25 16:59:37 -0700 | [diff] [blame] | 175 | } else if (mClearButton == v) { |
Michael Kolb | 31d469b | 2010-12-09 20:49:54 -0800 | [diff] [blame] | 176 | clearOrClose(); |
Michael Kolb | cfa3af5 | 2010-12-14 10:36:11 -0800 | [diff] [blame] | 177 | } else if (mVoiceSearch == v) { |
| 178 | mUiController.startVoiceSearch(); |
Michael Kolb | 11d1978 | 2011-03-20 10:17:40 -0700 | [diff] [blame] | 179 | } else { |
| 180 | super.onClick(v); |
Michael Kolb | fe25199 | 2010-07-08 15:41:55 -0700 | [diff] [blame] | 181 | } |
| 182 | } |
| 183 | |
Michael Kolb | 31d469b | 2010-12-09 20:49:54 -0800 | [diff] [blame] | 184 | private void clearOrClose() { |
Narayan Kamath | 5119edd | 2011-02-23 15:49:17 +0000 | [diff] [blame] | 185 | if (TextUtils.isEmpty(mUrlInput.getUserText())) { |
Michael Kolb | 31d469b | 2010-12-09 20:49:54 -0800 | [diff] [blame] | 186 | // close |
Michael Kolb | 7cdc490 | 2011-02-03 17:54:40 -0800 | [diff] [blame] | 187 | mUrlInput.clearFocus(); |
Michael Kolb | 31d469b | 2010-12-09 20:49:54 -0800 | [diff] [blame] | 188 | } else { |
| 189 | // clear |
| 190 | mUrlInput.setText(""); |
| 191 | } |
| 192 | } |
| 193 | |
John Reck | b8b2af8 | 2011-05-20 15:58:33 -0700 | [diff] [blame] | 194 | void updateUrlIcon() { |
John Reck | 4650033 | 2011-06-07 14:36:10 -0700 | [diff] [blame] | 195 | mUrlIcon.setImageResource(mInVoiceMode ? |
| 196 | R.drawable.ic_search_holo_dark |
| 197 | : R.drawable.ic_web_holo_dark); |
John Reck | b8b2af8 | 2011-05-20 15:58:33 -0700 | [diff] [blame] | 198 | } |
| 199 | |
Michael Kolb | 11d1978 | 2011-03-20 10:17:40 -0700 | [diff] [blame] | 200 | @Override |
| 201 | protected void setFocusState(boolean focus) { |
| 202 | super.setFocusState(focus); |
Michael Kolb | dc2ee1b | 2011-02-14 14:34:40 -0800 | [diff] [blame] | 203 | if (focus) { |
Michael Kolb | de46376 | 2011-07-14 15:25:45 -0700 | [diff] [blame] | 204 | if (mHideNavButtons) { |
| 205 | hideNavButtons(); |
| 206 | } |
Michael Kolb | b7b115e | 2010-09-25 16:59:37 -0700 | [diff] [blame] | 207 | mSearchButton.setVisibility(View.GONE); |
Michael Kolb | 31d469b | 2010-12-09 20:49:54 -0800 | [diff] [blame] | 208 | mStar.setVisibility(View.GONE); |
| 209 | mClearButton.setVisibility(View.VISIBLE); |
Michael Kolb | e3524d8 | 2011-03-02 14:53:15 -0800 | [diff] [blame] | 210 | mUrlIcon.setImageResource(R.drawable.ic_search_holo_dark); |
Michael Kolb | 60a68f5 | 2011-02-24 11:02:52 -0800 | [diff] [blame] | 211 | updateSearchMode(false); |
Michael Kolb | b7b115e | 2010-09-25 16:59:37 -0700 | [diff] [blame] | 212 | } else { |
Michael Kolb | de46376 | 2011-07-14 15:25:45 -0700 | [diff] [blame] | 213 | if (mHideNavButtons) { |
| 214 | showNavButtons(); |
| 215 | } |
Michael Kolb | b7b115e | 2010-09-25 16:59:37 -0700 | [diff] [blame] | 216 | mGoButton.setVisibility(View.GONE); |
Michael Kolb | 31d469b | 2010-12-09 20:49:54 -0800 | [diff] [blame] | 217 | mVoiceSearch.setVisibility(View.GONE); |
| 218 | mStar.setVisibility(View.VISIBLE); |
| 219 | mClearButton.setVisibility(View.GONE); |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 220 | if (mTitleBar.useQuickControls()) { |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 221 | mSearchButton.setVisibility(View.GONE); |
| 222 | } else { |
| 223 | mSearchButton.setVisibility(View.VISIBLE); |
| 224 | } |
John Reck | b8b2af8 | 2011-05-20 15:58:33 -0700 | [diff] [blame] | 225 | updateUrlIcon(); |
Michael Kolb | b7b115e | 2010-09-25 16:59:37 -0700 | [diff] [blame] | 226 | } |
John Reck | 7e5b8b5 | 2011-06-22 13:46:25 -0700 | [diff] [blame] | 227 | mUrlContainer.setBackgroundDrawable(focus |
| 228 | ? mFocusDrawable : mUnfocusDrawable); |
Michael Kolb | b7b115e | 2010-09-25 16:59:37 -0700 | [diff] [blame] | 229 | } |
| 230 | |
Michael Kolb | a2b2ba8 | 2010-08-04 17:54:03 -0700 | [diff] [blame] | 231 | private void stopOrRefresh() { |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 232 | if (mTitleBar.isInLoad()) { |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 233 | mUiController.stopLoading(); |
Michael Kolb | a2b2ba8 | 2010-08-04 17:54:03 -0700 | [diff] [blame] | 234 | } else { |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 235 | mUiController.getCurrentTopWebView().reload(); |
Michael Kolb | a2b2ba8 | 2010-08-04 17:54:03 -0700 | [diff] [blame] | 236 | } |
Leon Scroggins | 571b376 | 2010-05-26 10:25:01 -0400 | [diff] [blame] | 237 | } |
| 238 | |
Michael Kolb | fe25199 | 2010-07-08 15:41:55 -0700 | [diff] [blame] | 239 | @Override |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 240 | public void onProgressStarted() { |
Michael Kolb | 46f987e | 2011-04-05 10:39:10 -0700 | [diff] [blame] | 241 | mStopButton.setImageDrawable(mStopDrawable); |
Michael Kolb | 30adae6 | 2011-07-29 13:37:05 -0700 | [diff] [blame^] | 242 | mStopButton.setContentDescription(mStopDescription); |
Michael Kolb | 46f987e | 2011-04-05 10:39:10 -0700 | [diff] [blame] | 243 | } |
| 244 | |
| 245 | @Override |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 246 | public void onProgressStopped() { |
Michael Kolb | 46f987e | 2011-04-05 10:39:10 -0700 | [diff] [blame] | 247 | mStopButton.setImageDrawable(mReloadDrawable); |
Michael Kolb | 30adae6 | 2011-07-29 13:37:05 -0700 | [diff] [blame^] | 248 | mStopButton.setContentDescription(mRefreshDescription); |
Michael Kolb | fe25199 | 2010-07-08 15:41:55 -0700 | [diff] [blame] | 249 | } |
| 250 | |
Michael Kolb | 11d1978 | 2011-03-20 10:17:40 -0700 | [diff] [blame] | 251 | protected void updateSearchMode(boolean userEdited) { |
Narayan Kamath | 5119edd | 2011-02-23 15:49:17 +0000 | [diff] [blame] | 252 | setSearchMode(!userEdited || TextUtils.isEmpty(mUrlInput.getUserText())); |
Michael Kolb | 31d469b | 2010-12-09 20:49:54 -0800 | [diff] [blame] | 253 | } |
| 254 | |
Michael Kolb | 11d1978 | 2011-03-20 10:17:40 -0700 | [diff] [blame] | 255 | @Override |
| 256 | protected void setSearchMode(boolean voiceSearchEnabled) { |
Michael Kolb | 793e05e | 2011-01-11 15:17:31 -0800 | [diff] [blame] | 257 | boolean showvoicebutton = voiceSearchEnabled && |
Michael Kolb | 736990c | 2011-03-20 10:01:20 -0700 | [diff] [blame] | 258 | mUiController.supportsVoiceSearch(); |
Michael Kolb | 793e05e | 2011-01-11 15:17:31 -0800 | [diff] [blame] | 259 | mVoiceSearch.setVisibility(showvoicebutton ? View.VISIBLE : |
Michael Kolb | 31d469b | 2010-12-09 20:49:54 -0800 | [diff] [blame] | 260 | View.GONE); |
| 261 | mGoButton.setVisibility(voiceSearchEnabled ? View.GONE : |
| 262 | View.VISIBLE); |
| 263 | } |
| 264 | |
Michael Kolb | fe25199 | 2010-07-08 15:41:55 -0700 | [diff] [blame] | 265 | @Override |
Michael Kolb | cfa3af5 | 2010-12-14 10:36:11 -0800 | [diff] [blame] | 266 | public void setInVoiceMode(boolean voicemode, List<String> voiceResults) { |
Michael Kolb | 11d1978 | 2011-03-20 10:17:40 -0700 | [diff] [blame] | 267 | super.setInVoiceMode(voicemode, voiceResults); |
Michael Kolb | 3aaef25 | 2011-03-09 18:13:56 -0800 | [diff] [blame] | 268 | if (voicemode) { |
| 269 | mUrlIcon.setImageDrawable(mSearchButton.getDrawable()); |
| 270 | } |
Michael Kolb | cfa3af5 | 2010-12-14 10:36:11 -0800 | [diff] [blame] | 271 | } |
| 272 | |
Michael Kolb | de46376 | 2011-07-14 15:25:45 -0700 | [diff] [blame] | 273 | private void hideNavButtons() { |
| 274 | int awidth = mNavButtons.getMeasuredWidth(); |
| 275 | Animator anim1 = ObjectAnimator.ofFloat(mNavButtons, View.TRANSLATION_X, 0, - awidth); |
| 276 | Animator anim2 = ObjectAnimator.ofInt(mUrlContainer, "left", mUrlContainer.getLeft(), |
| 277 | mUrlContainer.getPaddingLeft()); |
| 278 | Animator anim3 = ObjectAnimator.ofFloat(mNavButtons, View.ALPHA, 1f, 0f); |
| 279 | AnimatorSet combo = new AnimatorSet(); |
| 280 | combo.playTogether(anim1, anim2, anim3); |
| 281 | combo.addListener(new AnimatorListenerAdapter() { |
| 282 | @Override |
| 283 | public void onAnimationEnd(Animator animation) { |
| 284 | mNavButtons.setVisibility(View.GONE); |
| 285 | } |
| 286 | }); |
| 287 | combo.setDuration(150); |
| 288 | combo.start(); |
| 289 | } |
| 290 | |
| 291 | private void showNavButtons() { |
| 292 | int awidth = mNavButtons.getMeasuredWidth(); |
| 293 | Animator anim1 = ObjectAnimator.ofFloat(mNavButtons, View.TRANSLATION_X, -awidth, 0); |
| 294 | Animator anim2 = ObjectAnimator.ofInt(mUrlContainer, "left", 0, awidth); |
| 295 | Animator anim3 = ObjectAnimator.ofFloat(mNavButtons, View.ALPHA, 0f, 1f); |
| 296 | AnimatorSet combo = new AnimatorSet(); |
| 297 | combo.playTogether(anim1, anim2, anim3); |
| 298 | mNavButtons.setVisibility(View.VISIBLE); |
| 299 | combo.setDuration(150); |
| 300 | combo.start(); |
| 301 | } |
| 302 | |
Leon Scroggins | 571b376 | 2010-05-26 10:25:01 -0400 | [diff] [blame] | 303 | } |