public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // If was send true to Profile.EnableUpdatesOnAccessTokenChange method
            // this notification will be called after the user is logged in and
            // after the AccessToken is gotten
            Profile.Notifications.ObserveDidChange((sender, e) => {
                if (e.NewProfile == null)
                {
                    return;
                }

                nameLabel.Text = e.NewProfile.Name;
            });

            var width = this.View.Bounds.Width;

            // The user image profile is set automatically once is logged in
            pictureView = new ProfilePictureView(new CGRect((width - 100) / 2, 80, 100, 100));

            // Create the label that will hold user's facebook name
            nameLabel = new UILabel(new RectangleF((float)(width - 200.0f) / 2, 220, 200, 21))
            {
                TextAlignment   = UITextAlignment.Center,
                BackgroundColor = UIColor.Clear
            };

            // Set the Read and Publish permissions you want to get
            loginView = new LoginButton(new CGRect((float)(width - 200.0f) / 2, 350, 200, 30))
            {
                LoginBehavior   = LoginBehavior.Native,
                ReadPermissions = readPermissions.ToArray()
            };

            // Handle actions once the user is logged in
            loginView.Completed += (sender, e) => {
                if (e.Error != null)
                {
                    return;
                }

                if (e.Result.IsCancelled)
                {
                    return;
                }
            };

            // Handle actions once the user is logged out
            loginView.LoggedOut += (sender, e) => {
                // Handle your logout
            };



            // Add views to main view
            View.AddSubview(loginView);
            View.AddSubview(pictureView);
            View.AddSubview(nameLabel);
        }
Exemplo n.º 2
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);



            //PackageInfo info = PackageManager.GetPackageInfo();
            //      "Package name",  //Replace your package name here
            //      PackageManager.GET_SIGNATURES);
            //for (Signature signature : info.signatures)
            //{
            //    MessageDigest md = MessageDigest.getInstance("SHA");
            //    md.update(signature.toByteArray());
            //    Log.e("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
            //}

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

            BtnFBLogin   = FindViewById <LoginButton>(Resource.Id.fblogin);
            TxtFirstName = FindViewById <TextView>(Resource.Id.TxtFirstname);
            TxtLastName  = FindViewById <TextView>(Resource.Id.TxtLastName);
            TxtName      = FindViewById <TextView>(Resource.Id.TxtName);
            mprofile     = FindViewById <ProfilePictureView>(Resource.Id.ImgPro);

            BtnFBLogin.SetReadPermissions(new List <string> {
                "user_friends", "public_profile"
            });
            mFBCallManager = CallbackManagerFactory.Create();
            BtnFBLogin.RegisterCallback(mFBCallManager, this);
        }
        private void InitializedFB()
        {
            activity = this.Context as Activity;
            view     = activity.LayoutInflater.Inflate(Resource.Layout.FacebookLayout, this, false);

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

            #region CHECKING IF ALREADY LOGGED IN TO FACEBOOK
            profile = Profile.CurrentProfile;

            if (profile != null)
            {
                firstname = profile.FirstName;
                lastname  = profile.LastName;
                GetUserInfoViaGraphRequest();
            }

            #endregion

            LoginManager.Instance.RegisterCallback(NativeFacebookPageRenderer.callbackManager, this);
            var buttonFB = view.FindViewById <Button>(Resource.Id.buttonFB);
            buttonFB.Click    += ButtonFB_Click;
            profilePictureView = view.FindViewById <ProfilePictureView>(Resource.Id.profilePicture);

            this.AddView(view);
            NativeView = view;
        }
Exemplo n.º 4
0
        /*Metodo de registro*/
        public void btn_empezar(object sender, EventArgs e)
        {
            //pantalla para logearse
            FacebookSdk.SdkInitialize(this.ApplicationContext);


            SetContentView(Resource.Layout.Main);

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


            /*Informacion extraida de facebook*/
            mTxtFirstName = FindViewById <TextView>(Resource.Id.txtFirstName);
            mTxtLastName  = FindViewById <TextView>(Resource.Id.txtLastName);
            mTxtName      = FindViewById <TextView>(Resource.Id.txtName);
            mProfilePic   = FindViewById <ProfilePictureView>(Resource.Id.profilePic);

            // LoginButton
            btnFacebook        = FindViewById <LoginButton>(Resource.Id.login_button);
            btnFacebook.Click += botonFB;



            btnRegistrar        = FindViewById <Button>(Resource.Id.btnRegistrar);
            btnRegistrar.Click += btn_registrar;

            btnIniciarSesion        = FindViewById <Button>(Resource.Id.btnIniciarSesion);
            btnIniciarSesion.Click += btn_iniciar_sesion;
        }
Exemplo n.º 5
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            // Perform any additional setup after loading the view, typically from a nib.

            // If was send true to Profile.EnableUpdatesOnAccessTokenChange method
            // this notification will be called after the user is logged in and
            // after the AccessToken is gotten
            Profile.Notifications.ObserveDidChange((sender, e) => {
                if (e.NewProfile == null)
                {
                    return;
                }

                LoggedIn(e.NewProfile.UserId);
            });

            loginButton = new LoginButton(new CGRect(48, 0, 218, 46))
            {
                Delegate = this
            };

            // This permission is set by default
            chkPublicProfile         = new CustomCheckboxElement("Public Profile", true);
            chkPublicProfile.Enabled = false;

            // Add or remove all the permissions that you want to ask
            readSection = new Section("Ask Read Permissions")
            {
                chkPublicProfile,
                new CustomCheckboxElement("Email", () => CheckReadPermission("email")),
                new CustomCheckboxElement("About Me", () => CheckReadPermission("user_about_me")),
                new CustomCheckboxElement("Birthday", () => CheckReadPermission("user_birthday")),
                new CustomCheckboxElement("Hometown", () => CheckReadPermission("user_hometown")),
                new CustomCheckboxElement("Friendlists", () => CheckReadPermission("read_custom_friendlists")),
                new CustomCheckboxElement("Managed Groups", () => CheckReadPermission("user_managed_groups"))
            };

            // The user image profile is set automatically once is logged in
            pictureView = new ProfilePictureView(new CGRect(48, 0, 220, 220));

            // Add the initial sections
            Root = new RootElement("Facebook iOS Sample")
            {
                readSection,
                new Section()
                {
                    new UIViewElement("", loginButton, true)
                    {
                        Flags = UIViewElement.CellFlags.DisableSelection | UIViewElement.CellFlags.Transparent,
                    }
                }
            };

            // If the user is already logged in, remove the read section and add the actions sections
            if (AccessToken.CurrentAccessToken != null)
            {
                LoggedIn(AccessToken.CurrentAccessToken.UserID);
            }
        }
Exemplo n.º 6
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            // Perform any additional setup after loading the view, typically from a nib.

            // If was send true to Profile.EnableUpdatesOnAccessTokenChange method
            // this notification will be called after the user is logged in and
            // after the AccessToken is gotten
            Profile.Notifications.ObserveDidChange((sender, e) => {
                if (e.NewProfile == null)
                {
                    return;
                }

                nameLabel.Text = e.NewProfile.Name;
            });

            // Set the Read and Publish permissions you want to get
            loginButton = new LoginButton(new CGRect(80, 20, 220, 46))
            {
                Permissions = readPermissions.ToArray(),
                Delegate    = this
            };

            // The user image profile is set automatically once is logged in
            pictureView = new ProfilePictureView(new CGRect(80, 100, 220, 220));

            // Create the label that will hold user's facebook name
            nameLabel = new UILabel(new CGRect(80, 340, 220, 21))
            {
                TextAlignment   = UITextAlignment.Center,
                BackgroundColor = UIColor.Clear
            };

            // If you have been logged into the app before, ask for the your profile name
            if (AccessToken.CurrentAccessToken != null)
            {
                var request = new GraphRequest("/me?fields=name", null, AccessToken.CurrentAccessToken.TokenString, null, "GET");
                request.Start((connection, result, error) => {
                    // Handle if something went wrong with the request
                    if (error != null)
                    {
                        new UIAlertView("Error...", error.Description, null, "Ok", null).Show();
                        return;
                    }

                    // Get your profile name
                    var userInfo   = result as NSDictionary;
                    nameLabel.Text = userInfo ["name"].ToString();
                });
            }

            // Add views to main view
            View.AddSubview(loginButton);
            View.AddSubview(pictureView);
            View.AddSubview(nameLabel);
        }
        public ListDetailViewController(string listId, string listName, FacebookListType type) : base(UITableViewStyle.Grouped, null, true)
        {
            Root = new RootElement(listName);

            // Ask for the members within the group
            var request           = new GraphRequest("/" + listId + "/members?fields=id,name", null, AccessToken.CurrentAccessToken.TokenString, null, "GET");
            var requestConnection = new GraphRequestConnection();

            requestConnection.AddRequest(request, (connection, result, error) => {
                // Handle if something went wrong
                if (error != null)
                {
                    new UIAlertView("Error...", error.Description, null, "Ok", null).Show();
                    return;
                }

                // Get the name and the userId of all the memebers
                NSArray membersData = (result as NSDictionary) ["data"] as NSArray;

                var listSection = new List <Section> ();

                // Add the name and the picture profile to the view
                for (nuint i = 0; i < membersData.Count; i++)
                {
                    // Get the info of one of the members
                    var memberData  = membersData.GetItem <NSDictionary> (i);
                    var pictureView = new ProfilePictureView(new CGRect(48, 0, 220, 220))
                    {
                        ProfileId = memberData ["id"].ToString(),
                        TranslatesAutoresizingMaskIntoConstraints = false
                    };

                    listSection.Add(new Section(memberData ["name"].ToString())
                    {
                        new UIViewElement("", pictureView, true)
                        {
                            Flags = UIViewElement.CellFlags.DisableSelection | UIViewElement.CellFlags.Transparent
                        }
                    });
                }

                Root = new RootElement(listName)
                {
                    listSection
                };
            });

            requestConnection.Start();
        }
