Pārlūkot izejas kodu

new settings for : preferred provider

Marino Faggiana 6 gadi atpakaļ
vecāks
revīzija
5027f30eba

+ 1 - 1
iOSClient/AppDelegate.h

@@ -128,7 +128,7 @@
 @property (nonatomic, strong) NSUserDefaults *ncUserDefaults;
 
 // Login View
-- (void)openLoginView:(id)delegate loginType:(enumLoginType)loginType;
+- (void)openLoginView:(id)delegate loginType:(NSInteger)loginType;
 
 // Setting Active Account
 - (void)settingActiveAccount:(NSString *)activeAccount activeUrl:(NSString *)activeUrl activeUser:(NSString *)activeUser activeUserID:(NSString *)activeUserID activePassword:(NSString *)activePassword;

+ 2 - 2
iOSClient/AppDelegate.m

@@ -321,7 +321,7 @@
 #pragma mark ===== Login =====
 #pragma --------------------------------------------------------------------------------------------
 
-- (void)openLoginView:(id)delegate loginType:(enumLoginType)loginType
+- (void)openLoginView:(id)delegate loginType:(NSInteger)loginType
 {
     BOOL loginWeb = NO;
     
@@ -348,7 +348,7 @@
         //
         
         // Login flow : LoginWeb
-        if (loginType == loginModifyPasswordUser) {
+        if (loginType == k_login_Modify_Password) {
             tableAccount *account = [[NCManageDatabase sharedInstance] getAccountActive];
             if (account.loginFlow)
                 loginWeb = YES;

+ 1 - 1
iOSClient/Brand/File_Provider_Extension.plist

@@ -19,7 +19,7 @@
 	<key>CFBundleShortVersionString</key>
 	<string>2.22.0</string>
 	<key>CFBundleVersion</key>
-	<string>11</string>
+	<string>12</string>
 	<key>NSExtension</key>
 	<dict>
 		<key>NSExtensionFileProviderDocumentGroup</key>

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

@@ -30,11 +30,10 @@
 
 @interface CCIntro : UIViewController <EAIntroDelegate>
 
-- (id)initWithDelegate:(id <CCIntroDelegate>)delegate delegateView:(UIView *)delegateView type:(NSString *)type;
+- (id)initWithDelegate:(id <CCIntroDelegate>)delegate delegateView:(UIView *)delegateView;
 
 @property (nonatomic, weak) id <CCIntroDelegate> delegate;
 @property (nonatomic, strong) UIView *rootView;
-@property (nonatomic, strong) NSString *type;
 
 - (void)show;
 
@@ -42,7 +41,6 @@
 
 @protocol CCIntroDelegate <NSObject>
 
-@optional - (void)introWillFinish:(EAIntroView *)introView type:(NSString *)type wasSkipped:(BOOL)wasSkipped;
-@optional - (void)introDidFinish:(EAIntroView *)introView type:(NSString *)type wasSkipped:(BOOL)wasSkipped;
+- (void)introFinishSelector:(NSInteger)selector;
 
 @end

+ 18 - 14
iOSClient/Brand/Intro/CCIntro.m

@@ -36,14 +36,13 @@
 
 @implementation CCIntro
 
-- (id)initWithDelegate:(id <CCIntroDelegate>)delegate delegateView:(UIView *)delegateView type:(NSString *)type
+- (id)initWithDelegate:(id <CCIntroDelegate>)delegate delegateView:(UIView *)delegateView
 {
     self = [super init];
     
     if (self) {
         self.delegate = delegate;
         self.rootView = delegateView;
-        self.type = type;
     }
 
     return self;
@@ -56,23 +55,27 @@
 
 - (void)introWillFinish:(EAIntroView *)introView wasSkipped:(BOOL)wasSkipped
 {
-    if (self.delegate && [self.delegate respondsToSelector:@selector(introWillFinish:type:wasSkipped:)])
-        [self.delegate introWillFinish:introView type:self.type wasSkipped:wasSkipped];
+    [self.delegate introFinishSelector:0];
 }
 
 - (void)introDidFinish:(EAIntroView *)introView wasSkipped:(BOOL)wasSkipped
 {
-    if (self.delegate && [self.delegate respondsToSelector:@selector(introDidFinish:type:wasSkipped:)])
-        [self.delegate introDidFinish:introView type:self.type wasSkipped:wasSkipped];
+    [self.delegate introFinishSelector:0];
+}
+
+- (void)login:(id)sender
+{
+    [self.delegate introFinishSelector:0];
+}
+
+- (void)signUp:(id)sender
+{
+    [self.delegate introFinishSelector:0];
 }
 
 - (void)show
 {
-    if ([self.type isEqualToString:k_Intro])
-        [self showIntro];
-    
-//    if ([self.type isEqualToString:k_Intro_no_cryptocloud])
-//        [self showIntroNoCryptoCloud];
+    [self showIntro];
 }
 
 - (void)showIntro
@@ -101,14 +104,14 @@
     [buttonLogin setTitle:@"Login" forState:UIControlStateNormal];
     buttonLogin.titleLabel.font = [UIFont systemFontOfSize:20];
     buttonLogin.backgroundColor = [[NCBrandColor sharedInstance] customerText];
-    [buttonLogin addTarget:self action:@selector(aMethod:) forControlEvents:UIControlEventTouchDown];
+    [buttonLogin addTarget:self action:@selector(login:) forControlEvents:UIControlEventTouchDown];
     
     UIButton *buttonSignUp = [UIButton buttonWithType:UIButtonTypeRoundedRect];
     buttonSignUp.frame = CGRectMake(50.0, 60.0, width - 100.0, 40.0);
     [buttonSignUp setTitle:@"Sign up with provider" forState:UIControlStateNormal];
     buttonSignUp.titleLabel.font = [UIFont systemFontOfSize:20];
     buttonSignUp.backgroundColor = [[NCBrandColor sharedInstance] customerText];
-    [buttonSignUp addTarget:self action:@selector(aMethod:) forControlEvents:UIControlEventTouchDown];
+    [buttonSignUp addTarget:self action:@selector(signUp:) forControlEvents:UIControlEventTouchDown];
     
     [buttonView addSubview:buttonLogin];
     [buttonView addSubview:buttonSignUp];
@@ -173,7 +176,7 @@
     
     EAIntroView *intro = [[EAIntroView alloc] initWithFrame:self.rootView.bounds andPages:@[page1,page2,page3]];
 
-    intro.tapToNext = YES;
+    intro.tapToNext = NO;
     intro.pageControl.pageIndicatorTintColor = [UIColor whiteColor];
     intro.pageControl.currentPageIndicatorTintColor = [UIColor blackColor];
     intro.pageControl.backgroundColor = [[NCBrandColor sharedInstance] customer];
@@ -183,6 +186,7 @@
     intro.skipButton = nil ;
     intro.titleView = buttonView;
     intro.titleViewY = buttonPosition;
+    intro.swipeToExit = NO;
     
     /*
     page1.onPageDidAppear = ^{

+ 1 - 1
iOSClient/Brand/Share.plist

@@ -19,7 +19,7 @@
 	<key>CFBundleShortVersionString</key>
 	<string>2.22.0</string>
 	<key>CFBundleVersion</key>
-	<string>11</string>
+	<string>12</string>
 	<key>NSAppTransportSecurity</key>
 	<dict>
 		<key>NSAllowsArbitraryLoads</key>

+ 1 - 1
iOSClient/Brand/iOSClient.plist

@@ -69,7 +69,7 @@
 		</dict>
 	</array>
 	<key>CFBundleVersion</key>
-	<string>11</string>
+	<string>12</string>
 	<key>FIREBASE_ANALYTICS_COLLECTION_DEACTIVATED</key>
 	<true/>
 	<key>Fabric</key>

+ 5 - 3
iOSClient/CCGlobal.h

@@ -78,9 +78,11 @@
 // Name Default DB
 #define k_databaseDefault                               @"nextcloud.realm"
 
-// Intro
-#define k_Intro                                         @"Intro"
-#define k_Intro_no_cryptocloud                          @"IntroNoCryptoCloud"
+// Login
+#define k_login_Add                                     0
+#define k_login_Add_Forced                              1
+#define k_login_Add_SignUp                              2
+#define k_login_Modify_Password                         3
 
 // Picker select image
 #define k_pickerControllerMax                           1000.0

+ 1 - 8
iOSClient/Login/CCLogin.h

@@ -38,12 +38,6 @@
 
 @interface CCLogin : UIViewController <UITextFieldDelegate, NSURLSessionTaskDelegate, NSURLSessionDelegate, CCCertificateDelegate, OCNetworkingDelegate>
 
-typedef enum {
-    loginAdd = 0,
-    loginAddForced = 1,
-    loginModifyPasswordUser = 2
-} enumLoginType;
-
 @property (nonatomic, weak) id <CCLoginDelegate> delegate;
 
 @property (nonatomic, weak) IBOutlet UIImageView *imageBrand;
@@ -65,7 +59,6 @@ typedef enum {
 @property (nonatomic, weak) IBOutlet UIButton *toggleVisiblePassword;
 @property (nonatomic, weak) IBOutlet UIButton *loginTypeView;
 
-
-@property enumLoginType loginType;
+@property NSInteger loginType;
 
 @end

+ 6 - 6
iOSClient/Login/CCLogin.m

@@ -133,7 +133,7 @@
         _baseUrl.hidden = YES;
     }
 
-    if (_loginType == loginAdd) {
+    if (_loginType == k_login_Add ) {
         // Login Flow ?
         _imageUser.hidden = YES;
         _user.hidden = YES;
@@ -141,7 +141,7 @@
         _password.hidden = YES;
     }
     
-    if (_loginType == loginAddForced) {
+    if (_loginType == k_login_Add_Forced) {
         _annulla.hidden = YES;
         // Login Flow ?
         _imageUser.hidden = YES;
@@ -150,7 +150,7 @@
         _password.hidden = YES;
     }
     
-    if (_loginType == loginModifyPasswordUser) {
+    if (_loginType == k_login_Modify_Password) {
         _baseUrl.text = appDelegate.activeUrl;
         _baseUrl.userInteractionEnabled = NO;
         _baseUrl.textColor = [UIColor lightGrayColor];
@@ -165,7 +165,7 @@
     [super viewWillAppear:animated];
 
     // verify URL
-    if (_loginType == loginModifyPasswordUser && [self.baseUrl.text length] > 0)
+    if (_loginType == k_login_Modify_Password && [self.baseUrl.text length] > 0)
         [self testUrl];
 }
 
@@ -320,7 +320,7 @@
 
 - (void)trustedCerticateDenied
 {
-    if (_loginType == loginModifyPasswordUser)
+    if (_loginType == k_login_Modify_Password)
         [self handleAnnulla:self];
 }
 
@@ -440,7 +440,7 @@
             // account
             NSString *account = [NSString stringWithFormat:@"%@ %@", user, url];
             
-            if (_loginType == loginModifyPasswordUser) {
+            if (_loginType == k_login_Modify_Password) {
                 
                 // Change Password
                 tableAccount *tbAccount = [[NCManageDatabase sharedInstance] setAccountPassword:account password:password];

+ 8 - 16
iOSClient/Login/CCLoginWeb.swift

@@ -29,20 +29,12 @@ import UIKit
 }
 
 public class CCLoginWeb: UIViewController {
-
-    /*
-    @objc enum enumLoginTypeWeb : NSInteger {
-        case loginAdd = 0
-        case loginAddForced = 1
-        case loginModifyPasswordUser = 2
-    }
-    */
-    
+   
     @objc weak var delegate: CCLoginDelegateWeb?
-    @objc var loginType = loginAdd
+    @objc var loginType: NSInteger = Int(k_login_Add)
     @objc var urlBase = ""
     
-    var viewController : UIViewController?
+    var viewController: UIViewController?
     let appDelegate = UIApplication.shared.delegate as! AppDelegate
     var doneButtonVisible: Bool = false
     
@@ -51,7 +43,7 @@ public class CCLoginWeb: UIViewController {
         var urlString = urlBase
         self.viewController = vc
         
-        if (loginType == loginAdd || loginType == loginModifyPasswordUser) {
+        if (loginType == k_login_Add || loginType == k_login_Modify_Password) {
             doneButtonVisible = true
         }
         
@@ -100,7 +92,7 @@ extension CCLoginWeb: SwiftModalWebVCDelegate {
                     let account : String = "\(username) \(serverUrl)"
                 
                     // Login Flow
-                    if (loginType == loginModifyPasswordUser && NCBrandOptions.sharedInstance.use_login_web_personalized == false) {
+                    if (loginType == k_login_Modify_Password && NCBrandOptions.sharedInstance.use_login_web_personalized == false) {
                         
                         // Verify if change the active account
                         guard let activeAccount = NCManageDatabase.sharedInstance.getAccountActive() else {
@@ -120,13 +112,13 @@ extension CCLoginWeb: SwiftModalWebVCDelegate {
                         
                         appDelegate.settingActiveAccount(account, activeUrl: serverUrl, activeUser: username, activeUserID: tableAccount.userID, activePassword: password)
                         
-                        self.delegate?.loginSuccess(NSInteger(loginType.rawValue))
+                        self.delegate?.loginSuccess(NSInteger(loginType))
                         self.delegate?.loginWebClose()
 
                         self.viewController?.dismiss(animated: true, completion: nil)
                     }
                     
-                    if (loginType == loginAdd || loginType == loginAddForced) {
+                    if (loginType == k_login_Add || loginType == k_login_Add_Forced) {
                         
                         // Add new account
                         NCManageDatabase.sharedInstance.deleteAccount(account)
@@ -139,7 +131,7 @@ extension CCLoginWeb: SwiftModalWebVCDelegate {
                         
                         appDelegate.settingActiveAccount(account, activeUrl: serverUrl, activeUser: username, activeUserID: tableAccount.userID, activePassword: password)
                         
-                        self.delegate?.loginSuccess(NSInteger(loginType.rawValue))
+                        self.delegate?.loginSuccess(NSInteger(loginType))
                         self.delegate?.loginWebClose()
 
                         self.viewController?.dismiss(animated: true, completion: nil)

+ 9 - 9
iOSClient/Main/CCMain.m

@@ -1441,7 +1441,7 @@
     } else {
         // Unauthorized
         if (errorCode == kOCErrorServerUnauthorized)
-            [appDelegate openLoginView:self loginType:loginModifyPasswordUser];
+            [appDelegate openLoginView:self loginType:k_login_Modify_Password];
     }
 }
 
@@ -1487,7 +1487,7 @@
         
         // Unauthorized
         if (errorCode == kOCErrorServerUnauthorized) {
-            [appDelegate openLoginView:self loginType:loginModifyPasswordUser];
+            [appDelegate openLoginView:self loginType:k_login_Modify_Password];
             
         } else {
             [self tableViewReloadData];
@@ -1744,7 +1744,7 @@
         
         // Unauthorized
         if (errorCode == kOCErrorServerUnauthorized)
-            [appDelegate openLoginView:self loginType:loginModifyPasswordUser];
+            [appDelegate openLoginView:self loginType:k_login_Modify_Password];
         else
             [appDelegate messageNotification:@"_error_" description:message visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError errorCode:errorCode];
         
@@ -1779,7 +1779,7 @@
 {
     // Unauthorized
     if (errorCode == kOCErrorServerUnauthorized)
-        [appDelegate openLoginView:self loginType:loginModifyPasswordUser];
+        [appDelegate openLoginView:self loginType:k_login_Modify_Password];
     
     [_queueSelector removeObject:metadataNet.selector];
     
@@ -2114,7 +2114,7 @@
         
         // Unauthorized
         if (errorCode == kOCErrorServerUnauthorized)
-            [appDelegate openLoginView:self loginType:loginModifyPasswordUser];
+            [appDelegate openLoginView:self loginType:k_login_Modify_Password];
         else
             [appDelegate messageNotification:@"_create_folder_" description:message visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError errorCode:errorCode];
         
@@ -2386,7 +2386,7 @@
     
     // Unauthorized
     if (errorCode == kOCErrorServerUnauthorized)
-        [appDelegate openLoginView:self loginType:loginModifyPasswordUser];
+        [appDelegate openLoginView:self loginType:k_login_Modify_Password];
     else
         [appDelegate messageNotification:@"_share_" description:message visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError errorCode:errorCode];
 
@@ -2492,7 +2492,7 @@
     
     // Unauthorized
     if (errorCode == kOCErrorServerUnauthorized)
-        [appDelegate openLoginView:self loginType:loginModifyPasswordUser];
+        [appDelegate openLoginView:self loginType:k_login_Modify_Password];
     else
         [appDelegate messageNotification:@"_error_" description:message visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError errorCode:errorCode];
 }
@@ -2611,7 +2611,7 @@
     } else {
         
         if (errorCode == kOCErrorServerUnauthorized)
-            [appDelegate openLoginView:self loginType:loginModifyPasswordUser];
+            [appDelegate openLoginView:self loginType:k_login_Modify_Password];
         
         NSLog(@"[LOG] Setting Favorite failure error %d, %@", (int)errorCode, message);
     }
@@ -2865,7 +2865,7 @@
     [appDelegate.netQueue cancelAllOperations];
     
     dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.3 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
-        [appDelegate openLoginView:self loginType:loginAdd];
+        [appDelegate openLoginView:self loginType:k_login_Add];
     });
 }
 

+ 1 - 1
iOSClient/Main/CCMore.swift

@@ -361,7 +361,7 @@ class CCMore: UIViewController, UITableViewDelegate, UITableViewDataSource, CCLo
                 let manageAccount = CCManageAccount()
                 manageAccount.delete(self.appDelegate.activeAccount)
                 
-                self.appDelegate.openLoginView(self, loginType: loginAddForced)
+                self.appDelegate.openLoginView(self, loginType: Int(k_login_Add_Forced))
             }
             
             let actionNo = UIAlertAction(title: NSLocalizedString("_no_delete_", comment: ""), style: .default) { (action:UIAlertAction) in

+ 10 - 40
iOSClient/Main/CCSplit.m

@@ -131,58 +131,28 @@
     // Brand
     if ([NCBrandOptions sharedInstance].disable_intro) {
         
-        [CCUtility setIntroMessage:k_Intro set:YES];
-//        [CCUtility setIntroMessage:k_Intro_no_cryptocloud set:YES];
+        [CCUtility setIntro:YES];
     
-        [self introWillFinish:nil type:nil wasSkipped:NO];
+        [self introFinishSelector:0];
 
     } else {
     
-        // -1-
-        if ([CCUtility getIntroMessage:k_Intro] == NO) {
+        if ([CCUtility getIntro] == NO) {
         
-            _intro = [[CCIntro alloc] initWithDelegate:self delegateView:self.view type:k_Intro];
+            _intro = [[CCIntro alloc] initWithDelegate:self delegateView:self.view];
             [_intro show];
         
-        }
-        
-        // -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 introWillFinish:nil type:nil wasSkipped:NO];
+        } else {
+    
+            [self introFinishSelector:0];
         }
     }
 }
 
-- (void)introWillFinish:(EAIntroView *)introView type:(NSString *)type wasSkipped:(BOOL)wasSkipped
+- (void)introFinishSelector:(NSInteger)selector
 {
-    // -1-
-    if ([type isEqualToString:k_Intro]) {
-        
-        [CCUtility setIntroMessage:k_Intro set:YES];
-        // next
-        //_intro = [[CCIntro alloc] initWithDelegate:self delegateView:self.view type:k_Intro_no_cryptocloud];
-        //[_intro show];
-        //
-        //return;
-    }
+    [CCUtility setIntro:YES];
     
-    // -2-
-    /*
-    if ([type isEqualToString:k_Intro_no_cryptocloud]) {
-        
-        [CCUtility setIntroMessage:k_Intro_no_cryptocloud set:YES];
-    }
-    */
     // check account
     [self performSelector:@selector(newAccount) withObject:nil afterDelay:0.1];
 }
@@ -214,7 +184,7 @@
 {
     if (appDelegate.activeAccount.length == 0) {
     
-        [appDelegate openLoginView:self loginType:loginAddForced];
+        [appDelegate openLoginView:self loginType:k_login_Add_Forced];
     }
 }
 

+ 3 - 3
iOSClient/Settings/CCManageAccount.m

@@ -232,13 +232,13 @@
     [appDelegate.netQueue cancelAllOperations];
     
     dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.3 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
-        [appDelegate openLoginView:self loginType:loginAdd];
+        [appDelegate openLoginView:self loginType:k_login_Add];
     });
 }
 
 - (void)addAccountForced
 {
-    [appDelegate openLoginView:self loginType:loginAddForced];
+    [appDelegate openLoginView:self loginType:k_login_Add_Forced];
 }
 
 #pragma --------------------------------------------------------------------------------------------
@@ -259,7 +259,7 @@
     [appDelegate.netQueue cancelAllOperations];
     
     dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.3 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
-        [appDelegate openLoginView:self loginType:loginModifyPasswordUser];
+        [appDelegate openLoginView:self loginType:k_login_Modify_Password];
     });
 }
 

+ 2 - 2
iOSClient/Utility/CCUtility.h

@@ -85,8 +85,8 @@
 + (NSString *)getGroupBySettings;
 + (void)setGroupBySettings:(NSString *)groupby;
 
-+ (BOOL)getIntroMessage:(NSString *)type;
-+ (void)setIntroMessage:(NSString *)type set:(BOOL)set;
++ (BOOL)getIntro;
++ (void)setIntro:(BOOL)set;
 
 + (NSString *)getIncrementalNumber;
 

+ 16 - 6
iOSClient/Utility/CCUtility.m

@@ -257,19 +257,29 @@
     [UICKeyChainStore setString:groupby forKey:@"groupby" service:k_serviceShareKeyChain];
 }
 
