Misc fix on network & internet screen for developer preview

- Move wifi calling into wifi preference screen
- Update tethering setting title
- Ripple for master swtich preference only apply on the left half.
- Move network reset to action bar overflow menu

Fix: 34974598
Fix: 34976385
Test: RunSettingsRoboTests
Change-Id: I0e11843efc52a0042784a4da46b7ac81fcf16138
This commit is contained in:
Fan Zhang
2017-02-06 14:40:20 -08:00
parent 99f0b44440
commit 56199e9487
13 changed files with 280 additions and 78 deletions

View File

@@ -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);

View File

@@ -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());
}
}

View File

@@ -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;
}
}