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