Browse Source

update XL library

Marino Faggiana 7 years ago
parent
commit
18cbc9fdfb

+ 0 - 4
Nextcloud.xcodeproj/project.pbxproj

@@ -241,7 +241,6 @@
 		F75EDFB11E8C106900E6F369 /* Protobuf.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F75EDFAB1E8C106900E6F369 /* Protobuf.framework */; };
 		F75EDFBD1E8C112F00E6F369 /* libsqlite3.0.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = F75EDFBC1E8C112F00E6F369 /* libsqlite3.0.tbd */; };
 		F75EDFBF1E8C116D00E6F369 /* libstdc++.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = F75EDFBE1E8C116D00E6F369 /* libstdc++.tbd */; };
-		F762CAF61EACB66200B38484 /* Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = F762CAA01EACB66200B38484 /* Info.plist */; };
 		F762CAF71EACB66200B38484 /* XLFormBaseCell.m in Sources */ = {isa = PBXBuildFile; fileRef = F762CAA41EACB66200B38484 /* XLFormBaseCell.m */; };
 		F762CAF81EACB66200B38484 /* XLFormButtonCell.m in Sources */ = {isa = PBXBuildFile; fileRef = F762CAA61EACB66200B38484 /* XLFormButtonCell.m */; };
 		F762CAF91EACB66200B38484 /* XLFormCheckCell.m in Sources */ = {isa = PBXBuildFile; fileRef = F762CAA81EACB66200B38484 /* XLFormCheckCell.m */; };
@@ -1001,7 +1000,6 @@
 		F75EDFAB1E8C106900E6F369 /* Protobuf.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Protobuf.framework; sourceTree = "<group>"; };
 		F75EDFBC1E8C112F00E6F369 /* libsqlite3.0.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libsqlite3.0.tbd; path = usr/lib/libsqlite3.0.tbd; sourceTree = SDKROOT; };
 		F75EDFBE1E8C116D00E6F369 /* libstdc++.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = "libstdc++.tbd"; path = "usr/lib/libstdc++.tbd"; sourceTree = SDKROOT; };
-		F762CAA01EACB66200B38484 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
 		F762CAA31EACB66200B38484 /* XLFormBaseCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XLFormBaseCell.h; sourceTree = "<group>"; };
 		F762CAA41EACB66200B38484 /* XLFormBaseCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XLFormBaseCell.m; sourceTree = "<group>"; };
 		F762CAA51EACB66200B38484 /* XLFormButtonCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XLFormButtonCell.h; sourceTree = "<group>"; };
@@ -2119,7 +2117,6 @@
 		F762CA9F1EACB66200B38484 /* XLForm */ = {
 			isa = PBXGroup;
 			children = (
-				F762CAA01EACB66200B38484 /* Info.plist */,
 				F762CAA11EACB66200B38484 /* XL */,
 				F762CAF51EACB66200B38484 /* XLForm.bundle */,
 			);
@@ -3311,7 +3308,6 @@
 				F77B0F671D118A16002130FE /* InfoPlist.strings in Resources */,
 				F7C525A21E3B6DA800FFE02C /* CCNotification.storyboard in Resources */,
 				F7F54CEB1E5B14C700E19C62 /* ImageSelectedOn.png in Resources */,
-				F762CAF61EACB66200B38484 /* Info.plist in Resources */,
 				F762CB951EACB84400B38484 /* icon-error.png in Resources */,
 				F7F54CF01E5B14C700E19C62 /* ImageSelectedSmallOff@3x.png in Resources */,
 				F73B4EF01F470D9100BBEE4B /* CMakeLists.txt in Resources */,

+ 0 - 26
iOSClient/Library/XLForm/Info.plist

@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
-	<key>CFBundleDevelopmentRegion</key>
-	<string>en</string>
-	<key>CFBundleExecutable</key>
-	<string>$(EXECUTABLE_NAME)</string>
-	<key>CFBundleIdentifier</key>
-	<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
-	<key>CFBundleInfoDictionaryVersion</key>
-	<string>6.0</string>
-	<key>CFBundleName</key>
-	<string>$(PRODUCT_NAME)</string>
-	<key>CFBundlePackageType</key>
-	<string>FMWK</string>
-	<key>CFBundleShortVersionString</key>
-	<string>1.0</string>
-	<key>CFBundleSignature</key>
-	<string>????</string>
-	<key>CFBundleVersion</key>
-	<string>$(CURRENT_PROJECT_VERSION)</string>
-	<key>NSPrincipalClass</key>
-	<string></string>
-</dict>
-</plist>

+ 20 - 4
iOSClient/Library/XLForm/XL/Cell/XLFormDateCell.m

@@ -37,6 +37,7 @@
 @implementation XLFormDateCell
 {
     UIColor * _beforeChangeColor;
+    NSDateFormatter *_dateFormatter;
 }
 
 
@@ -109,6 +110,7 @@
 {
     [super configure];
     self.formDatePickerMode = XLFormDateDatePickerModeGetFromRowDescriptor;
+    _dateFormatter = [[NSDateFormatter alloc] init];
 }
 
 -(void)update
@@ -173,16 +175,24 @@
         }
     }
     if ([self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeDate] || [self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeDateInline]){
-        return [NSDateFormatter localizedStringFromDate:date dateStyle:NSDateFormatterMediumStyle timeStyle:NSDateFormatterNoStyle];
+        _dateFormatter.dateStyle = NSDateFormatterMediumStyle;
+        _dateFormatter.timeStyle = NSDateFormatterNoStyle;
+        return [_dateFormatter stringFromDate:date];
     }
     else if ([self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeTime] || [self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeTimeInline]){
-        return [NSDateFormatter localizedStringFromDate:date dateStyle:NSDateFormatterNoStyle timeStyle:NSDateFormatterShortStyle];
+        _dateFormatter.dateStyle = NSDateFormatterNoStyle;
+        _dateFormatter.timeStyle = NSDateFormatterShortStyle;
+        return [_dateFormatter stringFromDate:date];
     }
     else if ([self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeCountDownTimer] || [self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeCountDownTimerInline]){
-        NSDateComponents *time = [[NSCalendar currentCalendar] components:NSCalendarUnitHour | NSCalendarUnitMinute fromDate:date];
+        NSCalendar *calendar = [NSCalendar currentCalendar];
+        [calendar setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]];
+        NSDateComponents *time = [calendar components:NSCalendarUnitHour | NSCalendarUnitMinute fromDate:date];
         return [NSString stringWithFormat:@"%ld%@ %ldmin", (long)[time hour], (long)[time hour] == 1 ? @"hour" : @"hours", (long)[time minute]];
     }
