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

Commit 6ab4f6a1 authored by Jorim Jaggi's avatar Jorim Jaggi Committed by android-build-merger
Browse files

Merge \"Revert \"Fix navigation bar order in seascape\"\" into nyc-mr1-dev

am: ce715e49

Change-Id: I02b59a2f7ed17f9f5fd209cc090da62e37fa63ba
parents 0f817392 ce715e49
Loading
Loading
Loading
Loading
+1 −17
Original line number Original line Diff line number Diff line
@@ -28,6 +28,7 @@ import android.widget.LinearLayout;
import android.widget.Space;
import android.widget.Space;


import com.android.systemui.R;
import com.android.systemui.R;
import com.android.systemui.SystemUIFactory;
import com.android.systemui.statusbar.policy.KeyButtonView;
import com.android.systemui.statusbar.policy.KeyButtonView;
import com.android.systemui.tuner.TunerService;
import com.android.systemui.tuner.TunerService;


@@ -70,8 +71,6 @@ public class NavigationBarInflaterView extends FrameLayout implements TunerServi
    private View mLastRot0;
    private View mLastRot0;
    private View mLastRot90;
    private View mLastRot90;


    private boolean mAlternativeOrder;

    public NavigationBarInflaterView(Context context, AttributeSet attrs) {
    public NavigationBarInflaterView(Context context, AttributeSet attrs) {
        super(context, attrs);
        super(context, attrs);
        mDensity = context.getResources().getConfiguration().densityDpi;
        mDensity = context.getResources().getConfiguration().densityDpi;
@@ -115,7 +114,6 @@ public class NavigationBarInflaterView extends FrameLayout implements TunerServi
                false);
                false);
        mRot90.setId(R.id.rot90);
        mRot90.setId(R.id.rot90);
        addView(mRot90);
        addView(mRot90);
        updateAlternativeOrder();
        if (getParent() instanceof NavigationBarView) {
        if (getParent() instanceof NavigationBarView) {
            ((NavigationBarView) getParent()).updateRotatedViews();
            ((NavigationBarView) getParent()).updateRotatedViews();
        }
        }
