private void CallAdapter_OnVideoCallClick(object sender, AddNewCall_AdapterClickEventArgs adapterClickEvents)
        {
            try
            {
                TimeNow = DateTime.Now.ToString("hh:mm");
                Int32 unixTimestamp = (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
                Time = Convert.ToString(unixTimestamp);

                var Position = adapterClickEvents.Position;
                if (Position >= 0)
                {
                    var item = CallAdapter.GetItem(Position);
                    if (item != null)
                    {
                        Intent IntentOfvideoCall = new Intent(this, typeof(TwilioVideoCallActivity));
                        if (AppSettings.Use_Agora_Library && AppSettings.Use_Twilio_Library == false)
                        {
                            IntentOfvideoCall = new Intent(this, typeof(AgoraVideoCallActivity));
                            IntentOfvideoCall.PutExtra("type", "Agora_video_calling_start");
                        }
                        else if (AppSettings.Use_Agora_Library == false && AppSettings.Use_Twilio_Library)
                        {
                            IntentOfvideoCall = new Intent(this, typeof(TwilioVideoCallActivity));
                            IntentOfvideoCall.PutExtra("type", "Twilio_video_calling_start");
                        }

                        IntentOfvideoCall.PutExtra("UserID", item.UserId);
                        IntentOfvideoCall.PutExtra("avatar", item.Avatar);
                        IntentOfvideoCall.PutExtra("name", item.Name);
                        IntentOfvideoCall.PutExtra("time", TimeNow);
                        IntentOfvideoCall.PutExtra("CallID", Time);
                        IntentOfvideoCall.PutExtra("access_token", "YOUR_TOKEN");
                        IntentOfvideoCall.PutExtra("access_token_2", "YOUR_TOKEN");
                        IntentOfvideoCall.PutExtra("from_id", "0");
                        IntentOfvideoCall.PutExtra("active", "0");
                        IntentOfvideoCall.PutExtra("status", "0");
                        IntentOfvideoCall.PutExtra("room_name", "TestRoom");

                        StartActivity(IntentOfvideoCall);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Example #2
0
        private void MAdapterOnCallClick(object sender, Last_Calls_AdapterClickEventArgs adapterClickEvents)
        {
            try
            {
                TimeNow = DateTime.Now.ToString("hh:mm");
                Int32 unixTimestamp = (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
                Time = Convert.ToString(unixTimestamp);

                if (AppSettings.Enable_Audio_Call && AppSettings.Enable_Video_Call)
                {
                    AlertDialog.Builder builder = new AlertDialog.Builder(Activity, Resource.Style.AlertDialogCustom);
                    var dd = this.GetText(Resource.String.Lbl_Call);
                    builder.SetTitle(this.GetText(Resource.String.Lbl_Call));
                    builder.SetMessage(this.GetText(Resource.String.Lbl_Select_Type_Call));

                    builder.SetPositiveButton(this.GetText(Resource.String.Lbl_Voice_call), delegate(object o, DialogClickEventArgs args)
                    {
                        try
                        {
                            var Position = adapterClickEvents.Position;
                            if (Position >= 0)
                            {
                                var item = mAdapter.GetItem(Position);
                                if (item != null)
                                {
                                    Intent IntentOfvideoCall =
                                        new Intent(this.Context, typeof(TwilioVideoCallActivity));
                                    if (AppSettings.Use_Agora_Library && AppSettings.Use_Twilio_Library == false)
                                    {
                                        IntentOfvideoCall = new Intent(this.Context, typeof(AgoraAudioCallActivity));
                                        IntentOfvideoCall.PutExtra("type", "Agora_audio_calling_start");
                                    }
                                    else if (AppSettings.Use_Agora_Library == false && AppSettings.Use_Twilio_Library)
                                    {
                                        IntentOfvideoCall = new Intent(this.Context, typeof(TwilioAudioCallActivity));
                                        IntentOfvideoCall.PutExtra("type", "Twilio_audio_calling_start");
                                    }

                                    IntentOfvideoCall.PutExtra("UserID", item.user_id);
                                    IntentOfvideoCall.PutExtra("avatar", item.avatar);
                                    IntentOfvideoCall.PutExtra("name", item.name);
                                    IntentOfvideoCall.PutExtra("time", TimeNow);
                                    IntentOfvideoCall.PutExtra("CallID", Time);
                                    StartActivity(IntentOfvideoCall);
                                }
                            }
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(e);
                        }
                    });

                    builder.SetNegativeButton(this.GetText(Resource.String.Lbl_Video_call), delegate(object o, DialogClickEventArgs args)
                    {
                        try
                        {
                            var Position = adapterClickEvents.Position;
                            if (Position >= 0)
                            {
                                var item = mAdapter.GetItem(Position);
                                if (item != null)
                                {
                                    Intent IntentOfvideoCall =
                                        new Intent(this.Context, typeof(TwilioVideoCallActivity));
                                    if (AppSettings.Use_Agora_Library && AppSettings.Use_Twilio_Library == false)
                                    {
                                        IntentOfvideoCall = new Intent(this.Context, typeof(AgoraVideoCallActivity));
                                        IntentOfvideoCall.PutExtra("type", "Agora_video_calling_start");
                                    }
                                    else if (AppSettings.Use_Agora_Library == false && AppSettings.Use_Twilio_Library)
                                    {
                                        IntentOfvideoCall = new Intent(this.Context, typeof(TwilioVideoCallActivity));
                                        IntentOfvideoCall.PutExtra("type", "Twilio_video_calling_start");
                                    }

                                    IntentOfvideoCall.PutExtra("UserID", item.user_id);
                                    IntentOfvideoCall.PutExtra("avatar", item.avatar);
                                    IntentOfvideoCall.PutExtra("name", item.name);
                                    IntentOfvideoCall.PutExtra("time", TimeNow);
                                    IntentOfvideoCall.PutExtra("CallID", Time);
                                    IntentOfvideoCall.PutExtra("access_token", "YOUR_TOKEN");
                                    IntentOfvideoCall.PutExtra("access_token_2", "YOUR_TOKEN");
                                    IntentOfvideoCall.PutExtra("from_id", "0");
                                    IntentOfvideoCall.PutExtra("active", "0");
                                    IntentOfvideoCall.PutExtra("status", "0");
                                    IntentOfvideoCall.PutExtra("room_name", "TestRoom");
                                    StartActivity(IntentOfvideoCall);
                                }
                            }
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(e);
                        }
                    });

                    var alert = builder.Create();
                    alert.Show();
                }
                else if (AppSettings.Enable_Audio_Call == false && AppSettings.Enable_Video_Call) // Video Call On
                {
                    try
                    {
                        var Position = adapterClickEvents.Position;
                        if (Position >= 0)
                        {
                            var item = mAdapter.GetItem(Position);
                            if (item != null)
                            {
                                Intent IntentOfvideoCall = new Intent(this.Context, typeof(TwilioVideoCallActivity));
                                if (AppSettings.Use_Agora_Library && AppSettings.Use_Twilio_Library == false)
                                {
                                    IntentOfvideoCall = new Intent(this.Context, typeof(AgoraVideoCallActivity));
                                    IntentOfvideoCall.PutExtra("type", "Agora_video_calling_start");
                                }
                                else if (AppSettings.Use_Agora_Library == false && AppSettings.Use_Twilio_Library)
                                {
                                    IntentOfvideoCall = new Intent(this.Context, typeof(TwilioVideoCallActivity));
                                    IntentOfvideoCall.PutExtra("type", "Twilio_video_calling_start");
                                }

                                IntentOfvideoCall.PutExtra("UserID", item.user_id);
                                IntentOfvideoCall.PutExtra("avatar", item.avatar);
                                IntentOfvideoCall.PutExtra("name", item.name);
                                IntentOfvideoCall.PutExtra("time", TimeNow);
                                IntentOfvideoCall.PutExtra("CallID", Time);
                                IntentOfvideoCall.PutExtra("access_token", "YOUR_TOKEN");
                                IntentOfvideoCall.PutExtra("access_token_2", "YOUR_TOKEN");
                                IntentOfvideoCall.PutExtra("from_id", "0");
                                IntentOfvideoCall.PutExtra("active", "0");
                                IntentOfvideoCall.PutExtra("status", "0");
                                IntentOfvideoCall.PutExtra("room_name", "TestRoom");
                                StartActivity(IntentOfvideoCall);
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                    }
                }
                else if (AppSettings.Enable_Audio_Call && AppSettings.Enable_Video_Call == false) // Audio Call On
                {
                    try
                    {
                        var Position = adapterClickEvents.Position;
                        if (Position >= 0)
                        {
                            var item = mAdapter.GetItem(Position);
                            if (item != null)
                            {
                                Intent IntentOfvideoCall = new Intent(this.Context, typeof(TwilioVideoCallActivity));
                                if (AppSettings.Use_Agora_Library && AppSettings.Use_Twilio_Library == false)
                                {
                                    IntentOfvideoCall = new Intent(this.Context, typeof(AgoraAudioCallActivity));
                                    IntentOfvideoCall.PutExtra("type", "Agora_audio_calling_start");
                                }
                                else if (AppSettings.Use_Agora_Library == false && AppSettings.Use_Twilio_Library)
                                {
                                    IntentOfvideoCall = new Intent(this.Context, typeof(TwilioAudioCallActivity));
                                    IntentOfvideoCall.PutExtra("type", "Twilio_audio_calling_start");
                                }

                                IntentOfvideoCall.PutExtra("UserID", item.user_id);
                                IntentOfvideoCall.PutExtra("avatar", item.avatar);
                                IntentOfvideoCall.PutExtra("name", item.name);
                                IntentOfvideoCall.PutExtra("time", TimeNow);
                                IntentOfvideoCall.PutExtra("CallID", Time);
                                IntentOfvideoCall.PutExtra("access_token", "YOUR_TOKEN");
                                IntentOfvideoCall.PutExtra("access_token_2", "YOUR_TOKEN");
                                IntentOfvideoCall.PutExtra("from_id", "0");
                                IntentOfvideoCall.PutExtra("active", "0");
                                IntentOfvideoCall.PutExtra("status", "0");
                                IntentOfvideoCall.PutExtra("room_name", "TestRoom");
                                StartActivity(IntentOfvideoCall);
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }