Bug 1403653 - Part 2 - Split out conversion from ColorRes to ColorInt into separate function. r=nechen

MozReview-Commit-ID: 8tDBT7kR9XF

--HG--
extra : rebase_source : 86449f2f0b3085e1a4961161a609b8a5f7c130f3
This commit is contained in:
Jan Henning 2017-09-27 21:27:28 +02:00
Родитель 3fe1971e3f
Коммит 72f7dc1f64
1 изменённых файлов: 11 добавлений и 5 удалений

Просмотреть файл

@ -7,6 +7,7 @@ package org.mozilla.gecko.util;
import android.app.Activity;
import android.os.Build;
import android.support.annotation.ColorInt;
import android.support.annotation.ColorRes;
import android.support.v4.content.ContextCompat;
import android.view.View;
@ -20,7 +21,7 @@ public class WindowUtil {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
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) {
@ -28,7 +29,7 @@ public class WindowUtil {
return;
}
final int colorResId;
final @ColorRes int colorResId;
final boolean isDarkTheme;
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;
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) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
return;
}
final Window window = activity.getWindow();
final int backgroundColor = ContextCompat.getColor(activity, colorResId);
window.setStatusBarColor(backgroundColor);
final View view = window.getDecorView();