mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
adds public method to handle user input from an alert view
This commit is contained in:
@@ -247,6 +247,11 @@ typedef NS_ENUM(NSUInteger, BITCrashManagerUserInput) {
|
|||||||
*/
|
*/
|
||||||
@property (nonatomic, readonly) BOOL didCrashInLastSession;
|
@property (nonatomic, readonly) BOOL didCrashInLastSession;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Provides an interface to handle user input from a custom alert
|
||||||
|
@return BOOl if the input is a valid option
|
||||||
|
*/
|
||||||
|
- (BOOL)handleUserInput: (BITCrashManagerUserInput) userInput;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Provides the time between startup and crash in seconds
|
Provides the time between startup and crash in seconds
|
||||||
|
|||||||
@@ -487,6 +487,36 @@ NSString *const kBITCrashManagerStatus = @"BITCrashManagerStatus";
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (BOOL)handleUserInput:(BITCrashManagerUserInput)userInput {
|
||||||
|
switch (userInput) {
|
||||||
|
case BITCrashManagerUserInputDontSend:
|
||||||
|
if (self.delegate != nil && [self.delegate respondsToSelector:@selector(crashManagerWillCancelSendingCrashReport:)]) {
|
||||||
|
[self.delegate crashManagerWillCancelSendingCrashReport:self];
|
||||||
|
}
|
||||||
|
|
||||||
|
[self cleanCrashReports];
|
||||||
|
YES;
|
||||||
|
|
||||||
|
case BITCrashManagerUserInputSend:
|
||||||
|
[self sendCrashReports];
|
||||||
|
YES;
|
||||||
|
|
||||||
|
case BITCrashManagerUserInputAlwaysSend:
|
||||||
|
_crashManagerStatus = BITCrashManagerStatusAutoSend;
|
||||||
|
[[NSUserDefaults standardUserDefaults] setInteger:_crashManagerStatus forKey:kBITCrashManagerStatus];
|
||||||
|
[[NSUserDefaults standardUserDefaults] synchronize];
|
||||||
|
if (self.delegate != nil && [self.delegate respondsToSelector:@selector(crashManagerWillSendCrashReportsAlways:)]) {
|
||||||
|
[self.delegate crashManagerWillSendCrashReportsAlways:self];
|
||||||
|
}
|
||||||
|
|
||||||
|
[self sendCrashReports];
|
||||||
|
return YES;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#pragma mark - PLCrashReporter
|
#pragma mark - PLCrashReporter
|
||||||
|
|
||||||
@@ -930,35 +960,20 @@ NSString *const kBITCrashManagerStatus = @"BITCrashManagerStatus";
|
|||||||
#pragma mark - UIAlertView Delegate
|
#pragma mark - UIAlertView Delegate
|
||||||
|
|
||||||
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
|
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
|
||||||
[self handleUserInput:buttonIndex];
|
switch (buttonIndex) {
|
||||||
|
case 0:
|
||||||
|
[self handleUserInput:BITCrashManagerUserInputDontSend];
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
[self handleUserInput:BITCrashManagerUserInputSend];
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
[self handleUserInput:BITCrashManagerUserInputAlwaysSend];
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)handleUserInput:(BITCrashManagerUserInput)userInput {
|
|
||||||
switch (userInput) {
|
|
||||||
case BITCrashManagerUserInputDontSend:
|
|
||||||
if (self.delegate != nil && [self.delegate respondsToSelector:@selector(crashManagerWillCancelSendingCrashReport:)]) {
|
|
||||||
[self.delegate crashManagerWillCancelSendingCrashReport:self];
|
|
||||||
}
|
|
||||||
|
|
||||||
_sendingInProgress = NO;
|
|
||||||
[self cleanCrashReports];
|
|
||||||
break;
|
|
||||||
case BITCrashManagerUserInputSend:
|
|
||||||
[self sendCrashReports];
|
|
||||||
break;
|
|
||||||
case BITCrashManagerUserInputAlwaysSend:
|
|
||||||
_crashManagerStatus = BITCrashManagerStatusAutoSend;
|
|
||||||
[[NSUserDefaults standardUserDefaults] setInteger:_crashManagerStatus forKey:kBITCrashManagerStatus];
|
|
||||||
[[NSUserDefaults standardUserDefaults] synchronize];
|
|
||||||
if (self.delegate != nil && [self.delegate respondsToSelector:@selector(crashManagerWillSendCrashReportsAlways:)]) {
|
|
||||||
[self.delegate crashManagerWillSendCrashReportsAlways:self];
|
|
||||||
}
|
|
||||||
|
|
||||||
[self sendCrashReports];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#pragma mark - Networking
|
#pragma mark - Networking
|
||||||
|
|||||||
Reference in New Issue
Block a user