Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 771fac59 authored by Maurice Lam's avatar Maurice Lam
Browse files

[WifiSettings] Add Wi-Fi dialog activity

Add a Wi-Fi dialog activity that can be started by setup wizard to
connect to a Wi-Fi access point.

Also refactored mEdit and mModify in WifiConfigController into an
int-enum mMode, with modes view, connect and modify. This is how the
new modes maps to the old flags:

MODE_VIEW     --  mEdit = false, mModify = *
MODE_CONNECT  --  mEdit = true, mModify = false
MODE_MODIFY   --  mEdit = true, mModify = true

Bug: 23426311
Change-Id: I8e2221fd3c42577068e07686dab245dd5888e0ae
parent 2662df84
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -2500,6 +2500,16 @@
            android:excludeFromRecents="true">
        </activity>

        <activity android:name=".wifi.WifiDialogActivity"
            android:theme="@style/Transparent"
            android:excludeFromRecents="true"
            android:exported="true">
            <intent-filter>
                <action android:name="com.android.settings.WIFI_DIALOG" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>

        <activity android:name=".sim.SimDialogActivity"
                android:theme="@android:style/Theme.Material.Light.Dialog.NoActionBar"
                android:label="@string/sim_settings_title"
+1 −0
Original line number Diff line number Diff line
@@ -239,6 +239,7 @@
    </style>

    <style name="Transparent">
        <item name="android:alertDialogTheme">@style/Theme.AlertDialog</item>
        <item name="android:windowBackground">@android:color/transparent</item>
        <item name="android:windowNoTitle">true</item>
        <item name="android:windowIsFloating">true</item>
+1 −1
Original line number Diff line number Diff line
@@ -146,7 +146,7 @@ public class SavedAccessPointsWifiSettings extends SettingsPreferenceFragment
                final boolean hideForgetButton = WifiSettings.isEditabilityLockedDown(getActivity(),
                        mDlgAccessPoint.getConfig());
                mDialog = new WifiDialog(getActivity(), this, mDlgAccessPoint,
                        false /* not editting */, false, true /* hide the submit button */,
                        WifiConfigUiBase.MODE_VIEW, true /* hide the submit button */,
                        hideForgetButton);
                return mDialog;

+15 −16
Original line number Diff line number Diff line
@@ -144,23 +144,20 @@ public class WifiConfigController implements TextWatcher,
    private StaticIpConfiguration mStaticIpConfiguration = null;

    private String[] mLevels;
    private boolean mEdit;
    private boolean mModify;
    private int mMode;
    private TextView mSsidView;

    private Context mContext;

    public WifiConfigController(
            WifiConfigUiBase parent, View view, AccessPoint accessPoint, boolean edit,
            boolean modify) {
    public WifiConfigController(WifiConfigUiBase parent, View view, AccessPoint accessPoint,
            int mode) {
        mConfigUi = parent;

        mView = view;
        mAccessPoint = accessPoint;
        mAccessPointSecurity = (accessPoint == null) ? AccessPoint.SECURITY_NONE :
                accessPoint.getSecurity();
        mEdit = edit;
        mModify = modify;
        mMode = mode;

        mTextViewChangedHandler = new Handler();
        mContext = mConfigUi.getContext();
@@ -238,7 +235,7 @@ public class WifiConfigController implements TextWatcher,
            }

            if ((!mAccessPoint.isSaved() && !mAccessPoint.isActive())
                    || mEdit) {
                    || mMode != WifiConfigUiBase.MODE_VIEW) {
                showSecurityFields();
                showIpConfigFields();
                showProxyFields();
@@ -251,8 +248,10 @@ public class WifiConfigController implements TextWatcher,
                }
            }

            if (mModify) {
            if (mMode == WifiConfigUiBase.MODE_MODIFY) {
                mConfigUi.setSubmitButton(res.getString(R.string.wifi_save));
            } else if (mMode == WifiConfigUiBase.MODE_CONNECT) {
                mConfigUi.setSubmitButton(res.getString(R.string.wifi_connect));
            } else {
                final DetailedState state = mAccessPoint.getDetailedState();
                final String signalLevel = getSignalString();
@@ -376,7 +375,7 @@ public class WifiConfigController implements TextWatcher,
    }

    /* package */ WifiConfiguration getConfig() {
        if (!mEdit) {
        if (mMode == WifiConfigUiBase.MODE_VIEW) {
            return null;
        }

@@ -966,12 +965,8 @@ public class WifiConfigController implements TextWatcher,
        }
    }

    public boolean isEdit() {
        return mEdit;
    }

    public boolean isModify() {
        return mModify;
    public int getMode() {
        return mMode;
    }

    @Override
@@ -1066,4 +1061,8 @@ public class WifiConfigController implements TextWatcher,
                InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD :
                InputType.TYPE_TEXT_VARIATION_PASSWORD));
    }

    public AccessPoint getAccessPoint() {
        return mAccessPoint;
    }
}
+17 −1
Original line number Diff line number Diff line
@@ -24,10 +24,26 @@ import android.widget.Button;
 * Foundation interface glues between Activities and UIs like {@link WifiDialog}.
 */
public interface WifiConfigUiBase {

    /**
     * Viewing mode for a Wi-Fi access point. Data is displayed in non-editable mode.
     */
    int MODE_VIEW = 0;
    /**
     * Connect mode. Data is displayed in editable mode, and a connect button will be shown.
     */
    int MODE_CONNECT = 1;
    /**
     * Modify mode. All data is displayed in editable fields, and a "save" button is shown instead
     * of "connect". Clients are expected to only save but not connect to the access point in this
     * mode.
     */
    int MODE_MODIFY = 2;

    public Context getContext();
    public WifiConfigController getController();
    public LayoutInflater getLayoutInflater();
    public boolean isEdit();
    public int getMode();

    public void dispatchSubmit();

Loading