Exemplo n.º 1
0
            public override void OnCreate(ISurfaceHolder surfaceHolder)
            {
                base.OnCreate(surfaceHolder);
                SetWatchFaceStyle(new WatchFaceStyle.Builder(owner)
                                  .SetCardPeekMode(WatchFaceStyle.PeekModeShort)
                                  .SetBackgroundVisibility(WatchFaceStyle.BackgroundVisibilityInterruptive)
                                  .SetShowSystemUiTime(false)
                                  .Build()
                                  );

                var resources = owner.Resources;

                yOffset = resources.GetDimension(Resource.Dimension.DigitalYOffset);

                backgroundPaint       = new Paint();
                backgroundPaint.Color = interactiveBackgroundColor;
                hourPaint             = CreateTextPaint(interactiveHourDigitsColor, BoldTypeFace);
                minutePaint           = CreateTextPaint(interactiveMinuteDigitsColor);
                secondPaint           = CreateTextPaint(interactiveSecondDigitsColor);
                amPmPaint             = CreateTextPaint(owner.Resources.GetColor(Resource.Color.DigitalAmPm));
                colonPaint            = CreateTextPaint(owner.Resources.GetColor(Resource.Color.DigitalColons));

                googleApiClient = new GoogleApiClientBuilder(owner)
                                  .AddConnectionCallbacks(this)
                                  .AddOnConnectionFailedListener(this)
                                  .AddApi(WearableClass.Api)
                                  .Build();
            }
Exemplo n.º 2
0
 protected override void OnCreate(Bundle savedInstanceState)
 {
     base.OnCreate(savedInstanceState);
     SetContentView(Resource.Layout.activity_main);
     mClient = new GoogleApiClientBuilder(this).AddApi(AppIndex.APP_INDEX_API).Build();
     OnNewIntent(Intent);
 }
Exemplo n.º 3
0
        /**
         * Build the Google Play Services API client
         */
        private void BuildApiClient()
        {
            // Create and connect the Google API client
            googleApiClient = new GoogleApiClientBuilder(this)
                              .AddApi(FitnessClass.HISTORY_API)
                              .AddScope(FitnessClass.ScopeActivityRead)
                              .AddConnectionCallbacks(
                // connection succeeded
                connectionHint => {
                if (Log.IsLoggable(Tag, LogPriority.Info))
                {
                    Log.Info(Tag, "Connected to the Google API client");
                }
                // Get step data from Google Play Services
                readSteps();
            },
                // connection suspended
                cause => {
                if (Log.IsLoggable(Tag, LogPriority.Info))
                {
                    Log.Info(Tag, "Connection suspended");
                }
            }
                )
                              .AddOnConnectionFailedListener(
                // connection failed
                result => {
                if (Log.IsLoggable(Tag, LogPriority.Info))
                {
                    Log.Info(Tag, "Failed to connect to the Google API client");
                }
                if (!result.HasResolution)
                {
                    GoogleApiAvailability.Instance.GetErrorDialog(this, result.ErrorCode, 0).Show();
                    return;
                }

                if (!authInProgress)
                {
                    try
                    {
                        if (Log.IsLoggable(Tag, LogPriority.Info))
                        {
                            Log.Info(Tag, "Attempting to resolve failed connection");
                        }
                        authInProgress = true;
                        result.StartResolutionForResult(this, OAUTH_REQUEST_CODE);
                    }
                    catch (IntentSender.SendIntentException e) {
                        if (Log.IsLoggable(Tag, LogPriority.Error))
                        {
                            Log.Error(Tag, "Exception while starting resolution activity", e);
                            authInProgress = false;
                        }
                    }
                }
            }
                )
                              .Build();
        }
Exemplo n.º 4
0
 public void OnDisconnected()
 {
     // Turn off the request flag
     mInProgress = false;
     // Destroy the current location client
     apiClient = null;
 }
Exemplo n.º 5
0
        void BuildFitnessClient()
        {
            var clientConnectionCallback = new ClientConnectionCallback();

            clientConnectionCallback.OnConnectedImpl = Subscribe;
            // Create the Google API Client
            mClient = new GoogleApiClientBuilder(this)
                      .AddApi(FitnessClass.RECORDING_API)
                      .AddScope(new Scope(Scopes.FitnessActivityRead))
                      .AddConnectionCallbacks(clientConnectionCallback)
                      .AddOnConnectionFailedListener((ConnectionResult result) => {
                Log.Info(TAG, "Connection failed. Cause: " + result.ToString());
                if (!result.HasResolution)
                {
                    // Show the localized error dialog
                    GooglePlayServicesUtil.GetErrorDialog(result.ErrorCode, this, 0).Show();
                    return;
                }
                // The failure has a resolution. Resolve it.
                // Called typically when the app is not yet authorized, and an
                // authorization dialog is displayed to the user.
                if (!authInProgress)
                {
                    try {
                        Log.Info(TAG, "Attempting to resolve failed connection");
                        result.StartResolutionForResult(this, REQUEST_OAUTH);
                    } catch (IntentSender.SendIntentException e) {
                        Log.Error(TAG, "Exception while starting resolution activity", e);
                    }
                }
            }).Build();
        }
