Commit c94239ba authored by Javier Ernesto Flores Robles's avatar Javier Ernesto Flores Robles Committed by Commit Bot

[iOS][MF] Adjusts tintAdjustmentMode

This change is made so the buttons keep the color on iPads when the
popovers are presented.

Bug: 845472
Change-Id: I7ce4d410bd66a5aa0dc1c1258914df493d3ac1db
Reviewed-on: https://chromium-review.googlesource.com/c/1352154Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Commit-Queue: Javier Ernesto Flores Robles <javierrobles@chromium.org>
Cr-Commit-Position: refs/heads/master@{#611132}
parent 98975b53
...@@ -109,75 +109,79 @@ static NSTimeInterval MFAnimationDuration = 0.2; ...@@ -109,75 +109,79 @@ static NSTimeInterval MFAnimationDuration = 0.2;
#pragma mark - Private #pragma mark - Private
// Helper to create a system button with the passed data and |self| as the
// target. Such button has been configured to have some preset properties
- (UIButton*)manualFillButtonWithAction:(SEL)selector
ImageNamed:(NSString*)imageName
accessibilityIdentifier:(NSString*)accessibilityIdentifier
accessibilityLabel:(NSString*)accessibilityLabel {
UIButton* button = [UIButton buttonWithType:UIButtonTypeSystem];
UIImage* image = [UIImage imageNamed:imageName];
[button setImage:image forState:UIControlStateNormal];
button.tintColor = [self activeTintColor];
button.translatesAutoresizingMaskIntoConstraints = NO;
[button addTarget:self
action:selector
forControlEvents:UIControlEventTouchUpInside];
button.accessibilityIdentifier = accessibilityIdentifier;
button.accessibilityLabel = accessibilityLabel;
button.tintAdjustmentMode = UIViewTintAdjustmentModeNormal;
return button;
}
- (void)loadView { - (void)loadView {
self.view = [[UIView alloc] init]; self.view = [[UIView alloc] init];
self.view.accessibilityViewIsModal = YES; self.view.accessibilityViewIsModal = YES;
self.view.translatesAutoresizingMaskIntoConstraints = NO; self.view.translatesAutoresizingMaskIntoConstraints = NO;
UIColor* tintColor = [self activeTintColor];
NSMutableArray<UIView*>* icons = [[NSMutableArray alloc] init]; NSMutableArray<UIView*>* icons = [[NSMutableArray alloc] init];
if (!IsIPadIdiom()) { if (!IsIPadIdiom()) {
self.keyboardButton = [UIButton buttonWithType:UIButtonTypeSystem]; self.keyboardButton = [self
UIImage* keyboardImage = [UIImage imageNamed:@"mf_keyboard"]; manualFillButtonWithAction:@selector(keyboardButtonPressed)
[self.keyboardButton setImage:keyboardImage forState:UIControlStateNormal]; ImageNamed:@"mf_keyboard"
self.keyboardButton.tintColor = tintColor; accessibilityIdentifier:manual_fill::
self.keyboardButton.translatesAutoresizingMaskIntoConstraints = NO; AccessoryKeyboardAccessibilityIdentifier
[self.keyboardButton addTarget:self accessibilityLabel:l10n_util::GetNSString(
action:@selector(keyboardButtonPressed) IDS_IOS_MANUAL_FALLBACK_SHOW_KEYBOARD)];
forControlEvents:UIControlEventTouchUpInside];
self.keyboardButton.accessibilityIdentifier =
manual_fill::AccessoryKeyboardAccessibilityIdentifier;
self.keyboardButton.accessibilityLabel =
l10n_util::GetNSString(IDS_IOS_MANUAL_FALLBACK_SHOW_KEYBOARD);
[icons addObject:self.keyboardButton]; [icons addObject:self.keyboardButton];
self.keyboardButton.hidden = YES;
self.keyboardButton.alpha = 0.0;
} }
self.passwordButton = [UIButton buttonWithType:UIButtonTypeSystem]; self.passwordButton = [self
UIImage* keyImage = [UIImage imageNamed:@"ic_vpn_key"]; manualFillButtonWithAction:@selector(passwordButtonPressed:)
[self.passwordButton setImage:keyImage forState:UIControlStateNormal]; ImageNamed:@"ic_vpn_key"
self.passwordButton.tintColor = tintColor; accessibilityIdentifier:manual_fill::
self.passwordButton.translatesAutoresizingMaskIntoConstraints = NO; AccessoryPasswordAccessibilityIdentifier
[self.passwordButton addTarget:self accessibilityLabel:l10n_util::GetNSString(
action:@selector(passwordButtonPressed:) IDS_IOS_MANUAL_FALLBACK_SHOW_PASSWORDS)];
forControlEvents:UIControlEventTouchUpInside];
self.passwordButton.accessibilityIdentifier =
manual_fill::AccessoryPasswordAccessibilityIdentifier;
self.passwordButton.hidden = self.isPasswordButtonHidden; self.passwordButton.hidden = self.isPasswordButtonHidden;
self.passwordButton.contentEdgeInsets = UIEdgeInsetsMake(0, 2, 0, 2); self.passwordButton.contentEdgeInsets = UIEdgeInsetsMake(0, 2, 0, 2);
self.passwordButton.accessibilityLabel =
l10n_util::GetNSString(IDS_IOS_MANUAL_FALLBACK_SHOW_PASSWORDS);
[icons addObject:self.passwordButton]; [icons addObject:self.passwordButton];
if (autofill::features::IsAutofillManualFallbackEnabled()) { if (autofill::features::IsAutofillManualFallbackEnabled()) {
self.cardsButton = [UIButton buttonWithType:UIButtonTypeSystem]; self.cardsButton =
UIImage* cardImage = [UIImage imageNamed:@"ic_credit_card"]; [self manualFillButtonWithAction:@selector(cardButtonPressed:)
[self.cardsButton setImage:cardImage forState:UIControlStateNormal]; ImageNamed:@"ic_credit_card"
self.cardsButton.tintColor = tintColor; accessibilityIdentifier:
self.cardsButton.translatesAutoresizingMaskIntoConstraints = NO; manual_fill::AccessoryCreditCardAccessibilityIdentifier
[self.cardsButton addTarget:self accessibilityLabel:
action:@selector(cardButtonPressed:) l10n_util::GetNSString(
forControlEvents:UIControlEventTouchUpInside]; IDS_IOS_MANUAL_FALLBACK_SHOW_CREDIT_CARDS)];
self.cardsButton.accessibilityIdentifier =
manual_fill::AccessoryCreditCardAccessibilityIdentifier;
self.cardsButton.hidden = self.isCreditCardButtonHidden; self.cardsButton.hidden = self.isCreditCardButtonHidden;
self.cardsButton.accessibilityLabel =
l10n_util::GetNSString(IDS_IOS_MANUAL_FALLBACK_SHOW_CREDIT_CARDS);
[icons addObject:self.cardsButton]; [icons addObject:self.cardsButton];
self.accountButton = [UIButton buttonWithType:UIButtonTypeSystem]; self.accountButton = [self
UIImage* accountImage = [UIImage imageNamed:@"ic_place"]; manualFillButtonWithAction:@selector(accountButtonPressed:)
[self.accountButton setImage:accountImage forState:UIControlStateNormal]; ImageNamed:@"ic_place"
self.accountButton.tintColor = tintColor; accessibilityIdentifier:manual_fill::
self.accountButton.translatesAutoresizingMaskIntoConstraints = NO; AccessoryAddressAccessibilityIdentifier
[self.accountButton addTarget:self accessibilityLabel:l10n_util::GetNSString(
action:@selector(accountButtonPressed:) IDS_IOS_MANUAL_FALLBACK_SHOW_ADDRESSES)];
forControlEvents:UIControlEventTouchUpInside];
self.accountButton.accessibilityIdentifier =
manual_fill::AccessoryAddressAccessibilityIdentifier;
self.accountButton.hidden = self.isAddressButtonHidden; self.accountButton.hidden = self.isAddressButtonHidden;
self.accountButton.accessibilityLabel =
l10n_util::GetNSString(IDS_IOS_MANUAL_FALLBACK_SHOW_ADDRESSES);
[icons addObject:self.accountButton]; [icons addObject:self.accountButton];
} }
UIStackView* stackView = [[UIStackView alloc] initWithArrangedSubviews:icons]; UIStackView* stackView = [[UIStackView alloc] initWithArrangedSubviews:icons];
...@@ -200,8 +204,6 @@ static NSTimeInterval MFAnimationDuration = 0.2; ...@@ -200,8 +204,6 @@ static NSTimeInterval MFAnimationDuration = 0.2;
constraintEqualToAnchor:stackView.trailingAnchor constraintEqualToAnchor:stackView.trailingAnchor
constant:ManualFillIconsRightInset], constant:ManualFillIconsRightInset],
]]; ]];
self.keyboardButton.hidden = YES;
self.keyboardButton.alpha = 0.0;
} }
// Resets the colors of all the icons to the active color. // Resets the colors of all the icons to the active color.
......
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