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

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

QS Tweaks

 - Bring back toolbar, save on close, reset -> overflow
 - Fix drag on touch
 - Fix battery icon size
 - Verify correct permission to display QS tile

Bug: 27327479
Bug: 27250519
Bug: 27341503
Change-Id: I8984e441222e004f7ddd4b280b0c154bda2cc742
parent a4fe2389
Loading
Loading
Loading
Loading
+5 −39
Original line number Diff line number Diff line
@@ -22,47 +22,13 @@
    android:background="@drawable/qs_customizer_background"
    android:gravity="center_horizontal">

    <LinearLayout
    <Toolbar
        android:id="@*android:id/action_bar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingTop="28dp"
        android:paddingEnd="8dp">

        <ImageView
            android:id="@+id/close"
            android:layout_width="56dp"
            android:layout_height="56dp"
            android:padding="16dp"
            android:src="@drawable/ic_close_white" />

        <Space
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_weight="1" />

        <Button
            android:id="@+id/save"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:paddingStart="12dp"
            android:paddingEnd="12dp"
            android:background="?android:attr/selectableItemBackground"
            android:textAppearance="@android:style/TextAppearance.Material.Widget.Button.Inverse"
            android:textColor="?android:attr/colorAccent"
            android:text="@string/save" />

        <Button
            android:id="@+id/reset"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:paddingStart="12dp"
            android:paddingEnd="12dp"
            android:background="?android:attr/selectableItemBackground"
            android:textAppearance="@android:style/TextAppearance.Material.Widget.Button.Inverse"
            android:textColor="?android:attr/colorAccent"
            android:text="@*android:string/reset" />

    </LinearLayout>
        android:layout_marginTop="28dp"
        android:navigationContentDescription="@*android:string/action_bar_up_description"
        style="?android:attr/toolbarStyle" />

    <android.support.v7.widget.RecyclerView
        android:id="@android:id/list"
+1 −0
Original line number Diff line number Diff line
@@ -203,6 +203,7 @@
    <dimen name="qs_data_usage_text_size">14sp</dimen>
    <dimen name="qs_data_usage_usage_text_size">36sp</dimen>
    <dimen name="qs_expand_margin">0dp</dimen>
    <dimen name="qs_battery_padding">2dp</dimen>

    <dimen name="segmented_button_spacing">0dp</dimen>
    <dimen name="borderless_button_radius">2dp</dimen>
