Commit e1b73c98 authored by newt's avatar newt Committed by Commit bot

Address NewApi warnings in src/ui.

TBR=nyquist@chromium.org
BUG=411461

Review URL: https://codereview.chromium.org/973403002

Cr-Commit-Position: refs/heads/master@{#319182}
parent 05f78889
......@@ -71,13 +71,6 @@ public class ApiCompatibilityUtils {
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
}
/**
* @return True if the running version of the Android supports HTML clipboard.
*/
public static boolean isHTMLClipboardSupported() {
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN;
}
/**
* @see android.view.View#setLayoutDirection(int)
*/
......
......@@ -4,6 +4,7 @@
package org.chromium.ui;
import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.drawable.GradientDrawable;
import android.graphics.drawable.GradientDrawable.Orientation;
......@@ -82,6 +83,7 @@ public class ColorPickerAdvancedComponent {
*
* @param newColors The set of colors representing the interpolation points for the gradient.
*/
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public void setGradientColors(int[] newColors) {
mGradientColors = newColors.clone();
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
......
......@@ -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;
......@@ -83,9 +88,10 @@ public class Clipboard {
* @return a Java string with the html text if any, or null if there is no html
* text or no entries on the primary clip.
*/
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@CalledByNative
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) {
......
......@@ -4,6 +4,7 @@
package org.chromium.ui.gfx;
import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.PixelFormat;
import android.graphics.Point;
......@@ -57,6 +58,7 @@ public class DeviceDisplayInfo {
/**
* @return Real physical display height in physical pixels.
*/
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
@CalledByNative
public int getPhysicalDisplayHeight() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
......@@ -69,6 +71,7 @@ public class DeviceDisplayInfo {
/**
* @return Real physical display width in physical pixels.
*/
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
@CalledByNative
public int getPhysicalDisplayWidth() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
......
......@@ -4,6 +4,7 @@
package org.chromium.ui.gl;
import android.annotation.TargetApi;
import android.graphics.SurfaceTexture;
import android.os.Build;
import android.util.Log;
......@@ -25,6 +26,7 @@ class SurfaceTexturePlatformWrapper {
return new SurfaceTexture(textureId);
}
@TargetApi(Build.VERSION_CODES.KITKAT)
@CalledByNative
private static SurfaceTexture createSingleBuffered(int textureId) {
assert Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
......@@ -53,29 +55,26 @@ class SurfaceTexturePlatformWrapper {
}
}
@TargetApi(Build.VERSION_CODES.KITKAT)
@CalledByNative
private static void releaseTexImage(SurfaceTexture surfaceTexture) {
assert Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
surfaceTexture.releaseTexImage();
}
@CalledByNative
private static void setDefaultBufferSize(SurfaceTexture surfaceTexture, int width,
int height) {
surfaceTexture.setDefaultBufferSize(width, height);
}
@CalledByNative
private static void getTransformMatrix(SurfaceTexture surfaceTexture, float[] matrix) {
surfaceTexture.getTransformMatrix(matrix);
}
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@CalledByNative
private static void attachToGLContext(SurfaceTexture surfaceTexture, int texName) {
assert Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN;
surfaceTexture.attachToGLContext(texName);
}
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@CalledByNative
private static void detachFromGLContext(SurfaceTexture surfaceTexture) {
assert Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN;
......
......@@ -4,7 +4,9 @@
package org.chromium.ui.widget;
import android.annotation.TargetApi;
import android.content.Context;
import android.os.Build;
import android.os.Bundle;
import android.text.Layout;
import android.text.SpannableString;
......@@ -61,6 +63,7 @@ public class TextViewWithClickableSpans extends TextView {
}
@Override
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public boolean performAccessibilityAction(int action, Bundle arguments) {
// BrailleBack will generate an accessibility click event directly
// on this view, make sure we handle that correctly.
......
......@@ -87,19 +87,6 @@ void SurfaceTexture::GetTransformMatrix(float mtx[16]) {
env->ReleaseFloatArrayElements(jmatrix.obj(), elements, JNI_ABORT);
}
void SurfaceTexture::SetDefaultBufferSize(int width, int height) {
JNIEnv* env = base::android::AttachCurrentThread();
if (width > 0 && height > 0) {
Java_SurfaceTexturePlatformWrapper_setDefaultBufferSize(
env, j_surface_texture_.obj(), static_cast<jint>(width),
static_cast<jint>(height));
} else {
LOG(WARNING) << "Not setting surface texture buffer size - "
"width or height is 0";
}
}
void SurfaceTexture::AttachToGLContext() {
if (GlContextMethodsAvailable()) {
int texture_id;
......
......@@ -46,9 +46,6 @@ class GL_EXPORT SurfaceTexture
// texture image set by the most recent call to updateTexImage.
void GetTransformMatrix(float mtx[16]);
// Set the default size of the image buffers.
void SetDefaultBufferSize(int width, int height);
// Attach the SurfaceTexture to the texture currently bound to
// GL_TEXTURE_EXTERNAL_OES.
void AttachToGLContext();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment