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