Пример #1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            // Create your application here
            FacebookSdk.SdkInitialize(this.ApplicationContext);
            SetContentView(Resource.Layout.activity_facebook);
            // Views
            mStatusTextView = FindViewById <TextView>(Resource.Id.status);
            mDetailTextView = FindViewById <TextView>(Resource.Id.detail);
            // Button listeners
            FirebaseApp.InitializeApp(this);
            mAuth = FirebaseAuth.Instance;
            LoginButton fblogin = FindViewById <LoginButton>(Resource.Id.button_facebook_login);

            fblogin.Click += delegate
            {
                mCallbackManager = CallbackManagerFactory.Create();
                fblogin.RegisterCallback(mCallbackManager, this);
            };
            FindViewById(Resource.Id.button_facebook_signout).Click += delegate
            {
                SignOut();
            };
        }
Пример #2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            //ToDo: Pavel - insert here your credentials - I still don't know how avoid that shit
            FacebookSdk.ApplicationName = Application.PackageName;
            FacebookSdk.ApplicationId   = Application.PackageName;

            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.MainLayout);

            var btn = FindViewById <Button>(Resource.Id.btn);

            OutputText = FindViewById <TextView>(Resource.Id.txt);
            btn.Click += Btn_Click;

            FacebookSdk.AutoInitEnabled = true; //da emu pohui na samom dele
            FacebookSdk.SdkInitialize(this);    //prosto zabei
            FacebookSdk.FullyInitialize();

            var loginCallback = new FacebookCallback <LoginResult>
            {
                HandleSuccess = (res) => RunOnUiThread(() => OutputText.Text = $"TOKEN>> {AccessToken.CurrentAccessToken}"),
                HandleError   = (ex) => Debug.WriteLine("Error on FB login detected>> " + ex),
                HandleCancel  = () =>
                {
                    OutputText.Text = "CANCELED from Login";
                    OutputText.SetTextColor(Color.MediumVioletRed);
                }
            };

            callbackManager = CallbackManagerFactory.Create(); //absolutely inusable thing - I suppose

            LoginManager.Instance.SetDefaultAudience(DefaultAudience.Everyone);
            LoginManager.Instance.SetLoginBehavior(LoginBehavior.WebViewOnly);
            LoginManager.Instance.RegisterCallback(callbackManager, loginCallback);
        }
Пример #3
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            try
            {
                base.OnCreate(savedInstanceState);

                IMethods.IApp.FullScreenApp(this);

                //View view = MyContextWrapper.GetContentView(this, Settings.Lang, Resource.Layout.Login_Layout);
                SetContentView(Resource.Layout.Login_Layout);

                regularTxt  = Typeface.CreateFromAsset(Assets, "fonts/SF-UI-Display-Regular.ttf");
                semiboldTxt = Typeface.CreateFromAsset(Assets, "fonts/SF-UI-Display-Semibold.ttf");

                //declare layouts and editext
                mEditTextEmail    = (EditText)FindViewById(Resource.Id.editTxtEmail);
                mEditTextPassword = (EditText)FindViewById(Resource.Id.editTxtPassword);

                mTextViewSignUp   = (TextView)FindViewById(Resource.Id.tvSignUp);         // Register
                mButtonViewSignIn = (Button)FindViewById(Resource.Id.SignInButton);       // Login

                mTextViewForgotPwd     = (TextView)FindViewById(Resource.Id.tvForgotPwd); // Forget password
                mTextViewCreateAccount = (TextView)FindViewById(Resource.Id.tvCreateAccount);

                progressBar                  = FindViewById <ProgressBar>(Resource.Id.progressBar);
                progressBar.Visibility       = ViewStates.Gone;
                mButtonViewSignIn.Visibility = ViewStates.Visible;

                //mTextViewSignIn.SetTypeface(semiboldTxt,TypefaceStyle.Bold);
                mTextViewCreateAccount.SetTypeface(regularTxt, TypefaceStyle.Normal);
                mTextViewForgotPwd.SetTypeface(regularTxt, TypefaceStyle.Normal);
                mTextViewSignUp.SetTypeface(regularTxt, TypefaceStyle.Normal);
                mEditTextEmail.SetTypeface(regularTxt, TypefaceStyle.Normal);
                mEditTextPassword.SetTypeface(regularTxt, TypefaceStyle.Normal);

                FacebookSdk.SdkInitialize(this);

                mprofileTracker = new FB_MyProfileTracker();
                mprofileTracker.mOnProfileChanged += MprofileTrackerOnM_OnProfileChanged;
                mprofileTracker.StartTracking();

                BtnFBLogin = FindViewById <LoginButton>(Resource.Id.fblogin_button);
                BtnFBLogin.SetReadPermissions(new List <string>
                {
                    "email",
                    "public_profile"
                });

                mFBCallManager = CallbackManagerFactory.Create();
                BtnFBLogin.RegisterCallback(mFBCallManager, this);


                //FB accessToken
                var accessToken = AccessToken.CurrentAccessToken;
                var isLoggedIn  = accessToken != null && !accessToken.IsExpired;

                // Configure sign-in to request the user's ID, email address, and basic profile. ID and basic profile are included in DEFAULT_SIGN_IN.
                var gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DefaultSignIn)
                          .RequestIdToken(GoogleServices.ClientId)
                          .RequestScopes(new Scope(Scopes.Profile))
                          .RequestScopes(new Scope(Scopes.PlusLogin))
                          .RequestServerAuthCode(GoogleServices.ClientId)
                          .RequestProfile().RequestEmail().Build();

                // Build a GoogleApiClient with access to the Google Sign-In API and the options specified by gso.
                mGoogleApiClient = new GoogleApiClient.Builder(this, this, this)
                                   .EnableAutoManage(this, this)
                                   .AddApi(Auth.GOOGLE_SIGN_IN_API, gso)
                                   .Build();

                mGoogleSignIn        = FindViewById <SignInButton>(Resource.Id.Googlelogin_button);
                mGoogleSignIn.Click += MGsignBtnOnClick;
                mGoogleSignIn.SetSize(SignInButton.SizeStandard);

                if (!Settings.Show_Facebook_Login)
                {
                    BtnFBLogin.Visibility = ViewStates.Invisible;
                }

                if (!Settings.Show_Google_Login)
                {
                    mGoogleSignIn.Visibility = ViewStates.Invisible;
                }

                IMethods.IApp.GetKeyHashesConfigured(this);
            }
            catch (Exception exception)
            {
                Crashes.TrackError(exception);
            }
        }
        public static void Initialize(Activity activity)
        {
            mLogger          = AppEventsLogger.NewLogger(Android.App.Application.Context as Android.App.Application);
            mCallbackManager = CallbackManagerFactory.Create();
            CurrentActivity  = activity;

            loginCallback = new FacebookCallback <LoginResult>
            {
                HandleSuccess = loginResult =>
                {
                    if (loginResult.AccessToken != null)
                    {
                        var fbArgs = new FBEventArgs <bool>(true, FacebookActionStatus.Completed);
                        _onLogin?.Invoke(CrossFacebookClient.Current, fbArgs);
                        _loginTcs?.TrySetResult(new FacebookResponse <bool>(fbArgs));

                        pendingAction?.Execute();

                        pendingAction = null;
                    }
                },
                HandleCancel = () =>
                {
                    var fbArgs = new FBEventArgs <bool>(false, FacebookActionStatus.Canceled, "User cancelled facebook operation");
                    _onLogin?.Invoke(CrossFacebookClient.Current, fbArgs);
                    _loginTcs?.TrySetResult(new FacebookResponse <bool>(fbArgs));
                    //Handle any cancel the user has perform
                    Console.WriteLine("User cancelled facebook login operation");

                    pendingAction?.Execute();

                    pendingAction = null;
                },
                HandleError = loginError =>
                {
                    var fbArgs = new FBEventArgs <bool>(false, FacebookActionStatus.Error, loginError.ToString());
                    _onLogin?.Invoke(CrossFacebookClient.Current, fbArgs);
                    _loginTcs?.TrySetResult(new FacebookResponse <bool>(fbArgs));

                    //Handle any error happends here
                    Console.WriteLine("Operation throws an error: " + loginError.ToString());

                    pendingAction?.Execute();
                    pendingAction = null;
                }
            };


            shareCallback = new FacebookCallback <SharerResult>
            {
                HandleSuccess = shareResult =>
                {
                    Dictionary <string, object> parameters = null;
                    if (shareResult.PostId != null)
                    {
                        parameters = new Dictionary <string, object>();
                        parameters.Add("postId", shareResult.PostId);
                    }
                    var fbArgs = new FBEventArgs <Dictionary <string, object> >(parameters, FacebookActionStatus.Completed);
                    _onSharing?.Invoke(CrossFacebookClient.Current, fbArgs);
                    _shareTcs?.TrySetResult(new FacebookResponse <Dictionary <string, object> >(fbArgs));
                },
                HandleCancel = () =>
                {
                    var fbArgs = new FBEventArgs <Dictionary <string, object> >(null, FacebookActionStatus.Canceled, "User cancelled facebook operation");
                    _onSharing?.Invoke(CrossFacebookClient.Current, fbArgs);
                    _shareTcs?.TrySetResult(new FacebookResponse <Dictionary <string, object> >(fbArgs));
                },
                HandleError = shareError =>
                {
                    var fbArgs = new FBEventArgs <Dictionary <string, object> >(null, FacebookActionStatus.Error, shareError.Message);
                    _onSharing?.Invoke(CrossFacebookClient.Current, fbArgs);
                    _shareTcs?.TrySetResult(new FacebookResponse <Dictionary <string, object> >(fbArgs));
                }
            };


            gameRequestCallback = new FacebookCallback <GameRequestDialog.Result>
            {
                HandleSuccess = gameRequestResult =>
                {
                    if (!string.IsNullOrEmpty(gameRequestResult.RequestId))
                    {
                        Dictionary <string, object> parameters = new Dictionary <string, object>();

                        parameters.Add("requestId", gameRequestResult.RequestId);
                        var fbArgs = new FBEventArgs <Dictionary <string, object> >(parameters, FacebookActionStatus.Completed);
                        _onGameRequest?.Invoke(CrossFacebookClient.Current, fbArgs);
                        _gameRequestTcs?.TrySetResult(new FacebookResponse <Dictionary <string, object> >(fbArgs));
                    }
                },
                HandleCancel = () =>
                {
                    var fbArgs = new FBEventArgs <Dictionary <string, object> >(null, FacebookActionStatus.Canceled, "User cancelled facebook operation");
                    _onGameRequest?.Invoke(CrossFacebookClient.Current, fbArgs);
                    _gameRequestTcs?.TrySetResult(new FacebookResponse <Dictionary <string, object> >(fbArgs));
                },
                HandleError = gameRequestError =>
                {
                    var fbArgs = new FBEventArgs <Dictionary <string, object> >(null, FacebookActionStatus.Error, gameRequestError.Message);
                    _onGameRequest?.Invoke(CrossFacebookClient.Current, fbArgs);
                    _gameRequestTcs?.TrySetResult(new FacebookResponse <Dictionary <string, object> >(fbArgs));
                }
            };

            LoginManager.Instance.RegisterCallback(mCallbackManager, loginCallback);
        }
