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

Commit 3d3d0a37 authored by ian's avatar ian Committed by Gerrit Code Review
Browse files

Patch Set 2/2: Add an "Automatically Connect" option for WiFi networks

Relies on: http://review.cyanogenmod.org/28529

Allows the ability for a user to determine whether to connect to an SSID automatically.
e.g. At work, there are several SSIDs with long, complex keys.
    I don't want to connect to them all of the time, but would like them to be remebered.
The default behaviour is to allow automatic connection, as it is today.

Patch set 2 : Fix capitalization & whitespace

Change-Id: I0f0aa64498115e3e1058f73113d37df63ab72d60
parent f155d29e
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -167,6 +167,15 @@
            </LinearLayout>
        </LinearLayout>

        <LinearLayout android:id="@+id/wifi_auto_connect_toggle"
                    style="@style/wifi_item"
                    android:visibility="gone">
            <CheckBox android:id="@+id/wifi_auto_connect_togglebox"
                    style="@style/wifi_item_content"
                    android:textSize="14sp"
                    android:text="@string/wifi_auto_connect" />
        </LinearLayout>

        <LinearLayout android:id="@+id/wifi_advanced_toggle"
                    style="@style/wifi_item"
                    android:visibility="gone">
+2 −0
Original line number Diff line number Diff line
@@ -1320,6 +1320,8 @@
    <string name="wifi_required_info_text">To complete setup, your tablet needs access to Wi-Fi. After setup, you can switch between mobile data and Wi-Fi.</string>

    <!-- Dialog for Access Points --> <skip />
    <!-- Label for automatically_connect -->
    <string name="wifi_auto_connect">Automatically connect</string>
    <!-- Label to show/hide advanced options -->
    <string name="wifi_show_advanced">Show advanced options</string>
    <!-- Title for the WPS setup dialog [CHAR LIMIT=50] -->
+3 −0
Original line number Diff line number Diff line
@@ -61,6 +61,7 @@ class AccessPoint extends Preference {
    String bssid;
    int security;
    int networkId;
    boolean autoConnect;
    boolean wpsAvailable = false;

    PskType pskType = PskType.UNKNOWN;
@@ -187,6 +188,7 @@ class AccessPoint extends Preference {
        bssid = config.BSSID;
        security = getSecurity(config);
        networkId = config.networkId;
        autoConnect = config.autoConnect;
        mRssi = Integer.MAX_VALUE;
        mConfig = config;
    }
@@ -199,6 +201,7 @@ class AccessPoint extends Preference {
        if (security == SECURITY_PSK)
            pskType = getPskType(result);
        networkId = -1;
        autoConnect = true;
        mRssi = result.level;
        mScanResult = result;
    }
+27 −0
Original line number Diff line number Diff line
@@ -118,6 +118,7 @@ public class WifiConfigController implements TextWatcher,
    private IpAssignment mIpAssignment = IpAssignment.UNASSIGNED;
    private ProxySettings mProxySettings = ProxySettings.UNASSIGNED;
    private LinkProperties mLinkProperties = new LinkProperties();
    private boolean mAutoConnect;

    // True when this instance is used in SetupWizard XL context.
    private final boolean mInXlSetupWizard;
@@ -160,6 +161,9 @@ public class WifiConfigController implements TextWatcher,
        mProxySettingsSpinner = (Spinner) mView.findViewById(R.id.proxy_settings);
        mProxySettingsSpinner.setOnItemSelectedListener(this);

        boolean showAutoConnectField = false;
        boolean showAutoConnectFieldValue = false;

        if (mAccessPoint == null) { // new network
            mConfigUi.setTitle(R.string.wifi_add_network);

@@ -182,6 +186,9 @@ public class WifiConfigController implements TextWatcher,

            showIpConfigFields();
            showProxyFields();
            mView.findViewById(R.id.wifi_auto_connect_toggle).setVisibility(View.VISIBLE);
            ((CheckBox) mView.findViewById(R.id.wifi_auto_connect_togglebox)).setChecked(true);
            mView.findViewById(R.id.wifi_auto_connect_togglebox).setOnClickListener(this);
            mView.findViewById(R.id.wifi_advanced_toggle).setVisibility(View.VISIBLE);
            mView.findViewById(R.id.wifi_advanced_togglebox).setOnClickListener(this);

@@ -230,12 +237,25 @@ public class WifiConfigController implements TextWatcher,
                } else {
                    mProxySettingsSpinner.setSelection(PROXY_NONE);
                }

                showAutoConnectField = true;
                showAutoConnectFieldValue = config.autoConnect;
            }

            if (mAccessPoint.networkId == INVALID_NETWORK_ID || mEdit) {
                showSecurityFields();
                showIpConfigFields();
                showProxyFields();
                mView.findViewById(R.id.wifi_auto_connect_toggle).setVisibility(View.VISIBLE);
                WifiConfiguration config = mAccessPoint.getConfig();
                if (mEdit) {
                    showAutoConnectField = false;
                    ((CheckBox) mView.findViewById(R.id.wifi_auto_connect_togglebox)).setChecked(config.autoConnect);
                } else {
                    mAutoConnect = true;
                    ((CheckBox) mView.findViewById(R.id.wifi_auto_connect_togglebox)).setChecked(true);
                }
                mView.findViewById(R.id.wifi_auto_connect_togglebox).setOnClickListener(this);
                mView.findViewById(R.id.wifi_advanced_toggle).setVisibility(View.VISIBLE);
                mView.findViewById(R.id.wifi_advanced_togglebox).setOnClickListener(this);
                if (showAdvancedFields) {
@@ -244,6 +264,10 @@ public class WifiConfigController implements TextWatcher,
                }
            }

            if (showAutoConnectField) {
                addRow(group, R.string.wifi_auto_connect, (showAutoConnectFieldValue ? context.getString(R.string.yes) : context.getString(R.string.no)));
            }

            if (mEdit) {
                mConfigUi.setSubmitButton(context.getString(R.string.wifi_save));
            } else {
@@ -388,6 +412,7 @@ public class WifiConfigController implements TextWatcher,
        config.proxySettings = mProxySettings;
        config.ipAssignment = mIpAssignment;
        config.linkProperties = new LinkProperties(mLinkProperties);
        config.autoConnect = mAutoConnect;

        return config;
    }
@@ -752,6 +777,8 @@ public class WifiConfigController implements TextWatcher,
            } else {
                mView.findViewById(R.id.wifi_advanced_fields).setVisibility(View.GONE);
            }
        } else if (view.getId() == R.id.wifi_auto_connect_togglebox) {
            mAutoConnect = ((CheckBox) view).isChecked();
        }
    }