Merge "Customize actionless car intents" into rvc-dev am: 6a335a153c am: 3f7c5aafd7
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/SettingsIntelligence/+/11369242
Change-Id: I5f6c8152b020762635f89bb16026b59014234ea6
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 281f5be..8c876bb 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -25,7 +25,7 @@
<uses-permission android:name="android.permission.MODIFY_PHONE_STATE" />
<uses-permission android:name="android.permission.MANAGE_FINGERPRINT" />
- <uses-sdk android:targetSdkVersion="24" />
+ <uses-sdk android:targetSdkVersion="29" />
<application
android:label="@string/app_name_settings_intelligence"
diff --git a/MODULE_LICENSE_APACHE2 b/MODULE_LICENSE_APACHE2
deleted file mode 100644
index e69de29..0000000
--- a/MODULE_LICENSE_APACHE2
+++ /dev/null
diff --git a/res/values/strings.xml b/res/values/strings.xml
index eb768f5..3445e51 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -19,6 +19,9 @@
<!-- Applications settings title. If clicked, the user is taken to a screen full of application settings [CHAR_LIMIT=NONE BACKUP_MESSAGE_ID=5281808652705396152] -->
<string name="applications_settings">App info</string>
+ <!-- Class name for AccessibilityServiceResult Task [CHAR_LIMIT=NONE]-->
+ <string name="accessibility_settings_classname">com.android.settings.accessibility.AccessibilitySettings</string>
+
<!-- Settings title in main settings screen for accessibility settings [CHAR_LIMIT=NONE BACKUP_MESSAGE_ID=3975902491934816215] -->
<string name="accessibility_settings">Accessibility</string>
diff --git a/res/values/themes.xml b/res/values/themes.xml
index 949b6dd..c0453b1 100644
--- a/res/values/themes.xml
+++ b/res/values/themes.xml
@@ -21,6 +21,7 @@
<style name="Theme.Settings.NoActionBar">
<item name="android:windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
+ <item name="android:windowSoftInputMode">adjustPan</item>
</style>
<style name="Theme.CarSettings" parent="@style/Theme.CarUi.WithToolbar"/>
diff --git a/src/com/android/settings/intelligence/search/SearchActivity.java b/src/com/android/settings/intelligence/search/SearchActivity.java
index 8b8bc42..229c926 100644
--- a/src/com/android/settings/intelligence/search/SearchActivity.java
+++ b/src/com/android/settings/intelligence/search/SearchActivity.java
@@ -39,8 +39,6 @@
}
super.onCreate(savedInstanceState);
setContentView(R.layout.search_main);
- // Keeps layouts in-place when keyboard opens.
- getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
FragmentManager fragmentManager = getSupportFragmentManager();
Fragment fragment = fragmentManager.findFragmentById(R.id.main_content);
diff --git a/src/com/android/settings/intelligence/search/SearchFragment.java b/src/com/android/settings/intelligence/search/SearchFragment.java
index 4642b16..c76eda3 100644
--- a/src/com/android/settings/intelligence/search/SearchFragment.java
+++ b/src/com/android/settings/intelligence/search/SearchFragment.java
@@ -344,9 +344,11 @@
final Activity activity = getActivity();
if (activity != null) {
View view = activity.getCurrentFocus();
- InputMethodManager imm = (InputMethodManager)
- activity.getSystemService(Context.INPUT_METHOD_SERVICE);
- imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
+ if (view != null) {
+ InputMethodManager imm = (InputMethodManager)
+ activity.getSystemService(Context.INPUT_METHOD_SERVICE);
+ imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
+ }
}
if (mResultsRecyclerView != null) {
diff --git a/src/com/android/settings/intelligence/search/car/CarSearchFragment.java b/src/com/android/settings/intelligence/search/car/CarSearchFragment.java
index 544bab9..0c49b11 100644
--- a/src/com/android/settings/intelligence/search/car/CarSearchFragment.java
+++ b/src/com/android/settings/intelligence/search/car/CarSearchFragment.java
@@ -32,10 +32,10 @@
import androidx.recyclerview.widget.RecyclerView;
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 com.android.car.ui.toolbar.ToolbarController;
+import com.android.settings.intelligence.R;
import com.android.settings.intelligence.overlay.FeatureFactory;
import com.android.settings.intelligence.search.SearchCommon;
import com.android.settings.intelligence.search.SearchFeatureProvider;
@@ -44,7 +44,6 @@
import com.android.settings.intelligence.search.savedqueries.car.CarSavedQueryController;
import com.android.settings.intelligence.search.savedqueries.car.CarSavedQueryViewHolder;
-import java.util.Collections;
import java.util.List;
/**
@@ -56,7 +55,6 @@
private SearchFeatureProvider mSearchFeatureProvider;
private ToolbarController mToolbar;
- private MenuItem mClearHistoryButton;
private RecyclerView mRecyclerView;
private String mQuery;
@@ -85,7 +83,7 @@
}
protected List<MenuItem> getToolbarMenuItems() {
- return Collections.singletonList(mClearHistoryButton);
+ return null;
}
@Override
@@ -98,12 +96,6 @@
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();
-
if (savedInstanceState != null) {
mQuery = savedInstanceState.getString(SearchCommon.STATE_QUERY);
mShowingSavedQuery = savedInstanceState.getBoolean(
@@ -166,11 +158,7 @@
// If indexing is not finished, register the query text, but don't search.
if (!mSearchFeatureProvider.isIndexingComplete(getActivity())) {
- if (!isEmptyQuery) {
- mToolbar.showProgressBar();
- } else {
- mToolbar.hideProgressBar();
- }
+ mToolbar.getProgressBar().setVisible(!isEmptyQuery);
return;
}
@@ -190,10 +178,6 @@
}
}
- private void onClearHistoryButtonClicked() {
- mSavedQueryController.removeQueries();
- }
-
/**
* Gets called when a saved query is clicked.
*/
@@ -240,7 +224,7 @@
if (getActivity() == null) {
return;
}
- mToolbar.hideProgressBar();
+ mToolbar.getProgressBar().setVisible(false);
if (mShowingSavedQuery) {
mSavedQueryController.loadSavedQueries();
} else {
diff --git a/src/com/android/settings/intelligence/search/query/AccessibilityServiceResultTask.java b/src/com/android/settings/intelligence/search/query/AccessibilityServiceResultTask.java
index cd7b4ad..d6de496 100644
--- a/src/com/android/settings/intelligence/search/query/AccessibilityServiceResultTask.java
+++ b/src/com/android/settings/intelligence/search/query/AccessibilityServiceResultTask.java
@@ -42,8 +42,6 @@
public static final int QUERY_WORKER_ID = SettingsIntelligenceLogProto.SettingsIntelligenceEvent
.SEARCH_QUERY_ACCESSIBILITY_SERVICES;
- private static final String ACCESSIBILITY_SETTINGS_CLASSNAME =
- "com.android.settings.accessibility.AccessibilitySettings";
private static final int NAME_NO_MATCH = -1;
private final AccessibilityManager mAccessibilityManager;
@@ -88,7 +86,8 @@
final String componentName = new ComponentName(serviceInfo.packageName,
serviceInfo.name).flattenToString();
final Intent intent = DatabaseIndexingUtils.buildSearchTrampolineIntent(mContext,
- ACCESSIBILITY_SETTINGS_CLASSNAME, componentName, screenTitle);
+ mContext.getString(R.string.accessibility_settings_classname),
+ componentName, screenTitle);
results.add(new SearchResult.Builder()
.setTitle(title)
@@ -111,7 +110,7 @@
private List<String> getBreadCrumb() {
if (mBreadcrumb == null || mBreadcrumb.isEmpty()) {
mBreadcrumb = mSiteMapManager.buildBreadCrumb(
- mContext, ACCESSIBILITY_SETTINGS_CLASSNAME,
+ mContext, mContext.getString(R.string.accessibility_settings_classname),
mContext.getString(R.string.accessibility_settings));
}
return mBreadcrumb;
diff --git a/src/com/android/settings/intelligence/search/query/CursorToSearchResultConverter.java b/src/com/android/settings/intelligence/search/query/CursorToSearchResultConverter.java
index a57f510..d6d865a 100644
--- a/src/com/android/settings/intelligence/search/query/CursorToSearchResultConverter.java
+++ b/src/com/android/settings/intelligence/search/query/CursorToSearchResultConverter.java
@@ -61,7 +61,7 @@
private final int LONG_TITLE_LENGTH = 20;
- private static final String[] whiteList = {
+ private static final String[] allowList = {
"main_toggle_wifi",
"main_toggle_bluetooth",
"main_toggle_bluetooth_obsolete",
@@ -73,7 +73,7 @@
"data_usage_enable",
"button_roaming_key",
};
- private static final Set<String> prioritySettings = new HashSet(Arrays.asList(whiteList));
+ private static final Set<String> prioritySettings = new HashSet(Arrays.asList(allowList));
public CursorToSearchResultConverter(Context context) {
diff --git a/src/com/android/settings/intelligence/search/query/SearchQueryUtils.java b/src/com/android/settings/intelligence/search/query/SearchQueryUtils.java
index d7011ee..b7ad1bd 100644
--- a/src/com/android/settings/intelligence/search/query/SearchQueryUtils.java
+++ b/src/com/android/settings/intelligence/search/query/SearchQueryUtils.java
@@ -18,6 +18,10 @@
import android.text.TextUtils;
+import com.android.settings.intelligence.search.indexing.IndexData;
+
+import java.util.Locale;
+
/**
* Utils for Query-time operations.
*/
@@ -40,12 +44,18 @@
* resultName: Abcde, query: bc, Returns NAME_NO_MATCH
* resultName: Abcde, query: xyz, Returns NAME_NO_MATCH
* resultName: Abc de, query: de, Returns 4
+ *
+ * In Japanese, normalize resultName to match normalized query.
*/
public static int getWordDifference(String resultName, String query) {
if (TextUtils.isEmpty(resultName) || TextUtils.isEmpty(query)) {
return NAME_NO_MATCH;
}
+ if (Locale.getDefault().equals(Locale.JAPAN)) {
+ resultName = IndexData.normalizeJapaneseString(resultName);
+ }
+
final char[] queryTokens = query.toLowerCase().toCharArray();
final char[] resultTokens = resultName.toLowerCase().toCharArray();
final int resultLength = resultTokens.length;