Exemplo n.º 8
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);


            //Initializes the sdk face
            FacebookSdk.SdkInitialize(this.ApplicationContext);


            //PackageInfo oPackageInfo = this.PackageManager.GetPackageInfo("com.facebook.FacebookActivity", PackageInfoFlags.Signatures);

            //foreach (Android.Content.PM.Signature oSignature in oPackageInfo.Signatures)
            //{
            //    MessageDigest oMessageDigest = MessageDigest.GetInstance("SHA");
            //    oMessageDigest.Update(oSignature.ToByteArray());

            //    string keyHash = Convert.ToBase64String(oMessageDigest.Digest());
            //    Console.WriteLine("KeyHash:", keyHash);
            //}

            //Initializes the Profile Tracker service
            oFacebookService = new FacebookService();
            oFacebookService.mOnProfileChanged += OFacebookService_mOnProfileChanged;
            oFacebookService.StartTracking();
            //Set Content view
            SetContentView(Resource.Layout.FacebookLogin);

            btnLogin     = FindViewById <LoginButton>(Resource.Id.fblogin);
            txtFirstName = FindViewById <TextView>(Resource.Id.TxtFirstname);
            txtLastName  = FindViewById <TextView>(Resource.Id.TxtLastName);
            txtName      = FindViewById <TextView>(Resource.Id.TxtName);
            pictureView  = FindViewById <ProfilePictureView>(Resource.Id.ImgPro);

            btnLogin.Click += (o, e) =>
            {
                if (AccessToken.CurrentAccessToken != null && Profile.CurrentProfile != null)
                {
                    //send this info to the other page
                }
                else
                {
                    btnLogin.SetReadPermissions(new List <string> {
                        "user_friends", "public_profile"
                    });
                    oICallbackManager = CallbackManagerFactory.Create();
                    btnLogin.RegisterCallback(oICallbackManager, this);
                }
            };
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            RemoveBackBarButtonTitle();

            Profile.Notifications.ObserveDidChange((sender, e) =>
            {
                if (e.NewProfile == null)
                {
                    return;
                }

                pictureView.ProfileId  = e.NewProfile.UserID;
                FacebookNameLabel.Text = e.NewProfile.Name;

                var outlet    = new Outlet();
                outlet.Name   = e.NewProfile.Name;
                outlet.Handle = e.NewProfile.UserID;
                outlet.Locked = true;
                outlet.Type   = Outlet.outlet_type_facebook;
                RealmServices.SaveOutlet(outlet);

                loginView.RemoveFromSuperview();
            });

            // Set the Read and Publish permissions you want to get
            loginView = new LoginButton(FacebookButtonSuperview.Bounds)
            {
                LoginBehavior   = LoginBehavior.Browser,
                ReadPermissions = readPermissions.ToArray()
            };

            // Handle actions once the user is logged in
            loginView.Completed += async(sender, e) =>
            {
                loginView.RemoveFromSuperview();

                await System.Threading.Tasks.Task.Delay(TimeSpan.FromSeconds(2));

                NavigationController.PopViewController(true);
            };
            FacebookButtonSuperview.AddSubview(loginView);

            pictureView = new ProfilePictureView(FacebookProfilePictureSuperview.Bounds);
            FacebookProfilePictureSuperview.AddSubview(pictureView);
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Initialize the SDK before executing any other operations
            FacebookSdk.SdkInitialize(Application.Context);

            // create callback manager using CallbackManagerFactory
            callbackManager = CallbackManagerFactory.Create();

            LoginManager.Instance.RegisterCallback(callbackManager, new MyFacebookCallback <LoginResult>(this));

            shareDialog   = new ShareDialog(this);
            shareCallback = new MySharedDialogCallback <SharerResult>(this);
            shareDialog.RegisterCallback(callbackManager, shareCallback);

            if (savedInstanceState != null)
            {
                var name = savedInstanceState.GetString(PENDING_ACTION_BUNDLE_KEY);
                System.Enum.TryParse(name, true, out pendingAction);
            }

            SetContentView(Resource.Layout.main);

            profileTracker = new MyProfileTracker(this);

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

            postStatusUpdateButton        = FindViewById <Button>(Resource.Id.postStatusUpdateButton);
            postStatusUpdateButton.Click += (sender, args) =>
            {
                OnClickPostStatusUpdate();
            };

            postPhotoButton        = FindViewById <Button>(Resource.Id.postPhotoButton);
            postPhotoButton.Click += (sender, args) =>
            {
                OnClickPostPhoto();
            };

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

            // Can we present the share dialog for photos?
            canPresentShareDialogWithPhotos = ShareDialog.CanShow(Class.FromType(typeof(SharePhotoContent)));
        }
Exemplo n.º 11
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;
        }
Exemplo n.º 12
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            loginButton = new LoginButton(new CGRect(80, 20, 220, 46))
            {
                LoginBehavior   = LoginBehavior.Native,
                ReadPermissions = readPermissions.ToArray()
            };

            // Handle actions once the user is logged in
            loginButton.Completed += (sender, e) => {
                if (e.Error != null)
                {
                    // Handle if there was an error
                }

                else if (e.Result.IsCancelled)
                {
                    // Handle if the user cancelled the login request
                }

                else
                {
                    // Handle your successful login
                    AmazonUtils.Credentials.AddLogin(Constants.PROVIDER_NAME, e.Result.Token.TokenString);
                    Console.WriteLine(e.Result.Token.TokenString);
                    Console.WriteLine(AmazonUtils.Credentials.GetIdentityId());
                }
            };

            // Handle actions once the user is logged out
            loginButton.LoggedOut += (sender, e) => {
                // Handle your logout
            };

            // The user image profile is set automatically once is logged in
            pictureView = new ProfilePictureView(new CGRect(80, 80, 220, 220));

            // Add views to main view
            View.AddSubview(loginButton);
            View.AddSubview(pictureView);
        }
		public ListDetailViewController (string listId, string listName, FacebookListType type) : base (UITableViewStyle.Grouped, null, true)
		{
			Root = new RootElement (listName);

			// Ask for the members within the group
			var request = new GraphRequest ("/" + listId + "/members?fields=id,name", null, AccessToken.CurrentAccessToken.TokenString, null, "GET");
			var requestConnection = new GraphRequestConnection ();
			requestConnection.AddRequest (request, (connection, result, error) => {
				// Handle if something went wrong
				if (error != null) {
					new UIAlertView ("Error...", error.Description, null, "Ok", null).Show ();
					return;
				}

				// Get the name and the userId of all the memebers
				NSArray membersData = (result as NSDictionary) ["data"] as NSArray;

				var listSection = new List<Section> ();

				// Add the name and the picture profile to the view
				for (nuint i = 0; i < membersData.Count; i++) {
					// Get the info of one of the members
					var memberData = membersData.GetItem<NSDictionary> (i);
					var pictureView = new ProfilePictureView (new CGRect (48, 0, 220, 220)) {
						ProfileId = memberData ["id"].ToString (),
						TranslatesAutoresizingMaskIntoConstraints = false
					};

					listSection.Add (new Section (memberData ["name"].ToString ()) {
						new UIViewElement ("", pictureView, true) {
							Flags = UIViewElement.CellFlags.DisableSelection | UIViewElement.CellFlags.Transparent
						}
					});
				}

				Root = new RootElement (listName) {
					listSection
				};
			});

			requestConnection.Start ();
		}
Exemplo n.º 14
0
		public DVCActions () : base (UITableViewStyle.Grouped, null, true)
		{
			
			pictureView = new ProfilePictureView (new CGRect (120, 0, 80, 80));

			// Create menu options with Monotouch.Dialog
			Root = new RootElement ("Menu") {
				new Section (){
					new UIViewElement ("", pictureView, true) {
						Flags = UIViewElement.CellFlags.DisableSelection | UIViewElement.CellFlags.Transparent,
					}
				},
				new Section () {
					new StringElement (Profile.CurrentProfile.Name) {
						Alignment = UITextAlignment.Center
					}
				},
				new Section ("Actions") {
					new CustomStringElement ("Share Xamarin.com", ShareUrl) {
						Alignment = UITextAlignment.Center,
						Value = "ShareDialog Sample"
					},
					new CustomStringElement ("Delete Shared Xamarin.com", DeleteSharedPost, 13) {
						Alignment = UITextAlignment.Center,
						Value = "GraphRequest Sample"
					},
					new CustomStringElement ("Post \"Hello\"", PostHello) {
						Alignment = UITextAlignment.Center,
						Value = "GraphRequest Sample"
					},
					new CustomStringElement ("Delete \"Hello\"", DeleteHelloPost) {
						Alignment = UITextAlignment.Center,
						Value = "GraphRequest Sample"
					},
					new CustomStringElement ("Invite some friends", InviteFriends) {
						Alignment = UITextAlignment.Center,
						Value = "AppInviteDialog Sample"
					},
				}
			};
		}
Exemplo n.º 15
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            //

            FacebookSdk.SdkInitialize(ApplicationContext);

            callbackManager = CallbackManagerFactory.Create();

            var loginCallback = new FacebookCallback <LoginResult> {
                HandleSuccess = (loginResult) => {
                    UpdateUI();
                    MoveToNextView();
                },
                HandleError = (loginError) => {
                    ShowAlert("Exception", loginError.Message, "確認", (obj) => { });
                    UpdateUI();
                },
                HandleCancel = () => {
                    ShowAlert("Cancel", "取消", "確認", (obj) => { });
                    UpdateUI();
                }
            };

            LoginManager.Instance.RegisterCallback(callbackManager, loginCallback);


            SetContentView(Resource.Layout.facebookloginview);

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


            var profile = Profile.CurrentProfile;

            if (profile != null)
            {
                profilePictureView.ProfileId = profile.Id;
                MoveToNextView();
            }
        }
Exemplo n.º 16
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.login);
     BtnFBLogin   = FindViewById <LoginButton>(Resource.Id.fblogin);
     TxtFirstName = FindViewById <TextView>(Resource.Id.TxtFirstname);
     TxtLastName  = FindViewById <TextView>(Resource.Id.TxtLastName);
     TxtName      = FindViewById <TextView>(Resource.Id.TxtName);
     mprofile     = FindViewById <ProfilePictureView>(Resource.Id.ImgPro);
     BtnFBLogin.SetReadPermissions(new List <string> {
         "user_friends",
         "public_profile"
     });
     mFBCallManager = CallbackManagerFactory.Create();
     BtnFBLogin.RegisterCallback(mFBCallManager, this);
 }
Exemplo n.º 17
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.RegisterPage);

            MapFragment oMapFragment = (MapFragment)FragmentManager.FindFragmentById(Resource.Id.map);

            oMapFragment.GetMapAsync(this);

            oProfilePictureView = FindViewById <ProfilePictureView>(Resource.Id.ImgPro);
            txtCorreo           = FindViewById <EditText>(Resource.Id.txtCorreo);
            txtName             = FindViewById <EditText>(Resource.Id.txtName);
            btnRegistro         = FindViewById <Button>(Resource.Id.btnRegistro);
            txtCedula           = FindViewById <EditText>(Resource.Id.txtCedula);
            txtNumber           = FindViewById <EditText>(Resource.Id.txtNumber);

            oProfilePictureView.Click += OProfilePictureView_Click;


            oProfilePictureView.ProfileId = oOwner.facebookId;
            txtName.Text   = $"{oOwner.firstName} { oOwner.lastName}";
            txtCorreo.Text = oOwner.email;
            InitializeLocationManager();

            btnRegistro.Click += async delegate
            {
                Random random       = new Random();
                string randomNumber = string.Join(string.Empty, Enumerable.Range(0, 10).Select(number => random.Next(0, 9).ToString()));

                oOwner.firstName            = txtName.Text;
                oOwner.email                = txtCorreo.Text;
                oOwner.identificationNumber = randomNumber;
                oOwner.phone                = txtNumber.Text;
                Repository.Services.Service oService = new Repository.Services.Service();
                var _oOwner = await oService.RegisterApi(oOwner);
            };
        }
Exemplo n.º 18
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            base.OnCreateView(inflater, container, savedInstanceState);
            Dialog.Window.RequestFeature(WindowFeatures.NoTitle);
            Dialog.Window.Attributes.WindowAnimations = Resource.Style.Animation_AppCompat_DropDownUp;

            var view = inflater.Inflate(Resource.Layout.createMemBox, container, false);

            memBoxName = view.FindViewById<EditText>(Resource.Id.inputMemBoxName);
            createMemBox = view.FindViewById<Button>(Resource.Id.submitNewMemBox);
            profilePic = view.FindViewById<ProfilePictureView>(Resource.Id.profilepic1);
            profilePic.ProfileId = Profile.CurrentProfile.Id;
            loggedInAs = view.FindViewById<TextView>(Resource.Id.loggedInAs);
            loggedInAs.SetText("Logged In As: "+Profile.CurrentProfile.Name, TextView.BufferType.Normal);

            createMemBox.Click += delegate
            {
                CreateMemBox.Invoke(this, new CreateNewMemBoxArgs(memBoxName.Text));

            };

            return view;
        }
Exemplo n.º 19
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            arguments  = this.Intent.Extras;
            login_type = arguments.GetString("login_type");

            SetContentView(Resource.Layout.activity_map);

            if (login_type.Equals("Facebook"))
            {
                facebookProfile = arguments.GetParcelable("user_profile") as Profile;
                ProfilePictureView profile_image = FindViewById <ProfilePictureView>(Resource.Id.profile_image);
                profile_image.ProfileId = facebookProfile.Id;
            }

            allowMarkerPlacing = Intent.GetBooleanExtra("allowMarkerPlacing", false);

            locationManager = (LocationManager)GetSystemService(Context.LocationService);
            provider        = locationManager.GetBestProvider(new Criteria(), false);

            /*if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER))
             * {
             * // Toast.makeText(this, "GPS is Enabled in your devide", Toast.LENGTH_SHORT).show();
             * }
             * else
             * {
             *  //showGPSDisabledAlertToUser();
             * }*/


            location = locationManager.GetLastKnownLocation(provider);
            if (location == null)
            {
                System.Diagnostics.Debug.WriteLine("Cant find your location");
            }

            MapFragment mapFragment = (MapFragment)FragmentManager.FindFragmentById(Resource.Id.map);

            mapFragment.GetMapAsync(this);

            Button place_marker = FindViewById <Button>(Resource.Id.placeMarker);

            place_marker.Click += delegate
            {
                Intent intent = new Intent(this, typeof(ActivityListBusStops));

                intent.PutExtra("MapGoogle", JsonConvert.SerializeObject(map));
                StartActivityForResult(intent, 0);
            };
            Button log_off = FindViewById <Button>(Resource.Id.log_off_button);

            log_off.Click += delegate
            {
                LoginManager.Instance.LogOut();
                Finish();
            };

            Button faq = FindViewById <Button>(Resource.Id.faq);

            faq.Click += delegate
            {
                Intent intent = new Intent(this, typeof(FAQActivity));
                StartActivity(intent);
            };
        }
Exemplo n.º 20
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            if (this.Element is NativeFacebookPage pageElement)
            {
                viewModel = pageElement.ViewModel;
            }

            Profile.Notifications.ObserveDidChange(Profile_Changed);

            // Login Button Setup
            loginView = new LoginButton();
            var frame = new CGRect();

            frame.Width               = 218;
            frame.X                   = (UIScreen.MainScreen.Bounds.Width - frame.Width) / 2;
            frame.Height              = 46;
            frame.Y                   = 310;
            loginView.Frame           = frame;
            loginView.LoginBehavior   = LoginBehavior.Native;
            loginView.ReadPermissions = readPermissions.ToArray();

            loginView.Completed += LoginView_Completed;
            loginView.LoggedOut += LoginView_LoggedOut;

            // The user image profile is set automatically once is logged in
            // Create the label that will hold user's facebook name
            // PictureView Setup
            var picFrame = new CGRect();

            picFrame.Width  = 220;
            picFrame.Height = 220;
            picFrame.X      = (UIScreen.MainScreen.Bounds.Width - frame.Width) / 2;
            picFrame.Y      = 70;
            pictureView     = new ProfilePictureView(picFrame);

            // Label Setup
            var labelFrame = new CGRect();

            labelFrame.Width  = 220;
            labelFrame.Height = 21;
            labelFrame.Y      = 50;
            labelFrame.X      = (UIScreen.MainScreen.Bounds.Width - labelFrame.Width) / 2;
            nameLabel         = new UILabel(labelFrame)
            {
                TextAlignment   = UITextAlignment.Center,
                BackgroundColor = UIColor.Clear
            };

            // If you have been logged into the app before, ask for the your profile name
            if (AccessToken.CurrentAccessToken != null)
            {
                ProcessFBInfo();
            }

            // Add views to main view
            View.AddSubview(loginView);
            View.AddSubview(pictureView);
            View.AddSubview(nameLabel);
        }
Exemplo n.º 21
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);
            mBtnKontynuacja = FindViewById<Button>(Resource.Id.btnKontynuacja);
            mBtnKontynuacja.Click += mBtnKontynuacja_Click;
            
        
         

            //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;
        }
