summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2019-05-15 18:39:37 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2019-05-15 18:39:37 +0000
commit62f53ddafbb7c139140dd3a80b0f6e9443d0ddfe (patch)
tree8596a4aa1dd0c8fc28af527b2ed2913c78ac6885 /src
parenteaed3a7c7b29b4de6e17db4562d9487ce8d5013c (diff)
parent41d51a0a15fe0017997fbdedd9c1d65aed27791b (diff)
downloadandroid_packages_apps_Trebuchet-62f53ddafbb7c139140dd3a80b0f6e9443d0ddfe.tar.gz
android_packages_apps_Trebuchet-62f53ddafbb7c139140dd3a80b0f6e9443d0ddfe.tar.bz2
android_packages_apps_Trebuchet-62f53ddafbb7c139140dd3a80b0f6e9443d0ddfe.zip
Merge "Enabling fake rotation by default" into ub-launcher3-qt-dev
Diffstat (limited to 'src')
-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);
}
}