Loading packages/SystemUI/shared/src/com/android/systemui/shared/rotation/FloatingRotationButton.java +20 −11 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.systemui.shared.rotation; import android.annotation.DimenRes; import android.annotation.IdRes; import android.annotation.LayoutRes; import android.annotation.Nullable; import android.annotation.StringRes; import android.content.Context; import android.content.pm.ActivityInfo; Loading Loading @@ -79,8 +80,8 @@ public class FloatingRotationButton implements RotationButton { private FloatingRotationButtonPositionCalculator mPositionCalculator; private RotationButtonController mRotationButtonController; private RotationButtonUpdatesCallback mUpdatesCallback; @Nullable private RotationButtonController mRotationButtonController; @Nullable private RotationButtonUpdatesCallback mUpdatesCallback; private Position mPosition; public FloatingRotationButton(Context context, @StringRes int contentDescriptionResource, Loading Loading @@ -132,14 +133,17 @@ public class FloatingRotationButton implements RotationButton { } @Override public void setRotationButtonController(RotationButtonController rotationButtonController) { public void setRotationButtonController( @Nullable RotationButtonController rotationButtonController) { mRotationButtonController = rotationButtonController; if (mRotationButtonController != null) { updateIcon(mRotationButtonController.getLightIconColor(), mRotationButtonController.getDarkIconColor()); } } @Override public void setUpdatesCallback(RotationButtonUpdatesCallback updatesCallback) { public void setUpdatesCallback(@Nullable RotationButtonUpdatesCallback updatesCallback) { mUpdatesCallback = updatesCallback; } Loading Loading @@ -195,9 +199,12 @@ public class FloatingRotationButton implements RotationButton { @Override public void updateIcon(int lightIconColor, int darkIconColor) { if (mRotationButtonController != null) { mAnimatedDrawable = (AnimatedVectorDrawable) mKeyButtonView.getContext() .getDrawable(mRotationButtonController.getIconResId()); mAnimatedDrawable.setBounds(0, 0, mKeyButtonView.getWidth(), mKeyButtonView.getHeight()); mAnimatedDrawable.setBounds( 0, 0, mKeyButtonView.getWidth(), mKeyButtonView.getHeight()); } mKeyButtonView.setImageDrawable(mAnimatedDrawable); mKeyButtonView.setColors(lightIconColor, darkIconColor); } Loading Loading @@ -251,8 +258,10 @@ public class FloatingRotationButton implements RotationButton { updateDimensionResources(); if (mIsShowing) { if (mRotationButtonController != null) { updateIcon(mRotationButtonController.getLightIconColor(), mRotationButtonController.getDarkIconColor()); } final LayoutParams layoutParams = adjustViewPositionAndCreateLayoutParams(); mWindowManager.updateViewLayout(mKeyButtonContainer, layoutParams); if (mAnimatedDrawable != null) { Loading packages/SystemUI/shared/src/com/android/systemui/shared/rotation/RotationButton.java +5 −2 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.systemui.shared.rotation; import android.annotation.Nullable; import android.graphics.drawable.Drawable; import android.view.View; Loading @@ -25,8 +26,10 @@ import android.view.View; * one in contextual for 3 button nav and a floating rotation button for gestural. */ public interface RotationButton { default void setRotationButtonController(RotationButtonController rotationButtonController) { } default void setUpdatesCallback(RotationButtonUpdatesCallback updatesCallback) { } default void setRotationButtonController( @Nullable RotationButtonController rotationButtonController) { } default void setUpdatesCallback( @Nullable RotationButtonUpdatesCallback updatesCallback) { } default View getCurrentView() { return null; Loading packages/SystemUI/shared/src/com/android/systemui/shared/rotation/RotationButtonController.java +30 −8 Original line number Diff line number Diff line Loading @@ -95,7 +95,7 @@ public class RotationButtonController { private final UiEventLogger mUiEventLogger = new UiEventLoggerImpl(); private final ViewRippler mViewRippler = new ViewRippler(); private final Supplier<Integer> mWindowRotationProvider; private RotationButton mRotationButton; @Nullable private RotationButton mRotationButton; private boolean mIsRecentsAnimationRunning; private boolean mDocked; Loading Loading @@ -202,6 +202,17 @@ public class RotationButtonController { mRotationButton.setUpdatesCallback(updatesCallback); } private void clearRotationButton() { if (mRotationButton == null) { return; } mRotationButton.setRotationButtonController(null); mRotationButton.setOnClickListener(null); mRotationButton.setOnHoverListener(null); mRotationButton.setUpdatesCallback(null); mRotationButton = null; } public Context getContext() { return mContext; } Loading Loading @@ -231,6 +242,7 @@ public class RotationButtonController { */ public void onDestroy() { unregisterListeners(); clearRotationButton(); } public void registerListeners(boolean registerRotationWatcher) { Loading Loading @@ -313,6 +325,8 @@ public class RotationButtonController { } void setRotateSuggestionButtonState(final boolean visible, final boolean force) { if (mRotationButton == null) return; // At any point the button can become invisible because an a11y service became active. // Similarly, a call to make the button visible may be rejected because an a11y service is // active. Must account for this. Loading Loading @@ -373,8 +387,10 @@ public class RotationButtonController { fadeOut.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { if (mRotationButton != null) { mRotationButton.hide(); } } }); mRotateHideAnimator = fadeOut; Loading @@ -383,8 +399,10 @@ public class RotationButtonController { } public void setDarkIntensity(float darkIntensity) { if (mRotationButton != null) { mRotationButton.setDarkIntensity(darkIntensity); } } public void setRecentsAnimationRunning(boolean running) { mIsRecentsAnimationRunning = running; Loading Loading @@ -412,6 +430,10 @@ public class RotationButtonController { } public void onRotationProposal(int rotation, boolean isValid) { if (mRotationButton == null) { return; } boolean isUserSetupComplete = Settings.Secure.getInt(mContext.getContentResolver(), Settings.Secure.USER_SETUP_COMPLETE, 0) != 0; if (!isUserSetupComplete && OEM_DISALLOW_ROTATION_IN_SUW) { Loading Loading @@ -485,7 +507,7 @@ public class RotationButtonController { } // The isVisible check makes the rotation button disappear when we are not locked // (e.g. for tabletop auto-rotate). if (isRotationLocked || mRotationButton.isVisible()) { if (isRotationLocked || (mRotationButton != null && mRotationButton.isVisible())) { // Do not allow a change in rotation to set user rotation when docked. if (shouldOverrideUserLockPrefs(rotation) && isRotationLocked && !mDocked) { setRotationAtAngle(true, rotation, /* caller= */ Loading Loading @@ -524,10 +546,9 @@ public class RotationButtonController { public void onTaskbarStateChange(boolean visible, boolean stashed) { mTaskBarVisible = visible; if (getRotationButton() == null) { return; if (mRotationButton != null) { mRotationButton.onTaskbarStateChanged(visible, stashed); } getRotationButton().onTaskbarStateChanged(visible, stashed); } private void showPendingRotationButtonIfNeeded() { Loading Loading @@ -586,6 +607,7 @@ public class RotationButtonController { "%s\tmDarkIconColor=0x%s", prefix, Integer.toHexString(mDarkIconColor))); } @Nullable public RotationButton getRotationButton() { return mRotationButton; } Loading Loading @@ -647,7 +669,7 @@ public class RotationButtonController { // Don't reschedule if a hide animator is running if (mRotateHideAnimator != null && mRotateHideAnimator.isRunning()) return; // Don't reschedule if not visible if (!mRotationButton.isVisible()) return; if (mRotationButton == null || !mRotationButton.isVisible()) return; } // Stop any pending removal Loading packages/SystemUI/src/com/android/systemui/navigationbar/views/NavigationBar.java +3 −1 Original line number Diff line number Diff line Loading @@ -139,6 +139,7 @@ import com.android.systemui.settings.UserTracker; import com.android.systemui.shade.ShadeViewController; import com.android.systemui.shade.domain.interactor.PanelExpansionInteractor; import com.android.systemui.shared.recents.utilities.Utilities; import com.android.systemui.shared.rotation.RotationButton; import com.android.systemui.shared.rotation.RotationButtonController; import com.android.systemui.shared.rotation.RotationPolicyUtil; import com.android.systemui.shared.statusbar.phone.BarTransitions; Loading Loading @@ -1170,12 +1171,13 @@ public class NavigationBar extends ViewController<NavigationBarView> implements final RotationButtonController rotationButtonController = mView.getRotationButtonController(); if (DEBUG_ROTATION) { RotationButton rotationButton = rotationButtonController.getRotationButton(); Log.v(TAG, "onRotationProposal proposedRotation=" + Surface.rotationToString(rotation) + ", isValid=" + isValid + ", mNavBarWindowState=" + StatusBarManager.windowStateToString(mNavigationBarWindowState) + ", rotateSuggestionsDisabled=" + rotateSuggestionsDisabled + ", isRotateButtonVisible=" + rotationButtonController.getRotationButton().isVisible()); + (rotationButton != null && rotationButton.isVisible())); } // Respect the disabled flag, no need for action as flag change callback will handle hiding if (rotateSuggestionsDisabled) return; Loading Loading
packages/SystemUI/shared/src/com/android/systemui/shared/rotation/FloatingRotationButton.java +20 −11 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.systemui.shared.rotation; import android.annotation.DimenRes; import android.annotation.IdRes; import android.annotation.LayoutRes; import android.annotation.Nullable; import android.annotation.StringRes; import android.content.Context; import android.content.pm.ActivityInfo; Loading Loading @@ -79,8 +80,8 @@ public class FloatingRotationButton implements RotationButton { private FloatingRotationButtonPositionCalculator mPositionCalculator; private RotationButtonController mRotationButtonController; private RotationButtonUpdatesCallback mUpdatesCallback; @Nullable private RotationButtonController mRotationButtonController; @Nullable private RotationButtonUpdatesCallback mUpdatesCallback; private Position mPosition; public FloatingRotationButton(Context context, @StringRes int contentDescriptionResource, Loading Loading @@ -132,14 +133,17 @@ public class FloatingRotationButton implements RotationButton { } @Override public void setRotationButtonController(RotationButtonController rotationButtonController) { public void setRotationButtonController( @Nullable RotationButtonController rotationButtonController) { mRotationButtonController = rotationButtonController; if (mRotationButtonController != null) { updateIcon(mRotationButtonController.getLightIconColor(), mRotationButtonController.getDarkIconColor()); } } @Override public void setUpdatesCallback(RotationButtonUpdatesCallback updatesCallback) { public void setUpdatesCallback(@Nullable RotationButtonUpdatesCallback updatesCallback) { mUpdatesCallback = updatesCallback; } Loading Loading @@ -195,9 +199,12 @@ public class FloatingRotationButton implements RotationButton { @Override public void updateIcon(int lightIconColor, int darkIconColor) { if (mRotationButtonController != null) { mAnimatedDrawable = (AnimatedVectorDrawable) mKeyButtonView.getContext() .getDrawable(mRotationButtonController.getIconResId()); mAnimatedDrawable.setBounds(0, 0, mKeyButtonView.getWidth(), mKeyButtonView.getHeight()); mAnimatedDrawable.setBounds( 0, 0, mKeyButtonView.getWidth(), mKeyButtonView.getHeight()); } mKeyButtonView.setImageDrawable(mAnimatedDrawable); mKeyButtonView.setColors(lightIconColor, darkIconColor); } Loading Loading @@ -251,8 +258,10 @@ public class FloatingRotationButton implements RotationButton { updateDimensionResources(); if (mIsShowing) { if (mRotationButtonController != null) { updateIcon(mRotationButtonController.getLightIconColor(), mRotationButtonController.getDarkIconColor()); } final LayoutParams layoutParams = adjustViewPositionAndCreateLayoutParams(); mWindowManager.updateViewLayout(mKeyButtonContainer, layoutParams); if (mAnimatedDrawable != null) { Loading
packages/SystemUI/shared/src/com/android/systemui/shared/rotation/RotationButton.java +5 −2 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.systemui.shared.rotation; import android.annotation.Nullable; import android.graphics.drawable.Drawable; import android.view.View; Loading @@ -25,8 +26,10 @@ import android.view.View; * one in contextual for 3 button nav and a floating rotation button for gestural. */ public interface RotationButton { default void setRotationButtonController(RotationButtonController rotationButtonController) { } default void setUpdatesCallback(RotationButtonUpdatesCallback updatesCallback) { } default void setRotationButtonController( @Nullable RotationButtonController rotationButtonController) { } default void setUpdatesCallback( @Nullable RotationButtonUpdatesCallback updatesCallback) { } default View getCurrentView() { return null; Loading
packages/SystemUI/shared/src/com/android/systemui/shared/rotation/RotationButtonController.java +30 −8 Original line number Diff line number Diff line Loading @@ -95,7 +95,7 @@ public class RotationButtonController { private final UiEventLogger mUiEventLogger = new UiEventLoggerImpl(); private final ViewRippler mViewRippler = new ViewRippler(); private final Supplier<Integer> mWindowRotationProvider; private RotationButton mRotationButton; @Nullable private RotationButton mRotationButton; private boolean mIsRecentsAnimationRunning; private boolean mDocked; Loading Loading @@ -202,6 +202,17 @@ public class RotationButtonController { mRotationButton.setUpdatesCallback(updatesCallback); } private void clearRotationButton() { if (mRotationButton == null) { return; } mRotationButton.setRotationButtonController(null); mRotationButton.setOnClickListener(null); mRotationButton.setOnHoverListener(null); mRotationButton.setUpdatesCallback(null); mRotationButton = null; } public Context getContext() { return mContext; } Loading Loading @@ -231,6 +242,7 @@ public class RotationButtonController { */ public void onDestroy() { unregisterListeners(); clearRotationButton(); } public void registerListeners(boolean registerRotationWatcher) { Loading Loading @@ -313,6 +325,8 @@ public class RotationButtonController { } void setRotateSuggestionButtonState(final boolean visible, final boolean force) { if (mRotationButton == null) return; // At any point the button can become invisible because an a11y service became active. // Similarly, a call to make the button visible may be rejected because an a11y service is // active. Must account for this. Loading Loading @@ -373,8 +387,10 @@ public class RotationButtonController { fadeOut.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { if (mRotationButton != null) { mRotationButton.hide(); } } }); mRotateHideAnimator = fadeOut; Loading @@ -383,8 +399,10 @@ public class RotationButtonController { } public void setDarkIntensity(float darkIntensity) { if (mRotationButton != null) { mRotationButton.setDarkIntensity(darkIntensity); } } public void setRecentsAnimationRunning(boolean running) { mIsRecentsAnimationRunning = running; Loading Loading @@ -412,6 +430,10 @@ public class RotationButtonController { } public void onRotationProposal(int rotation, boolean isValid) { if (mRotationButton == null) { return; } boolean isUserSetupComplete = Settings.Secure.getInt(mContext.getContentResolver(), Settings.Secure.USER_SETUP_COMPLETE, 0) != 0; if (!isUserSetupComplete && OEM_DISALLOW_ROTATION_IN_SUW) { Loading Loading @@ -485,7 +507,7 @@ public class RotationButtonController { } // The isVisible check makes the rotation button disappear when we are not locked // (e.g. for tabletop auto-rotate). if (isRotationLocked || mRotationButton.isVisible()) { if (isRotationLocked || (mRotationButton != null && mRotationButton.isVisible())) { // Do not allow a change in rotation to set user rotation when docked. if (shouldOverrideUserLockPrefs(rotation) && isRotationLocked && !mDocked) { setRotationAtAngle(true, rotation, /* caller= */ Loading Loading @@ -524,10 +546,9 @@ public class RotationButtonController { public void onTaskbarStateChange(boolean visible, boolean stashed) { mTaskBarVisible = visible; if (getRotationButton() == null) { return; if (mRotationButton != null) { mRotationButton.onTaskbarStateChanged(visible, stashed); } getRotationButton().onTaskbarStateChanged(visible, stashed); } private void showPendingRotationButtonIfNeeded() { Loading Loading @@ -586,6 +607,7 @@ public class RotationButtonController { "%s\tmDarkIconColor=0x%s", prefix, Integer.toHexString(mDarkIconColor))); } @Nullable public RotationButton getRotationButton() { return mRotationButton; } Loading Loading @@ -647,7 +669,7 @@ public class RotationButtonController { // Don't reschedule if a hide animator is running if (mRotateHideAnimator != null && mRotateHideAnimator.isRunning()) return; // Don't reschedule if not visible if (!mRotationButton.isVisible()) return; if (mRotationButton == null || !mRotationButton.isVisible()) return; } // Stop any pending removal Loading
packages/SystemUI/src/com/android/systemui/navigationbar/views/NavigationBar.java +3 −1 Original line number Diff line number Diff line Loading @@ -139,6 +139,7 @@ import com.android.systemui.settings.UserTracker; import com.android.systemui.shade.ShadeViewController; import com.android.systemui.shade.domain.interactor.PanelExpansionInteractor; import com.android.systemui.shared.recents.utilities.Utilities; import com.android.systemui.shared.rotation.RotationButton; import com.android.systemui.shared.rotation.RotationButtonController; import com.android.systemui.shared.rotation.RotationPolicyUtil; import com.android.systemui.shared.statusbar.phone.BarTransitions; Loading Loading @@ -1170,12 +1171,13 @@ public class NavigationBar extends ViewController<NavigationBarView> implements final RotationButtonController rotationButtonController = mView.getRotationButtonController(); if (DEBUG_ROTATION) { RotationButton rotationButton = rotationButtonController.getRotationButton(); Log.v(TAG, "onRotationProposal proposedRotation=" + Surface.rotationToString(rotation) + ", isValid=" + isValid + ", mNavBarWindowState=" + StatusBarManager.windowStateToString(mNavigationBarWindowState) + ", rotateSuggestionsDisabled=" + rotateSuggestionsDisabled + ", isRotateButtonVisible=" + rotationButtonController.getRotationButton().isVisible()); + (rotationButton != null && rotationButton.isVisible())); } // Respect the disabled flag, no need for action as flag change callback will handle hiding if (rotateSuggestionsDisabled) return; Loading