Skip to content
This repository has been archived by the owner on May 6, 2024. It is now read-only.

Commit

Permalink
Update account creation legal statement (#1101)
Browse files Browse the repository at this point in the history
* LEARNER-4934- Agreement Text update
  • Loading branch information
Zeshan Arif authored and salman2013 committed Apr 27, 2018
1 parent 9d43338 commit 5b78cf5
Show file tree
Hide file tree
Showing 22 changed files with 6,383 additions and 4,003 deletions.
63 changes: 63 additions & 0 deletions Source/AgreementTextView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
//
// AgreementTextView.swift
// edX
//
// Created by Zeeshan Arif on 4/25/18.
// Copyright © 2018 edX. All rights reserved.
//

import UIKit

@objc enum AgreementType: UInt {
case signIn,
signUp
}

@objc protocol AgreementTextViewDelegate: class {
func agreementTextView(_ textView: AgreementTextView, didSelect url: URL)
}

class AgreementTextView: UITextView {

weak var agreementDelegate: AgreementTextViewDelegate?

@objc func setup(for type: AgreementType) {
let style = OEXMutableTextStyle(weight: .normal, size: .xSmall, color: OEXStyles.shared().neutralDark())
style.lineBreakMode = .byWordWrapping
style.alignment = .center
let platformName = OEXConfig.shared().platformName()
let prefix: String
switch type {
case .signIn:
prefix = Strings.Agreement.textPrefixSignin
break
case .signUp:
prefix = Strings.Agreement.textPrefixSignup
break
}
let eulaText = Strings.Agreement.linkTextEula(platformName: platformName)
let tosText = Strings.Agreement.linkTextTos(platformName: platformName)
let privacyPolicyText = Strings.Agreement.linkTextPrivacyPolicy
let agreementText = "\(prefix)\(Strings.Agreement.text(eula: eulaText, tos: tosText, privacyPolicy: privacyPolicyText))"
var attributedString = style.attributedString(withText: agreementText)
if let eulaUrl = Bundle.main.url(forResource: "MobileAppEula", withExtension: "htm"),
let tosUrl = Bundle.main.url(forResource: "TermsOfServices", withExtension: "htm"),
let privacyPolicyUrl = Bundle.main.url(forResource: "PrivacyPolicy", withExtension: "htm") {
attributedString = attributedString.addLink(on: eulaText, value: eulaUrl)
attributedString = attributedString.addLink(on: tosText, value: tosUrl)
attributedString = attributedString.addLink(on: privacyPolicyText, value: privacyPolicyUrl)
}
attributedText = attributedString
isUserInteractionEnabled = true
isScrollEnabled = false
isEditable = false
delegate = self
}
}

extension AgreementTextView: UITextViewDelegate {
func textView(_ textView: UITextView, shouldInteractWith URL: URL, in characterRange: NSRange) -> Bool {
agreementDelegate?.agreementTextView(self, didSelect: URL)
return false
}
}
452 changes: 0 additions & 452 deletions Source/COURSE_NOT_LISTED.htm

This file was deleted.

932 changes: 0 additions & 932 deletions Source/EULA.htm

This file was deleted.

1,008 changes: 1,008 additions & 0 deletions Source/MobileAppEula.htm

Large diffs are not rendered by default.

458 changes: 0 additions & 458 deletions Source/NEW_USER.htm

This file was deleted.

17 changes: 17 additions & 0 deletions Source/NSAttributedString+Formatting.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,23 @@

import Foundation

extension NSAttributedString {
func addLink(on subString: String, value: URL) -> NSAttributedString {
if string.contains(find: subString) {
let mutableAttributedString = NSMutableAttributedString(attributedString: self)
let range = (string as NSString).range(of: subString)
let attributes = [
NSLinkAttributeName: value,
NSForegroundColorAttributeName: OEXStyles.shared().primaryBaseColor()
] as [String : Any]
mutableAttributedString.addAttributes(attributes, range: range)
return mutableAttributedString
}

return self
}
}

extension OEXTextStyle {

func apply(f : @escaping (String) -> String) -> ((NSAttributedString) -> NSAttributedString) {
Expand Down
106 changes: 20 additions & 86 deletions Source/OEXLoginViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,10 @@
@import edXCore;

#import "OEXLoginViewController.h"

#import "edX-Swift.h"

#import <Masonry/Masonry.h>

#import "NSString+OEXValidation.h"
#import "NSJSONSerialization+OEXSafeAccess.h"

#import "OEXAnalytics.h"
#import "OEXAppDelegate.h"
#import "OEXCustomButton.h"
Expand All @@ -40,7 +36,7 @@

#define USER_EMAIL @"USERNAME"

@interface OEXLoginViewController ()
@interface OEXLoginViewController () <AgreementTextViewDelegate>
{
CGPoint originalOffset; // store the offset of the scrollview.
UITextField* activeField; // assign textfield object which is in active state.
Expand All @@ -50,9 +46,6 @@ @interface OEXLoginViewController ()
@property (nonatomic, strong) NSString* signInID;
@property (nonatomic, strong) NSString* signInPassword;
@property (nonatomic, assign) BOOL reachable;
@property (weak, nonatomic, nullable) IBOutlet UIWebView* webview_EULA;
@property (weak, nonatomic, nullable) IBOutlet UIButton* btn_OpenEULA;
@property (weak, nonatomic, nullable) IBOutlet UIImageView* img_SeparatorEULA;
@property (strong, nonatomic) IBOutlet UIView* externalAuthContainer;
@property (weak, nonatomic, nullable) IBOutlet OEXCustomLabel* lbl_OrSignIn;
@property(nonatomic, strong) IBOutlet UIImageView* seperatorLeft;
Expand All @@ -62,16 +55,8 @@ @interface OEXLoginViewController ()
@property (weak, nonatomic, nullable) IBOutlet NSLayoutConstraint* constraint_MapTop;
@property (weak, nonatomic, nullable) IBOutlet NSLayoutConstraint* constraint_UsernameTop;
@property (weak, nonatomic, nullable) IBOutlet NSLayoutConstraint* constraint_PasswordTop;
@property (weak, nonatomic, nullable) IBOutlet NSLayoutConstraint* constraint_ForgotTop;
@property (weak, nonatomic, nullable) IBOutlet NSLayoutConstraint* constraint_SignInTop;
@property (weak, nonatomic, nullable) IBOutlet NSLayoutConstraint* constraint_SignTop;
@property (weak, nonatomic, nullable) IBOutlet NSLayoutConstraint* constraint_separatorTop;
@property (weak, nonatomic, nullable) IBOutlet NSLayoutConstraint* constraint_BySigningTop;
@property (weak, nonatomic, nullable) IBOutlet NSLayoutConstraint* constraint_EULATop;
@property (weak, nonatomic, nullable) IBOutlet NSLayoutConstraint* constraint_UserGreyTop;
@property (weak, nonatomic, nullable) IBOutlet NSLayoutConstraint* constraint_PassGreyTop;
@property (weak, nonatomic, nullable) IBOutlet NSLayoutConstraint* constraint_LeftSepTop;
@property (weak, nonatomic, nullable) IBOutlet NSLayoutConstraint* constraint_RightSepTop;
@property (weak, nonatomic, nullable) IBOutlet NSLayoutConstraint* constraint_ActivityIndTop;

@property (weak, nonatomic, nullable) IBOutlet UITextField* tf_EmailID;
Expand All @@ -81,14 +66,13 @@ @interface OEXLoginViewController ()
@property (weak, nonatomic, nullable) IBOutlet UIScrollView* scroll_Main;
@property (weak, nonatomic, nullable) IBOutlet UIImageView* img_Map;
@property (weak, nonatomic, nullable) IBOutlet UIImageView* img_Logo;
@property (weak, nonatomic, nullable) IBOutlet UILabel* lbl_Redirect;
@property (weak, nonatomic) IBOutlet AgreementTextView *agreementTextView;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *agreementTextViewHeight;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *agreementTextViewTop;
@property (weak, nonatomic, nullable) IBOutlet UIActivityIndicatorView* activityIndicator;
@property (strong, nonatomic) IBOutlet UILabel* versionLabel;

@property (nonatomic, assign) id <OEXExternalAuthProvider> authProvider;
@property (nonatomic) OEXTextStyle *placeHolderStyle;
@property (nonatomic) OEXMutableTextStyle *buttonsTitleStyle;


@end

Expand All @@ -99,6 +83,7 @@ - (void)layoutSubviews {
self.lbl_OrSignIn.hidden = YES;
self.seperatorLeft.hidden = YES;
self.seperatorRight.hidden = YES;
self.agreementTextViewTop.constant = -30;
}

if(IS_IPHONE_4) {
Expand All @@ -107,47 +92,15 @@ - (void)layoutSubviews {
self.constraint_UserGreyTop.constant = 20;
self.constraint_PasswordTop.constant = 8;
self.constraint_PassGreyTop.constant = 8;
self.constraint_ForgotTop.constant = 8;
self.constraint_SignInTop.constant = 13;
self.constraint_ActivityIndTop.constant = 43;
self.constraint_SignTop.constant = 9;

if([self isGoogleEnabled] || [self isFacebookEnabled]) {
self.constraint_LeftSepTop.constant = 18;
self.constraint_RightSepTop.constant = 18;
self.constraint_BySigningTop.constant = 69;
self.constraint_EULATop.constant = 73;
}
else {
self.lbl_OrSignIn.hidden = YES;
self.seperatorLeft.hidden = YES;
self.seperatorRight.hidden = YES;
self.constraint_LeftSepTop.constant = 18;
self.constraint_RightSepTop.constant = 18;
self.constraint_BySigningTop.constant = 18;
self.constraint_EULATop.constant = 23;
}
}
else {
self.constraint_MapTop.constant = 90;
self.constraint_UsernameTop.constant = 25;
self.constraint_UserGreyTop.constant = 25;
self.constraint_PasswordTop.constant = 12;
self.constraint_PassGreyTop.constant = 12;
self.constraint_ForgotTop.constant = 12;
self.constraint_SignInTop.constant = 20;
self.constraint_ActivityIndTop.constant = 55;
self.constraint_SignTop.constant = 15;
if([self isGoogleEnabled] || [self isFacebookEnabled]) {
self.constraint_LeftSepTop.constant = 25;
self.constraint_RightSepTop.constant = 25;
self.constraint_BySigningTop.constant = 85;
self.constraint_EULATop.constant = 88;
}
else {
self.constraint_BySigningTop.constant = 25;
self.constraint_EULATop.constant = 30;
}
}
}

Expand Down Expand Up @@ -222,18 +175,23 @@ - (void)viewDidLoad {
}

_placeHolderStyle = [[OEXTextStyle alloc] initWithWeight:OEXTextWeightNormal size:OEXTextSizeBase color:[[OEXStyles sharedStyles] neutralDark]];
_buttonsTitleStyle = [[OEXMutableTextStyle alloc] initWithWeight:OEXTextWeightBold size:OEXTextSizeBase color:[[OEXStyles sharedStyles] primaryBaseColor]];
[self setAccessibilityIdentifiers];
[self setUpAgreementTextView];
}

-(void) setUpAgreementTextView {
[self.agreementTextView setupFor:AgreementTypeSignIn];
self.agreementTextView.agreementDelegate = self;
// To adjust textView according to its content size.
self.agreementTextViewHeight.constant = self.agreementTextView.contentSize.height + [self.environment.styles standardHorizontalMargin];
}

//setting accessibility identifiers for developer automation use
- (void)setAccessibilityIdentifiers {
self.img_Logo.accessibilityIdentifier = @"LoginViewController:logo-image-view";
self.tf_EmailID.accessibilityIdentifier = @"LoginViewController:email-text-field";
self.tf_Password.accessibilityIdentifier = @"LoginViewController:password-text-field";
self.img_SeparatorEULA.accessibilityIdentifier = @"LoginViewController:separator-image-view";
self.lbl_Redirect.accessibilityIdentifier = @"LoginViewController:redirect-label";
self.btn_OpenEULA.accessibilityIdentifier = @"LoginViewController:open-eula-button";
self.agreementTextView.accessibilityIdentifier = @"LoginViewController:agreement-text-view";
self.externalAuthContainer.accessibilityIdentifier = @"LoginViewController:external-auth-container-view";
self.seperatorLeft.accessibilityIdentifier = @"LoginViewController:left-seperator-image-view";
self.seperatorRight.accessibilityIdentifier = @"LoginViewController:right-seperator-image-view";
Expand All @@ -251,20 +209,12 @@ - (void)navigateBack {
}

- (void)setExclusiveTouch {
self.btn_OpenEULA.exclusiveTouch = YES;
self.btn_Login.exclusiveTouch = YES;
self.btn_TroubleLogging.exclusiveTouch = YES;
self.view.multipleTouchEnabled = NO;
self.view.exclusiveTouch = YES;
}

- (void)hideEULA:(BOOL)hide {
//EULA
[self.webview_EULA.scrollView setContentOffset:CGPointMake(0, 0)];
self.webview_EULA.hidden = hide;
self.img_SeparatorEULA.hidden = hide;
}

- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];

Expand All @@ -277,9 +227,6 @@ - (void)viewWillAppear:(BOOL)animated {
[self.view setUserInteractionEnabled:YES];
self.view.exclusiveTouch = YES;

//EULA
[self hideEULA:YES];

// Scrolling on keyboard hide and show
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWasShown:)
Expand Down Expand Up @@ -340,21 +287,8 @@ - (void)setToDefaultProperties {
self.tf_Password.text = @"";
self.tf_EmailID.accessibilityLabel = nil;
self.tf_Password.accessibilityLabel = nil;

self.lbl_Redirect.text = [Strings redirectText];
self.lbl_Redirect.isAccessibilityElement = NO;
[self.btn_TroubleLogging setAttributedTitle:[_buttonsTitleStyle attributedStringWithText:[Strings troubleInLoginButton]] forState:UIControlStateNormal];
[self.btn_TroubleLogging setTitleColor:[[OEXStyles sharedStyles] primaryBaseColor] forState:UIControlStateNormal];
[self.btn_OpenEULA setTitleColor:[[OEXStyles sharedStyles] primaryBaseColor] forState:UIControlStateNormal];
_buttonsTitleStyle.weight = OEXTextWeightNormal;
_buttonsTitleStyle.size = OEXTextSizeXXSmall;

NSString *termsText = [Strings registrationAgreementButtonTitleWithPlatformName:self.environment.config.platformName];
[self.btn_OpenEULA setAttributedTitle:[_buttonsTitleStyle attributedStringWithText:termsText] forState:UIControlStateNormal];
self.btn_OpenEULA.titleLabel.adjustsFontSizeToFitWidth = YES;

self.btn_OpenEULA.accessibilityTraits = UIAccessibilityTraitLink;
self.btn_OpenEULA.accessibilityLabel = [NSString stringWithFormat:@"%@,%@",[Strings redirectText], termsText];
OEXTextStyle *forgotButtonStyle = [[OEXTextStyle alloc] initWithWeight:OEXTextWeightBold size:OEXTextSizeBase color:[self.environment.styles primaryBaseColor]];
[self.btn_TroubleLogging setAttributedTitle:[forgotButtonStyle attributedStringWithText:[Strings troubleInLoginButton]] forState:UIControlStateNormal];

[self.btn_Login applyButtonStyleWithStyle:[self.environment.styles filledPrimaryButtonStyle] withTitle:[self signInButtonText]];
[self.activityIndicator stopAnimating];
Expand Down Expand Up @@ -385,13 +319,13 @@ - (void)reachabilityDidChange:(NSNotification*)notification {
}
}

#pragma mark IBActions
- (IBAction)openEULA:(id)sender {
NSURL* url = [[NSBundle mainBundle] URLForResource:@"Terms-and-Services" withExtension:@"htm"];
#pragma mark AgreementTextViewDelegate
- (void)agreementTextView:(AgreementTextView *)textView didSelect:(NSURL *)url {
OEXUserLicenseAgreementViewController* viewController = [[OEXUserLicenseAgreementViewController alloc] initWithContentURL:url];
[self presentViewController:viewController animated:YES completion:nil];
}

#pragma mark IBActions
- (IBAction)troubleLoggingClicked:(id)sender {
if(self.reachable) {
[[UIAlertController alloc] showInViewController:self title:[Strings resetPasswordTitle] message:[Strings resetPasswordPopupText] preferredStyle:UIAlertControllerStyleAlert cancelButtonTitle:[Strings cancel] destructiveButtonTitle:nil otherButtonsTitle:@[[Strings ok]] tapBlock:^(UIAlertController* alertController, UIAlertAction* alertAction, NSInteger buttonIndex) {
Expand Down Expand Up @@ -534,7 +468,7 @@ - (void)externalLoginWithProvider:(id <OEXExternalAuthProvider>)provider {

[self.view setUserInteractionEnabled:NO];
[self.activityIndicator startAnimating];
[self.btn_Login applyButtonStyleWithStyle:[self.environment.styles filledPrimaryButtonStyle] withTitle:[[Strings signInButtonTextOnSignIn] oex_uppercaseStringInCurrentLocale]];
[self.btn_Login applyButtonStyleWithStyle:[self.environment.styles filledPrimaryButtonStyle] withTitle:[Strings signInButtonTextOnSignIn]];
}

- (void)loginHandleLoginError:(NSError*)error {
Expand Down
Loading

0 comments on commit 5b78cf5

Please sign in to comment.