зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1419463 - Add onFocusRequest to ContentListener API. r=snorp
This listens for "DOMWindowFocus" and calls onFocusRequest in the GeckoSession ContentListener whenever it is received, and implements onFocusRequest for custom tabs and PWAs.
This commit is contained in:
Родитель
a191f435d6
Коммит
c8a5a694f9
|
@ -844,6 +844,10 @@ public abstract class GeckoApp extends GeckoActivity
|
|||
public void onTitleChange(final GeckoSession session, final String title) {
|
||||
}
|
||||
|
||||
@Override // GeckoSession.ContentListener
|
||||
public void onFocusRequest(final GeckoSession session) {
|
||||
}
|
||||
|
||||
@Override // GeckoSession.ContentListener
|
||||
public void onFullScreen(final GeckoSession session, final boolean fullScreen) {
|
||||
if (fullScreen) {
|
||||
|
|
|
@ -678,6 +678,13 @@ public class CustomTabsActivity extends AppCompatActivity
|
|||
updateActionBar();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFocusRequest(GeckoSession session) {
|
||||
Intent intent = new Intent(getIntent());
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFullScreen(GeckoSession session, boolean fullScreen) {
|
||||
ActivityUtils.setFullScreen(this, fullScreen);
|
||||
|
|
|
@ -351,6 +351,13 @@ public class WebAppActivity extends AppCompatActivity
|
|||
public void onTitleChange(GeckoSession session, String title) {
|
||||
}
|
||||
|
||||
@Override // GeckoSession.ContentListener
|
||||
public void onFocusRequest(GeckoSession session) {
|
||||
Intent intent = new Intent(getIntent());
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@Override // GeckoSession.ContentListener
|
||||
public void onContextMenu(GeckoSession session, int screenX, int screenY,
|
||||
String uri, String elementSrc) {
|
||||
|
|
|
@ -25,6 +25,7 @@ class GeckoViewContent extends GeckoViewContentModule {
|
|||
debug("register");
|
||||
|
||||
addEventListener("DOMTitleChanged", this, false);
|
||||
addEventListener("DOMWindowFocus", this, false);
|
||||
addEventListener("MozDOMFullscreen:Entered", this, false);
|
||||
addEventListener("MozDOMFullscreen:Exit", this, false);
|
||||
addEventListener("MozDOMFullscreen:Exited", this, false);
|
||||
|
@ -43,6 +44,7 @@ class GeckoViewContent extends GeckoViewContentModule {
|
|||
debug("unregister");
|
||||
|
||||
removeEventListener("DOMTitleChanged", this);
|
||||
removeEventListener("DOMWindowFocus", this);
|
||||
removeEventListener("MozDOMFullscreen:Entered", this);
|
||||
removeEventListener("MozDOMFullscreen:Exit", this);
|
||||
removeEventListener("MozDOMFullscreen:Exited", this);
|
||||
|
@ -173,6 +175,11 @@ class GeckoViewContent extends GeckoViewContentModule {
|
|||
title: content.document.title
|
||||
});
|
||||
break;
|
||||
case "DOMWindowFocus":
|
||||
this.eventDispatcher.sendRequest({
|
||||
type: "GeckoView:DOMWindowFocus"
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -75,6 +75,7 @@ public class GeckoSession extends LayerSession
|
|||
new String[]{
|
||||
"GeckoView:ContextMenu",
|
||||
"GeckoView:DOMTitleChanged",
|
||||
"GeckoView:DOMWindowFocus",
|
||||
"GeckoView:FullScreenEnter",
|
||||
"GeckoView:FullScreenExit"
|
||||
}
|
||||
|
@ -94,6 +95,8 @@ public class GeckoSession extends LayerSession
|
|||
} else if ("GeckoView:DOMTitleChanged".equals(event)) {
|
||||
listener.onTitleChange(GeckoSession.this,
|
||||
message.getString("title"));
|
||||
} else if ("GeckoView:DOMWindowFocus".equals(event)) {
|
||||
listener.onFocusRequest(GeckoSession.this);
|
||||
} else if ("GeckoView:FullScreenEnter".equals(event)) {
|
||||
listener.onFullScreen(GeckoSession.this, true);
|
||||
} else if ("GeckoView:FullScreenExit".equals(event)) {
|
||||
|
@ -1197,6 +1200,13 @@ public class GeckoSession extends LayerSession
|
|||
*/
|
||||
void onTitleChange(GeckoSession session, String title);
|
||||
|
||||
/**
|
||||
* A page has requested focus. Note that window.focus() in content will not result
|
||||
* in this being called.
|
||||
* @param session The GeckoSession that initiated the callback.
|
||||
*/
|
||||
void onFocusRequest(GeckoSession session);
|
||||
|
||||
/**
|
||||
* A page has entered or exited full screen mode. Typically, the implementation
|
||||
* would set the Activity containing the GeckoSession to full screen when the page is
|
||||
|
|
|
@ -162,6 +162,11 @@ public class GeckoViewActivity extends Activity {
|
|||
Log.i(LOGTAG, "Content title changed to " + title);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFocusRequest(GeckoSession session) {
|
||||
Log.i(LOGTAG, "Content requesting focus");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFullScreen(final GeckoSession session, final boolean fullScreen) {
|
||||
getWindow().setFlags(fullScreen ? WindowManager.LayoutParams.FLAG_FULLSCREEN : 0,
|
||||
|
|
Загрузка…
Ссылка в новой задаче