| Index: content/public/android/java/src/org/chromium/content/browser/input/HandleViewResources.java
|
| diff --git a/content/public/android/java/src/org/chromium/content/browser/input/HandleViewResources.java b/content/public/android/java/src/org/chromium/content/browser/input/HandleViewResources.java
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..46a56f72e7258bd515d4191fcbffdf3f531eef09
|
| --- /dev/null
|
| +++ b/content/public/android/java/src/org/chromium/content/browser/input/HandleViewResources.java
|
| @@ -0,0 +1,71 @@
|
| +// Copyright 2012 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +package org.chromium.content.browser.input;
|
| +
|
| +import android.content.Context;
|
| +import android.content.res.TypedArray;
|
| +import android.graphics.drawable.Drawable;
|
| +
|
| +import org.chromium.base.CalledByNative;
|
| +import org.chromium.base.JNINamespace;
|
| +
|
| +/**
|
| + * Helper class for retrieving resources related to selection handles.
|
| + */
|
| +@JNINamespace("content")
|
| +public class HandleViewResources {
|
| + private static final int[] LEFT_HANDLE_ATTRS = {
|
| + android.R.attr.textSelectHandleLeft,
|
| + };
|
| +
|
| + private static final int[] CENTER_HANDLE_ATTRS = {
|
| + android.R.attr.textSelectHandle,
|
| + };
|
| +
|
| + private static final int[] RIGHT_HANDLE_ATTRS = {
|
| + android.R.attr.textSelectHandleRight,
|
| + };
|
| +
|
| + public static Drawable getLeftHandleDrawable(Context context) {
|
| + return getHandleDrawable(context, LEFT_HANDLE_ATTRS);
|
| + }
|
| +
|
| + public static Drawable getCenterHandleDrawable(Context context) {
|
| + return getHandleDrawable(context, CENTER_HANDLE_ATTRS);
|
| + }
|
| +
|
| + public static Drawable getRightHandleDrawable(Context context) {
|
| + return getHandleDrawable(context, RIGHT_HANDLE_ATTRS);
|
| + }
|
| +
|
| + private static Drawable getHandleDrawable(Context context, final int[] attrs) {
|
| + TypedArray a = context.getTheme().obtainStyledAttributes(attrs);
|
| + Drawable drawable = a.getDrawable(0);
|
| + a.recycle();
|
| + return drawable;
|
| + }
|
| +
|
| + private static int getHandleResourceId(Context context, final int[] attrs) {
|
| + TypedArray a = context.getTheme().obtainStyledAttributes(attrs);
|
| + int resId = a.getResourceId(a.getIndex(0), 0);
|
| + a.recycle();
|
| + return resId;
|
| + }
|
| +
|
| + @CalledByNative
|
| + private static int getLeftHandleResourceId(Context context) {
|
| + return getHandleResourceId(context, LEFT_HANDLE_ATTRS);
|
| + }
|
| +
|
| + @CalledByNative
|
| + private static int getCenterHandleResourceId(Context context) {
|
| + return getHandleResourceId(context, CENTER_HANDLE_ATTRS);
|
| + }
|
| +
|
| + @CalledByNative
|
| + private static int getRightHandleResourceId(Context context) {
|
| + return getHandleResourceId(context, RIGHT_HANDLE_ATTRS);
|
| + }
|
| +}
|
|
|