| Index: chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/contextualsearch/ContextualSearchContextControl.java
|
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/contextualsearch/ContextualSearchContextControl.java b/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/contextualsearch/ContextualSearchContextControl.java
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..4a5246a6eca58dfd3d3dbbdb6f5fcc6b19b48adb
|
| --- /dev/null
|
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/contextualsearch/ContextualSearchContextControl.java
|
| @@ -0,0 +1,73 @@
|
| +// Copyright 2015 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.chrome.browser.compositor.bottombar.contextualsearch;
|
| +
|
| +import android.content.Context;
|
| +import android.view.View;
|
| +import android.view.ViewGroup;
|
| +import android.widget.TextView;
|
| +
|
| +import org.chromium.chrome.R;
|
| +import org.chromium.ui.resources.dynamics.DynamicResourceLoader;
|
| +
|
| +/**
|
| + * Controls the Search Context View that is used as a dynamic resource.
|
| + */
|
| +public class ContextualSearchContextControl extends ContextualSearchInflater {
|
| + /**
|
| + * The selected text View.
|
| + */
|
| + private TextView mSelectedText;
|
| +
|
| + /**
|
| + * The start of the surrounding text View.
|
| + */
|
| + private TextView mStartText;
|
| +
|
| + /**
|
| + * The end of the surrounding text View.
|
| + */
|
| + private TextView mEndText;
|
| +
|
| + /**
|
| + * @param panel The panel delegate.
|
| + * @param context The Android Context used to inflate the View.
|
| + * @param container The container View used to inflate the View.
|
| + * @param resourceLoader The resource loader that will handle the snapshot capturing.
|
| + */
|
| + public ContextualSearchContextControl(ContextualSearchPanelDelegate panel,
|
| + Context context,
|
| + ViewGroup container,
|
| + DynamicResourceLoader resourceLoader) {
|
| + super(panel, R.layout.contextual_search_context_view, R.id.contextual_search_context_view,
|
| + context, container, resourceLoader);
|
| + }
|
| +
|
| + /**
|
| + * Sets the search context to display in the control.
|
| + * @param selection The portion of the context that represents the user's selection.
|
| + * @param start The portion of the context before the selection.
|
| + * @param end The portion of the context after the selection.
|
| + */
|
| + public void setSearchContext(String selection, String start, String end) {
|
| + inflate();
|
| +
|
| + mStartText.setText(sanitizeText(start));
|
| + mSelectedText.setText(sanitizeText(selection));
|
| + mEndText.setText(sanitizeText(end));
|
| +
|
| + invalidate();
|
| + }
|
| +
|
| + @Override
|
| + protected void onFinishInflate() {
|
| + super.onFinishInflate();
|
| +
|
| + View view = getView();
|
| + mSelectedText = (TextView) view.findViewById(R.id.selected_text);
|
| + mStartText = (TextView) view.findViewById(R.id.surrounding_text_start);
|
| + mEndText = (TextView) view.findViewById(R.id.surrounding_text_end);
|
| + }
|
| +}
|
|
|