Exemplo n.º 6
0
        void BuildFitnessClient()
        {
            var clientConnectionCallback = new ClientConnectionCallback();

            clientConnectionCallback.OnConnectedImpl = FindFitnessDataSources;
            mClient = new GoogleApiClientBuilder(this)
                      .AddApi(FitnessClass.SENSORS_API)
                      .AddScope(new Scope(Scopes.FitnessLocationRead))
                      .AddConnectionCallbacks(clientConnectionCallback)
                      .AddOnConnectionFailedListener((ConnectionResult result) => {
                Log.Info(TAG, "Connection failed. Cause: " + result);
                if (!result.HasResolution)
                {
                    // Show the localized error dialog
                    GooglePlayServicesUtil.GetErrorDialog(result.ErrorCode, this, 0).Show();
                    return;
                }
                if (!authInProgress)
                {
                    try {
                        Log.Info(TAG, "Attempting to resolve failed connection");
                        authInProgress = true;
                        result.StartResolutionForResult(this, REQUEST_OAUTH);
                    } catch (IntentSender.SendIntentException e) {
                        Log.Error(TAG, "Exception while starting resolution activity", e);
                    }
                }
            }).Build();
        }
Exemplo n.º 7
0
		protected override void OnCreate (Bundle savedInstanceState)
		{
			base.OnCreate (savedInstanceState);
			SetContentView (Resource.Layout.activity_main);

			if (savedInstanceState != null) {
				mIsResolving = savedInstanceState.GetBoolean (KEY_IS_RESOLVING);
				mShouldResolve = savedInstanceState.GetBoolean (KEY_SHOULD_RESOLVE);
			}

			FindViewById (Resource.Id.sign_in_button).SetOnClickListener (this);
			FindViewById (Resource.Id.sign_out_button).SetOnClickListener (this);
			FindViewById (Resource.Id.disconnect_button).SetOnClickListener (this);

			FindViewById<SignInButton> (Resource.Id.sign_in_button).SetSize (SignInButton.SizeWide);
			FindViewById (Resource.Id.sign_in_button).Enabled = false;

			mStatus = FindViewById<TextView> (Resource.Id.status);

			mGoogleApiClient = new GoogleApiClientBuilder (this)
				.AddConnectionCallbacks (this)
				.AddOnConnectionFailedListener (this)
				.AddApi (PlusClass.API)
				.AddScope (new Scope (Scopes.Profile))
				.Build ();
		}
Exemplo n.º 8
0
        void LaunchReceiver()
        {
            try
            {
                var _castListener = new MyCastListener
                {
                    ApplicationDisconnected = delegate(int statusCode)
                    {
                        Console.WriteLine("Application disconnected - code {0}", statusCode);
                        Teardown(true);
                    }
                };

                var apiOptionsBuilder = new CastClass.CastOptions.Builder(_selectedDevice, _castListener)
                                        .Build();

                _apiClient = new GoogleApiClientBuilder(this, this, this)
                             .AddApi(CastClass.API, apiOptionsBuilder)
                             .Build();

                _apiClient.Connect();
            }
            catch (Exception e)
            {
                Console.WriteLine("Failed LaunchReceiver - {0}", e);
            }
        }
Exemplo n.º 9
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.ActivityDigitalConfig);
            header = FindViewById <TextView> (Resource.Id.Header);

            var listView = FindViewById <WearableListView> (Resource.Id.ColorPicker);
            var content  = FindViewById <BoxInsetLayout> (Resource.Id.Content);

            content.ApplyWindowInsets = (v, insets) => {
                if (!insets.IsRound)
                {
                    v.SetPaddingRelative(
                        Resources.GetDimensionPixelSize(Resource.Dimension.ContentPaddingStart),
                        v.PaddingTop,
                        v.PaddingEnd,
                        v.PaddingBottom
                        );
                }
                return(v.OnApplyWindowInsets(insets));
            };

            listView.HasFixedSize = true;
            listView.SetClickListener(this);
            listView.AddOnScrollListener(this);
            var colors = Resources.GetStringArray(Resource.Array.ColorArray);

            listView.SetAdapter(new ColorListAdapter(this, colors));

            googleApiClient = new GoogleApiClientBuilder(this)
                              .AddApi(WearableClass.Api)
                              .Build();
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);


            RequestWindowFeature(WindowFeatures.ActionBar);


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

            ActionBar.SetIcon(Resource.Drawable.appiconaction);


            settingsFragment = new SettingsFragment();
            settingsFragment.OnSettingsChanged += Synchronize;

            FragmentManager.BeginTransaction()
            .Replace(Resource.Id.fragment_container, settingsFragment)
            .Commit();

            googleClient = new GoogleApiClientBuilder(this)
                           .AddApi(WearableClass.Api)
                           .AddConnectionCallbacks(this)
                           .AddOnConnectionFailedListener(this)
                           .Build();

            googleClient.Connect();
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.person_list_activity);

            var options = new PlusClass.PlusOptions.Builder()
                          .AddActivityTypes(MomentUtil.ACTIONS).Build();

            mGoogleApiClient = new GoogleApiClientBuilder(this)
                               .AddConnectionCallbacks(this)
                               .AddOnConnectionFailedListener(this)
                               .AddApi(PlusClass.API, options)
                               .AddScope(PlusClass.ScopePlusLogin)
                               .Build();

            mListItems   = new List <String>();
            mListAdapter = new ArrayAdapter <String>(this,
                                                     Android.Resource.Layout.SimpleListItem1, mListItems);
            mPersonListView = FindViewById <ListView> (Resource.Id.person_list);
            mResolvingError = savedInstanceState != null &&
                              savedInstanceState.GetBoolean(STATE_RESOLVING_ERROR, false);

            int available = GooglePlayServicesUtil.IsGooglePlayServicesAvailable(this);

            if (available != CommonStatusCodes.Success)
            {
                ShowDialog(DIALOG_GET_GOOGLE_PLAY_SERVICES);
            }

            if (Build.VERSION.SdkInt >= BuildVersionCodes.Honeycomb)
            {
                this.ActionBar.SetDisplayHomeAsUpEnabled(true);
            }
        }
        private void InitializeGoogleAPI()
        {
            int queryResult = GoogleApiAvailability.Instance.IsGooglePlayServicesAvailable(Android.App.Application.Context);

            if (queryResult == ConnectionResult.Success)
            {
                if (mGoogleApiClient == null)
                {
                    mGoogleApiClient = new GoogleApiClientBuilder(Android.App.Application.Context).AddApi(Android.Gms.Location.LocationServices.API).AddConnectionCallbacks(this).AddOnConnectionFailedListener(this).Build();
                    string message = string.Format("{0} - {1}", CrossGeofence.Id, "Google Play services is available.");
                    System.Diagnostics.Debug.WriteLine(message);
                }

                if (!mGoogleApiClient.IsConnected)
                {
                    mGoogleApiClient.Connect();
                }
            }
            else
            {
                string message = string.Format("{0} - {1}", CrossGeofence.Id, "Google Play services is unavailable.");
                System.Diagnostics.Debug.WriteLine(message);
                CrossGeofence.GeofenceListener.OnError(message);
            }
        }
