session-ios/Signal/src/view controllers/SettingsTableViewCell.m

66 lines
1.8 KiB
Mathematica
Raw Normal View History

2014-10-29 21:58:58 +01:00
//
// SettingsTableViewCell.m
// Signal
//
// Created by Dylan Bourgeois on 11/11/14.
// Copyright (c) 2014 Open Whisper Systems. All rights reserved.
//
#import "SettingsTableViewCell.h"
#import "Environment.h"
#import "PreferencesUtil.h"
2014-10-29 21:58:58 +01:00
@implementation SettingsTableViewCell
- (void)awakeFromNib {
2014-12-26 21:17:43 +01:00
if (self.toggle) {
[self.toggle setOn:[Environment.preferences screenSecurityIsEnabled]];
[self.toggle addTarget:self action:@selector(toggleSetting:) forControlEvents:UIControlEventValueChanged];
}
if ([self.reuseIdentifier isEqualToString:@"imageUploadQuality"]) {
[self updateImageQualityLabel];
}
2014-10-29 21:58:58 +01:00
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
}
#pragma mark - UISwitch
-(void)toggleSetting:(id)sender
{
2014-12-04 22:14:37 +01:00
if ([self.reuseIdentifier isEqualToString:@"enableScreenSecurity"]) {
[Environment.preferences setScreenSecurity:self.toggle.isOn];
2014-10-29 21:58:58 +01:00
}
}
2014-12-26 21:17:43 +01:00
#pragma mark - Detail Label
-(void)updateImageQualityLabel
{
/* this is currently unused, thus unlocalized. code should probably be excised as this will never be part of design */
2014-12-26 21:17:43 +01:00
switch ([Environment.preferences imageUploadQuality]) {
case TSImageQualityUncropped:
self.detailLabel.text = @"Full";
break;
2014-12-26 21:17:43 +01:00
case TSImageQualityHigh:
self.detailLabel.text = @"High";
break;
case TSImageQualityMedium:
self.detailLabel.text = @"Medium";
break;
case TSImageQualityLow:
self.detailLabel.text = @"Low";
break;
default:
2014-12-29 22:40:33 +01:00
DDLogWarn(@"Unknown Image Quality setting : %lu <%s>", [Environment.preferences imageUploadQuality], __PRETTY_FUNCTION__);
2014-12-26 21:17:43 +01:00
break;
}
}
2014-10-29 21:58:58 +01:00
@end