public AppCompatImageButton(Context context, AttributeSet attributeSet, int i) { super(context, attributeSet, i); TintManager a = TintManager.m3737a(context); this.f1351a = new AppCompatBackgroundHelper(this, a); this.f1351a.m2774a(attributeSet, i); this.f1352b = new AppCompatImageHelper(this, a); this.f1352b.m2787a(attributeSet, i); }
public AppCompatEditText(Context context, AttributeSet attrs, int defStyleAttr) { super(TintContextWrapper.wrap(context), attrs, defStyleAttr); this.mTintManager = TintManager.get(getContext()); this.mBackgroundTintHelper = new AppCompatBackgroundHelper(this, this.mTintManager); this.mBackgroundTintHelper.loadFromAttributes(attrs, defStyleAttr); this.mTextHelper = AppCompatTextHelper.create(this); this.mTextHelper.loadFromAttributes(attrs, defStyleAttr); this.mTextHelper.applyCompoundDrawablesTints(); }
void setImageResource(int i) { if (i != 0) { ImageView imageview = mView; android.graphics.drawable.Drawable drawable; if (mTintManager != null) { drawable = mTintManager.getDrawable(i); } else { drawable = ContextCompat.getDrawable(mView.getContext(), i); } imageview.setImageDrawable(drawable); return; } else { mView.setImageDrawable(null); return; } }
@Override public void setImageResource(@DrawableRes int resId) { // Intercept this call and instead retrieve the Drawable via the tint manager setImageDrawable(mTintManager.getDrawable(resId)); }
public ToolbarWidgetWrapper( Toolbar toolbar, boolean style, int defaultNavigationContentDescription, int defaultNavigationIcon) { mToolbar = toolbar; mTitle = toolbar.getTitle(); mSubtitle = toolbar.getSubtitle(); mTitleSet = mTitle != null; mNavIcon = toolbar.getNavigationIcon(); if (style) { final TintTypedArray a = TintTypedArray.obtainStyledAttributes( toolbar.getContext(), null, R.styleable.ActionBar, R.attr.actionBarStyle, 0); final CharSequence title = a.getText(R.styleable.ActionBar_title); if (!TextUtils.isEmpty(title)) { setTitle(title); } final CharSequence subtitle = a.getText(R.styleable.ActionBar_subtitle); if (!TextUtils.isEmpty(subtitle)) { setSubtitle(subtitle); } final Drawable logo = a.getDrawable(R.styleable.ActionBar_logo); if (logo != null) { setLogo(logo); } final Drawable icon = a.getDrawable(R.styleable.ActionBar_icon); if (mNavIcon == null && icon != null) { setIcon(icon); } final Drawable navIcon = a.getDrawable(R.styleable.ActionBar_homeAsUpIndicator); if (navIcon != null) { setNavigationIcon(navIcon); } setDisplayOptions(a.getInt(R.styleable.ActionBar_displayOptions, 0)); final int customNavId = a.getResourceId(R.styleable.ActionBar_customNavigationLayout, 0); if (customNavId != 0) { setCustomView( LayoutInflater.from(mToolbar.getContext()).inflate(customNavId, mToolbar, false)); setDisplayOptions(mDisplayOpts | ActionBar.DISPLAY_SHOW_CUSTOM); } final int height = a.getLayoutDimension(R.styleable.ActionBar_height, 0); if (height > 0) { final ViewGroup.LayoutParams lp = mToolbar.getLayoutParams(); lp.height = height; mToolbar.setLayoutParams(lp); } final int contentInsetStart = a.getDimensionPixelOffset(R.styleable.ActionBar_contentInsetStart, -1); final int contentInsetEnd = a.getDimensionPixelOffset(R.styleable.ActionBar_contentInsetEnd, -1); if (contentInsetStart >= 0 || contentInsetEnd >= 0) { mToolbar.setContentInsetsRelative( Math.max(contentInsetStart, 0), Math.max(contentInsetEnd, 0)); } final int titleTextStyle = a.getResourceId(R.styleable.ActionBar_titleTextStyle, 0); if (titleTextStyle != 0) { mToolbar.setTitleTextAppearance(mToolbar.getContext(), titleTextStyle); } final int subtitleTextStyle = a.getResourceId(R.styleable.ActionBar_subtitleTextStyle, 0); if (subtitleTextStyle != 0) { mToolbar.setSubtitleTextAppearance(mToolbar.getContext(), subtitleTextStyle); } final int popupTheme = a.getResourceId(R.styleable.ActionBar_popupTheme, 0); if (popupTheme != 0) { mToolbar.setPopupTheme(popupTheme); } a.recycle(); // Keep the TintManager in case we need it later mTintManager = a.getTintManager(); } else { mDisplayOpts = detectDisplayOptions(); // Create a TintManager in case we need it later mTintManager = new TintManager(toolbar.getContext()); } setDefaultNavigationContentDescription(defaultNavigationContentDescription); mHomeDescription = mToolbar.getNavigationContentDescription(); setDefaultNavigationIcon(mTintManager.getDrawable(defaultNavigationIcon)); mToolbar.setNavigationOnClickListener( new View.OnClickListener() { final ActionMenuItem mNavItem = new ActionMenuItem(mToolbar.getContext(), 0, android.R.id.home, 0, 0, mTitle); @Override public void onClick(View v) { if (mWindowCallback != null && mMenuPrepared) { mWindowCallback.onMenuItemSelected(Window.FEATURE_OPTIONS_PANEL, mNavItem); } } }); }
@Override public void setNavigationIcon(int resId) { setNavigationIcon(resId != 0 ? mTintManager.getDrawable(resId) : null); }
@Override public void setLogo(int resId) { setLogo(resId != 0 ? mTintManager.getDrawable(resId) : null); }
@Override public void setButtonDrawable(int resid) { setButtonDrawable(mTintManager.getDrawable(resid)); }
@Override public Resources getResources() { return mTintManager.getResources(); }