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

Commit 075b3cc5 authored by Roman Birg's avatar Roman Birg
Browse files

SystemUI: nuke broadcast tile from user tile list



Any app which is smart enough to mess with QS tiles has the ability to
make their own broadcast tile.

Ref: CYNGNOS-1814

Change-Id: I5553692b3ac4439c9c967a7209e6f687c7aef4f9
Signed-off-by: default avatarRoman Birg <roman@cyngn.com>
parent 1da54eea
Loading
Loading
Loading
Loading
+3 −35
Original line number Diff line number Diff line
@@ -88,7 +88,6 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On
    public static final boolean DEBUG_DRAG = false;

    private static final int MAX_ROW_COUNT = 3;
    private static final String BROADCAST_TILE_SPEC_PLACEHOLDER = "broadcast_placeholder";

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

@@ -1807,9 +1806,6 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On
                }
            }

            // add broadcast tile
            mPackageTileMap.get(PACKAGE_ANDROID).add(BROADCAST_TILE_SPEC_PLACEHOLDER);

            final List<String> systemTiles = mPackageTileMap.get(PACKAGE_ANDROID);
            Collections.sort(systemTiles);
        }
@@ -1918,9 +1914,7 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On
        }

        private String getQSTileLabel(String spec) {
            if (spec.equals(BROADCAST_TILE_SPEC_PLACEHOLDER)) {
                return mContext.getText(R.string.broadcast_tile).toString();
            } else if (QSUtils.isStaticQsTile(spec)) {
            if (QSUtils.isStaticQsTile(spec)) {
                int resource = QSTileHost.getLabelResource(spec);
                return mContext.getText(resource).toString();
            } else if (QSUtils.isDynamicQsTile(spec)) {
@@ -1947,9 +1941,6 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On
                        return state.icon.getDrawable(mContext);
                    }
                }
                if (spec.equals(BROADCAST_TILE_SPEC_PLACEHOLDER)) {
                    return getPackageDrawable(PACKAGE_ANDROID);
                }
                return getPackageDrawable(getCustomTilePackage(spec));
            }
        }
@@ -2013,12 +2004,8 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On
                public boolean onChildClick(ExpandableListView parent, View v,
                                            int groupPosition, int childPosition, long id) {
                    String spec = getChild(groupPosition, childPosition);
                    if (spec.equals(BROADCAST_TILE_SPEC_PLACEHOLDER)) {
                        showBroadcastTileDialog();
                    } else {
                    mPanel.add(spec);
                    mPanel.closeDetail();
                    }
                    return true;
                }
            });
@@ -2056,25 +2043,6 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On
            return CMMetricsLogger.DONT_LOG;
        }

        public void showBroadcastTileDialog() {
            final EditText editText = new EditText(mContext);
            final AlertDialog d = new AlertDialog.Builder(mContext)
                    .setTitle(R.string.broadcast_tile)
                    .setView(editText)
                    .setNegativeButton(android.R.string.cancel, null)
                    .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {
                            String action = editText.getText().toString();
                            if (isValid(action)) {
                                mPanel.add(IntentTile.PREFIX + action + ')');
                                mPanel.closeDetail();
                            }
                        }
                    }).create();
            SystemUIDialog.makeSystemUIDialog(d);
            d.show();
        }

        private boolean isValid(String action) {
            for (int i = 0; i < action.length(); i++) {
                char c = action.charAt(i);