mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-19 18:58:19 +00:00
Add option to use Google Assistant on the searchbar instead of voice search
This commit is contained in:
7
res/drawable/opa_assistant_logo.xml
Normal file
7
res/drawable/opa_assistant_logo.xml
Normal file
@@ -0,0 +1,7 @@
|
||||
<vector android:height="24dp" android:viewportHeight="512.0"
|
||||
android:viewportWidth="512.0" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="#2196F3" android:pathData="M156.3,167.7m-156.3,0a156.3,156.3 0,1 1,312.5 0a156.3,156.3 0,1 1,-312.5 0"/>
|
||||
<path android:fillColor="#00C853" android:pathData="M512,182.9c0,17.5 -14.2,31.8 -31.8,31.8s-31.8,-14.2 -31.8,-31.8c0,-17.5 14.2,-31.8 31.8,-31.8S512,165.4 512,182.9z"/>
|
||||
<path android:fillColor="#F44336" android:pathData="M454.8,260.4c0,35.1 -28.4,63.5 -63.5,63.5c-35.1,0 -63.5,-28.4 -63.5,-63.5c0,-35.1 28.4,-63.5 63.5,-63.5C426.4,196.9 454.8,225.4 454.8,260.4z"/>
|
||||
<path android:fillColor="#FFEB3B" android:pathData="M467.5,424.3c0,42.1 -34.1,76.2 -76.2,76.2c-42.1,0 -76.2,-34.1 -76.2,-76.2c0,-42.1 34.1,-76.2 76.2,-76.2C433.4,348.1 467.5,382.2 467.5,424.3z"/>
|
||||
</vector>
|
||||
7
res/drawable/opa_assistant_logo_shadow.xml
Normal file
7
res/drawable/opa_assistant_logo_shadow.xml
Normal file
@@ -0,0 +1,7 @@
|
||||
<vector android:height="24dp" android:viewportHeight="512.0"
|
||||
android:viewportWidth="512.0" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="#FFF" android:pathData="M156.3,167.7m-156.3,0a156.3,156.3 0,1 1,312.5 0a156.3,156.3 0,1 1,-312.5 0"/>
|
||||
<path android:fillColor="#FFF" android:pathData="M512,182.9c0,17.5 -14.2,31.8 -31.8,31.8s-31.8,-14.2 -31.8,-31.8c0,-17.5 14.2,-31.8 31.8,-31.8S512,165.4 512,182.9z"/>
|
||||
<path android:fillColor="#FFF" android:pathData="M454.8,260.4c0,35.1 -28.4,63.5 -63.5,63.5c-35.1,0 -63.5,-28.4 -63.5,-63.5c0,-35.1 28.4,-63.5 63.5,-63.5C426.4,196.9 454.8,225.4 454.8,260.4z"/>
|
||||
<path android:fillColor="#FFF" android:pathData="M467.5,424.3c0,42.1 -34.1,76.2 -76.2,76.2c-42.1,0 -76.2,-34.1 -76.2,-76.2c0,-42.1 34.1,-76.2 76.2,-76.2C433.4,348.1 467.5,382.2 467.5,424.3z"/>
|
||||
</vector>
|
||||
@@ -541,6 +541,8 @@
|
||||
<string name="action_do_nothing_class" translatable="false">ch.deletescape.lawnchair.gestures.BlankGestureHandler</string>
|
||||
<string name="pref_show_assistant_title">Show voice search button</string>
|
||||
<string name="pref_show_assistant_summary">Display a voice search button in the Google search bar</string>
|
||||
<string name="pref_show_as_assistant_title">Show as Assistant</string>
|
||||
<string name="pref_show_as_assistant_summary">Display a Google Assistant button instead of voice search</string>
|
||||
<string name="current_weather_provider">Current weather provider</string>
|
||||
<string name="smartspace_time_24_h">Show time in 24 hours</string>
|
||||
<string name="weather_provider_disabled">Disabled</string>
|
||||
|
||||
@@ -65,6 +65,14 @@
|
||||
android:summary="@string/pref_show_assistant_summary"
|
||||
android:title="@string/pref_show_assistant_title" />
|
||||
|
||||
<ch.deletescape.lawnchair.preferences.StyledSwitchPreferenceCompat
|
||||
android:defaultValue="true"
|
||||
android:key="opa_assistant"
|
||||
android:persistent="true"
|
||||
android:dependency="opa_enabled"
|
||||
android:summary="@string/pref_show_as_assistant_summary"
|
||||
android:title="@string/pref_show_as_assistant_title" />
|
||||
|
||||
<ch.deletescape.lawnchair.preferences.StyledSwitchPreferenceCompat
|
||||
android:defaultValue="false"
|
||||
android:key="pref_enableBlur"
|
||||
|
||||
@@ -7,6 +7,7 @@ import android.content.SharedPreferences;
|
||||
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
|
||||
import android.graphics.*;
|
||||
import android.graphics.PorterDuff.Mode;
|
||||
import android.support.annotation.DrawableRes;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
@@ -27,6 +28,8 @@ public abstract class AbstractQsbLayout extends FrameLayout implements LauncherL
|
||||
protected Bitmap mShadowBitmap;
|
||||
protected final Paint mShadowPaint;
|
||||
|
||||
private boolean mShowAssistant;
|
||||
|
||||
protected abstract int getWidth(int i);
|
||||
|
||||
protected abstract void loadBottomMargin();
|
||||
@@ -160,7 +163,7 @@ public abstract class AbstractQsbLayout extends FrameLayout implements LauncherL
|
||||
|
||||
public void onClick(View view) {
|
||||
if (view == mMicIconView) {
|
||||
fallbackSearch("android.intent.action.VOICE_ASSIST");
|
||||
fallbackSearch(mShowAssistant ? Intent.ACTION_VOICE_COMMAND : "android.intent.action.VOICE_ASSIST");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,17 +177,31 @@ public abstract class AbstractQsbLayout extends FrameLayout implements LauncherL
|
||||
}
|
||||
}
|
||||
|
||||
protected @DrawableRes int getMicResource() {
|
||||
return getMicResource(true);
|
||||
}
|
||||
|
||||
protected @DrawableRes int getMicResource(boolean colored){
|
||||
if(colored){
|
||||
return mShowAssistant ? R.drawable.opa_assistant_logo : R.drawable.ic_mic_color;
|
||||
} else {
|
||||
return mShowAssistant ? R.drawable.opa_assistant_logo_shadow : R.drawable.ic_mic_shadow;
|
||||
}
|
||||
}
|
||||
|
||||
protected void noGoogleAppSearch() {
|
||||
}
|
||||
|
||||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String str) {
|
||||
if ("opa_enabled".equals(str)) {
|
||||
if ("opa_enabled".equals(str) || "opa_assistant".equals(str)) {
|
||||
loadPreferences(sharedPreferences);
|
||||
}
|
||||
}
|
||||
|
||||
private void loadPreferences(SharedPreferences sharedPreferences) {
|
||||
mShowAssistant = sharedPreferences.getBoolean("opa_assistant", true);
|
||||
mMicIconView.setVisibility(!sharedPreferences.getBoolean("opa_enabled", false) ? View.GONE : View.VISIBLE);
|
||||
mMicIconView.setImageResource(getMicResource());
|
||||
requestLayout();
|
||||
}
|
||||
}
|
||||
@@ -264,7 +264,6 @@ public class AllAppsQsbLayout extends AbstractQsbLayout implements SearchUiManag
|
||||
mAllAppsGoogleSearch = allAppsGoogleSearch;
|
||||
mSearchIcon.setImageResource(mAllAppsGoogleSearch ?
|
||||
R.drawable.ic_super_g_color : R.drawable.ic_allapps_search);
|
||||
mMicIconView.setImageResource(mAllAppsGoogleSearch ? R.drawable.ic_mic_color : 0);
|
||||
if (mAllAppsGoogleSearch) {
|
||||
removeFallbackView();
|
||||
mSearchIcon.clearColorFilter();
|
||||
@@ -280,6 +279,11 @@ public class AllAppsQsbLayout extends AbstractQsbLayout implements SearchUiManag
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getMicResource(boolean colored) {
|
||||
return mAllAppsGoogleSearch ? super.getMicResource(colored) : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAccentChange(int color, int foregroundColor) {
|
||||
if (mSearchIcon != null) {
|
||||
|
||||
@@ -77,6 +77,11 @@ public class HotseatQsbWidget extends AbstractQsbLayout implements LawnchairPref
|
||||
bz(getResources().getColor(mIsGoogleColored ? R.color.qsb_background_hotseat_white : R.color.qsb_background_hotseat_default));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getMicResource() {
|
||||
return super.getMicResource(mIsGoogleColored);
|
||||
}
|
||||
|
||||
private void openQSB() {
|
||||
mSearchRequested = false;
|
||||
playAnimation(mGoogleHasFocus = true, true);
|
||||
|
||||
Reference in New Issue
Block a user