<commit_before>package com.simplemobiletools.commons.extensions

import android.content.res.Resources
import android.graphics.*

fun Resources.getColoredIcon(newColor: Int, resourceId: Int): Bitmap {
    val options = BitmapFactory.Options()
    options.inMutable = true
    val bmp = BitmapFactory.decodeResource(this, resourceId, options)
    val paint = Paint()
    val filter = PorterDuffColorFilter(newColor, PorterDuff.Mode.SRC_IN)
    paint.colorFilter = filter
    val canvas = Canvas(bmp)
    canvas.drawBitmap(bmp, 0f, 0f, paint)
    return bmp
}<commit_msg>add a new resource extension for getting colored drawable<commit_after>package com.simplemobiletools.commons.extensions

import android.content.res.Resources
import android.graphics.*
import android.graphics.drawable.Drawable

fun Resources.getColoredIcon(newColor: Int, resourceId: Int): Bitmap {
    val options = BitmapFactory.Options()
    options.inMutable = true
    val bmp = BitmapFactory.decodeResource(this, resourceId, options)
    val paint = Paint()
    val filter = PorterDuffColorFilter(newColor, PorterDuff.Mode.SRC_IN)
    paint.colorFilter = filter
    val canvas = Canvas(bmp)
    canvas.drawBitmap(bmp, 0f, 0f, paint)
    return bmp
}

fun Resources.getColoredDrawable(resId: Int, colorId: Int): Drawable {
    val drawable = getDrawable(resId)
    drawable.mutate().setColorFilter(getColor(colorId), PorterDuff.Mode.SRC_IN)
    return drawable
}
{'fraction_non_alphanumeric': 0.09205020920502092, 'fraction_numerical': 0.002789400278940028, 'mean_word_length': 4.694444444444445, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1568254', 'n_tokens_mistral': 445, 'n_tokens_neox': 427, 'n_words': 103}