Пример #5
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            FacebookSdk.SdkInitialize(this.ApplicationContext);

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

            // Setting Layout
            SetContentView(Resource.Layout.RegisterAccount);

            // getting editText
            nom    = FindViewById <EditText>(Resource.Id.reg_lname_text);
            prenom = FindViewById <EditText>(Resource.Id.reg_fname_text);
            email  = FindViewById <EditText>(Resource.Id.reg_email_text);
            mdp    = FindViewById <EditText>(Resource.Id.reg_pwd_text);
            mdp2   = FindViewById <EditText>(Resource.Id.reg_confPwd_text);
            pseudo = FindViewById <EditText>(Resource.Id.reg_pseudo_text);


            // Login if already have an account
            TextView loginTextView = FindViewById <TextView>(Resource.Id.reg_signin_text);

            loginTextView.Click += delegate
            {
                StartActivity(typeof(LoginActivity));
            };

            // Facebook Configuration

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

            button.SetReadPermissions(new List <string> {
                "public_profile", "user_friends", "email"
            });
            mCallBackManager = CallbackManagerFactory.Create();
            button.RegisterCallback(mCallBackManager, this);


            // bouton enregistrement inscription
            Button registerButton = FindViewById <Button>(Resource.Id.register_btn);

            registerButton.Click += delegate
            {
                // verification des champs
                bool error = false;
                if (!error)
                {
                    error = verifText("prenom", prenom);
                }
                if (!error)
                {
                    error = verifText("nom", nom);
                }
                if (!error)
                {
                    error = verifText("pseudo", pseudo);
                }
                if (!error)
                {
                    error = verifText("email", email);
                }
                if (!error)
                {
                    error = verifText("mot de passe", mdp);
                }
                if (!error)
                {
                    error = verifText("confirmation de mot de passe", mdp2);
                }

                if (!error && mdp.Text.ToString() != mdp2.Text.ToString())
                {
                    error = true;
                    Toast.MakeText(this, "Les mots de passe ne correspondent pas", ToastLength.Long).Show();
                }

                // Vérification de la saisie !!!
                if (!error)
                {
                    User user = new User(prenom.Text, nom.Text, pseudo.Text, email.Text, mdp.Text);
                    DataBase.Inscription(user);
                    DataBase.connected = true;

                    StartActivity(typeof(ProfileActivity));
                }
            };
        }
