Search in sources :

Example 16 with ConstraintSet

use of androidx.constraintlayout.widget.ConstraintSet 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();
            }
        }
    });
}
Also used : ConstraintSet(androidx.constraintlayout.widget.ConstraintSet) FirebaseAuthAnonymousUpgradeException(com.firebase.ui.auth.FirebaseAuthAnonymousUpgradeException) UserCancellationException(com.firebase.ui.auth.data.model.UserCancellationException) FirebaseUiException(com.firebase.ui.auth.FirebaseUiException) FirebaseAuthAnonymousUpgradeException(com.firebase.ui.auth.FirebaseAuthAnonymousUpgradeException) ConstraintLayout(androidx.constraintlayout.widget.ConstraintLayout) FlowParameters(com.firebase.ui.auth.data.model.FlowParameters) SocialProviderResponseHandler(com.firebase.ui.auth.viewmodel.idp.SocialProviderResponseHandler) UserCancellationException(com.firebase.ui.auth.data.model.UserCancellationException) TextView(android.widget.TextView) ImageView(android.widget.ImageView) FirebaseUiException(com.firebase.ui.auth.FirebaseUiException) ViewModelProvider(androidx.lifecycle.ViewModelProvider) IdpResponse(com.firebase.ui.auth.IdpResponse)

Example 17 with ConstraintSet

use of androidx.constraintlayout.widget.ConstraintSet in project Signal-Android by signalapp.

the class CreatePaymentFragment method initializeConstraintSets.

private void initializeConstraintSets() {
    cryptoConstraintSet = new ConstraintSet();
    cryptoConstraintSet.clone(constraintLayout);
    fiatConstraintSet = new ConstraintSet();
    fiatConstraintSet.clone(getContext(), R.layout.create_payment_fragment_amount_toggle);
}
Also used : ConstraintSet(androidx.constraintlayout.widget.ConstraintSet)

Example 18 with ConstraintSet

use of androidx.constraintlayout.widget.ConstraintSet in project Signal-Android by signalapp.

the class WebRtcCallView method layoutParticipants.

private void layoutParticipants() {
    Transition transition = new AutoTransition().setDuration(TRANSITION_DURATION_MILLIS);
    TransitionManager.beginDelayedTransition(participantsParent, transition);
    ConstraintSet constraintSet = new ConstraintSet();
    constraintSet.clone(participantsParent);
    constraintSet.setMargin(R.id.call_screen_participants_pager, ConstraintSet.BOTTOM, ViewUtil.dpToPx(withControlsHeight(pagerBottomMarginDp)));
    constraintSet.applyTo(participantsParent);
}
Also used : AutoTransition(androidx.transition.AutoTransition) Transition(androidx.transition.Transition) AutoTransition(androidx.transition.AutoTransition) ConstraintSet(androidx.constraintlayout.widget.ConstraintSet)

Example 19 with ConstraintSet

use of androidx.constraintlayout.widget.ConstraintSet in project Signal-Android by signalapp.

the class ConversationReactionOverlay method setupSelectedEmoji.

private void setupSelectedEmoji() {
    final List<String> emojis = SignalStore.emojiValues().getReactions();
    final String oldEmoji = getOldEmoji(messageRecord);
    if (oldEmoji == null) {
        selectedView.setVisibility(View.GONE);
    }
    boolean foundSelected = false;
    for (int i = 0; i < emojiViews.length; i++) {
        final EmojiImageView view = emojiViews[i];
        view.setScaleX(1.0f);
        view.setScaleY(1.0f);
        view.setTranslationY(0);
        boolean isAtCustomIndex = i == customEmojiIndex;
        boolean isNotAtCustomIndexAndOldEmojiMatches = !isAtCustomIndex && oldEmoji != null && emojis.get(i).equals(EmojiUtil.getCanonicalRepresentation(oldEmoji));
        boolean isAtCustomIndexAndOldEmojiExists = isAtCustomIndex && oldEmoji != null;
        if (!foundSelected && (isNotAtCustomIndexAndOldEmojiMatches || isAtCustomIndexAndOldEmojiExists)) {
            foundSelected = true;
            selectedView.setVisibility(View.VISIBLE);
            ConstraintSet constraintSet = new ConstraintSet();
            constraintSet.clone(foregroundView);
            constraintSet.clear(selectedView.getId(), ConstraintSet.LEFT);
            constraintSet.clear(selectedView.getId(), ConstraintSet.RIGHT);
            constraintSet.connect(selectedView.getId(), ConstraintSet.LEFT, view.getId(), ConstraintSet.LEFT);
            constraintSet.connect(selectedView.getId(), ConstraintSet.RIGHT, view.getId(), ConstraintSet.RIGHT);
            constraintSet.applyTo(foregroundView);
            if (isAtCustomIndex) {
                view.setImageEmoji(oldEmoji);
                view.setTag(oldEmoji);
            } else {
                view.setImageEmoji(SignalStore.emojiValues().getPreferredVariation(emojis.get(i)));
            }
        } else if (isAtCustomIndex) {
            view.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.ic_any_emoji_32));
            view.setTag(null);
        } else {
            view.setImageEmoji(SignalStore.emojiValues().getPreferredVariation(emojis.get(i)));
        }
    }
}
Also used : ConstraintSet(androidx.constraintlayout.widget.ConstraintSet) EmojiImageView(org.thoughtcrime.securesms.components.emoji.EmojiImageView)

Aggregations

ConstraintSet (androidx.constraintlayout.widget.ConstraintSet)19 AutoTransition (androidx.transition.AutoTransition)10 Transition (androidx.transition.Transition)8 ImageView (android.widget.ImageView)7 TextView (android.widget.TextView)7 View (android.view.View)6 RecyclerView (androidx.recyclerview.widget.RecyclerView)6 AvatarImageView (org.thoughtcrime.securesms.components.AvatarImageView)6 Animator (android.animation.Animator)4 AnimationCompleteListener (org.thoughtcrime.securesms.animation.AnimationCompleteListener)4 ConstraintLayout (androidx.constraintlayout.widget.ConstraintLayout)3 Context (android.content.Context)2 ColorMatrix (android.graphics.ColorMatrix)2 ColorMatrixColorFilter (android.graphics.ColorMatrixColorFilter)2 Point (android.graphics.Point)2 Rect (android.graphics.Rect)2 AttributeSet (android.util.AttributeSet)2 ViewGroup (android.view.ViewGroup)2 Animation (android.view.animation.Animation)2 FrameLayout (android.widget.FrameLayout)2