[WifiSetup] Make dialogs immersive
Added a dialog specific applyImmersiveFlags method that adds immersive flags without the LAYOUT_ flags. The LAYOUT_ flags causes the dialog to not resize when IME is visible, and the dialog doesn't need to be drawn under the navigation / status bars anyway. Bug: 17759269 Change-Id: I0186e85d9f398af73c511b1a5ec6e83febe97f83
This commit is contained in:
@@ -21,17 +21,23 @@ import com.android.setupwizard.navigationbar.SetupWizardNavBar;
|
||||
|
||||
|
||||
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 class SetupWizardUtils {
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
@@ -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.ListView;
|
||||
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
|
||||
@@ -118,6 +120,13 @@ public class WifiSettingsForSetupWizard extends WifiSettings {
|
||||
// Do not show menu during setup wizard
|
||||
}
|
||||
|
||||
@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();
|
||||
|
@@ -263,24 +263,26 @@ public class WifiSetupActivity extends WifiPickerActivity
|
||||
@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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user