Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 566f54c0 authored by Himanshu Jaju's avatar Himanshu Jaju Committed by Android (Google) Code Review
Browse files

Merge "Refactors RotationUtils to be independent from device width."

parents 4cc8fbc5 7dba1da1
Loading
Loading
Loading
Loading
+14 −3
Original line number Diff line number Diff line
@@ -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)));
                }
            }
        };
+14 −19
Original line number Diff line number Diff line
@@ -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;
            }
        }
        } else {
            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;
            }
        }
        } else {
            return ROTATION_NONE;
        }
    }
}