Merge "Updated the paddings of quick settings to match notifications" into rvc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
2c1bfedd7b
@@ -21,8 +21,6 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingTop="@dimen/qs_header_top_padding"
|
android:paddingTop="@dimen/qs_header_top_padding"
|
||||||
android:paddingBottom="@dimen/qs_header_bottom_padding"
|
android:paddingBottom="@dimen/qs_header_bottom_padding"
|
||||||
android:paddingStart="@dimen/status_bar_padding_start"
|
|
||||||
android:paddingEnd="@dimen/status_bar_padding_end"
|
|
||||||
android:layout_below="@id/quick_status_bar_system_icons"
|
android:layout_below="@id/quick_status_bar_system_icons"
|
||||||
android:clipChildren="false"
|
android:clipChildren="false"
|
||||||
android:clipToPadding="false"
|
android:clipToPadding="false"
|
||||||
|
|||||||
@@ -18,8 +18,6 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:paddingLeft="16dp"
|
|
||||||
android:paddingRight="16dp"
|
|
||||||
style="@style/BrightnessDialogContainer">
|
style="@style/BrightnessDialogContainer">
|
||||||
|
|
||||||
<com.android.systemui.settings.ToggleSliderView
|
<com.android.systemui.settings.ToggleSliderView
|
||||||
|
|||||||
@@ -19,8 +19,6 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="@dimen/qs_header_tooltip_height"
|
android:layout_height="@dimen/qs_header_tooltip_height"
|
||||||
android:layout_below="@id/quick_status_bar_system_icons"
|
android:layout_below="@id/quick_status_bar_system_icons"
|
||||||
android:paddingStart="@dimen/status_bar_padding_start"
|
|
||||||
android:paddingEnd="@dimen/status_bar_padding_end"
|
|
||||||
android:visibility="invisible"
|
android:visibility="invisible"
|
||||||
android:theme="@style/QSHeaderTheme">
|
android:theme="@style/QSHeaderTheme">
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
android:paddingStart="0dp"
|
android:paddingStart="0dp"
|
||||||
android:elevation="4dp" >
|
android:elevation="4dp" >
|
||||||
|
|
||||||
|
<!-- The clock -->
|
||||||
<include layout="@layout/quick_status_bar_header_system_icons" />
|
<include layout="@layout/quick_status_bar_header_system_icons" />
|
||||||
|
|
||||||
<!-- Status icons within the panel itself (and not in the top-most status bar) -->
|
<!-- Status icons within the panel itself (and not in the top-most status bar) -->
|
||||||
|
|||||||
@@ -25,8 +25,6 @@
|
|||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:clickable="true"
|
android:clickable="true"
|
||||||
android:paddingStart="@dimen/status_bar_padding_start"
|
|
||||||
android:paddingEnd="@dimen/status_bar_padding_end"
|
|
||||||
android:paddingTop="@dimen/status_bar_padding_top" >
|
android:paddingTop="@dimen/status_bar_padding_top" >
|
||||||
|
|
||||||
<com.android.systemui.statusbar.policy.Clock
|
<com.android.systemui.statusbar.policy.Clock
|
||||||
|
|||||||
@@ -17,5 +17,4 @@
|
|||||||
-->
|
-->
|
||||||
<resources>
|
<resources>
|
||||||
<dimen name="nav_content_padding">8dp</dimen>
|
<dimen name="nav_content_padding">8dp</dimen>
|
||||||
<dimen name="qs_header_tile_margin_horizontal">13dp</dimen>
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -482,7 +482,8 @@
|
|||||||
<dimen name="pull_span_min">25dp</dimen>
|
<dimen name="pull_span_min">25dp</dimen>
|
||||||
|
|
||||||
<dimen name="qs_tile_height">106dp</dimen>
|
<dimen name="qs_tile_height">106dp</dimen>
|
||||||
<dimen name="qs_tile_layout_margin_side">6dp</dimen>
|
<!--notification_side_paddings + notification_content_margin_start - (qs_quick_tile_size - qs_tile_background_size) / 2 -->
|
||||||
|
<dimen name="qs_tile_layout_margin_side">18dp</dimen>
|
||||||
<dimen name="qs_tile_margin_horizontal">18dp</dimen>
|
<dimen name="qs_tile_margin_horizontal">18dp</dimen>
|
||||||
<dimen name="qs_tile_margin_horizontal_two_line">2dp</dimen>
|
<dimen name="qs_tile_margin_horizontal_two_line">2dp</dimen>
|
||||||
<dimen name="qs_tile_margin_vertical">24dp</dimen>
|
<dimen name="qs_tile_margin_vertical">24dp</dimen>
|
||||||
@@ -498,7 +499,6 @@
|
|||||||
<dimen name="qs_quick_tile_size">48dp</dimen>
|
<dimen name="qs_quick_tile_size">48dp</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">4dp</dimen>
|
|
||||||
<dimen name="qs_header_tile_margin_bottom">18dp</dimen>
|
<dimen name="qs_header_tile_margin_bottom">18dp</dimen>
|
||||||
<dimen name="qs_page_indicator_width">16dp</dimen>
|
<dimen name="qs_page_indicator_width">16dp</dimen>
|
||||||
<dimen name="qs_page_indicator_height">8dp</dimen>
|
<dimen name="qs_page_indicator_height">8dp</dimen>
|
||||||
@@ -1057,9 +1057,8 @@
|
|||||||
<dimen name="edge_margin">8dp</dimen>
|
<dimen name="edge_margin">8dp</dimen>
|
||||||
|
|
||||||
<!-- The absolute side margins of quick settings -->
|
<!-- The absolute side margins of quick settings -->
|
||||||
<dimen name="quick_settings_side_margins">16dp</dimen>
|
|
||||||
<dimen name="quick_settings_expanded_bottom_margin">16dp</dimen>
|
<dimen name="quick_settings_expanded_bottom_margin">16dp</dimen>
|
||||||
<dimen name="quick_settings_media_extra_bottom_margin">4dp</dimen>
|
<dimen name="quick_settings_media_extra_bottom_margin">6dp</dimen>
|
||||||
<dimen name="rounded_corner_content_padding">0dp</dimen>
|
<dimen name="rounded_corner_content_padding">0dp</dimen>
|
||||||
<dimen name="nav_content_padding">0dp</dimen>
|
<dimen name="nav_content_padding">0dp</dimen>
|
||||||
<dimen name="nav_quick_scrub_track_edge_padding">24dp</dimen>
|
<dimen name="nav_quick_scrub_track_edge_padding">24dp</dimen>
|
||||||
|
|||||||
@@ -50,6 +50,8 @@ public class QSContainerImpl extends FrameLayout {
|
|||||||
|
|
||||||
private int mSideMargins;
|
private int mSideMargins;
|
||||||
private boolean mQsDisabled;
|
private boolean mQsDisabled;
|
||||||
|
private int mContentPaddingStart = -1;
|
||||||
|
private int mContentPaddingEnd = -1;
|
||||||
|
|
||||||
public QSContainerImpl(Context context, AttributeSet attrs) {
|
public QSContainerImpl(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
@@ -66,10 +68,9 @@ public class QSContainerImpl extends FrameLayout {
|
|||||||
mBackground = findViewById(R.id.quick_settings_background);
|
mBackground = findViewById(R.id.quick_settings_background);
|
||||||
mStatusBarBackground = findViewById(R.id.quick_settings_status_bar_background);
|
mStatusBarBackground = findViewById(R.id.quick_settings_status_bar_background);
|
||||||
mBackgroundGradient = findViewById(R.id.quick_settings_gradient_view);
|
mBackgroundGradient = findViewById(R.id.quick_settings_gradient_view);
|
||||||
mSideMargins = getResources().getDimensionPixelSize(R.dimen.notification_side_paddings);
|
updateResources();
|
||||||
|
|
||||||
setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO);
|
setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO);
|
||||||
setMargins();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -103,10 +104,15 @@ public class QSContainerImpl extends FrameLayout {
|
|||||||
if (navBelow) {
|
if (navBelow) {
|
||||||
maxQs -= getResources().getDimensionPixelSize(R.dimen.navigation_bar_height);
|
maxQs -= getResources().getDimensionPixelSize(R.dimen.navigation_bar_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int padding = mPaddingLeft + mPaddingRight + layoutParams.leftMargin
|
||||||
|
+ layoutParams.rightMargin;
|
||||||
|
final int qsPanelWidthSpec = getChildMeasureSpec(widthMeasureSpec, padding,
|
||||||
|
layoutParams.width);
|
||||||
// Measure with EXACTLY. That way, PagedTileLayout will only use excess height and will be
|
// Measure with EXACTLY. That way, PagedTileLayout will only use excess height and will be
|
||||||
// measured last, after other views and padding is accounted for.
|
// measured last, after other views and padding is accounted for.
|
||||||
mQSPanel.measure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(maxQs, MeasureSpec.EXACTLY));
|
mQSPanel.measure(qsPanelWidthSpec, MeasureSpec.makeMeasureSpec(maxQs, MeasureSpec.EXACTLY));
|
||||||
int width = mQSPanel.getMeasuredWidth();
|
int width = mQSPanel.getMeasuredWidth() + padding;
|
||||||
int height = layoutParams.topMargin + layoutParams.bottomMargin
|
int height = layoutParams.topMargin + layoutParams.bottomMargin
|
||||||
+ mQSPanel.getMeasuredHeight() + getPaddingBottom();
|
+ mQSPanel.getMeasuredHeight() + getPaddingBottom();
|
||||||
super.onMeasure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY),
|
super.onMeasure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY),
|
||||||
@@ -148,8 +154,18 @@ public class QSContainerImpl extends FrameLayout {
|
|||||||
LayoutParams layoutParams = (LayoutParams) mQSPanel.getLayoutParams();
|
LayoutParams layoutParams = (LayoutParams) mQSPanel.getLayoutParams();
|
||||||
layoutParams.topMargin = mContext.getResources().getDimensionPixelSize(
|
layoutParams.topMargin = mContext.getResources().getDimensionPixelSize(
|
||||||
com.android.internal.R.dimen.quick_qs_offset_height);
|
com.android.internal.R.dimen.quick_qs_offset_height);
|
||||||
|
|
||||||
mQSPanel.setLayoutParams(layoutParams);
|
mQSPanel.setLayoutParams(layoutParams);
|
||||||
|
|
||||||
|
mSideMargins = getResources().getDimensionPixelSize(R.dimen.notification_side_paddings);
|
||||||
|
mContentPaddingStart = getResources().getDimensionPixelSize(
|
||||||
|
com.android.internal.R.dimen.notification_content_margin_start);
|
||||||
|
int newPaddingEnd = getResources().getDimensionPixelSize(
|
||||||
|
com.android.internal.R.dimen.notification_content_margin_end);
|
||||||
|
boolean marginsChanged = newPaddingEnd != mContentPaddingEnd;
|
||||||
|
mContentPaddingEnd = newPaddingEnd;
|
||||||
|
if (marginsChanged) {
|
||||||
|
updatePaddingsAndMargins();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -196,17 +212,32 @@ public class QSContainerImpl extends FrameLayout {
|
|||||||
updateExpansion();
|
updateExpansion();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setMargins() {
|
private void updatePaddingsAndMargins() {
|
||||||
setMargins(mQSDetail);
|
for (int i = 0; i < getChildCount(); i++) {
|
||||||
setMargins(mBackground);
|
View view = getChildAt(i);
|
||||||
mQSPanel.setMargins(mSideMargins);
|
if (view == mStatusBarBackground || view == mBackgroundGradient
|
||||||
mHeader.setMargins(mSideMargins);
|
|| view == mQSCustomizer) {
|
||||||
}
|
// Some views are always full width
|
||||||
|
continue;
|
||||||
private void setMargins(View view) {
|
}
|
||||||
FrameLayout.LayoutParams lp = (LayoutParams) view.getLayoutParams();
|
LayoutParams lp = (LayoutParams) view.getLayoutParams();
|
||||||
lp.rightMargin = mSideMargins;
|
lp.rightMargin = mSideMargins;
|
||||||
lp.leftMargin = mSideMargins;
|
lp.leftMargin = mSideMargins;
|
||||||
|
if (view == mQSPanel) {
|
||||||
|
// QS panel lays out some of its content full width
|
||||||
|
mQSPanel.setContentMargins(mContentPaddingStart, mContentPaddingEnd);
|
||||||
|
} else if (view == mHeader) {
|
||||||
|
// The header contains the QQS panel which needs to have special padding, to
|
||||||
|
// visually align them.
|
||||||
|
mHeader.setContentMargins(mContentPaddingStart, mContentPaddingEnd);
|
||||||
|
} else {
|
||||||
|
view.setPaddingRelative(
|
||||||
|
mContentPaddingStart,
|
||||||
|
view.getPaddingTop(),
|
||||||
|
mContentPaddingEnd,
|
||||||
|
view.getPaddingBottom());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getDisplayHeight() {
|
private int getDisplayHeight() {
|
||||||
|
|||||||
@@ -88,6 +88,8 @@ public class QSPanel extends LinearLayout implements Tunable, Callback, Brightne
|
|||||||
private final H mHandler = new H();
|
private final H mHandler = new H();
|
||||||
private final MetricsLogger mMetricsLogger = Dependency.get(MetricsLogger.class);
|
private final MetricsLogger mMetricsLogger = Dependency.get(MetricsLogger.class);
|
||||||
private final QSTileRevealController mQsTileRevealController;
|
private final QSTileRevealController mQsTileRevealController;
|
||||||
|
/** Whether or not the QS media player feature is enabled. */
|
||||||
|
protected boolean mUsingMediaPlayer;
|
||||||
|
|
||||||
protected boolean mExpanded;
|
protected boolean mExpanded;
|
||||||
protected boolean mListening;
|
protected boolean mListening;
|
||||||
@@ -102,6 +104,9 @@ public class QSPanel extends LinearLayout implements Tunable, Callback, Brightne
|
|||||||
protected QSSecurityFooter mFooter;
|
protected QSSecurityFooter mFooter;
|
||||||
private PageIndicator mFooterPageIndicator;
|
private PageIndicator mFooterPageIndicator;
|
||||||
private boolean mGridContentVisible = true;
|
private boolean mGridContentVisible = true;
|
||||||
|
private int mContentMarginStart;
|
||||||
|
private int mContentMarginEnd;
|
||||||
|
private int mVisualTilePadding;
|
||||||
|
|
||||||
protected QSTileLayout mTileLayout;
|
protected QSTileLayout mTileLayout;
|
||||||
|
|
||||||
@@ -122,6 +127,7 @@ public class QSPanel extends LinearLayout implements Tunable, Callback, Brightne
|
|||||||
UiEventLogger uiEventLogger
|
UiEventLogger uiEventLogger
|
||||||
) {
|
) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
|
mUsingMediaPlayer = useQsMediaPlayer(context);
|
||||||
mMediaHost = mediaHost;
|
mMediaHost = mediaHost;
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mQSLogger = qsLogger;
|
mQSLogger = qsLogger;
|
||||||
@@ -170,8 +176,6 @@ public class QSPanel extends LinearLayout implements Tunable, Callback, Brightne
|
|||||||
mMediaHost.init(MediaHierarchyManager.LOCATION_QS);
|
mMediaHost.init(MediaHierarchyManager.LOCATION_QS);
|
||||||
ViewGroup hostView = mMediaHost.getHostView();
|
ViewGroup hostView = mMediaHost.getHostView();
|
||||||
addView(hostView);
|
addView(hostView);
|
||||||
int sidePaddings = getResources().getDimensionPixelSize(
|
|
||||||
R.dimen.quick_settings_side_margins);
|
|
||||||
int bottomPadding = getResources().getDimensionPixelSize(
|
int bottomPadding = getResources().getDimensionPixelSize(
|
||||||
R.dimen.quick_settings_expanded_bottom_margin);
|
R.dimen.quick_settings_expanded_bottom_margin);
|
||||||
MarginLayoutParams layoutParams = (MarginLayoutParams) hostView.getLayoutParams();
|
MarginLayoutParams layoutParams = (MarginLayoutParams) hostView.getLayoutParams();
|
||||||
@@ -179,8 +183,7 @@ public class QSPanel extends LinearLayout implements Tunable, Callback, Brightne
|
|||||||
layoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT;
|
layoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT;
|
||||||
layoutParams.bottomMargin = bottomPadding;
|
layoutParams.bottomMargin = bottomPadding;
|
||||||
hostView.setLayoutParams(layoutParams);
|
hostView.setLayoutParams(layoutParams);
|
||||||
hostView.setPadding(sidePaddings, hostView.getPaddingTop(), sidePaddings,
|
updateMediaHostContentMargins();
|
||||||
hostView.getPaddingBottom());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addDivider() {
|
protected void addDivider() {
|
||||||
@@ -359,8 +362,10 @@ public class QSPanel extends LinearLayout implements Tunable, Callback, Brightne
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void updateResources() {
|
public void updateResources() {
|
||||||
final Resources res = mContext.getResources();
|
int tileSize = getResources().getDimensionPixelSize(R.dimen.qs_quick_tile_size);
|
||||||
setPadding(0, res.getDimensionPixelSize(R.dimen.qs_panel_padding_top), 0, res.getDimensionPixelSize(R.dimen.qs_panel_padding_bottom));
|
int tileBg = getResources().getDimensionPixelSize(R.dimen.qs_tile_background_size);
|
||||||
|
mVisualTilePadding = (int) ((tileSize - tileBg) / 2.0f);
|
||||||
|
updatePadding();
|
||||||
|
|
||||||
updatePageIndicator();
|
updatePageIndicator();
|
||||||
|
|
||||||
@@ -372,6 +377,14 @@ public class QSPanel extends LinearLayout implements Tunable, Callback, Brightne
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void updatePadding() {
|
||||||
|
final Resources res = mContext.getResources();
|
||||||
|
setPaddingRelative(getPaddingStart(),
|
||||||
|
res.getDimensionPixelSize(R.dimen.qs_panel_padding_top),
|
||||||
|
getPaddingEnd(),
|
||||||
|
res.getDimensionPixelSize(R.dimen.qs_panel_padding_bottom));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onConfigurationChanged(Configuration newConfig) {
|
protected void onConfigurationChanged(Configuration newConfig) {
|
||||||
super.onConfigurationChanged(newConfig);
|
super.onConfigurationChanged(newConfig);
|
||||||
@@ -723,17 +736,51 @@ public class QSPanel extends LinearLayout implements Tunable, Callback, Brightne
|
|||||||
mFooter.showDeviceMonitoringDialog();
|
mFooter.showDeviceMonitoringDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMargins(int sideMargins) {
|
public void setContentMargins(int startMargin, int endMargin) {
|
||||||
for (int i = 0; i < getChildCount(); i++) {
|
// Only some views actually want this content padding, others want to go all the way
|
||||||
View view = getChildAt(i);
|
// to the edge like the brightness slider
|
||||||
if (view != mTileLayout) {
|
mContentMarginStart = startMargin;
|
||||||
LayoutParams lp = (LayoutParams) view.getLayoutParams();
|
mContentMarginEnd = endMargin;
|
||||||
lp.leftMargin = sideMargins;
|
updateTileLayoutMargins(mContentMarginStart - mVisualTilePadding,
|
||||||
lp.rightMargin = sideMargins;
|
mContentMarginEnd - mVisualTilePadding);
|
||||||
}
|
updateMediaHostContentMargins();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the margins of all tile Layouts.
|
||||||
|
*
|
||||||
|
* @param visualMarginStart the visual start margin of the tile, adjusted for local insets
|
||||||
|
* to the tile. This can be set on a tileLayout
|
||||||
|
* @param visualMarginEnd the visual end margin of the tile, adjusted for local insets
|
||||||
|
* to the tile. This can be set on a tileLayout
|
||||||
|
*/
|
||||||
|
protected void updateTileLayoutMargins(int visualMarginStart, int visualMarginEnd) {
|
||||||
|
updateMargins((View) mTileLayout, visualMarginStart, visualMarginEnd);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the margins of the media hosts
|
||||||
|
*/
|
||||||
|
protected void updateMediaHostContentMargins() {
|
||||||
|
if (mUsingMediaPlayer && mMediaHost != null) {
|
||||||
|
updateMargins(mMediaHost.getHostView(), mContentMarginStart, mContentMarginEnd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the margins of a view.
|
||||||
|
*
|
||||||
|
* @param view the view to adjust
|
||||||
|
* @param start the start margin to set
|
||||||
|
* @param end the end margin to set
|
||||||
|
*/
|
||||||
|
protected void updateMargins(View view, int start, int end) {
|
||||||
|
LayoutParams lp = (LayoutParams) view.getLayoutParams();
|
||||||
|
lp.setMarginStart(start);
|
||||||
|
lp.setMarginEnd(end);
|
||||||
|
view.setLayoutParams(lp);
|
||||||
|
}
|
||||||
|
|
||||||
public MediaHost getMediaHost() {
|
public MediaHost getMediaHost() {
|
||||||
return mMediaHost;
|
return mMediaHost;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,8 +62,6 @@ public class QuickQSPanel extends QSPanel {
|
|||||||
private boolean mDisabledByPolicy;
|
private boolean mDisabledByPolicy;
|
||||||
private int mMaxTiles;
|
private int mMaxTiles;
|
||||||
protected QSPanel mFullPanel;
|
protected QSPanel mFullPanel;
|
||||||
/** Whether or not the QS media player feature is enabled. */
|
|
||||||
private boolean mUsingMediaPlayer;
|
|
||||||
/** Whether or not the QuickQSPanel currently contains a media player. */
|
/** Whether or not the QuickQSPanel currently contains a media player. */
|
||||||
private boolean mShowHorizontalTileLayout;
|
private boolean mShowHorizontalTileLayout;
|
||||||
private LinearLayout mHorizontalLinearLayout;
|
private LinearLayout mHorizontalLinearLayout;
|
||||||
@@ -97,8 +95,6 @@ public class QuickQSPanel extends QSPanel {
|
|||||||
}
|
}
|
||||||
mMediaBottomMargin = getResources().getDimensionPixelSize(
|
mMediaBottomMargin = getResources().getDimensionPixelSize(
|
||||||
R.dimen.quick_settings_media_extra_bottom_margin);
|
R.dimen.quick_settings_media_extra_bottom_margin);
|
||||||
|
|
||||||
mUsingMediaPlayer = Utils.useQsMediaPlayer(context);
|
|
||||||
if (mUsingMediaPlayer) {
|
if (mUsingMediaPlayer) {
|
||||||
mHorizontalLinearLayout = new LinearLayout(mContext);
|
mHorizontalLinearLayout = new LinearLayout(mContext);
|
||||||
mHorizontalLinearLayout.setOrientation(LinearLayout.HORIZONTAL);
|
mHorizontalLinearLayout.setOrientation(LinearLayout.HORIZONTAL);
|
||||||
@@ -132,7 +128,6 @@ public class QuickQSPanel extends QSPanel {
|
|||||||
mHorizontalLinearLayout.setVisibility(useHorizontal ? View.VISIBLE : View.GONE);
|
mHorizontalLinearLayout.setVisibility(useHorizontal ? View.VISIBLE : View.GONE);
|
||||||
addView((View) mRegularTileLayout, 0);
|
addView((View) mRegularTileLayout, 0);
|
||||||
super.setPadding(0, 0, 0, 0);
|
super.setPadding(0, 0, 0, 0);
|
||||||
applySideMargins(mHorizontalLinearLayout);
|
|
||||||
applyBottomMargin((View) mRegularTileLayout);
|
applyBottomMargin((View) mRegularTileLayout);
|
||||||
} else {
|
} else {
|
||||||
sDefaultMaxTiles = getResources().getInteger(R.integer.quick_qs_panel_max_columns);
|
sDefaultMaxTiles = getResources().getInteger(R.integer.quick_qs_panel_max_columns);
|
||||||
@@ -151,14 +146,6 @@ public class QuickQSPanel extends QSPanel {
|
|||||||
view.setLayoutParams(layoutParams);
|
view.setLayoutParams(layoutParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void applySideMargins(View view) {
|
|
||||||
int margin = getResources().getDimensionPixelSize(R.dimen.qs_header_tile_margin_horizontal);
|
|
||||||
MarginLayoutParams layoutParams = (MarginLayoutParams) view.getLayoutParams();
|
|
||||||
layoutParams.setMarginStart(margin);
|
|
||||||
layoutParams.setMarginEnd(margin);
|
|
||||||
view.setLayoutParams(layoutParams);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void reAttachMediaHost() {
|
private void reAttachMediaHost() {
|
||||||
if (mMediaHost == null) {
|
if (mMediaHost == null) {
|
||||||
return;
|
return;
|
||||||
@@ -177,10 +164,6 @@ public class QuickQSPanel extends QSPanel {
|
|||||||
layoutParams.width = horizontal ? 0 : ViewGroup.LayoutParams.MATCH_PARENT;
|
layoutParams.width = horizontal ? 0 : ViewGroup.LayoutParams.MATCH_PARENT;
|
||||||
layoutParams.weight = horizontal ? 1.5f : 0;
|
layoutParams.weight = horizontal ? 1.5f : 0;
|
||||||
layoutParams.bottomMargin = mMediaBottomMargin;
|
layoutParams.bottomMargin = mMediaBottomMargin;
|
||||||
int marginStart = horizontal
|
|
||||||
? getResources().getDimensionPixelSize(R.dimen.qs_header_tile_margin_horizontal)
|
|
||||||
: 0;
|
|
||||||
layoutParams.setMarginStart(marginStart);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,11 +177,22 @@ public class QuickQSPanel extends QSPanel {
|
|||||||
mMediaHost.setShowsOnlyActiveMedia(true);
|
mMediaHost.setShowsOnlyActiveMedia(true);
|
||||||
mMediaHost.init(MediaHierarchyManager.LOCATION_QQS);
|
mMediaHost.init(MediaHierarchyManager.LOCATION_QQS);
|
||||||
reAttachMediaHost();
|
reAttachMediaHost();
|
||||||
|
updateMediaHostContentMargins();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPadding(int left, int top, int right, int bottom) {
|
protected void updateTileLayoutMargins(int visualMarginStart, int visualMarginEnd) {
|
||||||
// Always have no padding.
|
if (mUsingMediaPlayer) {
|
||||||
|
updateMargins((View) mRegularTileLayout, visualMarginStart, visualMarginEnd);
|
||||||
|
updateMargins((View) mHorizontalTileLayout, visualMarginStart, 0);
|
||||||
|
} else {
|
||||||
|
updateMargins((View) mTileLayout, visualMarginStart, visualMarginEnd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void updatePadding() {
|
||||||
|
// QS Panel is setting a top padding by default, which we don't need.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ import android.view.DisplayCutout;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.WindowInsets;
|
import android.view.WindowInsets;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
import android.widget.RelativeLayout;
|
import android.widget.RelativeLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
@@ -143,6 +144,11 @@ public class QuickStatusBarHeader extends RelativeLayout implements
|
|||||||
|
|
||||||
private boolean mHasTopCutout = false;
|
private boolean mHasTopCutout = false;
|
||||||
private int mRoundedCornerPadding = 0;
|
private int mRoundedCornerPadding = 0;
|
||||||
|
private int mContentMarginStart;
|
||||||
|
private int mContentMarginEnd;
|
||||||
|
private int mWaterfallTopInset;
|
||||||
|
private int mCutOutPaddingLeft;
|
||||||
|
private int mCutOutPaddingRight;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public QuickStatusBarHeader(@Named(VIEW_CONTEXT) Context context, AttributeSet attrs,
|
public QuickStatusBarHeader(@Named(VIEW_CONTEXT) Context context, AttributeSet attrs,
|
||||||
@@ -422,33 +428,42 @@ public class QuickStatusBarHeader extends RelativeLayout implements
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WindowInsets onApplyWindowInsets(WindowInsets insets) {
|
public WindowInsets onApplyWindowInsets(WindowInsets insets) {
|
||||||
// Handle padding of QuickStatusBarHeader
|
// Handle padding of the clock
|
||||||
setPadding(mRoundedCornerPadding, getPaddingTop(), mRoundedCornerPadding,
|
|
||||||
getPaddingBottom());
|
|
||||||
|
|
||||||
// Handle padding of SystemIconsView
|
|
||||||
DisplayCutout cutout = insets.getDisplayCutout();
|
DisplayCutout cutout = insets.getDisplayCutout();
|
||||||
Pair<Integer, Integer> cornerCutoutPadding = StatusBarWindowView.cornerCutoutMargins(
|
Pair<Integer, Integer> cornerCutoutPadding = StatusBarWindowView.cornerCutoutMargins(
|
||||||
cutout, getDisplay());
|
cutout, getDisplay());
|
||||||
Pair<Integer, Integer> padding =
|
Pair<Integer, Integer> padding =
|
||||||
StatusBarWindowView.paddingNeededForCutoutAndRoundedCorner(
|
StatusBarWindowView.paddingNeededForCutoutAndRoundedCorner(
|
||||||
cutout, cornerCutoutPadding, mRoundedCornerPadding);
|
cutout, cornerCutoutPadding, -1);
|
||||||
final int waterfallTopInset = cutout == null ? 0 : cutout.getWaterfallInsets().top;
|
mCutOutPaddingLeft = padding.first;
|
||||||
int statusBarPaddingLeft = isLayoutRtl()
|
mCutOutPaddingRight = padding.second;
|
||||||
? getResources().getDimensionPixelSize(R.dimen.status_bar_padding_end)
|
mWaterfallTopInset = cutout == null ? 0 : cutout.getWaterfallInsets().top;
|
||||||
: getResources().getDimensionPixelSize(R.dimen.status_bar_padding_start);
|
updateClockPadding();
|
||||||
int statusBarPaddingRight = isLayoutRtl()
|
|
||||||
? getResources().getDimensionPixelSize(R.dimen.status_bar_padding_start)
|
|
||||||
: getResources().getDimensionPixelSize(R.dimen.status_bar_padding_end);
|
|
||||||
mSystemIconsView.setPadding(
|
|
||||||
Math.max(padding.first + statusBarPaddingLeft - mRoundedCornerPadding, 0),
|
|
||||||
waterfallTopInset,
|
|
||||||
Math.max(padding.second + statusBarPaddingRight - mRoundedCornerPadding, 0),
|
|
||||||
0);
|
|
||||||
|
|
||||||
return super.onApplyWindowInsets(insets);
|
return super.onApplyWindowInsets(insets);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateClockPadding() {
|
||||||
|
int clockPaddingLeft = 0;
|
||||||
|
int clockPaddingRight = 0;
|
||||||
|
// The clock might collide with cutouts, let's shift it out of the way.
|
||||||
|
// We only do that if the inset is bigger than our own padding, since it's nicer to
|
||||||
|
// align with
|
||||||
|
if (mCutOutPaddingLeft > 0) {
|
||||||
|
// if there's a cutout, let's use at least the rounded corner inset
|
||||||
|
int cutoutPadding = Math.max(mCutOutPaddingLeft, mRoundedCornerPadding);
|
||||||
|
int contentMarginLeft = isLayoutRtl() ? mContentMarginEnd : mContentMarginStart;
|
||||||
|
clockPaddingLeft = Math.max(cutoutPadding - contentMarginLeft, 0);
|
||||||
|
}
|
||||||
|
if (mCutOutPaddingRight > 0) {
|
||||||
|
// if there's a cutout, let's use at least the rounded corner inset
|
||||||
|
int cutoutPadding = Math.max(mCutOutPaddingRight, mRoundedCornerPadding);
|
||||||
|
int contentMarginRight = isLayoutRtl() ? mContentMarginStart : mContentMarginEnd;
|
||||||
|
clockPaddingRight = Math.max(cutoutPadding - contentMarginRight, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
mSystemIconsView.setPadding(clockPaddingLeft, mWaterfallTopInset, clockPaddingRight, 0);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
public void onDetachedFromWindow() {
|
public void onDetachedFromWindow() {
|
||||||
@@ -558,24 +573,27 @@ public class QuickStatusBarHeader extends RelativeLayout implements
|
|||||||
return color == Color.WHITE ? 0 : 1;
|
return color == Color.WHITE ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMargins(int sideMargins) {
|
|
||||||
for (int i = 0; i < getChildCount(); i++) {
|
|
||||||
View v = getChildAt(i);
|
|
||||||
// Prevents these views from getting set a margin.
|
|
||||||
// The Icon views all have the same padding set in XML to be aligned.
|
|
||||||
if (v == mSystemIconsView || v == mQuickQsStatusIcons || v == mHeaderQsPanel
|
|
||||||
|| v == mHeaderTextContainerView) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) v.getLayoutParams();
|
|
||||||
lp.leftMargin = sideMargins;
|
|
||||||
lp.rightMargin = sideMargins;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public Lifecycle getLifecycle() {
|
public Lifecycle getLifecycle() {
|
||||||
return mLifecycle;
|
return mLifecycle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setContentMargins(int marginStart, int marginEnd) {
|
||||||
|
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
|
||||||
|
mHeaderQsPanel.setContentMargins(marginStart, marginEnd);
|
||||||
|
} else {
|
||||||
|
MarginLayoutParams lp = (MarginLayoutParams) view.getLayoutParams();
|
||||||
|
lp.setMarginStart(marginStart);
|
||||||
|
lp.setMarginEnd(marginEnd);
|
||||||
|
view.setLayoutParams(lp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
updateClockPadding();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -96,7 +96,6 @@ public class TileLayout extends ViewGroup implements QSTileLayout {
|
|||||||
mCellMarginHorizontal = res.getDimensionPixelSize(R.dimen.qs_tile_margin_horizontal);
|
mCellMarginHorizontal = res.getDimensionPixelSize(R.dimen.qs_tile_margin_horizontal);
|
||||||
mCellMarginVertical= res.getDimensionPixelSize(R.dimen.qs_tile_margin_vertical);
|
mCellMarginVertical= res.getDimensionPixelSize(R.dimen.qs_tile_margin_vertical);
|
||||||
mCellMarginTop = res.getDimensionPixelSize(R.dimen.qs_tile_margin_top);
|
mCellMarginTop = res.getDimensionPixelSize(R.dimen.qs_tile_margin_top);
|
||||||
mSidePadding = res.getDimensionPixelOffset(R.dimen.qs_tile_layout_margin_side);
|
|
||||||
mMaxAllowedRows = Math.max(1, getResources().getInteger(R.integer.quick_settings_max_rows));
|
mMaxAllowedRows = Math.max(1, getResources().getInteger(R.integer.quick_settings_max_rows));
|
||||||
if (mLessRows) mMaxAllowedRows = Math.max(1, mMaxAllowedRows - 1);
|
if (mLessRows) mMaxAllowedRows = Math.max(1, mMaxAllowedRows - 1);
|
||||||
if (mColumns != columns) {
|
if (mColumns != columns) {
|
||||||
@@ -120,7 +119,7 @@ public class TileLayout extends ViewGroup implements QSTileLayout {
|
|||||||
mRows = (numTiles + mColumns - 1) / mColumns;
|
mRows = (numTiles + mColumns - 1) / mColumns;
|
||||||
}
|
}
|
||||||
mCellWidth =
|
mCellWidth =
|
||||||
(availableWidth - mSidePadding * 2 - (mCellMarginHorizontal * mColumns)) / mColumns;
|
(availableWidth - (mCellMarginHorizontal * mColumns)) / mColumns;
|
||||||
|
|
||||||
// Measure each QS tile.
|
// Measure each QS tile.
|
||||||
View previousView = this;
|
View previousView = this;
|
||||||
@@ -204,7 +203,7 @@ public class TileLayout extends ViewGroup implements QSTileLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected int getColumnStart(int column) {
|
protected int getColumnStart(int column) {
|
||||||
return getPaddingStart() + mSidePadding + mCellMarginHorizontal / 2 +
|
return getPaddingStart() + mCellMarginHorizontal / 2 +
|
||||||
column * (mCellWidth + mCellMarginHorizontal);
|
column * (mCellWidth + mCellMarginHorizontal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user