Ejemplo n.º 1
0
        public static string getGreeting()
        {
            String name = "User";
            LocalDataAccessLayer dataAc = LocalDataAccessLayer.getInstance();

            DataBase.User user;

            user = dataAc.getUser();
            name = user.name;
            DateTime currTime = DateTime.Now;
            string   greeting = "";
            int      hour     = currTime.Hour;

            if (hour > 0 && hour < 12)
            {
                greeting = "Good Morning, " + name + ".";
            }
            else if (hour >= 12 && hour < 17)
            {
                greeting = "Good Afternoon, " + name + ".";
            }
            else
            {
                greeting = "Good Evening, " + name + ".";
            }
            return(greeting);
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            RequestWindowFeature(WindowFeatures.NoTitle);
            base.OnCreate(savedInstanceState);
            // Set our view from the "main" layout resource

            var clientId = "33665d08e62942c6b1f484f422bbb7c1";
            //var clientSecret = "ae94378b39e747b0ac5d6f8640636b02 ";
            var redirectUri = "https://elfsight.com/service/generate-instagram-access-token/";
            //var realtimeUri = "";

            var auth = new OAuth2Authenticator(
                clientId: clientId,
                scope: "public_content",
                authorizeUrl: new Uri("https://api.instagram.com/oauth/authorize/"),
                redirectUrl: new Uri(redirectUri));
            var token = "";
            LocalDataAccessLayer dataAc = LocalDataAccessLayer.getInstance();

            auth.Completed += (s, ee) => {
                token = ee.Account.Properties["access_token"];
                //ee.Account.Properties[]
                dataAc.updateLogin(token);
                //SaveCredentials(token);
                //var InstagramClient = new InstagramClient(token);

                //var info = await InstagramClient.GetMyUserAsync();
                dataAc.updateName("User");

                User user = dataAc.getUser();
            };
            StartActivity(auth.GetUI(this));

            auth.Completed += (sender, eventArgs) =>
            {
                // We presented the UI, so it's up to us to dimiss it on iOS.
                //DismissViewController(true, null);

                if (eventArgs.IsAuthenticated)
                {
                    // Use eventArgs.Account to do wonderful things
                    SaveCredentials(token);
                    runApp(token);
                }
                else
                {
                    // The user cancelled

                    StartActivity(typeof(WeatherScreen));
                }
            };
        }
Ejemplo n.º 3
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.layout1);

            LocalDataAccessLayer data = LocalDataAccessLayer.getInstance();



            //TextView t = FindViewById<TextView>(Resource.Id.textView1);
            // t.Text = ""+ num;
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.demoMenu);
            signOut = FindViewById <Button>(Resource.Id.SignOut);
            nxtImg  = FindViewById <Button>(Resource.Id.NextImage);

            LocalDataAccessLayer data = LocalDataAccessLayer.getInstance();

            signOut.Click += delegate
            {
                data.deleteUser();
            };

            nxtImg.Click += delegate
            {
                //Coulton add code here
            };
        }
Ejemplo n.º 5
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            RequestWindowFeature(WindowFeatures.NoTitle);
            // Set our view from the "main" layout resource
            string token;

            LocalDataAccessLayer dataAc = LocalDataAccessLayer.getInstance();
            User user;

            try
            {
                user = dataAc.getUser();
            }
            catch (Exception e)
            {
                dataAc.addUser("User", "");
                user = dataAc.getUser();
            }

            token = user.login;
            if (token != null && token != "")
            {
                Intent intent = new Intent(this, typeof(WeatherScreen));
                Bundle data   = new Bundle();
                data.PutString("UserToken", token);
                intent.PutExtras(data);
                StartActivity(intent);
            }
            else
            {
                SetContentView(Resource.Layout.LoginPrompt);

                ImageButton withInsta    = FindViewById <ImageButton>(Resource.Id.UseInstagram);
                ImageButton withoutInsta = FindViewById <ImageButton>(Resource.Id.NoInstagram);

                withInsta.Click += delegate {
                    Console.Write("Button Clicked");



                    //if token does not exist
                    if (user.login == "" || user.login == null)
                    {
                        StartActivity(typeof(InstagramLogin));
                    }


                    //if token exists pull from DB
                    else
                    {
                        token = user.login;
                        Intent intent = new Intent(this, typeof(WeatherScreen));
                        Bundle data   = new Bundle();
                        data.PutString("UserToken", token);
                        intent.PutExtras(data);
                        StartActivity(intent);
                    }
                };
                withoutInsta.Click += delegate {
                    Console.Write("Button Clicked");


                    StartActivity(typeof(WeatherScreen));
                };
            }
        }