示例#1
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.VoiceCall);
            this.callType = this.Intent.GetStringExtra("callType");
            if (friend == null)
            {
                if (this.callType.Equals("incoming"))
                {
                    friend          = new AppCore.User();
                    friend.Jid      = this.Intent.GetStringExtra("userChat");
                    friend.username = LegionUtils.GetUserNameClear(friend.Jid);
                }
                else
                {
                    friend = LegionUtils.getUserson(Intent.GetStringExtra("userChat"));
                }
            }
            App      = App.Instance;
            xmppFace = new XmppFacade();
            App.Xmpp.OnReceiveSessionAccept += (sender, e) =>
            {
                Log.Info("Success connection");
                timer.Interval = 1000;
                timer.Elapsed += OnTimedEvent;
                timer.Enabled  = true;
            };

            Layout       = (RelativeLayout)FindViewById(Resource.Id.layout);
            Bgconnection = (ImageView)FindViewById(Resource.Id.
                                                   bgconnection);
            avatar = (ImageView)FindViewById(Resource.Id.avatarFriend);
            if (friend.Photo != null)
            {
                Bitmap bitmap = xmppFace.Base64ToBitmap(friend.Photo);
                var    d      = new CircleDrawable(bitmap);
                avatar.SetBackgroundDrawable(d);
            }
            TxUserName      = (TextView)FindViewById(Resource.Id.userNameFriend);
            TxUserName.Text = friend.username;
            TxConnection    = (TextView)FindViewById(Resource.Id.time);

            LeaveButton = (ImageButton)FindViewById(Resource.Id.leaveButton);

            // Load native libraries.
            if (!Build.CpuAbi.ToLower().Contains("x86") && !Build.CpuAbi.ToLower().Contains("arm64"))
            {
                Java.Lang.JavaSystem.LoadLibrary("audioprocessing");
                Java.Lang.JavaSystem.LoadLibrary("audioprocessingJNI");
            }
            Java.Lang.JavaSystem.LoadLibrary("opus");
            Java.Lang.JavaSystem.LoadLibrary("opusJNI");
            Java.Lang.JavaSystem.LoadLibrary("vpx");
            Java.Lang.JavaSystem.LoadLibrary("vpxJNI");

            LeaveButton.Click += new EventHandler(LeaveButton_Click);

            Messaging.Log.Debug("VoiceCallActivity adding event handler Xmpp_OnReceiveSessionTerminate");
            //loadXmppConnect(this);
            //App.Instance.Xmpp.OnReceiveSessionTerminate += Xmpp_OnReceiveSessionTerminate;
            //App.Instance.Xmpp.OnReceiveSessionInitiate += Xmpp_OnReceiveSessionInitiate;


            if (!SignallingStarted)
            {
                StartSignalling();
            }

            if (!LocalMediaStarted)
            {
                StartLocalMedia();
            }
        }
示例#2
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            this.callType = this.Intent.GetStringExtra("callType");
            RequestWindowFeature(WindowFeatures.NoTitle);
            Window.AddFlags(WindowManagerFlags.KeepScreenOn);
            SetContentView(Resource.Layout.Video);
            Layout          = (RelativeLayout)FindViewById(Resource.Id.layout);
            ActivityService = ActivityService.GetInstance;
            if (friend == null)
            {
                if (this.callType.Equals("incoming"))
                {
                    friend          = new AppCore.User();
                    friend.Jid      = this.Intent.GetStringExtra("userChat");
                    friend.username = LegionUtils.GetUserNameClear(friend.Jid);
                }
                else
                {
                    friend = LegionUtils.getUserson(Intent.GetStringExtra("userChat"));
                }
            }

            //ActivityService.GetInstance.App.Xmpp.OnReceiveSessionAccept += (sender, e) => {
            //	Log.Info("Success connection");

            //	//RunOnUiThread(() =>
            //	//		showConnectionVideo(true)
            //	//		 );

            //};



            //Bgconnection = (ImageView)FindViewById(Resource.Id.
            //                                       bgconnection);
            //avatar = (ImageView)FindViewById(Resource.Id.avatarFriend);
            if (friend.Photo != null)
            {
                //Bitmap bitmap = xmppFace.Base64ToBitmap(friend.Photo);
                //var d = new CircleDrawable(bitmap);
                //avatar.SetBackgroundDrawable(d);
            }
            //TxUserName = (TextView)FindViewById(Resource.Id.userNameFriend);
            //TxUserName.Text = friend.username;
            //TxConnection = (TextView)FindViewById(Resource.Id.connect);

            LeaveButton = (ImageButton)FindViewById(Resource.Id.leaveButton);

            // Load native libraries.
            if (!Build.CpuAbi.ToLower().Contains("x86") && !Build.CpuAbi.ToLower().Contains("arm64"))
            {
                Java.Lang.JavaSystem.LoadLibrary("audioprocessing");
                Java.Lang.JavaSystem.LoadLibrary("audioprocessingJNI");
            }
            Java.Lang.JavaSystem.LoadLibrary("opus");
            Java.Lang.JavaSystem.LoadLibrary("opusJNI");
            Java.Lang.JavaSystem.LoadLibrary("vpx");
            Java.Lang.JavaSystem.LoadLibrary("vpxJNI");

            LeaveButton.Click += new EventHandler(LeaveButton_Click);

            Messaging.Log.Debug("VideoActivity adding event handler Xmpp_OnReceiveSessionTerminate");
            //oadXmppConnect(this);
            ActivityService.GetInstance.App.Xmpp.OnReceiveSessionTerminate += Xmpp_OnReceiveSessionTerminate;
            //ActivityService.GetInstance.App.Xmpp.OnReceiveSessionInitiate += Xmpp_OnReceiveSessionInitiate;

            // For demonstration purposes, use the double-tap gesture
            // to switch between the front and rear camera.
            GestureDetector = new GestureDetector(this, new OnGestureListener(ActivityService.GetInstance.App));

            // Preserve a static container across
            // activity destruction/recreation.
            var c = (RelativeLayout)FindViewById(Resource.Id.container);

            if (Container == null)
            {
                Container = c;

                Toast.MakeText(this, "Double tap to switch camera.", ToastLength.Short).Show();
            }
            Layout.RemoveView(c);

            if (!LocalMediaStarted)
            {
                StartLocalMedia();
            }
        }
