diff --git a/res/layout/dialog_mobile_network_rename.xml b/res/layout/dialog_mobile_network_rename.xml index 87f34bc1828..7a409f7cfd0 100644 --- a/res/layout/dialog_mobile_network_rename.xml +++ b/res/layout/dialog_mobile_network_rename.xml @@ -46,7 +46,7 @@ android:layout_height="wrap_content" android:inputType="text" android:paddingTop="@dimen/sim_label_padding" - android:maxLength="50" + android:maxLength="@integer/sim_label_max_length" android:singleLine="true"/> 3 2147483647 + + 50 diff --git a/src/com/android/settings/network/telephony/RenameMobileNetworkDialogFragment.java b/src/com/android/settings/network/telephony/RenameMobileNetworkDialogFragment.java index ebc5575146e..73f80f688c7 100644 --- a/src/com/android/settings/network/telephony/RenameMobileNetworkDialogFragment.java +++ b/src/com/android/settings/network/telephony/RenameMobileNetworkDialogFragment.java @@ -165,9 +165,9 @@ public class RenameMobileNetworkDialogFragment extends InstrumentedDialogFragmen } final CharSequence displayName = SubscriptionUtil.getUniqueSubscriptionDisplayName( info, getContext()); - mNameView.setText(displayName); if (!TextUtils.isEmpty(displayName)) { - mNameView.setSelection(displayName.length()); + mNameView.setSelection(Math.min(displayName.length(), + getResources().getInteger(R.integer.sim_label_max_length))); } mColorSpinner = view.findViewById(R.id.color_spinner); @@ -176,7 +176,7 @@ public class RenameMobileNetworkDialogFragment extends InstrumentedDialogFragmen mColorSpinner.setAdapter(adapter); mColorSpinner.setSelection(getSimColorIndex(info.getIconTint())); - if(Flags.isDualSimOnboardingEnabled()){ + if (Flags.isDualSimOnboardingEnabled()) { return; } @@ -293,10 +293,10 @@ public class RenameMobileNetworkDialogFragment extends InstrumentedDialogFragmen } /* - * Get the color index from previous color that defined in Android OS - * (frameworks/base/core/res/res/values/arrays.xml). If can't find the color, continue to look - * for it in the new color plattee. If not, give it the first index. - */ + * Get the color index from previous color that defined in Android OS + * (frameworks/base/core/res/res/values/arrays.xml). If can't find the color, continue to look + * for it in the new color plattee. If not, give it the first index. + */ private int getSimColorIndex(int color) { int index = -1;