Пример #6
0
        private void InitSocialLogins()
        {
            try
            {
                //#Facebook
                if (AppSettings.ShowFacebookLogin)
                {
                    //FacebookSdk.SdkInitialize(this);

                    MprofileTracker = new FbMyProfileTracker();
                    MprofileTracker.MOnProfileChanged += MprofileTrackerOnMOnProfileChanged;
                    MprofileTracker.StartTracking();

                    FbLoginButton            = FindViewById <LoginButton>(Resource.Id.fblogin_button);
                    FbLoginButton.Visibility = ViewStates.Visible;
                    //FbLoginButton.SetReadPermissions(new List<string>
                    //{
                    //    "email",
                    //    "public_profile"
                    //});

                    MFbCallManager = CallbackManagerFactory.Create();
                    FbLoginButton.RegisterCallback(MFbCallManager, this);

                    //FB accessToken
                    var accessToken = AccessToken.CurrentAccessToken;
                    var isLoggedIn  = accessToken != null && !accessToken.IsExpired;
                    if (isLoggedIn && Profile.CurrentProfile != null)
                    {
                        LoginManager.Instance.LogOut();
                    }

                    string hash = Methods.App.GetKeyHashesConfigured(this);
                    Console.WriteLine(hash);
                }
                else
                {
                    FbLoginButton            = FindViewById <LoginButton>(Resource.Id.fblogin_button);
                    FbLoginButton.Visibility = ViewStates.Gone;
                }

                //#Google
                if (AppSettings.ShowGoogleLogin)
                {
                    // Configure sign-in to request the user's ID, email address, and basic profile. ID and basic profile are included in DEFAULT_SIGN_IN.
                    var gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DefaultSignIn)
                              .RequestIdToken(AppSettings.ClientId)
                              .RequestScopes(new Scope(Scopes.Profile))
                              .RequestScopes(new Scope(Scopes.PlusMe))
                              .RequestScopes(new Scope(Scopes.DriveAppfolder))
                              .RequestServerAuthCode(AppSettings.ClientId)
                              .RequestProfile().RequestEmail().Build();

                    // Build a GoogleApiClient with access to the Google Sign-In API and the options specified by gso.
                    MGoogleApiClient = new GoogleApiClient.Builder(this, this, this)
                                       .EnableAutoManage(this, this)
                                       .AddApi(Auth.GOOGLE_SIGN_IN_API, gso)
                                       .Build();

                    GoogleSignInButton        = FindViewById <SignInButton>(Resource.Id.Googlelogin_button);
                    GoogleSignInButton.Click += GoogleSignInButtonOnClick;
                }
                else
                {
                    GoogleSignInButton            = FindViewById <SignInButton>(Resource.Id.Googlelogin_button);
                    GoogleSignInButton.Visibility = ViewStates.Gone;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Пример #7
0
 public override void OnCreate(Bundle savedInstanceState)
 {
     base.OnCreate(savedInstanceState);
     callbackManager = CallbackManagerFactory.Create();
     LoginManager.Instance.RegisterCallback(callbackManager, this);
 }
Пример #8
0
 public FacebookService()
 {
     CallbackManager = CallbackManagerFactory.Create();
     LoginManager.Instance.RegisterCallback(CallbackManager, this);
 }
Пример #9
0
 public void LoginFacebook()
 {
     callbackManager = CallbackManagerFactory.Create();
     LoginManager.Instance.RegisterCallback(callbackManager, this);
     LoginManager.Instance.LogInWithReadPermissions(this, new[] { "public_profile", "user_friends", "email", "user_birthday", "user_location" });
 }
Пример #10
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            try
            {
                base.OnCreate(savedInstanceState);

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

                regularTxt  = Typeface.CreateFromAsset(Assets, "fonts/SF-UI-Display-Regular.ttf");
                semiboldTxt = Typeface.CreateFromAsset(Assets, "fonts/SF-UI-Display-Semibold.ttf");

                //Get values
                UsernameEditext = FindViewById <EditText>(Resource.Id.usernamefield);
                PasswordEditext = FindViewById <EditText>(Resource.Id.passwordfield);
                progressBar     = FindViewById <ProgressBar>(Resource.Id.progressBar);

                Btn_Login = FindViewById <Button>(Resource.Id.loginButton);

                RegisterButton = FindViewById <Button>(Resource.Id.signUpButton);

                Main_LinearLayout = FindViewById <LinearLayout>(Resource.Id.mainLinearLayout);

                topTitile      = FindViewById <TextView>(Resource.Id.titile);
                topTitile.Text = AppSettings.Application_Name;

                subTitile      = FindViewById <TextView>(Resource.Id.subtitile);
                subTitile.Text = this.GetText(Resource.String.Lbl_Subtitile_Login);

                Txt_forgetpass = FindViewById <TextView>(Resource.Id.forgetpassButton);

                Txt_Terms_of_service = FindViewById <TextView>(Resource.Id.secTermTextView);
                Txt_Privacy          = FindViewById <TextView>(Resource.Id.secPrivacyTextView);

                progressBar.Visibility = ViewStates.Invisible;

                UsernameEditext.SetTypeface(regularTxt, TypefaceStyle.Normal);
                PasswordEditext.SetTypeface(regularTxt, TypefaceStyle.Normal);
                topTitile.SetTypeface(regularTxt, TypefaceStyle.Normal);
                subTitile.SetTypeface(regularTxt, TypefaceStyle.Normal);
                Txt_forgetpass.SetTypeface(regularTxt, TypefaceStyle.Normal);
                Txt_Terms_of_service.SetTypeface(regularTxt, TypefaceStyle.Normal);
                Txt_Privacy.SetTypeface(regularTxt, TypefaceStyle.Normal);
                FontController.SetFont(Btn_Login, 1);
                FontController.SetFont(RegisterButton, 1);

                //Social Logins >>
                //==============================
                FacebookSdk.SdkInitialize(this);

                mprofileTracker = new FB_MyProfileTracker();
                mprofileTracker.StartTracking();

                BtnFBLogin = FindViewById <LoginButton>(Resource.Id.fblogin_button);
                BtnFBLogin.SetReadPermissions(new List <string>
                {
                    "email",
                    "public_profile"
                });
                mFBCallManager = CallbackManagerFactory.Create();
                BtnFBLogin.RegisterCallback(mFBCallManager, this);

                //FB accessToken
                var accessToken = AccessToken.CurrentAccessToken;
                var isLoggedIn  = accessToken != null && !accessToken.IsExpired;
                if (isLoggedIn && Profile.CurrentProfile != null)
                {
                    LoginManager.Instance.LogOut();
                }

                // Configure sign-in to request the user's ID, email address, and basic profile. ID and basic profile are included in DEFAULT_SIGN_IN.
                var gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DefaultSignIn)
                          .RequestIdToken(GoogleServices.ClientId)
                          .RequestScopes(new Scope(Scopes.Profile))
                          .RequestScopes(new Scope(Scopes.PlusLogin))
                          .RequestServerAuthCode(GoogleServices.ClientId)
                          .RequestProfile().RequestEmail().Build();

                // Build a GoogleApiClient with access to the Google Sign-In API and the options specified by gso.
                mGoogleApiClient = new GoogleApiClient.Builder(this, this, this)
                                   .EnableAutoManage(this, this)
                                   .AddApi(Auth.GOOGLE_SIGN_IN_API, gso)
                                   .Build();

                mGoogleSignIn = FindViewById <Button>(Resource.Id.Googlelogin_button);



                if (!AppSettings.Show_Facebook_Login)
                {
                    BtnFBLogin.Visibility = ViewStates.Gone;
                }

                if (!AppSettings.Show_Google_Login)
                {
                    mGoogleSignIn.Visibility = ViewStates.Gone;
                }

                //==============================

                if (!string.IsNullOrEmpty(OneSignalNotification.OneSignalAPP_ID))
                {
                    if (AppSettings.ShowNotification)
                    {
                        OneSignalNotification.RegisterNotificationDevice();
                    }
                }

                if ((int)Build.VERSION.SdkInt < 23)
                {
                }
                else
                {
                    RequestPermissions(new string[]
                    {
                        Manifest.Permission.ReadExternalStorage,
                        Manifest.Permission.WriteExternalStorage,
                    }, 1);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Пример #11
0
 public static void RegisterGoogleCallbacks()
 {
     CallbackManager = CallbackManagerFactory.Create();
 }
Пример #12
0
 public static void Handle()
 {
     CallbackManager = CallbackManagerFactory.Create();
     CreateBuilder();
     RegisterGoogleCallbacks();
 }
Пример #13
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            try
            {
                FacebookSdk.SdkInitialize(this.ApplicationContext);

                callbackManager = CallbackManagerFactory.Create();
                LoginManager.Instance.RegisterCallback(callbackManager, this);

                LoginManager.Instance.LogInWithReadPermissions(this, LOGIN_PERMISSIONS);
            }
            catch (Exception e)
            {
                string failureInfo = e.ToString();
                Console.WriteLine("FacebookActivity::onCreate() EXCEPTION " + failureInfo);
            }

            SetContentView(Resource.Layout.facebookLoginPage);

            profileTracker = new CustomProfileTracker
            {
                HandleCurrentProfileChanged = (oldProfile, currentProfile) =>
                {
                    UpdateUI();
                }
            };

            // properties applied to all buttons on Facebook login page
            var      padding   = Awpbs.Mobile.Config.OkCancelButtonsPadding;
            var      minHeight = Awpbs.Mobile.Config.OkCancelButtonsHeight;
            Typeface typeface  = Typeface.CreateFromAsset(Resources.Assets, "fonts/Lato-Regular.ttf");

            // Profile Picture
            profilePictureView = FindViewById <ProfilePictureView>(Resource.Id.profilePicture);
            profilePictureView.SetMinimumHeight(minHeight);
            profilePictureView.SetPadding(padding, padding, padding, padding);

            // Greeting "Hello, Alex!", visible when connected to facebook account
            greeting = FindViewById <TextView>(Resource.Id.greeting);
            greeting.SetMinimumHeight(minHeight);
            greeting.SetPadding(padding, padding, padding, padding);
            greeting.SetTypeface(typeface, TypefaceStyle.Bold);
            greeting.SetTextSize(Android.Util.ComplexUnitType.Sp, Config.LargerFontSize);

            //
            // Cancel and Ok buttons at the bottom of the page
            //
            cancelButton = FindViewById <Button>(Resource.Id.CancelButtonFb);
            cancelButton.SetBackgroundColor(Config.ColorBackgroundLogo.ToAndroid());
            cancelButton.SetMinimumHeight(minHeight);
            cancelButton.SetPadding(padding, padding, padding, padding);
            cancelButton.SetTypeface(typeface, TypefaceStyle.Bold);
            cancelButton.SetTextSize(Android.Util.ComplexUnitType.Sp, Config.DefaultFontSize);
            cancelButton.Click += (sender, e) =>
            {
                this.Finish();
                App.FacebookService.OnLoginFailed();
            };

            thisIsMeButton = FindViewById <Button>(Resource.Id.thisIsMeButton);
            thisIsMeButton.SetBackgroundColor(Config.ColorRedBackground.ToAndroid());
            thisIsMeButton.SetMinimumHeight(minHeight);
            thisIsMeButton.SetPadding(padding, padding, padding, padding);
            thisIsMeButton.SetTypeface(typeface, TypefaceStyle.Bold);
            thisIsMeButton.SetTextSize(Android.Util.ComplexUnitType.Sp, Config.DefaultFontSize);
            thisIsMeButton.Click += (sender, e) =>
            {
                this.Finish();
                App.FacebookService.OnLoginSucessful();
            };
        }         // onCreate()
Пример #14
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            try
            {
                base.OnCreate(savedInstanceState);
                FacebookSdk.SdkInitialize(this.ApplicationContext);
                SetContentView(Resource.Layout.Login);
                txtUserName       = FindViewById <EditText>(Resource.Id.etEmailPhone);
                txtPassword       = FindViewById <EditText>(Resource.Id.etPassword);
                txtForgotUsername = FindViewById <EditText>(Resource.Id.etForgotUsername);

                btnLogIn = FindViewById <Button>(Resource.Id.btnLogin);
                GoogleApiClient.Builder builder = new GoogleApiClient.Builder(this);
                builder.AddConnectionCallbacks(this);
                builder.AddOnConnectionFailedListener(this);
                builder.AddApi(PlusClass.API);
                builder.AddScope(new Scope(Scopes.PlusLogin));
                mGoogleApiClient = builder.Build();
                mGoogleApiClient.Connect();

                if (Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.Lollipop)
                {
                    Window.AddFlags(WindowManagerFlags.DrawsSystemBarBackgrounds);
                    Window.SetStatusBarColor(new Android.Graphics.Color(ContextCompat.GetColor(this, Resource.Color.primaryDark)));
                }

                ISharedPreferences prefs = Application.Context.GetSharedPreferences("WeClip", FileCreationMode.Private);

                var FromUserScreen = Intent.GetStringExtra("FromUserName");

                if (!string.IsNullOrEmpty(FromUserScreen))
                {
                    var prefEditor = prefs.Edit();
                    prefEditor.PutBoolean("RegisterEmail", false);
                    prefEditor.PutBoolean("RegisterPhone", false);
                    prefEditor.Commit();
                }

                bool RegisterEmail = prefs.GetBoolean("RegisterEmail", false);
                bool RegisterPhone = prefs.GetBoolean("RegisterPhone", false);

                llayoutSignIn         = FindViewById <LinearLayout>(Resource.Id.llayoutSignIn);
                llayoutSignUpOptions  = FindViewById <LinearLayout>(Resource.Id.llayoutSignUpOptions);
                llayoutForgotPassword = FindViewById <LinearLayout>(Resource.Id.llayoutForgot);


                btnSignUpWsocial        = FindViewById <TextView>(Resource.Id.btnSignUpWsocial);
                btnSignUpWsocial.Click += BtnSignUpWsocial_Click;

                btnSignInView        = FindViewById <TextView>(Resource.Id.btnSignInView);
                btnSignInView.Click += BtnSignInView_Click;

                btnForgotPassword        = FindViewById <TextView>(Resource.Id.btnForgotPassword);
                btnForgotPassword.Click += BtnForgotPassword_Click;

                btnsignInInForgotPassword        = FindViewById <TextView>(Resource.Id.tvSigninInForgotPassword);
                btnsignInInForgotPassword.Click += BtnSigninForgotPassword_Click;


                btnSignupWithEmail     = FindViewById <Button>(Resource.Id.btnSignUpWithEmail);
                btnSignupWithPhone     = FindViewById <Button>(Resource.Id.btnSignUpWithPhone);
                btnSignupWithGoogle    = FindViewById <Button>(Resource.Id.btnGPlus);
                btnSignUpWithFacebook  = FindViewById <Button>(Resource.Id.btnFacebook);
                btnSumitForgotPassword = FindViewById <Button>(Resource.Id.btnSubmitForgotPassword);
                mcallBackManager       = CallbackManagerFactory.Create();

                btnSignupWithPhone.Visibility = ViewStates.Gone;

                LoginManager.Instance.RegisterCallback(mcallBackManager, this);

                btnSignupWithEmail.Click     += btnSignupWithEmail_Click;
                btnSignupWithPhone.Click     += BtnSignupWithPhone_Click;
                btnSignupWithGoogle.Click    += BtnSignupWithGoogle_Click;
                btnSignUpWithFacebook.Click  += BtnSignUpWithFacebook_Click;
                btnSumitForgotPassword.Click += BtnSumitForgotPassword_Click;
                btnLogIn.Click += BtnLogIn_Click;

                if (RegisterEmail == true)
                {
                    SignUpView();
                }
            }
            catch (Java.Lang.Exception ex)
            {
                new CrashReportAsync("LoginActivity", "OnCreate", ex.Message + ex.StackTrace).Execute();
            }
        }
Пример #15
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);
            };
        }
        protected override void OnCreate(Android.OS.Bundle savedInstanceState)
        {
            string title          = Intent.GetStringExtra("Title");
            string description    = Intent.GetStringExtra("Description");
            string imageUrl       = Intent.GetStringExtra("ImageUrl");
            string localImagePath = Intent.GetStringExtra("ImagePath");
            string localVideoPath = Intent.GetStringExtra("VideoPath");
            string link           = Intent.GetStringExtra("Link");

            base.OnCreate(savedInstanceState);

            FacebookSdk.ApplicationId   = Droid.DS.FacebookLogin.FacebookAppId;
            FacebookSdk.ApplicationName = "";
            FacebookSdk.SdkInitialize(ApplicationContext);


            callbackManager = CallbackManagerFactory.Create();
            fbShareCallback = new FacebookCallback <SharerResult>
            {
                HandleSuccess = loginResult =>
                {
                    Toast.MakeText(ApplicationContext, "Your post has been shared successfully.", ToastLength.Long).Show();
                    ShareCompleted(ShareStatus.Success, "Your post has been shared successfully.");
                },
                HandleCancel = () =>
                {
                    Toast.MakeText(ApplicationContext, "Cancelled", ToastLength.Long).Show();
                    ShareCompleted(ShareStatus.Cancelled, "User has cancelled.");
                },
                HandleError = loginError =>
                {
                    Toast.MakeText(ApplicationContext, "Error " + loginError.Message, ToastLength.Long).Show();
                    ShareCompleted(ShareStatus.Error, loginError.Message);
                }
            };
            ShareContent shareContent = null;

            if (!string.IsNullOrWhiteSpace(localImagePath))
            {
                SharePhoto sharePhoto = (SharePhoto) new SharePhoto.Builder()
                                        .SetBitmap(Android.Graphics.BitmapFactory.DecodeFile(localImagePath))
                                        .SetCaption(title)
                                        .Build();
                SharePhotoContent content = new SharePhotoContent.Builder()
                                            .AddPhoto(sharePhoto)
                                            .Build();

                shareContent = content; // new ShareMediaContent.Builder().AddMedium(sharePhoto).Build();
            }

            else if (!string.IsNullOrWhiteSpace(localVideoPath))
            {
                Android.Net.Uri videoFileUri = Android.Net.Uri.FromFile(new Java.IO.File(localVideoPath));
                ShareVideo      shareVideo   = (ShareVideo) new ShareVideo.Builder()
                                               .SetLocalUrl(videoFileUri)
                                               .Build();
                ShareVideoContent content = new ShareVideoContent.Builder()
                                            .SetVideo(shareVideo)
                                            .Build();
                shareContent = content;
            }
            else
            {
                var contentBuilder = new ShareLinkContent.Builder();
                contentBuilder.SetContentTitle(title);
                if (!string.IsNullOrWhiteSpace(description))
                {
                    contentBuilder.SetContentDescription(description);
                }
                if (!string.IsNullOrWhiteSpace(imageUrl))
                {
                    contentBuilder.SetImageUrl(Android.Net.Uri.Parse(imageUrl));
                }
                if (!string.IsNullOrWhiteSpace(link))
                {
                    contentBuilder.SetContentUrl(Android.Net.Uri.Parse(link));
                }
                shareContent = contentBuilder.Build();
            }
            if (ShareDialog.CanShow(shareContent.Class))
            {
                var shareDialog = new ShareDialog(this);
                shareDialog.RegisterCallback(callbackManager, fbShareCallback);
                shareDialog.Show(shareContent, ShareDialog.Mode.Automatic);
                return;
            }
            else
            {
                var FBLoginCallback = new FacebookCallback <LoginResult>
                {
                    HandleSuccess = loginResult =>
                    {
                        ShareApi.Share(shareContent, fbShareCallback);
                    },
                    HandleCancel = () =>
                    {
                        Toast.MakeText(ApplicationContext, "Cancelled", ToastLength.Long).Show();
                        ShareCompleted(ShareStatus.Cancelled, "User has cancelled.");
                    },
                    HandleError = loginError =>
                    {
                        LoginManager.Instance.LogOut();
                        Toast.MakeText(ApplicationContext, "Error " + loginError.Message, ToastLength.Long).Show();
                        ShareCompleted(ShareStatus.Error, loginError.Message);
                    }
                };
                LoginManager.Instance.RegisterCallback(callbackManager, FBLoginCallback);
                LoginManager.Instance.LogInWithPublishPermissions(this, new System.Collections.Generic.List <string>()
                {
                    "publish_actions"
                });
            }
        }
