Commit a61c035b authored by adamta's avatar adamta Committed by Commit Bot

[iOS] IPH for Discover feed header menu button

Adds IPH for top-level menu button of the Discover feed header in the
NTP. Here is clip for the IPH appearing: http://shortn/_TejkyqTmah

Bug: 1085419
Change-Id: I7a713d1e8cdb66fda3902ceb1f5db843bf414f0f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2354904
Commit-Queue: Sergio Collazos <sczs@chromium.org>
Reviewed-by: default avatarSergio Collazos <sczs@chromium.org>
Reviewed-by: default avatarTommy Nyquist <nyquist@chromium.org>
Reviewed-by: default avataredchin <edchin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#800161}
parent 89ac6b07
...@@ -122,6 +122,8 @@ const base::Feature kIPHBadgedReadingListFeature{ ...@@ -122,6 +122,8 @@ const base::Feature kIPHBadgedReadingListFeature{
"IPH_BadgedReadingList", base::FEATURE_DISABLED_BY_DEFAULT}; "IPH_BadgedReadingList", base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kIPHBadgedTranslateManualTriggerFeature{ const base::Feature kIPHBadgedTranslateManualTriggerFeature{
"IPH_BadgedTranslateManualTrigger", base::FEATURE_DISABLED_BY_DEFAULT}; "IPH_BadgedTranslateManualTrigger", base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kIPHDiscoverFeedHeaderFeature{
"IPH_DiscoverFeedHeaderMenu", base::FEATURE_DISABLED_BY_DEFAULT};
#endif // defined(OS_IOS) #endif // defined(OS_IOS)
} // namespace feature_engagement } // namespace feature_engagement
...@@ -81,6 +81,7 @@ extern const base::Feature kIPHNewTabTipFeature; ...@@ -81,6 +81,7 @@ extern const base::Feature kIPHNewTabTipFeature;
extern const base::Feature kIPHNewIncognitoTabTipFeature; extern const base::Feature kIPHNewIncognitoTabTipFeature;
extern const base::Feature kIPHBadgedReadingListFeature; extern const base::Feature kIPHBadgedReadingListFeature;
extern const base::Feature kIPHBadgedTranslateManualTriggerFeature; extern const base::Feature kIPHBadgedTranslateManualTriggerFeature;
extern const base::Feature kIPHDiscoverFeedHeaderFeature;
#endif // defined(OS_IOS) #endif // defined(OS_IOS)
} // namespace feature_engagement } // namespace feature_engagement
......
...@@ -62,6 +62,7 @@ const base::Feature* const kAllFeatures[] = { ...@@ -62,6 +62,7 @@ const base::Feature* const kAllFeatures[] = {
&kIPHNewIncognitoTabTipFeature, &kIPHNewIncognitoTabTipFeature,
&kIPHBadgedReadingListFeature, &kIPHBadgedReadingListFeature,
&kIPHBadgedTranslateManualTriggerFeature, &kIPHBadgedTranslateManualTriggerFeature,
&kIPHDiscoverFeedHeaderFeature,
#endif // defined(OS_IOS) #endif // defined(OS_IOS)
#if defined(OS_WIN) || defined(OS_APPLE) || defined(OS_LINUX) || \ #if defined(OS_WIN) || defined(OS_APPLE) || defined(OS_LINUX) || \
defined(OS_CHROMEOS) defined(OS_CHROMEOS)
......
...@@ -118,6 +118,8 @@ DEFINE_VARIATION_PARAM(kIPHNewIncognitoTabTipFeature, "IPH_NewIncognitoTabTip"); ...@@ -118,6 +118,8 @@ DEFINE_VARIATION_PARAM(kIPHNewIncognitoTabTipFeature, "IPH_NewIncognitoTabTip");
DEFINE_VARIATION_PARAM(kIPHBadgedReadingListFeature, "IPH_BadgedReadingList"); DEFINE_VARIATION_PARAM(kIPHBadgedReadingListFeature, "IPH_BadgedReadingList");
DEFINE_VARIATION_PARAM(kIPHBadgedTranslateManualTriggerFeature, DEFINE_VARIATION_PARAM(kIPHBadgedTranslateManualTriggerFeature,
"IPH_BadgedTranslateManualTrigger"); "IPH_BadgedTranslateManualTrigger");
DEFINE_VARIATION_PARAM(kIPHDiscoverFeedHeaderFeature,
"IPH_DiscoverFeedHeaderMenu");
#endif // defined(OS_IOS) #endif // defined(OS_IOS)
#if defined(OS_WIN) || defined(OS_APPLE) || defined(OS_LINUX) || \ #if defined(OS_WIN) || defined(OS_APPLE) || defined(OS_LINUX) || \
...@@ -186,6 +188,7 @@ constexpr flags_ui::FeatureEntry::FeatureVariation ...@@ -186,6 +188,7 @@ constexpr flags_ui::FeatureEntry::FeatureVariation
VARIATION_ENTRY(kIPHNewIncognitoTabTipFeature), VARIATION_ENTRY(kIPHNewIncognitoTabTipFeature),
VARIATION_ENTRY(kIPHBadgedReadingListFeature), VARIATION_ENTRY(kIPHBadgedReadingListFeature),
VARIATION_ENTRY(kIPHBadgedTranslateManualTriggerFeature), VARIATION_ENTRY(kIPHBadgedTranslateManualTriggerFeature),
VARIATION_ENTRY(kIPHDiscoverFeedHeaderFeature),
#elif defined(OS_WIN) || defined(OS_APPLE) || defined(OS_LINUX) || \ #elif defined(OS_WIN) || defined(OS_APPLE) || defined(OS_LINUX) || \
defined(OS_CHROMEOS) defined(OS_CHROMEOS)
VARIATION_ENTRY(kIPHDesktopTabGroupsNewGroupFeature), VARIATION_ENTRY(kIPHDesktopTabGroupsNewGroupFeature),
......
...@@ -717,6 +717,9 @@ Because your account is managed by <ph name="HOSTED_DOMAIN">$1<ex>google.com</ex ...@@ -717,6 +717,9 @@ Because your account is managed by <ph name="HOSTED_DOMAIN">$1<ex>google.com</ex
<message name="IDS_IOS_DISCONNECT_DIALOG_TITLE_UNITY" desc="The title of the disconnect dialog [Length: 30em]."> <message name="IDS_IOS_DISCONNECT_DIALOG_TITLE_UNITY" desc="The title of the disconnect dialog [Length: 30em].">
Sign out and turn off sync? Sign out and turn off sync?
</message> </message>
<message name="IDS_IOS_DISCOVER_FEED_HEADER_IPH" desc="In-product help that points at the menu icon for the news feed on Chrome's new tab page. This string instructs the user to open the menu for settings that let them control the content that appears on the feed.">
Control your stories and activity here
</message>
<message name="IDS_IOS_DISCOVER_FEED_TITLE" desc="The title in the Discover feed menu."> <message name="IDS_IOS_DISCOVER_FEED_TITLE" desc="The title in the Discover feed menu.">
Discover Discover
</message> </message>
......
ac7469a1b2f6aee4da011cfba151465980dd9310
\ No newline at end of file
...@@ -2219,6 +2219,7 @@ NSString* const kBrowserViewControllerSnackbarCategory = ...@@ -2219,6 +2219,7 @@ NSString* const kBrowserViewControllerSnackbarCategory =
kNewTabButtonGuide, kNewTabButtonGuide,
kSecondaryToolbarGuide, kSecondaryToolbarGuide,
kVoiceSearchButtonGuide, kVoiceSearchButtonGuide,
kDiscoverFeedHeaderMenuGuide,
]; ];
AddNamedGuidesToView(guideNames, self.view); AddNamedGuidesToView(guideNames, self.view);
......
...@@ -58,6 +58,8 @@ const CGFloat kBubblePresentationDelay = 1; ...@@ -58,6 +58,8 @@ const CGFloat kBubblePresentationDelay = 1;
BubbleViewControllerPresenter* tabTipBubblePresenter; BubbleViewControllerPresenter* tabTipBubblePresenter;
@property(nonatomic, strong, readwrite) @property(nonatomic, strong, readwrite)
BubbleViewControllerPresenter* incognitoTabTipBubblePresenter; BubbleViewControllerPresenter* incognitoTabTipBubblePresenter;
@property(nonatomic, strong)
BubbleViewControllerPresenter* discoverFeedHeaderMenuTipBubblePresenter;
@property(nonatomic, assign) ChromeBrowserState* browserState; @property(nonatomic, assign) ChromeBrowserState* browserState;
@property(nonatomic, weak) id<BubblePresenterDelegate> delegate; @property(nonatomic, weak) id<BubblePresenterDelegate> delegate;
...@@ -131,6 +133,7 @@ const CGFloat kBubblePresentationDelay = 1; ...@@ -131,6 +133,7 @@ const CGFloat kBubblePresentationDelay = 1;
[self.incognitoTabTipBubblePresenter dismissAnimated:NO]; [self.incognitoTabTipBubblePresenter dismissAnimated:NO];
[self.bottomToolbarTipBubblePresenter dismissAnimated:NO]; [self.bottomToolbarTipBubblePresenter dismissAnimated:NO];
[self.longPressToolbarTipBubblePresenter dismissAnimated:NO]; [self.longPressToolbarTipBubblePresenter dismissAnimated:NO];
[self.discoverFeedHeaderMenuTipBubblePresenter dismissAnimated:NO];
} }
- (void)userEnteredTabSwitcher { - (void)userEnteredTabSwitcher {
...@@ -158,9 +161,10 @@ const CGFloat kBubblePresentationDelay = 1; ...@@ -158,9 +161,10 @@ const CGFloat kBubblePresentationDelay = 1;
if (!self.incognitoTabTipBubblePresenter.isUserEngaged) if (!self.incognitoTabTipBubblePresenter.isUserEngaged)
[self presentNewIncognitoTabTipBubble]; [self presentNewIncognitoTabTipBubble];
// The bottom toolbar doesn't use the isUserEngaged, so don't check if the // The bottom toolbar and Discover feed header menu don't use the
// user is engaged here. // isUserEngaged, so don't check if the user is engaged here.
[self presentBottomToolbarTipBubble]; [self presentBottomToolbarTipBubble];
[self presentDiscoverFeedHeaderTipBubble];
} }
- (void)presentLongPressBubble { - (void)presentLongPressBubble {
...@@ -259,6 +263,34 @@ presentBubbleForFeature:(const base::Feature&)feature ...@@ -259,6 +263,34 @@ presentBubbleForFeature:(const base::Feature&)feature
->NotifyEvent(feature_engagement::events::kBottomToolbarOpened); ->NotifyEvent(feature_engagement::events::kBottomToolbarOpened);
} }
// Presents a bubble associated with the Discover feed header's menu button.
- (void)presentDiscoverFeedHeaderTipBubble {
if (![self canPresentBubble])
return;
BubbleArrowDirection arrowDirection = BubbleArrowDirectionDown;
NSString* text =
l10n_util::GetNSStringWithFixup(IDS_IOS_DISCOVER_FEED_HEADER_IPH);
CGPoint discoverFeedHeaderAnchor =
[self anchorPointToGuide:kDiscoverFeedHeaderMenuGuide
direction:arrowDirection];
// If the feature engagement tracker does not consider it valid to display
// the new tab tip, then end early to prevent the potential reassignment
// of the existing |tabTipBubblePresenter| to nil.
BubbleViewControllerPresenter* presenter = [self
presentBubbleForFeature:feature_engagement::kIPHDiscoverFeedHeaderFeature
direction:arrowDirection
alignment:BubbleAlignmentTrailing
text:text
voiceOverAnnouncement:nil
anchorPoint:discoverFeedHeaderAnchor];
if (!presenter)
return;
self.discoverFeedHeaderMenuTipBubblePresenter = presenter;
}
// Optionally presents a bubble associated with the new tab tip in-product help // Optionally presents a bubble associated with the new tab tip in-product help
// promotion. If the feature engagement tracker determines it is valid to show // promotion. If the feature engagement tracker determines it is valid to show
// the new tab tip, then it initializes |tabTipBubblePresenter| and presents // the new tab tip, then it initializes |tabTipBubblePresenter| and presents
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#import "ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_discover_header_item.h" #import "ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_discover_header_item.h"
#import "ios/chrome/browser/ui/content_suggestions/content_suggestions_constants.h" #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_constants.h"
#import "ios/chrome/browser/ui/util/named_guide.h"
#import "ios/chrome/browser/ui/util/uikit_ui_util.h" #import "ios/chrome/browser/ui/util/uikit_ui_util.h"
#import "ios/chrome/common/ui/colors/UIColor+cr_semantic_colors.h" #import "ios/chrome/common/ui/colors/UIColor+cr_semantic_colors.h"
#import "ios/chrome/common/ui/colors/semantic_color_names.h" #import "ios/chrome/common/ui/colors/semantic_color_names.h"
...@@ -211,6 +212,14 @@ const CGFloat kHeaderBorderRadius = 8; ...@@ -211,6 +212,14 @@ const CGFloat kHeaderBorderRadius = 8;
[self setConstraintsForFeedVisible:visible]; [self setConstraintsForFeedVisible:visible];
} }
self.container.layer.borderWidth = visible ? 0 : kHeaderBorderWidth; self.container.layer.borderWidth = visible ? 0 : kHeaderBorderWidth;
[self.contentView layoutIfNeeded];
NamedGuide* menuButtonGuide =
[NamedGuide guideWithName:kDiscoverFeedHeaderMenuGuide
view:self.menuButton];
menuButtonGuide.constrainedFrame =
[self.contentView convertRect:self.menuButton.frame toView:nil];
self.discoverFeedVisible = [NSNumber numberWithBool:visible];
} }
// Sets header properties for when the Discover feed is visible. // Sets header properties for when the Discover feed is visible.
......
...@@ -55,5 +55,8 @@ extern GuideName* const kTranslateInfobarOptionsGuide; ...@@ -55,5 +55,8 @@ extern GuideName* const kTranslateInfobarOptionsGuide;
// A guide that is constrained to match the frame of the last-tapped voice // A guide that is constrained to match the frame of the last-tapped voice
// search button. // search button.
extern GuideName* const kVoiceSearchButtonGuide; extern GuideName* const kVoiceSearchButtonGuide;
// A guide that is constrained to match the frame of the Discover feed header's
// top-level menu button.
extern GuideName* const kDiscoverFeedHeaderMenuGuide;
#endif // IOS_CHROME_BROWSER_UI_UTIL_LAYOUT_GUIDE_NAMES_H_ #endif // IOS_CHROME_BROWSER_UI_UTIL_LAYOUT_GUIDE_NAMES_H_
...@@ -26,3 +26,4 @@ GuideName* const kToolsMenuGuide = @"kToolsMenuGuide"; ...@@ -26,3 +26,4 @@ GuideName* const kToolsMenuGuide = @"kToolsMenuGuide";
GuideName* const kTranslateInfobarOptionsGuide = GuideName* const kTranslateInfobarOptionsGuide =
@"kTranslateInfobarOptionsGuide"; @"kTranslateInfobarOptionsGuide";
GuideName* const kVoiceSearchButtonGuide = @"kVoiceSearchButtonGuide"; GuideName* const kVoiceSearchButtonGuide = @"kVoiceSearchButtonGuide";
GuideName* const kDiscoverFeedHeaderMenuGuide = @"kDiscoverFeedHeaderMenuGuide";
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