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

Unified Diff: content/public/android/java/src/org/chromium/content/browser/input/HandleViewResources.java

Issue 335943002: [Android] Composited selection handle rendering (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@input_native_handles_final
Patch Set: Clean up paste popup interaction Created 6 years, 5 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: 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);
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698