浏览代码

New Intro control

Marino Faggiana 7 年之前
父节点
当前提交
df02ac5721

+ 6 - 4
iOSClient/Brand/Intro/CCIntro.h

@@ -30,18 +30,20 @@
 
 @interface CCIntro : NSObject <EAIntroDelegate>
 
-- (id)initWithDelegate:(id <CCIntroDelegate>)delegate delegateView:(UIView *)delegateView;
+- (id)initWithDelegate:(id <CCIntroDelegate>)delegate delegateView:(UIView *)delegateView type:(NSString *)type;
 
 @property (nonatomic, weak) id <CCIntroDelegate> delegate;
 @property (nonatomic, strong) UIView *rootView;
+@property (nonatomic, strong) NSString *type;
 
-- (void)showIntroCryptoCloud:(CGFloat)duration;
+
+- (void)show;
 
 @end
 
 @protocol CCIntroDelegate <NSObject>
 
-@optional - (void)introWillFinish:(EAIntroView *)introView wasSkipped:(BOOL)wasSkipped;
-@optional - (void)introDidFinish:(EAIntroView *)introView wasSkipped:(BOOL)wasSkipped;
+@optional - (void)introWillFinish:(EAIntroView *)introView type:(NSString *)type wasSkipped:(BOOL)wasSkipped;
+@optional - (void)introDidFinish:(EAIntroView *)introView type:(NSString *)type wasSkipped:(BOOL)wasSkipped;
 
 @end

+ 66 - 7
iOSClient/Brand/Intro/CCIntro.m

@@ -33,13 +33,14 @@
 
 @implementation CCIntro
 
-- (id)initWithDelegate:(id <CCIntroDelegate>)delegate delegateView:(UIView *)delegateView
+- (id)initWithDelegate:(id <CCIntroDelegate>)delegate delegateView:(UIView *)delegateView type:(NSString *)type
 {
     self = [super init];
     
     if (self) {
         self.delegate = delegate;
         self.rootView = delegateView;
+        self.type = type;
     }
 
     return self;
@@ -52,17 +53,26 @@
 
 - (void)introWillFinish:(EAIntroView *)introView wasSkipped:(BOOL)wasSkipped
 {
-    if (self.delegate && [self.delegate respondsToSelector:@selector(introWillFinish:wasSkipped:)])
-        [self.delegate introWillFinish:introView wasSkipped:wasSkipped];
+    if (self.delegate && [self.delegate respondsToSelector:@selector(introWillFinish:type:wasSkipped:)])
+        [self.delegate introWillFinish:introView type:self.type wasSkipped:wasSkipped];
 }
 
 - (void)introDidFinish:(EAIntroView *)introView wasSkipped:(BOOL)wasSkipped
 {
-    if (self.delegate && [self.delegate respondsToSelector:@selector(introDidFinish:wasSkipped:)])
-        [self.delegate introDidFinish:introView wasSkipped:wasSkipped];
+    if (self.delegate && [self.delegate respondsToSelector:@selector(introDidFinish:type:wasSkipped:)])
+        [self.delegate introDidFinish:introView type:self.type wasSkipped:wasSkipped];
 }
 
-- (void)showIntroCryptoCloud:(CGFloat)duration
+- (void)show
+{
+    if ([self.type isEqualToString:k_Intro])
+        [self showIntro];
+    
+    if ([self.type isEqualToString:k_Intro_no_cryptocloud])
+        [self showIntroNoCryptoCloud];
+}
+
+- (void)showIntro
 {
     //NSString *language = [[[NSBundle mainBundle] preferredLocalizations] objectAtIndex:0];
     CGFloat height = self.rootView.bounds.size.height;
@@ -169,7 +179,56 @@
 
     [intro setDelegate:self];
     [intro setPages:@[page1,page11,page2,page3]];
-    [intro showInView:self.rootView animateDuration:duration];
+    [intro showInView:self.rootView animateDuration:0];
+}
+
+- (void)showIntroNoCryptoCloud
+{
+    //NSString *language = [[[NSBundle mainBundle] preferredLocalizations] objectAtIndex:0];
+    CGFloat height = self.rootView.bounds.size.height;
+    
+    if (height <= 480) {
+        titleIconPositionY = 20; titlePositionY = 260; descPositionY = 230;
+    }
+    
+    // 812 = iPhoneX
+    if (height > 480 && height <= 812) {
+        titleIconPositionY = 50; titlePositionY = height / 2; descPositionY = height / 2 - 40 ;
+    }
+    
+    if (height > 812) {
+        titleIconPositionY = 100; titlePositionY = 290; descPositionY = 250;
+    }
+    
+    EAIntroPage *page1 = [EAIntroPage page];
+    
+    page1.titleIconView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"intro1"]];
+    page1.title = NSLocalizedStringFromTable(@"_intro_1_title_", @"Intro", nil);
+    page1.desc = NSLocalizedStringFromTable(@"_intro_1_text_",  @"Intro", nil);
+    
+    page1.titlePositionY = titlePositionY;
+    page1.titleColor = [UIColor blackColor];
+    page1.titleFont = [UIFont systemFontOfSize:20];
+    page1.descPositionY = descPositionY;
+    page1.descColor = [UIColor blackColor];
+    page1.descFont = [UIFont systemFontOfSize:14];
+    page1.bgImage = [UIImage imageNamed:@"bgbianco"];
+    page1.titleIconPositionY = titleIconPositionY;
+    page1.showTitleView = NO;
+    
+    EAIntroView *intro = [[EAIntroView alloc] initWithFrame:self.rootView.bounds];
+    
+    intro.tapToNext = YES;
+    intro.pageControl.pageIndicatorTintColor = [UIColor clearColor];
+    intro.pageControl.currentPageIndicatorTintColor = [UIColor clearColor];
+    intro.pageControl.backgroundColor = [UIColor clearColor];
+    [intro.skipButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
+    intro.skipButton.enabled = NO;
+    intro.skipButton.alpha = 0.f;
+    
+    [intro setDelegate:self];
+    [intro setPages:@[page1]];
+    [intro showInView:self.rootView animateDuration:0];
 }
 
 @end

