List of usage examples for android.content.res ColorStateList valueOf
@NonNull public static ColorStateList valueOf(@ColorInt int color)
From source file:com.agenmate.lollipop.util.ViewUtils.java
public static RippleDrawable createRipple(@NonNull Palette palette, @FloatRange(from = 0f, to = 1f) float darkAlpha, @FloatRange(from = 0f, to = 1f) float lightAlpha, @ColorInt int fallbackColor, boolean bounded) { int rippleColor = fallbackColor; if (palette != null) { // try the named swatches in preference order if (palette.getVibrantSwatch() != null) { rippleColor = ColorUtils.modifyAlpha(palette.getVibrantSwatch().getRgb(), darkAlpha); } else if (palette.getLightVibrantSwatch() != null) { rippleColor = ColorUtils.modifyAlpha(palette.getLightVibrantSwatch().getRgb(), lightAlpha); } else if (palette.getDarkVibrantSwatch() != null) { rippleColor = ColorUtils.modifyAlpha(palette.getDarkVibrantSwatch().getRgb(), darkAlpha); } else if (palette.getMutedSwatch() != null) { rippleColor = ColorUtils.modifyAlpha(palette.getMutedSwatch().getRgb(), darkAlpha); } else if (palette.getLightMutedSwatch() != null) { rippleColor = ColorUtils.modifyAlpha(palette.getLightMutedSwatch().getRgb(), lightAlpha); } else if (palette.getDarkMutedSwatch() != null) { rippleColor = ColorUtils.modifyAlpha(palette.getDarkMutedSwatch().getRgb(), darkAlpha); }//from w ww .j av a 2s . c o m } return new RippleDrawable(ColorStateList.valueOf(rippleColor), null, bounded ? new ColorDrawable(Color.WHITE) : null); }
From source file:com.agna.setmaster.ui.screen.profile.setting.change.ChangeVolumeSettingDialog.java
private void initViews() { settingIcon.setImageResource(SettingViewUtil.getSettingImage(setting.getClass())); settingIcon.setColorFilter(accentColor); deleteBtn.setColorFilter(ContextCompat.getColor(getActivity(), R.color.light_gray)); settingName.setText(SettingViewUtil.getSettingName(setting.getClass())); settingValue.setProgress((int) (setting.getValue() * 100)); settingValue.getProgressDrawable().setColorFilter(accentColor, PorterDuff.Mode.SRC_IN); settingValue.getThumb().setColorFilter(accentColor, PorterDuff.Mode.SRC_IN); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { settingValue.setThumbTintList(ColorStateList.valueOf(accentColor)); }/*from w ww. ja v a2 s. c om*/ }
From source file:net.mm2d.dmsexplorer.CdsDetailFragment.java
private void setupFloatingActionButton(View rootView, final CdsObject object) { FloatingActionButton fab = (FloatingActionButton) rootView.findViewById(R.id.fab); if (fab == null) { fab = (FloatingActionButton) getActivity().findViewById(R.id.fab); }//www . j a v a 2 s . c o m if (fab == null) { return; } fab.setVisibility(hasResource(object) ? View.VISIBLE : View.GONE); final boolean protectedResource = hasProtectedResource(object); final int color = protectedResource ? Color.GRAY : ContextCompat.getColor(getContext(), R.color.accent); fab.setBackgroundTintList(ColorStateList.valueOf(color)); fab.setOnClickListener(view -> { if (protectedResource) { Snackbar.make(view, R.string.toast_not_support_drm, Snackbar.LENGTH_LONG).show(); } else { final SelectResourceDialog dialog = SelectResourceDialog.newInstance(object); dialog.show(getActivity().getFragmentManager(), ""); } }); }
From source file:org.getlantern.firetweet.view.HomeActionButton.java
@Override public void setIconColor(int color, Mode mode) { mIconView.setColorFilter(color, mode); mProgressBar.setIndeterminateTintList(ColorStateList.valueOf(color)); }
From source file:jp.tkgktyk.xposed.forcetouchdetector.app.util.fab.LocalFloatingActionButton.java
public LocalFloatingActionButton(Context context, AttributeSet attrs, int defStyleAttr, boolean bigContent) { super(context, attrs, defStyleAttr); mShadowPadding = new Rect(); // TypedArray a = context.obtainStyledAttributes(attrs, // R.styleable.FloatingActionButton, defStyleAttr, // R.style.Widget_Design_FloatingActionButton); Drawable background = getResources().getDrawable(R.drawable.design_fab_background); // a.getDrawable(R.styleable.FloatingActionButton_android_background); mBackgroundTint = ColorStateList.valueOf(Color.BLACK); // a.getColorStateList(R.styleable.FloatingActionButton_backgroundTint); mBackgroundTintMode = parseTintMode(-1, null); // parseTintMode(a.getInt( // R.styleable.FloatingActionButton_backgroundTintMode, -1), null); mRippleColor = 0;//from w w w .j a v a2s . com // a.getColor(R.styleable.FloatingActionButton_rippleColor, 0); mSize = SIZE_NORMAL; // a.getInt(R.styleable.FloatingActionButton_fabSize, SIZE_NORMAL); mBorderWidth = getResources().getDimensionPixelSize(R.dimen.design_fab_border_width); // a.getDimensionPixelSize(R.styleable.FloatingActionButton_borderWidth, 0); final float elevation = getResources().getDimensionPixelSize(R.dimen.design_fab_elevation); // a.getDimension(R.styleable.FloatingActionButton_elevation, 0f); final float pressedTranslationZ = getResources() .getDimensionPixelSize(R.dimen.design_fab_translation_z_pressed); // a.getDimension( // R.styleable.FloatingActionButton_pressedTranslationZ, 0f); // a.recycle(); final ShadowViewDelegate delegate = new ShadowViewDelegate() { @Override public float getRadius() { return getSizeDimension() / 2f; } @Override public void setShadowPadding(int left, int top, int right, int bottom) { mShadowPadding.set(left, top, right, bottom); setPadding(left + mContentPadding, top + mContentPadding, right + mContentPadding, bottom + mContentPadding); } @Override public void setBackgroundDrawable(Drawable background) { LocalFloatingActionButton.super.setBackgroundDrawable(background); } }; final int sdk = Build.VERSION.SDK_INT; if (sdk >= 21) { mImpl = new FloatingActionButtonLollipop(this, delegate); } else if (sdk >= 12) { mImpl = new FloatingActionButtonHoneycombMr1(this, delegate); } else { mImpl = new FloatingActionButtonEclairMr1(this, delegate); } final int maxContentSize = (int) getResources() .getDimension(bigContent ? R.dimen.local_fab_content_size : R.dimen.design_fab_image_size); mContentPadding = (getSizeDimension() - maxContentSize) / 2; mImpl.setBackgroundDrawable(background, mBackgroundTint, mBackgroundTintMode, mRippleColor, mBorderWidth); mImpl.setElevation(elevation); mImpl.setPressedTranslationZ(pressedTranslationZ); setClickable(true); }
From source file:ua.boberproduction.bbr.feedback.FeedbackFragment.java
private void activateSendButton() { sendButton.setEnabled(true); sendButton.setBackgroundTintList( ColorStateList.valueOf(ContextCompat.getColor(getActivity(), R.color.colorPrimary))); }
From source file:com.joaquimley.faboptions.FabOptions.java
private void styleComponent(Context context, TypedArray attributes) { // If not set, the background same colour as the FAB, which if not set // it will use the default accent color int fabColor = attributes.getColor(R.styleable.FabOptions_fab_color, getThemeAccentColor(context)); int backgroundColor = attributes.getColor(R.styleable.FabOptions_background_color, fabColor); setBackgroundColor(context, backgroundColor); mFab.setBackgroundTintList(ColorStateList.valueOf(fabColor)); }
From source file:com.handmark.pulltorefresh.library.internal.LoadingLayout.java
public LoadingLayout(final Context context, final Mode mode, final TypedArray attrs) { super(context); final ViewGroup header = (ViewGroup) LayoutInflater.from(context).inflate(R.layout.pull_to_refresh_header, this); mMode = mode;/* ww w . j av a 2 s .co m*/ mHeaderText = (TextView) header.findViewById(R.id.pull_to_refresh_text); mSubHeaderText = (TextView) header.findViewById(R.id.pull_to_refresh_sub_text); mHeaderProgress = (ProgressBar) header.findViewById(R.id.pull_to_refresh_progress); mHeaderArrow = (ImageView) header.findViewById(R.id.pull_to_refresh_arrow); mRotateAnimation = AnimationUtils.loadAnimation(getContext(), R.anim.pull_to_refresh_rotate); audioManager = (AudioManager) context.getSystemService(Activity.AUDIO_SERVICE); mPreferences = context.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE); mContext = context; switch (mode) { case PULL_UP_TO_REFRESH: // Load in labels mPullLabel = context.getString(R.string.pull_to_refresh_from_bottom_pull_label); mRefreshingLabel = context.getString(R.string.pull_to_refresh_from_bottom_refreshing_label); mReleaseLabel = context.getString(R.string.pull_to_refresh_from_bottom_release_label); rotateArrow(); break; case PULL_DOWN_TO_REFRESH: default: // Load in labels mPullLabel = context.getString(R.string.pull_to_refresh_pull_label); mRefreshingLabel = context.getString(R.string.pull_to_refresh_refreshing_label); mReleaseLabel = context.getString(R.string.pull_to_refresh_release_label); break; } if (attrs.hasValue(R.styleable.PullToRefresh_ptrHeaderTextColor)) { final ColorStateList colors = attrs.getColorStateList(R.styleable.PullToRefresh_ptrHeaderTextColor); setTextColor(null != colors ? colors : ColorStateList.valueOf(0xFF000000)); } if (attrs.hasValue(R.styleable.PullToRefresh_ptrHeaderSubTextColor)) { final ColorStateList colors = attrs.getColorStateList(R.styleable.PullToRefresh_ptrHeaderSubTextColor); setSubTextColor(null != colors ? colors : ColorStateList.valueOf(0xFF000000)); } if (attrs.hasValue(R.styleable.PullToRefresh_ptrHeaderBackground)) { final Drawable background = attrs.getDrawable(R.styleable.PullToRefresh_ptrHeaderBackground); if (null != background) { setBackgroundDrawable(background); } } reset(); }
From source file:ua.boberproduction.bbr.feedback.FeedbackFragment.java
private void disableSendButton() { sendButton.setEnabled(false); sendButton.setBackgroundTintList( ColorStateList.valueOf(ContextCompat.getColor(getActivity(), R.color.save_btn_disabled))); }
From source file:com.gammalabs.wifianalyzer.wifi.ChannelRatingAdapter.java
@NonNull @Override/*from w w w . jav a 2s . c o m*/ public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) { View view = convertView; if (view == null) { LayoutInflater layoutInflater = MainContext.INSTANCE.getMainActivity().getLayoutInflater(); view = layoutInflater.inflate(R.layout.channel_rating_details, parent, false); } WiFiChannel wiFiChannel = getItem(position); if (wiFiChannel == null) { return view; } ((TextView) view.findViewById(R.id.channelNumber)) .setText(String.format(Locale.ENGLISH, "%d", wiFiChannel.getChannel())); ((TextView) view.findViewById(R.id.accessPointCount)) .setText(String.format(Locale.ENGLISH, "%d", channelRating.getCount(wiFiChannel))); Strength strength = Strength.reverse(channelRating.getStrength(wiFiChannel)); RatingBar ratingBar = (RatingBar) view.findViewById(R.id.channelRating); int size = Strength.values().length; ratingBar.setMax(size); ratingBar.setNumStars(size); ratingBar.setRating(strength.ordinal() + 1); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { ratingBar.getProgressDrawable().setColorFilter( ContextCompat.getColor(getContext(), R.color.success_color), PorterDuff.Mode.SRC_ATOP); } else { ratingBar.setProgressTintList( ColorStateList.valueOf(ContextCompat.getColor(getContext(), strength.colorResource()))); } return view; }