Remove "and" to align with the other menu items. Fixes: 183642373 Test: robotests & visual Change-Id: I4d48b9c5a867d7afa04b7c3f0d6495b455df6621
94 lines
3.6 KiB
Java
94 lines
3.6 KiB
Java
/*
|
|
* 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.
|
|
*/
|
|
|
|
package com.android.settings.network;
|
|
|
|
import android.content.Context;
|
|
import android.text.BidiFormatter;
|
|
import android.text.TextUtils;
|
|
|
|
import com.android.settings.R;
|
|
import com.android.settings.Utils;
|
|
import com.android.settings.core.BasePreferenceController;
|
|
import com.android.settings.wifi.WifiPrimarySwitchPreferenceController;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
public class TopLevelNetworkEntryPreferenceController extends BasePreferenceController {
|
|
|
|
private final WifiPrimarySwitchPreferenceController mWifiPreferenceController;
|
|
private final MobileNetworkPreferenceController mMobileNetworkPreferenceController;
|
|
private final TetherPreferenceController mTetherPreferenceController;
|
|
|
|
public TopLevelNetworkEntryPreferenceController(Context context, String preferenceKey) {
|
|
super(context, preferenceKey);
|
|
mMobileNetworkPreferenceController = new MobileNetworkPreferenceController(mContext);
|
|
mTetherPreferenceController = new TetherPreferenceController(
|
|
mContext, null /* lifecycle */);
|
|
mWifiPreferenceController = new WifiPrimarySwitchPreferenceController(
|
|
mContext, null /* metrics */);
|
|
}
|
|
|
|
@Override
|
|
public int getAvailabilityStatus() {
|
|
return Utils.isDemoUser(mContext) ? UNSUPPORTED_ON_DEVICE : AVAILABLE;
|
|
}
|
|
|
|
@Override
|
|
public CharSequence getSummary() {
|
|
final String wifiSummary = BidiFormatter.getInstance()
|
|
.unicodeWrap(mContext.getString(R.string.wifi_settings_title));
|
|
final String mobileSummary = mContext.getString(
|
|
R.string.network_dashboard_summary_mobile);
|
|
final String dataUsageSummary = mContext.getString(
|
|
R.string.network_dashboard_summary_data_usage);
|
|
final String hotspotSummary = mContext.getString(
|
|
R.string.network_dashboard_summary_hotspot);
|
|
|
|
final List<String> summaries = new ArrayList<>();
|
|
if (mWifiPreferenceController.isAvailable()
|
|
&& !TextUtils.isEmpty(wifiSummary)) {
|
|
summaries.add(wifiSummary);
|
|
}
|
|
if (mMobileNetworkPreferenceController.isAvailable() && !TextUtils.isEmpty(mobileSummary)) {
|
|
summaries.add(mobileSummary);
|
|
}
|
|
if (!TextUtils.isEmpty(dataUsageSummary)) {
|
|
summaries.add(dataUsageSummary);
|
|
}
|
|
if (mTetherPreferenceController.isAvailable()
|
|
&& !TextUtils.isEmpty(hotspotSummary)) {
|
|
summaries.add(hotspotSummary);
|
|
}
|
|
return concatSummaries(summaries);
|
|
}
|
|
|
|
private CharSequence concatSummaries(List<String> summaries) {
|
|
if (summaries.isEmpty()) {
|
|
return mContext.getText(R.string.summary_placeholder);
|
|
}
|
|
|
|
String summary = summaries.get(0);
|
|
final int summary_size = summaries.size();
|
|
for (int i = 1; i < summary_size; i++) {
|
|
summary = mContext.getString(R.string.join_two_unrelated_items, summary,
|
|
summaries.get(i));
|
|
}
|
|
return summary;
|
|
}
|
|
}
|