diff options
18 files changed, 112 insertions, 45 deletions
diff --git a/InCallUI/res/drawable-hdpi/ic_hd_18dp.png b/InCallUI/res/drawable-hdpi/ic_hd_18dp.png Binary files differnew file mode 100644 index 000000000..ade1788c1 --- /dev/null +++ b/InCallUI/res/drawable-hdpi/ic_hd_18dp.png diff --git a/InCallUI/res/drawable-hdpi/ic_hd_audio.png b/InCallUI/res/drawable-hdpi/ic_hd_audio.png Binary files differdeleted file mode 100644 index cccaf4949..000000000 --- a/InCallUI/res/drawable-hdpi/ic_hd_audio.png +++ /dev/null diff --git a/InCallUI/res/drawable-hdpi/ic_signal_wifi_4_bar_18dp.png b/InCallUI/res/drawable-hdpi/ic_signal_wifi_4_bar_18dp.png Binary files differnew file mode 100644 index 000000000..d7b98055e --- /dev/null +++ b/InCallUI/res/drawable-hdpi/ic_signal_wifi_4_bar_18dp.png diff --git a/InCallUI/res/drawable-mdpi/ic_hd_18dp.png b/InCallUI/res/drawable-mdpi/ic_hd_18dp.png Binary files differnew file mode 100644 index 000000000..82c972646 --- /dev/null +++ b/InCallUI/res/drawable-mdpi/ic_hd_18dp.png diff --git a/InCallUI/res/drawable-mdpi/ic_hd_audio.png b/InCallUI/res/drawable-mdpi/ic_hd_audio.png Binary files differdeleted file mode 100644 index 6353b7acf..000000000 --- a/InCallUI/res/drawable-mdpi/ic_hd_audio.png +++ /dev/null diff --git a/InCallUI/res/drawable-mdpi/ic_signal_wifi_4_bar_18dp.png b/InCallUI/res/drawable-mdpi/ic_signal_wifi_4_bar_18dp.png Binary files differnew file mode 100644 index 000000000..d537ab469 --- /dev/null +++ b/InCallUI/res/drawable-mdpi/ic_signal_wifi_4_bar_18dp.png diff --git a/InCallUI/res/drawable-xhdpi/ic_hd_18dp.png b/InCallUI/res/drawable-xhdpi/ic_hd_18dp.png Binary files differnew file mode 100644 index 000000000..35bf51a4f --- /dev/null +++ b/InCallUI/res/drawable-xhdpi/ic_hd_18dp.png diff --git a/InCallUI/res/drawable-xhdpi/ic_hd_audio.png b/InCallUI/res/drawable-xhdpi/ic_hd_audio.png Binary files differdeleted file mode 100644 index 6d05d45f5..000000000 --- a/InCallUI/res/drawable-xhdpi/ic_hd_audio.png +++ /dev/null diff --git a/InCallUI/res/drawable-xhdpi/ic_signal_wifi_4_bar_18dp.png b/InCallUI/res/drawable-xhdpi/ic_signal_wifi_4_bar_18dp.png Binary files differnew file mode 100644 index 000000000..5a5319212 --- /dev/null +++ b/InCallUI/res/drawable-xhdpi/ic_signal_wifi_4_bar_18dp.png diff --git a/InCallUI/res/drawable-xxhdpi/ic_hd_18dp.png b/InCallUI/res/drawable-xxhdpi/ic_hd_18dp.png Binary files differnew file mode 100644 index 000000000..510aa6e8b --- /dev/null +++ b/InCallUI/res/drawable-xxhdpi/ic_hd_18dp.png diff --git a/InCallUI/res/drawable-xxhdpi/ic_hd_audio.png b/InCallUI/res/drawable-xxhdpi/ic_hd_audio.png Binary files differdeleted file mode 100644 index 44294ba05..000000000 --- a/InCallUI/res/drawable-xxhdpi/ic_hd_audio.png +++ /dev/null diff --git a/InCallUI/res/drawable-xxhdpi/ic_signal_wifi_4_bar_18dp.png b/InCallUI/res/drawable-xxhdpi/ic_signal_wifi_4_bar_18dp.png Binary files differnew file mode 100644 index 000000000..b627198f5 --- /dev/null +++ b/InCallUI/res/drawable-xxhdpi/ic_signal_wifi_4_bar_18dp.png diff --git a/InCallUI/res/drawable-xxxhdpi/ic_hd_18dp.png b/InCallUI/res/drawable-xxxhdpi/ic_hd_18dp.png Binary files differnew file mode 100644 index 000000000..dd08bbbec --- /dev/null +++ b/InCallUI/res/drawable-xxxhdpi/ic_hd_18dp.png diff --git a/InCallUI/res/drawable-xxxhdpi/ic_hd_audio.png b/InCallUI/res/drawable-xxxhdpi/ic_hd_audio.png Binary files differdeleted file mode 100644 index 459cd8f46..000000000 --- a/InCallUI/res/drawable-xxxhdpi/ic_hd_audio.png +++ /dev/null diff --git a/InCallUI/res/drawable-xxxhdpi/ic_signal_wifi_4_bar_18dp.png b/InCallUI/res/drawable-xxxhdpi/ic_signal_wifi_4_bar_18dp.png Binary files differnew file mode 100644 index 000000000..f4105ec8d --- /dev/null +++ b/InCallUI/res/drawable-xxxhdpi/ic_signal_wifi_4_bar_18dp.png diff --git a/InCallUI/res/layout/primary_call_info.xml b/InCallUI/res/layout/primary_call_info.xml index 71369d479..8f0c0e24d 100644 --- a/InCallUI/res/layout/primary_call_info.xml +++ b/InCallUI/res/layout/primary_call_info.xml @@ -43,22 +43,21 @@ <!-- Subscription provider or WiFi calling icon displayed to the left of the label --> <ImageView android:id="@+id/callStateIcon" android:layout_width="16dp" - android:layout_height="16dp" - android:layout_marginEnd="4dp" - android:baselineAlignBottom="true" + android:layout_height="match_parent" + android:layout_marginEnd="8dp" android:tint="@color/incall_accent_color" android:alpha="0.0" - android:scaleType="centerInside" + android:scaleType="center" android:visibility="gone" /> <ImageView android:id="@+id/videoCallIcon" android:src="@drawable/ic_toolbar_video" android:layout_width="16dp" - android:layout_height="16dp" - android:layout_marginEnd="4dp" + android:layout_height="match_parent" + android:layout_marginEnd="16dp" android:baselineAlignBottom="true" android:tint="@color/incall_accent_color" - android:scaleType="centerInside" + android:scaleType="center" android:visibility="gone" /> <TextView android:id="@+id/callStateLabel" @@ -96,29 +95,38 @@ android:clipChildren="false" android:clipToPadding="false"> + <ImageView android:id="@+id/hdAudioIcon" + android:src="@drawable/ic_hd_18dp" + android:layout_width="16dp" + android:layout_height="match_parent" + android:layout_marginEnd="8dp" + android:tint="@color/incall_call_banner_subtext_color" + android:scaleType="center" + android:visibility="gone" /> + <!-- Label (like "Mobile" or "Work", if present) and phone number, side by side --> <LinearLayout android:id="@+id/labelAndNumber" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal"> - <TextView android:id="@+id/label" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:textAppearance="?android:attr/textAppearanceSmall" - android:textColor="@color/incall_call_banner_subtext_color" - android:textSize="@dimen/call_label_text_size" - android:singleLine="true" - android:textDirection="ltr" /> - - <TextView android:id="@+id/phoneNumber" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_marginStart="6dp" - android:textAppearance="?android:attr/textAppearanceSmall" - android:textColor="@color/incall_call_banner_subtext_color" - android:textSize="@dimen/call_label_text_size" - android:singleLine="true" /> + <TextView android:id="@+id/label" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:textAppearance="?android:attr/textAppearanceSmall" + android:textColor="@color/incall_call_banner_subtext_color" + android:textSize="@dimen/call_label_text_size" + android:singleLine="true" + android:textDirection="ltr" /> + + <TextView android:id="@+id/phoneNumber" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginStart="6dp" + android:textAppearance="?android:attr/textAppearanceSmall" + android:textColor="@color/incall_call_banner_subtext_color" + android:textSize="@dimen/call_label_text_size" + android:singleLine="true" /> </LinearLayout> @@ -127,7 +135,6 @@ android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" - android:layout_centerVertical="true" android:textAlignment="viewEnd" android:textAppearance="?android:attr/textAppearanceSmall" android:textColor="@color/incall_call_banner_subtext_color" diff --git a/InCallUI/src/com/android/incallui/CallCardFragment.java b/InCallUI/src/com/android/incallui/CallCardFragment.java index 81b9ff78c..814876105 100644 --- a/InCallUI/src/com/android/incallui/CallCardFragment.java +++ b/InCallUI/src/com/android/incallui/CallCardFragment.java @@ -79,6 +79,7 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr private ImageView mCallStateVideoCallIcon; private TextView mCallStateLabel; private TextView mCallTypeLabel; + private ImageView mHdAudioIcon; private View mCallNumberAndLabel; private ImageView mPhoto; private TextView mElapsedTime; @@ -181,6 +182,7 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr mCallStateIcon = (ImageView) view.findViewById(R.id.callStateIcon); mCallStateVideoCallIcon = (ImageView) view.findViewById(R.id.videoCallIcon); mCallStateLabel = (TextView) view.findViewById(R.id.callStateLabel); + mHdAudioIcon = (ImageView) view.findViewById(R.id.hdAudioIcon); mCallNumberAndLabel = view.findViewById(R.id.labelAndNumber); mCallTypeLabel = (TextView) view.findViewById(R.id.callTypeLabel); mElapsedTime = (TextView) view.findViewById(R.id.elapsedTime); @@ -796,6 +798,16 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr } /** + * Changes the visibility of the HD audio icon. + * + * @param visible {@code true} if the UI should show the HD audio icon. + */ + @Override + public void showHdAudioIndicator(boolean visible) { + mHdAudioIcon.setVisibility(visible ? View.VISIBLE : View.GONE); + } + + /** * Changes the visibility of the "manage conference call" button. * * @param visible Whether to set the button to be visible or not. diff --git a/InCallUI/src/com/android/incallui/CallCardPresenter.java b/InCallUI/src/com/android/incallui/CallCardPresenter.java index cb378a687..47e4328b7 100644 --- a/InCallUI/src/com/android/incallui/CallCardPresenter.java +++ b/InCallUI/src/com/android/incallui/CallCardPresenter.java @@ -23,7 +23,9 @@ import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.graphics.drawable.Drawable; import android.net.Uri; +import android.net.wifi.WifiManager; import android.os.Bundle; +import android.telecom.Call.Details; import android.telecom.DisconnectCause; import android.telecom.PhoneAccount; import android.telecom.PhoneAccountHandle; @@ -64,7 +66,9 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi> private ContactCacheEntry mPrimaryContactInfo; private ContactCacheEntry mSecondaryContactInfo; private CallTimer mCallTimer; + private Context mContext; + private WifiManager mWifiManager; public static class ContactLookupCallback implements ContactInfoCacheCallback { private final WeakReference<CallCardPresenter> mCallCardPresenter; @@ -105,6 +109,7 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi> public void init(Context context, Call call) { mContext = Preconditions.checkNotNull(context); + mWifiManager = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE); // Call may be null if disconnect happened already. if (call != null) { @@ -219,7 +224,7 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi> } // Start/stop timers. - if (mPrimary != null && mPrimary.getState() == Call.State.ACTIVE) { + if (isPrimaryCallActive()) { Log.d(this, "Starting the calltime timer"); mCallTimer.start(CALL_TIME_UPDATE_INTERVAL_MS); } else { @@ -242,6 +247,7 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi> null, null, null); + getUi().showHdAudioIndicator(false); } // Hide/show the contact photo based on the video state. @@ -262,13 +268,11 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi> } @Override - public void onDetailsChanged(Call call, android.telecom.Call.Details details) { + public void onDetailsChanged(Call call, Details details) { updatePrimaryCallState(); - if (call.can(android.telecom.Call.Details.CAPABILITY_MANAGE_CONFERENCE) != - android.telecom.Call.Details.can( - details.getCallCapabilities(), - android.telecom.Call.Details.CAPABILITY_MANAGE_CONFERENCE)) { + if (call.can(Details.CAPABILITY_MANAGE_CONFERENCE) != + Details.can(details.getCallCapabilities(), Details.CAPABILITY_MANAGE_CONFERENCE)) { maybeShowManageConferenceCallButton(); } } @@ -298,6 +302,11 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi> getConnectionLabel(), getCallStateIcon(), getGatewayNumber()); + + boolean showHdAudioIndicator = + isPrimaryCallActive() && primaryCallCan(Details.CAPABILITY_HIGH_DEF_AUDIO); + getUi().showHdAudioIndicator(showHdAudioIndicator); + setCallbackNumber(); } } @@ -320,7 +329,7 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi> return false; } - return mPrimary.can(android.telecom.Call.Details.CAPABILITY_MANAGE_CONFERENCE); + return mPrimary.can(Details.CAPABILITY_MANAGE_CONFERENCE); } private void setCallbackNumber() { @@ -353,10 +362,10 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi> public void updateCallTime() { final CallCardUi ui = getUi(); - if (ui == null || mPrimary == null || mPrimary.getState() != Call.State.ACTIVE) { - if (ui != null) { - ui.setPrimaryCallElapsedTime(false, 0); - } + if (ui == null) { + mCallTimer.cancel(); + } else if (!isPrimaryCallActive()) { + ui.setPrimaryCallElapsedTime(false, 0); mCallTimer.cancel(); } else { final long callStart = mPrimary.getConnectTimeMillis(); @@ -591,6 +600,13 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi> return statusHints.getLabel().toString(); } + // Assume the SSID of the connection reported by the WifiManager is the name of the wifi + // network used for calling, since currently a phone only connects to a single wifi network. + if (isPrimaryCallActive() && primaryCallCan(Details.CAPABILITY_WIFI) + && mWifiManager.getConnectionInfo() != null) { + return formatWifiSSID(mWifiManager.getConnectionInfo().getSSID()); + } + if (hasOutgoingGatewayCall() && getUi() != null) { // Return the label for the gateway app on outgoing calls. final PackageManager pm = mContext.getPackageManager(); @@ -616,11 +632,8 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi> } } - // Return high definition audio icon if the capability is indicated. - if (mPrimary.getTelecommCall().getDetails().can( - android.telecom.Call.Details.CAPABILITY_HIGH_DEF_AUDIO) - && mPrimary.getState() == Call.State.ACTIVE) { - return mContext.getResources().getDrawable(R.drawable.ic_hd_audio); + if (isPrimaryCallActive() && primaryCallCan(Details.CAPABILITY_WIFI)) { + return mContext.getResources().getDrawable(R.drawable.ic_signal_wifi_4_bar_18dp); } return null; @@ -700,9 +713,16 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi> ui.setCallCardVisible(!isFullScreenVideo); } + private boolean isPrimaryCallActive() { + return mPrimary != null && mPrimary.getState() == Call.State.ACTIVE; + } + + private boolean primaryCallCan(int capability) { + return mPrimary.getTelecommCall().getDetails().can(capability); + } + private String getConferenceString(Call call) { - boolean isGenericConference = call.can( - android.telecom.Call.Details.CAPABILITY_GENERIC_CONFERENCE); + boolean isGenericConference = call.can(Details.CAPABILITY_GENERIC_CONFERENCE); Log.v(this, "getConferenceString: " + isGenericConference); final int resId = isGenericConference @@ -711,8 +731,7 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi> } private Drawable getConferencePhoto(Call call) { - boolean isGenericConference = call.can( - android.telecom.Call.Details.CAPABILITY_GENERIC_CONFERENCE); + boolean isGenericConference = call.can(Details.CAPABILITY_GENERIC_CONFERENCE); Log.v(this, "getConferencePhoto: " + isGenericConference); final int resId = isGenericConference @@ -722,6 +741,34 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi> return photo; } + /** + * Strip quotations off the outside of a Wifi SSID identifier. For example, \"GoogleGuest\" + * becomes GoogleGuest. + * + * TODO: Move into utility class. + * TODO: Add unit tests. + * + * @param ssid The ssid of the wifi network. + */ + private String formatWifiSSID(String ssid) { + if (TextUtils.isEmpty(ssid)) { + return ""; + } + + // Trim quotation if first character. + if (ssid.charAt(0) == '\"') { + ssid = ssid.substring(1); + } + + // Trim quotation if last character. + int lastIndex = ssid.length() - 1; + if (lastIndex >= 0 && ssid.charAt(lastIndex) == '\"') { + ssid = ssid.substring(0, lastIndex); + } + + return ssid; + } + public interface CallCardUi extends Ui { void setVisible(boolean on); void setCallCardVisible(boolean visible); @@ -741,6 +788,7 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi> void setCallbackNumber(String number, boolean isEmergencyCalls); void setPhotoVisible(boolean isVisible); void setProgressSpinnerVisible(boolean visible); + void showHdAudioIndicator(boolean visible); void showManageConferenceCallButton(boolean visible); boolean isManageConferenceVisible(); } |