Skip to content

Commit

Permalink
Launcher3: move/Use switch from system settings
Browse files Browse the repository at this point in the history
* so that it can be anabled disabled for 3rd party launchers (nova etc..)
  • Loading branch information
drkphnx authored and AnkitSavani111 committed Dec 22, 2024
1 parent 4906196 commit 86137f5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 19 deletions.
4 changes: 0 additions & 4 deletions res/values/cr_strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -423,8 +423,4 @@
<!-- Force monochrome icons -->
<string name="force_monochrome_icons_title">Force themed icons</string>
<string name="force_monochrome_icons_summary">Generate monochromatic icons, if not supported by the app (requires re-toggling of themed icons)</string>

<!-- Circle to Search -->
<string name="pref_allow_cts_title">Circle to Search</string>
<string name="pref_allow_cts_summary">Touch and hold the Home button or the navigation handle to search using the content on your screen.</string>
</resources>
7 changes: 0 additions & 7 deletions res/xml/launcher_misc_preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,6 @@
settings:units="px"
android:defaultValue="23" />

<SwitchPreferenceCompat
android:key="pref_allow_cts"
android:title="@string/pref_allow_cts_title"
android:summary="@string/pref_allow_cts_summary"
android:defaultValue="@*android:bool/config_searchAllEntrypointsEnabledDefault"
launcher:iconSpaceReserved="false" />

<androidx.preference.PreferenceScreen
android:persistent="false"
android:title="@string/suggestion_pref_screen_title"
Expand Down
18 changes: 10 additions & 8 deletions src/com/android/launcher3/settings/SettingsMisc.java
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,8 @@ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, Strin
LauncherAppState.INSTANCE.executeIfCreated(app -> app.setNeedsRestart());
break;
case CTS_KEY:
mCtsEnabled = LauncherPrefs.getPrefs(mContext).getBoolean(CTS_KEY, mContextualSearchDefValue);
Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Secure.SEARCH_ALL_ENTRYPOINTS_ENABLED, mCtsEnabled ? 1 : 0);
SystemUiProxy.INSTANCE.get(mContext).setAssistantOverridesRequested(
mCtsEnabled = Settings.Secure.putInt(mContext.getContentResolver(),"search_all_entrypoints_enabled", mCtsEnabled ? 1 : 0);
SystemUiProxy.INSTANCE.get(mContext).setAssistantOverridesRequested(
AssistUtils.newInstance(mContext).getSysUiAssistOverrideInvocationTypes());
break;
default:
Expand Down Expand Up @@ -244,14 +242,18 @@ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
getActivity().setTitle(getPreferenceScreen().getTitle());
}

mContextualSearchDefValue = mContext.getResources().getBoolean(
com.android.internal.R.bool.config_searchAllEntrypointsEnabledDefault);

mCtsEnabled = Settings.Secure.getInt(mContext.getContentResolver(),
Settings.Secure.SEARCH_ALL_ENTRYPOINTS_ENABLED, mContextualSearchDefValue ? 1 : 0) == 1;
"search_all_entrypoints_enabled", mContextualSearchDefValue ? 1 : 0) == 1;

mCtsPref = (SwitchPreferenceCompat) findPreference(CTS_KEY);
if (!AssistUtils.newInstance(mContext).isContextualSearchIntentAvailable()) {
getPreferenceScreen().removePreference(mCtsPref);
Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Secure.SEARCH_ALL_ENTRYPOINTS_ENABLED, 0);
} else {
mCtsPref.setChecked(mCtsEnabled);
Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Secure.SEARCH_ALL_ENTRYPOINTS_ENABLED, mCtsEnabled ? 1 : 0);
}
}

Expand Down

0 comments on commit 86137f5

Please sign in to comment.