Merge "Misc fix on network & internet screen for developer preview"
This commit is contained in:
committed by
Android (Google) Code Review
commit
14c2050330
@@ -23,7 +23,6 @@ import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.os.Bundle;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
@@ -31,14 +30,12 @@ import android.provider.SearchIndexableResource;
|
||||
import android.provider.Settings;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.PreferenceScreen;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.settings.network.AirplaneModePreferenceController;
|
||||
import com.android.settings.network.MobileNetworkPreferenceController;
|
||||
import com.android.settings.network.MobilePlanPreferenceController;
|
||||
import com.android.settings.network.NetworkResetPreferenceController;
|
||||
import com.android.settings.network.ProxyPreferenceController;
|
||||
import com.android.settings.network.TetherPreferenceController;
|
||||
import com.android.settings.network.VpnPreferenceController;
|
||||
@@ -47,7 +44,6 @@ import com.android.settings.nfc.NfcPreferenceController;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settings.search.Indexable;
|
||||
import com.android.settingslib.RestrictedLockUtils;
|
||||
import com.android.settingslib.RestrictedPreference;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -69,7 +65,6 @@ public class WirelessSettings extends SettingsPreferenceFragment implements Inde
|
||||
private TetherPreferenceController mTetherPreferenceController;
|
||||
private MobileNetworkPreferenceController mMobileNetworkPreferenceController;
|
||||
private VpnPreferenceController mVpnPreferenceController;
|
||||
private NetworkResetPreferenceController mNetworkResetPreferenceController;
|
||||
private WifiCallingPreferenceController mWifiCallingPreferenceController;
|
||||
private ProxyPreferenceController mProxyPreferenceController;
|
||||
private MobilePlanPreferenceController mMobilePlanPreferenceController;
|
||||
@@ -150,7 +145,6 @@ public class WirelessSettings extends SettingsPreferenceFragment implements Inde
|
||||
mMobileNetworkPreferenceController = new MobileNetworkPreferenceController(activity);
|
||||
mVpnPreferenceController = new VpnPreferenceController(activity);
|
||||
mWifiCallingPreferenceController = new WifiCallingPreferenceController(activity);
|
||||
mNetworkResetPreferenceController = new NetworkResetPreferenceController(activity);
|
||||
mProxyPreferenceController = new ProxyPreferenceController(activity);
|
||||
mMobilePlanPreferenceController = new MobilePlanPreferenceController(activity, this);
|
||||
mNfcPreferenceController = new NfcPreferenceController(activity);
|
||||
@@ -162,7 +156,6 @@ public class WirelessSettings extends SettingsPreferenceFragment implements Inde
|
||||
mMobileNetworkPreferenceController.displayPreference(screen);
|
||||
mVpnPreferenceController.displayPreference(screen);
|
||||
mWifiCallingPreferenceController.displayPreference(screen);
|
||||
mNetworkResetPreferenceController.displayPreference(screen);
|
||||
mProxyPreferenceController.displayPreference(screen);
|
||||
mMobilePlanPreferenceController.displayPreference(screen);
|
||||
mNfcPreferenceController.displayPreference(screen);
|
||||
@@ -270,7 +263,6 @@ public class WirelessSettings extends SettingsPreferenceFragment implements Inde
|
||||
|
||||
new TetherPreferenceController(context).updateNonIndexableKeys(result);
|
||||
new WifiCallingPreferenceController(context).updateNonIndexableKeys(result);
|
||||
new NetworkResetPreferenceController(context).updateNonIndexableKeys(result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@@ -20,6 +20,8 @@ import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.provider.SearchIndexableResource;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto;
|
||||
import com.android.settings.R;
|
||||
@@ -42,6 +44,8 @@ public class NetworkDashboardFragment extends DashboardFragment implements
|
||||
|
||||
private static final String TAG = "NetworkDashboardFrag";
|
||||
|
||||
private NetworkResetActionMenuController mNetworkResetController;
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
return MetricsProto.MetricsEvent.SETTINGS_NETWORK_CATEGORY;
|
||||
@@ -57,6 +61,18 @@ public class NetworkDashboardFragment extends DashboardFragment implements
|
||||
return R.xml.network_and_internet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
mNetworkResetController = new NetworkResetActionMenuController(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
mNetworkResetController.buildMenuItem(menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<PreferenceController> getPreferenceControllers(Context context) {
|
||||
final AirplaneModePreferenceController airplaneModePreferenceController =
|
||||
@@ -64,7 +80,7 @@ public class NetworkDashboardFragment extends DashboardFragment implements
|
||||
final MobilePlanPreferenceController mobilePlanPreferenceController =
|
||||
new MobilePlanPreferenceController(context, this);
|
||||
final WifiMasterSwitchPreferenceController wifiPreferenceController =
|
||||
new WifiMasterSwitchPreferenceController(context, mMetricsFeatureProvider);
|
||||
new WifiMasterSwitchPreferenceController(context, mMetricsFeatureProvider);
|
||||
final Lifecycle lifecycle = getLifecycle();
|
||||
lifecycle.addObserver(airplaneModePreferenceController);
|
||||
lifecycle.addObserver(mobilePlanPreferenceController);
|
||||
@@ -75,8 +91,6 @@ public class NetworkDashboardFragment extends DashboardFragment implements
|
||||
controllers.add(new MobileNetworkPreferenceController(context));
|
||||
controllers.add(new TetherPreferenceController(context));
|
||||
controllers.add(new VpnPreferenceController(context));
|
||||
controllers.add(new WifiCallingPreferenceController(context));
|
||||
controllers.add(new NetworkResetPreferenceController(context));
|
||||
controllers.add(new ProxyPreferenceController(context));
|
||||
controllers.add(mobilePlanPreferenceController);
|
||||
controllers.add(wifiPreferenceController);
|
||||
|
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (C) 2017 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.
|
||||
*/
|
||||
|
||||
package com.android.settings.network;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
import android.support.annotation.VisibleForTesting;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.ResetNetwork;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settingslib.RestrictedLockUtils;
|
||||
|
||||
public class NetworkResetActionMenuController {
|
||||
|
||||
private static final int MENU_NETWORK_RESET = Menu.FIRST + 200;
|
||||
private final Context mContext;
|
||||
|
||||
public NetworkResetActionMenuController(Context context) {
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
public void buildMenuItem(Menu menu) {
|
||||
MenuItem item = null;
|
||||
if (isAvailable() && menu != null) {
|
||||
item = menu.add(0, MENU_NETWORK_RESET, 0, R.string.reset_network_title);
|
||||
}
|
||||
if (item != null) {
|
||||
item.setOnMenuItemClickListener(target -> {
|
||||
Utils.startWithFragment(mContext, ResetNetwork.class.getName(), null, null,
|
||||
0, R.string.reset_network_title, null);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
|
||||
boolean isAvailable() {
|
||||
return !RestrictedLockUtils.hasBaseUserRestriction(mContext,
|
||||
UserManager.DISALLOW_NETWORK_RESET, UserHandle.myUserId());
|
||||
}
|
||||
}
|
@@ -1,44 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2016 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.
|
||||
*/
|
||||
package com.android.settings.network;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
import android.support.v7.preference.Preference;
|
||||
|
||||
import com.android.settings.core.PreferenceController;
|
||||
import com.android.settingslib.RestrictedLockUtils;
|
||||
|
||||
public class NetworkResetPreferenceController extends PreferenceController {
|
||||
|
||||
private static final String KEY_NETWORK_RESET = "network_reset";
|
||||
|
||||
public NetworkResetPreferenceController(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable() {
|
||||
return !RestrictedLockUtils.hasBaseUserRestriction(mContext,
|
||||
UserManager.DISALLOW_NETWORK_RESET, UserHandle.myUserId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPreferenceKey() {
|
||||
return KEY_NETWORK_RESET;
|
||||
}
|
||||
}
|
@@ -110,6 +110,7 @@ public class MasterSwitchPreference extends Preference {
|
||||
}
|
||||
|
||||
private void init() {
|
||||
setLayoutResource(R.layout.preference_master_switch);
|
||||
setWidgetLayoutResource(R.layout.preference_widget_master_switch);
|
||||
}
|
||||
}
|
||||
|
@@ -25,6 +25,7 @@ import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.PreferenceController;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.network.WifiCallingPreferenceController;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settings.search.Indexable;
|
||||
import com.android.settings.wifi.p2p.WifiP2pPreferenceController;
|
||||
@@ -71,6 +72,7 @@ public class ConfigureWifiSettings extends DashboardFragment {
|
||||
controllers.add(new WifiWakeupPreferenceController(context, getLifecycle()));
|
||||
controllers.add(new WifiSleepPolicyPreferenceController(context));
|
||||
controllers.add(new WifiP2pPreferenceController(context, getLifecycle(), mWifiManager));
|
||||
controllers.add(new WifiCallingPreferenceController(context));
|
||||
controllers.add(new WpsPreferenceController(
|
||||
context, getLifecycle(), mWifiManager, getFragmentManager()));
|
||||
return controllers;
|
||||
|
Reference in New Issue
Block a user