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

Commit 92c91412 authored by Muyuan Li's avatar Muyuan Li
Browse files

sysui: refactor for extensibility.

Bug: 28466607
Change-Id: I73b017240d86dd3d1be9f76bad284ef6f3c91c9f
(cherry picked from commit a78c415c79287f5d03086d0ebd9a7d970ac5360c)
parent 66df39df
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -28,7 +28,8 @@
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        sysui:itemHeight="@dimen/qs_detail_item_height" />
        sysui:itemHeight="@dimen/qs_detail_item_height"
        style="@style/AutoSizingList" />

    <LinearLayout
        android:id="@android:id/empty"
+6 −0
Original line number Diff line number Diff line
@@ -75,6 +75,12 @@
        <attr name="horizontalSpacing" format="dimension" />
    </declare-styleable>

    <declare-styleable name="AutoSizingList">
        <!-- Whether AutoSizingList will show only as many items as fit on screen and
             remove extra items instead of scrolling. -->
        <attr name="enableAutoSizing" format="boolean" />
    </declare-styleable>

    <!-- Theme for icons in the status bar (light/dark). background/fillColor is used for dual tone
         icons like wifi and signal, and singleToneColor is used for icons with only one tone.
         Contract: Pixel with fillColor blended over backgroundColor blended over translucent should
+3 −0
Original line number Diff line number Diff line
@@ -256,6 +256,9 @@
        <item name="numColumns">3</item>
    </style>

    <style name="AutoSizingList">
        <item name="enableAutoSizing">true</item>
    </style>
    <style name="Theme.AlertDialogHost" parent="android:Theme.DeviceDefault">
        <item name="android:windowIsTranslucent">true</item>
        <item name="android:windowBackground">@android:color/transparent</item>
+10 −1
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ public class AutoSizingList extends LinearLayout {

    private ListAdapter mAdapter;
    private int mCount;
    private boolean mEnableAutoSizing;

    public AutoSizingList(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
@@ -44,6 +45,8 @@ public class AutoSizingList extends LinearLayout {
        mHandler = new Handler();
        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.AutoSizingList);
        mItemSize = a.getDimensionPixelSize(R.styleable.AutoSizingList_itemHeight, 0);
        mEnableAutoSizing = a.getBoolean(R.styleable.AutoSizingList_enableAutoSizing, true);
        a.recycle();
    }

    public void setAdapter(ListAdapter adapter) {
@@ -60,7 +63,7 @@ public class AutoSizingList extends LinearLayout {
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        int requestedHeight = MeasureSpec.getSize(heightMeasureSpec);
        if (requestedHeight != 0) {
            int count = Math.min(requestedHeight / mItemSize, getDesiredCount());
            int count = getItemCount(requestedHeight);
            if (mCount != count) {
                postRebindChildren();
                mCount = count;
@@ -69,6 +72,12 @@ public class AutoSizingList extends LinearLayout {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    }

    private int getItemCount(int requestedHeight) {
        int desiredCount = getDesiredCount();
        return mEnableAutoSizing ? Math.min(requestedHeight / mItemSize, desiredCount)
                : desiredCount;
    }

    private int getDesiredCount() {
        return mAdapter != null ? mAdapter.getCount() : 0;
    }
+1 −1
Original line number Diff line number Diff line
@@ -54,7 +54,7 @@ public class QSDetail extends LinearLayout {

    protected View mQsDetailHeader;
    protected TextView mQsDetailHeaderTitle;
    private Switch mQsDetailHeaderSwitch;
    protected Switch mQsDetailHeaderSwitch;
    private ImageView mQsDetailHeaderProgress;

    protected QSTileHost mHost;
Loading