CCManageOptimizations.m 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. //
  2. // CCManageOptimizations.m
  3. // Crypto Cloud Technology Nextcloud
  4. //
  5. // Created by Marino Faggiana on 22/09/15.
  6. // Copyright (c) 2014 TWS. All rights reserved.
  7. //
  8. // Author Marino Faggiana <m.faggiana@twsweb.it>
  9. //
  10. // This program is free software: you can redistribute it and/or modify
  11. // it under the terms of the GNU General Public License as published by
  12. // the Free Software Foundation, either version 3 of the License, or
  13. // (at your option) any later version.
  14. //
  15. // This program is distributed in the hope that it will be useful,
  16. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. // GNU General Public License for more details.
  19. //
  20. // You should have received a copy of the GNU General Public License
  21. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. //
  23. #import "CCManageOptimizations.h"
  24. #import "CCUtility.h"
  25. #import "AppDelegate.h"
  26. @implementation CCManageOptimizations
  27. - (id)initWithCoder:(NSCoder *)aDecoder
  28. {
  29. self = [super initWithCoder:aDecoder];
  30. if (self) {
  31. [self initializeForm];
  32. }
  33. return self;
  34. }
  35. - (void)initializeForm
  36. {
  37. XLFormDescriptor *form ;
  38. XLFormSectionDescriptor *section;
  39. XLFormRowDescriptor *row;
  40. form = [XLFormDescriptor formDescriptorWithTitle:NSLocalizedString(@"_optimizations_", nil)];
  41. section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"_optimized_photos_", nil)];
  42. [form addFormSection:section];
  43. section.footerTitle = NSLocalizedString(@"_optimized_photos_how_", nil);
  44. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"optimizedphoto" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_optimized_photos_", nil)];
  45. if ([CCUtility getOptimizedPhoto]) row.value = @"1";
  46. else row.value = @"0";
  47. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  48. [section addFormRow:row];
  49. section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"_upload_del_photos_", nil)];
  50. [form addFormSection:section];
  51. section.footerTitle = [CCUtility localizableBrand:@"_upload_del_photos_how_" table:nil];
  52. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"uploadremovephoto" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_upload_del_photos_", nil)];
  53. if ([CCUtility getUploadAndRemovePhoto]) row.value = @"1";
  54. else row.value = @"0";
  55. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  56. [section addFormRow:row];
  57. section = [XLFormSectionDescriptor formSection];
  58. [form addFormSection:section];
  59. self.form = form;
  60. }
  61. // Apparirà
  62. - (void)viewWillAppear:(BOOL)animated
  63. {
  64. [super viewWillAppear:animated];
  65. // Color
  66. [CCAspect aspectNavigationControllerBar:self.navigationController.navigationBar encrypted:NO online:[app.reachability isReachable] hidden:NO];
  67. [CCAspect aspectTabBar:self.tabBarController.tabBar hidden:NO];
  68. }
  69. -(void)formRowDescriptorValueHasChanged:(XLFormRowDescriptor *)rowDescriptor oldValue:(id)oldValue newValue:(id)newValue
  70. {
  71. [super formRowDescriptorValueHasChanged:rowDescriptor oldValue:oldValue newValue:newValue];
  72. if ([rowDescriptor.tag isEqualToString:@"optimizedphoto"]) {
  73. if ([[rowDescriptor.value valueData] boolValue] == YES) {
  74. [CCUtility setOptimizedPhoto:YES];
  75. } else {
  76. [CCUtility setOptimizedPhoto:NO];
  77. }
  78. }
  79. if ([rowDescriptor.tag isEqualToString:@"uploadremovephoto"]) {
  80. if ([[rowDescriptor.value valueData] boolValue] == YES) {
  81. [CCUtility setUploadAndRemovePhoto:YES];
  82. } else {
  83. [CCUtility setUploadAndRemovePhoto:NO];
  84. }
  85. }
  86. }
  87. @end