+ 4 - 0
iOSClient/CCGlobal.h

@@ -56,6 +56,10 @@ extern NSString *const dav;
 // Name Default DB
 #define k_databaseDefault                               @"nextcloud.realm"
 
+// Intro
+#define k_Intro                                         @"Intro"
+#define k_Intro_no_cryptocloud                          @"IntroNoCryptoCloud"
+
 // Picker select image
 #define k_pickerControllerMax                           1000.0
 

+ 1 - 1
iOSClient/Library/OCCommunicationLib/OCCommunication.h

@@ -902,7 +902,7 @@ typedef enum {
 
 #pragma mark - End-to-End Encryption
 
-- (void)getEndToEndPublicKeys:(NSString*)serverPath userID:(NSString *)userID onCommunication:(OCCommunication *)sharedOCComunication successRequest:(void(^)(NSHTTPURLResponse *response, NSString *publicKey, NSString *redirectedServer)) successRequest failureRequest:(void(^)(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer)) failureRequest;
+- (void)getEndToEndPublicKeys:(NSString*)serverPath onCommunication:(OCCommunication *)sharedOCComunication successRequest:(void(^)(NSHTTPURLResponse *response, NSString *publicKey, NSString *redirectedServer)) successRequest failureRequest:(void(^)(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer)) failureRequest;
 
 - (void)getEndToEndPrivateKey:(NSString*)serverPath onCommunication:(OCCommunication *)sharedOCComunication successRequest:(void(^)(NSHTTPURLResponse *response, NSString *privateKey, NSString *redirectedServer)) successRequest failureRequest:(void(^)(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer)) failureRequest;
 

+ 2 - 2
iOSClient/Library/OCCommunicationLib/OCCommunication.m

@@ -1954,7 +1954,7 @@
 
 #pragma mark - End-to-End Encryption
 
-- (void)getEndToEndPublicKeys:(NSString*)serverPath userID:(NSString *)userID onCommunication:(OCCommunication *)sharedOCComunication successRequest:(void(^)(NSHTTPURLResponse *response, NSString *publicKey, NSString *redirectedServer)) successRequest failureRequest:(void(^)(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer)) failureRequest {
+- (void)getEndToEndPublicKeys:(NSString*)serverPath onCommunication:(OCCommunication *)sharedOCComunication successRequest:(void(^)(NSHTTPURLResponse *response, NSString *publicKey, NSString *redirectedServer)) successRequest failureRequest:(void(^)(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer)) failureRequest {
     
     serverPath = [serverPath stringByAppendingString:k_url_client_side_encryption];
     serverPath = [serverPath stringByAppendingString:@"/public-key"];
@@ -1986,7 +1986,7 @@
                 if ([data valueForKey:@"public-keys"] && ![[data valueForKey:@"public-keys"] isKindOfClass:[NSNull class]]) {
                     
                     NSDictionary *publickeys = [data valueForKey:@"public-keys"];
-                    publicKey = [publickeys valueForKey:userID];
+                    publicKey = [publickeys valueForKey:self.userID];
                 }
                 
             } else {

+ 2 - 0
iOSClient/Main/CCMain.m

@@ -1184,6 +1184,7 @@
     [app addNetworkingOperationQueue:app.netQueue delegate:self metadataNet:metadataNet];
     
     // Get End-To-End PrivateKey (if enabled)
+    /*
     if (capabilities.isEndToEndEncryptionEnabled) {
         
         if (![CCUtility isEndToEndEnabled:app.activeAccount]) {
@@ -1191,6 +1192,7 @@
             [self initEndToEnd];
         }
     }
+    */
 }
 
 #pragma mark -

+ 32 - 9
iOSClient/Main/CCSplit.m

@@ -100,29 +100,52 @@
 {
     // Brand
     if ([NCBrandOptions sharedInstance].disable_intro) {
-
-        [CCUtility setIntro:@"1.0"];
+        
+        [CCUtility setIntroMessage:k_Intro view:YES];
+        [CCUtility setIntroMessage:k_Intro_no_cryptocloud view:YES];
     
         [self performSelector:@selector(newAccount) withObject:nil afterDelay:0.1];
 
     } else {
     
-        if ([CCUtility getIntro:@"1.0"] == NO) {
+        // -1-
+        if ([CCUtility getIntroMessage:k_Intro] == NO) {
         
-            _intro = [[CCIntro alloc] initWithDelegate:self delegateView:self.view];
-            [_intro showIntroCryptoCloud:0.0];
+            _intro = [[CCIntro alloc] initWithDelegate:self delegateView:self.view type:k_Intro];
+            [_intro show];
         
-        } else {
+        }
+        
+        // -2-
+        else if ([CCUtility getIntroMessage:k_Intro_no_cryptocloud] == NO) {
+            
+            _intro = [[CCIntro alloc] initWithDelegate:self delegateView:self.view type:k_Intro_no_cryptocloud];
+            [_intro show];
+        }
         
+        // NO INTRO
+        else {
+            
             [self performSelector:@selector(newAccount) withObject:nil afterDelay:0.1];
         }
     }
 }
 
-- (void)introWillFinish:(EAIntroView *)introView wasSkipped:(BOOL)wasSkipped
+- (void)introWillFinish:(EAIntroView *)introView type:(NSString *)type wasSkipped:(BOOL)wasSkipped
 {
-    [CCUtility setIntro:@"1.0"];
-    [self performSelector:@selector(newAccount) withObject:nil afterDelay:0.1];
+    // -1-
+    if ([type isEqualToString:k_Intro]) {
+        [CCUtility setIntroMessage:k_Intro view:YES];
+        // next
+        _intro = [[CCIntro alloc] initWithDelegate:self delegateView:self.view type:k_Intro_no_cryptocloud];
+        [_intro show];
+    }
+    
+    // -2-
+    else if ([type isEqualToString:k_Intro_no_cryptocloud]) {
+        [CCUtility setIntroMessage:k_Intro_no_cryptocloud view:YES];
+        [self performSelector:@selector(newAccount) withObject:nil afterDelay:0.1];
+    }
 }
 
 #pragma --------------------------------------------------------------------------------------------

+ 1 - 1
iOSClient/Networking/OCNetworking.m

@@ -1677,7 +1677,7 @@
     [communication setCredentialsWithUser:_activeUser andUserID:_activeUserID andPassword:_activePassword];
     [communication setUserAgent:[CCUtility getUserAgent]];
     
-    [communication getEndToEndPublicKeys:[_activeUrl stringByAppendingString:@"/"] userID:_activeUserID onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSString *publicKey, NSString *redirectedServer) {
+    [communication getEndToEndPublicKeys:[_activeUrl stringByAppendingString:@"/"] onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSString *publicKey, NSString *redirectedServer) {
         
         // 200 ok: body contain the public key
         _metadataNet.options = publicKey;

+ 3 - 2
iOSClient/Utility/CCUtility.h

@@ -67,7 +67,7 @@
 + (void)setAscendingSettings:(BOOL)ascendente;
 + (void)setGroupBySettings:(NSString *)groupby;
 
-+ (void)setIntro:(NSString *)version;
++ (void)setIntroMessage:(NSString *)type view:(BOOL)view;
 
 + (void)setActiveAccountExt:(NSString *)activeAccount;
 + (void)setServerUrlExt:(NSString *)serverUrl;
@@ -116,7 +116,8 @@
 + (BOOL)getAscendingSettings;
 + (NSString *)getGroupBySettings;
 
-+ (BOOL)getIntro:(NSString *)version;
++ (BOOL)getIntroMessage:(NSString *)type;
+
 + (NSString *)getIncrementalNumber;
 
 + (NSString *)getActiveAccountExt;

+ 9 - 4
iOSClient/Utility/CCUtility.m

@@ -145,9 +145,12 @@
     [UICKeyChainStore setString:groupby forKey:@"groupby" service:k_serviceShareKeyChain];
 }
 
-+ (void)setIntro:(NSString *)version
++ (void)setIntroMessage:(NSString *)type view:(BOOL)view
 {
-    [UICKeyChainStore setString:@"true" forKey:version service:k_serviceShareKeyChain];
+    NSString *key = [@"messageType_" stringByAppendingString:type];
+    NSString *sView = (view) ? @"true" : @"false";
+
+    [UICKeyChainStore setString:sView forKey:key service:k_serviceShareKeyChain];
 }
 
 + (void)setActiveAccountExt:(NSString *)activeAccount
@@ -360,9 +363,11 @@
     return groupby;
 }
 
-+ (BOOL)getIntro:(NSString *)version
++ (BOOL)getIntroMessage:(NSString *)type
 {
-    return [[UICKeyChainStore stringForKey:version service:k_serviceShareKeyChain] boolValue];
+    NSString *key = [@"messageType_" stringByAppendingString:type];
+    
+    return [[UICKeyChainStore stringForKey:key service:k_serviceShareKeyChain] boolValue];
 }
 
 + (NSString *)getIncrementalNumber