Example #1
0
        public async void OnContextItemSelectedAsync(IMenuItem item)
        {
            var info         = (AdapterView.AdapterContextMenuInfo)item.MenuInfo;
            var conversation = _adapter[info.Position];

            if (item.ItemId == MENU_CONVERSATION_HIDE)
            {
                await ChadderUI.SetHidden(conversation);
            }
            else if (item.ItemId == MENU_DELETE_ALL)
            {
                await ChadderUI.DeleteAllMessages(conversation);
            }
            else if (item.ItemId == MENU_TAKEBACK_ALL)
            {
                await ChadderUI.TakeAllBack(conversation);
            }
        }
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            var view = inflater.Inflate(Resource.Layout.profile_fragment, container, false);

            grid = view.FindViewById <GridView>(Resource.Id.profile_devices);

            _adapter = new DevicesAdapter(Activity, ChadderUI.Source.db.LocalUser.Devices);

            grid.Adapter    = _adapter;
            grid.ItemClick += grid_ItemClick;
            SetupMenu();

            _btnPicture        = view.FindViewById <ImageButton>(Resource.Id.profile_picture);
            _btnPicture.Click += (sender, e) =>
            {
                ChadderImagePicker.MultiSourcePick(this);
            };

            var btnName = view.FindViewById <Button>(Resource.Id.profile_name_btn);

            _tvName = view.FindViewById <TextView>(Resource.Id.profile_name_label);

            btnName.Click += async(object sender, EventArgs e) =>
                             await ChadderUI.ChangeName();

            var btnEmail = view.FindViewById <Button>(Resource.Id.profile_email_btn);

            _tvEmail = view.FindViewById <TextView>(Resource.Id.profile_email_label);

            btnEmail.Click += async(object sender, EventArgs e) =>
                              await ChadderUI.ChangeEmail();

            var btnPhone = view.FindViewById <Button>(Resource.Id.profile_phone_btn);

            _tvPhone        = view.FindViewById <TextView>(Resource.Id.profile_phone_label);
            btnPhone.Click += async(object sender, EventArgs e) =>
                              await ChadderUI.ChangePhone();

            var btnShareName = view.FindViewById <Button>(Resource.Id.profile_sharename_btn);

            _tvShareName = view.FindViewById <TextView>(Resource.Id.profile_sharename_label);

            btnShareName.Click += async(object sender, EventArgs e) =>
                                  await ChadderUI.ChangeShareName();

            var btnFacebook = view.FindViewById <Button>(Resource.Id.profile_facebook_btn);

            btnFacebook.Click += (object sender, EventArgs e) =>
                                 //++RegisterEndFragment.ShareFacebook(Activity, uiHelper);
                                 RegisterEndFragment.ShareFacebook(Activity);

            var btnDevicePassword = view.FindViewById <Button>(Resource.Id.profile_device_pwd_btn);

            btnDevicePassword.Click += async(object sender, EventArgs e) =>
                                       await ChadderUI.ChangeDevicePassword();

            var btnAccPassword = view.FindViewById <Button>(Resource.Id.profile_account_pwd_btn);

            btnAccPassword.Click += async(object sender, EventArgs e) =>
                                    await ChadderUI.ChangeAccountPassword();

            var btnLogout = view.FindViewById <Button>(Resource.Id.profile_logout_btn);

            btnLogout.Click += async(object sender, EventArgs e) =>
            {
                await ChadderUI.Logout();

                ChadderApp.UIHelper.Source_OnNotAuthorized();
            };

            view.FindViewById <Button>(Resource.Id.profile_scan_btn)
            .Click += (object sender, EventArgs e) => MainActivity.ScanFingerprint(Activity as MainActivity);

            _btnFingerprint        = view.FindViewById <Button>(Resource.Id.profile_fingerprint_btn);
            _btnFingerprint.Click += async(object sender, EventArgs e) =>
            {
                var layout = new RelativeLayout(Activity);

                var image = new ImageView(Activity);
                image.Focusable            = true;
                image.FocusableInTouchMode = true;
                image.SetScaleType(ImageView.ScaleType.FitCenter);
                image.SetBackgroundResource(Android.Resource.Color.White);
                layout.AddView(image, new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MatchParent, RelativeLayout.LayoutParams.MatchParent));

                var bottomText = new TextView(Activity);
                var param      = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WrapContent, RelativeLayout.LayoutParams.WrapContent);
                param.SetMargins(20, 20, 20, 20);
                param.AddRule(LayoutRules.CenterHorizontal);
                param.AddRule(LayoutRules.AlignParentBottom);
                layout.AddView(bottomText, param);
                bottomText.Text = GetString(Resource.String.ProfileFingerprintBottomMessage);

                InputDialog.ShowProgressDialog(Activity);
                var writer = new ZXing.BarcodeWriter {
                    Format = ZXing.BarcodeFormat.QR_CODE
                };
                var qr = writer.Write(await ChadderUI.GetFingerprint());
                image.SetImageBitmap(qr);
                InputDialog.DismissProgressDialog();

                var wnd = new PopupWindow(layout, RelativeLayout.LayoutParams.MatchParent, RelativeLayout.LayoutParams.MatchParent);
                wnd.ShowAtLocation(View, GravityFlags.Center, 0, 0);
                image.Touch += (object s, Android.Views.View.TouchEventArgs e2) =>
                {
                    wnd.Dismiss();
                };
            };

            view.FindViewById <Button>(Resource.Id.Erase_All_Msgs_btn)
            .Click += async(object sender, EventArgs e) => await ChadderUI.DeleteAllMessages();

            view.FindViewById <Button>(Resource.Id.profile_contactbook_btn)
            //++.Click += async (s, e) => await ChadderUI.ToggleUploadContactBook();
            .Click        += (s, e) => { };
            _tvContactBook = view.FindViewById <TextView>(Resource.Id.profile_contactbook_label);

            return(view);
        }