CCManageHelp.m 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. //
  2. // CCManageHelp.m
  3. // Crypto Cloud Technology Nextcloud
  4. //
  5. // Created by Marino Faggiana on 06/11/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 "CCManageHelp.h"
  24. #import "CCUtility.h"
  25. #import "AppDelegate.h"
  26. @interface CCManageHelp ()
  27. @end
  28. @implementation CCManageHelp
  29. - (id)initWithCoder:(NSCoder *)aDecoder
  30. {
  31. self = [super initWithCoder:aDecoder];
  32. if (self) {
  33. [self initializeForm];
  34. }
  35. return self;
  36. }
  37. - (void)initializeForm
  38. {
  39. XLFormDescriptor *form ;
  40. XLFormSectionDescriptor *section;
  41. XLFormRowDescriptor *row;
  42. form = [XLFormDescriptor formDescriptorWithTitle:NSLocalizedString(@"_help_", nil)];
  43. section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"_help_tutorial_", nil)];
  44. [form addFormSection:section];
  45. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"intro" rowType:XLFormRowDescriptorTypeButton title:[CCUtility localizableBrand:@"_help_intro_" table:nil]];
  46. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  47. [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
  48. [row.cellConfig setObject:COLOR_BRAND forKey:@"textLabel.textColor"];
  49. [row.cellConfig setObject:[UIImage imageNamed:image_settingsIntroduction] forKey:@"imageView.image"];
  50. row.action.formSelector = @selector(intro:);
  51. [section addFormRow:row];
  52. section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"_help_debug_section_", nil)];
  53. [form addFormSection:section];
  54. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"activityVerboseDebug" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_help_debug_Activity_verbose_", nil)];
  55. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  56. [row.cellConfig setObject:[UIImage imageNamed:image_settingsDebug] forKey:@"imageView.image"];
  57. if ([CCUtility getActivityVerboseDebug]) row.value = @"1";
  58. else row.value = @"0";
  59. [section addFormRow:row];
  60. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"sendMailDebug" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_help_debug_Activity_mail_", nil)];
  61. [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
  62. [row.cellConfig setObject:COLOR_BRAND forKey:@"textLabel.textColor"];
  63. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  64. [row.cellConfig setObject:[UIImage imageNamed:image_settingsKeyMail] forKey:@"imageView.image"];
  65. row.action.formSelector = @selector(sendMail:);
  66. [section addFormRow:row];
  67. section = [XLFormSectionDescriptor formSection];
  68. [form addFormSection:section];
  69. self.form = form;
  70. }
  71. - (void)viewDidLoad
  72. {
  73. [super viewDidLoad];
  74. // Color
  75. [CCAspect aspectNavigationControllerBar:self.navigationController.navigationBar encrypted:NO online:[app.reachability isReachable] hidden:NO];
  76. [CCAspect aspectTabBar:self.tabBarController.tabBar hidden:NO];
  77. // Intro
  78. self.intro = [[CCIntro alloc] initWithDelegate:self delegateView:self.splitViewController.view];
  79. }
  80. // Apparirà
  81. - (void)viewWillAppear:(BOOL)animated
  82. {
  83. [super viewWillAppear:animated];
  84. // Color
  85. [CCAspect aspectNavigationControllerBar:self.navigationController.navigationBar encrypted:NO online:[app.reachability isReachable] hidden:NO];
  86. [CCAspect aspectTabBar:self.tabBarController.tabBar hidden:NO];
  87. }
  88. - (void)formRowDescriptorValueHasChanged:(XLFormRowDescriptor *)rowDescriptor oldValue:(id)oldValue newValue:(id)newValue
  89. {
  90. [super formRowDescriptorValueHasChanged:rowDescriptor oldValue:oldValue newValue:newValue];
  91. if ([rowDescriptor.tag isEqualToString:@"activityVerboseDebug"]) {
  92. if ([[rowDescriptor.value valueData] boolValue] == YES) {
  93. [CCUtility setActivityVerboseDebug:true];
  94. } else {
  95. [CCUtility setActivityVerboseDebug:false];
  96. }
  97. }
  98. }
  99. #pragma --------------------------------------------------------------------------------------------
  100. #pragma mark === Intro ===
  101. #pragma --------------------------------------------------------------------------------------------
  102. - (void)intro:(XLFormRowDescriptor *)sender
  103. {
  104. [self deselectFormRow:sender];
  105. [self.intro showIntroCryptoCloud:0.1];
  106. }
  107. #pragma --------------------------------------------------------------------------------------------
  108. #pragma mark === Mail ===
  109. #pragma --------------------------------------------------------------------------------------------
  110. - (void) mailComposeController:(MFMailComposeViewController *)vc didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
  111. {
  112. switch (result)
  113. {
  114. case MFMailComposeResultCancelled:
  115. [app messageNotification:@"_info_" description:@"_mail_deleted_" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeSuccess];
  116. break;
  117. case MFMailComposeResultSaved:
  118. [app messageNotification:@"_info_" description:@"_mail_saved_" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeSuccess];
  119. break;
  120. case MFMailComposeResultSent:
  121. [app messageNotification:@"_info_" description:@"_mail_sent_" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeSuccess];
  122. break;
  123. case MFMailComposeResultFailed: {
  124. NSString *msg = [NSString stringWithFormat:NSLocalizedString(@"_mail_failure_", nil), [error localizedDescription]];
  125. [app messageNotification:@"_error_" description:msg visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError];
  126. }
  127. break;
  128. default:
  129. break;
  130. }
  131. // Close the Mail Interface
  132. [self dismissViewControllerAnimated:YES completion:NULL];
  133. }
  134. - (void)sendMail:(XLFormRowDescriptor *)sender
  135. {
  136. // Email Subject
  137. NSString *emailTitle = NSLocalizedString(@"_information_req_", nil);
  138. // Email Content
  139. NSString *messageBody;
  140. // Email Recipents
  141. NSArray *toRecipents;
  142. messageBody = [NSString stringWithFormat:@"\n\n\n%@ Version %@ (%@)", k_brand,[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"], [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]];
  143. toRecipents = [NSArray arrayWithObject:k_mailMe];
  144. MFMailComposeViewController *mc = [[MFMailComposeViewController alloc] init];
  145. mc.mailComposeDelegate = self;
  146. [mc setSubject:emailTitle];
  147. [mc setMessageBody:messageBody isHTML:NO];
  148. [mc setToRecipients:toRecipents];
  149. // Present mail view controller on screen
  150. [self presentViewController:mc animated:YES completion:NULL];
  151. }
  152. @end