Upstream version 9.37.195.0
[platform/framework/web/crosswalk.git] / src / xwalk / runtime / android / core_internal / src / org / xwalk / core / internal / XWalkUIClientInternal.java
index 057a36e..f4ce916 100644 (file)
@@ -20,6 +20,7 @@ import android.widget.EditText;
 /**
  * This class notifies the embedder UI events/callbacks.
  */
+@XWalkAPI(createExternally = true)
 public class XWalkUIClientInternal {
 
     // Strings for displaying Dialog.
@@ -36,12 +37,14 @@ public class XWalkUIClientInternal {
     private View mDecorView;
     private XWalkViewInternal mXWalkView;
     private boolean mOriginalFullscreen;
+    private boolean mOriginalForceNotFullscreen;
 
     /**
      * Constructor.
      * @param view the owner XWalkViewInternal instance.
      * @since 1.0
      */
+    @XWalkAPI
     public XWalkUIClientInternal(XWalkViewInternal view) {
         mContext = view.getContext();
         mDecorView = view.getActivity().getWindow().getDecorView();
@@ -68,6 +71,7 @@ public class XWalkUIClientInternal {
      * @param view the owner XWalkViewInternal instance.
      * @since 1.0
      */
+    @XWalkAPI
     public void onRequestFocus(XWalkViewInternal view) {
     }
 
@@ -76,6 +80,7 @@ public class XWalkUIClientInternal {
      * @param view the owner XWalkViewInternal instance.
      * @since 1.0
      */
+    @XWalkAPI
     public void onJavascriptCloseWindow(XWalkViewInternal view) {
         if (view != null && view.getActivity() != null) {
             view.getActivity().finish();
@@ -86,6 +91,7 @@ public class XWalkUIClientInternal {
      * The type of JavaScript modal dialog.
      * @since 1.0
      */
+    @XWalkAPI
     public enum JavascriptMessageTypeInternal {
         /** JavaScript alert dialog. */
         JAVASCRIPT_ALERT,
@@ -107,6 +113,7 @@ public class XWalkUIClientInternal {
      * @param result the callback to handle the result from caller.
      * @since 1.0
      */
+    @XWalkAPI
     public boolean onJavascriptModalDialog(XWalkViewInternal view, JavascriptMessageTypeInternal type,
             String url, String message, String defaultValue, XWalkJavascriptResultInternal result) {
         switch(type) {
@@ -132,9 +139,18 @@ public class XWalkUIClientInternal {
      * @param enterFullscreen true if it has entered fullscreen mode.
      * @since 1.0
      */
+    @XWalkAPI
     public void onFullscreenToggled(XWalkViewInternal view, boolean enterFullscreen) {
         Activity activity = view.getActivity();
         if (enterFullscreen) {
+            if ((activity.getWindow().getAttributes().flags &
+                    WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN) != 0) {
+                mOriginalForceNotFullscreen = true;
+                activity.getWindow().clearFlags(
+                        WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
+            } else {
+                mOriginalForceNotFullscreen = false;
+            }
             if (VERSION.SDK_INT >= VERSION_CODES.KITKAT) {
                 mSystemUiFlag = mDecorView.getSystemUiVisibility();
                 mDecorView.setSystemUiVisibility(
@@ -150,14 +166,14 @@ public class XWalkUIClientInternal {
                     mOriginalFullscreen = true;
                 } else {
                     mOriginalFullscreen = false;
-                }
-                if (!mOriginalFullscreen) {
-                    activity.getWindow().setFlags(
-                            WindowManager.LayoutParams.FLAG_FULLSCREEN,
-                            WindowManager.LayoutParams.FLAG_FULLSCREEN);
+                    activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
                 }
             }
         } else {
+            if (mOriginalForceNotFullscreen) {
+                activity.getWindow().addFlags(
+                        WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
+            }
             if (VERSION.SDK_INT >= VERSION_CODES.KITKAT) {
                 mDecorView.setSystemUiVisibility(mSystemUiFlag);
             } else {
@@ -181,6 +197,7 @@ public class XWalkUIClientInternal {
      *        with this file picker
      * @since 1.0
      */
+    @XWalkAPI
     public void openFileChooser(XWalkViewInternal view, ValueCallback<Uri> uploadFile,
             String acceptType, String capture) {
         uploadFile.onReceiveValue(null);
@@ -193,6 +210,7 @@ public class XWalkUIClientInternal {
      * @param newScale the current scale factor after scaling.
      * @since 1.0
      */
+    @XWalkAPI
     public void onScaleChanged(XWalkViewInternal view, float oldScale, float newScale) {
     }
 
@@ -210,6 +228,7 @@ public class XWalkUIClientInternal {
      *
      * @since 2.1
      */
+    @XWalkAPI
     public boolean shouldOverrideKeyEvent(XWalkViewInternal view, KeyEvent event) {
         return false;
     }
@@ -226,6 +245,7 @@ public class XWalkUIClientInternal {
      *
      * @since 2.1
      */
+    @XWalkAPI
     public void onUnhandledKeyEvent(XWalkViewInternal view, KeyEvent event) {
     }
 
@@ -235,6 +255,7 @@ public class XWalkUIClientInternal {
      * @param title A String containing the new title of the document.
      * @since 2.1
      */
+    @XWalkAPI
     public void onReceivedTitle(XWalkViewInternal view, String title) {
     }
 
@@ -243,6 +264,7 @@ public class XWalkUIClientInternal {
      * The status when a page stopped loading
      * @since 2.1
      */
+    @XWalkAPI
     public enum LoadStatusInternal {
         /** Loading finished. */
         FINISHED,
@@ -264,14 +286,14 @@ public class XWalkUIClientInternal {
      *
      * @since 2.1
      */
+    @XWalkAPI
     public void onPageLoadStarted(XWalkViewInternal view, String url) {
     }
 
     /**
      * Notify the host application that a page has stopped loading. This method
      * is called only for main frame. When onPageLoadStopped() is called, the
-     * rendering picture may not be updated yet. To get the notification for the
-     * new Picture, use {@link XWalkViewInternal.PictureListener#onNewPicture}.
+     * rendering picture may not be updated yet.
      *
      * @param view The XWalkViewInternal that is initiating the callback.
      * @param url The url of the page.
@@ -279,6 +301,7 @@ public class XWalkUIClientInternal {
      *
      * @since 2.1
      */
+    @XWalkAPI
     public void onPageLoadStopped(XWalkViewInternal view, String url, LoadStatusInternal status) {
     }