Exemplo n.º 13
0
		void BuildFitnessClient() {
			var clientConnectionCallback = new ClientConnectionCallback ();
			clientConnectionCallback.OnConnectedImpl = FindFitnessDataSources;
			mClient = new GoogleApiClientBuilder(this)
				.AddApi(FitnessClass.SENSORS_API)
				.AddScope(new Scope(Scopes.FitnessLocationRead))
				.AddConnectionCallbacks(clientConnectionCallback)
				.AddOnConnectionFailedListener((ConnectionResult result) => {
							Log.Info(TAG, "Connection failed. Cause: " + result);
							if (!result.HasResolution) {
								// Show the localized error dialog
						GooglePlayServicesUtil.GetErrorDialog(result.ErrorCode,
									this, 0).Show();
								return;
							}
							if (!authInProgress) {
								try {
							Log.Info(TAG, "Attempting to resolve failed connection");
									authInProgress = true;
									result.StartResolutionForResult(this,
										REQUEST_OAUTH);
								} catch (IntentSender.SendIntentException e) {
							Log.Error(TAG,
										"Exception while starting resolution activity", e);
								}
							}
						})
				.Build();
		}
Exemplo n.º 14
0
		protected override void OnCreate (Bundle savedInstanceState)
		{
			base.OnCreate (savedInstanceState);
			SetContentView (Resource.Layout.activity_main);
			mClient = new GoogleApiClientBuilder(this).AddApi (AppIndex.APP_INDEX_API).Build ();
			OnNewIntent (Intent);
		}
        /// <summary>
        /// Sign out of Google Play and make sure we don't try to auto sign in on the next startup
        /// </summary>
        public void SignOut()
        {
            this.SignedOut = true;

            if (this.client.IsConnected)
            {
                GamesClass.SignOut(this.client);
                this.Stop();

                using (var settings = this.activity.GetSharedPreferences("googleplayservicessettings", FileCreationMode.Private))
                {
                    using (var e = settings.Edit())
                    {
                        e.PutString("playerid", String.Empty);
                        e.Commit();
                    }
                }

                this.client.Dispose();
                this.client = null;

                if (this.OnSignedOut != null)
                {
                    this.OnSignedOut(this, EventArgs.Empty);
                }
            }
        }
Exemplo n.º 16
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_main);

            if (savedInstanceState != null)
            {
                mIsResolving   = savedInstanceState.GetBoolean(KEY_IS_RESOLVING);
                mShouldResolve = savedInstanceState.GetBoolean(KEY_SHOULD_RESOLVE);
            }

            FindViewById(Resource.Id.sign_in_button).SetOnClickListener(this);
            FindViewById(Resource.Id.sign_out_button).SetOnClickListener(this);
            FindViewById(Resource.Id.disconnect_button).SetOnClickListener(this);

            FindViewById <SignInButton> (Resource.Id.sign_in_button).SetSize(SignInButton.SizeWide);
            FindViewById(Resource.Id.sign_in_button).Enabled = false;

            mStatus = FindViewById <TextView> (Resource.Id.status);

            mGoogleApiClient = new GoogleApiClientBuilder(this)
                               .AddConnectionCallbacks(this)
                               .AddOnConnectionFailedListener(this)
                               .AddApi(PlusClass.API)
                               .AddScope(new Scope(Scopes.Profile))
                               .Build();
        }
        protected override void OnCreate (Bundle savedInstanceState) 
        {
            base.OnCreate (savedInstanceState);
            SetContentView (Resource.Layout.person_list_activity);

            var options = new PlusClass.PlusOptions.Builder ().AddActivityTypes (MomentUtil.ACTIONS).Build ();
            mGoogleApiClient = new GoogleApiClientBuilder (this)
                .AddConnectionCallbacks (this)
                .AddOnConnectionFailedListener (this)
                .AddApi (PlusClass.API, options)
                .AddScope (PlusClass.ScopePlusLogin)
                .Build ();

            mListItems = new List<string>();
            mListAdapter = new ArrayAdapter<string> (this,
                Android.Resource.Layout.SimpleListItem1, mListItems);
            mPersonListView = FindViewById<ListView> (Resource.Id.person_list);
            mResolvingError = savedInstanceState != null
                && savedInstanceState.GetBoolean (STATE_RESOLVING_ERROR, false);

            var available = GooglePlayServicesUtil.IsGooglePlayServicesAvailable (this);
            if (available != CommonStatusCodes.Success)
                ShowDialog (DIALOG_GET_GOOGLE_PLAY_SERVICES);

            if (Build.VERSION.SdkInt >= BuildVersionCodes.Honeycomb) {
                this.ActionBar.SetDisplayHomeAsUpEnabled (true);
            }
        }
