Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3266)

Unified Diff: base/android/java/src/org/chromium/base/BaseChromiumApplication.java

Issue 1226373010: Roll android_tools repo. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert MENU workaround Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « DEPS ('k') | base/android/junit/src/org/chromium/base/BaseChromiumApplicationTest.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/android/java/src/org/chromium/base/BaseChromiumApplication.java
diff --git a/base/android/java/src/org/chromium/base/BaseChromiumApplication.java b/base/android/java/src/org/chromium/base/BaseChromiumApplication.java
index 8ec4afa6637fc90138ba1eec32f7dca47864198b..d7c7b05ea58d88808aef44d10e798448e74ec0ca 100644
--- a/base/android/java/src/org/chromium/base/BaseChromiumApplication.java
+++ b/base/android/java/src/org/chromium/base/BaseChromiumApplication.java
@@ -8,6 +8,7 @@ import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.os.Bundle;
+import android.view.KeyEvent;
import android.view.Window;
import java.lang.reflect.InvocationHandler;
@@ -37,6 +38,9 @@ public class BaseChromiumApplication extends Application {
/**
* Intercepts calls to an existing Window.Callback. Most invocations are passed on directly
* to the composed Window.Callback but enables intercepting/manipulating others.
+ *
+ * This is used to relay window focus changes throughout the app and remedy a bug in the
+ * appcompat library.
*/
private class WindowCallbackProxy implements InvocationHandler {
private final Window.Callback mCallback;
@@ -53,6 +57,9 @@ public class BaseChromiumApplication extends Application {
&& args[0] instanceof Boolean) {
onWindowFocusChanged((boolean) args[0]);
return null;
+ } else if (method.getName().equals("dispatchKeyEvent") && args.length == 1
+ && args[0] instanceof KeyEvent) {
+ return dispatchKeyEvent((KeyEvent) args[0]);
} else {
try {
return method.invoke(mCallback, args);
@@ -78,6 +85,15 @@ public class BaseChromiumApplication extends Application {
listener.onWindowFocusChanged(mActivity, hasFocus);
}
}
+
+ public boolean dispatchKeyEvent(KeyEvent event) {
+ // TODO(aurimas): remove this once AppCompatDelegateImpl no longer steals
+ // KEYCODE_MENU. (see b/20529185)
+ if (event.getKeyCode() == KeyEvent.KEYCODE_MENU && mActivity.dispatchKeyEvent(event)) {
+ return true;
+ }
+ return mCallback.dispatchKeyEvent(event);
+ }
}
@Override
public void onCreate() {
« no previous file with comments | « DEPS ('k') | base/android/junit/src/org/chromium/base/BaseChromiumApplicationTest.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698