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

Commit d10e52b5 authored by Adnan Begovic's avatar Adnan Begovic
Browse files

SystemUI: Move remove button impl to QSDragPanel.

  Expose a few methods to make attaching listeners to
  objects in the detail adapter possible.

Change-Id: Ic72f27f7db4323de4a7b45643230bd20f8c8b4b5
parent d0199cf8
Loading
Loading
Loading
Loading
+36 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.content.ContentResolver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.res.Resources;
import android.content.res.Configuration;
import android.graphics.Canvas;
import android.graphics.PointF;
import android.graphics.drawable.Drawable;
@@ -42,6 +43,7 @@ import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import com.android.internal.logging.MetricsLogger;
import com.android.systemui.FontSizeUtils;
import com.android.systemui.R;
import com.android.systemui.cm.UserContentObserver;
import com.android.systemui.qs.tiles.EditTile;
@@ -52,9 +54,13 @@ import com.android.systemui.statusbar.phone.QSTileHost;
import com.android.systemui.statusbar.phone.SystemUIDialog;
import com.android.systemui.statusbar.policy.BrightnessMirrorController;
import com.android.systemui.tuner.QsTuner;

import com.viewpagerindicator.CirclePageIndicator;
import cyanogenmod.providers.CMSettings;

import cyanogenmod.app.StatusBarPanelCustomTile;
import cyanogenmod.providers.CMSettings;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -76,6 +82,7 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On
    QSPanelTopView mQsPanelTop;
    CirclePageIndicator mPageIndicator;

    private TextView mDetailRemoveButton;
    private DragTileRecord mDraggingRecord;
    private boolean mEditing;
    private boolean mDragging;
@@ -109,6 +116,7 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On

        mDetail = LayoutInflater.from(mContext).inflate(R.layout.qs_detail, this, false);
        mDetailContent = (ViewGroup) mDetail.findViewById(android.R.id.content);
        mDetailRemoveButton = (TextView) mDetail.findViewById(android.R.id.button3);
        mDetailSettingsButton = (TextView) mDetail.findViewById(android.R.id.button2);
        mDetailDoneButton = (TextView) mDetail.findViewById(android.R.id.button1);
        updateDetailText();
@@ -420,6 +428,12 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On
        return getPagesForCount(initialSize);
    }

    @Override
    protected void updateDetailText() {
        super.updateDetailText();
        mDetailRemoveButton.setText(R.string.quick_settings_remove);
    }

    /**
     * @return returns the number of pages that has at least 1 visible tile
     */
@@ -1454,6 +1468,22 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On
        }
    }

    @Override
    protected void handleShowDetailImpl(Record r, boolean show, int x, int y) {
        super.handleShowDetailImpl(r, show, x, y);
        if (show) {
            final StatusBarPanelCustomTile customTile = r.detailAdapter.getCustomTile();
            mDetailRemoveButton.setVisibility(customTile != null ? VISIBLE : GONE);
            mDetailRemoveButton.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    mHost.collapsePanels();
                    mHost.removeCustomTile(customTile);
                }
            });
        }
    }

    public int getDesiredColumnCount(int page, int row) {
        if (page == 0 && row == 0) {
            return 2; // TODO change if large tiles are disabled
@@ -1462,6 +1492,12 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On
        }
    }

    @Override
    protected void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        FontSizeUtils.updateFontSize(mDetailRemoveButton, R.dimen.qs_detail_button_text_size);
    }

    @Override
    public void setExpanded(boolean expanded) {
        super.setExpanded(expanded);
+4 −15
Original line number Diff line number Diff line
@@ -57,7 +57,6 @@ public class QSPanel extends ViewGroup {
    protected final ArrayList<TileRecord> mRecords = new ArrayList<>();
    protected View mDetail;
    protected ViewGroup mDetailContent;
    protected TextView mDetailRemoveButton;
    protected TextView mDetailSettingsButton;
    protected TextView mDetailDoneButton;
    protected View mBrightnessView;
@@ -95,10 +94,12 @@ public class QSPanel extends ViewGroup {
        setupViews();
    }

    /**
     * THIS IS OVERRIDDEN in QSDragPanel
     */
    protected void setupViews() {
        mDetail = LayoutInflater.from(mContext).inflate(R.layout.qs_detail, this, false);
        mDetailContent = (ViewGroup) mDetail.findViewById(android.R.id.content);
        mDetailRemoveButton = (TextView) mDetail.findViewById(android.R.id.button3);
        mDetailSettingsButton = (TextView) mDetail.findViewById(android.R.id.button2);
        mDetailDoneButton = (TextView) mDetail.findViewById(android.R.id.button1);
        updateDetailText();
@@ -149,7 +150,6 @@ public class QSPanel extends ViewGroup {
    protected void updateDetailText() {
        mDetailDoneButton.setText(R.string.quick_settings_done);
        mDetailSettingsButton.setText(R.string.quick_settings_more_settings);
        mDetailRemoveButton.setText(R.string.quick_settings_remove);
    }

    public void setBrightnessMirror(BrightnessMirrorController c) {
@@ -201,7 +201,6 @@ public class QSPanel extends ViewGroup {
        super.onConfigurationChanged(newConfig);
        FontSizeUtils.updateFontSize(mDetailDoneButton, R.dimen.qs_detail_button_text_size);
        FontSizeUtils.updateFontSize(mDetailSettingsButton, R.dimen.qs_detail_button_text_size);
        FontSizeUtils.updateFontSize(mDetailRemoveButton, R.dimen.qs_detail_button_text_size);

        // We need to poke the detail views as well as they might not be attached to the view
        // hierarchy but reused at a later point.
@@ -408,7 +407,7 @@ public class QSPanel extends ViewGroup {
        handleShowDetailImpl(r, show, x, y);
    }

    protected final void handleShowDetailImpl(Record r, boolean show, int x, int y) {
    protected void handleShowDetailImpl(Record r, boolean show, int x, int y) {
        boolean visibleDiff = (mDetailRecord != null) != show;
        if (!visibleDiff && mDetailRecord == r) return;  // already in right state
        DetailAdapter detailAdapter = null;
@@ -427,16 +426,6 @@ public class QSPanel extends ViewGroup {
                }
            });

            final StatusBarPanelCustomTile customTile = detailAdapter.getCustomTile();
            mDetailRemoveButton.setVisibility(customTile != null ? VISIBLE : GONE);
            mDetailRemoveButton.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    mHost.collapsePanels();
                    mHost.removeCustomTile(customTile);
                }
            });

            mDetailContent.removeAllViews();
            mDetail.bringToFront();
            mDetailContent.addView(r.detailView);