| 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.Notification; | |
| 11 import android.app.PendingIntent; | 10 import android.app.PendingIntent; |
| 12 import android.content.ContentResolver; | 11 import android.content.ContentResolver; |
| 13 import android.content.Context; | 12 import android.content.Context; |
| 14 import android.content.Intent; | 13 import android.content.Intent; |
| 15 import android.content.pm.PackageManager; | 14 import android.content.pm.PackageManager; |
| 16 import android.content.res.ColorStateList; | 15 import android.content.res.ColorStateList; |
| 17 import android.content.res.Configuration; | 16 import android.content.res.Configuration; |
| 18 import android.content.res.Resources; | 17 import android.content.res.Resources; |
| 19 import android.content.res.Resources.NotFoundException; | 18 import android.content.res.Resources.NotFoundException; |
| 20 import android.graphics.Bitmap; | 19 import android.graphics.Bitmap; |
| 21 import android.graphics.Color; | 20 import android.graphics.Color; |
| 22 import android.graphics.ColorFilter; | 21 import android.graphics.ColorFilter; |
| 23 import android.graphics.Rect; | 22 import android.graphics.Rect; |
| 24 import android.graphics.drawable.Drawable; | 23 import android.graphics.drawable.Drawable; |
| 25 import android.net.Uri; | 24 import android.net.Uri; |
| 26 import android.os.Build; | 25 import android.os.Build; |
| 27 import android.os.PowerManager; | 26 import android.os.PowerManager; |
| 28 import android.os.Process; | 27 import android.os.Process; |
| 29 import android.os.StatFs; | 28 import android.os.StatFs; |
| 30 import android.os.UserManager; | 29 import android.os.UserManager; |
| 31 import android.provider.Settings; | 30 import android.provider.Settings; |
| 32 import android.view.View; | 31 import android.view.View; |
| 33 import android.view.ViewGroup.MarginLayoutParams; | 32 import android.view.ViewGroup.MarginLayoutParams; |
| 34 import android.view.Window; | 33 import android.view.Window; |
| 35 import android.view.WindowManager; | 34 import android.view.WindowManager; |
| 36 import android.view.inputmethod.InputMethodSubtype; | 35 import android.view.inputmethod.InputMethodSubtype; |
| 37 import android.widget.RemoteViews; | |
| 38 import android.widget.TextView; | 36 import android.widget.TextView; |
| 39 | 37 |
| 40 import java.io.File; | 38 import java.io.File; |
| 41 import java.lang.reflect.Method; | 39 import java.lang.reflect.Method; |
| 42 | 40 |
| 43 /** | 41 /** |
| 44 * Utility class to use new APIs that were added after ICS (API level 14). | 42 * Utility class to use new APIs that were added after ICS (API level 14). |
| 45 */ | 43 */ |
| 46 @TargetApi(Build.VERSION_CODES.LOLLIPOP) | 44 @TargetApi(Build.VERSION_CODES.LOLLIPOP) |
| 47 public class ApiCompatibilityUtils { | 45 public class ApiCompatibilityUtils { |
| (...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 595 return context.checkPermission(permission, pid, uid); | 593 return context.checkPermission(permission, pid, uid); |
| 596 } catch (RuntimeException e) { | 594 } catch (RuntimeException e) { |
| 597 // Some older versions of Android throw odd errors when checking for
permissions, so | 595 // Some older versions of Android throw odd errors when checking for
permissions, so |
| 598 // just swallow the exception and treat it as the permission is deni
ed. | 596 // just swallow the exception and treat it as the permission is deni
ed. |
| 599 // crbug.com/639099 | 597 // crbug.com/639099 |
| 600 return PackageManager.PERMISSION_DENIED; | 598 return PackageManager.PERMISSION_DENIED; |
| 601 } | 599 } |
| 602 } | 600 } |
| 603 | 601 |
| 604 /** | 602 /** |
| 605 * @see android.app.Notification.Builder#setContent(RemoteViews) | |
| 606 */ | |
| 607 @SuppressWarnings("deprecation") | |
| 608 public static void setContentViewForNotificationBuilder( | |
| 609 Notification.Builder builder, RemoteViews views) { | |
| 610 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { | |
| 611 builder.setCustomContentView(views); | |
| 612 } else { | |
| 613 builder.setContent(views); | |
| 614 } | |
| 615 } | |
| 616 | |
| 617 /** | |
| 618 * @see android.app.Notification#bigContentView | |
| 619 */ | |
| 620 @SuppressWarnings("deprecation") | |
| 621 public static Notification notificationWithBigContentView( | |
| 622 Notification.Builder builder, RemoteViews view) { | |
| 623 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { | |
| 624 return builder.setCustomBigContentView(view).build(); | |
| 625 } else { | |
| 626 Notification notification = builder.build(); | |
| 627 notification.bigContentView = view; | |
| 628 return notification; | |
| 629 } | |
| 630 } | |
| 631 | |
| 632 /** | |
| 633 * @see android.view.inputmethod.InputMethodSubType#getLocate() | 603 * @see android.view.inputmethod.InputMethodSubType#getLocate() |
| 634 */ | 604 */ |
| 635 @SuppressWarnings("deprecation") | 605 @SuppressWarnings("deprecation") |
| 636 public static String getLocale(InputMethodSubtype inputMethodSubType) { | 606 public static String getLocale(InputMethodSubtype inputMethodSubType) { |
| 637 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { | 607 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { |
| 638 return inputMethodSubType.getLanguageTag(); | 608 return inputMethodSubType.getLanguageTag(); |
| 639 } else { | 609 } else { |
| 640 return inputMethodSubType.getLocale(); | 610 return inputMethodSubType.getLocale(); |
| 641 } | 611 } |
| 642 } | 612 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 663 @SuppressWarnings("deprecation") | 633 @SuppressWarnings("deprecation") |
| 664 int featureNumber = Window.FEATURE_INDETERMINATE_PROGRESS; | 634 int featureNumber = Window.FEATURE_INDETERMINATE_PROGRESS; |
| 665 | 635 |
| 666 @SuppressWarnings("deprecation") | 636 @SuppressWarnings("deprecation") |
| 667 int featureValue = Window.PROGRESS_VISIBILITY_OFF; | 637 int featureValue = Window.PROGRESS_VISIBILITY_OFF; |
| 668 | 638 |
| 669 window.setFeatureInt(featureNumber, featureValue); | 639 window.setFeatureInt(featureNumber, featureValue); |
| 670 } | 640 } |
| 671 } | 641 } |
| 672 } | 642 } |
| OLD | NEW |