Leon Scroggins | 81db366 | 2009-06-04 17:45:11 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2009 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 | */ |
| 16 | |
| 17 | package com.android.browser; |
| 18 | |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 19 | import android.app.Activity; |
Leon Scroggins | 11e71b1 | 2010-01-25 10:40:38 -0500 | [diff] [blame] | 20 | import android.content.Intent; |
| 21 | import android.content.pm.PackageManager; |
| 22 | import android.content.pm.ResolveInfo; |
Leon Scroggins | 3bbb6ca | 2009-09-09 12:51:10 -0400 | [diff] [blame] | 23 | import android.content.res.Resources; |
Leon Scroggins | 62e8f94 | 2009-09-03 15:08:54 -0400 | [diff] [blame] | 24 | import android.graphics.drawable.Animatable; |
Leon Scroggins | 81db366 | 2009-06-04 17:45:11 -0400 | [diff] [blame] | 25 | import android.graphics.drawable.Drawable; |
Leon Scroggins | 11e71b1 | 2010-01-25 10:40:38 -0500 | [diff] [blame] | 26 | import android.speech.RecognizerIntent; |
Leon Scroggins | f48d44e | 2010-02-05 16:41:49 -0500 | [diff] [blame] | 27 | import android.text.SpannableString; |
| 28 | import android.text.Spanned; |
Leon Scroggins | 76e1686 | 2010-02-08 14:39:34 -0500 | [diff] [blame] | 29 | import android.text.TextUtils; |
Leon Scroggins | f48d44e | 2010-02-05 16:41:49 -0500 | [diff] [blame] | 30 | import android.text.style.ImageSpan; |
Leon Scroggins | 9535cee | 2010-03-15 20:37:16 -0400 | [diff] [blame] | 31 | import android.util.DisplayMetrics; |
Leon Scroggins | 3bbb6ca | 2009-09-09 12:51:10 -0400 | [diff] [blame] | 32 | import android.util.TypedValue; |
Leon Scroggins | c6fa110 | 2009-09-21 10:40:01 -0400 | [diff] [blame] | 33 | import android.view.ContextMenu; |
Leon Scroggins | e4b3bda | 2009-06-09 15:46:41 -0400 | [diff] [blame] | 34 | import android.view.LayoutInflater; |
Leon Scroggins | c6fa110 | 2009-09-21 10:40:01 -0400 | [diff] [blame] | 35 | import android.view.MenuInflater; |
Leon Scroggins | e4b3bda | 2009-06-09 15:46:41 -0400 | [diff] [blame] | 36 | import android.view.View; |
John Reck | bb2a345 | 2011-02-15 11:31:56 -0800 | [diff] [blame] | 37 | import android.view.View.OnClickListener; |
John Reck | 9202673 | 2011-02-15 10:12:30 -0800 | [diff] [blame] | 38 | import android.view.View.OnFocusChangeListener; |
| 39 | import android.widget.ImageButton; |
Leon Scroggins | 81db366 | 2009-06-04 17:45:11 -0400 | [diff] [blame] | 40 | import android.widget.ImageView; |
Leon Scroggins | 81db366 | 2009-06-04 17:45:11 -0400 | [diff] [blame] | 41 | import android.widget.ProgressBar; |
Leon Scroggins | 81db366 | 2009-06-04 17:45:11 -0400 | [diff] [blame] | 42 | |
Leon Scroggins | 1f005d3 | 2009-08-10 17:36:42 -0400 | [diff] [blame] | 43 | /** |
| 44 | * This class represents a title bar for a particular "tab" or "window" in the |
| 45 | * browser. |
| 46 | */ |
John Reck | bb2a345 | 2011-02-15 11:31:56 -0800 | [diff] [blame] | 47 | public class TitleBar extends TitleBarBase implements OnFocusChangeListener, |
| 48 | OnClickListener { |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 49 | |
| 50 | private Activity mActivity; |
John Reck | bb2a345 | 2011-02-15 11:31:56 -0800 | [diff] [blame] | 51 | private ImageButton mBookmarkButton; |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 52 | private Drawable mCircularProgress; |
| 53 | private ProgressBar mHorizontalProgress; |
John Reck | bb2a345 | 2011-02-15 11:31:56 -0800 | [diff] [blame] | 54 | private ImageButton mStopButton; |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 55 | private Drawable mBookmarkDrawable; |
| 56 | private Drawable mVoiceDrawable; |
| 57 | private boolean mInLoad; |
| 58 | private View mTitleBg; |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 59 | private Intent mVoiceSearchIntent; |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 60 | private Drawable mVoiceModeBackground; |
| 61 | private Drawable mNormalBackground; |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 62 | private ImageSpan mArcsSpan; |
| 63 | private int mLeftMargin; |
| 64 | private int mRightMargin; |
Leon Scroggins | c6fa110 | 2009-09-21 10:40:01 -0400 | [diff] [blame] | 65 | |
John Reck | 9202673 | 2011-02-15 10:12:30 -0800 | [diff] [blame] | 66 | public TitleBar(Activity activity, UiController controller, PhoneUi ui) { |
| 67 | super(activity, controller, ui); |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 68 | LayoutInflater factory = LayoutInflater.from(activity); |
Leon Scroggins | 81db366 | 2009-06-04 17:45:11 -0400 | [diff] [blame] | 69 | factory.inflate(R.layout.title_bar, this); |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 70 | mActivity = activity; |
Leon Scroggins | 81db366 | 2009-06-04 17:45:11 -0400 | [diff] [blame] | 71 | |
John Reck | 9202673 | 2011-02-15 10:12:30 -0800 | [diff] [blame] | 72 | mUrlInput = (UrlInputView) findViewById(R.id.url_input); |
| 73 | mUrlInput.setCompoundDrawablePadding(5); |
| 74 | mUrlInput.setContainer(this); |
| 75 | mUrlInput.setSelectAllOnFocus(true); |
| 76 | mUrlInput.setController(mUiController); |
| 77 | mUrlInput.setUrlInputListener(this); |
| 78 | mUrlInput.setOnFocusChangeListener(this); |
Leon Scroggins | 81db366 | 2009-06-04 17:45:11 -0400 | [diff] [blame] | 79 | |
Leon Scroggins | 6857939 | 2009-09-15 15:31:54 -0400 | [diff] [blame] | 80 | mTitleBg = findViewById(R.id.title_bg); |
Leon Scroggins | 62e8f94 | 2009-09-03 15:08:54 -0400 | [diff] [blame] | 81 | mLockIcon = (ImageView) findViewById(R.id.lock); |
Leon Scroggins | f4bb18a | 2009-09-11 18:37:53 -0400 | [diff] [blame] | 82 | mFavicon = (ImageView) findViewById(R.id.favicon); |
John Reck | bb2a345 | 2011-02-15 11:31:56 -0800 | [diff] [blame] | 83 | mStopButton = (ImageButton) findViewById(R.id.stop); |
| 84 | mBookmarkButton = (ImageButton) findViewById(R.id.bookmark); |
| 85 | mStopButton.setOnClickListener(this); |
| 86 | mBookmarkButton.setOnClickListener(this); |
Leon Scroggins | 62e8f94 | 2009-09-03 15:08:54 -0400 | [diff] [blame] | 87 | |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 88 | Resources resources = activity.getResources(); |
| 89 | mCircularProgress = resources.getDrawable( |
Leon Scroggins | 62e8f94 | 2009-09-03 15:08:54 -0400 | [diff] [blame] | 90 | com.android.internal.R.drawable.search_spinner); |
Leon Scroggins | 9535cee | 2010-03-15 20:37:16 -0400 | [diff] [blame] | 91 | DisplayMetrics metrics = resources.getDisplayMetrics(); |
Leon Scroggins | cd663ea | 2010-03-31 14:50:47 -0400 | [diff] [blame] | 92 | mLeftMargin = (int) TypedValue.applyDimension( |
| 93 | TypedValue.COMPLEX_UNIT_DIP, 8f, metrics); |
| 94 | mRightMargin = (int) TypedValue.applyDimension( |
| 95 | TypedValue.COMPLEX_UNIT_DIP, 6f, metrics); |
Leon Scroggins | 571b376 | 2010-05-26 10:25:01 -0400 | [diff] [blame] | 96 | int iconDimension = (int) TypedValue.applyDimension( |
Leon Scroggins | 9535cee | 2010-03-15 20:37:16 -0400 | [diff] [blame] | 97 | TypedValue.COMPLEX_UNIT_DIP, 20f, metrics); |
Leon Scroggins | 571b376 | 2010-05-26 10:25:01 -0400 | [diff] [blame] | 98 | mCircularProgress.setBounds(0, 0, iconDimension, iconDimension); |
Leon Scroggins | 81db366 | 2009-06-04 17:45:11 -0400 | [diff] [blame] | 99 | mHorizontalProgress = (ProgressBar) findViewById( |
| 100 | R.id.progress_horizontal); |
Leon Scroggins | 11e71b1 | 2010-01-25 10:40:38 -0500 | [diff] [blame] | 101 | mVoiceSearchIntent = new Intent(RecognizerIntent.ACTION_WEB_SEARCH); |
| 102 | mVoiceSearchIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, |
| 103 | RecognizerIntent.LANGUAGE_MODEL_WEB_SEARCH); |
Mike LeBeau | 9f677bc | 2010-04-01 14:57:10 -0700 | [diff] [blame] | 104 | // This extra tells voice search not to send the application id in its |
| 105 | // results intent - http://b/2546173 |
| 106 | // |
| 107 | // TODO: Make a constant for this extra. |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 108 | mVoiceSearchIntent.putExtra("android.speech.extras.SEND_APPLICATION_ID_EXTRA", |
| 109 | false); |
| 110 | PackageManager pm = activity.getPackageManager(); |
Leon Scroggins | 11e71b1 | 2010-01-25 10:40:38 -0500 | [diff] [blame] | 111 | ResolveInfo ri = pm.resolveActivity(mVoiceSearchIntent, |
| 112 | PackageManager.MATCH_DEFAULT_ONLY); |
| 113 | if (ri == null) { |
| 114 | mVoiceSearchIntent = null; |
| 115 | } else { |
| 116 | mVoiceDrawable = resources.getDrawable( |
| 117 | android.R.drawable.ic_btn_speak_now); |
| 118 | } |
John Reck | bb2a345 | 2011-02-15 11:31:56 -0800 | [diff] [blame] | 119 | mBookmarkDrawable = mBookmarkButton.getDrawable(); |
Leon Scroggins | 58d56c6 | 2010-01-28 15:12:40 -0500 | [diff] [blame] | 120 | mVoiceModeBackground = resources.getDrawable( |
Leon Scroggins | f48d44e | 2010-02-05 16:41:49 -0500 | [diff] [blame] | 121 | R.drawable.title_voice); |
Leon Scroggins | 58d56c6 | 2010-01-28 15:12:40 -0500 | [diff] [blame] | 122 | mNormalBackground = mTitleBg.getBackground(); |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 123 | mArcsSpan = new ImageSpan(activity, R.drawable.arcs, |
Leon Scroggins | f48d44e | 2010-02-05 16:41:49 -0500 | [diff] [blame] | 124 | ImageSpan.ALIGN_BASELINE); |
Leon Scroggins | e4b3bda | 2009-06-09 15:46:41 -0400 | [diff] [blame] | 125 | } |
| 126 | |
Leon Scroggins | c6fa110 | 2009-09-21 10:40:01 -0400 | [diff] [blame] | 127 | @Override |
Leon Scroggins | 4e9f89b | 2010-02-22 16:54:14 -0500 | [diff] [blame] | 128 | public void createContextMenu(ContextMenu menu) { |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 129 | MenuInflater inflater = mActivity.getMenuInflater(); |
Leon Scroggins | c6fa110 | 2009-09-21 10:40:01 -0400 | [diff] [blame] | 130 | inflater.inflate(R.menu.title_context, menu); |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 131 | mActivity.onCreateContextMenu(menu, this, null); |
Leon Scroggins | c6fa110 | 2009-09-21 10:40:01 -0400 | [diff] [blame] | 132 | } |
| 133 | |
Leon Scroggins | 1f005d3 | 2009-08-10 17:36:42 -0400 | [diff] [blame] | 134 | /** |
Leon Scroggins | 11e71b1 | 2010-01-25 10:40:38 -0500 | [diff] [blame] | 135 | * Change the TitleBar to or from voice mode. If there is no package to |
| 136 | * handle voice search, the TitleBar cannot be set to voice mode. |
| 137 | */ |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 138 | @Override |
| 139 | void setInVoiceMode(boolean inVoiceMode) { |
Leon Scroggins | 11e71b1 | 2010-01-25 10:40:38 -0500 | [diff] [blame] | 140 | if (mInVoiceMode == inVoiceMode) return; |
| 141 | mInVoiceMode = inVoiceMode && mVoiceSearchIntent != null; |
Leon Scroggins | b3b04f7 | 2010-03-03 17:17:18 -0500 | [diff] [blame] | 142 | Drawable titleDrawable; |
Leon Scroggins | 11e71b1 | 2010-01-25 10:40:38 -0500 | [diff] [blame] | 143 | if (mInVoiceMode) { |
John Reck | bb2a345 | 2011-02-15 11:31:56 -0800 | [diff] [blame] | 144 | mBookmarkButton.setImageDrawable(mVoiceDrawable); |
Leon Scroggins | 58d56c6 | 2010-01-28 15:12:40 -0500 | [diff] [blame] | 145 | titleDrawable = mVoiceModeBackground; |
John Reck | 9202673 | 2011-02-15 10:12:30 -0800 | [diff] [blame] | 146 | mUrlInput.setEllipsize(null); |
John Reck | bb2a345 | 2011-02-15 11:31:56 -0800 | [diff] [blame] | 147 | mBookmarkButton.setVisibility(View.VISIBLE); |
Leon Scroggins | b3b04f7 | 2010-03-03 17:17:18 -0500 | [diff] [blame] | 148 | mStopButton.setVisibility(View.GONE); |
Leon Scroggins III | 1644ff6 | 2010-04-08 10:34:14 -0400 | [diff] [blame] | 149 | mTitleBg.setBackgroundDrawable(titleDrawable); |
Leon Scroggins | 7fb1a35 | 2010-04-15 10:55:02 -0400 | [diff] [blame] | 150 | mTitleBg.setPadding(mLeftMargin, mTitleBg.getPaddingTop(), |
| 151 | mRightMargin, mTitleBg.getPaddingBottom()); |
Leon Scroggins | 11e71b1 | 2010-01-25 10:40:38 -0500 | [diff] [blame] | 152 | } else { |
Leon Scroggins | 58d56c6 | 2010-01-28 15:12:40 -0500 | [diff] [blame] | 153 | if (mInLoad) { |
John Reck | bb2a345 | 2011-02-15 11:31:56 -0800 | [diff] [blame] | 154 | mBookmarkButton.setVisibility(View.GONE); |
Leon Scroggins | b3b04f7 | 2010-03-03 17:17:18 -0500 | [diff] [blame] | 155 | mStopButton.setVisibility(View.VISIBLE); |
Leon Scroggins | 58d56c6 | 2010-01-28 15:12:40 -0500 | [diff] [blame] | 156 | } else { |
John Reck | bb2a345 | 2011-02-15 11:31:56 -0800 | [diff] [blame] | 157 | mBookmarkButton.setVisibility(View.VISIBLE); |
Leon Scroggins | b3b04f7 | 2010-03-03 17:17:18 -0500 | [diff] [blame] | 158 | mStopButton.setVisibility(View.GONE); |
John Reck | bb2a345 | 2011-02-15 11:31:56 -0800 | [diff] [blame] | 159 | mBookmarkButton.setImageDrawable(mBookmarkDrawable); |
Leon Scroggins | 58d56c6 | 2010-01-28 15:12:40 -0500 | [diff] [blame] | 160 | } |
John Reck | 9202673 | 2011-02-15 10:12:30 -0800 | [diff] [blame] | 161 | mUrlInput.setEllipsize(TextUtils.TruncateAt.END); |
Leon Scroggins III | 1644ff6 | 2010-04-08 10:34:14 -0400 | [diff] [blame] | 162 | mTitleBg.setPadding(mLeftMargin, 0, mRightMargin, 0); |
Leon Scroggins | 11e71b1 | 2010-01-25 10:40:38 -0500 | [diff] [blame] | 163 | } |
John Reck | 9202673 | 2011-02-15 10:12:30 -0800 | [diff] [blame] | 164 | mUrlInput.setSingleLine(!mInVoiceMode); |
Leon Scroggins | 11e71b1 | 2010-01-25 10:40:38 -0500 | [diff] [blame] | 165 | } |
| 166 | |
| 167 | /** |
Leon Scroggins | 1f005d3 | 2009-08-10 17:36:42 -0400 | [diff] [blame] | 168 | * Update the progress, from 0 to 100. |
| 169 | */ |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 170 | @Override |
| 171 | void setProgress(int newProgress) { |
Nicolas Roard | 1382b49 | 2009-09-16 21:50:06 +0100 | [diff] [blame] | 172 | if (newProgress >= mHorizontalProgress.getMax()) { |
John Reck | 9202673 | 2011-02-15 10:12:30 -0800 | [diff] [blame] | 173 | mUrlInput.setCompoundDrawables(null, null, null, null); |
Leon Scroggins | 62e8f94 | 2009-09-03 15:08:54 -0400 | [diff] [blame] | 174 | ((Animatable) mCircularProgress).stop(); |
| 175 | mHorizontalProgress.setVisibility(View.INVISIBLE); |
Leon Scroggins | 11e71b1 | 2010-01-25 10:40:38 -0500 | [diff] [blame] | 176 | if (!mInVoiceMode) { |
John Reck | bb2a345 | 2011-02-15 11:31:56 -0800 | [diff] [blame] | 177 | mBookmarkButton.setImageDrawable(mBookmarkDrawable); |
| 178 | mBookmarkButton.setVisibility(View.VISIBLE); |
Leon Scroggins | b3b04f7 | 2010-03-03 17:17:18 -0500 | [diff] [blame] | 179 | mStopButton.setVisibility(View.GONE); |
| 180 | mTitleBg.setBackgroundDrawable(mNormalBackground); |
Leon Scroggins | cd663ea | 2010-03-31 14:50:47 -0400 | [diff] [blame] | 181 | mTitleBg.setPadding(mLeftMargin, 0, mRightMargin, 0); |
Leon Scroggins | 1f005d3 | 2009-08-10 17:36:42 -0400 | [diff] [blame] | 182 | } |
Leon Scroggins | 81db366 | 2009-06-04 17:45:11 -0400 | [diff] [blame] | 183 | mInLoad = false; |
| 184 | } else { |
Leon Scroggins | 81db366 | 2009-06-04 17:45:11 -0400 | [diff] [blame] | 185 | mHorizontalProgress.setProgress(newProgress); |
Nicolas Roard | 1382b49 | 2009-09-16 21:50:06 +0100 | [diff] [blame] | 186 | if (!mInLoad && getWindowToken() != null) { |
| 187 | // checking the window token lets us be sure that we |
| 188 | // are attached to a window before starting the animation, |
| 189 | // preventing a potential race condition |
| 190 | // (fix for bug http://b/2115736) |
John Reck | 9202673 | 2011-02-15 10:12:30 -0800 | [diff] [blame] | 191 | mUrlInput.setCompoundDrawables(null, null, mCircularProgress, |
Leon Scroggins | 62e8f94 | 2009-09-03 15:08:54 -0400 | [diff] [blame] | 192 | null); |
| 193 | ((Animatable) mCircularProgress).start(); |
| 194 | mHorizontalProgress.setVisibility(View.VISIBLE); |
Leon Scroggins | 11e71b1 | 2010-01-25 10:40:38 -0500 | [diff] [blame] | 195 | if (!mInVoiceMode) { |
Leon Scroggins | cd663ea | 2010-03-31 14:50:47 -0400 | [diff] [blame] | 196 | mTitleBg.setPadding(mLeftMargin, 0, mRightMargin, 0); |
John Reck | bb2a345 | 2011-02-15 11:31:56 -0800 | [diff] [blame] | 197 | mBookmarkButton.setVisibility(View.GONE); |
Leon Scroggins | b3b04f7 | 2010-03-03 17:17:18 -0500 | [diff] [blame] | 198 | mStopButton.setVisibility(View.VISIBLE); |
Leon Scroggins | 62e8f94 | 2009-09-03 15:08:54 -0400 | [diff] [blame] | 199 | } |
| 200 | mInLoad = true; |
Leon Scroggins | e4b3bda | 2009-06-09 15:46:41 -0400 | [diff] [blame] | 201 | } |
Leon Scroggins | 81db366 | 2009-06-04 17:45:11 -0400 | [diff] [blame] | 202 | } |
| 203 | } |
| 204 | |
Leon Scroggins | 1f005d3 | 2009-08-10 17:36:42 -0400 | [diff] [blame] | 205 | /** |
Leon Scroggins | 58d56c6 | 2010-01-28 15:12:40 -0500 | [diff] [blame] | 206 | * Update the text displayed in the title bar. |
John Reck | ef07426 | 2010-12-02 16:09:14 -0800 | [diff] [blame] | 207 | * @param title String to display. If null, the new tab string will be |
Leon Scroggins | 58d56c6 | 2010-01-28 15:12:40 -0500 | [diff] [blame] | 208 | * shown. |
Leon Scroggins | 1f005d3 | 2009-08-10 17:36:42 -0400 | [diff] [blame] | 209 | */ |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 210 | @Override |
| 211 | void setDisplayTitle(String title) { |
Leon Scroggins | 58d56c6 | 2010-01-28 15:12:40 -0500 | [diff] [blame] | 212 | if (title == null) { |
John Reck | 9202673 | 2011-02-15 10:12:30 -0800 | [diff] [blame] | 213 | mUrlInput.setText(R.string.new_tab); |
Leon Scroggins | d7c3dd5 | 2009-07-20 13:38:47 -0400 | [diff] [blame] | 214 | } else { |
Leon Scroggins | f48d44e | 2010-02-05 16:41:49 -0500 | [diff] [blame] | 215 | if (mInVoiceMode) { |
| 216 | // Add two spaces. The second one will be replaced with an |
| 217 | // image, and the first one will put space between it and the |
| 218 | // text |
| 219 | SpannableString spannable = new SpannableString(title + " "); |
| 220 | int end = spannable.length(); |
| 221 | spannable.setSpan(mArcsSpan, end - 1, end, |
| 222 | Spanned.SPAN_MARK_POINT); |
John Reck | 9202673 | 2011-02-15 10:12:30 -0800 | [diff] [blame] | 223 | mUrlInput.setText(spannable); |
Leon Scroggins | f48d44e | 2010-02-05 16:41:49 -0500 | [diff] [blame] | 224 | } else { |
John Reck | 9202673 | 2011-02-15 10:12:30 -0800 | [diff] [blame] | 225 | mUrlInput.setText(title); |
Leon Scroggins | f48d44e | 2010-02-05 16:41:49 -0500 | [diff] [blame] | 226 | } |
Leon Scroggins | d7c3dd5 | 2009-07-20 13:38:47 -0400 | [diff] [blame] | 227 | } |
Leon Scroggins | 81db366 | 2009-06-04 17:45:11 -0400 | [diff] [blame] | 228 | } |
John Reck | 9202673 | 2011-02-15 10:12:30 -0800 | [diff] [blame] | 229 | |
| 230 | @Override |
| 231 | public void onFocusChange(View v, boolean hasFocus) { |
| 232 | if (v == mUrlInput && hasFocus) { |
| 233 | mActivity.closeOptionsMenu(); |
| 234 | } |
| 235 | } |
John Reck | bb2a345 | 2011-02-15 11:31:56 -0800 | [diff] [blame] | 236 | |
| 237 | @Override |
| 238 | public void onClick(View v) { |
| 239 | if (v == mStopButton) { |
| 240 | mUiController.stopLoading(); |
| 241 | } else if (v == mBookmarkButton) { |
| 242 | mUiController.bookmarkCurrentPage(AddBookmarkPage.DEFAULT_FOLDER_ID, |
| 243 | true); |
| 244 | } |
| 245 | } |
Leon Scroggins | 81db366 | 2009-06-04 17:45:11 -0400 | [diff] [blame] | 246 | } |