Merge "Disallow making a call to emergency numbers" am: ab856cb957 am: 6e1c1395cb am: d7098efcd1

Change-Id: I6e16540cd48488d468656aa15f367205a6948997
This commit is contained in:
Treehugger Robot
2020-05-25 21:37:07 +00:00
committed by Automerger Merge Worker
2 changed files with 23 additions and 12 deletions

View File

@@ -979,4 +979,7 @@
<string name="selected_sim_content_message"><xliff:g id="selected_sim">%s</xliff:g> selected</string>
<string name="work_directory_display_name">Work Profile contacts</string>
<!-- When making a call to emergency numbers, show this toast -->
<string name="disallow_emergency_call">Can\'t make a voice call to emergency services here.</string>
</resources>

View File

@@ -51,6 +51,7 @@ import androidx.recyclerview.widget.DefaultItemAnimator;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.RecyclerView.ViewHolder;
import android.telephony.PhoneNumberUtils;
import android.text.TextUtils;
import android.view.ActionMode;
import android.view.Display;
@@ -774,20 +775,27 @@ public class ConversationFragment extends Fragment implements ConversationDataLi
case R.id.action_call:
final String phoneNumber = mBinding.getData().getParticipantPhoneNumber();
Assert.notNull(phoneNumber);
final View targetView = getActivity().findViewById(R.id.action_call);
Point centerPoint;
if (targetView != null) {
final int screenLocation[] = new int[2];
targetView.getLocationOnScreen(screenLocation);
final int centerX = screenLocation[0] + targetView.getWidth() / 2;
final int centerY = screenLocation[1] + targetView.getHeight() / 2;
centerPoint = new Point(centerX, centerY);
// Can't make a call to emergency numbers using ACTION_CALL.
if (PhoneNumberUtils.isEmergencyNumber(phoneNumber)) {
UiUtils.showToast(R.string.disallow_emergency_call);
} else {
// In the overflow menu, just use the center of the screen.
final Display display = getActivity().getWindowManager().getDefaultDisplay();
centerPoint = new Point(display.getWidth() / 2, display.getHeight() / 2);
final View targetView = getActivity().findViewById(R.id.action_call);
Point centerPoint;
if (targetView != null) {
final int screenLocation[] = new int[2];
targetView.getLocationOnScreen(screenLocation);
final int centerX = screenLocation[0] + targetView.getWidth() / 2;
final int centerY = screenLocation[1] + targetView.getHeight() / 2;
centerPoint = new Point(centerX, centerY);
} else {
// In the overflow menu, just use the center of the screen.
final Display display =
getActivity().getWindowManager().getDefaultDisplay();
centerPoint = new Point(display.getWidth() / 2, display.getHeight() / 2);
}
UIIntents.get()
.launchPhoneCallActivity(getActivity(), phoneNumber, centerPoint);
}
UIIntents.get().launchPhoneCallActivity(getActivity(), phoneNumber, centerPoint);
return true;
case R.id.action_archive: