Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/ContextualButton.java +6 −12 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ public class ContextualButton extends ButtonDispatcher { private ContextButtonListener mListener; private ContextualButtonGroup mGroup; protected final Context mLightContext; protected final @DrawableRes int mIconResId; /** Loading @@ -42,8 +43,10 @@ public class ContextualButton extends ButtonDispatcher { * @param buttonResId the button view from xml layout * @param iconResId icon resource to be used */ public ContextualButton(@IdRes int buttonResId, @DrawableRes int iconResId) { public ContextualButton(@IdRes int buttonResId, Context lightContext, @DrawableRes int iconResId) { super(buttonResId); mLightContext = lightContext; mIconResId = iconResId; } Loading Loading @@ -117,17 +120,8 @@ public class ContextualButton extends ButtonDispatcher { } protected KeyButtonDrawable getNewDrawable(int lightIconColor, int darkIconColor) { return KeyButtonDrawable.create(getContext().getApplicationContext(), lightIconColor, darkIconColor, mIconResId, false /* shadow */, null /* ovalBackground */); } /** * This context is from the view that could be stale after rotation or config change. To get * correct resources use getApplicationContext() as well. * @return current view context */ protected Context getContext() { return getCurrentView().getContext(); return KeyButtonDrawable.create(mLightContext, lightIconColor, darkIconColor, mIconResId, false /* shadow */, null /* ovalBackground */); } public interface ContextButtonListener { Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java +4 −3 Original line number Diff line number Diff line Loading @@ -295,11 +295,12 @@ public class NavigationBarView extends FrameLayout implements // Set up the context group of buttons mContextualButtonGroup = new ContextualButtonGroup(R.id.menu_container); final ContextualButton imeSwitcherButton = new ContextualButton(R.id.ime_switcher, R.drawable.ic_ime_switcher_default); mLightContext, R.drawable.ic_ime_switcher_default); final RotationContextButton rotateSuggestionButton = new RotationContextButton( R.id.rotate_suggestion, R.drawable.ic_sysbar_rotate_button_ccw_start_0); R.id.rotate_suggestion, mLightContext, R.drawable.ic_sysbar_rotate_button_ccw_start_0); final ContextualButton accessibilityButton = new ContextualButton(R.id.accessibility_button, new ContextualButton(R.id.accessibility_button, mLightContext, R.drawable.ic_sysbar_accessibility_button); mContextualButtonGroup.addButton(imeSwitcherButton); if (!isGesturalMode) { Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/RotationButtonController.java +0 −1 Original line number Diff line number Diff line Loading @@ -283,7 +283,6 @@ public class RotationButtonController { return; } // TODO: Remove styles? // Prepare to show the navbar icon by updating the icon style to change anim params mLastRotationSuggestion = rotation; // Remember rotation for click final boolean rotationCCW = isRotationAnimationCCW(windowRotation, rotation); Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/RotationContextButton.java +7 −2 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.systemui.statusbar.phone; import android.annotation.DrawableRes; import android.annotation.IdRes; import android.content.Context; import android.view.View; import com.android.systemui.statusbar.policy.KeyButtonDrawable; Loading @@ -28,8 +29,12 @@ public class RotationContextButton extends ContextualButton implements RotationB private RotationButtonController mRotationButtonController; public RotationContextButton(@IdRes int buttonResId, @DrawableRes int iconResId) { super(buttonResId, iconResId); /** * @param lightContext the context to use to load the icon resource */ public RotationContextButton(@IdRes int buttonResId, Context lightContext, @DrawableRes int iconResId) { super(buttonResId, lightContext, iconResId); } @Override Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NavigationBarContextTest.java +3 −3 Original line number Diff line number Diff line Loading @@ -65,9 +65,9 @@ public class NavigationBarContextTest extends SysuiTestCase { mDependency.injectMockDependency(AssistManager.class); mGroup = new ContextualButtonGroup(GROUP_ID); mBtn0 = new ContextualButton(BUTTON_0_ID, ICON_RES_ID); mBtn1 = new ContextualButton(BUTTON_1_ID, ICON_RES_ID); mBtn2 = new ContextualButton(BUTTON_2_ID, ICON_RES_ID); mBtn0 = new ContextualButton(BUTTON_0_ID, mContext, ICON_RES_ID); mBtn1 = new ContextualButton(BUTTON_1_ID, mContext, ICON_RES_ID); mBtn2 = new ContextualButton(BUTTON_2_ID, mContext, ICON_RES_ID); // Order of adding buttons to group determines the priority, ascending priority order mGroup.addButton(mBtn0); Loading Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/ContextualButton.java +6 −12 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ public class ContextualButton extends ButtonDispatcher { private ContextButtonListener mListener; private ContextualButtonGroup mGroup; protected final Context mLightContext; protected final @DrawableRes int mIconResId; /** Loading @@ -42,8 +43,10 @@ public class ContextualButton extends ButtonDispatcher { * @param buttonResId the button view from xml layout * @param iconResId icon resource to be used */ public ContextualButton(@IdRes int buttonResId, @DrawableRes int iconResId) { public ContextualButton(@IdRes int buttonResId, Context lightContext, @DrawableRes int iconResId) { super(buttonResId); mLightContext = lightContext; mIconResId = iconResId; } Loading Loading @@ -117,17 +120,8 @@ public class ContextualButton extends ButtonDispatcher { } protected KeyButtonDrawable getNewDrawable(int lightIconColor, int darkIconColor) { return KeyButtonDrawable.create(getContext().getApplicationContext(), lightIconColor, darkIconColor, mIconResId, false /* shadow */, null /* ovalBackground */); } /** * This context is from the view that could be stale after rotation or config change. To get * correct resources use getApplicationContext() as well. * @return current view context */ protected Context getContext() { return getCurrentView().getContext(); return KeyButtonDrawable.create(mLightContext, lightIconColor, darkIconColor, mIconResId, false /* shadow */, null /* ovalBackground */); } public interface ContextButtonListener { Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java +4 −3 Original line number Diff line number Diff line Loading @@ -295,11 +295,12 @@ public class NavigationBarView extends FrameLayout implements // Set up the context group of buttons mContextualButtonGroup = new ContextualButtonGroup(R.id.menu_container); final ContextualButton imeSwitcherButton = new ContextualButton(R.id.ime_switcher, R.drawable.ic_ime_switcher_default); mLightContext, R.drawable.ic_ime_switcher_default); final RotationContextButton rotateSuggestionButton = new RotationContextButton( R.id.rotate_suggestion, R.drawable.ic_sysbar_rotate_button_ccw_start_0); R.id.rotate_suggestion, mLightContext, R.drawable.ic_sysbar_rotate_button_ccw_start_0); final ContextualButton accessibilityButton = new ContextualButton(R.id.accessibility_button, new ContextualButton(R.id.accessibility_button, mLightContext, R.drawable.ic_sysbar_accessibility_button); mContextualButtonGroup.addButton(imeSwitcherButton); if (!isGesturalMode) { Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/RotationButtonController.java +0 −1 Original line number Diff line number Diff line Loading @@ -283,7 +283,6 @@ public class RotationButtonController { return; } // TODO: Remove styles? // Prepare to show the navbar icon by updating the icon style to change anim params mLastRotationSuggestion = rotation; // Remember rotation for click final boolean rotationCCW = isRotationAnimationCCW(windowRotation, rotation); Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/RotationContextButton.java +7 −2 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.systemui.statusbar.phone; import android.annotation.DrawableRes; import android.annotation.IdRes; import android.content.Context; import android.view.View; import com.android.systemui.statusbar.policy.KeyButtonDrawable; Loading @@ -28,8 +29,12 @@ public class RotationContextButton extends ContextualButton implements RotationB private RotationButtonController mRotationButtonController; public RotationContextButton(@IdRes int buttonResId, @DrawableRes int iconResId) { super(buttonResId, iconResId); /** * @param lightContext the context to use to load the icon resource */ public RotationContextButton(@IdRes int buttonResId, Context lightContext, @DrawableRes int iconResId) { super(buttonResId, lightContext, iconResId); } @Override Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NavigationBarContextTest.java +3 −3 Original line number Diff line number Diff line Loading @@ -65,9 +65,9 @@ public class NavigationBarContextTest extends SysuiTestCase { mDependency.injectMockDependency(AssistManager.class); mGroup = new ContextualButtonGroup(GROUP_ID); mBtn0 = new ContextualButton(BUTTON_0_ID, ICON_RES_ID); mBtn1 = new ContextualButton(BUTTON_1_ID, ICON_RES_ID); mBtn2 = new ContextualButton(BUTTON_2_ID, ICON_RES_ID); mBtn0 = new ContextualButton(BUTTON_0_ID, mContext, ICON_RES_ID); mBtn1 = new ContextualButton(BUTTON_1_ID, mContext, ICON_RES_ID); mBtn2 = new ContextualButton(BUTTON_2_ID, mContext, ICON_RES_ID); // Order of adding buttons to group determines the priority, ascending priority order mGroup.addButton(mBtn0); Loading