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

Commit b1c2f3bb authored by Jason Monk's avatar Jason Monk
Browse files

Update the QS footer from UI thread

Bug: 17070248
Change-Id: I0d72ce6e137f42ad321b3fd6b10b9a5f35ca7801
parent 03374ccc
Loading
Loading
Loading
Loading
+23 −7
Original line number Diff line number Diff line
@@ -51,6 +51,10 @@ public class QSFooter implements OnClickListener, DialogInterface.OnClickListene
    private QSTileHost mHost;
    private Handler mHandler;

    private boolean mIsVisible;
    private boolean mIsIconVisible;
    private int mFooterTextId;

    public QSFooter(QSPanel qsPanel, Context context) {
        mRootView = LayoutInflater.from(context)
                .inflate(R.layout.quick_settings_footer, qsPanel, false);
@@ -99,16 +103,17 @@ public class QSFooter implements OnClickListener, DialogInterface.OnClickListene

    private void handleRefreshState() {
        if (mSecurityController.hasDeviceOwner()) {
            mFooterText.setText(R.string.device_owned_footer);
            mRootView.setVisibility(View.VISIBLE);
            mFooterIcon.setVisibility(View.INVISIBLE);
            mFooterTextId = R.string.device_owned_footer;
            mIsVisible = true;
            mIsIconVisible = false;
        } else if (mSecurityController.isVpnEnabled()) {
            mFooterText.setText(R.string.vpn_footer);
            mRootView.setVisibility(View.VISIBLE);
            mFooterIcon.setVisibility(View.VISIBLE);
            mFooterTextId = R.string.vpn_footer;
            mIsVisible = true;
            mIsIconVisible = true;
        } else {
            mRootView.setVisibility(View.GONE);
            mIsVisible = false;
        }
        mRootView.post(mUpdateDisplayState);
    }

    @Override
@@ -181,6 +186,17 @@ public class QSFooter implements OnClickListener, DialogInterface.OnClickListene
        return R.string.monitoring_title;
    }

    private final Runnable mUpdateDisplayState = new Runnable() {
        @Override
        public void run() {
            if (mFooterTextId != 0) {
                mFooterText.setText(mFooterTextId);
            }
            mRootView.setVisibility(mIsVisible ? View.VISIBLE : View.GONE);
            mFooterIcon.setVisibility(mIsIconVisible ? View.VISIBLE : View.INVISIBLE);
        }
    };

    private class Callback implements VpnCallback {
        @Override
        public void onVpnStateChanged() {