Skip to content

Commit

Permalink
[BottomSheet] Add back accidentally removed setLightStatusBar method …
Browse files Browse the repository at this point in the history
…and annotate it as deprecated

PiperOrigin-RevId: 450696352
  • Loading branch information
drchen authored and afohrman committed May 24, 2022
1 parent 66581f2 commit 53086a0
Showing 1 changed file with 21 additions and 3 deletions.
Expand Up @@ -19,13 +19,13 @@
import com.google.android.material.R;

import static com.google.android.material.color.MaterialColors.isColorLight;
import static com.google.android.material.internal.EdgeToEdgeUtils.setLightStatusBar;

import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Build;
import android.os.Build.VERSION;
import android.os.Build.VERSION_CODES;
import android.os.Bundle;
Expand All @@ -49,6 +49,7 @@
import androidx.core.view.WindowInsetsCompat;
import androidx.core.view.WindowInsetsControllerCompat;
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
import com.google.android.material.internal.EdgeToEdgeUtils;
import com.google.android.material.shape.MaterialShapeDrawable;

/**
Expand Down Expand Up @@ -484,7 +485,8 @@ private void setPaddingForPosition(View bottomSheet) {
// If the bottomsheet is light, we should set light status bar so the icons are visible
// since the bottomsheet is now under the status bar.
if (window != null) {
setLightStatusBar(window, lightBottomSheet == null ? lightStatusBar : lightBottomSheet);
EdgeToEdgeUtils.setLightStatusBar(
window, lightBottomSheet == null ? lightStatusBar : lightBottomSheet);
}
// Smooth transition into status bar when drawing edge to edge.
bottomSheet.setPadding(
Expand All @@ -496,7 +498,7 @@ private void setPaddingForPosition(View bottomSheet) {
// Reset the status bar icons to the original color because the bottomsheet is not under the
// status bar.
if (window != null) {
setLightStatusBar(window, lightStatusBar);
EdgeToEdgeUtils.setLightStatusBar(window, lightStatusBar);
}
bottomSheet.setPadding(
bottomSheet.getPaddingLeft(),
Expand All @@ -506,4 +508,20 @@ private void setPaddingForPosition(View bottomSheet) {
}
}
}

/**
* @deprecated use {@link EdgeToEdgeUtils#setLightStatusBar(Window, boolean)} instead
*/
@Deprecated
public static void setLightStatusBar(@NonNull View view, boolean isLight) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
int flags = view.getSystemUiVisibility();
if (isLight) {
flags |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
} else {
flags &= ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
}
view.setSystemUiVisibility(flags);
}
}
}

0 comments on commit 53086a0

Please sign in to comment.