summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSantos Cordon <santoscordon@google.com>2013-08-22 18:03:39 -0700
committerSantos Cordon <santoscordon@google.com>2013-08-23 11:59:34 -0700
commit3d3d25f2bee7cf9cdb91ef35d3028a6a62317e08 (patch)
tree394949d82f3bea509977c3b37ab1d1cef39270fa
parent98a02fa7d8e4f8cd10605834134ada0ac83c2873 (diff)
Show gateway UI when dialing via a gateway
Gateway information is not available in the Call object. Inside CallCardPresenter, we use this to show the user dialing information when dialing out through a gateway. This includes a "Calling via..." notice above the call state label and the gateway number. bug: 10393622 Change-Id: Iff1247cd592b0730bb7cfc6d16bd8f60b47f3737
-rw-r--r--InCallUI/res/layout/primary_call_info.xml77
-rw-r--r--InCallUI/res/values/styles.xml2
-rw-r--r--InCallUI/src/com/android/incallui/CallCardFragment.java20
-rw-r--r--InCallUI/src/com/android/incallui/CallCardPresenter.java52
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 65a75d78a..da87f9954 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
@@ -122,7 +128,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);
@@ -139,6 +146,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 5ab2529ff..f233d78ea 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.graphics.BitmapFactory;
@@ -54,9 +57,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
@@ -66,7 +69,8 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi>
});
}
- public void init(PhoneNumberService phoneNumberService) {
+ public void init(Context context, PhoneNumberService phoneNumberService) {
+ mContext = context;
mPhoneNumberService = phoneNumberService;
}
@@ -266,11 +270,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);
}
}
@@ -300,6 +307,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>() {
@@ -374,7 +416,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);