Example usage for android.support.v4.graphics.drawable DrawableCompat setTint

List of usage examples for android.support.v4.graphics.drawable DrawableCompat setTint

Introduction

In this page you can find the example usage for android.support.v4.graphics.drawable DrawableCompat setTint.

Prototype

public static void setTint(Drawable drawable, int i) 

Source Link

Usage

From source file:com.owncloud.android.ui.activity.ManageAccountsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mTintedCheck = ContextCompat.getDrawable(this, R.drawable.ic_current_white);
    mTintedCheck = DrawableCompat.wrap(mTintedCheck);
    int tint = ContextCompat.getColor(this, R.color.actionbar_start_color);
    DrawableCompat.setTint(mTintedCheck, tint);

    setContentView(R.layout.accounts_layout);

    mListView = findViewById(R.id.account_list);
    mListView.setFilterTouchesWhenObscured(true);

    setupToolbar();/*from w ww  . ja v a2 s . c  o  m*/
    updateActionBarTitleAndHomeButtonByString(getResources().getString(R.string.prefs_manage_accounts));

    Account[] accountList = AccountManager.get(this).getAccountsByType(MainApp.getAccountType());
    mOriginalAccounts = toAccountNameSet(accountList);
    mOriginalCurrentAccount = AccountUtils.getCurrentOwnCloudAccount(this).name;

    setAccount(AccountUtils.getCurrentOwnCloudAccount(this));
    onAccountSet(false);

    initializeComponentGetters();

    // added click listener to switch account
    mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            switchAccount(position);
        }
    });
}

From source file:com.txusballesteros.PasswordEditText.java

private Drawable getDrawable(Drawable drawable, int tint) {
    if (drawable != null && tint != WITHOUT_TINT) {
        drawable = DrawableCompat.wrap(drawable);
        DrawableCompat.setTint(drawable, tint);
    }/* www .  ja  v a 2s  . co m*/
    return drawable;
}

From source file:com.tevinjeffrey.njitct.ui.utils.TintImageView.java

public Drawable tintDrawable(Drawable drawable, @ColorInt int color) {
    Drawable wrappedDrawable = DrawableCompat.wrap(drawable);
    DrawableCompat.setTint(wrappedDrawable, color);
    DrawableCompat.setTintMode(wrappedDrawable, PorterDuff.Mode.SRC_IN);
    return wrappedDrawable;
}

From source file:com.google.samples.apps.topeka.adapter.ScoreAdapter.java

/**
 * Convenience method to aid tintint of vector drawables at runtime.
 *
 * @param context The {@link Context} for this app.
 * @param drawableId The id of the drawable to load.
 * @param tintColor The tint to apply.// w w  w . ja  v  a 2s  . c  o  m
 * @return The tinted drawable.
 */
private Drawable loadAndTint(Context context, @DrawableRes int drawableId, @ColorRes int tintColor) {
    Drawable imageDrawable = ContextCompat.getDrawable(context, drawableId);
    if (imageDrawable == null) {
        throw new IllegalArgumentException("The drawable with id " + drawableId + " does not exist");
    }
    DrawableCompat.setTint(DrawableCompat.wrap(imageDrawable), tintColor);
    return imageDrawable;
}

From source file:com.arlib.floatingsearchview.suggestions.SearchSuggestionsAdapter.java

public SearchSuggestionsAdapter(Context context, int suggestionTextSize, Listener listener) {
    this.mContext = context;
    this.mListener = listener;
    this.mBodyTextSizePx = suggestionTextSize;

    mRightIconDrawable = Util.getWrappedDrawable(mContext, R.drawable.ic_arrow_back_black_24dp);
    DrawableCompat.setTint(mRightIconDrawable, Util.getColor(mContext, R.color.gray_active_icon));
}

From source file:io.syng.fragment.profile.ProfileDialogFragment.java

private void tintMenuItem() {
    Drawable drawable1 = mToolbar.getMenu().findItem(R.id.action_key_export).getIcon();
    drawable1 = DrawableCompat.wrap(drawable1);
    DrawableCompat.setTint(drawable1, getResources().getColor(R.color.drawer_icon_color));
    mToolbar.getMenu().findItem(R.id.action_key_export).setIcon(drawable1);

    Drawable drawable2 = mToolbar.getMenu().findItem(R.id.action_key_import).getIcon();
    drawable2 = DrawableCompat.wrap(drawable2);
    DrawableCompat.setTint(drawable2, getResources().getColor(R.color.drawer_icon_color));
    mToolbar.getMenu().findItem(R.id.action_key_import).setIcon(drawable2);

    Drawable drawable3 = mToolbar.getMenu().findItem(R.id.action_remove).getIcon();
    drawable3 = DrawableCompat.wrap(drawable3);
    DrawableCompat.setTint(drawable3, getResources().getColor(R.color.drawer_icon_color));
    mToolbar.getMenu().findItem(R.id.action_remove).setIcon(drawable3);
}

