Michael Kolb | 11d1978 | 2011-03-20 10:17:40 -0700 | [diff] [blame] | 1 | /* |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 2 | * Copyright (C) 2011 The Android Open Source Project |
Michael Kolb | 11d1978 | 2011-03-20 10:17:40 -0700 | [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; |
Michael Kolb | 11d1978 | 2011-03-20 10:17:40 -0700 | [diff] [blame] | 17 | |
Michael Kolb | 11d1978 | 2011-03-20 10:17:40 -0700 | [diff] [blame] | 18 | import android.content.Context; |
Michael Kolb | 2814a36 | 2011-05-19 15:49:41 -0700 | [diff] [blame] | 19 | import android.content.res.Resources; |
Pankaj Garg | 32e1b94 | 2015-06-03 18:13:24 -0700 | [diff] [blame^] | 20 | import android.graphics.Bitmap; |
Michael Kolb | 2814a36 | 2011-05-19 15:49:41 -0700 | [diff] [blame] | 21 | import android.graphics.drawable.Drawable; |
Pankaj Garg | 32e1b94 | 2015-06-03 18:13:24 -0700 | [diff] [blame^] | 22 | import android.os.Bundle; |
Kulanthaivel Palanichamy | f36e1db | 2015-04-08 16:11:06 -0700 | [diff] [blame] | 23 | import android.os.Handler; |
| 24 | import android.os.Message; |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 25 | import android.util.AttributeSet; |
Enrico Ros | 1f5a095 | 2014-11-18 20:15:48 -0800 | [diff] [blame] | 26 | import android.util.TypedValue; |
Michael Kolb | 11d1978 | 2011-03-20 10:17:40 -0700 | [diff] [blame] | 27 | import android.view.View; |
Kulanthaivel Palanichamy | f36e1db | 2015-04-08 16:11:06 -0700 | [diff] [blame] | 28 | |
Pankaj Garg | 32e1b94 | 2015-06-03 18:13:24 -0700 | [diff] [blame^] | 29 | import org.codeaurora.swe.Engine; |
Kulanthaivel Palanichamy | f36e1db | 2015-04-08 16:11:06 -0700 | [diff] [blame] | 30 | import org.codeaurora.swe.WebRefiner; |
Bijan Amirzada | 9b1e988 | 2014-02-26 17:15:46 -0800 | [diff] [blame] | 31 | import org.codeaurora.swe.WebView; |
Enrico Ros | 1f5a095 | 2014-11-18 20:15:48 -0800 | [diff] [blame] | 32 | import org.codeaurora.swe.util.Activator; |
| 33 | import org.codeaurora.swe.util.Observable; |
Michael Kolb | 11d1978 | 2011-03-20 10:17:40 -0700 | [diff] [blame] | 34 | |
Enrico Ros | 1f5a095 | 2014-11-18 20:15:48 -0800 | [diff] [blame] | 35 | import android.widget.ImageView; |
| 36 | import android.widget.TextView; |
Bijan Amirzada | 41242f2 | 2014-03-21 12:12:18 -0700 | [diff] [blame] | 37 | import com.android.browser.UrlInputView.StateListener; |
Pankaj Garg | 32e1b94 | 2015-06-03 18:13:24 -0700 | [diff] [blame^] | 38 | import com.android.browser.preferences.AboutPreferencesFragment; |
| 39 | import com.android.browser.preferences.SiteSpecificPreferencesFragment; |
| 40 | |
| 41 | import java.io.ByteArrayOutputStream; |
Michael Kolb | 305b1c5 | 2011-06-21 16:16:22 -0700 | [diff] [blame] | 42 | |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 43 | public class NavigationBarPhone extends NavigationBarBase implements |
Enrico Ros | 1f5a095 | 2014-11-18 20:15:48 -0800 | [diff] [blame] | 44 | StateListener { |
Michael Kolb | 11d1978 | 2011-03-20 10:17:40 -0700 | [diff] [blame] | 45 | |
Michael Kolb | c16c595 | 2011-03-29 15:37:03 -0700 | [diff] [blame] | 46 | private ImageView mStopButton; |
Michael Kolb | 94ec527 | 2011-08-31 16:23:57 -0700 | [diff] [blame] | 47 | private ImageView mMagnify; |
| 48 | private ImageView mClearButton; |
Michael Kolb | 0b12912 | 2012-06-04 16:31:58 -0700 | [diff] [blame] | 49 | private ImageView mVoiceButton; |
Michael Kolb | 2814a36 | 2011-05-19 15:49:41 -0700 | [diff] [blame] | 50 | private Drawable mStopDrawable; |
| 51 | private Drawable mRefreshDrawable; |
Michael Kolb | 30adae6 | 2011-07-29 13:37:05 -0700 | [diff] [blame] | 52 | private String mStopDescription; |
| 53 | private String mRefreshDescription; |
John Reck | 8ac4290 | 2011-06-29 16:14:34 -0700 | [diff] [blame] | 54 | private View mTabSwitcher; |
Enrico Ros | 1f5a095 | 2014-11-18 20:15:48 -0800 | [diff] [blame] | 55 | private TextView mTabText; |
Michael Kolb | 305b1c5 | 2011-06-21 16:16:22 -0700 | [diff] [blame] | 56 | private View mComboIcon; |
John Reck | 419f6b4 | 2011-08-16 16:10:51 -0700 | [diff] [blame] | 57 | private View mIncognitoIcon; |
Enrico Ros | 1f5a095 | 2014-11-18 20:15:48 -0800 | [diff] [blame] | 58 | private float mTabSwitcherInitialTextSize = 0; |
| 59 | private float mTabSwitcherCompressedTextSize = 0; |
| 60 | |
Kulanthaivel Palanichamy | f36e1db | 2015-04-08 16:11:06 -0700 | [diff] [blame] | 61 | private static final int MSG_UPDATE_NOTIFICATION_COUNTER = 4242; |
| 62 | private static final int NOTIFICATION_COUNTER_UPDATE_DELAY = 3000; |
| 63 | private TextView mNotificationCounter; |
| 64 | private Handler mHandler; |
Michael Kolb | 11d1978 | 2011-03-20 10:17:40 -0700 | [diff] [blame] | 65 | |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 66 | public NavigationBarPhone(Context context) { |
| 67 | super(context); |
| 68 | } |
| 69 | |
| 70 | public NavigationBarPhone(Context context, AttributeSet attrs) { |
| 71 | super(context, attrs); |
| 72 | } |
| 73 | |
| 74 | public NavigationBarPhone(Context context, AttributeSet attrs, int defStyle) { |
| 75 | super(context, attrs, defStyle); |
Michael Kolb | 11d1978 | 2011-03-20 10:17:40 -0700 | [diff] [blame] | 76 | } |
| 77 | |
| 78 | @Override |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 79 | protected void onFinishInflate() { |
| 80 | super.onFinishInflate(); |
Michael Kolb | c16c595 | 2011-03-29 15:37:03 -0700 | [diff] [blame] | 81 | mStopButton = (ImageView) findViewById(R.id.stop); |
Michael Kolb | 11d1978 | 2011-03-20 10:17:40 -0700 | [diff] [blame] | 82 | mStopButton.setOnClickListener(this); |
Michael Kolb | 94ec527 | 2011-08-31 16:23:57 -0700 | [diff] [blame] | 83 | mClearButton = (ImageView) findViewById(R.id.clear); |
| 84 | mClearButton.setOnClickListener(this); |
Michael Kolb | 0b12912 | 2012-06-04 16:31:58 -0700 | [diff] [blame] | 85 | mVoiceButton = (ImageView) findViewById(R.id.voice); |
| 86 | mVoiceButton.setOnClickListener(this); |
Michael Kolb | 94ec527 | 2011-08-31 16:23:57 -0700 | [diff] [blame] | 87 | mMagnify = (ImageView) findViewById(R.id.magnify); |
John Reck | 8ac4290 | 2011-06-29 16:14:34 -0700 | [diff] [blame] | 88 | mTabSwitcher = findViewById(R.id.tab_switcher); |
| 89 | mTabSwitcher.setOnClickListener(this); |
Enrico Ros | 1f5a095 | 2014-11-18 20:15:48 -0800 | [diff] [blame] | 90 | mTabText = (TextView) findViewById(R.id.tab_switcher_text); |
Michael Kolb | 305b1c5 | 2011-06-21 16:16:22 -0700 | [diff] [blame] | 91 | mComboIcon = findViewById(R.id.iconcombo); |
Michael Kolb | 315d502 | 2011-10-13 12:47:11 -0700 | [diff] [blame] | 92 | mComboIcon.setOnClickListener(this); |
Michael Kolb | 11d1978 | 2011-03-20 10:17:40 -0700 | [diff] [blame] | 93 | setFocusState(false); |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 94 | Resources res = getContext().getResources(); |
Enrico Ros | 1f5a095 | 2014-11-18 20:15:48 -0800 | [diff] [blame] | 95 | mStopDrawable = res.getDrawable(R.drawable.ic_action_stop); |
| 96 | mRefreshDrawable = res.getDrawable(R.drawable.ic_action_reload); |
Michael Kolb | 30adae6 | 2011-07-29 13:37:05 -0700 | [diff] [blame] | 97 | mStopDescription = res.getString(R.string.accessibility_button_stop); |
| 98 | mRefreshDescription = res.getString(R.string.accessibility_button_refresh); |
John Reck | 67f3363 | 2011-06-17 16:23:42 -0700 | [diff] [blame] | 99 | mUrlInput.setContainer(this); |
Michael Kolb | 305b1c5 | 2011-06-21 16:16:22 -0700 | [diff] [blame] | 100 | mUrlInput.setStateListener(this); |
John Reck | 419f6b4 | 2011-08-16 16:10:51 -0700 | [diff] [blame] | 101 | mIncognitoIcon = findViewById(R.id.incognito_icon); |
Enrico Ros | 1f5a095 | 2014-11-18 20:15:48 -0800 | [diff] [blame] | 102 | |
| 103 | if (mTabSwitcherInitialTextSize == 0) { |
| 104 | mTabSwitcherInitialTextSize = mTabText.getTextSize(); |
| 105 | mTabSwitcherCompressedTextSize = (float) (mTabSwitcherInitialTextSize / 1.2); |
| 106 | } |
Kulanthaivel Palanichamy | f36e1db | 2015-04-08 16:11:06 -0700 | [diff] [blame] | 107 | |
| 108 | mNotificationCounter = (TextView) findViewById(R.id.notification_counter); |
| 109 | mHandler = new Handler() { |
| 110 | @Override |
| 111 | public void handleMessage(Message m) { |
| 112 | switch (m.what) { |
| 113 | case MSG_UPDATE_NOTIFICATION_COUNTER: |
| 114 | WebView wv = mUiController.getCurrentTopWebView(); |
| 115 | if (wv != null && WebRefiner.isInitialized()) { |
| 116 | int count = WebRefiner.getInstance().getBlockedURLCount(wv); |
| 117 | if (count > 0) { |
| 118 | mNotificationCounter.setText(String.valueOf(count)); |
| 119 | mNotificationCounter.setVisibility(View.VISIBLE); |
| 120 | } |
| 121 | } |
| 122 | mHandler.sendEmptyMessageDelayed(MSG_UPDATE_NOTIFICATION_COUNTER, NOTIFICATION_COUNTER_UPDATE_DELAY); |
| 123 | break; |
| 124 | } |
| 125 | } |
| 126 | }; |
Enrico Ros | 1f5a095 | 2014-11-18 20:15:48 -0800 | [diff] [blame] | 127 | } |
| 128 | |
| 129 | @Override |
| 130 | public void setTitleBar(TitleBar titleBar) { |
| 131 | super.setTitleBar(titleBar); |
| 132 | Activator.activate( |
| 133 | new Observable.Observer() { |
| 134 | @Override |
| 135 | public void onChange(Object... params) { |
| 136 | if ((Integer)params[0] > 9) { |
| 137 | mTabText.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTabSwitcherCompressedTextSize); |
| 138 | } else { |
| 139 | mTabText.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTabSwitcherInitialTextSize); |
| 140 | } |
| 141 | |
| 142 | mTabText.setText(Integer.toString((Integer) params[0])); |
| 143 | } |
| 144 | }, |
| 145 | mUiController.getTabControl().getTabCountObservable()); |
Michael Kolb | 11d1978 | 2011-03-20 10:17:40 -0700 | [diff] [blame] | 146 | } |
| 147 | |
| 148 | @Override |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 149 | public void onProgressStarted() { |
| 150 | super.onProgressStarted(); |
Kulanthaivel Palanichamy | f36e1db | 2015-04-08 16:11:06 -0700 | [diff] [blame] | 151 | /*if (mStopButton.getDrawable() != mStopDrawable) { |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 152 | mStopButton.setImageDrawable(mStopDrawable); |
Michael Kolb | 30adae6 | 2011-07-29 13:37:05 -0700 | [diff] [blame] | 153 | mStopButton.setContentDescription(mStopDescription); |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 154 | if (mStopButton.getVisibility() != View.VISIBLE) { |
| 155 | mComboIcon.setVisibility(View.GONE); |
| 156 | mStopButton.setVisibility(View.VISIBLE); |
Michael Kolb | 305b1c5 | 2011-06-21 16:16:22 -0700 | [diff] [blame] | 157 | } |
Kulanthaivel Palanichamy | f36e1db | 2015-04-08 16:11:06 -0700 | [diff] [blame] | 158 | }*/ |
Pankaj Garg | 32e1b94 | 2015-06-03 18:13:24 -0700 | [diff] [blame^] | 159 | mFaviconBadge.setImageResource(R.drawable.ic_fav_overlay_normal); |
Kulanthaivel Palanichamy | f36e1db | 2015-04-08 16:11:06 -0700 | [diff] [blame] | 160 | mNotificationCounter.setVisibility(View.INVISIBLE); |
| 161 | mHandler.removeMessages(MSG_UPDATE_NOTIFICATION_COUNTER); |
| 162 | mHandler.sendEmptyMessageDelayed(MSG_UPDATE_NOTIFICATION_COUNTER, NOTIFICATION_COUNTER_UPDATE_DELAY); |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 163 | } |
| 164 | |
| 165 | @Override |
| 166 | public void onProgressStopped() { |
| 167 | super.onProgressStopped(); |
Kulanthaivel Palanichamy | f36e1db | 2015-04-08 16:11:06 -0700 | [diff] [blame] | 168 | //mStopButton.setImageDrawable(mRefreshDrawable); |
| 169 | //mStopButton.setContentDescription(mRefreshDescription); |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 170 | if (!isEditingUrl()) { |
| 171 | mComboIcon.setVisibility(View.VISIBLE); |
Michael Kolb | 2814a36 | 2011-05-19 15:49:41 -0700 | [diff] [blame] | 172 | } |
Michael Kolb | 5e8f2b9 | 2011-07-19 13:22:32 -0700 | [diff] [blame] | 173 | onStateChanged(mUrlInput.getState()); |
Michael Kolb | 2814a36 | 2011-05-19 15:49:41 -0700 | [diff] [blame] | 174 | } |
| 175 | |
Michael Kolb | 11d1978 | 2011-03-20 10:17:40 -0700 | [diff] [blame] | 176 | /** |
| 177 | * Update the text displayed in the title bar. |
| 178 | * @param title String to display. If null, the new tab string will be |
| 179 | * shown. |
| 180 | */ |
| 181 | @Override |
| 182 | void setDisplayTitle(String title) { |
John Reck | 434e9f8 | 2011-08-10 18:16:52 -0700 | [diff] [blame] | 183 | mUrlInput.setTag(title); |
John Reck | 67f3363 | 2011-06-17 16:23:42 -0700 | [diff] [blame] | 184 | if (!isEditingUrl()) { |
Vivek Sekhar | 60dca80 | 2014-06-27 14:48:30 -0700 | [diff] [blame] | 185 | // add for carrier requirement - show title from native instead of url |
| 186 | Tab currentTab = mUiController.getTabControl().getCurrentTab(); |
Panos Thomas | 4bdb525 | 2014-11-13 16:20:11 -0800 | [diff] [blame] | 187 | if (BrowserConfig.getInstance(getContext()) |
| 188 | .hasFeature(BrowserConfig.Feature.TITLE_IN_URL_BAR) && |
| 189 | currentTab != null && currentTab.getTitle() != null) { |
Vivek Sekhar | 60dca80 | 2014-06-27 14:48:30 -0700 | [diff] [blame] | 190 | mUrlInput.setText(currentTab.getTitle(), false); |
| 191 | } else if (title == null) { |
John Reck | 67f3363 | 2011-06-17 16:23:42 -0700 | [diff] [blame] | 192 | mUrlInput.setText(R.string.new_tab); |
| 193 | } else { |
Bijan Amirzada | e75909d | 2014-05-06 14:18:54 -0700 | [diff] [blame] | 194 | mUrlInput.setText(UrlUtils.stripUrl(title), false); |
John Reck | 67f3363 | 2011-06-17 16:23:42 -0700 | [diff] [blame] | 195 | } |
| 196 | mUrlInput.setSelection(0); |
Michael Kolb | 11d1978 | 2011-03-20 10:17:40 -0700 | [diff] [blame] | 197 | } |
| 198 | } |
| 199 | |
| 200 | @Override |
Michael Kolb | 11d1978 | 2011-03-20 10:17:40 -0700 | [diff] [blame] | 201 | public void onClick(View v) { |
| 202 | if (v == mStopButton) { |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 203 | if (mTitleBar.isInLoad()) { |
Michael Kolb | 2814a36 | 2011-05-19 15:49:41 -0700 | [diff] [blame] | 204 | mUiController.stopLoading(); |
| 205 | } else { |
| 206 | WebView web = mBaseUi.getWebView(); |
| 207 | if (web != null) { |
Michael Kolb | 305b1c5 | 2011-06-21 16:16:22 -0700 | [diff] [blame] | 208 | stopEditingUrl(); |
Bijan Amirzada | 9b1e988 | 2014-02-26 17:15:46 -0800 | [diff] [blame] | 209 | Tab currentTab = mUiController.getTabControl().getCurrentTab(); |
Michael Kolb | 2814a36 | 2011-05-19 15:49:41 -0700 | [diff] [blame] | 210 | web.reload(); |
| 211 | } |
| 212 | } |
John Reck | 8ac4290 | 2011-06-29 16:14:34 -0700 | [diff] [blame] | 213 | } else if (v == mTabSwitcher) { |
Michael Kolb | 20be26d | 2011-07-18 16:38:02 -0700 | [diff] [blame] | 214 | ((PhoneUi) mBaseUi).toggleNavScreen(); |
Michael Kolb | 94ec527 | 2011-08-31 16:23:57 -0700 | [diff] [blame] | 215 | } else if (mClearButton == v) { |
| 216 | mUrlInput.setText(""); |
Michael Kolb | 315d502 | 2011-10-13 12:47:11 -0700 | [diff] [blame] | 217 | } else if (mComboIcon == v) { |
Pankaj Garg | 32e1b94 | 2015-06-03 18:13:24 -0700 | [diff] [blame^] | 218 | showSiteSpecificSettings(); |
Michael Kolb | 0b12912 | 2012-06-04 16:31:58 -0700 | [diff] [blame] | 219 | } else if (mVoiceButton == v) { |
| 220 | mUiController.startVoiceRecognizer(); |
Michael Kolb | 11d1978 | 2011-03-20 10:17:40 -0700 | [diff] [blame] | 221 | } else { |
| 222 | super.onClick(v); |
| 223 | } |
| 224 | } |
| 225 | |
John Reck | 5889190 | 2011-08-11 17:48:53 -0700 | [diff] [blame] | 226 | @Override |
John Reck | 434e9f8 | 2011-08-10 18:16:52 -0700 | [diff] [blame] | 227 | public void onFocusChange(View view, boolean hasFocus) { |
Panos Thomas | 6ea3a42 | 2014-10-09 23:42:59 -0700 | [diff] [blame] | 228 | if (view == mUrlInput && !hasFocus) { |
| 229 | setDisplayTitle(mUrlInput.getText().toString()); |
John Reck | 434e9f8 | 2011-08-10 18:16:52 -0700 | [diff] [blame] | 230 | } |
| 231 | super.onFocusChange(view, hasFocus); |
| 232 | } |
| 233 | |
| 234 | @Override |
Michael Kolb | 305b1c5 | 2011-06-21 16:16:22 -0700 | [diff] [blame] | 235 | public void onStateChanged(int state) { |
Enrico Ros | 1f5a095 | 2014-11-18 20:15:48 -0800 | [diff] [blame] | 236 | super.onStateChanged(state); |
Michael Kolb | e721cc3 | 2012-06-26 15:26:59 -0700 | [diff] [blame] | 237 | mVoiceButton.setVisibility(View.GONE); |
Michael Kolb | 305b1c5 | 2011-06-21 16:16:22 -0700 | [diff] [blame] | 238 | switch(state) { |
| 239 | case StateListener.STATE_NORMAL: |
| 240 | mComboIcon.setVisibility(View.VISIBLE); |
| 241 | mStopButton.setVisibility(View.GONE); |
Michael Kolb | 94ec527 | 2011-08-31 16:23:57 -0700 | [diff] [blame] | 242 | mClearButton.setVisibility(View.GONE); |
| 243 | mMagnify.setVisibility(View.GONE); |
Michael Kolb | 305b1c5 | 2011-06-21 16:16:22 -0700 | [diff] [blame] | 244 | mTabSwitcher.setVisibility(View.VISIBLE); |
Enrico Ros | 1f5a095 | 2014-11-18 20:15:48 -0800 | [diff] [blame] | 245 | mTabText.setVisibility(View.VISIBLE); |
Pankaj Garg | 7b279f6 | 2014-08-12 14:47:18 -0700 | [diff] [blame] | 246 | if (mUiController != null) { |
Vivek Sekhar | b991edb | 2014-12-17 18:18:07 -0800 | [diff] [blame] | 247 | mUiController.setWindowDimming(0.0f); |
Pankaj Garg | 7b279f6 | 2014-08-12 14:47:18 -0700 | [diff] [blame] | 248 | } |
Michael Kolb | 305b1c5 | 2011-06-21 16:16:22 -0700 | [diff] [blame] | 249 | break; |
| 250 | case StateListener.STATE_HIGHLIGHTED: |
| 251 | mComboIcon.setVisibility(View.GONE); |
| 252 | mStopButton.setVisibility(View.VISIBLE); |
Michael Kolb | 94ec527 | 2011-08-31 16:23:57 -0700 | [diff] [blame] | 253 | mClearButton.setVisibility(View.GONE); |
Michael Kolb | e721cc3 | 2012-06-26 15:26:59 -0700 | [diff] [blame] | 254 | if ((mUiController != null) && mUiController.supportsVoice()) { |
| 255 | mVoiceButton.setVisibility(View.VISIBLE); |
| 256 | } |
Michael Kolb | 94ec527 | 2011-08-31 16:23:57 -0700 | [diff] [blame] | 257 | mMagnify.setVisibility(View.GONE); |
Michael Kolb | 305b1c5 | 2011-06-21 16:16:22 -0700 | [diff] [blame] | 258 | mTabSwitcher.setVisibility(View.GONE); |
Enrico Ros | 1f5a095 | 2014-11-18 20:15:48 -0800 | [diff] [blame] | 259 | mTabText.setVisibility(View.GONE); |
Pankaj Garg | 7b279f6 | 2014-08-12 14:47:18 -0700 | [diff] [blame] | 260 | |
Panos Thomas | 6ea3a42 | 2014-10-09 23:42:59 -0700 | [diff] [blame] | 261 | if (!mUrlInput.getText().toString().equals(mUrlInput.getTag())) { |
| 262 | // only change text if different |
| 263 | mUrlInput.setText((String) mUrlInput.getTag(), false); |
| 264 | mUrlInput.selectAll(); |
| 265 | } |
Pankaj Garg | 7b279f6 | 2014-08-12 14:47:18 -0700 | [diff] [blame] | 266 | |
| 267 | if (mUiController != null) { |
| 268 | mUiController.setWindowDimming(0.75f); |
| 269 | } |
Michael Kolb | 305b1c5 | 2011-06-21 16:16:22 -0700 | [diff] [blame] | 270 | break; |
| 271 | case StateListener.STATE_EDITED: |
| 272 | mComboIcon.setVisibility(View.GONE); |
| 273 | mStopButton.setVisibility(View.GONE); |
Michael Kolb | 94ec527 | 2011-08-31 16:23:57 -0700 | [diff] [blame] | 274 | mClearButton.setVisibility(View.VISIBLE); |
| 275 | mMagnify.setVisibility(View.VISIBLE); |
Michael Kolb | 305b1c5 | 2011-06-21 16:16:22 -0700 | [diff] [blame] | 276 | mTabSwitcher.setVisibility(View.GONE); |
Enrico Ros | 1f5a095 | 2014-11-18 20:15:48 -0800 | [diff] [blame] | 277 | mTabText.setVisibility(View.GONE); |
Michael Kolb | 305b1c5 | 2011-06-21 16:16:22 -0700 | [diff] [blame] | 278 | break; |
Michael Kolb | 2814a36 | 2011-05-19 15:49:41 -0700 | [diff] [blame] | 279 | } |
| 280 | } |
John Reck | 419f6b4 | 2011-08-16 16:10:51 -0700 | [diff] [blame] | 281 | |
| 282 | @Override |
| 283 | public void onTabDataChanged(Tab tab) { |
| 284 | super.onTabDataChanged(tab); |
Enrico Ros | d6efa97 | 2014-12-02 19:49:59 -0800 | [diff] [blame] | 285 | boolean isPrivate = tab.isPrivateBrowsingEnabled(); |
| 286 | mIncognitoIcon.setVisibility(isPrivate ? View.VISIBLE : View.GONE); |
| 287 | // change the background to a darker tone to reflect the 'incognito' state |
| 288 | setBackgroundColor(getResources().getColor(isPrivate ? |
| 289 | R.color.NavigationBarBackgroundIncognito : R.color.NavigationBarBackground)); |
| 290 | |
John Reck | 419f6b4 | 2011-08-16 16:10:51 -0700 | [diff] [blame] | 291 | } |
Michael Kolb | 11d1978 | 2011-03-20 10:17:40 -0700 | [diff] [blame] | 292 | } |