From 1d62ab209130bdacdb64b2cd824b5ff35817b89f Mon Sep 17 00:00:00 2001 From: wangqi Date: Wed, 29 Nov 2017 14:29:31 -0800 Subject: Enable timer in emergency call. "This phone's number: xxx" is shown for emergency call which replaces in call timer. This change move it to under emergency location service so timer could be shown again. Bug: 69810801 Test: manual PiperOrigin-RevId: 177363955 Change-Id: I543fbbee869923800ffd92a5799819b712f0b953 --- java/com/android/incallui/CallCardPresenter.java | 31 ++-- .../incallui/answer/impl/AnswerFragment.java | 4 +- .../impl/res/layout/fragment_incoming_call.xml | 5 + .../impl/res/layout/location_fragment.xml | 181 ++++++++++----------- .../android/incallui/contactgrid/BottomRow.java | 4 - .../incallui/contactgrid/ContactGridManager.java | 33 ++++ .../contactgrid/res/layout/device_number_row.xml | 39 +++++ .../incallui/contactgrid/res/values/ids.xml | 2 + .../incallui/incall/impl/InCallFragment.java | 14 +- .../incall/impl/res/layout/frag_incall_voice.xml | 21 ++- 10 files changed, 210 insertions(+), 124 deletions(-) create mode 100644 java/com/android/incallui/contactgrid/res/layout/device_number_row.xml diff --git a/java/com/android/incallui/CallCardPresenter.java b/java/com/android/incallui/CallCardPresenter.java index f3c2af6c7..eb5221669 100644 --- a/java/com/android/incallui/CallCardPresenter.java +++ b/java/com/android/incallui/CallCardPresenter.java @@ -212,7 +212,7 @@ public class CallCardPresenter // Showing the location may have been skipped if the UI wasn't ready during previous layout. if (shouldShowLocation()) { - updatePrimaryDisplayInfo(); + mInCallScreen.showLocationUi(getLocationFragment()); // Log location impressions if (!hasLocationPermission()) { @@ -801,40 +801,47 @@ public class CallCardPresenter } private Fragment getLocationFragment() { + if (!shouldShowLocation()) { + return null; + } + LogUtil.i("CallCardPresenter.getLocationFragment", "returning location fragment"); + return callLocation.getLocationFragment(mContext); + } + + private boolean shouldShowLocation() { if (!ConfigProviderBindings.get(mContext) .getBoolean(CONFIG_ENABLE_EMERGENCY_LOCATION, CONFIG_ENABLE_EMERGENCY_LOCATION_DEFAULT)) { LogUtil.i("CallCardPresenter.getLocationFragment", "disabled by config."); - return null; + return false; } - if (!shouldShowLocation()) { + if (!isPotentialEmergencyCall()) { LogUtil.i("CallCardPresenter.getLocationFragment", "shouldn't show location"); - return null; + return false; } if (!hasLocationPermission()) { LogUtil.i("CallCardPresenter.getLocationFragment", "no location permission."); - return null; + return false; } if (isBatteryTooLowForEmergencyLocation()) { LogUtil.i("CallCardPresenter.getLocationFragment", "low battery."); - return null; + return false; } if (ActivityCompat.isInMultiWindowMode(mInCallScreen.getInCallScreenFragment().getActivity())) { LogUtil.i("CallCardPresenter.getLocationFragment", "in multi-window mode"); - return null; + return false; } if (mPrimary.isVideoCall()) { LogUtil.i("CallCardPresenter.getLocationFragment", "emergency video calls not supported"); - return null; + return false; } if (!callLocation.canGetLocation(mContext)) { LogUtil.i("CallCardPresenter.getLocationFragment", "can't get current location"); - return null; + return false; } - LogUtil.i("CallCardPresenter.getLocationFragment", "returning location fragment"); - return callLocation.getLocationFragment(mContext); + return true; } - private boolean shouldShowLocation() { + private boolean isPotentialEmergencyCall() { if (isOutgoingEmergencyCall(mPrimary)) { LogUtil.i("CallCardPresenter.shouldShowLocation", "new emergency call"); return true; diff --git a/java/com/android/incallui/answer/impl/AnswerFragment.java b/java/com/android/incallui/answer/impl/AnswerFragment.java index 4362a995d..d687b6e01 100644 --- a/java/com/android/incallui/answer/impl/AnswerFragment.java +++ b/java/com/android/incallui/answer/impl/AnswerFragment.java @@ -694,6 +694,8 @@ public class AnswerFragment extends Fragment updateImportanceBadgeVisibility(); contactGridManager = new ContactGridManager(view, null, 0, false /* showAnonymousAvatar */); + boolean isInMultiWindowMode = ActivityCompat.isInMultiWindowMode(getActivity()); + contactGridManager.onMultiWindowModeChanged(isInMultiWindowMode); Fragment answerMethod = getChildFragmentManager().findFragmentById(R.id.answer_method_container); @@ -712,7 +714,7 @@ public class AnswerFragment extends Fragment initSecondaryButton(); int flags = View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; - if (!ActivityCompat.isInMultiWindowMode(getActivity()) + if (!isInMultiWindowMode && (getActivity().checkSelfPermission(permission.STATUS_BAR) == PackageManager.PERMISSION_GRANTED)) { LogUtil.i("AnswerFragment.onCreateView", "STATUS_BAR permission granted, disabling nav bar"); diff --git a/java/com/android/incallui/answer/impl/res/layout/fragment_incoming_call.xml b/java/com/android/incallui/answer/impl/res/layout/fragment_incoming_call.xml index d79da8843..b17fc7358 100644 --- a/java/com/android/incallui/answer/impl/res/layout/fragment_incoming_call.xml +++ b/java/com/android/incallui/answer/impl/res/layout/fragment_incoming_call.xml @@ -131,6 +131,11 @@ android:layout_width="match_parent" android:layout_height="wrap_content"/> + + - - + android:layout_marginTop="16dp" + android:background="@drawable/bg_location_card" + android:elevation="2dp" + android:inAnimation="@android:anim/fade_in" + android:measureAllChildren="true" + android:outAnimation="@android:anim/fade_out"> - + android:layout_gravity="center_vertical" + android:orientation="vertical"> + + + android:id="@+id/location_loading_text" + style="@style/LocationLoadingTextStyle" + android:layout_width="match_parent" + android:layout_height="24sp" + android:layout_marginBottom="20dp" + android:layout_marginStart="24dp" + android:layout_marginEnd="24dp" + android:gravity="center" + android:text="@string/location_loading"/> + android:id="@+id/location_layout" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_gravity="center" + android:columnCount="2" + android:orientation="horizontal"> + android:id="@+id/location_address_title" + style="@style/LocationAddressTitleTextStyle" + android:layout_width="0dp" + android:layout_height="20sp" + android:layout_marginTop="16dp" + android:layout_marginBottom="4dp" + android:layout_marginStart="16dp" + android:layout_columnWeight="1" + android:text="@string/location_title"/> + android:id="@+id/location_map" + android:layout_width="@dimen/location_map_width" + android:layout_height="@dimen/location_map_height" + android:layout_margin="16dp" + android:layout_gravity="end|center_vertical" + android:layout_rowSpan="4" + android:contentDescription="@string/location_map_description" + android:scaleType="centerCrop" + android:visibility="invisible" + tools:src="?android:colorPrimaryDark" + tools:visibility="visible"/> + android:id="@+id/address_line_one" + style="@style/LocationAddressTextStyle" + android:layout_width="0dp" + android:layout_height="24sp" + android:layout_marginStart="16dp" + android:layout_columnWeight="1" + android:ellipsize="end" + android:lines="1" + android:visibility="invisible" + tools:text="1600 Amphitheatre Pkwy And a bit" + tools:visibility="visible"/> + android:id="@+id/address_line_two" + style="@style/LocationAddressTextStyle" + android:layout_width="0dp" + android:layout_height="24sp" + android:layout_marginStart="16dp" + android:layout_columnWeight="1" + android:ellipsize="end" + android:lines="1" + android:visibility="invisible" + tools:text="Mountain View, CA 94043" + tools:visibility="visible"/> + android:id="@+id/lat_long_line" + style="@style/LocationLatLongTextStyle" + android:layout_width="0dp" + android:layout_height="24sp" + android:layout_marginBottom="12dp" + android:layout_marginStart="16dp" + android:layout_columnWeight="1" + android:ellipsize="end" + android:lines="1" + android:visibility="invisible" + tools:text="Lat: 37.421719, Long: -122.085297" + tools:visibility="visible"/> diff --git a/java/com/android/incallui/contactgrid/BottomRow.java b/java/com/android/incallui/contactgrid/BottomRow.java index a0d118552..f9fc870dc 100644 --- a/java/com/android/incallui/contactgrid/BottomRow.java +++ b/java/com/android/incallui/contactgrid/BottomRow.java @@ -97,10 +97,6 @@ public class BottomRow { if (TextUtils.isEmpty(label)) { label = context.getString(R.string.incall_call_ended); } - } else if (!TextUtils.isEmpty(state.callbackNumber)) { - // This is used for carriers like Project Fi to show the callback number for emergency calls. - label = context.getString(R.string.contact_grid_callback_number, state.callbackNumber); - isTimerVisible = false; } else { label = getLabelForPhoneNumber(primaryInfo); shouldPopulateAccessibilityEvent = primaryInfo.nameIsNumber; diff --git a/java/com/android/incallui/contactgrid/ContactGridManager.java b/java/com/android/incallui/contactgrid/ContactGridManager.java index 8deee8263..1bac97842 100644 --- a/java/com/android/incallui/contactgrid/ContactGridManager.java +++ b/java/com/android/incallui/contactgrid/ContactGridManager.java @@ -81,9 +81,14 @@ public class ContactGridManager { private boolean middleRowVisible = true; private boolean isTimerStarted; + // Row in emergency call: This phone's number: +1 (650) 253-0000 + private final TextView deviceNumberTextView; + private final View deviceNumberDivider; + private PrimaryInfo primaryInfo = PrimaryInfo.createEmptyPrimaryInfo(); private PrimaryCallState primaryCallState = PrimaryCallState.createEmptyPrimaryCallState(); private final LetterTileDrawable letterTile; + private boolean isInMultiWindowMode; public ContactGridManager( View view, @Nullable ImageView avatarImageView, int avatarSize, boolean showAnonymousAvatar) { @@ -109,6 +114,9 @@ public class ContactGridManager { contactGridLayout = (View) contactNameTextView.getParent(); letterTile = new LetterTileDrawable(context.getResources()); isTimerStarted = false; + + deviceNumberTextView = view.findViewById(R.id.contactgrid_device_number_text); + deviceNumberDivider = view.findViewById(R.id.contactgrid_location_divider); } public void show() { @@ -148,6 +156,7 @@ public class ContactGridManager { this.primaryInfo = primaryInfo; updatePrimaryNameAndPhoto(); updateBottomRow(); + updateDeviceNumberRow(); } public void setCallState(PrimaryCallState primaryCallState) { @@ -155,6 +164,7 @@ public class ContactGridManager { updatePrimaryNameAndPhoto(); updateBottomRow(); updateTopRow(); + updateDeviceNumberRow(); } public void dispatchPopulateAccessibilityEvent(AccessibilityEvent event) { @@ -174,6 +184,14 @@ public class ContactGridManager { updatePrimaryNameAndPhoto(); } + public void onMultiWindowModeChanged(boolean isInMultiWindowMode) { + if (this.isInMultiWindowMode == isInMultiWindowMode) { + return; + } + this.isInMultiWindowMode = isInMultiWindowMode; + updateDeviceNumberRow(); + } + private void dispatchPopulateAccessibilityEvent(AccessibilityEvent event, View view) { final List eventText = event.getText(); int size = eventText.size(); @@ -379,4 +397,19 @@ public class ContactGridManager { isTimerStarted = false; } } + + private void updateDeviceNumberRow() { + if (isInMultiWindowMode || TextUtils.isEmpty(primaryCallState.callbackNumber)) { + deviceNumberTextView.setVisibility(View.GONE); + deviceNumberDivider.setVisibility(View.GONE); + return; + } + // This is used for carriers like Project Fi to show the callback number for emergency calls. + deviceNumberTextView.setText( + context.getString(R.string.contact_grid_callback_number, primaryCallState.callbackNumber)); + deviceNumberTextView.setVisibility(View.VISIBLE); + if (primaryInfo.shouldShowLocation) { + deviceNumberDivider.setVisibility(View.VISIBLE); + } + } } diff --git a/java/com/android/incallui/contactgrid/res/layout/device_number_row.xml b/java/com/android/incallui/contactgrid/res/layout/device_number_row.xml new file mode 100644 index 000000000..4f8bbad5a --- /dev/null +++ b/java/com/android/incallui/contactgrid/res/layout/device_number_row.xml @@ -0,0 +1,39 @@ + + + + + + + \ No newline at end of file diff --git a/java/com/android/incallui/contactgrid/res/values/ids.xml b/java/com/android/incallui/contactgrid/res/values/ids.xml index f3b111a16..03f5a3d81 100644 --- a/java/com/android/incallui/contactgrid/res/values/ids.xml +++ b/java/com/android/incallui/contactgrid/res/values/ids.xml @@ -29,4 +29,6 @@ + + diff --git a/java/com/android/incallui/incall/impl/InCallFragment.java b/java/com/android/incallui/incall/impl/InCallFragment.java index 73b414d46..a4dcd72a8 100644 --- a/java/com/android/incallui/incall/impl/InCallFragment.java +++ b/java/com/android/incallui/incall/impl/InCallFragment.java @@ -42,6 +42,7 @@ import android.widget.Toast; import com.android.dialer.common.Assert; import com.android.dialer.common.FragmentUtils; import com.android.dialer.common.LogUtil; +import com.android.dialer.compat.ActivityCompat; import com.android.dialer.logging.DialerImpression; import com.android.dialer.logging.Logger; import com.android.dialer.multimedia.MultimediaData; @@ -153,6 +154,7 @@ public class InCallFragment extends Fragment (ImageView) view.findViewById(R.id.contactgrid_avatar), getResources().getDimensionPixelSize(R.dimen.incall_avatar_size), true /* showAnonymousAvatar */); + contactGridManager.onMultiWindowModeChanged(ActivityCompat.isInMultiWindowMode(getActivity())); paginator = (InCallPaginator) view.findViewById(R.id.incall_paginator); pager = (LockableViewPager) view.findViewById(R.id.incall_pager); @@ -258,18 +260,9 @@ public class InCallFragment extends Fragment // Hide the avatar to make room for location contactGridManager.setAvatarHidden(true); - // Need to widen the contact grid to fit location information - View contactGridView = getView().findViewById(R.id.incall_contact_grid); - ViewGroup.LayoutParams params = contactGridView.getLayoutParams(); - if (params instanceof ViewGroup.MarginLayoutParams) { - ((ViewGroup.MarginLayoutParams) params).setMarginStart(0); - ((ViewGroup.MarginLayoutParams) params).setMarginEnd(0); - } - contactGridView.setLayoutParams(params); - // Need to let the dialpad move up a little further when location info is being shown View dialpadView = getView().findViewById(R.id.incall_dialpad_container); - params = dialpadView.getLayoutParams(); + ViewGroup.LayoutParams params = dialpadView.getLayoutParams(); if (params instanceof RelativeLayout.LayoutParams) { ((RelativeLayout.LayoutParams) params).removeRule(RelativeLayout.BELOW); } @@ -560,6 +553,7 @@ public class InCallFragment extends Fragment // Need to show or hide location showLocationUi(isInMultiWindowMode ? null : getLocationFragment()); } + contactGridManager.onMultiWindowModeChanged(isInMultiWindowMode); } private Fragment getLocationFragment() { diff --git a/java/com/android/incallui/incall/impl/res/layout/frag_incall_voice.xml b/java/com/android/incallui/incall/impl/res/layout/frag_incall_voice.xml index 73b9c267e..ccec8a4a4 100644 --- a/java/com/android/incallui/incall/impl/res/layout/frag_incall_voice.xml +++ b/java/com/android/incallui/incall/impl/res/layout/frag_incall_voice.xml @@ -36,8 +36,6 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="12dp" - android:layout_marginStart="@dimen/incall_window_margin_horizontal" - android:layout_marginEnd="@dimen/incall_window_margin_horizontal" android:gravity="center_horizontal" android:orientation="vertical"> @@ -51,7 +49,9 @@ + android:layout_height="wrap_content" + android:layout_marginStart="@dimen/incall_window_margin_horizontal" + android:layout_marginEnd="@dimen/incall_window_margin_horizontal"/> @@ -60,6 +60,8 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="4dp" + android:layout_marginStart="@dimen/incall_window_margin_horizontal" + android:layout_marginEnd="@dimen/incall_window_margin_horizontal" android:singleLine="true" android:textAppearance="@style/Dialer.Incall.TextAppearance.Large" app:autoResizeText_minTextSize="28sp" @@ -69,12 +71,19 @@ + android:layout_height="wrap_content" + android:layout_marginStart="@dimen/incall_window_margin_horizontal" + android:layout_marginEnd="@dimen/incall_window_margin_horizontal"/> + + + android:background="@android:color/background_dark" + android:visibility="gone"/> -- cgit v1.2.3