John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2011 The Android Open Source Project |
| 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; |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 17 | |
| 18 | import android.app.SearchManager; |
kaiyiz | c4ada32 | 2013-07-30 09:58:07 +0800 | [diff] [blame] | 19 | import android.content.ActivityNotFoundException; |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 20 | import android.content.Context; |
| 21 | import android.content.Intent; |
| 22 | import android.graphics.Bitmap; |
| 23 | import android.graphics.drawable.Drawable; |
kaiyiz | c4ada32 | 2013-07-30 09:58:07 +0800 | [diff] [blame] | 24 | import android.net.Uri; |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 25 | import android.os.Bundle; |
Narayan Kamath | f3174a5 | 2011-11-17 14:43:32 +0000 | [diff] [blame] | 26 | import android.text.Editable; |
| 27 | import android.text.TextWatcher; |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 28 | import android.util.AttributeSet; |
kaiyiz | c4ada32 | 2013-07-30 09:58:07 +0800 | [diff] [blame] | 29 | import android.util.Log; |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 30 | import android.view.KeyEvent; |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 31 | import android.view.View; |
| 32 | import android.view.View.OnClickListener; |
| 33 | import android.view.View.OnFocusChangeListener; |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 34 | import android.widget.ImageView; |
| 35 | import android.widget.LinearLayout; |
kaiyiz | c4ada32 | 2013-07-30 09:58:07 +0800 | [diff] [blame] | 36 | import android.widget.Toast; |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 37 | |
Bijan Amirzada | 41242f2 | 2014-03-21 12:12:18 -0700 | [diff] [blame] | 38 | import com.android.browser.R; |
| 39 | import com.android.browser.UrlInputView.UrlInputListener; |
| 40 | import com.android.browser.reflect.ReflectHelper; |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 41 | |
kaiyiz | c4ada32 | 2013-07-30 09:58:07 +0800 | [diff] [blame] | 42 | import java.io.UnsupportedEncodingException; |
kaiyiz | 950eca2 | 2013-08-08 11:01:28 +0800 | [diff] [blame] | 43 | import java.net.URISyntaxException; |
kaiyiz | c4ada32 | 2013-07-30 09:58:07 +0800 | [diff] [blame] | 44 | |
Bijan Amirzada | 9b1e988 | 2014-02-26 17:15:46 -0800 | [diff] [blame] | 45 | import org.codeaurora.swe.WebView; |
| 46 | |
John Reck | 42229bc | 2011-08-19 13:26:43 -0700 | [diff] [blame] | 47 | public class NavigationBarBase extends LinearLayout implements |
| 48 | OnClickListener, UrlInputListener, OnFocusChangeListener, |
Narayan Kamath | f3174a5 | 2011-11-17 14:43:32 +0000 | [diff] [blame] | 49 | TextWatcher { |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 50 | |
kaiyiz | c4ada32 | 2013-07-30 09:58:07 +0800 | [diff] [blame] | 51 | private final static String TAG = "NavigationBarBase"; |
| 52 | |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 53 | protected BaseUi mBaseUi; |
| 54 | protected TitleBar mTitleBar; |
| 55 | protected UiController mUiController; |
| 56 | protected UrlInputView mUrlInput; |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 57 | |
| 58 | private ImageView mFavicon; |
| 59 | private ImageView mLockIcon; |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 60 | |
| 61 | public NavigationBarBase(Context context) { |
| 62 | super(context); |
| 63 | } |
| 64 | |
| 65 | public NavigationBarBase(Context context, AttributeSet attrs) { |
| 66 | super(context, attrs); |
| 67 | } |
| 68 | |
| 69 | public NavigationBarBase(Context context, AttributeSet attrs, int defStyle) { |
| 70 | super(context, attrs, defStyle); |
| 71 | } |
| 72 | |
| 73 | @Override |
| 74 | protected void onFinishInflate() { |
| 75 | super.onFinishInflate(); |
| 76 | mLockIcon = (ImageView) findViewById(R.id.lock); |
| 77 | mFavicon = (ImageView) findViewById(R.id.favicon); |
| 78 | mUrlInput = (UrlInputView) findViewById(R.id.url); |
| 79 | mUrlInput.setUrlInputListener(this); |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 80 | mUrlInput.setOnFocusChangeListener(this); |
| 81 | mUrlInput.setSelectAllOnFocus(true); |
Narayan Kamath | f3174a5 | 2011-11-17 14:43:32 +0000 | [diff] [blame] | 82 | mUrlInput.addTextChangedListener(this); |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 83 | } |
| 84 | |
| 85 | public void setTitleBar(TitleBar titleBar) { |
| 86 | mTitleBar = titleBar; |
| 87 | mBaseUi = mTitleBar.getUi(); |
| 88 | mUiController = mTitleBar.getUiController(); |
Michael Kolb | b2e91fd | 2011-07-14 13:47:29 -0700 | [diff] [blame] | 89 | mUrlInput.setController(mUiController); |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 90 | } |
| 91 | |
| 92 | public void setLock(Drawable d) { |
| 93 | if (mLockIcon == null) return; |
| 94 | if (d == null) { |
| 95 | mLockIcon.setVisibility(View.GONE); |
| 96 | } else { |
| 97 | mLockIcon.setImageDrawable(d); |
| 98 | mLockIcon.setVisibility(View.VISIBLE); |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | public void setFavicon(Bitmap icon) { |
| 103 | if (mFavicon == null) return; |
| 104 | mFavicon.setImageDrawable(mBaseUi.getFaviconDrawable(icon)); |
| 105 | } |
| 106 | |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 107 | @Override |
| 108 | public void onClick(View v) { |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 109 | } |
| 110 | |
| 111 | @Override |
| 112 | public void onFocusChange(View view, boolean hasFocus) { |
| 113 | // if losing focus and not in touch mode, leave as is |
| 114 | if (hasFocus || view.isInTouchMode() || mUrlInput.needsUpdate()) { |
| 115 | setFocusState(hasFocus); |
| 116 | } |
| 117 | if (hasFocus) { |
| 118 | mBaseUi.showTitleBar(); |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 119 | } else if (!mUrlInput.needsUpdate()) { |
| 120 | mUrlInput.dismissDropDown(); |
| 121 | mUrlInput.hideIME(); |
| 122 | if (mUrlInput.getText().length() == 0) { |
| 123 | Tab currentTab = mUiController.getTabControl().getCurrentTab(); |
| 124 | if (currentTab != null) { |
John Reck | 434e9f8 | 2011-08-10 18:16:52 -0700 | [diff] [blame] | 125 | setDisplayTitle(currentTab.getUrl()); |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 126 | } |
| 127 | } |
| 128 | mBaseUi.suggestHideTitleBar(); |
| 129 | } |
| 130 | mUrlInput.clearNeedsUpdate(); |
| 131 | } |
| 132 | |
| 133 | protected void setFocusState(boolean focus) { |
| 134 | } |
| 135 | |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 136 | public boolean isEditingUrl() { |
| 137 | return mUrlInput.hasFocus(); |
| 138 | } |
| 139 | |
| 140 | void stopEditingUrl() { |
Michael Kolb | 0b12912 | 2012-06-04 16:31:58 -0700 | [diff] [blame] | 141 | WebView currentTopWebView = mUiController.getCurrentTopWebView(); |
| 142 | if (currentTopWebView != null) { |
| 143 | currentTopWebView.requestFocus(); |
| 144 | } |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 145 | } |
| 146 | |
| 147 | void setDisplayTitle(String title) { |
| 148 | if (!isEditingUrl()) { |
Michael Kolb | 29aab40 | 2012-05-29 17:22:35 -0700 | [diff] [blame] | 149 | if (!title.equals(mUrlInput.getText().toString())) { |
| 150 | mUrlInput.setText(title, false); |
| 151 | } |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 152 | } |
| 153 | } |
| 154 | |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 155 | void setIncognitoMode(boolean incognito) { |
| 156 | mUrlInput.setIncognitoMode(incognito); |
| 157 | } |
| 158 | |
| 159 | void clearCompletions() { |
Narayan Kamath | f3174a5 | 2011-11-17 14:43:32 +0000 | [diff] [blame] | 160 | mUrlInput.dismissDropDown(); |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 161 | } |
| 162 | |
| 163 | // UrlInputListener implementation |
| 164 | |
| 165 | /** |
| 166 | * callback from suggestion dropdown |
| 167 | * user selected a suggestion |
| 168 | */ |
| 169 | @Override |
| 170 | public void onAction(String text, String extra, String source) { |
Michael Kolb | 0b12912 | 2012-06-04 16:31:58 -0700 | [diff] [blame] | 171 | stopEditingUrl(); |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 172 | if (UrlInputView.TYPED.equals(source)) { |
kaiyiz | c4ada32 | 2013-07-30 09:58:07 +0800 | [diff] [blame] | 173 | String url = null; |
Bijan Amirzada | 9b1e988 | 2014-02-26 17:15:46 -0800 | [diff] [blame] | 174 | Object[] params = {new String("persist.env.browser.wap2estore"), |
| 175 | Boolean.valueOf(false)}; |
| 176 | Class[] type = new Class[] {String.class, boolean.class}; |
Bijan Amirzada | 58383e7 | 2014-04-01 14:45:22 -0700 | [diff] [blame^] | 177 | Boolean wap2estore = (Boolean) ReflectHelper.invokeMethod( |
Bijan Amirzada | 9b1e988 | 2014-02-26 17:15:46 -0800 | [diff] [blame] | 178 | "android.os.SystemProperties", "getBoolean", type, params); |
Vivek Sekhar | 5e63147 | 2014-03-31 23:59:10 -0700 | [diff] [blame] | 179 | if ((wap2estore && isEstoreTypeUrl(text)) || isRtspTypeUrl(text) |
| 180 | || isMakeCallTypeUrl(text)) { |
kaiyiz | c4ada32 | 2013-07-30 09:58:07 +0800 | [diff] [blame] | 181 | url = text; |
| 182 | } else { |
| 183 | url = UrlUtils.smartUrlFilter(text, false); |
| 184 | } |
| 185 | |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 186 | Tab t = mBaseUi.getActiveTab(); |
| 187 | // Only shortcut javascript URIs for now, as there is special |
| 188 | // logic in UrlHandler for other schemas |
| 189 | if (url != null && t != null && url.startsWith("javascript:")) { |
| 190 | mUiController.loadUrl(t, url); |
| 191 | setDisplayTitle(text); |
| 192 | return; |
| 193 | } |
kaiyiz | c4ada32 | 2013-07-30 09:58:07 +0800 | [diff] [blame] | 194 | |
| 195 | // add for carrier wap2estore feature |
| 196 | if (url != null && t != null && wap2estore && isEstoreTypeUrl(url)) { |
| 197 | handleEstoreTypeUrl(url); |
| 198 | setDisplayTitle(text); |
| 199 | return; |
| 200 | } |
kaiyiz | 950eca2 | 2013-08-08 11:01:28 +0800 | [diff] [blame] | 201 | // add for rtsp scheme feature |
| 202 | if (url != null && t != null && isRtspTypeUrl(url)) { |
| 203 | if (handleRtspTypeUrl(url)) { |
| 204 | return; |
| 205 | } |
| 206 | } |
Vivek Sekhar | 5e63147 | 2014-03-31 23:59:10 -0700 | [diff] [blame] | 207 | // add for "wtai://wp/mc;" scheme feature |
| 208 | if (url != null && t != null && isMakeCallTypeUrl(url)) { |
| 209 | if (handleMakeCallTypeUrl(url)) { |
| 210 | return; |
| 211 | } |
| 212 | } |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 213 | } |
| 214 | Intent i = new Intent(); |
Michael Kolb | 5ff5c8b | 2012-05-03 11:37:58 -0700 | [diff] [blame] | 215 | String action = Intent.ACTION_SEARCH; |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 216 | i.setAction(action); |
| 217 | i.putExtra(SearchManager.QUERY, text); |
| 218 | if (extra != null) { |
| 219 | i.putExtra(SearchManager.EXTRA_DATA_KEY, extra); |
| 220 | } |
| 221 | if (source != null) { |
| 222 | Bundle appData = new Bundle(); |
Bijan Amirzada | 9b1e988 | 2014-02-26 17:15:46 -0800 | [diff] [blame] | 223 | appData.putString("source", source); |
| 224 | i.putExtra("source", appData); |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 225 | } |
| 226 | mUiController.handleNewIntent(i); |
| 227 | setDisplayTitle(text); |
| 228 | } |
| 229 | |
Vivek Sekhar | 5e63147 | 2014-03-31 23:59:10 -0700 | [diff] [blame] | 230 | private boolean isMakeCallTypeUrl(String url) { |
| 231 | String utf8Url = null; |
| 232 | try { |
| 233 | utf8Url = new String(url.getBytes("UTF-8"), "UTF-8"); |
| 234 | } catch (UnsupportedEncodingException e) { |
| 235 | Log.e(TAG, "err " + e); |
| 236 | } |
| 237 | if (utf8Url != null && utf8Url.startsWith(UrlHandler.SCHEME_WTAI_MC)) { |
| 238 | return true; |
| 239 | } |
| 240 | return false; |
| 241 | } |
| 242 | |
| 243 | private boolean handleMakeCallTypeUrl(String url) { |
| 244 | // wtai://wp/mc;number |
| 245 | // number=string(phone-number) |
| 246 | if (url.startsWith(UrlHandler.SCHEME_WTAI_MC)) { |
| 247 | Intent intent = new Intent(Intent.ACTION_VIEW, |
| 248 | Uri.parse(WebView.SCHEME_TEL + |
| 249 | url.substring(UrlHandler.SCHEME_WTAI_MC.length()))); |
| 250 | getContext().startActivity(intent); |
| 251 | // before leaving BrowserActivity, close the empty child tab. |
| 252 | // If a new tab is created through JavaScript open to load this |
| 253 | // url, we would like to close it as we will load this url in a |
| 254 | // different Activity. |
| 255 | Tab current = mUiController.getCurrentTab(); |
| 256 | if (current != null |
| 257 | && current.getWebView().copyBackForwardList().getSize() == 0) { |
| 258 | mUiController.closeCurrentTab(); |
| 259 | } |
| 260 | return true; |
| 261 | } |
| 262 | return false; |
| 263 | } |
| 264 | |
kaiyiz | c4ada32 | 2013-07-30 09:58:07 +0800 | [diff] [blame] | 265 | private boolean isEstoreTypeUrl(String url) { |
| 266 | String utf8Url = null; |
| 267 | try { |
| 268 | utf8Url = new String(url.getBytes("UTF-8"), "UTF-8"); |
| 269 | } catch (UnsupportedEncodingException e) { |
| 270 | Log.e(TAG, "err " + e); |
| 271 | } |
| 272 | if (utf8Url != null && utf8Url.startsWith("estore:")) { |
| 273 | return true; |
| 274 | } |
| 275 | return false; |
| 276 | } |
| 277 | |
| 278 | private void handleEstoreTypeUrl(String url) { |
| 279 | String utf8Url = null, finalUrl = null; |
| 280 | try { |
| 281 | utf8Url = new String(url.getBytes("UTF-8"), "UTF-8"); |
| 282 | } catch (UnsupportedEncodingException e) { |
| 283 | Log.e(TAG, "err " + e); |
| 284 | } |
| 285 | if (utf8Url != null) { |
| 286 | finalUrl = utf8Url; |
| 287 | } else { |
| 288 | finalUrl = url; |
| 289 | } |
| 290 | if (finalUrl.replaceFirst("estore:", "").length() > 256) { |
Bijan Amirzada | 9b1e988 | 2014-02-26 17:15:46 -0800 | [diff] [blame] | 291 | Toast.makeText(getContext(), R.string.estore_url_warning, Toast.LENGTH_LONG).show(); |
kaiyiz | c4ada32 | 2013-07-30 09:58:07 +0800 | [diff] [blame] | 292 | return; |
| 293 | } |
| 294 | Intent intent = new Intent(Intent.ACTION_VIEW); |
| 295 | intent.setData(Uri.parse(finalUrl)); |
| 296 | try { |
Bijan Amirzada | 9b1e988 | 2014-02-26 17:15:46 -0800 | [diff] [blame] | 297 | getContext().startActivity(intent); |
kaiyiz | c4ada32 | 2013-07-30 09:58:07 +0800 | [diff] [blame] | 298 | } catch (ActivityNotFoundException ex) { |
Bijan Amirzada | 9b1e988 | 2014-02-26 17:15:46 -0800 | [diff] [blame] | 299 | String downloadUrl = getContext().getResources().getString(R.string.estore_homepage); |
kaiyiz | c4ada32 | 2013-07-30 09:58:07 +0800 | [diff] [blame] | 300 | mUiController.loadUrl(mBaseUi.getActiveTab(), downloadUrl); |
Bijan Amirzada | 9b1e988 | 2014-02-26 17:15:46 -0800 | [diff] [blame] | 301 | Toast.makeText(getContext(), R.string.download_estore_app, Toast.LENGTH_LONG).show(); |
kaiyiz | c4ada32 | 2013-07-30 09:58:07 +0800 | [diff] [blame] | 302 | } |
| 303 | } |
| 304 | |
kaiyiz | 950eca2 | 2013-08-08 11:01:28 +0800 | [diff] [blame] | 305 | private boolean isRtspTypeUrl(String url) { |
| 306 | String utf8Url = null; |
| 307 | try { |
| 308 | utf8Url = new String(url.getBytes("UTF-8"), "UTF-8"); |
| 309 | } catch (UnsupportedEncodingException e) { |
| 310 | Log.e(TAG, "err " + e); |
| 311 | } |
| 312 | if (utf8Url != null && utf8Url.startsWith("rtsp://")) { |
| 313 | return true; |
| 314 | } |
| 315 | return false; |
| 316 | } |
| 317 | |
| 318 | private boolean handleRtspTypeUrl(String url) { |
| 319 | Intent intent; |
| 320 | // perform generic parsing of the URI to turn it into an Intent. |
| 321 | try { |
| 322 | intent = Intent.parseUri(url, Intent.URI_INTENT_SCHEME); |
| 323 | } catch (URISyntaxException ex) { |
| 324 | Log.w("Browser", "Bad URI " + url + ": " + ex.getMessage()); |
| 325 | return false; |
| 326 | } |
| 327 | |
| 328 | try { |
Bijan Amirzada | 9b1e988 | 2014-02-26 17:15:46 -0800 | [diff] [blame] | 329 | getContext().startActivity(intent); |
kaiyiz | 950eca2 | 2013-08-08 11:01:28 +0800 | [diff] [blame] | 330 | } catch (ActivityNotFoundException ex) { |
| 331 | Log.w("Browser", "No resolveActivity " + url); |
| 332 | return false; |
| 333 | } |
| 334 | return true; |
| 335 | } |
| 336 | |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 337 | @Override |
| 338 | public void onDismiss() { |
| 339 | final Tab currentTab = mBaseUi.getActiveTab(); |
| 340 | mBaseUi.hideTitleBar(); |
| 341 | post(new Runnable() { |
| 342 | public void run() { |
| 343 | clearFocus(); |
Michael Kolb | 5ff5c8b | 2012-05-03 11:37:58 -0700 | [diff] [blame] | 344 | if (currentTab != null) { |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 345 | setDisplayTitle(currentTab.getUrl()); |
| 346 | } |
| 347 | } |
| 348 | }); |
| 349 | } |
| 350 | |
| 351 | /** |
| 352 | * callback from the suggestion dropdown |
| 353 | * copy text to input field and stay in edit mode |
| 354 | */ |
| 355 | @Override |
| 356 | public void onCopySuggestion(String text) { |
| 357 | mUrlInput.setText(text, true); |
| 358 | if (text != null) { |
| 359 | mUrlInput.setSelection(text.length()); |
| 360 | } |
| 361 | } |
| 362 | |
| 363 | public void setCurrentUrlIsBookmark(boolean isBookmark) { |
| 364 | } |
| 365 | |
| 366 | @Override |
| 367 | public boolean dispatchKeyEventPreIme(KeyEvent evt) { |
| 368 | if (evt.getKeyCode() == KeyEvent.KEYCODE_BACK) { |
| 369 | // catch back key in order to do slightly more cleanup than usual |
Michael Kolb | 0b12912 | 2012-06-04 16:31:58 -0700 | [diff] [blame] | 370 | stopEditingUrl(); |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 371 | return true; |
| 372 | } |
| 373 | return super.dispatchKeyEventPreIme(evt); |
| 374 | } |
| 375 | |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 376 | /** |
| 377 | * called from the Ui when the user wants to edit |
| 378 | * @param clearInput clear the input field |
| 379 | */ |
Michael Kolb | 1f9b356 | 2012-04-24 14:38:34 -0700 | [diff] [blame] | 380 | void startEditingUrl(boolean clearInput, boolean forceIME) { |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 381 | // editing takes preference of progress |
| 382 | setVisibility(View.VISIBLE); |
| 383 | if (mTitleBar.useQuickControls()) { |
| 384 | mTitleBar.getProgressView().setVisibility(View.GONE); |
| 385 | } |
| 386 | if (!mUrlInput.hasFocus()) { |
| 387 | mUrlInput.requestFocus(); |
| 388 | } |
| 389 | if (clearInput) { |
| 390 | mUrlInput.setText(""); |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 391 | } |
Michael Kolb | 1f9b356 | 2012-04-24 14:38:34 -0700 | [diff] [blame] | 392 | if (forceIME) { |
Michael Kolb | 4bb6fcb | 2012-04-13 14:25:27 -0700 | [diff] [blame] | 393 | mUrlInput.showIME(); |
| 394 | } |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 395 | } |
| 396 | |
| 397 | public void onProgressStarted() { |
| 398 | } |
| 399 | |
| 400 | public void onProgressStopped() { |
| 401 | } |
| 402 | |
John Reck | 5889190 | 2011-08-11 17:48:53 -0700 | [diff] [blame] | 403 | public boolean isMenuShowing() { |
John Reck | 42229bc | 2011-08-19 13:26:43 -0700 | [diff] [blame] | 404 | return false; |
John Reck | 5889190 | 2011-08-11 17:48:53 -0700 | [diff] [blame] | 405 | } |
| 406 | |
John Reck | 419f6b4 | 2011-08-16 16:10:51 -0700 | [diff] [blame] | 407 | public void onTabDataChanged(Tab tab) { |
| 408 | } |
| 409 | |
Michael Kolb | 0b12912 | 2012-06-04 16:31:58 -0700 | [diff] [blame] | 410 | public void onVoiceResult(String s) { |
| 411 | startEditingUrl(true, true); |
| 412 | onCopySuggestion(s); |
| 413 | } |
| 414 | |
Narayan Kamath | f3174a5 | 2011-11-17 14:43:32 +0000 | [diff] [blame] | 415 | @Override |
| 416 | public void beforeTextChanged(CharSequence s, int start, int count, int after) { } |
| 417 | |
| 418 | @Override |
Michael Kolb | 5ff5c8b | 2012-05-03 11:37:58 -0700 | [diff] [blame] | 419 | public void onTextChanged(CharSequence s, int start, int before, int count) { } |
Narayan Kamath | f3174a5 | 2011-11-17 14:43:32 +0000 | [diff] [blame] | 420 | |
| 421 | @Override |
| 422 | public void afterTextChanged(Editable s) { } |
Michael Kolb | 0b12912 | 2012-06-04 16:31:58 -0700 | [diff] [blame] | 423 | |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 424 | } |