Пример #17
0
 public static void Init(Activity activity)
 {
     FacebookSdk.SdkInitialize(activity);
     CallbackManager = CallbackManagerFactory.Create();
 }
Пример #18
0
        protected override void OnElementChanged(ElementChangedEventArgs <View> e)
        {
            FacebookSdk.SdkInitialize(Android.App.Application.Context);

            callbackManager = CallbackManagerFactory.Create();

            var loginCallback = new FacebookCallback <LoginResult>
            {
                HandleSuccess = loginResult =>
                {
                    Console.WriteLine("1");
                    //HandlePendingAction();
                    //UpdateUI();
                },
                HandleCancel = () =>
                {
                    Console.WriteLine("2");
                    //if (pendingAction != PendingAction.NONE)
                    //{
                    //	ShowAlert(
                    //		GetString(Resource.String.cancelled),
                    //		GetString(Resource.String.permission_not_granted));
                    //	pendingAction = PendingAction.NONE;
                    //}
                    //UpdateUI();
                },
                HandleError = loginError =>
                {
                    Console.WriteLine("3");
                    //if (pendingAction != PendingAction.NONE
                    //	&& loginError is FacebookAuthorizationException)
                    //{
                    //	ShowAlert(
                    //		GetString(Resource.String.cancelled),
                    //		GetString(Resource.String.permission_not_granted));
                    //	pendingAction = PendingAction.NONE;
                    //}
                    //UpdateUI();
                }
            };

            LoginManager.Instance.RegisterCallback(callbackManager, loginCallback);

            shareCallback = new FacebookCallback <SharerResult>
            {
                HandleSuccess = shareResult =>
                {
                    Console.WriteLine("HelloFacebook: Success!");
                },
                HandleCancel = () =>
                {
                    Console.WriteLine("HelloFacebook: Canceled");
                },
                HandleError = shareError =>
                {
                    Console.WriteLine("HelloFacebook: Error: {0}", shareError);
                }
            };
            //profileTracker = new CustomProfileTracker
            //{
            //	HandleCurrentProfileChanged = (oldProfile, currentProfile) =>
            //	{
            //		UpdateUI();
            //		HandlePendingAction();
            //	}
            //};

            var r             = (Android.Views.LayoutInflater)Context.GetSystemService(Context.LayoutInflaterService);
            var containerView = r.Inflate(Resource.Layout.FacebookButton, null, false);

            SetNativeControl(containerView);

            //Activity activity = Context as Activity;
            //var ft = activity.FragmentManager.BeginTransaction();
            //ft.Replace(Resource.Id.contentSwipe, new FragmentInbox(((SwipeCausaForms)Element).causa, activity, ((SwipeCausaForms)Element).page), "fragment_inbox");
            //ft.Commit();
        }
