Пример #1
0
        public void OnSuccess(Java.Lang.Object result)
        {
            var n = result as LoginResult;

            if (n != null)
            {
                var request = GraphRequest.NewMeRequest(n.AccessToken, this);
                var bundle  = new Android.OS.Bundle();
                bundle.PutString("fields", "id, first_name, email, last_name, picture.width(500).height(500)");
                request.Parameters = bundle;
                request.ExecuteAsync();
            }
        }
Пример #2
0
        public void OnSuccess(Java.Lang.Object result)
        {
            var loginResult = result as Xamarin.Facebook.Login.LoginResult;

            Bundle parameters = new Bundle();

            parameters.PutString("fields", "email");

            GraphRequest request = GraphRequest.NewMeRequest(loginResult.AccessToken, new GraphJSONCallback(loginResult, this));

            request.Parameters = parameters;
            request.ExecuteAsync();
        }
Пример #3
0
        public void OnSuccess(Java.Lang.Object p0)
        {
            // Facebook Email address
            LoginResult loginResult = (LoginResult)p0;

            _graphCBHandler = new GraphCBHandler(_fba);
            _fba.SetAccessToken(loginResult.AccessToken.Token);
            GraphRequest request = GraphRequest.NewMeRequest(loginResult.AccessToken, _graphCBHandler);

            Bundle parameters = new Bundle();

            parameters.PutString("fields", "email");
            request.Parameters = (parameters);
            request.ExecuteAsync();
        }
Пример #4
0
        public void OnSuccess(Java.Lang.Object result)
        {
            var facebookLoginResult = result.JavaCast <Xamarin.Facebook.Login.LoginResult>();

            if (facebookLoginResult == null)
            {
                return;
            }

            var parameters = new Bundle();

            parameters.PutString("fields", "id,email,picture.width(1000).height(1000)");
            var request = GraphRequest.NewMeRequest(facebookLoginResult.AccessToken, this);

            request.Parameters = parameters;
            request.ExecuteAsync();
        }
Пример #5
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            FacebookSdk.SdkInitialize(this);
            callbackManager = CallbackManagerFactory.Create();

            var loginCallback = new FacebookCallback <LoginResult>
            {
                HandleSuccess = loginResult =>
                {
                    var graphRequestCallback = new FacebookGraphCallback <GraphResponse>
                    {
                        HandleCompleted = graph =>
                        {
                            // TODO : SUCCESS
                            Intent mainIntent = new Intent(this, typeof(MainActivity));
                            mainIntent.PutExtra("facebookToken", loginResult.AccessToken.Token);
                            SetResult(Result.FirstUser, mainIntent);
                            Finish();
                        }
                    };
                    var    gr         = GraphRequest.NewMeRequest(loginResult.AccessToken, graphRequestCallback);
                    Bundle parameters = new Bundle();
                    parameters.PutString("fields", "id,name,link,email,gender,birthday");
                    gr.Parameters = parameters;
                    gr.ExecuteAsync();
                },
                HandleCancel = () =>
                {
                    // TODO : CANCEL
                },
                HandleError = loginError =>
                {
                    // TODO : ERROR
                }
            };

            if (AccessToken.CurrentAccessToken != null)
            {
                LoginManager.Instance.LogOut();
            }

            LoginManager.Instance.RegisterCallback(callbackManager, loginCallback);
            LoginManager.Instance.LogInWithReadPermissions(this, new[] { "email", "public_profile", "user_birthday" });
        }
