2017-08-17 15:28:08 +00:00
|
|
|
|
/*
|
|
|
|
|
Copyright 2017 Aram Sargsyan
|
|
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
|
limitations under the License.
|
|
|
|
|
*/
|
2017-08-10 22:38:47 +00:00
|
|
|
|
|
|
|
|
|
#import <Foundation/Foundation.h>
|
|
|
|
|
#import <MatrixKit/MatrixKit.h>
|
|
|
|
|
|
2017-08-16 20:01:54 +00:00
|
|
|
|
@class ShareExtensionManager;
|
2017-08-25 09:55:37 +00:00
|
|
|
|
@class SharePresentingViewController;
|
2017-08-16 20:01:54 +00:00
|
|
|
|
|
2017-08-21 20:33:06 +00:00
|
|
|
|
|
2017-08-17 22:27:56 +00:00
|
|
|
|
/**
|
|
|
|
|
The protocol for the manager's delegate
|
|
|
|
|
*/
|
2017-08-16 20:01:54 +00:00
|
|
|
|
@protocol ShareExtensionManagerDelegate <NSObject>
|
|
|
|
|
|
|
|
|
|
@required
|
|
|
|
|
|
2017-08-17 22:27:56 +00:00
|
|
|
|
/**
|
|
|
|
|
Called when an image is going to be shared to show a compression prompt
|
|
|
|
|
@param extensionManager the ShareExtensionManager object that called the method
|
|
|
|
|
@param compressionPrompt the prompt that was prepared for the image which is going to be shared
|
|
|
|
|
*/
|
2017-08-16 20:01:54 +00:00
|
|
|
|
- (void)shareExtensionManager:(ShareExtensionManager *)extensionManager showImageCompressionPrompt:(UIAlertController *)compressionPrompt;
|
|
|
|
|
|
|
|
|
|
@optional
|
|
|
|
|
|
2017-08-26 11:54:25 +00:00
|
|
|
|
/**
|
|
|
|
|
Called when the manager starts sending the content to a room
|
|
|
|
|
@param extensionManager the ShareExtensionManager object that called the method
|
2017-08-31 13:51:49 +00:00
|
|
|
|
@param room the room where content will be sent
|
2017-08-26 11:54:25 +00:00
|
|
|
|
*/
|
2017-08-31 13:51:49 +00:00
|
|
|
|
- (void)shareExtensionManager:(ShareExtensionManager *)extensionManager didStartSendingContentToRoom:(MXRoom *)room;
|
2017-08-20 21:39:08 +00:00
|
|
|
|
|
2017-08-17 22:27:56 +00:00
|
|
|
|
/**
|
|
|
|
|
Called when the progress of the uploading media changes
|
|
|
|
|
@param extensionManager the ShareExtensionManager object that called the method
|
|
|
|
|
@param progress the current progress
|
|
|
|
|
*/
|
2017-08-16 20:01:54 +00:00
|
|
|
|
- (void)shareExtensionManager:(ShareExtensionManager *)extensionManager mediaUploadProgress:(CGFloat)progress;
|
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
2017-08-17 22:27:56 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
A class used to share content from the extension
|
|
|
|
|
*/
|
|
|
|
|
|
2017-08-10 22:38:47 +00:00
|
|
|
|
@interface ShareExtensionManager : NSObject
|
|
|
|
|
|
2017-08-17 22:27:56 +00:00
|
|
|
|
/**
|
|
|
|
|
The share extension context that represents a user's sharing request, also stores the content to be shared
|
|
|
|
|
*/
|
2017-08-16 20:01:54 +00:00
|
|
|
|
@property (nonatomic) NSExtensionContext *shareExtensionContext;
|
|
|
|
|
|
2017-08-25 09:55:37 +00:00
|
|
|
|
/**
|
|
|
|
|
The share app extension’s primary view controller.
|
|
|
|
|
*/
|
|
|
|
|
@property (nonatomic) SharePresentingViewController *primaryViewController;
|
|
|
|
|
|
2017-09-08 15:02:45 +00:00
|
|
|
|
/**
|
|
|
|
|
The current user account
|
|
|
|
|
*/
|
|
|
|
|
@property (nonatomic, readonly) MXKAccount *userAccount;
|
2017-08-21 20:33:06 +00:00
|
|
|
|
|
2017-08-17 22:27:56 +00:00
|
|
|
|
/**
|
|
|
|
|
A delegate used to notify about needed UI changes when sharing
|
|
|
|
|
*/
|
2017-08-16 20:01:54 +00:00
|
|
|
|
@property (nonatomic) id<ShareExtensionManagerDelegate> delegate;
|
2017-08-10 22:38:47 +00:00
|
|
|
|
|
2017-08-17 22:27:56 +00:00
|
|
|
|
/**
|
|
|
|
|
The singleton instance
|
|
|
|
|
*/
|
2017-08-10 22:38:47 +00:00
|
|
|
|
+ (instancetype)sharedManager;
|
|
|
|
|
|
2017-08-17 22:27:56 +00:00
|
|
|
|
/**
|
|
|
|
|
Send the content that the user has chosen to a room
|
2017-08-31 13:51:49 +00:00
|
|
|
|
@param room the room to send the content to
|
2017-08-17 22:27:56 +00:00
|
|
|
|
@param failureBlock the code to be executed when sharing has failed for whatever reason
|
|
|
|
|
note: there is no "successBlock" parameter because when the sharing succeds, the extension needs to close itself
|
|
|
|
|
*/
|
2017-08-31 13:51:49 +00:00
|
|
|
|
- (void)sendContentToRoom:(MXRoom *)room failureBlock:(void(^)())failureBlock;
|
2017-08-10 22:38:47 +00:00
|
|
|
|
|
2017-08-17 22:27:56 +00:00
|
|
|
|
/**
|
|
|
|
|
Checks if there is an image in the user chosen content
|
|
|
|
|
@return YES if there is, NO otherwise
|
|
|
|
|
*/
|
2017-08-16 20:01:54 +00:00
|
|
|
|
- (BOOL)hasImageTypeContent;
|
|
|
|
|
|
2017-08-17 22:27:56 +00:00
|
|
|
|
/**
|
|
|
|
|
Terminate the extension and return to the app that started it
|
|
|
|
|
@param canceled YES if the user chose to cancel the sharing, NO otherwise
|
|
|
|
|
*/
|
|
|
|
|
- (void)terminateExtensionCanceled:(BOOL)canceled;
|
2017-08-16 20:01:54 +00:00
|
|
|
|
|
2017-08-10 22:38:47 +00:00
|
|
|
|
@end
|
2017-08-22 15:52:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@interface NSItemProvider (ShareExtensionManager)
|
|
|
|
|
|
|
|
|
|
@property BOOL isLoaded;
|
|
|
|
|
|
|
|
|
|
@end
|