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

Commit 2c0861e6 authored by jackqdyulei's avatar jackqdyulei
Browse files

Remove AdvancedOptionsPreference

This is used to show "Advanced" preference in telephony package.
Remove it since we have better way to do it in settings.

Bug: 114749736
Test: Manual
Change-Id: I3008bf856b8f42ba10ab26cb81d35a9370601c58
parent 106ae1d7
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -10245,8 +10245,6 @@
    <!-- Dialog title for CDMA subscription [CHAR LIMIT=30] -->
    <string name="cdma_subscription_dialogtitle">subscription</string>
    <!-- Mobile network settings screen, Advanced button to show more items when clicked [CHAR LIMIT=50] -->
    <string name="advanced_options_title">Advanced</string>
    <!-- Title to register automatically [CHAR LIMIT=NONE] -->
    <string name="register_automatically">Automatic registration\u2026</string>
    <!-- Mobile network settings screen, dialog message title when user selects the Data roaming check box [CHAR LIMIT=120] -->
+4 −4
Original line number Diff line number Diff line
@@ -13,7 +13,10 @@
     See the License for the specific language governing permissions and
     limitations under the License.
-->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceScreen
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:settings="http://schemas.android.com/apk/res-auto"
    settings:initialExpandedChildrenCount="4">

    <PreferenceScreen
        android:key="cdma_lte_data_service_key"
@@ -36,9 +39,6 @@
        android:key="data_usage_summary"
        android:title="@string/data_usage_title" />

    <com.android.settings.mobilenetwork.AdvancedOptionsPreference
        android:key="advanced_options"/>

    <SwitchPreference
        android:key="enhanced_4g_lte"
        android:title="@string/enhanced_4g_lte_mode_title"
+0 −36
Original line number Diff line number Diff line
/*
 * 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.mobilenetwork;

import android.content.Context;
import androidx.preference.Preference;
import androidx.preference.PreferenceViewHolder;

import android.util.AttributeSet;
import android.widget.TextView;

import com.android.settings.R;

/**
 * Customized preference class representing the "Advanced" button that expands to fields that
 * are hidden by default.
 */
//TODO(b/114749736): Change it back to normal preference
public class AdvancedOptionsPreference extends Preference {
    public AdvancedOptionsPreference(Context context, AttributeSet attrs) {
        super(context, attrs);
    }
}
 No newline at end of file
+7 −8
Original line number Diff line number Diff line
@@ -47,16 +47,15 @@ public class DataUsagePreference extends Preference {
     * initialize which subID it connects to.
     */
    public void initialize(int subId) {
        Activity activity = (Activity) getContext();

        final Context context = getContext();
        mSubId = subId;
        mTemplate = getNetworkTemplate(activity, subId);
        mTemplate = getNetworkTemplate(context, subId);

        DataUsageController controller = new DataUsageController(activity);
        DataUsageController controller = new DataUsageController(context);

        DataUsageController.DataUsageInfo usageInfo = controller.getDataUsageInfo(mTemplate);
        setSummary(activity.getString(R.string.data_usage_template,
                Formatter.formatFileSize(activity, usageInfo.usageLevel), usageInfo.period));
        setSummary(context.getString(R.string.data_usage_template,
                Formatter.formatFileSize(context, usageInfo.usageLevel), usageInfo.period));
        setIntent(getIntent());
    }

@@ -70,8 +69,8 @@ public class DataUsagePreference extends Preference {
        return intent;
    }

    private NetworkTemplate getNetworkTemplate(Activity activity, int subId) {
        TelephonyManager tm = (TelephonyManager) activity
    private NetworkTemplate getNetworkTemplate(Context context, int subId) {
        TelephonyManager tm = (TelephonyManager) context
                .getSystemService(Context.TELEPHONY_SERVICE);
        NetworkTemplate mobileAll = NetworkTemplate.buildTemplateMobileAll(
                tm.getSubscriberId(subId));
+2 −31
Original line number Diff line number Diff line
@@ -146,7 +146,6 @@ public class MobileNetworkFragment extends DashboardFragment implements
    private int mSubId;

    //UI objects
    private AdvancedOptionsPreference mAdvancedOptions;
    private ListPreference mButtonPreferredNetworkMode;
    private ListPreference mButtonEnabledNetworks;
    private RestrictedSwitchPreference mButtonDataRoam;
@@ -167,7 +166,6 @@ public class MobileNetworkFragment extends DashboardFragment implements
    private ImsManager mImsMgr;
    private MyHandler mHandler;
    private boolean mOkClicked;
    private boolean mExpandAdvancedFields;

    //GsmUmts options and Cdma options
    GsmUmtsOptions mGsmUmtsOptions;
@@ -302,10 +300,6 @@ public class MobileNetworkFragment extends DashboardFragment implements
        } else if (preference == mWiFiCallingPref || preference == mVideoCallingPref
                || preference == mMobileDataPref || preference == mDataUsagePref) {
            return false;
        } else if (preference == mAdvancedOptions) {
            mExpandAdvancedFields = true;
            updateBody();
            return true;
        } else {
            // if the button is anything but the simple toggle preference,
            // we'll need to disable all preferences to reject all click
@@ -389,15 +383,6 @@ public class MobileNetworkFragment extends DashboardFragment implements
        mPhoneStateListener.updateSubscriptionId(mSubId);
    }

    @Override
    public void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);

        // If advanced fields are already expanded, we save it and expand it
        // when it's re-created.
        outState.putBoolean(EXPAND_ADVANCED_FIELDS, mExpandAdvancedFields);
    }

    @Override
    public void onCreate(Bundle icicle) {
        Log.i(LOG_TAG, "onCreate:+");
@@ -416,12 +401,6 @@ public class MobileNetworkFragment extends DashboardFragment implements
                Context.TELEPHONY_SERVICE);
        mCarrierConfigManager = new CarrierConfigManager(getContext());

        if (icicle != null) {
            mExpandAdvancedFields = icicle.getBoolean(EXPAND_ADVANCED_FIELDS, false);
        } else if (getIntent().getBooleanExtra(EXPAND_EXTRA, false)) {
            mExpandAdvancedFields = true;
        }

        mButton4glte = (SwitchPreference)findPreference(BUTTON_4G_LTE_KEY);
        mButton4glte.setOnPreferenceChangeListener(this);