Пример #6
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            FacebookSdk.SdkInitialize(this.ApplicationContext);
            // Set our view from the "main" layout resource

            mProfileTracker = new MyProfileTracker();
            mProfileTracker.mOnProfileChanged += MProfileTracker_mOnProfileChanged;
            mProfileTracker.StartTracking();
            SetContentView(Resource.Layout.Main);

            Button faceBookButton = FindViewById <Button>(Resource.Id.button);

            mTxtFirstName = FindViewById <TextView>(Resource.Id.txtFirstName);
            mTxtLastName  = FindViewById <TextView>(Resource.Id.txtLastName);
            mTxtName      = FindViewById <TextView>(Resource.Id.txtName);
            mProfilePic   = FindViewById <ProfilePictureView>(Resource.Id.profilePic);
            mBtnShared    = FindViewById <ShareButton>(Resource.Id.btnShare);
            mBtnGetEmail  = FindViewById <Button>(Resource.Id.btnGetEmail);


            LoginButton button = FindViewById <LoginButton>(Resource.Id.login_button);

            button.SetReadPermissions(new List <string> {
                "public_profile", "user_friends", "email"
            });

            mCallBackManager = CallbackManagerFactory.Create();

            button.RegisterCallback(mCallBackManager, this);

            mBtnGetEmail.Click += (o, e) =>
            {
                GraphRequest request = GraphRequest.NewMeRequest(AccessToken.CurrentAccessToken, this);

                Bundle parameters = new Bundle();
                parameters.PutString("fields", "id,name,age_range,email");
                request.Parameters = parameters;
                request.ExecuteAsync();
            };


            ShareLinkContent content = new ShareLinkContent.Builder().Build();

            mBtnShared.ShareContent = content;
        }
Пример #7
0
        /// <summary>
        /// Get user data from facebook
        /// </summary>
        /// <param name="callback"></param>
        public void GetUserData(IFacebookDataCallback callback)
        {
            FacebookDataCallback = callback;

            AccessToken accessToken = AccessToken.CurrentAccessToken;

            FacebookResult       = new FacebookResult();
            FacebookResult.Token = accessToken.Token;

            Bundle parameters = new Bundle();

            parameters.PutString("fields", FacebookService.Fields);

            GraphRequest graphRequest = GraphRequest.NewMeRequest(accessToken, this);

            graphRequest.Parameters = parameters;
            graphRequest.ExecuteAsync();
        }
Пример #8
0
        void mProfileTracker_mOnProfileChanged(object sender, OnProfileChangedEventArgs e)
        {
            if (e.mProfile != null)
            {
                GraphRequest request = GraphRequest.NewMeRequest(AccessToken.CurrentAccessToken, this);

                Bundle parameters = new Bundle();
                parameters.PutString("fields", "email");
                request.Parameters = parameters;
                request.ExecuteAsync();

                nom.Text    = e.mProfile.FirstName;
                prenom.Text = e.mProfile.LastName;
                pseudo.Text = e.mProfile.Name;
            }

            else
            {
            }
        }
Пример #9
0
        void mProfileTracker_mOnProfileChanged(object sender, OnProfileChangedEventArgs e)
        {
            LoginManager.Instance.LogInWithReadPermissions(this, new List <string> {
                "user_friends", "public_profile"
            });
            if (e.mProfile != null)
            {
                try
                {
                    var sc = new SocialLoginData();
                    sc.scFirstName     = e.mProfile.FirstName;
                    sc.scLastName      = e.mProfile.LastName;
                    sc.scUserName      = e.mProfile.FirstName + e.mProfile.LastName;
                    sc.scSocialId      = e.mProfile.Id;
                    facebookpicture    = "http://graph.facebook.com/" + e.mProfile.Id + "/picture?type=large";
                    sc.scProfileImgUrl = facebookpicture;
                    sc.scEmail         = email ?? "";

                    sc.scSource    = "facebook";
                    sc.scAccessUrl = "http://facebook.com/profile.php?id=" +
                                     e.mProfile.Id;

                    sc.scSocialOauthToken = AccessToken.CurrentAccessToken.Token;
                    sc.scAccount          = AccessToken.CurrentAccessToken.UserId;


                    GraphRequest request = GraphRequest.NewMeRequest(AccessToken.CurrentAccessToken, this);

                    Bundle parameters = new Bundle();
                    parameters.PutString("fields", "id,name,email,picture");
                    request.Parameters = parameters;
                    request.ExecuteAsync();



                    StartRegistration(sc);
                }

                catch (Java.Lang.Exception ex) { }
            }
        }
        public void OnSuccess(Java.Lang.Object p0)
        {
            var n = p0 as LoginResult;

            if (n != null)
            {
                if (_isPermissionsLogin && _pTask != null)
                {
                    _isPermissionsLogin = false;
                    _pTask.TrySetResult(true);
                    _pTask = null;
                    return;
                }

                if (_isSimpleLogin)
                {
                    _isSimpleLogin = false;
                    if (tcss != null)
                    {
                        tcss.TrySetResult(true);
                    }
                    tcss = null;
                    return;
                }
                var request = GraphRequest.NewMeRequest(n.AccessToken, this);
                var bundle  = new Android.OS.Bundle();
                bundle.PutString("fields", "id, first_name, email, last_name, picture.width(500).height(500)");
                request.Parameters = bundle;
                request.ExecuteAsync();
            }
            else if (p0 is SharerResult)
            {
                if (tcsPhoto != null)
                {
                    tcsPhoto.TrySetResult(true);
                    tcsPhoto = null;
                }
            }
        }