示例#3
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.ChatActivity);
            layout         = FindViewById(Resource.Id.rootRelative);
            mKeyboard      = new Keyboard(this, Resource.Layout.keyboard2);
            smileyKeyBoard = (ImageView)FindViewById(Resource.Id.btn_key_board);

            smileyKeyBoard.Touch += (sender, e) =>
            {
                ShowKeyboardWithAnimation();
            };

            Rect r    = new Rect();
            View view = Window.DecorView;

            view.GetWindowVisibleDisplayFrame(r);
            iHeightDefault = r.Bottom;

            rootView     = (RelativeLayout)FindViewById(Resource.Id.rootRelative);
            relative2    = (RelativeLayout)FindViewById(Resource.Id.relative2);
            usersRecents = getGroupsTempToList(AppPreferences.GROUPS_TEMP);

            rootView.ViewTreeObserver.GlobalLayout += (sender, e) =>
            {
                r    = new Rect();
                view = Window.DecorView;
                view.GetWindowVisibleDisplayFrame(r);

                if (iHeightDefault > r.Bottom)
                {
                    // Keyboard is Show
                    if (relative2.Visibility == ViewStates.Visible)
                    {
                        relative2.Visibility = ViewStates.Gone;
                    }
                }
            };

            var toolbar = loadToolBar(Resource.Id.toolbar);

            toolbar.SetNavigationIcon(Resource.Drawable.back);

            TextView tvToo = (TextView)toolbar.FindViewById(Resource.Id.toolbar_title);

            mLayoutManager = new LinearLayoutManager(this);

            rvList     = (RecyclerView)FindViewById(Resource.Id.rvLista);
            btnSendMsg = (ImageView)FindViewById(Resource.Id.btnEnviar);
            edtMsg     = (EmojiconEditText)FindViewById(Resource.Id.edtMessage);

            EmojiconsFragment.EmojiClicked += (e) =>
            {
                EmojiconsFragment.Input(edtMsg, e);
            };
            EmojiconsFragment.EmojiconBackspaceClicked += (v) =>
            {
                EmojiconsFragment.Backspace(edtMsg);
            };


            this.isGroupChat = Intent.GetBooleanExtra("chatGroup", false);
            jsonUser         = Intent.GetStringExtra("userChat");
            if (jsonUser != null)
            {
                friend = LegionUtils.getUserson(jsonUser);
                appPreferences.saveKeyMSGCount(LegionUtils.GetUserNameClear(friend.Jid), 0);
                inChatJid = LegionUtils.GetUserNameClear(friend.Jid);
            }
            if (this.isGroupChat)
            {
                string gson = Intent.GetStringExtra("groupJson");
                isFromGroup = Intent.GetBooleanExtra("isFromGroup", false);

                if (gson == null || gson.Equals(""))
                {
                    gson = appPreferences.getValueKey(AppPreferences.GROUP_JSON);
                }
                groupFromGson = LegionUtils.getUserson(gson);
                GroupName     = groupFromGson.username;
                inChatJid     = GroupName;

                tvToo.Text = (GroupName.Replace("_", " "));
                tvToo.Text = tvToo.Text.Split('@')[0];
                msgs       = getMsgs(groupFromGson.Jid);
                appPreferences.saveKeyMSGCount(LegionUtils.GetUserNameClear(groupFromGson.Jid), 0);
            }
            else
            {
                friend.Jid = friend.username + "@" + GetString(Resource.String.jid);
                tvToo.Text = (friend.username);
                msgs       = getMsgs(friend.username);
            }


            btnSendMsg.Click += BtnSendMsg_Click;


            RefrashRecycleView();

            //loadXmppConnect(this);
            // ActivityService = new ActivityService(this);


            if (!SignallingStarted)
            {
                StartSignalling();
            }

            var isDirect = Intent.GetBooleanExtra("isDirectCall", false);
            var typeCall = Intent.GetStringExtra("callType");

            if (isDirect)
            {
                if (typeCall.Equals("callPhone"))
                {
                    startCall(PHONE_CALL);
                }
                else
                {
                    startCall(VIDEO_CALL);
                }
            }

            recentConversationsUserName = userService.getRecentUsers(appPreferences);
            clearUnreadMessage();
        }