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

Unified Diff: ios/chrome/browser/ui/settings/compose_email_handler_collection_view_controller.mm

Issue 2889183005: Show all mailto: handlers, but dim unavailable ones. (Closed)
Patch Set: add deps Created 3 years, 7 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: ios/chrome/browser/ui/settings/compose_email_handler_collection_view_controller.mm
diff --git a/ios/chrome/browser/ui/settings/compose_email_handler_collection_view_controller.mm b/ios/chrome/browser/ui/settings/compose_email_handler_collection_view_controller.mm
index 71010f36ccdaf758b63926738c54d99894ddb2e5..a7652498cf6d6cb2337c754c0e27ae3b33c4c424 100644
--- a/ios/chrome/browser/ui/settings/compose_email_handler_collection_view_controller.mm
+++ b/ios/chrome/browser/ui/settings/compose_email_handler_collection_view_controller.mm
@@ -6,6 +6,7 @@
#include "base/mac/foundation_util.h"
#import "ios/chrome/browser/ui/collection_view/cells/collection_view_text_item.h"
+#import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.h"
rohitrao (ping after 24h) 2017/05/22 12:50:37 If all you need is greyColor, you should be able t
pkl (ping after 24h if needed) 2017/05/22 20:27:09 Thanks! Makes sense.
#import "ios/chrome/browser/web/mailto_handler.h"
#import "ios/chrome/browser/web/mailto_url_rewriter.h"
#include "ios/chrome/grit/ios_strings.h"
@@ -56,13 +57,18 @@ typedef NS_ENUM(NSInteger, ItemType) {
// choice available to the user. If this UI is being presented when there is
// only one choice, it is considered a software error.
NSArray<MailtoHandler*>* handlers = [_rewriter defaultHandlers];
- DCHECK([handlers count] > 1);
NSString* currentHandlerID = [_rewriter defaultHandlerID];
for (MailtoHandler* handler in handlers) {
CollectionViewTextItem* item =
[[CollectionViewTextItem alloc] initWithType:ItemTypeMailtoHandlers];
[item setText:[handler appName]];
- [item setAccessibilityTraits:UIAccessibilityTraitButton];
+ if ([handler isAvailable]) {
+ [item setTextColor:[[MDCPalette greyPalette] tint900]];
+ [item setAccessibilityTraits:UIAccessibilityTraitButton];
+ } else {
+ [item setTextColor:[[MDCPalette greyPalette] tint500]];
+ [item setAccessibilityTraits:UIAccessibilityTraitNotEnabled];
+ }
if ([currentHandlerID isEqualToString:[handler appStoreID]])
[item setAccessoryType:MDCCollectionViewCellAccessoryCheckmark];
[model addItem:item
@@ -87,6 +93,13 @@ typedef NS_ENUM(NSInteger, ItemType) {
if (selectedItem.accessoryType == MDCCollectionViewCellAccessoryCheckmark)
return;
+ // Do nothing if the handler for the tapped row is not available.
rohitrao (ping after 24h) 2017/05/22 12:50:37 Consider handling this in shouldSelectItemAtIndexP
pkl (ping after 24h if needed) 2017/05/22 20:27:09 Added shouldSelectItemAtIndexPath:, however it doe
+ NSUInteger handlerIndex = [model indexInItemTypeForIndexPath:indexPath];
+ MailtoHandler* handler =
+ [[_rewriter defaultHandlers] objectAtIndex:handlerIndex];
+ if (![handler isAvailable])
+ return;
+
// Iterate through the rows and remove the checkmark from any that has it.
NSMutableArray* modifiedItems = [NSMutableArray array];
for (id item in
@@ -106,9 +119,6 @@ typedef NS_ENUM(NSInteger, ItemType) {
}
}
- NSUInteger handlerIndex = [model indexInItemTypeForIndexPath:indexPath];
- MailtoHandler* handler =
- [[_rewriter defaultHandlers] objectAtIndex:handlerIndex];
[_rewriter setDefaultHandlerID:[handler appStoreID]];
[self reconfigureCellsForItems:modifiedItems];

Powered by Google App Engine
This is Rietveld 408576698