+2 −0
Original line number Diff line number Diff line
@@ -70,11 +70,13 @@ public class QSIconView extends ViewGroup {
    protected void setIcon(ImageView iv, QSTile.State state) {
        if (!Objects.equals(state.icon, iv.getTag(R.id.qs_icon_tag))) {
            Drawable d = state.icon != null ? state.icon.getDrawable(mContext) : null;
            int padding = state.icon != null ? state.icon.getPadding() : null;
            if (d != null && state.autoMirrorDrawable) {
                d.setAutoMirrored(true);
            }
            iv.setImageDrawable(d);
            iv.setTag(R.id.qs_icon_tag, state.icon);
            iv.setPadding(0, padding, 0, padding);
            if (d instanceof Animatable) {
                Animatable a = (Animatable) d;
                a.start();
+4 −0
Original line number Diff line number Diff line
@@ -420,6 +420,10 @@ public abstract class QSTile<TState extends State> implements Listenable {
        public int hashCode() {
            return Icon.class.hashCode();
        }

        public int getPadding() {
            return 0;
        }
    }

    public static class DrawableIcon extends Icon {
+35 −26
Original line number Diff line number Diff line
@@ -22,12 +22,15 @@ import android.content.Context;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.helper.ItemTouchHelper;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.ContextThemeWrapper;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.LinearLayout;
import android.widget.Toolbar;
import android.widget.Toolbar.OnMenuItemClickListener;
import com.android.systemui.R;
import com.android.systemui.qs.QSDetailClipper;
import com.android.systemui.qs.QSTile;
@@ -43,7 +46,9 @@ import java.util.List;
 * This adds itself to the status bar window, so it can appear on top of quick settings and
 * *someday* do fancy animations to get into/out of it.
 */
public class QSCustomizer extends LinearLayout implements OnClickListener {
public class QSCustomizer extends LinearLayout implements OnMenuItemClickListener {

    private static final int MENU_RESET = Menu.FIRST;

    private final QSDetailClipper mClipper;

@@ -53,9 +58,7 @@ public class QSCustomizer extends LinearLayout implements OnClickListener {
    private QSTileHost mHost;
    private RecyclerView mRecyclerView;
    private TileAdapter mTileAdapter;
    private View mClose;
    private View mSave;
    private View mReset;
    private Toolbar mToolbar;

    public QSCustomizer(Context context, AttributeSet attrs) {
        super(new ContextThemeWrapper(context, android.R.style.Theme_Material), attrs);
@@ -70,17 +73,26 @@ public class QSCustomizer extends LinearLayout implements OnClickListener {
    @Override
    protected void onFinishInflate() {
        super.onFinishInflate();
        mClose = findViewById(R.id.close);
        mSave = findViewById(R.id.save);
        mReset = findViewById(R.id.reset);
        mClose.setOnClickListener(this);
        mSave.setOnClickListener(this);
        mReset.setOnClickListener(this);
        mToolbar = (Toolbar) findViewById(com.android.internal.R.id.action_bar);
        TypedValue value = new TypedValue();
        mContext.getTheme().resolveAttribute(android.R.attr.homeAsUpIndicator, value, true);
        mToolbar.setNavigationIcon(
                getResources().getDrawable(R.drawable.ic_close_white, mContext.getTheme()));
        mToolbar.setNavigationOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                save();
                hide((int) v.getX() + v.getWidth() / 2, (int) v.getY() + v.getHeight() / 2);
            }
        });
        mToolbar.setOnMenuItemClickListener(this);
        mToolbar.getMenu().add(Menu.NONE, MENU_RESET, 0,
                mContext.getString(com.android.internal.R.string.reset));

        mRecyclerView = (RecyclerView) findViewById(android.R.id.list);
        mTileAdapter = new TileAdapter(getContext());
        mRecyclerView.setAdapter(mTileAdapter);
        new ItemTouchHelper(mTileAdapter.getCallback()).attachToRecyclerView(mRecyclerView);
        mTileAdapter.getItemTouchHelper().attachToRecyclerView(mRecyclerView);
        GridLayoutManager layout = new GridLayoutManager(getContext(), 3);
        layout.setSpanSizeLookup(mTileAdapter.getSizeLookup());
        mRecyclerView.setLayoutManager(layout);
@@ -111,6 +123,16 @@ public class QSCustomizer extends LinearLayout implements OnClickListener {
        return isShown;
    }

    @Override
    public boolean onMenuItemClick(MenuItem item) {
        switch (item.getItemId()) {
            case MENU_RESET:
                reset();
                break;
        }
        return false;
    }

    private void reset() {
        ArrayList<String> tiles = new ArrayList<>();
        String defTiles = mContext.getString(R.string.quick_settings_tiles_default);
@@ -130,19 +152,6 @@ public class QSCustomizer extends LinearLayout implements OnClickListener {

    private void save() {
        mTileAdapter.saveSpecs(mHost);
        hide((int) mSave.getX() + mSave.getWidth() / 2, (int) mSave.getY() + mSave.getHeight() / 2);
    }

    @Override
    public void onClick(View v) {
        if (v == mClose) {
            hide((int) mClose.getX() + mClose.getWidth() / 2,
                    (int) mClose.getY() + mClose.getHeight() / 2);
        } else if (v == mSave) {
            save();
        } else if (v == mReset) {
            reset();
        }
    }

    private final AnimatorListener mCollapseAnimationListener = new AnimatorListenerAdapter() {
Loading