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

Commit 707e2072 authored by Selim Cinek's avatar Selim Cinek
Browse files

Fixed an issue where the shelf could be hidden

During reinflation, the panel could be stuck in
a bad state where qs edit mode was on but not
visible. QS edit now persists through reinflations.

Test: manual
Change-Id: I6e7a20fda2db2184a26a11093064a1367469ab45
Fixes: 62807612
parent d43bc31e
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -117,6 +117,18 @@ public class TransitionDrawable extends LayerDrawable implements Drawable.Callba
        invalidateSelf();
    }

    /**
     * Show the second layer on top of the first layer immediately
     *
     * @hide
     */
    public void showSecondLayer() {
        mAlpha = 255;
        mReverse = false;
        mTransitionState = TRANSITION_NONE;
        invalidateSelf();
    }

    /**
     * Show only the first layer.
     */
+4 −0
Original line number Diff line number Diff line
@@ -100,4 +100,8 @@ public class QSDetailClipper {
            mAnimator = null;
        };
    };

    public void showBackground() {
        mBackground.showSecondLayer();
    }
}
+8 −0
Original line number Diff line number Diff line
@@ -94,6 +94,13 @@ public class QSFragment extends Fragment implements QS {
        if (savedInstanceState != null) {
            setExpanded(savedInstanceState.getBoolean(EXTRA_EXPANDED));
            setListening(savedInstanceState.getBoolean(EXTRA_LISTENING));
            int[] loc = new int[2];
            View edit = view.findViewById(android.R.id.edit);
            edit.getLocationInWindow(loc);
            int x = loc[0] + edit.getWidth() / 2;
            int y = loc[1] + edit.getHeight() / 2;
            mQSCustomizer.setEditLocation(x, y);
            mQSCustomizer.restoreInstanceState(savedInstanceState);
        }
    }

@@ -110,6 +117,7 @@ public class QSFragment extends Fragment implements QS {
        super.onSaveInstanceState(outState);
        outState.putBoolean(EXTRA_EXPANDED, mQsExpanded);
        outState.putBoolean(EXTRA_LISTENING, mListening);
        mQSCustomizer.saveInstanceState(outState);
    }

    @VisibleForTesting
+54 −0
Original line number Diff line number Diff line
@@ -20,6 +20,9 @@ import android.animation.Animator.AnimatorListener;
import android.animation.AnimatorListenerAdapter;
import android.content.Context;
import android.content.res.Configuration;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.TransitionDrawable;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.support.v7.widget.DefaultItemAnimator;
@@ -42,6 +45,7 @@ import com.android.systemui.Dependency;
import com.android.systemui.R;
import com.android.systemui.plugins.qs.QS;
import com.android.systemui.plugins.qs.QSTile;
import com.android.systemui.qs.QSContainerImpl;
import com.android.systemui.qs.QSDetailClipper;
import com.android.systemui.qs.QSTileHost;
import com.android.systemui.statusbar.phone.NotificationsQuickSettingsContainer;
@@ -60,6 +64,7 @@ import java.util.List;
public class QSCustomizer extends LinearLayout implements OnMenuItemClickListener {

    private static final int MENU_RESET = Menu.FIRST;
    private static final String EXTRA_QS_CUSTOMIZING = "qs_customizing";

    private final QSDetailClipper mClipper;

@@ -109,11 +114,16 @@ public class QSCustomizer extends LinearLayout implements OnMenuItemClickListene
        DefaultItemAnimator animator = new DefaultItemAnimator();
        animator.setMoveDuration(TileAdapter.MOVE_DURATION);
        mRecyclerView.setItemAnimator(animator);
        updateNavBackDrop(getResources().getConfiguration());
    }

    @Override
    protected void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        updateNavBackDrop(newConfig);
    }

    private void updateNavBackDrop(Configuration newConfig) {
        View navBackdrop = findViewById(R.id.nav_bar_background);
        if (navBackdrop != null) {
            boolean shouldShow = newConfig.smallestScreenWidthDp >= 600
@@ -154,6 +164,21 @@ public class QSCustomizer extends LinearLayout implements OnMenuItemClickListene
        }
    }


    public void showImmediately() {
        if (!isShown) {
            setVisibility(VISIBLE);
            mClipper.showBackground();
            isShown = true;
            setTileSpecs();
            setCustomizing(true);
            queryTiles();
            mNotifQsContainer.setCustomizerAnimating(false);
            mNotifQsContainer.setCustomizerShowing(true);
            Dependency.get(KeyguardMonitor.class).addCallback(mKeyguardCallback);
        }
    }

    private void queryTiles() {
        mFinishedFetchingTiles = false;
        Runnable tileQueryFetchCompletion = () -> {
@@ -227,6 +252,35 @@ public class QSCustomizer extends LinearLayout implements OnMenuItemClickListene
        }
    }


    public void saveInstanceState(Bundle outState) {
        if (isShown) {
            Dependency.get(KeyguardMonitor.class).removeCallback(mKeyguardCallback);
        }
        outState.putBoolean(EXTRA_QS_CUSTOMIZING, mCustomizing);
    }

    public void restoreInstanceState(Bundle savedInstanceState) {
        boolean customizing = savedInstanceState.getBoolean(EXTRA_QS_CUSTOMIZING);
        if (customizing) {
            setVisibility(VISIBLE);
            addOnLayoutChangeListener(new OnLayoutChangeListener() {
                @Override
                public void onLayoutChange(View v, int left, int top, int right, int bottom,
                        int oldLeft,
                        int oldTop, int oldRight, int oldBottom) {
                    removeOnLayoutChangeListener(this);
                    showImmediately();
                }
            });
        }
    }

    public void setEditLocation(int x, int y) {
        mX = x;
        mY = y;
    }

    private final Callback mKeyguardCallback = () -> {
        if (!isAttachedToWindow()) return;
        if (Dependency.get(KeyguardMonitor.class).isShowing() && !mOpening) {
+5 −0
Original line number Diff line number Diff line
@@ -3484,6 +3484,11 @@ public class StatusBar extends SystemUI implements DemoMode,
            pw.print  ("      ");
            mNotificationPanel.dump(fd, pw, args);
        }
        pw.println("  mStackScroller: ");
        if (mStackScroller != null) {
            pw.print  ("      ");
            mStackScroller.dump(fd, pw, args);
        }

        DozeLog.dump(pw);

Loading