Commit 0371b900 authored by Lijin Shen's avatar Lijin Shen Committed by Commit Bot

Add min-height to the learn more link in the incognito page view

Set a min height to reach the min target touch size.

Bug: 1096146
Change-Id: I3de7b9d1716ed25464120001a9fa15839ceb867b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2337955
Commit-Queue: Lijin Shen <lazzzis@google.com>
Reviewed-by: default avatarTheresa  <twellington@chromium.org>
Cr-Commit-Position: refs/heads/master@{#796600}
parent e0917f58
...@@ -282,6 +282,7 @@ chrome_test_java_sources = [ ...@@ -282,6 +282,7 @@ chrome_test_java_sources = [
"javatests/src/org/chromium/chrome/browser/notifications/channels/ChannelsUpdaterTest.java", "javatests/src/org/chromium/chrome/browser/notifications/channels/ChannelsUpdaterTest.java",
"javatests/src/org/chromium/chrome/browser/notifications/channels/SiteChannelsManagerTest.java", "javatests/src/org/chromium/chrome/browser/notifications/channels/SiteChannelsManagerTest.java",
"javatests/src/org/chromium/chrome/browser/notifications/settings/NotificationSettingsTest.java", "javatests/src/org/chromium/chrome/browser/notifications/settings/NotificationSettingsTest.java",
"javatests/src/org/chromium/chrome/browser/ntp/IncognitoDescriptionViewRenderTest.java",
"javatests/src/org/chromium/chrome/browser/ntp/IncognitoNewTabPageTest.java", "javatests/src/org/chromium/chrome/browser/ntp/IncognitoNewTabPageTest.java",
"javatests/src/org/chromium/chrome/browser/ntp/NewTabPageLoadTest.java", "javatests/src/org/chromium/chrome/browser/ntp/NewTabPageLoadTest.java",
"javatests/src/org/chromium/chrome/browser/ntp/NewTabPageNavigationTest.java", "javatests/src/org/chromium/chrome/browser/ntp/NewTabPageNavigationTest.java",
......
...@@ -63,6 +63,8 @@ ...@@ -63,6 +63,8 @@
android:id="@+id/learn_more" android:id="@+id/learn_more"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:minHeight="@dimen/min_touch_target_size"
android:gravity="center_vertical"
android:text="@string/learn_more" android:text="@string/learn_more"
android:textAppearance="@style/TextAppearance.IncognitoNewTabLearnMoreLinkModern" android:textAppearance="@style/TextAppearance.IncognitoNewTabLearnMoreLinkModern"
app:leading="@dimen/text_size_medium_leading" /> app:leading="@dimen/text_size_medium_leading" />
...@@ -74,7 +76,6 @@ ...@@ -74,7 +76,6 @@
android:layout_gravity="center" android:layout_gravity="center"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:padding="16dp"> android:padding="16dp">
<ImageView <ImageView
......
...@@ -55,6 +55,7 @@ public class IncognitoDescriptionView extends LinearLayout { ...@@ -55,6 +55,7 @@ public class IncognitoDescriptionView extends LinearLayout {
private static final int BULLETPOINTS_HORIZONTAL_SPACING_DP = 40; private static final int BULLETPOINTS_HORIZONTAL_SPACING_DP = 40;
private static final int CONTENT_WIDTH_DP = 600; private static final int CONTENT_WIDTH_DP = 600;
private static final int WIDE_LAYOUT_THRESHOLD_DP = 720; private static final int WIDE_LAYOUT_THRESHOLD_DP = 720;
private static final int COOKIES_CONTROL_MARGIN_TOP_DP = 24;
/** Default constructor needed to inflate via XML. */ /** Default constructor needed to inflate via XML. */
public IncognitoDescriptionView(Context context, AttributeSet attrs) { public IncognitoDescriptionView(Context context, AttributeSet attrs) {
...@@ -108,7 +109,7 @@ public class IncognitoDescriptionView extends LinearLayout { ...@@ -108,7 +109,7 @@ public class IncognitoDescriptionView extends LinearLayout {
mSubtitle = findViewById(R.id.new_tab_incognito_subtitle); mSubtitle = findViewById(R.id.new_tab_incognito_subtitle);
mLearnMore = findViewById(R.id.learn_more); mLearnMore = findViewById(R.id.learn_more);
mParagraphs = new TextView[] {mSubtitle, findViewById(R.id.new_tab_incognito_features), mParagraphs = new TextView[] {mSubtitle, findViewById(R.id.new_tab_incognito_features),
findViewById(R.id.new_tab_incognito_warning), mLearnMore}; findViewById(R.id.new_tab_incognito_warning)};
mBulletpointsContainer = findViewById(R.id.new_tab_incognito_bulletpoints_container); mBulletpointsContainer = findViewById(R.id.new_tab_incognito_bulletpoints_container);
mCookieControlsCard = findViewById(R.id.cookie_controls_card); mCookieControlsCard = findViewById(R.id.cookie_controls_card);
mCookieControlsToggle = findViewById(R.id.cookie_controls_card_toggle); mCookieControlsToggle = findViewById(R.id.cookie_controls_card_toggle);
...@@ -256,6 +257,20 @@ public class IncognitoDescriptionView extends LinearLayout { ...@@ -256,6 +257,20 @@ public class IncognitoDescriptionView extends LinearLayout {
paragraph.setLayoutParams(paragraph.getLayoutParams()); // Apply the new layout. paragraph.setLayoutParams(paragraph.getLayoutParams()); // Apply the new layout.
} }
// Set up margins of learn more link to maintain a constant space between link text
// and other views.
int innerSpacing = (int) ((getContext().getResources().getDimensionPixelSize(
R.dimen.min_touch_target_size)
- mLearnMore.getTextSize())
/ 2);
int learnMoreSpacingTop = spacingPx - innerSpacing;
int learnMoreSpacingBottom =
dpToPx(getContext(), COOKIES_CONTROL_MARGIN_TOP_DP) - innerSpacing;
LinearLayout.LayoutParams params = (LayoutParams) mLearnMore.getLayoutParams();
params.setMargins(
0, Math.max(learnMoreSpacingTop, 0), 0, Math.max(learnMoreSpacingBottom, 0));
mLearnMore.requestLayout();
((LinearLayout.LayoutParams) mHeader.getLayoutParams()).setMargins(0, spacingPx, 0, 0); ((LinearLayout.LayoutParams) mHeader.getLayoutParams()).setMargins(0, spacingPx, 0, 0);
mHeader.setLayoutParams(mHeader.getLayoutParams()); // Apply the new layout. mHeader.setLayoutParams(mHeader.getLayoutParams()); // Apply the new layout.
} }
......
// Copyright 2020 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.ntp;
import android.app.Activity;
import android.view.View;
import androidx.test.filters.MediumTest;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.chromium.base.test.params.ParameterAnnotations;
import org.chromium.base.test.params.ParameterAnnotations.UseRunnerDelegate;
import org.chromium.base.test.params.ParameterSet;
import org.chromium.base.test.params.ParameterizedRunner;
import org.chromium.base.test.util.Feature;
import org.chromium.chrome.R;
import org.chromium.chrome.test.ChromeJUnit4RunnerDelegate;
import org.chromium.chrome.test.util.ChromeRenderTestRule;
import org.chromium.content_public.browser.test.util.TestThreadUtils;
import org.chromium.ui.test.util.DummyUiActivityTestCase;
import org.chromium.ui.test.util.NightModeTestUtils;
import java.io.IOException;
import java.util.List;
/**
* Render test of incognito description in the incognito ntp.
*/
@RunWith(ParameterizedRunner.class)
@UseRunnerDelegate(ChromeJUnit4RunnerDelegate.class)
public class IncognitoDescriptionViewRenderTest extends DummyUiActivityTestCase {
@ParameterAnnotations.ClassParameter
private static List<ParameterSet> sClassParams =
new NightModeTestUtils.NightModeParams().getParameters();
@Rule
public ChromeRenderTestRule mRenderTestRule =
ChromeRenderTestRule.Builder.withPublicCorpus().build();
public IncognitoDescriptionViewRenderTest(boolean nightModeEnabled) {
NightModeTestUtils.setUpNightModeForDummyUiActivity(nightModeEnabled);
mRenderTestRule.setNightModeEnabled(nightModeEnabled);
}
@Override
public void setUpTest() throws Exception {
super.setUpTest();
TestThreadUtils.runOnUiThreadBlocking(() -> {
Activity activity = getActivity();
activity.setContentView(R.layout.incognito_description_layout);
});
}
@Test
@MediumTest
@Feature({"RenderTest"})
public void testRender_IncognitoDescriptionView() throws IOException {
View view = getActivity().findViewById(android.R.id.content);
TestThreadUtils.runOnUiThreadBlocking(() -> {
view.setBackgroundResource(R.color.ntp_bg_incognito);
});
mRenderTestRule.render(view, "incognito_description_view");
}
}
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