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

Commit 11254354 authored by Roman Birg's avatar Roman Birg
Browse files

SystemUI: improve layout of qs detail panel



Don't try to fit the detail views, but allow the user to scroll freely
while detail view is showing and we are in landscape. The user can still
fling up and down and the velocity flings are respected in the detail
scroll lock mode.

Hitting done will always return the user
to the QS panel, or they can close the detail view manually.

Ticket: FEIJ-201

Change-Id: Id8b16a682ba5cebdc57c0455d81aa38fd5e90cbd
Signed-off-by: default avatarRoman Birg <roman@cyngn.com>
parent ed671ae4
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@
            android:layout_weight="1" />

    <LinearLayout
            android:id="@+id/buttons"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:paddingEnd="8dp"
+1 −1
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@
<com.android.systemui.qs.QSDetailItemsList xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:minHeight="200dp"
    android:minHeight="100dp"
    android:paddingTop="16dp"
    android:paddingStart="16dp"
    android:paddingEnd="16dp">
+2 −1
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListAdapter;
@@ -42,7 +43,7 @@ import java.util.List;
/**
 * Quick settings common detail list view with line items.
 */
public class QSDetailItemsList extends LinearLayout {
public class QSDetailItemsList extends FrameLayout {
    private static final String TAG = "QSDetailItemsList";

    private ListView mListView;
+26 −41
Original line number Diff line number Diff line
@@ -57,6 +57,7 @@ import com.android.systemui.qs.tiles.CustomQSTile;
import com.android.systemui.qs.tiles.EditTile;
import com.android.systemui.settings.BrightnessController;
import com.android.systemui.settings.ToggleSlider;
import com.android.systemui.statusbar.phone.NotificationPanelView;
import com.android.systemui.statusbar.phone.QSTileHost;
import com.android.systemui.statusbar.policy.BrightnessMirrorController;
import com.android.systemui.tuner.QsTuner;
@@ -64,11 +65,9 @@ import com.viewpagerindicator.CirclePageIndicator;
import cyanogenmod.app.StatusBarPanelCustomTile;
import cyanogenmod.providers.CMSettings;
import org.cyanogenmod.internal.logging.CMMetricsLogger;
import org.cyanogenmod.internal.util.QSConstants;
import org.cyanogenmod.internal.util.QSUtils;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
@@ -76,6 +75,8 @@ import java.util.List;
import java.util.ListIterator;
import java.util.Map;

import static android.content.res.Configuration.ORIENTATION_LANDSCAPE;

public class QSDragPanel extends QSPanel implements View.OnDragListener, View.OnLongClickListener {

    private static final String TAG = "QSDragPanel";
@@ -90,6 +91,7 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On

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

    private NotificationPanelView mPanelView;
    protected QSViewPager mViewPager;
    protected PagerAdapter mPagerAdapter;
    QSPanelTopView mQsPanelTop;
@@ -98,6 +100,7 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On

    private TextView mDetailRemoveButton;
    private DragTileRecord mDraggingRecord, mLastDragRecord;
    private ViewGroup mDetailButtons;
    private boolean mEditing;
    private boolean mDragging;
    private float mLastTouchLocationX, mLastTouchLocationY;
@@ -115,9 +118,6 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On
    List<TileRecord> mCurrentlyAnimating
            = Collections.synchronizedList(new ArrayList<TileRecord>());

    private Point mDisplaySize;
    private int[] mTmpLoc;

    private Runnable mResetPage = new Runnable() {
        @Override
        public void run() {
@@ -141,6 +141,7 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On
        updateResources();

        mDetail = LayoutInflater.from(mContext).inflate(R.layout.qs_detail, this, false);
        mDetailButtons = (ViewGroup) mDetail.findViewById(R.id.buttons);
        mDetailContent = (ViewGroup) mDetail.findViewById(android.R.id.content);
        mDetailRemoveButton = (TextView) mDetail.findViewById(android.R.id.button3);
        mDetailSettingsButton = (TextView) mDetail.findViewById(android.R.id.button2);
@@ -786,13 +787,6 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On
        return QSTileHost.TILES_PER_PAGE;
    }

    @Override
    protected void onSizeChanged(int w, int h, int oldw, int oldh) {
        super.onSizeChanged(w, h, oldw, oldh);
        mTmpLoc = null;
        mDisplaySize = null;
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        final int width = MeasureSpec.getSize(widthMeasureSpec);
@@ -807,37 +801,18 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On
        if (mFooter.hasFooter()) {
            h += mFooter.getView().getMeasuredHeight();
        }
        mGridHeight = h;

        mDetail.measure(exactly(width), MeasureSpec.UNSPECIFIED);

        if (mDetail.getMeasuredHeight() < h) {
            mDetail.measure(exactly(width), exactly(h));
        }

        // Check if the detail view would be overflowing below the physical height of the device
        // and cutting the content off. If it is, reduce the detail height to fit.
        if (isShowingDetail()) {
            if (mDisplaySize == null) {
                mDisplaySize = new Point();
                getDisplay().getSize(mDisplaySize);
            }
            if (mTmpLoc == null) {
                mTmpLoc = new int[2];
                mDetail.getLocationOnScreen(mTmpLoc);
        if (isShowingDetail() && !isClosingDetail() && mExpanded) {
            h = mDetail.getMeasuredHeight();
        }

            final int containerTop = mTmpLoc[1];
            final int detailBottom = containerTop + mDetail.getMeasuredHeight();
            if (detailBottom >= mDisplaySize.y) {
                // panel is hanging below the screen
                final int detailMinHeight = mDisplaySize.y - containerTop;
                mDetail.measure(exactly(width), exactly(detailMinHeight));
            }
            setMeasuredDimension(width, mDetail.getMeasuredHeight());
            mGridHeight = mDetail.getMeasuredHeight();
        } else {
        setMeasuredDimension(width, h);
            mGridHeight = h;
        }

        for (TileRecord record : mRecords) {
            setupRecord(record);
        }
@@ -867,11 +842,13 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On
            }
            r.tile.setDetailListening(show);
            int x = (int) ((DragTileRecord) r).destination.x + r.tileView.getWidth() / 2;
            int y = mViewPager.getTop() + (int) ((DragTileRecord) r).destination.y + r.tileView.getHeight() / 2;
            int y = mViewPager.getTop()
                    + (int) ((DragTileRecord) r).destination.y + r.tileView.getHeight() / 2;
            handleShowDetailImpl(r, show, x, y);
        } else {
            super.handleShowDetailTile(r, show);
        }
        mPageIndicator.setVisibility(!show ? View.VISIBLE : View.INVISIBLE);
    }

    @Override
@@ -884,9 +861,6 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On
        // view pager laid out from top of brightness view to bottom to page through settings
        mViewPager.layout(0, 0, w, viewPagerBottom);

        // layout page indicator inside viewpager inset
        mPageIndicator.layout(0, b - mPageIndicatorHeight, w, b);

        mDetail.layout(0, 0, w, mDetail.getMeasuredHeight());

        if (mFooter.hasFooter()) {
@@ -897,7 +871,10 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On

        if (!isShowingDetail() && !isClosingDetail()) {
            mQsPanelTop.bringToFront();

        }
        // layout page indicator inside viewpager inset
        mPageIndicator.layout(0, b - mPageIndicatorHeight, w, b);
    }

    protected int getRowTop(int row) {
@@ -1832,12 +1809,16 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On
                }
            });
        }
        mPanelView.setDetailRequestedScrollLock(mExpanded && show
                && getResources().getConfiguration().orientation == ORIENTATION_LANDSCAPE);
    }

    @Override
    protected void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        FontSizeUtils.updateFontSize(mDetailRemoveButton, R.dimen.qs_detail_button_text_size);
        mPanelView.setDetailRequestedScrollLock(mExpanded && isShowingDetail()
                && getResources().getConfiguration().orientation == ORIENTATION_LANDSCAPE);
    }

    @Override
@@ -1887,6 +1868,10 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On
        }
    }

    public void setPanelView(NotificationPanelView panelView) {
        this.mPanelView = panelView;
    }

    public static class TilesListAdapter extends BaseExpandableListAdapter
            implements QSTile.DetailAdapter {

+1 −1
Original line number Diff line number Diff line
@@ -72,7 +72,7 @@ public class QSPanel extends ViewGroup {
    protected int mDualTileUnderlap;
    protected int mBrightnessPaddingTop;
    protected int mGridHeight;
    private boolean mExpanded;
    protected boolean mExpanded;
    protected boolean mListening;
    private boolean mClosingDetail;

Loading