From source file:io.github.hidroh.materialistic.widget.StoryView.java

public StoryView(Context context, @Nullable AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.StoryView);
    mIsLocal = ta.getBoolean(R.styleable.StoryView_local, false);
    TypedArray a = context.getTheme().obtainStyledAttributes(new int[] { android.R.attr.textColorTertiary,
            android.R.attr.textColorSecondary, R.attr.colorCardBackground, R.attr.colorCardHighlight });
    mTertiaryTextColorResId = ContextCompat.getColor(context, a.getResourceId(0, 0));
    mSecondaryTextColorResId = ContextCompat.getColor(context, a.getResourceId(1, 0));
    mBackgroundColor = ContextCompat.getColor(context, a.getResourceId(2, 0));
    mHighlightColor = ContextCompat.getColor(context, a.getResourceId(3, 0));
    mPromotedColorResId = ContextCompat.getColor(context, R.color.greenA700);
    mHotColorResId = ContextCompat.getColor(context, R.color.orange500);
    mAccentColorResId = ContextCompat.getColor(getContext(),
            AppUtils.getThemedResId(getContext(), R.attr.colorAccent));
    mCommentDrawable = DrawableCompat//from  w w  w. j ava  2s. c  om
            .wrap(ContextCompat.getDrawable(context, R.drawable.ic_comment_white_24dp).mutate());
    DrawableCompat.setTint(mCommentDrawable, mAccentColorResId);
    inflate(context, mIsLocal ? R.layout.local_story_view : R.layout.story_view, this);
    mBackground = findViewById(R.id.background);
    mBackground.setBackgroundColor(mBackgroundColor);
    mVoteSwitcher = (ViewSwitcher) findViewById(R.id.vote_switcher);
    mRankTextView = (TextView) findViewById(R.id.rank);
    mScoreTextView = (TextView) findViewById(R.id.score);
    mBookmarked = findViewById(R.id.bookmarked);
    mPostedTextView = (TextView) findViewById(R.id.posted);
    mTitleTextView = (TextView) findViewById(R.id.title);
    mSourceTextView = (TextView) findViewById(R.id.source);
    mCommentButton = (TextView) findViewById(R.id.comment);
    mCommentButton.setCompoundDrawablesWithIntrinsicBounds(mCommentDrawable, null, null, null);
    mMoreButton = findViewById(R.id.button_more);
    // replace with bounded ripple as unbounded ripple requires container bg
    // http://b.android.com/155880
    mMoreButton.setBackgroundResource(AppUtils.getThemedResId(context, R.attr.selectableItemBackground));
    ta.recycle();
    a.recycle();
}

From source file:com.linkbubble.ui.ContentViewButton.java

public void updateTheme(Integer color) {
    Drawable d = mImageView.getDrawable();
    if (d != null) {
        int textColor;
        if (color == null || !Settings.get().getThemeToolbar()) {
            textColor = Settings.get().getThemedTextColor();
        } else {/* w  ww. j  a v a  2  s.c  o  m*/
            textColor = Settings.COLOR_WHITE;
        }
        DrawableCompat.setTint(d, textColor);
    }
}

From source file:org.floens.chan.ui.layout.FilesLayout.java

public void setFiles(FileItems fileItems) {
    // Save the associated list position
    if (currentFileItems != null) {
        int[] indexTop = RecyclerUtils.getIndexAndTop(recyclerView);
        currentHistory.index = indexTop[0];
        currentHistory.top = indexTop[1];
        history.put(currentFileItems.path.getAbsolutePath(), currentHistory);
    }//w ww. j a v  a  2s.  co m

    filesAdapter.setFiles(fileItems);
    currentFileItems = fileItems;

    // Restore any previous list position
    currentHistory = history.get(fileItems.path.getAbsolutePath());
    if (currentHistory != null) {
        layoutManager.scrollToPositionWithOffset(currentHistory.index, currentHistory.top);
        filesAdapter.setHighlightedItem(currentHistory.clickedItem);
    } else {
        currentHistory = new FileItemHistory();
        filesAdapter.setHighlightedItem(null);
    }

    boolean enabled = fileItems.canNavigateUp;
    backLayout.setEnabled(enabled);
    Drawable wrapped = DrawableCompat.wrap(backImage.getDrawable());
    backImage.setImageDrawable(wrapped);
    int color = getAttrColor(getContext(), enabled ? R.attr.text_color_primary : R.attr.text_color_hint);
    DrawableCompat.setTint(wrapped, color);
    backText.setEnabled(enabled);
    backText.setTextColor(color);
}

From source file:io.mpos.ui.shared.util.UiHelper.java

public static void tintView(View view, int color) {
    Drawable wrappedDrawable = DrawableCompat.wrap(view.getBackground());
    DrawableCompat.setTint(wrappedDrawable, color);
    view.setBackgroundDrawable(wrappedDrawable);
}