Make status bar transparent when activity is paused (rotated)
Previously, when drawer is open, we make status bar transparent;
then if screen is rotated, status bar will be opaque again. This
CL addresses this issue by making it transparent again on resume.
Bug 28891044
Change-Id: I0379275a544c3eab616c07c789d8ec0bc0a26550
diff --git a/src/com/android/contacts/ContactsDrawerActivity.java b/src/com/android/contacts/ContactsDrawerActivity.java
index 466aa91..81c7252 100644
--- a/src/com/android/contacts/ContactsDrawerActivity.java
+++ b/src/com/android/contacts/ContactsDrawerActivity.java
@@ -108,10 +108,8 @@
public void onDrawerStateChanged(int newState) {
super.onDrawerStateChanged(newState);
// Set transparent status bar when drawer starts to move.
- if (CompatUtils.isLollipopCompatible() && newState != DrawerLayout.STATE_IDLE
- && getWindow().getStatusBarColor() == ContextCompat.getColor
- (ContactsDrawerActivity.this, R.color.primary_color_dark)) {
- getWindow().setStatusBarColor(Color.TRANSPARENT);
+ if (newState != DrawerLayout.STATE_IDLE) {
+ makeStatusBarTransparent();
}
if (mRunnable != null && newState == DrawerLayout.STATE_IDLE) {
mRunnable.run();
@@ -199,6 +197,22 @@
}
}
+ @Override
+ protected void onResume() {
+ super.onResume();
+ if (mDrawer.isDrawerOpen(GravityCompat.START)) {
+ makeStatusBarTransparent();
+ }
+ }
+
+ private void makeStatusBarTransparent() {
+ if (CompatUtils.isLollipopCompatible()
+ && getWindow().getStatusBarColor() ==
+ ContextCompat.getColor(this, R.color.primary_color_dark)) {
+ getWindow().setStatusBarColor(Color.TRANSPARENT);
+ }
+ }
+
/**
* Returns true if child class is DuplicatesActivity
*/