The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2006 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 | |
Bijan Amirzada | 41242f2 | 2014-03-21 12:12:18 -0700 | [diff] [blame] | 17 | package com.android.browser; |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 18 | |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 19 | import android.app.Activity; |
John Reck | 7878f22 | 2012-04-18 16:23:14 -0700 | [diff] [blame] | 20 | import android.app.KeyguardManager; |
John Reck | 9d27ff5 | 2011-02-11 17:47:54 -0800 | [diff] [blame] | 21 | import android.content.Context; |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 22 | import android.content.Intent; |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 23 | import android.content.res.Configuration; |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 24 | import android.os.Bundle; |
qqzhou | 8c5b0a3 | 2013-07-22 15:31:03 +0800 | [diff] [blame] | 25 | import android.os.Handler; |
John Reck | 7878f22 | 2012-04-18 16:23:14 -0700 | [diff] [blame] | 26 | import android.os.PowerManager; |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 27 | import android.util.Log; |
Leon Scroggins III | 8e4fbf1 | 2010-08-17 16:58:15 -0400 | [diff] [blame] | 28 | import android.view.ActionMode; |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 29 | import android.view.ContextMenu; |
Michael Kolb | a2b2ba8 | 2010-08-04 17:54:03 -0700 | [diff] [blame] | 30 | import android.view.ContextMenu.ContextMenuInfo; |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 31 | import android.view.KeyEvent; |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 32 | import android.view.Menu; |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 33 | import android.view.MenuItem; |
Michael Kolb | c3af067 | 2011-08-09 10:24:41 -0700 | [diff] [blame] | 34 | import android.view.MotionEvent; |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 35 | import android.view.View; |
Kulanthaivel Palanichamy | 7794268 | 2014-10-28 11:52:06 -0700 | [diff] [blame] | 36 | import android.view.ViewGroup; |
| 37 | import android.view.ViewTreeObserver; |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 38 | import android.view.Window; |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 39 | |
John Reck | d3e4d5b | 2011-07-13 15:48:43 -0700 | [diff] [blame] | 40 | import com.google.common.annotations.VisibleForTesting; |
Bijan Amirzada | 41242f2 | 2014-03-21 12:12:18 -0700 | [diff] [blame] | 41 | import com.android.browser.R; |
Bijan Amirzada | 41242f2 | 2014-03-21 12:12:18 -0700 | [diff] [blame] | 42 | import com.android.browser.search.DefaultSearchEngine; |
| 43 | import com.android.browser.search.SearchEngine; |
| 44 | import com.android.browser.stub.NullController; |
Bijan Amirzada | 9b1e988 | 2014-02-26 17:15:46 -0800 | [diff] [blame] | 45 | |
Dany Rybnikov | c912c55 | 2015-01-19 15:40:13 +0200 | [diff] [blame^] | 46 | import org.codeaurora.swe.CookieManager; |
Bijan Amirzada | 9b1e988 | 2014-02-26 17:15:46 -0800 | [diff] [blame] | 47 | import org.codeaurora.swe.WebView; |
John Reck | d3e4d5b | 2011-07-13 15:48:43 -0700 | [diff] [blame] | 48 | |
Kulanthaivel Palanichamy | 7794268 | 2014-10-28 11:52:06 -0700 | [diff] [blame] | 49 | public class BrowserActivity extends Activity implements ViewTreeObserver.OnPreDrawListener { |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 50 | |
John Reck | 439c9a5 | 2010-12-14 10:04:39 -0800 | [diff] [blame] | 51 | public static final String ACTION_SHOW_BOOKMARKS = "show_bookmarks"; |
| 52 | public static final String ACTION_SHOW_BROWSER = "show_browser"; |
John Reck | 63bb687 | 2010-12-01 19:29:32 -0800 | [diff] [blame] | 53 | public static final String ACTION_RESTART = "--restart--"; |
| 54 | private static final String EXTRA_STATE = "state"; |
John Reck | 38b3965 | 2012-06-05 09:22:59 -0700 | [diff] [blame] | 55 | public static final String EXTRA_DISABLE_URL_OVERRIDE = "disable_url_override"; |
John Reck | 63bb687 | 2010-12-01 19:29:32 -0800 | [diff] [blame] | 56 | |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 57 | private final static String LOGTAG = "browser"; |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 58 | |
John Reck | 6c2e2f3 | 2011-08-22 13:41:23 -0700 | [diff] [blame] | 59 | private final static boolean LOGV_ENABLED = Browser.LOGV_ENABLED; |
Dave Bort | 31a6d1c | 2009-04-13 15:56:49 -0700 | [diff] [blame] | 60 | |
John Reck | 9c35b9c | 2012-05-30 10:08:50 -0700 | [diff] [blame] | 61 | private ActivityController mController = NullController.INSTANCE; |
Bijan Amirzada | 9b1e988 | 2014-02-26 17:15:46 -0800 | [diff] [blame] | 62 | |
qqzhou | 8c5b0a3 | 2013-07-22 15:31:03 +0800 | [diff] [blame] | 63 | private Handler mHandler = new Handler(); |
Jeff Davidson | 4361029 | 2010-07-16 16:03:58 -0700 | [diff] [blame] | 64 | |
kaiyiz | bb2db87 | 2013-08-01 22:24:07 -0400 | [diff] [blame] | 65 | private UiController mUiController; |
| 66 | private Handler mHandlerEx = new Handler(); |
| 67 | private Runnable runnable = new Runnable() { |
| 68 | @Override |
| 69 | public void run() { |
| 70 | if (mUiController != null) { |
| 71 | WebView current = mUiController.getCurrentWebView(); |
| 72 | if (current != null) { |
| 73 | current.postInvalidate(); |
| 74 | } |
| 75 | } |
| 76 | } |
| 77 | }; |
| 78 | |
Kulanthaivel Palanichamy | 7794268 | 2014-10-28 11:52:06 -0700 | [diff] [blame] | 79 | private Bundle mSavedInstanceState; |
| 80 | private EngineInitializer mEngineInitializer; |
Bijan Amirzada | 9b1e988 | 2014-02-26 17:15:46 -0800 | [diff] [blame] | 81 | |
Grace Kloba | 22ac16e | 2009-10-07 18:00:23 -0700 | [diff] [blame] | 82 | @Override |
| 83 | public void onCreate(Bundle icicle) { |
Dave Bort | 31a6d1c | 2009-04-13 15:56:49 -0700 | [diff] [blame] | 84 | if (LOGV_ENABLED) { |
John Reck | 6c2e2f3 | 2011-08-22 13:41:23 -0700 | [diff] [blame] | 85 | Log.v(LOGTAG, this + " onStart, has state: " |
| 86 | + (icicle == null ? "false" : "true")); |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 87 | } |
| 88 | super.onCreate(icicle); |
Derek Sollenberger | ffa561e | 2010-11-16 14:19:01 -0500 | [diff] [blame] | 89 | |
John Reck | 7878f22 | 2012-04-18 16:23:14 -0700 | [diff] [blame] | 90 | if (shouldIgnoreIntents()) { |
| 91 | finish(); |
| 92 | return; |
| 93 | } |
| 94 | |
John Reck | f57c029 | 2011-07-21 18:15:39 -0700 | [diff] [blame] | 95 | // If this was a web search request, pass it on to the default web |
| 96 | // search provider and finish this activity. |
Bijan Amirzada | 41242f2 | 2014-03-21 12:12:18 -0700 | [diff] [blame] | 97 | /* |
kaiyiz | a2368f1 | 2013-09-02 10:43:31 +0800 | [diff] [blame] | 98 | SearchEngine searchEngine = BrowserSettings.getInstance().getSearchEngine(); |
| 99 | boolean result = IntentHandler.handleWebSearchIntent(this, null, getIntent()); |
| 100 | if (result && (searchEngine instanceof DefaultSearchEngine)) { |
John Reck | f57c029 | 2011-07-21 18:15:39 -0700 | [diff] [blame] | 101 | finish(); |
| 102 | return; |
| 103 | } |
Bijan Amirzada | 41242f2 | 2014-03-21 12:12:18 -0700 | [diff] [blame] | 104 | */ |
Kulanthaivel Palanichamy | 7794268 | 2014-10-28 11:52:06 -0700 | [diff] [blame] | 105 | |
| 106 | mEngineInitializer = EngineInitializer.getInstance(); |
| 107 | mEngineInitializer.onActivityCreate(BrowserActivity.this); |
| 108 | |
| 109 | Thread.setDefaultUncaughtExceptionHandler(new CrashLogExceptionHandler(this)); |
| 110 | |
| 111 | mSavedInstanceState = icicle; |
| 112 | // Create the initial UI views |
John Reck | 9c35b9c | 2012-05-30 10:08:50 -0700 | [diff] [blame] | 113 | mController = createController(); |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 114 | |
Kulanthaivel Palanichamy | 7794268 | 2014-10-28 11:52:06 -0700 | [diff] [blame] | 115 | // Workaround for the black screen flicker on SurfaceView creation |
| 116 | ViewGroup topLayout = (ViewGroup) findViewById(R.id.main_content); |
| 117 | topLayout.requestTransparentRegion(topLayout); |
| 118 | |
| 119 | // Add pre-draw listener to start the controller after engine initialization. |
| 120 | final ViewTreeObserver observer = getWindow().getDecorView().getViewTreeObserver(); |
| 121 | observer.addOnPreDrawListener(this); |
| 122 | |
| 123 | mEngineInitializer.initializeResourceExtractor(this); |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 124 | } |
| 125 | |
Kulanthaivel Palanichamy | 7794268 | 2014-10-28 11:52:06 -0700 | [diff] [blame] | 126 | @Override |
| 127 | public boolean onPreDraw() |
| 128 | { |
| 129 | final ViewTreeObserver observer = getWindow().getDecorView().getViewTreeObserver(); |
| 130 | observer.removeOnPreDrawListener(this); |
| 131 | mEngineInitializer.onPreDraw(); |
| 132 | return true; |
| 133 | } |
| 134 | |
| 135 | |
John Reck | a5176f3 | 2011-05-17 12:35:37 -0700 | [diff] [blame] | 136 | public static boolean isTablet(Context context) { |
| 137 | return context.getResources().getBoolean(R.bool.isTablet); |
John Reck | 9d27ff5 | 2011-02-11 17:47:54 -0800 | [diff] [blame] | 138 | } |
| 139 | |
John Reck | 9c35b9c | 2012-05-30 10:08:50 -0700 | [diff] [blame] | 140 | private Controller createController() { |
| 141 | Controller controller = new Controller(this); |
| 142 | boolean xlarge = isTablet(this); |
| 143 | UI ui = null; |
| 144 | if (xlarge) { |
kaiyiz | bb2db87 | 2013-08-01 22:24:07 -0400 | [diff] [blame] | 145 | XLargeUi tablet = new XLargeUi(this, controller); |
| 146 | ui = tablet; |
| 147 | mUiController = tablet.getUiController(); |
John Reck | 9c35b9c | 2012-05-30 10:08:50 -0700 | [diff] [blame] | 148 | } else { |
kaiyiz | bb2db87 | 2013-08-01 22:24:07 -0400 | [diff] [blame] | 149 | PhoneUi phone = new PhoneUi(this, controller); |
| 150 | ui = phone; |
| 151 | mUiController = phone.getUiController(); |
John Reck | 9c35b9c | 2012-05-30 10:08:50 -0700 | [diff] [blame] | 152 | } |
| 153 | controller.setUi(ui); |
| 154 | return controller; |
| 155 | } |
| 156 | |
Kulanthaivel Palanichamy | 7794268 | 2014-10-28 11:52:06 -0700 | [diff] [blame] | 157 | public void onEngineInitializationComplete() { |
| 158 | Intent intent = (mSavedInstanceState == null) ? getIntent() : null; |
| 159 | mController.start(intent); |
| 160 | } |
| 161 | |
John Reck | 4155485 | 2010-12-01 12:53:37 -0800 | [diff] [blame] | 162 | @VisibleForTesting |
Tarun Nainani | 436b873 | 2014-06-10 13:58:41 -0700 | [diff] [blame] | 163 | //public to facilitate testing |
| 164 | public Controller getController() { |
John Reck | 9c35b9c | 2012-05-30 10:08:50 -0700 | [diff] [blame] | 165 | return (Controller) mController; |
Michael Kolb | a2b2ba8 | 2010-08-04 17:54:03 -0700 | [diff] [blame] | 166 | } |
| 167 | |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 168 | @Override |
| 169 | protected void onNewIntent(Intent intent) { |
John Reck | 7878f22 | 2012-04-18 16:23:14 -0700 | [diff] [blame] | 170 | if (shouldIgnoreIntents()) return; |
Kulanthaivel Palanichamy | 7794268 | 2014-10-28 11:52:06 -0700 | [diff] [blame] | 171 | mEngineInitializer.onNewIntent(intent); |
| 172 | // Note: Do not add any more application logic in this method. |
| 173 | // Move any additional app logic into handleOnNewIntent(). |
| 174 | } |
| 175 | |
| 176 | protected void handleOnNewIntent(Intent intent) { |
John Reck | 63bb687 | 2010-12-01 19:29:32 -0800 | [diff] [blame] | 177 | if (ACTION_RESTART.equals(intent.getAction())) { |
| 178 | Bundle outState = new Bundle(); |
John Reck | 1cf4b79 | 2011-07-26 10:22:22 -0700 | [diff] [blame] | 179 | mController.onSaveInstanceState(outState); |
John Reck | 63bb687 | 2010-12-01 19:29:32 -0800 | [diff] [blame] | 180 | finish(); |
| 181 | getApplicationContext().startActivity( |
| 182 | new Intent(getApplicationContext(), BrowserActivity.class) |
| 183 | .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) |
| 184 | .putExtra(EXTRA_STATE, outState)); |
| 185 | return; |
| 186 | } |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 187 | mController.handleNewIntent(intent); |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 188 | } |
| 189 | |
John Reck | 7878f22 | 2012-04-18 16:23:14 -0700 | [diff] [blame] | 190 | private KeyguardManager mKeyguardManager; |
| 191 | private PowerManager mPowerManager; |
| 192 | private boolean shouldIgnoreIntents() { |
| 193 | // Only process intents if the screen is on and the device is unlocked |
| 194 | // aka, if we will be user-visible |
| 195 | if (mKeyguardManager == null) { |
| 196 | mKeyguardManager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE); |
| 197 | } |
| 198 | if (mPowerManager == null) { |
| 199 | mPowerManager = (PowerManager) getSystemService(Context.POWER_SERVICE); |
| 200 | } |
| 201 | boolean ignore = !mPowerManager.isScreenOn(); |
| 202 | ignore |= mKeyguardManager.inKeyguardRestrictedInputMode(); |
| 203 | if (LOGV_ENABLED) { |
| 204 | Log.v(LOGTAG, "ignore intents: " + ignore); |
| 205 | } |
| 206 | return ignore; |
| 207 | } |
| 208 | |
Grace Kloba | 22ac16e | 2009-10-07 18:00:23 -0700 | [diff] [blame] | 209 | @Override |
Kulanthaivel Palanichamy | 7794268 | 2014-10-28 11:52:06 -0700 | [diff] [blame] | 210 | protected void onStart() { |
| 211 | super.onStart(); |
| 212 | mEngineInitializer.onActivityStart(); |
| 213 | } |
| 214 | |
| 215 | @Override |
Grace Kloba | 22ac16e | 2009-10-07 18:00:23 -0700 | [diff] [blame] | 216 | protected void onResume() { |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 217 | super.onResume(); |
Dave Bort | 31a6d1c | 2009-04-13 15:56:49 -0700 | [diff] [blame] | 218 | if (LOGV_ENABLED) { |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 219 | Log.v(LOGTAG, "BrowserActivity.onResume: this=" + this); |
| 220 | } |
Kulanthaivel Palanichamy | 7794268 | 2014-10-28 11:52:06 -0700 | [diff] [blame] | 221 | mEngineInitializer.onActivityResume(); |
| 222 | // Note: Do not add any more application logic in this method. |
| 223 | // Move any additional app logic into handleOnResume(). |
| 224 | } |
Tarun Nainani | ef749cb | 2014-05-19 18:16:53 -0700 | [diff] [blame] | 225 | |
Kulanthaivel Palanichamy | 7794268 | 2014-10-28 11:52:06 -0700 | [diff] [blame] | 226 | protected void handleOnResume() { |
Tarun Nainani | b4a173f | 2015-01-05 09:23:08 -0800 | [diff] [blame] | 227 | // Note: Intentionally left blank. |
| 228 | } |
| 229 | |
| 230 | protected void handleOnStart() { |
Kulanthaivel Palanichamy | 7794268 | 2014-10-28 11:52:06 -0700 | [diff] [blame] | 231 | mController.onResume(); |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 232 | } |
| 233 | |
Leon Scroggins | a81a764 | 2009-08-31 17:05:41 -0400 | [diff] [blame] | 234 | @Override |
Tarun Nainani | b4a173f | 2015-01-05 09:23:08 -0800 | [diff] [blame] | 235 | protected void onStop() { |
| 236 | mEngineInitializer.onActivityStop(); |
| 237 | super.onStop(); |
| 238 | // Note: Do not add any more application logic in this method. |
| 239 | // Move any additional app logic into handleOnStop(). |
| 240 | } |
| 241 | |
| 242 | @Override |
Leon Scroggins | a81a764 | 2009-08-31 17:05:41 -0400 | [diff] [blame] | 243 | public boolean onMenuOpened(int featureId, Menu menu) { |
Leon Scroggins | 3bbb6ca | 2009-09-09 12:51:10 -0400 | [diff] [blame] | 244 | if (Window.FEATURE_OPTIONS_PANEL == featureId) { |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 245 | mController.onMenuOpened(featureId, menu); |
Leon Scroggins | 3bbb6ca | 2009-09-09 12:51:10 -0400 | [diff] [blame] | 246 | } |
Leon Scroggins | a81a764 | 2009-08-31 17:05:41 -0400 | [diff] [blame] | 247 | return true; |
| 248 | } |
| 249 | |
Leon Scroggins | 3bbb6ca | 2009-09-09 12:51:10 -0400 | [diff] [blame] | 250 | @Override |
| 251 | public void onOptionsMenuClosed(Menu menu) { |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 252 | mController.onOptionsMenuClosed(menu); |
Leon Scroggins | c6fa110 | 2009-09-21 10:40:01 -0400 | [diff] [blame] | 253 | } |
| 254 | |
Leon Scroggins | b2b19f5 | 2009-10-09 16:10:00 -0400 | [diff] [blame] | 255 | @Override |
| 256 | public void onContextMenuClosed(Menu menu) { |
| 257 | super.onContextMenuClosed(menu); |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 258 | mController.onContextMenuClosed(menu); |
Leon Scroggins | b2b19f5 | 2009-10-09 16:10:00 -0400 | [diff] [blame] | 259 | } |
| 260 | |
Leon Scroggins | c6fa110 | 2009-09-21 10:40:01 -0400 | [diff] [blame] | 261 | /** |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 262 | * onSaveInstanceState(Bundle map) |
| 263 | * onSaveInstanceState is called right before onStop(). The map contains |
| 264 | * the saved state. |
| 265 | */ |
Grace Kloba | 22ac16e | 2009-10-07 18:00:23 -0700 | [diff] [blame] | 266 | @Override |
| 267 | protected void onSaveInstanceState(Bundle outState) { |
Dave Bort | 31a6d1c | 2009-04-13 15:56:49 -0700 | [diff] [blame] | 268 | if (LOGV_ENABLED) { |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 269 | Log.v(LOGTAG, "BrowserActivity.onSaveInstanceState: this=" + this); |
| 270 | } |
John Reck | 9c35b9c | 2012-05-30 10:08:50 -0700 | [diff] [blame] | 271 | mController.onSaveInstanceState(outState); |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 272 | } |
| 273 | |
Grace Kloba | 22ac16e | 2009-10-07 18:00:23 -0700 | [diff] [blame] | 274 | @Override |
| 275 | protected void onPause() { |
Kulanthaivel Palanichamy | 7794268 | 2014-10-28 11:52:06 -0700 | [diff] [blame] | 276 | mEngineInitializer.onActivityPause(); |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 277 | super.onPause(); |
Kulanthaivel Palanichamy | 7794268 | 2014-10-28 11:52:06 -0700 | [diff] [blame] | 278 | // Note: Do not add any more application logic in this method. |
| 279 | // Move any additional app logic into handleOnPause(). |
| 280 | } |
| 281 | |
| 282 | protected void handleOnPause() { |
Tarun Nainani | b4a173f | 2015-01-05 09:23:08 -0800 | [diff] [blame] | 283 | // Note: Intentionally left blank |
| 284 | } |
| 285 | |
| 286 | protected void handleOnStop() { |
Dany Rybnikov | c912c55 | 2015-01-19 15:40:13 +0200 | [diff] [blame^] | 287 | CookieManager.getInstance().flushCookieStore(); |
Kulanthaivel Palanichamy | 7794268 | 2014-10-28 11:52:06 -0700 | [diff] [blame] | 288 | mController.onPause(); |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 289 | } |
| 290 | |
Grace Kloba | 22ac16e | 2009-10-07 18:00:23 -0700 | [diff] [blame] | 291 | @Override |
| 292 | protected void onDestroy() { |
Dave Bort | 31a6d1c | 2009-04-13 15:56:49 -0700 | [diff] [blame] | 293 | if (LOGV_ENABLED) { |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 294 | Log.v(LOGTAG, "BrowserActivity.onDestroy: this=" + this); |
| 295 | } |
| 296 | super.onDestroy(); |
Enrico Ros | d6efa97 | 2014-12-02 19:49:59 -0800 | [diff] [blame] | 297 | // mEngineInitializer can be null if onCreate is not called before onDestroy |
| 298 | // it happens when starting the activity with an intent while the screen is locked. |
| 299 | if (mEngineInitializer != null) |
| 300 | mEngineInitializer.onActivityDestroy(); |
John Reck | 9c35b9c | 2012-05-30 10:08:50 -0700 | [diff] [blame] | 301 | mController.onDestroy(); |
| 302 | mController = NullController.INSTANCE; |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 303 | } |
| 304 | |
| 305 | @Override |
| 306 | public void onConfigurationChanged(Configuration newConfig) { |
| 307 | super.onConfigurationChanged(newConfig); |
John Reck | 9c35b9c | 2012-05-30 10:08:50 -0700 | [diff] [blame] | 308 | mController.onConfgurationChanged(newConfig); |
kaiyiz | bb2db87 | 2013-08-01 22:24:07 -0400 | [diff] [blame] | 309 | |
| 310 | //For avoiding bug CR520353 temporarily, delay 300ms to refresh WebView. |
| 311 | mHandlerEx.postDelayed(runnable, 300); |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 312 | } |
| 313 | |
Grace Kloba | 22ac16e | 2009-10-07 18:00:23 -0700 | [diff] [blame] | 314 | @Override |
| 315 | public void onLowMemory() { |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 316 | super.onLowMemory(); |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 317 | mController.onLowMemory(); |
Grace Kloba | 22ac16e | 2009-10-07 18:00:23 -0700 | [diff] [blame] | 318 | } |
| 319 | |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 320 | @Override |
Pankaj Garg | 49b7925 | 2014-11-07 17:33:41 -0800 | [diff] [blame] | 321 | public void invalidateOptionsMenu() { |
| 322 | super.invalidateOptionsMenu(); |
| 323 | mController.invalidateOptionsMenu(); |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 324 | } |
| 325 | |
| 326 | @Override |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 327 | public boolean onPrepareOptionsMenu(Menu menu) { |
| 328 | super.onPrepareOptionsMenu(menu); |
Enrico Ros | 1f5a095 | 2014-11-18 20:15:48 -0800 | [diff] [blame] | 329 | return false; |
Cary Clark | 01cfcdd | 2010-06-04 16:36:45 -0400 | [diff] [blame] | 330 | } |
| 331 | |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 332 | @Override |
| 333 | public boolean onOptionsItemSelected(MenuItem item) { |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 334 | if (!mController.onOptionsItemSelected(item)) { |
| 335 | return super.onOptionsItemSelected(item); |
Michael Kolb | 370a4f3 | 2010-10-06 10:45:32 -0700 | [diff] [blame] | 336 | } |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 337 | return true; |
| 338 | } |
| 339 | |
| 340 | @Override |
| 341 | public void onCreateContextMenu(ContextMenu menu, View v, |
| 342 | ContextMenuInfo menuInfo) { |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 343 | mController.onCreateContextMenu(menu, v, menuInfo); |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 344 | } |
| 345 | |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 346 | @Override |
| 347 | public boolean onContextItemSelected(MenuItem item) { |
| 348 | return mController.onContextItemSelected(item); |
Grace Kloba | 22ac16e | 2009-10-07 18:00:23 -0700 | [diff] [blame] | 349 | } |
| 350 | |
Grace Kloba | 5942df0 | 2009-09-18 11:48:29 -0700 | [diff] [blame] | 351 | @Override |
| 352 | public boolean onKeyDown(int keyCode, KeyEvent event) { |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 353 | return mController.onKeyDown(keyCode, event) || |
| 354 | super.onKeyDown(keyCode, event); |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 355 | } |
| 356 | |
Grace Kloba | 5942df0 | 2009-09-18 11:48:29 -0700 | [diff] [blame] | 357 | @Override |
John Reck | e6bf4ab | 2011-02-24 15:48:05 -0800 | [diff] [blame] | 358 | public boolean onKeyLongPress(int keyCode, KeyEvent event) { |
| 359 | return mController.onKeyLongPress(keyCode, event) || |
| 360 | super.onKeyLongPress(keyCode, event); |
| 361 | } |
| 362 | |
| 363 | @Override |
Grace Kloba | 5942df0 | 2009-09-18 11:48:29 -0700 | [diff] [blame] | 364 | public boolean onKeyUp(int keyCode, KeyEvent event) { |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 365 | return mController.onKeyUp(keyCode, event) || |
| 366 | super.onKeyUp(keyCode, event); |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 367 | } |
| 368 | |
Michael Kolb | e421c24 | 2010-10-04 19:29:01 -0700 | [diff] [blame] | 369 | @Override |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 370 | public void onActionModeStarted(ActionMode mode) { |
| 371 | super.onActionModeStarted(mode); |
| 372 | mController.onActionModeStarted(mode); |
Michael Kolb | e421c24 | 2010-10-04 19:29:01 -0700 | [diff] [blame] | 373 | } |
| 374 | |
Michael Kolb | e421c24 | 2010-10-04 19:29:01 -0700 | [diff] [blame] | 375 | @Override |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 376 | public void onActionModeFinished(ActionMode mode) { |
| 377 | super.onActionModeFinished(mode); |
| 378 | mController.onActionModeFinished(mode); |
Michael Kolb | e421c24 | 2010-10-04 19:29:01 -0700 | [diff] [blame] | 379 | } |
| 380 | |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 381 | @Override |
Kulanthaivel Palanichamy | 7794268 | 2014-10-28 11:52:06 -0700 | [diff] [blame] | 382 | protected void onActivityResult (int requestCode, int resultCode, |
| 383 | Intent intent) { |
| 384 | mEngineInitializer.onActivityResult(requestCode, resultCode, intent); |
| 385 | } |
| 386 | |
| 387 | protected void handleOnActivityResult (int requestCode, int resultCode, Intent intent) { |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 388 | mController.onActivityResult(requestCode, resultCode, intent); |
Andrei Popescu | 163ab74 | 2009-10-20 17:58:23 +0100 | [diff] [blame] | 389 | } |
| 390 | |
Michael Kolb | fbc579a | 2011-07-07 15:59:33 -0700 | [diff] [blame] | 391 | @Override |
| 392 | public boolean onSearchRequested() { |
| 393 | return mController.onSearchRequested(); |
| 394 | } |
| 395 | |
Michael Kolb | c3af067 | 2011-08-09 10:24:41 -0700 | [diff] [blame] | 396 | @Override |
| 397 | public boolean dispatchKeyEvent(KeyEvent event) { |
| 398 | return mController.dispatchKeyEvent(event) |
| 399 | || super.dispatchKeyEvent(event); |
| 400 | } |
| 401 | |
| 402 | @Override |
| 403 | public boolean dispatchKeyShortcutEvent(KeyEvent event) { |
| 404 | return mController.dispatchKeyShortcutEvent(event) |
| 405 | || super.dispatchKeyShortcutEvent(event); |
| 406 | } |
| 407 | |
| 408 | @Override |
| 409 | public boolean dispatchTouchEvent(MotionEvent ev) { |
| 410 | return mController.dispatchTouchEvent(ev) |
| 411 | || super.dispatchTouchEvent(ev); |
| 412 | } |
| 413 | |
| 414 | @Override |
| 415 | public boolean dispatchTrackballEvent(MotionEvent ev) { |
| 416 | return mController.dispatchTrackballEvent(ev) |
| 417 | || super.dispatchTrackballEvent(ev); |
| 418 | } |
| 419 | |
| 420 | @Override |
| 421 | public boolean dispatchGenericMotionEvent(MotionEvent ev) { |
| 422 | return mController.dispatchGenericMotionEvent(ev) || |
| 423 | super.dispatchGenericMotionEvent(ev); |
| 424 | } |
| 425 | |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 426 | } |