@@ -154,20 +152,6 @@ public class NavigationBarInflaterView extends FrameLayout implements TunerServi
        }
        }
    }
    }


    public void setAlternativeOrder(boolean alternativeOrder) {
        if (alternativeOrder != mAlternativeOrder) {
            mAlternativeOrder = alternativeOrder;
            updateAlternativeOrder();
        }
    }

    private void updateAlternativeOrder() {
        ((ReverseLinearLayout) mRot90.findViewById(R.id.ends_group)).setAlternativeOrder(
                mAlternativeOrder);
        ((ReverseLinearLayout) mRot90.findViewById(R.id.center_group)).setAlternativeOrder(
                mAlternativeOrder);
    }

    private void initiallyFill(ButtonDispatcher buttonDispatcher) {
    private void initiallyFill(ButtonDispatcher buttonDispatcher) {
        addAll(buttonDispatcher, (ViewGroup) mRot0.findViewById(R.id.ends_group));
        addAll(buttonDispatcher, (ViewGroup) mRot0.findViewById(R.id.ends_group));
        addAll(buttonDispatcher, (ViewGroup) mRot0.findViewById(R.id.center_group));
        addAll(buttonDispatcher, (ViewGroup) mRot0.findViewById(R.id.center_group));
+2 −6
Original line number Original line Diff line number Diff line
@@ -99,8 +99,6 @@ public class NavigationBarView extends LinearLayout {
    private final SparseArray<ButtonDispatcher> mButtonDisatchers = new SparseArray<>();
    private final SparseArray<ButtonDispatcher> mButtonDisatchers = new SparseArray<>();
    private Configuration mConfiguration;
    private Configuration mConfiguration;


    private NavigationBarInflaterView mNavigationInflaterView;

    private class NavTransitionListener implements TransitionListener {
    private class NavTransitionListener implements TransitionListener {
        private boolean mBackTransitioning;
        private boolean mBackTransitioning;
        private boolean mHomeAppearing;
        private boolean mHomeAppearing;
@@ -474,10 +472,9 @@ public class NavigationBarView extends LinearLayout {


    @Override
    @Override
    public void onFinishInflate() {
    public void onFinishInflate() {
        mNavigationInflaterView = (NavigationBarInflaterView) findViewById(
                R.id.navigation_inflater);
        updateRotatedViews();
        updateRotatedViews();
        mNavigationInflaterView.setButtonDispatchers(mButtonDisatchers);
        ((NavigationBarInflaterView) findViewById(R.id.navigation_inflater)).setButtonDispatchers(
                mButtonDisatchers);


        getImeSwitchButton().setOnClickListener(mImeSwitcherClickListener);
        getImeSwitchButton().setOnClickListener(mImeSwitcherClickListener);


@@ -533,7 +530,6 @@ public class NavigationBarView extends LinearLayout {
        }
        }
        mCurrentView = mRotatedViews[rot];
        mCurrentView = mRotatedViews[rot];
        mCurrentView.setVisibility(View.VISIBLE);
        mCurrentView.setVisibility(View.VISIBLE);
        mNavigationInflaterView.setAlternativeOrder(rot == Surface.ROTATION_90);
        for (int i = 0; i < mButtonDisatchers.size(); i++) {
        for (int i = 0; i < mButtonDisatchers.size(); i++) {
            mButtonDisatchers.valueAt(i).setCurrentView(mCurrentView);
            mButtonDisatchers.valueAt(i).setCurrentView(mCurrentView);
        }
        }
+18 −27
Original line number Original line Diff line number Diff line
@@ -30,11 +30,7 @@ import java.util.ArrayList;
 */
 */
public class ReverseLinearLayout extends LinearLayout {
public class ReverseLinearLayout extends LinearLayout {


    /** If true, the layout is reversed vs. a regular linear layout */
    private boolean mIsLayoutRtl;
    private boolean mIsLayoutReverse;

    /** If true, the layout is opposite to it's natural reversity from the layout direction */
    private boolean mIsAlternativeOrder;


    public ReverseLinearLayout(Context context, @Nullable AttributeSet attrs) {
    public ReverseLinearLayout(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        super(context, attrs);
@@ -43,50 +39,45 @@ public class ReverseLinearLayout extends LinearLayout {
    @Override
    @Override
    protected void onFinishInflate() {
    protected void onFinishInflate() {
        super.onFinishInflate();
        super.onFinishInflate();
        updateOrder();
        mIsLayoutRtl = getResources().getConfiguration()
                .getLayoutDirection() == LAYOUT_DIRECTION_RTL;
    }
    }


    @Override
    @Override
    public void addView(View child) {
    public void addView(View child) {
        reversParams(child.getLayoutParams());
        reversParams(child.getLayoutParams());
        if (mIsLayoutReverse) {
        if (mIsLayoutRtl) {
            super.addView(child, 0);
        } else {
            super.addView(child);
            super.addView(child);
        } else {
            super.addView(child, 0);
        }
        }
    }
    }


    @Override
    @Override
    public void addView(View child, ViewGroup.LayoutParams params) {
    public void addView(View child, ViewGroup.LayoutParams params) {
        reversParams(params);
        reversParams(params);
        if (mIsLayoutReverse) {
        if (mIsLayoutRtl) {
            super.addView(child, 0, params);
        } else {
            super.addView(child, params);
            super.addView(child, params);
        } else {
            super.addView(child, 0, params);
        }
        }
    }
    }


    @Override
    @Override
    public void onRtlPropertiesChanged(int layoutDirection) {
    protected void onConfigurationChanged(Configuration newConfig) {
        super.onRtlPropertiesChanged(layoutDirection);
        super.onConfigurationChanged(newConfig);
        updateOrder();
        updateRTLOrder();
    }

    public void setAlternativeOrder(boolean alternative) {
        mIsAlternativeOrder = alternative;
        updateOrder();
    }
    }


    /**
    /**
     * In landscape, the LinearLayout is not auto mirrored since it is vertical. Therefore we
     * In landscape, the LinearLayout is not auto mirrored since it is vertical. Therefore we
     * have to do it manually
     * have to do it manually
     */
     */
    private void updateOrder() {
    private void updateRTLOrder() {
        boolean isLayoutRtl = getLayoutDirection() == LAYOUT_DIRECTION_RTL;
        boolean isLayoutRtl = getResources().getConfiguration()
        boolean isLayoutReverse = isLayoutRtl ^ mIsAlternativeOrder;
                .getLayoutDirection() == LAYOUT_DIRECTION_RTL;

        if (mIsLayoutRtl != isLayoutRtl) {
        if (mIsLayoutReverse != isLayoutReverse) {
            // RTL changed, swap the order of all views.
            // reversity changed, swap the order of all views.
            int childCount = getChildCount();
            int childCount = getChildCount();
            ArrayList<View> childList = new ArrayList<>(childCount);
            ArrayList<View> childList = new ArrayList<>(childCount);
            for (int i = 0; i < childCount; i++) {
            for (int i = 0; i < childCount; i++) {
@@ -96,7 +87,7 @@ public class ReverseLinearLayout extends LinearLayout {
            for (int i = childCount - 1; i >= 0; i--) {
            for (int i = childCount - 1; i >= 0; i--) {
                super.addView(childList.get(i));
                super.addView(childList.get(i));
            }
            }
            mIsLayoutReverse = isLayoutReverse;
            mIsLayoutRtl = isLayoutRtl;
        }
        }
    }
    }