Skip to content
This repository has been archived by the owner on Oct 5, 2018. It is now read-only.

Commit

Permalink
Updated InAppSettingsKit to the latest version
Browse files Browse the repository at this point in the history
  • Loading branch information
Adrian Kosmaczewski committed Jul 23, 2010
1 parent 87ebef8 commit 083f721
Show file tree
Hide file tree
Showing 17 changed files with 517 additions and 205 deletions.
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -24,19 +24,18 @@
@end @end




@interface IASKAppSettingsViewController : UIViewController <UITextFieldDelegate> { @interface IASKAppSettingsViewController : UIViewController <UITextFieldDelegate, UINavigationControllerDelegate> {
id<IASKSettingsDelegate> _delegate; id<IASKSettingsDelegate> _delegate;
IBOutlet UITableView *_tableView; IBOutlet UITableView *_tableView;


NSMutableArray *_viewList; NSMutableArray *_viewList;
NSIndexPath *_currentIndexPath; NSIndexPath *_currentIndexPath;
CGFloat animatedDistance; NSIndexPath *_topmostRowBeforeKeyboardWasShown;
CGRect viewFrameBeforeAnimation;


IASKSettingsReader *_settingsReader; IASKSettingsReader *_settingsReader;
NSString *_file; NSString *_file;


id currentFirstResponder; id _currentFirstResponder;


BOOL _showCreditsFooter; BOOL _showCreditsFooter;
BOOL _showDoneButton; BOOL _showDoneButton;
Expand All @@ -52,4 +51,9 @@


- (IBAction)dismiss:(id)sender; - (IBAction)dismiss:(id)sender;


// subclassing: optionally override these methods to customize appearance and functionality
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
- (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath;
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath;

@end @end
310 changes: 198 additions & 112 deletions Externals/InAppSettingsKit/Controllers/IASKAppSettingsViewController.m

Large diffs are not rendered by default.

Original file line number Original file line Diff line number Diff line change
Expand Up @@ -49,8 +49,15 @@ - (void)viewWillAppear:(BOOL)animated {
if (_tableView) { if (_tableView) {
[_tableView reloadData]; [_tableView reloadData];
} }
[super viewWillAppear:animated];
} }


- (void)viewDidAppear:(BOOL)animated {
[_tableView flashScrollIndicators];
[super viewDidAppear:animated];
}


- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationPortrait) || (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown); return (interfaceOrientation == UIInterfaceOrientationPortrait) || (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown);
} }
Expand Down
24 changes: 18 additions & 6 deletions Externals/InAppSettingsKit/Models/IASKSettingsReader.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#define kIASKIsSecure @"IsSecure" #define kIASKIsSecure @"IsSecure"
#define KIASKKeyboardType @"KeyboardType" #define KIASKKeyboardType @"KeyboardType"
#define kIASKAutocapitalizationType @"AutocapitalizationType" #define kIASKAutocapitalizationType @"AutocapitalizationType"
#define kIASKAutoCorrectionType @"AutoCorrectionType" #define kIASKAutoCorrectionType @"AutocorrectionType"
#define kIASKValues @"Values" #define kIASKValues @"Values"
#define kIASKTitles @"Titles" #define kIASKTitles @"Titles"
#define kIASKKeyboardAlphabet @"Alphabet" #define kIASKKeyboardAlphabet @"Alphabet"
Expand All @@ -53,26 +53,37 @@
#define kIASKPSSliderSpecifier @"PSSliderSpecifier" #define kIASKPSSliderSpecifier @"PSSliderSpecifier"
#define kIASKPSTitleValueSpecifier @"PSTitleValueSpecifier" #define kIASKPSTitleValueSpecifier @"PSTitleValueSpecifier"
#define kIASKPSTextFieldSpecifier @"PSTextFieldSpecifier" #define kIASKPSTextFieldSpecifier @"PSTextFieldSpecifier"

