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

Commit 3fb64f7f authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Update nav buttons current view after inflates occur" into pi-dev

parents e16d4a8d 1efc9c38
Loading
Loading
Loading
Loading
+17 −2
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.view.Display;
import android.view.Display.Mode;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.Surface;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
@@ -80,6 +81,7 @@ public class NavigationBarInflaterView extends FrameLayout
    private static final String WEIGHT_CENTERED_SUFFIX = "WC";

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

    protected LayoutInflater mLayoutInflater;
    protected LayoutInflater mLandscapeInflater;
@@ -99,9 +101,9 @@ public class NavigationBarInflaterView extends FrameLayout
    public NavigationBarInflaterView(Context context, AttributeSet attrs) {
        super(context, attrs);
        createInflaters();
        Display display = ((WindowManager)
        mDisplay = ((WindowManager)
                context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
        Mode displayMode = display.getMode();
        Mode displayMode = mDisplay.getMode();
        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) {
        if (alternativeOrder != mAlternativeOrder) {
            mAlternativeOrder = alternativeOrder;
@@ -239,6 +252,8 @@ public class NavigationBarInflaterView extends FrameLayout

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

        updateButtonDispatchersCurrentView();
    }

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