Merge "Disallow making a call to emergency numbers" am: ab856cb957 am: 6e1c1395cb am: d7098efcd1 am: 7a7734c16d
Change-Id: Ida066c7282aec89bbffc89d0c36be93a69d3e4e6
This commit is contained in:
@@ -979,4 +979,7 @@
|
|||||||
<string name="selected_sim_content_message"><xliff:g id="selected_sim">%s</xliff:g> selected</string>
|
<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>
|
<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>
|
</resources>
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ import androidx.recyclerview.widget.DefaultItemAnimator;
|
|||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import androidx.recyclerview.widget.RecyclerView.ViewHolder;
|
import androidx.recyclerview.widget.RecyclerView.ViewHolder;
|
||||||
|
import android.telephony.PhoneNumberUtils;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.view.ActionMode;
|
import android.view.ActionMode;
|
||||||
import android.view.Display;
|
import android.view.Display;
|
||||||
@@ -774,20 +775,27 @@ public class ConversationFragment extends Fragment implements ConversationDataLi
|
|||||||
case R.id.action_call:
|
case R.id.action_call:
|
||||||
final String phoneNumber = mBinding.getData().getParticipantPhoneNumber();
|
final String phoneNumber = mBinding.getData().getParticipantPhoneNumber();
|
||||||
Assert.notNull(phoneNumber);
|
Assert.notNull(phoneNumber);
|
||||||
final View targetView = getActivity().findViewById(R.id.action_call);
|
// Can't make a call to emergency numbers using ACTION_CALL.
|
||||||
Point centerPoint;
|
if (PhoneNumberUtils.isEmergencyNumber(phoneNumber)) {
|
||||||
if (targetView != null) {
|
UiUtils.showToast(R.string.disallow_emergency_call);
|
||||||
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 {
|
} else {
|
||||||
// In the overflow menu, just use the center of the screen.
|
final View targetView = getActivity().findViewById(R.id.action_call);
|
||||||
final Display display = getActivity().getWindowManager().getDefaultDisplay();
|
Point centerPoint;
|
||||||
centerPoint = new Point(display.getWidth() / 2, display.getHeight() / 2);
|
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;
|
return true;
|
||||||
|
|
||||||
case R.id.action_archive:
|
case R.id.action_archive:
|
||||||
|
|||||||
Reference in New Issue
Block a user