Search in sources :

Example 16 with GoogleApiClient

use of com.google.android.gms.common.api.GoogleApiClient in project Memento-Calendar by alexstyl.

the class ContactEventsProviderService method onComplicationUpdate.

@Override
public void onComplicationUpdate(final int complicationId, final int dataType, final ComplicationManager complicationManager) {
    GoogleApiClient.ConnectionCallbacks connectionCallbacks = new GoogleApiClient.ConnectionCallbacks() {

        @Override
        public void onConnected(@Nullable Bundle bundle) {
            wearCommunicationService.loadDataItems(new WearCommunicationService.Callback() {

                @Override
                public void onDataItemsLoaded(DataItem item) {
                    ComplicationData complicationData = createComplicationData(item, dataType);
                    if (complicationData != null) {
                        complicationManager.updateComplicationData(complicationId, complicationData);
                    }
                }

                @Override
                public void onNoDataItemsAvailable() {
                    ComplicationData emptyComplicationData = createComplicationData(dataType, NO_DATE_AVAILABLE, Collections.<String>emptyList());
                    complicationManager.updateComplicationData(complicationId, emptyComplicationData);
                }
            });
        }

        @Override
        public void onConnectionSuspended(int i) {
        // no-op
        }
    };
    GoogleApiClient googleApiClient = new GoogleApiClient.Builder(this).addApi(Wearable.API).addConnectionCallbacks(connectionCallbacks).build();
    wearCommunicationService = new WearCommunicationService(googleApiClient);
    googleApiClient.connect();
}
Also used : GoogleApiClient(com.google.android.gms.common.api.GoogleApiClient) DataItem(com.google.android.gms.wearable.DataItem) Bundle(android.os.Bundle) ComplicationData(android.support.wearable.complications.ComplicationData) Nullable(android.support.annotation.Nullable)

Example 17 with GoogleApiClient

use of com.google.android.gms.common.api.GoogleApiClient in project Memento-Calendar by alexstyl.

the class WearSyncService method onHandleIntent.

@Override
protected void onHandleIntent(Intent intent) {
    if (!permissions.canReadAndWriteContacts()) {
        return;
    }
    Optional<ContactEventsOnADate> eventsOptional = fetchContactEvents();
    if (eventsOptional.isPresent()) {
        ContactEventsOnADate contactEvents = eventsOptional.get();
        PutDataRequest putDataRequest = createDataRequest(contactEvents);
        GoogleApiClient googleApiClient = new GoogleApiClient.Builder(getApplicationContext()).addApi(Wearable.API).build();
        if (googleApiClient.blockingConnect().isSuccess()) {
            Wearable.DataApi.putDataItem(googleApiClient, putDataRequest);
        }
    }
}
Also used : GoogleApiClient(com.google.android.gms.common.api.GoogleApiClient) PutDataRequest(com.google.android.gms.wearable.PutDataRequest) ContactEventsOnADate(com.alexstyl.specialdates.events.peopleevents.ContactEventsOnADate)

Example 18 with GoogleApiClient

use of com.google.android.gms.common.api.GoogleApiClient in project FirebaseUI-Android by firebase.

the class CheckEmailFragment method getEmailHintIntent.

private PendingIntent getEmailHintIntent() {
    GoogleApiClient client = new GoogleApiClient.Builder(getContext()).addApi(Auth.CREDENTIALS_API).enableAutoManage(getActivity(), GoogleApiHelper.getSafeAutoManageId(), new GoogleApiClient.OnConnectionFailedListener() {

        @Override
        public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
            Log.e(TAG, "Client connection failed: " + connectionResult.getErrorMessage());
        }
    }).build();
    HintRequest hintRequest = new HintRequest.Builder().setHintPickerConfig(new CredentialPickerConfig.Builder().setShowCancelButton(true).build()).setEmailAddressIdentifierSupported(true).build();
    return Auth.CredentialsApi.getHintPickerIntent(client, hintRequest);
}
Also used : GoogleApiClient(com.google.android.gms.common.api.GoogleApiClient) HintRequest(com.google.android.gms.auth.api.credentials.HintRequest) NonNull(android.support.annotation.NonNull) ConnectionResult(com.google.android.gms.common.ConnectionResult) CredentialPickerConfig(com.google.android.gms.auth.api.credentials.CredentialPickerConfig)

Example 19 with GoogleApiClient

use of com.google.android.gms.common.api.GoogleApiClient in project FirebaseUI-Android by firebase.

