OSDN Git Service

Remove AdvancedOptionsPreference
authorjackqdyulei <jackqdyulei@google.com>
Fri, 5 Oct 2018 22:49:52 +0000 (15:49 -0700)
committerjackqdyulei <jackqdyulei@google.com>
Mon, 8 Oct 2018 18:12:03 +0000 (11:12 -0700)
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

res/values/strings.xml
res/xml/network_setting_fragment.xml
src/com/android/settings/mobilenetwork/AdvancedOptionsPreference.java [deleted file]
src/com/android/settings/mobilenetwork/DataUsagePreference.java
src/com/android/settings/mobilenetwork/MobileNetworkFragment.java

index 41d024d..f1746fe 100644 (file)
     <!-- 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] -->
index b1b7854..c383ab6 100644 (file)
      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"
diff --git a/src/com/android/settings/mobilenetwork/AdvancedOptionsPreference.java b/src/com/android/settings/mobilenetwork/AdvancedOptionsPreference.java
deleted file mode 100644 (file)
index 78392d6..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * 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
index c564e03..05d26ed 100644 (file)
@@ -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));
index f93e352..d8df8fa 100644 (file)
@@ -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
@@ -390,15 +384,6 @@ public class MobileNetworkFragment extends DashboardFragment implements
     }
 
     @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:+");
         super.onCreate(icicle);
@@ -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);
-            }
+            updateBodyAdvancedFields(activity, prefSet, mSubId, hasActiveSubscriptions);
         } 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) {