Ask before calling

This commit is contained in:
Ivan K
2022-03-15 17:55:40 +03:00
parent 702f6a30e9
commit 2be35b4877
3 changed files with 20 additions and 1 deletions

View File

@@ -1680,7 +1680,7 @@ public class AlertsCreator {
AlertDialog dialog = new AlertDialog.Builder(context).setView(frameLayout)
.setPositiveButton(LocaleController.getString("Call", R.string.Call), (dialogInterface, i) -> {
final TLRPC.UserFull userFull = fragment.getMessagesController().getUserFull(user.id);
VoIPHelper.startCall(user, videoCall, userFull != null && userFull.video_calls_available, fragment.getParentActivity(), userFull, fragment.getAccountInstance());
VoIPHelper.startCall(user, videoCall, userFull != null && userFull.video_calls_available, fragment.getParentActivity(), userFull, fragment.getAccountInstance(), true);
})
.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null)
.create();

View File

@@ -69,6 +69,10 @@ public class VoIPHelper {
private static final int VOIP_SUPPORT_ID = 4244000;
public static void startCall(TLRPC.User user, boolean videoCall, boolean canVideoCall, final Activity activity, TLRPC.UserFull userFull, AccountInstance accountInstance) {
startCall(user, videoCall, canVideoCall, activity, userFull, accountInstance, false);
}
public static void startCall(TLRPC.User user, boolean videoCall, boolean canVideoCall, final Activity activity, TLRPC.UserFull userFull, AccountInstance accountInstance, boolean confirmed) {
if (userFull != null && userFull.phone_calls_private) {
new AlertDialog.Builder(activity)
.setTitle(LocaleController.getString("VoipFailed", R.string.VoipFailed))
@@ -78,6 +82,18 @@ public class VoIPHelper {
.show();
return;
}
if (!confirmed) {
new AlertDialog.Builder(activity)
.setTitle(LocaleController.getString("ConfirmCall", R.string.ConfirmCall))
.setMessage(AndroidUtilities.replaceTags(LocaleController.formatString("CallTo", R.string.CallTo,
ContactsController.formatName(user.first_name, user.last_name))))
.setPositiveButton(LocaleController.getString("OK", R.string.OK), (dialog, which) -> startCall(user, videoCall, canVideoCall, activity, userFull, accountInstance, true))
.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null)
.show();
return;
}
if (ConnectionsManager.getInstance(UserConfig.selectedAccount).getConnectionState() != ConnectionsManager.ConnectionStateConnected) {
boolean isAirplaneMode = Settings.System.getInt(activity.getContentResolver(), Settings.System.AIRPLANE_MODE_ON, 0) != 0;
AlertDialog.Builder bldr = new AlertDialog.Builder(activity)

View File

@@ -44,4 +44,7 @@
<string name="Media">Media</string>
<string name="RearVideoMessages">Rear Camera in Video Messages</string>
<string name="ConfirmCall">Confirm call</string>
<string name="CallTo">Call to **%1$s**?</string>
</resources>