diff options
Diffstat (limited to 'InCallUI')
-rw-r--r-- | InCallUI/res/layout/primary_call_info.xml | 77 | ||||
-rw-r--r-- | InCallUI/res/values/styles.xml | 2 | ||||
-rw-r--r-- | InCallUI/src/com/android/incallui/CallCardFragment.java | 20 | ||||
-rw-r--r-- | InCallUI/src/com/android/incallui/CallCardPresenter.java | 52 |
4 files changed, 126 insertions, 25 deletions
diff --git a/InCallUI/res/layout/primary_call_info.xml b/InCallUI/res/layout/primary_call_info.xml index 251ded30b..681519b76 100644 --- a/InCallUI/res/layout/primary_call_info.xml +++ b/InCallUI/res/layout/primary_call_info.xml @@ -110,24 +110,67 @@ </GridLayout> <!-- End of call_banner --> + <LinearLayout android:id="@+id/supplementary_info_container" + style="@style/PrimaryCallInfoSupplementaryInfoContainer" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_gravity="center_vertical|right" + android:orientation="vertical" + android:background="@color/incall_secondary_info_background" + android:animateLayoutChanges="true"> + + <!-- Shown when a gateway provider is used during any outgoing call. --> + <LinearLayout android:id="@+id/providerInfo" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:paddingTop="@dimen/provider_info_top_bottom_padding" + android:paddingBottom="@dimen/provider_info_top_bottom_padding" + android:paddingStart="@dimen/call_banner_side_padding" + android:paddingEnd="@dimen/call_banner_side_padding" + android:gravity="end" + android:orientation="horizontal" + android:background="@android:color/transparent" + android:visibility="gone"> + <TextView android:id="@+id/providerLabel" + android:layout_width="0px" + android:layout_height="wrap_content" + android:layout_weight="6" + android:textAppearance="?android:attr/textAppearanceSmall" + android:textAllCaps="true" + android:textColor="@color/incall_call_banner_text_color" + android:singleLine="true" + android:ellipsize="marquee" /> + <TextView android:id="@+id/providerAddress" + android:layout_width="0px" + android:layout_height="wrap_content" + android:layout_weight="4" + android:gravity="end" + android:paddingStart="8dp" + android:textAppearance="?android:attr/textAppearanceSmall" + android:textAllCaps="true" + android:textColor="@color/incall_call_banner_text_color" + android:singleLine="true" + android:ellipsize="middle" /> + </LinearLayout> - <!-- The "call state label": In some states, this shows a special - indication like "Dialing" or "Incoming call" or "Call ended". - It's unused for the normal case of an active ongoing call. --> - <TextView android:id="@+id/callStateLabel" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:paddingTop="@dimen/provider_info_top_bottom_padding" - android:paddingBottom="@dimen/provider_info_top_bottom_padding" - android:paddingStart="@dimen/call_banner_side_padding" - android:paddingEnd="@dimen/call_banner_side_padding" - android:gravity="end" - android:textAppearance="?android:attr/textAppearanceSmall" - android:textColor="@color/incall_call_banner_text_color" - android:textAllCaps="true" - android:background="@color/incall_secondary_info_background" - android:singleLine="true" - android:ellipsize="end"/> + <!-- The "call state label": In some states, this shows a special + indication like "Dialing" or "Incoming call" or "Call ended". + It's unused for the normal case of an active ongoing call. --> + <TextView android:id="@+id/callStateLabel" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:paddingTop="@dimen/provider_info_top_bottom_padding" + android:paddingBottom="@dimen/provider_info_top_bottom_padding" + android:paddingStart="@dimen/call_banner_side_padding" + android:paddingEnd="@dimen/call_banner_side_padding" + android:gravity="end" + android:textAppearance="?android:attr/textAppearanceSmall" + android:textColor="@color/incall_call_banner_text_color" + android:textAllCaps="true" + android:background="@color/incall_secondary_info_background" + android:singleLine="true" + android:ellipsize="end"/> + </LinearLayout> </LinearLayout> diff --git a/InCallUI/res/values/styles.xml b/InCallUI/res/values/styles.xml index 415db361d..457065320 100644 --- a/InCallUI/res/values/styles.xml +++ b/InCallUI/res/values/styles.xml @@ -152,7 +152,7 @@ <style name="PrimaryCallInfoPrimaryCallBanner"> <item name="android:layout_alignParentTop">true</item> </style> - <style name="PrimaryCallInfoSecondaryInfoContainer"> + <style name="PrimaryCallInfoSupplementaryInfoContainer"> <item name="android:layout_below">@id/primary_call_banner</item> </style> diff --git a/InCallUI/src/com/android/incallui/CallCardFragment.java b/InCallUI/src/com/android/incallui/CallCardFragment.java index 889ff4908..b77dc4cde 100644 --- a/InCallUI/src/com/android/incallui/CallCardFragment.java +++ b/InCallUI/src/com/android/incallui/CallCardFragment.java @@ -46,6 +46,9 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr private TextView mCallStateLabel; private ImageView mPhoto; private TextView mElapsedTime; + private View mProviderInfo; + private TextView mProviderLabel; + private TextView mProviderNumber; // Secondary caller info private ViewStub mSecondaryCallInfo; @@ -69,7 +72,7 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - getPresenter().init(ServiceFactory.newPhoneNumberService(getActivity())); + getPresenter().init(getActivity(), ServiceFactory.newPhoneNumberService(getActivity())); } @Override @@ -93,6 +96,9 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr mPhoto = (ImageView) view.findViewById(R.id.photo); mCallStateLabel = (TextView) view.findViewById(R.id.callStateLabel); mElapsedTime = (TextView) view.findViewById(R.id.elapsedTime); + mProviderInfo = view.findViewById(R.id.providerInfo); + mProviderLabel = (TextView) view.findViewById(R.id.providerLabel); + mProviderNumber = (TextView) view.findViewById(R.id.providerAddress); } @Override @@ -124,7 +130,8 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr @Override public void setPrimary(String number, String name, boolean nameIsNumber, String label, - Drawable photo, boolean isConference) { + Drawable photo, boolean isConference, String gatewayLabel, String gatewayNumber) { + Log.d(this, "Setting primary call [" + gatewayLabel + "][" + gatewayNumber + "]"); if (isConference) { name = getView().getResources().getString(R.string.card_title_conf_call); @@ -141,6 +148,15 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr mPhoneNumber.setTextDirection(View.TEXT_DIRECTION_LTR); } + // Set any gateway information + if (!TextUtils.isEmpty(gatewayLabel) && !TextUtils.isEmpty(gatewayNumber)) { + mProviderLabel.setText(gatewayLabel); + mProviderNumber.setText(gatewayNumber); + mProviderInfo.setVisibility(View.VISIBLE); + } else { + mProviderInfo.setVisibility(View.GONE); + } + // Set direction of the name field // set the name field. diff --git a/InCallUI/src/com/android/incallui/CallCardPresenter.java b/InCallUI/src/com/android/incallui/CallCardPresenter.java index 1239695c3..cc2e3bf54 100644 --- a/InCallUI/src/com/android/incallui/CallCardPresenter.java +++ b/InCallUI/src/com/android/incallui/CallCardPresenter.java @@ -16,6 +16,9 @@ package com.android.incallui; +import android.content.Context; +import android.content.pm.ApplicationInfo; +import android.content.pm.PackageManager; import android.graphics.drawable.Drawable; import android.graphics.Bitmap; import android.os.AsyncTask; @@ -50,9 +53,9 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi> private ContactCacheEntry mPrimaryContactInfo; private ContactCacheEntry mSecondaryContactInfo; private CallTimer mCallTimer; + private Context mContext; public CallCardPresenter() { - // create the call timer mCallTimer = new CallTimer(new Runnable() { @Override @@ -62,7 +65,8 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi> }); } - public void init(PhoneNumberService phoneNumberService) { + public void init(Context context, PhoneNumberService phoneNumberService) { + mContext = context; mPhoneNumberService = phoneNumberService; } @@ -262,11 +266,14 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi> final String name = getNameForCall(mPrimaryContactInfo); final String number = getNumberForCall(mPrimaryContactInfo); final boolean nameIsNumber = name != null && name.equals(mPrimaryContactInfo.number); + final String gatewayLabel = getGatewayLabel(); + final String gatewayNumber = getGatewayNumber(); ui.setPrimary(number, name, nameIsNumber, mPrimaryContactInfo.label, - mPrimaryContactInfo.photo, mPrimary.isConferenceCall()); + mPrimaryContactInfo.photo, mPrimary.isConferenceCall(), gatewayLabel, + gatewayNumber); } else { // reset to nothing (like at end of call) - ui.setPrimary(null, null, false, null, null, false); + ui.setPrimary(null, null, false, null, null, false, null, null); } } @@ -296,6 +303,41 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi> } } + /** + * Returns the gateway number for any existing outgoing call. + */ + private String getGatewayNumber() { + if (hasOutgoingGatewayCall()) { + return mPrimary.getGatewayNumber(); + } + + return null; + } + + /** + * Returns the label for the gateway app for any existing outgoing call. + */ + private String getGatewayLabel() { + if (hasOutgoingGatewayCall() && getUi() != null) { + final PackageManager pm = mContext.getPackageManager(); + try { + final ApplicationInfo info = pm.getApplicationInfo(mPrimary.getGatewayPackage(), 0); + return mContext.getString(R.string.calling_via_template, + pm.getApplicationLabel(info).toString()); + } catch (PackageManager.NameNotFoundException e) { + } + } + return null; + } + + private boolean hasOutgoingGatewayCall() { + // We only display the gateway information while DIALING so return false for any othe + // call state. + return (mPrimary.getState() == Call.State.DIALING && + !TextUtils.isEmpty(mPrimary.getGatewayNumber()) && + !TextUtils.isEmpty(mPrimary.getGatewayPackage())); + } + private void fetchImage(final String url) { if (url != null) { new AsyncTask<Void, Void, Bitmap>() { @@ -364,7 +406,7 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi> public interface CallCardUi extends Ui { void setVisible(boolean on); void setPrimary(String number, String name, boolean nameIsNumber, String label, - Drawable photo, boolean isConference); + Drawable photo, boolean isConference, String gatewayLabel, String gatewayNumber); void setSecondary(boolean show, String name, String label, Drawable photo); void setCallState(int state, Call.DisconnectCause cause, boolean bluetoothOn); void setPrimaryCallElapsedTime(boolean show, String duration); |