Make only the "Add Network" WifiDialog fullscreen.

Fixes an issue where other instances of WifiDialog were being launched
fullscreen. Creates static methods for creating fullscreen and modal
WifiDialogs to make the style more explicit.

Bug: 63889135
Test: make -j40 RunSettingsRoboTests
Change-Id: I2200b5d7f817b9f69a6abb73bf2c04ea24556d19
This commit is contained in:
Eric Schwarzenbach
2017-07-21 15:48:58 -07:00
parent bd429f42cb
commit bc1cf7e260
5 changed files with 101 additions and 24 deletions

View File

@@ -27,6 +27,7 @@ import com.android.settings.R;
import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.wifi.AccessPoint;
// TODO(b/64069122) Have this extend a dialogfragment to handle the fullscreen launch case.
class WifiDialog extends AlertDialog implements WifiConfigUiBase, DialogInterface.OnClickListener {
public interface WifiDialogListener {
@@ -45,21 +46,31 @@ class WifiDialog extends AlertDialog implements WifiConfigUiBase, DialogInterfac
private WifiConfigController mController;
private boolean mHideSubmitButton;
public WifiDialog(Context context, WifiDialogListener listener, AccessPoint accessPoint,
int mode, boolean hideSubmitButton) {
this(context, listener, accessPoint, mode);
mHideSubmitButton = hideSubmitButton;
/** Creates a WifiDialog with fullscreen style. It displays in fullscreen mode. */
public static WifiDialog createFullscreen(Context context, WifiDialogListener listener,
AccessPoint accessPoint, int mode) {
return new WifiDialog(context, listener, accessPoint, mode,
R.style.Theme_Settings_NoActionBar, false /* hideSubmitButton */);
}
public WifiDialog(Context context, WifiDialogListener listener, AccessPoint accessPoint,
int mode) {
// conditionally sets the theme to fullscreen dialog for "Add Network"
super(context,
mode == WifiConfigUiBase.MODE_CONNECT ? R.style.Theme_Settings_NoActionBar : 0);
/**
* Creates a WifiDialog with no additional style. It displays as a dialog above the current
* view.
*/
public static WifiDialog createModal(Context context, WifiDialogListener listener,
AccessPoint accessPoint, int mode) {
return new WifiDialog(context, listener, accessPoint, mode, 0 /* style */,
mode == WifiConfigUiBase.MODE_VIEW /* hideSubmitButton*/);
}
/* package */ WifiDialog(Context context, WifiDialogListener listener, AccessPoint accessPoint,
int mode, int style, boolean hideSubmitButton) {
super(context, style);
mMode = mode;
mListener = listener;
mAccessPoint = accessPoint;
mHideSubmitButton = false;
mHideSubmitButton = hideSubmitButton;
}
@Override