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

Commit 2cbd720d authored by Antony Sargent's avatar Antony Sargent
Browse files

Add a feature flag for new version of Network and internet settings page

In addition to adding the flag, this also adds a new xml layout that is
the same as the existing network and internet page, but will begin to be
changed in subsequent CLs. There is also a change in code to use this
new layout when the flag is turned on.

One other change is to make the list of displayed feature flags in
developer options be in sorted order instead of whatever semirandom
order they come out of the map's key set.

Bug: 116349402
Test: Manual (settings_network_and_internet_v2 flag should should up in
Settings -> System -> Developer options -> Feature flags, and those
flags should be in sorted order)

Change-Id: I5520d286efb6bec50ba4ca99f64aeca94f01d533
parent 76da1123
Loading
Loading
Loading
Loading
+100 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2018 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->

<PreferenceScreen
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:settings="http://schemas.android.com/apk/res-auto"
    android:key="network_and_internet_screen"
    android:title="@string/network_dashboard_title"
    settings:initialExpandedChildrenCount="5">

    <com.android.settings.widget.MasterSwitchPreference
        android:fragment="com.android.settings.wifi.WifiSettings"
        android:key="toggle_wifi"
        android:title="@string/wifi_settings"
        android:summary="@string/summary_placeholder"
        android:icon="@drawable/ic_settings_wireless"
        android:order="-30">
        <intent
            android:action="android.settings.WIFI_SETTINGS"
            android:targetClass="Settings$WifiSettingsActivity" />
    </com.android.settings.widget.MasterSwitchPreference>

    <com.android.settingslib.RestrictedPreference
        android:key="mobile_network_settings"
        android:title="@string/network_settings_title"
        android:summary="@string/summary_placeholder"
        android:icon="@drawable/ic_network_cell"
        android:order="-15"
        settings:keywords="@string/keywords_more_mobile_networks"
        settings:userRestriction="no_config_mobile_networks"
        settings:useAdminDisabledSummary="true">
    </com.android.settingslib.RestrictedPreference>

    <com.android.settingslib.RestrictedPreference
        android:fragment="com.android.settings.TetherSettings"
        android:key="tether_settings"
        android:title="@string/tether_settings_title_all"
        android:icon="@drawable/ic_wifi_tethering"
        android:order="-5"
        android:summary="@string/summary_placeholder"
        settings:keywords="@string/keywords_hotspot_tethering"
        settings:userRestriction="no_config_tethering"
        settings:useAdminDisabledSummary="true" />

    <com.android.settingslib.RestrictedPreference
        android:key="manage_mobile_plan"
        android:title="@string/manage_mobile_plan_title"
        android:persistent="false"
        android:order="0"
        settings:userRestriction="no_config_mobile_networks"
        settings:useAdminDisabledSummary="true" />

    <com.android.settingslib.RestrictedSwitchPreference
        android:key="toggle_airplane"
        android:title="@string/airplane_mode"
        android:icon="@drawable/ic_airplanemode_active"
        android:disableDependentsState="true"
        android:order="5"
        settings:controller="com.android.settings.network.AirplaneModePreferenceController"
        settings:platform_slice="true"
        settings:userRestriction="no_airplane_mode"/>

    <Preference
        android:fragment="com.android.settings.ProxySelector"
        android:key="proxy_settings"
        android:title="@string/proxy_settings_title" />

    <com.android.settingslib.RestrictedPreference
        android:fragment="com.android.settings.vpn2.VpnSettings"
        android:key="vpn_settings"
        android:title="@string/vpn_settings_title"
        android:icon="@drawable/ic_vpn_key"
        android:order="10"
        android:summary="@string/summary_placeholder"
        settings:userRestriction="no_config_vpn"
        settings:useAdminDisabledSummary="true" />

    <com.android.settings.network.PrivateDnsModeDialogPreference
        android:key="private_dns_settings"
        android:title="@string/select_private_dns_configuration_title"
        android:order="15"
        android:dialogTitle="@string/select_private_dns_configuration_dialog_title"
        android:dialogLayout="@layout/private_dns_mode_dialog"
        android:positiveButtonText="@string/save"
        android:negativeButtonText="@android:string/cancel" />

</PreferenceScreen>
+1 −0
Original line number Diff line number Diff line
@@ -27,4 +27,5 @@ public class FeatureFlags {
    public static final String MOBILE_NETWORK_V2 = "settings_mobile_network_v2";
    public static final String DATA_USAGE_V2 = "settings_data_usage_v2";
    public static final String WIFI_MAC_RANDOMIZATION = "settings_wifi_mac_randomization";
    public static final String NETWORK_INTERNET_V2 = "settings_network_and_internet_v2";
}
+2 −3
Original line number Diff line number Diff line
@@ -59,8 +59,7 @@ public class FeatureFlagsPreferenceController extends BasePreferenceController
        }
        mGroup.removeAll();
        final Context prefContext = mGroup.getContext();
        for (String feature : featureMap.keySet()) {
            mGroup.addPreference(new FeatureFlagPreference(prefContext, feature));
        }
        featureMap.keySet().stream().sorted().forEach(feature ->
            mGroup.addPreference(new FeatureFlagPreference(prefContext, feature)));
    }
}
+7 −1
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import static com.android.settings.network.MobilePlanPreferenceController
import android.app.Dialog;
import android.content.Context;
import android.provider.SearchIndexableResource;
import android.util.FeatureFlagUtils;
import android.util.Log;

import androidx.appcompat.app.AlertDialog;
@@ -28,6 +29,7 @@ import androidx.fragment.app.Fragment;

import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
import com.android.settings.core.FeatureFlags;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.network.MobilePlanPreferenceController.MobilePlanPreferenceHost;
import com.android.settings.search.BaseSearchIndexProvider;
@@ -59,8 +61,12 @@ public class NetworkDashboardFragment extends DashboardFragment implements

    @Override
    protected int getPreferenceScreenResId() {
        if (FeatureFlagUtils.isEnabled(getContext(), FeatureFlags.NETWORK_INTERNET_V2)) {
            return R.xml.network_and_internet_v2;
        } else {
            return R.xml.network_and_internet;
        }
    }

    @Override
    public void onAttach(Context context) {