Clean up WifiDataUsageSummaryPreferenceController
Which is legacy and not finished implemented. Bug: 295260929 Test: unit test Test: robo test Test: manual - on Mobile Settings page Test: manual - on Network details page Change-Id: I30ac639c1ba285a74038d5413b63e2c31c6cc8ba
This commit is contained in:
@@ -17,14 +17,10 @@
|
||||
package com.android.settings.datausage;
|
||||
|
||||
import android.annotation.AttrRes;
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Typeface;
|
||||
import android.icu.text.MessageFormat;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkTemplate;
|
||||
import android.os.Bundle;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableString;
|
||||
import android.text.TextUtils;
|
||||
@@ -32,7 +28,6 @@ import android.text.format.Formatter;
|
||||
import android.text.style.AbsoluteSizeSpan;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
@@ -42,7 +37,6 @@ import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceViewHolder;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.SubSettingLauncher;
|
||||
import com.android.settingslib.Utils;
|
||||
import com.android.settingslib.net.DataUsageController;
|
||||
import com.android.settingslib.utils.StringUtil;
|
||||
@@ -77,7 +71,6 @@ public class DataUsageSummaryPreference extends Preference {
|
||||
/** Name of carrier, or null if not available */
|
||||
private CharSequence mCarrierName;
|
||||
private CharSequence mLimitInfoText;
|
||||
private Intent mLaunchIntent;
|
||||
|
||||
/** Progress to display on ProgressBar */
|
||||
private float mProgress;
|
||||
@@ -92,11 +85,6 @@ public class DataUsageSummaryPreference extends Preference {
|
||||
/** The number of bytes used since the start of the cycle. */
|
||||
private long mDataplanUse;
|
||||
|
||||
/** WiFi only mode */
|
||||
private boolean mWifiMode;
|
||||
private String mUsagePeriod;
|
||||
private boolean mSingleWifi; // Shows only one specified WiFi network usage
|
||||
|
||||
public DataUsageSummaryPreference(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
setLayoutResource(R.layout.data_usage_summary_preference);
|
||||
@@ -115,12 +103,11 @@ public class DataUsageSummaryPreference extends Preference {
|
||||
}
|
||||
|
||||
public void setUsageInfo(long cycleEnd, long snapshotTime, CharSequence carrierName,
|
||||
int numPlans, Intent launchIntent) {
|
||||
int numPlans) {
|
||||
mCycleEndTimeMs = cycleEnd;
|
||||
mSnapshotTimeMs = snapshotTime;
|
||||
mCarrierName = carrierName;
|
||||
mNumPlans = numPlans;
|
||||
mLaunchIntent = launchIntent;
|
||||
notifyChanged();
|
||||
}
|
||||
|
||||
@@ -144,13 +131,6 @@ public class DataUsageSummaryPreference extends Preference {
|
||||
notifyChanged();
|
||||
}
|
||||
|
||||
void setWifiMode(boolean isWifiMode, String usagePeriod, boolean isSingleWifi) {
|
||||
mWifiMode = isWifiMode;
|
||||
mUsagePeriod = usagePeriod;
|
||||
mSingleWifi = isSingleWifi;
|
||||
notifyChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(PreferenceViewHolder holder) {
|
||||
super.onBindViewHolder(holder);
|
||||
@@ -171,66 +151,13 @@ public class DataUsageSummaryPreference extends Preference {
|
||||
|
||||
TextView usageTitle = getUsageTitle(holder);
|
||||
TextView carrierInfo = getCarrierInfo(holder);
|
||||
Button launchButton = getLaunchButton(holder);
|
||||
TextView limitInfo = getDataLimits(holder);
|
||||
|
||||
if (mWifiMode && mSingleWifi) {
|
||||
updateCycleTimeText(holder);
|
||||
|
||||
usageTitle.setVisibility(View.GONE);
|
||||
launchButton.setVisibility(View.GONE);
|
||||
carrierInfo.setVisibility(View.GONE);
|
||||
|
||||
limitInfo.setVisibility(TextUtils.isEmpty(mLimitInfoText) ? View.GONE : View.VISIBLE);
|
||||
limitInfo.setText(mLimitInfoText);
|
||||
} else if (mWifiMode) {
|
||||
usageTitle.setText(R.string.data_usage_wifi_title);
|
||||
usageTitle.setVisibility(View.VISIBLE);
|
||||
TextView cycleTime = getCycleTime(holder);
|
||||
cycleTime.setText(mUsagePeriod);
|
||||
carrierInfo.setVisibility(View.GONE);
|
||||
limitInfo.setVisibility(View.GONE);
|
||||
|
||||
final long usageLevel = getHistoricalUsageLevel();
|
||||
if (usageLevel > 0L) {
|
||||
launchButton.setOnClickListener((view) -> {
|
||||
launchWifiDataUsage(getContext());
|
||||
});
|
||||
} else {
|
||||
launchButton.setEnabled(false);
|
||||
}
|
||||
launchButton.setText(R.string.launch_wifi_text);
|
||||
launchButton.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
usageTitle.setVisibility(mNumPlans > 1 ? View.VISIBLE : View.GONE);
|
||||
updateCycleTimeText(holder);
|
||||
updateCarrierInfo(carrierInfo);
|
||||
if (mLaunchIntent != null) {
|
||||
launchButton.setOnClickListener((view) -> {
|
||||
getContext().startActivity(mLaunchIntent);
|
||||
});
|
||||
launchButton.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
launchButton.setVisibility(View.GONE);
|
||||
}
|
||||
limitInfo.setVisibility(
|
||||
TextUtils.isEmpty(mLimitInfoText) ? View.GONE : View.VISIBLE);
|
||||
limitInfo.setText(mLimitInfoText);
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
static void launchWifiDataUsage(Context context) {
|
||||
final Bundle args = new Bundle(1);
|
||||
args.putParcelable(DataUsageList.EXTRA_NETWORK_TEMPLATE,
|
||||
new NetworkTemplate.Builder(NetworkTemplate.MATCH_WIFI).build());
|
||||
args.putInt(DataUsageList.EXTRA_NETWORK_TYPE, ConnectivityManager.TYPE_WIFI);
|
||||
final SubSettingLauncher launcher = new SubSettingLauncher(context)
|
||||
.setArguments(args)
|
||||
.setDestination(DataUsageList.class.getName())
|
||||
.setSourceMetricsCategory(SettingsEnums.PAGE_UNKNOWN);
|
||||
launcher.setTitleRes(R.string.wifi_data_usage);
|
||||
launcher.launch();
|
||||
usageTitle.setVisibility(mNumPlans > 1 ? View.VISIBLE : View.GONE);
|
||||
updateCycleTimeText(holder);
|
||||
updateCarrierInfo(carrierInfo);
|
||||
limitInfo.setVisibility(TextUtils.isEmpty(mLimitInfoText) ? View.GONE : View.VISIBLE);
|
||||
limitInfo.setText(mLimitInfoText);
|
||||
}
|
||||
|
||||
private void updateDataUsageLabels(PreferenceViewHolder holder) {
|
||||
@@ -403,11 +330,6 @@ public class DataUsageSummaryPreference extends Preference {
|
||||
return (TextView) holder.findViewById(R.id.data_remaining_view);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
protected Button getLaunchButton(PreferenceViewHolder holder) {
|
||||
return (Button) holder.findViewById(R.id.launch_mdp_app_button);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
protected LinearLayout getLabelBar(PreferenceViewHolder holder) {
|
||||
return (LinearLayout) holder.findViewById(R.id.label_bar);
|
||||
|
||||
Reference in New Issue
Block a user