Exemplo n.º 18
0
		protected void BuildGoogleApiClient() {
			mGoogleApiClient = new GoogleApiClientBuilder(this)
				.AddConnectionCallbacks(this)
				.AddOnConnectionFailedListener(this)
				.AddApi(LocationServices.API)
				.Build();
		}
Exemplo n.º 19
0
		void BuildFitnessClient() {
			var clientConnectionCallback = new ClientConnectionCallback ();
			clientConnectionCallback.OnConnectedImpl = Subscribe;
			// Create the Google API Client
			mClient = new GoogleApiClientBuilder(this)
				.AddApi(FitnessClass.RECORDING_API)
				.AddScope(new Scope(Scopes.FitnessActivityRead))
				.AddConnectionCallbacks(clientConnectionCallback)
				.AddOnConnectionFailedListener((ConnectionResult result) => {
							Log.Info(TAG, "Connection failed. Cause: " + result.ToString());
					if (!result.HasResolution) {
								// Show the localized error dialog
						GooglePlayServicesUtil.GetErrorDialog(result.ErrorCode,
									this, 0).Show();
								return;
							}
							// The failure has a resolution. Resolve it.
							// Called typically when the app is not yet authorized, and an
							// authorization dialog is displayed to the user.
							if (!authInProgress) {
								try {
							Log.Info(TAG, "Attempting to resolve failed connection");
									authInProgress = true;
									result.StartResolutionForResult(this,
										REQUEST_OAUTH);
								} catch (IntentSender.SendIntentException e) {
									Log.Error(TAG,
										"Exception while starting resolution activity", e);
								}
							}
					})
				.Build();
		}
Exemplo n.º 20
0
 public void AddGeofences()
 {
     // Start a request to add geofences
     mRequestType = RequestType.Add;
     // Test for Google Play services after setting the request type
     if (!IsGooglePlayServicesAvailable)
     {
         Log.Error(Constants.TAG, "Unable to add geofences - Google Play services unavailable.");
         return;
     }
     // Create a new location client object. Since this activity implements ConnectionCallbacks and OnConnectionFailedListener,
     // it can be used as the listener for both parameters
     apiClient = new GoogleApiClientBuilder(this, this, this)
                 .AddApi(LocationServices.API)
                 .Build();
     // If a request is not already underway
     if (!mInProgress)
     {
         // Indicate that a request is underway
         mInProgress = true;
         // Request a connection from the client to Location Services
         apiClient.Connect();
     }
     else
     {
         // A request is already underway, so disconnect the client and retry the request
         apiClient.Disconnect();
         apiClient.Connect();
     }
 }
Exemplo n.º 21
0
 void SetupGeofencing()
 {
     client = new GoogleApiClientBuilder (this, this, this)
         .AddApi (LocationServices.API)
         .Build ();
     client.Connect ();
 }
Exemplo n.º 22
0
		protected override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);


			RequestWindowFeature (WindowFeatures.ActionBar);


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

			ActionBar.SetIcon (Resource.Drawable.appiconaction);


			settingsFragment = new SettingsFragment ();
			settingsFragment.OnSettingsChanged += Synchronize;

			FragmentManager.BeginTransaction ()
				.Replace (Resource.Id.fragment_container, settingsFragment)
				.Commit ();

			googleClient = new GoogleApiClientBuilder (this)
				.AddApi (WearableClass.Api)
				.AddConnectionCallbacks (this)
				.AddOnConnectionFailedListener (this)
				.Build ();

			googleClient.Connect ();
		}
Exemplo n.º 23
0
		protected void buildGoogleApiClient ()
		{
			mGoogleApiClient = new GoogleApiClientBuilder (this)
				.AddConnectionCallbacks (this)
				.AddOnConnectionFailedListener (this)
				.AddApi (Android.Gms.Location.ActivityRecognition.API)
				.Build ();
		}
Exemplo n.º 24
0
		protected override void OnCreate (Bundle savedInstanceState)
		{
			base.OnCreate (savedInstanceState);
			handler = new Handler ();
			client = new GoogleApiClientBuilder (this, this, this)
				.AddApi (WearableClass.Api)
				.Build ();
		}
Exemplo n.º 25
0
 protected void buildGoogleApiClient()
 {
     mGoogleApiClient = new GoogleApiClientBuilder(this)
                        .AddConnectionCallbacks(this)
                        .AddOnConnectionFailedListener(this)
                        .AddApi(Android.Gms.Location.ActivityRecognition.API)
                        .Build();
 }
Exemplo n.º 26
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            client = new GoogleApiClientBuilder(this, this, this)
                     .AddApi(PanoramaClass.API)
                     .Build();
        }
Exemplo n.º 27
0
 protected void BuildGoogleApiClient()
 {
     mGoogleApiClient = new GoogleApiClientBuilder(this)
                        .AddConnectionCallbacks(this)
                        .AddOnConnectionFailedListener(this)
                        .AddApi(LocationServices.API)
                        .Build();
 }
Exemplo n.º 28
0
 protected override void OnCreate(Bundle savedInstanceState)
 {
     base.OnCreate(savedInstanceState);
     handler = new Handler();
     client  = new GoogleApiClientBuilder(this, this, this)
               .AddApi(WearableClass.Api)
               .Build();
 }
 public override void OnCreate()
 {
     base.OnCreate();
     googleApiClient = new GoogleApiClientBuilder(this.ApplicationContext)
                       .AddApi(WearableClass.Api)
                       .Build();
     googleApiClient.Connect();
 }
