Skip to content

Commit

Permalink
/issues/5009 - Moved files around, cleaned up imports and logs.
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanceriu committed Oct 14, 2021
1 parent ad1f412 commit 956e2c9
Show file tree
Hide file tree
Showing 20 changed files with 76 additions and 88 deletions.
20 changes: 10 additions & 10 deletions Riot/Modules/Room/RoomViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
#import "AvatarGenerator.h"
#import "Tools.h"
#import "WidgetManager.h"
#import "ShareExtensionManager.h"
#import "ShareManager.h"

#import "GBDeviceInfo_iOS.h"

Expand Down Expand Up @@ -252,7 +252,7 @@ @interface RoomViewController () <UISearchBarDelegate, UIGestureRecognizerDelega
@property (nonatomic, strong) VoiceMessageController *voiceMessageController;
@property (nonatomic, strong) SpaceDetailPresenter *spaceDetailPresenter;

@property (nonatomic, strong) ShareExtensionManager *shareExtensionManager;
@property (nonatomic, strong) ShareManager *shareManager;

@end

Expand Down Expand Up @@ -3170,17 +3170,17 @@ - (void)showAdditionalActionsMenuForEvent:(MXEvent*)selectedEvent inCell:(id<MXK
NSExtensionItem *item = [[NSExtensionItem alloc] init];
item.attachments = @[[[NSItemProvider alloc] initWithItem:selectedComponent.textMessage typeIdentifier:(__bridge NSString *)kUTTypeText]];

self.shareExtensionManager = [[ShareExtensionManager alloc] initWithShareExtensionContext:nil
extensionItems:@[item]];
self.shareManager = [[ShareManager alloc] initWithShareExtensionContext:nil
extensionItems:@[item]];

MXWeakify(self);
[self.shareExtensionManager setCompletionCallback:^(ShareExtensionManagerResult result) {
[self.shareManager setCompletionCallback:^(ShareManagerResult result) {
MXStrongifyAndReturnIfNil(self);
[attachment onShareEnded];
[self dismissViewControllerAnimated:YES completion:nil];
}];

[self presentViewController:self.shareExtensionManager.mainViewController animated:YES completion:nil];
[self presentViewController:self.shareManager.mainViewController animated:YES completion:nil];
}]];

