use of com.firebase.ui.auth.data.model.FlowParameters in project FirebaseUI-Android by firebase.
the class CheckEmailFragment method onViewCreated.
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
mNextButton = view.findViewById(R.id.button_next);
mProgressBar = view.findViewById(R.id.top_progress_bar);
// Email field and validator
mEmailLayout = view.findViewById(R.id.email_layout);
mEmailEditText = view.findViewById(R.id.email);
mEmailFieldValidator = new EmailFieldValidator(mEmailLayout);
mEmailLayout.setOnClickListener(this);
mEmailEditText.setOnClickListener(this);
// Hide header
TextView headerText = view.findViewById(R.id.header_text);
if (headerText != null) {
headerText.setVisibility(View.GONE);
}
ImeHelper.setImeOnDoneListener(mEmailEditText, this);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && getFlowParams().enableHints) {
mEmailEditText.setImportantForAutofill(View.IMPORTANT_FOR_AUTOFILL_NO);
}
mNextButton.setOnClickListener(this);
TextView termsText = view.findViewById(R.id.email_tos_and_pp_text);
TextView footerText = view.findViewById(R.id.email_footer_tos_and_pp_text);
FlowParameters flowParameters = getFlowParams();
if (!flowParameters.shouldShowProviderChoice()) {
PrivacyDisclosureUtils.setupTermsOfServiceAndPrivacyPolicyText(requireContext(), flowParameters, termsText);
} else {
termsText.setVisibility(View.GONE);
PrivacyDisclosureUtils.setupTermsOfServiceFooter(requireContext(), flowParameters, footerText);
}
}
use of com.firebase.ui.auth.data.model.FlowParameters in project FirebaseUI-Android by firebase.
the class AuthMethodPickerActivity method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FlowParameters params = getFlowParams();
customLayout = params.authMethodPickerLayout;
mHandler = new ViewModelProvider(this).get(SocialProviderResponseHandler.class);
mHandler.init(params);
mProviders = new ArrayList<>();
if (customLayout != null) {
setContentView(customLayout.getMainLayout());
// Setup using custom layout
populateIdpListCustomLayout(params.providers);
} else {
setContentView(R.layout.fui_auth_method_picker_layout);
// UI only with default layout
mProgressBar = findViewById(R.id.top_progress_bar);
mProviderHolder = findViewById(R.id.btn_holder);
populateIdpList(params.providers);
int logoId = params.logoId;
if (logoId == AuthUI.NO_LOGO) {
findViewById(R.id.logo).setVisibility(View.GONE);
ConstraintLayout layout = findViewById(R.id.root);
ConstraintSet constraints = new ConstraintSet();
constraints.clone(layout);
constraints.setHorizontalBias(R.id.container, 0.5f);
constraints.setVerticalBias(R.id.container, 0.5f);
constraints.applyTo(layout);
} else {
ImageView logo = findViewById(R.id.logo);
logo.setImageResource(logoId);
}
}
boolean tosAndPpConfigured = getFlowParams().isPrivacyPolicyUrlProvided() && getFlowParams().isTermsOfServiceUrlProvided();
int termsTextId = customLayout == null ? R.id.main_tos_and_pp : customLayout.getTosPpView();
if (termsTextId >= 0) {
TextView termsText = findViewById(termsTextId);
// No ToS or PP provided, so we should hide the view entirely
if (!tosAndPpConfigured) {
termsText.setVisibility(View.GONE);
} else {
PrivacyDisclosureUtils.setupTermsOfServiceAndPrivacyPolicyText(this, getFlowParams(), termsText);
}
}
// Handler for both
mHandler.getOperation().observe(this, new ResourceObserver<IdpResponse>(this, R.string.fui_progress_dialog_signing_in) {
@Override
protected void onSuccess(@NonNull IdpResponse response) {
startSaveCredentials(mHandler.getCurrentUser(), response, null);
}
@Override
protected void onFailure(@NonNull Exception e) {
if (e instanceof UserCancellationException) {
// User pressed back, there is no error.
return;
}
if (e instanceof FirebaseAuthAnonymousUpgradeException) {
finish(ErrorCodes.ANONYMOUS_UPGRADE_MERGE_CONFLICT, ((FirebaseAuthAnonymousUpgradeException) e).getResponse().toIntent());
} else if (e instanceof FirebaseUiException) {
FirebaseUiException fue = (FirebaseUiException) e;
finish(RESULT_CANCELED, IdpResponse.from(fue).toIntent());
} else {
String text = getString(R.string.fui_error_unknown);
Toast.makeText(AuthMethodPickerActivity.this, text, Toast.LENGTH_SHORT).show();
}
}
});
}
use of com.firebase.ui.auth.data.model.FlowParameters in project FirebaseUI-Android by firebase.
the class GenericIdpAnonymousUpgradeLinkingHandler method startSignIn.
@Override
public void startSignIn(@NonNull FirebaseAuth auth, @NonNull HelperActivityBase activity, @NonNull String providerId) {
setResult(Resource.forLoading());
FlowParameters flowParameters = activity.getFlowParams();
OAuthProvider provider = buildOAuthProvider(providerId, auth);
if (flowParameters != null && AuthOperationManager.getInstance().canUpgradeAnonymous(auth, flowParameters)) {
handleAnonymousUpgradeLinkingFlow(activity, provider, flowParameters);
return;
}
handleNormalSignInFlow(auth, activity, provider);
}
use of com.firebase.ui.auth.data.model.FlowParameters in project FirebaseUI-Android by firebase.
the class LinkingSocialProviderResponseHandlerTest method setUp.
@Before
public void setUp() {
TestHelper.initialize();
MockitoAnnotations.initMocks(this);
mHandler = new LinkingSocialProviderResponseHandler((Application) ApplicationProvider.getApplicationContext());
FlowParameters testParams = TestHelper.getFlowParameters(Collections.singletonList(GoogleAuthProvider.PROVIDER_ID));
mHandler.initializeForTesting(testParams, mMockAuth, null);
}
use of com.firebase.ui.auth.data.model.FlowParameters in project FirebaseUI-Android by firebase.
the class SocialProviderResponseHandlerTest method setupAnonymousUpgrade.
private void setupAnonymousUpgrade() {
// enableAnonymousUpgrade must be set to true
FlowParameters testParams = TestHelper.getFlowParameters(AuthUI.SUPPORTED_PROVIDERS, /* enableAnonymousUpgrade */
true);
mHandler.initializeForTesting(testParams, mMockAuth, null);
when(mUser.isAnonymous()).thenReturn(true);
when(mMockAuth.getCurrentUser()).thenReturn(mUser);
}
Aggregations