Skip to content

Commit

Permalink
Merge pull request #232 from apptentive/branch_5.2.4
Browse files Browse the repository at this point in the history
Release 5.2.4
  • Loading branch information
weeeBox authored May 17, 2019
2 parents 2ed5687 + a17088c commit c0dccd2
Show file tree
Hide file tree
Showing 27 changed files with 121 additions and 155 deletions.
6 changes: 0 additions & 6 deletions .travis.yml

This file was deleted.

8 changes: 4 additions & 4 deletions Apptentive/Apptentive.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2394,7 +2394,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 23;
CURRENT_PROJECT_VERSION = 24;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
Expand Down Expand Up @@ -2452,7 +2452,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 23;
CURRENT_PROJECT_VERSION = 24;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
Expand Down Expand Up @@ -2484,7 +2484,7 @@
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = 86WML2UN43;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 23;
DYLIB_CURRENT_VERSION = 24;
DYLIB_INSTALL_NAME_BASE = "@rpath";
GCC_PREFIX_HEADER = "Apptentive/Misc/ApptentiveConnect-Prefix.pch";
GCC_PREPROCESSOR_DEFINITIONS = "APPTENTIVE_DEBUG=1";
Expand All @@ -2506,7 +2506,7 @@
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = 86WML2UN43;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 23;
DYLIB_CURRENT_VERSION = 24;
DYLIB_INSTALL_NAME_BASE = "@rpath";
GCC_PREFIX_HEADER = "Apptentive/Misc/ApptentiveConnect-Prefix.pch";
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
Expand Down
2 changes: 1 addition & 1 deletion Apptentive/Apptentive/Apptentive.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ FOUNDATION_EXPORT double ApptentiveVersionNumber;
FOUNDATION_EXPORT const unsigned char ApptentiveVersionString[];

/** The version number of the Apptentive SDK. */
#define kApptentiveVersionString @"5.2.3"
#define kApptentiveVersionString @"5.2.4"

/** The version number of the Apptentive API platform. */
#define kApptentiveAPIVersionString @"9"
Expand Down
5 changes: 4 additions & 1 deletion Apptentive/Apptentive/Apptentive.m
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ - (void)sendAttachmentText:(NSString *)text {
}

ApptentiveMessage *message = [[ApptentiveMessage alloc] initWithBody:text attachments:nil automated:NO customData:nil creationDate:[NSDate date]];
message.hidden = YES;
ApptentiveAssertNotNil(message, @"Message is nil");

