зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1403653 - Part 2 - Split out conversion from ColorRes to ColorInt into separate function. r=nechen
MozReview-Commit-ID: 8tDBT7kR9XF --HG-- extra : rebase_source : aba767491182f5066d3cc3988c822366f40ec145
This commit is contained in:
Родитель
45de111d36
Коммит
9088ecc81a
|
@ -7,6 +7,7 @@ package org.mozilla.gecko.util;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
|
import android.support.annotation.ColorInt;
|
||||||
import android.support.annotation.ColorRes;
|
import android.support.annotation.ColorRes;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -20,7 +21,7 @@ public class WindowUtil {
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setStatusBarColor(activity, R.color.status_bar_bg_color_tabs_tray, true);
|
setStatusBarColorRes(activity, R.color.status_bar_bg_color_tabs_tray, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setStatusBarColor(final Activity activity, final boolean isPrivate) {
|
public static void setStatusBarColor(final Activity activity, final boolean isPrivate) {
|
||||||
|
@ -28,7 +29,7 @@ public class WindowUtil {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final int colorResId;
|
final @ColorRes int colorResId;
|
||||||
final boolean isDarkTheme;
|
final boolean isDarkTheme;
|
||||||
|
|
||||||
if (HardwareUtils.isTablet()) {
|
if (HardwareUtils.isTablet()) {
|
||||||
|
@ -38,17 +39,22 @@ public class WindowUtil {
|
||||||
colorResId = isPrivate ? R.color.status_bar_bg_color_private : R.color.status_bar_bg_color;
|
colorResId = isPrivate ? R.color.status_bar_bg_color_private : R.color.status_bar_bg_color;
|
||||||
isDarkTheme = isPrivate;
|
isDarkTheme = isPrivate;
|
||||||
}
|
}
|
||||||
setStatusBarColor(activity, colorResId, isDarkTheme);
|
setStatusBarColorRes(activity, colorResId, isDarkTheme);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setStatusBarColor(final Activity activity, @ColorRes final int colorResId,
|
public static void setStatusBarColorRes(final Activity activity, final @ColorRes int colorResId,
|
||||||
|
final boolean isDarkTheme) {
|
||||||
|
final int backgroundColor = ContextCompat.getColor(activity, colorResId);
|
||||||
|
setStatusBarColor(activity, backgroundColor, isDarkTheme);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setStatusBarColor(final Activity activity, final @ColorInt int backgroundColor,
|
||||||
final boolean isDarkTheme) {
|
final boolean isDarkTheme) {
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Window window = activity.getWindow();
|
final Window window = activity.getWindow();
|
||||||
final int backgroundColor = ContextCompat.getColor(activity, colorResId);
|
|
||||||
window.setStatusBarColor(backgroundColor);
|
window.setStatusBarColor(backgroundColor);
|
||||||
|
|
||||||
final View view = window.getDecorView();
|
final View view = window.getDecorView();
|
||||||
|
|
Загрузка…
Ссылка в новой задаче