6 package com.google.appinventor.components.runtime.util;
8 import static android.graphics.PorterDuff.Mode.MULTIPLY;
10 import android.app.Activity;
11 import android.content.res.ColorStateList;
12 import android.view.View;
13 import android.view.ViewGroup;
14 import android.widget.ImageView;
15 import androidx.core.widget.ImageViewCompat;
16 import java.util.LinkedList;
17 import java.util.Queue;
29 ColorStateList stateList =
new ColorStateList(
new int[][]{
new int[]{}},
new int[]{color});
30 ImageView view = findOverflowMenuView(activity);
32 ImageViewCompat.setImageTintMode(view, MULTIPLY);
33 ImageViewCompat.setImageTintList(view, stateList);
37 private static ImageView findOverflowMenuView(Activity activity) {
38 ViewGroup vg = (ViewGroup) activity.getWindow().getDecorView();
39 Queue<ViewGroup> children =
new LinkedList<ViewGroup>();
41 while (children.size() > 0) {
43 for (
int i = 0; i < vg.getChildCount(); i++) {
44 View child = vg.getChildAt(i);
45 if (child instanceof ImageView) {
46 return (ImageView) child;
47 }
else if (child instanceof ViewGroup) {
48 children.add((ViewGroup) child);