@@ -450,8 +429,6 @@ public class MobileNetworkFragment extends DashboardFragment implements
                BUTTON_PREFERED_NETWORK_MODE);
        mButtonEnabledNetworks = (ListPreference) prefSet.findPreference(
                BUTTON_ENABLED_NETWORKS_KEY);
        mAdvancedOptions = (AdvancedOptionsPreference) prefSet.findPreference(
                BUTTON_ADVANCED_OPTIONS_KEY);
        mButtonDataRoam.setOnPreferenceChangeListener(this);

        mLteDataServicePref = prefSet.findPreference(BUTTON_CDMA_LTE_DATA_SERVICE_KEY);
@@ -637,11 +614,7 @@ public class MobileNetworkFragment extends DashboardFragment implements
        updateBodyBasicFields(activity, prefSet, mSubId, hasActiveSubscriptions);

        if (hasActiveSubscriptions) {
            if (mExpandAdvancedFields) {
            updateBodyAdvancedFields(activity, prefSet, mSubId, hasActiveSubscriptions);
            } else {
                prefSet.addPreference(mAdvancedOptions);
            }
        } else {
            // Shows the "Carrier" preference that allows user to add a e-sim profile.
            if (MobileNetworkUtils.showEuiccSettings(getContext())) {
@@ -1740,7 +1713,7 @@ public class MobileNetworkFragment extends DashboardFragment implements
        // open the list dialog. When a value is chosen, another MetricsEvent is logged with
        // new value in onPreferenceChange.
        if (preference == mLteDataServicePref || preference == mDataUsagePref
                || preference == mEuiccSettingsPref || preference == mAdvancedOptions
                || preference == mEuiccSettingsPref
                || preference == mWiFiCallingPref || preference == mButtonPreferredNetworkMode
                || preference == mButtonEnabledNetworks
                || preference == preferenceScreen.findPreference(BUTTON_CDMA_SYSTEM_SELECT_KEY)
@@ -1786,8 +1759,6 @@ public class MobileNetworkFragment extends DashboardFragment implements
            return MetricsProto.MetricsEvent.ACTION_MOBILE_NETWORK_DATA_USAGE;
        } else if (preference == mLteDataServicePref) {
            return MetricsProto.MetricsEvent.ACTION_MOBILE_NETWORK_SET_UP_DATA_SERVICE;
        } else if (preference == mAdvancedOptions) {
            return MetricsProto.MetricsEvent.ACTION_MOBILE_NETWORK_EXPAND_ADVANCED_FIELDS;
        } else if (preference == mButton4glte) {
            return MetricsProto.MetricsEvent.ACTION_MOBILE_ENHANCED_4G_LTE_MODE_TOGGLE;
        } else if (preference == mButtonPreferredNetworkMode) {