Move TSImageQuality enum.

// FREEBIE
pull/1/head
Matthew Chen 8 years ago
parent 27b515ea45
commit 164db41c29

@ -13,13 +13,6 @@ typedef NS_ENUM(NSUInteger, NotificationType) {
NotificationNamePreview,
};
typedef NS_ENUM(NSUInteger, TSImageQuality) {
TSImageQualityUncropped = 1,
TSImageQualityHigh = 2,
TSImageQualityMedium = 3,
TSImageQualityLow = 4
};
// Used when migrating logging to NSUserDefaults.
extern NSString *const PropertyListPreferencesSignalDatabaseCollection;
extern NSString *const PropertyListPreferencesKeyEnableDebugLog;
@ -59,8 +52,6 @@ extern NSString *const PropertyListPreferencesKeyEnableDebugLog;
- (BOOL)hasRegisteredVOIPPush;
- (void)setHasRegisteredVOIPPush:(BOOL)enabled;
- (TSImageQuality)imageUploadQuality;
+ (nullable NSString *)lastRanVersion;
+ (NSString *)setAndGetCurrentVersion;

@ -110,12 +110,6 @@ NSString *const PropertyListPreferencesKeyCallsHideIPAddress = @"CallsHideIPAddr
}
}
- (TSImageQuality)imageUploadQuality
{
// always return average image quality
return TSImageQualityMedium;
}
- (void)setScreenSecurity:(BOOL)flag
{
[self setValueForKey:PropertyListPreferencesKeyScreenSecurity toValue:@(flag)];

@ -118,10 +118,6 @@ typedef enum : NSUInteger {
- (BOOL)canPerformAction:(SEL)action withSender:(id)sender {
if (action == @selector(paste:)) {
DDLogWarn(@"UIPasteboard.generalPasteboard(): %@.",
[UIPasteboard generalPasteboard].pasteboardTypes);
DDLogWarn(@"UIPasteboard.generalPasteboard(): %d.",
(int) [UIPasteboard generalPasteboard].numberOfItems);
if ([self pasteBoardHasPossibleAttachment]) {
return YES;
}
@ -2479,9 +2475,6 @@ typedef enum : NSUInteger {
- (BOOL)composerTextView:(JSQMessagesComposerTextView *)textView
shouldPasteWithSender:(id)sender {
DDLogError(@"%@ sender: %@",
self.tag,
sender);
return YES;
}

@ -13,6 +13,13 @@ enum SignalAttachmentError: String {
case invalidFileFormat
}
enum TSImageQuality: Int {
case uncropped
case high
case medium
case low
}
// Represents a possible attachment to upload.
// The attachment may be invalid.
//
@ -260,6 +267,13 @@ class SignalAttachment: NSObject {
}
}
private class func defaultImageUploadQuality() -> TSImageQuality {
// always return average image quality
//
// TODO: Why are we using this value? Why not default to .uncropped?
return .medium
}
// If the proposed attachment already is a JPEG, and already conforms to the
// file size and content size limits, don't recompress it.
//
@ -272,8 +286,8 @@ class SignalAttachment: NSObject {
return false
}
if dataUTI == kUTTypeJPEG as String {
let imageUploadQuality = Environment.preferences().imageUploadQuality()
let maxSize = maxSizeForImage(image: image, imageUploadQuality:imageUploadQuality)
let maxSize = maxSizeForImage(image: image,
imageUploadQuality:defaultImageUploadQuality())
if image.size.width <= maxSize &&
image.size.height <= maxSize &&
imageData.count <= kMaxFileSizeImage {
@ -305,7 +319,7 @@ class SignalAttachment: NSObject {
private class func compressImageAsJPEG(image: UIImage!, attachment: SignalAttachment!) -> SignalAttachment! {
assert(attachment.error == nil)
var imageUploadQuality = Environment.preferences().imageUploadQuality()
var imageUploadQuality = defaultImageUploadQuality()
while true {
let maxSize = maxSizeForImage(image: image, imageUploadQuality:imageUploadQuality)

Loading…
Cancel
Save