Пример #11
0
        internal void GetOwnName()
        {
            var callback = new GraphJSONObjectCallback
            {
                HandleSuccess = obj =>
                {
                    var intent = new Intent(FacebookOwnNameReceiver.ActionKey);
                    intent.PutExtra(FacebookOwnNameReceiver.ExtraResult, (int)Result.Success);
                    intent.PutExtra(FacebookOwnNameReceiver.ExtraName, obj.GetString("name"));
                    activity.SendBroadcast(intent);
                },
                HandleError = error =>
                {
                    var intent = new Intent(FacebookOwnNameReceiver.ActionKey);
                    intent.PutExtra(FacebookOwnNameReceiver.ExtraResult, (int)Result.Error);
                    intent.PutExtra(FacebookOwnNameReceiver.ExtraError, error.ToString());
                    activity.SendBroadcast(intent);
                }
            };
            GraphRequest request = GraphRequest.NewMeRequest(token, callback);

            request.ExecuteAsync();
        }
Пример #12
0
        //Login With Facebook
        private void MprofileTrackerOnMOnProfileChanged(object sender, ProfileChangedEventArgs e)
        {
            try
            {
                if (e.MProfile != null)
                {
                    FbFirstName = e.MProfile.FirstName;
                    FbLastName  = e.MProfile.LastName;
                    FbName      = e.MProfile.Name;
                    FbProfileId = e.MProfile.Id;

                    var request    = GraphRequest.NewMeRequest(AccessToken.CurrentAccessToken, this);
                    var parameters = new Bundle();
                    parameters.PutString("fields", "id,name,age_range,email");
                    request.Parameters = parameters;
                    request.ExecuteAsync();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
Пример #13
0
        protected override void OnCreate(Bundle bundle)
        {
            //NOTE*** you have decodebitmapfromstream and decoderesource and decodebytearray
            //def don't need them all

            base.OnCreate(bundle);

            //problem getting view to load with fb login button
            //make fresh activity and try copying xml and code there.
            //async it's another activity we shouldnt get the bother from fb login through a dialog'

            FacebookSdk.SdkInitialize(this.ApplicationContext);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            mBtnSignIn        = FindViewById <Button>(Resource.Id.btnSignIn);
            mTxtImgChoiceInfo = FindViewById <TextView>(Resource.Id.txtOr);
            mBtnSignup        = FindViewById <Button>(Resource.Id.btnSignUp);
            mProgressBar      = FindViewById <ProgressBar>(Resource.Id.progressBar1);
            mTxtBase64String  = FindViewById <TextView>(Resource.Id.txtViewImgBase64);
            mImgUploadedPhoto = FindViewById <ImageView>(Resource.Id.imgUploadedPhoto);
            mTxtTestCross     = FindViewById <TextView>(Resource.Id.txtImgPath);
            mBtnOpenGallery   = FindViewById <Button>(Resource.Id.btnOpenGallery);
            mBtnConverttoBase = FindViewById <Button>(Resource.Id.btnConverttoBase64);
            mBtnConverttoImg  = FindViewById <Button>(Resource.Id.btnConverttoImg);
            mTblImgStrings    = FindViewById <TableLayout>(Resource.Id.tblBaseStrings);

            mBtnGetEmail = FindViewById <Button>(Resource.Id.btnGetEmail);

            //string[] mImgBaseStrings = new string[] { };
            //List<string> mImgBaseStrings = new List<string>();

            mProfileTracker = new MyProfileTracker();
            mProfileTracker.mOnProfileChanged += mProfileTracker_mOnProfileChanged;
            mProfileTracker.StartTracking();

            mProfilePic = FindViewById <ProfilePictureView>(Resource.Id.profilePicMain);

            mBtnFbLogin = FindViewById <LoginButton>(Resource.Id.btnFbLoginMain);
            mTest       = FindViewById <TextView>(Resource.Id.txtTest);

            mBtnFbLogin.SetReadPermissions(new List <string> {
                "public_profile", "user_friends", "email"
            });

            mCallBackManager = CallbackManagerFactory.Create();

            mBtnFbLogin.RegisterCallback(mCallBackManager, this);

            mBtnGetEmail.Click += (o, e) =>
            {
                System.Diagnostics.Debug.Write("welllllllllllllllll");
                GraphRequest request = GraphRequest.NewMeRequest(AccessToken.CurrentAccessToken, this);

                Bundle parameters = new Bundle();
                parameters.PutString("fields", "id,name,age_range,email");
                request.Parameters = parameters;
                request.ExecuteAsync();
            };


            mBtnSignIn.Click += (object sender, EventArgs e) =>
            {
                //pull up dialog

                //finish matching up login dialog, some of the code here is to do with signup as its copied from elsewhere

                FragmentTransaction transaction  = FragmentManager.BeginTransaction();
                dialogue_Login      signInDialog = new dialogue_Login();

                signInDialog.Show(transaction, "dialog fragment");

                signInDialog.mOnLoginComplete += SignInDialog_mOnSignInComplete;
                System.Diagnostics.Debug.Write("BTN SIGNIN CLICKED");
                //Went with a fully-fledged function(name on line above) as it'd be quite a bit to write inside of a lambda expression
                //signInDialog.mOnLoginComplete += (object theSender, OnLoginEventArgs e) =>
                //{

                //}
            };

            mBtnSignup.Click += (object sender, EventArgs e) =>
            {
                //pull up dialog
                //this is used to pull up the dialog from the activity
                FragmentTransaction transaction  = FragmentManager.BeginTransaction();
                dialogue_SignUp     signUpDialog = new dialogue_SignUp();
                signUpDialog.Show(transaction, "dialog fragment");

                //signUpDialog.mOnSignUpComplete += signUpDialog_mOnSignUpComplete;
                signUpDialog.mOnSignUpComplete += SignUpDialog_mOnSignUpComplete;
            };

            mBtnOpenGallery.Click += delegate {
                var imageIntent = new Intent();
                imageIntent.SetType("image/*");
                imageIntent.SetAction(Intent.ActionGetContent);
                StartActivityForResult(
                    Intent.CreateChooser(imageIntent, "Select photo"), 0);
            };

            mBtnConverttoBase.Click += MBtnConverttoBase_Click;

            mBtnConverttoImg.Click += MBtnConverttoImg_Click;

            mImgUploadedPhoto.Click += (object sender, EventArgs e) =>
            {
                Bitmap bitmap = BitmapFactory.DecodeResource(Resources, Resource.Drawable.mail4_small);

                //Convert to byte array
                MemoryStream memStream = new MemoryStream();
                bitmap.Compress(Bitmap.CompressFormat.Jpeg, 100, memStream);
                byte[] byteArray = memStream.ToArray();

                var intent = new Intent(this, typeof(FullscreenImage));
                intent.SetType("image/*");
                intent.SetAction(Intent.ActionGetContent);
                intent.PutExtra("MyImg", byteArray);

                StartActivity(intent);
            };
        }
Пример #14
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            var transaction = SupportFragmentManager.BeginTransaction();

            transaction.Add(Resource.Id.under_fragment, new FlyingObjectsFragment());
            transaction.Add(Resource.Id.over_fragment, new MyCardsRecyclerViewFragment());
            transaction.Commit();

            var footerTextView = FindViewById <TextView>(Resource.Id.footer);

            footerTextView.Text = DrawerShared.GetFooterText();

            var navigationView = FindViewById <NavigationView>(Resource.Id.nav_view);

            navigationView.NavigationItemSelected += (sender, e) =>
            {
                var drawer = FindViewById <DrawerLayout>(Resource.Id.drawer_layout);
                drawer?.CloseDrawers();

                if (e.MenuItem.ItemId == Resource.Id.my_cards)
                {
                    AddFragmentOver(new MyCardsRecyclerViewFragment());
                    return;
                }

                if (e.MenuItem.ItemId == Resource.Id.discover)
                {
                    // AddFragmentOver("Discover");
                    return;
                }

                if (e.MenuItem.ItemId == Resource.Id.connections)
                {
                    //AddFragmentOver("Connections");
                    return;
                }

                if (e.MenuItem.ItemId == Resource.Id.settings)
                {
                    AddFragmentOver(new SettingsRecyclerViewFragment());
                    return;
                }
            };

            var itemDecorator = new DividerItemDecoration(this, DividerItemDecoration.Vertical);

            itemDecorator.SetDrawable(ContextCompat.GetDrawable(this, Resource.Drawable.RecyclerViewWhiteDivider));
            var navMenu = (NavigationMenuView)navigationView.GetChildAt(0);

            navMenu.AddItemDecoration(itemDecorator);

            var me                 = RealmUserServices.GetMe(true);
            var headerView         = navigationView.GetHeaderView(0);
            var innititalsTextView = headerView.FindViewById <TextView>(Resource.Id.InnititalsTextView);

            innititalsTextView.Text = (me.FirstName?.FirstOrDefault() + " " + me.LastName?.FirstOrDefault()).Trim();

            var nameTextView = headerView.FindViewById <TextView>(Resource.Id.NameTextView);

            nameTextView.Text = me.Name;

            var handelTextView = headerView.FindViewById <TextView>(Resource.Id.HandelTextView);

            handelTextView.Text = me.Handle;

            UpdateToolbar();

            mAdView = FindViewById <AdView>(Resource.Id.adView);

            if (ShowsAds)
            {
                var iPersistant   = ServiceLocator.Instance.Resolve <IPersistantStorage>();
                var facebookToken = iPersistant.GetFacebookToken();

                var facebookCallback = new FacebookCallback();
                facebookCallback.OnCompletedAction += (GraphResponse obj) =>
                {
                    if (obj == null || obj.RawResponse == null)
                    {
                        return;
                    }

                    var token = JToken.Parse(obj.RawResponse.ToString());
                    if (token == null)
                    {
                        return;
                    }

                    var dict = new Dictionary <string, string>();

                    if (token[AdKeyGender] != null)
                    {
                        dict.Add(AdKeyGender, token[AdKeyGender].ToString());
                    }

                    if (token[AdKeyBirthday] != null)
                    {
                        dict.Add(AdKeyBirthday, token[AdKeyBirthday].ToString());
                    }

                    ShowBanner(dict);
                };
                var request = GraphRequest.NewMeRequest(AccessToken.CurrentAccessToken, facebookCallback);

                var parameters = new Bundle();
                parameters.PutString("fields", "gender,birthday");
                request.Parameters = parameters;
                request.ExecuteAsync();
            }
        }