-+ (BOOL)getIntroMessage:(NSString *)type
++ (BOOL)getIntro
 {
-    NSString *key = [INTRO_MessageType stringByAppendingString:type];
+    // Set compatibility old version don't touch me
+    if ([[UICKeyChainStore stringForKey:[INTRO_MessageType stringByAppendingString:@"Intro"] service:k_serviceShareKeyChain] boolValue] == YES) {
+        [CCUtility setIntro:YES];
+        return YES;
+    }
+    
+    return [[UICKeyChainStore stringForKey:@"intro" service:k_serviceShareKeyChain] boolValue];
+}
+
++ (BOOL)getIntroMessageOldVersion
+{
+    NSString *key = [INTRO_MessageType stringByAppendingString:@"Intro"];
     
     return [[UICKeyChainStore stringForKey:key service:k_serviceShareKeyChain] boolValue];
 }
 
-+ (void)setIntroMessage:(NSString *)type set:(BOOL)set
++ (void)setIntro:(BOOL)set
 {
-    NSString *key = [INTRO_MessageType stringByAppendingString:type];
-    NSString *sSet = (set) ? @"true" : @"false";
+    NSString *sIntro = (set) ? @"true" : @"false";
+    [UICKeyChainStore setString:sIntro forKey:@"intro" service:k_serviceShareKeyChain];
 
-    [UICKeyChainStore setString:sSet forKey:key service:k_serviceShareKeyChain];
 }
 
 + (NSString *)getIncrementalNumber