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; |
11 import android.content.ContentResolver; | 11 import android.content.ContentResolver; |
12 import android.content.Context; | 12 import android.content.Context; |
13 import android.content.Intent; | 13 import android.content.Intent; |
14 import android.content.pm.PackageManager; | 14 import android.content.pm.PackageManager; |
15 import android.content.res.ColorStateList; | 15 import android.content.res.ColorStateList; |
16 import android.content.res.Configuration; | 16 import android.content.res.Configuration; |
17 import android.content.res.Resources; | 17 import android.content.res.Resources; |
18 import android.content.res.Resources.NotFoundException; | 18 import android.content.res.Resources.NotFoundException; |
19 import android.graphics.Bitmap; | 19 import android.graphics.Bitmap; |
20 import android.graphics.Color; | 20 import android.graphics.Color; |
21 import android.graphics.ColorFilter; | 21 import android.graphics.ColorFilter; |
22 import android.graphics.Rect; | 22 import android.graphics.Rect; |
23 import android.graphics.drawable.Drawable; | 23 import android.graphics.drawable.Drawable; |
24 import android.net.Uri; | 24 import android.net.Uri; |
25 import android.os.Build; | 25 import android.os.Build; |
26 import android.os.PowerManager; | 26 import android.os.PowerManager; |
27 import android.os.Process; | 27 import android.os.Process; |
28 import android.os.StatFs; | 28 import android.os.StatFs; |
| 29 import android.os.StrictMode; |
29 import android.os.UserManager; | 30 import android.os.UserManager; |
30 import android.provider.Settings; | 31 import android.provider.Settings; |
31 import android.text.Html; | 32 import android.text.Html; |
32 import android.text.Spanned; | 33 import android.text.Spanned; |
33 import android.view.View; | 34 import android.view.View; |
34 import android.view.ViewGroup.MarginLayoutParams; | 35 import android.view.ViewGroup.MarginLayoutParams; |
35 import android.view.Window; | 36 import android.view.Window; |
36 import android.view.WindowManager; | 37 import android.view.WindowManager; |
37 import android.view.inputmethod.InputMethodSubtype; | 38 import android.view.inputmethod.InputMethodSubtype; |
38 import android.widget.TextView; | 39 import android.widget.TextView; |
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BAC
KGROUNDS); | 440 window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BAC
KGROUNDS); |
440 } | 441 } |
441 window.setStatusBarColor(statusBarColor); | 442 window.setStatusBarColor(statusBarColor); |
442 } | 443 } |
443 | 444 |
444 /** | 445 /** |
445 * @see android.content.res.Resources#getDrawable(int id). | 446 * @see android.content.res.Resources#getDrawable(int id). |
446 */ | 447 */ |
447 @SuppressWarnings("deprecation") | 448 @SuppressWarnings("deprecation") |
448 public static Drawable getDrawable(Resources res, int id) throws NotFoundExc
eption { | 449 public static Drawable getDrawable(Resources res, int id) throws NotFoundExc
eption { |
449 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { | 450 StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads(); |
450 return res.getDrawable(id, null); | 451 try { |
451 } else { | 452 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { |
452 return res.getDrawable(id); | 453 return res.getDrawable(id, null); |
| 454 } else { |
| 455 return res.getDrawable(id); |
| 456 } |
| 457 } finally { |
| 458 StrictMode.setThreadPolicy(oldPolicy); |
453 } | 459 } |
454 } | 460 } |
455 | 461 |
456 /** | 462 /** |
457 * @see android.content.res.Resources#getDrawableForDensity(int id, int dens
ity). | 463 * @see android.content.res.Resources#getDrawableForDensity(int id, int dens
ity). |
458 */ | 464 */ |
459 @SuppressWarnings("deprecation") | 465 @SuppressWarnings("deprecation") |
460 public static Drawable getDrawableForDensity(Resources res, int id, int dens
ity) { | 466 public static Drawable getDrawableForDensity(Resources res, int id, int dens
ity) { |
461 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { | 467 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { |
462 return res.getDrawableForDensity(id, density, null); | 468 return res.getDrawableForDensity(id, density, null); |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
667 | 673 |
668 /** | 674 /** |
669 * Null-safe equivalent of {@code a.equals(b)}. | 675 * Null-safe equivalent of {@code a.equals(b)}. |
670 * | 676 * |
671 * @see Objects#equals(Object, Object) | 677 * @see Objects#equals(Object, Object) |
672 */ | 678 */ |
673 public static boolean objectEquals(Object a, Object b) { | 679 public static boolean objectEquals(Object a, Object b) { |
674 return (a == null) ? (b == null) : a.equals(b); | 680 return (a == null) ? (b == null) : a.equals(b); |
675 } | 681 } |
676 } | 682 } |
OLD | NEW |