UI changes for icons in sim settings

+ UI changes relate to displaying sim icons in sim settings
+ Correcting way to display phone number inside sim settings dialog

Bug: 18356419
Change-Id: I1fe025fac52f20b607d4492b99cfef9588ec9416
This commit is contained in:
Sanket Padawe
2014-11-12 12:41:35 -08:00
parent cdbba0489b
commit 0381f6c675
7 changed files with 77 additions and 38 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 411 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 306 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 463 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 635 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 814 B

View File

@@ -14,11 +14,12 @@
limitations under the License. limitations under the License.
--> -->
<!-- Layout of a single item in the InCallUI Account Chooser Dialog. --> <!-- Layout of a single item for displaying sim cards. -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" android:orientation="horizontal"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground"
android:padding="4dp" > android:padding="4dp" >
<ImageView android:id="@+id/icon" <ImageView android:id="@+id/icon"
@@ -26,11 +27,32 @@
android:layout_height="48dp" android:layout_height="48dp"
android:scaleType="center" /> android:scaleType="center" />
<TextView android:id="@+id/text" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:textAppearance="?android:attr/textAppearanceMedium" android:orientation="vertical"
android:layout_marginStart="15dip"
android:layout_marginEnd="6dip"
android:layout_marginTop="6dip"
android:layout_marginBottom="6dip"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="1" >
<TextView android:id="@+id/title"
android:textAppearance="?android:attr/textAppearanceLarge"
android:gravity="start|center_vertical" android:gravity="start|center_vertical"
android:layout_marginLeft="8dp" android:layout_marginLeft="8dp"
android:layout_width="0dp" android:layout_width="match_parent"
android:layout_weight="1" android:layout_height="wrap_content"
android:layout_height="match_parent" /> android:singleLine="true"
android:ellipsize="marquee"
android:fadingEdge="horizontal" />
<TextView android:id="@+id/summary"
android:textAppearance="?android:attr/textAppearanceSmall"
android:gravity="start|center_vertical"
android:layout_marginLeft="8dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/title"
android:textColor="?android:attr/textColorSecondary"
android:layout_alignStart="@id/title" />
</LinearLayout>
</LinearLayout> </LinearLayout>

View File

