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

Commit 71b98744 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Update Network & internet->Wi-Fi to use MasterSwitchPreference."

parents f8f5f46f c4c9f4d5
Loading
Loading
Loading
Loading
+0 −14
Original line number Diff line number Diff line
@@ -3060,20 +3060,6 @@
                       android:value="com.android.settings.network.NetworkDashboardFragment"/>
        </activity>

        <activity-alias android:name="WifiDashboardAlias"
                        android:targetActivity="Settings$WifiSettingsActivity"
                        android:configChanges="orientation|keyboardHidden|screenSize">
            <intent-filter android:priority="20">
                <action android:name="com.android.settings.action.SETTINGS" />
            </intent-filter>
            <meta-data android:name="com.android.settings.category"
                       android:value="com.android.settings.category.ia.wireless" />
            <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
                       android:value="com.android.settings.wifi.WifiSettings" />
            <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
                       android:value="true" />
        </activity-alias>

        <activity-alias android:name="DataUsageDashboardAlias"
                        android:targetActivity="Settings$DataUsageSummaryActivity">
            <intent-filter android:priority="10">
+12 −1
Original line number Diff line number Diff line
@@ -19,12 +19,23 @@
    xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
    android:title="@string/network_dashboard_title">

    <com.android.settings.widget.MasterSwitchPreference
        android:fragment="com.android.settings.wifi.WifiSettings"
        android:key="toggle_wifi"
        android:title="@string/wifi_settings"
        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>

    <SwitchPreference
        android:key="toggle_airplane"
        android:title="@string/airplane_mode"
        android:icon="@drawable/ic_airplanemode_active"
        android:disableDependentsState="true"
        android:order="-30"/>
        android:order="5"/>

    <com.android.settingslib.RestrictedPreference
        android:key="mobile_network_settings"
+8 −5
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.content.IntentFilter;
import android.os.Handler;
import android.os.Message;
import android.provider.Settings;
import android.widget.Switch;
import android.widget.Toast;

import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
@@ -41,6 +42,7 @@ import com.android.settingslib.bluetooth.LocalBluetoothManager;
 * preference reflects the current state.
 */
