UploadSettingController.m 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. //
  2. // UploadSettingController.m
  3. // RA Image
  4. //
  5. // Created by Jack on 2017/5/9.
  6. // Copyright © 2017年 USAI. All rights reserved.
  7. //
  8. #import "UploadSettingController.h"
  9. #import "RAUploadManager.h"
  10. #import "RASingleton.h"
  11. @interface UploadSettingController ()<UITextFieldDelegate>
  12. @property (strong, nonatomic) IBOutlet UISwitch *autoSwitch;
  13. @property (strong, nonatomic) IBOutlet UITextField *retryCountBox;
  14. //@property (strong, nonatomic) IBOutlet UISwitch *autoRmFinishSwitch;
  15. //@property (strong, nonatomic) IBOutlet UISwitch *autoRmErrorSwith;
  16. @property (strong, nonatomic) IBOutlet UISwitch *compressSwitch;
  17. @property (strong, nonatomic) IBOutlet UISwitch *onlyWiFiSwitch;
  18. @property (strong, nonatomic) IBOutlet UITextField *retryTimeIntervalBox;
  19. @end
  20. @implementation UploadSettingController
  21. - (void)viewDidLoad {
  22. [super viewDidLoad];
  23. // Do any additional setup after loading the view.
  24. UIBarButtonItem *saveItem = [[UIBarButtonItem alloc] initWithTitle:@"Save" style:UIBarButtonItemStylePlain target:self action:@selector(saveItemClick:)];
  25. self.navigationItem.rightBarButtonItem = saveItem;
  26. // AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
  27. // BOOL autoUpload = YES;
  28. //// BOOL autoRmFinish = YES;
  29. //// BOOL autoRmErr = NO;
  30. // BOOL compress = YES;
  31. // BOOL onlyWiFi = NO;
  32. // int retryCount = 5;
  33. // int retryTimeInterval = 300;
  34. //
  35. // NSDictionary *param = [self userDefaultsValue:kUploadSetting];
  36. // if (param) {
  37. // autoUpload = [[param objectForKey:@"auto_upload"] boolValue];
  38. // retryCount = [[param objectForKey:@"retry_count"] intValue];
  39. //// autoRmFinish = [[param objectForKey:@"auto_rm_finish"] boolValue];
  40. //// autoRmErr = [[param objectForKey:@"auto_rm_error"] boolValue];
  41. // compress = [[param objectForKey:@"compress_img"] boolValue];
  42. // onlyWiFi = [[param objectForKey:@"only_wifi"] boolValue];
  43. // NSNumber *timeInterval = [param objectForKey:@"retry_time_interval"];
  44. // if (timeInterval != nil) {
  45. // retryTimeInterval = [timeInterval intValue];
  46. // }
  47. // } else {
  48. //
  49. // autoUpload = appDelegate.uploadManager.autoStart;
  50. // retryCount = appDelegate.uploadManager.maxRetry;
  51. //// autoRmFinish = appDelegate.uploadManager.removeFinish;
  52. //// autoRmErr = appDelegate.uploadManager.removeError;
  53. // compress = appDelegate.compressFile;
  54. // onlyWiFi = appDelegate.uploadManager.onlyWiFi;
  55. // retryTimeInterval = appDelegate.uploadManager.retryTimeInterval;
  56. // }
  57. RAUPloadManagerConfigure *configure = [[RAUPloadManagerConfigure alloc] init];
  58. self.autoSwitch.on = configure.autoUpload;
  59. // self.autoRmFinishSwitch.on = autoRmFinish;
  60. // self.autoRmErrorSwith.on = autoRmErr;
  61. self.retryCountBox.text = [NSString stringWithFormat:@"%d",configure.retryCount];
  62. self.compressSwitch.on = configure.compressImage;
  63. self.onlyWiFiSwitch.on = configure.onlyWIFI;
  64. self.retryTimeIntervalBox.text = [NSString stringWithFormat:@"%d",(int)configure.retryTimeIntetval];
  65. [self registListenKeyboard];
  66. }
  67. - (void)didReceiveMemoryWarning {
  68. [super didReceiveMemoryWarning];
  69. // Dispose of any resources that can be recreated.
  70. }
  71. #pragma mark - Action
  72. - (IBAction)autoSwitchValueChange:(UISwitch *)sender {
  73. }
  74. - (IBAction)autoRmFinishClick:(UISwitch *)sender {
  75. }
  76. - (IBAction)autoRmErrClick:(UISwitch *)sender {
  77. }
  78. - (IBAction)compressSwitchClick:(UISwitch *)sender {
  79. }
  80. - (void)saveItemClick:(UIBarButtonItem *)sender {
  81. BOOL autoUpload = self.autoSwitch.isOn;
  82. // BOOL autoRmFinish = self.autoRmFinishSwitch.isOn;
  83. // BOOL autoRmErr = self.autoRmErrorSwith.isOn;
  84. BOOL compress = self.compressSwitch.isOn;
  85. int retryCount = [self.retryCountBox.text intValue];
  86. BOOL onlyWiFi = self.onlyWiFiSwitch.isOn;
  87. int retryTimeInterval = [self.retryTimeIntervalBox.text intValue];
  88. // NSDictionary *param = @{
  89. // @"auto_upload" : @(autoUpload),
  90. //// @"auto_rm_finish" : @(autoRmFinish),
  91. //// @"auto_rm_error" : @(autoRmErr),
  92. // @"compress_img" : @(compress),
  93. // @"retry_count" : @(retryCount),
  94. // @"only_wifi" : @(onlyWiFi),
  95. // @"retry_time_interval" : @(retryTimeInterval)
  96. // };
  97. // [self setUserDefaultsValue:param forKey:kUploadSetting];
  98. [RAUploadManager configureUploadManager:^(RAUPloadManagerConfigure *configure) {
  99. configure.autoUpload = autoUpload;
  100. configure.compressImage = compress;
  101. configure.retryCount = retryCount;
  102. configure.onlyWIFI = onlyWiFi;
  103. configure.retryTimeIntetval = retryTimeInterval;
  104. }];
  105. // AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
  106. // appDelegate.uploadManager.maxRetry = retryCount;
  107. // appDelegate.uploadManager.autoStart = autoUpload;
  108. // appDelegate.uploadManager.removeFinish = autoRmFinish;
  109. // appDelegate.uploadManager.removeError = autoRmErr;
  110. RASingleton.sharedInstance.compressFile = compress;
  111. // appDelegate.uploadManager.onlyWiFi = onlyWiFi;
  112. // appDelegate.uploadManager.retryTimeInterval = retryTimeInterval;
  113. [self.navigationController popViewControllerAnimated:YES];
  114. }
  115. #pragma mark - Textfield Delegate
  116. - (void)textFieldDidBeginEditing:(UITextField *)textField {
  117. self.currentFirstResponder = textField;
  118. }
  119. - (void)textFieldDidEndEditing:(UITextField *)textField {
  120. self.currentFirstResponder = nil;
  121. }
  122. @end