@@ -22,6 +22,7 @@ import android.content.ContentUris;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.res.Resources; import android.content.res.Resources;
import android.database.Cursor; import android.database.Cursor;
import android.graphics.drawable.BitmapDrawable;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.preference.Preference; import android.preference.Preference;
@@ -322,7 +323,7 @@ public class SimSettings extends RestrictedSettingsFragment implements Indexable
ListAdapter adapter = new SelectAccountListAdapter( ListAdapter adapter = new SelectAccountListAdapter(
builder.getContext(), builder.getContext(),
R.layout.select_account_list_item, R.layout.select_account_list_item,
arr); arr, id);
if (id == DATA_PICK) { if (id == DATA_PICK) {
builder.setTitle(R.string.select_sim_for_data); builder.setTitle(R.string.select_sim_for_data);
@@ -339,43 +340,61 @@ public class SimSettings extends RestrictedSettingsFragment implements Indexable
private class SelectAccountListAdapter extends ArrayAdapter<String> { private class SelectAccountListAdapter extends ArrayAdapter<String> {
private Context mContext; private Context mContext;
private int mResId; private int mResId;
private int mDialogId;
private final float OPACITY = 0.54f;
public SelectAccountListAdapter( public SelectAccountListAdapter(
Context context, int resource, String[] arr) { Context context, int resource, String[] arr, int dialogId) {
super(context, resource, arr); super(context, resource, arr);
mContext = context; mContext = context;
mResId = resource; mResId = resource;
mDialogId = dialogId;
} }
@Override @Override
public View getView(int position, View convertView, ViewGroup parent) { public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) LayoutInflater inflater = (LayoutInflater)
mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View rowView; View rowView;
final ViewHolder holder; final ViewHolder holder;
SubscriptionInfo sir;
if (convertView == null) { if (convertView == null) {
// Cache views for faster scrolling // Cache views for faster scrolling
rowView = inflater.inflate(mResId, null); rowView = inflater.inflate(mResId, null);
holder = new ViewHolder(); holder = new ViewHolder();
holder.textView = (TextView) rowView.findViewById(R.id.text); holder.title = (TextView) rowView.findViewById(R.id.title);
holder.imageView = (ImageView) rowView.findViewById(R.id.icon); holder.summary = (TextView) rowView.findViewById(R.id.summary);
holder.icon = (ImageView) rowView.findViewById(R.id.icon);
rowView.setTag(holder); rowView.setTag(holder);
} } else {
else {
rowView = convertView; rowView = convertView;
holder = (ViewHolder) rowView.getTag(); holder = (ViewHolder) rowView.getTag();
} }
holder.textView.setText(getItem(position)); if (mDialogId == CALLS_PICK && position == 0) {
holder.imageView.setImageDrawable(getResources().getDrawable(R.drawable.ic_sim_sd)); holder.title.setText(getItem(position));
holder.summary.setText("");
holder.icon.setImageDrawable(getResources()
.getDrawable(R.drawable.ic_live_help));
holder.icon.setAlpha(OPACITY);
} else {
if (mDialogId == CALLS_PICK && position != 0) {
sir = mSelectableSubInfos.get(position - 1);
} else {
sir = mSelectableSubInfos.get(position);
}
holder.title.setText(sir.getDisplayName());
holder.summary.setText(sir.getNumber());
holder.icon.setImageBitmap(sir.createIconBitmap(mContext));
}
return rowView; return rowView;
} }
private class ViewHolder { private class ViewHolder {
TextView textView; TextView title;
ImageView imageView; TextView summary;
ImageView icon;
} }
} }
@@ -397,10 +416,12 @@ public class SimSettings extends RestrictedSettingsFragment implements Indexable
private SubscriptionInfo mSubInfoRecord; private SubscriptionInfo mSubInfoRecord;
private int mSlotId; private int mSlotId;
private int[] tintArr; private int[] tintArr;
Context mContext;
public SimPreference(Context context, SubscriptionInfo subInfoRecord, int slotId) { public SimPreference(Context context, SubscriptionInfo subInfoRecord, int slotId) {
super(context); super(context);
mContext = context;
mSubInfoRecord = subInfoRecord; mSubInfoRecord = subInfoRecord;
mSlotId = slotId; mSlotId = slotId;
setKey("sim" + mSlotId); setKey("sim" + mSlotId);
@@ -411,12 +432,17 @@ public class SimSettings extends RestrictedSettingsFragment implements Indexable
public void update() { public void update() {
final Resources res = getResources(); final Resources res = getResources();
setTitle(String.format(getResources()
.getString(R.string.sim_editor_title), (mSlotId + 1)));
if (mSubInfoRecord != null) { if (mSubInfoRecord != null) {
setTitle(String.format(res.getString(R.string.sim_editor_title), if (TextUtils.isEmpty(mSubInfoRecord.getNumber().toString())) {
(mSubInfoRecord.getSimSlotIndex() + 1))); setSummary(mSubInfoRecord.getDisplayName());
} else {
setSummary(mSubInfoRecord.getDisplayName() + " - " + setSummary(mSubInfoRecord.getDisplayName() + " - " +
mSubInfoRecord.getNumber().toString()); mSubInfoRecord.getNumber().toString());
setEnabled(true); setEnabled(true);
}
setIcon(new BitmapDrawable(res, (mSubInfoRecord.createIconBitmap(mContext))));
} else { } else {
setSummary(R.string.sim_slot_empty); setSummary(R.string.sim_slot_empty);
setFragment(null); setFragment(null);
@@ -424,20 +450,6 @@ public class SimSettings extends RestrictedSettingsFragment implements Indexable
} }
} }
public String getFormattedPhoneNumber() {
try{
final String rawNumber = PhoneFactory.getPhone(mSlotId).getLine1Number();
String formattedNumber = null;
if (!TextUtils.isEmpty(rawNumber)) {
formattedNumber = PhoneNumberUtils.formatNumber(rawNumber);
}
return formattedNumber;
} catch (java.lang.IllegalStateException ise){
return "Unknown";
}
}
public SubscriptionInfo getSubInfoRecord() { public SubscriptionInfo getSubInfoRecord() {
return mSubInfoRecord; return mSubInfoRecord;
} }
@@ -480,7 +492,12 @@ public class SimSettings extends RestrictedSettingsFragment implements Indexable
}); });
TextView numberView = (TextView)dialogLayout.findViewById(R.id.number); TextView numberView = (TextView)dialogLayout.findViewById(R.id.number);
numberView.setText(simPref.getFormattedPhoneNumber()); final String rawNumber = mSubInfoRecord.getNumber();
if (TextUtils.isEmpty(rawNumber)) {
numberView.setText(res.getString(com.android.internal.R.string.unknownName));
} else {
numberView.setText(PhoneNumberUtils.formatNumber(rawNumber));
}
TextView carrierView = (TextView)dialogLayout.findViewById(R.id.carrier); TextView carrierView = (TextView)dialogLayout.findViewById(R.id.carrier);
carrierView.setText(mSubInfoRecord.getCarrierName()); carrierView.setText(mSubInfoRecord.getCarrierName());