Merge "Fix crash due to over limited length." into main

This commit is contained in:
Treehugger Robot
2025-02-05 23:09:41 -08:00
committed by Android (Google) Code Review
3 changed files with 10 additions and 8 deletions

View File

@@ -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"/>
<TextView

View File

@@ -42,4 +42,6 @@
<integer name="pointer_scale_seek_bar_end">3</integer>
<integer name="max_integer">2147483647</integer>
<integer name="sim_label_max_length">50</integer>
</resources>

View File

@@ -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;