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