OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.base; | 5 package org.chromium.base; |
6 | 6 |
7 import android.annotation.TargetApi; | 7 import android.annotation.TargetApi; |
8 import android.app.Activity; | 8 import android.app.Activity; |
9 import android.app.ActivityManager; | 9 import android.app.ActivityManager; |
10 import android.app.PendingIntent; | 10 import android.app.PendingIntent; |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 public static void setTaskDescription(Activity activity, String title, Bitma
p icon, int color) { | 342 public static void setTaskDescription(Activity activity, String title, Bitma
p icon, int color) { |
343 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { | 343 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { |
344 ActivityManager.TaskDescription description = | 344 ActivityManager.TaskDescription description = |
345 new ActivityManager.TaskDescription(title, icon, color); | 345 new ActivityManager.TaskDescription(title, icon, color); |
346 activity.setTaskDescription(description); | 346 activity.setTaskDescription(description); |
347 } | 347 } |
348 } | 348 } |
349 | 349 |
350 /** | 350 /** |
351 * @see android.view.Window#setStatusBarColor(int color). | 351 * @see android.view.Window#setStatusBarColor(int color). |
| 352 * TODO(ianwen): remove this method after downstream rolling. |
352 */ | 353 */ |
353 public static void setStatusBarColor(Activity activity, int statusBarColor)
{ | 354 public static void setStatusBarColor(Activity activity, int statusBarColor)
{ |
354 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { | 355 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { |
355 // If both system bars are black, we can remove these from our layou
t, | 356 // If both system bars are black, we can remove these from our layou
t, |
356 // removing or shrinking the SurfaceFlinger overlay required for our
views. | 357 // removing or shrinking the SurfaceFlinger overlay required for our
views. |
357 Window window = activity.getWindow(); | 358 Window window = activity.getWindow(); |
358 if (statusBarColor == Color.BLACK && window.getNavigationBarColor()
== Color.BLACK) { | 359 if (statusBarColor == Color.BLACK && window.getNavigationBarColor()
== Color.BLACK) { |
359 window.clearFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_B
AR_BACKGROUNDS); | 360 window.clearFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_B
AR_BACKGROUNDS); |
360 } else { | 361 } else { |
361 window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR
_BACKGROUNDS); | 362 window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR
_BACKGROUNDS); |
362 } | 363 } |
363 window.setStatusBarColor(statusBarColor); | 364 window.setStatusBarColor(statusBarColor); |
364 } | 365 } |
365 } | 366 } |
366 | 367 |
367 /** | 368 /** |
| 369 * @see android.view.Window#setStatusBarColor(int color). |
| 370 */ |
| 371 public static void setStatusBarColor(Window window, int statusBarColor) { |
| 372 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { |
| 373 // If both system bars are black, we can remove these from our layou
t, |
| 374 // removing or shrinking the SurfaceFlinger overlay required for our
views. |
| 375 if (statusBarColor == Color.BLACK && window.getNavigationBarColor()
== Color.BLACK) { |
| 376 window.clearFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_B
AR_BACKGROUNDS); |
| 377 } else { |
| 378 window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR
_BACKGROUNDS); |
| 379 } |
| 380 window.setStatusBarColor(statusBarColor); |
| 381 } |
| 382 } |
| 383 |
| 384 /** |
368 * @see android.content.res.Resources#getDrawable(int id). | 385 * @see android.content.res.Resources#getDrawable(int id). |
369 */ | 386 */ |
370 @SuppressWarnings("deprecation") | 387 @SuppressWarnings("deprecation") |
371 public static Drawable getDrawable(Resources res, int id) throws NotFoundExc
eption { | 388 public static Drawable getDrawable(Resources res, int id) throws NotFoundExc
eption { |
372 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { | 389 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { |
373 return res.getDrawable(id, null); | 390 return res.getDrawable(id, null); |
374 } else { | 391 } else { |
375 return res.getDrawable(id); | 392 return res.getDrawable(id); |
376 } | 393 } |
377 } | 394 } |
378 | 395 |
379 /** | 396 /** |
380 * @see android.content.res.Resources#getDrawableForDensity(int id, int dens
ity). | 397 * @see android.content.res.Resources#getDrawableForDensity(int id, int dens
ity). |
381 */ | 398 */ |
382 @SuppressWarnings("deprecation") | 399 @SuppressWarnings("deprecation") |
383 public static Drawable getDrawableForDensity(Resources res, int id, int dens
ity) { | 400 public static Drawable getDrawableForDensity(Resources res, int id, int dens
ity) { |
384 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { | 401 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { |
385 return res.getDrawableForDensity(id, density, null); | 402 return res.getDrawableForDensity(id, density, null); |
386 } else { | 403 } else { |
387 return res.getDrawableForDensity(id, density); | 404 return res.getDrawableForDensity(id, density); |
388 } | 405 } |
389 } | 406 } |
390 } | 407 } |
OLD | NEW |