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

Commit 5d69d2cb authored by Flamefire's avatar Flamefire Committed by Clark Scheff
Browse files

Fix wrong scaling of QS tiles

Also increase margin with the number of tiles shown
and tweak sizes for better usability

PS2: Whitespace fix

Change-Id: I78a1e0d41d487ac48edc5f8992b7d5c95fbbfa71
parent 6d9ed990
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -13,19 +13,19 @@
     See the License for the specific language governing permissions and
     limitations under the License.
-->
<LinearLayout
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="top"
    android:orientation="vertical">
    android:layout_gravity="top">
    <ImageView
        android:id="@+id/image"
        android:layout_marginTop="@dimen/qs_tile_margin_above_icon"
        android:layout_marginBottom="@dimen/qs_tile_margin_below_icon"
        android:layout_width="@dimen/qs_tile_icon_size"
        android:layout_height="wrap_content"
        android:layout_height="@dimen/qs_tile_icon_size"
        android:layout_gravity="top|center_horizontal"
        android:layout_centerHorizontal="true"
        android:scaleType="centerInside"
        />
    <TextView
@@ -35,5 +35,7 @@
        android:layout_height="wrap_content"
        android:layout_gravity="top|center_horizontal"
        android:gravity="top|center_horizontal"
        android:layout_centerHorizontal="true"
        android:layout_below="@id/image"
        />
</LinearLayout>
 No newline at end of file
</RelativeLayout>
 No newline at end of file
+8 −3
Original line number Diff line number Diff line
@@ -18,12 +18,17 @@
    <dimen name="wifi_combo_margin_end">-6dp</dimen>

    <!-- Quick Settings tile geometry: width and height (ribbon mode) -->
    <dimen name="qs_ribbon_width_min">40dp</dimen>
    <dimen name="qs_ribbon_width_min">44dp</dimen>
    <dimen name="qs_ribbon_width_max">128dp</dimen>
    <dimen name="qs_ribbon_width_big">64dp</dimen>
    <dimen name="qs_ribbon_height_small">40dp</dimen>
    <dimen name="qs_ribbon_height_small">48dp</dimen>
    <dimen name="qs_ribbon_height_big">64dp</dimen>
    <!-- Quick Settings tile geometry: interior margin, above and below icon (ribbon mode) -->
    <dimen name="qs_tile_ribbon_icon_margin_small">4dp</dimen>
    <!-- Min/Max are used for automatic, the other ones for fixed settings -->
    <dimen name="qs_tile_ribbon_icon_margin_small">6dp</dimen>
    <dimen name="qs_tile_ribbon_icon_margin_small_min">4dp</dimen>
    <dimen name="qs_tile_ribbon_icon_margin_small_max">8dp</dimen>
    <dimen name="qs_tile_ribbon_icon_margin_big">16dp</dimen>
    <dimen name="qs_tile_ribbon_icon_margin_big_min">14dp</dimen>
    <dimen name="qs_tile_ribbon_icon_margin_big_max">17dp</dimen>
</resources>
 No newline at end of file
+3 −1
Original line number Diff line number Diff line
@@ -28,7 +28,8 @@ import android.provider.Settings;
import android.util.DisplayMetrics;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.view.View.OnLongClickListener;
import android.view.ViewGroup.MarginLayoutParams;
import android.widget.ImageView;
import android.widget.TextView;
@@ -75,6 +76,7 @@ public class QuickSettingsTile implements View.OnClickListener {
        mTileTextPadding = container.getTileTextPadding();
        mTile = (QuickSettingsTileView) inflater.inflate(
                R.layout.quick_settings_tile, container, false);
        mTile.setTile(this);
        mTile.setContent(mTileLayout, inflater);
        mContainer = container;
        mContainer.addView(mTile);
+17 −0
Original line number Diff line number Diff line
@@ -59,6 +59,8 @@ public class QuickSettingsContainerView extends FrameLayout {
    private int mCellWidth = -1;
    private int mMinCellWidth = 0;
    private int mMaxCellWidth = 0;
    private int mMinMargin = 0;
    private int mMaxMargin = 0;

    public QuickSettingsContainerView(Context context, AttributeSet attrs) {
        super(context, attrs);
@@ -96,6 +98,13 @@ public class QuickSettingsContainerView extends FrameLayout {
        mMaxCellWidth = r.getDimensionPixelSize(R.dimen.qs_ribbon_width_max);
        if (size == QSSize.Auto || size == QSSize.AutoNarrow) {
            mCellWidth = -1;
            if (size == QSSize.Auto) {
                mMaxMargin = r.getDimensionPixelSize(R.dimen.qs_tile_ribbon_icon_margin_big_max);
                mMinMargin = r.getDimensionPixelSize(R.dimen.qs_tile_ribbon_icon_margin_big_min);
            } else {
                mMaxMargin = r.getDimensionPixelSize(R.dimen.qs_tile_ribbon_icon_margin_small_max);
                mMinMargin = r.getDimensionPixelSize(R.dimen.qs_tile_ribbon_icon_margin_small_min);
            }
        } else {
            mCellWidth = r.getDimensionPixelSize(R.dimen.qs_ribbon_width_big);
        }
@@ -139,6 +148,14 @@ public class QuickSettingsContainerView extends FrameLayout {
                        cellWidth = mMinCellWidth;
                    else if (cellWidth > mMaxCellWidth)
                        cellWidth = mMaxCellWidth;
                    // Calculate the margin based on a linear interpolation
                    int widthDiff = mMaxCellWidth - mMinCellWidth;
                    float factor = widthDiff > 0 ? (cellWidth - mMinCellWidth) / widthDiff : 0.5f;
                    int margin = Math.round(mMaxMargin - factor * (mMaxMargin - mMinMargin));
                    for (int i = 0; i < N; ++i) {
                        QuickSettingsTileView v = (QuickSettingsTileView) getChildAt(i);
                        v.getTile().setImageMargins(margin);
                    }
                }
            }
        } else {
+11 −0
Original line number Diff line number Diff line
@@ -24,6 +24,8 @@ import android.view.View;
import android.view.ViewParent;
import android.widget.FrameLayout;

import com.android.systemui.quicksettings.QuickSettingsTile;

/**
 *
 */
@@ -34,6 +36,7 @@ public class QuickSettingsTileView extends FrameLayout {
    private int mColSpan;
    private boolean mPrepared;
    private OnPrepareListener mOnPrepareListener;
    private QuickSettingsTile mTile;

    public QuickSettingsTileView(Context context, AttributeSet attrs) {
        super(context, attrs);
@@ -42,6 +45,14 @@ public class QuickSettingsTileView extends FrameLayout {
        mColSpan = 1;
    }

    public void setTile(QuickSettingsTile tile) {
        mTile = tile;
    }

    public QuickSettingsTile getTile() {
        return mTile;
    }

    void setColumnSpan(int span) {
        mColSpan = span;
    }