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

Commit 8934e670 authored by Jorim Jaggi's avatar Jorim Jaggi Committed by Android (Google) Code Review
Browse files

Merge "Limit item count in QS detail" into lmp-mr1-dev

parents d3cccec0 0ed01deb
Loading
Loading
Loading
Loading
+4 −0
Original line number Original line Diff line number Diff line
@@ -49,4 +49,8 @@
            android:textAppearance="@style/TextAppearance.QS.DetailEmpty" />
            android:textAppearance="@style/TextAppearance.QS.DetailEmpty" />
    </LinearLayout>
    </LinearLayout>


    <View
        android:id="@+id/min_height_spacer"
        android:layout_width="match_parent"
        android:layout_height="0dp"/>
</com.android.systemui.qs.QSDetailItems>
</com.android.systemui.qs.QSDetailItems>
 No newline at end of file
+23 −0
Original line number Original line Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>

<!--
  ~ Copyright (C) 2014 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
  -->

<resources>
    <!-- The maximum number of items to be displayed in quick settings -->
    <integer name="quick_settings_detail_max_item_count">8</integer>
</resources>
+3 −0
Original line number Original line Diff line number Diff line
@@ -131,6 +131,9 @@
    <integer name="quick_settings_brightness_dialog_short_timeout">2000</integer>
    <integer name="quick_settings_brightness_dialog_short_timeout">2000</integer>
    <integer name="quick_settings_brightness_dialog_long_timeout">4000</integer>
    <integer name="quick_settings_brightness_dialog_long_timeout">4000</integer>


    <!-- The maximum number of items to be displayed in quick settings -->
    <integer name="quick_settings_detail_max_item_count">7</integer>

    <integer name="blinds_pop_duration_ms">10</integer>
    <integer name="blinds_pop_duration_ms">10</integer>


    <!-- Should "4G" be shown instead of "LTE" when the network is NETWORK_TYPE_LTE? -->
    <!-- Should "4G" be shown instead of "LTE" when the network is NETWORK_TYPE_LTE? -->
+19 −1
Original line number Original line Diff line number Diff line
@@ -51,8 +51,10 @@ public class QSDetailItems extends FrameLayout {
    private boolean mItemsVisible = true;
    private boolean mItemsVisible = true;
    private LinearLayout mItems;
    private LinearLayout mItems;
    private View mEmpty;
    private View mEmpty;
    private View mMinHeightSpacer;
    private TextView mEmptyText;
    private TextView mEmptyText;
    private ImageView mEmptyIcon;
    private ImageView mEmptyIcon;
    private int mMaxItems;


    public QSDetailItems(Context context, AttributeSet attrs) {
    public QSDetailItems(Context context, AttributeSet attrs) {
        super(context, attrs);
        super(context, attrs);
@@ -77,6 +79,12 @@ public class QSDetailItems extends FrameLayout {
        mEmpty.setVisibility(GONE);
        mEmpty.setVisibility(GONE);
        mEmptyText = (TextView) mEmpty.findViewById(android.R.id.title);
        mEmptyText = (TextView) mEmpty.findViewById(android.R.id.title);
        mEmptyIcon = (ImageView) mEmpty.findViewById(android.R.id.icon);
        mEmptyIcon = (ImageView) mEmpty.findViewById(android.R.id.icon);
        mMinHeightSpacer = findViewById(R.id.min_height_spacer);

        // By default, a detail item view has fixed size.
        mMaxItems = getResources().getInteger(
                R.integer.quick_settings_detail_max_item_count);
        setMinHeightInItems(mMaxItems);
    }
    }


    @Override
    @Override
@@ -102,6 +110,16 @@ public class QSDetailItems extends FrameLayout {
        mEmptyText.setText(text);
        mEmptyText.setText(text);
    }
    }


    /**
     * Set the minimum height of this detail view, in item count.
     */
    public void setMinHeightInItems(int minHeightInItems) {
        ViewGroup.LayoutParams lp = mMinHeightSpacer.getLayoutParams();
        lp.height = minHeightInItems * getResources().getDimensionPixelSize(
                R.dimen.qs_detail_item_height);
        mMinHeightSpacer.setLayoutParams(lp);
    }

    @Override
    @Override
    protected void onAttachedToWindow() {
    protected void onAttachedToWindow() {
        super.onAttachedToWindow();
        super.onAttachedToWindow();
@@ -135,7 +153,7 @@ public class QSDetailItems extends FrameLayout {
    }
    }


    private void handleSetItems(Item[] items) {
    private void handleSetItems(Item[] items) {
        final int itemCount = items != null ? items.length : 0;
        final int itemCount = items != null ? Math.min(items.length, mMaxItems) : 0;
        mEmpty.setVisibility(itemCount == 0 ? VISIBLE : GONE);
        mEmpty.setVisibility(itemCount == 0 ? VISIBLE : GONE);
        mItems.setVisibility(itemCount == 0 ? GONE : VISIBLE);
        mItems.setVisibility(itemCount == 0 ? GONE : VISIBLE);
        for (int i = mItems.getChildCount() - 1; i >= itemCount; i--) {
        for (int i = mItems.getChildCount() - 1; i >= itemCount; i--) {
+1 −0
Original line number Original line Diff line number Diff line
@@ -185,6 +185,7 @@ public class BluetoothTile extends QSTile<QSTile.BooleanState> {
            mItems.setEmptyState(R.drawable.ic_qs_bluetooth_detail_empty,
            mItems.setEmptyState(R.drawable.ic_qs_bluetooth_detail_empty,
                    R.string.quick_settings_bluetooth_detail_empty_text);
                    R.string.quick_settings_bluetooth_detail_empty_text);
            mItems.setCallback(this);
            mItems.setCallback(this);
            mItems.setMinHeightInItems(0);
            updateItems();
            updateItems();
            setItemsVisible(mState.value);
            setItemsVisible(mState.value);
            return mItems;
            return mItems;