if (!isJitsiCallEvent)
Expand Down Expand Up @@ -3383,17 +3383,17 @@ - (void)showAdditionalActionsMenuForEvent:(MXEvent*)selectedEvent inCell:(id<MXK
NSExtensionItem *item = [[NSExtensionItem alloc] init];
item.attachments = @[[[NSItemProvider alloc] initWithItem:fileURL typeIdentifier:attachmentTypeToIdentifier[@(attachment.type)]]];

self.shareExtensionManager = [[ShareExtensionManager alloc] initWithShareExtensionContext:nil
extensionItems:@[item]];
self.shareManager = [[ShareManager alloc] initWithShareExtensionContext:nil
extensionItems:@[item]];

MXWeakify(self);
[self.shareExtensionManager setCompletionCallback:^(ShareExtensionManagerResult result) {
[self.shareManager setCompletionCallback:^(ShareManagerResult result) {
MXStrongifyAndReturnIfNil(self);
[attachment onShareEnded];
[self dismissViewControllerAnimated:YES completion:nil];
}];

[self presentViewController:self.shareExtensionManager.mainViewController animated:YES completion:nil];
[self presentViewController:self.shareManager.mainViewController animated:YES completion:nil];
} failure:^(NSError *error) {
[self showError:error];
[self stopActivityIndicator];
Expand Down
3 changes: 1 addition & 2 deletions Riot/target.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ targets:
excludes:
- "Modules/Room/EmojiPicker/Data/EmojiMart/EmojiJSONStore.swift"
- "**/*.strings" # Exclude all strings files
- path: ../RiotShareExtension/Managers
- path: ../RiotShareExtension/Modules
- path: ../RiotShareExtension/Shared

# Add separately localizable files
# Once a language has enough translations (>80%), it must be declared here
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
*/

#import "ShareExtensionRootViewController.h"
#import "ShareViewController.h"
#import "ShareExtensionManager.h"
#import "ShareManager.h"
#import "ThemeService.h"

#ifdef IS_SHARE_EXTENSION
Expand All @@ -27,7 +26,7 @@

@interface ShareExtensionRootViewController ()

@property (nonatomic, strong, readonly) ShareExtensionManager *shareExtensionManager;
@property (nonatomic, strong, readonly) ShareManager *shareManager;

@end

Expand All @@ -39,24 +38,24 @@ - (instancetype)init

[ThemeService.shared setThemeId:RiotSettings.shared.userInterfaceTheme];

_shareExtensionManager = [[ShareExtensionManager alloc] initWithShareExtensionContext:self.extensionContext
_shareManager = [[ShareManager alloc] initWithShareExtensionContext:self.extensionContext
extensionItems:self.extensionContext.inputItems];

MXWeakify(self);
[_shareExtensionManager setCompletionCallback:^(ShareExtensionManagerResult result) {
[_shareManager setCompletionCallback:^(ShareManagerResult result) {
MXStrongifyAndReturnIfNil(self);

switch (result)
{
case ShareExtensionManagerResultFinished:
case ShareManagerResultFinished:
[self.extensionContext completeRequestReturningItems:nil completionHandler:nil];
[self _dismiss];
break;
case ShareExtensionManagerResultCancelled:
case ShareManagerResultCancelled:
[self.extensionContext cancelRequestWithError:[NSError errorWithDomain:@"MXUserCancelErrorDomain" code:4201 userInfo:nil]];
[self _dismiss];
break;
case ShareExtensionManagerResultFailed:
case ShareManagerResultFailed:
[self.extensionContext cancelRequestWithError:[NSError errorWithDomain:@"MXFailureErrorDomain" code:500 userInfo:nil]];
[self _dismiss];
break;
Expand All @@ -73,7 +72,7 @@ - (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];

[self presentViewController:self.shareExtensionManager.mainViewController animated:YES completion:nil];
[self presentViewController:self.shareManager.mainViewController animated:YES completion:nil];
}

#pragma mark - Private
Expand All @@ -83,9 +82,9 @@ - (void)_dismiss
[self dismissViewControllerAnimated:true completion:^{
[self.presentingViewController dismissViewControllerAnimated:false completion:nil];

// // FIXME: Share extension memory usage increase when launched several times and then crash due to some memory leaks.
// // For now, we force the share extension to exit and free memory.
// [NSException raise:@"Kill the app extension" format:@"Free memory used by share extension"];
// FIXME: Share extension memory usage increase when launched several times and then crash due to some memory leaks.
// For now, we force the share extension to exit and free memory.
[NSException raise:@"Kill the app extension" format:@"Free memory used by share extension"];
}];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@
limitations under the License.
*/

#import <MatrixKit/MatrixKit.h>

#import "RoomsListViewController.h"
#import "RecentRoomTableViewCell.h"
#import "NSBundle+MatrixKit.h"
#import "ShareExtensionManager.h"
#import "RecentCellData.h"
#import "ThemeService.h"
#import <MatrixKit/MatrixKit.h>

#ifdef IS_SHARE_EXTENSION
#import "RiotShareExtension-Swift.h"
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/

#import "ShareDataSource.h"
#import "ShareExtensionManager.h"
#import "RecentRoomTableViewCell.h"

@interface ShareDataSource ()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,15 @@

#import <MatrixKit/MatrixKit.h>

@class ShareExtensionManager;

typedef NS_ENUM(NSUInteger, ShareExtensionManagerResult) {
ShareExtensionManagerResultFinished,
ShareExtensionManagerResultCancelled,
ShareExtensionManagerResultFailed
typedef NS_ENUM(NSUInteger, ShareManagerResult) {
ShareManagerResultFinished,
ShareManagerResultCancelled,
ShareManagerResultFailed
};

@interface ShareExtensionManager : NSObject
@interface ShareManager : NSObject

@property (nonatomic, copy) void (^completionCallback)(ShareExtensionManagerResult);
@property (nonatomic, copy) void (^completionCallback)(ShareManagerResult);

- (instancetype)initWithShareExtensionContext:(NSExtensionContext *)shareExtensionContext
extensionItems:(NSArray<NSExtensionItem *> *)extensionItems;
Expand All @@ -36,7 +34,7 @@ typedef NS_ENUM(NSUInteger, ShareExtensionManagerResult) {
@end


@interface NSItemProvider (ShareExtensionManager)
@interface NSItemProvider (ShareManager)

@property BOOL isLoaded;

Expand Down
Loading

0 comments on commit 956e2c9

Please sign in to comment.