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

Side by Side Diff: ui/android/java/src/org/chromium/ui/base/ViewAndroidDelegate.java

Issue 2745623003: Revert of Fix TODOs related to SDK 24 (Closed)
Patch Set: Created 3 years, 9 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 unified diff | Download patch
« no previous file with comments | « content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.ui.base; 5 package org.chromium.ui.base;
6 6
7 import android.annotation.TargetApi;
8 import android.content.ClipData; 7 import android.content.ClipData;
9 import android.content.Intent; 8 import android.content.Intent;
10 import android.graphics.Bitmap; 9 import android.graphics.Bitmap;
11 import android.os.Build; 10 import android.os.Build;
12 import android.view.View; 11 import android.view.View;
13 import android.view.ViewGroup; 12 import android.view.ViewGroup;
14 import android.widget.FrameLayout.LayoutParams; 13 import android.widget.FrameLayout.LayoutParams;
15 import android.widget.ImageView; 14 import android.widget.ImageView;
16 15
17 import org.chromium.base.ApiCompatibilityUtils; 16 import org.chromium.base.ApiCompatibilityUtils;
18 import org.chromium.base.Log; 17 import org.chromium.base.Log;
19 import org.chromium.base.annotations.CalledByNative; 18 import org.chromium.base.annotations.CalledByNative;
20 import org.chromium.base.annotations.JNINamespace; 19 import org.chromium.base.annotations.JNINamespace;
21 20
22 import java.net.URISyntaxException; 21 import java.net.URISyntaxException;
23 22
24 /** 23 /**
25 * Class to acquire, position, and remove anchor views from the implementing Vie w. 24 * Class to acquire, position, and remove anchor views from the implementing Vie w.
26 */ 25 */
27 @JNINamespace("ui") 26 @JNINamespace("ui")
28 public abstract class ViewAndroidDelegate { 27 public abstract class ViewAndroidDelegate {
29 private static final String TAG = "ViewAndroidDelegate"; 28 private static final String TAG = "ViewAndroidDelegate";
29
30 // TODO(hush): use View#DRAG_FLAG_GLOBAL when Chromium starts to build with API 24.
31 private static final int DRAG_FLAG_GLOBAL = 1 << 8;
32
30 private static final String GEO_SCHEME = "geo"; 33 private static final String GEO_SCHEME = "geo";
31 private static final String TEL_SCHEME = "tel"; 34 private static final String TEL_SCHEME = "tel";
32 private static final String MAILTO_SCHEME = "mailto"; 35 private static final String MAILTO_SCHEME = "mailto";
33 36
34 /** 37 /**
35 * @return An anchor view that can be used to anchor decoration views like A utofill popup. 38 * @return An anchor view that can be used to anchor decoration views like A utofill popup.
36 */ 39 */
37 @CalledByNative 40 @CalledByNative
38 public View acquireView() { 41 public View acquireView() {
39 ViewGroup containerView = getContainerView(); 42 ViewGroup containerView = getContainerView();
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 lp.topMargin = topMargin; 88 lp.topMargin = topMargin;
86 view.setLayoutParams(lp); 89 view.setLayoutParams(lp);
87 } 90 }
88 91
89 /** 92 /**
90 * Drag the text out of current view. 93 * Drag the text out of current view.
91 * @param text The dragged text. 94 * @param text The dragged text.
92 * @param shadowImage The shadow image for the dragged text. 95 * @param shadowImage The shadow image for the dragged text.
93 */ 96 */
94 @SuppressWarnings("deprecation") 97 @SuppressWarnings("deprecation")
95 @TargetApi(Build.VERSION_CODES.N) 98 // TODO(hush): uncomment below when we build with API 24.
99 // @TargetApi(Build.VERSION_CODES.N)
96 @CalledByNative 100 @CalledByNative
97 private boolean startDragAndDrop(String text, Bitmap shadowImage) { 101 private boolean startDragAndDrop(String text, Bitmap shadowImage) {
98 if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.M) return false; 102 if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.M) return false;
99 103
100 ViewGroup containerView = getContainerView(); 104 ViewGroup containerView = getContainerView();
101 if (containerView == null) return false; 105 if (containerView == null) return false;
102 106
103 ImageView imageView = new ImageView(containerView.getContext()); 107 ImageView imageView = new ImageView(containerView.getContext());
104 imageView.setImageBitmap(shadowImage); 108 imageView.setImageBitmap(shadowImage);
105 imageView.layout(0, 0, shadowImage.getWidth(), shadowImage.getHeight()); 109 imageView.layout(0, 0, shadowImage.getWidth(), shadowImage.getHeight());
106 110
107 return containerView.startDragAndDrop(ClipData.newPlainText(null, text), 111 // TODO(hush): use View#startDragAndDrop when Chromium starts to build w ith API 24.
108 new View.DragShadowBuilder(imageView), null, View.DRAG_FLAG_GLOB AL); 112 return containerView.startDrag(ClipData.newPlainText(null, text),
113 new View.DragShadowBuilder(imageView), null, DRAG_FLAG_GLOBAL);
109 } 114 }
110 115
111 /** 116 /**
112 * Called whenever the background color of the page changes as notified by B link. 117 * Called whenever the background color of the page changes as notified by B link.
113 * @param color The new ARGB color of the page background. 118 * @param color The new ARGB color of the page background.
114 */ 119 */
115 @CalledByNative 120 @CalledByNative
116 public void onBackgroundColorChanged(int color) {} 121 public void onBackgroundColorChanged(int color) {}
117 122
118 /** 123 /**
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 return this; 185 return this;
181 } 186 }
182 187
183 @Override 188 @Override
184 public ViewGroup getContainerView() { 189 public ViewGroup getContainerView() {
185 return mContainerView; 190 return mContainerView;
186 } 191 }
187 }.init(containerView); 192 }.init(containerView);
188 } 193 }
189 } 194 }
OLDNEW
« no previous file with comments | « content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698