Merge "[WifiSetup] Make dialogs immersive"
diff --git a/src/com/android/settings/SetupWizardUtils.java b/src/com/android/settings/SetupWizardUtils.java
index e83482a..6762bfe 100644
--- a/src/com/android/settings/SetupWizardUtils.java
+++ b/src/com/android/settings/SetupWizardUtils.java
@@ -21,17 +21,23 @@
 
 
 import android.app.Activity;
+import android.app.Dialog;
 import android.content.Intent;
 import android.graphics.Color;
 import android.graphics.drawable.BitmapDrawable;
 import android.graphics.drawable.Drawable;
 import android.graphics.drawable.LayerDrawable;
+import android.view.View;
 import android.view.Window;
+import android.view.WindowManager;
 import android.widget.TextView;
 
 public class SetupWizardUtils {
     private static final String TAG = "SetupWizardUtils";
 
+    public static final int DIALOG_IMMERSIVE_FLAGS = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
+            | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
+
     // Extra containing the resource name of the theme to be used
     public static final String EXTRA_THEME = "theme";
     public static final String THEME_HOLO = "holo";
@@ -95,6 +101,16 @@
         }
     }
 
+    public static void applyImmersiveFlags(final Dialog dialog) {
+        applyImmersiveFlags(dialog.getWindow(), DIALOG_IMMERSIVE_FLAGS);
+    }
+
+    private static void applyImmersiveFlags(final Window window, final int vis) {
+        WindowManager.LayoutParams attrs = window.getAttributes();
+        attrs.systemUiVisibility |= vis;
+        window.setAttributes(attrs);
+    }
+
     public static TextView getHeader(Activity activity) {
         return (TextView) activity.findViewById(R.id.title);
     }
diff --git a/src/com/android/settings/wifi/WifiSettingsForSetupWizard.java b/src/com/android/settings/wifi/WifiSettingsForSetupWizard.java
index 5716bec..9862258 100644
--- a/src/com/android/settings/wifi/WifiSettingsForSetupWizard.java
+++ b/src/com/android/settings/wifi/WifiSettingsForSetupWizard.java
@@ -16,6 +16,7 @@
 
 package com.android.settings.wifi;
 
+import android.app.Dialog;
 import android.content.Intent;
 import android.net.wifi.WifiConfiguration;
 import android.os.Bundle;
@@ -29,6 +30,7 @@
 import android.widget.TextView;
 
 import com.android.settings.R;
+import com.android.settings.SetupWizardUtils;
 
 /**
  * This customized version of WifiSettings is shown to the user only during Setup Wizard. Menu
@@ -119,6 +121,13 @@
     }
 
     @Override
+    public Dialog onCreateDialog(int dialogId) {
+        final Dialog dialog = super.onCreateDialog(dialogId);
+        SetupWizardUtils.applyImmersiveFlags(dialog);
+        return dialog;
+    }
+
+    @Override
     protected void connect(final WifiConfiguration config) {
         WifiSetupActivity activity = (WifiSetupActivity) getActivity();
         activity.networkSelected();
diff --git a/src/com/android/settings/wifi/WifiSetupActivity.java b/src/com/android/settings/wifi/WifiSetupActivity.java
index 155fd93..d9974b4 100644
--- a/src/com/android/settings/wifi/WifiSetupActivity.java
+++ b/src/com/android/settings/wifi/WifiSetupActivity.java
@@ -263,24 +263,26 @@
         @Override
         public Dialog onCreateDialog(Bundle savedInstanceState) {
             int messageRes = getArguments().getInt("messageRes");
-            return new AlertDialog.Builder(getActivity())
+            final AlertDialog dialog = new AlertDialog.Builder(getActivity())
                     .setMessage(messageRes)
                     .setCancelable(false)
                     .setPositiveButton(R.string.wifi_skip_anyway,
                             new DialogInterface.OnClickListener() {
-                        @Override
-                        public void onClick(DialogInterface dialog, int id) {
-                            WifiSetupActivity activity = (WifiSetupActivity) getActivity();
-                            activity.finishOrNext(RESULT_SKIP);
-                        }
-                    })
+                                @Override
+                                public void onClick(DialogInterface dialog, int id) {
+                                    WifiSetupActivity activity = (WifiSetupActivity) getActivity();
+                                    activity.finishOrNext(RESULT_SKIP);
+                                }
+                            })
                     .setNegativeButton(R.string.wifi_dont_skip,
                             new DialogInterface.OnClickListener() {
-                        @Override
-                        public void onClick(DialogInterface dialog, int id) {
-                        }
-                    })
+                                @Override
+                                public void onClick(DialogInterface dialog, int id) {
+                                }
+                            })
                     .create();
+            SetupWizardUtils.applyImmersiveFlags(dialog);
+            return dialog;
         }
     }
 }