#define kIASKPSChildPaneSpecifier @"PSChildPaneSpecifier" #define kIASKPSChildPaneSpecifier @"PSChildPaneSpecifier"
#define kIASKOpenURLSpecifier @"IASKOpenURLSpecifier"


#define kIASKBundleFolder @"Settings.bundle" #define kIASKBundleFolder @"Settings.bundle"
#define kIASKBundleFolderAlt @"InAppSettings.bundle"
#define kIASKBundleFilename @"Root.plist" #define kIASKBundleFilename @"Root.plist"


#define kIASKAppSettingChanged @"kAppSettingChanged" #define kIASKAppSettingChanged @"kAppSettingChanged"


#define kIASKSectionHeaderIndex 0 #define kIASKSectionHeaderIndex 0


#define kIASKSliderNoImagesX 11 #define kIASKSliderNoImagesX 21
#define kIASKSliderNoImagesWidth 278 #define kIASKSliderNoImagesWidth 278
#define kIASKSliderBothImagesX 45 #define kIASKSliderBothImagesX 53
#define kIASKSliderBothImagesWidth 210 #define kIASKSliderBothImagesWidth 214
#define kIASKSliderOneImageWidth 244 #define kIASKSliderOneImageWidth 246

#define kIASKTableWidth 320
#define kIASKSpacing 5
#define kIASKMinLabelWidth 97
#define kIASKMinValueWidth 35
#define kIASKPaddingLeft 9
#define kIASKPaddingRight 10

#define kIASKLabelFontSize 17


@class IASKSpecifier; @class IASKSpecifier;


