Merge "[QS] Change spacing for QQS in landscape" into pi-dev
This commit is contained in:
@@ -24,6 +24,8 @@
|
|||||||
|
|
||||||
<dimen name="brightness_mirror_height">96dp</dimen>
|
<dimen name="brightness_mirror_height">96dp</dimen>
|
||||||
|
|
||||||
|
<!-- Width for the spacer, used between QS tiles. -->
|
||||||
|
<dimen name="qs_quick_tile_space_width">38dp</dimen>
|
||||||
<dimen name="qs_tile_margin_top">2dp</dimen>
|
<dimen name="qs_tile_margin_top">2dp</dimen>
|
||||||
<dimen name="qs_header_tooltip_height">24dp</dimen>
|
<dimen name="qs_header_tooltip_height">24dp</dimen>
|
||||||
|
|
||||||
|
|||||||
@@ -317,6 +317,8 @@
|
|||||||
<dimen name="qs_tile_margin_vertical">24dp</dimen>
|
<dimen name="qs_tile_margin_vertical">24dp</dimen>
|
||||||
<dimen name="qs_tile_margin_top">18dp</dimen>
|
<dimen name="qs_tile_margin_top">18dp</dimen>
|
||||||
<dimen name="qs_quick_tile_size">48dp</dimen>
|
<dimen name="qs_quick_tile_size">48dp</dimen>
|
||||||
|
<!-- Width for the spacer, used between QS tiles. -->
|
||||||
|
<dimen name="qs_quick_tile_space_width">0dp</dimen>
|
||||||
<dimen name="qs_quick_tile_padding">12dp</dimen>
|
<dimen name="qs_quick_tile_padding">12dp</dimen>
|
||||||
<dimen name="qs_header_gear_translation">16dp</dimen>
|
<dimen name="qs_header_gear_translation">16dp</dimen>
|
||||||
<dimen name="qs_header_tile_margin_horizontal">0dp</dimen>
|
<dimen name="qs_header_tile_margin_horizontal">0dp</dimen>
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
package com.android.systemui.qs;
|
package com.android.systemui.qs;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.res.Configuration;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@@ -179,15 +180,55 @@ public class QuickQSPanel extends QSPanel {
|
|||||||
|
|
||||||
protected final ArrayList<TileRecord> mRecords = new ArrayList<>();
|
protected final ArrayList<TileRecord> mRecords = new ArrayList<>();
|
||||||
private boolean mListening;
|
private boolean mListening;
|
||||||
|
/** Size of the QS tile (width & height). */
|
||||||
|
private int mTileDimensionSize;
|
||||||
|
|
||||||
public HeaderTileLayout(Context context) {
|
public HeaderTileLayout(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
setClipChildren(false);
|
setClipChildren(false);
|
||||||
setClipToPadding(false);
|
setClipToPadding(false);
|
||||||
setGravity(Gravity.CENTER_VERTICAL);
|
|
||||||
|
mTileDimensionSize = mContext.getResources().getDimensionPixelSize(
|
||||||
|
R.dimen.qs_quick_tile_size);
|
||||||
|
|
||||||
|
setGravity(Gravity.CENTER);
|
||||||
setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
|
setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onConfigurationChanged(Configuration newConfig) {
|
||||||
|
super.onConfigurationChanged(newConfig);
|
||||||
|
|
||||||
|
setGravity(Gravity.CENTER);
|
||||||
|
LayoutParams staticSpaceLayoutParams = generateSpaceLayoutParams(
|
||||||
|
mContext.getResources().getDimensionPixelSize(
|
||||||
|
R.dimen.qs_quick_tile_space_width));
|
||||||
|
|
||||||
|
// Update space params since they fill any open space in portrait orientation and have
|
||||||
|
// a static width in landscape orientation.
|
||||||
|
final int childViewCount = getChildCount();
|
||||||
|
for (int i = 0; i < childViewCount; i++) {
|
||||||
|
View childView = getChildAt(i);
|
||||||
|
if (childView instanceof Space) {
|
||||||
|
childView.setLayoutParams(staticSpaceLayoutParams);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns {@link LayoutParams} based on the given {@code spaceWidth}. If the width is 0,
|
||||||
|
* then we're going to have the space expand to take up as much space as possible. If the
|
||||||
|
* width is non-zero, we want the inter-tile spacers to be fixed.
|
||||||
|
*/
|
||||||
|
private LayoutParams generateSpaceLayoutParams(int spaceWidth) {
|
||||||
|
LayoutParams lp = new LayoutParams(spaceWidth, mTileDimensionSize);
|
||||||
|
if (spaceWidth == 0) {
|
||||||
|
lp.weight = 1;
|
||||||
|
}
|
||||||
|
lp.gravity = Gravity.CENTER;
|
||||||
|
return lp;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setListening(boolean listening) {
|
public void setListening(boolean listening) {
|
||||||
if (mListening == listening) return;
|
if (mListening == listening) return;
|
||||||
@@ -200,25 +241,22 @@ public class QuickQSPanel extends QSPanel {
|
|||||||
@Override
|
@Override
|
||||||
public void addTile(TileRecord tile) {
|
public void addTile(TileRecord tile) {
|
||||||
if (getChildCount() != 0) {
|
if (getChildCount() != 0) {
|
||||||
// Add a spacer.
|
// Add a spacer between tiles. We want static-width spaces if we're in landscape to
|
||||||
addView(new Space(mContext), getChildCount(), generateSpaceParams());
|
// keep the tiles close. For portrait, we stick with spaces that fill up any
|
||||||
|
// available space.
|
||||||
|
LayoutParams spaceLayoutParams = generateSpaceLayoutParams(
|
||||||
|
mContext.getResources().getDimensionPixelSize(
|
||||||
|
R.dimen.qs_quick_tile_space_width));
|
||||||
|
addView(new Space(mContext), getChildCount(), spaceLayoutParams);
|
||||||
}
|
}
|
||||||
addView(tile.tileView, getChildCount(), generateLayoutParams());
|
|
||||||
|
addView(tile.tileView, getChildCount(), generateTileLayoutParams());
|
||||||
mRecords.add(tile);
|
mRecords.add(tile);
|
||||||
tile.tile.setListening(this, mListening);
|
tile.tile.setListening(this, mListening);
|
||||||
}
|
}
|
||||||
|
|
||||||
private LayoutParams generateSpaceParams() {
|
private LayoutParams generateTileLayoutParams() {
|
||||||
int size = mContext.getResources().getDimensionPixelSize(R.dimen.qs_quick_tile_size);
|
LayoutParams lp = new LayoutParams(mTileDimensionSize, mTileDimensionSize);
|
||||||
LayoutParams lp = new LayoutParams(0, size);
|
|
||||||
lp.weight = 1;
|
|
||||||
lp.gravity = Gravity.CENTER;
|
|
||||||
return lp;
|
|
||||||
}
|
|
||||||
|
|
||||||
private LayoutParams generateLayoutParams() {
|
|
||||||
int size = mContext.getResources().getDimensionPixelSize(R.dimen.qs_quick_tile_size);
|
|
||||||
LayoutParams lp = new LayoutParams(size, size);
|
|
||||||
lp.gravity = Gravity.CENTER;
|
lp.gravity = Gravity.CENTER;
|
||||||
return lp;
|
return lp;
|
||||||
}
|
}
|
||||||
@@ -237,8 +275,8 @@ public class QuickQSPanel extends QSPanel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private int getChildIndex(QSTileView tileView) {
|
private int getChildIndex(QSTileView tileView) {
|
||||||
final int N = getChildCount();
|
final int childViewCount = getChildCount();
|
||||||
for (int i = 0; i < N; i++) {
|
for (int i = 0; i < childViewCount; i++) {
|
||||||
if (getChildAt(i) == tileView) {
|
if (getChildAt(i) == tileView) {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user