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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/contextualsearch/ContextualSearchPanelBase.java

Issue 1361153004: [Contextual Search] Adds offscreen View rendering capability (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sync & rebase Created 5 years, 3 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: chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/contextualsearch/ContextualSearchPanelBase.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/contextualsearch/ContextualSearchPanelBase.java b/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/contextualsearch/ContextualSearchPanelBase.java
index c9695ca49b8b0582dd144d294bbc599dcc5be5b4..398b1e08bf3c4e9603c5b6eb7db8e01a4ef60f4b 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/contextualsearch/ContextualSearchPanelBase.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/contextualsearch/ContextualSearchPanelBase.java
@@ -189,7 +189,7 @@ abstract class ContextualSearchPanelBase extends ContextualSearchPanelStateHandl
/**
* The current context.
*/
- private final Context mContext;
+ protected final Context mContext;
/**
* The object for handling global Contextual Search management duties
@@ -242,8 +242,7 @@ abstract class ContextualSearchPanelBase extends ContextualSearchPanelStateHandl
protected abstract void animatePromoAcceptance();
/**
- * Animates the BottomBar text visibility. The BottomBar context text fades out while the
- * BottomBar search text fades in.
+ * Animates the search term resolution.
*/
protected abstract void animateSearchTermResolution();
@@ -539,8 +538,6 @@ abstract class ContextualSearchPanelBase extends ContextualSearchPanelStateHandl
// --------------------------------------------------------------------------------------------
private float mSearchBarMarginSide;
private float mSearchBarHeight;
- private float mBottomBarSearchContextOpacity = 1.f;
- private float mBottomBarSearchTermOpacity = 1.f;
private boolean mIsSearchBarBorderVisible;
private float mSearchBarBorderY;
private float mSearchBarBorderHeight;
@@ -568,20 +565,6 @@ abstract class ContextualSearchPanelBase extends ContextualSearchPanelStateHandl
}
/**
- * @return The opacity of the BottomBar search context view.
- */
- public float getBottomBarSearchContextOpacity() {
- return mBottomBarSearchContextOpacity;
- }
-
- /**
- * @return The opacity of the BottomBar search term view.
- */
- public float getBottomBarSearchTermOpacity() {
- return mBottomBarSearchTermOpacity;
- }
-
- /**
* @return Whether the Search Bar border is visible.
*/
public boolean isSearchBarBorderVisible() {
@@ -917,7 +900,6 @@ abstract class ContextualSearchPanelBase extends ContextualSearchPanelStateHandl
if (state == PanelState.CLOSED) {
mIsShowing = false;
destroyPromoView();
- destroyBottomBarTextControl();
onClose(reason);
} else if (state == PanelState.EXPANDED && isFullscreenSizePanel()
|| (state == PanelState.MAXIMIZED && !isFullscreenSizePanel())) {
@@ -1309,8 +1291,8 @@ abstract class ContextualSearchPanelBase extends ContextualSearchPanelStateHandl
// Resource Loader
// ============================================================================================
- private ViewGroup mContainerView;
- private DynamicResourceLoader mResourceLoader;
+ protected ViewGroup mContainerView;
+ protected DynamicResourceLoader mResourceLoader;
/**
* @param resourceLoader The {@link DynamicResourceLoader} to register and unregister the view.
@@ -1318,13 +1300,6 @@ abstract class ContextualSearchPanelBase extends ContextualSearchPanelStateHandl
public void setDynamicResourceLoader(DynamicResourceLoader resourceLoader) {
mResourceLoader = resourceLoader;
- if (mBottomBarTextControl != null) {
- mResourceLoader.registerResource(R.id.contextual_search_context_view,
- mBottomBarTextControl.getSearchContextResourceAdapter());
- mResourceLoader.registerResource(R.id.contextual_search_term_view,
- mBottomBarTextControl.getSearchTermResourceAdapter());
- }
-
if (mPromoView != null) {
mResourceLoader.registerResource(R.id.contextual_search_opt_out_promo,
mPromoView.getResourceAdapter());
@@ -1341,86 +1316,6 @@ abstract class ContextualSearchPanelBase extends ContextualSearchPanelStateHandl
}
// ============================================================================================
- // BottomBarTextControl
- // ============================================================================================
-
- private BottomBarTextControl mBottomBarTextControl;
-
- /**
- * Creates the BottomBarTextControl, if needed. The Views are set to INVISIBLE, because they
- * won't actually be displayed on the screen (their snapshots will be displayed instead).
- */
- protected BottomBarTextControl getBottomBarTextControl() {
- assert mContainerView != null;
-
- if (mBottomBarTextControl == null) {
- mBottomBarTextControl = new BottomBarTextControl(mContext, mContainerView);
-
- // Adjust size for small Panel.
- if (!isFullscreenSizePanel()) {
- mBottomBarTextControl.setWidth(getMaximumWidthPx());
- }
-
- if (mResourceLoader != null) {
- mResourceLoader.registerResource(R.id.contextual_search_context_view,
- mBottomBarTextControl.getSearchContextResourceAdapter());
- mResourceLoader.registerResource(R.id.contextual_search_term_view,
- mBottomBarTextControl.getSearchTermResourceAdapter());
- }
- }
-
- assert mBottomBarTextControl != null;
- return mBottomBarTextControl;
- }
-
- protected void destroyBottomBarTextControl() {
- if (mBottomBarTextControl != null) {
- mBottomBarTextControl.removeFromContainer();
- mBottomBarTextControl = null;
- if (mResourceLoader != null) {
- mResourceLoader.unregisterResource(R.id.contextual_search_context_view);
- mResourceLoader.unregisterResource(R.id.contextual_search_term_view);
- }
- }
- }
-
- /**
- * Updates the UI state for the BottomBar text. The BottomBar search context view will fade out
- * while the search term fades in.
- *
- * @param percentage The visibility percentage of the BottomBar search term view.
- */
- protected void updateBottomBarTextVisibility(float percentage) {
- // The search context will start fading out before the search term starts fading in.
- // They will both be partially visible for overlapPercentage of the animation duration.
- float overlapPercentage = .75f;
- float fadingOutPercentage = Math.max(1 - (percentage / overlapPercentage), 0.f);
- float fadingInPercentage =
- Math.max(percentage - (1 - overlapPercentage), 0.f) / overlapPercentage;
-
- mBottomBarSearchContextOpacity = fadingOutPercentage;
- mBottomBarSearchTermOpacity = fadingInPercentage;
- }
-
- /**
- * Resets the BottomBar text visibility when a new search context is set. The BottomBar search
- * context is made visible and the BottomBar search text invisible.
- */
- protected void resetBottomBarSearchContextVisibility() {
- mBottomBarSearchContextOpacity = 1.f;
- mBottomBarSearchTermOpacity = 0.f;
- }
-
- /**
- * Resets the BottomBar text visibility when a new search term is set. The BottomBar search
- * term is made visible and the BottomBar search context invisible.
- */
- protected void resetBottomBarSearchTermVisibility() {
- mBottomBarSearchContextOpacity = 0.f;
- mBottomBarSearchTermOpacity = 1.f;
- }
-
- // ============================================================================================
// Promo Host
// ============================================================================================
@@ -1473,6 +1368,7 @@ abstract class ContextualSearchPanelBase extends ContextualSearchPanelStateHandl
assert mContainerView != null;
if (mPromoView == null) {
+ // TODO(pedrosimonetti): Refactor promo code to use ViewResourceInflater.
LayoutInflater.from(mContext).inflate(
R.layout.contextual_search_opt_out_promo, mContainerView);
mPromoView = (ContextualSearchOptOutPromo)

Powered by Google App Engine
This is Rietveld 408576698