public final class BluetoothEnabler implements SwitchWidgetController.OnSwitchChangeListener {
    private final Switch mSwitch;
    private final SwitchWidgetController mSwitchWidget;
    private final MetricsFeatureProvider mMetricsFeatureProvider;
    private Context mContext;
@@ -79,6 +81,7 @@ public final class BluetoothEnabler implements SwitchWidgetController.OnSwitchCh
        mContext = context;
        mMetricsFeatureProvider = metricsFeatureProvider;
        mSwitchWidget = switchWidget;
        mSwitch = mSwitchWidget.getSwitch();
        mSwitchWidget.setListener(this);
        mValidListener = false;

@@ -92,11 +95,11 @@ public final class BluetoothEnabler implements SwitchWidgetController.OnSwitchCh
        mIntentFilter = new IntentFilter(BluetoothAdapter.ACTION_STATE_CHANGED);
    }

    public void setupSwitchBar() {
    public void setupSwitchController() {
        mSwitchWidget.setupView();
    }

    public void teardownSwitchBar() {
    public void teardownSwitchController() {
        mSwitchWidget.teardownView();
    }

@@ -184,7 +187,7 @@ public final class BluetoothEnabler implements SwitchWidgetController.OnSwitchCh
                !WirelessUtils.isRadioAllowed(mContext, Settings.Global.RADIO_BLUETOOTH)) {
            Toast.makeText(mContext, R.string.wifi_in_airplane_mode, Toast.LENGTH_SHORT).show();
            // Reset switch to off
            mSwitchWidget.setChecked(false);
            mSwitch.setChecked(false);
            return false;
        }

@@ -196,8 +199,8 @@ public final class BluetoothEnabler implements SwitchWidgetController.OnSwitchCh
            // a) The switch should be OFF but it should still be togglable (enabled = True)
            // b) The switch bar should have OFF text.
            if (isChecked && !status) {
                mSwitchWidget.setChecked(false);
                mSwitchWidget.setEnabled(true);
                mSwitch.setChecked(false);
                mSwitch.setEnabled(true);
                mSwitchWidget.updateTitle(false);
                return false;
            }
+6 −6
Original line number Diff line number Diff line
@@ -25,12 +25,13 @@ import com.android.settings.core.lifecycle.events.OnResume;
import com.android.settings.core.lifecycle.events.OnStart;
import com.android.settings.core.lifecycle.events.OnStop;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.widget.SummaryUpdater.OnSummaryChangeListener;
import com.android.settings.widget.MasterSwitchPreference;
import com.android.settings.widget.MasterSwitchController;
import com.android.settingslib.bluetooth.LocalBluetoothManager;

public class BluetoothMasterSwitchPreferenceController extends PreferenceController
        implements BluetoothSummaryHelper.OnSummaryChangeListener,
        implements OnSummaryChangeListener,
        LifecycleObserver, OnResume, OnPause, OnStart, OnStop {

    private static final String KEY_TOGGLE_BLUETOOTH = "toggle_bluetooth";
@@ -38,14 +39,13 @@ public class BluetoothMasterSwitchPreferenceController extends PreferenceControl
    private LocalBluetoothManager mBluetoothManager;
    private MasterSwitchPreference mBtPreference;
    private BluetoothEnabler mBluetoothEnabler;
    private BluetoothSummaryHelper mSummaryHelper;
    private BluetoothSummaryUpdater mSummaryUpdater;

    public BluetoothMasterSwitchPreferenceController(Context context,
            LocalBluetoothManager bluetoothManager) {
        super(context);
        mBluetoothManager = bluetoothManager;
        mSummaryHelper = new BluetoothSummaryHelper(mContext, mBluetoothManager);
        mSummaryHelper.setOnSummaryChangeListener(this);
        mSummaryUpdater = new BluetoothSummaryUpdater(mContext, this, mBluetoothManager);
    }

    @Override
@@ -68,12 +68,12 @@ public class BluetoothMasterSwitchPreferenceController extends PreferenceControl
    }

    public void onResume() {
        mSummaryHelper.setListening(true);
        mSummaryUpdater.register(true);
    }

    @Override
    public void onPause() {
        mSummaryHelper.setListening(false);
        mSummaryUpdater.register(false);
    }

    @Override
+6 −7
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@ import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.LinkifyUtils;
import com.android.settings.R;
import com.android.settings.SettingsActivity;
import com.android.settings.bluetooth.BluetoothSummaryHelper.OnSummaryChangeListener;
import com.android.settings.widget.SummaryUpdater.OnSummaryChangeListener;
import com.android.settings.dashboard.SummaryLoader;
import com.android.settings.location.ScanningSettings;
import com.android.settings.search.BaseSearchIndexProvider;
@@ -150,14 +150,14 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment implem

        mBluetoothEnabler = new BluetoothEnabler(activity, new SwitchBarController(mSwitchBar),
            mMetricsFeatureProvider, Utils.getLocalBtManager(activity));
        mBluetoothEnabler.setupSwitchBar();
        mBluetoothEnabler.setupSwitchController();
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();

        mBluetoothEnabler.teardownSwitchBar();
        mBluetoothEnabler.teardownSwitchController();
    }

    @Override
@@ -516,20 +516,19 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment implem
        private final SummaryLoader mSummaryLoader;

        @VisibleForTesting
        BluetoothSummaryHelper mSummaryHelper;
        BluetoothSummaryUpdater mSummaryUpdater;

        public SummaryProvider(Context context, SummaryLoader summaryLoader,
                LocalBluetoothManager bluetoothManager) {
            mBluetoothManager = bluetoothManager;
            mContext = context;
            mSummaryLoader = summaryLoader;
            mSummaryHelper = new BluetoothSummaryHelper(mContext, mBluetoothManager);
            mSummaryHelper.setOnSummaryChangeListener(this);
            mSummaryUpdater = new BluetoothSummaryUpdater(mContext, this, mBluetoothManager);
        }

        @Override
        public void setListening(boolean listening) {
            mSummaryHelper.setListening(listening);
            mSummaryUpdater.register(listening);
        }

        @Override
Loading