List of usage examples for android.support.v4.graphics.drawable DrawableCompat setTint
public static void setTint(Drawable drawable, int i)
From source file:org.gateshipone.malp.application.fragments.ProfilesFragment.java
/** * Initialize the options menu.//from w ww.j av a 2s . com * Be sure to call {@link #setHasOptionsMenu} before. * * @param menu The container for the custom options menu. * @param menuInflater The inflater to instantiate the layout. */ @Override public void onCreateOptionsMenu(Menu menu, MenuInflater menuInflater) { // Inflate the menu; this adds items to the action bar if it is present. menuInflater.inflate(R.menu.fragment_menu_profiles, menu); // get tint color int tintColor = ThemeUtils.getThemeColor(getContext(), R.attr.malp_color_text_accent); Drawable drawable = menu.findItem(R.id.action_add).getIcon(); drawable = DrawableCompat.wrap(drawable); DrawableCompat.setTint(drawable, tintColor); menu.findItem(R.id.action_add).setIcon(drawable); super.onCreateOptionsMenu(menu, menuInflater); }
From source file:com.ruesga.rview.misc.Formatter.java
@BindingAdapter({ "draftAccountDisplayName", "isDraft" }) public static void toDraftAccountDisplayName(TextView view, AccountInfo accountInfo, boolean isDraft) { if (isDraft) { Context ctx = view.getContext(); view.setText(ctx.getString(R.string.menu_draft).toUpperCase(AndroidHelper.getCurrentLocale(ctx))); Drawable dw = ContextCompat.getDrawable(ctx, R.drawable.bg_tag); DrawableCompat.setTint(dw, ContextCompat.getColor(ctx, R.color.unscored)); view.setBackground(dw);//w w w. j a v a2 s . c om return; } view.setBackground(null); toAccountDisplayName(view, accountInfo); }
From source file:galilei.kelimekavanozu.activity.ThemeChooserActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Accelerometer check PackageManager manager = getPackageManager(); hasAccelerometer = manager.hasSystemFeature(PackageManager.FEATURE_SENSOR_ACCELEROMETER); setContentView(R.layout.activity_theme_chooser); SugarContext.init(this); arkaplan500 = (ImageView) findViewById(R.id.arkaplan500); kavanoz = (ImageView) findViewById(R.id.cannonball_logo); recyclerView = (RecyclerView) findViewById(R.id.main_list); final Animation shake = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.shake); fab = (FloatingActionButton) findViewById(R.id.fab); StaggeredGridLayoutManager gridLayoutManager = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL); gridLayoutManager.setGapStrategy(StaggeredGridLayoutManager.GAP_HANDLING_MOVE_ITEMS_BETWEEN_SPANS); recyclerView.setLayoutManager(gridLayoutManager); initialCount = Note.count(Note.class); if (savedInstanceState != null) modifyPos = savedInstanceState.getInt("modify"); if (initialCount >= 0) { notes = Note.listAll(Note.class); adapter = new KelimelerAdapter(ThemeChooserActivity.this, notes); recyclerView.setAdapter(adapter); }//from www . j ava 2s .c o m if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { Drawable drawable = ContextCompat.getDrawable(this, R.drawable.ic_add_24dp); drawable = DrawableCompat.wrap(drawable); DrawableCompat.setTint(drawable, Color.WHITE); DrawableCompat.setTintMode(drawable, PorterDuff.Mode.SRC_IN); fab.setImageDrawable(drawable); } fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // Crashlytics.log("Yeni Kelime: butona basld"); // Answers.getInstance().logCustom(new CustomEvent("Ekle butonuna basld")); Intent i = new Intent(ThemeChooserActivity.this, AddNoteActivity.class); startActivity(i); } }); if (isNetworkConnected()) { new arkaplan().execute(); } // Handling swipe to delete setUpViews(); ItemTouchHelper.SimpleCallback simpleCallback = new ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT) { @Override public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) { return false; } @Override public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) { //Remove swiped item from list and notify the RecyclerView final int position = viewHolder.getAdapterPosition(); final Note note = notes.get(viewHolder.getAdapterPosition()); notes.remove(viewHolder.getAdapterPosition()); adapter.notifyItemRemoved(position); note.delete(); initialCount -= 1; Snackbar.make(fab, "Kelime silindi", Snackbar.LENGTH_SHORT) .setAction("GER AL", new View.OnClickListener() { @Override public void onClick(View v) { note.save(); notes.add(position, note); adapter.notifyItemInserted(position); initialCount += 1; } }).show(); } }; ItemTouchHelper itemTouchHelper = new ItemTouchHelper(simpleCallback); itemTouchHelper.attachToRecyclerView(recyclerView); adapter.SetOnItemClickListener(new KelimelerAdapter.OnItemClickListener() { @Override public void onItemClick(View view, int position) { Log.d("Main", "click"); Intent i = new Intent(ThemeChooserActivity.this, AddNoteActivity.class); i.putExtra("isEditing", true); i.putExtra("note_title", notes.get(position).title); i.putExtra("note", notes.get(position).note); i.putExtra("note_time", notes.get(position).time); modifyPos = position; startActivity(i); } }); if (hasAccelerometer) { kavanoz.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // View element to be shaken // Perform animation if (notclick) { kavanoz.startAnimation(shake); shakemode = true; notclick = false; Snackbar.make(fab, "Rastgele kelimelerden birini grmek iin telefonunuzu sallayn.", Snackbar.LENGTH_LONG).show(); kavanoz.setColorFilter(Color.argb(100, 255, 140, 0)); } else { shakemode = false; notclick = true; kavanoz.setColorFilter(getResources().getColor(R.color.green)); } } }); // ShakeDetector initialization mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE); mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); mShakeDetector = new ShakeDetector(); mShakeDetector.setOnShakeListener(new ShakeDetector.OnShakeListener() { @Override public void onShake(int count) { if (shakemode) { /* * The following method, "handleShakeEvent(count):" is a stub // * method you would use to setup whatever you want done once the * device has been shook. */ // View element to be shaken // Perform animation Crashlytics.log("Shake event : triggered"); Answers.getInstance().logCustom(new CustomEvent("Shake event : tetiklendi")); kavanoz.startAnimation(shake); new rastgeletweet().execute(); } } }); } }
From source file:org.onebusaway.android.ui.ArrivalsListAdapterStyleA.java
@Override protected void initView(View view, ArrivalInfo stopInfo) { final Context context = getContext(); final ObaArrivalInfo arrivalInfo = stopInfo.getInfo(); TextView route = (TextView) view.findViewById(R.id.route); TextView destination = (TextView) view.findViewById(R.id.destination); TextView time = (TextView) view.findViewById(R.id.time); TextView status = (TextView) view.findViewById(R.id.status); TextView etaView = (TextView) view.findViewById(R.id.eta); TextView minView = (TextView) view.findViewById(R.id.eta_min); ViewGroup realtimeView = (ViewGroup) view.findViewById(R.id.eta_realtime_indicator); ImageView moreView = (ImageView) view.findViewById(R.id.more_horizontal); moreView.setColorFilter(context.getResources().getColor(R.color.switch_thumb_normal_material_dark)); ImageView starView = (ImageView) view.findViewById(R.id.route_favorite); starView.setColorFilter(context.getResources().getColor(R.color.navdrawer_icon_tint)); starView.setImageResource(//from www . j a v a 2 s . c om stopInfo.isRouteAndHeadsignFavorite() ? R.drawable.focus_star_on : R.drawable.focus_star_off); route.setText(arrivalInfo.getShortName()); destination.setText(MyTextUtils.toTitleCase(arrivalInfo.getHeadsign())); status.setText(stopInfo.getStatusText()); long eta = stopInfo.getEta(); if (eta == 0) { etaView.setText(R.string.stop_info_eta_now); minView.setVisibility(View.GONE); } else { etaView.setText(String.valueOf(eta)); minView.setVisibility(View.VISIBLE); } status.setBackgroundResource(R.drawable.round_corners_style_b_status); GradientDrawable d = (GradientDrawable) status.getBackground(); Integer colorCode = stopInfo.getColor(); int color = context.getResources().getColor(colorCode); if (stopInfo.getPredicted()) { // Show real-time indicator UIUtils.setRealtimeIndicatorColorByResourceCode(realtimeView, colorCode, android.R.color.transparent); realtimeView.setVisibility(View.VISIBLE); } else { realtimeView.setVisibility(View.INVISIBLE); } etaView.setTextColor(color); minView.setTextColor(color); d.setColor(color); // Set padding on status view int pSides = UIUtils.dpToPixels(context, 5); int pTopBottom = UIUtils.dpToPixels(context, 2); status.setPadding(pSides, pTopBottom, pSides, pTopBottom); time.setText(DateUtils.formatDateTime(context, stopInfo.getDisplayTime(), DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_NO_NOON | DateUtils.FORMAT_NO_MIDNIGHT)); ContentValues values = null; if (mTripsForStop != null) { values = mTripsForStop.getValues(arrivalInfo.getTripId()); } if (values != null) { String reminderName = values.getAsString(ObaContract.Trips.NAME); TextView reminder = (TextView) view.findViewById(R.id.reminder); if (reminderName.length() == 0) { reminderName = context.getString(R.string.trip_info_noname); } reminder.setText(reminderName); Drawable d2 = reminder.getCompoundDrawables()[0]; d2 = DrawableCompat.wrap(d2); DrawableCompat.setTint(d2.mutate(), view.getResources().getColor(R.color.button_material_dark)); reminder.setCompoundDrawables(d2, null, null, null); reminder.setVisibility(View.VISIBLE); } else { // Explicitly set this to invisible because we might be reusing // this view. View reminder = view.findViewById(R.id.reminder); reminder.setVisibility(View.GONE); } }
From source file:jahirfiquitiva.iconshowcase.utilities.color.ColorUtils.java
@CheckResult @Nullable//from w w w . j a v a2s .c om public static Drawable getTintedIcon(Drawable drawable, int color) { if (drawable != null) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (drawable instanceof VectorDrawable) { drawable.setColorFilter(color, PorterDuff.Mode.SRC_IN); } drawable = DrawableCompat.wrap(drawable.mutate()); } else { drawable = DrawableCompat.wrap(drawable); } DrawableCompat.setTintMode(drawable, PorterDuff.Mode.SRC_IN); DrawableCompat.setTint(drawable, color); return drawable; } else { return null; } }
From source file:com.jaredrummler.materialspinner.MaterialSpinner.java
private void init(Context context, AttributeSet attrs) { TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.MaterialSpinner); int defaultColor = getTextColors().getDefaultColor(); backgroundColor = typedArray.getColor(R.styleable.MaterialSpinner_ms_background_color, Color.WHITE); textColor = typedArray.getColor(R.styleable.MaterialSpinner_ms_text_color, defaultColor); arrowColor = typedArray.getColor(R.styleable.MaterialSpinner_ms_arrow_tint, textColor); hideArrow = typedArray.getBoolean(R.styleable.MaterialSpinner_ms_hide_arrow, false); typedArray.recycle();/* w ww. j ava 2 s. c om*/ setGravity(Gravity.CENTER_VERTICAL | Gravity.START); boolean rtl = false; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { Configuration config = getResources().getConfiguration(); rtl = config.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL; if (rtl) { setLayoutDirection(View.LAYOUT_DIRECTION_RTL); setTextDirection(View.TEXT_DIRECTION_RTL); } } Resources resources = getResources(); int left, right, bottom, top; left = right = bottom = top = resources.getDimensionPixelSize(R.dimen.ms__padding_top); if (rtl) { right = resources.getDimensionPixelSize(R.dimen.ms__padding_left); } else { left = resources.getDimensionPixelSize(R.dimen.ms__padding_left); } setClickable(true); setPadding(left, top, right, bottom); setBackgroundResource(R.drawable.ms__selector); if (!hideArrow) { arrowDrawable = DrawableCompat.wrap(ContextCompat.getDrawable(context, R.drawable.ms__arrow)); DrawableCompat.setTint(arrowDrawable, arrowColor); if (rtl) { setCompoundDrawablesWithIntrinsicBounds(arrowDrawable, null, null, null); } else { setCompoundDrawablesWithIntrinsicBounds(null, null, arrowDrawable, null); } } listView = new ListView(context); listView.setId(getId()); listView.setDivider(null); listView.setItemsCanFocus(true); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (position >= selectedIndex && position < adapter.getCount()) { position++; } selectedIndex = position; nothingSelected = false; Object item = adapter.get(position); adapter.notifyItemSelected(position); setText(item.toString()); collapse(); if (onItemSelectedListener != null) { //noinspection unchecked onItemSelectedListener.onItemSelected(MaterialSpinner.this, position, id, item); } } }); popupWindow = new PopupWindow(context); popupWindow.setContentView(listView); popupWindow.setOutsideTouchable(true); popupWindow.setFocusable(true); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { popupWindow.setElevation(16); popupWindow.setBackgroundDrawable(ContextCompat.getDrawable(context, R.drawable.ms__drawable)); } else { popupWindow.setBackgroundDrawable(ContextCompat.getDrawable(context, R.drawable.ms__drop_down_shadow)); } if (backgroundColor != Color.WHITE) { // default color is white setBackgroundColor(backgroundColor); } if (textColor != defaultColor) { setTextColor(textColor); } popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() { @Override public void onDismiss() { if (nothingSelected && onNothingSelectedListener != null) { onNothingSelectedListener.onNothingSelected(MaterialSpinner.this); } if (!hideArrow) { animateArrow(false); } } }); }
From source file:org.gateshipone.malp.application.views.AlbumArtistView.java
/** * Shows the placeholder image./*from ww w . j av a2s .co m*/ */ public void clearAlbumImage() { // get tint color int tintColor = ThemeUtils.getThemeColor(getContext(), R.attr.malp_color_text_background_primary); Drawable drawable = getResources().getDrawable(R.drawable.cover_placeholder, null); drawable = DrawableCompat.wrap(drawable); DrawableCompat.setTint(drawable, tintColor); mAlbumImage.setImageDrawable(drawable); mAlbumImageAvailable = false; imagesChanged(); }
From source file:com.pdmanager.views.patient.MainActivity.java
public static void setOverflowButtonColor(final Toolbar toolbar, final int color) { Drawable drawable = toolbar.getOverflowIcon(); if (drawable != null) { drawable = DrawableCompat.wrap(drawable); DrawableCompat.setTint(drawable.mutate(), color); toolbar.setOverflowIcon(drawable); }/*w ww . jav a2s . c o m*/ }
From source file:com.tr4android.support.extension.picker.PickerThemeUtils.java
public static void setNavButtonDrawable(Context context, ImageButton left, ImageButton right, int monthTextAppearanceResId) { // Retrieve the previous and next drawables AppCompatDrawableManager dm = AppCompatDrawableManager.get(); Drawable prevDrawable = dm.getDrawable(context, R.drawable.ic_chevron_left_black_24dp); Drawable nextDrawable = dm.getDrawable(context, R.drawable.ic_chevron_right_black_24dp); // Proxy the month text color into the previous and next drawables. final TypedArray ta = context.obtainStyledAttributes(null, new int[] { android.R.attr.textColor }, 0, monthTextAppearanceResId);//from w w w. j a v a 2 s . c o m final ColorStateList monthColor = ta.getColorStateList(0); if (monthColor != null) { DrawableCompat.setTint(DrawableCompat.wrap(prevDrawable), monthColor.getDefaultColor()); DrawableCompat.setTint(DrawableCompat.wrap(nextDrawable), monthColor.getDefaultColor()); } ta.recycle(); // Set the previous and next drawables left.setImageDrawable(prevDrawable); right.setImageDrawable(nextDrawable); }
From source file:com.owncloud.android.ui.dialog.SetupEncryptionDialogFragment.java
@NonNull @Override//w w w .j av a 2s. co m public Dialog onCreateDialog(Bundle savedInstanceState) { int accentColor = ThemeUtils.primaryAccentColor(getContext()); account = getArguments().getParcelable(ARG_ACCOUNT); arbitraryDataProvider = new ArbitraryDataProvider(getContext().getContentResolver()); // Inflate the layout for the dialog LayoutInflater inflater = getActivity().getLayoutInflater(); // Setup layout View v = inflater.inflate(R.layout.setup_encryption_dialog, null); textView = v.findViewById(R.id.encryption_status); passphraseTextView = v.findViewById(R.id.encryption_passphrase); passwordField = v.findViewById(R.id.encryption_passwordInput); passwordField.getBackground().setColorFilter(accentColor, PorterDuff.Mode.SRC_ATOP); Drawable wrappedDrawable = DrawableCompat.wrap(passwordField.getBackground()); DrawableCompat.setTint(wrappedDrawable, accentColor); passwordField.setBackgroundDrawable(wrappedDrawable); return createDialog(accentColor, v); }