Make smart actions icon to respect dark theme setting

Problem:
The context from getPackageContext() does not have the theme set.

Solution:
Use the SystemUI theme to inflate the icon.
And we probably want to have a unified theme for all action chips anyway.

Test: Send myself a message "Code 12345", Verify that the
      icon works in both light and dark theme.
Test: Send myself a message "www.android.com", verify that the
      app icon is shown properly in both light and dark theme

Fixes: 142972040

Merged-In: I60f5fbea802fe1fdf498e93dfa4fdcebf38af78c
Change-Id: I60f5fbea802fe1fdf498e93dfa4fdcebf38af78c
This commit is contained in:
Tony Mak
2019-11-04 16:15:08 +00:00
parent e39c7bd211
commit 7773a752ec

View File

@@ -22,6 +22,7 @@ import android.text.TextPaint;
import android.text.method.TransformationMethod;
import android.util.AttributeSet;
import android.util.Log;
import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -238,13 +239,15 @@ public class SmartReplyView extends ViewGroup {
public List<Button> inflateSmartActions(Context packageContext,
@NonNull SmartActions smartActions, SmartReplyController smartReplyController,
NotificationEntry entry, HeadsUpManager headsUpManager, boolean delayOnClickListener) {
Context themedPackageContext = new ContextThemeWrapper(packageContext, mContext.getTheme());
List<Button> buttons = new ArrayList<>();
int numSmartActions = smartActions.actions.size();
for (int n = 0; n < numSmartActions; n++) {
Notification.Action action = smartActions.actions.get(n);
if (action.actionIntent != null) {
buttons.add(inflateActionButton(
this, getContext(), packageContext, n, smartActions, smartReplyController,
this, getContext(), themedPackageContext, n, smartActions,
smartReplyController,
entry, headsUpManager, delayOnClickListener));
}
}