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

Commit 5cac50c3 authored by Jason Monk's avatar Jason Monk Committed by Android (Google) Code Review
Browse files

Merge "Remove lights out views from nav bar" into nyc-dev

parents 6f1cdc92 5332e596
Loading
Loading
Loading
Loading
+0 −20
Original line number Diff line number Diff line
@@ -41,26 +41,6 @@

    </FrameLayout>

    <FrameLayout
        android:id="@+id/lights_out"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <LinearLayout
            android:id="@+id/ends_group_lightsout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="horizontal" />

        <LinearLayout
            android:id="@+id/center_group_lightsout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:gravity="center"
            android:orientation="horizontal" />

    </FrameLayout>

    <com.android.systemui.statusbar.policy.DeadZone
        android:id="@+id/deadzone"
        android:layout_height="match_parent"
+0 −20
Original line number Diff line number Diff line
@@ -42,26 +42,6 @@

    </FrameLayout>

    <FrameLayout
        android:id="@+id/lights_out"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <LinearLayout
            android:id="@+id/ends_group_lightsout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="horizontal" />

        <LinearLayout
            android:id="@+id/center_group_lightsout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:gravity="center"
            android:orientation="horizontal" />

    </FrameLayout>

    <com.android.systemui.statusbar.policy.DeadZone
        android:id="@+id/deadzone"
        android:layout_height="match_parent"
+0 −20
Original line number Diff line number Diff line
@@ -42,26 +42,6 @@

    </FrameLayout>

    <FrameLayout
        android:id="@+id/lights_out"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <com.android.systemui.statusbar.phone.ReverseLinearLayout
            android:id="@+id/ends_group_lightsout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical" />

        <com.android.systemui.statusbar.phone.ReverseLinearLayout
            android:id="@+id/center_group_lightsout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:gravity="center"
            android:orientation="vertical" />

    </FrameLayout>

    <com.android.systemui.statusbar.policy.DeadZone
        android:id="@+id/deadzone"
        android:layout_height="match_parent"
