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