summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2019-05-14 09:44:34 -0700
committerSunny Goyal <sunnygoyal@google.com>2019-05-15 11:21:34 -0700
commit41d51a0a15fe0017997fbdedd9c1d65aed27791b (patch)
tree23db4bcfdef255c92a3fb1f5a8d797ad3a65a65e /src/com/android/launcher3
parent4d3d51b3becacced0cd47502d63bc6f32a24de49 (diff)
downloadpackages_apps_Trebuchet-41d51a0a15fe0017997fbdedd9c1d65aed27791b.tar.gz
packages_apps_Trebuchet-41d51a0a15fe0017997fbdedd9c1d65aed27791b.tar.bz2
packages_apps_Trebuchet-41d51a0a15fe0017997fbdedd9c1d65aed27791b.zip
Enabling fake rotation by default
Fake rotation is only enabled if homescreen rotation is not enabled Bug: 131360075 Change-Id: Ie56fc4b46b38d3a599ec6da3d506a971e73b0394
Diffstat (limited to 'src/com/android/launcher3')
-rw-r--r--src/com/android/launcher3/CellLayout.java3
-rw-r--r--src/com/android/launcher3/Launcher.java19
-rw-r--r--src/com/android/launcher3/config/BaseFlags.java2
-rw-r--r--src/com/android/launcher3/states/RotationHelper.java43
4 files changed, 46 insertions, 21 deletions
diff --git a/src/com/android/launcher3/CellLayout.java b/src/com/android/launcher3/CellLayout.java
index 3eb01e6c3..09fb2446d 100644
--- a/src/com/android/launcher3/CellLayout.java
+++ b/src/com/android/launcher3/CellLayout.java
@@ -845,7 +845,8 @@ public class CellLayout extends ViewGroup implements Transposable {
* width in {@link DeviceProfile#calculateCellWidth(int, int)}.
*/
public int getUnusedHorizontalSpace() {
- return getMeasuredWidth() - getPaddingLeft() - getPaddingRight() - (mCountX * mCellWidth);
+ return (mRotationMode.isTransposed ? getMeasuredHeight() : getMeasuredWidth())
+ - getPaddingLeft() - getPaddingRight() - (mCountX * mCellWidth);
}
public Drawable getScrimBackground() {
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 823fb6b0a..359d8d932 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -303,6 +303,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
LauncherAppState app = LauncherAppState.getInstance(this);
mOldConfig = new Configuration(getResources().getConfiguration());
mModel = app.setLauncher(this);
+ mRotationHelper = new RotationHelper(this);
InvariantDeviceProfile idp = app.getInvariantDeviceProfile();
initDeviceProfile(idp);
idp.addOnChangeListener(this);
@@ -325,7 +326,6 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
setupViews();
mPopupDataProvider = new PopupDataProvider(this);
- mRotationHelper = new RotationHelper(this);
mAppTransitionManager = LauncherAppTransitionManager.newInstance(this);
boolean internalStateHandled = InternalStateHandler.handleCreate(this, getIntent());
@@ -396,12 +396,6 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
}
}
});
-
- if (FeatureFlags.FAKE_LANDSCAPE_UI.get()) {
- WindowManager.LayoutParams lp = getWindow().getAttributes();
- lp.rotationAnimation = WindowManager.LayoutParams.ROTATION_ANIMATION_SEAMLESS;
- getWindow().setAttributes(lp);
- }
}
@Override
@@ -428,9 +422,13 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
super.onConfigurationChanged(newConfig);
}
+ private boolean supportsFakeLandscapeUI() {
+ return FeatureFlags.FAKE_LANDSCAPE_UI.get() && !mRotationHelper.homeScreenCanRotate();
+ }
+
@Override
- protected void reapplyUi() {
- if (FeatureFlags.FAKE_LANDSCAPE_UI.get()) {
+ public void reapplyUi() {
+ if (supportsFakeLandscapeUI()) {
mRotationMode = mStableDeviceProfile == null
? RotationMode.NORMAL : UiFactory.getRotationMode(mDeviceProfile);
}
@@ -486,7 +484,8 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
mDeviceProfile = mDeviceProfile.getMultiWindowProfile(this, mwSize);
}
- if (FeatureFlags.FAKE_LANDSCAPE_UI.get() && mDeviceProfile.isVerticalBarLayout()
+ if (supportsFakeLandscapeUI()
+ && mDeviceProfile.isVerticalBarLayout()
&& !mDeviceProfile.isMultiWindowMode) {
mStableDeviceProfile = mDeviceProfile.inv.portraitProfile;
mRotationMode = UiFactory.getRotationMode(mDeviceProfile);
diff --git a/src/com/android/launcher3/config/BaseFlags.java b/src/com/android/launcher3/config/BaseFlags.java
index 70df97ae8..bad8282f5 100644
--- a/src/com/android/launcher3/config/BaseFlags.java
+++ b/src/com/android/launcher3/config/BaseFlags.java
@@ -111,7 +111,7 @@ abstract class BaseFlags {
"Show chip hints and gleams on the overview screen");
public static final TogglableFlag FAKE_LANDSCAPE_UI = new TogglableFlag(
- "FAKE_LANDSCAPE_UI", false,
+ "FAKE_LANDSCAPE_UI", true,
"Rotate launcher UI instead of using transposed layout");
public static void initialize(Context context) {
diff --git a/src/com/android/launcher3/states/RotationHelper.java b/src/com/android/launcher3/states/RotationHelper.java
index fb41ea1a2..3727fa663 100644
--- a/src/com/android/launcher3/states/RotationHelper.java
+++ b/src/com/android/launcher3/states/RotationHelper.java
@@ -20,13 +20,16 @@ import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_NOSENSOR;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
import static android.util.DisplayMetrics.DENSITY_DEVICE_STABLE;
-import android.app.Activity;
import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.content.res.Resources;
+import android.view.WindowManager;
+import android.view.WindowManager.LayoutParams;
+import com.android.launcher3.Launcher;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
+import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.util.UiThreadHelper;
/**
@@ -49,7 +52,7 @@ public class RotationHelper implements OnSharedPreferenceChangeListener {
public static final int REQUEST_ROTATE = 1;
public static final int REQUEST_LOCK = 2;
- private final Activity mActivity;
+ private final Launcher mLauncher;
private final SharedPreferences mPrefs;
private boolean mIgnoreAutoRotateSettings;
@@ -70,13 +73,13 @@ public class RotationHelper implements OnSharedPreferenceChangeListener {
private int mLastActivityFlags = -1;
- public RotationHelper(Activity activity) {
- mActivity = activity;
+ public RotationHelper(Launcher launcher) {
+ mLauncher = launcher;
// On large devices we do not handle auto-rotate differently.
- mIgnoreAutoRotateSettings = mActivity.getResources().getBoolean(R.bool.allow_rotation);
+ mIgnoreAutoRotateSettings = mLauncher.getResources().getBoolean(R.bool.allow_rotation);
if (!mIgnoreAutoRotateSettings) {
- mPrefs = Utilities.getPrefs(mActivity);
+ mPrefs = Utilities.getPrefs(mLauncher);
mPrefs.registerOnSharedPreferenceChangeListener(this);
mAutoRotateEnabled = mPrefs.getBoolean(ALLOW_ROTATION_PREFERENCE_KEY,
getAllowRotationDefaultValue());
@@ -85,11 +88,32 @@ public class RotationHelper implements OnSharedPreferenceChangeListener {
}
}
+ public boolean homeScreenCanRotate() {
+ return mIgnoreAutoRotateSettings || mAutoRotateEnabled
+ || mStateHandlerRequest != REQUEST_NONE;
+ }
+
+ private void updateRotationAnimation() {
+ if (FeatureFlags.FAKE_LANDSCAPE_UI.get()) {
+ WindowManager.LayoutParams lp = mLauncher.getWindow().getAttributes();
+ lp.rotationAnimation = homeScreenCanRotate()
+ ? WindowManager.LayoutParams.ROTATION_ANIMATION_ROTATE
+ : WindowManager.LayoutParams.ROTATION_ANIMATION_SEAMLESS;
+ mLauncher.getWindow().setAttributes(lp);
+ }
+ }
+
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String s) {
+ boolean wasRotationEnabled = mAutoRotateEnabled;
mAutoRotateEnabled = mPrefs.getBoolean(ALLOW_ROTATION_PREFERENCE_KEY,
getAllowRotationDefaultValue());
- notifyChange();
+ if (mAutoRotateEnabled != wasRotationEnabled) {
+
+ notifyChange();
+ updateRotationAnimation();
+ mLauncher.reapplyUi();
+ }
}
public void setStateHandlerRequest(int request) {
@@ -109,7 +133,7 @@ public class RotationHelper implements OnSharedPreferenceChangeListener {
// Used by tests only.
public void forceAllowRotationForTesting(boolean allowRotation) {
mIgnoreAutoRotateSettings =
- allowRotation || mActivity.getResources().getBoolean(R.bool.allow_rotation);
+ allowRotation || mLauncher.getResources().getBoolean(R.bool.allow_rotation);
notifyChange();
}
@@ -117,6 +141,7 @@ public class RotationHelper implements OnSharedPreferenceChangeListener {
if (!mInitialized) {
mInitialized = true;
notifyChange();
+ updateRotationAnimation();
}
}
@@ -150,7 +175,7 @@ public class RotationHelper implements OnSharedPreferenceChangeListener {
}
if (activityFlags != mLastActivityFlags) {
mLastActivityFlags = activityFlags;
- UiThreadHelper.setOrientationAsync(mActivity, activityFlags);
+ UiThreadHelper.setOrientationAsync(mLauncher, activityFlags);
}
}