Loading src/com/android/launcher3/Launcher.java +15 −3 Original line number Diff line number Diff line Loading @@ -636,7 +636,10 @@ public class Launcher extends StatefulActivity<LauncherState> @Override public void onIdpChanged(boolean modelPropertiesChanged) { initDeviceProfile(mDeviceProfile.inv); if (!initDeviceProfile(mDeviceProfile.inv)) { return; } dispatchDeviceProfileChanged(); reapplyUi(); mDragLayer.recreateControllers(); Loading @@ -659,9 +662,17 @@ public class Launcher extends StatefulActivity<LauncherState> mDragLayer.onOneHandedModeStateChanged(activated); } protected void initDeviceProfile(InvariantDeviceProfile idp) { /** * Returns {@code true} if a new DeviceProfile is initialized, and {@code false} otherwise. */ protected boolean initDeviceProfile(InvariantDeviceProfile idp) { // Load configuration-specific DeviceProfile mDeviceProfile = idp.getDeviceProfile(this); DeviceProfile deviceProfile = idp.getDeviceProfile(this); if (mDeviceProfile == deviceProfile) { return false; } mDeviceProfile = deviceProfile; if (isInMultiWindowMode()) { mDeviceProfile = mDeviceProfile.getMultiWindowProfile( this, getMultiWindowDisplaySize()); Loading @@ -669,6 +680,7 @@ public class Launcher extends StatefulActivity<LauncherState> onDeviceProfileInitiated(); mModelWriter = mModel.getWriter(getDeviceProfile().isVerticalBarLayout(), true, this); return true; } public RotationHelper getRotationHelper() { Loading src/com/android/launcher3/states/RotationHelper.java +10 −6 Original line number Diff line number Diff line Loading @@ -23,19 +23,21 @@ import static android.util.DisplayMetrics.DENSITY_DEVICE_STABLE; import static com.android.launcher3.Utilities.dpiFromPx; import static com.android.launcher3.util.window.WindowManagerProxy.MIN_TABLET_WIDTH; import android.content.Context; import android.content.SharedPreferences; import android.content.SharedPreferences.OnSharedPreferenceChangeListener; import com.android.launcher3.BaseActivity; import com.android.launcher3.DeviceProfile; import com.android.launcher3.Utilities; import com.android.launcher3.util.DisplayController; import com.android.launcher3.util.UiThreadHelper; /** * Utility class to manage launcher rotation */ public class RotationHelper implements OnSharedPreferenceChangeListener, DeviceProfile.OnDeviceProfileChangeListener { DisplayController.DisplayInfoChangeListener { private static final String TAG = "RotationHelper"; Loading Loading @@ -119,8 +121,8 @@ public class RotationHelper implements OnSharedPreferenceChangeListener, } @Override public void onDeviceProfileChanged(DeviceProfile dp) { boolean ignoreAutoRotateSettings = dp.isTablet; public void onDisplayInfoChanged(Context context, DisplayController.Info info, int flags) { boolean ignoreAutoRotateSettings = info.isTablet(info.realBounds); if (mIgnoreAutoRotateSettings != ignoreAutoRotateSettings) { setIgnoreAutoRotateSettings(ignoreAutoRotateSettings); notifyChange(); Loading Loading @@ -157,8 +159,10 @@ public class RotationHelper implements OnSharedPreferenceChangeListener, public void initialize() { if (!mInitialized) { mInitialized = true; setIgnoreAutoRotateSettings(mActivity.getDeviceProfile().isTablet); mActivity.addOnDeviceProfileChangeListener(this); DisplayController displayController = DisplayController.INSTANCE.get(mActivity); DisplayController.Info info = displayController.getInfo(); setIgnoreAutoRotateSettings(info.isTablet(info.realBounds)); displayController.addChangeListener(this); notifyChange(); } } Loading @@ -166,7 +170,7 @@ public class RotationHelper implements OnSharedPreferenceChangeListener, public void destroy() { if (!mDestroyed) { mDestroyed = true; mActivity.removeOnDeviceProfileChangeListener(this); DisplayController.INSTANCE.get(mActivity).removeChangeListener(this); mActivity = null; if (mSharedPrefs != null) { mSharedPrefs.unregisterOnSharedPreferenceChangeListener(this); Loading src/com/android/launcher3/util/DisplayController.java +3 −3 Original line number Diff line number Diff line Loading @@ -278,11 +278,11 @@ public class DisplayController implements ComponentCallbacks, SafeCloseable { public final float fontScale; private final int densityDpi; public final NavigationMode navigationMode; private final PortraitSize mScreenSizeDp; // WindowBounds public final WindowBounds realBounds; public final Set<WindowBounds> supportedBounds = new ArraySet<>(); private final ArrayMap<CachedDisplayInfo, WindowBounds[]> mPerDisplayBounds = new ArrayMap<>(); Loading Loading @@ -310,7 +310,7 @@ public class DisplayController implements ComponentCallbacks, SafeCloseable { mPerDisplayBounds.putAll(perDisplayBoundsCache); WindowBounds[] cachedValue = mPerDisplayBounds.get(normalizedDisplayInfo); WindowBounds realBounds = wmProxy.getRealBounds(displayInfoContext, displayInfo); realBounds = wmProxy.getRealBounds(displayInfoContext, displayInfo); if (cachedValue == null) { // Unexpected normalizedDisplayInfo is found, recreate the cache Log.e(TAG, "Unexpected normalizedDisplayInfo found, invalidating cache"); Loading Loading
src/com/android/launcher3/Launcher.java +15 −3 Original line number Diff line number Diff line Loading @@ -636,7 +636,10 @@ public class Launcher extends StatefulActivity<LauncherState> @Override public void onIdpChanged(boolean modelPropertiesChanged) { initDeviceProfile(mDeviceProfile.inv); if (!initDeviceProfile(mDeviceProfile.inv)) { return; } dispatchDeviceProfileChanged(); reapplyUi(); mDragLayer.recreateControllers(); Loading @@ -659,9 +662,17 @@ public class Launcher extends StatefulActivity<LauncherState> mDragLayer.onOneHandedModeStateChanged(activated); } protected void initDeviceProfile(InvariantDeviceProfile idp) { /** * Returns {@code true} if a new DeviceProfile is initialized, and {@code false} otherwise. */ protected boolean initDeviceProfile(InvariantDeviceProfile idp) { // Load configuration-specific DeviceProfile mDeviceProfile = idp.getDeviceProfile(this); DeviceProfile deviceProfile = idp.getDeviceProfile(this); if (mDeviceProfile == deviceProfile) { return false; } mDeviceProfile = deviceProfile; if (isInMultiWindowMode()) { mDeviceProfile = mDeviceProfile.getMultiWindowProfile( this, getMultiWindowDisplaySize()); Loading @@ -669,6 +680,7 @@ public class Launcher extends StatefulActivity<LauncherState> onDeviceProfileInitiated(); mModelWriter = mModel.getWriter(getDeviceProfile().isVerticalBarLayout(), true, this); return true; } public RotationHelper getRotationHelper() { Loading
src/com/android/launcher3/states/RotationHelper.java +10 −6 Original line number Diff line number Diff line Loading @@ -23,19 +23,21 @@ import static android.util.DisplayMetrics.DENSITY_DEVICE_STABLE; import static com.android.launcher3.Utilities.dpiFromPx; import static com.android.launcher3.util.window.WindowManagerProxy.MIN_TABLET_WIDTH; import android.content.Context; import android.content.SharedPreferences; import android.content.SharedPreferences.OnSharedPreferenceChangeListener; import com.android.launcher3.BaseActivity; import com.android.launcher3.DeviceProfile; import com.android.launcher3.Utilities; import com.android.launcher3.util.DisplayController; import com.android.launcher3.util.UiThreadHelper; /** * Utility class to manage launcher rotation */ public class RotationHelper implements OnSharedPreferenceChangeListener, DeviceProfile.OnDeviceProfileChangeListener { DisplayController.DisplayInfoChangeListener { private static final String TAG = "RotationHelper"; Loading Loading @@ -119,8 +121,8 @@ public class RotationHelper implements OnSharedPreferenceChangeListener, } @Override public void onDeviceProfileChanged(DeviceProfile dp) { boolean ignoreAutoRotateSettings = dp.isTablet; public void onDisplayInfoChanged(Context context, DisplayController.Info info, int flags) { boolean ignoreAutoRotateSettings = info.isTablet(info.realBounds); if (mIgnoreAutoRotateSettings != ignoreAutoRotateSettings) { setIgnoreAutoRotateSettings(ignoreAutoRotateSettings); notifyChange(); Loading Loading @@ -157,8 +159,10 @@ public class RotationHelper implements OnSharedPreferenceChangeListener, public void initialize() { if (!mInitialized) { mInitialized = true; setIgnoreAutoRotateSettings(mActivity.getDeviceProfile().isTablet); mActivity.addOnDeviceProfileChangeListener(this); DisplayController displayController = DisplayController.INSTANCE.get(mActivity); DisplayController.Info info = displayController.getInfo(); setIgnoreAutoRotateSettings(info.isTablet(info.realBounds)); displayController.addChangeListener(this); notifyChange(); } } Loading @@ -166,7 +170,7 @@ public class RotationHelper implements OnSharedPreferenceChangeListener, public void destroy() { if (!mDestroyed) { mDestroyed = true; mActivity.removeOnDeviceProfileChangeListener(this); DisplayController.INSTANCE.get(mActivity).removeChangeListener(this); mActivity = null; if (mSharedPrefs != null) { mSharedPrefs.unregisterOnSharedPreferenceChangeListener(this); Loading
src/com/android/launcher3/util/DisplayController.java +3 −3 Original line number Diff line number Diff line Loading @@ -278,11 +278,11 @@ public class DisplayController implements ComponentCallbacks, SafeCloseable { public final float fontScale; private final int densityDpi; public final NavigationMode navigationMode; private final PortraitSize mScreenSizeDp; // WindowBounds public final WindowBounds realBounds; public final Set<WindowBounds> supportedBounds = new ArraySet<>(); private final ArrayMap<CachedDisplayInfo, WindowBounds[]> mPerDisplayBounds = new ArrayMap<>(); Loading Loading @@ -310,7 +310,7 @@ public class DisplayController implements ComponentCallbacks, SafeCloseable { mPerDisplayBounds.putAll(perDisplayBoundsCache); WindowBounds[] cachedValue = mPerDisplayBounds.get(normalizedDisplayInfo); WindowBounds realBounds = wmProxy.getRealBounds(displayInfoContext, displayInfo); realBounds = wmProxy.getRealBounds(displayInfoContext, displayInfo); if (cachedValue == null) { // Unexpected normalizedDisplayInfo is found, recreate the cache Log.e(TAG, "Unexpected normalizedDisplayInfo found, invalidating cache"); Loading