Correct colors for icons in "Search settings" for dark theme
Create a themed app context with theme from R.style.Theme_Settings.
After that create a context with theme from themed app context
before getting the drawable from the package.
Bug: 139695450
Test: Manual - set dark theme and search for 'media volume'
in settings. The icon should be visible
Change-Id: I40ea745046074ddd80c01cb35ebaf566ffa80b74
diff --git a/src/com/android/settings/intelligence/search/query/CursorToSearchResultConverter.java b/src/com/android/settings/intelligence/search/query/CursorToSearchResultConverter.java
index dad9f14..a57f510 100644
--- a/src/com/android/settings/intelligence/search/query/CursorToSearchResultConverter.java
+++ b/src/com/android/settings/intelligence/search/query/CursorToSearchResultConverter.java
@@ -27,7 +27,9 @@
import android.os.BadParcelableException;
import android.text.TextUtils;
import android.util.Log;
+import android.view.ContextThemeWrapper;
+import com.android.settings.intelligence.R;
import com.android.settings.intelligence.search.ResultPayload;
import com.android.settings.intelligence.search.ResultPayloadUtils;
import com.android.settings.intelligence.search.SearchResult;
@@ -162,7 +164,11 @@
Context packageContext = contextMap.get(pkgName);
if (packageContext == null) {
try {
- packageContext = mContext.createPackageContext(pkgName, 0);
+ final Context themedAppContext = new ContextThemeWrapper(
+ mContext, R.style.Theme_Settings);
+ packageContext = new ContextThemeWrapper(
+ themedAppContext.createPackageContext(pkgName, 0),
+ themedAppContext.getTheme());
contextMap.put(pkgName, packageContext);
} catch (PackageManager.NameNotFoundException e) {
Log.e(TAG, "Cannot create Context for package: " + pkgName);