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

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

Working towards a better QS

Some work (mostly on the new QS only) to make things more like they
will be.

 - Remove Quick Tiles
 - Remove Dual Tiles
 - All tiles are the same, with slightly different UI in the header
 - QS tiles in the header match the beginning of QS
 - handleClick is a click from QS, handleSecondaryClick is a click
   from the header, but defaults to normal behavior.
 - Opening a detail panel from the header opens QS and the detail
   selected
 - Fix onStartListening bug in CustomTile
 - UI updates towards how QS will look

Change-Id: Id820586ccdaa258a5bcb72cadbeb14941fc5f935
parent 8dac23ea
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright (C) 2015 The Android Open Source Project
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~      http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License
  -->

<ripple xmlns:android="http://schemas.android.com/apk/res/android"
    android:color="?android:attr/colorControlHighlight" >
    <item android:drawable="@color/system_primary_color"/>
</ripple>
+7 −4
Original line number Diff line number Diff line
@@ -25,9 +25,10 @@
    android:layout_gravity="@integer/notification_panel_layout_gravity"
    android:paddingStart="@dimen/notification_side_padding"
    android:paddingEnd="@dimen/notification_side_padding"
    android:clipChildren="false"
    android:clipToPadding="false"
    android:baselineAligned="false"
    android:elevation="4dp"
    android:background="@drawable/notification_header_bg"
    android:background="@drawable/quick_header_bg"
    android:clickable="true"
    android:focusable="true"
    >
@@ -35,9 +36,11 @@
    <com.android.systemui.qs.QuickQSPanel
        android:id="@+id/quick_qs_panel"
        android:background="#0000"
        android:layout_width="144dp"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_alignParentEnd="true"
        android:clipChildren="false"
        android:clipToPadding="false"
        android:layout_marginEnd="12dp" />

    <LinearLayout
@@ -49,7 +52,7 @@
        android:clipToPadding="false"
        android:orientation="horizontal"
        android:layout_alignParentEnd="true"
        android:layout_marginEnd="10dp">
        android:layout_marginEnd="12dp">

        <com.android.systemui.statusbar.AlphaOptimizedFrameLayout
            android:id="@+id/settings_button_container"
+1 −1
Original line number Diff line number Diff line
@@ -173,7 +173,7 @@
    <dimen name="borderless_button_radius">2dp</dimen>

    <!-- How far the expanded QS panel peeks from the header in collapsed state. -->
    <dimen name="qs_peek_height">8dp</dimen>
    <dimen name="qs_peek_height">0dp</dimen>

    <!-- Zen mode panel: condition item button padding -->
    <dimen name="zen_mode_condition_detail_button_padding">8dp</dimen>
+0 −5
Original line number Diff line number Diff line
@@ -101,10 +101,6 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout {
        final int NT = mTiles.size();
        for (int i = 0; i < NT; i++) {
            TileRecord tile = mTiles.get(i);
            if (tile.tile.getTileType() == QSTileView.QS_TYPE_QUICK) {
                // Don't show any quick tiles for now.
                continue;
            }
            if (mPages.get(index).isFull()) {
                if (++index == mPages.size()) {
                    if (DEBUG) Log.d(TAG, "Adding page for " + tile.tile.getClass().getSimpleName());
@@ -178,7 +174,6 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout {

        public TilePage(Context context, AttributeSet attrs) {
            super(context, attrs);
            mAllowDual = false;
            updateResources();
        }

+104 −0
Original line number Diff line number Diff line
@@ -14,65 +14,91 @@
 * limitations under the License.
 */

package com.android.systemui;
package com.android.systemui.qs;

import android.content.Context;
import android.content.res.Resources;
import android.graphics.drawable.Animatable;
import android.graphics.drawable.Drawable;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import com.android.systemui.qs.QSTile;
import com.android.systemui.qs.QSTileBaseView;
import com.android.systemui.R;

public class QSQuickTileView extends QSTileBaseView {
import java.util.Objects;

    private final int mPadding;
    private final ImageView mIcon;
public class QSIconView extends ViewGroup {

    public QSQuickTileView(Context context) {
    private final View mIcon;
    private final int mIconSizePx;
    private final int mTilePaddingBelowIconPx;

    public QSIconView(Context context) {
        super(context);
        mPadding = context.getResources().getDimensionPixelSize(R.dimen.qs_quick_tile_padding);

        final Resources res = context.getResources();
        mIconSizePx = res.getDimensionPixelSize(R.dimen.qs_tile_icon_size);
        mTilePaddingBelowIconPx =  res.getDimensionPixelSize(R.dimen.qs_tile_padding_below_icon);

        mIcon = createIcon();
        addView(mIcon);
    }

    protected ImageView createIcon() {
        final ImageView icon = new ImageView(mContext);
        icon.setId(android.R.id.icon);
        icon.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
        return icon;
    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        final int w = MeasureSpec.getSize(widthMeasureSpec);
        final int iconSpec = exactly(mIconSizePx);
        mIcon.measure(MeasureSpec.makeMeasureSpec(w, getIconMeasureMode()), iconSpec);
        setMeasuredDimension(w, mIcon.getMeasuredHeight() + mTilePaddingBelowIconPx);
    }

    @Override
    public void init(OnClickListener click, OnClickListener clickSecondary,
                     OnLongClickListener longClick) {
        setClickable(true);
        setOnClickListener(click);
    protected void onLayout(boolean changed, int l, int t, int r, int b) {
        final int w = getMeasuredWidth();
        final int h = getMeasuredHeight();
        int top = 0;
        final int iconLeft = (w - mIcon.getMeasuredWidth()) / 2;
        layout(mIcon, iconLeft, top);
    }

    @Override
    protected void handleStateChanged(QSTile.State state) {
        mIcon.setImageDrawable(state.icon.getDrawable(getContext()));
        setContentDescription(state.contentDescription);
    public void setIcon(QSTile.State state) {
        setIcon((ImageView) mIcon, state);
    }

    @Override
    public boolean setType(int type) {
        return false;
    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;
            if (d != null && state.autoMirrorDrawable) {
                d.setAutoMirrored(true);
            }
            iv.setImageDrawable(d);
            iv.setTag(R.id.qs_icon_tag, state.icon);
            if (d instanceof Animatable) {
                Animatable a = (Animatable) d;
                if (state.icon instanceof QSTile.AnimationIcon && !iv.isShown()) {
                    a.stop(); // skip directly to end state
                }
            }
        }

    @Override
    public View updateAccessibilityOrder(View previousView) {
        return this;
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
        mIcon.measure(exactly(getMeasuredWidth() - 2 * mPadding),
                exactly(getMeasuredHeight() - 2 * mPadding));
    protected int getIconMeasureMode() {
        return MeasureSpec.EXACTLY;
    }

    @Override
    protected void onLayout(boolean changed, int l, int t, int r, int b) {
        layout(mIcon, mPadding, mPadding);
    protected View createIcon() {
        final ImageView icon = new ImageView(mContext);
        icon.setId(android.R.id.icon);
        icon.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
        return icon;
    }

    protected static int exactly(int size) {
        return MeasureSpec.makeMeasureSpec(size, MeasureSpec.EXACTLY);
    }

    protected static void layout(View child, int left, int top) {
        child.layout(left, top, left + child.getMeasuredWidth(), top + child.getMeasuredHeight());
    }
}
Loading