Exemplo n.º 22
0
        public override void ViewDidLoad()
		{
			base.ViewDidLoad();

			int height = AppDelegate.height;
			int width = AppDelegate.width;

			// If was send true to Profile.EnableUpdatesOnAccessTokenChange method
			// this notification will be called after the user is logged in and
			// after the AccessToken is gotten

			//UIImage bg = new UIImage("launch_screen.jpeg", 2f);
			//UIImageView bgImage = new UIImageView(bg);

			var bgImage = new UIImageView(UIImage.FromBundle("login_image.jpeg"));
			bgImage.Frame = new CoreGraphics.CGRect(-100, 0, ((float) bgImage.Image.CGImage.Width / (float) bgImage.Image.CGImage.Height) * (float)AppDelegate.height, AppDelegate.height);

			Facebook.CoreKit.Profile.Notifications.ObserveDidChange((sender, e) =>
			{

				if (e.NewProfile == null)
					return;
				
				nameLabel.Text = e.NewProfile.Name;
				name = e.NewProfile.Name;


				logIn(width, height);
			});

			b = UIButton.FromType(UIButtonType.System);
			b.SetTitle("Button!", UIControlState.Normal);

			b.TouchUpInside += (sender, e) => {
				System.Diagnostics.Debug.WriteLine("Lort");
			};
			// Set the Read and Publish permissions you want to get


			loginView = new LoginButton(new CGRect(width / 2 - (110), height / 1.5, 220, 46))
			{
				LoginBehavior = LoginBehavior.Native,
				ReadPermissions = readPermissions.ToArray()
			};

			// Handle actions once the user is logged in
			loginView.Completed += (sender, e) =>
			{
				if (e.Error != null)
				{
					HowlOut.LoginPage.LoginCancel();
				}

				if (e.Result.IsCancelled)
				{
					HowlOut.LoginPage.LoginCancel();
				}
				token = e.Result.Token.TokenString;
				id = e.Result.Token.UserID;
			};

			// Handle actions once the user is logged out
			loginView.LoggedOut += (sender, e) =>
			{
				// Handle your logout
			};

			UIButton continueBtn = new UIButton(new CGRect(width / 2 - 110, height / 1.25, 220, 46));
			continueBtn.BackgroundColor = App.HowlOut.ToUIColor();
			continueBtn.TintColor = App.HowlOut.ToUIColor();
			continueBtn.SetTitle("log in with HowlOut", UIControlState.Normal);
			continueBtn.SetTitleColor(Color.White.ToUIColor(), UIControlState.Normal);
			continueBtn.TouchUpInside += (sender, e) =>
			{
				LoginPage.HowlOutLogin();
			};




			// The user image profile is set automatically once is logged in
			pictureView = new ProfilePictureView(new CGRect(width / 2 - 110, 50, 220, 220));

			// Create the label that will hold user's facebook name
			nameLabel = new UILabel(new RectangleF(width / 2 - 140, 319, 280, 21))
			{
				TextAlignment = UITextAlignment.Center,
				BackgroundColor = UIColor.Clear
			};
			// Add views to main view

			View.AddSubview(bgImage);

			UILabel header = new UILabel(new RectangleF(width / 2 - (110), height / 4f, 220, 100));
			header.Text = "please log in";
			header.TextColor = Color.White.ToUIColor();
			header.TextAlignment = UITextAlignment.Center;
			header.Font = UIFont.FromName("Helvetica-Bold", 16);
			View.AddSubview(header);

			UILabel hoHeader = new UILabel(new RectangleF(width / 2 - (110), height / 5f, 220, 100));
			hoHeader.Text = "HowlOut";
			hoHeader.TextColor = Color.White.ToUIColor();
			hoHeader.TextAlignment = UITextAlignment.Center;
			hoHeader.Font = UIFont.FromName("Helvetica-Bold", 40f);
			View.AddSubview(hoHeader);



			View.AddSubview(loginView);
			View.AddSubview(continueBtn);


			View.AddSubview(b);
			//hoHeader.AddSubview(pictureView);
			View.AddSubview(nameLabel);



			/*
			var query = string.Format("SELECT uid,name,pic_square FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1={0}) ORDER BY name ASC", "me()");
			FacebookClient fb = new FacebookClient(userToken);

			fb.GetTaskAsync("fql", new { q = query }).ContinueWith(t =>
			{
				if (!t.IsFaulted)
				{
					var result = (IDictionary<string, object>)t.Result;
					var data = (IList<object>)result["data"];
					var count = data.Count;
					var message = string.Format("You have {0} friends", count);
					Console.WriteLine(message);

					foreach (IDictionary<string, object> friend in data)
						Console.WriteLine((string)friend["name"]);
				}
			});
			*/

		}
Exemplo n.º 23
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            loginButton = new LoginButton(new CGRect(80, 120, 220, 46))
            {
                LoginBehavior = LoginBehavior.SystemAccount,
                ReadPermissions = readPermissions.ToArray()
            };

            loginButton.Completed += (sender, e) => {
                if (e.Error != null)
                {
                    Debug.WriteLine(e.Error.Description);
                }

                if (e.Result != null && e.Result.IsCancelled)
                {
                    // Handle if the user cancelled the login request
                }

                // Handle your successful login
            };

            // Handle actions once the user is logged out
            loginButton.LoggedOut += (sender, e) => {
                // Handle your logout
                nameLabel.Text = "";
            };

            // The user image profile is set automatically once is logged in
            pictureView = new ProfilePictureView(new CGRect(80, 200, 220, 220));

            // Create the label that will hold user's facebook name
            nameLabel = new UILabel(new CGRect(20, 319, 280, 21))
            {
                TextAlignment = UITextAlignment.Center,
                BackgroundColor = UIColor.Clear
            };

            // If you have been logged into the app before, ask for the your profile name
            if (AccessToken.CurrentAccessToken != null)
            {
                var request = new GraphRequest("/me?fields=name", null, AccessToken.CurrentAccessToken.TokenString, null, "GET");
                request.Start((connection, result, error) => {
                    // Handle if something went wrong with the request
                    if (error != null)
                    {
                        new UIAlertView("Error...", error.Description, null, "Ok", null).Show();
                        return;
                    }

                    // Get your profile name
                    var userInfo = result as NSDictionary;
                    nameLabel.Text = userInfo["name"].ToString();
                });
            }

            // Add views to main view
            View.AddSubview(loginButton);
            View.AddSubview(pictureView);
            View.AddSubview(nameLabel);

            // Perform any additional setup after loading the view, typically from a nib.
            ConfigureView();
        }
Exemplo n.º 24
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()
Exemplo n.º 25
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

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

            ProfilePictureView profile_picture = FindViewById <ProfilePictureView>(Resource.Id.profile_image);
            TextView           profile_name    = FindViewById <TextView>(Resource.Id.profile_name);

            arguments  = this.Intent.Extras;
            login_type = arguments.GetString("login_type");
            if (login_type.Equals("Facebook"))
            {
                facebookProfile           = arguments.GetParcelable("user_profile") as Profile;
                profile_picture.ProfileId = facebookProfile.Id;
                profile_name.Text         = facebookProfile.Name;
            }


            Button open_map = FindViewById <Button>(Resource.Id.map_view);

            open_map.Click += delegate
            {
                Intent intent = new Intent(this, typeof(MapActivity));
                StartActivity(intent);
            };

            Button place_marker = FindViewById <Button>(Resource.Id.map_edit);

            place_marker.Click += delegate
            {
                Intent intent = new Intent(this, typeof(MapActivity));
                intent.PutExtra("allowMarkerPlacing", true);
                StartActivityForResult(intent, 1);
            };

            Button log_off = FindViewById <Button>(Resource.Id.log_off_button);

            log_off.Click += delegate
            {
                if (login_type.Equals("Facebook"))
                {
                    LoginManager.Instance.LogOut();
                    Finish();
                }
            };

            Button clear = FindViewById <Button>(Resource.Id.clear);

            clear.Click += delegate
            {
                ApplicationDatabaseHelper dbHelper = new ApplicationDatabaseHelper(this);
                dbHelper.ClearAllMarkers();
            };

            Button faq = FindViewById <Button>(Resource.Id.faq);

            faq.Click += delegate
            {
                Intent intent = new Intent(this, typeof(FAQActivity));
                StartActivity(intent); //
            };
        }
Exemplo n.º 26
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();


            // Perform any additional setup after loading the view, typically from a nib.
            // If was send true to Profile.EnableUpdatesOnAccessTokenChange method
            // this notification will be called after the user is logged in and
            // after the AccessToken is gotten
            Profile.Notifications.ObserveDidChange((sender, e) => {
                if (e.NewProfile == null)
                {
                    return;
                }

                nameLabel.Text = e.NewProfile.Name;
            });

            // Set the Read and Publish permissions you want to get
            loginView = new LoginButton(new CGRect(51, 0, 218, 46))
            {
                LoginBehavior   = LoginBehavior.Native,
                ReadPermissions = readPermissions.ToArray()
            };

            // Handle actions once the user is logged in
            loginView.Completed += (sender, e) => {
                if (e.Error != null)
                {
                    // Handle if there was an error
                }

                if (e.Result.IsCancelled)
                {
                    // Handle if the user cancelled the login request
                }

                // Handle your successful login
            };

            // Handle actions once the user is logged out
            loginView.LoggedOut += (sender, e) => {
                // Handle your logout
            };

            // The user image profile is set automatically once is logged in
            pictureView = new ProfilePictureView(new CGRect(50, 50, 220, 220));

            // Create the label that will hold user's facebook name
            nameLabel = new UILabel(new RectangleF(20, 319, 280, 21))
            {
                TextAlignment   = UITextAlignment.Center,
                BackgroundColor = UIColor.Clear
            };

            // Add views to main view
            View.AddSubview(loginView);
            //View.AddSubview(pictureView);
            //View.AddSubview(nameLabel);


            var userController = new WKUserContentController();

            var config = new WKWebViewConfiguration
            {
                UserContentController = userController,
                //WebsiteDataStore = WKWebsiteDataStore.NonPersistentDataStore
            };

            WKWebView = new WKWebView(View.Bounds, config);
            //View.AddSubview(WKWebView);
            View.AddSubviews(WKWebView, loginView);

            WKWebView.LoadRequest(new NSUrlRequest(new NSUrl(imgurl)));
            WKWebView.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
            //Webview.ScalesPageToFit = true;
        }
