WIP support icon
Added static sim icon to alert box for selecting different sim accounts.
Change-Id: Ib22ceba4b96d636754d7946859f194488517ff9d
diff --git a/res/layout/select_account_list_item.xml b/res/layout/select_account_list_item.xml
new file mode 100644
index 0000000..d80fef5
--- /dev/null
+++ b/res/layout/select_account_list_item.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 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.
+-->
+
+<!-- Layout of a single item in the InCallUI Account Chooser Dialog. -->
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="horizontal"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:padding="4dp" >
+
+ <ImageView android:id="@+id/icon"
+ android:layout_width="48dp"
+ android:layout_height="48dp"
+ android:scaleType="center" />
+
+ <TextView android:id="@+id/text"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:gravity="start|center_vertical"
+ android:layout_marginLeft="8dp"
+ android:layout_width="0dp"
+ android:layout_weight="1"
+ android:layout_height="match_parent" />
+</LinearLayout>
diff --git a/src/com/android/settings/sim/SimSettings.java b/src/com/android/settings/sim/SimSettings.java
index cd556b6..b9a3cbb 100644
--- a/src/com/android/settings/sim/SimSettings.java
+++ b/src/com/android/settings/sim/SimSettings.java
@@ -381,11 +381,13 @@
String[] arr = new String[availableSubInfoLength];
arr = list.toArray(arr);
- ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity(),
- android.R.layout.simple_list_item_1, arr);
-
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
+ ListAdapter adapter = new SelectAccountListAdapter(
+ builder.getContext(),
+ R.layout.select_account_list_item,
+ arr);
+
if (id == DATA_PICK) {
builder.setTitle(R.string.select_sim_for_data);
} else if (id == CALLS_PICK) {
@@ -398,6 +400,49 @@
.create();
}
+ private class SelectAccountListAdapter extends ArrayAdapter<String> {
+ private Context mContext;
+ private int mResId;
+
+ public SelectAccountListAdapter(
+ Context context, int resource, String[] arr) {
+ super(context, resource, arr);
+ mContext = context;
+ mResId = resource;
+ }
+
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ LayoutInflater inflater = (LayoutInflater)
+ mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+
+ View rowView;
+ final ViewHolder holder;
+
+ if (convertView == null) {
+ // Cache views for faster scrolling
+ rowView = inflater.inflate(mResId, null);
+ holder = new ViewHolder();
+ holder.textView = (TextView) rowView.findViewById(R.id.text);
+ holder.imageView = (ImageView) rowView.findViewById(R.id.icon);
+ rowView.setTag(holder);
+ }
+ else {
+ rowView = convertView;
+ holder = (ViewHolder) rowView.getTag();
+ }
+
+ holder.textView.setText(getItem(position));
+ holder.imageView.setImageDrawable(getResources().getDrawable(R.drawable.ic_sim_sd));
+ return rowView;
+ }
+
+ private class ViewHolder {
+ TextView textView;
+ ImageView imageView;
+ }
+ }
+
private void setActivity(Preference preference, SubInfoRecord sir) {
final String key = preference.getKey();