+8 −49
Original line number Diff line number Diff line
@@ -163,68 +163,29 @@ public class NavigationBarInflaterView extends FrameLayout implements TunerServi
        String[] start = sets[0].split(BUTTON_SEPARATOR);
        String[] center = sets[1].split(BUTTON_SEPARATOR);
        String[] end = sets[2].split(BUTTON_SEPARATOR);
        inflateButtons(start, (ViewGroup) mRot0.findViewById(R.id.ends_group),
                (ViewGroup) mRot0.findViewById(R.id.ends_group_lightsout), false);
        inflateButtons(start, (ViewGroup) mRot90.findViewById(R.id.ends_group),
                (ViewGroup) mRot90.findViewById(R.id.ends_group_lightsout), true);
        inflateButtons(start, (ViewGroup) mRot0.findViewById(R.id.ends_group), false);
        inflateButtons(start, (ViewGroup) mRot90.findViewById(R.id.ends_group), true);

        inflateButtons(center, (ViewGroup) mRot0.findViewById(R.id.center_group),
                (ViewGroup) mRot0.findViewById(R.id.center_group_lightsout), false);
        inflateButtons(center, (ViewGroup) mRot90.findViewById(R.id.center_group),
                (ViewGroup) mRot90.findViewById(R.id.center_group_lightsout), true);
        inflateButtons(center, (ViewGroup) mRot0.findViewById(R.id.center_group), false);
        inflateButtons(center, (ViewGroup) mRot90.findViewById(R.id.center_group), true);

        addGravitySpacer((LinearLayout) mRot0.findViewById(R.id.ends_group));
        addGravitySpacer((LinearLayout) mRot90.findViewById(R.id.ends_group));

        inflateButtons(end, (ViewGroup) mRot0.findViewById(R.id.ends_group),
                (ViewGroup) mRot0.findViewById(R.id.ends_group_lightsout), false);
        inflateButtons(end, (ViewGroup) mRot90.findViewById(R.id.ends_group),
                (ViewGroup) mRot90.findViewById(R.id.ends_group_lightsout), true);
        inflateButtons(end, (ViewGroup) mRot0.findViewById(R.id.ends_group), false);
        inflateButtons(end, (ViewGroup) mRot90.findViewById(R.id.ends_group), true);
    }

    private void addGravitySpacer(LinearLayout layout) {
        layout.addView(new Space(mContext), new LinearLayout.LayoutParams(0, 0, 1));
    }

    private void inflateButtons(String[] buttons, ViewGroup parent, ViewGroup lightsOutParent,
            boolean landscape) {
    private void inflateButtons(String[] buttons, ViewGroup parent, boolean landscape) {
        for (int i = 0; i < buttons.length; i++) {
            copyToLightsout(inflateButton(buttons[i], parent, landscape), lightsOutParent);
            inflateButton(buttons[i], parent, landscape);
        }
    }

    private void copyToLightsout(View view, ViewGroup lightsOutParent) {
        if (view == null) return;

        if (view instanceof FrameLayout) {
            // The only ViewGroup we support in here is a FrameLayout, so copy those manually.
            FrameLayout original = (FrameLayout) view;
            FrameLayout layout = new FrameLayout(view.getContext());
            for (int i = 0; i < original.getChildCount(); i++) {
                copyToLightsout(original.getChildAt(i), layout);
            }
            lightsOutParent.addView(layout, copy(view.getLayoutParams()));
        } else if (view instanceof Space) {
            lightsOutParent.addView(new Space(view.getContext()), copy(view.getLayoutParams()));
        } else {
            lightsOutParent.addView(generateLightsOutView(view), copy(view.getLayoutParams()));
        }
    }

    private View generateLightsOutView(View view) {
        ImageView imageView = new ImageView(view.getContext());
        // Copy everything we can about the original view.
        imageView.setPadding(view.getPaddingLeft(), view.getPaddingTop(), view.getPaddingRight(),
                view.getPaddingBottom());
        imageView.setContentDescription(view.getContentDescription());
        imageView.setId(view.getId());
        // Only home gets a big dot, everything else will be little.
        imageView.setImageResource(view.getId() == R.id.home
                ? R.drawable.ic_sysbar_lights_out_dot_large
                : R.drawable.ic_sysbar_lights_out_dot_small);
        return imageView;
    }

    private ViewGroup.LayoutParams copy(ViewGroup.LayoutParams layoutParams) {
        if (layoutParams instanceof LinearLayout.LayoutParams) {
            return new LinearLayout.LayoutParams(layoutParams.width, layoutParams.height,
@@ -348,9 +309,7 @@ public class NavigationBarInflaterView extends FrameLayout implements TunerServi
            }
        }
        clearAllChildren((ViewGroup) mRot0.findViewById(R.id.nav_buttons));
        clearAllChildren((ViewGroup) mRot0.findViewById(R.id.lights_out));
        clearAllChildren((ViewGroup) mRot90.findViewById(R.id.nav_buttons));
        clearAllChildren((ViewGroup) mRot90.findViewById(R.id.lights_out));
    }

    private void clearAllChildren(ViewGroup group) {
+1 −23
Original line number Diff line number Diff line
@@ -64,42 +64,20 @@ public final class NavigationBarTransitions extends BarTransitions {
        mLightsOut = lightsOut;

        final View navButtons = mView.getCurrentView().findViewById(R.id.nav_buttons);
        final View lowLights = mView.getCurrentView().findViewById(R.id.lights_out);

        // ok, everyone, stop it right there
        navButtons.animate().cancel();
        lowLights.animate().cancel();

        final float navButtonsAlpha = lightsOut ? 0f : 1f;
        final float lowLightsAlpha = lightsOut ? 1f : 0f;
        final float navButtonsAlpha = lightsOut ? 0.5f : 1f;

        if (!animate) {
            navButtons.setAlpha(navButtonsAlpha);
            lowLights.setAlpha(lowLightsAlpha);
            lowLights.setVisibility(lightsOut ? View.VISIBLE : View.GONE);
        } else {
            final int duration = lightsOut ? LIGHTS_OUT_DURATION : LIGHTS_IN_DURATION;
            navButtons.animate()
                .alpha(navButtonsAlpha)
                .setDuration(duration)
                .start();

            lowLights.setOnTouchListener(mLightsOutListener);
            if (lowLights.getVisibility() == View.GONE) {
                lowLights.setAlpha(0f);
                lowLights.setVisibility(View.VISIBLE);
            }
            lowLights.animate()
                .alpha(lowLightsAlpha)
                .setDuration(duration)
                .setInterpolator(new AccelerateInterpolator(2.0f))
                .setListener(lightsOut ? null : new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationEnd(Animator _a) {
                        lowLights.setVisibility(View.GONE);
                    }
                })
                .start();
        }
    }

Loading