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

Commit 848baf95 authored by Roman Birg's avatar Roman Birg
Browse files

QSTiles: use host to reset tiles instead of receiver



Change-Id: Icebe022826a623d37b7c82e07021c24b38a52565
Signed-off-by: default avatarRoman Birg <roman@cyngn.com>
parent f662e4b1
Loading
Loading
Loading
Loading
+0 −37
Original line number Diff line number Diff line
@@ -65,10 +65,6 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On

    public static final boolean DEBUG_DRAG = true;

    public static final String ACTION_EDIT_TILES = "com.android.systemui.ACTION_EDIT_TILES";
    public static final String EXTRA_EDIT = "edit";
    public static final String EXTRA_RESET = "reset";

    protected final ArrayList<QSPage> mPages = new ArrayList<>();

    protected QSViewPager mViewPager;
@@ -91,16 +87,6 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On
            = Collections.synchronizedList(new ArrayList<TileRecord>());
    private Collection<QSTile<?>> mTempTiles = null;

    private BroadcastReceiver mEditReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            if (intent.hasExtra(EXTRA_RESET) && intent.getBooleanExtra(EXTRA_RESET, false)) {
                setEditing(false);
                setTiles(mHost.getTiles());
            }
        }
    };

    public QSDragPanel(Context context) {
        this(context, null);
    }
@@ -235,18 +221,6 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On
        mQsPanelTop.getDropTarget().setOnDragListener(this);
    }

    @Override
    protected void onAttachedToWindow() {
        super.onAttachedToWindow();
        mContext.registerReceiver(mEditReceiver, new IntentFilter(ACTION_EDIT_TILES));
    }

    @Override
    protected void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        mContext.unregisterReceiver(mEditReceiver);
    }

    protected void drawTile(TileRecord r, QSTile.State state) {
        final int visibility = state.visible || mEditing ? VISIBLE : GONE;
        setTileVisibility(r.tileView, visibility);
@@ -283,7 +257,6 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On
    }

    protected void onStopDrag() {
        //mDraggingRecord.tileView.setVisibility(View.VISIBLE);
        mDraggingRecord.tileView.setAlpha(1f);

        mDraggingRecord = null;
@@ -1111,8 +1084,6 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On
            ti.row = tnext.row;
            ti.col = tnext.col;
            ti.destination.x = getLeft(tnext.destinationPage, ti.row, ti.col, desiredColumnCount);
//            ti.destination.x = getLeft(ti.row, ti.col, desiredColumnCount,
//                    tnext.destinationPage == 0 && ti.row == 0);
            ti.destination.y = getRowTop(ti.row);

            if (ti.destinationPage != tnext.destinationPage) {
@@ -1417,14 +1388,6 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On
        mHost.setTiles(tiles);
    }

    public void reset() {
        CMSettings.Secure.putStringForUser(getContext().getContentResolver(),
                CMSettings.Secure.QS_TILES, "default", ActivityManager.getCurrentUser());
        setEditing(false);
        setTiles(mHost.getTiles());
        requestLayout();
    }

    public boolean isDragging() {
        return mDragging;
    }
+1 −0
Original line number Diff line number Diff line
@@ -337,6 +337,7 @@ public abstract class QSTile<TState extends State> implements Listenable {
        KeyguardMonitor getKeyguardMonitor();
        boolean isEditing();
        void setEditing(boolean editing);
        void resetTiles();

        public interface Callback {
            void onTilesChanged();
+1 −3
Original line number Diff line number Diff line
@@ -61,9 +61,7 @@ public class EditTile extends QSTile<QSTile.BooleanState> {
                        new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                Intent edit = new Intent(QSDragPanel.ACTION_EDIT_TILES);
                                edit.putExtra(QSDragPanel.EXTRA_RESET, true);
                                mContext.sendBroadcast(edit);
                                getHost().resetTiles();
                                refreshState(false);
                            }
                        }).create();
+7 −0
Original line number Diff line number Diff line
@@ -331,6 +331,13 @@ public class QSTileHost implements QSTile.Host, Tunable {
                TextUtils.join(",", tiles), ActivityManager.getCurrentUser());
    }

    @Override
    public void resetTiles() {
        setEditing(false);
        CMSettings.Secure.putStringForUser(getContext().getContentResolver(),
                CMSettings.Secure.QS_TILES, "default", ActivityManager.getCurrentUser());
    }

    public static int getLabelResource(String spec) {
        if (spec.equals("wifi")) return R.string.quick_settings_wifi_label;
        else if (spec.equals("bt")) return R.string.quick_settings_bluetooth_label;
+1 −1
Original line number Diff line number Diff line
@@ -105,7 +105,7 @@ public class QsTuner extends Fragment implements Callback {
                mQsPanel.setEditing(!mQsPanel.isEditing());
                break;
            case MENU_RESET:
                mQsPanel.reset();
                mTileHost.resetTiles();
                break;
            case android.R.id.home:
                getFragmentManager().popBackStack();