summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Himanshu Jaju <himanshujaju@google.com> 2020-12-17 12:07:25 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2020-12-17 12:07:25 +0000
commit566f54c05226dfb30ef3ce976637f50b242c5aeb (patch)
tree1f50bd0bdd952eb54425d90400dd2ef58620e34d
parent4cc8fbc5bfaaad74aa2dbbad95520c33acc2fada (diff)
parent7dba1da1fa527e74cc0c91b1d2cdc827a79c1039 (diff)
Merge "Refactors RotationUtils to be independent from device width."
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/ScreenPinningRequest.java17
-rw-r--r--packages/SystemUI/src/com/android/systemui/util/leak/RotationUtils.java33
2 files changed, 28 insertions, 22 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/recents/ScreenPinningRequest.java b/packages/SystemUI/src/com/android/systemui/recents/ScreenPinningRequest.java
index 6afc75624a9f..c2ba3440f19f 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/ScreenPinningRequest.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/ScreenPinningRequest.java
@@ -17,6 +17,7 @@
package com.android.systemui.recents;
import static com.android.systemui.util.leak.RotationUtils.ROTATION_LANDSCAPE;
+import static com.android.systemui.util.leak.RotationUtils.ROTATION_NONE;
import static com.android.systemui.util.leak.RotationUtils.ROTATION_SEASCAPE;
import android.animation.ArgbEvaluator;
@@ -27,6 +28,7 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
+import android.content.res.Configuration;
import android.graphics.PixelFormat;
import android.graphics.drawable.ColorDrawable;
import android.os.Binder;
@@ -186,7 +188,7 @@ public class ScreenPinningRequest implements View.OnClickListener,
DisplayMetrics metrics = new DisplayMetrics();
mWindowManager.getDefaultDisplay().getMetrics(metrics);
float density = metrics.density;
- int rotation = RotationUtils.getRotation(mContext);
+ int rotation = getRotation(mContext);
inflateView(rotation);
int bgColor = mContext.getColor(
@@ -342,14 +344,23 @@ public class ScreenPinningRequest implements View.OnClickListener,
protected void onConfigurationChanged() {
removeAllViews();
- inflateView(RotationUtils.getRotation(mContext));
+ inflateView(getRotation(mContext));
+ }
+
+ private int getRotation(Context context) {
+ Configuration config = context.getResources().getConfiguration();
+ if (config.smallestScreenWidthDp >= 600) {
+ return ROTATION_NONE;
+ }
+
+ return RotationUtils.getRotation(context);
}
private final Runnable mUpdateLayoutRunnable = new Runnable() {
@Override
public void run() {
if (mLayout != null && mLayout.getParent() != null) {
- mLayout.setLayoutParams(getRequestLayoutParams(RotationUtils.getRotation(mContext)));
+ mLayout.setLayoutParams(getRequestLayoutParams(getRotation(mContext)));
}
}
};
diff --git a/packages/SystemUI/src/com/android/systemui/util/leak/RotationUtils.java b/packages/SystemUI/src/com/android/systemui/util/leak/RotationUtils.java
index 11c72c4c0cb9..e44981e24906 100644
--- a/packages/SystemUI/src/com/android/systemui/util/leak/RotationUtils.java
+++ b/packages/SystemUI/src/com/android/systemui/util/leak/RotationUtils.java
@@ -15,7 +15,6 @@
package com.android.systemui.util.leak;
import android.content.Context;
-import android.content.res.Configuration;
import android.view.Surface;
public class RotationUtils {
@@ -26,30 +25,26 @@ public class RotationUtils {
public static final int ROTATION_UPSIDE_DOWN = 3;
public static int getRotation(Context context) {
- Configuration config = context.getResources().getConfiguration();
int rot = context.getDisplay().getRotation();
- if (config.smallestScreenWidthDp < 600) {
- if (rot == Surface.ROTATION_90) {
- return ROTATION_LANDSCAPE;
- } else if (rot == Surface.ROTATION_270) {
- return ROTATION_SEASCAPE;
- }
+ if (rot == Surface.ROTATION_90) {
+ return ROTATION_LANDSCAPE;
+ } else if (rot == Surface.ROTATION_270) {
+ return ROTATION_SEASCAPE;
+ } else {
+ return ROTATION_NONE;
}
- return ROTATION_NONE;
}
public static int getExactRotation(Context context) {
- Configuration config = context.getResources().getConfiguration();
int rot = context.getDisplay().getRotation();
- if (config.smallestScreenWidthDp < 600) {
- if (rot == Surface.ROTATION_90) {
- return ROTATION_LANDSCAPE;
- } else if (rot == Surface.ROTATION_270) {
- return ROTATION_SEASCAPE;
- } else if (rot == Surface.ROTATION_180) {
- return ROTATION_UPSIDE_DOWN;
- }
+ if (rot == Surface.ROTATION_90) {
+ return ROTATION_LANDSCAPE;
+ } else if (rot == Surface.ROTATION_270) {
+ return ROTATION_SEASCAPE;
+ } else if (rot == Surface.ROTATION_180) {
+ return ROTATION_UPSIDE_DOWN;
+ } else {
+ return ROTATION_NONE;
}
- return ROTATION_NONE;
}
}