Drop VectorChildFinder dependency
This commit is contained in:
1 parent
d6ee455952
commit
7ec7c933fc
22 files changed
+179
-91
No files matched your search
@@ -367,7 +367,6 @@ dependencies {
|
||||
implementation "com.google.accompanist:accompanist-placeholder-material:$accompanist_version"
|
||||
implementation "com.google.accompanist:accompanist-systemuicontroller:$accompanist_version"
|
||||
implementation 'com.google.android.material:material:1.6.0'
|
||||
implementation "com.github.devsideal:VectorChildFinder:1.0.0"
|
||||
implementation "com.github.fornewid:material-motion-compose:0.8.0-beta01"
|
||||
implementation 'dev.kdrag0n:colorkt:1.0.3'
|
||||
implementation "io.coil-kt:coil-compose:1.4.0"
|
||||
|
||||
@@ -1,26 +1,9 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:name="qsbIconTintTertiary"
|
||||
android:fillColor="#FBBC05"
|
||||
android:pathData="M16,5C17.66,5 19,6.34 19,8V10H21V8C21,5.24 18.76,3 16,3H14V5H16Z" />
|
||||
<path
|
||||
android:name="qsbIconTintPrimary"
|
||||
android:fillColor="#4285F4"
|
||||
android:pathData="M8,19C6.34,19 5,17.66 5,16V14H3V16C3,18.76 5.24,21 8,21H10V19H8Z" />
|
||||
<path
|
||||
android:name="qsbIconTintPrimary2"
|
||||
android:fillColor="#4285F4"
|
||||
android:pathData="M8.5,12C8.4976,11.2595 8.7304,10.537 9.1645,9.937C9.5986,9.3371 10.2123,8.8901 10.9164,8.6609C11.6205,8.4316 12.3795,8.4316 13.0836,8.6609C13.7878,8.8901 14.4014,9.3371 14.8355,9.937C15.2696,10.537 15.5024,11.2595 15.5,12C15.5024,12.7405 15.2696,13.463 14.8355,14.063C14.4014,14.6629 13.7878,15.1099 13.0836,15.3391C12.3795,15.5684 11.6205,15.5684 10.9164,15.3391C10.2123,15.1099 9.5986,14.6629 9.1645,14.063C8.7304,13.463 8.4976,12.7405 8.5,12Z" />
|
||||
<path
|
||||
android:name="qsbIconTintSecondary"
|
||||
android:fillColor="#34A853"
|
||||
android:pathData="M16,18C16,17.4697 16.2109,16.9608 16.5858,16.5858C16.9608,16.2109 17.4697,16 18,16C18.5303,16 19.0392,16.2109 19.4142,16.5858C19.7891,16.9608 20,17.4697 20,18C20,18.5303 19.7891,19.0392 19.4142,19.4142C19.0392,19.7891 18.5303,20 18,20C17.4697,20 16.9608,19.7891 16.5858,19.4142C16.2109,19.0392 16,18.5303 16,18Z" />
|
||||
<path
|
||||
android:name="qsbIconTintQuaternary"
|
||||
android:fillColor="#EA4335"
|
||||
android:pathData="M8,5C6.34,5 5,6.34 5,8V10H3V8C3,5.24 5.24,3 8,3H10V5H8Z" />
|
||||
</vector>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:id="@id/qsbIconTintTertiary" android:drawable="@drawable/ic_lens_color_1" />
|
||||
<item android:id="@id/qsbIconTintPrimary" android:drawable="@drawable/ic_lens_color_2" />
|
||||
<item android:id="@id/qsbIconTintPrimary" android:drawable="@drawable/ic_lens_color_3" />
|
||||
<item android:id="@id/qsbIconTintSecondary" android:drawable="@drawable/ic_lens_color_4" />
|
||||
<item android:id="@id/qsbIconTintQuaternary" android:drawable="@drawable/ic_lens_color_5" />
|
||||
</layer-list>
|
||||
@@ -0,0 +1,9 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="#FBBC05"
|
||||
android:pathData="M16,5C17.66,5 19,6.34 19,8V10H21V8C21,5.24 18.76,3 16,3H14V5H16Z" />
|
||||
</vector>
|
||||
@@ -0,0 +1,9 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="#4285F4"
|
||||
android:pathData="M8,19C6.34,19 5,17.66 5,16V14H3V16C3,18.76 5.24,21 8,21H10V19H8Z" />
|
||||
</vector>
|
||||
@@ -0,0 +1,9 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="#4285F4"
|
||||
android:pathData="M8.5,12C8.4976,11.2595 8.7304,10.537 9.1645,9.937C9.5986,9.3371 10.2123,8.8901 10.9164,8.6609C11.6205,8.4316 12.3795,8.4316 13.0836,8.6609C13.7878,8.8901 14.4014,9.3371 14.8355,9.937C15.2696,10.537 15.5024,11.2595 15.5,12C15.5024,12.7405 15.2696,13.463 14.8355,14.063C14.4014,14.6629 13.7878,15.1099 13.0836,15.3391C12.3795,15.5684 11.6205,15.5684 10.9164,15.3391C10.2123,15.1099 9.5986,14.6629 9.1645,14.063C8.7304,13.463 8.4976,12.7405 8.5,12Z" />
|
||||
</vector>
|
||||
@@ -0,0 +1,9 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="#34A853"
|
||||
android:pathData="M16,18C16,17.4697 16.2109,16.9608 16.5858,16.5858C16.9608,16.2109 17.4697,16 18,16C18.5303,16 19.0392,16.2109 19.4142,16.5858C19.7891,16.9608 20,17.4697 20,18C20,18.5303 19.7891,19.0392 19.4142,19.4142C19.0392,19.7891 18.5303,20 18,20C17.4697,20 16.9608,19.7891 16.5858,19.4142C16.2109,19.0392 16,18.5303 16,18Z" />
|
||||
</vector>
|
||||
@@ -1,22 +1,8 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:name="qsbIconTintPrimary"
|
||||
android:fillColor="#4285F4"
|
||||
android:pathData="M12,15c1.66,0 2.99,-1.34 2.99,-3L15,5c0,-1.66 -1.34,-3 -3,-3S9,3.34 9,5v7c0,1.66 1.34,3 3,3z" />
|
||||
<path
|
||||
android:name="qsbIconTintSecondary"
|
||||
android:fillColor="#34A853"
|
||||
android:pathData="M11,18.92h2V22h-2z" />
|
||||
<path
|
||||
android:name="qsbIconTintTertiary"
|
||||
android:fillColor="#FBBC05"
|
||||
android:pathData="M7,12H5c0,1.93 0.78,3.68 2.05,4.95l1.41,-1.41C7.56,14.63 7,13.38 7,12z" />
|
||||
<path
|
||||
android:name="qsbIconTintQuaternary"
|
||||
android:fillColor="#EA4335"
|
||||
android:pathData="M12,17c-1.38,0 -2.63,-0.56 -3.54,-1.47l-1.41,1.41C8.32,18.21 10.07,19 12.01,19c3.87,0 6.98,-3.14 6.98,-7h-2c0,2.76 -2.23,5 -4.99,5z" />
|
||||
</vector>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:id="@id/qsbIconTintPrimary" android:drawable="@drawable/ic_mic_color_1" />
|
||||
<item android:id="@id/qsbIconTintSecondary" android:drawable="@drawable/ic_mic_color_2" />
|
||||
<item android:id="@id/qsbIconTintTertiary" android:drawable="@drawable/ic_mic_color_3" />
|
||||
<item android:id="@id/qsbIconTintQuaternary" android:drawable="@drawable/ic_mic_color_4" />
|
||||
</layer-list>
|
||||
@@ -0,0 +1,9 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="#4285F4"
|
||||
android:pathData="M12,15c1.66,0 2.99,-1.34 2.99,-3L15,5c0,-1.66 -1.34,-3 -3,-3S9,3.34 9,5v7c0,1.66 1.34,3 3,3z" />
|
||||
</vector>
|
||||
@@ -0,0 +1,9 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="#34A853"
|
||||
android:pathData="M11,18.92h2V22h-2z" />
|
||||
</vector>
|
||||
@@ -0,0 +1,9 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="#FBBC05"
|
||||
android:pathData="M7,12H5c0,1.93 0.78,3.68 2.05,4.95l1.41,-1.41C7.56,14.63 7,13.38 7,12z" />
|
||||
</vector>
|
||||
@@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:name="qsbIconTintQuaternary"
|
||||
android:fillColor="#EA4335"
|
||||
android:pathData="M12,17c-1.38,0 -2.63,-0.56 -3.54,-1.47l-1.41,1.41C8.32,18.21 10.07,19 12.01,19c3.87,0 6.98,-3.14 6.98,-7h-2c0,2.76 -2.23,5 -4.99,5z" />
|
||||
</vector>
|
||||
@@ -1,22 +1,8 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:name="qsbIconTintPrimary"
|
||||
android:pathData="M23.49,12.27C23.49,11.48 23.42,10.73 23.3,10H12V14.51H18.47C18.18,15.99 17.33,17.24 16.07,18.09V21.09H19.93C22.19,19 23.49,15.92 23.49,12.27Z"
|
||||
android:fillColor="#4285F4"/>
|
||||
<path
|
||||
android:name="qsbIconTintSecondary"
|
||||
android:pathData="M12,24C15.24,24 17.95,22.92 19.93,21.09L16.07,18.09C14.99,18.81 13.62,19.25 12,19.25C8.87,19.25 6.22,17.14 5.27,14.29H1.29V17.38C3.26,21.3 7.31,24 12,24Z"
|
||||
android:fillColor="#34A853"/>
|
||||
<path
|
||||
android:name="qsbIconTintTertiary"
|
||||
android:pathData="M5.27,14.29C5.02,13.57 4.89,12.8 4.89,12C4.89,11.2 5.03,10.43 5.27,9.71V6.62H1.29C0.47,8.24 0,10.06 0,12C0,13.94 0.47,15.76 1.29,17.38L5.27,14.29Z"
|
||||
android:fillColor="#FBBC05"/>
|
||||
<path
|
||||
android:name="qsbIconTintQuaternary"
|
||||
android:pathData="M12,4.75C13.77,4.75 15.35,5.36 16.6,6.55L20.02,3.13C17.95,1.19 15.24,0 12,0C7.31,0 3.26,2.7 1.29,6.62L5.27,9.71C6.22,6.86 8.87,4.75 12,4.75Z"
|
||||
android:fillColor="#EA4335"/>
|
||||
</vector>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:id="@id/qsbIconTintPrimary" android:drawable="@drawable/ic_super_g_color_1" />
|
||||
<item android:id="@id/qsbIconTintSecondary" android:drawable="@drawable/ic_super_g_color_2" />
|
||||
<item android:id="@id/qsbIconTintTertiary" android:drawable="@drawable/ic_super_g_color_3" />
|
||||
<item android:id="@id/qsbIconTintQuaternary" android:drawable="@drawable/ic_super_g_color_4" />
|
||||
</layer-list>
|
||||
@@ -0,0 +1,9 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:pathData="M23.49,12.27C23.49,11.48 23.42,10.73 23.3,10H12V14.51H18.47C18.18,15.99 17.33,17.24 16.07,18.09V21.09H19.93C22.19,19 23.49,15.92 23.49,12.27Z"
|
||||
android:fillColor="#4285F4"/>
|
||||
</vector>
|
||||
@@ -0,0 +1,9 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:pathData="M12,24C15.24,24 17.95,22.92 19.93,21.09L16.07,18.09C14.99,18.81 13.62,19.25 12,19.25C8.87,19.25 6.22,17.14 5.27,14.29H1.29V17.38C3.26,21.3 7.31,24 12,24Z"
|
||||
android:fillColor="#34A853"/>
|
||||
</vector>
|
||||
@@ -0,0 +1,9 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:pathData="M12,4.75C13.77,4.75 15.35,5.36 16.6,6.55L20.02,3.13C17.95,1.19 15.24,0 12,0C7.31,0 3.26,2.7 1.29,6.62L5.27,9.71C6.22,6.86 8.87,4.75 12,4.75Z"
|
||||
android:fillColor="#EA4335"/>
|
||||
</vector>
|
||||
@@ -22,4 +22,9 @@
|
||||
<item type="id" name="font_heading_medium" />
|
||||
<item type="id" name="font_body" />
|
||||
<item type="id" name="font_body_medium" />
|
||||
|
||||
<item type="id" name="qsbIconTintPrimary" />
|
||||
<item type="id" name="qsbIconTintSecondary" />
|
||||
<item type="id" name="qsbIconTintTertiary" />
|
||||
<item type="id" name="qsbIconTintQuaternary" />
|
||||
</resources>
|
||||
@@ -7,7 +7,6 @@ import android.widget.ImageButton
|
||||
import androidx.core.view.isVisible
|
||||
import app.lawnchair.preferences2.PreferenceManager2
|
||||
import com.android.launcher3.R
|
||||
import com.android.launcher3.util.Themes
|
||||
|
||||
@SuppressLint("AppCompatCustomView")
|
||||
class AssistantIconView(context: Context, attrs: AttributeSet?) : ImageButton(context, attrs) {
|
||||
@@ -27,7 +26,7 @@ class AssistantIconView(context: Context, attrs: AttributeSet?) : ImageButton(co
|
||||
clearColorFilter()
|
||||
|
||||
val iconRes = if (isGoogle) R.drawable.ic_mic_color else R.drawable.ic_mic_flat
|
||||
val themingMethod = if (isGoogle) ThemingMethod.THEME_BY_NAME else ThemingMethod.TINT
|
||||
val themingMethod = if (isGoogle) ThemingMethod.THEME_BY_LAYER_ID else ThemingMethod.TINT
|
||||
|
||||
setThemedIconResource(
|
||||
resId = iconRes,
|
||||
|
||||
@@ -1,29 +1,41 @@
|
||||
package app.lawnchair.qsb
|
||||
|
||||
import android.graphics.drawable.LayerDrawable
|
||||
import android.widget.ImageView
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.core.content.res.ResourcesCompat
|
||||
import app.lawnchair.theme.color.ColorTokens
|
||||
import com.devs.vectorchildfinder.VectorChildFinder
|
||||
import com.android.launcher3.R
|
||||
|
||||
fun ImageView.setThemedIconResource(
|
||||
@DrawableRes resId: Int,
|
||||
themed: Boolean,
|
||||
method: ThemingMethod = ThemingMethod.THEME_BY_NAME
|
||||
method: ThemingMethod = ThemingMethod.THEME_BY_LAYER_ID
|
||||
) {
|
||||
if (themed && method == ThemingMethod.THEME_BY_NAME) {
|
||||
val vector = VectorChildFinder(context, resId, this)
|
||||
val primary = vector.findPathByName("qsbIconTintPrimary")
|
||||
val primary2 = vector.findPathByName("qsbIconTintPrimary2")
|
||||
val secondary = vector.findPathByName("qsbIconTintSecondary")
|
||||
val tertiary = vector.findPathByName("qsbIconTintTertiary")
|
||||
val quaternary = vector.findPathByName("qsbIconTintQuaternary")
|
||||
if (themed && method == ThemingMethod.THEME_BY_LAYER_ID) {
|
||||
val drawable = ResourcesCompat.getDrawable(resources, resId, null)!!
|
||||
if (drawable is LayerDrawable) {
|
||||
drawable.mutate()
|
||||
val primary = ColorTokens.QsbIconTintPrimary.resolveColor(context)
|
||||
val secondary = ColorTokens.QsbIconTintSecondary.resolveColor(context)
|
||||
val tertiary = ColorTokens.QsbIconTintTertiary.resolveColor(context)
|
||||
val quaternary = ColorTokens.QsbIconTintQuaternary.resolveColor(context)
|
||||
|
||||
primary?.fillColor = ColorTokens.QsbIconTintPrimary.resolveColor(context)
|
||||
primary2?.fillColor = ColorTokens.QsbIconTintPrimary.resolveColor(context)
|
||||
secondary?.fillColor = ColorTokens.QsbIconTintSecondary.resolveColor(context)
|
||||
tertiary?.fillColor = ColorTokens.QsbIconTintTertiary.resolveColor(context)
|
||||
quaternary?.fillColor = ColorTokens.QsbIconTintQuaternary.resolveColor(context)
|
||||
invalidate()
|
||||
for (i in (0 until drawable.numberOfLayers)) {
|
||||
val color = when (drawable.getId(i)) {
|
||||
R.id.qsbIconTintPrimary -> primary
|
||||
R.id.qsbIconTintSecondary -> secondary
|
||||
R.id.qsbIconTintTertiary -> tertiary
|
||||
R.id.qsbIconTintQuaternary -> quaternary
|
||||
else -> 0
|
||||
}
|
||||
if (color == 0) continue
|
||||
|
||||
val layer = drawable.getDrawable(i)
|
||||
layer.setTint(color)
|
||||
}
|
||||
}
|
||||
setImageDrawable(drawable)
|
||||
} else {
|
||||
setImageResource(resId)
|
||||
if (themed) setColorFilter(ColorTokens.ColorAccent.resolveColor(context))
|
||||
@@ -33,5 +45,5 @@ fun ImageView.setThemedIconResource(
|
||||
|
||||
enum class ThemingMethod {
|
||||
TINT,
|
||||
THEME_BY_NAME
|
||||
THEME_BY_LAYER_ID
|
||||
}
|
||||
@@ -7,7 +7,7 @@ object Google : QsbSearchProvider(
|
||||
id = "google",
|
||||
name = R.string.search_provider_google,
|
||||
icon = R.drawable.ic_super_g_color,
|
||||
themingMethod = ThemingMethod.THEME_BY_NAME,
|
||||
themingMethod = ThemingMethod.THEME_BY_LAYER_ID,
|
||||
packageName = "com.google.android.googlequicksearchbox",
|
||||
action = "android.search.action.GLOBAL_SEARCH",
|
||||
supportVoiceIntent = true,
|
||||
|
||||
@@ -8,7 +8,7 @@ object GoogleGo : QsbSearchProvider(
|
||||
id = "google_go",
|
||||
name = R.string.search_provider_google_go,
|
||||
icon = R.drawable.ic_super_g_color,
|
||||
themingMethod = ThemingMethod.THEME_BY_NAME,
|
||||
themingMethod = ThemingMethod.THEME_BY_LAYER_ID,
|
||||
packageName = "com.google.android.apps.searchlite",
|
||||
action = "android.search.action.GLOBAL_SEARCH",
|
||||
supportVoiceIntent = true,
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="#EA4335"
|
||||
android:pathData="M8,5C6.34,5 5,6.34 5,8V10H3V8C3,5.24 5.24,3 8,3H10V5H8Z" />
|
||||
</vector>
|
||||
@@ -0,0 +1,9 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:pathData="M5.27,14.29C5.02,13.57 4.89,12.8 4.89,12C4.89,11.2 5.03,10.43 5.27,9.71V6.62H1.29C0.47,8.24 0,10.06 0,12C0,13.94 0.47,15.76 1.29,17.38L5.27,14.29Z"
|
||||
android:fillColor="#FBBC05"/>
|
||||
</vector>
|
||||
Reference in new issue
Block a user