Skip to content

Add documentation for GoogleApiHelper#getSafeAutoManageId() and do a teeny bit of cleanup in the auth README #575

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions auth/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,8 @@ startActivityForResult(

#### Handling the sign-in response

#####Response codes
##### Response codes

The authentication flow provides several response codes of which the most common are as follows:
`ResultCodes.OK` if a user is signed in, `ResultCodes.CANCELLED` if the user manually canceled the sign in,
`ResultCodes.NO_NETWORK` if sign in failed due to a lack of network connectivity,
Expand Down Expand Up @@ -344,6 +345,23 @@ AuthUI.getInstance()
});
```

### Using the `GoogleApiClient` in your own app with `enableAutoManage`

FirebaseUI Auth heavily relies on the `GoogleApiClient` and its `enableAutoManage` method to
help prevent memory leaks. However, using `enableAutoManage` can be risky because the method will throw
an `IllegalStateException` if another `GoogleApiClient` is being managed with the same id.
To help solve this problem, FirebaseUI provides a helper method to get a safe id that is
not being used: `GoogleApiHelper#getSafeAutoManageId()`.

#### Example usage:

```java
new GoogleApiClient.Builder(mActivity)
.enableAutoManage(mActivity, GoogleApiHelper.getSafeAutoManageId(), null /* listener */)
.addApi(...)
.build()
```

### Authentication flow chart

The authentication flow implemented on Android is more complex than on other
Expand All @@ -352,7 +370,7 @@ represented in the following diagram:

![FirebaseUI authentication flow on Android](flow.png)

### UI customization
## UI customization
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This header is part of the Table of Contents so it should be on the same level as configuration and using-firebaseui-for-authentication.


To provide customization of the visual style of the activities that implement
the flow, a new theme can be declared. Standard material design color
Expand Down Expand Up @@ -459,4 +477,4 @@ startActivityForResult(

#### Twitter

Twitter permissions can only be configured through Twitter's developer console.
Twitter permissions can only be configured through [Twitter's developer console](https://apps.twitter.com/).
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ protected GoogleApiHelper(FragmentActivity activity, GoogleApiClient.Builder bui
mClient = builder.build();
}

/**
* @return a safe id for {@link GoogleApiClient.Builder#enableAutoManage(FragmentActivity, int,
* GoogleApiClient.OnConnectionFailedListener)}
*/
public static int getSafeAutoManageId() {
return SAFE_ID.getAndIncrement();
}
Expand Down