Loading quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java +8 −0 Original line number Diff line number Diff line Loading @@ -85,6 +85,7 @@ import com.android.launcher3.BaseActivity; import com.android.launcher3.DeviceProfile; import com.android.launcher3.Insettable; import com.android.launcher3.InvariantDeviceProfile; import com.android.launcher3.Launcher; import com.android.launcher3.LauncherState; import com.android.launcher3.PagedView; import com.android.launcher3.R; Loading Loading @@ -275,6 +276,9 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl } }; private RotationHelper.ForcedRotationChangedListener mForcedRotationChangedListener = isForcedRotation -> RecentsView.this.disableMultipleLayoutRotations(!isForcedRotation); private final PinnedStackAnimationListener mIPinnedStackAnimationListener = new PinnedStackAnimationListener(); Loading Loading @@ -467,6 +471,8 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl mIPinnedStackAnimationListener.setActivity(mActivity); SystemUiProxy.INSTANCE.get(getContext()).setPinnedStackAnimationListener( mIPinnedStackAnimationListener); Launcher launcher = Launcher.getLauncher(getContext()); launcher.getRotationHelper().addForcedRotationCallback(mForcedRotationChangedListener); } @Override Loading @@ -481,6 +487,8 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl mIdp.removeOnChangeListener(this); SystemUiProxy.INSTANCE.get(getContext()).setPinnedStackAnimationListener(null); mIPinnedStackAnimationListener.setActivity(null); Launcher launcher = Launcher.getLauncher(getContext()); launcher.getRotationHelper().removeForcedRotationCallback(mForcedRotationChangedListener); } @Override Loading quickstep/src/com/android/quickstep/OrientationTouchTransformer.java +1 −1 Original line number Diff line number Diff line Loading @@ -49,7 +49,7 @@ import java.io.PrintWriter; class OrientationTouchTransformer { private static final String TAG = "OrientationTouchTransformer"; private static final boolean DEBUG = true; private static final boolean DEBUG = false; private static final int MAX_ORIENTATIONS = 4; private SparseArray<OrientationRectF> mSwipeTouchRegions = new SparseArray<>(MAX_ORIENTATIONS); Loading src/com/android/launcher3/PagedView.java +1 −0 Original line number Diff line number Diff line Loading @@ -47,6 +47,7 @@ import com.android.launcher3.compat.AccessibilityManagerCompat; import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.model.PagedViewOrientedState; import com.android.launcher3.pageindicators.PageIndicator; import com.android.launcher3.states.RotationHelper; import com.android.launcher3.touch.PortraitPagedViewHandler; import com.android.launcher3.touch.OverScroll; import com.android.launcher3.touch.PagedOrientationHandler; Loading src/com/android/launcher3/states/RotationHelper.java +58 −13 Original line number Diff line number Diff line Loading @@ -17,8 +17,10 @@ package com.android.launcher3.states; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_LOCKED; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_NOSENSOR; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; import static android.util.DisplayMetrics.DENSITY_DEVICE_STABLE; import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; import android.content.ContentResolver; Loading @@ -41,6 +43,9 @@ import com.android.launcher3.Utilities; import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.util.UiThreadHelper; import java.util.ArrayList; import java.util.List; /** * Utility class to manage launcher rotation */ Loading @@ -49,16 +54,38 @@ public class RotationHelper implements OnSharedPreferenceChangeListener { public static final String ALLOW_ROTATION_PREFERENCE_KEY = "pref_allowRotation"; public static final String FIXED_ROTATION_TRANSFORM_SETTING_NAME = "fixed_rotation_transform"; private final ContentResolver mContentResolver; /** * Listener to receive changes when {@link #FIXED_ROTATION_TRANSFORM_SETTING_NAME} flag changes. */ public interface ForcedRotationChangedListener { void onForcedRotationChanged(boolean isForcedRotation); } public static boolean getAllowRotationDefaultValue() { // If the device was scaled, used the original dimensions to determine if rotation // is allowed of not. // If the device's pixel density was scaled (usually via settings for A11y), use the // original dimensions to determine if rotation is allowed of not. Resources res = Resources.getSystem(); int originalSmallestWidth = res.getConfiguration().smallestScreenWidthDp * res.getDisplayMetrics().densityDpi / DENSITY_DEVICE_STABLE; return originalSmallestWidth >= 600; } private final ContentObserver mContentObserver = new ContentObserver(MAIN_EXECUTOR.getHandler()) { @Override public void onChange(boolean selfChange) { boolean forcedRotation = Utilities.isForcedRotation(mLauncher); PagedView.sFlagForcedRotation = forcedRotation; updateForcedRotation(); for (ForcedRotationChangedListener listener : mForcedRotationChangedListeners) { listener.onForcedRotationChanged(forcedRotation); } } }; public static final int REQUEST_NONE = 0; public static final int REQUEST_ROTATE = 1; public static final int REQUEST_LOCK = 2; Loading @@ -68,6 +95,8 @@ public class RotationHelper implements OnSharedPreferenceChangeListener { private boolean mIgnoreAutoRotateSettings; private boolean mAutoRotateEnabled; private boolean mForcedRotation; private List<ForcedRotationChangedListener> mForcedRotationChangedListeners = new ArrayList<>(); /** * Rotation request made by Loading Loading @@ -96,6 +125,7 @@ public class RotationHelper implements OnSharedPreferenceChangeListener { // On large devices we do not handle auto-rotate differently. mIgnoreAutoRotateSettings = mLauncher.getResources().getBoolean(R.bool.allow_rotation); updateForcedRotation(); if (!mIgnoreAutoRotateSettings) { mPrefs = Utilities.getPrefs(mLauncher); mPrefs.registerOnSharedPreferenceChangeListener(this); Loading @@ -106,16 +136,24 @@ public class RotationHelper implements OnSharedPreferenceChangeListener { } // TODO(b/150260456) Add this in home settings as well final ContentResolver resolver = launcher.getContentResolver(); final ContentObserver observer = new ContentObserver(MAIN_EXECUTOR.getHandler()) { @Override public void onChange(boolean selfChange) { PagedView.sFlagForcedRotation = Utilities.isForcedRotation(mLauncher); mContentResolver = launcher.getContentResolver(); mContentResolver.registerContentObserver(Settings.Global.getUriFor( FIXED_ROTATION_TRANSFORM_SETTING_NAME), false, mContentObserver); } }; resolver.registerContentObserver(Settings.Global.getUriFor( FIXED_ROTATION_TRANSFORM_SETTING_NAME), false, observer); private void updateForcedRotation() { mForcedRotation = !getAllowRotationDefaultValue() && Utilities.isForcedRotation(mLauncher); } /** * will not be called when first registering the listener. */ public void addForcedRotationCallback(ForcedRotationChangedListener listener) { mForcedRotationChangedListeners.add(listener); } public void removeForcedRotationCallback(ForcedRotationChangedListener listener) { mForcedRotationChangedListeners.remove(listener); } public void setRotationHadDifferentUI(boolean rotationHasDifferentUI) { Loading Loading @@ -197,6 +235,10 @@ public class RotationHelper implements OnSharedPreferenceChangeListener { if (mPrefs != null) { mPrefs.unregisterOnSharedPreferenceChangeListener(this); } if (mContentResolver != null) { mContentResolver.unregisterContentObserver(mContentObserver); } mForcedRotationChangedListeners.clear(); } } Loading @@ -206,7 +248,10 @@ public class RotationHelper implements OnSharedPreferenceChangeListener { } final int activityFlags; if (mStateHandlerRequest != REQUEST_NONE) { if (mForcedRotation) { // TODO(b/150214193) Properly address this activityFlags = SCREEN_ORIENTATION_PORTRAIT; } else if (mStateHandlerRequest != REQUEST_NONE) { activityFlags = mStateHandlerRequest == REQUEST_LOCK ? SCREEN_ORIENTATION_LOCKED : SCREEN_ORIENTATION_UNSPECIFIED; } else if (mCurrentTransitionRequest != REQUEST_NONE) { Loading Loading
quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java +8 −0 Original line number Diff line number Diff line Loading @@ -85,6 +85,7 @@ import com.android.launcher3.BaseActivity; import com.android.launcher3.DeviceProfile; import com.android.launcher3.Insettable; import com.android.launcher3.InvariantDeviceProfile; import com.android.launcher3.Launcher; import com.android.launcher3.LauncherState; import com.android.launcher3.PagedView; import com.android.launcher3.R; Loading Loading @@ -275,6 +276,9 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl } }; private RotationHelper.ForcedRotationChangedListener mForcedRotationChangedListener = isForcedRotation -> RecentsView.this.disableMultipleLayoutRotations(!isForcedRotation); private final PinnedStackAnimationListener mIPinnedStackAnimationListener = new PinnedStackAnimationListener(); Loading Loading @@ -467,6 +471,8 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl mIPinnedStackAnimationListener.setActivity(mActivity); SystemUiProxy.INSTANCE.get(getContext()).setPinnedStackAnimationListener( mIPinnedStackAnimationListener); Launcher launcher = Launcher.getLauncher(getContext()); launcher.getRotationHelper().addForcedRotationCallback(mForcedRotationChangedListener); } @Override Loading @@ -481,6 +487,8 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl mIdp.removeOnChangeListener(this); SystemUiProxy.INSTANCE.get(getContext()).setPinnedStackAnimationListener(null); mIPinnedStackAnimationListener.setActivity(null); Launcher launcher = Launcher.getLauncher(getContext()); launcher.getRotationHelper().removeForcedRotationCallback(mForcedRotationChangedListener); } @Override Loading
quickstep/src/com/android/quickstep/OrientationTouchTransformer.java +1 −1 Original line number Diff line number Diff line Loading @@ -49,7 +49,7 @@ import java.io.PrintWriter; class OrientationTouchTransformer { private static final String TAG = "OrientationTouchTransformer"; private static final boolean DEBUG = true; private static final boolean DEBUG = false; private static final int MAX_ORIENTATIONS = 4; private SparseArray<OrientationRectF> mSwipeTouchRegions = new SparseArray<>(MAX_ORIENTATIONS); Loading
src/com/android/launcher3/PagedView.java +1 −0 Original line number Diff line number Diff line Loading @@ -47,6 +47,7 @@ import com.android.launcher3.compat.AccessibilityManagerCompat; import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.model.PagedViewOrientedState; import com.android.launcher3.pageindicators.PageIndicator; import com.android.launcher3.states.RotationHelper; import com.android.launcher3.touch.PortraitPagedViewHandler; import com.android.launcher3.touch.OverScroll; import com.android.launcher3.touch.PagedOrientationHandler; Loading
src/com/android/launcher3/states/RotationHelper.java +58 −13 Original line number Diff line number Diff line Loading @@ -17,8 +17,10 @@ package com.android.launcher3.states; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_LOCKED; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_NOSENSOR; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; import static android.util.DisplayMetrics.DENSITY_DEVICE_STABLE; import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; import android.content.ContentResolver; Loading @@ -41,6 +43,9 @@ import com.android.launcher3.Utilities; import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.util.UiThreadHelper; import java.util.ArrayList; import java.util.List; /** * Utility class to manage launcher rotation */ Loading @@ -49,16 +54,38 @@ public class RotationHelper implements OnSharedPreferenceChangeListener { public static final String ALLOW_ROTATION_PREFERENCE_KEY = "pref_allowRotation"; public static final String FIXED_ROTATION_TRANSFORM_SETTING_NAME = "fixed_rotation_transform"; private final ContentResolver mContentResolver; /** * Listener to receive changes when {@link #FIXED_ROTATION_TRANSFORM_SETTING_NAME} flag changes. */ public interface ForcedRotationChangedListener { void onForcedRotationChanged(boolean isForcedRotation); } public static boolean getAllowRotationDefaultValue() { // If the device was scaled, used the original dimensions to determine if rotation // is allowed of not. // If the device's pixel density was scaled (usually via settings for A11y), use the // original dimensions to determine if rotation is allowed of not. Resources res = Resources.getSystem(); int originalSmallestWidth = res.getConfiguration().smallestScreenWidthDp * res.getDisplayMetrics().densityDpi / DENSITY_DEVICE_STABLE; return originalSmallestWidth >= 600; } private final ContentObserver mContentObserver = new ContentObserver(MAIN_EXECUTOR.getHandler()) { @Override public void onChange(boolean selfChange) { boolean forcedRotation = Utilities.isForcedRotation(mLauncher); PagedView.sFlagForcedRotation = forcedRotation; updateForcedRotation(); for (ForcedRotationChangedListener listener : mForcedRotationChangedListeners) { listener.onForcedRotationChanged(forcedRotation); } } }; public static final int REQUEST_NONE = 0; public static final int REQUEST_ROTATE = 1; public static final int REQUEST_LOCK = 2; Loading @@ -68,6 +95,8 @@ public class RotationHelper implements OnSharedPreferenceChangeListener { private boolean mIgnoreAutoRotateSettings; private boolean mAutoRotateEnabled; private boolean mForcedRotation; private List<ForcedRotationChangedListener> mForcedRotationChangedListeners = new ArrayList<>(); /** * Rotation request made by Loading Loading @@ -96,6 +125,7 @@ public class RotationHelper implements OnSharedPreferenceChangeListener { // On large devices we do not handle auto-rotate differently. mIgnoreAutoRotateSettings = mLauncher.getResources().getBoolean(R.bool.allow_rotation); updateForcedRotation(); if (!mIgnoreAutoRotateSettings) { mPrefs = Utilities.getPrefs(mLauncher); mPrefs.registerOnSharedPreferenceChangeListener(this); Loading @@ -106,16 +136,24 @@ public class RotationHelper implements OnSharedPreferenceChangeListener { } // TODO(b/150260456) Add this in home settings as well final ContentResolver resolver = launcher.getContentResolver(); final ContentObserver observer = new ContentObserver(MAIN_EXECUTOR.getHandler()) { @Override public void onChange(boolean selfChange) { PagedView.sFlagForcedRotation = Utilities.isForcedRotation(mLauncher); mContentResolver = launcher.getContentResolver(); mContentResolver.registerContentObserver(Settings.Global.getUriFor( FIXED_ROTATION_TRANSFORM_SETTING_NAME), false, mContentObserver); } }; resolver.registerContentObserver(Settings.Global.getUriFor( FIXED_ROTATION_TRANSFORM_SETTING_NAME), false, observer); private void updateForcedRotation() { mForcedRotation = !getAllowRotationDefaultValue() && Utilities.isForcedRotation(mLauncher); } /** * will not be called when first registering the listener. */ public void addForcedRotationCallback(ForcedRotationChangedListener listener) { mForcedRotationChangedListeners.add(listener); } public void removeForcedRotationCallback(ForcedRotationChangedListener listener) { mForcedRotationChangedListeners.remove(listener); } public void setRotationHadDifferentUI(boolean rotationHasDifferentUI) { Loading Loading @@ -197,6 +235,10 @@ public class RotationHelper implements OnSharedPreferenceChangeListener { if (mPrefs != null) { mPrefs.unregisterOnSharedPreferenceChangeListener(this); } if (mContentResolver != null) { mContentResolver.unregisterContentObserver(mContentObserver); } mForcedRotationChangedListeners.clear(); } } Loading @@ -206,7 +248,10 @@ public class RotationHelper implements OnSharedPreferenceChangeListener { } final int activityFlags; if (mStateHandlerRequest != REQUEST_NONE) { if (mForcedRotation) { // TODO(b/150214193) Properly address this activityFlags = SCREEN_ORIENTATION_PORTRAIT; } else if (mStateHandlerRequest != REQUEST_NONE) { activityFlags = mStateHandlerRequest == REQUEST_LOCK ? SCREEN_ORIENTATION_LOCKED : SCREEN_ORIENTATION_UNSPECIFIED; } else if (mCurrentTransitionRequest != REQUEST_NONE) { Loading