Exemplo n.º 30
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            handler = new Handler();
            client  = new GoogleApiClientBuilder(this, this, this).AddApi(WearableClass.Api).Build();

            _platformProvider = new WearPlatformProvider();
        }
		public override void OnCreate ()
		{
			base.OnCreate ();
			mGoogleApiClient = new GoogleApiClientBuilder (this.ApplicationContext)
				.AddApi (WearableClass.Api)
				.Build ();
			mGoogleApiClient.Connect ();
		}
 public SimpleLocationManager()
 {
     googleApiClient = new GoogleApiClientBuilder(context)
         .AddConnectionCallbacks(this)
         .AddOnConnectionFailedListener(this)
         .AddApi(LocationServices.Api)
         .Build();
 }
Exemplo n.º 33
0
        protected override void OnCreate (Bundle savedInstanceState) 
        {
            base.OnCreate(savedInstanceState);

            client = new GoogleApiClientBuilder (this, this, this)
                .AddApi (PanoramaClass.API)
                .Build ();
        }
Exemplo n.º 34
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            AndroidExtensions.Initialize(this);
            SetContentView(Resource.Layout.Main);

            this.drawer       = FindViewById <DrawerLayout> (Resource.Id.drawer_layout);
            this.drawerToggle = new MoyeuActionBarToggle(this,
                                                         drawer,
                                                         Resource.Drawable.ic_drawer,
                                                         Resource.String.open_drawer,
                                                         Resource.String.close_drawer)
            {
                OpenCallback = () => {
                    ActionBar.Title = Title;
                    CurrentFragment.HasOptionsMenu = false;
                    InvalidateOptionsMenu();
                },
                CloseCallback = () => {
                    var currentFragment = CurrentFragment;
                    if (currentFragment != null)
                    {
                        ActionBar.Title = ((IMoyeuSection)currentFragment).Title;
                        currentFragment.HasOptionsMenu = true;
                    }
                    InvalidateOptionsMenu();
                },
            };
            drawer.SetDrawerShadow(Resource.Drawable.drawer_shadow, (int)GravityFlags.Left);
            drawer.SetDrawerListener(drawerToggle);
            ActionBar.SetDisplayHomeAsUpEnabled(true);
            ActionBar.SetHomeButtonEnabled(true);

            Hubway.Instance.Subscribe(this);
            FavoriteManager.FavoritesChanged += (sender, e) => aroundAdapter.Refresh();

            drawerMenu = FindViewById <ListView> (Resource.Id.left_drawer);
            drawerMenu.AddFooterView(new Space(this));
            drawerMenu.ItemClick += HandleSectionItemClick;
            menuNormalTf          = Typeface.Create(Resources.GetString(Resource.String.menu_item_fontFamily),
                                                    TypefaceStyle.Normal);
            menuHighlightTf = Typeface.Create(Resources.GetString(Resource.String.menu_item_fontFamily),
                                              TypefaceStyle.Bold);
            drawerMenu.Adapter = new DrawerMenuAdapter(this);

            drawerAround            = FindViewById <ListView> (Resource.Id.left_drawer_around);
            drawerAround.ItemClick += HandleAroundItemClick;
            drawerAround.Adapter    = aroundAdapter = new DrawerAroundAdapter(this);

            drawerMenu.SetItemChecked(0, true);
            if (CheckGooglePlayServices())
            {
                client = CreateApiClient();
                SwitchTo(mapFragment = new HubwayMapFragment(this));
                ActionBar.Title      = ((IMoyeuSection)mapFragment).Title;
            }
        }
		public override void OnCreate()
		{
			base.OnCreate ();
			google_api_client = new GoogleApiClientBuilder (this)
				.AddApi (WearableClass.Api)
				.AddConnectionCallbacks (this)
				.AddOnConnectionFailedListener (this)
				.Build ();
		}
        public ParksLocatorService(IParksLocatorRepository parksLocatorRepository,
                                   IGoogleApiClient googleApiClient,
                                   IDistanceService distanceService)

        {
            _googleApiClient        = googleApiClient;
            _parksLocatorRepository = parksLocatorRepository;
            _distanceService        = distanceService;
        }
Exemplo n.º 37
0
 public override void OnCreate()
 {
     base.OnCreate();
     googleApiClient = new GoogleApiClientBuilder(this)
                       .AddApi(WearableClass.Api)
                       .AddConnectionCallbacks(this)
                       .AddOnConnectionFailedListener(this)
                       .Build();
 }
Exemplo n.º 38
0
		protected override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);
			SetContentView (Resource.Layout.activity_phone);
			googleApiClient = new GoogleApiClientBuilder (this)
				.AddApi (WearableClass.Api)
				.AddConnectionCallbacks (this)
				.AddOnConnectionFailedListener (this)
				.Build ();
		}
Exemplo n.º 39
0
 protected override void OnCreate(Bundle bundle)
 {
     base.OnCreate(bundle);
     SetContentView(Resource.Layout.activity_phone);
     googleApiClient = new GoogleApiClientBuilder(this)
                       .AddApi(WearableClass.Api)
                       .AddConnectionCallbacks(this)
                       .AddOnConnectionFailedListener(this)
                       .Build();
 }
		public override void OnCreate ()
		{
			base.OnCreate ();
			if (Log.IsLoggable (Constants.TAG, LogPriority.Info))
				Log.Info (Constants.TAG, "HomeListenerService created");
			mGoogleApiClient = new GoogleApiClientBuilder (this.ApplicationContext)
				.AddApi (WearableClass.Api)
				.Build ();
			mGoogleApiClient.Connect ();
		}
