Merge "[Live Tile] Do not allow rotation in Overview when home rotation is off" into sc-dev
This commit is contained in:
@@ -134,5 +134,8 @@ interface ISystemUiProxy {
|
|||||||
*/
|
*/
|
||||||
void onBackPressed() = 44;
|
void onBackPressed() = 44;
|
||||||
|
|
||||||
// Next id = 45
|
/** Sets home rotation enabled. */
|
||||||
|
void setHomeRotationEnabled(boolean enabled) = 45;
|
||||||
|
|
||||||
|
// Next id = 46
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -363,6 +363,11 @@ public class NavigationBar implements View.OnAttachStateChangeListener,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onHomeRotationEnabled(boolean enabled) {
|
||||||
|
mNavigationBarView.getRotationButtonController().setHomeRotationEnabled(enabled);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onOverviewShown(boolean fromHome) {
|
public void onOverviewShown(boolean fromHome) {
|
||||||
// If the overview has fixed orientation that may change display to natural rotation,
|
// If the overview has fixed orientation that may change display to natural rotation,
|
||||||
@@ -951,6 +956,7 @@ public class NavigationBar implements View.OnAttachStateChangeListener,
|
|||||||
if (running) {
|
if (running) {
|
||||||
mNavbarOverlayController.setButtonState(/* visible */false, /* force */true);
|
mNavbarOverlayController.setButtonState(/* visible */false, /* force */true);
|
||||||
}
|
}
|
||||||
|
mNavigationBarView.getRotationButtonController().setRecentsAnimationRunning(running);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Restores the appearance and the transient saved state to {@link NavigationBar}. */
|
/** Restores the appearance and the transient saved state to {@link NavigationBar}. */
|
||||||
|
|||||||
@@ -71,6 +71,8 @@ public class RotationButtonController {
|
|||||||
private final ViewRippler mViewRippler = new ViewRippler();
|
private final ViewRippler mViewRippler = new ViewRippler();
|
||||||
private RotationButton mRotationButton;
|
private RotationButton mRotationButton;
|
||||||
|
|
||||||
|
private boolean mIsRecentsAnimationRunning;
|
||||||
|
private boolean mHomeRotationEnabled;
|
||||||
private int mLastRotationSuggestion;
|
private int mLastRotationSuggestion;
|
||||||
private boolean mPendingRotationSuggestion;
|
private boolean mPendingRotationSuggestion;
|
||||||
private boolean mHoveringRotationSuggestion;
|
private boolean mHoveringRotationSuggestion;
|
||||||
@@ -92,7 +94,6 @@ public class RotationButtonController {
|
|||||||
() -> mPendingRotationSuggestion = false;
|
() -> mPendingRotationSuggestion = false;
|
||||||
private Animator mRotateHideAnimator;
|
private Animator mRotateHideAnimator;
|
||||||
|
|
||||||
|
|
||||||
private final Stub mRotationWatcher = new Stub() {
|
private final Stub mRotationWatcher = new Stub() {
|
||||||
@Override
|
@Override
|
||||||
public void onRotationChanged(final int rotation) throws RemoteException {
|
public void onRotationChanged(final int rotation) throws RemoteException {
|
||||||
@@ -105,7 +106,7 @@ public class RotationButtonController {
|
|||||||
if (shouldOverrideUserLockPrefs(rotation)) {
|
if (shouldOverrideUserLockPrefs(rotation)) {
|
||||||
setRotationLockedAtAngle(rotation);
|
setRotationLockedAtAngle(rotation);
|
||||||
}
|
}
|
||||||
setRotateSuggestionButtonState(false /* visible */, true /* forced */);
|
setRotateSuggestionButtonState(false /* visible */, true /* hideImmediately */);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mRotWatcherListener != null) {
|
if (mRotWatcherListener != null) {
|
||||||
@@ -192,10 +193,14 @@ public class RotationButtonController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void setRotateSuggestionButtonState(boolean visible) {
|
void setRotateSuggestionButtonState(boolean visible) {
|
||||||
setRotateSuggestionButtonState(visible, false /* force */);
|
setRotateSuggestionButtonState(visible, false /* hideImmediately */);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setRotateSuggestionButtonState(final boolean visible, final boolean force) {
|
/**
|
||||||
|
* Change the visibility of rotate suggestion button. If {@code hideImmediately} is true,
|
||||||
|
* it doesn't wait until the completion of the running animation.
|
||||||
|
*/
|
||||||
|
void setRotateSuggestionButtonState(final boolean visible, final boolean hideImmediately) {
|
||||||
// At any point the the button can become invisible because an a11y service became active.
|
// At any point the 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
|
// Similarly, a call to make the button visible may be rejected because an a11y service is
|
||||||
// active. Must account for this.
|
// active. Must account for this.
|
||||||
@@ -236,7 +241,7 @@ public class RotationButtonController {
|
|||||||
} else { // Hide
|
} else { // Hide
|
||||||
mViewRippler.stop(); // Prevent any pending ripples, force hide or not
|
mViewRippler.stop(); // Prevent any pending ripples, force hide or not
|
||||||
|
|
||||||
if (force) {
|
if (hideImmediately) {
|
||||||
// If a hide animator is running stop it and make invisible
|
// If a hide animator is running stop it and make invisible
|
||||||
if (mRotateHideAnimator != null && mRotateHideAnimator.isRunning()) {
|
if (mRotateHideAnimator != null && mRotateHideAnimator.isRunning()) {
|
||||||
mRotateHideAnimator.pause();
|
mRotateHideAnimator.pause();
|
||||||
@@ -263,12 +268,29 @@ public class RotationButtonController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setRecentsAnimationRunning(boolean running) {
|
||||||
|
mIsRecentsAnimationRunning = running;
|
||||||
|
updateRotationButtonStateInOverview();
|
||||||
|
}
|
||||||
|
|
||||||
|
void setHomeRotationEnabled(boolean enabled) {
|
||||||
|
mHomeRotationEnabled = enabled;
|
||||||
|
updateRotationButtonStateInOverview();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateRotationButtonStateInOverview() {
|
||||||
|
if (mIsRecentsAnimationRunning && !mHomeRotationEnabled) {
|
||||||
|
setRotateSuggestionButtonState(false, true /* hideImmediately */ );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void setDarkIntensity(float darkIntensity) {
|
void setDarkIntensity(float darkIntensity) {
|
||||||
mRotationButton.setDarkIntensity(darkIntensity);
|
mRotationButton.setDarkIntensity(darkIntensity);
|
||||||
}
|
}
|
||||||
|
|
||||||
void onRotationProposal(int rotation, int windowRotation, boolean isValid) {
|
void onRotationProposal(int rotation, int windowRotation, boolean isValid) {
|
||||||
if (!mRotationButton.acceptRotationProposal()) {
|
if (!mRotationButton.acceptRotationProposal() || (!mHomeRotationEnabled
|
||||||
|
&& mIsRecentsAnimationRunning)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -259,6 +259,21 @@ public class OverviewProxyService extends CurrentUserTracker implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setHomeRotationEnabled(boolean enabled) {
|
||||||
|
if (!verifyCaller("setHomeRotationEnabled")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final long token = Binder.clearCallingIdentity();
|
||||||
|
try {
|
||||||
|
mHandler.post(() -> {
|
||||||
|
mHandler.post(() -> notifyHomeRotationEnabled(enabled));
|
||||||
|
});
|
||||||
|
} finally {
|
||||||
|
Binder.restoreCallingIdentity(token);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private boolean sendEvent(int action, int code) {
|
private boolean sendEvent(int action, int code) {
|
||||||
long when = SystemClock.uptimeMillis();
|
long when = SystemClock.uptimeMillis();
|
||||||
final KeyEvent ev = new KeyEvent(when, when, action, code, 0 /* repeat */,
|
final KeyEvent ev = new KeyEvent(when, when, action, code, 0 /* repeat */,
|
||||||
@@ -847,6 +862,12 @@ public class OverviewProxyService extends CurrentUserTracker implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void notifyHomeRotationEnabled(boolean enabled) {
|
||||||
|
for (int i = mConnectionCallbacks.size() - 1; i >= 0; --i) {
|
||||||
|
mConnectionCallbacks.get(i).onHomeRotationEnabled(enabled);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void notifyConnectionChanged() {
|
private void notifyConnectionChanged() {
|
||||||
for (int i = mConnectionCallbacks.size() - 1; i >= 0; --i) {
|
for (int i = mConnectionCallbacks.size() - 1; i >= 0; --i) {
|
||||||
mConnectionCallbacks.get(i).onConnectionChanged(mOverviewProxy != null);
|
mConnectionCallbacks.get(i).onConnectionChanged(mOverviewProxy != null);
|
||||||
@@ -994,6 +1015,7 @@ public class OverviewProxyService extends CurrentUserTracker implements
|
|||||||
default void onToggleRecentApps() {}
|
default void onToggleRecentApps() {}
|
||||||
/** Notify changes in the nav bar button alpha */
|
/** Notify changes in the nav bar button alpha */
|
||||||
default void onNavBarButtonAlphaChanged(float alpha, boolean animate) {}
|
default void onNavBarButtonAlphaChanged(float alpha, boolean animate) {}
|
||||||
|
default void onHomeRotationEnabled(boolean enabled) {}
|
||||||
default void onSystemUiStateChanged(int sysuiStateFlags) {}
|
default void onSystemUiStateChanged(int sysuiStateFlags) {}
|
||||||
default void onAssistantProgress(@FloatRange(from = 0.0, to = 1.0) float progress) {}
|
default void onAssistantProgress(@FloatRange(from = 0.0, to = 1.0) float progress) {}
|
||||||
default void onAssistantGestureCompletion(float velocity) {}
|
default void onAssistantGestureCompletion(float velocity) {}
|
||||||
|
|||||||
Reference in New Issue
Block a user