-    return [NSDateFormatter localizedStringFromDate:date dateStyle:NSDateFormatterShortStyle timeStyle:NSDateFormatterShortStyle];
+    _dateFormatter.dateStyle = NSDateFormatterShortStyle;
+    _dateFormatter.timeStyle = NSDateFormatterShortStyle;
+    return [_dateFormatter stringFromDate:date];
 }
 
 -(void)setModeToDatePicker:(UIDatePicker *)datePicker
@@ -195,6 +205,7 @@
     }
     else if ([self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeCountDownTimer] || [self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeCountDownTimerInline]){
         datePicker.datePickerMode = UIDatePickerModeCountDownTimer;
+        datePicker.timeZone = [NSTimeZone timeZoneForSecondsFromGMT:0];
     }
     else{
         datePicker.datePickerMode = UIDatePickerModeDateAndTime;
@@ -225,6 +236,11 @@
     return _datePicker;
 }
 
+-(void)setLocale:(NSLocale *)locale
+{
+    _locale = locale;
+    _dateFormatter.locale = locale;
+}
 
 #pragma mark - Target Action
 

+ 1 - 1
iOSClient/Library/XLForm/XL/Cell/XLFormSelectorCell.m

@@ -87,7 +87,7 @@
             return tranformedValue;
         }
     }
-    return [self.rowDescriptor.value displayText];
+    return self.rowDescriptor.displayTextValue;
 }
 
 

+ 3 - 0
iOSClient/Library/XLForm/XL/Controllers/XLFormOptionsObject.h

@@ -28,6 +28,9 @@
 
 @interface XLFormOptionsObject : NSObject <XLFormOptionObject,NSCoding>
 
+@property (nonatomic) NSString * formDisplaytext;
+@property (nonatomic) id formValue;
+
 +(XLFormOptionsObject *)formOptionsObjectWithValue:(id)value displayText:(NSString *)displayText;
 +(XLFormOptionsObject *)formOptionsOptionForValue:(id)value fromOptions:(NSArray *)options;
 +(XLFormOptionsObject *)formOptionsOptionForDisplayText:(NSString *)displayText fromOptions:(NSArray *)options;

+ 3 - 4
iOSClient/Library/XLForm/XL/Controllers/XLFormOptionsObject.m

@@ -26,10 +26,6 @@
 #import "XLFormOptionsObject.h"
 
 @implementation XLFormOptionsObject
