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

Commit 1efc9c38 authored by Matthew Ng's avatar Matthew Ng
Browse files

Update nav buttons current view after inflates occur

Made sure that after nav buttons are inflated that the current view is
set immediately so that when using getCurrentView() you may not get an
older view (that could cause issues). Fixes the inability to quick scrub
because the getCurrentView() returned an old view that was detached from
parent and it's position was wrong not allowing home button to be
dragged.

Change-Id: Ia9ef61712298d0391b6479ee14d6410ca6d3f980
Fixes: 77909224
Test: wipe phone and try quick scrub
parent cd7a174c
Loading
Loading
Loading
Loading
+17 −2
Original line number Original line Diff line number Diff line
@@ -25,6 +25,7 @@ import android.view.Display;
import android.view.Display.Mode;
import android.view.Display.Mode;
import android.view.Gravity;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.LayoutInflater;
import android.view.Surface;
import android.view.View;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.view.WindowManager;
@@ -80,6 +81,7 @@ public class NavigationBarInflaterView extends FrameLayout
    private static final String WEIGHT_CENTERED_SUFFIX = "WC";
    private static final String WEIGHT_CENTERED_SUFFIX = "WC";


    private final List<NavBarButtonProvider> mPlugins = new ArrayList<>();
    private final List<NavBarButtonProvider> mPlugins = new ArrayList<>();
    private final Display mDisplay;


    protected LayoutInflater mLayoutInflater;
    protected LayoutInflater mLayoutInflater;
    protected LayoutInflater mLandscapeInflater;
    protected LayoutInflater mLandscapeInflater;
@@ -99,9 +101,9 @@ public class NavigationBarInflaterView extends FrameLayout
    public NavigationBarInflaterView(Context context, AttributeSet attrs) {
    public NavigationBarInflaterView(Context context, AttributeSet attrs) {
        super(context, attrs);
        super(context, attrs);
        createInflaters();
        createInflaters();
        Display display = ((WindowManager)
        mDisplay = ((WindowManager)
                context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
                context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
        Mode displayMode = display.getMode();
        Mode displayMode = mDisplay.getMode();
        isRot0Landscape = displayMode.getPhysicalWidth() > displayMode.getPhysicalHeight();
        isRot0Landscape = displayMode.getPhysicalWidth() > displayMode.getPhysicalHeight();
    }
    }


@@ -173,6 +175,17 @@ public class NavigationBarInflaterView extends FrameLayout
        }
        }
    }
    }


    public void updateButtonDispatchersCurrentView() {
        if (mButtonDispatchers != null) {
            final int rotation = mDisplay.getRotation();
            final View view = rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_180
                    ? mRot0 : mRot90;
            for (int i = 0; i < mButtonDispatchers.size(); i++) {
                mButtonDispatchers.valueAt(i).setCurrentView(view);
            }
        }
    }

    public void setAlternativeOrder(boolean alternativeOrder) {
    public void setAlternativeOrder(boolean alternativeOrder) {
        if (alternativeOrder != mAlternativeOrder) {
        if (alternativeOrder != mAlternativeOrder) {
            mAlternativeOrder = alternativeOrder;
            mAlternativeOrder = alternativeOrder;
@@ -239,6 +252,8 @@ public class NavigationBarInflaterView extends FrameLayout


        inflateButtons(end, mRot0.findViewById(R.id.ends_group), isRot0Landscape, false);
        inflateButtons(end, mRot0.findViewById(R.id.ends_group), isRot0Landscape, false);
        inflateButtons(end, mRot90.findViewById(R.id.ends_group), !isRot0Landscape, false);
        inflateButtons(end, mRot90.findViewById(R.id.ends_group), !isRot0Landscape, false);

        updateButtonDispatchersCurrentView();
    }
    }


    private void addGravitySpacer(LinearLayout layout) {
    private void addGravitySpacer(LinearLayout layout) {
+1 −3
Original line number Original line Diff line number Diff line
@@ -873,9 +873,7 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav
        mCurrentView = mRotatedViews[rot];
        mCurrentView = mRotatedViews[rot];
        mCurrentView.setVisibility(View.VISIBLE);
        mCurrentView.setVisibility(View.VISIBLE);
        mNavigationInflaterView.setAlternativeOrder(rot == Surface.ROTATION_90);
        mNavigationInflaterView.setAlternativeOrder(rot == Surface.ROTATION_90);
        for (int i = 0; i < mButtonDispatchers.size(); i++) {
        mNavigationInflaterView.updateButtonDispatchersCurrentView();
            mButtonDispatchers.valueAt(i).setCurrentView(mCurrentView);
        }
        updateLayoutTransitionsEnabled();
        updateLayoutTransitionsEnabled();
        mCurrentRotation = rot;
        mCurrentRotation = rot;
    }
    }