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

Commit 09c932b2 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add dialog for changing display name for mobile network"

parents fd9cdb50 e13d04c7
Loading
Loading
Loading
Loading
+64 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2019 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.
-->
<ScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:padding="@dimen/sim_content_padding">

        <EditText
            android:id="@+id/edittext"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:inputType="text"
            android:maxLength="50"
            android:singleLine="true">
            <requestFocus/>
        </EditText>

        <TextView
            style="@style/device_info_dialog_label"
            android:id="@+id/operator_name_label"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/status_operator"/>
        <TextView
            style="@style/device_info_dialog_value"
            android:id="@+id/operator_name_value"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/device_info_not_available"/>

        <TextView
            style="@style/device_info_dialog_label"
            android:id="@+id/number_label"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/status_number_sim_status"/>
        <TextView
            style="@style/device_info_dialog_value"
            android:id="@+id/number_value"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/device_info_not_available"/>

    </LinearLayout>
</ScrollView>
+3 −0
Original line number Diff line number Diff line
@@ -31,4 +31,7 @@
    <item type="id" name="action_drag_move_top" />
    <item type="id" name="action_drag_move_bottom" />
    <item type="id" name="action_drag_remove" />

    <!-- For a menu item allowing users to edit a SIM display name -->
    <item type="id" name="edit_sim_name" />
</resources>
+8 −0
Original line number Diff line number Diff line
@@ -10456,6 +10456,14 @@
    <!-- Summary for an item in the page listing multiple mobile service subscriptions, indicating
         that service is inactive and is tied to an eSIM profile [CHAR LIMIT=40] -->
    <string name="mobile_network_inactive_esim">Inactive eSIM</string>
    <!-- Title of a dialog that lets a user modify the display name used for a mobile network
         subscription in various places in the Settings app. The default name is typically just the
          carrier name, but especially in multi-SIM configurations users may want to use a different
           name. [CHAR LIMIT=40] -->
    <string name="mobile_network_sim_name">SIM name</string>
    <!-- Label on the confirmation button of a dialog that lets a user set the display name of a
         mobile network subscription [CHAR LIMIT=20] -->
    <string name="mobile_network_sim_name_rename">Rename</string>
    <!-- Title for preferred network type [CHAR LIMIT=NONE] -->
    <string name="preferred_network_mode_title">Preferred network type</string>
+8 −7
Original line number Diff line number Diff line
@@ -97,13 +97,6 @@ public class MobileNetworkActivity extends SettingsBaseActivity {
            actionBar.setDisplayHomeAsUpEnabled(true);
        }

        // Set the title to the name of the subscription. If we don't have subscription info, the
        // title will just default to the label for this activity that's already specified in
        // AndroidManifest.xml.
        final SubscriptionInfo subscription = getSubscription();
        if (subscription != null) {
            setTitle(subscription.getDisplayName());
        }
        updateSubscriptions(savedInstanceState);
    }

@@ -136,6 +129,14 @@ public class MobileNetworkActivity extends SettingsBaseActivity {

    @VisibleForTesting
    void updateSubscriptions(Bundle savedInstanceState) {
        // Set the title to the name of the subscription. If we don't have subscription info, the
        // title will just default to the label for this activity that's already specified in
        // AndroidManifest.xml.
        final SubscriptionInfo subscription = getSubscription();
        if (subscription != null) {
            setTitle(subscription.getDisplayName());
        }

        mSubscriptionInfos = mSubscriptionManager.getActiveSubscriptionInfoList(true);

        if (!FeatureFlagPersistent.isEnabled(this, FeatureFlags.NETWORK_INTERNET_V2)) {
+31 −3
Original line number Diff line number Diff line
@@ -28,9 +28,9 @@ import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Log;

import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;

import com.android.internal.telephony.TelephonyIntents;
import com.android.settings.R;
@@ -52,6 +52,9 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;

@SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
public class MobileNetworkSettings extends RestrictedDashboardFragment {

@@ -219,6 +222,31 @@ public class MobileNetworkSettings extends RestrictedDashboardFragment {
        }
    }

    @Override
    public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
        if (FeatureFlagPersistent.isEnabled(getContext(), FeatureFlags.NETWORK_INTERNET_V2) &&
                mSubId != SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
            final MenuItem item = menu.add(Menu.NONE, R.id.edit_sim_name, Menu.NONE,
                    R.string.mobile_network_sim_name);
            item.setIcon(com.android.internal.R.drawable.ic_mode_edit);
            item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
        }
        super.onCreateOptionsMenu(menu, inflater);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem menuItem) {
        if (FeatureFlagPersistent.isEnabled(getContext(), FeatureFlags.NETWORK_INTERNET_V2) &&
                mSubId != SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
            if (menuItem.getItemId() == R.id.edit_sim_name) {
                RenameMobileNetworkDialogFragment.newInstance(mSubId).show(
                        getFragmentManager(), RenameMobileNetworkDialogFragment.TAG);
                return true;
            }
        }
        return super.onOptionsItemSelected(menuItem);
    }

    public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
            new BaseSearchIndexProvider() {
                @Override
Loading