Commit b74b9644 authored by Justin Cohen's avatar Justin Cohen Committed by Commit Bot

[ios] Remove forward swipe for reading list.

Bug: 909724
Change-Id: I24c3341ca5245d599ce43cba8b17c164e38e3618
Reviewed-on: https://chromium-review.googlesource.com/c/1354414
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Reviewed-by: default avatarOlivier Robin <olivierrobin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#612291}
parent 343df2ec
...@@ -20,8 +20,6 @@ source_set("reading_list") { ...@@ -20,8 +20,6 @@ source_set("reading_list") {
"reading_list_menu_notification_delegate.h", "reading_list_menu_notification_delegate.h",
"reading_list_menu_notifier.h", "reading_list_menu_notifier.h",
"reading_list_menu_notifier.mm", "reading_list_menu_notifier.mm",
"reading_list_side_swipe_provider.h",
"reading_list_side_swipe_provider.mm",
"reading_list_table_view_item.h", "reading_list_table_view_item.h",
"reading_list_table_view_item.mm", "reading_list_table_view_item.mm",
"reading_list_utils.h", "reading_list_utils.h",
...@@ -97,7 +95,6 @@ source_set("reading_list_ui") { ...@@ -97,7 +95,6 @@ source_set("reading_list_ui") {
deps = [ deps = [
"resources:reading_list_empty_state", "resources:reading_list_empty_state",
"resources:reading_list_empty_state_new", "resources:reading_list_empty_state_new",
"resources:reading_list_side_swipe",
"resources:reading_list_tools_icon", "resources:reading_list_tools_icon",
"//base", "//base",
"//base:i18n", "//base:i18n",
......
// Copyright 2016 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.
#ifndef IOS_CHROME_BROWSER_UI_READING_LIST_READING_LIST_SIDE_SWIPE_PROVIDER_H_
#define IOS_CHROME_BROWSER_UI_READING_LIST_READING_LIST_SIDE_SWIPE_PROVIDER_H_
#import "ios/chrome/browser/ui/side_swipe/side_swipe_controller.h"
class ReadingListModel;
@interface ReadingListSideSwipeProvider : NSObject<SideSwipeContentProvider>
- (instancetype)initWithReadingList:(ReadingListModel*)readingListModel;
@end
#endif // IOS_CHROME_BROWSER_UI_READING_LIST_READING_LIST_SIDE_SWIPE_PROVIDER_H_
// Copyright 2016 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.
#import "ios/chrome/browser/ui/reading_list/reading_list_side_swipe_provider.h"
#include "base/logging.h"
#include "base/metrics/user_metrics.h"
#include "base/metrics/user_metrics_action.h"
#include "components/reading_list/core/reading_list_entry.h"
#include "components/reading_list/core/reading_list_model.h"
#include "ios/chrome/browser/browser_state/chrome_browser_state.h"
#import "ios/chrome/browser/metrics/new_tab_page_uma.h"
#include "ios/web/public/web_state/web_state.h"
#include "net/base/network_change_notifier.h"
#include "url/gurl.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
class ReadingListObserverBridge;
@interface ReadingListSideSwipeProvider () {
// Keep a reference to detach before deallocing.
ReadingListModel* _readingListModel; // weak
}
@end
@implementation ReadingListSideSwipeProvider
- (instancetype)initWithReadingList:(ReadingListModel*)readingListModel {
if (self = [super init]) {
_readingListModel = readingListModel;
}
return self;
}
- (BOOL)canGoBack {
return NO;
}
- (void)goBack:(web::WebState*)webState {
NOTREACHED();
}
- (BOOL)canGoForward {
return _readingListModel->unread_size() > 0;
}
- (UIImage*)paneIcon {
return [UIImage imageNamed:@"reading_list_side_swipe"];
}
- (BOOL)rotateForwardIcon {
return NO;
}
- (void)goForward:(web::WebState*)webState {
if (!webState || _readingListModel->unread_size() == 0) {
return;
}
const ReadingListEntry* firstEntry = _readingListModel->GetFirstUnreadEntry(
net::NetworkChangeNotifier::IsOffline());
DCHECK(firstEntry);
base::RecordAction(base::UserMetricsAction("MobileReadingListOpen"));
new_tab_page_uma::RecordAction(
ios::ChromeBrowserState::FromBrowserState(webState->GetBrowserState()),
new_tab_page_uma::ACTION_OPENED_READING_LIST_ENTRY);
web::NavigationManager::WebLoadParams params(firstEntry->URL());
params.transition_type = ui::PageTransition::PAGE_TRANSITION_AUTO_BOOKMARK;
webState->GetNavigationManager()->LoadURLWithParams(params);
}
@end
...@@ -31,15 +31,6 @@ imageset("reading_list_empty_state_new") { ...@@ -31,15 +31,6 @@ imageset("reading_list_empty_state_new") {
] ]
} }
imageset("reading_list_side_swipe") {
sources = [
"reading_list_side_swipe.imageset/Contents.json",
"reading_list_side_swipe.imageset/reading_list_side_swipe.png",
"reading_list_side_swipe.imageset/reading_list_side_swipe@2x.png",
"reading_list_side_swipe.imageset/reading_list_side_swipe@3x.png",
]
}
imageset("reading_list_tools_icon") { imageset("reading_list_tools_icon") {
sources = [ sources = [
"reading_list_tools_icon.imageset/Contents.json", "reading_list_tools_icon.imageset/Contents.json",
......
{
"images": [
{
"idiom": "universal",
"scale": "1x",
"filename": "reading_list_side_swipe.png"
},
{
"idiom": "universal",
"scale": "2x",
"filename": "reading_list_side_swipe@2x.png"
},
{
"idiom": "universal",
"scale": "3x",
"filename": "reading_list_side_swipe@3x.png"
}
],
"info": {
"version": 1,
"author": "xcode"
}
}
...@@ -7,8 +7,6 @@ source_set("side_swipe") { ...@@ -7,8 +7,6 @@ source_set("side_swipe") {
sources = [ sources = [
"card_side_swipe_view.h", "card_side_swipe_view.h",
"card_side_swipe_view.mm", "card_side_swipe_view.mm",
"history_side_swipe_provider.h",
"history_side_swipe_provider.mm",
"side_swipe_controller.h", "side_swipe_controller.h",
"side_swipe_controller.mm", "side_swipe_controller.mm",
"side_swipe_navigation_view.h", "side_swipe_navigation_view.h",
......
// Copyright 2016 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.
#ifndef IOS_CHROME_BROWSER_UI_SIDE_SWIPE_HISTORY_SIDE_SWIPE_PROVIDER_H_
#define IOS_CHROME_BROWSER_UI_SIDE_SWIPE_HISTORY_SIDE_SWIPE_PROVIDER_H_
#import "ios/chrome/browser/ui/side_swipe/side_swipe_controller.h"
@class TabModel;
@interface HistorySideSwipeProvider : NSObject<SideSwipeContentProvider>
- (instancetype)initWithTabModel:(TabModel*)tabModel;
@end
#endif // IOS_CHROME_BROWSER_UI_SIDE_SWIPE_HISTORY_SIDE_SWIPE_PROVIDER_H_
// Copyright 2016 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.
#import "ios/chrome/browser/ui/side_swipe/history_side_swipe_provider.h"
#include "ios/chrome/browser/tabs/tab.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
@interface HistorySideSwipeProvider () {
// Keep a reference to detach before deallocing.
__weak TabModel* _tabModel; // weak
}
@end
@implementation HistorySideSwipeProvider
- (instancetype)initWithTabModel:(TabModel*)tabModel {
self = [super init];
if (self) {
_tabModel = tabModel;
}
return self;
}
- (BOOL)canGoBack {
return [[_tabModel currentTab] canGoBack];
}
- (BOOL)canGoForward {
return [[_tabModel currentTab] canGoForward];
}
- (void)goForward:(web::WebState*)webState {
[[_tabModel currentTab] goForward];
}
- (void)goBack:(web::WebState*)webState {
[[_tabModel currentTab] goBack];
}
- (UIImage*)paneIcon {
return [UIImage imageNamed:@"side_swipe_navigation_back"];
}
- (BOOL)rotateForwardIcon {
return YES;
}
@end
...@@ -22,24 +22,6 @@ extern NSString* const kSideSwipeWillStartNotification; ...@@ -22,24 +22,6 @@ extern NSString* const kSideSwipeWillStartNotification;
// Notification sent when the user finishes a side swipe (on tablet). // Notification sent when the user finishes a side swipe (on tablet).
extern NSString* const kSideSwipeDidStopNotification; extern NSString* const kSideSwipeDidStopNotification;
// A protocol for the Side Swipe controller sources.
@protocol SideSwipeContentProvider
// Returns whether this source can provide content for a back/forward side swipe
// gesture.
- (BOOL)canGoBack;
- (BOOL)canGoForward;
// Called on completion of a back/forward gesture.
- (void)goBack:(web::WebState*)webState;
- (void)goForward:(web::WebState*)webState;
// The icon to display in the side panel.
- (UIImage*)paneIcon;
// Whether the icon is oriented and should be reflected on forward pane.
- (BOOL)rotateForwardIcon;
@end
@protocol SideSwipeControllerDelegate @protocol SideSwipeControllerDelegate
@required @required
// Called when the horizontal stack view is done and should be removed. // Called when the horizontal stack view is done and should be removed.
......
...@@ -9,9 +9,7 @@ ...@@ -9,9 +9,7 @@
#include "base/feature_list.h" #include "base/feature_list.h"
#import "base/ios/block_types.h" #import "base/ios/block_types.h"
#include "base/scoped_observer.h" #include "base/scoped_observer.h"
#include "components/reading_list/core/reading_list_model.h"
#import "ios/chrome/browser/browser_state/chrome_browser_state.h" #import "ios/chrome/browser/browser_state/chrome_browser_state.h"
#import "ios/chrome/browser/reading_list/reading_list_model_factory.h"
#import "ios/chrome/browser/snapshots/snapshot_cache.h" #import "ios/chrome/browser/snapshots/snapshot_cache.h"
#import "ios/chrome/browser/snapshots/snapshot_cache_factory.h" #import "ios/chrome/browser/snapshots/snapshot_cache_factory.h"
#import "ios/chrome/browser/snapshots/snapshot_tab_helper.h" #import "ios/chrome/browser/snapshots/snapshot_tab_helper.h"
...@@ -20,9 +18,7 @@ ...@@ -20,9 +18,7 @@
#import "ios/chrome/browser/ui/fullscreen/animated_scoped_fullscreen_disabler.h" #import "ios/chrome/browser/ui/fullscreen/animated_scoped_fullscreen_disabler.h"
#import "ios/chrome/browser/ui/fullscreen/fullscreen_controller_factory.h" #import "ios/chrome/browser/ui/fullscreen/fullscreen_controller_factory.h"
#import "ios/chrome/browser/ui/fullscreen/scoped_fullscreen_disabler.h" #import "ios/chrome/browser/ui/fullscreen/scoped_fullscreen_disabler.h"
#import "ios/chrome/browser/ui/reading_list/reading_list_side_swipe_provider.h"
#import "ios/chrome/browser/ui/side_swipe/card_side_swipe_view.h" #import "ios/chrome/browser/ui/side_swipe/card_side_swipe_view.h"
#import "ios/chrome/browser/ui/side_swipe/history_side_swipe_provider.h"
#import "ios/chrome/browser/ui/side_swipe/side_swipe_navigation_view.h" #import "ios/chrome/browser/ui/side_swipe/side_swipe_navigation_view.h"
#import "ios/chrome/browser/ui/side_swipe/side_swipe_util.h" #import "ios/chrome/browser/ui/side_swipe/side_swipe_util.h"
#import "ios/chrome/browser/ui/side_swipe_gesture_recognizer.h" #import "ios/chrome/browser/ui/side_swipe_gesture_recognizer.h"
...@@ -95,14 +91,6 @@ const NSUInteger kIpadGreySwipeTabCount = 8; ...@@ -95,14 +91,6 @@ const NSUInteger kIpadGreySwipeTabCount = 8;
// Curtain over web view while waiting for it to load. // Curtain over web view while waiting for it to load.
UIView* curtain_; UIView* curtain_;
// Provides forward/back action for history entries.
HistorySideSwipeProvider* historySideSwipeProvider_;
// Provides forward action for reading list.
ReadingListSideSwipeProvider* readingListSideSwipeProvider_;
__weak id<SideSwipeContentProvider> currentContentProvider_;
// The disabler that prevents the toolbar from being scrolled away when the // The disabler that prevents the toolbar from being scrolled away when the
// side swipe gesture is being recognized. // side swipe gesture is being recognized.
std::unique_ptr<ScopedFullscreenDisabler> fullscreenDisabler_; std::unique_ptr<ScopedFullscreenDisabler> fullscreenDisabler_;
...@@ -156,13 +144,6 @@ const NSUInteger kIpadGreySwipeTabCount = 8; ...@@ -156,13 +144,6 @@ const NSUInteger kIpadGreySwipeTabCount = 8;
if (self) { if (self) {
model_ = model; model_ = model;
[model_ addObserver:self]; [model_ addObserver:self];
historySideSwipeProvider_ =
[[HistorySideSwipeProvider alloc] initWithTabModel:model_];
readingListSideSwipeProvider_ = [[ReadingListSideSwipeProvider alloc]
initWithReadingList:ReadingListModelFactory::GetForBrowserState(
browserState)];
webStateObserverBridge_ = webStateObserverBridge_ =
std::make_unique<web::WebStateObserverBridge>(self); std::make_unique<web::WebStateObserverBridge>(self);
scopedWebStateObserver_ = scopedWebStateObserver_ =
...@@ -424,20 +405,14 @@ const NSUInteger kIpadGreySwipeTabCount = 8; ...@@ -424,20 +405,14 @@ const NSUInteger kIpadGreySwipeTabCount = 8;
} }
} }
- (id<SideSwipeContentProvider>)contentProviderForGesture:(BOOL)goBack { - (BOOL)canNavigate:(BOOL)goBack {
if (goBack && [historySideSwipeProvider_ canGoBack]) { if (goBack && [[model_ currentTab] canGoBack]) {
return historySideSwipeProvider_; return YES;
}
if (!goBack && [historySideSwipeProvider_ canGoForward]) {
return historySideSwipeProvider_;
}
if (goBack && [readingListSideSwipeProvider_ canGoBack]) {
return readingListSideSwipeProvider_;
} }
if (!goBack && [readingListSideSwipeProvider_ canGoForward]) { if (!goBack && [[model_ currentTab] canGoForward]) {
return readingListSideSwipeProvider_; return YES;
} }
return nil; return NO;
} }
// Show swipe to navigate. // Show swipe to navigate.
...@@ -454,9 +429,6 @@ const NSUInteger kIpadGreySwipeTabCount = 8; ...@@ -454,9 +429,6 @@ const NSUInteger kIpadGreySwipeTabCount = 8;
[swipeDelegate_ updateAccessoryViewsForSideSwipeWithVisibility:NO]; [swipeDelegate_ updateAccessoryViewsForSideSwipeWithVisibility:NO];
BOOL goBack = IsSwipingBack(gesture.direction); BOOL goBack = IsSwipingBack(gesture.direction);
currentContentProvider_ = [self contentProviderForGesture:goBack];
BOOL canNavigate = currentContentProvider_ != nil;
CGRect gestureBounds = gesture.view.bounds; CGRect gestureBounds = gesture.view.bounds;
CGFloat headerHeight = [swipeDelegate_ headerHeightForSideSwipe]; CGFloat headerHeight = [swipeDelegate_ headerHeightForSideSwipe];
CGRect navigationFrame = CGRect navigationFrame =
...@@ -468,9 +440,8 @@ const NSUInteger kIpadGreySwipeTabCount = 8; ...@@ -468,9 +440,8 @@ const NSUInteger kIpadGreySwipeTabCount = 8;
pageSideSwipeView_ = [[SideSwipeNavigationView alloc] pageSideSwipeView_ = [[SideSwipeNavigationView alloc]
initWithFrame:navigationFrame initWithFrame:navigationFrame
withDirection:gesture.direction withDirection:gesture.direction
canNavigate:canNavigate canNavigate:[self canNavigate:goBack]
image:[currentContentProvider_ paneIcon] image:[UIImage imageNamed:@"side_swipe_navigation_back"]];
rotateForward:[currentContentProvider_ rotateForwardIcon]];
[pageSideSwipeView_ setTargetView:[swipeDelegate_ sideSwipeContentView]]; [pageSideSwipeView_ setTargetView:[swipeDelegate_ sideSwipeContentView]];
[gesture.view insertSubview:pageSideSwipeView_ [gesture.view insertSubview:pageSideSwipeView_
...@@ -489,9 +460,9 @@ const NSUInteger kIpadGreySwipeTabCount = 8; ...@@ -489,9 +460,9 @@ const NSUInteger kIpadGreySwipeTabCount = 8;
BOOL wantsBack = IsSwipingBack(gesture.direction); BOOL wantsBack = IsSwipingBack(gesture.direction);
web::WebState* webState = [weakCurrentTab webState]; web::WebState* webState = [weakCurrentTab webState];
if (wantsBack) { if (wantsBack) {
[currentContentProvider_ goBack:webState]; [[model_ currentTab] goBack];
} else { } else {
[currentContentProvider_ goForward:webState]; [[model_ currentTab] goForward];
} }
// Checking -IsLoading() is likely incorrect, but to narrow the scope of // Checking -IsLoading() is likely incorrect, but to narrow the scope of
......
...@@ -19,8 +19,7 @@ ...@@ -19,8 +19,7 @@
- (instancetype)initWithFrame:(CGRect)frame - (instancetype)initWithFrame:(CGRect)frame
withDirection:(UISwipeGestureRecognizerDirection)direction withDirection:(UISwipeGestureRecognizerDirection)direction
canNavigate:(BOOL)canNavigate canNavigate:(BOOL)canNavigate
image:(UIImage*)image image:(UIImage*)image;
rotateForward:(BOOL)rotateForward;
// Update views for latest gesture, and call completion blocks whether // Update views for latest gesture, and call completion blocks whether
// |threshold| is met. // |threshold| is met.
......
...@@ -81,10 +81,6 @@ const CGFloat kSelectionAnimationDuration = 0.5; ...@@ -81,10 +81,6 @@ const CGFloat kSelectionAnimationDuration = 0.5;
// If |NO| this is an edge gesture and navigation isn't possible. Don't show // If |NO| this is an edge gesture and navigation isn't possible. Don't show
// arrows and bubbles and don't allow navigate. // arrows and bubbles and don't allow navigate.
BOOL canNavigate_; BOOL canNavigate_;
// If |YES| arrowView_ is directionnal and must be rotated 180 degreed for the
// forward panes.
BOOL rotateForward_;
} }
// Returns a newly allocated and configured selection circle shape. // Returns a newly allocated and configured selection circle shape.
- (CAShapeLayer*)newSelectionCircleLayer; - (CAShapeLayer*)newSelectionCircleLayer;
...@@ -100,14 +96,12 @@ const CGFloat kSelectionAnimationDuration = 0.5; ...@@ -100,14 +96,12 @@ const CGFloat kSelectionAnimationDuration = 0.5;
- (instancetype)initWithFrame:(CGRect)frame - (instancetype)initWithFrame:(CGRect)frame
withDirection:(UISwipeGestureRecognizerDirection)direction withDirection:(UISwipeGestureRecognizerDirection)direction
canNavigate:(BOOL)canNavigate canNavigate:(BOOL)canNavigate
image:(UIImage*)image image:(UIImage*)image {
rotateForward:(BOOL)rotateForward {
self = [super initWithFrame:frame]; self = [super initWithFrame:frame];
if (self) { if (self) {
self.backgroundColor = [UIColor colorWithWhite:90.0 / 256 alpha:1.0]; self.backgroundColor = [UIColor colorWithWhite:90.0 / 256 alpha:1.0];
canNavigate_ = canNavigate; canNavigate_ = canNavigate;
rotateForward_ = rotateForward;
if (canNavigate) { if (canNavigate) {
image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
const CGRect imageSize = CGRectMake(0, 0, 24, 24); const CGRect imageSize = CGRectMake(0, 0, 24, 24);
...@@ -188,13 +182,8 @@ const CGFloat kSelectionAnimationDuration = 0.5; ...@@ -188,13 +182,8 @@ const CGFloat kSelectionAnimationDuration = 0.5;
CGFloat rotationStart = -CGFloat(base::kPiDouble) / 2; CGFloat rotationStart = -CGFloat(base::kPiDouble) / 2;
CGFloat rotationEnd = 0; CGFloat rotationEnd = 0;
if (gesture.direction == UISwipeGestureRecognizerDirectionLeft) { if (gesture.direction == UISwipeGestureRecognizerDirectionLeft) {
if (rotateForward_) { rotationStart = CGFloat(base::kPiDouble) * 1.5;
rotationStart = CGFloat(base::kPiDouble) * 1.5; rotationEnd = CGFloat(base::kPiDouble);
rotationEnd = CGFloat(base::kPiDouble);
} else {
rotationStart = CGFloat(base::kPiDouble) / 2;
rotationEnd = 0;
}
} }
CGAffineTransform rotation = CGAffineTransformMakeRotation(MapValueToRange( CGAffineTransform rotation = CGAffineTransformMakeRotation(MapValueToRange(
{0, kArrowThreshold}, {rotationStart, rotationEnd}, distance)); {0, kArrowThreshold}, {rotationStart, rotationEnd}, distance));
......
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