the class AuthUI method signOut.

/**
     * Signs the current user out, if one is signed in.
     *
     * @param activity The activity requesting the user be signed out.
     * @return a task which, upon completion, signals that the user has been signed out ({@code
     * result.isSuccess()}, or that the sign-out attempt failed unexpectedly ({@code
     * !result.isSuccess()}).
     * @deprecated use {@link #signOut(FragmentActivity)} instead
     */
@Deprecated
public Task<Void> signOut(@NonNull Activity activity) {
    // Get helper for Google Sign In and Credentials API
    GoogleApiClientTaskHelper taskHelper = GoogleApiClientTaskHelper.getInstance(activity);
    taskHelper.getBuilder().addApi(Auth.CREDENTIALS_API).addApi(Auth.GOOGLE_SIGN_IN_API, GoogleSignInOptions.DEFAULT_SIGN_IN);
    // Get Credentials Helper
    CredentialTaskApi credentialsHelper = CredentialsApiHelper.getInstance(taskHelper);
    // Firebase Sign out
    mAuth.signOut();
    // Disable credentials auto sign-in
    Task<Status> disableCredentialsTask = credentialsHelper.disableAutoSignIn();
    // Google sign out
    Task<Void> googleSignOutTask = taskHelper.getConnectedGoogleApiClient().continueWith(new Continuation<GoogleApiClient, Void>() {

        @Override
        public Void then(@NonNull Task<GoogleApiClient> task) throws Exception {
            if (task.isSuccessful()) {
                Auth.GoogleSignInApi.signOut(task.getResult());
            }
            return null;
        }
    });
    // Facebook sign out
    LoginManager.getInstance().logOut();
    // Wait for all tasks to complete
    return Tasks.whenAll(disableCredentialsTask, googleSignOutTask);
}
Also used : Status(com.google.android.gms.common.api.Status) GoogleApiClient(com.google.android.gms.common.api.GoogleApiClient) GoogleApiClientTaskHelper(com.firebase.ui.auth.util.GoogleApiClientTaskHelper) CredentialTaskApi(com.firebase.ui.auth.util.CredentialTaskApi)

Example 20 with GoogleApiClient

use of com.google.android.gms.common.api.GoogleApiClient in project Android-ReactiveLocation by mcharmas.

the class BaseObservable method createApiClient.

protected GoogleApiClient createApiClient(Subscriber<? super T> subscriber) {
    ApiClientConnectionCallbacks apiClientConnectionCallbacks = new ApiClientConnectionCallbacks(subscriber);
    GoogleApiClient.Builder apiClientBuilder = new GoogleApiClient.Builder(ctx);
    for (Api<? extends Api.ApiOptions.NotRequiredOptions> service : services) {
        apiClientBuilder.addApi(service);
    }
    apiClientBuilder.addConnectionCallbacks(apiClientConnectionCallbacks);
    apiClientBuilder.addOnConnectionFailedListener(apiClientConnectionCallbacks);
    GoogleApiClient apiClient = apiClientBuilder.build();
    apiClientConnectionCallbacks.setClient(apiClient);
    return apiClient;
}
Also used : GoogleApiClient(com.google.android.gms.common.api.GoogleApiClient)

Aggregations

GoogleApiClient (com.google.android.gms.common.api.GoogleApiClient)32 ConnectionResult (com.google.android.gms.common.ConnectionResult)10 Bundle (android.os.Bundle)6 Intent (android.content.Intent)5 Handler (android.os.Handler)4 PendingIntent (android.app.PendingIntent)3 SharedPreferences (android.content.SharedPreferences)3 Bitmap (android.graphics.Bitmap)3 NonNull (android.support.annotation.NonNull)3 GoogleSignInOptions (com.google.android.gms.auth.api.signin.GoogleSignInOptions)3 NotificationManager (android.app.NotificationManager)2 NotificationCompat (android.support.v4.app.NotificationCompat)2 GoogleSignInResult (com.google.android.gms.auth.api.signin.GoogleSignInResult)2 Scope (com.google.android.gms.common.api.Scope)2 Status (com.google.android.gms.common.api.Status)2 DataItem (com.google.android.gms.wearable.DataItem)2 Node (com.google.android.gms.wearable.Node)2 PutDataMapRequest (com.google.android.gms.wearable.PutDataMapRequest)2 RemoteIntent (com.google.android.wearable.intent.RemoteIntent)2 SuppressLint (android.annotation.SuppressLint)1