Exemplo n.º 41
0
 void PostCheckGooglePlayServices()
 {
     if (client == null)
     {
         client = CreateApiClient();
     }
     SwitchTo(mapFragment   = new HubwayMapFragment());
     SupportActionBar.Title = ((IMoyeuSection)mapFragment).Title;
     CheckForSearchTermInIntent(Intent);
 }
Exemplo n.º 42
0

        
Exemplo n.º 43
0
        public override void OnCreate()
        {
            base.OnCreate();
            _client = new GoogleApiClientBuilder(this.ApplicationContext)
                      .AddApi(WearableClass.Api)
                      .Build();

            _client.Connect();

            Android.Util.Log.Info("WearIntegration", "Created");
        }
Exemplo n.º 44
0
        void BuildFitnessClient()
        {
            var clientConnectionCallback = new ClientConnectionCallback();

            clientConnectionCallback.OnConnectedImpl = () => {
                DataSet dataSet = InsertFitnessData();

                Log.Info(TAG, "Inserting the dataset in the History API");
                var insertStatus = (Statuses)FitnessClass.HistoryApi.InsertData(mClient, dataSet).Await(1, TimeUnit.Minutes);

                if (!insertStatus.IsSuccess)
                {
                    Log.Info(TAG, "There was a problem inserting the dataset.");
                    return;
                }

                Log.Info(TAG, "Data insert was successful!");

                var readRequest = QueryFitnessData();

                var dataReadResult = (DataReadResult)FitnessClass.HistoryApi.ReadData(mClient, readRequest).Await(1, TimeUnit.Minutes);

                PrintData(dataReadResult);
            };
            // Create the Google API Client
            mClient = new GoogleApiClientBuilder(this)
                      .AddApi(FitnessClass.HISTORY_API)
                      .AddScope(new Scope(Scopes.FitnessActivityReadWrite))
                      .AddConnectionCallbacks(clientConnectionCallback)
                      .AddOnConnectionFailedListener(result => {
                Log.Info(TAG, "Connection failed. Cause: " + result);
                if (!result.HasResolution)
                {
                    // Show the localized error dialog
                    GooglePlayServicesUtil.GetErrorDialog(result.ErrorCode, this, 0).Show();
                    return;
                }
                // The failure has a resolution. Resolve it.
                // Called typically when the app is not yet authorized, and an
                // authorization dialog is displayed to the user.
                if (!authInProgress)
                {
                    try {
                        Log.Info(TAG, "Attempting to resolve failed connection");
                        authInProgress = true;
                        result.StartResolutionForResult(this,
                                                        REQUEST_OAUTH);
                    } catch (IntentSender.SendIntentException e) {
                        Log.Error(TAG,
                                  "Exception while starting resolution activity", e);
                    }
                }
            }).Build();
        }
Exemplo n.º 45
0
 public void OnDisconnected()
 {
     Log.Debug("LocClient", "Disconnected");
     client = null;
     // If the client was disconnected too early
     if (currentRequest != ConnectionUpdateRequest.None)
     {
         client = CreateGoogleClient();
         client.Connect();
     }
 }
Exemplo n.º 46
0
        public override void OnCreate()
        {
            base.OnCreate();
            _client = new GoogleApiClientBuilder(this.ApplicationContext)
                    .AddApi(WearableClass.Api)
                    .Build();

            _client.Connect();

            Android.Util.Log.Info("WearIntegration", "Created");
        }
Exemplo n.º 47
0
        public void Init()
        {
            mDatePickerDialog = new DatePickerDialog(this, this, ViewModel.EndBookingDateTime.Year, ViewModel.EndBookingDateTime.Month - 1, ViewModel.EndBookingDateTime.Day);
            mTimePickerDialog = new TimePickerDialog(this, this, ViewModel.EndBookingDateTime.Hour, ViewModel.EndBookingDateTime.Minute, true);
            etDate            = FindViewById <TextView>(Resource.Id.etDate);
            etHour            = FindViewById <TextView>(Resource.Id.etHour);
            mSeekBar          = FindViewById <SeekBar>(Resource.Id.seekBar1);
            mSeekBar.Touch   += (sender, args) =>
            {
                if (args.Event.Action == MotionEventActions.Up)
                {
                    if (mSeekBar.Progress != mCurrentProgress)
                    {
                        mCurrentProgress = mSeekBar.Progress;
                        ViewModel.HandleValueChanged();
                        args.Handled = true;
                        return;
                    }
                }

                args.Handled = false;
            };
            mCurrentProgress = 0;
            etDate.Click    += (sender, args) =>
            {
                mDatePickerDialog.UpdateDate(ViewModel.EndBookingDateTime.Year, ViewModel.EndBookingDateTime.Month - 1, ViewModel.EndBookingDateTime.Day);
                mDatePickerDialog.Show();
            };
            etHour.Click += (sender, args) =>
            {
                mTimePickerDialog.UpdateTime(ViewModel.EndBookingDateTime.Hour, ViewModel.EndBookingDateTime.Minute);
                mTimePickerDialog.Show();
            };

            locationManager = (LocationManager)GetSystemService(LocationService);
            bool GPSEnable = DetectLocationService();

            var _isGooglePlayServicesInstalled = IsGooglePlayServicesInstalled();

            if (_isGooglePlayServicesInstalled)
            {
                // pass in the Context, ConnectionListener and ConnectionFailedListener
                apiClient = new GoogleApiClientBuilder(this, this, this)
                            .AddApi(LocationServices.API).Build();

                // generate a location request that we will pass into a call for location updates
                locRequest = new LocationRequest();
            }
            else
            {
                Log.Error("OnCreate", "Google Play Services is not installed");
                Toast.MakeText(this, ViewModel.SharedTextSource.GetText("GGPlayNotInstalledText"), ToastLength.Long).Show();
            }
        }
