Commit 191c8d8a authored by Benjamin Verdier's avatar Benjamin Verdier

Add views for call recording display

parent 9d1afa7c
//
// UIRecordingCell.h
// linphone
//
// Created by benjamin_verdier on 25/07/2018.
//
#import <UIKit/UIKit.h>
@interface UIRecordingCell : UITableViewCell
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
@property (weak, nonatomic) IBOutlet UILabel *dateLabel;
@property(nonatomic, assign) NSString *recording;
- (id)initWithIdentifier:(NSString*)identifier;
@end
//
// UIRecordingCell.m
// linphone
//
// Created by benjamin_verdier on 25/07/2018.
//
#import "UIRecordingCell.h"
#import "PhoneMainView.h"
#import "UILabel+Boldify.h"
#import "Utils.h"
@implementation UIRecordingCell
#pragma mark - Lifecycle Functions
- (id)initWithIdentifier:(NSString *)identifier {
if ((self = [super initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier]) != nil) {
NSArray *arrayOfViews =
[[NSBundle mainBundle] loadNibNamed:NSStringFromClass(self.class) owner:self options:nil];
// resize cell to match .nib size. It is needed when resized the cell to
// correctly adapt its height too
UIView *sub = ((UIView *)[arrayOfViews objectAtIndex:0]);
[self setFrame:CGRectMake(0, 0, sub.frame.size.width, sub.frame.size.height)];
[self addSubview:sub];
self.recording = NULL;
}
return self;
}
- (void)dealloc {
self.recording = NULL;
[NSNotificationCenter.defaultCenter removeObserver:self];
}
#pragma mark - Property Functions
- (void)setRecording:(NSString *)arecording {
_recording = arecording;
if(_recording) {
//TODO: Parse file name to get name of contact and date
}
}
#pragma mark -
- (void)touchUp:(id)sender {
[self setHighlighted:true animated:true];
}
- (void)touchDown:(id)sender {
[self setHighlighted:false animated:true];
}
- (NSString *)accessibilityLabel {
return _nameLabel.text;
}
- (void)setEditing:(BOOL)editing {
[self setEditing:editing animated:FALSE];
}
- (void)setEditing:(BOOL)editing animated:(BOOL)animated {
if (animated) {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.3];
}
if (animated) {
[UIView commitAnimations];
}
}
@end
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14113" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" rowHeight="64" id="KGk-i7-Jjw" customClass="UIRecordingCell">
<rect key="frame" x="0.0" y="0.0" width="320" height="64"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
<rect key="frame" x="0.0" y="0.0" width="320" height="63.5"/>
<autoresizingMask key="autoresizingMask"/>
<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="XQs-XC-lBb">
<rect key="frame" x="16" y="11" width="136" height="42"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Date" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="o4f-sF-niV">
<rect key="frame" x="202" y="11" width="102" height="42"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</tableViewCellContentView>
<viewLayoutGuide key="safeArea" id="aW0-zy-SZf"/>
<connections>
<outlet property="dateLabel" destination="o4f-sF-niV" id="8A8-UM-4FP"/>
<outlet property="nameLabel" destination="XQs-XC-lBb" id="1MA-DM-Xh7"/>
</connections>
<point key="canvasLocation" x="-172" y="62"/>
</tableViewCell>
</objects>
</document>
//
// RecordingsListTableView.h
// linphone
//
// Created by benjamin_verdier on 25/07/2018.
//
#import <UIKit/UIKit.h>
#import "UICheckBoxTableView.h"
#import "OrderedDictionary.h"
@interface RecordingsListTableView : UICheckBoxTableView {
@private
OrderedDictionary *recordings;
//This has sub arrays indexed with the date of the recordings, themselves containings the recordings.
}
@property(nonatomic) BOOL ongoing;
- (void)loadData;
- (void)removeAllRecordings;
@end
//
// RecordingsListTableView.m
// linphone
//
// Created by benjamin_verdier on 25/07/2018.
//
#import "RecordingsListTableView.h"
#import "UIRecordingCell.h"
#import "LinphoneManager.h"
#import "PhoneMainView.h"
#import "Utils.h"
@implementation RecordingsListTableView
NSArray *sortedRecordings;
#pragma mark - Lifecycle Functions
- (void)initRecordingsTableViewController {
recordings = [[OrderedDictionary alloc] init];
sortedRecordings = [[NSArray alloc] init];
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
if (![self selectFirstRow]) {
//TODO: Make first cell expand to show player
}
}
- (id)init {
self = [super init];
if (self) {
[self initRecordingsTableViewController];
}
_ongoing = FALSE;
return self;
}
- (id)initWithCoder:(NSCoder *)decoder {
self = [super initWithCoder:decoder];
if (self) {
[self initRecordingsTableViewController];
}
return self;
}
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
[self removeAllRecordings];
}
- (void)removeAllRecordings {
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];
}
}
}
- (void)loadData {
_ongoing = TRUE;
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]] setContact:nil];
}
}
//TODO: Fill the recordings dictionnary with the recording names, keys are dates
LOGI(@"====>>>> Load recording list - End");
[super loadData];
_ongoing = FALSE;
}
#pragma mark - UITableViewDataSource Functions
- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView {
return [recordings allKeys];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return [recordings count];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [(OrderedDictionary *)[recordings objectForKey:[recordings keyAtIndex:section]] count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *kCellId = NSStringFromClass(UIRecordingCell.class);
UIRecordingCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellId];
if (cell == nil) {
cell = [[UIRecordingCell alloc] initWithIdentifier:kCellId];
}
NSString *recording = @"";
//TODO: Set recording to the path of the recording
[cell setRecording:recording];
[super accessoryForCell:cell atPath:indexPath];
return cell;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
CGRect frame = CGRectMake(0, 0, tableView.frame.size.width, tableView.sectionHeaderHeight);
UIView *tempView = [[UIView alloc] initWithFrame:frame];
tempView.backgroundColor = [UIColor whiteColor];
UILabel *tempLabel = [[UILabel alloc] initWithFrame:frame];
tempLabel.backgroundColor = [UIColor clearColor];
tempLabel.textColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"color_A.png"]];
tempLabel.text = [recordings keyAtIndex:section];
tempLabel.textAlignment = NSTextAlignmentCenter;
tempLabel.font = [UIFont boldSystemFontOfSize:17];
tempLabel.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
[tempView addSubview:tempLabel];
return tempView;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[super tableView:tableView didSelectRowAtIndexPath:indexPath];
if (![self isEditing]) {
//TODO: Expand selected cell to display player
}
}
- (void)tableView:(UITableView *)tableView
commitEditingStyle:(UITableViewCellEditingStyle)editingStyle
forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {
[NSNotificationCenter.defaultCenter removeObserver:self];
[tableView beginUpdates];
NSString *date = [recordings keyAtIndex:[indexPath section]];
NSMutableArray *subAr = [recordings objectForKey:date];
//NSString *recording = subAr[indexPath.row];
[subAr removeObjectAtIndex:indexPath.row];
if (subAr.count == 0) {
[recordings removeObjectForKey:date];
[tableView deleteSections:[NSIndexSet indexSetWithIndex:indexPath.section]
withRowAnimation:UITableViewRowAnimationFade];
}
UIRecordingCell* cell = [self.tableView cellForRowAtIndexPath:indexPath];
[cell setRecording:NULL];
//TODO: Delete recording file here
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
[tableView endUpdates];
[self loadData];
}
}
- (void)removeSelectionUsing:(void (^)(NSIndexPath *))remover {
[super removeSelectionUsing:^(NSIndexPath *indexPath) {
[NSNotificationCenter.defaultCenter removeObserver:self];
NSString *date = [recordings keyAtIndex:[indexPath section]];
NSMutableArray *subAr = [recordings objectForKey:date];
//NSString *recording = subAr[indexPath.row];
[subAr removeObjectAtIndex:indexPath.row];
if (subAr.count == 0) {
[recordings removeObjectForKey:date];
}
UIRecordingCell* cell = [self.tableView cellForRowAtIndexPath:indexPath];
[cell setRecording:NULL];
//TODO: Delete recording file here
}];
}
@end
//
// RecordingsListView.h
// linphone
//
// Created by benjamin_verdier on 25/07/2018.
//
#import <UIKit/UIKit.h>
#import "UICompositeView.h"
#import "RecordingsListTableView.h"
#import "UIIconButton.h"
typedef enum _RecordingSelectionMode { RecordingSelectionModeNone, RecordingSelectionModeEdit } RecordingSelectionMode;
@interface RecordingSelection : NSObject <UISearchBarDelegate> {
}
+ (void)setSelectionMode:(RecordingSelectionMode)selectionMode;
+ (RecordingSelectionMode)getSelectionMode;
@end
@interface RecordingsListView : UIViewController <UICompositeViewDelegate>
@property(strong, nonatomic) IBOutlet RecordingsListTableView *tableController;
@property(strong, nonatomic) IBOutlet UIView *topBar;
@property(weak, nonatomic) IBOutlet UIIconButton *deleteButton;
- (IBAction)onDeleteClick:(id)sender;
- (IBAction)onEditionChangeClick:(id)sender;
@end
//
// RecordingsListView.m
// linphone
//
// Created by benjamin_verdier on 25/07/2018.
//
#import "RecordingsListView.h"
#import "PhoneMainView.h"
@implementation RecordingSelection
static RecordingSelectionMode sSelectionMode = RecordingSelectionModeNone;
+ (void)setSelectionMode:(RecordingSelectionMode)selectionMode {
sSelectionMode = selectionMode;
}
+ (RecordingSelectionMode)getSelectionMode {
return sSelectionMode;
}
@end
@implementation RecordingsListView
@synthesize tableController;
@synthesize topBar;
#pragma mark - UICompositeViewDelegate Functions
static UICompositeViewDescription *compositeDescription = nil;
+ (UICompositeViewDescription *)compositeViewDescription {
if (compositeDescription == nil) {
compositeDescription = [[UICompositeViewDescription alloc] init:self.class
statusBar:StatusBarView.class
tabBar:TabBarView.class
sideMenu:SideMenuView.class
fullscreen:false
isLeftFragment:YES
fragmentWith:ContactDetailsView.class];
}
return compositeDescription;
}
- (UICompositeViewDescription *)compositeViewDescription {
return self.class.compositeViewDescription;
}
#pragma mark - ViewController Functions
- (void)viewDidLoad {
[super viewDidLoad];
tableController.tableView.accessibilityIdentifier = @"Recordings table";
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
if (tableController.isEditing) {
tableController.editing = NO;
}
}
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
}
- (void) viewWillDisappear:(BOOL)animated {
self.view = NULL;
[self.tableController removeAllRecordings];
}
#pragma mark - Action Functions
- (IBAction)onDeleteClick:(id)sender {
NSString *msg = [NSString stringWithFormat:NSLocalizedString(@"Do you want to delete selected recordings?", nil)];
[LinphoneManager.instance setContactsUpdated:TRUE];
[UIConfirmationDialog ShowWithMessage:msg
cancelMessage:nil
confirmMessage:nil
onCancelClick:^() {
[self onEditionChangeClick:nil];
}
onConfirmationClick:^() {
[tableController removeSelectionUsing:nil];
[tableController loadData];
[self onEditionChangeClick:nil];
}];
}
- (IBAction)onEditionChangeClick:(id)sender {
_deleteButton.hidden = !self.tableController.isEditing;
}
@end
This diff is collapsed.
......@@ -60,6 +60,12 @@
}]];
}
[_sideMenuEntries
addObject:[[SideMenuEntry alloc] initWithTitle:NSLocalizedString(@"Recordings", nil)
tapBlock:^() {
[PhoneMainView.instance
changeCurrentView:AssistantView.compositeViewDescription];
}]];
[_sideMenuEntries
addObject:[[SideMenuEntry alloc] initWithTitle:NSLocalizedString(@"Settings", nil)
tapBlock:^() {
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment