Merge "Hide icons in QS Header if there's a cutout" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
378fafcd3b
@@ -28,7 +28,7 @@
|
||||
|
||||
<com.android.systemui.statusbar.policy.Clock
|
||||
android:id="@+id/clock"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:minWidth="48dp"
|
||||
android:minHeight="48dp"
|
||||
@@ -49,17 +49,35 @@
|
||||
android:layout_gravity="end|center_vertical"
|
||||
android:focusable="false"/>
|
||||
|
||||
<com.android.systemui.statusbar.phone.StatusIconContainer
|
||||
android:id="@+id/statusIcons"
|
||||
android:layout_width="wrap_content"
|
||||
<View
|
||||
android:id="@+id/separator"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingEnd="@dimen/signal_cluster_battery_padding" />
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:visibility="gone"
|
||||
/>
|
||||
|
||||
<com.android.systemui.BatteryMeterView
|
||||
android:id="@+id/batteryRemainingIcon"
|
||||
<LinearLayout
|
||||
android:id="@+id/rightLayout"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_width="wrap_content"
|
||||
systemui:textAppearance="@style/TextAppearance.QS.Status"
|
||||
android:paddingEnd="2dp" />
|
||||
android:layout_weight="1"
|
||||
>
|
||||
<com.android.systemui.statusbar.phone.StatusIconContainer
|
||||
android:id="@+id/statusIcons"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingEnd="@dimen/signal_cluster_battery_padding" />
|
||||
|
||||
<com.android.systemui.BatteryMeterView
|
||||
android:id="@+id/batteryRemainingIcon"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
systemui:textAppearance="@style/TextAppearance.QS.Status"
|
||||
android:paddingEnd="2dp" />
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
@@ -38,7 +38,6 @@ import com.android.systemui.BatteryMeterView;
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.animation.Interpolators;
|
||||
import com.android.systemui.qs.QSDetail.Callback;
|
||||
import com.android.systemui.statusbar.StatusBarIconView;
|
||||
import com.android.systemui.statusbar.phone.StatusBarIconController.TintedIconManager;
|
||||
import com.android.systemui.statusbar.phone.StatusBarWindowView;
|
||||
import com.android.systemui.statusbar.phone.StatusIconContainer;
|
||||
@@ -67,7 +66,11 @@ public class QuickStatusBarHeader extends FrameLayout {
|
||||
|
||||
private View mQSCarriers;
|
||||
private Clock mClockView;
|
||||
private Space mSpace;
|
||||
private Space mDatePrivacySeparator;
|
||||
private View mClockIconsSeparator;
|
||||
private boolean mShowClockIconsSeparator;
|
||||
private ViewGroup mRightLayout;
|
||||
|
||||
private BatteryMeterView mBatteryRemainingIcon;
|
||||
private StatusIconContainer mIconContainer;
|
||||
private View mPrivacyChip;
|
||||
@@ -117,9 +120,11 @@ public class QuickStatusBarHeader extends FrameLayout {
|
||||
mPrivacyChip = findViewById(R.id.privacy_chip);
|
||||
mDateView = findViewById(R.id.date);
|
||||
mSecurityHeaderView = findViewById(R.id.header_text_container);
|
||||
mClockIconsSeparator = findViewById(R.id.separator);
|
||||
mRightLayout = findViewById(R.id.rightLayout);
|
||||
|
||||
mClockView = findViewById(R.id.clock);
|
||||
mSpace = findViewById(R.id.space);
|
||||
mDatePrivacySeparator = findViewById(R.id.space);
|
||||
// Tint for the battery icons are handled in setupHost()
|
||||
mBatteryRemainingIcon = findViewById(R.id.batteryRemainingIcon);
|
||||
|
||||
@@ -230,36 +235,36 @@ public class QuickStatusBarHeader extends FrameLayout {
|
||||
}
|
||||
|
||||
private void updateAlphaAnimator() {
|
||||
StatusBarIconView noCallingIcon =
|
||||
((StatusBarIconView) mIconContainer.getViewForSlot(mMobileSlotName));
|
||||
StatusBarIconView callStrengthIcon =
|
||||
((StatusBarIconView) mIconContainer.getViewForSlot(mCallStrengthSlotName));
|
||||
TouchAnimator.Builder builder = new TouchAnimator.Builder()
|
||||
// The following two views have to be hidden manually, so as not to hide the
|
||||
// Privacy chip in QQS
|
||||
.addFloat(mDateView, "alpha", 0, 1)
|
||||
.addFloat(mSecurityHeaderView, "alpha", 0, 1)
|
||||
.addFloat(mQSCarriers, "alpha", 0, 1);
|
||||
builder.setListener(new TouchAnimator.ListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationAtEnd() {
|
||||
mIconContainer.addIgnoredSlot(mMobileSlotName);
|
||||
mIconContainer.addIgnoredSlot(mCallStrengthSlotName);
|
||||
}
|
||||
.addFloat(mQSCarriers, "alpha", 0, 1)
|
||||
.setListener(new TouchAnimator.ListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationAtEnd() {
|
||||
mIconContainer.addIgnoredSlot(mMobileSlotName);
|
||||
mIconContainer.addIgnoredSlot(mCallStrengthSlotName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationStarted() {
|
||||
mIconContainer.addIgnoredSlot(mMobileSlotName);
|
||||
mIconContainer.addIgnoredSlot(mCallStrengthSlotName);
|
||||
}
|
||||
@Override
|
||||
public void onAnimationStarted() {
|
||||
mIconContainer.addIgnoredSlot(mMobileSlotName);
|
||||
mIconContainer.addIgnoredSlot(mCallStrengthSlotName);
|
||||
|
||||
@Override
|
||||
public void onAnimationAtStart() {
|
||||
super.onAnimationAtStart();
|
||||
mIconContainer.removeIgnoredSlot(mMobileSlotName);
|
||||
mIconContainer.removeIgnoredSlot(mCallStrengthSlotName);
|
||||
}
|
||||
});
|
||||
setSeparatorVisibility(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationAtStart() {
|
||||
super.onAnimationAtStart();
|
||||
mIconContainer.removeIgnoredSlot(mMobileSlotName);
|
||||
mIconContainer.removeIgnoredSlot(mCallStrengthSlotName);
|
||||
|
||||
setSeparatorVisibility(mShowClockIconsSeparator);
|
||||
}
|
||||
});
|
||||
mAlphaAnimator = builder.build();
|
||||
}
|
||||
|
||||
@@ -337,20 +342,30 @@ public class QuickStatusBarHeader extends FrameLayout {
|
||||
cutout, cornerCutoutPadding, -1);
|
||||
mDatePrivacyView.setPadding(padding.first, 0, padding.second, 0);
|
||||
mClockIconsView.setPadding(padding.first, 0, padding.second, 0);
|
||||
LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) mSpace.getLayoutParams();
|
||||
LinearLayout.LayoutParams datePrivacySeparatorLayoutParams =
|
||||
(LinearLayout.LayoutParams) mDatePrivacySeparator.getLayoutParams();
|
||||
LinearLayout.LayoutParams mClockIconsSeparatorLayoutParams =
|
||||
(LinearLayout.LayoutParams) mClockIconsSeparator.getLayoutParams();
|
||||
boolean cornerCutout = cornerCutoutPadding != null
|
||||
&& (cornerCutoutPadding.first == 0 || cornerCutoutPadding.second == 0);
|
||||
if (cutout != null) {
|
||||
Rect topCutout = cutout.getBoundingRectTop();
|
||||
if (topCutout.isEmpty() || cornerCutout) {
|
||||
lp.width = 0;
|
||||
mSpace.setVisibility(View.GONE);
|
||||
datePrivacySeparatorLayoutParams.width = 0;
|
||||
mDatePrivacySeparator.setVisibility(View.GONE);
|
||||
mClockIconsSeparatorLayoutParams.width = 0;
|
||||
setSeparatorVisibility(false);
|
||||
mShowClockIconsSeparator = false;
|
||||
} else {
|
||||
lp.width = topCutout.width();
|
||||
mSpace.setVisibility(View.VISIBLE);
|
||||
datePrivacySeparatorLayoutParams.width = topCutout.width();
|
||||
mDatePrivacySeparator.setVisibility(View.VISIBLE);
|
||||
mClockIconsSeparatorLayoutParams.width = topCutout.width();
|
||||
mShowClockIconsSeparator = true;
|
||||
setSeparatorVisibility(mKeyguardExpansionFraction == 0f);
|
||||
}
|
||||
}
|
||||
mSpace.setLayoutParams(lp);
|
||||
mDatePrivacySeparator.setLayoutParams(datePrivacySeparatorLayoutParams);
|
||||
mClockIconsSeparator.setLayoutParams(mClockIconsSeparatorLayoutParams);
|
||||
mCutOutPaddingLeft = padding.first;
|
||||
mCutOutPaddingRight = padding.second;
|
||||
mWaterfallTopInset = cutout == null ? 0 : cutout.getWaterfallInsets().top;
|
||||
@@ -358,6 +373,32 @@ public class QuickStatusBarHeader extends FrameLayout {
|
||||
return super.onApplyWindowInsets(insets);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the visibility of the separator between clock and icons.
|
||||
*
|
||||
* This separator is "visible" when there is a center cutout, to block that space. In that
|
||||
* case, the clock and the layout on the right (containing the icons and the battery meter) are
|
||||
* set to weight 1 to take the available space.
|
||||
* @param visible whether the separator between clock and icons should be visible.
|
||||
*/
|
||||
private void setSeparatorVisibility(boolean visible) {
|
||||
int newVisibility = visible ? View.VISIBLE : View.GONE;
|
||||
if (mClockIconsSeparator.getVisibility() == newVisibility) return;
|
||||
|
||||
mClockIconsSeparator.setVisibility(visible ? View.VISIBLE : View.GONE);
|
||||
mQSCarriers.setVisibility(visible ? View.GONE : View.VISIBLE);
|
||||
|
||||
LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) mClockView.getLayoutParams();
|
||||
lp.width = visible ? 0 : WRAP_CONTENT;
|
||||
lp.weight = visible ? 1f : 0f;
|
||||
mClockView.setLayoutParams(lp);
|
||||
|
||||
lp = (LinearLayout.LayoutParams) mRightLayout.getLayoutParams();
|
||||
lp.width = visible ? 0 : WRAP_CONTENT;
|
||||
lp.weight = visible ? 1f : 0f;
|
||||
mRightLayout.setLayoutParams(lp);
|
||||
}
|
||||
|
||||
private void updateHeadersPadding() {
|
||||
setContentMargins(mDatePrivacyView, 0, 0);
|
||||
setContentMargins(mClockIconsView, 0, 0);
|
||||
|
||||
Reference in New Issue
Block a user