if (message != nil) {
Expand Down Expand Up @@ -268,6 +269,7 @@ - (void)sendAttachmentImage:(UIImage *)image {
ApptentiveAssertNotNil(attachment, @"Attachment is nil");
if (attachment != nil) {
ApptentiveMessage *message = [[ApptentiveMessage alloc] initWithBody:nil attachments:@[attachment] automated:NO customData:nil creationDate:[NSDate date]];
message.hidden = YES;
ApptentiveAssertNotNil(message, @"Message is nil");

if (message != nil) {
Expand Down Expand Up @@ -308,8 +310,9 @@ - (void)sendAttachmentFile:(NSData *)fileData withMimeType:(NSString *)mimeType

if (attachment != nil) {
ApptentiveMessage *message = [[ApptentiveMessage alloc] initWithBody:nil attachments:@[attachment] automated:NO customData:nil creationDate:[NSDate date]];

message.hidden = YES;
ApptentiveAssertNotNil(message, @"Message is nil");

if (message != nil) {
if (self.messageManager) {
[self.messageManager enqueueMessageForSending:message];
Expand Down
65 changes: 26 additions & 39 deletions Apptentive/Apptentive/Apptentive.storyboard

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions Apptentive/Apptentive/Engagement/Model/ApptentiveAppRelease.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ NS_ASSUME_NONNULL_BEGIN
*/
@property (readonly, strong, nonatomic) NSString *type;


/**
The bundle identifier of the app, e.g. com.example.MyApp
*/
@property (readonly, strong, nonatomic) NSString *bundleIdentifier;

/**
The version object corresponding to the value of the
`CFBundleShortVersionString` key in the application's `Info.plist` file.
Expand Down
5 changes: 5 additions & 0 deletions Apptentive/Apptentive/Engagement/Model/ApptentiveAppRelease.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
NS_ASSUME_NONNULL_BEGIN

static NSString *const TypeKey = @"type";
static NSString *const BundleIdentifierKey = @"bundleIdentifier";
static NSString *const VersionKey = @"version";
static NSString *const BuildKey = @"build";
static NSString *const HasAppStoreReceiptKey = @"hasAppStoreReceipt";
Expand Down Expand Up @@ -62,6 +63,7 @@ - (instancetype)initWithCurrentAppRelease {

if (self) {
_type = @"ios";
_bundleIdentifier = NSBundle.mainBundle.infoDictionary[@"CFBundleIdentifier"];
_version = [[ApptentiveVersion alloc] initWithString:[NSBundle mainBundle].infoDictionary[@"CFBundleShortVersionString"]];
_build = [[ApptentiveVersion alloc] initWithString:[NSBundle mainBundle].infoDictionary[(NSString *)kCFBundleVersionKey]];
_hasAppStoreReceipt = [NSData dataWithContentsOfURL:[NSBundle mainBundle].appStoreReceiptURL] != nil;
Expand Down Expand Up @@ -89,6 +91,7 @@ - (nullable instancetype)initWithCoder:(NSCoder *)coder {

if (self) {
_type = [coder decodeObjectOfClass:[NSString class] forKey:TypeKey];
_bundleIdentifier = [coder decodeObjectOfClass:[NSString class] forKey:BundleIdentifierKey];
_version = [coder decodeObjectOfClass:[ApptentiveVersion class] forKey:VersionKey];
_build = [coder decodeObjectOfClass:[ApptentiveVersion class] forKey:BuildKey];
_hasAppStoreReceipt = [coder decodeBoolForKey:HasAppStoreReceiptKey];
Expand Down Expand Up @@ -119,6 +122,7 @@ - (void)encodeWithCoder:(NSCoder *)coder {
[super encodeWithCoder:coder];

[coder encodeObject:self.type forKey:TypeKey];
[coder encodeObject:self.bundleIdentifier forKey:BundleIdentifierKey];
[coder encodeObject:self.version forKey:VersionKey];
[coder encodeObject:self.build forKey:BuildKey];
[coder encodeBool:self.hasAppStoreReceipt forKey:HasAppStoreReceiptKey];
Expand Down Expand Up @@ -235,6 +239,7 @@ - (NSNumber *)boxedOverridingStyles {
+ (NSDictionary *)JSONKeyPathMapping {
return @{
@"type": NSStringFromSelector(@selector(type)),
@"cf_bundle_identifier": NSStringFromSelector(@selector(bundleIdentifier)),
@"cf_bundle_short_version_string": NSStringFromSelector(@selector(versionString)),
@"cf_bundle_version": NSStringFromSelector(@selector(buildString)),
@"app_store_receipt": NSStringFromSelector(@selector(appStoreReceiptDictionary)),
Expand Down
2 changes: 1 addition & 1 deletion Apptentive/Apptentive/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>5.2.3</string>
<string>5.2.4</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ typedef NS_ENUM(NSInteger, ATMessageCenterMessageStatus) {
@property (readonly, nonatomic) NSString *profileInitialEmailPlaceholder;
@property (readonly, nonatomic) NSString *profileInitialSkipButtonTitle;
@property (readonly, nonatomic) NSString *profileInitialSaveButtonTitle;
@property (readonly, nonatomic) NSString *profileInitialEmailExplanation;

@property (readonly, nonatomic) NSString *profileEditTitle;
@property (readonly, nonatomic) NSString *profileEditNamePlaceholder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,6 @@ - (NSString *)profileInitialSaveButtonTitle {
return self.interaction.configuration[@"profile"][@"initial"][@"save_button"];
}

- (NSString *)profileInitialEmailExplanation {
return self.interaction.configuration[@"profile"][@"initial"][@"email_explanation"];
}

#pragma mark - Profile (Edit)

- (NSString *)profileEditTitle {
Expand Down Expand Up @@ -300,6 +296,10 @@ - (nullable NSDate *)dateOfMessageGroupAtIndex:(NSInteger)index {
- (ATMessageCenterMessageStatus)statusOfMessageAtIndexPath:(NSIndexPath *)indexPath {
ApptentiveMessage *message = [self messageAtIndexPath:indexPath];

if (message.hidden) {
return ATMessageCenterMessageStatusHidden;
}

switch (message.state) {
case ApptentiveMessageStateFailedToSend:
return ATMessageCenterMessageStatusFailed;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,6 @@ - (void)configureView {
self.profileView.containerView.backgroundColor = [self.viewModel.styleSheet colorForStyle:ApptentiveColorBackground];
self.profileView.titleLabel.text = self.viewModel.profileInitialTitle;
self.profileView.titleLabel.textColor = [self.viewModel.styleSheet colorForStyle:ApptentiveTextStyleButton];
self.profileView.requiredLabel.text = self.viewModel.profileInitialEmailExplanation;
self.profileView.requiredLabel.textColor = [self.viewModel.styleSheet colorForStyle:ApptentiveTextStyleSurveyInstructions];
[self.profileView.saveButton setTitle:self.viewModel.profileInitialSaveButtonTitle forState:UIControlStateNormal];
[self.profileView.skipButton setTitle:self.viewModel.profileInitialSkipButtonTitle forState:UIControlStateNormal];
self.profileView.skipButton.hidden = self.viewModel.profileRequired;
Expand All @@ -306,14 +304,11 @@ - (void)configureView {

if (self.viewModel.profileRequired && [self shouldShowProfileViewBeforeComposing:YES]) {
self.profileView.skipButton.hidden = YES;
self.profileView.mode = ATMessageCenterProfileModeCompact;

self.composeButtonItem.enabled = NO;
self.neuMessageButtonItem.enabled = NO;
} else {
self.profileView.mode = ATMessageCenterProfileModeFull;
}
} else {
} else {
self.navigationItem.leftBarButtonItem = nil;
}
}
Expand Down Expand Up @@ -743,8 +738,6 @@ - (IBAction)clear:(UIButton *)sender {
}

- (IBAction)showWho:(id)sender {
self.profileView.mode = ATMessageCenterProfileModeFull;

self.profileView.skipButton.hidden = NO;
self.profileView.titleLabel.text = self.viewModel.profileEditTitle;

Expand Down Expand Up @@ -1254,7 +1247,6 @@ - (void)updateHeaderFooterTextSize:(nullable NSNotification *)notification {
self.profileView.titleLabel.font = [self.viewModel.styleSheet fontForStyle:ApptentiveTextStyleButton];
self.profileView.saveButton.titleLabel.font = [self.viewModel.styleSheet fontForStyle:ApptentiveTextStyleDoneButton];
self.profileView.skipButton.titleLabel.font = [self.viewModel.styleSheet fontForStyle:ApptentiveTextStyleButton];
self.profileView.requiredLabel.font = [self.viewModel.styleSheet fontForStyle:ApptentiveTextStyleSurveyInstructions];
self.profileView.nameField.font = [self.viewModel.styleSheet fontForStyle:ApptentiveTextStyleTextInput];
self.profileView.emailField.font = [self.viewModel.styleSheet fontForStyle:ApptentiveTextStyleTextInput];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,14 @@ - (nullable instancetype)initWithData:(NSData *)data contentType:(NSString *)con
_attachmentDirectoryPath = attachmentDirectoryPath;

NSURL *URL = [self permanentLocation];
[data writeToURL:URL atomically:YES];
NSError *error = nil;
BOOL success = [data writeToURL:URL options:NSDataWritingAtomic | NSDataWritingFileProtectionCompleteUntilFirstUserAuthentication error:&error];

if (!success) {
ApptentiveLogError(ApptentiveLogTagMessages, @"Failed to write attachment to path");
return nil;
}

_filename = URL.lastPathComponent;
_size = [data length];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ typedef NS_ENUM(NSInteger, ApptentiveMessageState) {
ApptentiveMessageStateSent,
ApptentiveMessageStateFailedToSend,
ApptentiveMessageStateUnread,
ApptentiveMessageStateRead,
ApptentiveMessageStateHidden
ApptentiveMessageStateRead
};


Expand All @@ -38,6 +37,7 @@ typedef NS_ENUM(NSInteger, ApptentiveMessageState) {
@property (readonly, nonatomic) BOOL automated;
@property (readonly, nullable, nonatomic) NSDictionary *customData;
@property (readonly, nonatomic) BOOL inbound;
@property (assign, nonatomic) BOOL hidden;

- (nullable instancetype)initWithJSON:(NSDictionary *)JSON;
- (nullable instancetype)initWithBody:(nullable NSString *)body attachments:(nullable NSArray *)attachments automated:(BOOL)automated customData:(NSDictionary *_Nullable)customData creationDate:(NSDate *)creationDate;
Expand Down
15 changes: 9 additions & 6 deletions Apptentive/Apptentive/Message Center/Model/ApptentiveMessage.m
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,17 @@ - (nullable instancetype)initWithJSON:(NSDictionary *)JSON {
_inbound = YES;
}


if ([JSON[@"hidden"] isKindOfClass:[NSNumber class]] && [JSON[@"hidden"] boolValue]) {
_state = ApptentiveMessageStateHidden;
_hidden = YES;
} else {
if (_inbound) {
_state = ApptentiveMessageStateSent;
} else {
_state = ApptentiveMessageStateUnread;
}
_hidden = NO;
}

if (_inbound) {
_state = ApptentiveMessageStateSent;
} else {
_state = ApptentiveMessageStateUnread;
}

_identifier = ApptentiveDictionaryGetString(JSON, @"id");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,15 @@

NS_ASSUME_NONNULL_BEGIN

typedef NS_ENUM(NSInteger, ATMessageCenterProfileMode) {
ATMessageCenterProfileModeCompact = 1,
ATMessageCenterProfileModeFull
};


@interface ApptentiveMessageCenterProfileView : UIView

@property (assign, nonatomic) ATMessageCenterProfileMode mode;
@property (weak, nonatomic) IBOutlet UIView *containerView;
@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
@property (weak, nonatomic) IBOutlet UITextField *nameField;
@property (weak, nonatomic) IBOutlet UITextField *emailField;
@property (weak, nonatomic) IBOutlet UIButton *skipButton;
@property (weak, nonatomic) IBOutlet UIButton *saveButton;
@property (weak, nonatomic) IBOutlet UILabel *requiredLabel;
@property (strong, nonatomic) UIColor *borderColor;

@end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ @interface ApptentiveMessageCenterProfileView ()
@property (strong, nonatomic) NSArray *portraitFullConstraints;
@property (strong, nonatomic) NSArray *landscapeFullConstraints;

@property (strong, nonatomic) NSArray *portraitCompactConstraints;
@property (strong, nonatomic) NSArray *landscapeCompactConstraints;

@property (strong, nonatomic) NSArray *baseConstraints;

@end
Expand All @@ -42,14 +39,12 @@ - (void)awakeFromNib {
self.buttonBar.layer.borderWidth = borderWidth;

self.portraitFullConstraints = @[self.nameTrailingConstraint, self.emailLeadingConstraint, self.nameVerticalSpaceToEmail];
self.portraitCompactConstraints = @[self.nameTrailingConstraint, self.emailLeadingConstraint];

self.nameHorizontalSpaceToEmail = [NSLayoutConstraint constraintWithItem:self.nameField attribute:NSLayoutAttributeTrailing relatedBy:NSLayoutRelationEqual toItem:self.emailField attribute:NSLayoutAttributeLeading multiplier:1.0 constant:-8.0];
NSLayoutConstraint *nameEmailTopAlignment = [NSLayoutConstraint constraintWithItem:self.nameField attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.emailField attribute:NSLayoutAttributeTop multiplier:1.0 constant:0.0];
NSLayoutConstraint *nameEmailBottomAlignment = [NSLayoutConstraint constraintWithItem:self.nameField attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.emailField attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0.0];

self.landscapeFullConstraints = @[self.nameHorizontalSpaceToEmail, nameEmailTopAlignment, nameEmailBottomAlignment];
self.landscapeCompactConstraints = @[self.emailLeadingConstraint, nameEmailTopAlignment, nameEmailBottomAlignment];

// Find constraints common to both modes/orientations
NSMutableSet *baseConstraintSet = [NSMutableSet setWithArray:self.containerView.constraints];
Expand All @@ -60,11 +55,7 @@ - (void)awakeFromNib {
}

- (BOOL)becomeFirstResponder {
if (self.mode == ATMessageCenterProfileModeFull) {
return [self.nameField becomeFirstResponder];
} else {
return [self.emailField becomeFirstResponder];
}
return [self.nameField becomeFirstResponder];
}

- (void)setBorderColor:(UIColor *)borderColor {
Expand All @@ -79,65 +70,12 @@ - (void)traitCollectionDidChange:(nullable UITraitCollection *)previousTraitColl

// Deactivate all, then selectively re-activate
[NSLayoutConstraint deactivateConstraints:self.portraitFullConstraints];
[NSLayoutConstraint deactivateConstraints:self.portraitCompactConstraints];
[NSLayoutConstraint deactivateConstraints:self.landscapeFullConstraints];
[NSLayoutConstraint deactivateConstraints:self.landscapeCompactConstraints];

if (self.traitCollection.verticalSizeClass == UIUserInterfaceSizeClassCompact) {
switch (self.mode) {
case ATMessageCenterProfileModeFull:
[NSLayoutConstraint activateConstraints:self.landscapeFullConstraints];
break;

case ATMessageCenterProfileModeCompact:
[NSLayoutConstraint activateConstraints:self.landscapeCompactConstraints];
break;
}
[NSLayoutConstraint activateConstraints:self.landscapeFullConstraints];
} else {
switch (self.mode) {
case ATMessageCenterProfileModeFull:
[NSLayoutConstraint activateConstraints:self.portraitFullConstraints];
break;

case ATMessageCenterProfileModeCompact:
[NSLayoutConstraint activateConstraints:self.portraitCompactConstraints];
break;
}
}
}

- (void)setMode:(ATMessageCenterProfileMode)mode {
if (_mode != mode) {
_mode = mode;

CGFloat nameFieldAlpha;

if (mode == ATMessageCenterProfileModeCompact) {
self.requiredLabel.hidden = NO;
nameFieldAlpha = 0;
self.emailVerticalSpaceToButtonBar.constant = 37.0;
} else {
self.nameField.hidden = NO;
nameFieldAlpha = 1;
self.emailVerticalSpaceToButtonBar.constant = 16.0;
}

[self traitCollectionDidChange:self.traitCollection];

[UIView animateWithDuration:0.25
animations:^{
self.nameField.alpha = nameFieldAlpha;
self.requiredLabel.alpha = 1.0 - nameFieldAlpha;

[self layoutIfNeeded];
}
completion:^(BOOL finished) {
if (nameFieldAlpha == 0) {
self.nameField.hidden = YES;
} else {
self.requiredLabel.hidden = YES;
}
}];
[NSLayoutConstraint activateConstraints:self.portraitFullConstraints];
}
}

Expand Down
Loading

0 comments on commit c0dccd2

Please sign in to comment.