Exemplo n.º 27
0
		public DVCLogIn () : base (UITableViewStyle.Grouped, null, true)
		{
			 
			// If was sent true to Profile.EnableUpdatesOnAccessTokenChange method
			// this notification will be called once the user is logged in
			Profile.Notifications.ObserveDidChange ((sender, e) => {
				if (e.NewProfile != null) {
					Root.Add (new Section ("Hello " + e.NewProfile.Name) {
						new StringElement ("Actions Menu", () => {
							var dvc = new DVCActions ();
							NavigationController.PushViewController (dvc, true);
						}) {
							Alignment = UITextAlignment.Center
						}
					});
				}
			});

			// If you use Native login behavior, you will get all read and publish permisions
			// otherwise, set the Read and Publish permissions you want to get
			loginView = new LoginButton (new CGRect (51, 0, 218, 46)) {
				LoginBehavior = LoginBehavior.Native,
				// ReadPermissions = extendedPermissions,
				// PublishPermissions = publishPermissions
			};

			// Handle actions once the user is logged in
			loginView.Completed += (sender, e) => {
				if (e.Error != null) {
					new UIAlertView ("Ups", e.Error.Description, null, "Ok", null).Show ();
					return;
				}
			};

			// Handle actions once the user is logged out
			loginView.LoggedOut += (sender, e) => {
				if (Root.Count >= 3) {
					InvokeOnMainThread (() => {
						var section = Root [2];
						section.Remove (0);
						Root.Remove (section);
						ReloadData ();
					});
				}
			};

			// The user image profile is set automatically once is logged in
			pictureView = new ProfilePictureView (new CGRect (50, 0, 220, 220));

			Root = new RootElement ("Facebook Sample") {
				new Section () {
					new UIViewElement ("", loginView, true) {
						Flags = UIViewElement.CellFlags.DisableSelection | UIViewElement.CellFlags.Transparent,
					}
				},
				new Section () {
					new UIViewElement ("", pictureView, true) {
						Flags = UIViewElement.CellFlags.DisableSelection | UIViewElement.CellFlags.Transparent,
					}, 
				}
			};
		}
Exemplo n.º 28
0
        private void IntializeUI(Bundle savestate)
        {
            EnableLocationDialog();

            FacebookSdk.SdkInitialize(this.ApplicationContext);

            mProfileTracker = new MyProfileTracker();

            SetContentView(Resource.Layout.home_page);

            toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);

            SetSupportActionBar(toolbar);

            SupportActionBar.Title = "HOME";

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

            View headerview = navigationView.InflateHeaderView(Resource.Layout.drawer_header);

            UserName = headerview.FindViewById <TextView>(Resource.Id.userName);

            UserImage = headerview.FindViewById <ImageView>(Resource.Id.userImage);



            ISharedPreferences prefs = this.GetSharedPreferences("MYPROFILE", FileCreationMode.Private);

            if (prefs.GetString("username", "") != null && prefs.GetString("profilePic", "") != null)
            {
                UserImage.Visibility = ViewStates.Gone;
                ProfilePictureView fbProfilePicture = headerview.FindViewById <ProfilePictureView>(Resource.Id.facebook_profile_pic);
                fbProfilePicture.Visibility = ViewStates.Visible;
                string name       = prefs.GetString("username", "");
                string profilePic = prefs.GetString("profilepic", "");

                UserName.Text = name;
                fbProfilePicture.ProfileId = profilePic;
            }


            TextView userLocationView = headerview.FindViewById <TextView>(Resource.Id.userLocation);


            userLocationView.Click += UserLocationView_Click;



            drawerLayout = FindViewById <DrawerLayout>(Resource.Id.drawerLayout);

            var drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, Resource.String.drawer_open, Resource.String.drawer_close);

            drawerLayout.AddDrawerListener(drawerToggle);


            drawerToggle.SyncState();
            //SupportActionBar.Show();

            // FindViewById<Button>(Resource.Id.button1).Click += HomePage_Click;
            iconList.Add(Resource.Raw.ic_bike);
            iconList.Add(Resource.Raw.ic_bike);
            iconList.Add(Resource.Raw.ic_service);
            iconList.Add(Resource.Raw.ic_gallery);


            dotslayout     = FindViewById <LinearLayout>(Resource.Id.HomePageDotsContainer);
            imagePager     = FindViewById <ViewPager>(Resource.Id.homePageImagePagerContainer);
            homeRView      = FindViewById <RecyclerView>(Resource.Id.homePageRView);
            _layoutManager = new GridLayoutManager(this, 2);
            homeRView.SetLayoutManager(_layoutManager);

            RecycleHomeIconAdapter RVadapter = new RecycleHomeIconAdapter(this, iconList, iconNameList);

            homeRView.SetAdapter(RVadapter);


            RVadapter.ItemClick += RVadapter_ItemClick;



            imageList.Add(Resource.Raw.image1);
            imageList.Add(Resource.Raw.image4);
            imageList.Add(Resource.Raw.image2);

            PageImageAdapter adapter = new PageImageAdapter(this, imageList);

            imagePager.Adapter = adapter;

            imagePager.SetCurrentItem(0, true);

            imagePager.AddOnPageChangeListener(this);



            setUiPageViewController();


            Bundle savestates = new Bundle();


            // _bottomNavBar = BottomBar.Attach(this, bundle);
            _bottomNavBar = BottomBar.AttachShy((CoordinatorLayout)FindViewById(Resource.Id.homePageCoordinatorLayout), FindViewById(Resource.Id.homePageScrollingContent), savestates);
            _bottomNavBar.SetItems(Resource.Menu.bottomMenuBar);
            _bottomNavBar.SetOnMenuTabClickListener(this);



            navigationView.NavigationItemSelected += NavigationView_NavigationItemSelected;
        }
Exemplo n.º 29
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)));
        }
        public AddIdentityPage()
        {
            NavigationPage.SetHasBackButton(this, false);

            var enterEmailLabel = new Label {
                Text = "Please enter email to be added", HorizontalOptions = LayoutOptions.Start
            };
            var emailEntry = new Entry {
                Placeholder = "*****@*****.**", HorizontalOptions = LayoutOptions.FillAndExpand
            };
            var photoImage = new ProfilePictureView
            {
                AutomationId         = "profilePicImage",
                Margin               = new Thickness(40, 0),
                WidthRequest         = App.ScreenWidth * 0.5,
                DownsampleToViewSize = true,
                HorizontalOptions    = LayoutOptions.Center,
                VerticalOptions      = LayoutOptions.FillAndExpand,
            };
            var addPhotoButton = new Button {
                AutomationId = "addPhotoButton", Text = "Take photo", BackgroundColor = Color.Blue, TextColor = Color.White, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.EndAndExpand
            };
            var submitButton = new Button {
                AutomationId = "submitButton", Text = "Submit", BackgroundColor = Color.Blue, TextColor = Color.White, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.End
            };
            var activityIndicator = new ActivityIndicator {
                AutomationId = "loadingIndicator"
            };

            var layout = new StackLayout
            {
                Padding         = 20,
                VerticalOptions = LayoutOptions.FillAndExpand,
                Children        =
                {
                    enterEmailLabel,
                    emailEntry,
                    photoImage,
                    activityIndicator,
                    addPhotoButton,
                    submitButton
                }
            };

            var verifyUserToolBarItem = new ToolbarItem {
                Text = "Verify"
            };
            var viewModel = new AddIdentityViewModel();

            Content        = layout;
            Title          = "Add Identified User";
            BindingContext = viewModel;
            ToolbarItems.Add(verifyUserToolBarItem);

            emailEntry.SetBinding(Entry.TextProperty, "Email");
            photoImage.SetBinding(CachedImage.SourceProperty, "ProfilePicSource", BindingMode.TwoWay);
            addPhotoButton.SetBinding(Button.TextProperty, "AddPhotoButtonTitle");
            activityIndicator.SetBinding(ActivityIndicator.IsRunningProperty, "IsLoading");
            activityIndicator.SetBinding(ActivityIndicator.IsVisibleProperty, "IsLoading");

            addPhotoButton.Clicked        += viewModel.AddPhotoButton_Clicked;
            submitButton.Clicked          += viewModel.SubmitButton_Clicked;
            verifyUserToolBarItem.Clicked += viewModel.VerifyUser;
        }
