mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-21 09:02:44 +02:00
Bug report: Add option to send screenshot
This commit is contained in:
@@ -23,6 +23,9 @@
|
||||
@interface BugReportViewController ()
|
||||
{
|
||||
MXBugReportRestClient *bugReportRestClient;
|
||||
|
||||
// The temporary file used to store the screenshot
|
||||
NSURL *screenShotFile;
|
||||
}
|
||||
|
||||
@property (nonatomic) BOOL sendLogs;
|
||||
@@ -62,8 +65,6 @@
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
NSLog(@"%@", _screenshot);
|
||||
|
||||
_logsDescriptionLabel.text = NSLocalizedStringFromTable(@"bug_report_logs_description", @"Vector", nil);
|
||||
_sendLogsLabel.text = NSLocalizedStringFromTable(@"bug_report_send_logs", @"Vector", nil);
|
||||
_sendScreenshotLabel.text = NSLocalizedStringFromTable(@"bug_report_send_screenshot", @"Vector", nil);
|
||||
@@ -95,7 +96,7 @@
|
||||
self.sendScreenshot = YES;
|
||||
|
||||
// Hide the screenshot button if there is no screenshot
|
||||
// if (!_screenshot) // TODO: always hide it becayse screenshot is not yet supported by the bug report API
|
||||
if (!_screenshot)
|
||||
{
|
||||
_sendScreenshotContainer.hidden = YES;
|
||||
_sendScreenshotContainerHeightConstraint.constant = 0;
|
||||
@@ -122,6 +123,17 @@
|
||||
_bugReportDescriptionTextView.inputAccessoryView = nil;
|
||||
}
|
||||
|
||||
-(void)viewWillDisappear:(BOOL)animated
|
||||
{
|
||||
[super viewWillDisappear:animated];
|
||||
|
||||
if (screenShotFile)
|
||||
{
|
||||
[[NSFileManager defaultManager] removeItemAtURL:screenShotFile error:nil];
|
||||
screenShotFile = nil;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setSendLogs:(BOOL)sendLogs
|
||||
{
|
||||
_sendLogs = sendLogs;
|
||||
@@ -199,8 +211,20 @@
|
||||
bugReportRestClient.deviceModel = [GBDeviceInfo deviceInfo].modelString;
|
||||
bugReportRestClient.deviceOS = [NSString stringWithFormat:@"%@ %@", [[UIDevice currentDevice] systemName], [[UIDevice currentDevice] systemVersion]];
|
||||
|
||||
// Screenshot
|
||||
NSArray<NSURL*> *files;
|
||||
if (_screenshot && _sendScreenshot)
|
||||
{
|
||||
// Store the screenshot into a temporary file
|
||||
NSData *screenShotData = UIImagePNGRepresentation(_screenshot);
|
||||
screenShotFile = [NSURL fileURLWithPath:[NSTemporaryDirectory() stringByAppendingPathComponent:@"screenshot.png"]];
|
||||
[screenShotData writeToURL:screenShotFile atomically:YES];
|
||||
|
||||
files = @[screenShotFile];
|
||||
}
|
||||
|
||||
// Submit
|
||||
[bugReportRestClient sendBugReport:_bugReportDescriptionTextView.text sendLogs:_sendLogs sendCrashLog:_reportCrash progress:^(MXBugReportState state, NSProgress *progress) {
|
||||
[bugReportRestClient sendBugReport:_bugReportDescriptionTextView.text sendLogs:_sendLogs sendCrashLog:_reportCrash sendFiles:files progress:^(MXBugReportState state, NSProgress *progress) {
|
||||
|
||||
switch (state)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user