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

Commit c01754ba authored by Jeff Davidson's avatar Jeff Davidson Committed by Android (Google) Code Review
Browse files

Merge "Final UX for Wi-Fi assistant platform settings." into lmp-mr1-dev

parents fdebfc35 ce32b217
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -1451,10 +1451,12 @@
    <string name="wifi_scan_always_available_title">Always allow scanning</string>
    <!-- Checkbox summary for option to toggle scan always available setting -->
    <string name="wifi_scan_always_available_summary">Let Google\'s location service and other apps scan for networks, even when Wi\u2011Fi is off</string>
    <!-- Checkbox title for option to Automatically manage Wi\u2011Fi  [CHAR LIMIT=40] -->
    <string name="wifi_automatically_manage_title">Automatically manage Wi\u2011Fi</string>
    <!-- Checkbox summary for option to Automatically manage Wi\u2011Fi  [CHAR LIMIT=100] -->
    <string name="wifi_automatically_manage_summary">Let <xliff:g id="wifi_assistant">%1$s</xliff:g> manage your Wi\u2011Fi connection</string>
    <!-- Checkbox title for option to connect to open Wi-Fi automatically [CHAR LIMIT=40] -->
    <string name="wifi_automatically_connect_title">Connect to open Wi\u2011Fi automatically</string>
    <!-- Checkbox summary for option to connect to open Wi-Fi automatically  [CHAR LIMIT=100] -->
    <string name="wifi_automatically_connect_summary">Allow a Wi\u2011Fi assistant to automatically rate and connect to open Wi\u2011Fi networks determined to be high quality</string>
    <!-- Dialog title for option to select an app which connects to open Wi-Fi automatically [CHAR LIMIT=40] -->
    <string name="wifi_select_assistant_dialog_title">Select a Wi\u2011Fi assistant</string>
    <!-- Preference title for option to install certificates -->
    <string name="wifi_install_credentials">Install certificates</string>
    <string name="wifi_scan_notify_text_location_on">To improve location accuracy and for other purposes, Google and other apps may scan for nearby networks, even when Wi-Fi is off. If you don\'t want this to happen, go to Advanced &gt; Scanning always available.</string>
+4 −1
Original line number Diff line number Diff line
@@ -312,6 +312,10 @@
        <item name="android:layout">@layout/apn_preference_layout</item>
    </style>

    <style name="AppListSwitchPreference" parent="@*android:style/Preference.Material.DialogPreference">
        <item name="android:widgetLayout">@*android:layout/preference_widget_switch</item>
    </style>

    <style name="TextAppearance.Medium" parent="@android:style/TextAppearance.Material.Medium">
    </style>

@@ -341,5 +345,4 @@
    <style name="Widget.TimePicker" parent="@*android:style/Widget.Material.Light.TimePicker">
        <item name="@android:numbersBackgroundColor">@android:color/white</item>
    </style>

</resources>
+7 −5
Original line number Diff line number Diff line
@@ -30,11 +30,6 @@
            android:summary="@string/wifi_scan_always_available_summary"
            android:persistent="false" />

    <SwitchPreference
            android:key="wifi_assistant"
            android:title="@string/wifi_automatically_manage_title"
            android:persistent="false" />

    <ListPreference
            android:key="sleep_policy"
            android:title="@string/wifi_setting_sleep_policy_title"
@@ -42,6 +37,13 @@
            android:entries="@array/wifi_sleep_policy_entries"
            android:entryValues="@array/wifi_sleep_policy_values" />

    <com.android.settings.AppListSwitchPreference
            android:key="wifi_assistant"
            android:title="@string/wifi_automatically_connect_title"
            android:summary="@string/wifi_automatically_connect_summary"
            android:dialogTitle="@string/wifi_select_assistant_dialog_title"
            android:persistent="false" />

    <ListPreference
            android:key="frequency_band"
            android:title="@string/wifi_setting_frequency_band_title"
+7 −0
Original line number Diff line number Diff line
@@ -67,6 +67,11 @@ public class AppListPreference extends ListPreference {
        }
    }

    public AppListPreference(Context context, AttributeSet attrs,
            int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
    }

    public AppListPreference(Context context, AttributeSet attrs) {
        super(context, attrs);
    }
@@ -105,6 +110,8 @@ public class AppListPreference extends ListPreference {
        setEntryValues(packageNames);
        if (selectedIndex != -1) {
            setValueIndex(selectedIndex);
        } else {
            setValue(null);
        }
    }

+59 −0
Original line number Diff line number Diff line
package com.android.settings;

import android.content.Context;
import android.os.Bundle;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
import android.widget.Checkable;

/**
 * A hybrid of AppListPreference and SwitchPreference, representing a preference which can be on or
 * off but must have a selected value when turned on.
 *
 * It is invalid to show this preference when zero valid apps are present.
 */
public class AppListSwitchPreference extends AppListPreference {
    private static final String TAG = "AppListSwitchPref";

    private Checkable mSwitch;

    public AppListSwitchPreference(Context context, AttributeSet attrs) {
        super(context, attrs, 0, R.style.AppListSwitchPreference);
    }

    @Override
    protected void onBindView(View view) {
        super.onBindView(view);
        mSwitch = (Checkable) view.findViewById(com.android.internal.R.id.switchWidget);
        mSwitch.setChecked(getValue() != null);
    }

    @Override
    protected void showDialog(Bundle state) {
        if (getValue() != null) {
            // Turning off the current value.
            if (callChangeListener(null)) {
                setValue(null);
            }
        } else if (getEntryValues() == null || getEntryValues().length == 0) {
            Log.e(TAG, "Attempting to show dialog with zero entries: " + getKey());
        } else if (getEntryValues().length == 1) {
            // Suppress the dialog and just toggle the preference with the only choice.
            String value = getEntryValues()[0].toString();
            if (callChangeListener(value)) {
                setValue(value);
            }
        } else {
            super.showDialog(state);
        }
    }

    @Override
    public void setValue(String value) {
        super.setValue(value);
        if (mSwitch != null) {
            mSwitch.setChecked(value != null);
        }
    }
}
Loading