Exemplo n.º 48
0
		public void StartUpdatingLocation ()
		{
			if (_googleApiClient == null) {
				_googleApiClient = new GoogleApiClientBuilder (Forms.Context)
					.AddApi (LocationServices.API)
					.AddConnectionCallbacks (this)
					.AddOnConnectionFailedListener (this)
					.Build ();

				_googleApiClient.Connect ();
			}
		}
Exemplo n.º 49
0
		protected override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);

			// Set our view from the "main" layout resource
			SetContentView (Resource.Layout.main);
			mLogTextView = (TextView)FindViewById (Resource.Id.log);
			mSCroller = (ScrollView)FindViewById (Resource.Id.scroller);
			mGoogleApiClient = new GoogleApiClientBuilder (this).AddApi (WearableClass.API)
				.AddConnectionCallbacks (this)
				.AddOnConnectionFailedListener (this)
				.Build ();
		}
		protected override void OnCreate (Bundle savedInstanceState)
		{
			base.OnCreate (savedInstanceState);
			SetContentView (Resource.Layout.deep_link_activity);

			FindViewById (Resource.Id.button_ok).SetOnClickListener (this);

			googleApiClient = new GoogleApiClientBuilder (this)
				.AddConnectionCallbacks (this)
				.EnableAutoManage (this, 0, this)
				.AddApi (Android.Gms.AppInvite.AppInviteClass.API)
				.Build ();
		}
Exemplo n.º 51
0
		protected override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);
			SetContentView (Resource.Layout.main_activity);
			mGoogleApiClient = new GoogleApiClientBuilder (this)
				.AddApi (WearableClass.Api)
				.AddConnectionCallbacks (this)
				.AddOnConnectionFailedListener (this)
				.Build ();
			FindViewById (Resource.Id.start_wearable_activity).Click += delegate {
				OnStartWearableActivityClick (null);
			};
		}
Exemplo n.º 52
0
 ///<inheritdoc/>
 public void Connect()
 {
     if(this._apiClient == null)
     {
         this._apiClient = new GoogleApiClientBuilder(Forms.Context)
             .AddApi(PlacesClass.GEO_DATA_API)
             .Build();
     }
     if(!this._apiClient.IsConnected && !this._apiClient.IsConnecting)
     {
         this._apiClient.Connect();
     }
 }
Exemplo n.º 53
0
		protected override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);
			SetContentView (Resource.Layout.main_activity);
			delayedConfirmationView = FindViewById<DelayedConfirmationView> (Resource.Id.delayed_confirmation);
			delayedConfirmationView.SetTotalTimeMs (NUM_SECONDS * 1000);
			mGoogleApiClient = new GoogleApiClientBuilder (this)
				.AddApi (WearableClass.Api)
				.AddOnConnectionFailedListener (this)
				.Build ();
			FindViewById (Resource.Id.start_timer).Click += delegate {
				OnStartTimer (null);
			};
		}
Exemplo n.º 54
0
    protected override void OnCreate(Bundle bundle)
    {
      base.OnCreate(bundle);
      handler = new Handler();
      client = new GoogleApiClientBuilder(this, this, this)
        .AddApi(WearableClass.API)
        .Build();
      // Set our view from the "main" layout resource
      SetContentView(Resource.Layout.Main);

      viewPager = FindViewById<GridViewPager>(Resource.Id.pager);
      progress = FindViewById<ProgressBar>(Resource.Id.progressBar);

    }
Exemplo n.º 55
0
        public void RegisterGeofences(PlaceGeofence[] fenceData)
        {
            if(pendingIntent != null)
            {
                Toast.MakeText(context, "Removing old fences", ToastLength.Short).Show();
                currentStage = FencingStage.Removing;
            }

            if (fencesToAdd == null)
            {
                fencesToAdd = new List<IGeofence>();
            }

            ISharedPreferences prefs = context.GetSharedPreferences("FENCES", FileCreationMode.MultiProcess);
            ISharedPreferencesEditor editor = prefs.Edit();

            editor.Clear();
            editor.Apply();

            foreach (PlaceGeofence fence in fenceData)
            {
                fencesToAdd.Add(new GeofenceBuilder()
                    .SetCircularRegion(fence.lat, fence.lng, fence.radius)
                    .SetExpirationDuration(Geofence.NeverExpire)
                    .SetRequestId(fence.placeId)
                    .SetLoiteringDelay(0)
                    .SetTransitionTypes(Geofence.GeofenceTransitionEnter | Geofence.GeofenceTransitionDwell | Geofence.GeofenceTransitionExit)
                    .Build());

                editor.PutString(fence.placeId, JsonConvert.SerializeObject(fence));
            }

            editor.Apply();

            if(googleApiClient == null)
            {
                intent = new Intent(context, typeof(GeofencingReceiver));
                googleApiClient = new GoogleApiClientBuilder(context)
                    .AddApi(LocationServices.Api)
                    .AddConnectionCallbacks(this)
                    .AddOnConnectionFailedListener(this)
                    .Build();
            }
            
            googleApiClient.Connect();
        }
Exemplo n.º 56
0
		protected override void OnCreate (Bundle savedInstanceState)
		{
			base.OnCreate (savedInstanceState);
			SetContentView (Resource.Layout.activity_main);

			FindViewById (Resource.Id.button_advertise).SetOnClickListener (this);
			FindViewById (Resource.Id.button_discover).SetOnClickListener (this);
			FindViewById (Resource.Id.button_send).SetOnClickListener (this);

			mMessageText = FindViewById<EditText> (Resource.Id.edittext_message);

			mDebugInfo = FindViewById<TextView> (Resource.Id.debug_text);
			mDebugInfo.MovementMethod = new ScrollingMovementMethod ();

			mGoogleApiClient = new GoogleApiClientBuilder (this)
				.AddConnectionCallbacks (this)
				.AddOnConnectionFailedListener (this)
				.AddApi (NearbyClass.CONNECTIONS_API)
				.Build ();
		}