Exemplo n.º 31
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 (Bundle savedInstanceState)
		{
			base.OnCreate (savedInstanceState);
			uiHelper = new UiLifecycleHelper (this, callback);
			uiHelper.OnCreate (savedInstanceState);

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

			SetContentView (Resource.Layout.main);

			loginButton = (LoginButton)FindViewById (Resource.Id.login_button);
			loginButton.UserInfoChangedCallback = new MyUserInfoChangedCallback (this);

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

			postStatusUpdateButton = FindViewById<Button> (Resource.Id.postStatusUpdateButton);
			postStatusUpdateButton.Click += delegate {
				OnClickPostStatusUpdate ();
			};

			postPhotoButton = (Button)FindViewById (Resource.Id.postPhotoButton);
			postPhotoButton.Click += delegate {
				OnClickPostPhoto ();
			};

			pickFriendsButton = (Button)FindViewById (Resource.Id.pickFriendsButton);
			pickFriendsButton.Click += delegate {
				OnClickPickFriends ();
			};

			pickPlaceButton = (Button)FindViewById (Resource.Id.pickPlaceButton);
			pickPlaceButton.Click += delegate {
				OnClickPickPlace ();
			};

			controlsContainer = (ViewGroup)FindViewById (Resource.Id.main_ui_container);

			FragmentManager fm = SupportFragmentManager;
			Fragment fragment = fm.FindFragmentById (Resource.Id.fragment_container);
			if (fragment != null) {
				// If we're being re-created and have a fragment, we need to a) hide the main UI controls and
				// b) hook up its listeners again.
				controlsContainer.Visibility = ViewStates.Gone;
				if (fragment is FriendPickerFragment) {
					SetFriendPickerListeners ((FriendPickerFragment)fragment);
				} else if (fragment is PlacePickerFragment) {
					SetPlacePickerListeners ((PlacePickerFragment)fragment);
				}
			}

			fm.BackStackChanged += delegate {
				if (fm.BackStackEntryCount == 0) {
					// We need to re-show our UI.
					controlsContainer.Visibility = ViewStates.Visible;
				}
			};
		}
Exemplo n.º 33
0
        private void InitFacebookLogin()
        {
            LoginView.Hidden = false;
            Profile.Notifications.ObserveDidChange ((sender, e) => {

                if (e.NewProfile == null)
                    return;

                LoginView.Hidden = true;
                LightBox.Hidden = true;
                nameLabel.Text = e.NewProfile.Name;
            });
            CGRect viewBounds = LoginView.Bounds;

            // Set the Read and Publish permissions you want to get
            nfloat leftEdge = (viewBounds.Width - 220) /2;
            loginButton = new LoginButton (new CGRect (leftEdge, 60, 220, 46)) {
                LoginBehavior = LoginBehavior.Native,
                ReadPermissions = readPermissions.ToArray ()
            };

            // Handle actions once the user is logged in
            loginButton.Completed += (sender, e) => {
                if (e.Error != null) {
                    // Handle if there was an error
                }

                if (e.Result.IsCancelled) {
                    // Handle if the user cancelled the login request
                }

                // Handle your successful login
                FinalizeLogin();
            };

            // Handle actions once the user is logged out
            loginButton.LoggedOut += (sender, e) => {
                // Handle your logout
                nameLabel.Text = "";
            };

            // The user image profile is set automatically once is logged in
            pictureView = new ProfilePictureView (new CGRect (leftEdge, 140, 220, 220));

            // Create the label that will hold user's facebook name
            nameLabel = new UILabel (new CGRect (20, 360, viewBounds.Width - 40, 21)) {
                TextAlignment = UITextAlignment.Center,
                BackgroundColor = UIColor.Clear
            };

            // If you have been logged into the app before, ask for the your profile name
            if (AccessToken.CurrentAccessToken != null) {
                var request = new GraphRequest ("/me?fields=name", null, AccessToken.CurrentAccessToken.TokenString, null, "GET");
                request.Start ((connection, result, error) => {
                    // Handle if something went wrong with the request
                    if (error != null) {
                        new UIAlertView ("Error...", error.Description, null, "Ok", null).Show ();
                        return;
                    }

                    // Get your profile name
                    var userInfo = result as NSDictionary;
                    nameLabel.Text = userInfo ["name"].ToString ();
                    var controller = AppDelegate.ProfileController;
                    this.NavigationController.PresentViewController(controller, true, null);

                });
            }

            // Add views to main view
            LoginView.AddSubview (loginButton);
            LoginView.AddSubview (pictureView);
            LoginView.AddSubview (nameLabel);
        }
Exemplo n.º 34
0
        public override void ViewDidAppear(bool animated)
        {
            base.ViewDidAppear(animated);

            List <string> readPermissions = new List <string> {
                "public_profile", "email"
            };

            Profile.Notifications.ObserveDidChange((sender, e) =>
            {
                if (e.NewProfile == null)
                {
                    return;
                }

                nameLabel.Text          = e.NewProfile.Name;
                pictureView.PictureMode = ProfilePictureMode.Square;

                User u = new User();

                u.Name     = e.NewProfile.FirstName;
                u.ImageUrl = e.NewProfile.ImageUrl(ProfilePictureMode.Square, new CGSize(70, 70)).ToString();

                App.SaveUser(u);
            });

            loginButton = new LoginButton(new CGRect(80, 20, 220, 46))
            {
                LoginBehavior   = LoginBehavior.Native,
                ReadPermissions = readPermissions.ToArray()
            };

            nameLabel = new UILabel();

            pictureView = new ProfilePictureView(new CGRect(80, 90, 220, 46));

            loginButton.TouchUpInside += (sender, e) =>
            {
            };

            loginButton.Completed += (sender, e) =>
            {
                App.SaveToken(AccessToken.CurrentAccessToken.TokenString);
                App.SuccessfulLoginAction.Invoke();

                if (e.Error != null)
                {
                    // Handle if there was an error
                    new UIAlertView("Login", e.Error.Description, null, "Ok", null).Show();
                    return;
                }

                if (e.Result.IsCancelled)
                {
                    // Handle if the user cancelled the login request
                    new UIAlertView("Login", "The user cancelled the login", null, "Ok", null).Show();
                    return;
                }
            };

            // Handle actions once the user is logged out
            loginButton.LoggedOut += (sender, e) =>
            {
                // Handle your logout
                new UIAlertView("Login", "Logout", null, "Ok", null).Show();
            };

            // If you have been logged into the app before, ask for the your profile name
            if (AccessToken.CurrentAccessToken != null)
            {
                var request = new GraphRequest("/me?fields=name", null, AccessToken.CurrentAccessToken.TokenString, null, "GET");
                request.Start((connection, result, error) =>
                {
                    // Handle if something went wrong with the request
                    if (error != null)
                    {
                        new UIAlertView("Error...", error.Description, null, "Ok", null).Show();
                        return;
                    }

                    // Get your profile name
                    var userInfo = result as NSDictionary;

                    //App.SaveToken(userInfo["token"].ToString());
                    //nameLabel.Text = userInfo["name"].ToString();
                });
            }

            // Add views to main view
            View.AddSubview(loginButton);
            View.AddSubview(pictureView);
            View.AddSubview(nameLabel);
        }
        //        public override void ViewDidLoad ()
        //        {
        //            
        //        }
        public override void ViewDidLoad()
        {
            Profile.Notifications.ObserveDidChange ((sender, e) => {

                if (e.NewProfile == null)
                    return;

                nameLabel.Text = e.NewProfile.Name;
            });

            // Set the Read and Publish permissions you want to get
            loginButton = new LoginButton (new CGRect (100, 100, 220, 46)) {
                LoginBehavior = LoginBehavior.Native,
                ReadPermissions = readPermissions.ToArray ()
            };

            // Handle actions once the user is logged in
            loginButton.Completed += (sender, e) => {
                if (e.Error != null) {
                    // Handle if there was an error
                }

                if (e.Result.IsCancelled) {
                    // Handle if the user cancelled the login request
                }

                // Handle your successful login
            };

            // Handle actions once the user is logged out
            loginButton.LoggedOut += (sender, e) => {
                // Handle your logout
                nameLabel.Text = "";
            };

            // The user image profile is set automatically once is logged in
            pictureView = new ProfilePictureView (new CGRect (100, 160, 220, 220));

            // Create the label that will hold user's facebook name
            nameLabel = new UILabel (new CGRect (100, 400, 280, 21)) {
                TextAlignment = UITextAlignment.Left,
                BackgroundColor = UIColor.Clear
            };

            // If you have been logged into the app before, ask for the your profile name
            if (AccessToken.CurrentAccessToken != null) {
                var request = new GraphRequest ("/me/friends", null, AccessToken.CurrentAccessToken.TokenString, null, "GET");
                request.Start ((connection, result, error) => {
                    // Handle if something went wrong with the request
                    if (error != null) {
                        new UIAlertView ("Error...", error.Description, null, "Ok", null).Show ();
                        return;
                    }

                    // Get your profile name
                    var userInfo = result as NSDictionary;
                    var friendlist = userInfo["data"];
                    var summary = userInfo["summary"];
                });
            }

            // Add views to main view
            View.AddSubview (loginButton);
            View.AddSubview (pictureView);
            View.AddSubview (nameLabel);
        }
