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

Commit fd388805 authored by Fabian Kozynski's avatar Fabian Kozynski
Browse files

Calculate min height for header in code

Having a resource that depended on 6 other resources was becoming
unmaintainable. Replace with in code calculation, guaranteeing that
it'll always be up to date for handheld devices.

Test: manual
Fixes: 225405922
Change-Id: Ieb13b1d71d4b205ea37ff096e447f93bbaec2630
parent 1283caac
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -21,6 +21,5 @@
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:minHeight="@dimen/qs_customize_header_min_height"
    android:textAppearance="@style/TextAppearance.QSEdit"
    android:text="@string/drag_to_rearrange_tiles" />
 No newline at end of file
+0 −5
Original line number Diff line number Diff line
@@ -25,11 +25,6 @@
    <dimen name="qs_brightness_margin_top">0dp</dimen>
    <dimen name="qs_brightness_margin_bottom">12dp</dimen>
    <dimen name="qqs_layout_margin_top">8dp</dimen>
    <!-- The height of the qs customize header. Should be
    (qs_panel_padding_top (48dp) +  brightness_mirror_height (48dp) + qs_brightness_margin_top (0dp) + qs_brightness_margin_bottom (12dp)) -
    (Toolbar_minWidth (56dp) + qs_tile_margin_top_bottom (4dp))
    -->
    <dimen name="qs_customize_header_min_height">48dp</dimen>

    <!--  In landscape the security footer is actually part of the header,
    and needs to be as short as the header  -->
+1 −5
Original line number Diff line number Diff line
@@ -476,11 +476,7 @@
    <dimen name="qs_brightness_margin_top">8dp</dimen>
    <dimen name="qs_brightness_margin_bottom">24dp</dimen>
    <dimen name="qqs_layout_margin_top">16dp</dimen>
    <!-- The height of the qs customize header. Should be
         (qs_panel_padding_top (48dp) +  brightness_mirror_height (48dp) + qs_brightness_margin_top(8dp) + qs_brightness_margin_bottom (24dp)) -
         (Toolbar_minWidth (56dp) + qs_tile_margin_top_bottom (4dp))
    -->
    <dimen name="qs_customize_header_min_height">68dp</dimen>

    <dimen name="qs_customize_internal_side_paddings">8dp</dimen>
    <dimen name="qs_icon_size">20dp</dimen>
    <dimen name="qs_side_view_size">28dp</dimen>
+1 −0
Original line number Diff line number Diff line
@@ -88,6 +88,7 @@ public class QSCustomizer extends LinearLayout {
        LayoutParams lp = (LayoutParams) mTransparentView.getLayoutParams();
        lp.height = QSUtils.getQsHeaderSystemIconsAreaHeight(mContext);
        mTransparentView.setLayoutParams(lp);
        mRecyclerView.getAdapter().notifyItemChanged(0);
    }

    void updateNavBackDrop(Configuration newConfig, LightBarController lightBarController) {
+26 −1
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@ package com.android.systemui.qs.customize;
import android.content.ComponentName;
import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
@@ -277,7 +278,9 @@ public class TileAdapter extends RecyclerView.Adapter<Holder> implements TileSta
        final Context context = parent.getContext();
        LayoutInflater inflater = LayoutInflater.from(context);
        if (viewType == TYPE_HEADER) {
            return new Holder(inflater.inflate(R.layout.qs_customize_header, parent, false));
            View v = inflater.inflate(R.layout.qs_customize_header, parent, false);
            v.setMinimumHeight(calculateHeaderMinHeight(context));
            return new Holder(v);
        }
        if (viewType == TYPE_DIVIDER) {
            return new Holder(inflater.inflate(R.layout.qs_customize_tile_divider, parent, false));
@@ -835,4 +838,26 @@ public class TileAdapter extends RecyclerView.Adapter<Holder> implements TileSta
            super.clearView(recyclerView, viewHolder);
        }
    };

    private static int calculateHeaderMinHeight(Context context) {
        Resources res = context.getResources();
        // style used in qs_customize_header.xml for the Toolbar
        TypedArray toolbarStyle = context.obtainStyledAttributes(
                R.style.QSCustomizeToolbar, com.android.internal.R.styleable.Toolbar);
        int buttonStyle = toolbarStyle.getResourceId(
                com.android.internal.R.styleable.Toolbar_navigationButtonStyle, 0);
        toolbarStyle.recycle();
        int buttonMinWidth = 0;
        if (buttonStyle != 0) {
            TypedArray t = context.obtainStyledAttributes(buttonStyle, android.R.styleable.View);
            buttonMinWidth = t.getDimensionPixelSize(android.R.styleable.View_minWidth, 0);
            t.recycle();
        }
        return res.getDimensionPixelSize(R.dimen.qs_panel_padding_top)
                + res.getDimensionPixelSize(R.dimen.brightness_mirror_height)
                + res.getDimensionPixelSize(R.dimen.qs_brightness_margin_top)
                + res.getDimensionPixelSize(R.dimen.qs_brightness_margin_bottom)
                - buttonMinWidth
                - res.getDimensionPixelSize(R.dimen.qs_tile_margin_top_bottom);
    }
}