Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
VLC-iOS
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
311
Issues
311
List
Boards
Labels
Service Desk
Milestones
Merge Requests
6
Merge Requests
6
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
VideoLAN
VLC-iOS
Commits
bb845d98
Commit
bb845d98
authored
Dec 25, 2013
by
Carola Nitz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Gdrive and Dropbox: show remaning downloadtime
parent
f6420e75
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
107 additions
and
23 deletions
+107
-23
Resources/en.lproj/Localizable.strings
Resources/en.lproj/Localizable.strings
+0
-0
Sources/VLCDropboxController.h
Sources/VLCDropboxController.h
+1
-0
Sources/VLCDropboxController.m
Sources/VLCDropboxController.m
+30
-2
Sources/VLCDropboxTableViewController.m
Sources/VLCDropboxTableViewController.m
+23
-9
Sources/VLCGoogleDriveController.h
Sources/VLCGoogleDriveController.h
+1
-0
Sources/VLCGoogleDriveController.m
Sources/VLCGoogleDriveController.m
+28
-3
Sources/VLCGoogleDriveTableViewController.m
Sources/VLCGoogleDriveTableViewController.m
+24
-9
No files found.
Resources/en.lproj/Localizable.strings
View file @
bb845d98
B
"CHOOSE_AUDIO_TRACK"="Choose Audio Track";
...
...
Sources/VLCDropboxController.h
View file @
bb845d98
...
...
@@ -19,6 +19,7 @@
@optional
-
(
void
)
operationWithProgressInformationStarted
;
-
(
void
)
currentProgressInformation
:(
float
)
progress
;
-
(
void
)
updateRemainingTime
:(
NSString
*
)
time
;
-
(
void
)
operationWithProgressInformationStopped
;
-
(
void
)
numberOfFilesWaitingToBeDownloadedChanged
;
...
...
Sources/VLCDropboxController.m
View file @
bb845d98
...
...
@@ -24,6 +24,11 @@
BOOL
_downloadInProgress
;
NSInteger
_outstandingNetworkRequests
;
CGFloat
_averageSpeed
;
CGFloat
_fileSize
;
NSTimeInterval
_startDL
;
NSTimeInterval
_lastStatsUpdate
;
}
@end
...
...
@@ -96,7 +101,8 @@
{
NSArray
*
searchPaths
=
NSSearchPathForDirectoriesInDomains
(
NSDocumentDirectory
,
NSUserDomainMask
,
YES
);
NSString
*
filePath
=
[
searchPaths
[
0
]
stringByAppendingFormat
:
@"/%@"
,
file
.
filename
];
_startDL
=
[
NSDate
timeIntervalSinceReferenceDate
];
_fileSize
=
file
.
totalBytes
;
[[
self
restClient
]
loadFile
:
file
.
path
intoPath
:
filePath
];
if
([
self
.
delegate
respondsToSelector
:
@selector
(
operationWithProgressInformationStarted
)])
...
...
@@ -160,12 +166,16 @@
if
([
self
.
delegate
respondsToSelector
:
@selector
(
operationWithProgressInformationStopped
)])
[
self
.
delegate
operationWithProgressInformationStopped
];
_downloadInProgress
=
NO
;
[
self
_triggerNextDownload
];
}
-
(
void
)
restClient
:(
DBRestClient
*
)
client
loadProgress
:(
CGFloat
)
progress
forFile
:(
NSString
*
)
destPath
{
if
((
_lastStatsUpdate
>
0
&&
([
NSDate
timeIntervalSinceReferenceDate
]
-
_lastStatsUpdate
>
.
5
))
||
_lastStatsUpdate
<=
0
)
{
[
self
calculateRemainingTime
:
progress
*
_fileSize
expectedDownloadSize
:
_fileSize
];
_lastStatsUpdate
=
[
NSDate
timeIntervalSinceReferenceDate
];
}
if
([
self
.
delegate
respondsToSelector
:
@selector
(
currentProgressInformation
:)])
[
self
.
delegate
currentProgressInformation
:
progress
];
}
...
...
@@ -211,6 +221,24 @@
#pragma mark - VLC internal communication and delegate
-
(
void
)
calculateRemainingTime
:(
CGFloat
)
receivedDataSize
expectedDownloadSize
:(
CGFloat
)
expectedDownloadSize
{
CGFloat
lastSpeed
=
receivedDataSize
/
([
NSDate
timeIntervalSinceReferenceDate
]
-
_startDL
);
CGFloat
smoothingFactor
=
0
.
005
;
_averageSpeed
=
isnan
(
_averageSpeed
)
?
lastSpeed
:
smoothingFactor
*
lastSpeed
+
(
1
-
smoothingFactor
)
*
_averageSpeed
;
CGFloat
RemainingInSeconds
=
(
expectedDownloadSize
-
receivedDataSize
)
/
_averageSpeed
;
NSDate
*
date
=
[
NSDate
dateWithTimeIntervalSince1970
:
RemainingInSeconds
];
NSDateFormatter
*
formatter
=
[[
NSDateFormatter
alloc
]
init
];
[
formatter
setDateFormat
:
@"HH:mm:ss"
];
[
formatter
setTimeZone
:[
NSTimeZone
timeZoneForSecondsFromGMT
:
0
]];
NSString
*
remaingTime
=
[
formatter
stringFromDate
:
date
];
if
([
self
.
delegate
respondsToSelector
:
@selector
(
updateRemainingTime
:)])
[
self
.
delegate
updateRemainingTime
:
remaingTime
];
}
-
(
NSArray
*
)
currentListFiles
{
return
_currentFileList
;
...
...
Sources/VLCDropboxTableViewController.m
View file @
bb845d98
...
...
@@ -34,7 +34,8 @@
UIBarButtonItem
*
_numberOfFilesBarButtonItem
;
UIBarButtonItem
*
_progressBarButtonItem
;
UIBarButtonItem
*
_downloadingBarLabel
;
UIProgressView
*
_progressView
;
UIProgressView
*
_progressBar
;
UILabel
*
_progressLabel
;
UIActivityIndicatorView
*
_activityIndicator
;
DBMetadata
*
_selectedFile
;
...
...
@@ -69,11 +70,18 @@
_numberOfFilesBarButtonItem
=
[[
UIBarButtonItem
alloc
]
initWithTitle
:[
NSString
stringWithFormat
:
NSLocalizedString
(
@"NUM_OF_FILES"
,
@""
),
0
]
style
:
UIBarButtonItemStylePlain
target
:
nil
action
:
nil
];
[
_numberOfFilesBarButtonItem
setTitleTextAttributes
:@{
UITextAttributeFont
:
[
UIFont
systemFontOfSize
:
11
.]
}
forState
:
UIControlStateNormal
];
_progressBar
=
[[
UIProgressView
alloc
]
initWithProgressViewStyle
:
UIProgressViewStyleBar
];
_progressLabel
=
[[
UILabel
alloc
]
init
];
_progressLabel
.
textColor
=
[
UIColor
whiteColor
];
_progressLabel
.
font
=
[
UIFont
systemFontOfSize
:
11
.];
_progressView
=
[[
UIProgressView
alloc
]
initWithProgressViewStyle
:
UIProgressViewStyleBar
];
_progressBarButtonItem
=
[[
UIBarButtonItem
alloc
]
initWithCustomView
:
_progressView
];
_downloadingBarLabel
=
[[
UIBarButtonItem
alloc
]
initWithTitle
:
NSLocalizedString
(
@"DOWNLOADING"
,
@""
)
style
:
UIBarButtonItemStylePlain
target
:
nil
action
:
nil
];
[
_downloadingBarLabel
setTitleTextAttributes
:@{
UITextAttributeFont
:
[
UIFont
systemFontOfSize
:
11
.]
}
forState
:
UIControlStateNormal
];
UIView
*
progressView
=
[[
UIView
alloc
]
init
];
[
progressView
addSubview
:
_progressBar
];
[
progressView
addSubview
:
_progressLabel
];
[
progressView
addConstraint
:[
NSLayoutConstraint
constraintWithItem
:
progressView
attribute
:
NSLayoutAttributeWidth
relatedBy
:
NSLayoutRelationEqual
toItem
:
_progressLabel
attribute
:
NSLayoutAttributeWidth
multiplier
:
1
.
0
f
constant
:
0
.
0
f
]];
progressView
.
translatesAutoresizingMaskIntoConstraints
=
NO
;
_progressBarButtonItem
=
[[
UIBarButtonItem
alloc
]
initWithCustomView
:
progressView
];
[
self
.
cloudStorageLogo
setImage
:[
UIImage
imageNamed
:
@"dropbox-white.png"
]];
if
(
!
SYSTEM_RUNS_IOS7_OR_LATER
)
{
...
...
@@ -123,8 +131,8 @@
if
(
!
value
)
[
self
setToolbarItems
:@[[[
UIBarButtonItem
alloc
]
initWithBarButtonSystemItem
:
UIBarButtonSystemItemFlexibleSpace
target
:
nil
action
:
nil
],
_numberOfFilesBarButtonItem
,
[[
UIBarButtonItem
alloc
]
initWithBarButtonSystemItem
:
UIBarButtonSystemItemFlexibleSpace
target
:
nil
action
:
nil
]]
animated
:
YES
];
else
{
_progress
View
.
progress
=
0
.;
[
self
setToolbarItems
:@[[[
UIBarButtonItem
alloc
]
initWithBarButtonSystemItem
:
UIBarButtonSystemItemFlexibleSpace
target
:
nil
action
:
nil
],
_
downloadingBarLabel
,
_
progressBarButtonItem
,
[[
UIBarButtonItem
alloc
]
initWithBarButtonSystemItem
:
UIBarButtonSystemItemFlexibleSpace
target
:
nil
action
:
nil
]]
animated
:
YES
];
_progress
Bar
.
progress
=
0
.;
[
self
setToolbarItems
:@[[[
UIBarButtonItem
alloc
]
initWithBarButtonSystemItem
:
UIBarButtonSystemItemFlexibleSpace
target
:
nil
action
:
nil
],
_progressBarButtonItem
,
[[
UIBarButtonItem
alloc
]
initWithBarButtonSystemItem
:
UIBarButtonSystemItemFlexibleSpace
target
:
nil
action
:
nil
]]
animated
:
YES
];
}
}
...
...
@@ -233,9 +241,15 @@
[
self
_showProgressInToolbar
:
YES
];
}
-
(
void
)
currentProgressInformation
:(
float
)
progress
-
(
void
)
updateRemainingTime
:(
NSString
*
)
time
{
[
_progressView
setProgress
:
progress
animated
:
YES
];
[
_progressLabel
setText
:[
NSString
stringWithFormat
:
NSLocalizedString
(
@"REMAINING_TIME"
,
nil
),
time
]];
CGSize
size
=
[
_progressLabel
.
text
sizeWithFont
:
_progressLabel
.
font
];
[
_progressLabel
setFrame
:
CGRectMake
(
0
,
2
,
size
.
width
,
size
.
height
)];
}
-
(
void
)
currentProgressInformation
:(
float
)
progress
{
[
_progressBar
setProgress
:
progress
animated
:
YES
];
}
-
(
void
)
operationWithProgressInformationStopped
...
...
Sources/VLCGoogleDriveController.h
View file @
bb845d98
...
...
@@ -22,6 +22,7 @@
@optional
-
(
void
)
operationWithProgressInformationStarted
;
-
(
void
)
currentProgressInformation
:(
float
)
progress
;
-
(
void
)
updateRemainingTime
:(
NSString
*
)
time
;
-
(
void
)
operationWithProgressInformationStopped
;
-
(
void
)
numberOfFilesWaitingToBeDownloadedChanged
;
@end
...
...
Sources/VLCGoogleDriveController.m
View file @
bb845d98
...
...
@@ -27,6 +27,10 @@
BOOL
_downloadInProgress
;
NSString
*
_nextPageToken
;
CGFloat
_averageSpeed
;
NSTimeInterval
_startDL
;
NSTimeInterval
_lastStatsUpdate
;
}
@end
...
...
@@ -211,12 +215,15 @@
// Fetcher logging can include comments.
[
fetcher
setCommentWithFormat
:
@"Downloading
\"
%@
\"
"
,
file
.
title
];
__weak
GTMHTTPFetcher
*
weakFetcher
=
fetcher
;
_startDL
=
[
NSDate
timeIntervalSinceReferenceDate
];
fetcher
.
receivedDataBlock
=
^
(
NSData
*
receivedData
)
{
float
progress
=
(
float
)
weakFetcher
.
downloadedLength
/
(
float
)[
file
.
fileSize
longLongValue
];
if
((
_lastStatsUpdate
>
0
&&
([
NSDate
timeIntervalSinceReferenceDate
]
-
_lastStatsUpdate
>
.
5
))
||
_lastStatsUpdate
<=
0
)
{
[
self
calculateRemainingTime
:
weakFetcher
.
downloadedLength
expectedDownloadSize
:[
file
.
fileSize
floatValue
]];
_lastStatsUpdate
=
[
NSDate
timeIntervalSinceReferenceDate
];
}
CGFloat
progress
=
(
CGFloat
)
weakFetcher
.
downloadedLength
/
(
CGFloat
)[
file
.
fileSize
unsignedLongValue
];
if
([
self
.
delegate
respondsToSelector
:
@selector
(
currentProgressInformation
:)])
[
self
.
delegate
currentProgressInformation
:
progress
];
};
...
...
@@ -233,6 +240,24 @@
}
}
-
(
void
)
calculateRemainingTime
:(
CGFloat
)
receivedDataSize
expectedDownloadSize
:(
CGFloat
)
expectedDownloadSize
{
CGFloat
lastSpeed
=
receivedDataSize
/
([
NSDate
timeIntervalSinceReferenceDate
]
-
_startDL
);
CGFloat
smoothingFactor
=
0
.
005
;
_averageSpeed
=
isnan
(
_averageSpeed
)
?
lastSpeed
:
smoothingFactor
*
lastSpeed
+
(
1
-
smoothingFactor
)
*
_averageSpeed
;
CGFloat
RemainingInSeconds
=
(
expectedDownloadSize
-
receivedDataSize
)
/
_averageSpeed
;
NSDate
*
date
=
[
NSDate
dateWithTimeIntervalSince1970
:
RemainingInSeconds
];
NSDateFormatter
*
formatter
=
[[
NSDateFormatter
alloc
]
init
];
[
formatter
setDateFormat
:
@"HH:mm:ss"
];
[
formatter
setTimeZone
:[
NSTimeZone
timeZoneForSecondsFromGMT
:
0
]];
NSString
*
remaingTime
=
[
formatter
stringFromDate
:
date
];
if
([
self
.
delegate
respondsToSelector
:
@selector
(
updateRemainingTime
:)])
[
self
.
delegate
updateRemainingTime
:
remaingTime
];
}
-
(
void
)
downloadSucessfull
{
/* update library now that we got a file */
...
...
Sources/VLCGoogleDriveTableViewController.m
View file @
bb845d98
...
...
@@ -32,7 +32,8 @@
UIBarButtonItem
*
_numberOfFilesBarButtonItem
;
UIBarButtonItem
*
_progressBarButtonItem
;
UIBarButtonItem
*
_downloadingBarLabel
;
UIProgressView
*
_progressView
;
UIProgressView
*
_progressBar
;
UILabel
*
_progressLabel
;
UIActivityIndicatorView
*
_activityIndicator
;
...
...
@@ -69,10 +70,18 @@
_numberOfFilesBarButtonItem
=
[[
UIBarButtonItem
alloc
]
initWithTitle
:[
NSString
stringWithFormat
:
NSLocalizedString
(
@"NUM_OF_FILES"
,
@""
),
0
]
style
:
UIBarButtonItemStylePlain
target
:
nil
action
:
nil
];
[
_numberOfFilesBarButtonItem
setTitleTextAttributes
:@{
UITextAttributeFont
:
[
UIFont
systemFontOfSize
:
11
.]
}
forState
:
UIControlStateNormal
];
_progressView
=
[[
UIProgressView
alloc
]
initWithProgressViewStyle
:
UIProgressViewStyleBar
];
_progressBarButtonItem
=
[[
UIBarButtonItem
alloc
]
initWithCustomView
:
_progressView
];
_downloadingBarLabel
=
[[
UIBarButtonItem
alloc
]
initWithTitle
:
NSLocalizedString
(
@"DOWNLOADING"
,
@""
)
style
:
UIBarButtonItemStylePlain
target
:
nil
action
:
nil
];
[
_downloadingBarLabel
setTitleTextAttributes
:@{
UITextAttributeFont
:
[
UIFont
systemFontOfSize
:
11
.]
}
forState
:
UIControlStateNormal
];
_progressBar
=
[[
UIProgressView
alloc
]
initWithProgressViewStyle
:
UIProgressViewStyleBar
];
_progressLabel
=
[[
UILabel
alloc
]
init
];
_progressLabel
.
textColor
=
[
UIColor
whiteColor
];
_progressLabel
.
font
=
[
UIFont
systemFontOfSize
:
11
.];
UIView
*
progressView
=
[[
UIView
alloc
]
init
];
[
progressView
addSubview
:
_progressBar
];
[
progressView
addSubview
:
_progressLabel
];
[
progressView
addConstraint
:[
NSLayoutConstraint
constraintWithItem
:
progressView
attribute
:
NSLayoutAttributeWidth
relatedBy
:
NSLayoutRelationEqual
toItem
:
_progressLabel
attribute
:
NSLayoutAttributeWidth
multiplier
:
1
.
0
f
constant
:
0
.
0
f
]];
progressView
.
translatesAutoresizingMaskIntoConstraints
=
NO
;
_progressBarButtonItem
=
[[
UIBarButtonItem
alloc
]
initWithCustomView
:
progressView
];
[
self
.
cloudStorageLogo
setImage
:[
UIImage
imageNamed
:
@"DriveWhite"
]];
...
...
@@ -161,8 +170,8 @@
if
(
!
value
)
[
self
setToolbarItems
:@[[[
UIBarButtonItem
alloc
]
initWithBarButtonSystemItem
:
UIBarButtonSystemItemFlexibleSpace
target
:
nil
action
:
nil
],
_numberOfFilesBarButtonItem
,
[[
UIBarButtonItem
alloc
]
initWithBarButtonSystemItem
:
UIBarButtonSystemItemFlexibleSpace
target
:
nil
action
:
nil
]]
animated
:
YES
];
else
{
_progress
View
.
progress
=
0
.;
[
self
setToolbarItems
:@[[[
UIBarButtonItem
alloc
]
initWithBarButtonSystemItem
:
UIBarButtonSystemItemFlexibleSpace
target
:
nil
action
:
nil
],
_
downloadingBarLabel
,
_
progressBarButtonItem
,
[[
UIBarButtonItem
alloc
]
initWithBarButtonSystemItem
:
UIBarButtonSystemItemFlexibleSpace
target
:
nil
action
:
nil
]]
animated
:
YES
];
_progress
Bar
.
progress
=
0
.;
[
self
setToolbarItems
:@[[[
UIBarButtonItem
alloc
]
initWithBarButtonSystemItem
:
UIBarButtonSystemItemFlexibleSpace
target
:
nil
action
:
nil
],
_progressBarButtonItem
,
[[
UIBarButtonItem
alloc
]
initWithBarButtonSystemItem
:
UIBarButtonSystemItemFlexibleSpace
target
:
nil
action
:
nil
]]
animated
:
YES
];
}
}
...
...
@@ -272,9 +281,15 @@
[
self
_showProgressInToolbar
:
YES
];
}
-
(
void
)
currentProgressInformation
:(
float
)
progress
-
(
void
)
updateRemainingTime
:(
NSString
*
)
time
{
[
_progressView
setProgress
:
progress
animated
:
YES
];
[
_progressLabel
setText
:[
NSString
stringWithFormat
:
NSLocalizedString
(
@"REMAINING_TIME"
,
nil
),
time
]];
CGSize
size
=
[
_progressLabel
.
text
sizeWithFont
:
_progressLabel
.
font
];
[
_progressLabel
setFrame
:
CGRectMake
(
0
,
2
,
size
.
width
,
size
.
height
)];
}
-
(
void
)
currentProgressInformation
:(
float
)
progress
{
[
_progressBar
setProgress
:
progress
animated
:
YES
];
}
-
(
void
)
operationWithProgressInformationStopped
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment