Get dimens values from resources in pixels

This helps keep the indicator dots evenly distributed.

Fixes: 152093000
Test: manual - swipe between pages in QS and look at placement of dots
Change-Id: Idd474aff43d383c88290bf97e2adb711839bc076
This commit is contained in:
Robert Snoeberger
2020-09-25 15:29:12 -04:00
parent 993254c89e
commit b33db3f689
2 changed files with 9 additions and 8 deletions

View File

@@ -504,6 +504,10 @@
<dimen name="qs_header_tile_margin_bottom">18dp</dimen>
<dimen name="qs_page_indicator_width">16dp</dimen>
<dimen name="qs_page_indicator_height">8dp</dimen>
<!-- The size of a single dot in relation to the whole animation.
Scaled @dimen/qs_page_indicator-width by .4f.
-->
<dimen name="qs_page_indicator_dot_width">6.4dp</dimen>
<dimen name="qs_tile_icon_size">24dp</dimen>
<dimen name="qs_tile_text_size">12sp</dimen>
<dimen name="qs_tile_divider_height">1dp</dimen>

View File

@@ -2,6 +2,7 @@ package com.android.systemui.qs;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.drawable.Animatable2;
import android.graphics.drawable.AnimatedVectorDrawable;
@@ -31,9 +32,6 @@ public class PageIndicator extends ViewGroup {
private static final long ANIMATION_DURATION = 250;
// The size of a single dot in relation to the whole animation.
private static final float SINGLE_SCALE = .4f;
private static final float MINOR_ALPHA = .42f;
private final ArrayList<Integer> mQueuedPositions = new ArrayList<>();
@@ -75,11 +73,10 @@ public class PageIndicator extends ViewGroup {
}
array.recycle();
mPageIndicatorWidth =
(int) mContext.getResources().getDimension(R.dimen.qs_page_indicator_width);
mPageIndicatorHeight =
(int) mContext.getResources().getDimension(R.dimen.qs_page_indicator_height);
mPageDotWidth = (int) (mPageIndicatorWidth * SINGLE_SCALE);
Resources res = context.getResources();
mPageIndicatorWidth = res.getDimensionPixelSize(R.dimen.qs_page_indicator_width);
mPageIndicatorHeight = res.getDimensionPixelSize(R.dimen.qs_page_indicator_height);
mPageDotWidth = res.getDimensionPixelSize(R.dimen.qs_page_indicator_dot_width);
}
public void setNumPages(int numPages) {