Пример #19
0
        private void InitSocialLogins()
        {
            try
            {
                //#Facebook
                if (AppSettings.ShowFacebookLogin)
                {
                    //FacebookSdk.SdkInitialize(this);

                    MprofileTracker = new FbMyProfileTracker();
                    MprofileTracker.MOnProfileChanged += MprofileTrackerOnMOnProfileChanged;
                    MprofileTracker.StartTracking();

                    FbLoginButton            = FindViewById <LoginButton>(Resource.Id.fblogin_button);
                    FbLoginButton.Visibility = ViewStates.Visible;
                    FbLoginButton.SetPermissions(new List <string>
                    {
                        "email",
                        "public_profile"
                    });

                    MFbCallManager = CallbackManagerFactory.Create();
                    FbLoginButton.RegisterCallback(MFbCallManager, this);

                    //FB accessToken
                    var accessToken = AccessToken.CurrentAccessToken;
                    var isLoggedIn  = accessToken != null && !accessToken.IsExpired;
                    if (isLoggedIn && Profile.CurrentProfile != null)
                    {
                        LoginManager.Instance.LogOut();
                    }

                    string hash = Methods.App.GetKeyHashesConfigured(this);
                    Console.WriteLine(hash);
                }
                else
                {
                    FbLoginButton            = FindViewById <LoginButton>(Resource.Id.fblogin_button);
                    FbLoginButton.Visibility = ViewStates.Gone;
                }

                //#Google
                if (AppSettings.ShowGoogleLogin)
                {
                    GoogleSignInButton        = FindViewById <SignInButton>(Resource.Id.Googlelogin_button);
                    GoogleSignInButton.Click += GoogleSignInButtonOnClick;
                }
                else
                {
                    GoogleSignInButton            = FindViewById <SignInButton>(Resource.Id.Googlelogin_button);
                    GoogleSignInButton.Visibility = ViewStates.Gone;
                }

                //#WoWonder
                if (AppSettings.ShowWoWonderLogin)
                {
                    WoWonderSignInButton        = FindViewById <Button>(Resource.Id.WoWonderLogin_button);
                    WoWonderSignInButton.Click += WoWonderSignInButtonOnClick;

                    WoWonderSignInButton.Text       = GetString(Resource.String.Lbl_LoginWith) + " " + AppSettings.AppNameWoWonder;
                    WoWonderSignInButton.Visibility = ViewStates.Visible;
                }
                else
                {
                    WoWonderSignInButton            = FindViewById <Button>(Resource.Id.WoWonderLogin_button);
                    WoWonderSignInButton.Visibility = ViewStates.Gone;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Пример #20
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            FacebookSdk.SdkInitialize(this.ApplicationContext);

            callbackManager = CallbackManagerFactory.Create();

            var loginCallback = new FacebookCallback <LoginResult> {
                HandleSuccess = loginResult => {
                    HandlePendingAction();
                    UpdateUI();
                },
                HandleCancel = () => {
                    if (pendingAction != PendingAction.NONE)
                    {
                        ShowAlert(
                            GetString(Resource.String.cancelled),
                            GetString(Resource.String.permission_not_granted));
                        pendingAction = PendingAction.NONE;
                    }
                    UpdateUI();
                },
                HandleError = loginError => {
                    if (pendingAction != PendingAction.NONE &&
                        loginError is FacebookAuthorizationException)
                    {
                        ShowAlert(
                            GetString(Resource.String.cancelled),
                            GetString(Resource.String.permission_not_granted));
                        pendingAction = PendingAction.NONE;
                    }
                    UpdateUI();
                }
            };

            LoginManager.Instance.RegisterCallback(callbackManager, loginCallback);

            shareCallback = new FacebookCallback <SharerResult> {
                HandleSuccess = shareResult => {
                    Console.WriteLine("HelloFacebook: Success!");

                    if (shareResult.PostId != null)
                    {
                        var title    = Parent.GetString(Resource.String.error);
                        var id       = shareResult.PostId;
                        var alertMsg = Parent.GetString(Resource.String.successfully_posted_post, id);

                        ShowAlert(title, alertMsg);
                    }
                },
                HandleCancel = () => {
                    Console.WriteLine("HelloFacebook: Canceled");
                },
                HandleError = shareError => {
                    Console.WriteLine("HelloFacebook: Error: {0}", shareError);

                    var title    = Parent.GetString(Resource.String.error);
                    var alertMsg = shareError.Message;

                    ShowAlert(title, alertMsg);
                }
            };

            shareDialog = new ShareDialog(this);
            shareDialog.RegisterCallback(callbackManager, shareCallback);

            if (savedInstanceState != null)
            {
                var name = savedInstanceState.GetString(PENDING_ACTION_BUNDLE_KEY);
                pendingAction = (PendingAction)Enum.Parse(typeof(PendingAction), name);
            }

            SetContentView(Resource.Layout.main);

            profileTracker = new CustomProfileTracker {
                HandleCurrentProfileChanged = (oldProfile, currentProfile) => {
                    UpdateUI();
                    HandlePendingAction();
                }
            };

            profilePictureView = FindViewById <ProfilePictureView> (Resource.Id.profilePicture);

            greeting = FindViewById <TextView> (Resource.Id.greeting);

            postStatusUpdateButton        = FindViewById <Button> (Resource.Id.postStatusUpdateButton);
            postStatusUpdateButton.Click += (sender, e) => {
                PerformPublish(PendingAction.POST_STATUS_UPDATE, canPresentShareDialog);
            };

            postPhotoButton        = FindViewById <Button> (Resource.Id.postPhotoButton);
            postPhotoButton.Click += (sender, e) => {
                PerformPublish(PendingAction.POST_PHOTO, canPresentShareDialogWithPhotos);
            };

            // Can we present the share dialog for regular links?
            canPresentShareDialog = ShareDialog.CanShow(Java.Lang.Class.FromType(typeof(ShareLinkContent)));

            // Can we present the share dialog for photos?
            canPresentShareDialogWithPhotos = ShareDialog.CanShow(Java.Lang.Class.FromType(typeof(SharePhotoContent)));
        }
Пример #21
0
 public static void Handle()
 {
     CallbackManager = CallbackManagerFactory.Create();
     RegisterFacebookCallbacks();
     HandleToken();
 }
        private void InitSocialLogins()
        {
            try
            {
                //#Facebook
                if (AppSettings.ShowFacebookLogin)
                {
                    LoginButton loginButton = new LoginButton(this);
                    MprofileTracker = new FbMyProfileTracker();
                    MprofileTracker.StartTracking();

                    BtnFacebook            = FindViewById <Button>(Resource.Id.btn_facebook);
                    BtnFacebook.Visibility = ViewStates.Visible;
                    BtnFacebook.Click     += BtnFacebookOnClick;

                    MprofileTracker.MOnProfileChanged += MprofileTrackerOnMOnProfileChanged;
                    loginButton.SetPermissions(new List <string>
                    {
                        "email",
                        "public_profile"
                    });

                    MFbCallManager = CallbackManagerFactory.Create();
                    loginButton.RegisterCallback(MFbCallManager, this);

                    //FB accessToken
                    var accessToken = AccessToken.CurrentAccessToken;
                    var isLoggedIn  = accessToken != null && !accessToken.IsExpired;
                    if (isLoggedIn && Profile.CurrentProfile != null)
                    {
                        LoginManager.Instance.LogOut();
                    }

                    string hashId = Methods.App.GetKeyHashesConfigured(this);
                    Console.WriteLine(hashId);
                }
                else
                {
                    BtnFacebook            = FindViewById <Button>(Resource.Id.btn_facebook);
                    BtnFacebook.Visibility = ViewStates.Gone;
                }

                //#Google
                if (AppSettings.ShowGoogleLogin)
                {
                    // Configure sign-in to request the user's ID, email address, and basic profile. ID and basic profile are included in DEFAULT_SIGN_IN.
                    var gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DefaultSignIn)
                              .RequestIdToken(AppSettings.ClientId)
                              .RequestScopes(new Scope(Scopes.Profile))
                              .RequestScopes(new Scope(Scopes.PlusMe))
                              .RequestScopes(new Scope(Scopes.DriveAppfolder))
                              .RequestServerAuthCode(AppSettings.ClientId)
                              .RequestProfile().RequestEmail().Build();

                    MGoogleSignInClient = GoogleSignIn.GetClient(this, gso);

                    BtnGoogle        = FindViewById <Button>(Resource.Id.btn_google);
                    BtnGoogle.Click += GoogleSignInButtonOnClick;
                }
                else
                {
                    BtnGoogle            = FindViewById <Button>(Resource.Id.btn_google);
                    BtnGoogle.Visibility = ViewStates.Gone;
                }
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
Пример #23
0
 private void InitializeFacebook()
 {
     FacebookSdk.ApplicationId = "534663733642417";
     CallbackManager           = CallbackManagerFactory.Create();
 }
Пример #24
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            FacebookSdk.SdkInitialize(this.ApplicationContext);
            textToSpeech = new TextToSpeech(this, this);
            locale       = new Java.Util.Locale("pt", "BR");

            SetContentView(Resource.Layout.PagInicCliente);

            historico = Facade.GetPesquisas();

            // Facebook
            LoginButton loginbutton = FindViewById <LoginButton>(Resource.Id.login_button);

            loginbutton.SetReadPermissions("user_friends");

            mCallBackManager = CallbackManagerFactory.Create();

            loginbutton.RegisterCallback(mCallBackManager, this);

            PackageInfo info = this.PackageManager.GetPackageInfo("com.uminhomieili4.pick_a_prato", PackageInfoFlags.Signatures);

            foreach (Android.Content.PM.Signature signature in info.Signatures)
            {
                MessageDigest md = MessageDigest.GetInstance("SHA");
                md.Update(signature.ToByteArray());

                string keyhash = Convert.ToBase64String(md.Digest());
                Console.WriteLine("KeyHash: " + keyhash);
            }

            var imageuser = FindViewById <ImageView>(Resource.Id.foto);

            byte[] a = Convert.FromBase64String(Facade.atualUserC.Foto);
            Bitmap b = BitmapFactory.DecodeByteArray(a, 0, a.Length);

            imageuser.SetImageBitmap(b);

            var preferenciasButtom = FindViewById <Button>(Resource.Id.pref);

            preferenciasButtom.Click += (sender, e) => {
                StartActivity(typeof(EditarPreferencias));
            };

            var switchpref = FindViewById <Switch>(Resource.Id.switchpref);

            switchpref.Checked = true;

            Button guardadosbottom = FindViewById <Button>(Resource.Id.selecoes);

            guardadosbottom.Click += (sender, e) => {
                ListaPratos.pratoList = Facade.GetPratosGuardados();
                StartActivity(typeof(ListaPratos));
            };

            var gobottom = FindViewById <ImageView>(Resource.Id.go);

            textView        = FindViewById <AutoCompleteTextView>(Resource.Id.autocomplete_prato);
            textView.Click += (sender, e) => {
                textView.Text = "";
            };
            var adapter = new ArrayAdapter <String>(this, Resource.Layout.ListItem, historico);

            textView.Adapter = adapter;
            gobottom.Click  += (sender, e) => {
                if (textView.Text.Length != 0)
                {
                    List <Prato> pratos;
                    if (switchpref.Checked == true)
                    {
                        pratos = Facade.PesquisaPrato(textView.Text, true);
                    }
                    else
                    {
                        pratos = Facade.PesquisaPrato(textView.Text, false);
                    }
                    if (pratos.Count == 0)
                    {
                        textToSpeech.Speak("Não encontrei " + textView.Text, QueueMode.Flush, null, null);
                    }
                    else
                    {
                        ListaPratos.pratoList = pratos;
                        ListaPratos.pesquisa  = textView.Text;
                        StartActivity(typeof(ListaPratos));
                    }
                }
            };

            recButton        = FindViewById <ImageView>(Resource.Id.rec);
            recButton.Click += delegate {
                var voiceIntent = new Intent(RecognizerIntent.ActionRecognizeSpeech);
                voiceIntent.PutExtra(RecognizerIntent.ExtraLanguageModel, "pr-BR");
                voiceIntent.PutExtra(RecognizerIntent.ExtraPrompt, "Fale agora");
                voiceIntent.PutExtra(RecognizerIntent.ExtraSpeechInputCompleteSilenceLengthMillis, 1500);
                voiceIntent.PutExtra(RecognizerIntent.ExtraSpeechInputPossiblyCompleteSilenceLengthMillis, 1500);
                voiceIntent.PutExtra(RecognizerIntent.ExtraSpeechInputMinimumLengthMillis, 15000);
                voiceIntent.PutExtra(RecognizerIntent.ExtraMaxResults, 1);
                StartActivityForResult(voiceIntent, VOICE);
            };
        }
Пример #25
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.LoginActivity);

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



            // Create your application here


            mContext = this;

            Firebase.FirebaseApp.InitializeApp(this);


            var signedIn = FirebaseAuth.Instance.CurrentUser;

            if (signedIn == null)
            {
                //Toast.MakeText(this, "User Not Signed in", ToastLength.Short).Show();
            }
            else
            {
            }

            TextView txtLogin       = FindViewById <TextView>(Resource.Id.txtLogin);
            TextView txtRegister    = FindViewById <TextView>(Resource.Id.txtRegister);
            TextView txtGoogleLogin = FindViewById <TextView>(Resource.Id.txtLoginGoogle);



            txtLogin.Click    += moveToEmailLogin;
            txtRegister.Click += moveToRegister;


            //facebook

            //var BtnFBLogin = FindViewById<LoginButton>(Resource.Id.txtLoginFacebook);


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

            //mFBCallManager = CallbackManagerFactory.Create();
            //BtnFBLogin.RegisterCallback(mFBCallManager, this);



            mFBCallManager = CallbackManagerFactory.Create();
            LoginManager.Instance.RegisterCallback(mFBCallManager, this);

            facebookButton        = FindViewById <TextView>(Resource.Id.txtLoginFacebook);
            facebookButton.Click += OnFacebookButtonClick;



            LoginManager.Instance.LogOut();
        }