Exemplo n.º 36
0
        public void FBLoginButtonSetting()
        {
            UIApplication.SharedApplication.BeginInvokeOnMainThread(() =>
            {
                #region loginButton Setting
                var facebookLoginButtonText = new NSAttributedString("以FB登入並繼續");

                LoginBtn.SetAttributedTitle(facebookLoginButtonText, UIControlState.Normal);
                LoginBtn.LoginBehavior   = LoginBehavior.Native;
                LoginBtn.ReadPermissions = Common.Variables.FBPermissions.ToArray();
                if (token != null)
                {
                    LoginBtn.SetAttributedTitle(new NSAttributedString("登出"), UIControlState.Normal);
                    ProfileName.Text = "Hi! " + currentProfile.Name + " 大美女";
                }

                #endregion

                // The user image profile is set automatically once is logged in
                pictureView = new ProfilePictureView(new CGRect(50, 50, 220, 220));

                // Create the label that will hold user's facebook name
                nameLabel = new UILabel(new RectangleF(20, 319, 280, 21))
                {
                    TextAlignment   = UITextAlignment.Center,
                    BackgroundColor = UIColor.Clear
                };
                loadingView.Hide();
            });


            // Handle actions once the user is logged in
            LoginBtn.Completed += (sender, e) =>
            {
                var SplitVC  = this.Storyboard.InstantiateViewController("SplitViewController");
                var listView = SplitVC.View;
                if (e.Error != null)
                {
                    // Handle if there was an error
                }

                if (e.Result.IsCancelled)
                {
                    // Handle if the user cancelled the login request
                }
                View.AddSubview(loadingView);
                // Handle your successful login
                token = AccessToken.CurrentAccessToken;
                if (token != null)
                {
                    LoginBtn.SetAttributedTitle(new NSAttributedString("登出"), UIControlState.Normal);
                    SplitVC.ModalTransitionStyle = UIModalTransitionStyle.FlipHorizontal;
                    this.PresentViewController(SplitVC, true, null);
                }
            };

            // Handle actions once the user is logged out
            LoginBtn.LoggedOut += (sender, e) =>
            {
                // Handle your logout
                token = AccessToken.CurrentAccessToken;
                if (token == null)
                {
                    LoginBtn.SetAttributedTitle(new NSAttributedString("以FB進行登入"), UIControlState.Normal);
                }
            };
        }
Exemplo n.º 37
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            uiHelper = new UiLifecycleHelper(this, callback);
            uiHelper.OnCreate(savedInstanceState);

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

            SetContentView(Resource.Layout.main);

            loginButton = (LoginButton)FindViewById(Resource.Id.login_button);
            loginButton.UserInfoChangedCallback = new MyUserInfoChangedCallback(this);

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

            postStatusUpdateButton        = FindViewById <Button> (Resource.Id.postStatusUpdateButton);
            postStatusUpdateButton.Click += delegate {
                OnClickPostStatusUpdate();
            };

            postPhotoButton        = (Button)FindViewById(Resource.Id.postPhotoButton);
            postPhotoButton.Click += delegate {
                OnClickPostPhoto();
            };

            pickFriendsButton        = (Button)FindViewById(Resource.Id.pickFriendsButton);
            pickFriendsButton.Click += delegate {
                OnClickPickFriends();
            };

            pickPlaceButton        = (Button)FindViewById(Resource.Id.pickPlaceButton);
            pickPlaceButton.Click += delegate {
                OnClickPickPlace();
            };

            controlsContainer = (ViewGroup)FindViewById(Resource.Id.main_ui_container);

            FragmentManager fm       = SupportFragmentManager;
            Fragment        fragment = fm.FindFragmentById(Resource.Id.fragment_container);

            if (fragment != null)
            {
                // If we're being re-created and have a fragment, we need to a) hide the main UI controls and
                // b) hook up its listeners again.
                controlsContainer.Visibility = ViewStates.Gone;
                if (fragment is FriendPickerFragment)
                {
                    SetFriendPickerListeners((FriendPickerFragment)fragment);
                }
                else if (fragment is PlacePickerFragment)
                {
                    SetPlacePickerListeners((PlacePickerFragment)fragment);
                }
            }

            fm.BackStackChanged += delegate {
                if (fm.BackStackEntryCount == 0)
                {
                    // We need to re-show our UI.
                    controlsContainer.Visibility = ViewStates.Visible;
                }
            };
        }
