mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 14:45:21 +00:00
+ Enabled Feedback Observation mode Three-Finger-Tap
This commit is contained in:
@@ -75,7 +75,7 @@ typedef NS_ENUM(NSInteger, BITFeedbackObservationMode) {
|
|||||||
* Feedback compose will open with a generated screenshot if the screen is tapped
|
* Feedback compose will open with a generated screenshot if the screen is tapped
|
||||||
* three fingers for three seconds.
|
* three fingers for three seconds.
|
||||||
*/
|
*/
|
||||||
BITFeedbackObservationModeThreeFingersThreeSeconds = 2
|
BITFeedbackObservationModeThreeFingerTap = 2
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -53,6 +53,12 @@
|
|||||||
#define kBITFeedbackLastMessageID @"HockeyFeedbackLastMessageID"
|
#define kBITFeedbackLastMessageID @"HockeyFeedbackLastMessageID"
|
||||||
#define kBITFeedbackAppID @"HockeyFeedbackAppID"
|
#define kBITFeedbackAppID @"HockeyFeedbackAppID"
|
||||||
|
|
||||||
|
@interface BITFeedbackManager()<UIGestureRecognizerDelegate>
|
||||||
|
|
||||||
|
@property (nonatomic, strong) UITapGestureRecognizer *tapRecognizer;
|
||||||
|
@property (nonatomic) BOOL screenshotNotificationEnabled;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
@implementation BITFeedbackManager {
|
@implementation BITFeedbackManager {
|
||||||
NSFileManager *_fileManager;
|
NSFileManager *_fileManager;
|
||||||
@@ -1087,12 +1093,34 @@
|
|||||||
|
|
||||||
-(void)setFeedbackObservationMode:(BITFeedbackObservationMode)mode {
|
-(void)setFeedbackObservationMode:(BITFeedbackObservationMode)mode {
|
||||||
if (mode == BITFeedbackObservationModeOnScreenshot){
|
if (mode == BITFeedbackObservationModeOnScreenshot){
|
||||||
// [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(screenshotNotificationReceived:) name:UIApplicationUserDidTakeScreenshotNotification object:nil];
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(screenshotNotificationReceived:) name:UIApplicationUserDidTakeScreenshotNotification object:nil];
|
||||||
|
self.screenshotNotificationEnabled = YES;
|
||||||
|
if (self.tapRecognizer){
|
||||||
|
[[[UIApplication sharedApplication] keyWindow] removeGestureRecognizer:self.tapRecognizer];
|
||||||
|
self.tapRecognizer = nil;
|
||||||
|
}
|
||||||
|
} else if (mode == BITFeedbackObservationModeThreeFingerTap){
|
||||||
|
if (!self.tapRecognizer){
|
||||||
|
self.tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(screenshotTripleTap:)];
|
||||||
|
self.tapRecognizer.numberOfTouchesRequired = 3;
|
||||||
|
self.tapRecognizer.delegate = self;
|
||||||
|
|
||||||
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
|
[[UIApplication sharedApplication].keyWindow addGestureRecognizer:self.tapRecognizer];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (self.screenshotNotificationEnabled){
|
||||||
|
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationUserDidTakeScreenshotNotification object:nil];
|
||||||
|
self.screenshotNotificationEnabled = NO;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void)screenshotNotificationReceived:(NSNotification *)notification {
|
-(void)screenshotNotificationReceived:(NSNotification *)notification {
|
||||||
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
[self extractLastPictureFromLibraryAndLaunchFeedback];
|
[self extractLastPictureFromLibraryAndLaunchFeedback];
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void)extractLastPictureFromLibraryAndLaunchFeedback {
|
-(void)extractLastPictureFromLibraryAndLaunchFeedback {
|
||||||
@@ -1108,13 +1136,25 @@
|
|||||||
ALAssetRepresentation *representation = [alAsset defaultRepresentation];
|
ALAssetRepresentation *representation = [alAsset defaultRepresentation];
|
||||||
UIImage *latestPhoto = [UIImage imageWithCGImage:[representation fullScreenImage]];
|
UIImage *latestPhoto = [UIImage imageWithCGImage:[representation fullScreenImage]];
|
||||||
|
|
||||||
*stop = YES; *innerStop = YES;
|
*stop = YES;
|
||||||
|
*innerStop = YES;
|
||||||
|
|
||||||
[self showFeedbackComposeViewWithPreparedItems:@[latestPhoto]];
|
[self showFeedbackComposeViewWithPreparedItems:@[latestPhoto]];
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
} failureBlock: nil];
|
} failureBlock: nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)screenshotTripleTap:(UITapGestureRecognizer *)tapRecognizer {
|
||||||
|
if (tapRecognizer.state == UIGestureRecognizerStateRecognized){
|
||||||
|
[self showFeedbackComposeViewWithGeneratedScreenshot];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user