Пример #26
0
        public override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            _callbackManager = CallbackManagerFactory.Create();
        }
Пример #27
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            Console.Error.WriteLine("--------------------------- Creating activity ---------------------------");

            base.OnCreate(savedInstanceState);

            _activityResultWait      = new ManualResetEvent(false);
            _facebookCallbackManager = CallbackManagerFactory.Create();
            _serviceBindWait         = new ManualResetEvent(false);

            Window.AddFlags(global::Android.Views.WindowManagerFlags.DismissKeyguard);
            Window.AddFlags(global::Android.Views.WindowManagerFlags.ShowWhenLocked);
            Window.AddFlags(global::Android.Views.WindowManagerFlags.TurnScreenOn);

            Forms.Init(this, savedInstanceState);
            FormsMaps.Init(this, savedInstanceState);
            ZXing.Net.Mobile.Forms.Android.Platform.Init();
            CrossCurrentActivity.Current.Activity = this;

#if UI_TESTING
            Forms.ViewInitialized += (sender, e) =>
            {
                if (!string.IsNullOrWhiteSpace(e.View.StyleId))
                {
                    e.NativeView.ContentDescription = e.View.StyleId;
                }
            };
#endif

            LoadApplication(new App());

            _serviceConnection = new AndroidSensusServiceConnection();
            _serviceConnection.ServiceConnected += (o, e) =>
            {
                // it's happened that the service is created / started after the service helper is disposed:  https://insights.xamarin.com/app/Sensus-Production/issues/46
                // binding to the service in such a situation can result in a null service helper within the binder. if the service helper was disposed, then the goal is
                // to close down sensus. so finish the activity.
                if (e.Binder.SensusServiceHelper == null)
                {
                    Finish();
                    return;
                }

                // tell the service to finish this activity when it is stopped
                e.Binder.ServiceStopAction = Finish;

                // signal the activity that the service has been bound
                _serviceBindWait.Set();

                // if we're UI testing, try to load and run the UI testing protocol from the embedded assets
#if UI_TESTING
                using (Stream protocolFile = Assets.Open("UiTestingProtocol.json"))
                {
                    Protocol.RunUiTestingProtocolAsync(protocolFile);
                }
#endif
            };

            // the following is fired if the process hosting the service crashes or is killed.
            _serviceConnection.ServiceDisconnected += (o, e) =>
            {
                Toast.MakeText(this, "The Sensus service has crashed.", ToastLength.Long);
                DisconnectFromService();
                Finish();
            };

            OpenIntentAsync(Intent);
        }
