Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
VideoLAN
VLC-iOS
Commits
8b56f7ab
Commit
8b56f7ab
authored
May 24, 2017
by
Soomin Lee
Committed by
Jean-Baptiste Kempf
May 28, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
iOS: Sleep timer initialization refactoring
Signed-off-by:
Jean-Baptiste Kempf
<
jb@videolan.org
>
parent
821ea287
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
40 deletions
+49
-40
Sources/VLCMovieViewController.m
Sources/VLCMovieViewController.m
+49
-40
No files found.
Sources/VLCMovieViewController.m
View file @
8b56f7ab
...
...
@@ -365,46 +365,8 @@ typedef NS_ENUM(NSInteger, VLCPanType) {
_equalizerView
.
hidden
=
YES
;
[
self
.
view
addSubview
:
_equalizerView
];
/* add sleep timer UI */
_sleepTimerContainer
=
[[
VLCFrostedGlasView
alloc
]
initWithFrame
:
CGRectMake
(
0
.,
0
.,
300
.,
162
.)];
_sleepTimerContainer
.
center
=
self
.
view
.
center
;
_sleepTimerContainer
.
autoresizingMask
=
UIViewAutoresizingFlexibleRightMargin
|
UIViewAutoresizingFlexibleLeftMargin
|
UIViewAutoresizingFlexibleBottomMargin
|
UIViewAutoresizingFlexibleTopMargin
;
_sleepTimeDatePicker
=
[[
UIDatePicker
alloc
]
init
];
if
(
deviceSpeedCategory
>=
3
)
{
_sleepTimeDatePicker
.
opaque
=
NO
;
_sleepTimeDatePicker
.
backgroundColor
=
[
UIColor
clearColor
];
}
else
_sleepTimeDatePicker
.
backgroundColor
=
[
UIColor
blackColor
];
_sleepTimeDatePicker
.
tintColor
=
[
UIColor
VLCLightTextColor
];
_sleepTimeDatePicker
.
frame
=
CGRectMake
(
0
.,
0
.,
300
.,
162
.);
_sleepTimeDatePicker
.
autoresizingMask
=
UIViewAutoresizingFlexibleRightMargin
|
UIViewAutoresizingFlexibleLeftMargin
|
UIViewAutoresizingFlexibleBottomMargin
|
UIViewAutoresizingFlexibleTopMargin
;
[
_sleepTimerContainer
addSubview
:
_sleepTimeDatePicker
];
/* adapt the date picker style to suit our needs */
[
_sleepTimeDatePicker
setValue
:[
UIColor
whiteColor
]
forKeyPath
:
@"textColor"
];
SEL
selector
=
NSSelectorFromString
(
@"setHighlightsToday:"
);
NSInvocation
*
invocation
=
[
NSInvocation
invocationWithMethodSignature
:[
UIDatePicker
instanceMethodSignatureForSelector
:
selector
]];
BOOL
no
=
NO
;
[
invocation
setSelector
:
selector
];
[
invocation
setArgument
:
&
no
atIndex
:
2
];
[
invocation
invokeWithTarget
:
_sleepTimeDatePicker
];
if
(
_sleepTimerContainer
.
subviews
.
count
>
0
)
{
NSArray
*
subviewsOfSubview
=
[
_sleepTimeDatePicker
.
subviews
[
0
]
subviews
];
NSUInteger
subviewCount
=
subviewsOfSubview
.
count
;
for
(
NSUInteger
x
=
0
;
x
<
subviewCount
;
x
++
)
{
if
([
subviewsOfSubview
[
x
]
isKindOfClass
:[
UILabel
class
]])
[
subviewsOfSubview
[
x
]
setTextColor
:[
UIColor
VLCLightTextColor
]];
}
}
_sleepTimeDatePicker
.
datePickerMode
=
UIDatePickerModeCountDownTimer
;
_sleepTimeDatePicker
.
minuteInterval
=
1
;
_sleepTimeDatePicker
.
minimumDate
=
[
NSDate
date
];
_sleepTimeDatePicker
.
countDownDuration
=
1200
.;
[
_sleepTimeDatePicker
addTarget
:
self
action
:
@selector
(
sleepTimerAction
:
)
forControlEvents
:
UIControlEventValueChanged
];
[
self
.
view
addSubview
:
_sleepTimerContainer
];
//Sleep Timer initialization
[
self
sleepTimerInitializer
:
deviceSpeedCategory
];
VLCMovieViewControlPanelViewController
*
panelVC
=
[[
VLCMovieViewControlPanelViewController
alloc
]
initWithNibName
:
@"VLCMovieViewControlPanel"
bundle:
nil
];
...
...
@@ -579,6 +541,53 @@ typedef NS_ENUM(NSInteger, VLCPanType) {
_variableJumpDurationEnabled
=
[[
defaults
objectForKey
:
kVLCSettingVariableJumpDuration
]
boolValue
];
}
#pragma mark - Initializer helper
-
(
void
)
sleepTimerInitializer
:(
int
)
deviceSpeedCategory
{
/* add sleep timer UI */
_sleepTimerContainer
=
[[
VLCFrostedGlasView
alloc
]
initWithFrame
:
CGRectMake
(
0
.,
0
.,
300
.,
200
.)];
_sleepTimerContainer
.
center
=
self
.
view
.
center
;
_sleepTimerContainer
.
autoresizingMask
=
UIViewAutoresizingFlexibleRightMargin
|
UIViewAutoresizingFlexibleLeftMargin
|
UIViewAutoresizingFlexibleBottomMargin
|
UIViewAutoresizingFlexibleTopMargin
;
_sleepTimeDatePicker
=
[[
UIDatePicker
alloc
]
init
];
if
(
deviceSpeedCategory
>=
3
)
{
_sleepTimeDatePicker
.
opaque
=
NO
;
_sleepTimeDatePicker
.
backgroundColor
=
[
UIColor
clearColor
];
}
else
_sleepTimeDatePicker
.
backgroundColor
=
[
UIColor
blackColor
];
_sleepTimeDatePicker
.
tintColor
=
[
UIColor
VLCLightTextColor
];
_sleepTimeDatePicker
.
frame
=
CGRectMake
(
0
.,
0
.,
300
.,
162
.);
_sleepTimeDatePicker
.
autoresizingMask
=
UIViewAutoresizingFlexibleRightMargin
|
UIViewAutoresizingFlexibleLeftMargin
|
UIViewAutoresizingFlexibleBottomMargin
|
UIViewAutoresizingFlexibleTopMargin
;
[
_sleepTimerContainer
addSubview
:
_sleepTimeDatePicker
];
/* adapt the date picker style to suit our needs */
[
_sleepTimeDatePicker
setValue
:[
UIColor
whiteColor
]
forKeyPath
:
@"textColor"
];
SEL
selector
=
NSSelectorFromString
(
@"setHighlightsToday:"
);
NSInvocation
*
invocation
=
[
NSInvocation
invocationWithMethodSignature
:[
UIDatePicker
instanceMethodSignatureForSelector
:
selector
]];
BOOL
no
=
NO
;
[
invocation
setSelector
:
selector
];
[
invocation
setArgument
:
&
no
atIndex
:
2
];
[
invocation
invokeWithTarget
:
_sleepTimeDatePicker
];
if
(
_sleepTimerContainer
.
subviews
.
count
>
0
)
{
NSArray
*
subviewsOfSubview
=
[
_sleepTimeDatePicker
.
subviews
[
0
]
subviews
];
NSUInteger
subviewCount
=
subviewsOfSubview
.
count
;
for
(
NSUInteger
x
=
0
;
x
<
subviewCount
;
x
++
)
{
if
([
subviewsOfSubview
[
x
]
isKindOfClass
:[
UILabel
class
]])
[
subviewsOfSubview
[
x
]
setTextColor
:[
UIColor
VLCLightTextColor
]];
}
}
_sleepTimeDatePicker
.
datePickerMode
=
UIDatePickerModeCountDownTimer
;
_sleepTimeDatePicker
.
minuteInterval
=
1
;
_sleepTimeDatePicker
.
minimumDate
=
[
NSDate
date
];
_sleepTimeDatePicker
.
countDownDuration
=
1200
.;
[
self
.
view
addSubview
:
_sleepTimerContainer
];
}
#pragma mark - controls visibility
-
(
void
)
handlePinchGesture
:(
UIPinchGestureRecognizer
*
)
recognizer
...
...
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