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