Пример #28
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            FacebookSdk.SdkInitialize(this.ApplicationContext);

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

            // Set our view from the "main" layout resource
            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);

            //if (AccessToken.CurrentAccessToken != null)
            //{
            //    //The user is logged in through Facebook
            //    faceBookButton.Text = "Logged Out";
            //}

            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();
            };

            //LoginManager.Instance.RegisterCallback(mCallBackManager, this);

            //faceBookButton.Click += (o, e) =>
            //{
            //    if (AccessToken.CurrentAccessToken != null)
            //    {
            //        //The user is logged in through Facebook
            //        LoginManager.Instance.LogOut();
            //        faceBookButton.Text = "My Facebook login button";
            //    }

            //    else
            //    {
            //        //The user is not logged in
            //        LoginManager.Instance.LogInWithReadPermissions(this, new List<string> { "public_profile", "user_friends" });
            //        faceBookButton.Text = "Logged Out";
            //    }

            //};

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

            mBtnShared.ShareContent = content;
        }
Пример #29
0
 public FacebookManager()
 {
     _callbackManager = CallbackManagerFactory.Create();
     LoginManager.Instance.RegisterCallback(_callbackManager, this);
 }
Пример #30
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            MAIN = this;
            LocationManager lm = (LocationManager)GetSystemService(LocationService);

            /* Used to get App manifest hash
             *
             *  PackageInfo info = this.PackageManager.GetPackageInfo("UniProject.UniProject", PackageInfoFlags.Signatures);
             *
             *  foreach(Android.Content.PM.Signature signature in info.Signatures)
             *  {
             *      MessageDigest md = MessageDigest.GetInstance("SHA");
             *      md.Update(signature.ToByteArray());
             *
             *      string keyHash = Convert.ToBase64String(md.Digest());
             *      Console.WriteLine("KH: ", keyHash);
             *  }
             *  // Set our view from the "main" layout resource
             *  // SetContentView (Resource.Layout.Main);
             * }*/


            // Init the facebook SDK
            FacebookSdk.SdkInitialize(this.ApplicationContext);
            mProfileTracker = new myProfileTracker();
            mProfileTracker.mOnProfileChanged += MProfileTracker_mOnProfileChanged;
            mProfileTracker.StartTracking();

            if (currentProfile == null)
            {
                SetContentView(Resource.Layout.Main);
            }
            else
            {
                SetContentView(Resource.Layout.Fragment1);
            }



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

            button.SetReadPermissions("user_friends");
            mCallBackManager = CallbackManagerFactory.Create();
            button.RegisterCallback(mCallBackManager, this);
            mText = FindViewById <TextView>(Resource.Id.textView1);
            Button MainToFrag1 = FindViewById <Button>(Resource.Id.m1_f1);

            //Button Frag1ToMain = FindViewById<Button>(Resource.Id.button1);

            // Click Handler delegates //
            MainToFrag1.Click += (object e, EventArgs s) =>
            {
                SetContentView(Resource.Layout.Fragment1);
            };

            /*  Frag1ToMain.Click += (object e, EventArgs s) =>
             * {
             *    SetContentView(Resource.Layout.Main);
             * };a*/
        }