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
This commit is contained in:
Fabian Kozynski
2022-03-24 14:40:57 -04:00
parent 1283caacb6
commit fd388805d6
5 changed files with 28 additions and 12 deletions

View File

@@ -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" />

View File

@@ -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 -->

View File

@@ -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>

View File

@@ -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) {

View File

@@ -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);
}
}