Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bc454a59 authored by tibbi's avatar tibbi
Browse files

use extension functions for applying color filters

parent e74b3014
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@ buildscript {
        propMinSdkVersion = 16
        propTargetSdkVersion = propCompileSdkVersion
        propVersionCode = 1
        propVersionName = '3.0.15'
        propVersionName = '3.0.16'
        kotlin_version = '1.2.0'
        support_libs = '27.0.2'
    }
+1 −1
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@ fun Resources.getColoredDrawable(drawableId: Int, colorId: Int, alpha: Int = 255

fun Resources.getColoredDrawableWithColor(drawableId: Int, color: Int, alpha: Int = 255): Drawable {
    val drawable = getDrawable(drawableId)
    drawable.mutate().setColorFilter(color, PorterDuff.Mode.SRC_IN)
    drawable.mutate().applyColorFilter(color)
    drawable.mutate().alpha = alpha
    return drawable
}
+2 −2
Original line number Diff line number Diff line
package com.simplemobiletools.commons.views

import android.content.Context
import android.graphics.PorterDuff
import android.support.v4.widget.SwipeRefreshLayout
import android.support.v7.widget.LinearLayoutManager
import android.support.v7.widget.RecyclerView
@@ -9,6 +8,7 @@ import android.util.AttributeSet
import android.view.MotionEvent
import android.view.View
import android.widget.FrameLayout
import com.simplemobiletools.commons.extensions.applyColorFilter
import com.simplemobiletools.commons.extensions.baseConfig

// based on https://blog.stylingandroid.com/recyclerview-fastscroll-part-1
@@ -50,7 +50,7 @@ class FastScroller : FrameLayout {
    }

    fun updateHandleColor() {
        handle!!.background.setColorFilter(context.baseConfig.primaryColor, PorterDuff.Mode.SRC_IN)
        handle!!.background.applyColorFilter(context.baseConfig.primaryColor)
    }

    override fun onSizeChanged(width: Int, height: Int, oldWidth: Int, oldHeight: Int) {
+2 −2
Original line number Diff line number Diff line
package com.simplemobiletools.commons.views

import android.content.Context
import android.graphics.PorterDuff
import android.support.v7.widget.AppCompatSpinner
import android.util.AttributeSet
import android.view.View
@@ -9,6 +8,7 @@ import android.widget.AdapterView
import android.widget.TextView
import com.simplemobiletools.commons.R
import com.simplemobiletools.commons.adapters.MyArrayAdapter
import com.simplemobiletools.commons.extensions.applyColorFilter

class MyAppCompatSpinner : AppCompatSpinner {
    constructor(context: Context) : super(context)
@@ -43,6 +43,6 @@ class MyAppCompatSpinner : AppCompatSpinner {
            override fun onNothingSelected(parent: AdapterView<*>?) {
            }
        }
        background.setColorFilter(textColor, PorterDuff.Mode.SRC_ATOP)
        background.applyColorFilter(textColor)
    }
}
+2 −2
Original line number Diff line number Diff line
package com.simplemobiletools.commons.views

import android.content.Context
import android.graphics.PorterDuff
import android.util.AttributeSet
import android.widget.EditText
import com.simplemobiletools.commons.extensions.adjustAlpha
import com.simplemobiletools.commons.extensions.applyColorFilter

class MyEditText : EditText {
    constructor(context: Context) : super(context)
@@ -14,7 +14,7 @@ class MyEditText : EditText {
    constructor(context: Context, attrs: AttributeSet, defStyle: Int) : super(context, attrs, defStyle)

    fun setColors(textColor: Int, accentColor: Int, backgroundColor: Int) {
        background?.mutate()?.setColorFilter(accentColor, PorterDuff.Mode.SRC_ATOP)
        background?.mutate()?.applyColorFilter(accentColor)

        // requires android:textCursorDrawable="@null" in xml to color the cursor too
        setTextColor(textColor)
Loading