Refactored the contextual group of buttons that appear on the nav bar

Refactored NavigationBarView's contextual buttons to keep track of just
one button's visiblity with its container group. The visiblity is
determined by the priority of the buttons. For example, accessibility
has the highest priority, if that is visible, no other buttons can take
its place, however if menu button is visible, then rotation can appear
instead.

Bug: 116041410
Test: atest NavigationBarContextTest
Change-Id: Ic0762c7b7121a313b7c08989f9ab761426372c5c
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonDrawable.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonDrawable.java
index 945d9b9..2340786 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonDrawable.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonDrawable.java
@@ -19,6 +19,7 @@
 import android.animation.ArgbEvaluator;
 import android.annotation.ColorInt;
 import android.annotation.DrawableRes;
+import android.annotation.NonNull;
 import android.content.Context;
 import android.content.res.Resources;
 import android.graphics.Bitmap;
@@ -35,6 +36,7 @@
 import android.graphics.drawable.AnimatedVectorDrawable;
 import android.graphics.drawable.Drawable;
 import android.util.FloatProperty;
+import android.view.ContextThemeWrapper;
 import com.android.settingslib.Utils;
 import com.android.systemui.R;
 
@@ -388,6 +390,23 @@
         }
     }
 
+    /**
+     * Creates a KeyButtonDrawable with a shadow given its icon. The tint applied to the drawable
+     * is determined by the dark and light theme given by the context.
+     * @param ctx Context to get the drawable and determine the dark and light theme
+     * @param icon the icon resource id
+     * @param hasShadow if a shadow will appear with the drawable
+     * @return KeyButtonDrawable
+     */
+    public static KeyButtonDrawable create(@NonNull Context ctx, @DrawableRes int icon,
+        boolean hasShadow) {
+        final int dualToneDarkTheme = Utils.getThemeAttr(ctx, R.attr.darkIconTheme);
+        final int dualToneLightTheme = Utils.getThemeAttr(ctx, R.attr.lightIconTheme);
+        Context lightContext = new ContextThemeWrapper(ctx, dualToneLightTheme);
+        Context darkContext = new ContextThemeWrapper(ctx, dualToneDarkTheme);
+        return KeyButtonDrawable.create(lightContext, darkContext, icon, hasShadow);
+    }
+
     public static KeyButtonDrawable create(Context lightContext, Context darkContext,
         @DrawableRes int iconResId, boolean hasShadow) {
         return create(lightContext,