-{
-    NSString * _formDisplaytext;
-    id _formValue;
-}
 
 +(XLFormOptionsObject *)formOptionsObjectWithValue:(id)value displayText:(NSString *)displayText
 {
@@ -85,6 +81,7 @@
 {
     return _formValue;
 }
+
 #pragma mark - NSCoding
 -(void)encodeWithCoder:(NSCoder *)encoder
 {
@@ -94,6 +91,7 @@
     [encoder encodeObject:self.formDisplayText
                    forKey:@"formDisplayText"];
 }
+
 -(instancetype)initWithCoder:(NSCoder *)decoder
 {
     if ((self=[super init])) {
@@ -108,4 +106,5 @@
     return self;
     
 }
+
 @end

+ 1 - 0
iOSClient/Library/XLForm/XL/Controllers/XLFormViewController.h

@@ -60,6 +60,7 @@ typedef NS_ENUM(NSUInteger, XLFormRowNavigationDirection) {
 
 -(NSArray *)formValidationErrors;
 -(void)showFormValidationError:(NSError *)error;
+-(void)showFormValidationError:(NSError *)error withTitle:(NSString*)title;
 
 -(UITableViewRowAnimation)insertRowAnimationForRow:(XLFormRowDescriptor *)formRow;
 -(UITableViewRowAnimation)deleteRowAnimationForRow:(XLFormRowDescriptor *)formRow;

+ 32 - 0
iOSClient/Library/XLForm/XL/Controllers/XLFormViewController.m

@@ -492,6 +492,38 @@
 #endif
 }
 
+-(void)showFormValidationError:(NSError *)error withTitle:(NSString*)title
+{
+#if __IPHONE_OS_VERSION_MAX_ALLOWED < 80000
+    UIAlertView * alertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(title, nil)
+                                                         message:error.localizedDescription
+                                                        delegate:self
+                                               cancelButtonTitle:NSLocalizedString(@"OK", nil)
+                                               otherButtonTitles:nil];
+    [alertView show];
+#else
+    if ([UIAlertController class]){
+        UIAlertController * alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(title, nil)
+                                                                                  message:error.localizedDescription
+                                                                           preferredStyle:UIAlertControllerStyleAlert];
+        [alertController addAction:[UIAlertAction actionWithTitle:@"OK"
+                                                            style:UIAlertActionStyleDefault
+                                                          handler:nil]];
+        [self presentViewController:alertController animated:YES completion:nil];
+    }
+#ifndef XL_APP_EXTENSIONS
+    else{
+        UIAlertView * alertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(title, nil)
+                                                             message:error.localizedDescription
+                                                            delegate:self
+                                                   cancelButtonTitle:NSLocalizedString(@"OK", nil)
+                                                   otherButtonTitles:nil];
+        [alertView show];
+    }
+#endif
+#endif
+}
+
 -(void)performFormSelector:(SEL)selector withObject:(id)sender
 {
     UIResponder * responder = [self targetForAction:selector withSender:sender];;

+ 1 - 0
iOSClient/Library/XLForm/XL/Descriptors/XLFormSectionDescriptor.h

@@ -69,5 +69,6 @@ typedef NS_ENUM(NSUInteger, XLFormSectionInsertMode) {
 -(void)addFormRow:(nonnull XLFormRowDescriptor *)formRow beforeRow:(nonnull XLFormRowDescriptor *)beforeRow;
 -(void)removeFormRowAtIndex:(NSUInteger)index;
 -(void)removeFormRow:(nonnull XLFormRowDescriptor *)formRow;
+-(void)moveRowAtIndexPath:(nonnull NSIndexPath *)sourceIndex toIndexPath:(nonnull NSIndexPath *)destinationIndex;
 
 @end

+ 9 - 1
iOSClient/Library/XLForm/XL/Descriptors/XLFormSectionDescriptor.m

@@ -125,7 +125,15 @@
 
 -(void)addFormRow:(XLFormRowDescriptor *)formRow
 {
-    [self insertObject:formRow inAllRowsAtIndex:([self canInsertUsingButton] ? MAX(0, [self.formRows count] - 1) : [self.allRows count])];
+    NSUInteger index;
+    
+    if ([self canInsertUsingButton]) {
+        index = ([self.formRows count] > 0) ? [self.formRows count] - 1 : 0;
+    } else {
+        index = [self.allRows count];
+    }
+
+    [self insertObject:formRow inAllRowsAtIndex:index];
 }
 
 -(void)addFormRow:(XLFormRowDescriptor *)formRow afterRow:(XLFormRowDescriptor *)afterRow