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

Commit 11324a2d authored by Jiangyi's avatar Jiangyi Committed by Gerrit Code Review
Browse files

SystemUI: Rework SearchPanelView calculations

Make isScreenLarge calculations match how the system calculates where to put the navigation
bar. This fixes certain cases where the quick launch buttons on the glowpad of the
navigation bar is improperly oriented.

Patch set 2: The eval should be greater OR EQUAL to 600, not just greater. Also cache result
into a boolean before returning it.

Patch set 3-4: Actually cache it this time.

Patch set 5-6: Make it final.

Change-Id: I5703578b4d49a6eeab100bb23167abd5cf9a326d
parent 7eece5bb
Loading
Loading
Loading
Loading
+19 −5
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.database.ContentObserver;
import android.graphics.Point;
import android.os.Bundle;
import android.os.Handler;
import android.os.ServiceManager;
@@ -31,12 +32,14 @@ import android.os.Vibrator;
import android.provider.Settings;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.util.EventLog;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.ViewTreeObserver.OnPreDrawListener;
import android.view.WindowManager;
import android.widget.FrameLayout;

import com.android.internal.util.cm.NavigationRingConstants;
@@ -62,6 +65,7 @@ public class SearchPanelView extends FrameLayout implements
    private static final String ASSIST_ICON_METADATA_NAME =
            "com.android.systemui.action_assist_icon";
    private final Context mContext;
    private final boolean mIsScreenLarge;
    private BaseStatusBar mBar;
    private SettingsObserver mObserver;

@@ -83,6 +87,7 @@ public class SearchPanelView extends FrameLayout implements
        mContext = context;
        mActionTarget = new ActionTarget(context);
        mObserver = new SettingsObserver(new Handler());
        mIsScreenLarge = isScreenLarge();
    }

    class GlowPadTriggerListener implements GlowPadView.OnTriggerListener {
@@ -156,7 +161,7 @@ public class SearchPanelView extends FrameLayout implements
    private void setDrawables() {
        final ArrayList<TargetDrawable> targets = new ArrayList<TargetDrawable>();

        if (isScreenLarge() || isScreenPortrait()) {
        if (mIsScreenLarge || isScreenPortrait()) {
            mStartPosOffset =  1;
            mEndPosOffset = 4;
        } else {
@@ -326,11 +331,20 @@ public class SearchPanelView extends FrameLayout implements
    }

    private boolean isScreenLarge() {
        final Configuration configuration = mContext.getResources().getConfiguration();
        final int screenSize = configuration.screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK;
        WindowManager wm = (WindowManager) mContext.getSystemService(mContext.WINDOW_SERVICE);
        Point size = new Point();
        DisplayMetrics metrics = new DisplayMetrics();
        wm.getDefaultDisplay().getRealSize(size);
        wm.getDefaultDisplay().getMetrics(metrics);
        int width = size.x;
        int height = size.y;

        int shortSide = height > width ? width : height;
        int shortSideDp = shortSide * metrics.DENSITY_DEFAULT / metrics.densityDpi;

        boolean largeScreen = shortSideDp >= 600;

        return screenSize == Configuration.SCREENLAYOUT_SIZE_LARGE
                || screenSize == Configuration.SCREENLAYOUT_SIZE_XLARGE;
        return largeScreen;
    }

    private boolean isScreenPortrait() {