Skip to content

Commit

Permalink
Separate media up / download settings
Browse files Browse the repository at this point in the history
improves #968
  • Loading branch information
FriedrichAltheide committed Nov 17, 2023
1 parent 4b91236 commit d236a91
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 16 deletions.
44 changes: 29 additions & 15 deletions Monal/Classes/MLAutoDownloadFiletransferSettingViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@

enum MLAutoDownloadFiletransferSettingViewController {
FiletransferSettingsGeneralSettings,
FiletransferSettingsAdvancedSettings,
FiletransferSettingsAdvancedDownloadSettings,
FiletransferSettingsAdvancedUploadSettings,
FiletransferSettingSectionCnt
};

Expand All @@ -33,16 +34,19 @@ - (void)viewDidLoad {
self.navigationItem.title = NSLocalizedString(@"Auto-Download Media", @"");
}

-(nullable NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
-(nullable NSString*) tableView:(UITableView*) tableView titleForHeaderInSection:(NSInteger) section
{
NSString* sectionTitle = nil;
switch(section)
{
case FiletransferSettingsGeneralSettings:
sectionTitle = NSLocalizedString(@"General File Transfer Settings", @"");
break;
case FiletransferSettingsAdvancedSettings:
sectionTitle = NSLocalizedString(@"Maximum File Transfer Size", @"");
case FiletransferSettingsAdvancedDownloadSettings:
sectionTitle = NSLocalizedString(@"Download Settings", @"");
break;
case FiletransferSettingsAdvancedUploadSettings:
sectionTitle = NSLocalizedString(@"Upload Settings", @"");
break;
default:
break;
Expand All @@ -62,8 +66,10 @@ -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)
{
case FiletransferSettingsGeneralSettings:
return 1;
case FiletransferSettingsAdvancedSettings:
return 3;
case FiletransferSettingsAdvancedDownloadSettings:
return 2;
case FiletransferSettingsAdvancedUploadSettings:
return 1;
default:
unreachable();
break;
Expand Down Expand Up @@ -91,8 +97,8 @@ -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NS
unreachable();
}
break;
case FiletransferSettingsAdvancedSettings:
switch (indexPath.row)
case FiletransferSettingsAdvancedDownloadSettings:
switch(indexPath.row)
{
case 0:
{
Expand All @@ -115,7 +121,7 @@ -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NS
// byte -> mb
float mb = sliderValue / 1024 / 1024;
labelToUpdate.text = [NSString stringWithFormat:NSLocalizedString(@"Load over cellular upto: %.fMB", @""), mb];

return mb;
} withUpdateFunc:^(UILabel* labelToUpdate, float sliderValue) {
float newValue = roundf(sliderValue);
Expand All @@ -125,15 +131,23 @@ -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NS
}];
break;
}
case 2:
default:
unreachable();
break;
}
break;
case FiletransferSettingsAdvancedUploadSettings:
switch(indexPath.row)
{
case 0:
{
[cell initCell:NSLocalizedString(@"Image Quality", @"") withSliderDefaultsKey:@"ImageUploadQuality" minValue:0.33f maxValue:1.0 withLoadFunc:^(UILabel* labelToUpdate, float sliderValue) {
[cell initCell:NSLocalizedString(@"Image Upload Quality", @"") withSliderDefaultsKey:@"ImageUploadQuality" minValue:0.33f maxValue:1.0 withLoadFunc:^(UILabel* labelToUpdate, float sliderValue) {
float rate = roundf(sliderValue * 100) / 100;
labelToUpdate.text = [NSString stringWithFormat:NSLocalizedString(@"Image Quality: %.2f", @""), rate];
labelToUpdate.text = [NSString stringWithFormat:NSLocalizedString(@"Image Upload Quality: %.2f", @""), rate];
return rate;
} withUpdateFunc:^(UILabel* labelToUpdate, float sliderValue) {
float rate = roundf(sliderValue * 100) / 100;
labelToUpdate.text = [NSString stringWithFormat:NSLocalizedString(@"Image Quality: %.2f", @""), rate];
labelToUpdate.text = [NSString stringWithFormat:NSLocalizedString(@"Image Upload Quality: %.2f", @""), rate];
return rate;
}];
break;
Expand All @@ -149,15 +163,15 @@ -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NS
return cell;
}

-(void)sliderValueChanged:(UISlider*) slider
-(void) sliderValueChanged:(UISlider*) slider
{
int maxFileSize = (int)slider.value;
[sliderResultLabel setText:[NSString stringWithFormat:@"%d MB", maxFileSize]];
[sliderResultLabel adjustsFontSizeToFitWidth];
[[HelperTools defaultsDB] setInteger:(maxFileSize * 1024 * 1024) forKey:@"AutodownloadFiletransfersMaxSize"];
}

-(void)updateUI
-(void) updateUI
{
BOOL isAutodownloadFiletransfers = [[HelperTools defaultsDB] boolForKey:@"AutodownloadFiletransfers"];
[slider setUserInteractionEnabled:isAutodownloadFiletransfers];
Expand Down
2 changes: 1 addition & 1 deletion Monal/Classes/MLPrivacySettingsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
}
case 10:
{
[cell initTapCell:NSLocalizedString(@"Auto-Download Media Settings", @"")];
[cell initTapCell:NSLocalizedString(@"Media Upload & Download Settings", @"")];
break;
}
case 11:
Expand Down

0 comments on commit d236a91

Please sign in to comment.