OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 package org.chromium.content.browser; |
| 6 |
| 7 import android.content.Intent; |
| 8 import android.graphics.drawable.Drawable; |
| 9 import android.view.View.OnClickListener; |
| 10 |
| 11 import org.chromium.base.annotations.SuppressFBWarnings; |
| 12 |
| 13 /** |
| 14 * The interface that controls contextual text selection. |
| 15 */ |
| 16 @SuppressFBWarnings("UUF_UNUSED_PUBLIC_OR_PROTECTED_FIELD") |
| 17 public interface ContextSelectionProvider { |
| 18 /** |
| 19 * The result of the text analysis. |
| 20 */ |
| 21 public static class Result { |
| 22 /** |
| 23 * The number of characters that the left boundary of the original |
| 24 * selection should be moved. Negative number means moving left. |
| 25 */ |
| 26 public int startAdjust; |
| 27 |
| 28 /** |
| 29 * The number of characters that the right boundary of the original |
| 30 * selection should be moved. Negative number means moving left. |
| 31 */ |
| 32 public int endAdjust; |
| 33 |
| 34 /** |
| 35 * Label for the suggested menu item. |
| 36 */ |
| 37 public CharSequence label; |
| 38 |
| 39 /** |
| 40 * Icon for the suggested menu item. |
| 41 */ |
| 42 public Drawable icon; |
| 43 |
| 44 /** |
| 45 * Intent for the suggested menu item. |
| 46 */ |
| 47 public Intent intent; |
| 48 |
| 49 /** |
| 50 * OnClickListener for the suggested menu item. |
| 51 */ |
| 52 public OnClickListener onClickListener; |
| 53 } |
| 54 |
| 55 /** |
| 56 * The interface that returns the result of the selected text analysis. |
| 57 */ |
| 58 public interface ResultCallback { |
| 59 /** |
| 60 * The result is delivered with this method. |
| 61 */ |
| 62 void onClassified(Result result); |
| 63 } |
| 64 |
| 65 /** |
| 66 * Sends asynchronous request to obtain the selection, analyze its type and
suggest |
| 67 * better selection boundaries. |
| 68 * @param text The textual context that encloses the selected text. |
| 69 * @param start The start index of the selected text inside the textual cont
ext. |
| 70 * @param end The index pointing to the first character that comes after |
| 71 * the selected text inside the textual context. |
| 72 */ |
| 73 public void sendSuggestAndClassifyRequest(CharSequence text, int start, int
end); |
| 74 |
| 75 /** |
| 76 * Sends asynchronous request to obtain the selection and analyze its type. |
| 77 * @param text The textual context that encloses the selected text. |
| 78 * @param start The start index of the selected text inside the textual cont
ext. |
| 79 * @param end The index pointing to the first character that comes after |
| 80 * the selected text inside the textual context. |
| 81 */ |
| 82 public void sendClassifyRequest(CharSequence text, int start, int end); |
| 83 |
| 84 /** |
| 85 * Cancel all asynchronous requests. |
| 86 */ |
| 87 public void cancelAllRequests(); |
| 88 } |
OLD | NEW |