Move TSImageQuality enum.

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

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

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

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

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

Loading…
Cancel
Save