Loading Android.bp +2 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ android_app { privileged: true, required: ["privapp_whitelist_com.android.settings.intelligence"], libs: ["android.car-stubs"], static_libs: [ "androidx.legacy_legacy-support-v4", "androidx.legacy_legacy-support-v13", Loading @@ -30,6 +31,7 @@ android_app { "androidx.preference_preference", "androidx.recyclerview_recyclerview", "androidx.legacy_legacy-preference-v14", "car-ui-lib", ], resource_dirs: ["res"], srcs: [ Loading OWNERS +2 −1 Original line number Diff line number Diff line ## People who can approve changes # Android auto rlagos@google.com rlagos@google.com # OWNER for SUW related code ericberglund@google.com # OWNER for Car Settings related code # TV Settings leifhendrik@google.com Loading res/values/themes.xml +2 −0 Original line number Diff line number Diff line Loading @@ -22,4 +22,6 @@ <item name="android:windowActionBar">false</item> <item name="android:windowNoTitle">true</item> </style> <style name="Theme.CarSettings" parent="@style/Theme.CarUi.WithToolbar"/> </resources> No newline at end of file res/xml/car_search_fragment.xml 0 → 100644 +21 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- ~ Copyright (C) 2020 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. --> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" xmlns:settings="http://schemas.android.com/apk/res-auto" android:title="@string/app_name_settings_intelligence"/> src/com/android/settings/intelligence/search/CarSearchFragment.java 0 → 100644 +90 −0 Original line number Diff line number Diff line /* * Copyright (C) 2020 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. */ package com.android.settings.intelligence.search; import static com.android.car.ui.core.CarUi.requireInsets; import static com.android.car.ui.core.CarUi.requireToolbar; import android.os.Bundle; import com.android.car.ui.preference.PreferenceFragment; import com.android.car.ui.toolbar.ToolbarController; import com.android.settings.intelligence.R; import com.android.car.ui.toolbar.MenuItem; import com.android.car.ui.toolbar.Toolbar; import java.util.Collections; import java.util.List; /** * Search fragment for car settings */ public class CarSearchFragment extends PreferenceFragment { private MenuItem mClearHistoryButton; @Override public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { setPreferencesFromResource(R.xml.car_search_fragment, rootKey); } protected ToolbarController getToolbar() { return requireToolbar(requireActivity()); } protected List<MenuItem> getToolbarMenuItems() { return Collections.singletonList(mClearHistoryButton); } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mClearHistoryButton = new MenuItem.Builder(getContext()) .setTitle(R.string.search_clear_history) .setDisplayBehavior(MenuItem.DisplayBehavior.NEVER) .setOnClickListener(i -> onClearHistoryButtonClicked()) .build(); } @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); ToolbarController toolbar = getToolbar(); if (toolbar != null) { List<MenuItem> items = getToolbarMenuItems(); toolbar.setTitle(getPreferenceScreen().getTitle()); toolbar.setMenuItems(items); toolbar.setNavButtonMode(Toolbar.NavButtonMode.BACK); toolbar.setState(Toolbar.State.SUBPAGE); toolbar.setState(Toolbar.State.SEARCH); toolbar.setSearchHint(R.string.abc_search_hint); toolbar.registerOnSearchListener(this::onQueryTextChange); toolbar.setShowMenuItemsWhileSearching(true); } } @Override public void onStart() { super.onStart(); onCarUiInsetsChanged(requireInsets(requireActivity())); } private void onQueryTextChange(String query) {} private void onClearHistoryButtonClicked() {} } Loading
Android.bp +2 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ android_app { privileged: true, required: ["privapp_whitelist_com.android.settings.intelligence"], libs: ["android.car-stubs"], static_libs: [ "androidx.legacy_legacy-support-v4", "androidx.legacy_legacy-support-v13", Loading @@ -30,6 +31,7 @@ android_app { "androidx.preference_preference", "androidx.recyclerview_recyclerview", "androidx.legacy_legacy-preference-v14", "car-ui-lib", ], resource_dirs: ["res"], srcs: [ Loading
OWNERS +2 −1 Original line number Diff line number Diff line ## People who can approve changes # Android auto rlagos@google.com rlagos@google.com # OWNER for SUW related code ericberglund@google.com # OWNER for Car Settings related code # TV Settings leifhendrik@google.com Loading
res/values/themes.xml +2 −0 Original line number Diff line number Diff line Loading @@ -22,4 +22,6 @@ <item name="android:windowActionBar">false</item> <item name="android:windowNoTitle">true</item> </style> <style name="Theme.CarSettings" parent="@style/Theme.CarUi.WithToolbar"/> </resources> No newline at end of file
res/xml/car_search_fragment.xml 0 → 100644 +21 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- ~ Copyright (C) 2020 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. --> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" xmlns:settings="http://schemas.android.com/apk/res-auto" android:title="@string/app_name_settings_intelligence"/>
src/com/android/settings/intelligence/search/CarSearchFragment.java 0 → 100644 +90 −0 Original line number Diff line number Diff line /* * Copyright (C) 2020 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. */ package com.android.settings.intelligence.search; import static com.android.car.ui.core.CarUi.requireInsets; import static com.android.car.ui.core.CarUi.requireToolbar; import android.os.Bundle; import com.android.car.ui.preference.PreferenceFragment; import com.android.car.ui.toolbar.ToolbarController; import com.android.settings.intelligence.R; import com.android.car.ui.toolbar.MenuItem; import com.android.car.ui.toolbar.Toolbar; import java.util.Collections; import java.util.List; /** * Search fragment for car settings */ public class CarSearchFragment extends PreferenceFragment { private MenuItem mClearHistoryButton; @Override public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { setPreferencesFromResource(R.xml.car_search_fragment, rootKey); } protected ToolbarController getToolbar() { return requireToolbar(requireActivity()); } protected List<MenuItem> getToolbarMenuItems() { return Collections.singletonList(mClearHistoryButton); } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mClearHistoryButton = new MenuItem.Builder(getContext()) .setTitle(R.string.search_clear_history) .setDisplayBehavior(MenuItem.DisplayBehavior.NEVER) .setOnClickListener(i -> onClearHistoryButtonClicked()) .build(); } @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); ToolbarController toolbar = getToolbar(); if (toolbar != null) { List<MenuItem> items = getToolbarMenuItems(); toolbar.setTitle(getPreferenceScreen().getTitle()); toolbar.setMenuItems(items); toolbar.setNavButtonMode(Toolbar.NavButtonMode.BACK); toolbar.setState(Toolbar.State.SUBPAGE); toolbar.setState(Toolbar.State.SEARCH); toolbar.setSearchHint(R.string.abc_search_hint); toolbar.registerOnSearchListener(this::onQueryTextChange); toolbar.setShowMenuItemsWhileSearching(true); } } @Override public void onStart() { super.onStart(); onCarUiInsetsChanged(requireInsets(requireActivity())); } private void onQueryTextChange(String query) {} private void onClearHistoryButtonClicked() {} }