diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2017-11-30 00:41:06 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2017-11-30 00:41:06 +0000 |
commit | 226b01b4fb3a6342dd5acf5531d9c44744eab031 (patch) | |
tree | 04e535956686bb2a8ddc98977fb305faa19bb77f | |
parent | b33463c7cdf3a4d481767452d3a21c09527ffcb1 (diff) | |
parent | 1d62ab209130bdacdb64b2cd824b5ff35817b89f (diff) |
Merge "Enable timer in emergency call."
10 files changed, 210 insertions, 124 deletions
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"/> + <include + layout="@layout/device_number_row" + android:layout_width="match_parent" + android:layout_height="wrap_content"/> + <FrameLayout android:id="@+id/incall_data_container" android:layout_width="match_parent" diff --git a/java/com/android/incallui/calllocation/impl/res/layout/location_fragment.xml b/java/com/android/incallui/calllocation/impl/res/layout/location_fragment.xml index 53188eb19..b1601f9fd 100644 --- a/java/com/android/incallui/calllocation/impl/res/layout/location_fragment.xml +++ b/java/com/android/incallui/calllocation/impl/res/layout/location_fragment.xml @@ -17,117 +17,116 @@ --> <ViewAnimator xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:tools="http://schemas.android.com/tools" - android:id="@+id/location_view_animator" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_marginTop="16dp" - android:layout_marginBottom="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"> - - <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:id="@+id/location_loading_layout" + xmlns:tools="http://schemas.android.com/tools" + android:id="@+id/location_view_animator" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_gravity="center_vertical" - android:orientation="vertical"> + 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"> - <ProgressBar - android:id="@+id/location_loading_spinner" - android:layout_width="wrap_content" + <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/location_loading_layout" + android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginTop="28dp" - android:layout_marginBottom="12dp" - android:layout_gravity="center_horizontal"/> + android:layout_gravity="center_vertical" + android:orientation="vertical"> + + <ProgressBar + android:id="@+id/location_loading_spinner" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginTop="28dp" + android:layout_marginBottom="12dp" + android:layout_gravity="center_horizontal"/> <TextView - 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_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"/> </LinearLayout> <GridLayout xmlns:android="http://schemas.android.com/apk/res/android" - 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_layout" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_gravity="center" + android:columnCount="2" + android:orientation="horizontal"> <TextView - 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_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"/> <ImageView - 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/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"/> <TextView - 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_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"/> <TextView - 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/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"/> <TextView - 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"/> + 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"/> </GridLayout> 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<CharSequence> 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 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ Copyright (C) 2017 The Android Open Source Project + ~ + ~ Licensed under the Apache License, Version 2.0 (the "License"); + ~ you may not use this file except in compliance with the License. + ~ You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, software + ~ distributed under the License is distributed on an "AS IS" BASIS, + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ~ See the License for the specific language governing permissions and + ~ limitations under the License + --> +<merge xmlns:android="http://schemas.android.com/apk/res/android"> + <View + android:id="@+id/contactgrid_location_divider" + android:layout_width="match_parent" + android:layout_height="1dp" + android:layout_gravity="bottom" + android:background="#D8D8D8" + android:visibility="gone"/> + + <TextView + android:id="@+id/contactgrid_device_number_text" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginBottom="16dp" + android:padding="16dp" + android:background="@android:color/white" + android:elevation="2dp" + android:gravity="start" + android:orientation="vertical" + android:textColor="#DD000000" + android:textSize="16sp" + android:visibility="gone"/> +</merge>
\ 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 @@ <item name="contactgrid_top_row" type="id"/> <item name="contactgrid_bottom_row" type="id"/> <item name="contactgrid_top_row_space" type="id"/> + <item name="contactgrid_location_divider" type="id"/> + <item name="contactgrid_device_number_text" type="id"/> </resources> 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 @@ <include layout="@layout/incall_contactgrid_top_row" android:layout_width="wrap_content" - android:layout_height="wrap_content"/> + android:layout_height="wrap_content" + android:layout_marginStart="@dimen/incall_window_margin_horizontal" + android:layout_marginEnd="@dimen/incall_window_margin_horizontal"/> <!-- We have to keep deprecated singleLine to allow long text being truncated with ellipses. a bug --> @@ -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 @@ <include layout="@layout/incall_contactgrid_bottom_row" android:layout_width="wrap_content" - android:layout_height="wrap_content"/> + android:layout_height="wrap_content" + android:layout_marginStart="@dimen/incall_window_margin_horizontal" + android:layout_marginEnd="@dimen/incall_window_margin_horizontal"/> <FrameLayout android:id="@+id/incall_location_holder" android:layout_width="match_parent" android:layout_height="match_parent"/> + + <include + layout="@layout/device_number_row" + android:layout_width="match_parent" + android:layout_height="wrap_content"/> </LinearLayout> <com.android.dialer.widget.LockableViewPager @@ -123,6 +132,6 @@ android:layout_width="match_parent" android:layout_height="0dp" android:layout_gravity="bottom" - android:visibility="gone" - android:background="@android:color/background_dark"/> + android:background="@android:color/background_dark" + android:visibility="gone"/> </FrameLayout> |