@interface IASKSettingsReader : NSObject { @interface IASKSettingsReader : NSObject {
NSString *_path; NSString *_path;
NSString *_bundleFolder;
NSDictionary *_settingsBundle; NSDictionary *_settingsBundle;
NSArray *_dataSource; NSArray *_dataSource;
NSBundle *_bundle; NSBundle *_bundle;
Expand All @@ -89,6 +100,7 @@
- (NSString*)pathForImageNamed:(NSString*)image; - (NSString*)pathForImageNamed:(NSString*)image;


@property (nonatomic, retain) NSString *path; @property (nonatomic, retain) NSString *path;
@property (nonatomic, retain) NSString *bundleFolder;
@property (nonatomic, retain) NSDictionary *settingsBundle; @property (nonatomic, retain) NSDictionary *settingsBundle;
@property (nonatomic, retain) NSArray *dataSource; @property (nonatomic, retain) NSArray *dataSource;


Expand Down
29 changes: 19 additions & 10 deletions Externals/InAppSettingsKit/Models/IASKSettingsReader.m
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ - (BOOL)_sectionHasHeading:(NSInteger)section;


@implementation IASKSettingsReader @implementation IASKSettingsReader


@synthesize path=_path, @synthesize path=_path,
bundleFolder=_bundleFolder,
settingsBundle=_settingsBundle, settingsBundle=_settingsBundle,
dataSource=_dataSource; dataSource=_dataSource;


Expand All @@ -33,15 +34,23 @@ - (id)init {
} }


- (id)initWithFile:(NSString*)file { - (id)initWithFile:(NSString*)file {
if (self=[super init]) { if ((self=[super init])) {
// Generate the settings bundle path [self setBundleFolder:kIASKBundleFolderAlt];
NSString *path = [self bundlePath]; // Generate the settings bundle path
NSString *path = [self bundlePath];
[self setPath:[path stringByAppendingPathComponent:[file stringByAppendingString:@".inApp.plist"]]];
[self setSettingsBundle:[NSDictionary dictionaryWithContentsOfFile:[self path]]]; // Try both bundle folders
if (!self.settingsBundle) { for (int i=0;i<2;i++) {
[self setPath:[path stringByAppendingPathComponent:[file stringByAppendingString:@".plist"]]]; [self setPath:[path stringByAppendingPathComponent:[file stringByAppendingString:@".inApp.plist"]]];
[self setSettingsBundle:[NSDictionary dictionaryWithContentsOfFile:[self path]]]; [self setSettingsBundle:[NSDictionary dictionaryWithContentsOfFile:[self path]]];
if (!self.settingsBundle) {
[self setPath:[path stringByAppendingPathComponent:[file stringByAppendingString:@".plist"]]];
[self setSettingsBundle:[NSDictionary dictionaryWithContentsOfFile:[self path]]];
}
if (self.settingsBundle)
break;
[self setBundleFolder:kIASKBundleFolder];
path = [self bundlePath];
} }
_bundle = [[NSBundle bundleWithPath:path] retain]; _bundle = [[NSBundle bundleWithPath:path] retain];


Expand Down Expand Up @@ -138,7 +147,7 @@ - (NSString*)titleForStringId:(NSString*)stringId {


- (NSString*)bundlePath { - (NSString*)bundlePath {
NSString *libDirectory = [[NSBundle mainBundle] bundlePath]; NSString *libDirectory = [[NSBundle mainBundle] bundlePath];
return [libDirectory stringByAppendingPathComponent:kIASKBundleFolder]; return [libDirectory stringByAppendingPathComponent:_bundleFolder];
} }


- (NSString*)pathForImageNamed:(NSString*)image { - (NSString*)pathForImageNamed:(NSString*)image {
Expand Down
2 changes: 1 addition & 1 deletion Externals/InAppSettingsKit/Models/IASKSpecifier.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
IASKSettingsReader *_settingsReader; IASKSettingsReader *_settingsReader;
} }
@property (nonatomic, retain) NSDictionary *specifierDict; @property (nonatomic, retain) NSDictionary *specifierDict;
@property (nonatomic, retain) IASKSettingsReader *settingsReader; @property (nonatomic, assign) IASKSettingsReader *settingsReader;


- (id)initWithSpecifier:(NSDictionary*)specifier; - (id)initWithSpecifier:(NSDictionary*)specifier;
- (NSString*)title; - (NSString*)title;
Expand Down
28 changes: 19 additions & 9 deletions Externals/InAppSettingsKit/Models/IASKSpecifier.m
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ - (id)initWithSpecifier:(NSDictionary*)specifier {
if ([super init]) { if ([super init]) {
[self setSpecifierDict:specifier]; [self setSpecifierDict:specifier];


if ([[self type] isEqualToString:kIASKPSMultiValueSpecifier]) { if ([[self type] isEqualToString:kIASKPSMultiValueSpecifier] ||
[[self type] isEqualToString:kIASKPSTitleValueSpecifier]) {
[self _reinterpretValues:[self specifierDict]]; [self _reinterpretValues:[self specifierDict]];
} }
} }
Expand All @@ -42,7 +43,6 @@ - (id)initWithSpecifier:(NSDictionary*)specifier {
- (void)dealloc { - (void)dealloc {
[_specifierDict release]; [_specifierDict release];
[_multipleValuesDict release]; [_multipleValuesDict release];
[_settingsReader release];
_settingsReader = nil; _settingsReader = nil;


[super dealloc]; [super dealloc];
Expand All @@ -54,8 +54,13 @@ - (void)_reinterpretValues:(NSDictionary*)specifierDict {


NSMutableDictionary *multipleValuesDict = [[[NSMutableDictionary alloc] init] autorelease]; NSMutableDictionary *multipleValuesDict = [[[NSMutableDictionary alloc] init] autorelease];


[multipleValuesDict setObject:values forKey:kIASKValues]; if (values) {
[multipleValuesDict setObject:titles forKey:kIASKTitles]; [multipleValuesDict setObject:values forKey:kIASKValues];
}

if (titles) {
[multipleValuesDict setObject:titles forKey:kIASKTitles];
}


[self setMultipleValuesDict:multipleValuesDict]; [self setMultipleValuesDict:multipleValuesDict];
} }
Expand All @@ -73,12 +78,17 @@ - (NSString*)type {
} }


- (NSString*)titleForCurrentValue:(id)currentValue { - (NSString*)titleForCurrentValue:(id)currentValue {
NSInteger keyIndex = [[_multipleValuesDict objectForKey:kIASKValues] indexOfObject:currentValue]; NSArray *values = [self multipleValues];
NSArray *titles = [self multipleTitles];
if (values.count != titles.count) {
return nil;
}
NSInteger keyIndex = [values indexOfObject:currentValue];
if (keyIndex == NSNotFound) { if (keyIndex == NSNotFound) {
return nil; return nil;
} }
@try { @try {
return [self.settingsReader titleForStringId:[[_multipleValuesDict objectForKey:kIASKTitles] objectAtIndex:keyIndex]]; return [self.settingsReader titleForStringId:[titles objectAtIndex:keyIndex]];
} }
@catch (NSException * e) {} @catch (NSException * e) {}
return nil; return nil;
Expand Down Expand Up @@ -183,13 +193,13 @@ - (UITextAutocapitalizationType)autocapitalizationType {
} }


- (UITextAutocorrectionType)autoCorrectionType { - (UITextAutocorrectionType)autoCorrectionType {
if ([[_specifierDict objectForKey:kIASKAutoCorrectionType] isEqualToString:kIASKAutoCapNone]) { if ([[_specifierDict objectForKey:kIASKAutoCorrectionType] isEqualToString:kIASKAutoCorrDefault]) {
return UITextAutocorrectionTypeDefault; return UITextAutocorrectionTypeDefault;
} }
else if ([[_specifierDict objectForKey:kIASKAutoCorrectionType] isEqualToString:kIASKAutoCapSentences]) { else if ([[_specifierDict objectForKey:kIASKAutoCorrectionType] isEqualToString:kIASKAutoCorrNo]) {
return UITextAutocorrectionTypeNo; return UITextAutocorrectionTypeNo;
} }
else if ([[_specifierDict objectForKey:kIASKAutoCorrectionType] isEqualToString:kIASKAutoCapWords]) { else if ([[_specifierDict objectForKey:kIASKAutoCorrectionType] isEqualToString:kIASKAutoCorrYes]) {
return UITextAutocorrectionTypeYes; return UITextAutocorrectionTypeYes;
} }
return UITextAutocorrectionTypeDefault; return UITextAutocorrectionTypeDefault;
Expand Down
51 changes: 35 additions & 16 deletions Externals/InAppSettingsKit/Views/IASKPSSliderSpecifierViewCell.m
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// IASKPSSliderSpecifierViewCell.m // IASKPSSliderSpecifierViewCell.m
// http://www.inappsettingskit.com // http://www.inappsettingskit.com
// //
// Copyright (c) 2009: // Copyright (c) 2009-2010:
// Luc Vandal, Edovia Inc., http://www.edovia.com // Luc Vandal, Edovia Inc., http://www.edovia.com
// Ortwin Gentz, FutureTap GmbH, http://www.futuretap.com // Ortwin Gentz, FutureTap GmbH, http://www.futuretap.com
// All rights reserved. // All rights reserved.
Expand All @@ -16,32 +16,51 @@


#import "IASKPSSliderSpecifierViewCell.h" #import "IASKPSSliderSpecifierViewCell.h"
#import "IASKSlider.h" #import "IASKSlider.h"
#import "IASKSettingsReader.h"


@implementation IASKPSSliderSpecifierViewCell @implementation IASKPSSliderSpecifierViewCell


@synthesize slider=_slider, @synthesize slider=_slider,
minImage=_minImage, minImage=_minImage,
maxImage=_maxImage; maxImage=_maxImage;


- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { - (void)layoutSubviews {
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) { CGRect sliderFrame = _slider.frame;
// Initialization code sliderFrame.origin.x = kIASKSliderNoImagesX;
} sliderFrame.size.width = kIASKSliderNoImagesWidth;
return self; _minImage.hidden = YES;
} _maxImage.hidden = YES;


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {

[super setSelected:selected animated:animated];

// Configure the view for the selected state
}


// Check if there are min and max images. If so, change the layout accordingly.
if (_minImage.image && _maxImage.image) {
// Both images
_minImage.hidden = NO;
_maxImage.hidden = NO;
sliderFrame.origin.x = kIASKSliderBothImagesX;
sliderFrame.size.width = kIASKSliderBothImagesWidth;
}
else if (_minImage.image) {
// Min image
_minImage.hidden = NO;
sliderFrame.origin.x = kIASKSliderBothImagesX;
sliderFrame.size.width = kIASKSliderOneImageWidth;
}
else if (_maxImage.image) {
// Max image
_maxImage.hidden = NO;
sliderFrame.origin.x = kIASKSliderNoImagesX;
sliderFrame.size.width = kIASKSliderOneImageWidth;
}

_slider.frame = sliderFrame;
}


- (void)dealloc { - (void)dealloc {
[super dealloc]; [super dealloc];
} }



- (void)prepareForReuse {
_minImage.image = nil;
_maxImage.image = nil;
}
@end @end
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// IASKPSTextFieldSpecifierViewCell.m // IASKPSTextFieldSpecifierViewCell.m
// http://www.inappsettingskit.com // http://www.inappsettingskit.com
// //
// Copyright (c) 2009: // Copyright (c) 2009-2010:
// Luc Vandal, Edovia Inc., http://www.edovia.com // Luc Vandal, Edovia Inc., http://www.edovia.com
// Ortwin Gentz, FutureTap GmbH, http://www.futuretap.com // Ortwin Gentz, FutureTap GmbH, http://www.futuretap.com
// All rights reserved. // All rights reserved.
Expand All @@ -16,19 +16,24 @@


#import "IASKPSTextFieldSpecifierViewCell.h" #import "IASKPSTextFieldSpecifierViewCell.h"
#import "IASKTextField.h" #import "IASKTextField.h"
#import "IASKSettingsReader.h"


@implementation IASKPSTextFieldSpecifierViewCell @implementation IASKPSTextFieldSpecifierViewCell


@synthesize label=_label, @synthesize label=_label,
textField=_textField; textField=_textField;

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
// Initialization code
}
return self;
}


- (void)layoutSubviews {
CGSize labelSize = [_label sizeThatFits:CGSizeZero];
labelSize.width = MIN(labelSize.width, _label.bounds.size.width);

CGRect textFieldFrame = _textField.frame;
textFieldFrame.origin.x = _label.frame.origin.x + MAX(kIASKMinLabelWidth, labelSize.width) + kIASKSpacing;
if (!_label.text.length)
textFieldFrame.origin.x = _label.frame.origin.x;
textFieldFrame.size.width = kIASKTableWidth - textFieldFrame.origin.x - _label.frame.origin.x;
_textField.frame = textFieldFrame;
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated { - (void)setSelected:(BOOL)selected animated:(BOOL)animated {


Expand Down
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,22 @@
//
// IASKPSTitleValueSpecifierViewCell.h
// http://www.inappsettingskit.com
//
// Copyright (c) 2010:
// Luc Vandal, Edovia Inc., http://www.edovia.com
// Ortwin Gentz, FutureTap GmbH, http://www.futuretap.com
// All rights reserved.
//
// It is appreciated but not required that you give credit to Luc Vandal and Ortwin Gentz,
// as the original authors of this code. You can give credit in a blog post, a tweet or on
// a info page of your app. Also, the original authors appreciate letting them know if you use this code.
//
// This code is licensed under the BSD license that is available at: http://www.opensource.org/licenses/bsd-license.php
//

#import <UIKit/UIKit.h>


@interface IASKPSTitleValueSpecifierViewCell : UITableViewCell

@end
Loading

0 comments on commit 083f721

Please sign in to comment.