Commit efd3f9d9 authored by Felix Paul Kühne's avatar Felix Paul Kühne

settings view controller: refactor code

parent 5fbd35fc
......@@ -17,8 +17,7 @@
@property (nonatomic, strong) IBOutlet UISwitch *audioPlaybackInBackgroundSwitch;
@property (nonatomic, strong) IBOutlet UILabel *audioPlaybackInBackgroundLabel;
- (IBAction)togglePasscodeLockSetting:(id)sender;
- (IBAction)toggleAudioInBackGroundSetting:(id)sender;
- (IBAction)toggleSetting:(id)sender;
- (IBAction)dismiss:(id)sender;
......
......@@ -37,28 +37,27 @@
[super viewWillAppear:animated];
}
- (IBAction)togglePasscodeLockSetting:(id)sender
- (IBAction)toggleSetting:(id)sender
{
if (self.passcodeLockSwitch.on) {
VLCAppDelegate* appDelegate = [UIApplication sharedApplication].delegate;
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
CGRect frame = self.view.frame;
frame.size.height -= 44.;
appDelegate.playlistViewController.passcodeLockViewController.view.frame = frame;
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if (sender == self.passcodeLockSwitch) {
if (self.passcodeLockSwitch.on) {
VLCAppDelegate* appDelegate = [UIApplication sharedApplication].delegate;
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
CGRect frame = self.view.frame;
frame.size.height -= 44.;
appDelegate.playlistViewController.passcodeLockViewController.view.frame = frame;
}
[self.view addSubview:appDelegate.playlistViewController.passcodeLockViewController.view];
[appDelegate.playlistViewController.passcodeLockViewController resetPasscode];
} else {
[defaults setObject:@0 forKey:kVLCSettingPasscodeOnKey];
}
[self.view addSubview:appDelegate.playlistViewController.passcodeLockViewController.view];
[appDelegate.playlistViewController.passcodeLockViewController resetPasscode];
} else {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:@0 forKey:kVLCSettingPasscodeOnKey];
[defaults synchronize];
} else if (sender == self.audioPlaybackInBackgroundSwitch) {
[defaults setObject:@(self.audioPlaybackInBackgroundSwitch.on) forKey:kVLCSettingContinueAudioInBackgroundKey];
}
}
- (IBAction)toggleAudioInBackGroundSetting:(id)sender
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:@(self.audioPlaybackInBackgroundSwitch.on) forKey:kVLCSettingContinueAudioInBackgroundKey];
[defaults synchronize];
}
......
......@@ -82,17 +82,17 @@
<bool key="IBUIUserInteractionEnabled">NO</bool>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<string key="IBUIText">Passcode Lock</string>
<object class="NSColor" key="IBUITextColor" id="33374124">
<object class="NSColor" key="IBUITextColor" id="827890894">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MC42NjY2NjY2NjY3AA</bytes>
</object>
<nil key="IBUIHighlightedColor"/>
<int key="IBUIBaselineAdjustment">0</int>
<object class="IBUIFontDescription" key="IBUIFontDescription" id="210361183">
<object class="IBUIFontDescription" key="IBUIFontDescription" id="954619706">
<int key="type">1</int>
<double key="pointSize">17</double>
</object>
<object class="NSFont" key="IBUIFont" id="965406955">
<object class="NSFont" key="IBUIFont" id="444457035">
<string key="NSName">Helvetica</string>
<double key="NSSize">17</double>
<int key="NSfFlags">16</int>
......@@ -105,20 +105,20 @@
<string key="NSFrame">{{428, 72}, {94, 27}}</string>
<reference key="NSSuperview" ref="1058981638"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="76469752"/>
<reference key="NSNextKeyView" ref="607504973"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="IBUIOpaque">NO</bool>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<int key="IBUIContentHorizontalAlignment">0</int>
<int key="IBUIContentVerticalAlignment">0</int>
</object>
<object class="IBUILabel" id="76469752">
<object class="IBUILabel" id="607504973">
<reference key="NSNextResponder" ref="1058981638"/>
<int key="NSvFlags">290</int>
<string key="NSFrame">{{20, 116}, {415, 42}}</string>
<reference key="NSSuperview" ref="1058981638"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="115965713"/>
<reference key="NSNextKeyView" ref="857139100"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIClipsSubviews">YES</bool>
......@@ -126,17 +126,17 @@
<bool key="IBUIUserInteractionEnabled">NO</bool>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<string key="IBUIText">Continue audio playback in background</string>
<reference key="IBUITextColor" ref="33374124"/>
<reference key="IBUITextColor" ref="827890894"/>
<nil key="IBUIHighlightedColor"/>
<int key="IBUIBaselineAdjustment">0</int>
<int key="IBUINumberOfLines">2</int>
<int key="IBUILineBreakMode">0</int>
<reference key="IBUIFontDescription" ref="210361183"/>
<reference key="IBUIFont" ref="965406955"/>
<reference key="IBUIFontDescription" ref="954619706"/>
<reference key="IBUIFont" ref="444457035"/>
<bool key="IBUIAdjustsFontSizeToFit">NO</bool>
<double key="preferredMaxLayoutWidth">415</double>
</object>
<object class="IBUISwitch" id="115965713">
<object class="IBUISwitch" id="857139100">
<reference key="NSNextResponder" ref="1058981638"/>
<int key="NSvFlags">289</int>
<string key="NSFrame">{{428, 123}, {94, 27}}</string>
......@@ -204,7 +204,7 @@
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">audioPlaybackInBackgroundLabel</string>
<reference key="source" ref="372490531"/>
<reference key="destination" ref="76469752"/>
<reference key="destination" ref="607504973"/>
</object>
<int key="connectionID">42</int>
</object>
......@@ -212,7 +212,7 @@
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">audioPlaybackInBackgroundSwitch</string>
<reference key="source" ref="372490531"/>
<reference key="destination" ref="115965713"/>
<reference key="destination" ref="857139100"/>
</object>
<int key="connectionID">43</int>
</object>
......@@ -226,21 +226,21 @@
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">togglePasscodeLockSetting:</string>
<string key="label">toggleSetting:</string>
<reference key="source" ref="268284080"/>
<reference key="destination" ref="372490531"/>
<int key="IBEventType">13</int>
</object>
<int key="connectionID">36</int>
<int key="connectionID">46</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">toggleAudioInBackGroundSetting:</string>
<reference key="source" ref="115965713"/>
<string key="label">toggleSetting:</string>
<reference key="source" ref="857139100"/>
<reference key="destination" ref="372490531"/>
<int key="IBEventType">13</int>
</object>
<int key="connectionID">44</int>
<int key="connectionID">45</int>
</object>
</array>
<object class="IBMutableOrderedSet" key="objectRecords">
......@@ -269,8 +269,8 @@
<reference ref="222768752"/>
<reference ref="890162779"/>
<reference ref="268284080"/>
<reference ref="76469752"/>
<reference ref="115965713"/>
<reference ref="607504973"/>
<reference ref="857139100"/>
</array>
<reference key="parent" ref="0"/>
</object>
......@@ -307,12 +307,12 @@
</object>
<object class="IBObjectRecord">
<int key="objectID">39</int>
<reference key="object" ref="76469752"/>
<reference key="object" ref="607504973"/>
<reference key="parent" ref="1058981638"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">40</int>
<reference key="object" ref="115965713"/>
<reference key="object" ref="857139100"/>
<reference key="parent" ref="1058981638"/>
</object>
</array>
......@@ -335,7 +335,7 @@
<nil key="activeLocalization"/>
<dictionary class="NSMutableDictionary" key="localizations"/>
<nil key="sourceID"/>
<int key="maxID">44</int>
<int key="maxID">46</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
......@@ -344,20 +344,15 @@
<string key="superclassName">UIViewController</string>
<dictionary class="NSMutableDictionary" key="actions">
<string key="dismiss:">id</string>
<string key="toggleAudioInBackGroundSetting:">id</string>
<string key="togglePasscodeLockSetting:">id</string>
<string key="toggleSetting:">id</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="actionInfosByName">
<object class="IBActionInfo" key="dismiss:">
<string key="name">dismiss:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo" key="toggleAudioInBackGroundSetting:">
<string key="name">toggleAudioInBackGroundSetting:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo" key="togglePasscodeLockSetting:">
<string key="name">togglePasscodeLockSetting:</string>
<object class="IBActionInfo" key="toggleSetting:">
<string key="name">toggleSetting:</string>
<string key="candidateClassName">id</string>
</object>
</dictionary>
......
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