QRCodeActivity.m 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // _____ _
  2. // |_ _| |_ _ _ ___ ___ _ __ __ _
  3. // | | | ' \| '_/ -_) -_) ' \/ _` |_
  4. // |_| |_||_|_| \___\___|_|_|_\__,_(_)
  5. //
  6. // Threema iOS Client
  7. // Copyright (c) 2014-2020 Threema GmbH
  8. //
  9. // This program is free software: you can redistribute it and/or modify
  10. // it under the terms of the GNU Affero General Public License, version 3,
  11. // as published by the Free Software Foundation.
  12. //
  13. // This program is distributed in the hope that it will be useful,
  14. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. // GNU Affero General Public License for more details.
  17. //
  18. // You should have received a copy of the GNU Affero General Public License
  19. // along with this program. If not, see <https://www.gnu.org/licenses/>.
  20. #import "QRCodeActivity.h"
  21. #import "QRCodeViewController.h"
  22. #import "PortraitNavigationController.h"
  23. #import "StatusNavigationBar.h"
  24. #import "TextMessage.h"
  25. @implementation QRCodeActivity {
  26. NSString *qrData;
  27. }
  28. + (UIActivityCategory)activityCategory {
  29. return UIActivityCategoryAction;
  30. }
  31. - (NSString *)activityType {
  32. return APP_ID ".genqr";
  33. }
  34. - (NSString *)activityTitle {
  35. return NSLocalizedString(@"qr_code", nil);
  36. }
  37. - (UIImage *)activityImage {
  38. return [UIImage imageNamed:@"QRScan"];
  39. }
  40. - (BOOL)canPerformWithActivityItems:(NSArray *)activityItems {
  41. return (activityItems.count == 1 && [activityItems[0] isKindOfClass:[NSString class]]);
  42. }
  43. - (void)prepareWithActivityItems:(NSArray *)activityItems {
  44. qrData = activityItems[0];
  45. }
  46. - (UIViewController *)activityViewController {
  47. QRCodeViewController *viewController = [[QRCodeViewController alloc] init];
  48. viewController.qrData = qrData;
  49. viewController.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(donePressed)];
  50. UINavigationController *navController = [[PortraitNavigationController alloc] initWithNavigationBarClass:[StatusNavigationBar class] toolbarClass:nil];
  51. [navController pushViewController:viewController animated:NO];
  52. return navController;
  53. }
  54. - (void)donePressed {
  55. [self activityDidFinish:YES];
  56. }
  57. @end