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

Commit c63ab11a authored by Danesh Mondegarian's avatar Danesh Mondegarian
Browse files

Navbar : Rework logic for determining orientation

This patch introduces better checks for hybrid ui's.
This should fix issues of small buttons due to incorrect ui determination

Thanks Rolf Arne Schulze for testing :)

Patchset 2 : Add more constraints for hybrid detection
Patchset 3 : Fix mismatched constraints

Change-Id: If5b61dc4764a98deedb5b801d11451fed2488cba
parent 9c4942e9
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -12,6 +12,7 @@ import android.content.res.Configuration;
import android.database.DataSetObserver;
import android.graphics.Color;
import android.provider.Settings;
import android.util.DisplayMetrics;
import android.view.HapticFeedbackConstants;
import android.view.KeyEvent;
import android.view.LayoutInflater;
@@ -56,6 +57,7 @@ public class NavbarEditor implements OnTouchListener {
            new LinkedHashMap<String,ButtonInfo>();

    protected static int visibleCount = 4;
    private static Boolean mIsDeviceHybrid = null;

    /**
     * Holds reference to the parent/root of the inflated view
@@ -165,6 +167,21 @@ public class NavbarEditor implements OnTouchListener {
        }
    };

    protected static boolean isDeviceHybrid(Context con) {
        if (mIsDeviceHybrid == null) {
            WindowManager wm = (WindowManager)con.getSystemService(Context.WINDOW_SERVICE);
            android.view.Display display = wm.getDefaultDisplay();
            int shortSize = Math.min(display.getRawHeight(), display.getRawWidth());
            int shortSizeDp = shortSize * DisplayMetrics.DENSITY_DEFAULT / DisplayMetrics.DENSITY_DEVICE;
            if (shortSizeDp < 720 && shortSizeDp >= 600) {
                mIsDeviceHybrid = true;
            } else {
                mIsDeviceHybrid = false;
            }
        }
        return mIsDeviceHybrid;
    }

    @Override
    public boolean onTouch(final View view, MotionEvent event) {
        if (!NavigationBarView.getEditMode() || (mDialog != null && mDialog.isShowing())) {
+1 −5
Original line number Diff line number Diff line
@@ -70,7 +70,6 @@ public class NavigationBarView extends LinearLayout {
    private OnClickListener mRecentsClickListener;
    private RecentsPanelView mRecentsPanel;
    private OnTouchListener mHomeSearchActionListener;
    private boolean mIs600dp;

    protected IStatusBarService mBarService;
    final Display mDisplay;
@@ -181,9 +180,6 @@ public class NavigationBarView extends LinearLayout {
        mBarSize = res.getDimensionPixelSize(R.dimen.navigation_bar_size);
        mVertical = false;
        mShowMenu = false;
        //Silly way to identify 600dp
        //TODO come up with a better way
        mIs600dp = res.getInteger(R.integer.notification_panel_layout_gravity) == 49;
        mDelegateHelper = new DelegateViewHelper(this);
        updateResources();

@@ -415,7 +411,7 @@ public class NavigationBarView extends LinearLayout {
        }
        mCurrentView = mRotatedViews[rot];
        mCurrentView.setVisibility(View.VISIBLE);
        if (!mIs600dp) {
        if (!NavbarEditor.isDeviceHybrid(mContext)) {
            mVertical = (rot == Surface.ROTATION_90 || rot == Surface.ROTATION_270);
        } else {
            mVertical = getWidth() > 0 && getHeight() > getWidth();