Permalink
Browse files

Updated InAppSettingsKit to the latest version

  • Loading branch information...
1 parent 87ebef8 commit 083f7211a7b598530c3daeb3a961ededb2f804bf Adrian Kosmaczewski committed Jul 23, 2010
@@ -24,19 +24,18 @@
@end
-@interface IASKAppSettingsViewController : UIViewController <UITextFieldDelegate> {
+@interface IASKAppSettingsViewController : UIViewController <UITextFieldDelegate, UINavigationControllerDelegate> {
id<IASKSettingsDelegate> _delegate;
IBOutlet UITableView *_tableView;
NSMutableArray *_viewList;
NSIndexPath *_currentIndexPath;
- CGFloat animatedDistance;
- CGRect viewFrameBeforeAnimation;
+ NSIndexPath *_topmostRowBeforeKeyboardWasShown;
IASKSettingsReader *_settingsReader;
NSString *_file;
- id currentFirstResponder;
+ id _currentFirstResponder;
BOOL _showCreditsFooter;
BOOL _showDoneButton;
@@ -52,4 +51,9 @@
- (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

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -49,8 +49,15 @@ - (void)viewWillAppear:(BOOL)animated {
if (_tableView) {
[_tableView reloadData];
}
+ [super viewWillAppear:animated];
}
+- (void)viewDidAppear:(BOOL)animated {
+ [_tableView flashScrollIndicators];
+ [super viewDidAppear:animated];
+}
+
+
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationPortrait) || (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown);
}
@@ -29,7 +29,7 @@
#define kIASKIsSecure @"IsSecure"
#define KIASKKeyboardType @"KeyboardType"
#define kIASKAutocapitalizationType @"AutocapitalizationType"
-#define kIASKAutoCorrectionType @"AutoCorrectionType"
+#define kIASKAutoCorrectionType @"AutocorrectionType"
#define kIASKValues @"Values"
#define kIASKTitles @"Titles"
#define kIASKKeyboardAlphabet @"Alphabet"
@@ -53,26 +53,37 @@
#define kIASKPSSliderSpecifier @"PSSliderSpecifier"
#define kIASKPSTitleValueSpecifier @"PSTitleValueSpecifier"
#define kIASKPSTextFieldSpecifier @"PSTextFieldSpecifier"
-
#define kIASKPSChildPaneSpecifier @"PSChildPaneSpecifier"
+#define kIASKOpenURLSpecifier @"IASKOpenURLSpecifier"
#define kIASKBundleFolder @"Settings.bundle"
+#define kIASKBundleFolderAlt @"InAppSettings.bundle"
#define kIASKBundleFilename @"Root.plist"
#define kIASKAppSettingChanged @"kAppSettingChanged"
#define kIASKSectionHeaderIndex 0
-#define kIASKSliderNoImagesX 11
+#define kIASKSliderNoImagesX 21
#define kIASKSliderNoImagesWidth 278
-#define kIASKSliderBothImagesX 45
-#define kIASKSliderBothImagesWidth 210
-#define kIASKSliderOneImageWidth 244
+#define kIASKSliderBothImagesX 53
+#define kIASKSliderBothImagesWidth 214
+#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;
@interface IASKSettingsReader : NSObject {
NSString *_path;
+ NSString *_bundleFolder;
NSDictionary *_settingsBundle;
NSArray *_dataSource;
NSBundle *_bundle;
@@ -89,6 +100,7 @@
- (NSString*)pathForImageNamed:(NSString*)image;
@property (nonatomic, retain) NSString *path;
+@property (nonatomic, retain) NSString *bundleFolder;
@property (nonatomic, retain) NSDictionary *settingsBundle;
@property (nonatomic, retain) NSArray *dataSource;
@@ -24,7 +24,8 @@ - (BOOL)_sectionHasHeading:(NSInteger)section;
@implementation IASKSettingsReader
-@synthesize path=_path,
+@synthesize path=_path,
+bundleFolder=_bundleFolder,
settingsBundle=_settingsBundle,
dataSource=_dataSource;
@@ -33,15 +34,23 @@ - (id)init {
}
- (id)initWithFile:(NSString*)file {
- if (self=[super init]) {
- // Generate the settings bundle path
- NSString *path = [self bundlePath];
-
- [self setPath:[path stringByAppendingPathComponent:[file stringByAppendingString:@".inApp.plist"]]];
- [self setSettingsBundle:[NSDictionary dictionaryWithContentsOfFile:[self path]]];
- if (!self.settingsBundle) {
- [self setPath:[path stringByAppendingPathComponent:[file stringByAppendingString:@".plist"]]];
+ if ((self=[super init])) {
+ [self setBundleFolder:kIASKBundleFolderAlt];
+ // Generate the settings bundle path
+ NSString *path = [self bundlePath];
+
+ // Try both bundle folders
+ for (int i=0;i<2;i++) {
+ [self setPath:[path stringByAppendingPathComponent:[file stringByAppendingString:@".inApp.plist"]]];
[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];
@@ -138,7 +147,7 @@ - (NSString*)titleForStringId:(NSString*)stringId {
- (NSString*)bundlePath {
NSString *libDirectory = [[NSBundle mainBundle] bundlePath];
- return [libDirectory stringByAppendingPathComponent:kIASKBundleFolder];
+ return [libDirectory stringByAppendingPathComponent:_bundleFolder];
}
- (NSString*)pathForImageNamed:(NSString*)image {
@@ -24,7 +24,7 @@
IASKSettingsReader *_settingsReader;
}
@property (nonatomic, retain) NSDictionary *specifierDict;
-@property (nonatomic, retain) IASKSettingsReader *settingsReader;
+@property (nonatomic, assign) IASKSettingsReader *settingsReader;
- (id)initWithSpecifier:(NSDictionary*)specifier;
- (NSString*)title;
@@ -32,7 +32,8 @@ - (id)initWithSpecifier:(NSDictionary*)specifier {
if ([super init]) {
[self setSpecifierDict:specifier];
- if ([[self type] isEqualToString:kIASKPSMultiValueSpecifier]) {
+ if ([[self type] isEqualToString:kIASKPSMultiValueSpecifier] ||
+ [[self type] isEqualToString:kIASKPSTitleValueSpecifier]) {
[self _reinterpretValues:[self specifierDict]];
}
}
@@ -42,7 +43,6 @@ - (id)initWithSpecifier:(NSDictionary*)specifier {
- (void)dealloc {
[_specifierDict release];
[_multipleValuesDict release];
- [_settingsReader release];
_settingsReader = nil;
[super dealloc];
@@ -54,8 +54,13 @@ - (void)_reinterpretValues:(NSDictionary*)specifierDict {
NSMutableDictionary *multipleValuesDict = [[[NSMutableDictionary alloc] init] autorelease];
- [multipleValuesDict setObject:values forKey:kIASKValues];
- [multipleValuesDict setObject:titles forKey:kIASKTitles];
+ if (values) {
+ [multipleValuesDict setObject:values forKey:kIASKValues];
+ }
+
+ if (titles) {
+ [multipleValuesDict setObject:titles forKey:kIASKTitles];
+ }
[self setMultipleValuesDict:multipleValuesDict];
}
@@ -73,12 +78,17 @@ - (NSString*)type {
}
- (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) {
return nil;
}
@try {
- return [self.settingsReader titleForStringId:[[_multipleValuesDict objectForKey:kIASKTitles] objectAtIndex:keyIndex]];
+ return [self.settingsReader titleForStringId:[titles objectAtIndex:keyIndex]];
}
@catch (NSException * e) {}
return nil;
@@ -183,13 +193,13 @@ - (UITextAutocapitalizationType)autocapitalizationType {
}
- (UITextAutocorrectionType)autoCorrectionType {
- if ([[_specifierDict objectForKey:kIASKAutoCorrectionType] isEqualToString:kIASKAutoCapNone]) {
+ if ([[_specifierDict objectForKey:kIASKAutoCorrectionType] isEqualToString:kIASKAutoCorrDefault]) {
return UITextAutocorrectionTypeDefault;
}
- else if ([[_specifierDict objectForKey:kIASKAutoCorrectionType] isEqualToString:kIASKAutoCapSentences]) {
+ else if ([[_specifierDict objectForKey:kIASKAutoCorrectionType] isEqualToString:kIASKAutoCorrNo]) {
return UITextAutocorrectionTypeNo;
}
- else if ([[_specifierDict objectForKey:kIASKAutoCorrectionType] isEqualToString:kIASKAutoCapWords]) {
+ else if ([[_specifierDict objectForKey:kIASKAutoCorrectionType] isEqualToString:kIASKAutoCorrYes]) {
return UITextAutocorrectionTypeYes;
}
return UITextAutocorrectionTypeDefault;
@@ -2,7 +2,7 @@
// IASKPSSliderSpecifierViewCell.m
// http://www.inappsettingskit.com
//
-// Copyright (c) 2009:
+// Copyright (c) 2009-2010:
// Luc Vandal, Edovia Inc., http://www.edovia.com
// Ortwin Gentz, FutureTap GmbH, http://www.futuretap.com
// All rights reserved.
@@ -16,32 +16,51 @@
#import "IASKPSSliderSpecifierViewCell.h"
#import "IASKSlider.h"
+#import "IASKSettingsReader.h"
@implementation IASKPSSliderSpecifierViewCell
@synthesize slider=_slider,
minImage=_minImage,
maxImage=_maxImage;
-- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
- if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
- // Initialization code
- }
- return self;
-}
-
-
-- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
-
- [super setSelected:selected animated:animated];
-
- // Configure the view for the selected state
-}
+- (void)layoutSubviews {
+ CGRect sliderFrame = _slider.frame;
+ sliderFrame.origin.x = kIASKSliderNoImagesX;
+ sliderFrame.size.width = kIASKSliderNoImagesWidth;
+ _minImage.hidden = YES;
+ _maxImage.hidden = YES;
+ // 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 {
[super dealloc];
}
-
+- (void)prepareForReuse {
+ _minImage.image = nil;
+ _maxImage.image = nil;
+}
@end
@@ -2,7 +2,7 @@
// IASKPSTextFieldSpecifierViewCell.m
// http://www.inappsettingskit.com
//
-// Copyright (c) 2009:
+// Copyright (c) 2009-2010:
// Luc Vandal, Edovia Inc., http://www.edovia.com
// Ortwin Gentz, FutureTap GmbH, http://www.futuretap.com
// All rights reserved.
@@ -16,19 +16,24 @@
#import "IASKPSTextFieldSpecifierViewCell.h"
#import "IASKTextField.h"
+#import "IASKSettingsReader.h"
@implementation IASKPSTextFieldSpecifierViewCell
@synthesize label=_label,
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 {
@@ -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
Oops, something went wrong.

0 comments on commit 083f721

Please sign in to comment.