mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-05-03 20:46:28 +00:00
Add share button and share handling
This commit is contained in:
parent
60f3f6a121
commit
381a648a9b
7 changed files with 72 additions and 21 deletions
|
|
@ -9,10 +9,13 @@
|
|||
|
||||
@interface UIRecordingCell : UITableViewCell
|
||||
|
||||
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
|
||||
@property (weak, nonatomic) IBOutlet UIView *playerView;
|
||||
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
|
||||
@property (strong, nonatomic) IBOutlet UIToolbar *toolbar;
|
||||
@property (weak, nonatomic) IBOutlet UIBarButtonItem *shareButton;
|
||||
|
||||
@property(nonatomic, assign) NSString *recording;
|
||||
|
||||
@property(nonatomic, assign) __block NSString *recording;
|
||||
|
||||
- (id)initWithIdentifier:(NSString*)identifier;
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,13 @@
|
|||
static UILinphoneAudioPlayer *player;
|
||||
|
||||
#pragma mark - Lifecycle Functions
|
||||
|
||||
/*
|
||||
* TODO:
|
||||
* - When we scroll past a selected row, the player loads incorrectly (no buttons). Probably a problem in the player code.
|
||||
* - mkv recording is probably buggy, wrong eof. wav playing works but does not display the length/timestamp.
|
||||
* - When coming back from the action extension (to share a recording), we have to pop and reload the view for it to dislpay correctly. Find out why?
|
||||
* - The share button is greyed out when not clicking it. idk why, it's really weird.
|
||||
*/
|
||||
- (id)initWithIdentifier:(NSString *)identifier {
|
||||
if ((self = [super initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier])) {
|
||||
NSArray *arrayOfViews =
|
||||
|
|
@ -28,6 +34,8 @@ static UILinphoneAudioPlayer *player;
|
|||
[self setFrame:CGRectMake(0, 0, sub.frame.size.width, 40)];
|
||||
self = sub;
|
||||
self.recording = NULL;
|
||||
_shareButton.target = self;
|
||||
_shareButton.action = @selector(onShareButtonPressed);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
|
@ -42,7 +50,6 @@ static UILinphoneAudioPlayer *player;
|
|||
- (void)setRecording:(NSString *)arecording {
|
||||
_recording = arecording;
|
||||
if(_recording) {
|
||||
//TODO: Parse file name to get name of contact and date
|
||||
NSArray *parsedRecording = [LinphoneUtils parseRecordingName:_recording];
|
||||
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
|
||||
[dateFormat setDateFormat:@"HH:mm:ss"];
|
||||
|
|
@ -86,8 +93,10 @@ static UILinphoneAudioPlayer *player;
|
|||
|
||||
-(void)setSelected:(BOOL)selected animated:(BOOL)animated{
|
||||
[super setSelected:selected animated:animated];
|
||||
if (!selected)
|
||||
_toolbar.hidden = !selected;
|
||||
if (!selected) {
|
||||
return;
|
||||
}
|
||||
if (!player)
|
||||
player = [UILinphoneAudioPlayer audioPlayerWithFilePath:[self recording]];
|
||||
else
|
||||
|
|
@ -102,4 +111,17 @@ static UILinphoneAudioPlayer *player;
|
|||
[player open];
|
||||
}
|
||||
|
||||
- (void)onShareButtonPressed {
|
||||
UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:@[[NSURL fileURLWithPath:_recording]] applicationActivities:nil];
|
||||
[activityVC setCompletionWithItemsHandler:^(UIActivityType __nullable activityType, BOOL completed, NSArray * __nullable returnedItems, NSError * __nullable activityError) {
|
||||
//This is used to select the same row when we get back to the recordings view.
|
||||
NSString *file = player.file;
|
||||
//This reloads the view, if don't it's empty for some reason. Idealy we'd want to do this before closing the view but it's functionnal.
|
||||
[PhoneMainView.instance popCurrentView];
|
||||
[PhoneMainView.instance changeCurrentView:RecordingsListView.compositeViewDescription];
|
||||
[[(RecordingsListView *)VIEW(RecordingsListView) tableController] setSelected:file];
|
||||
}];
|
||||
[PhoneMainView.instance presentViewController:activityVC animated:YES completion:nil];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -16,26 +16,35 @@
|
|||
<rect key="frame" x="0.0" y="0.0" width="360" height="150"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Name" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="QmK-ci-4No">
|
||||
<rect key="frame" x="16" y="9" width="328" height="25"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<nil key="textColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<view contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Nk9-eo-eCo">
|
||||
<rect key="frame" x="0.0" y="42" width="360" height="108"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
</view>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Bzd-99-LAI">
|
||||
<rect key="frame" x="16" y="0.0" width="300" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<nil key="textColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<toolbar opaque="NO" clearsContextBeforeDrawing="NO" contentMode="scaleAspectFill" fixedFrame="YES" translucent="NO" translatesAutoresizingMaskIntoConstraints="NO" id="xjs-iK-dSH">
|
||||
<rect key="frame" x="300" y="0.0" width="60" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
|
||||
<items>
|
||||
<barButtonItem style="plain" systemItem="action" id="Drx-8h-kbM"/>
|
||||
</items>
|
||||
</toolbar>
|
||||
</subviews>
|
||||
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<nil key="simulatedStatusBarMetrics"/>
|
||||
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
|
||||
<viewLayoutGuide key="safeArea" id="Ak9-b1-W1C"/>
|
||||
<connections>
|
||||
<outlet property="nameLabel" destination="QmK-ci-4No" id="Jvc-Qm-ZZ6"/>
|
||||
<outlet property="nameLabel" destination="Bzd-99-LAI" id="Ubb-kU-T09"/>
|
||||
<outlet property="playerView" destination="Nk9-eo-eCo" id="64I-70-nHC"/>
|
||||
<outlet property="shareButton" destination="Drx-8h-kbM" id="Vhv-4D-Ptx"/>
|
||||
<outlet property="toolbar" destination="xjs-iK-dSH" id="NY4-Wk-dld"/>
|
||||
</connections>
|
||||
<point key="canvasLocation" x="26" y="105"/>
|
||||
</view>
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@
|
|||
#import "HistoryDetailsView.h"
|
||||
#import "HistoryListView.h"
|
||||
#import "ImageView.h"
|
||||
#import "RecordingsListView.h"
|
||||
#import "SettingsView.h"
|
||||
#import "SideMenuView.h"
|
||||
#import "UIConfirmationDialog.h"
|
||||
|
|
|
|||
|
|
@ -18,5 +18,6 @@
|
|||
}
|
||||
- (void)loadData;
|
||||
- (void)removeAllRecordings;
|
||||
- (void)setSelected:(NSString *)filepath;
|
||||
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -63,13 +63,6 @@
|
|||
- (void)loadData {
|
||||
LOGI(@"====>>>> Load recording list - Start");
|
||||
|
||||
//Clear recording cells
|
||||
for (NSInteger j = 0; j < [self.tableView numberOfSections]; ++j){
|
||||
for (NSInteger i = 0; i < [self.tableView numberOfRowsInSection:j]; ++i)
|
||||
{
|
||||
[[self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:i inSection:j]] setRecording:nil];
|
||||
}
|
||||
}
|
||||
recordings = [NSMutableDictionary dictionary];
|
||||
NSArray *directoryContent = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:writablePath error:NULL];
|
||||
for (NSString *file in directoryContent) {
|
||||
|
|
@ -217,6 +210,29 @@ forRowAtIndexPath:(NSIndexPath *)indexPath {
|
|||
}];
|
||||
}
|
||||
|
||||
- (void)setSelected:(NSString *)filepath {
|
||||
NSArray *parsedName = [LinphoneUtils parseRecordingName:filepath];
|
||||
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
|
||||
[dateFormat setDateFormat:@"EEEE, MMM d, yyyy"];
|
||||
NSString *dayPretty = [dateFormat stringFromDate:[parsedName objectAtIndex:1]];
|
||||
NSUInteger section;
|
||||
NSArray *keys = [recordings allKeys];
|
||||
for (section = 0; section < [keys count]; ++section) {
|
||||
if ([dayPretty isEqualToString:(NSString *)[keys objectAtIndex:section]]) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
NSUInteger row;
|
||||
NSArray *recs = [recordings objectForKey:dayPretty];
|
||||
for (row = 0; row < [recs count]; ++row) {
|
||||
if ([filepath isEqualToString:(NSString *)[recs objectAtIndex:row]]) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
NSUInteger indexes[] = {section, row};
|
||||
[self.tableView selectRowAtIndexPath:[NSIndexPath indexPathWithIndexes:indexes length:2] animated:TRUE scrollPosition:UITableViewScrollPositionNone];
|
||||
}
|
||||
|
||||
#pragma mark - Utilities
|
||||
|
||||
- (NSArray *)getSortedKeys {
|
||||
|
|
|
|||
|
|
@ -58,7 +58,6 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
|
||||
- (void)viewWillAppear:(BOOL)animated {
|
||||
[super viewWillAppear:animated];
|
||||
|
||||
if (tableController.isEditing) {
|
||||
tableController.editing = NO;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue