Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3241)

Unified Diff: base/android/java/src/org/chromium/base/ApiCompatibilityUtils.java

Issue 2632103002: (Android) Replacing deprecated API with current (Closed)
Patch Set: Indentation fix after previous patch set Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/ChromeTabbedActivity.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/android/java/src/org/chromium/base/ApiCompatibilityUtils.java
diff --git a/base/android/java/src/org/chromium/base/ApiCompatibilityUtils.java b/base/android/java/src/org/chromium/base/ApiCompatibilityUtils.java
index 3d8ef6f6e593a5cd890b692137935e8ae451beda..b4b1c02364cf86e494bc702290d2f78fac0debdd 100644
--- a/base/android/java/src/org/chromium/base/ApiCompatibilityUtils.java
+++ b/base/android/java/src/org/chromium/base/ApiCompatibilityUtils.java
@@ -7,6 +7,7 @@ package org.chromium.base;
import android.annotation.TargetApi;
import android.app.Activity;
import android.app.ActivityManager;
+import android.app.Notification;
import android.app.PendingIntent;
import android.content.ContentResolver;
import android.content.Context;
@@ -21,6 +22,7 @@ import android.graphics.Color;
import android.graphics.ColorFilter;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
+import android.net.Uri;
import android.os.Build;
import android.os.PowerManager;
import android.os.Process;
@@ -31,8 +33,11 @@ import android.view.View;
import android.view.ViewGroup.MarginLayoutParams;
import android.view.Window;
import android.view.WindowManager;
+import android.view.inputmethod.InputMethodSubtype;
+import android.widget.RemoteViews;
import android.widget.TextView;
+import java.io.File;
import java.lang.reflect.Method;
/**
@@ -601,4 +606,73 @@ public class ApiCompatibilityUtils {
return PackageManager.PERMISSION_DENIED;
}
}
+
+ /**
+ * @see android.app.Notification.Builder#setContent(RemoteViews)
+ */
+ @SuppressWarnings("deprecation")
+ public static void setContentViewForNotificationBuilder(
+ Notification.Builder builder, RemoteViews views) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
+ builder.setCustomContentView(views);
+ } else {
+ builder.setContent(views);
+ }
+ }
+
+ /**
+ * @see android.app.Notification#bigContentView
+ */
+ @SuppressWarnings("deprecation")
+ public static Notification notificationWithBigContentView(
+ Notification.Builder builder, RemoteViews view) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
+ return builder.setCustomBigContentView(view).build();
+ } else {
+ Notification notification = builder.build();
+ notification.bigContentView = view;
+ return notification;
+ }
+ }
+
+ /**
+ * @see android.view.inputmethod.InputMethodSubType#getLocate()
+ */
+ @SuppressWarnings("deprecation")
+ public static String getLocale(InputMethodSubtype inputMethodSubType) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
+ return inputMethodSubType.getLanguageTag();
+ } else {
+ return inputMethodSubType.getLocale();
+ }
+ }
+
+ /**
+ * Get a URI for |file| which has the image capture. This function assumes that path of |file|
+ * is based on the result of UiUtils.getDirectoryForImageCapture().
+ *
+ * @param context The application context.
+ * @param file image capture file.
+ * @return URI for |file|.
+ */
+ public static Uri getUriForImageCaptureFile(Context context, File file) {
+ return Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2
+ ? ContentUriUtils.getContentUriFromFile(context, file)
+ : Uri.fromFile(file);
+ }
+
+ /**
+ * @see android.view.Window#FEATURE_INDETERMINATE_PROGRESS
+ */
+ public static void setWindowIndeterminateProgress(Window window) {
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
+ @SuppressWarnings("deprecation")
+ int featureNumber = Window.FEATURE_INDETERMINATE_PROGRESS;
+
+ @SuppressWarnings("deprecation")
+ int featureValue = Window.PROGRESS_VISIBILITY_OFF;
+
+ window.setFeatureInt(featureNumber, featureValue);
+ }
+ }
}
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/ChromeTabbedActivity.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698