mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-27 15:26:58 +00:00
Use alternate qsb icons when search provider is not google
This commit is contained in:
25
lawnchair/res/drawable/ic_qsb_search.xml
Normal file
25
lawnchair/res/drawable/ic_qsb_search.xml
Normal file
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Copyright (C) 2016 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportHeight="18.0"
|
||||
android:viewportWidth="18.0"
|
||||
android:autoMirrored="true">
|
||||
<path
|
||||
android:fillColor="#ffffff"
|
||||
android:pathData="M12.5 11H11.71L11.43 10.73C12.63 9.33001 13.25 7.42002 12.91 5.39002C12.44 2.61002 10.12 0.390015 7.32001 0.0500152C3.09001 -0.469985 -0.469985 3.09001 0.0500152 7.32001C0.390015 10.12 2.61002 12.44 5.39002 12.91C7.42002 13.25 9.33001 12.63 10.73 11.43L11 11.71V12.5L15.25 16.75C15.66 17.16 16.33 17.16 16.74 16.75C17.15 16.34 17.15 15.67 16.74 15.26L12.5 11ZM6.50002 11C4.01002 11 2.00002 8.99002 2.00002 6.50002C2.00002 4.01002 4.01002 2.00002 6.50002 2.00002C8.99002 2.00002 11 4.01002 11 6.50002C11 8.99002 8.99002 11 6.50002 11Z" />
|
||||
</vector>
|
||||
@@ -8,6 +8,7 @@ import android.widget.ImageButton
|
||||
import androidx.core.view.isVisible
|
||||
import com.android.launcher3.R
|
||||
import com.android.launcher3.qsb.QsbContainerView
|
||||
import com.android.launcher3.util.Themes
|
||||
|
||||
@SuppressLint("AppCompatCustomView")
|
||||
class AssistantIconView(context: Context, attrs: AttributeSet?) : ImageButton(context, attrs) {
|
||||
@@ -26,7 +27,13 @@ class AssistantIconView(context: Context, attrs: AttributeSet?) : ImageButton(co
|
||||
}
|
||||
}
|
||||
|
||||
fun setIcon() {
|
||||
setImageResource(R.drawable.ic_mic_color)
|
||||
fun setIcon(isGoogle: Boolean) {
|
||||
clearColorFilter()
|
||||
if (isGoogle) {
|
||||
setImageResource(R.drawable.ic_mic_color)
|
||||
} else {
|
||||
setImageResource(R.drawable.ic_mic_flat)
|
||||
setColorFilter(Themes.getColorAccent(context))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import com.android.launcher3.BaseActivity
|
||||
import com.android.launcher3.DeviceProfile
|
||||
import com.android.launcher3.R
|
||||
import com.android.launcher3.qsb.QsbContainerView
|
||||
import com.android.launcher3.util.Themes
|
||||
import com.android.launcher3.views.ActivityContext
|
||||
|
||||
class QsbLayout(context: Context, attrs: AttributeSet?) : FrameLayout(context, attrs) {
|
||||
@@ -24,7 +25,6 @@ class QsbLayout(context: Context, attrs: AttributeSet?) : FrameLayout(context, a
|
||||
override fun onFinishInflate() {
|
||||
super.onFinishInflate()
|
||||
assistantIcon = ViewCompat.requireViewById(this, R.id.mic_icon)
|
||||
assistantIcon.setIcon()
|
||||
lensIcon = ViewCompat.requireViewById(this, R.id.lens_icon)
|
||||
|
||||
val searchPackage = QsbContainerView.getSearchWidgetPackageName(context)
|
||||
@@ -34,8 +34,15 @@ class QsbLayout(context: Context, attrs: AttributeSet?) : FrameLayout(context, a
|
||||
.setPackage(searchPackage)
|
||||
context.startActivity(intent)
|
||||
}
|
||||
if (searchPackage == GOOGLE_PACKAGE) {
|
||||
|
||||
val isGoogle = searchPackage == GOOGLE_PACKAGE
|
||||
assistantIcon.setIcon(isGoogle)
|
||||
if (isGoogle) {
|
||||
setupLensIcon()
|
||||
} else {
|
||||
val gIcon = ViewCompat.requireViewById<ImageView>(this, R.id.g_icon)
|
||||
gIcon.setImageResource(R.drawable.ic_qsb_search)
|
||||
gIcon.setColorFilter(Themes.getColorAccent(context))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
12
res/drawable/ic_mic_flat.xml
Normal file
12
res/drawable/ic_mic_flat.xml
Normal file
@@ -0,0 +1,12 @@
|
||||
<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 15C13.66 15 14.99 13.66 14.99 12L15 5C15 3.34 13.66 2 12 2C10.34 2 9 3.34 9 5V12C9 13.66 10.34 15 12 15Z"
|
||||
android:fillColor="#ffffff"/>
|
||||
<path
|
||||
android:pathData="M7 12H5C5 13.93 5.78 15.68 7.05 16.95L7.0549 16.9451C8.09967 17.9877 9.46835 18.7059 11 18.9276V22H13V18.9304C16.3969 18.4488 18.9898 15.5245 18.9898 12H16.9898C16.9898 14.76 14.7598 17 11.9998 17C10.6198 17 9.3698 16.44 8.4598 15.53L8.45493 15.5349C7.5579 14.6253 7 13.3774 7 12Z"
|
||||
android:fillColor="#ffffff"/>
|
||||
</vector>
|
||||
Reference in New Issue
Block a user