Skip to content
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

Use intent to pass custom flags #608

Merged
merged 2 commits into from
Dec 12, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import android.content.Context;
import android.net.Uri;
import android.os.Bundle;
import android.util.Patterns;

import com.amazonaws.mobileconnectors.cognitoauth.exceptions.AuthInvalidParameterException;
Expand Down Expand Up @@ -59,6 +60,11 @@ public final class Auth {
*/
private final String idpIdentifier;

/**
* Bundle containing customization flags for chrome custom tab
*/
private final Bundle extraCustomBundle;

/**
* This identifies the settings for additional userPool features.
*/
Expand Down Expand Up @@ -143,7 +149,8 @@ private Auth(final Context context,
final AuthHandler userHandler,
final boolean advancedSecurityDataCollectionFlag,
final String identityProvider,
final String idpIdentifier) {
final String idpIdentifier,
final Bundle extraCustomBundle) {
this.context = context;
this.appWebDomain = appWebDomain;
this.appId = appId;
Expand All @@ -158,6 +165,7 @@ private Auth(final Context context,
this.advancedSecurityDataCollectionFlag = advancedSecurityDataCollectionFlag;
this.identityProvider = identityProvider;
this.idpIdentifier = idpIdentifier;
this.extraCustomBundle = extraCustomBundle;
getCurrentUser();
}

Expand Down Expand Up @@ -222,6 +230,11 @@ public static final class Builder {
*/
private String mIdpIdentifier;

/**
* Bundle of flags to customize chrome custom tab UI
*/
private Bundle mExtraCustomBundle;

/**
* Flag indicating if data collection for advanced security mode is enabled.
* By default this is enabled.
Expand Down Expand Up @@ -400,6 +413,20 @@ public Builder setIdpIdentifier(final String mIdpIdentifier) {
return this;
}

/**
* Sets customization bundle. This allow to customize chrome custom tab.
* <p>
* Optional. Set a bundle to customize UI
* </p>
* @param mExtraCustomBundle Optional: Pass to chrome custom tab a bundle of customization flags
* @return A reference to this builder.
*/
@SuppressWarnings("checkstyle:hiddenfield")
public Builder setExtraCustomBundle(final Bundle mExtraCustomBundle) {
rlatapy-luna marked this conversation as resolved.
Show resolved Hide resolved
this.mExtraCustomBundle = mExtraCustomBundle;
return this;
}

/**
* Instantiates {@link Auth} with the set options.
* @return {@link Auth}.
Expand All @@ -417,7 +444,8 @@ public Auth build() {
this.mUserHandler,
this.mAdvancedSecurityDataCollectionFlag,
this.mIdentityProvider,
this.mIdpIdentifier);
this.mIdpIdentifier,
this.mExtraCustomBundle);
}


Expand Down Expand Up @@ -559,6 +587,13 @@ public String getIdpIdentifier() {
return idpIdentifier;
}

/**
* @return Extra customization bundle for this {@link Auth} instance.
*/
public Bundle getExtraCustomBundle() {
return extraCustomBundle;
}

/**
* Use this method to get tokens for a user, the tokens are returned though the callback.
* {@link AuthHandler#onSuccess(AuthUserSession)}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,8 @@ private void launchCustomTabs(final Uri uri) {
try {
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder(mCustomTabsSession);
mCustomTabsIntent = builder.build();
if(pool.getExtraCustomBundle() != null)
mCustomTabsIntent.intent.putExtras(pool.getExtraCustomBundle());
mCustomTabsIntent.intent.setPackage(ClientConstants.CHROME_PACKAGE);
mCustomTabsIntent.intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
mCustomTabsIntent.intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Expand Down