Exemplo n.º 57
0
        void Init ()
        {
            mediaRouter = MediaRouter.GetInstance (this);

            mediaRouteSelector =
                new MediaRouteSelector.Builder ().AddControlCategory (MediaControlIntent.CategoryRemotePlayback) //CastMediaControlIntent.CategoryForCast (APP_ID))
                    .Build();
            mediaRouteButton.RouteSelector = mediaRouteSelector;

            myMediaRouterCallback = new MyMediaRouterCallback {
                OnRouteSelectedHandler = (router, route) => {

                    Console.WriteLine ("Route Selected: " + route.Name);

                    var device = CastDevice.GetFromBundle(route.Extras);

                    myCastListener = new MyCastListener();

                    var apiOptionsBuilder = new CastClass.CastOptions.Builder (
                        device,
                        myCastListener).SetVerboseLoggingEnabled (true);

                    googleApiClient = new GoogleApiClientBuilder(this)
                        .AddApi (CastClass.API, apiOptionsBuilder.Build())
                        .AddConnectionCallbacks (this)
                        .AddOnConnectionFailedListener (this)
                        .Build ();

                    googleApiClient.Connect();

                },
                OnRouteUnselectedHandler = (router, route) => {
                    Console.WriteLine ("Route Unselected: " + route.Name);
                },
                RouteCountChangedHandler = newCount => {
                    mediaRouteButton.Visibility = newCount > 0 ? ViewStates.Visible : ViewStates.Gone;
                }
            };

            mediaRouter.AddCallback(mediaRouteSelector, myMediaRouterCallback, MediaRouter.CallbackFlagRequestDiscovery);
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            _client = new GoogleApiClientBuilder(this, this, this)
                             .AddApi(WearableClass.Api)
                             .Build();

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);
            var v = FindViewById<WatchViewStub>(Resource.Id.watch_view_stub);
            v.LayoutInflated += delegate {

                // Get our button from the layout resource,
                // and attach an event to it
                Button button = FindViewById<Button>(Resource.Id.myButton);

                button.Click += delegate {
                    SendData();
                };
            };
        }
Exemplo n.º 59
0
		protected override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);
			SetContentView (Resource.Layout.activity_main);

			google_api_client = new GoogleApiClientBuilder (this)
				.AddApi (WearableClass.Api)
				.AddConnectionCallbacks (this)
				.AddOnConnectionFailedListener (this)
				.Build ();

			future_questions = new Java.Util.PriorityQueue (10);

			question_edit_text = FindViewById <EditText> (Resource.Id.question_text);
			choice_a_edit_text = FindViewById <EditText> (Resource.Id.choice_a_text);
			choice_b_edit_text = FindViewById <EditText> (Resource.Id.choice_b_text);
			choice_c_edit_text = FindViewById <EditText> (Resource.Id.choice_c_text);
			choice_d_edit_text = FindViewById <EditText> (Resource.Id.choice_d_text);
			choices_radio_group = FindViewById <RadioGroup> (Resource.Id.choices_radio_group);
			quiz_status = FindViewById <TextView> (Resource.Id.quiz_status);
			quiz_buttons = FindViewById<LinearLayout> (Resource.Id.quiz_buttons);
			questions_container = FindViewById<LinearLayout> (Resource.Id.questions_container);
			read_quiz_from_file_button = FindViewById<Button> (Resource.Id.read_quiz_from_file_button);
			reset_quiz_button = FindViewById<Button> (Resource.Id.reset_quiz_button);
			new_quiz_button = FindViewById<Button> (Resource.Id.new_quiz_button);

			read_quiz_from_file_button.Click += delegate {
				ReadQuizFromFile (read_quiz_from_file_button);
			};

			reset_quiz_button.Click += delegate {
				ResetQuiz ();
			};
			new_quiz_button.Click += delegate {
				NewQuiz ();
			};

		}
Exemplo n.º 60
0
		////Lifecycle methods

		protected override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);
			Log.Debug ("OnCreate", "OnCreate called, initializing views...");

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

			// UI to print last location
			button = FindViewById<Button> (Resource.Id.myButton);
			latitude = FindViewById<TextView> (Resource.Id.latitude);
			longitude = FindViewById<TextView> (Resource.Id.longitude);
			provider = FindViewById<TextView> (Resource.Id.provider);

			// UI to print location updates
			button2 = FindViewById<Button> (Resource.Id.myButton2);
			latitude2 = FindViewById<TextView> (Resource.Id.latitude2);
			longitude2 = FindViewById<TextView> (Resource.Id.longitude2);
			provider2 = FindViewById<TextView> (Resource.Id.provider2);

			_isGooglePlayServicesInstalled = IsGooglePlayServicesInstalled ();

			if (_isGooglePlayServicesInstalled) {
				// pass in the Context, ConnectionListener and ConnectionFailedListener
				apiClient = new GoogleApiClientBuilder (this, this, this)
					.AddApi (LocationServices.API).Build ();

				// generate a location request that we will pass into a call for location updates
				locRequest = new LocationRequest ();

			} else {
				Log.Error ("OnCreate", "Google Play Services is not installed");
				Toast.MakeText (this, "Google Play Services is not installed", ToastLength.Long).Show ();
				Finish ();
			}

		}