Search in sources :

Example 1 with LayoutRes

use of androidx.annotation.LayoutRes in project FirebaseUI-Android by firebase.

the class AuthMethodPickerActivity method populateIdpList.

private void populateIdpList(List<IdpConfig> providerConfigs) {
    ViewModelProvider supplier = new ViewModelProvider(this);
    mProviders = new ArrayList<>();
    for (IdpConfig idpConfig : providerConfigs) {
        @LayoutRes int buttonLayout;
        final String providerId = idpConfig.getProviderId();
        switch(providerId) {
            case GoogleAuthProvider.PROVIDER_ID:
                buttonLayout = R.layout.fui_idp_button_google;
                break;
            case FacebookAuthProvider.PROVIDER_ID:
                buttonLayout = R.layout.fui_idp_button_facebook;
                break;
            case EMAIL_LINK_PROVIDER:
            case EmailAuthProvider.PROVIDER_ID:
                buttonLayout = R.layout.fui_provider_button_email;
                break;
            case PhoneAuthProvider.PROVIDER_ID:
                buttonLayout = R.layout.fui_provider_button_phone;
                break;
            case AuthUI.ANONYMOUS_PROVIDER:
                buttonLayout = R.layout.fui_provider_button_anonymous;
                break;
            default:
                if (!TextUtils.isEmpty(idpConfig.getParams().getString(GENERIC_OAUTH_PROVIDER_ID))) {
                    buttonLayout = idpConfig.getParams().getInt(GENERIC_OAUTH_BUTTON_ID);
                    break;
                }
                throw new IllegalStateException("Unknown provider: " + providerId);
        }
        View loginButton = getLayoutInflater().inflate(buttonLayout, mProviderHolder, false);
        handleSignInOperation(idpConfig, loginButton);
        mProviderHolder.addView(loginButton);
    }
}
Also used : IdpConfig(com.firebase.ui.auth.AuthUI.IdpConfig) LayoutRes(androidx.annotation.LayoutRes) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) ViewModelProvider(androidx.lifecycle.ViewModelProvider)

Example 2 with LayoutRes

use of androidx.annotation.LayoutRes in project Signal-Android by signalapp.

the class ConversationItemFooter method init.

private void init(@Nullable AttributeSet attrs) {
    final TypedArray typedArray;
    if (attrs != null) {
        typedArray = getContext().getTheme().obtainStyledAttributes(attrs, R.styleable.ConversationItemFooter, 0, 0);
    } else {
        typedArray = null;
    }
    @LayoutRes final int contentId;
    if (typedArray != null) {
        int mode = typedArray.getInt(R.styleable.ConversationItemFooter_footer_mode, 0);
        isOutgoing = mode == 0;
        if (isOutgoing) {
            contentId = R.layout.conversation_item_footer_outgoing;
        } else {
            contentId = R.layout.conversation_item_footer_incoming;
        }
    } else {
        contentId = R.layout.conversation_item_footer_outgoing;
        isOutgoing = true;
    }
    inflate(getContext(), contentId, this);
    dateView = findViewById(R.id.footer_date);
    simView = findViewById(R.id.footer_sim_info);
    timerView = findViewById(R.id.footer_expiration_timer);
    insecureIndicatorView = findViewById(R.id.footer_insecure_indicator);
    deliveryStatusView = findViewById(R.id.footer_delivery_status);
    audioDuration = findViewById(R.id.footer_audio_duration);
    revealDot = findViewById(R.id.footer_revealed_dot);
    playbackSpeedToggleTextView = findViewById(R.id.footer_audio_playback_speed_toggle);
    if (typedArray != null) {
        setTextColor(typedArray.getInt(R.styleable.ConversationItemFooter_footer_text_color, getResources().getColor(R.color.core_white)));
        setIconColor(typedArray.getInt(R.styleable.ConversationItemFooter_footer_icon_color, getResources().getColor(R.color.core_white)));
        setRevealDotColor(typedArray.getInt(R.styleable.ConversationItemFooter_footer_reveal_dot_color, getResources().getColor(R.color.core_white)));
        typedArray.recycle();
    }
    dateView.addOnLayoutChangeListener((v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> {
        if (oldLeft != left || oldRight != right) {
            notifyTouchDelegateChanged(getPlaybackSpeedToggleTouchDelegateRect(), playbackSpeedToggleTextView);
        }
    });
}
Also used : LayoutRes(androidx.annotation.LayoutRes) TypedArray(android.content.res.TypedArray) SuppressLint(android.annotation.SuppressLint)

Example 3 with LayoutRes

use of androidx.annotation.LayoutRes in project Signal-Android by WhisperSystems.

the class ConversationItemFooter method init.

private void init(@Nullable AttributeSet attrs) {
    final TypedArray typedArray;
    if (attrs != null) {
        typedArray = getContext().getTheme().obtainStyledAttributes(attrs, R.styleable.ConversationItemFooter, 0, 0);
    } else {
        typedArray = null;
    }
    @LayoutRes final int contentId;
    if (typedArray != null) {
        int mode = typedArray.getInt(R.styleable.ConversationItemFooter_footer_mode, 0);
        isOutgoing = mode == 0;
        if (isOutgoing) {
            contentId = R.layout.conversation_item_footer_outgoing;
        } else {
            contentId = R.layout.conversation_item_footer_incoming;
        }
    } else {
        contentId = R.layout.conversation_item_footer_outgoing;
        isOutgoing = true;
    }
    inflate(getContext(), contentId, this);
    dateView = findViewById(R.id.footer_date);
    simView = findViewById(R.id.footer_sim_info);
    timerView = findViewById(R.id.footer_expiration_timer);
    insecureIndicatorView = findViewById(R.id.footer_insecure_indicator);
    deliveryStatusView = findViewById(R.id.footer_delivery_status);
    audioDuration = findViewById(R.id.footer_audio_duration);
    revealDot = findViewById(R.id.footer_revealed_dot);
    playbackSpeedToggleTextView = findViewById(R.id.footer_audio_playback_speed_toggle);
    if (typedArray != null) {
        setTextColor(typedArray.getInt(R.styleable.ConversationItemFooter_footer_text_color, getResources().getColor(R.color.core_white)));
        setIconColor(typedArray.getInt(R.styleable.ConversationItemFooter_footer_icon_color, getResources().getColor(R.color.core_white)));
        setRevealDotColor(typedArray.getInt(R.styleable.ConversationItemFooter_footer_reveal_dot_color, getResources().getColor(R.color.core_white)));
        typedArray.recycle();
    }
    dateView.addOnLayoutChangeListener((v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> {
        if (oldLeft != left || oldRight != right) {
            notifyTouchDelegateChanged(getPlaybackSpeedToggleTouchDelegateRect(), playbackSpeedToggleTextView);
        }
    });
}
Also used : LayoutRes(androidx.annotation.LayoutRes) TypedArray(android.content.res.TypedArray) SuppressLint(android.annotation.SuppressLint)

Aggregations

LayoutRes (androidx.annotation.LayoutRes)3 SuppressLint (android.annotation.SuppressLint)2 TypedArray (android.content.res.TypedArray)2 View (android.view.View)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 ViewModelProvider (androidx.lifecycle.ViewModelProvider)1 IdpConfig (com.firebase.ui.auth.AuthUI.IdpConfig)1