Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(546)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/widget/bottomsheet/BottomSheet.java

Issue 2809003006: 🏠 Fix coloring issues in status bar (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/ChromeTabbedActivity.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/widget/bottomsheet/BottomSheet.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/widget/bottomsheet/BottomSheet.java b/chrome/android/java/src/org/chromium/chrome/browser/widget/bottomsheet/BottomSheet.java
index 45ffb7fa91b240010d40e84748bd6d04fc740019..0004325e90f6e4ae787c9203273cb3fd8539629f 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/widget/bottomsheet/BottomSheet.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/widget/bottomsheet/BottomSheet.java
@@ -9,7 +9,9 @@ import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.content.Context;
+import android.graphics.Color;
import android.graphics.Region;
+import android.os.Build;
import android.support.annotation.IntDef;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
@@ -17,6 +19,7 @@ import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.VelocityTracker;
import android.view.View;
+import android.view.Window;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.Interpolator;
import android.widget.FrameLayout;
@@ -29,6 +32,7 @@ import org.chromium.chrome.browser.NativePageHost;
import org.chromium.chrome.browser.TabLoadStatus;
import org.chromium.chrome.browser.fullscreen.ChromeFullscreenManager;
import org.chromium.chrome.browser.ntp.NativePageFactory;
+import org.chromium.chrome.browser.ntp.NewTabPage;
import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.tabmodel.TabModel;
import org.chromium.chrome.browser.tabmodel.TabModelSelector;
@@ -402,6 +406,32 @@ public class BottomSheet
}
/**
+ * Set the window's status bar color. On Android M and above, this will set the status bar color
+ * to the default theme color with dark icons except in the case of the tab switcher and
+ * incognito NTP. On Android versions < M, the status bar will always be black.
+ * @param window The Android window.
+ */
+ public void setStatusBarColor(Window window) {
+ Tab tab = getActiveTab();
+ boolean isInOverviewMode = tab != null && tab.getActivity().isInOverviewMode();
+ boolean isIncognitoNtp =
+ tab != null && NewTabPage.isNTPUrl(tab.getUrl()) && tab.isIncognito();
+ boolean isValidAndroidVersion = Build.VERSION.SDK_INT >= Build.VERSION_CODES.M;
+
+ int color = ApiCompatibilityUtils.getColor(getResources(), R.color.default_primary_color);
+ setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
+
+ // Special case the incognito NTP and the tab switcher.
+ if (!isValidAndroidVersion || isIncognitoNtp || isInOverviewMode) {
+ color = Color.BLACK;
+ // The light status bar flag is always set above, meaning XORing that value with the
+ // current flags will remove it.
+ setSystemUiVisibility(getSystemUiVisibility() ^ View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
+ }
+ ApiCompatibilityUtils.setStatusBarColor(window, color);
+ }
+
+ /**
* @return Whether or not the toolbar Android View is hidden due to being scrolled off-screen.
*/
private boolean isToolbarAndroidViewHidden() {
@@ -508,7 +538,7 @@ public class BottomSheet
@Override
public Tab getActiveTab() {
- return mTabModelSelector.getCurrentTab();
+ return mTabModelSelector == null ? null : mTabModelSelector.getCurrentTab();
}
@Override
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/ChromeTabbedActivity.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698