Swiftgram/Classes/BITFeedbackActivity.m
Andreas Linde 11a8a14e4f Add support for excluding features at compile time
Features can be excluded/included at compile-time using #define statements, e.g. using `Preprocessor Macros`. These don't influence if the feature will actually be enabled, since that can also be done at runtime and some features are disabled automatically in the App Store or disabled by default in general.

The BITHockeyManager header file will still reference all modules, but accessing the modules will not be possible if excluded from the library.

Value of 1 includes the feature into the static library, 0 will exclude the feature from the static library.

Defaults:

Crash Reporting: HOCKEYSDK_FEATURE_CRASH_REPORTER 1
Feedback: HOCKEYSDK_FEATURE_FEEDBACK 1
App Store Updates: HOCKEYSDK_FEATURE_STORE_UPDATES 1 (This feature is disabled by default in code!)
Authenticator: HOCKEYSDK_FEATURE_AUTHENTICATOR 1
Beta Updates: HOCKEYSDK_FEATURE_UPDATES 1
Jira Mobile Connect: HOCKEYSDK_FEATURE_JIRA_MOBILE_CONNECT 0
2013-09-11 19:18:21 +02:00

117 lines
2.8 KiB
Objective-C

//
// BITFeedbackActivity.m
// HockeySDK
//
// Created by Andreas Linde on 15.10.12.
//
//
#import "HockeySDK.h"
#if HOCKEYSDK_FEATURE_FEEDBACK
#import "HockeySDKPrivate.h"
#import "BITFeedbackActivity.h"
#import "BITHockeyHelper.h"
#import "BITFeedbackManagerPrivate.h"
#import "BITHockeyBaseManagerPrivate.h"
@interface BITFeedbackActivity()
@property (nonatomic, strong) NSMutableArray *items;
@end
@implementation BITFeedbackActivity
#pragma mark - NSObject
- (id)init {
if ((self = [super init])) {
_customActivityImage = nil;
_customActivityTitle = nil;
self.items = [NSMutableArray array];;
}
return self;
}
#pragma mark - UIActivity
- (NSString *)activityType {
return @"UIActivityTypePostToHockeySDKFeedback";
}
- (NSString *)activityTitle {
if (self.customActivityTitle)
return self.customActivityTitle;
NSString *appName = bit_appName(BITHockeyLocalizedString(@"HockeyFeedbackActivityAppPlaceholder"));
return [NSString stringWithFormat:BITHockeyLocalizedString(@"HockeyFeedbackActivityButtonTitle"), appName];
}
- (UIImage *)activityImage {
if (self.customActivityImage)
return self.customActivityImage;
return bit_imageNamed(@"feedbackActiviy.png", BITHOCKEYSDK_BUNDLE);
}
- (BOOL)canPerformWithActivityItems:(NSArray *)activityItems {
if ([BITHockeyManager sharedHockeyManager].disableFeedbackManager) return NO;
for (UIActivityItemProvider *item in activityItems) {
if ([item isKindOfClass:[NSString class]]) {
return YES;
} else if ([item isKindOfClass:[NSURL class]]) {
return YES;
}
}
return NO;
}
- (void)prepareWithActivityItems:(NSArray *)activityItems {
for (id item in activityItems) {
if ([item isKindOfClass:[NSString class]] ||
[item isKindOfClass:[NSURL class]]) {
[_items addObject:item];
} else {
BITHockeyLog(@"Unknown item type %@", item);
}
}
}
- (UIViewController *)activityViewController {
// TODO: return compose controller with activity content added
BITFeedbackManager *manager = [BITHockeyManager sharedHockeyManager].feedbackManager;
BITFeedbackComposeViewController *composeViewController = [manager feedbackComposeViewController];
composeViewController.delegate = self;
[composeViewController prepareWithItems:_items];
UINavigationController *navController = [manager customNavigationControllerWithRootViewController:composeViewController
presentationStyle:UIModalPresentationFormSheet];
navController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
return navController;
}
-(void)feedbackComposeViewControllerDidFinish:(BITFeedbackComposeViewController *)composeViewController {
[self activityDidFinish:YES];
}
@end
#endif /* HOCKEYSDK_FEATURE_FEEDBACK */