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 | |
| 17 | package com.android.browser; |
| 18 | |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 19 | import android.app.Activity; |
qqzhou | e6ff8b4 | 2013-07-23 17:28:48 +0800 | [diff] [blame^] | 20 | import android.app.AlertDialog; |
John Reck | 7878f22 | 2012-04-18 16:23:14 -0700 | [diff] [blame] | 21 | import android.app.KeyguardManager; |
John Reck | 9d27ff5 | 2011-02-11 17:47:54 -0800 | [diff] [blame] | 22 | import android.content.Context; |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 23 | import android.content.Intent; |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 24 | import android.content.res.Configuration; |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 25 | import android.os.Bundle; |
qqzhou | 8c5b0a3 | 2013-07-22 15:31:03 +0800 | [diff] [blame] | 26 | import android.os.Handler; |
John Reck | 7878f22 | 2012-04-18 16:23:14 -0700 | [diff] [blame] | 27 | import android.os.PowerManager; |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 28 | import android.util.Log; |
Leon Scroggins III | 8e4fbf1 | 2010-08-17 16:58:15 -0400 | [diff] [blame] | 29 | import android.view.ActionMode; |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 30 | import android.view.ContextMenu; |
Michael Kolb | a2b2ba8 | 2010-08-04 17:54:03 -0700 | [diff] [blame] | 31 | import android.view.ContextMenu.ContextMenuInfo; |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 32 | import android.view.KeyEvent; |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 33 | import android.view.Menu; |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 34 | import android.view.MenuItem; |
Michael Kolb | c3af067 | 2011-08-09 10:24:41 -0700 | [diff] [blame] | 35 | import android.view.MotionEvent; |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 36 | import android.view.View; |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 37 | import android.view.Window; |
qqzhou | e6ff8b4 | 2013-07-23 17:28:48 +0800 | [diff] [blame^] | 38 | import android.webkit.WebSettings; |
| 39 | import android.webkit.WebView; |
qqzhou | 8c5b0a3 | 2013-07-22 15:31:03 +0800 | [diff] [blame] | 40 | import android.webkit.JavascriptInterface; |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 41 | |
qqzhou | 8c5b0a3 | 2013-07-22 15:31:03 +0800 | [diff] [blame] | 42 | import com.android.browser.UI.ComboViews; |
John Reck | 9c35b9c | 2012-05-30 10:08:50 -0700 | [diff] [blame] | 43 | import com.android.browser.stub.NullController; |
qqzhou | 8c5b0a3 | 2013-07-22 15:31:03 +0800 | [diff] [blame] | 44 | |
John Reck | d3e4d5b | 2011-07-13 15:48:43 -0700 | [diff] [blame] | 45 | import com.google.common.annotations.VisibleForTesting; |
| 46 | |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 47 | public class BrowserActivity extends Activity { |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 48 | |
John Reck | 439c9a5 | 2010-12-14 10:04:39 -0800 | [diff] [blame] | 49 | public static final String ACTION_SHOW_BOOKMARKS = "show_bookmarks"; |
| 50 | public static final String ACTION_SHOW_BROWSER = "show_browser"; |
John Reck | 63bb687 | 2010-12-01 19:29:32 -0800 | [diff] [blame] | 51 | public static final String ACTION_RESTART = "--restart--"; |
| 52 | private static final String EXTRA_STATE = "state"; |
John Reck | 38b3965 | 2012-06-05 09:22:59 -0700 | [diff] [blame] | 53 | public static final String EXTRA_DISABLE_URL_OVERRIDE = "disable_url_override"; |
John Reck | 63bb687 | 2010-12-01 19:29:32 -0800 | [diff] [blame] | 54 | |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 55 | private final static String LOGTAG = "browser"; |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 56 | |
John Reck | 6c2e2f3 | 2011-08-22 13:41:23 -0700 | [diff] [blame] | 57 | private final static boolean LOGV_ENABLED = Browser.LOGV_ENABLED; |
Dave Bort | 31a6d1c | 2009-04-13 15:56:49 -0700 | [diff] [blame] | 58 | |
John Reck | 9c35b9c | 2012-05-30 10:08:50 -0700 | [diff] [blame] | 59 | private ActivityController mController = NullController.INSTANCE; |
qqzhou | 8c5b0a3 | 2013-07-22 15:31:03 +0800 | [diff] [blame] | 60 | private Handler mHandler = new Handler(); |
Jeff Davidson | 4361029 | 2010-07-16 16:03:58 -0700 | [diff] [blame] | 61 | |
Grace Kloba | 22ac16e | 2009-10-07 18:00:23 -0700 | [diff] [blame] | 62 | @Override |
| 63 | public void onCreate(Bundle icicle) { |
Dave Bort | 31a6d1c | 2009-04-13 15:56:49 -0700 | [diff] [blame] | 64 | if (LOGV_ENABLED) { |
John Reck | 6c2e2f3 | 2011-08-22 13:41:23 -0700 | [diff] [blame] | 65 | Log.v(LOGTAG, this + " onStart, has state: " |
| 66 | + (icicle == null ? "false" : "true")); |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 67 | } |
| 68 | super.onCreate(icicle); |
Derek Sollenberger | ffa561e | 2010-11-16 14:19:01 -0500 | [diff] [blame] | 69 | |
John Reck | 7878f22 | 2012-04-18 16:23:14 -0700 | [diff] [blame] | 70 | if (shouldIgnoreIntents()) { |
| 71 | finish(); |
| 72 | return; |
| 73 | } |
| 74 | |
John Reck | f57c029 | 2011-07-21 18:15:39 -0700 | [diff] [blame] | 75 | // If this was a web search request, pass it on to the default web |
| 76 | // search provider and finish this activity. |
| 77 | if (IntentHandler.handleWebSearchIntent(this, null, getIntent())) { |
| 78 | finish(); |
| 79 | return; |
| 80 | } |
John Reck | 9c35b9c | 2012-05-30 10:08:50 -0700 | [diff] [blame] | 81 | mController = createController(); |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 82 | |
George Mount | 3636d0a | 2011-11-21 09:08:21 -0800 | [diff] [blame] | 83 | Intent intent = (icicle == null) ? getIntent() : null; |
| 84 | mController.start(intent); |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 85 | } |
| 86 | |
John Reck | a5176f3 | 2011-05-17 12:35:37 -0700 | [diff] [blame] | 87 | public static boolean isTablet(Context context) { |
| 88 | return context.getResources().getBoolean(R.bool.isTablet); |
John Reck | 9d27ff5 | 2011-02-11 17:47:54 -0800 | [diff] [blame] | 89 | } |
| 90 | |
John Reck | 9c35b9c | 2012-05-30 10:08:50 -0700 | [diff] [blame] | 91 | private Controller createController() { |
| 92 | Controller controller = new Controller(this); |
| 93 | boolean xlarge = isTablet(this); |
| 94 | UI ui = null; |
| 95 | if (xlarge) { |
| 96 | ui = new XLargeUi(this, controller); |
| 97 | } else { |
| 98 | ui = new PhoneUi(this, controller); |
| 99 | } |
| 100 | controller.setUi(ui); |
| 101 | return controller; |
| 102 | } |
| 103 | |
John Reck | 4155485 | 2010-12-01 12:53:37 -0800 | [diff] [blame] | 104 | @VisibleForTesting |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 105 | Controller getController() { |
John Reck | 9c35b9c | 2012-05-30 10:08:50 -0700 | [diff] [blame] | 106 | return (Controller) mController; |
Michael Kolb | a2b2ba8 | 2010-08-04 17:54:03 -0700 | [diff] [blame] | 107 | } |
| 108 | |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 109 | @Override |
| 110 | protected void onNewIntent(Intent intent) { |
John Reck | 7878f22 | 2012-04-18 16:23:14 -0700 | [diff] [blame] | 111 | if (shouldIgnoreIntents()) return; |
John Reck | 63bb687 | 2010-12-01 19:29:32 -0800 | [diff] [blame] | 112 | if (ACTION_RESTART.equals(intent.getAction())) { |
| 113 | Bundle outState = new Bundle(); |
John Reck | 1cf4b79 | 2011-07-26 10:22:22 -0700 | [diff] [blame] | 114 | mController.onSaveInstanceState(outState); |
John Reck | 63bb687 | 2010-12-01 19:29:32 -0800 | [diff] [blame] | 115 | finish(); |
| 116 | getApplicationContext().startActivity( |
| 117 | new Intent(getApplicationContext(), BrowserActivity.class) |
| 118 | .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) |
| 119 | .putExtra(EXTRA_STATE, outState)); |
| 120 | return; |
| 121 | } |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 122 | mController.handleNewIntent(intent); |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 123 | } |
| 124 | |
John Reck | 7878f22 | 2012-04-18 16:23:14 -0700 | [diff] [blame] | 125 | private KeyguardManager mKeyguardManager; |
| 126 | private PowerManager mPowerManager; |
| 127 | private boolean shouldIgnoreIntents() { |
| 128 | // Only process intents if the screen is on and the device is unlocked |
| 129 | // aka, if we will be user-visible |
| 130 | if (mKeyguardManager == null) { |
| 131 | mKeyguardManager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE); |
| 132 | } |
| 133 | if (mPowerManager == null) { |
| 134 | mPowerManager = (PowerManager) getSystemService(Context.POWER_SERVICE); |
| 135 | } |
| 136 | boolean ignore = !mPowerManager.isScreenOn(); |
| 137 | ignore |= mKeyguardManager.inKeyguardRestrictedInputMode(); |
| 138 | if (LOGV_ENABLED) { |
| 139 | Log.v(LOGTAG, "ignore intents: " + ignore); |
| 140 | } |
| 141 | return ignore; |
| 142 | } |
| 143 | |
Grace Kloba | 22ac16e | 2009-10-07 18:00:23 -0700 | [diff] [blame] | 144 | @Override |
| 145 | protected void onResume() { |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 146 | super.onResume(); |
Dave Bort | 31a6d1c | 2009-04-13 15:56:49 -0700 | [diff] [blame] | 147 | if (LOGV_ENABLED) { |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 148 | Log.v(LOGTAG, "BrowserActivity.onResume: this=" + this); |
| 149 | } |
John Reck | 9c35b9c | 2012-05-30 10:08:50 -0700 | [diff] [blame] | 150 | mController.onResume(); |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 151 | } |
| 152 | |
Leon Scroggins | a81a764 | 2009-08-31 17:05:41 -0400 | [diff] [blame] | 153 | @Override |
| 154 | public boolean onMenuOpened(int featureId, Menu menu) { |
Leon Scroggins | 3bbb6ca | 2009-09-09 12:51:10 -0400 | [diff] [blame] | 155 | if (Window.FEATURE_OPTIONS_PANEL == featureId) { |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 156 | mController.onMenuOpened(featureId, menu); |
Leon Scroggins | 3bbb6ca | 2009-09-09 12:51:10 -0400 | [diff] [blame] | 157 | } |
Leon Scroggins | a81a764 | 2009-08-31 17:05:41 -0400 | [diff] [blame] | 158 | return true; |
| 159 | } |
| 160 | |
Leon Scroggins | 3bbb6ca | 2009-09-09 12:51:10 -0400 | [diff] [blame] | 161 | @Override |
| 162 | public void onOptionsMenuClosed(Menu menu) { |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 163 | mController.onOptionsMenuClosed(menu); |
Leon Scroggins | c6fa110 | 2009-09-21 10:40:01 -0400 | [diff] [blame] | 164 | } |
| 165 | |
Leon Scroggins | b2b19f5 | 2009-10-09 16:10:00 -0400 | [diff] [blame] | 166 | @Override |
| 167 | public void onContextMenuClosed(Menu menu) { |
| 168 | super.onContextMenuClosed(menu); |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 169 | mController.onContextMenuClosed(menu); |
Leon Scroggins | b2b19f5 | 2009-10-09 16:10:00 -0400 | [diff] [blame] | 170 | } |
| 171 | |
Leon Scroggins | c6fa110 | 2009-09-21 10:40:01 -0400 | [diff] [blame] | 172 | /** |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 173 | * onSaveInstanceState(Bundle map) |
| 174 | * onSaveInstanceState is called right before onStop(). The map contains |
| 175 | * the saved state. |
| 176 | */ |
Grace Kloba | 22ac16e | 2009-10-07 18:00:23 -0700 | [diff] [blame] | 177 | @Override |
| 178 | protected void onSaveInstanceState(Bundle outState) { |
Dave Bort | 31a6d1c | 2009-04-13 15:56:49 -0700 | [diff] [blame] | 179 | if (LOGV_ENABLED) { |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 180 | Log.v(LOGTAG, "BrowserActivity.onSaveInstanceState: this=" + this); |
| 181 | } |
John Reck | 9c35b9c | 2012-05-30 10:08:50 -0700 | [diff] [blame] | 182 | mController.onSaveInstanceState(outState); |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 183 | } |
| 184 | |
Grace Kloba | 22ac16e | 2009-10-07 18:00:23 -0700 | [diff] [blame] | 185 | @Override |
| 186 | protected void onPause() { |
John Reck | 9c35b9c | 2012-05-30 10:08:50 -0700 | [diff] [blame] | 187 | mController.onPause(); |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 188 | super.onPause(); |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 189 | } |
| 190 | |
Grace Kloba | 22ac16e | 2009-10-07 18:00:23 -0700 | [diff] [blame] | 191 | @Override |
| 192 | protected void onDestroy() { |
Dave Bort | 31a6d1c | 2009-04-13 15:56:49 -0700 | [diff] [blame] | 193 | if (LOGV_ENABLED) { |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 194 | Log.v(LOGTAG, "BrowserActivity.onDestroy: this=" + this); |
| 195 | } |
| 196 | super.onDestroy(); |
John Reck | 9c35b9c | 2012-05-30 10:08:50 -0700 | [diff] [blame] | 197 | mController.onDestroy(); |
| 198 | mController = NullController.INSTANCE; |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 199 | } |
| 200 | |
| 201 | @Override |
| 202 | public void onConfigurationChanged(Configuration newConfig) { |
| 203 | super.onConfigurationChanged(newConfig); |
John Reck | 9c35b9c | 2012-05-30 10:08:50 -0700 | [diff] [blame] | 204 | mController.onConfgurationChanged(newConfig); |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 205 | } |
| 206 | |
Grace Kloba | 22ac16e | 2009-10-07 18:00:23 -0700 | [diff] [blame] | 207 | @Override |
| 208 | public void onLowMemory() { |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 209 | super.onLowMemory(); |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 210 | mController.onLowMemory(); |
Grace Kloba | 22ac16e | 2009-10-07 18:00:23 -0700 | [diff] [blame] | 211 | } |
| 212 | |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 213 | @Override |
| 214 | public boolean onCreateOptionsMenu(Menu menu) { |
| 215 | super.onCreateOptionsMenu(menu); |
John Reck | 9c35b9c | 2012-05-30 10:08:50 -0700 | [diff] [blame] | 216 | return mController.onCreateOptionsMenu(menu); |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 217 | } |
| 218 | |
| 219 | @Override |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 220 | public boolean onPrepareOptionsMenu(Menu menu) { |
| 221 | super.onPrepareOptionsMenu(menu); |
John Reck | b3417f0 | 2011-01-14 11:01:05 -0800 | [diff] [blame] | 222 | return mController.onPrepareOptionsMenu(menu); |
Cary Clark | 01cfcdd | 2010-06-04 16:36:45 -0400 | [diff] [blame] | 223 | } |
| 224 | |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 225 | @Override |
| 226 | public boolean onOptionsItemSelected(MenuItem item) { |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 227 | if (!mController.onOptionsItemSelected(item)) { |
kaiyiz | a8b6dbb | 2013-07-29 18:11:22 +0800 | [diff] [blame] | 228 | if (item.getItemId() == R.id.exit_menu_id) { |
| 229 | finish(); |
| 230 | new Handler().postDelayed(new Runnable() { |
| 231 | @Override |
| 232 | public void run() { |
| 233 | // Make sure all tabs are closed. |
| 234 | if (mController != NullController.INSTANCE) { |
| 235 | mController.onPause(); |
| 236 | mController.onDestroy(); |
| 237 | // Clear the state before kill the browser process. |
| 238 | CrashRecoveryHandler.getInstance().clearState(true); |
| 239 | mController = NullController.INSTANCE; |
| 240 | } |
| 241 | android.os.Process.killProcess(android.os.Process.myPid()); |
| 242 | } |
| 243 | }, 300); |
| 244 | } |
qqzhou | e6ff8b4 | 2013-07-23 17:28:48 +0800 | [diff] [blame^] | 245 | if (item.getItemId() == R.id.about_menu_id) { |
| 246 | final AlertDialog.Builder builder = new AlertDialog.Builder(this); |
| 247 | builder.setTitle(R.string.about); |
| 248 | builder.setCancelable(true); |
| 249 | String ua = ""; |
| 250 | final WebView current = getController().getCurrentWebView(); |
| 251 | if (current != null) { |
| 252 | final WebSettings s = current.getSettings(); |
| 253 | if (s != null) { |
| 254 | ua = s.getUserAgentString(); |
| 255 | } |
| 256 | } |
| 257 | builder.setMessage("Agent:" + ua); |
| 258 | builder.setPositiveButton(android.R.string.ok, null); |
| 259 | builder.create().show(); |
| 260 | } |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 261 | return super.onOptionsItemSelected(item); |
Michael Kolb | 370a4f3 | 2010-10-06 10:45:32 -0700 | [diff] [blame] | 262 | } |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 263 | return true; |
| 264 | } |
| 265 | |
| 266 | @Override |
| 267 | public void onCreateContextMenu(ContextMenu menu, View v, |
| 268 | ContextMenuInfo menuInfo) { |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 269 | mController.onCreateContextMenu(menu, v, menuInfo); |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 270 | } |
| 271 | |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 272 | @Override |
| 273 | public boolean onContextItemSelected(MenuItem item) { |
| 274 | return mController.onContextItemSelected(item); |
Grace Kloba | 22ac16e | 2009-10-07 18:00:23 -0700 | [diff] [blame] | 275 | } |
| 276 | |
Grace Kloba | 5942df0 | 2009-09-18 11:48:29 -0700 | [diff] [blame] | 277 | @Override |
| 278 | public boolean onKeyDown(int keyCode, KeyEvent event) { |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 279 | return mController.onKeyDown(keyCode, event) || |
| 280 | super.onKeyDown(keyCode, event); |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 281 | } |
| 282 | |
Grace Kloba | 5942df0 | 2009-09-18 11:48:29 -0700 | [diff] [blame] | 283 | @Override |
John Reck | e6bf4ab | 2011-02-24 15:48:05 -0800 | [diff] [blame] | 284 | public boolean onKeyLongPress(int keyCode, KeyEvent event) { |
| 285 | return mController.onKeyLongPress(keyCode, event) || |
| 286 | super.onKeyLongPress(keyCode, event); |
| 287 | } |
| 288 | |
| 289 | @Override |
Grace Kloba | 5942df0 | 2009-09-18 11:48:29 -0700 | [diff] [blame] | 290 | public boolean onKeyUp(int keyCode, KeyEvent event) { |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 291 | return mController.onKeyUp(keyCode, event) || |
| 292 | super.onKeyUp(keyCode, event); |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 293 | } |
| 294 | |
Michael Kolb | e421c24 | 2010-10-04 19:29:01 -0700 | [diff] [blame] | 295 | @Override |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 296 | public void onActionModeStarted(ActionMode mode) { |
| 297 | super.onActionModeStarted(mode); |
| 298 | mController.onActionModeStarted(mode); |
Michael Kolb | e421c24 | 2010-10-04 19:29:01 -0700 | [diff] [blame] | 299 | } |
| 300 | |
Michael Kolb | e421c24 | 2010-10-04 19:29:01 -0700 | [diff] [blame] | 301 | @Override |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 302 | public void onActionModeFinished(ActionMode mode) { |
| 303 | super.onActionModeFinished(mode); |
| 304 | mController.onActionModeFinished(mode); |
Michael Kolb | e421c24 | 2010-10-04 19:29:01 -0700 | [diff] [blame] | 305 | } |
| 306 | |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 307 | @Override |
| 308 | protected void onActivityResult(int requestCode, int resultCode, |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 309 | Intent intent) { |
| 310 | mController.onActivityResult(requestCode, resultCode, intent); |
Andrei Popescu | 163ab74 | 2009-10-20 17:58:23 +0100 | [diff] [blame] | 311 | } |
| 312 | |
Michael Kolb | fbc579a | 2011-07-07 15:59:33 -0700 | [diff] [blame] | 313 | @Override |
| 314 | public boolean onSearchRequested() { |
| 315 | return mController.onSearchRequested(); |
| 316 | } |
| 317 | |
Michael Kolb | c3af067 | 2011-08-09 10:24:41 -0700 | [diff] [blame] | 318 | @Override |
| 319 | public boolean dispatchKeyEvent(KeyEvent event) { |
| 320 | return mController.dispatchKeyEvent(event) |
| 321 | || super.dispatchKeyEvent(event); |
| 322 | } |
| 323 | |
| 324 | @Override |
| 325 | public boolean dispatchKeyShortcutEvent(KeyEvent event) { |
| 326 | return mController.dispatchKeyShortcutEvent(event) |
| 327 | || super.dispatchKeyShortcutEvent(event); |
| 328 | } |
| 329 | |
| 330 | @Override |
| 331 | public boolean dispatchTouchEvent(MotionEvent ev) { |
| 332 | return mController.dispatchTouchEvent(ev) |
| 333 | || super.dispatchTouchEvent(ev); |
| 334 | } |
| 335 | |
| 336 | @Override |
| 337 | public boolean dispatchTrackballEvent(MotionEvent ev) { |
| 338 | return mController.dispatchTrackballEvent(ev) |
| 339 | || super.dispatchTrackballEvent(ev); |
| 340 | } |
| 341 | |
| 342 | @Override |
| 343 | public boolean dispatchGenericMotionEvent(MotionEvent ev) { |
| 344 | return mController.dispatchGenericMotionEvent(ev) || |
| 345 | super.dispatchGenericMotionEvent(ev); |
| 346 | } |
| 347 | |
qqzhou | 8c5b0a3 | 2013-07-22 15:31:03 +0800 | [diff] [blame] | 348 | // add for carrier homepage feature |
| 349 | @JavascriptInterface |
| 350 | public void loadBookmarks() { |
| 351 | mHandler.post(new Runnable() { |
| 352 | @Override |
| 353 | public void run() { |
| 354 | if (mController instanceof Controller) { |
| 355 | ((Controller)mController).bookmarksOrHistoryPicker(ComboViews.Bookmarks); |
| 356 | } |
| 357 | } |
| 358 | }); |
| 359 | } |
| 360 | |
| 361 | // add for carrier homepage feature |
| 362 | @JavascriptInterface |
| 363 | public void loadHistory() { |
| 364 | mHandler.post(new Runnable() { |
| 365 | @Override |
| 366 | public void run() { |
| 367 | if (mController instanceof Controller) { |
| 368 | ((Controller)mController).bookmarksOrHistoryPicker(ComboViews.History); |
| 369 | } |
| 370 | } |
| 371 | }); |
| 372 | } |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 373 | } |