Merge "Fix sizes and paddings" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
81b1281672
@@ -17,7 +17,8 @@
|
||||
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:autoMirrored="true">
|
||||
<item android:id="@+id/slider_foreground">
|
||||
<item android:id="@+id/slider_foreground"
|
||||
android:height="@dimen/rounded_slider_height">
|
||||
<shape>
|
||||
<size android:height="@dimen/rounded_slider_height" />
|
||||
<solid android:color="?android:attr/colorControlActivated" />
|
||||
|
||||
@@ -16,8 +16,7 @@
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_gravity="center"
|
||||
style="@style/BrightnessDialogContainer">
|
||||
android:layout_gravity="center">
|
||||
|
||||
<com.android.systemui.settings.brightness.BrightnessSliderView
|
||||
android:id="@+id/brightness_slider"
|
||||
@@ -35,6 +34,8 @@
|
||||
android:minHeight="48dp"
|
||||
android:thumb="@null"
|
||||
android:background="@null"
|
||||
android:paddingStart="0dp"
|
||||
android:paddingEnd="0dp"
|
||||
android:progressDrawable="@drawable/brightness_progress_drawable_thick"
|
||||
android:splitTrack="false"
|
||||
/>
|
||||
|
||||
@@ -87,6 +87,10 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout {
|
||||
attrs, R.styleable.PagedTileLayout, 0, 0);
|
||||
mSideLabels = t.getBoolean(R.styleable.PagedTileLayout_sideLabels, false);
|
||||
t.recycle();
|
||||
if (mSideLabels) {
|
||||
setPageMargin(context.getResources().getDimensionPixelOffset(
|
||||
R.dimen.qs_tile_margin_horizontal));
|
||||
}
|
||||
}
|
||||
private int mLastMaxHeight = -1;
|
||||
|
||||
@@ -341,6 +345,9 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout {
|
||||
// Update bottom padding, useful for removing extra space once the panel page indicator is
|
||||
// hidden.
|
||||
Resources res = getContext().getResources();
|
||||
if (mSideLabels) {
|
||||
setPageMargin(res.getDimensionPixelOffset(R.dimen.qs_tile_margin_horizontal));
|
||||
}
|
||||
setPadding(0, 0, 0,
|
||||
getContext().getResources().getDimensionPixelSize(
|
||||
R.dimen.qs_paged_tile_layout_padding_bottom));
|
||||
|
||||
@@ -649,7 +649,7 @@ public class QSPanel extends LinearLayout implements Tunable {
|
||||
if (mFooter != null) {
|
||||
int footerMargin = 0;
|
||||
int indicatorMargin = 0;
|
||||
if (mUsingHorizontalLayout) {
|
||||
if (mUsingHorizontalLayout && !mSideLabels) {
|
||||
footerMargin = mFooterMarginStartHorizontal;
|
||||
indicatorMargin = footerMargin - mVisualMarginEnd;
|
||||
}
|
||||
@@ -677,15 +677,19 @@ public class QSPanel extends LinearLayout implements Tunable {
|
||||
}
|
||||
|
||||
public Pair<Integer, Integer> getVisualSideMargins() {
|
||||
return new Pair(mVisualMarginStart, mUsingHorizontalLayout ? 0 : mVisualMarginEnd);
|
||||
if (mSideLabels) {
|
||||
return new Pair(0, 0);
|
||||
} else {
|
||||
return new Pair(mVisualMarginStart, mUsingHorizontalLayout ? 0 : mVisualMarginEnd);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateTileLayoutMargins() {
|
||||
int marginEnd = mVisualMarginEnd;
|
||||
if (mUsingHorizontalLayout) {
|
||||
if (mUsingHorizontalLayout || mSideLabels) {
|
||||
marginEnd = 0;
|
||||
}
|
||||
updateMargins((View) mTileLayout, mVisualMarginStart, marginEnd);
|
||||
updateMargins((View) mTileLayout, mSideLabels ? 0 : mVisualMarginStart, marginEnd);
|
||||
}
|
||||
|
||||
private void updateDividerMargin() {
|
||||
|
||||
@@ -370,21 +370,21 @@ public class QuickStatusBarHeader extends FrameLayout {
|
||||
QuickQSPanelController quickQSPanelController) {
|
||||
mContentMarginStart = marginStart;
|
||||
mContentMarginEnd = marginEnd;
|
||||
for (int i = 0; i < getChildCount(); i++) {
|
||||
View view = getChildAt(i);
|
||||
if (view == mHeaderQsPanel) {
|
||||
// QS panel doesn't lays out some of its content full width
|
||||
quickQSPanelController.setContentMargins(marginStart, marginEnd);
|
||||
} else {
|
||||
MarginLayoutParams lp = (MarginLayoutParams) view.getLayoutParams();
|
||||
lp.setMarginStart(marginStart);
|
||||
lp.setMarginEnd(marginEnd);
|
||||
view.setLayoutParams(lp);
|
||||
}
|
||||
}
|
||||
// The clock and QQS are not direct children, but the container should be just a wrapper to
|
||||
// be able to move them together. So we set the margins to the actual views.
|
||||
quickQSPanelController.setContentMargins(0, 0);
|
||||
setContentMargins(mDatePrivacyView, marginStart, marginEnd);
|
||||
setContentMargins(mClockIconsView, marginStart, marginEnd);
|
||||
updateHeadersPadding();
|
||||
}
|
||||
|
||||
private void setContentMargins(View view, int marginStart, int marginEnd) {
|
||||
MarginLayoutParams lp = (MarginLayoutParams) view.getLayoutParams();
|
||||
lp.setMarginStart(marginStart);
|
||||
lp.setMarginEnd(marginEnd);
|
||||
view.setLayoutParams(lp);
|
||||
}
|
||||
|
||||
/**
|
||||
* When QS is scrolling, mClockIconsAlpha should scroll away and fade out.
|
||||
*
|
||||
|
||||
@@ -35,6 +35,10 @@ open class SideLabelTileLayout(
|
||||
return mRecords.size >= maxTiles()
|
||||
}
|
||||
|
||||
override fun useSidePadding(): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the position from the top of the layout of the tile with this index.
|
||||
*
|
||||
|
||||
@@ -121,6 +121,7 @@ public class TileLayout extends ViewGroup implements QSTileLayout {
|
||||
updateColumns();
|
||||
mMaxCellHeight = mContext.getResources().getDimensionPixelSize(mCellHeightResId);
|
||||
mCellMarginHorizontal = res.getDimensionPixelSize(R.dimen.qs_tile_margin_horizontal);
|
||||
mSidePadding = useSidePadding() ? mCellMarginHorizontal / 2 : 0;
|
||||
mCellMarginVertical= res.getDimensionPixelSize(R.dimen.qs_tile_margin_vertical);
|
||||
mCellMarginTop = res.getDimensionPixelSize(R.dimen.qs_tile_margin_top);
|
||||
mMaxAllowedRows = Math.max(1, getResources().getInteger(R.integer.quick_settings_max_rows));
|
||||
@@ -132,6 +133,10 @@ public class TileLayout extends ViewGroup implements QSTileLayout {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean useSidePadding() {
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean updateColumns() {
|
||||
int oldColumns = mColumns;
|
||||
mColumns = Math.min(mResourceColumns, mMaxColumns);
|
||||
@@ -150,8 +155,9 @@ public class TileLayout extends ViewGroup implements QSTileLayout {
|
||||
if (heightMode == MeasureSpec.UNSPECIFIED) {
|
||||
mRows = (numTiles + mColumns - 1) / mColumns;
|
||||
}
|
||||
final int gaps = mColumns - 1;
|
||||
mCellWidth =
|
||||
(availableWidth - (mCellMarginHorizontal * mColumns)) / mColumns;
|
||||
(availableWidth - (mCellMarginHorizontal * gaps) - mSidePadding * 2) / mColumns;
|
||||
|
||||
// Measure each QS tile.
|
||||
View previousView = this;
|
||||
@@ -241,8 +247,8 @@ public class TileLayout extends ViewGroup implements QSTileLayout {
|
||||
}
|
||||
|
||||
protected int getColumnStart(int column) {
|
||||
return getPaddingStart() + mCellMarginHorizontal / 2 +
|
||||
column * (mCellWidth + mCellMarginHorizontal);
|
||||
return getPaddingStart() + mSidePadding
|
||||
+ column * (mCellWidth + mCellMarginHorizontal);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -35,6 +35,7 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.view.AccessibilityDelegateCompat;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.GridLayoutManager.SpanSizeLookup;
|
||||
import androidx.recyclerview.widget.ItemTouchHelper;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
@@ -118,11 +119,12 @@ public class TileAdapter extends RecyclerView.Adapter<Holder> implements TileSta
|
||||
mUiEventLogger = uiEventLogger;
|
||||
mItemTouchHelper = new ItemTouchHelper(mCallbacks);
|
||||
mDecoration = new TileItemDecoration(context);
|
||||
mMarginDecoration = new MarginTileDecoration();
|
||||
mMarginDecoration = new MarginTileDecoration(!useHorizontalTiles);
|
||||
mMinNumTiles = context.getResources().getInteger(R.integer.quick_settings_min_num_tiles);
|
||||
mNumColumns = context.getResources().getInteger(NUM_COLUMNS_ID);
|
||||
mAccessibilityDelegate = new TileAdapterDelegate();
|
||||
mUseHorizontalTiles = useHorizontalTiles;
|
||||
mSizeLookup.setSpanIndexCacheEnabled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -708,6 +710,11 @@ public class TileAdapter extends RecyclerView.Adapter<Holder> implements TileSta
|
||||
|
||||
private static class MarginTileDecoration extends ItemDecoration {
|
||||
private int mHalfMargin;
|
||||
private final boolean mUseOutsideMargins;
|
||||
|
||||
private MarginTileDecoration(boolean useOutsideMargins) {
|
||||
mUseOutsideMargins = useOutsideMargins;
|
||||
}
|
||||
|
||||
public void setHalfMargin(int halfMargin) {
|
||||
mHalfMargin = halfMargin;
|
||||
@@ -716,11 +723,30 @@ public class TileAdapter extends RecyclerView.Adapter<Holder> implements TileSta
|
||||
@Override
|
||||
public void getItemOffsets(@NonNull Rect outRect, @NonNull View view,
|
||||
@NonNull RecyclerView parent, @NonNull State state) {
|
||||
if (parent.getLayoutManager() == null) return;
|
||||
|
||||
GridLayoutManager lm = ((GridLayoutManager) parent.getLayoutManager());
|
||||
SpanSizeLookup span = lm.getSpanSizeLookup();
|
||||
ViewHolder holder = parent.getChildViewHolder(view);
|
||||
int column = span.getSpanIndex(holder.getLayoutPosition(), lm.getSpanCount());
|
||||
|
||||
if (view instanceof TextView) {
|
||||
super.getItemOffsets(outRect, view, parent, state);
|
||||
} else {
|
||||
outRect.left = mHalfMargin;
|
||||
outRect.right = mHalfMargin;
|
||||
if (mUseOutsideMargins || (column != 0 && column != lm.getSpanCount() - 1)) {
|
||||
// Using outside margins or in a column that's not leftmost or rightmost
|
||||
// (half of the margin between columns).
|
||||
outRect.left = mHalfMargin;
|
||||
outRect.right = mHalfMargin;
|
||||
} else if (column == 0) {
|
||||
// Leftmost column when not using side margins. Should only have margin on the
|
||||
// right.
|
||||
outRect.right = mHalfMargin;
|
||||
} else {
|
||||
// Rightmost column when not using side margins. Should only have margin on the
|
||||
// left.
|
||||
outRect.left = mHalfMargin;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user