Merge "Change the SIM color for passing the GAR" into sc-qpr1-dev
This commit is contained in:
@@ -52,6 +52,7 @@ import com.android.settingslib.DeviceInfoUtils;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -108,18 +109,18 @@ public class RenameMobileNetworkDialogFragment extends InstrumentedDialogFragmen
|
||||
mSubId = getArguments().getInt(KEY_SUBSCRIPTION_ID);
|
||||
Resources res = context.getResources();
|
||||
mLightDarkMap = ImmutableMap.<Integer, Integer>builder()
|
||||
.put(res.getInteger(R.color.SIM_color_teal),
|
||||
res.getInteger(R.color.SIM_dark_mode_color_teal))
|
||||
.put(res.getInteger(R.color.SIM_color_blue),
|
||||
.put(res.getInteger(R.color.SIM_color_cyan),
|
||||
res.getInteger(R.color.SIM_dark_mode_color_cyan))
|
||||
.put(res.getInteger(R.color.SIM_color_blue800),
|
||||
res.getInteger(R.color.SIM_dark_mode_color_blue))
|
||||
.put(res.getInteger(R.color.SIM_color_indigo),
|
||||
res.getInteger(R.color.SIM_dark_mode_color_indigo))
|
||||
.put(res.getInteger(R.color.SIM_color_purple),
|
||||
.put(res.getInteger(R.color.SIM_color_green800),
|
||||
res.getInteger(R.color.SIM_dark_mode_color_green))
|
||||
.put(res.getInteger(R.color.SIM_color_purple800),
|
||||
res.getInteger(R.color.SIM_dark_mode_color_purple))
|
||||
.put(res.getInteger(R.color.SIM_color_pink),
|
||||
.put(res.getInteger(R.color.SIM_color_pink800),
|
||||
res.getInteger(R.color.SIM_dark_mode_color_pink))
|
||||
.put(res.getInteger(R.color.SIM_color_red),
|
||||
res.getInteger(R.color.SIM_dark_mode_color_red))
|
||||
.put(res.getInteger(R.color.SIM_color_orange),
|
||||
res.getInteger(R.color.SIM_dark_mode_color_orange))
|
||||
.build();
|
||||
}
|
||||
|
||||
@@ -175,12 +176,7 @@ public class RenameMobileNetworkDialogFragment extends InstrumentedDialogFragmen
|
||||
final ColorAdapter adapter = new ColorAdapter(getContext(),
|
||||
R.layout.dialog_mobile_network_color_picker_item, mColors);
|
||||
mColorSpinner.setAdapter(adapter);
|
||||
for (int i = 0; i < mColors.length; i++) {
|
||||
if (mColors[i].getColor() == info.getIconTint()) {
|
||||
mColorSpinner.setSelection(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
mColorSpinner.setSelection(getSimColorIndex(info.getIconTint()));
|
||||
|
||||
final TextView operatorName = view.findViewById(R.id.operator_name_value);
|
||||
mTelephonyManager = mTelephonyManager.createForSubscriptionId(mSubId);
|
||||
@@ -239,7 +235,7 @@ public class RenameMobileNetworkDialogFragment extends InstrumentedDialogFragmen
|
||||
|
||||
private Color[] getColors() {
|
||||
final Resources res = getContext().getResources();
|
||||
final int[] colorInts = res.getIntArray(com.android.internal.R.array.sim_colors);
|
||||
final int[] colorInts = res.getIntArray(R.array.sim_color_light);
|
||||
final String[] colorStrings = res.getStringArray(R.array.color_picker);
|
||||
final int iconSize = res.getDimensionPixelSize(R.dimen.color_swatch_size);
|
||||
final int strokeWidth = res.getDimensionPixelSize(R.dimen.color_swatch_stroke_width);
|
||||
@@ -286,4 +282,31 @@ public class RenameMobileNetworkDialogFragment extends InstrumentedDialogFragmen
|
||||
private int getDarkColor(int lightColor) {
|
||||
return mLightDarkMap.getOrDefault(lightColor, lightColor);
|
||||
}
|
||||
|
||||
/*
|
||||
* 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;
|
||||
final int[] previousSimColorInts =
|
||||
getContext().getResources().getIntArray(com.android.internal.R.array.sim_colors);
|
||||
for (int i = 0; i < previousSimColorInts.length; i++) {
|
||||
if (previousSimColorInts[i] == color) {
|
||||
index = i;
|
||||
}
|
||||
}
|
||||
|
||||
if (index == -1) {
|
||||
for (int i = 0; i < mColors.length; i++) {
|
||||
if (mColors[i].getColor() == color) {
|
||||
index = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return index == -1 ? 0 : index;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user