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

Unified Diff: ui/android/java/src/org/chromium/ui/base/Clipboard.java

Issue 973403002: Address NewApi warnings in src/ui. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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
Index: ui/android/java/src/org/chromium/ui/base/Clipboard.java
diff --git a/ui/android/java/src/org/chromium/ui/base/Clipboard.java b/ui/android/java/src/org/chromium/ui/base/Clipboard.java
index aaa500ea6dec0a58c941f9e461844608253c7c66..8abde25f86c27a2af2669f662463f12d287570b6 100644
--- a/ui/android/java/src/org/chromium/ui/base/Clipboard.java
+++ b/ui/android/java/src/org/chromium/ui/base/Clipboard.java
@@ -4,12 +4,13 @@
package org.chromium.ui.base;
+import android.annotation.TargetApi;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
+import android.os.Build;
import android.widget.Toast;
-import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.CalledByNative;
import org.chromium.base.JNINamespace;
import org.chromium.ui.R;
@@ -20,6 +21,10 @@ import org.chromium.ui.R;
*/
@JNINamespace("ui")
public class Clipboard {
+
+ private static final boolean IS_HTML_CLIPBOARD_SUPPORTED =
+ Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN;
+
// Necessary for coercing clipboard contents to text if they require
// access to network resources, etceteras (e.g., URI in clipboard)
private final Context mContext;
@@ -84,8 +89,9 @@ public class Clipboard {
* text or no entries on the primary clip.
*/
@CalledByNative
+ @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private String getHTMLText() {
- if (isHTMLClipboardSupported()) {
+ if (IS_HTML_CLIPBOARD_SUPPORTED) {
final ClipData clip = mClipboardManager.getPrimaryClip();
if (clip != null && clip.getItemCount() > 0) {
return clip.getItemAt(0).getHtmlText();
@@ -129,8 +135,9 @@ public class Clipboard {
* @param label The Plain-text label for the HTML content.
* @param text Plain-text representation of the HTML content.
*/
+ @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public void setHTMLText(final String html, final String label, final String text) {
- if (isHTMLClipboardSupported()) {
+ if (IS_HTML_CLIPBOARD_SUPPORTED) {
setPrimaryClipNoException(ClipData.newHtmlText(label, text, html));
}
}
@@ -150,7 +157,7 @@ public class Clipboard {
@CalledByNative
private static boolean isHTMLClipboardSupported() {
- return ApiCompatibilityUtils.isHTMLClipboardSupported();
+ return IS_HTML_CLIPBOARD_SUPPORTED;
}
private void setPrimaryClipNoException(ClipData clip) {

Powered by Google App Engine
This is Rietveld 408576698