Merge "fix(non linear font scaling): qs customizer page tile height is not scaling with font size" into udc-dev am: 716fe59bc1
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/23722147 Change-Id: If7a4d9cd4d48ca3324e329249dd218f4071cc694 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_height="@dimen/qs_tile_height"
|
android:layout_height="wrap_content"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_marginTop="@dimen/qs_tile_margin_top_bottom"
|
android:layout_marginTop="@dimen/qs_tile_margin_top_bottom"
|
||||||
android:layout_marginBottom="@dimen/qs_tile_margin_top_bottom"
|
android:layout_marginBottom="@dimen/qs_tile_margin_top_bottom"
|
||||||
|
|||||||
@@ -114,11 +114,18 @@ public class QSCustomizer extends LinearLayout {
|
|||||||
mQs = qs;
|
mQs = qs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void reloadAdapterTileHeight(@Nullable RecyclerView.Adapter adapter) {
|
||||||
|
if (adapter instanceof TileAdapter) {
|
||||||
|
((TileAdapter) adapter).reloadTileHeight();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** Animate and show QSCustomizer panel.
|
/** Animate and show QSCustomizer panel.
|
||||||
* @param x,y Location on screen of {@code edit} button to determine center of animation.
|
* @param x,y Location on screen of {@code edit} button to determine center of animation.
|
||||||
*/
|
*/
|
||||||
void show(int x, int y, TileAdapter tileAdapter) {
|
void show(int x, int y, TileAdapter tileAdapter) {
|
||||||
if (!isShown) {
|
if (!isShown) {
|
||||||
|
reloadAdapterTileHeight(tileAdapter);
|
||||||
mRecyclerView.getLayoutManager().scrollToPosition(0);
|
mRecyclerView.getLayoutManager().scrollToPosition(0);
|
||||||
int[] containerLocation = findViewById(R.id.customize_container).getLocationOnScreen();
|
int[] containerLocation = findViewById(R.id.customize_container).getLocationOnScreen();
|
||||||
mX = x - containerLocation[0];
|
mX = x - containerLocation[0];
|
||||||
@@ -136,6 +143,7 @@ public class QSCustomizer extends LinearLayout {
|
|||||||
|
|
||||||
void showImmediately() {
|
void showImmediately() {
|
||||||
if (!isShown) {
|
if (!isShown) {
|
||||||
|
reloadAdapterTileHeight(mRecyclerView.getAdapter());
|
||||||
mRecyclerView.getLayoutManager().scrollToPosition(0);
|
mRecyclerView.getLayoutManager().scrollToPosition(0);
|
||||||
setVisibility(VISIBLE);
|
setVisibility(VISIBLE);
|
||||||
mClipper.cancelAnimator();
|
mClipper.cancelAnimator();
|
||||||
|
|||||||
@@ -43,9 +43,11 @@ import androidx.recyclerview.widget.RecyclerView.State;
|
|||||||
import androidx.recyclerview.widget.RecyclerView.ViewHolder;
|
import androidx.recyclerview.widget.RecyclerView.ViewHolder;
|
||||||
|
|
||||||
import com.android.internal.logging.UiEventLogger;
|
import com.android.internal.logging.UiEventLogger;
|
||||||
|
import com.android.systemui.FontSizeUtils;
|
||||||
import com.android.systemui.R;
|
import com.android.systemui.R;
|
||||||
import com.android.systemui.qs.QSEditEvent;
|
import com.android.systemui.qs.QSEditEvent;
|
||||||
import com.android.systemui.qs.QSHost;
|
import com.android.systemui.qs.QSHost;
|
||||||
|
import com.android.systemui.qs.TileLayout;
|
||||||
import com.android.systemui.qs.customize.TileAdapter.Holder;
|
import com.android.systemui.qs.customize.TileAdapter.Holder;
|
||||||
import com.android.systemui.qs.customize.TileQueryHelper.TileInfo;
|
import com.android.systemui.qs.customize.TileQueryHelper.TileInfo;
|
||||||
import com.android.systemui.qs.customize.TileQueryHelper.TileStateListener;
|
import com.android.systemui.qs.customize.TileQueryHelper.TileStateListener;
|
||||||
@@ -114,6 +116,9 @@ public class TileAdapter extends RecyclerView.Adapter<Holder> implements TileSta
|
|||||||
private RecyclerView mRecyclerView;
|
private RecyclerView mRecyclerView;
|
||||||
private int mNumColumns;
|
private int mNumColumns;
|
||||||
|
|
||||||
|
private TextView mTempTextView;
|
||||||
|
private int mMinTileViewHeight;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public TileAdapter(
|
public TileAdapter(
|
||||||
@QSThemedContext Context context,
|
@QSThemedContext Context context,
|
||||||
@@ -129,6 +134,8 @@ public class TileAdapter extends RecyclerView.Adapter<Holder> implements TileSta
|
|||||||
mNumColumns = context.getResources().getInteger(NUM_COLUMNS_ID);
|
mNumColumns = context.getResources().getInteger(NUM_COLUMNS_ID);
|
||||||
mAccessibilityDelegate = new TileAdapterDelegate();
|
mAccessibilityDelegate = new TileAdapterDelegate();
|
||||||
mSizeLookup.setSpanIndexCacheEnabled(true);
|
mSizeLookup.setSpanIndexCacheEnabled(true);
|
||||||
|
mTempTextView = new TextView(context);
|
||||||
|
mMinTileViewHeight = context.getResources().getDimensionPixelSize(R.dimen.qs_tile_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -318,6 +325,10 @@ public class TileAdapter extends RecyclerView.Adapter<Holder> implements TileSta
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(final Holder holder, int position) {
|
public void onBindViewHolder(final Holder holder, int position) {
|
||||||
|
if (holder.mTileView != null) {
|
||||||
|
holder.mTileView.setMinimumHeight(mMinTileViewHeight);
|
||||||
|
}
|
||||||
|
|
||||||
if (holder.getItemViewType() == TYPE_HEADER) {
|
if (holder.getItemViewType() == TYPE_HEADER) {
|
||||||
setSelectableForHeaders(holder.itemView);
|
setSelectableForHeaders(holder.itemView);
|
||||||
return;
|
return;
|
||||||
@@ -860,4 +871,19 @@ public class TileAdapter extends RecyclerView.Adapter<Holder> implements TileSta
|
|||||||
- buttonMinWidth
|
- buttonMinWidth
|
||||||
- res.getDimensionPixelSize(R.dimen.qs_tile_margin_top_bottom);
|
- res.getDimensionPixelSize(R.dimen.qs_tile_margin_top_bottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Re-estimate the tile view height based under current font scaling. Like
|
||||||
|
* {@link TileLayout#estimateCellHeight()}, the tile view height would be estimated with 2
|
||||||
|
* labels as general case.
|
||||||
|
*/
|
||||||
|
public void reloadTileHeight() {
|
||||||
|
final int minHeight = mContext.getResources().getDimensionPixelSize(R.dimen.qs_tile_height);
|
||||||
|
FontSizeUtils.updateFontSize(mTempTextView, R.dimen.qs_tile_text_size);
|
||||||
|
int unspecifiedSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
|
||||||
|
mTempTextView.measure(unspecifiedSpec, unspecifiedSpec);
|
||||||
|
int padding = mContext.getResources().getDimensionPixelSize(R.dimen.qs_tile_padding);
|
||||||
|
int estimatedTileViewHeight = mTempTextView.getMeasuredHeight() * 2 + padding * 2;
|
||||||
|
mMinTileViewHeight = Math.max(minHeight, estimatedTileViewHeight);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user