Exemplo n.º 38
0
		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();
			// Perform any additional setup after loading the view, typically from a nib.

			// If was send true to Profile.EnableUpdatesOnAccessTokenChange method
			// this notification will be called after the user is logged in and
			// after the AccessToken is gotten
			Profile.Notifications.ObserveDidChange ((sender, e) => {

				if (e.NewProfile == null)
					return;

				nameLabel.Text = e.NewProfile.Name;
			});

			// Set the Read and Publish permissions you want to get
			loginButton = new LoginButton (new CGRect (80, 20, 220, 46)) {
				LoginBehavior = LoginBehavior.Native,
				ReadPermissions = readPermissions.ToArray ()
			};

			// Handle actions once the user is logged in
			loginButton.Completed += (sender, e) => {
				if (e.Error != null) {
					// Handle if there was an error
					new UIAlertView ("Login", e.Error.Description, null, "Ok", null).Show ();
					return;
				}

				if (e.Result.IsCancelled) {
					// Handle if the user cancelled the login request
					new UIAlertView ("Login", "The user cancelled the login", null, "Ok", null).Show ();
					return;
				}

				// Handle your successful login
				new UIAlertView ("Login", "Success!!", null, "Ok", null).Show ();
			};

			// Handle actions once the user is logged out
			loginButton.LoggedOut += (sender, e) => {
				// Handle your logout
				nameLabel.Text = "";
			};

			// The user image profile is set automatically once is logged in
			pictureView = new ProfilePictureView (new CGRect (80, 100, 220, 220));

			// Create the label that will hold user's facebook name
			nameLabel = new UILabel (new CGRect (80, 340, 220, 21)) {
				TextAlignment = UITextAlignment.Center,
				BackgroundColor = UIColor.Clear
			};

			// If you have been logged into the app before, ask for the your profile name
			if (AccessToken.CurrentAccessToken != null) {
				var request = new GraphRequest ("/me?fields=name", null, AccessToken.CurrentAccessToken.TokenString, null, "GET");
				request.Start ((connection, result, error) => {
					// Handle if something went wrong with the request
					if (error != null) {
						new UIAlertView ("Error...", error.Description, null, "Ok", null).Show ();
						return;
					}

					// Get your profile name
					var userInfo = result as NSDictionary;
					nameLabel.Text = userInfo ["name"].ToString ();
				});
			}

			// Add views to main view
			View.AddSubview (loginButton);
			View.AddSubview (pictureView);
			View.AddSubview (nameLabel);
		}
		public override void ViewDidLoad ()
		{
			
			base.ViewDidLoad ();
			// Perform any additional setup after loading the view, typically from a nib.

			// If was send true to Profile.EnableUpdatesOnAccessTokenChange method
			// this notification will be called after the user is logged in and
			// after the AccessToken is gotten
			Profile.Notifications.ObserveDidChange ((sender, e) => {

				if (e.NewProfile == null)
					return;
				
				LoggedIn (e.NewProfile.UserID);
			});

			loginButton = new LoginButton (new CGRect (48, 0, 218, 46)) {
                LoginBehavior = LoginBehavior.Native
			};

			// Handle actions once the user is logged in
			loginButton.Completed += (sender, e) => {
				if (e.Error != null) {
					ShowMessageBox ("Ups", e.Error.Description, "Ok", null, null);
					return;
				}
				if (e.Result.IsCancelled) {
					ShowMessageBox ("Ups", "The user cancelled the request", "Ok", null, null);
					return;
				}
			};

			// Handle actions once the user is logged out
			loginButton.LoggedOut += (sender, e) => {				
				LoggedOut ();
			};

			// This permission is set by default
			chkPublicProfile = new CustomCheckboxElement ("Public Profile", true);
			chkPublicProfile.Enabled = false;

			// Add or remove all the permissions that you want to ask
			readSection = new Section ("Ask Read Permissions") {
				chkPublicProfile,
				new CustomCheckboxElement ("Email", () => CheckReadPermission ("email")),
				new CustomCheckboxElement ("About Me", () => CheckReadPermission ("user_about_me")),
				new CustomCheckboxElement ("Birthday", () => CheckReadPermission ("user_birthday")),
				new CustomCheckboxElement ("Hometown", () => CheckReadPermission ("user_hometown")),
				new CustomCheckboxElement ("Friendlists", () => CheckReadPermission ("read_custom_friendlists")),
				new CustomCheckboxElement ("Managed Groups", () => CheckReadPermission ("user_managed_groups"))
			};

			// The user image profile is set automatically once is logged in
			pictureView = new ProfilePictureView (new CGRect (48, 0, 220, 220));

			// Add the initial sections
			Root = new RootElement ("Facebook iOS Sample") {
				readSection,
				new Section () {
					new UIViewElement ("", loginButton, true) {
						Flags = UIViewElement.CellFlags.DisableSelection | UIViewElement.CellFlags.Transparent,
					}
				}
			};

			// If the user is already logged in, remove the read section and add the actions sections
			if (AccessToken.CurrentAccessToken != null)
				LoggedIn (AccessToken.CurrentAccessToken.UserID);

		}
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            loginFacebookButton.TouchUpInside += delegate {
                Console.WriteLine("presing facebook link");

                loginView.SendActionForControlEvents(UIControlEvent.TouchUpInside);
            };



            get_helplbl.TextColor = UIColor.FromRGB(112, 112, 112);

            back_button.SetTitleColor(UIColor.FromRGB(75, 171, 229), UIControlState.Normal);

            loginButton.BackgroundColor = UIColor.FromRGB(75, 171, 229);



            signup_lbl.TextColor = UIColor.FromRGB(112, 112, 112);

            passwordText.SecureTextEntry = true;

            Profile.CurrentProfile = null;

            AccessToken.CurrentAccessToken = null;

            NSHttpCookieStorage storage = NSHttpCookieStorage.SharedStorage;

            foreach (NSHttpCookie cookie in storage.Cookies)
            {
                if (cookie.Domain == "facebook.com")
                {
                    storage.DeleteCookie(cookie);
                }
            }


            NSUrlCache.SharedCache.RemoveAllCachedResponses();
            var cookies = NSHttpCookieStorage.SharedStorage.Cookies;

            foreach (var c in cookies)
            {
                NSHttpCookieStorage.SharedStorage.DeleteCookie(c);
            }

            var websiteDataTypes = new NSSet <NSString>(new[]
            {
                //Choose which ones you want to remove
                WKWebsiteDataType.Cookies,
                WKWebsiteDataType.DiskCache,
                WKWebsiteDataType.IndexedDBDatabases,
                WKWebsiteDataType.LocalStorage,
                WKWebsiteDataType.MemoryCache,
                WKWebsiteDataType.OfflineWebApplicationCache,
                WKWebsiteDataType.SessionStorage,
                WKWebsiteDataType.WebSQLDatabases
            });

            WKWebsiteDataStore.DefaultDataStore.FetchDataRecordsOfTypes(websiteDataTypes, (NSArray records) =>
            {
                for (nuint i = 0; i < records.Count; i++)
                {
                    var record = records.GetItem <WKWebsiteDataRecord>(i);

                    WKWebsiteDataStore.DefaultDataStore.RemoveDataOfTypes(record.DataTypes,
                                                                          new[] { record }, () => { Console.Write($"deleted: {record.DisplayName}"); });
                }
            });

            NavigationController.NavigationBarHidden = true;

            this.View.BringSubviewToFront(passwordText);

            this.View.BringSubviewToFront(emailText);

            this.View.BringSubviewToFront(back_button);

            var screenTap = new UITapGestureRecognizer(() =>
            {
                emailText.ResignFirstResponder();
                passwordText.ResignFirstResponder();
            });

            var show_signup = new UITapGestureRecognizer(() =>
            {
                ViewModel.ShowSignUp();
            });

            this.View.AddGestureRecognizer(screenTap);

            this.signup_lbl.AddGestureRecognizer(show_signup);

            this.signup_lbl.UserInteractionEnabled = true;

            back_button.TouchUpInside += (sender, e) => {
                ViewModel.BackIntroduction();
            };

            ViewModel.ForPropertyChange(x => x.ErrorMessage, y =>
            {
                //Debug.WriteLine("PORPOISE LOGO CHANGED");

                var okAlertController = UIAlertController.Create("Error message", ViewModel.ErrorMessage, UIAlertControllerStyle.Alert);

                //Add Action
                okAlertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));

                // Present Alert
                PresentViewController(okAlertController, true, null);
            });



            loginButton.TouchUpInside += (sender, e) => {
                if (!string.IsNullOrEmpty(emailText.Text) && !string.IsNullOrEmpty(passwordText.Text))
                {
                    ViewModel.email = emailText.Text;

                    ViewModel.password = passwordText.Text;

                    ViewModel.Login();
                }

                else if (string.IsNullOrEmpty(emailText.Text))
                {
                    var okAlertController = UIAlertController.Create("Error message", "Please enter email", UIAlertControllerStyle.Alert);

                    //Add Action
                    okAlertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));

                    // Present Alert
                    PresentViewController(okAlertController, true, null);
                }

                else if (string.IsNullOrEmpty(passwordText.Text))
                {
                    var okAlertController = UIAlertController.Create("Error message", "Please enter password", UIAlertControllerStyle.Alert);

                    //Add Action
                    okAlertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));

                    // Present Alert
                    PresentViewController(okAlertController, true, null);
                }

                //UsingOauth();
            };



            Profile.Notifications.ObserveDidChange((sender, e) => {
                if (e.NewProfile == null)
                {
                    return;
                }
                if (AccessToken.CurrentAccessToken != null)
                {
                    var request = new GraphRequest("/me?fields=first_name,last_name,name,email,picture,birthday,gender", null, AccessToken.CurrentAccessToken.TokenString, null, "GET");
                    request.Start((connection, result, error) =>
                    {
                        // Handle if something went wrong with the request
                        if (error != null)
                        {
                            //showAlert("Error", error.Description);
                            return;
                        }

                        //fbReponseFromSDK facebookSDKLoginItem = new fbReponseFromSDK();
                        // Get your profile name
                        var userInfo = result as NSDictionary;
                        if (userInfo["id"] != null)
                        {
                            ViewModel.provider_id = userInfo["id"].ToString();

                            ViewModel.user_login_provider.user_provider_id = userInfo["id"].ToString();

                            Console.WriteLine("id is: " + userInfo["id"].ToString());
                        }
                        if (userInfo["name"] != null)
                        {
                            ViewModel.user_login_provider.user_provider_name = userInfo["name"].ToString();

                            Console.WriteLine("name is: " + userInfo["name"].ToString());
                        }

                        if (userInfo["first_name"] != null)
                        {
                            ViewModel.first_name = userInfo["first_name"].ToString();

                            Console.WriteLine("first_name is: " + userInfo["first_name"].ToString());
                        }

                        if (userInfo["last_name"] != null)
                        {
                            ViewModel.last_name = userInfo["last_name"].ToString();

                            Console.WriteLine("last_name is: " + userInfo["last_name"].ToString());
                        }

                        if (userInfo["email"] != null)
                        {
                            ViewModel.email = userInfo["email"].ToString();

                            Console.WriteLine("email is: " + userInfo["email"].ToString());
                        }

                        if (userInfo["picture"] != null)
                        {
                            Console.WriteLine("profile image is: " + userInfo["picture"].ToString());
                        }

                        if (userInfo["birthday"] != null)
                        {
                            var formatted        = DateTime.Parse(userInfo["birthday"].ToString());
                            ViewModel.birth_date = formatted.ToString("yyyy-MM-dd");
                            Console.WriteLine("birthday is: " + userInfo["birthday"].ToString());
                        }

                        if (userInfo["gender"] != null)
                        {
                            if (userInfo["gender"].Equals("male"))
                            {
                                ViewModel.gender = "MALE";
                            }
                            else if (userInfo["gender"].Equals("female"))
                            {
                                ViewModel.gender = "FEMALE";
                            }
                            Console.WriteLine("gender is: " + userInfo["gender"].ToString());
                        }
                        //(Success) Do what you want next :
                        //doneFacbookLogin();

                        //loginView.LoggedOut();

                        ViewModel.user_login_provider.provider = "FACEBOOK";

                        ViewModel.EmailVerification();
                    });
                }

                nameLabel.Text = e.NewProfile.Name;
            });

            // Set the Read and Publish permissions you want to get
            loginView = new LoginButton(new CGRect(0, 0, loginFacebookButton.Frame.Width, loginFacebookButton.Frame.Height))
            {
                //LoginBehavior = LoginBehavior.,
                Permissions = readPermissions.ToArray()
            };



            var attributes = new UIStringAttributes
            {
                BackgroundColor = UIColor.FromRGB(75, 171, 229),

                ForegroundColor = UIColor.White,
                Font            = UIFont.FromName("System Semibold", 17f)
            };
            var titleText = new NSAttributedString("Log In With Facebook", attributes);

            loginView.SetAttributedTitle(titleText, UIControlState.Normal);

            loginView.SetBackgroundImage(null, UIControlState.Normal);

            loginView.BackgroundColor = UIColor.FromRGB(75, 171, 229);
            // Handle actions once the user is logged in
            loginView.Completed += (sender, e) => {
                if (e.Error != null)
                {
                    // Handle if there was an error
                }

                if (e.Result.IsCancelled)
                {
                    // Handle if the user cancelled the login request
                }

                // Handle your successful login
            };

            // Handle actions once the user is logged out
            loginView.LoggedOut += (sender, e) => {
                Profile.CurrentProfile = null;
                // Handle your logout
            };

            // The user image profile is set automatically once is logged in
            pictureView = new ProfilePictureView(new CGRect(50, 50, 220, 220));

            // Create the label that will hold user's facebook name
            nameLabel = new UILabel(new RectangleF(20, 319, 280, 21))
            {
                TextAlignment   = UITextAlignment.Center,
                BackgroundColor = UIColor.Clear
            };

            // Add views to main view

            Console.WriteLine();

            loginFacebookButton.BackgroundColor = UIColor.FromRGB(75, 171, 229);

            //loginFacebookButton.AddSubview(loginView);
        }