예제 #1
0
        private void InitComponent()
        {
            try
            {
                var media = new MediaController(this);
                media.Show(5000);

                ProgressBar            = FindViewById <ProgressBar>(Resource.Id.progress_bar);
                ProgressBar.Visibility = ViewStates.Visible;

                PostVideoView             = FindViewById <VideoView>(Resource.Id.videoView);
                PostVideoView.Completion += PostVideoViewOnCompletion;
                PostVideoView.SetMediaController(media);
                PostVideoView.Prepared += PostVideoViewOnPrepared;
                PostVideoView.CanSeekBackward();
                PostVideoView.CanSeekForward();
                PostVideoView.SetAudioAttributes(new AudioAttributes.Builder().SetUsage(AudioUsageKind.Media).SetContentType(AudioContentType.Movie).Build());

                if (VideoUrl.Contains("http"))
                {
                    PostVideoView.SetVideoURI(Uri.Parse(VideoUrl));
                }
                else
                {
                    PostVideoView.SetVideoPath(VideoUrl);
                }

                MsgTabbedMainActivity.GetInstance()?.SetWakeLock();
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
예제 #2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            try
            {
                base.OnCreate(savedInstanceState);
                SetTheme(AppSettings.SetTabDarkTheme ? Resource.Style.MyTheme_Dark_Base : Resource.Style.MyTheme_Base);
                Methods.App.FullScreenApp(this);

                // Create your application here
                SetContentView(Resource.Layout.CreateGroupChatLayout);

                TypePage = Intent?.GetStringExtra("Type") ?? "";
                string obj = Intent?.GetStringExtra("GroupObject") ?? "";
                if (!string.IsNullOrEmpty(obj))
                {
                    GroupData = JsonConvert.DeserializeObject <ChatObject>(obj);
                    GroupId   = GroupData.GroupId;
                }

                GlobalContext = MsgTabbedMainActivity.GetInstance();

                //Get Value And Set Toolbar
                InitComponent();
                InitToolbar();
                SetRecyclerViewAdapters();

                LoadContacts();
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
        //========================= Functions =========================
        public static async Task SendMessageTask(GroupChatWindowActivity windowActivity, string id, string messageId, string text = "", string contact = "", string pathFile = "", string imageUrl = "", string stickerId = "", string gifUrl = "", string lat = "", string lng = "")
        {
            try
            {
                MainWindowActivity = windowActivity;
                if (windowActivity.GroupData != null)
                {
                    GroupData = windowActivity.GroupData;
                }

                GlobalContext = MsgTabbedMainActivity.GetInstance();

                if (AppSettings.EnableVideoCompress && Methods.AttachmentFiles.Check_FileExtension(pathFile) == "Video")
                {
                    File destinationPath = new File(Methods.Path.FolderDcimVideo + "/Compressor");

                    if (!Directory.Exists(destinationPath.Path))
                    {
                        Directory.CreateDirectory(destinationPath.Path);
                    }

                    await Task.Factory.StartNew(() => new VideoCompressAsyncTask(windowActivity, id, messageId, text, pathFile).Execute("false", pathFile, destinationPath.Path));
                }
                else
                {
                    StartApiService(id, messageId, text, contact, pathFile, imageUrl, stickerId, gifUrl, lat, lng);
                }

                await Task.Delay(0);
            }
            catch (Exception ex)
            {
                Methods.DisplayReportResultTrack(ex);
            }
        }
예제 #4
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            try
            {
                base.OnCreate(savedInstanceState);

                Methods.App.FullScreenApp(this);

                Window?.AddFlags(WindowManagerFlags.KeepScreenOn);

                // Create your application here
                SetContentView(Resource.Layout.TwilioAudioCallActivityLayout);

                SensorManager = (SensorManager)GetSystemService(SensorService);
                Proximity     = SensorManager?.GetDefaultSensor(SensorType.Proximity);

                GlobalContext = MsgTabbedMainActivity.GetInstance();

                //Get Value And Set Toolbar
                InitComponent();
                InitTwilioCall();
                MsgTabbedMainActivity.RunCall = true;
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
예제 #5
0
        private void ShowEmptyPage()
        {
            try
            {
                if (MAdapter.GroupList.Count > 0)
                {
                    MRecycler.Visibility        = ViewStates.Visible;
                    EmptyStateLayout.Visibility = ViewStates.Gone;
                }
                else
                {
                    MRecycler.Visibility = ViewStates.Gone;

                    if (AppSettings.LastChatSystem == SystemApiGetLastChat.Old)
                    {
                        var tabLayoutFriendRequest = MsgTabbedMainActivity.GetInstance()?.LastGroupChatsTab?.LayoutGroupRequest;
                        if (tabLayoutFriendRequest != null)
                        {
                            tabLayoutFriendRequest.Visibility = ViewStates.Gone;
                        }
                    }

                    if (Inflated == null)
                    {
                        Inflated = EmptyStateLayout.Inflate();
                    }

                    EmptyStateInflater x = new EmptyStateInflater();
                    x.InflateLayout(Inflated, EmptyStateInflater.Type.NoGroupRequest);
                    if (!x.EmptyStateButton.HasOnClickListeners)
                    {
                        x.EmptyStateButton.Click += null;
                    }
                    EmptyStateLayout.Visibility = ViewStates.Visible;
                }

                if (ListUtils.GroupRequestsList.Count == 0)
                {
                    if (MsgTabbedMainActivity.GetInstance()?.LastGroupChatsTab != null)
                    {
                        MsgTabbedMainActivity.GetInstance().LastGroupChatsTab.LayoutGroupRequest.Visibility = ViewStates.Gone;
                    }
                }
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
예제 #6
0
        public override void OnBackPressed()
        {
            try
            {
                PostVideoView?.StopPlayback();
                PostVideoView = null;

                MsgTabbedMainActivity.GetInstance()?.OffWakeLock();

                base.OnBackPressed();
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
                base.OnBackPressed();
            }
        }
예제 #7
0
 // Function Call
 public void Insert(Classes.CallUser call)
 {
     try
     {
         var check = MCallUser.FirstOrDefault(a => a.Id == call.Id);
         if (check == null)
         {
             MCallUser.Insert(0, call);
             NotifyItemInserted(0);
             MsgTabbedMainActivity.GetInstance().LastCallsTab.MRecycler?.ScrollToPosition(0);
         }
     }
     catch (Exception e)
     {
         Methods.DisplayReportResultTrack(e);
     }
 }
예제 #8
0
        //========================= Functions =========================
        public static async Task SendMessageTask(ChatWindowActivity windowActivity, string userId, string messageHashId, string text = "", string contact = "", string filePath = "", string imageUrl = "", string stickerId = "", string gifUrl = "", string productId = "", string lat = "", string lng = "")
        {
            try
            {
                WindowActivity = windowActivity;
                if (windowActivity.DataUser != null)
                {
                    DataUser = windowActivity.DataUser;
                }
                else if (windowActivity.UserData != null)
                {
                    UserData = windowActivity.UserData;
                }
                else if (windowActivity.DataUserChat != null)
                {
                    DataUserChat = windowActivity.DataUserChat;
                }

                GlobalContext = MsgTabbedMainActivity.GetInstance();

                if (Methods.AttachmentFiles.Check_FileExtension(filePath) == "Video")
                {
                    File destinationPath = new File(Methods.Path.FolderDcimVideo + "/Compressor");

                    if (!Directory.Exists(destinationPath.Path))
                    {
                        Directory.CreateDirectory(destinationPath.Path);
                    }

                    await Task.Factory.StartNew(() => new VideoCompressAsyncTask(windowActivity, userId, messageHashId, text, filePath).Execute("false", filePath, destinationPath.Path));
                }
                else
                {
                    StartApiService(userId, messageHashId, text, contact, filePath, imageUrl, stickerId, gifUrl, productId, lat, lng);
                }

                await Task.Delay(0);
            }
            catch (Exception ex)
            {
                Methods.DisplayReportResultTrack(ex);
            }
        }
예제 #9
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            try
            {
                base.OnCreate(savedInstanceState);
                SetTheme(AppSettings.SetTabDarkTheme ? Resource.Style.MyTheme_Dark_Base : Resource.Style.MyTheme_Base);
                Methods.App.FullScreenApp(this);

                // Create your application here
                SetContentView(Resource.Layout.CreateGroupChatLayout);

                GlobalContext = MsgTabbedMainActivity.GetInstance();

                //Get Value And Set Toolbar
                InitComponent();
                InitToolbar();
                SetRecyclerViewAdapters();
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
예제 #10
0
 public void OnSensorChanged(SensorEvent e)
 {
     try
     {
         if (e.Sensor.Type == SensorType.Proximity)
         {
             if (e.Values[0] >= -SensorSensitivity && e.Values[0] <= SensorSensitivity)
             {
                 //near
                 MsgTabbedMainActivity.GetInstance()?.SetOffWakeLock();
             }
             else
             {
                 //far
                 MsgTabbedMainActivity.GetInstance()?.SetOnWakeLock();
             }
         }
     }
     catch (Exception exception)
     {
         Methods.DisplayReportResultTrack(exception);
     }
 }
        private void ShowEmptyPage()
        {
            try
            {
                if (MAdapter.GroupList.Count > 0)
                {
                    MRecycler.Visibility        = ViewStates.Visible;
                    EmptyStateLayout.Visibility = ViewStates.Gone;
                }
                else
                {
                    MRecycler.Visibility = ViewStates.Gone;

                    var adapter   = MsgTabbedMainActivity.GetInstance().LastChatTab?.MAdapter;
                    var checkList = adapter?.LastChatsList?.FirstOrDefault(q => q.Type == Classes.ItemType.GroupRequest);
                    if (checkList != null)
                    {
                        adapter.LastChatsList.Remove(checkList);
                        adapter.NotifyDataSetChanged();
                    }

                    Inflated ??= EmptyStateLayout.Inflate();

                    EmptyStateInflater x = new EmptyStateInflater();
                    x.InflateLayout(Inflated, EmptyStateInflater.Type.NoGroupRequest);
                    if (!x.EmptyStateButton.HasOnClickListeners)
                    {
                        x.EmptyStateButton.Click += null;
                    }
                    EmptyStateLayout.Visibility = ViewStates.Visible;
                }
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
예제 #12
0
        public static void UpdateRecyclerLastMessageView(MessageData result, GetUsersListObject.User user, int index, MsgTabbedMainActivity context)
        {
            try
            {
                if (IsImageExtension(result.MediaFileName))
                {
                    result.Text = WindowActivity?.GetText(Resource.String.Lbl_SendImageFile);
                }
                else if (IsVideoExtension(result.MediaFileName))
                {
                    result.Text = WindowActivity?.GetText(Resource.String.Lbl_SendVideoFile);
                }
                else if (IsAudioExtension(result.MediaFileName))
                {
                    result.Text = WindowActivity?.GetText(Resource.String.Lbl_SendAudioFile);
                }
                else if (IsFileExtension(result.MediaFileName))
                {
                    result.Text = WindowActivity?.GetText(Resource.String.Lbl_SendFile);
                }
                else if (result.MediaFileName.Contains(".gif") || result.MediaFileName.Contains(".GIF"))
                {
                    result.Text = WindowActivity?.GetText(Resource.String.Lbl_SendGifFile);
                }
                else
                {
                    result.Text = Methods.FunString.DecodeString(result.Text);
                }

                context.Activity?.RunOnUiThread(() =>
                {
                    try
                    {
                        context.LastChatTab?.MAdapter?.NotifyItemChanged(index, "WithoutBlob");
                    }
                    catch (Exception e)
                    {
                        Methods.DisplayReportResultTrack(e);
                    }
                });

                SqLiteDatabase dbDatabase = new SqLiteDatabase();
                //Update All data users to database
                dbDatabase.Insert_Or_Update_LastUsersChat(GlobalContext.Context, new ObservableCollection <GetUsersListObject.User> {
                    user
                });
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
 public override void OnCreate(Bundle savedInstanceState)
 {
     base.OnCreate(savedInstanceState);
     // Create your fragment here
     ContextMain = MsgTabbedMainActivity.GetInstance();
 }
예제 #14
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            try
            {
                base.OnCreate(savedInstanceState);
                SetContentView(Resource.Layout.AgoraVideoCallActivityLayout);

                GlobalContext = MsgTabbedMainActivity.GetInstance();

                SensorManager = (SensorManager)GetSystemService(SensorService);
                Proximity     = SensorManager.GetDefaultSensor(SensorType.Proximity);

                UserId = Intent?.GetStringExtra("UserID");
                Avatar = Intent?.GetStringExtra("avatar");
                Name   = Intent?.GetStringExtra("name");

                var dataCallId = Intent?.GetStringExtra("CallID") ?? "Data not available";
                if (dataCallId != "Data not available" && !string.IsNullOrEmpty(dataCallId))
                {
                    CallId = dataCallId;

                    FromId = Intent?.GetStringExtra("from_id");
                    Active = Intent?.GetStringExtra("active");
                    var time = Intent?.GetStringExtra("time");
                    Status   = Intent?.GetStringExtra("status");
                    RoomName = Intent?.GetStringExtra("room_name");
                    CallType = Intent?.GetStringExtra("type");
                    Console.WriteLine(time);
                }

                SwitchCamButton = FindViewById <Button>(Resource.Id.switch_cam_button);
                MuteVideoButton = FindViewById <CircleButton>(Resource.Id.mute_video_button);
                EndCallButton   = FindViewById <CircleButton>(Resource.Id.end_call_button);
                MuteAudioButton = FindViewById <CircleButton>(Resource.Id.mute_audio_button);

                UserInfoviewContainer    = FindViewById <RelativeLayout>(Resource.Id.userInfoview_container);
                UserImageView            = FindViewById <ImageView>(Resource.Id.userImageView);
                UserNameTextView         = FindViewById <TextView>(Resource.Id.userNameTextView);
                NoteTextView             = FindViewById <TextView>(Resource.Id.noteTextView);
                PictureInToPictureButton = FindViewById <ImageView>(Resource.Id.pictureintopictureButton);

                if (!PackageManager.HasSystemFeature(PackageManager.FeaturePictureInPicture))
                {
                    PictureInToPictureButton.Visibility = ViewStates.Gone;
                }

                SwitchCamButton.Click          += Switch_cam_button_Click;
                MuteVideoButton.Click          += Mute_video_button_Click;
                EndCallButton.Click            += End_call_button_Click;
                MuteAudioButton.Click          += Mute_audio_button_Click;
                PictureInToPictureButton.Click += PictureInToPictureButton_Click;

                LoadUserInfo();

                if (CallType == "Agora_video_calling_start")
                {
                    Start_Call_Action("call");
                }
                else
                {
                    Start_Call_Action("recieve_call");
                }
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
예제 #15
0
        private void SetTheme(Activity activity, string color)
        {
            try
            {
                if (color.Contains("b582af"))
                {
                    activity.SetTheme(Resource.Style.Chatththemeb582af);
                }
                else if (color.Contains("a84849"))
                {
                    activity.SetTheme(Resource.Style.Chatththemea84849);
                }
                else if (color.Contains("f9c270"))
                {
                    activity.SetTheme(Resource.Style.Chatththemef9c270);
                }
                else if (color.Contains("70a0e0"))
                {
                    activity.SetTheme(Resource.Style.Chatththeme70a0e0);
                }
                else if (color.Contains("56c4c5"))
                {
                    activity.SetTheme(Resource.Style.Chatththeme56c4c5);
                }
                else if (color.Contains("f33d4c"))
                {
                    activity.SetTheme(Resource.Style.Chatththemef33d4c);
                }
                else if (color.Contains("a1ce79"))
                {
                    activity.SetTheme(Resource.Style.Chatththemea1ce79);
                }
                else if (color.Contains("a085e2"))
                {
                    activity.SetTheme(Resource.Style.Chatththemea085e2);
                }
                else if (color.Contains("ed9e6a"))
                {
                    activity.SetTheme(Resource.Style.Chatththemeed9e6a);
                }
                else if (color.Contains("2b87ce"))
                {
                    activity.SetTheme(Resource.Style.Chatththeme2b87ce);
                }
                else if (color.Contains("f2812b"))
                {
                    activity.SetTheme(Resource.Style.Chatththemef2812b);
                }
                else if (color.Contains("0ba05d"))
                {
                    activity.SetTheme(Resource.Style.Chatththeme0ba05d);
                }
                else if (color.Contains("0e71ea"))
                {
                    activity.SetTheme(Resource.Style.Chatththeme0e71ea);
                }
                else if (color.Contains("aa2294"))
                {
                    activity.SetTheme(Resource.Style.Chatththemeaa2294);
                }
                else if (color.Contains("f9a722"))
                {
                    activity.SetTheme(Resource.Style.Chatththemef9a722);
                }
                else if (color.Contains("008484"))
                {
                    activity.SetTheme(Resource.Style.Chatththeme008484);
                }
                else if (color.Contains("5462a5"))
                {
                    activity.SetTheme(Resource.Style.Chatththeme5462a5);
                }
                else if (color.Contains("fc9cde"))
                {
                    activity.SetTheme(Resource.Style.Chatththemefc9cde);
                }
                else if (color.Contains("fc9cde"))
                {
                    activity.SetTheme(Resource.Style.Chatththemefc9cde);
                }
                else if (color.Contains("51bcbc"))
                {
                    activity.SetTheme(Resource.Style.Chatththeme51bcbc);
                }
                else if (color.Contains("c9605e"))
                {
                    activity.SetTheme(Resource.Style.Chatththemec9605e);
                }
                else if (color.Contains("01a5a5"))
                {
                    activity.SetTheme(Resource.Style.Chatththeme01a5a5);
                }
                else if (color.Contains("056bba"))
                {
                    activity.SetTheme(Resource.Style.Chatththeme056bba);
                }
                else
                {
                    //Default Color >> AppSettings.MainColor
                    activity.SetTheme(Resource.Style.Chatththemedefault);
                }

                var dataUser = MsgTabbedMainActivity.GetInstance().LastChatTab.MAdapter.ChatList?.FirstOrDefault(a => a.UserId == UserId);
                if (dataUser != null)
                {
                    dataUser.LastMessage.LastMessageClass.ChatColor = color;
                }

                var mainActivityview = ((ChatWindowActivity)Activity);
                if (mainActivityview.DataUser != null)
                {
                    mainActivityview.DataUser.LastMessage.LastMessageClass.ChatColor = color;
                }
                if (mainActivityview.UserData != null)
                {
                    mainActivityview.UserData.ChatColor = color;
                }

                ChatWindowActivity.MainChatColor = color;
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            try
            {
                base.OnCreate(savedInstanceState);
                SetContentView(Resource.Layout.AgoraAudioCallActivityLayout);

                GlobalContext = MsgTabbedMainActivity.GetInstance();

                SensorManager = (SensorManager)GetSystemService(SensorService);
                Proximity     = SensorManager.GetDefaultSensor(SensorType.Proximity);

                UserId = Intent?.GetStringExtra("UserID");
                Avatar = Intent?.GetStringExtra("avatar");
                Name   = Intent?.GetStringExtra("name");

                var dataCallId = Intent?.GetStringExtra("CallID") ?? "Data not available";
                if (dataCallId != "Data not available" && !string.IsNullOrEmpty(dataCallId))
                {
                    CallId = dataCallId;

                    FromId = Intent?.GetStringExtra("from_id");
                    Active = Intent?.GetStringExtra("active");
                    var time = Intent?.GetStringExtra("time");
                    Status   = Intent?.GetStringExtra("status");
                    RoomName = Intent?.GetStringExtra("room_name");
                    CallType = Intent?.GetStringExtra("type");
                    Console.WriteLine(time);
                }

                SpeakerAudioButton = FindViewById <CircleButton>(Resource.Id.speaker_audio_button);
                EndCallButton      = FindViewById <CircleButton>(Resource.Id.end_audio_call_button);
                MuteAudioButton    = FindViewById <CircleButton>(Resource.Id.mute_audio_call_button);

                UserImageView    = FindViewById <ImageView>(Resource.Id.audiouserImageView);
                UserNameTextView = FindViewById <TextView>(Resource.Id.audiouserNameTextView);
                DurationTextView = FindViewById <TextView>(Resource.Id.audiodurationTextView);

                SpeakerAudioButton.Click += Speaker_audio_button_Click;
                EndCallButton.Click      += End_call_button_Click;
                MuteAudioButton.Click    += Mute_audio_button_Click;


                SpeakerAudioButton.SetImageResource(Resource.Drawable.ic_speaker_close);


                LoadUserInfo(UserId);

                if (CallType == "Agora_audio_calling_start")
                {
                    Start_Call_Action("call");
                }
                else
                {
                    Start_Call_Action("recieve_call");
                }


                MsgTabbedMainActivity.RunCall = true;
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
예제 #17
0
        private async void SendMess(string text)
        {
            try
            {
                if (!Methods.CheckConnectivity())
                {
                    Toast.MakeText(this, GetString(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short)?.Show();
                }
                else
                {
                    var unixTimestamp = (int)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
                    var time2         = unixTimestamp.ToString();

                    //Here on This function will send Selected audio file to the user
                    var(apiStatus, respond) = await RequestsAsync.Message.Send_Message(UserId, time2, text);

                    if (apiStatus == 200)
                    {
                        if (respond is SendMessageObject result)
                        {
                            Console.WriteLine(result.MessageData);
                            if (!string.IsNullOrEmpty(CallId))
                            {
                                var ckd = MsgTabbedMainActivity.GetInstance().LastCallsTab?.MAdapter?.MCallUser?.FirstOrDefault(a => a.Id == CallId); // id >> Call_Id
                                if (ckd == null)
                                {
                                    Classes.CallUser cv = new Classes.CallUser
                                    {
                                        Id           = CallId,
                                        UserId       = UserId,
                                        Avatar       = Avatar,
                                        Name         = Name,
                                        AccessToken  = TwilioAccessToken,
                                        AccessToken2 = TwilioAccessTokenUser2,
                                        FromId       = FromId,
                                        Active       = Active,
                                        Time         = "Missed call",
                                        Status       = Status,
                                        RoomName     = RoomName,
                                        Type         = CallType,
                                        TypeIcon     = "Cancel",
                                        TypeColor    = "#FF0000"
                                    };

                                    MsgTabbedMainActivity.GetInstance().LastCallsTab.MAdapter?.Insert(cv);

                                    SqLiteDatabase dbDatabase = new SqLiteDatabase();
                                    dbDatabase.Insert_CallUser(cv);
                                }
                            }

                            switch (CallType)
                            {
                            case "Twilio_video_call":
                                PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                                    () => RequestsAsync.Call.DeclineCallAsync(UserDetails.UserId, CallId, TypeCall.Video)
                                });
                                break;

                            case "Twilio_audio_call":
                                PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                                    () => RequestsAsync.Call.DeclineCallAsync(UserDetails.UserId, CallId, TypeCall.Audio)
                                });
                                break;

                            case "Agora_video_call_recieve":
                            case "Agora_audio_call_recieve":
                                PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                                    () => ApiRequest.Send_Agora_Call_Action_Async("decline", CallId)
                                });
                                break;
                            }

                            FinishVideoAudio();
                        }
                    }
                    else
                    {
                        Methods.DisplayReportResult(this, respond);
                    }
                }
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
예제 #18
0
        private void RejectCallButton_Click(object sender, EventArgs e)
        {
            try
            {
                switch (CallType)
                {
                case "Twilio_video_call":
                    PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                        () => RequestsAsync.Call.DeclineCallAsync(UserDetails.UserId, CallId, TypeCall.Video)
                    });
                    break;

                case "Twilio_audio_call":
                    PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                        () => RequestsAsync.Call.DeclineCallAsync(UserDetails.UserId, CallId, TypeCall.Audio)
                    });
                    break;

                case "Agora_video_call_recieve":
                case "Agora_audio_call_recieve":
                    PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                        () => ApiRequest.Send_Agora_Call_Action_Async("decline", CallId)
                    });
                    break;
                }

                if (!string.IsNullOrEmpty(CallId))
                {
                    var ckd = MsgTabbedMainActivity.GetInstance().LastCallsTab?.MAdapter?.MCallUser?.FirstOrDefault(a => a.Id == CallId); // id >> Call_Id
                    if (ckd == null)
                    {
                        Classes.CallUser cv = new Classes.CallUser
                        {
                            Id           = CallId,
                            UserId       = UserId,
                            Avatar       = Avatar,
                            Name         = Name,
                            AccessToken  = TwilioAccessToken,
                            AccessToken2 = TwilioAccessTokenUser2,
                            FromId       = FromId,
                            Active       = Active,
                            Time         = "Missed call",
                            Status       = Status,
                            RoomName     = RoomName,
                            Type         = CallType,
                            TypeIcon     = "Cancel",
                            TypeColor    = "#FF0000"
                        };

                        MsgTabbedMainActivity.GetInstance().LastCallsTab.MAdapter?.Insert(cv);

                        SqLiteDatabase dbDatabase = new SqLiteDatabase();
                        dbDatabase.Insert_CallUser(cv);
                    }
                }

                FinishVideoAudio();
            }
            catch (Exception exception)
            {
                FinishVideoAudio();
                Methods.DisplayReportResultTrack(exception);
            }
        }
예제 #19
0
        private void IconView_Click()
        {
            try
            {
                if (DataUser == null)
                {
                    return;
                }

                try
                {
                    if (AppSettings.LastChatSystem == SystemApiGetLastChat.New)
                    {
                        var item = MsgTabbedMainActivity.GetInstance()?.LastChatTab?.MAdapter?.LastChatsList?.FirstOrDefault(a => a.LastChat?.UserId == DataUser.UserId);
                        if (item?.LastChat != null && item.LastChat?.LastMessage.LastMessageClass.ToId == UserDetails.UserId && item.LastChat?.LastMessage.LastMessageClass.FromId != UserDetails.UserId)
                        {
                            item.LastChat.LastMessage.LastMessageClass.Seen         = "1";
                            item.LastChat.LastMessage.LastMessageClass.MessageCount = "0";
                            MsgTabbedMainActivity.GetInstance()?.LastChatTab?.MAdapter?.NotifyDataSetChanged();
                        }
                    }
                    else
                    {
                        var item = MsgTabbedMainActivity.GetInstance()?.LastChatTab?.MAdapter?.LastChatsList?.FirstOrDefault(a => a.LastMessagesUser?.UserId == DataUser.UserId);
                        if (item?.LastMessagesUser != null && item.LastMessagesUser?.LastMessage.ToId == UserDetails.UserId && item.LastMessagesUser?.LastMessage.FromId != UserDetails.UserId)
                        {
                            item.LastMessagesUser.LastMessage.Seen = "1";
                            MsgTabbedMainActivity.GetInstance()?.LastChatTab?.MAdapter?.NotifyDataSetChanged();
                        }
                    }
                }
                catch (Exception exception)
                {
                    Methods.DisplayReportResultTrack(exception);
                }

                DataUser.ChatColor ??= AppSettings.MainColor;

                var mainChatColor = DataUser.ChatColor.Contains("rgb") ? Methods.FunString.ConvertColorRgBtoHex(DataUser.ChatColor) : DataUser.ChatColor ?? AppSettings.MainColor;

                if (DataUser.ChatType == "user")
                {
                    Intent intent = new Intent(Application.Context, typeof(ChatWindowActivity));
                    intent.SetFlags(ActivityFlags.NewTask | ActivityFlags.ClearTask);
                    intent.AddFlags(ActivityFlags.SingleTop);
                    intent.SetAction(Intent.ActionView);
                    intent.PutExtra("UserID", DataUser.UserId);
                    intent.PutExtra("TypeChat", "User");
                    intent.PutExtra("ColorChat", mainChatColor);
                    intent.PutExtra("UserItem", JsonConvert.SerializeObject(new ChatObject
                    {
                        ChatType         = DataUser.ChatType,
                        UserId           = DataUser.UserId,
                        GroupId          = DataUser.GroupId,
                        PageId           = DataUser.PageId,
                        Avatar           = DataUser.Avatar,
                        Name             = DataUser.Name,
                        Lastseen         = DataUser.LastSeen,
                        LastseenUnixTime = DataUser.LastSeenUnixTime,
                        LastMessage      = new LastMessageUnion
                        {
                            LastMessageClass = new MessageData
                            {
                                Product = new ProductUnion()
                            }
                        },
                    }));
                    Application.Context.StartActivity(intent);
                }

                Destroy();
            }
            catch (Exception exception)
            {
                Methods.DisplayReportResultTrack(exception);
            }
        }
예제 #20
0
        private async Task LoadChatAsync()
        {
            try
            {
                //Toast.MakeText(Application.Context, "StartApiService", ToastLength.Short)?.Show();
                if (LastChatFragment.ApiRun)
                {
                    return;
                }

                LastChatFragment.ApiRun = true;

                if (AppSettings.LastChatSystem == SystemApiGetLastChat.New)
                {
                    var fetch = "users";
                    if (AppSettings.EnableChatGroup)
                    {
                        fetch += ",groups";
                    }

                    if (AppSettings.EnableChatPage)
                    {
                        fetch += ",pages";
                    }

                    var(apiStatus, respond) = await RequestsAsync.Message.GetChatAsync(fetch);

                    if (apiStatus != 200 || respond is not LastChatObject result || result.Data == null)
                    {
                        LastChatFragment.ApiRun = false;
                        //Methods.DisplayReportResult(new Activity(), respond);
                    }
                    else
                    {
                        var respondList = result.Data.Count;
                        if (respondList > 0)
                        {
                            if (Methods.AppLifecycleObserver.AppState == "Foreground")
                            {
                                MsgTabbedMainActivity.GetInstance()?.OnReceiveResult(JsonConvert.SerializeObject(result));
                            }
                            else
                            {
                                ListUtils.UserList = new ObservableCollection <ChatObject>(result.Data);

                                //Insert All data users to database
                                SqLiteDatabase dbDatabase = new SqLiteDatabase();
                                dbDatabase.Insert_Or_Update_LastUsersChat(Application.Context, ListUtils.UserList, UserDetails.ChatHead);

                                LastChatFragment.LoadCall(result);
                                LastChatFragment.ApiRun = false;
                            }
                        }
                    }
                }
                else
                {
                    if (Methods.AppLifecycleObserver.AppState == "Background")
                    {
                        UserDetails.OnlineUsers = false;
                    }

                    var(apiStatus, respond) = await RequestsAsync.Message.GetusersListAsync(UserDetails.UserId, UserDetails.UserId, "20", "0", UserDetails.OnlineUsers);

                    if (apiStatus != 200 || respond is not GetUsersListObject result || result.Users == null)
                    {
                        LastChatFragment.ApiRun = false;
                        //Methods.DisplayReportResult(new Activity(), respond);
                    }