Merge "Use getActivity instead of getContext for backporting." into ub-contactsdialer-b-dev
diff --git a/InCallUI/res/layout/primary_call_info.xml b/InCallUI/res/layout/primary_call_info.xml
index d149a3c..629d220 100644
--- a/InCallUI/res/layout/primary_call_info.xml
+++ b/InCallUI/res/layout/primary_call_info.xml
@@ -161,18 +161,16 @@
android:visibility="gone" />
<!-- Label (like "Mobile" or "Work", if present) and phone number, side by side -->
- <RelativeLayout android:id="@+id/labelAndNumber"
- android:layout_width="0dp"
- android:layout_height="match_parent"
+ <LinearLayout android:id="@+id/labelAndNumber"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
android:layout_weight="1"
- android:orientation="horizontal"
- android:gravity="start">
+ android:orientation="horizontal">
<TextView android:id="@+id/label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_alignParentTop="true"
- android:layout_alignParentStart="true"
+ android:layout_weight="0"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/incall_call_banner_subtext_color"
android:textSize="@dimen/call_label_text_size"
@@ -183,9 +181,8 @@
<TextView android:id="@+id/phoneNumber"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:layout_weight="1"
android:layout_marginStart="6dp"
- android:layout_alignParentTop="true"
- android:layout_toEndOf="@id/label"
android:textAlignment="viewStart"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/incall_call_banner_subtext_color"
@@ -193,17 +190,19 @@
android:singleLine="false"
android:visibility="gone" />
- <TextView android:id="@+id/elapsedTime"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentTop="true"
- android:layout_alignParentEnd="true"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:textColor="@color/incall_call_banner_subtext_color"
- android:textSize="@dimen/call_label_text_size"
- android:visibility="gone" />
+ </LinearLayout>
- </RelativeLayout>
+ <!-- Elapsed time indication for a call in progress. -->
+ <TextView android:id="@+id/elapsedTime"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_weight="0"
+ android:textAlignment="viewEnd"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:textColor="@color/incall_call_banner_subtext_color"
+ android:textSize="@dimen/call_label_text_size"
+ android:singleLine="true"
+ android:visibility="gone" />
</LinearLayout>
diff --git a/InCallUI/src/com/android/incallui/AnswerPresenter.java b/InCallUI/src/com/android/incallui/AnswerPresenter.java
index fc75bf0..02dbfca 100644
--- a/InCallUI/src/com/android/incallui/AnswerPresenter.java
+++ b/InCallUI/src/com/android/incallui/AnswerPresenter.java
@@ -280,7 +280,7 @@
// Only present the user with the option to answer as a video call if the incoming call is
// a bi-directional video call.
- if (VideoProfile.isBidirectional((call.getVideoState()))) {
+ if (CallUtils.isBidirectionalVideoCall(call)) {
if (withSms) {
getUi().showTargets(AnswerFragment.TARGET_SET_FOR_VIDEO_WITH_SMS);
getUi().configureMessageDialog(textMsgs);
diff --git a/InCallUI/src/com/android/incallui/CallCardFragment.java b/InCallUI/src/com/android/incallui/CallCardFragment.java
index f7c9f2b..3c92a76 100644
--- a/InCallUI/src/com/android/incallui/CallCardFragment.java
+++ b/InCallUI/src/com/android/incallui/CallCardFragment.java
@@ -977,8 +977,7 @@
callStateLabel = label;
} else if (isAccount) {
callStateLabel = context.getString(R.string.incoming_via_template, label);
- } else if (VideoProfile.isTransmissionEnabled(videoState) ||
- VideoProfile.isReceptionEnabled(videoState)) {
+ } else if (CallUtils.isVideoCall(videoState)) {
callStateLabel = context.getString(R.string.notification_incoming_video_call);
} else {
callStateLabel = context.getString(R.string.card_title_incoming_call);
diff --git a/InCallUI/src/com/android/incallui/CallList.java b/InCallUI/src/com/android/incallui/CallList.java
index bed1d60..37ae14b 100644
--- a/InCallUI/src/com/android/incallui/CallList.java
+++ b/InCallUI/src/com/android/incallui/CallList.java
@@ -564,12 +564,14 @@
*/
public void notifyCallsOfDeviceRotation(int rotation) {
for (Call call : mCallById.values()) {
- // First, ensure a VideoCall is set on the call so that the change can be sent to the
+ // First, ensure that the call videoState has video enabled (there is no need to set
+ // device orientation on a voice call which has not yet been upgraded to video).
+ // Second, ensure a VideoCall is set on the call so that the change can be sent to the
// provider (a VideoCall can be present for a call that does not currently have video,
// but can be upgraded to video).
- // Second, ensure that the call videoState has video enabled (there is no need to set
- // device orientation on a voice call which has not yet been upgraded to video).
- if (call.getVideoCall() != null && CallUtils.isVideoCall(call)) {
+ // NOTE: is it necessary to use this order because getVideoCall references the class
+ // VideoProfile which is not available on APIs <23 (M).
+ if (CallUtils.isVideoCall(call) && call.getVideoCall() != null) {
call.getVideoCall().setDeviceOrientation(rotation);
}
}
diff --git a/InCallUI/src/com/android/incallui/CallUtils.java b/InCallUI/src/com/android/incallui/CallUtils.java
index c69334c..6eb1a05 100644
--- a/InCallUI/src/com/android/incallui/CallUtils.java
+++ b/InCallUI/src/com/android/incallui/CallUtils.java
@@ -30,6 +30,8 @@
import android.telecom.VideoProfile;
+import com.android.dialer.compat.DialerCompatUtils;
+
import com.google.common.base.Preconditions;
public class CallUtils {
@@ -39,10 +41,22 @@
}
public static boolean isVideoCall(int videoState) {
+ if (!DialerCompatUtils.isVideoCompatible()) {
+ return false;
+ }
+
return VideoProfile.isTransmissionEnabled(videoState)
|| VideoProfile.isReceptionEnabled(videoState);
}
+ public static boolean isBidirectionalVideoCall(Call call) {
+ if (!DialerCompatUtils.isVideoCompatible()) {
+ return false;
+ }
+
+ return VideoProfile.isBidirectional(call.getVideoState());
+ }
+
public static boolean isIncomingVideoCall(Call call) {
if (!CallUtils.isVideoCall(call)) {
return false;
@@ -65,6 +79,10 @@
}
public static boolean isAudioCall(Call call) {
+ if (!DialerCompatUtils.isVideoCompatible()) {
+ return true;
+ }
+
return call != null && VideoProfile.isAudioOnly(call.getVideoState());
}
diff --git a/InCallUI/src/com/android/incallui/InCallPresenter.java b/InCallUI/src/com/android/incallui/InCallPresenter.java
index de563f5..33e4e5a 100644
--- a/InCallUI/src/com/android/incallui/InCallPresenter.java
+++ b/InCallUI/src/com/android/incallui/InCallPresenter.java
@@ -1661,7 +1661,9 @@
final Resources resources = mInCallActivity.getResources();
final int color;
if (resources.getBoolean(R.bool.is_layout_landscape)) {
- color = resources.getColor(R.color.statusbar_background_color, null);
+ // TODO use ResourcesCompat.getColor(Resources, int, Resources.Theme) when available
+ // {@link Resources#getColor(int)} used for compatibility
+ color = resources.getColor(R.color.statusbar_background_color);
} else {
color = mThemeColors.mSecondaryColor;
}
diff --git a/InCallUI/src/com/android/incallui/InCallUIMaterialColorMapUtils.java b/InCallUI/src/com/android/incallui/InCallUIMaterialColorMapUtils.java
index d65580e..44b035f 100644
--- a/InCallUI/src/com/android/incallui/InCallUIMaterialColorMapUtils.java
+++ b/InCallUI/src/com/android/incallui/InCallUIMaterialColorMapUtils.java
@@ -44,9 +44,13 @@
return super.calculatePrimaryAndSecondaryColor(color);
}
+ /**
+ * {@link Resources#getColor(int) used for compatibility
+ */
+ @SuppressWarnings("deprecation")
public static MaterialPalette getDefaultPrimaryAndSecondaryColors(Resources resources) {
- final int primaryColor = resources.getColor(R.color.dialer_theme_color, null);
- final int secondaryColor = resources.getColor(R.color.dialer_theme_color_dark, null);
+ final int primaryColor = resources.getColor(R.color.dialer_theme_color);
+ final int secondaryColor = resources.getColor(R.color.dialer_theme_color_dark);
return new MaterialPalette(primaryColor, secondaryColor);
}
}
\ No newline at end of file
diff --git a/InCallUI/src/com/android/incallui/VideoCallPresenter.java b/InCallUI/src/com/android/incallui/VideoCallPresenter.java
index 12b7188..84d9c97 100644
--- a/InCallUI/src/com/android/incallui/VideoCallPresenter.java
+++ b/InCallUI/src/com/android/incallui/VideoCallPresenter.java
@@ -33,6 +33,7 @@
import android.widget.ImageView;
import com.android.contacts.common.ContactPhotoManager;
+import com.android.dialer.compat.DialerCompatUtils;
import com.android.incallui.InCallPresenter.InCallDetailsListener;
import com.android.incallui.InCallPresenter.InCallOrientationListener;
import com.android.incallui.InCallPresenter.InCallStateListener;
@@ -225,6 +226,12 @@
super.onUiReady(ui);
Log.d(this, "onUiReady:");
+ // Do not register any listeners if video calling is not compatible to safeguard against
+ // any accidental calls of video calling code.
+ if (!DialerCompatUtils.isVideoCompatible()) {
+ return;
+ }
+
// Register for call state changes last
InCallPresenter.getInstance().addListener(this);
InCallPresenter.getInstance().addDetailsListener(this);
@@ -251,6 +258,10 @@
super.onUiUnready(ui);
Log.d(this, "onUiUnready:");
+ if (!DialerCompatUtils.isVideoCompatible()) {
+ return;
+ }
+
InCallPresenter.getInstance().removeListener(this);
InCallPresenter.getInstance().removeDetailsListener(this);
InCallPresenter.getInstance().removeIncomingCallListener(this);
@@ -798,6 +809,10 @@
* @return {@code true} if the incoming video surface should be shown, {@code false} otherwise.
*/
public static boolean showIncomingVideo(int videoState, int callState) {
+ if (!DialerCompatUtils.isVideoCompatible()) {
+ return false;
+ }
+
boolean isPaused = VideoProfile.isPaused(videoState);
boolean isCallActive = callState == Call.State.ACTIVE;
@@ -813,6 +828,10 @@
* otherwise.
*/
public static boolean showOutgoingVideo(int videoState) {
+ if (!DialerCompatUtils.isVideoCompatible()) {
+ return false;
+ }
+
return VideoProfile.isTransmissionEnabled(videoState);
}