List of usage examples for android.graphics.drawable Drawable setColorFilter
public abstract void setColorFilter(@Nullable ColorFilter colorFilter);
From source file:com.hctrom.romcontrol.licenseadapter.LicenseDialogoAlerta.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ThemeSelectorUtility theme = new ThemeSelectorUtility(getActivity()); theme.onActivityCreateSetTheme(getActivity()); final View view = inflater.inflate(R.layout.license_app, container, false); titulo = (TextView) view.findViewById(R.id.textViewTitulo); licenses = (Button) view.findViewById(R.id.imageButtonCompartir); buttonBack = (ActionButton) view.findViewById(R.id.boton_flotante_back); email = (ImageView) view.findViewById(R.id.mail); apache = (TextView) view.findViewById(R.id.textViewApache); Linkify.addLinks(apache, Linkify.WEB_URLS); applyBlurMaskFilter(titulo, BlurMaskFilter.Blur.OUTER); getDialog().setCanceledOnTouchOutside(false); licenses.setOnClickListener(this); buttonBack.setOnClickListener(new View.OnClickListener() { @Override/*from w w w . j a va 2 s . co m*/ public void onClick(View v) { getDialog().cancel(); } }); email.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: { Drawable mDrawable = getActivity().getResources().getDrawable(R.drawable.mail); mDrawable.setColorFilter(new PorterDuffColorFilter( getActivity().getResources().getColor(R.color.selector), PorterDuff.Mode.MULTIPLY)); email.setAnimation(AnimationUtils.loadAnimation(getActivity(), R.anim.fab_close)); email.invalidate(); break; } case MotionEvent.ACTION_UP: { Drawable mDrawable = getActivity().getResources().getDrawable(R.drawable.mail); mDrawable.setColorFilter(new PorterDuffColorFilter( getActivity().getResources().getColor(R.color.selector), PorterDuff.Mode.MULTIPLY)); email.setAnimation(AnimationUtils.loadAnimation(getActivity(), R.anim.fab_open)); email.invalidate(); break; } } return false; } }); email.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { startActivity(new Intent(getActivity(), Mail.class)); } }); return view; }
From source file:com.xnote.lol.xnote.views.SlidingTabLayout.java
public SlidingTabLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); // determining width of screen to set padding to the tabs so they take the entire screen: WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Point size = new Point(); display.getSize(size);// w w w. j a v a2s .c om mScreenHorizontalWidth = size.x; // Disable the Scroll Bar setHorizontalScrollBarEnabled(false); // Make sure that the Tab Strips fills this View setFillViewport(true); mTitleOffset = (int) (TITLE_OFFSET_DIPS * getResources().getDisplayMetrics().density); mTabStrip = new SlidingTabStrip(context); addView(mTabStrip, LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); // initializing iconMap: mIconMap = new HashMap<Integer, TwoThings<Drawable, Drawable>>(); for (int i = 0; i < 3; i++) { // TODO: get rid of hardcoded value. int iconId = getIconResourceByPosition(i); Drawable positive = context.getResources().getDrawable(iconId); // TODO: deprecated! Drawable negative = context.getResources().getDrawable(iconId).mutate(); negative.setColorFilter(new PorterDuffColorFilter(SlidingTabStrip.DEFAULT_SELECTED_INDICATOR_COLOR, PorterDuff.Mode.MULTIPLY)); mIconMap.put(i, new TwoThings<Drawable, Drawable>(positive, negative)); } }
From source file:com.lithidsw.wallbox.app.wallsnap.WallSnapFragment.java
private void updateImagePre() { Drawable drawable = mImageView.getDrawable(); if (drawable != null) { drawable.setColorFilter( ColorFilterGenerator.adjustColor(mBrightItem, mContrastItem, mSatItem, mHueItem)); }/*from w w w . j a v a 2 s .c o m*/ }
From source file:com.lithidsw.wallbox.app.wallsnap.WallSnapFragment.java
private void updateBlur() { Bitmap bitmap = BlurImage(Utils.drawableToBitmap(getMainDrawable()), mBlurItem); if (bitmap != null) { mImageView.setImageBitmap(BlurImage(bitmap, mBlurItem)); Drawable drawable = mImageView.getDrawable(); if (drawable != null) { drawable.setColorFilter( ColorFilterGenerator.adjustColor(mBrightItem, mContrastItem, mSatItem, mHueItem)); }/*from w w w . j a v a 2s .c om*/ } }
From source file:co.ceryle.segmentedbutton.SegmentedButton.java
/** * If button has any drawable, it sets drawable's tint color without changing drawable's position. * * @param drawable is directly set to button's drawable * @param position specifies button's drawable position relative to text position. * These values can be given to position: * {@link #DRAWABLE_LEFT} sets drawable to the left of button's text * {@link #DRAWABLE_TOP} sets drawable to the top of button's text * {@link #DRAWABLE_RIGHT} sets drawable to the right of button's text * {@link #DRAWABLE_BOTTOM} sets drawable to the bottom of button's text * @param color is used to set drawable's tint color *///from w w w. j av a2s . c om public void setDrawableTint(Drawable drawable, int position, int color) { drawable.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_IN)); setDrawable(drawable, position); }
From source file:io.bunnyblue.noticedog.app.overlay.ui.OverlayNotificationBarView.java
private void setButton(Button button, Message message, int index) { List<Action> actions = message.getActions(); if (index >= actions.size()) { button.setVisibility(View.GONE); return;/*from w w w. j av a2 s.c o m*/ } Action action = (Action) actions.get(index); button.setOnClickListener(null); button.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0); button.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0, 0, 0); button.setVisibility(View.VISIBLE); Drawable icon = getActionIcon(message.getAppId(), action.icon); icon.setColorFilter(new LightingColorFilter(ViewCompat.MEASURED_STATE_MASK, 6914181)); button.setCompoundDrawablesRelativeWithIntrinsicBounds(icon, null, null, null); button.setText(action.title); }
From source file:org.mozilla.mozstumbler.client.navdrawer.MetricsView.java
public MetricsView(View view) { mView = view;// www. j a v a2s. com LocalBroadcastManager.getInstance(mView.getContext()).registerReceiver(new BroadcastReceiver() { public void onReceive(Context context, Intent intent) { Bundle bundle = intent.getExtras(); mPersistedStats = (Properties) bundle.get(PersistedStats.EXTRAS_PERSISTENT_SYNC_STATUS_UPDATED); updateSentStats(); } }, new IntentFilter(PersistedStats.ACTION_PERSISTENT_SYNC_STATUS_UPDATED)); mOnMapShowMLS = (CheckBox) mView.findViewById(R.id.checkBox_show_mls); mOnMapShowMLS.setVisibility(View.GONE); mOnMapShowMLS.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { ClientPrefs.getInstance(mView.getContext()).setOnMapShowMLS(mOnMapShowMLS.isChecked()); if (mMapLayerToggleListener.get() != null) { mMapLayerToggleListener.get().setShowMLS(mOnMapShowMLS.isChecked()); } } }); mLastUpdateTimeView = (TextView) mView.findViewById(R.id.last_upload_time_value); mAllTimeObservationsSentView = (TextView) mView.findViewById(R.id.observations_sent_value); mQueuedObservationsView = (TextView) mView.findViewById(R.id.observations_queued_value); mThisSessionObservationsView = (TextView) mView.findViewById(R.id.this_session_observations_value); mThisSessionUniqueCellsView = (TextView) mView.findViewById(R.id.cells_unique_value); mThisSessionUniqueAPsView = (TextView) mView.findViewById(R.id.wifis_unique_value); mUploadButton = (ImageButton) mView.findViewById(R.id.upload_observations_button); mUploadButton.setEnabled(false); mUploadButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (!mHasQueuedObservations) { return; } AsyncUploader uploader = new AsyncUploader(); AsyncUploadParam param = new AsyncUploadParam(false /* useWifiOnly */, Prefs.getInstance(mView.getContext()).getNickname(), Prefs.getInstance(mView.getContext()).getEmail()); uploader.execute(param); setUploadButtonToSyncing(true); } }); mSettingsButton = (ImageButton) mView.findViewById(R.id.metrics_settings_button); mSettingsButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Activity mainDrawer = (Activity) v.getContext(); assert (mainDrawer instanceof MainDrawerActivity); mainDrawer.startActivityForResult(new Intent(v.getContext(), PreferencesScreen.class), 1); } }); // Remove click listener of the Drawer buttons container to avoid to get it triggered on the Map view mButtonsContainer = (RelativeLayout) mView.findViewById(R.id.metrics_buttons_container); mButtonsContainer.setOnClickListener(null); mHandler.postDelayed(mUpdateLastUploadedLabel, FREQ_UPDATE_UPLOADTIME); Button showPowerButton = (Button) mView.findViewById(R.id.button_change_power_setting); if (Build.VERSION.SDK_INT >= 16) { Drawable clone = showPowerButton.getBackground().getConstantState().newDrawable(); clone.setColorFilter(new LightingColorFilter(0xFFFFFFFF, 0xFF106E99)); showPowerButton.setBackground(clone); } showPowerButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Activity mainDrawer = (Activity) v.getContext(); assert (mainDrawer instanceof MainDrawerActivity); mainDrawer.startActivityForResult(new Intent(v.getContext(), PowerSavingScreen.class), 1); } }); }
From source file:uk.co.brightec.ratetheapp.RateTheApp.java
private void initStars() { Drawable selected = ContextCompat.getDrawable(getContext(), mDrawableResSelected); selected = selected.mutate();// w ww.j a v a2 s . c om selected.setColorFilter(new PorterDuffColorFilter(mSelectedStarColour, PorterDuff.Mode.SRC_ATOP)); Drawable unselected = ContextCompat.getDrawable(getContext(), mDrawableResUnSelected); unselected = unselected.mutate(); unselected.setColorFilter(new PorterDuffColorFilter(mUnselectedStarColour, PorterDuff.Mode.SRC_ATOP)); LayerDrawable ld = (LayerDrawable) mRatingBar.getProgressDrawable(); ld.setDrawableByLayerId(android.R.id.background, unselected); ld.setDrawableByLayerId(android.R.id.secondaryProgress, unselected); ld.setDrawableByLayerId(android.R.id.progress, selected); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { mRatingBar.setProgressDrawableTiled(ld); } else { Drawable tiledDrawable = tileify(ld, false); mRatingBar.setProgressDrawable(tiledDrawable); } }
From source file:com.bytestemplar.tonedef.touchpad.TouchPadActivity.java
private void assertInvertState(boolean hook_buttons) { boolean mInvertKeyColors = false; if (_preferences.getBoolean("invert_text_color", false)) { mInvertKeyColors = true;// ww w . j ava 2s . co m ColorMatrix cm = new ColorMatrix(_invert); _invert_paint = new ColorMatrixColorFilter(cm); } // hook those _buttons for (int i = 0; i < _buttons.buttons.size(); i++) { ButtonDefinition button = _buttons.buttons.get(i); if (hook_buttons) { button.getButtonView().setOnTouchListener(this); button.getButtonView().setSoundEffectsEnabled(false); } if (button.getButtonView() instanceof ImageButton) { Drawable ib = ((ImageButton) (button.getButtonView())).getDrawable(); if (ib != null) { if (mInvertKeyColors) { ib.setColorFilter(_invert_paint); } else { ib.setColorFilter(null); } } } } }
From source file:alexander.martinz.libs.materialpreferences.MaterialPreference.java
public boolean init(Context context, AttributeSet attrs) { if (mInit) {/* w w w. ja v a2 s. com*/ return false; } mInit = true; if (attrs != null) { TypedArray typedArray = parseAttrs(context, attrs); recycleTypedArray(typedArray); } final int layoutResId = mPrefAsCard ? R.layout.material_prefs_card_preference : R.layout.material_prefs_preference; mView = getLayoutInflater().inflate(layoutResId, this, true); if (mPrefAsCard) { mCardView = (CardView) mView.findViewById(R.id.card_preference_root); } mIcon = (ImageView) mView.findViewById(android.R.id.icon); mTitle = (TextView) mView.findViewById(android.R.id.title); mSummary = (TextView) mView.findViewById(android.R.id.summary); mWidgetFrame = (LinearLayout) mView.findViewById(android.R.id.widget_frame); mWidgetFrameBottom = (LinearLayout) mView.findViewById(R.id.widget_frame_bottom); if (mResIdIcon != -1 && mIcon != null) { Drawable d = ContextCompat.getDrawable(context, mResIdIcon); if (d != null && mIconTintColor != Integer.MIN_VALUE) { d = d.mutate(); d.setColorFilter(new LightingColorFilter(Color.BLACK, mIconTintColor)); } mIcon.setImageDrawable(d); mIcon.setVisibility(View.VISIBLE); } if (mResIdTitle != -1) { mTitle.setText(mResIdTitle); } if (mResIdSummary != -1 && mSummary != null) { mSummary.setText(mResIdSummary); mSummary.setVisibility(View.VISIBLE); } if (mPrefAsCard && mCardBackgroundColor != Integer.MIN_VALUE) { setBackgroundColor(mCardBackgroundColor); } setSelectable(true); setOnClickListener(this); setOnTouchListener(this); setOrientation(LinearLayout.VERTICAL); return true; }