Update the target SDK to fix the IME UI issue in landscape mode. am: 0199960756 am: 35743b0062
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/SettingsIntelligence/+/11439288
Change-Id: Id90e69e11386a7c5beedb21119313b293b41c33b
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/CarSearchFeatureProviderImpl.java b/src/com/android/settings/intelligence/search/car/CarSearchFeatureProviderImpl.java
index c141b36..2491cbd 100644
--- a/src/com/android/settings/intelligence/search/car/CarSearchFeatureProviderImpl.java
+++ b/src/com/android/settings/intelligence/search/car/CarSearchFeatureProviderImpl.java
@@ -29,6 +29,7 @@
import com.android.settings.intelligence.search.indexing.DatabaseIndexingManager;
import com.android.settings.intelligence.search.indexing.IndexData;
import com.android.settings.intelligence.search.indexing.IndexingCallback;
+import com.android.settings.intelligence.search.indexing.car.CarDatabaseIndexingManager;
import com.android.settings.intelligence.search.query.DatabaseResultTask;
import com.android.settings.intelligence.search.query.InstalledAppResultTask;
import com.android.settings.intelligence.search.query.SearchQueryTask;
@@ -49,7 +50,7 @@
private static final String TAG = "CarSearchFeatureProvider";
private static final long SMART_SEARCH_RANKING_TIMEOUT = 300L;
- private DatabaseIndexingManager mDatabaseIndexingManager;
+ private CarDatabaseIndexingManager mDatabaseIndexingManager;
private ExecutorService mExecutorService;
private SiteMapManager mSiteMapManager;
@@ -75,7 +76,8 @@
@Override
public DatabaseIndexingManager getIndexingManager(Context context) {
if (mDatabaseIndexingManager == null) {
- mDatabaseIndexingManager = new DatabaseIndexingManager(context.getApplicationContext());
+ mDatabaseIndexingManager = new CarDatabaseIndexingManager(
+ context.getApplicationContext());
}
return mDatabaseIndexingManager;
}
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/indexing/DatabaseIndexingManager.java b/src/com/android/settings/intelligence/search/indexing/DatabaseIndexingManager.java
index 0053f14..32add54 100644
--- a/src/com/android/settings/intelligence/search/indexing/DatabaseIndexingManager.java
+++ b/src/com/android/settings/intelligence/search/indexing/DatabaseIndexingManager.java
@@ -178,7 +178,7 @@
private List<IndexData> getIndexData(PreIndexData data) {
if (mConverter == null) {
- mConverter = new IndexDataConverter(mContext);
+ mConverter = getIndexDataConverter(mContext);
}
return mConverter.convertPreIndexDataToIndexData(data);
}
@@ -186,7 +186,7 @@
private List<SiteMapPair> getSiteMapPairs(List<IndexData> indexData,
List<Pair<String, String>> siteMapClassNames) {
if (mConverter == null) {
- mConverter = new IndexDataConverter(mContext);
+ mConverter = getIndexDataConverter(mContext);
}
return mConverter.convertSiteMapPairs(indexData, siteMapClassNames);
}
@@ -312,6 +312,14 @@
}
}
+ /**
+ * Protected method to get a new IndexDataConverter instance. This method can be overridden
+ * in subclasses to substitute in a custom IndexDataConverter.
+ */
+ protected IndexDataConverter getIndexDataConverter(Context context) {
+ return new IndexDataConverter(context);
+ }
+
public class IndexingTask extends AsyncTask<Void, Void, Void> {
@VisibleForTesting
diff --git a/src/com/android/settings/intelligence/search/indexing/IndexData.java b/src/com/android/settings/intelligence/search/indexing/IndexData.java
index 904deaf..7318eaa 100644
--- a/src/com/android/settings/intelligence/search/indexing/IndexData.java
+++ b/src/com/android/settings/intelligence/search/indexing/IndexData.java
@@ -68,7 +68,7 @@
private static final Pattern REMOVE_DIACRITICALS_PATTERN
= Pattern.compile("\\p{InCombiningDiacriticalMarks}+");
- private IndexData(Builder builder) {
+ protected IndexData(Builder builder) {
locale = Locale.getDefault().toString();
updatedTitle = normalizeHyphen(builder.mTitle);
updatedSummaryOn = normalizeHyphen(builder.mSummaryOn);
@@ -186,6 +186,18 @@
return mKey;
}
+ public String getIntentAction() {
+ return mIntentAction;
+ }
+
+ public String getIntentTargetPackage() {
+ return mIntentTargetPackage;
+ }
+
+ public String getIntentTargetClass() {
+ return mIntentTargetClass;
+ }
+
public Builder setSummaryOn(String summaryOn) {
mSummaryOn = summaryOn;
return this;
@@ -290,9 +302,10 @@
}
/**
- * Adds Intent payload to builder.
+ * Builds Intent payload for the builder.
+ * This protected method that can be overridden in a subclass for custom intents.
*/
- private Intent buildIntent(Context context) {
+ protected Intent buildIntent(Context context) {
final Intent intent;
// TODO REFACTOR (b/62807132) With inline results re-add proper intent support
diff --git a/src/com/android/settings/intelligence/search/indexing/IndexDataConverter.java b/src/com/android/settings/intelligence/search/indexing/IndexDataConverter.java
index bd53596..f57ce6b 100644
--- a/src/com/android/settings/intelligence/search/indexing/IndexDataConverter.java
+++ b/src/com/android/settings/intelligence/search/indexing/IndexDataConverter.java
@@ -165,7 +165,7 @@
// A row is enabled if it does not show up as an nonIndexableKey
boolean enabled = !(nonIndexableKeys != null && nonIndexableKeys.contains(raw.key));
- final IndexData.Builder builder = new IndexData.Builder();
+ final IndexData.Builder builder = getIndexDataBuilder();
builder.setTitle(raw.title)
.setSummaryOn(raw.summaryOn)
.setEntries(raw.entries)
@@ -244,7 +244,7 @@
headerKeywords = XmlParserUtils.getDataKeywords(context, attrs);
enabled = !nonIndexableKeys.contains(headerKey);
// TODO: Set payload type for header results
- IndexData.Builder headerBuilder = new IndexData.Builder();
+ IndexData.Builder headerBuilder = getIndexDataBuilder();
headerBuilder.setTitle(headerTitle)
.setSummaryOn(headerSummary)
.setScreenTitle(screenTitle)
@@ -286,7 +286,7 @@
isHeaderUnique = false;
}
- builder = new IndexData.Builder();
+ builder = getIndexDataBuilder();
builder.setTitle(title)
.setKeywords(keywords)
.setClassName(sir.className)
@@ -365,4 +365,8 @@
final Set<String> result = nonIndexableKeys.get(authority);
return result != null ? result : new ArraySet<>();
}
+
+ protected IndexData.Builder getIndexDataBuilder() {
+ return new IndexData.Builder();
+ }
}
diff --git a/src/com/android/settings/intelligence/search/indexing/car/CarDatabaseIndexingManager.java b/src/com/android/settings/intelligence/search/indexing/car/CarDatabaseIndexingManager.java
new file mode 100644
index 0000000..3026e82
--- /dev/null
+++ b/src/com/android/settings/intelligence/search/indexing/car/CarDatabaseIndexingManager.java
@@ -0,0 +1,39 @@
+/*
+ * 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.indexing.car;
+
+import android.content.Context;
+
+import com.android.settings.intelligence.search.indexing.DatabaseIndexingManager;
+import com.android.settings.intelligence.search.indexing.IndexDataConverter;
+import com.android.settings.intelligence.search.indexing.PreIndexData;
+
+/**
+ * Car extension to {@link DatabaseIndexingManager} to use {@link CarIndexDataConverter} for
+ * converting {@link PreIndexData} into {@link CarIndexData}.
+ */
+public class CarDatabaseIndexingManager extends DatabaseIndexingManager {
+
+ public CarDatabaseIndexingManager(Context context) {
+ super(context);
+ }
+
+ @Override
+ protected IndexDataConverter getIndexDataConverter(Context context) {
+ return new CarIndexDataConverter(context);
+ }
+}
diff --git a/src/com/android/settings/intelligence/search/indexing/car/CarIndexData.java b/src/com/android/settings/intelligence/search/indexing/car/CarIndexData.java
new file mode 100644
index 0000000..a57d003
--- /dev/null
+++ b/src/com/android/settings/intelligence/search/indexing/car/CarIndexData.java
@@ -0,0 +1,46 @@
+/*
+ * 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.indexing.car;
+
+import android.content.Context;
+import android.content.Intent;
+
+import com.android.settings.intelligence.search.indexing.DatabaseIndexingUtils;
+import com.android.settings.intelligence.search.indexing.IndexData;
+
+/**
+ * Car data class representing a single row in the Setting Search results database.
+ */
+public class CarIndexData extends IndexData {
+
+ public CarIndexData(IndexData.Builder builder) {
+ super(builder);
+ }
+
+ /**
+ * Builder class for {@link CarIndexData}, extending {@link IndexData.Builder}, which replaces
+ * all intents with direct search intents, since CarSettings doesn't support
+ * SearchResultTrampolineIntents.
+ */
+ public static class Builder extends IndexData.Builder {
+ @Override
+ protected Intent buildIntent(Context context) {
+ return DatabaseIndexingUtils.buildDirectSearchResultIntent(getIntentAction(),
+ getIntentTargetPackage(), getIntentTargetClass(), getKey());
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/com/android/settings/intelligence/search/indexing/car/CarIndexDataConverter.java b/src/com/android/settings/intelligence/search/indexing/car/CarIndexDataConverter.java
new file mode 100644
index 0000000..11f35cb
--- /dev/null
+++ b/src/com/android/settings/intelligence/search/indexing/car/CarIndexDataConverter.java
@@ -0,0 +1,38 @@
+/*
+ * 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.indexing.car;
+
+import android.content.Context;
+
+import com.android.settings.intelligence.search.indexing.IndexData;
+import com.android.settings.intelligence.search.indexing.IndexDataConverter;
+import com.android.settings.intelligence.search.indexing.PreIndexData;
+
+/**
+ * Car helper class to convert {@link PreIndexData} to {@link CarIndexData}.
+ */
+public class CarIndexDataConverter extends IndexDataConverter {
+
+ public CarIndexDataConverter(Context context) {
+ super(context);
+ }
+
+ @Override
+ protected IndexData.Builder getIndexDataBuilder() {
+ return new CarIndexData.Builder();
+ }
+}
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;