Commit cb9359cc authored by Bernhard Bauer's avatar Bernhard Bauer Committed by Commit Bot

Add Chrome Home promo on the NTP.

Screenshots:
https://folio.googleplex.com/zine/chrome_home_promo

Bug: 769003
Change-Id: I37e452762f6696f53bd7c21ee09a8af5edcf1f03
Reviewed-on: https://chromium-review.googlesource.com/690715Reviewed-by: default avatarNicolas Dossou-Gbété <dgn@chromium.org>
Reviewed-by: default avatarTheresa <twellington@chromium.org>
Commit-Queue: Bernhard Bauer <bauerb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#505369}
parent 4b56fb46
...@@ -96,6 +96,23 @@ ...@@ -96,6 +96,23 @@
android:src="@drawable/btn_mic" /> android:src="@drawable/btn_mic" />
</LinearLayout> </LinearLayout>
<!-- Chrome Home promo -->
<FrameLayout
android:id="@+id/chrome_home_promo_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:visibility="gone">
<org.chromium.ui.widget.TextViewWithClickableSpans
android:id="@+id/chrome_home_promo_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableStart="@drawable/ic_new_releases_black_18dp"
android:drawablePadding="8dp"
android:padding="8dp"
android:textAppearance="@style/BlackHint2" />
</FrameLayout>
<!-- Middle spacer --> <!-- Middle spacer -->
<View <View
android:id="@+id/ntp_middle_spacer" android:id="@+id/ntp_middle_spacer"
......
...@@ -18,6 +18,7 @@ import android.support.v7.widget.RecyclerView.AdapterDataObserver; ...@@ -18,6 +18,7 @@ import android.support.v7.widget.RecyclerView.AdapterDataObserver;
import android.support.v7.widget.RecyclerView.ViewHolder; import android.support.v7.widget.RecyclerView.ViewHolder;
import android.text.Editable; import android.text.Editable;
import android.text.TextWatcher; import android.text.TextWatcher;
import android.text.method.LinkMovementMethod;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View; import android.view.View;
...@@ -56,8 +57,11 @@ import org.chromium.chrome.browser.tab.Tab; ...@@ -56,8 +57,11 @@ import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.util.FeatureUtilities; import org.chromium.chrome.browser.util.FeatureUtilities;
import org.chromium.chrome.browser.util.MathUtils; import org.chromium.chrome.browser.util.MathUtils;
import org.chromium.chrome.browser.util.ViewUtils; import org.chromium.chrome.browser.util.ViewUtils;
import org.chromium.chrome.browser.widget.bottomsheet.ChromeHomePromoDialog;
import org.chromium.chrome.browser.widget.displaystyle.UiConfig; import org.chromium.chrome.browser.widget.displaystyle.UiConfig;
import org.chromium.ui.base.DeviceFormFactor; import org.chromium.ui.base.DeviceFormFactor;
import org.chromium.ui.text.NoUnderlineClickableSpan;
import org.chromium.ui.text.SpanApplier;
/** /**
* The native new tab page, represented by some basic data such as title and url, and an Android * The native new tab page, represented by some basic data such as title and url, and an Android
...@@ -284,6 +288,7 @@ public class NewTabPageView extends FrameLayout implements TileGroup.Observer { ...@@ -284,6 +288,7 @@ public class NewTabPageView extends FrameLayout implements TileGroup.Observer {
initializeSearchBoxTextView(); initializeSearchBoxTextView();
initializeVoiceSearchButton(); initializeVoiceSearchButton();
initializeChromeHomePromo();
initializeLayoutChangeListeners(); initializeLayoutChangeListeners();
setSearchProviderInfo(searchProviderHasLogo, searchProviderIsGoogle); setSearchProviderInfo(searchProviderHasLogo, searchProviderIsGoogle);
mSearchProviderLogoView.showSearchProviderInitialView(); mSearchProviderLogoView.showSearchProviderInitialView();
...@@ -409,6 +414,25 @@ public class NewTabPageView extends FrameLayout implements TileGroup.Observer { ...@@ -409,6 +414,25 @@ public class NewTabPageView extends FrameLayout implements TileGroup.Observer {
TraceEvent.end(TAG + ".initializeVoiceSearchButton()"); TraceEvent.end(TAG + ".initializeVoiceSearchButton()");
} }
private void initializeChromeHomePromo() {
if (!ChromeFeatureList.isEnabled(ChromeFeatureList.CHROME_HOME_PROMO)) return;
NoUnderlineClickableSpan link = new NoUnderlineClickableSpan() {
@Override
public void onClick(View view) {
new ChromeHomePromoDialog(mActivity).show();
}
};
TextView textView = mNewTabPageLayout.findViewById(R.id.chrome_home_promo_text);
textView.setText(
SpanApplier.applySpans(getResources().getString(R.string.ntp_chrome_home_promo),
new SpanApplier.SpanInfo("<link>", "</link>", link)));
textView.setMovementMethod(LinkMovementMethod.getInstance());
mNewTabPageLayout.findViewById(R.id.chrome_home_promo_container)
.setVisibility(View.VISIBLE);
}
private void initializeLayoutChangeListeners() { private void initializeLayoutChangeListeners() {
TraceEvent.begin(TAG + ".initializeLayoutChangeListeners()"); TraceEvent.begin(TAG + ".initializeLayoutChangeListeners()");
mNewTabPageLayout.addOnLayoutChangeListener(new OnLayoutChangeListener() { mNewTabPageLayout.addOnLayoutChangeListener(new OnLayoutChangeListener() {
...@@ -642,8 +666,13 @@ public class NewTabPageView extends FrameLayout implements TileGroup.Observer { ...@@ -642,8 +666,13 @@ public class NewTabPageView extends FrameLayout implements TileGroup.Observer {
for (int i = 0; i < childCount; i++) { for (int i = 0; i < childCount; i++) {
View child = mNewTabPageLayout.getChildAt(i); View child = mNewTabPageLayout.getChildAt(i);
if (child == mSiteSectionViewHolder.itemView) break; if (child == mSiteSectionViewHolder.itemView) break;
// Don't change the visibility of a ViewStub as that will automagically inflate it. // Don't change the visibility of a ViewStub as that will automagically inflate it.
if (child instanceof ViewStub) continue; if (child instanceof ViewStub) continue;
// Skip the Chrome Home promo.
if (child.getId() == R.id.chrome_home_promo_container) continue;
if (child == mSearchProviderLogoView) { if (child == mSearchProviderLogoView) {
child.setVisibility(logoVisibility); child.setVisibility(logoVisibility);
} else { } else {
......
...@@ -2394,6 +2394,9 @@ To obtain new licenses, connect to the internet and play your downloaded content ...@@ -2394,6 +2394,9 @@ To obtain new licenses, connect to the internet and play your downloaded content
<message name="IDS_ACCESSIBILITY_NTP_OFFLINE_BADGE" desc="Content description for the badge that indicates offline availability of a most visited item or content suggestion on the new tab page."> <message name="IDS_ACCESSIBILITY_NTP_OFFLINE_BADGE" desc="Content description for the badge that indicates offline availability of a most visited item or content suggestion on the new tab page.">
Available offline Available offline
</message> </message>
<message name="IDS_NTP_CHROME_HOME_PROMO" desc="Text below the search box on the New Tab Page that encourages the user to try Chrome Home. Part of the text is a link to open the promo dialog.">
Be the first to <ph name="BEGIN_LINK">&lt;link&gt;</ph>try the new Chrome<ph name="END_LINK">&lt;/link&gt;</ph>
</message>
<message name="IDS_NTP_LEARN_MORE_ABOUT_SUGGESTED_CONTENT" desc="Text in the footer of the New Tab Page. Part of the text is a link to a help center page where the user can learn more about suggested content."> <message name="IDS_NTP_LEARN_MORE_ABOUT_SUGGESTED_CONTENT" desc="Text in the footer of the New Tab Page. Part of the text is a link to a help center page where the user can learn more about suggested content.">
<ph name="BEGIN_LINK">&lt;link&gt;</ph>Learn more<ph name="END_LINK">&lt;/link&gt;</ph> about suggested content <ph name="BEGIN_LINK">&lt;link&gt;</ph>Learn more<ph name="END_LINK">&lt;/link&gt;</ph> about suggested content
</message> </message>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment