Loading quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java +19 −8 Original line number Diff line number Diff line Loading @@ -285,6 +285,9 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl } }; private final RecentsOrientedState.SystemRotationChangeListener mSystemRotationChangeListener = enabled -> toggleOrientationEventListener(); private final PinnedStackAnimationListener mIPinnedStackAnimationListener = new PinnedStackAnimationListener(); Loading Loading @@ -484,6 +487,7 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl SystemUiProxy.INSTANCE.get(getContext()).setPinnedStackAnimationListener( mIPinnedStackAnimationListener); mOrientationState.init(); mOrientationState.addSystemRotationChangeListener(mSystemRotationChangeListener); } @Override Loading @@ -498,6 +502,7 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl mIdp.removeOnChangeListener(this); SystemUiProxy.INSTANCE.get(getContext()).setPinnedStackAnimationListener(null); mIPinnedStackAnimationListener.setActivity(null); mOrientationState.removeSystemRotationChangeListener(mSystemRotationChangeListener); mOrientationState.destroy(); } Loading Loading @@ -554,13 +559,6 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl } public void setOverviewStateEnabled(boolean enabled) { if (canEnableOverviewRotationAnimation()) { if (enabled) { mOrientationListener.enable(); } else { mOrientationListener.disable(); } } mOverviewStateEnabled = enabled; updateTaskStackListenerState(); if (!enabled) { Loading @@ -568,13 +566,26 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl // its thumbnail mTmpRunningTask = null; } toggleOrientationEventListener(); } private void toggleOrientationEventListener() { boolean canEnable = canEnableOverviewRotationAnimation() && mOverviewStateEnabled; UI_HELPER_EXECUTOR.execute(() -> { if (canEnable) { mOrientationListener.enable(); } else { mOrientationListener.disable(); } }); } private boolean canEnableOverviewRotationAnimation() { return supportsVerticalLandscape() // not 3P launcher && !TestProtocol.sDisableSensorRotation // Ignore hardware dependency for tests.. && mOrientationListener.canDetectOrientation() // ..but does the hardware even work? && !mOrientationState.canLauncherAutoRotate(); // launcher is going to rotate itself && (mOrientationState.isSystemRotationAllowed() && !mOrientationState.canLauncherRotate()); // launcher is going to rotate itself } public void onDigitalWellbeingToastShown() { Loading quickstep/src/com/android/quickstep/util/RecentsOrientedState.java +36 −10 Original line number Diff line number Diff line Loading @@ -51,6 +51,8 @@ import com.android.launcher3.touch.PagedOrientationHandler; import com.android.launcher3.touch.PortraitPagedViewHandler; import java.lang.annotation.Retention; import java.util.ArrayList; import java.util.List; /** * Container to hold orientation/rotation related information for Launcher. Loading Loading @@ -81,6 +83,10 @@ public final class RecentsOrientedState implements SharedPreferences.OnSharedPre private @SurfaceRotation int mDisplayRotation = ROTATION_0; private @SurfaceRotation int mLauncherRotation = Surface.ROTATION_0; public interface SystemRotationChangeListener { void onSystemRotationChanged(boolean enabled); } /** * If {@code true} we default to {@link PortraitPagedViewHandler} and don't support any fake * launcher orientations. Loading @@ -93,6 +99,7 @@ public final class RecentsOrientedState implements SharedPreferences.OnSharedPre private final SharedPreferences mSharedPrefs; private final boolean mAllowConfigurationDefaultValue; private List<SystemRotationChangeListener> mSystemRotationChangeListeners = new ArrayList<>(); private final Matrix mTmpMatrix = new Matrix(); private final Matrix mTmpInverseMatrix = new Matrix(); Loading Loading @@ -167,14 +174,6 @@ public final class RecentsOrientedState implements SharedPreferences.OnSharedPre return true; } public boolean areMultipleLayoutOrientationsDisabled() { return mDisableMultipleOrientations; } public boolean canLauncherAutoRotate() { return mIsHomeRotationAllowed && mIsSystemRotationAllowed; } /** * Setting this preference renders future calls to {@link #update(int, int, int)} as a no-op. */ Loading @@ -198,6 +197,10 @@ public final class RecentsOrientedState implements SharedPreferences.OnSharedPre } catch (Settings.SettingNotFoundException e) { Log.e(TAG, "autorotate setting not found", e); } for (SystemRotationChangeListener listener : mSystemRotationChangeListeners) { listener.onSystemRotationChanged(mIsSystemRotationAllowed); } } private void updateHomeRotationSetting() { Loading @@ -205,6 +208,15 @@ public final class RecentsOrientedState implements SharedPreferences.OnSharedPre mAllowConfigurationDefaultValue); } public void addSystemRotationChangeListener(SystemRotationChangeListener listener) { mSystemRotationChangeListeners.add(listener); listener.onSystemRotationChanged(mIsSystemRotationAllowed); } public void removeSystemRotationChangeListener(SystemRotationChangeListener listener) { mSystemRotationChangeListeners.remove(listener); } public void init() { mSharedPrefs.registerOnSharedPreferenceChangeListener(this); mContentResolver.registerContentObserver( Loading @@ -217,6 +229,7 @@ public final class RecentsOrientedState implements SharedPreferences.OnSharedPre public void destroy() { mSharedPrefs.unregisterOnSharedPreferenceChangeListener(this); mContentResolver.unregisterContentObserver(mSystemAutoRotateObserver); mSystemRotationChangeListeners.clear(); } @SurfaceRotation Loading @@ -229,12 +242,25 @@ public final class RecentsOrientedState implements SharedPreferences.OnSharedPre return mTouchRotation; } @SurfaceRotation public int getLauncherRotation() { return mLauncherRotation; } public boolean areMultipleLayoutOrientationsDisabled() { return mDisableMultipleOrientations; } public boolean isSystemRotationAllowed() { return mIsSystemRotationAllowed; } public boolean isHomeRotationAllowed() { return mIsHomeRotationAllowed; } public int getLauncherRotation() { return mLauncherRotation; public boolean canLauncherRotate() { return isSystemRotationAllowed() && isHomeRotationAllowed(); } public int getTouchRotationDegrees() { Loading Loading
quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java +19 −8 Original line number Diff line number Diff line Loading @@ -285,6 +285,9 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl } }; private final RecentsOrientedState.SystemRotationChangeListener mSystemRotationChangeListener = enabled -> toggleOrientationEventListener(); private final PinnedStackAnimationListener mIPinnedStackAnimationListener = new PinnedStackAnimationListener(); Loading Loading @@ -484,6 +487,7 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl SystemUiProxy.INSTANCE.get(getContext()).setPinnedStackAnimationListener( mIPinnedStackAnimationListener); mOrientationState.init(); mOrientationState.addSystemRotationChangeListener(mSystemRotationChangeListener); } @Override Loading @@ -498,6 +502,7 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl mIdp.removeOnChangeListener(this); SystemUiProxy.INSTANCE.get(getContext()).setPinnedStackAnimationListener(null); mIPinnedStackAnimationListener.setActivity(null); mOrientationState.removeSystemRotationChangeListener(mSystemRotationChangeListener); mOrientationState.destroy(); } Loading Loading @@ -554,13 +559,6 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl } public void setOverviewStateEnabled(boolean enabled) { if (canEnableOverviewRotationAnimation()) { if (enabled) { mOrientationListener.enable(); } else { mOrientationListener.disable(); } } mOverviewStateEnabled = enabled; updateTaskStackListenerState(); if (!enabled) { Loading @@ -568,13 +566,26 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl // its thumbnail mTmpRunningTask = null; } toggleOrientationEventListener(); } private void toggleOrientationEventListener() { boolean canEnable = canEnableOverviewRotationAnimation() && mOverviewStateEnabled; UI_HELPER_EXECUTOR.execute(() -> { if (canEnable) { mOrientationListener.enable(); } else { mOrientationListener.disable(); } }); } private boolean canEnableOverviewRotationAnimation() { return supportsVerticalLandscape() // not 3P launcher && !TestProtocol.sDisableSensorRotation // Ignore hardware dependency for tests.. && mOrientationListener.canDetectOrientation() // ..but does the hardware even work? && !mOrientationState.canLauncherAutoRotate(); // launcher is going to rotate itself && (mOrientationState.isSystemRotationAllowed() && !mOrientationState.canLauncherRotate()); // launcher is going to rotate itself } public void onDigitalWellbeingToastShown() { Loading
quickstep/src/com/android/quickstep/util/RecentsOrientedState.java +36 −10 Original line number Diff line number Diff line Loading @@ -51,6 +51,8 @@ import com.android.launcher3.touch.PagedOrientationHandler; import com.android.launcher3.touch.PortraitPagedViewHandler; import java.lang.annotation.Retention; import java.util.ArrayList; import java.util.List; /** * Container to hold orientation/rotation related information for Launcher. Loading Loading @@ -81,6 +83,10 @@ public final class RecentsOrientedState implements SharedPreferences.OnSharedPre private @SurfaceRotation int mDisplayRotation = ROTATION_0; private @SurfaceRotation int mLauncherRotation = Surface.ROTATION_0; public interface SystemRotationChangeListener { void onSystemRotationChanged(boolean enabled); } /** * If {@code true} we default to {@link PortraitPagedViewHandler} and don't support any fake * launcher orientations. Loading @@ -93,6 +99,7 @@ public final class RecentsOrientedState implements SharedPreferences.OnSharedPre private final SharedPreferences mSharedPrefs; private final boolean mAllowConfigurationDefaultValue; private List<SystemRotationChangeListener> mSystemRotationChangeListeners = new ArrayList<>(); private final Matrix mTmpMatrix = new Matrix(); private final Matrix mTmpInverseMatrix = new Matrix(); Loading Loading @@ -167,14 +174,6 @@ public final class RecentsOrientedState implements SharedPreferences.OnSharedPre return true; } public boolean areMultipleLayoutOrientationsDisabled() { return mDisableMultipleOrientations; } public boolean canLauncherAutoRotate() { return mIsHomeRotationAllowed && mIsSystemRotationAllowed; } /** * Setting this preference renders future calls to {@link #update(int, int, int)} as a no-op. */ Loading @@ -198,6 +197,10 @@ public final class RecentsOrientedState implements SharedPreferences.OnSharedPre } catch (Settings.SettingNotFoundException e) { Log.e(TAG, "autorotate setting not found", e); } for (SystemRotationChangeListener listener : mSystemRotationChangeListeners) { listener.onSystemRotationChanged(mIsSystemRotationAllowed); } } private void updateHomeRotationSetting() { Loading @@ -205,6 +208,15 @@ public final class RecentsOrientedState implements SharedPreferences.OnSharedPre mAllowConfigurationDefaultValue); } public void addSystemRotationChangeListener(SystemRotationChangeListener listener) { mSystemRotationChangeListeners.add(listener); listener.onSystemRotationChanged(mIsSystemRotationAllowed); } public void removeSystemRotationChangeListener(SystemRotationChangeListener listener) { mSystemRotationChangeListeners.remove(listener); } public void init() { mSharedPrefs.registerOnSharedPreferenceChangeListener(this); mContentResolver.registerContentObserver( Loading @@ -217,6 +229,7 @@ public final class RecentsOrientedState implements SharedPreferences.OnSharedPre public void destroy() { mSharedPrefs.unregisterOnSharedPreferenceChangeListener(this); mContentResolver.unregisterContentObserver(mSystemAutoRotateObserver); mSystemRotationChangeListeners.clear(); } @SurfaceRotation Loading @@ -229,12 +242,25 @@ public final class RecentsOrientedState implements SharedPreferences.OnSharedPre return mTouchRotation; } @SurfaceRotation public int getLauncherRotation() { return mLauncherRotation; } public boolean areMultipleLayoutOrientationsDisabled() { return mDisableMultipleOrientations; } public boolean isSystemRotationAllowed() { return mIsSystemRotationAllowed; } public boolean isHomeRotationAllowed() { return mIsHomeRotationAllowed; } public int getLauncherRotation() { return mLauncherRotation; public boolean canLauncherRotate() { return isSystemRotationAllowed() && isHomeRotationAllowed(); } public int getTouchRotationDegrees() { Loading