Subversion Repositories Projects

Compare Revisions

Ignore whitespace Rev 804 → Rev 805

/iKopter/trunk/Classes/InAppSettings/Cells/InAppSettingsPSChildPaneSpecifierCell.h
0,0 → 1,14
//
// PSChildPaneSpecifierCell.h
// InAppSettingsTestApp
//
// Created by David Keegan on 11/21/09.
// Copyright 2009 InScopeApps{+}. All rights reserved.
//
 
#import <UIKit/UIKit.h>
#import "InAppSettingsTableCell.h"
 
@interface InAppSettingsPSChildPaneSpecifierCell : InAppSettingsTableCell {}
 
@end
/iKopter/trunk/Classes/InAppSettings/Cells/InAppSettingsPSChildPaneSpecifierCell.m
0,0 → 1,27
//
// PSToggleSwitchSpecifier.m
// InAppSettingsTestApp
//
// Created by David Keegan on 11/21/09.
// Copyright 2009 InScopeApps{+}. All rights reserved.
//
 
#import "InAppSettingsPSChildPaneSpecifierCell.h"
#import "InAppSettingsConstants.h"
 
@implementation InAppSettingsPSChildPaneSpecifierCell
 
- (void)setUIValues{
[super setUIValues];
[self setTitle];
}
 
- (void)setupCell{
[super setupCell];
[self setDisclosure:YES];
self.canSelectCell = YES;
}
 
@end
/iKopter/trunk/Classes/InAppSettings/Cells/InAppSettingsPSMultiValueSpecifierCell.h
0,0 → 1,16
//
// PSToggleSwitchSpecifier.h
// InAppSettingsTestApp
//
// Created by David Keegan on 11/21/09.
// Copyright 2009 InScopeApps{+}. All rights reserved.
//
 
#import <UIKit/UIKit.h>
#import "InAppSettingsTableCell.h"
 
@interface InAppSettingsPSMultiValueSpecifierCell : InAppSettingsTableCell {}
 
- (NSString *)getValueTitle;
 
@end
/iKopter/trunk/Classes/InAppSettings/Cells/InAppSettingsPSMultiValueSpecifierCell.m
0,0 → 1,41
//
// PSToggleSwitchSpecifier.m
// InAppSettingsTestApp
//
// Created by David Keegan on 11/21/09.
// Copyright 2009 InScopeApps{+}. All rights reserved.
//
 
#import "InAppSettingsPSMultiValueSpecifierCell.h"
#import "InAppSettingsConstants.h"
 
@implementation InAppSettingsPSMultiValueSpecifierCell
 
- (NSString *)getValueTitle{
NSArray *titles = [self.setting valueForKey:InAppSettingsSpecifierTitles];
NSArray *values = [self.setting valueForKey:InAppSettingsSpecifierValues];
id obj = [self.setting getValue];
NSLog(@"%@",obj);
NSInteger valueIndex = [values indexOfObject:[self.setting getValue]];
if((valueIndex >= 0) && (valueIndex < (NSInteger)[titles count])){
return InAppSettingsLocalize([titles objectAtIndex:valueIndex], self.setting.stringsTable);
}
return nil;
}
 
- (void)setUIValues{
[super setUIValues];
[self setTitle];
[self setDetail:[self getValueTitle]];
}
 
- (void)setupCell{
[super setupCell];
[self setDisclosure:YES];
self.canSelectCell = YES;
}
 
@end
/iKopter/trunk/Classes/InAppSettings/Cells/InAppSettingsPSSliderSpecifierCell.h
0,0 → 1,20
//
// PSToggleSwitchSpecifier.h
// InAppSettingsTestApp
//
// Created by David Keegan on 11/21/09.
// Copyright 2009 InScopeApps{+}. All rights reserved.
//
 
#import <UIKit/UIKit.h>
#import "InAppSettingsTableCell.h"
 
@interface InAppSettingsPSSliderSpecifierCell : InAppSettingsTableCell {
UISlider *valueSlider;
}
 
@property (nonatomic, retain) UISlider *valueSlider;
 
- (void)slideAction;
 
@end
/iKopter/trunk/Classes/InAppSettings/Cells/InAppSettingsPSSliderSpecifierCell.m
0,0 → 1,55
//
// PSToggleSwitchSpecifier.m
// InAppSettingsTestApp
//
// Created by David Keegan on 11/21/09.
// Copyright 2009 InScopeApps{+}. All rights reserved.
//
 
#import "InAppSettingsPSSliderSpecifierCell.h"
#import "InAppSettingsConstants.h"
 
@implementation InAppSettingsPSSliderSpecifierCell
 
@synthesize valueSlider;
 
- (void)slideAction{
[self.setting setValue:[NSNumber numberWithFloat:[self.valueSlider value]]];
}
 
- (void)setUIValues{
[super setUIValues];
 
//get the abolute path to the images
NSString *minImagePath = [InAppSettingsBundlePath stringByAppendingPathComponent:[self.setting valueForKey:@"MinimumValueImage"]];
NSString *maxImagePath = [InAppSettingsBundlePath stringByAppendingPathComponent:[self.setting valueForKey:@"MaximumValueImage"]];
//setup the slider
self.valueSlider.minimumValue = [[self.setting valueForKey:InAppSettingsSpecifierMinimumValue] floatValue];
self.valueSlider.maximumValue = [[self.setting valueForKey:InAppSettingsSpecifierMaximumValue] floatValue];
self.valueSlider.minimumValueImage = [UIImage imageWithContentsOfFile:minImagePath];
self.valueSlider.maximumValueImage = [UIImage imageWithContentsOfFile:maxImagePath];
CGRect valueSliderFrame = self.valueSlider.frame;
valueSliderFrame.origin.y = (CGFloat)round((self.contentView.frame.size.height*0.5f)-(valueSliderFrame.size.height*0.5f));
valueSliderFrame.origin.x = InAppSettingsCellPadding;
valueSliderFrame.size.width = InAppSettingsScreenWidth-(InAppSettingsTotalTablePadding+InAppSettingsTotalCellPadding);
self.valueSlider.frame = valueSliderFrame;
self.valueSlider.value = [[self.setting getValue] floatValue];
}
 
- (void)setupCell{
[super setupCell];
//create the slider
self.valueSlider = [[UISlider alloc] initWithFrame:CGRectZero];
[self.valueSlider addTarget:self action:@selector(slideAction) forControlEvents:UIControlEventTouchUpInside];
[self.contentView addSubview:self.valueSlider];
}
 
- (void)dealloc{
[valueSlider release];
[super dealloc];
}
 
@end
/iKopter/trunk/Classes/InAppSettings/Cells/InAppSettingsPSTextFieldSpecifierCell.h
0,0 → 1,24
//
// PSToggleSwitchSpecifier.h
// InAppSettingsTestApp
//
// Created by David Keegan on 11/21/09.
// Copyright 2009 InScopeApps{+}. All rights reserved.
//
 
#import <UIKit/UIKit.h>
#import "InAppSettingsTableCell.h"
 
@interface InAppSettingsPSTextFieldSpecifierCell : InAppSettingsTableCell {
UITextField *textField;
}
 
@property (nonatomic, retain) UITextField *textField;
 
- (BOOL)isSecure;
- (UIKeyboardType)getKeyboardType;
- (UITextAutocapitalizationType)getAutocapitalizationType;
- (UITextAutocorrectionType)getAutocorrectionType;
- (void)textChangeAction;
 
@end
/iKopter/trunk/Classes/InAppSettings/Cells/InAppSettingsPSTextFieldSpecifierCell.m
0,0 → 1,137
//
// PSToggleSwitchSpecifier.m
// InAppSettingsTestApp
//
// Created by David Keegan on 11/21/09.
// Copyright 2009 InScopeApps{+}. All rights reserved.
//
 
#import "InAppSettingsPSTextFieldSpecifierCell.h"
#import "InAppSettingsConstants.h"
 
@implementation InAppSettingsPSTextFieldSpecifierCell
 
@synthesize textField;
 
#pragma mark helper methods
 
- (BOOL)isSecure{
NSNumber *isSecure = [self.setting valueForKey:@"IsSecure"];
if(!isSecure){
return NO;
}
return [isSecure boolValue];
}
 
- (UIKeyboardType)getKeyboardType{
NSString *keyboardType = [self.setting valueForKey:@"KeyboardType"];
if([keyboardType isEqualToString:@"NumbersAndPunctuation"]){
return UIKeyboardTypeNumbersAndPunctuation;
}
else if([keyboardType isEqualToString:@"NumberPad"]){
return UIKeyboardTypeNumberPad;
}
else if([keyboardType isEqualToString:@"URL"]){
return UIKeyboardTypeURL;
}
else if([keyboardType isEqualToString:@"EmailAddress"]){
return UIKeyboardTypeEmailAddress;
}
return UIKeyboardTypeAlphabet;
}
 
- (UITextAutocapitalizationType)getAutocapitalizationType{
//this works, but the real settings don't seem to respect these values eventhough they are in the docs
NSString *autoCapitalizationType = [self.setting valueForKey:@"AutoCapitalizationType"];
if([autoCapitalizationType isEqualToString:@"Words"]){
return UITextAutocapitalizationTypeWords;
}
else if([autoCapitalizationType isEqualToString:@"Sentences"]){
return UITextAutocapitalizationTypeSentences;
}
else if([autoCapitalizationType isEqualToString:@"AllCharacters"]){
return UITextAutocapitalizationTypeAllCharacters;
}
return UITextAutocapitalizationTypeNone;
}
 
- (UITextAutocorrectionType)getAutocorrectionType{
NSString *autocorrectionType = [self.setting valueForKey:@"AutocorrectionType"];
if([autocorrectionType isEqualToString:@"Yes"]){
return UITextAutocorrectionTypeYes;
}
else if([autocorrectionType isEqualToString:@"No"]){
return UITextAutocorrectionTypeNo;
}
return UITextAutocorrectionTypeDefault;
}
 
- (void)textChangeAction{
NSNumber* isNumtype = [self.setting valueForKey:InAppSettingsSpecifierInAppNumtype];
if ( [isNumtype boolValue] ){
NSNumber* n = [NSNumber numberWithInt:[self.textField.text intValue]];
[self.setting setValue:n];
}
else
[self.setting setValue:self.textField.text];
}
 
#pragma mark cell controlls
 
- (void)setValueDelegate:(id)delegate{
self.textField.delegate = delegate;
[super setValueDelegate:delegate];
}
 
- (void)setUIValues{
[super setUIValues];
[self setTitle];
CGRect textFieldFrame = self.textField.frame;
CGSize titleSize = [titleLabel.text sizeWithFont:titleLabel.font];
textFieldFrame.origin.x = (CGFloat)round(titleSize.width+InAppSettingsTotalTablePadding);
if(textFieldFrame.origin.x < InAppSettingsCellTextFieldMinX){
textFieldFrame.origin.x = InAppSettingsCellTextFieldMinX;
}
textFieldFrame.origin.y = (CGFloat)round((self.contentView.frame.size.height*0.5f)-(titleSize.height*0.5f))-InAppSettingsOffsetY;
textFieldFrame.size.width = (CGFloat)round((InAppSettingsScreenWidth-(InAppSettingsTotalTablePadding+InAppSettingsCellPadding))-textFieldFrame.origin.x);
textFieldFrame.size.height = titleSize.height;
self.textField.frame = textFieldFrame;
self.textField.text = [[self.setting getValue] description];
//keyboard traits
self.textField.secureTextEntry = [self isSecure];
self.textField.keyboardType = [self getKeyboardType];
self.textField.autocapitalizationType = [self getAutocapitalizationType];
self.textField.autocorrectionType = [self getAutocorrectionType];
//these are set here so they are set per cell
//self.textField.delegate = self;
self.valueInput = self.textField;
}
 
- (void)setupCell{
[super setupCell];
//create text field
self.textField =[[UITextField alloc] initWithFrame:CGRectZero];
self.textField.textColor = InAppSettingsBlue;
self.textField.adjustsFontSizeToFitWidth = YES;
//THIS IS NOT THE BEHAVIOR OF THE SETTINGS APP
//but we need a way to dismiss the keyboard
self.textField.returnKeyType = UIReturnKeyDone;
[self.textField addTarget:self action:@selector(textChangeAction) forControlEvents:UIControlEventEditingChanged];
[self.contentView addSubview:self.textField];
}
 
- (void)dealloc{
[textField release];
[super dealloc];
}
 
@end
/iKopter/trunk/Classes/InAppSettings/Cells/InAppSettingsPSTitleValueSpecifierCell.h
0,0 → 1,16
//
// PSTitleValueSpecifierCell.h
// InAppSettingsTestApp
//
// Created by David Keegan on 11/21/09.
// Copyright 2009 InScopeApps{+}. All rights reserved.
//
 
#import <UIKit/UIKit.h>
#import "InAppSettingsTableCell.h"
 
@interface InAppSettingsPSTitleValueSpecifierCell : InAppSettingsTableCell {}
 
- (NSString *)getValueTitle;
 
@end
/iKopter/trunk/Classes/InAppSettings/Cells/InAppSettingsPSTitleValueSpecifierCell.m
0,0 → 1,45
//
// PSTitleValueSpecifierCell.m
// InAppSettingsTestApp
//
// Created by David Keegan on 11/21/09.
// Copyright 2009 InScopeApps{+}. All rights reserved.
//
 
#import "InAppSettingsPSTitleValueSpecifierCell.h"
#import "InAppSettingsConstants.h"
 
@implementation InAppSettingsPSTitleValueSpecifierCell
 
- (NSString *)getValueTitle{
NSArray *titles = [self.setting valueForKey:InAppSettingsSpecifierTitles];
NSArray *values = [self.setting valueForKey:InAppSettingsSpecifierValues];
if(titles || values){
if(([titles count] == 0) || ([values count] == 0) || ([titles count] != [values count])){
return nil;
}
NSInteger valueIndex = [values indexOfObject:[self.setting getValue]];
if((valueIndex >= 0) && (valueIndex < (NSInteger)[titles count])){
return [titles objectAtIndex:valueIndex];
}
return nil;
}
return [self.setting getValue];
}
 
- (void)setUIValues{
[super setUIValues];
[self setTitle];
if([self.setting valueForKey:InAppSettingsSpecifierInAppURL]){
[self setDisclosure:YES];
self.canSelectCell = YES;
}
[self setDetail:[self getValueTitle]];
}
 
@end
/iKopter/trunk/Classes/InAppSettings/Cells/InAppSettingsPSToggleSwitchSpecifierCell.h
0,0 → 1,22
//
// PSToggleSwitchSpecifier.h
// InAppSettingsTestApp
//
// Created by David Keegan on 11/21/09.
// Copyright 2009 InScopeApps{+}. All rights reserved.
//
 
#import <UIKit/UIKit.h>
#import "InAppSettingsTableCell.h"
 
@interface InAppSettingsPSToggleSwitchSpecifierCell : InAppSettingsTableCell {
UISwitch *valueSwitch;
}
 
@property (nonatomic, retain) UISwitch *valueSwitch;
 
- (BOOL)getBool;
- (void)setBool:(BOOL)newValue;
- (void)switchAction;
 
@end
/iKopter/trunk/Classes/InAppSettings/Cells/InAppSettingsPSToggleSwitchSpecifierCell.m
0,0 → 1,84
//
// PSToggleSwitchSpecifier.m
// InAppSettingsTestApp
//
// Created by David Keegan on 11/21/09.
// Copyright 2009 InScopeApps{+}. All rights reserved.
//
 
#import "InAppSettingsPSToggleSwitchSpecifierCell.h"
#import "InAppSettingsConstants.h"
 
@implementation InAppSettingsPSToggleSwitchSpecifierCell
 
@synthesize valueSwitch;
 
// The value associated with the preference when the toggle switch
// is in the ON position. The value type for this key can be any
// scalar type, including Boolean, String, Number, Date, or Data.
// If this key is not present, the default value type is a Boolean.
 
- (BOOL)getBool{
id value = [self.setting getValue];
id trueValue = [self.setting valueForKey:@"TrueValue"];
id falseValue = [self.setting valueForKey:@"FalseValue"];
if([value isEqual:trueValue]){
return YES;
}
if([value isEqual:falseValue]){
return NO;
}
//if there is no true or false values the value has to be a bool
return [value boolValue];
}
 
- (void)setBool:(BOOL)newValue{
id value = [NSNumber numberWithBool:newValue];
if(newValue){
id trueValue = [self.setting valueForKey:@"TrueValue"];
if(trueValue){
value = trueValue;
}
}
else{
id falseValue = [self.setting valueForKey:@"FalseValue"];
if(falseValue){
value = falseValue;
}
}
[self.setting setValue:value];
}
 
- (void)switchAction{
[self setBool:[self.valueSwitch isOn]];
}
 
- (void)setUIValues{
[super setUIValues];
[self setTitle];
self.valueSwitch.on = [self getBool];
}
 
- (void)setupCell{
[super setupCell];
//create the switch
self.valueSwitch = [[UISwitch alloc] initWithFrame:CGRectZero];
CGRect valueSwitchFrame = self.valueSwitch.frame;
valueSwitchFrame.origin.y = (CGFloat)round((self.contentView.frame.size.height*0.5f)-(valueSwitchFrame.size.height*0.5f))-InAppSettingsOffsetY;
valueSwitchFrame.origin.x = (CGFloat)round((InAppSettingsScreenWidth-(InAppSettingsTotalTablePadding+InAppSettingsCellPadding))-valueSwitchFrame.size.width);
self.valueSwitch.frame = valueSwitchFrame;
[self.valueSwitch addTarget:self action:@selector(switchAction) forControlEvents:UIControlEventValueChanged];
[self.contentView addSubview:self.valueSwitch];
}
 
- (void)dealloc{
[valueSwitch release];
[super dealloc];
}
 
@end
/iKopter/trunk/Classes/InAppSettings/Cells/InAppSettingsPotiValueSpecifierCell.h
0,0 → 1,16
//
// InAppSettingsPotiValueSpecifierCell.h
// InAppSettingsTestApp
//
// Created by Frank Blumenberg on 04.05.10.
// Copyright 2010 __MyCompanyName__. All rights reserved.
//
 
#import <Foundation/Foundation.h>
#import "InAppSettings.h"
 
@interface InAppSettingsPotiValueSpecifierCell : InAppSettingsTableCell {}
 
- (NSString *)getValueTitle;
 
@end
/iKopter/trunk/Classes/InAppSettings/Cells/InAppSettingsPotiValueSpecifierCell.m
0,0 → 1,40
//
// InAppSettingsPotiValueSpecifierCell.m
// InAppSettingsTestApp
//
// Created by Frank Blumenberg on 04.05.10.
// Copyright 2010 __MyCompanyName__. All rights reserved.
//
 
#import "InAppSettingsPotiValueSpecifierCell.h"
 
 
@implementation InAppSettingsPotiValueSpecifierCell
 
- (NSString *)getValueTitle{
NSNumber* value = [self.setting getValue];
int intValue=[value intValue];
if( intValue <= 245 )
return [NSString stringWithFormat:@"%@",value];
return [NSString stringWithFormat:NSLocalizedString(@"Poti%d",@"Potiname"),256-intValue];
}
 
- (void)setUIValues{
[super setUIValues];
[self setTitle];
[self setDetail:[self getValueTitle]];
}
 
- (void)setupCell{
[super setupCell];
[self setDisclosure:YES];
self.canSelectCell = YES;
}
 
@end
/iKopter/trunk/Classes/InAppSettings/Cells/InAppSettingsTableCell.h
0,0 → 1,35
//
// InAppSettingsTableCell.h
// InAppSettingsTestApp
//
// Created by David Keegan on 11/21/09.
// Copyright 2009 InScopeApps{+}. All rights reserved.
//
 
#import <UIKit/UIKit.h>
#import "InAppSettingsSpecifier.h"
 
@interface InAppSettingsTableCell : UITableViewCell {
InAppSettingsSpecifier *setting;
UILabel *titleLabel, *valueLabel;
UIControl *valueInput;
BOOL canSelectCell;
}
 
@property (nonatomic, retain) InAppSettingsSpecifier *setting;
@property (nonatomic, retain) UILabel *titleLabel, *valueLabel;
@property (nonatomic, assign) UIControl *valueInput;
@property (nonatomic, assign) BOOL canSelectCell;
 
- (void)setTitle;
- (void)setDetail;
- (void)setDetail:(NSString *)detail;
- (void)setDisclosure:(BOOL)disclosure;
 
- (void)setValueDelegate:(id)delegate;
 
- (void)setupCell;
- (void)setUIValues;
- (id)initWithReuseIdentifier:(NSString *)reuseIdentifier;
 
@end
/iKopter/trunk/Classes/InAppSettings/Cells/InAppSettingsTableCell.m
0,0 → 1,155
//
// InAppSettingsTableCell.m
// InAppSettingsTestApp
//
// Created by David Keegan on 11/21/09.
// Copyright 2009 InScopeApps{+}. All rights reserved.
//
 
#import "InAppSettingsTableCell.h"
#import "InAppSettingsConstants.h"
 
@implementation InAppSettingsTableCell
 
@synthesize setting;
@synthesize titleLabel, valueLabel;
@synthesize valueInput;
@synthesize canSelectCell;
 
#pragma mark Cell lables
 
- (void)setTitle{
self.titleLabel.text = [self.setting localizedTitle];
CGSize titleSize = [self.titleLabel.text sizeWithFont:self.titleLabel.font];
CGFloat maxTitleWidth = InAppSettingsCellTitleMaxWidth;
if([self.setting isType:InAppSettingsPSToggleSwitchSpecifier]){
maxTitleWidth = InAppSettingsCellTitleMaxWidth-(InAppSettingsCellToggleSwitchWidth+InAppSettingsCellPadding);
}else if(self.accessoryType == UITableViewCellAccessoryDisclosureIndicator){
maxTitleWidth = InAppSettingsCellTitleMaxWidth-(InAppSettingsCellDisclosureIndicatorWidth+InAppSettingsCellPadding);
}
if(titleSize.width > maxTitleWidth){
titleSize.width = maxTitleWidth;
}
 
CGRect titleFrame = self.titleLabel.frame;
titleFrame.size = titleSize;
titleFrame.origin.x = InAppSettingsCellPadding;
titleFrame.origin.y = (CGFloat)round((self.contentView.frame.size.height*0.5f)-(titleSize.height*0.5f))-InAppSettingsOffsetY;
self.titleLabel.frame = titleFrame;
}
 
- (void)setDetail{
[self setDetail:[self.setting getValue]];
}
 
- (void)setDetail:(NSString *)detail{
//the detail is not localized
self.valueLabel.text = detail;
 
CGSize valueSize = [self.valueLabel.text sizeWithFont:self.valueLabel.font];
CGRect valueFrame = self.valueLabel.frame;
CGFloat titleRightSide = self.titleLabel.frame.size.width+InAppSettingsTablePadding;
if([self.setting isType:InAppSettingsPSMultiValueSpecifier] && [[self.setting localizedTitle] length] == 0){
valueFrame.origin.x = InAppSettingsCellPadding;
}else{
valueFrame.origin.x = (InAppSettingsScreenWidth-(InAppSettingsTotalTablePadding+InAppSettingsCellPadding))-valueSize.width;
if(self.accessoryType == UITableViewCellAccessoryDisclosureIndicator){
valueFrame.origin.x -= InAppSettingsCellDisclosureIndicatorWidth+InAppSettingsCellPadding;
}
if(titleRightSide >= valueFrame.origin.x){
valueFrame.origin.x = titleRightSide;
}
}
valueFrame.origin.y = (CGFloat)round((self.contentView.frame.size.height*0.5f)-(valueSize.height*0.5f))-InAppSettingsOffsetY;
valueFrame.size.width = InAppSettingsScreenWidth-(valueFrame.origin.x+InAppSettingsTotalTablePadding+InAppSettingsCellPadding);
if(self.accessoryType == UITableViewCellAccessoryDisclosureIndicator){
valueFrame.size.width -= InAppSettingsCellDisclosureIndicatorWidth+InAppSettingsCellPadding;
}
//if the width is less then 0 just hide the label
if(valueFrame.size.width <= 0){
self.valueLabel.hidden = YES;
}else{
self.valueLabel.hidden = NO;
}
valueFrame.size.height = valueSize.height;
self.valueLabel.frame = valueFrame;
}
 
- (void)setDisclosure:(BOOL)disclosure{
if(disclosure){
self.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
else{
self.accessoryType = UITableViewCellAccessoryNone;
}
}
 
- (void)setCanSelectCell:(BOOL)value{
if(value){
self.selectionStyle = UITableViewCellSelectionStyleBlue;
}else{
self.selectionStyle = UITableViewCellSelectionStyleNone;
}
canSelectCell = value;
}
 
#pragma mark -
 
- (id)initWithReuseIdentifier:(NSString *)reuseIdentifier{
//the docs say UITableViewCellStyleValue1 is used for settings,
//but it doesn't look 100% the same so we will just draw our own UILabels
#if InAppSettingsUseNewCells
self = [super initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseIdentifier];
#else
self = [super initWithFrame:CGRectZero reuseIdentifier:reuseIdentifier];
#endif
if(self != nil){
self.canSelectCell = NO;
}
return self;
}
 
#pragma mark implement in cell
 
- (void)setUIValues{
//implement this per cell type
}
 
- (void)setValueDelegate:(id)delegate{
//implement in cell
}
 
- (void)setupCell{
//setup title label
self.titleLabel = [[UILabel alloc] initWithFrame:CGRectZero];
self.titleLabel.font = InAppSettingsBoldFont;
self.titleLabel.highlightedTextColor = [UIColor whiteColor];
self.titleLabel.backgroundColor = [UIColor clearColor];
// self.titleLabel.backgroundColor = [UIColor greenColor];
[self.contentView addSubview:self.titleLabel];
//setup value label
self.valueLabel = [[UILabel alloc] initWithFrame:CGRectZero];
self.valueLabel.font = InAppSettingsNormalFont;
self.valueLabel.textColor = InAppSettingsBlue;
self.valueLabel.highlightedTextColor = [UIColor whiteColor];
self.valueLabel.backgroundColor = [UIColor clearColor];
// self.valueLabel.backgroundColor = [UIColor redColor];
[self.contentView addSubview:self.valueLabel];
}
 
- (void)dealloc{
[setting release];
[titleLabel release];
[valueLabel release];
self.valueInput = nil;
[super dealloc];
}
 
@end
/iKopter/trunk/Classes/InAppSettings/InAppSettings.h
0,0 → 1,83
//
// InAppSettingsViewController.h
// InAppSettings
//
// Created by David Keegan on 11/21/09.
// Copyright 2009 InScopeApps{+}. All rights reserved.
//
 
#import <UIKit/UIKit.h>
#import "InAppSettingsTableCell.h"
#import "InAppSettingsReader.h"
#import "InAppSettingsSpecifier.h"
 
@protocol InAppSettingsDelegate;
 
@protocol InAppSettingsDatasource < NSObject >
- (id) objectForKey:(id)aKey;
- (void) setObject:(id)anObject forKey:(id)aKey;
@end
 
@interface InAppSettings : NSObject {}
 
+ (void) registerDefaults;
 
@end
 
@interface InAppSettingsModalViewController : UIViewController {}
 
@end
 
@interface InAppSettingsViewController : UIViewController <UITableViewDelegate, UITableViewDataSource, UITextFieldDelegate, InAppSettingsSpecifierDelegate> {
NSString * file;
UITableView * settingsTableView;
UIControl * firstResponder;
InAppSettingsReader * settingsReader;
id<InAppSettingsDelegate> delegate;
id<InAppSettingsDatasource> dataSource;
}
 
@property (nonatomic, copy) NSString * file;
@property (nonatomic, retain) UITableView * settingsTableView;
@property (nonatomic, assign) UIControl * firstResponder;
@property (nonatomic, retain) InAppSettingsReader * settingsReader;
@property (assign) id<InAppSettingsDelegate> delegate;
@property (assign) id<InAppSettingsDatasource> dataSource;
 
- (id) initWithFile:(NSString *)inputFile;
 
// modal view
- (void) dismissModalView;
- (void) addDoneButton;
 
// keyboard notification
- (void) registerForKeyboardNotifications;
- (void) keyboardWillShow:(NSNotification *)notification;
- (void) keyboardWillHide:(NSNotification *)notification;
 
@end
 
@interface InAppSettingsLightningBolt : UIView {
BOOL flip;
}
 
@property (nonatomic, assign) BOOL flip;
 
@end
 
@protocol InAppSettingsDelegate < NSObject >
 
@optional
- (void) InAppSettingsValue:(id)value forKey:(NSString *)key;
 
@end
 
@protocol InAppSettingsChildPane < NSObject >
 
@property (nonatomic, retain) InAppSettingsSpecifier * setting;
 
- (id) initWithSetting:(InAppSettingsSpecifier *)inputSetting;
- (id) getValue;
- (void) setValue:(id)newValue;
 
@end
/iKopter/trunk/Classes/InAppSettings/InAppSettings.m
0,0 → 1,375
//
// InAppSettingsViewController.m
// InAppSettings
//
// Created by David Keegan on 11/21/09.
// Copyright 2009 InScopeApps{+}. All rights reserved.
//
 
#import "InAppSettings.h"
#import "InAppSettingsConstants.h"
#import "InAppSettingsPSMultiValueSpecifierTable.h"
 
@implementation InAppSettings
 
+ (void) registerDefaults {
[[[InAppSettingsReaderRegisterDefaults alloc] init] release];
}
 
@end
 
@implementation InAppSettingsModalViewController
 
- (id) init {
InAppSettingsViewController * settings = [[InAppSettingsViewController alloc] init];
 
self = [[UINavigationController alloc] initWithRootViewController:settings];
[settings addDoneButton];
[settings release];
return self;
}
 
@end
 
@implementation InAppSettingsViewController
 
@synthesize file;
@synthesize settingsTableView;
@synthesize firstResponder;
@synthesize settingsReader;
@synthesize delegate;
@synthesize dataSource;
 
 
#pragma mark modal view
 
- (void) dismissModalView {
[self.navigationController dismissModalViewControllerAnimated:YES];
}
 
- (void) addDoneButton {
UIBarButtonItem * doneButton = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemDone
target:self
action:@selector(dismissModalView)];
 
self.navigationItem.rightBarButtonItem = doneButton;
[doneButton release];
}
 
#pragma mark setup view
 
- (id) initWithFile:(NSString *)inputFile {
self = [super init];
if (self != nil) {
self.file = inputFile;
}
return self;
}
 
- (void) viewDidLoad {
// setup the table
self.settingsTableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStyleGrouped];
self.settingsTableView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
self.settingsTableView.delegate = self;
self.settingsTableView.dataSource = self;
[self.view addSubview:self.settingsTableView];
 
// if the title is nil set it to Settings
if (!self.title) {
self.title = NSLocalizedString(@"Settings", nil);
}
 
// load settigns plist
if (!self.file) {
self.file = InAppSettingsRootFile;
}
 
InAppSettingsReader* tmpSettingsReader = [[InAppSettingsReader alloc] initWithFile:self.file dataSource:dataSource];
self.settingsReader = tmpSettingsReader;
[tmpSettingsReader release];
 
// setup keyboard notification
self.firstResponder = nil;
[self registerForKeyboardNotifications];
}
 
- (void) viewWillAppear:(BOOL)animated {
self.firstResponder = nil;
 
self.settingsTableView.contentInset = UIEdgeInsetsZero;
self.settingsTableView.scrollIndicatorInsets = UIEdgeInsetsZero;
 
[self.settingsTableView reloadData];
[super viewWillAppear:animated];
}
 
- (void) viewWillDisappear:(BOOL)animated {
self.firstResponder = nil;
[super viewWillDisappear:animated];
}
 
- (void) dealloc {
self.firstResponder = nil;
self.delegate = nil;
 
[file release];
[settingsTableView release];
[settingsReader release];
[super dealloc];
}
 
#pragma mark text field cell delegate
 
- (void) textFieldDidBeginEditing:(UITextField *)cellTextField {
self.firstResponder = cellTextField;
 
// TODO: find a better way to get the cell from the text view
NSIndexPath * indexPath = [self.settingsTableView indexPathForCell:(UITableViewCell *)[[cellTextField superview] superview]];
[self.settingsTableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionMiddle animated:YES];
}
 
- (BOOL) textFieldShouldReturn:(UITextField *)cellTextField {
self.firstResponder = nil;
[cellTextField resignFirstResponder];
return YES;
}
 
#pragma mark keyboard notification
 
- (void) registerForKeyboardNotifications {
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillShow:)
name:UIKeyboardWillShowNotification object:nil];
 
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillHide:)
name:UIKeyboardWillHideNotification object:nil];
}
 
- (void) keyboardWillShow:(NSNotification *)notification {
if (self.firstResponder == nil) {
// get the keybaord rect
CGRect keyboardRect = [[[notification userInfo] objectForKey:UIKeyboardBoundsUserInfoKey] CGRectValue];
 
// determin the bottom inset for the table view
UIEdgeInsets settingsTableInset = self.settingsTableView.contentInset;
CGPoint tableViewScreenSpace = [self.settingsTableView.superview convertPoint:self.settingsTableView.frame.origin toView:nil];
CGFloat tableViewBottomOffset = InAppSettingsScreenHeight - (tableViewScreenSpace.y + self.settingsTableView.frame.size.height);
settingsTableInset.bottom = keyboardRect.size.height - tableViewBottomOffset;
 
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:InAppSettingsKeyboardAnimation];
[UIView setAnimationBeginsFromCurrentState:YES];
self.settingsTableView.contentInset = settingsTableInset;
self.settingsTableView.scrollIndicatorInsets = settingsTableInset;
[UIView commitAnimations];
}
}
 
- (void) keyboardWillHide:(NSNotification *)notification {
if (self.firstResponder == nil) {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:InAppSettingsKeyboardAnimation];
[UIView setAnimationBeginsFromCurrentState:YES];
self.settingsTableView.contentInset = UIEdgeInsetsZero;
self.settingsTableView.scrollIndicatorInsets = UIEdgeInsetsZero;
[UIView commitAnimations];
}
}
 
#pragma mark specifier delegate
 
- (void) settingsSpecifierUpdated:(InAppSettingsSpecifier *)specifier {
if ([self.delegate respondsToSelector:@selector(InAppSettingsValue:forKey:)]) {
[self.delegate InAppSettingsValue:[specifier getValue] forKey:[specifier getKey]];
}
}
 
#pragma mark Table view methods
 
- (InAppSettingsSpecifier *) settingAtIndexPath:(NSIndexPath *)indexPath {
return [[self.settingsReader.settings objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
}
 
- (NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
return [self.settingsReader.headers count];
}
 
- (NSString *) tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
return [self.settingsReader.headers objectAtIndex:section];
}
 
- (NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [[self.settingsReader.settings objectAtIndex:section] count];
}
 
- (CGFloat) tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
if (InAppSettingsDisplayPowered && [self.file isEqualToString:InAppSettingsRootFile] && section == (NSInteger)[self.settingsReader.headers count] - 1) {
return InAppSettingsPowerFooterHeight;
}
return 0.0f;
}
 
- (UIView *) tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
if (InAppSettingsDisplayPowered && [self.file isEqualToString:InAppSettingsRootFile] && section == (NSInteger)[self.settingsReader.headers count] - 1) {
UIView * powerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, InAppSettingsScreenWidth, InAppSettingsPowerFooterHeight)];
 
// InAppSettings label
CGSize InAppSettingsSize = [InAppSettingsProjectName sizeWithFont:InAppSettingsFooterFont];
CGPoint InAppSettingsPos = CGPointMake((CGFloat)round((InAppSettingsScreenWidth * 0.5f) - (InAppSettingsSize.width * 0.5f)),
(CGFloat)round((InAppSettingsPowerFooterHeight * 0.5f) - (InAppSettingsSize.height * 0.5f)) - 1);
UILabel * InAppLabel = [[UILabel alloc] initWithFrame:CGRectMake(InAppSettingsPos.x, InAppSettingsPos.y, InAppSettingsSize.width, InAppSettingsSize.height)];
InAppLabel.text = InAppSettingsProjectName;
InAppLabel.font = InAppSettingsFooterFont;
InAppLabel.backgroundColor = [UIColor clearColor];
InAppLabel.textColor = InAppSettingsFooterBlue;
InAppLabel.shadowColor = [UIColor whiteColor];
InAppLabel.shadowOffset = CGSizeMake(0.0f, 1.0f);
[powerView addSubview:InAppLabel];
[InAppLabel release];
 
// lighting bolts
CGPoint leftLightningBoltPos = CGPointMake(InAppSettingsPos.x - InAppSettingsLightingBoltSize,
(CGFloat)round((InAppSettingsPowerFooterHeight * 0.5f) - (InAppSettingsLightingBoltSize * 0.5f)));
InAppSettingsLightningBolt * leftLightningBolt = [[InAppSettingsLightningBolt alloc]
initWithFrame:CGRectMake(leftLightningBoltPos.x, leftLightningBoltPos.y,
InAppSettingsLightingBoltSize, InAppSettingsLightingBoltSize)];
[powerView addSubview:leftLightningBolt];
[leftLightningBolt release];
 
CGPoint rightLightningBoltPos = CGPointMake((CGFloat)round(InAppSettingsPos.x + InAppSettingsSize.width), leftLightningBoltPos.y);
InAppSettingsLightningBolt * rightLightningBolt = [[InAppSettingsLightningBolt alloc]
initWithFrame:CGRectMake(rightLightningBoltPos.x, rightLightningBoltPos.y,
InAppSettingsLightingBoltSize, InAppSettingsLightingBoltSize)];
rightLightningBolt.flip = YES;
[powerView addSubview:rightLightningBolt];
[rightLightningBolt release];
 
return [powerView autorelease];
}
return nil;
}
 
- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
InAppSettingsSpecifier * setting = [self settingAtIndexPath:indexPath];
 
setting.delegate = self;
 
// get the NSClass for a specifier, if there is none use the base class InAppSettingsTableCell
NSString * cellType = [setting cellName];
Class nsclass = NSClassFromString(cellType);
if (!nsclass) {
cellType = @"InAppSettingsTableCell";
nsclass = NSClassFromString(cellType);
}
 
InAppSettingsTableCell * cell = ((InAppSettingsTableCell *)[tableView dequeueReusableCellWithIdentifier:cellType]);
if (cell == nil) {
cell = [[[nsclass alloc] initWithReuseIdentifier:cellType] autorelease];
// setup the cells controlls
[cell setupCell];
}
 
// set the values of the cell, this is separated from setupCell for reloading the table
cell.setting = setting;
[cell setValueDelegate:self];
[cell setUIValues];
 
return cell;
}
 
- (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
InAppSettingsSpecifier * setting = [self settingAtIndexPath:indexPath];
 
if ([setting isType:InAppSettingsPSMultiValueSpecifier]) {
InAppSettingsPSMultiValueSpecifierTable * multiValueSpecifier = [[InAppSettingsPSMultiValueSpecifierTable alloc] initWithSetting:setting];
[self.navigationController pushViewController:multiValueSpecifier animated:YES];
[multiValueSpecifier release];
} else if ([setting isType:InAppSettingsPSChildPaneSpecifier]) {
 
if ( [setting valueForKey:InAppSettingsSpecifierInAppChildPaneClass] ) {
 
UIViewController * childPane;
 
Class childPaneClass = NSClassFromString([setting valueForKey:InAppSettingsSpecifierInAppChildPaneClass]);
if ( [childPaneClass conformsToProtocol:@protocol(InAppSettingsChildPane)] ) {
childPane = [[childPaneClass alloc] initWithSetting:setting];
} else {
childPane = [[childPaneClass alloc] init];
}
 
childPane.title = [setting localizedTitle];
[self.navigationController pushViewController:childPane animated:YES];
[childPane release];
} else {
 
InAppSettingsViewController * childPane = [[InAppSettingsViewController alloc] initWithFile:[setting valueForKey:InAppSettingsSpecifierFile]];
childPane.title = [setting localizedTitle];
childPane.dataSource = self.dataSource;
[self.navigationController pushViewController:childPane animated:YES];
[childPane release];
}
} else if ([setting isType:InAppSettingsPSTitleValueSpecifier]) {
InAppSettingsOpenUrl([NSURL URLWithString:[setting valueForKey:InAppSettingsSpecifierInAppURL]]);
}
}
 
- (NSIndexPath *) tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath {
InAppSettingsTableCell * cell = ((InAppSettingsTableCell *)[tableView cellForRowAtIndexPath:indexPath]);
 
if ([cell.setting isType:@"PSTextFieldSpecifier"]) {
[cell.valueInput becomeFirstResponder];
} else if (cell.canSelectCell) {
[self.firstResponder resignFirstResponder];
return indexPath;
}
return nil;
}
 
@end
 
@implementation InAppSettingsLightningBolt
 
@synthesize flip;
 
- (id) initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self != nil) {
self.flip = NO;
self.backgroundColor = [UIColor clearColor];
}
return self;
}
 
- (void) drawRect:(CGRect)rect {
CGContextRef context = UIGraphicsGetCurrentContext();
 
CGContextSetFillColorWithColor(context, [InAppSettingsFooterBlue CGColor]);
#if __IPHONE_3_2
CGContextSetShadowWithColor(context, CGSizeMake(0.0f, 1.0f), 0.0f, [[UIColor whiteColor] CGColor]);
#else
CGContextSetShadowWithColor(context, CGSizeMake(0.0f, -1.0f), 0.0f, [[UIColor whiteColor] CGColor]);
#endif
if (self.flip) {
CGContextMoveToPoint(context, 4.0f, 1.0f);
CGContextAddLineToPoint(context, 13.0f, 1.0f);
CGContextAddLineToPoint(context, 10.0f, 5.0f);
CGContextAddLineToPoint(context, 12.0f, 7.0f);
CGContextAddLineToPoint(context, 2.0f, 15.0f);
CGContextAddLineToPoint(context, 5.0f, 7.0f);
CGContextAddLineToPoint(context, 3.0f, 5.0f);
} else {
CGContextMoveToPoint(context, 3.0f, 1.0f);
CGContextAddLineToPoint(context, 12.0f, 1.0f);
CGContextAddLineToPoint(context, 13.0f, 5.0f);
CGContextAddLineToPoint(context, 11.0f, 7.0f);
CGContextAddLineToPoint(context, 14.0f, 15.0f);
CGContextAddLineToPoint(context, 4.0f, 7.0f);
CGContextAddLineToPoint(context, 6.0f, 5.0f);
}
CGContextFillPath(context);
}
 
@end
/iKopter/trunk/Classes/InAppSettings/InAppSettingsConstants.h
0,0 → 1,76
//
// InAppSettingsConstants.h
// InAppSettingsTestApp
//
// Created by David Keegan on 11/21/09.
// Copyright 2009 InScopeApps{+}. All rights reserved.
//
 
#import <Availability.h>
 
#define InAppSettingsRootFile @"Root"
#define InAppSettingsProjectName @"InAppSettings"
 
#define InAppSettingsOffsetY 2.0f
#define InAppSettingsFontSize 17.0f
#define InAppSettingsCellPadding 9.0f
#define InAppSettingsTablePadding 10.0f
#define InAppSettingsPowerFooterHeight 32.0f
#define InAppSettingsLightingBoltSize 16.0f
#define InAppSettingsKeyboardAnimation 0.3f
#define InAppSettingsCellTextFieldMinX 115.0f
#define InAppSettingsCellToggleSwitchWidth 94.0f
#define InAppSettingsCellDisclosureIndicatorWidth 10.0f
#define InAppSettingsTotalCellPadding InAppSettingsCellPadding * 2
#define InAppSettingsTotalTablePadding InAppSettingsTablePadding * 2
#define InAppSettingsScreenWidth 320
#define InAppSettingsScreenHeight 480
#define InAppSettingsCellTitleMaxWidth InAppSettingsScreenWidth - (InAppSettingsTotalTablePadding + InAppSettingsTotalCellPadding)
#define InAppSettingsFooterFont [UIFont systemFontOfSize:14.0f]
#define InAppSettingsBoldFont [UIFont boldSystemFontOfSize:InAppSettingsFontSize]
#define InAppSettingsNormalFont [UIFont systemFontOfSize:InAppSettingsFontSize]
#define InAppSettingsBlue [UIColor colorWithRed:0.22f green:0.33f blue:0.53f alpha:1.0f];
#define InAppSettingsFooterBlue [UIColor colorWithRed:0.36f green:0.39f blue:0.45f alpha:1.0f]
 
#define InAppSettingsOpenUrl(url) [[UIApplication sharedApplication] openURL : url];
#define InAppSettingsBundlePath [[NSBundle mainBundle] pathForResource:@"Settings" ofType:@"bundle"]
#define InAppSettingsFullPlistPath(file) \
[InAppSettingsBundlePath stringByAppendingPathComponent :[file stringByAppendingPathExtension:@"plist"]]
#define InAppSettingsLocalize(stringKey, tableKey) \
[[NSBundle bundleWithPath:InAppSettingsBundlePath] localizedStringForKey : stringKey value : stringKey table : tableKey]
 
// settings strings
#define InAppSettingsStringsTable @"StringsTable"
#define InAppSettingsPreferenceSpecifiers @"PreferenceSpecifiers"
 
#define InAppSettingsPSGroupSpecifier @"PSGroupSpecifier"
#define InAppSettingsPSSliderSpecifier @"PSSliderSpecifier"
#define InAppSettingsPSChildPaneSpecifier @"PSChildPaneSpecifier"
#define InAppSettingsPSTextFieldSpecifier @"PSTextFieldSpecifier"
#define InAppSettingsPSTitleValueSpecifier @"PSTitleValueSpecifier"
#define InAppSettingsPSMultiValueSpecifier @"PSMultiValueSpecifier"
#define InAppSettingsPSToggleSwitchSpecifier @"PSToggleSwitchSpecifier"
 
#define InAppSettingsSpecifierKey @"Key"
#define InAppSettingsSpecifierType @"Type"
#define InAppSettingsSpecifierFile @"File"
#define InAppSettingsSpecifierTitle @"Title"
#define InAppSettingsSpecifierTitles @"Titles"
#define InAppSettingsSpecifierValues @"Values"
#define InAppSettingsSpecifierDefaultValue @"DefaultValue"
#define InAppSettingsSpecifierMinimumValue @"MinimumValue"
#define InAppSettingsSpecifierMaximumValue @"MaximumValue"
#define InAppSettingsSpecifierInAppURL @"InAppURL"
#define InAppSettingsSpecifierInAppTitle @"InAppTitle"
 
#define InAppSettingsSpecifierInAppNumtype @"InAppNumtype"
 
#define InAppSettingsSpecifierInAppChildPaneClass @"InAppChildPaneClass"
#define InAppSettingsSpecifierInAppCellClass @"InAppCellClass"
 
 
// test what cell init code should be used
#define InAppSettingsUseNewCells __IPHONE_3_0 && __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_3_0
 
// if you dont want to display the footer set this to NO
#define InAppSettingsDisplayPowered YES
/iKopter/trunk/Classes/InAppSettings/InAppSettingsPSMultiValueSpecifierTable.h
0,0 → 1,22
//
// PSMultiValueSpecifierTable.h
// InAppSettings
//
// Created by David Keegan on 11/3/09.
// Copyright 2009 InScopeApps{+}. All rights reserved.
//
 
#import <UIKit/UIKit.h>
#import "InAppSettingsSpecifier.h"
 
@interface InAppSettingsPSMultiValueSpecifierTable : UITableViewController {
InAppSettingsSpecifier * setting;
}
 
@property (nonatomic, retain) InAppSettingsSpecifier * setting;
 
- (id) initWithSetting:(InAppSettingsSpecifier *)inputSetting;
- (id) getValue;
- (void) setValue:(id)newValue;
 
@end
/iKopter/trunk/Classes/InAppSettings/InAppSettingsPSMultiValueSpecifierTable.m
0,0 → 1,126
//
// PSMultiValueSpecifierTable.m
// InAppSettings
//
// Created by David Keegan on 11/3/09.
// Copyright 2009 InScopeApps{+}. All rights reserved.
//
 
#import "InAppSettings.h"
#import "InAppSettingsPSMultiValueSpecifierTable.h"
#import "InAppSettingsConstants.h"
 
@implementation InAppSettingsPSMultiValueSpecifierTable
 
@synthesize setting;
 
- (id) initWithStyle:(UITableViewStyle)style {
return [super initWithStyle:UITableViewStyleGrouped];
}
 
- (id) initWithSetting:(InAppSettingsSpecifier *)inputSetting {
self = [super init];
if (self != nil) {
self.setting = inputSetting;
}
return self;
}
 
- (void) viewDidLoad {
[super viewDidLoad];
 
self.title = [self.setting localizedTitle];
}
 
- (void) dealloc {
[setting release];
[super dealloc];
}
 
#pragma mark Value
 
- (id) getValue {
 
id value;
 
if ( self.setting.dataSource != nil )
value = [self.setting.dataSource objectForKey:[self.setting getKey]];
else
value = [[NSUserDefaults standardUserDefaults] valueForKey:[self.setting getKey]];
 
if (value == nil) {
value = [self.setting valueForKey:InAppSettingsSpecifierDefaultValue];
}
return value;
}
 
- (void) setValue:(id)newValue {
if ( self.setting.dataSource != nil )
[self.setting.dataSource setObject:newValue forKey:[self.setting getKey]];
else
[[NSUserDefaults standardUserDefaults] setObject:newValue forKey:[self.setting getKey]];
}
 
#pragma mark Table view methods
 
- (NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
 
- (NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [[self.setting valueForKey:InAppSettingsSpecifierValues] count];
}
 
- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString * CellIdentifier = @"PSMultiValueSpecifierTableCell";
 
UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
 
if (cell == nil) {
#if InAppSettingsUseNewCells
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
#else
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
#endif
}
 
NSString * cellTitle = InAppSettingsLocalize([[self.setting valueForKey:InAppSettingsSpecifierTitles] objectAtIndex:indexPath.row], self.setting.stringsTable);
id cellValue = [[self.setting valueForKey:InAppSettingsSpecifierValues] objectAtIndex:indexPath.row];
#if InAppSettingsUseNewCells
cell.textLabel.text = cellTitle;
#else
cell.text = cellTitle;
#endif
if ([cellValue isEqual:[self getValue]]) {
cell.accessoryType = UITableViewCellAccessoryCheckmark;
#if InAppSettingsUseNewCells
cell.textLabel.textColor = InAppSettingsBlue;
#else
cell.textColor = InAppSettingsBlue;
#endif
} else {
cell.accessoryType = UITableViewCellAccessoryNone;
#if InAppSettingsUseNewCells
cell.textLabel.textColor = [UIColor blackColor];
#else
cell.textColor = [UIColor blackColor];
#endif
}
 
return cell;
}
 
- (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:[tableView indexPathForSelectedRow] animated:YES];
}
 
- (NSIndexPath *) tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath {
id cellValue = [[self.setting valueForKey:InAppSettingsSpecifierValues] objectAtIndex:indexPath.row];
 
[self setValue:cellValue];
[self.tableView reloadData];
return indexPath;
}
 
@end
 
/iKopter/trunk/Classes/InAppSettings/InAppSettingsPotiValueController.h
0,0 → 1,37
//
// InAppSettingsPotiValueController.h
// MK4PhoneNav
//
// Created by Frank Blumenberg on 05.05.10.
// Copyright 2010 __MyCompanyName__. All rights reserved.
//
 
#import <UIKit/UIKit.h>
#import "InAppSettings.h"
 
 
@interface InAppSettingsPotiValueController : UIViewController<InAppSettingsChildPane, UITextFieldDelegate> {
 
InAppSettingsSpecifier* setting;
 
UITextField *numberField;
UILabel *sliderLabel;
UISwitch *potiSwitch;
 
UIPickerView *potiPicker;
NSArray *pickerData;
}
 
@property (nonatomic, retain) NSArray *pickerData;
@property (nonatomic, retain) InAppSettingsSpecifier* setting;
 
@property (nonatomic, retain) IBOutlet UIPickerView *potiPicker;
@property (nonatomic, retain) IBOutlet UITextField *numberField;
@property (nonatomic, retain) IBOutlet UILabel *sliderLabel;
@property (nonatomic, retain) IBOutlet UISwitch *potiSwitch;
 
- (IBAction)textFieldDoneEditing:(id)sender;
- (IBAction)backgroundTap:(id)sender;
- (IBAction)toggleControls:(id)sender;
 
@end
/iKopter/trunk/Classes/InAppSettings/InAppSettingsPotiValueController.m
0,0 → 1,166
//
// InAppSettingsPotiValueController.m
// MK4PhoneNav
//
// Created by Frank Blumenberg on 05.05.10.
// Copyright 2010 __MyCompanyName__. All rights reserved.
//
 
#import "InAppSettingsPotiValueController.h"
 
 
@implementation InAppSettingsPotiValueController
 
@synthesize setting;
@synthesize numberField;
@synthesize sliderLabel;
@synthesize potiSwitch;
@synthesize pickerData;
@synthesize potiPicker;
 
- (id) initWithSetting:(InAppSettingsSpecifier *)inputSetting {
if ((self = [super initWithNibName:@"InAppSettingsPotiValueController" bundle:nil])) {
self.setting=inputSetting;
NSArray *array = [[NSArray alloc] initWithObjects:
@"Poti1",
@"Poti2",
@"Poti3",
@"Poti4",
@"Poti5",
@"Poti6",
@"Poti7",
@"Poti8",
nil];
self.pickerData = array;
[array release];
}
return self;
}
 
 
- (void) viewDidLoad {
[super viewDidLoad];
self.title = [self.setting localizedTitle];
}
 
- (void)viewWillAppear:(BOOL)animated {
 
int value = [[setting getValue] intValue];
if (value<248) {
potiSwitch.on = NO;
numberField.alpha = 1.0f;
potiPicker.alpha = 0.0f;
numberField.text =[NSString stringWithFormat:@"%d",value];
}
else {
potiSwitch.on = YES;
numberField.alpha = 0.0f;
potiPicker.alpha = 1.0f;
numberField.text =@"0";
[potiPicker selectRow:255-value inComponent:0 animated:NO];
}
}
 
-(void) viewWillDisappear:(BOOL)animated
{
int value=0;
if(potiSwitch.on)
{
int row = [potiPicker selectedRowInComponent:0];
value = 255-row;
}
else
{
value = [numberField.text intValue];
}
 
[setting setValue:[NSNumber numberWithInt:value]];
}
 
- (void) dealloc {
[setting release];
[numberField release];
[sliderLabel release];
[potiSwitch release];
[pickerData release];
[potiPicker release];
[super dealloc];
}
 
- (id) getValue {
return nil;
}
 
- (void) setValue:(id)newValue {
}
 
- (IBAction)textFieldDoneEditing:(id)sender {
[sender resignFirstResponder];
}
 
- (IBAction)backgroundTap:(id)sender {
[numberField resignFirstResponder];
}
 
- (IBAction)toggleControls:(id)sender {
 
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.3];
numberField.alpha = potiSwitch.on?0.0f:1.0f;
potiPicker.alpha = potiSwitch.on?1.0f:0.0f;
[UIView commitAnimations];
}
 
 
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
 
- (void)viewDidUnload {
self.numberField = nil;
self.sliderLabel = nil;
self.potiSwitch = nil;
self.pickerData = nil;
self.potiPicker = nil;
[super viewDidUnload];
}
 
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
NSMutableString* s = [textField.text mutableCopy];
[s replaceCharactersInRange:range withString:string];
 
int value = [s intValue];
[s release];
if (value <=245 ) {
return YES;
}
return NO;
}
 
#pragma mark -
#pragma mark Picker Data Source Methods
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
return 1;
}
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
return [pickerData count];
}
#pragma mark Picker Delegate Methods
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
return [pickerData objectAtIndex:row];
}
 
@end
/iKopter/trunk/Classes/InAppSettings/InAppSettingsPotiValueController.xib
0,0 → 1,648
<?xml version="1.0" encoding="UTF-8"?>
<archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="7.10">
<data>
<int key="IBDocument.SystemTarget">1024</int>
<string key="IBDocument.SystemVersion">10D573</string>
<string key="IBDocument.InterfaceBuilderVersion">783</string>
<string key="IBDocument.AppKitVersion">1038.29</string>
<string key="IBDocument.HIToolboxVersion">460.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="NS.object.0">107</string>
</object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
<integer value="1"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
</object>
<object class="NSMutableDictionary" key="IBDocument.Metadata">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys" id="0">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
</object>
<object class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBProxyObject" id="372490531">
<string key="IBProxiedObjectIdentifier">IBFilesOwner</string>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
</object>
<object class="IBProxyObject" id="975951072">
<string key="IBProxiedObjectIdentifier">IBFirstResponder</string>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
</object>
<object class="IBUIView" id="191373211">
<reference key="NSNextResponder"/>
<int key="NSvFlags">274</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBUIPickerView" id="175389793">
<reference key="NSNextResponder" ref="191373211"/>
<int key="NSvFlags">290</int>
<string key="NSFrame">{{0, 88}, {320, 216}}</string>
<reference key="NSSuperview" ref="191373211"/>
<float key="IBUIAlpha">0.0</float>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<bool key="IBUIShowsSelectionIndicator">YES</bool>
</object>
<object class="IBUITextField" id="164640674">
<reference key="NSNextResponder" ref="191373211"/>
<int key="NSvFlags">292</int>
<string key="NSFrame">{{20, 88}, {280, 31}}</string>
<reference key="NSSuperview" ref="191373211"/>
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIClipsSubviews">YES</bool>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<int key="IBUIContentVerticalAlignment">0</int>
<string key="IBUIText"/>
<int key="IBUIBorderStyle">3</int>
<object class="NSColor" key="IBUITextColor">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MAA</bytes>
<object class="NSColorSpace" key="NSCustomColorSpace">
<int key="NSID">2</int>
</object>
</object>
<object class="NSFont" key="IBUIFont">
<string key="NSName">Helvetica</string>
<double key="NSSize">17</double>
<int key="NSfFlags">16</int>
</object>
<bool key="IBUIAdjustsFontSizeToFit">YES</bool>
<float key="IBUIMinimumFontSize">17</float>
<object class="IBUITextInputTraits" key="IBUITextInputTraits">
<int key="IBUIAutocorrectionType">1</int>
<int key="IBUIKeyboardType">4</int>
<int key="IBUIReturnKeyType">9</int>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
</object>
</object>
<object class="IBUISwitch" id="1007142614">
<reference key="NSNextResponder" ref="191373211"/>
<int key="NSvFlags">292</int>
<string key="NSFrame">{{206, 20}, {94, 27}}</string>
<reference key="NSSuperview" ref="191373211"/>
<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="805205008">
<reference key="NSNextResponder" ref="191373211"/>
<int key="NSvFlags">292</int>
<string key="NSFrame">{{20, 22}, {73, 22}}</string>
<reference key="NSSuperview" ref="191373211"/>
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIClipsSubviews">YES</bool>
<int key="IBUIContentMode">7</int>
<bool key="IBUIUserInteractionEnabled">NO</bool>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<string key="IBUIText">Use Poti</string>
<object class="NSFont" key="IBUIFont">
<string key="NSName">Helvetica-Bold</string>
<double key="NSSize">17</double>
<int key="NSfFlags">16</int>
</object>
<object class="NSColor" key="IBUITextColor">
<int key="NSColorSpace">1</int>
<bytes key="NSRGB">MCAwIDAAA</bytes>
</object>
<nil key="IBUIHighlightedColor"/>
<int key="IBUIBaselineAdjustment">1</int>
<float key="IBUIMinimumFontSize">10</float>
</object>
</object>
<string key="NSFrameSize">{320, 372}</string>
<reference key="NSSuperview"/>
<object class="NSColor" key="IBUIBackgroundColor">
<int key="NSColorSpace">1</int>
<bytes key="NSRGB">MC43MDE5NjA4MDIxIDAuNzAxOTYwODAyMSAwLjcwMTk2MDgwMjEAA</bytes>
</object>
<object class="IBUISimulatedStatusBarMetrics" key="IBUISimulatedStatusBarMetrics"/>
<object class="IBUISimulatedNavigationBarMetrics" key="IBUISimulatedTopBarMetrics">
<bool key="IBUIPrompted">NO</bool>
</object>
<object class="IBUISimulatedToolbarMetrics" key="IBUISimulatedBottomBarMetrics"/>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
</object>
</object>
<object class="IBObjectContainer" key="IBDocument.Objects">
<object class="NSMutableArray" key="connectionRecords">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">view</string>
<reference key="source" ref="372490531"/>
<reference key="destination" ref="191373211"/>
</object>
<int key="connectionID">3</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">sliderLabel</string>
<reference key="source" ref="372490531"/>
<reference key="destination" ref="805205008"/>
</object>
<int key="connectionID">8</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">numberField</string>
<reference key="source" ref="372490531"/>
<reference key="destination" ref="164640674"/>
</object>
<int key="connectionID">9</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">potiSwitch</string>
<reference key="source" ref="372490531"/>
<reference key="destination" ref="1007142614"/>
</object>
<int key="connectionID">10</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">potiPicker</string>
<reference key="source" ref="372490531"/>
<reference key="destination" ref="175389793"/>
</object>
<int key="connectionID">11</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">dataSource</string>
<reference key="source" ref="175389793"/>
<reference key="destination" ref="372490531"/>
</object>
<int key="connectionID">12</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">delegate</string>
<reference key="source" ref="175389793"/>
<reference key="destination" ref="372490531"/>
</object>
<int key="connectionID">13</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">backgroundTap:</string>
<reference key="source" ref="191373211"/>
<reference key="destination" ref="372490531"/>
<int key="IBEventType">7</int>
</object>
<int key="connectionID">14</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">textFieldDoneEditing:</string>
<reference key="source" ref="164640674"/>
<reference key="destination" ref="372490531"/>
<int key="IBEventType">19</int>
</object>
<int key="connectionID">15</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">toggleControls:</string>
<reference key="source" ref="1007142614"/>
<reference key="destination" ref="372490531"/>
<int key="IBEventType">13</int>
</object>
<int key="connectionID">16</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">delegate</string>
<reference key="source" ref="164640674"/>
<reference key="destination" ref="372490531"/>
</object>
<int key="connectionID">17</int>
</object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBObjectRecord">
<int key="objectID">0</int>
<reference key="object" ref="0"/>
<reference key="children" ref="1000"/>
<nil key="parent"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">1</int>
<reference key="object" ref="191373211"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="1007142614"/>
<reference ref="805205008"/>
<reference ref="164640674"/>
<reference ref="175389793"/>
</object>
<reference key="parent" ref="0"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">-1</int>
<reference key="object" ref="372490531"/>
<reference key="parent" ref="0"/>
<string key="objectName">File's Owner</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">-2</int>
<reference key="object" ref="975951072"/>
<reference key="parent" ref="0"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">4</int>
<reference key="object" ref="175389793"/>
<reference key="parent" ref="191373211"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">5</int>
<reference key="object" ref="164640674"/>
<reference key="parent" ref="191373211"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">6</int>
<reference key="object" ref="1007142614"/>
<reference key="parent" ref="191373211"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">7</int>
<reference key="object" ref="805205008"/>
<reference key="parent" ref="191373211"/>
</object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>-1.CustomClassName</string>
<string>-2.CustomClassName</string>
<string>1.CustomClassName</string>
<string>1.IBEditorWindowLastContentRect</string>
<string>1.IBPluginDependency</string>
<string>4.IBPluginDependency</string>
<string>5.IBPluginDependency</string>
<string>6.IBPluginDependency</string>
<string>7.IBPluginDependency</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>InAppSettingsPotiValueController</string>
<string>UIResponder</string>
<string>UIControl</string>
<string>{{673, 278}, {320, 480}}</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
</object>
</object>
<object class="NSMutableDictionary" key="unlocalizedProperties">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference key="dict.sortedKeys" ref="0"/>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
</object>
<nil key="activeLocalization"/>
<object class="NSMutableDictionary" key="localizations">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference key="dict.sortedKeys" ref="0"/>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
</object>
<nil key="sourceID"/>
<int key="maxID">18</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBPartialClassDescription">
<string key="className">InAppSettingsPotiValueController</string>
<string key="superclassName">UIViewController</string>
<object class="NSMutableDictionary" key="actions">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>backgroundTap:</string>
<string>textFieldDoneEditing:</string>
<string>toggleControls:</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>id</string>
<string>id</string>
<string>id</string>
</object>
</object>
<object class="NSMutableDictionary" key="actionInfosByName">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>backgroundTap:</string>
<string>textFieldDoneEditing:</string>
<string>toggleControls:</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBActionInfo">
<string key="name">backgroundTap:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo">
<string key="name">textFieldDoneEditing:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo">
<string key="name">toggleControls:</string>
<string key="candidateClassName">id</string>
</object>
</object>
</object>
<object class="NSMutableDictionary" key="outlets">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>numberField</string>
<string>potiPicker</string>
<string>potiSwitch</string>
<string>sliderLabel</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>UITextField</string>
<string>UIPickerView</string>
<string>UISwitch</string>
<string>UILabel</string>
</object>
</object>
<object class="NSMutableDictionary" key="toOneOutletInfosByName">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>numberField</string>
<string>potiPicker</string>
<string>potiSwitch</string>
<string>sliderLabel</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBToOneOutletInfo">
<string key="name">numberField</string>
<string key="candidateClassName">UITextField</string>
</object>
<object class="IBToOneOutletInfo">
<string key="name">potiPicker</string>
<string key="candidateClassName">UIPickerView</string>
</object>
<object class="IBToOneOutletInfo">
<string key="name">potiSwitch</string>
<string key="candidateClassName">UISwitch</string>
</object>
<object class="IBToOneOutletInfo">
<string key="name">sliderLabel</string>
<string key="candidateClassName">UILabel</string>
</object>
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">InAppSettingsPotiValueController.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSObject</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">../MKCommunication/AsyncSocket.h</string>
</object>
</object>
</object>
<object class="NSMutableArray" key="referencedPartialClassDescriptionsV3.2+">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBPartialClassDescription">
<string key="className">NSObject</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">Foundation.framework/Headers/NSError.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSObject</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">Foundation.framework/Headers/NSFileManager.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSObject</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">Foundation.framework/Headers/NSKeyValueCoding.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSObject</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">Foundation.framework/Headers/NSKeyValueObserving.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSObject</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">Foundation.framework/Headers/NSKeyedArchiver.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSObject</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">Foundation.framework/Headers/NSObject.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSObject</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">Foundation.framework/Headers/NSRunLoop.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSObject</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">Foundation.framework/Headers/NSThread.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSObject</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">Foundation.framework/Headers/NSURL.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSObject</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">Foundation.framework/Headers/NSURLConnection.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSObject</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">UIKit.framework/Headers/UIAccessibility.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSObject</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">UIKit.framework/Headers/UINibLoading.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSObject</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier" id="938759004">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">UIKit.framework/Headers/UIResponder.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">UIControl</string>
<string key="superclassName">UIView</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">UIKit.framework/Headers/UIControl.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">UILabel</string>
<string key="superclassName">UIView</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">UIKit.framework/Headers/UILabel.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">UIPickerView</string>
<string key="superclassName">UIView</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">UIKit.framework/Headers/UIPickerView.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">UIResponder</string>
<string key="superclassName">NSObject</string>
<reference key="sourceIdentifier" ref="938759004"/>
</object>
<object class="IBPartialClassDescription">
<string key="className">UISearchBar</string>
<string key="superclassName">UIView</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">UIKit.framework/Headers/UISearchBar.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">UISearchDisplayController</string>
<string key="superclassName">NSObject</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">UIKit.framework/Headers/UISearchDisplayController.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">UISwitch</string>
<string key="superclassName">UIControl</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">UIKit.framework/Headers/UISwitch.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">UITextField</string>
<string key="superclassName">UIControl</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier" id="360062614">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">UIKit.framework/Headers/UITextField.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">UIView</string>
<reference key="sourceIdentifier" ref="360062614"/>
</object>
<object class="IBPartialClassDescription">
<string key="className">UIView</string>
<string key="superclassName">UIResponder</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">UIKit.framework/Headers/UIView.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">UIViewController</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">UIKit.framework/Headers/UINavigationController.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">UIViewController</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">UIKit.framework/Headers/UIPopoverController.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">UIViewController</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">UIKit.framework/Headers/UISplitViewController.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">UIViewController</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">UIKit.framework/Headers/UITabBarController.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">UIViewController</string>
<string key="superclassName">UIResponder</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">UIKit.framework/Headers/UIViewController.h</string>
</object>
</object>
</object>
</object>
<int key="IBDocument.localizationMode">0</int>
<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaTouchFramework</string>
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDevelopmentDependencies">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3</string>
<integer value="3000" key="NS.object.0"/>
</object>
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
<string key="IBDocument.LastKnownRelativeProjectPath">MK4PhoneNav.xcodeproj</string>
<int key="IBDocument.defaultPropertyAccessControl">3</int>
<string key="IBCocoaTouchPluginVersion">107</string>
</data>
</archive>
/iKopter/trunk/Classes/InAppSettings/InAppSettingsReader.h
0,0 → 1,36
//
// InAppSettingsReader.h
// InAppSettingsTestApp
//
// Created by David Keegan on 1/19/10.
// Copyright 2010 InScopeApps{+}. All rights reserved.
//
 
#import <Foundation/Foundation.h>
 
@protocol InAppSettingsDatasource;
 
@interface InAppSettingsReaderRegisterDefaults : NSObject {
// keep track of what files we've read to avoid circular references
NSMutableArray * files;
NSMutableDictionary * values;
}
 
@property (nonatomic, retain) NSMutableArray * files;
@property (nonatomic, retain) NSMutableDictionary * values;
 
@end
 
@interface InAppSettingsReader : NSObject {
NSString * file;
NSMutableArray * headers, * settings;
id<InAppSettingsDatasource> dataSource;
}
 
@property (nonatomic, copy) NSString * file;
@property (nonatomic, retain) NSMutableArray * headers, * settings;
 
- (id) initWithFile:(NSString *)inputFile;
- (id) initWithFile:(NSString *)inputFile dataSource:(id<InAppSettingsDatasource>)aDataSource;
 
@end
/iKopter/trunk/Classes/InAppSettings/InAppSettingsReader.m
0,0 → 1,128
//
// InAppSettingsReader.m
// InAppSettingsTestApp
//
// Created by David Keegan on 1/19/10.
// Copyright 2010 InScopeApps{+}. All rights reserved.
//
 
#import "InAppSettingsReader.h"
#import "InAppSettingsSpecifier.h"
#import "InAppSettingsConstants.h"
 
@implementation InAppSettingsReaderRegisterDefaults
 
@synthesize files;
@synthesize values;
 
- (void) loadFile:(NSString *)file {
// if the file is not in the files list we havn't read it yet
NSInteger fileIndex = [self.files indexOfObject:file];
 
if (fileIndex == NSNotFound) {
[self.files addObject:file];
 
// load plist
NSDictionary * settingsDictionary = [[NSDictionary alloc] initWithContentsOfFile:InAppSettingsFullPlistPath(file)];
NSArray * preferenceSpecifiers = [settingsDictionary objectForKey:InAppSettingsPreferenceSpecifiers];
NSString * stringsTable = [settingsDictionary objectForKey:InAppSettingsStringsTable];
 
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
for (NSDictionary * eachSetting in preferenceSpecifiers) {
InAppSettingsSpecifier * setting = [[InAppSettingsSpecifier alloc] initWithDictionary:eachSetting andStringsTable:stringsTable];
if ([setting isValid]) {
if ([setting isType:InAppSettingsPSChildPaneSpecifier]) {
[self loadFile:[setting valueForKey:InAppSettingsSpecifierFile]];
} else if ([setting hasKey]) {
if ([setting valueForKey:InAppSettingsSpecifierDefaultValue]) {
[self.values
setObject:[setting valueForKey:InAppSettingsSpecifierDefaultValue]
forKey:[setting getKey]];
}
}
}
[setting release];
}
[pool drain];
[settingsDictionary release];
}
}
 
- (id) init {
self = [super init];
if (self != nil) {
self.files = [[NSMutableArray alloc] init];
self.values = [[NSMutableDictionary alloc] init];
[self loadFile:InAppSettingsRootFile];
[[NSUserDefaults standardUserDefaults] registerDefaults:self.values];
}
return self;
}
 
 
- (void) dealloc {
[files release];
[values release];
[super dealloc];
}
 
@end
 
@implementation InAppSettingsReader
 
@synthesize file;
@synthesize headers, settings;
 
- (id) initWithFile:(NSString *)inputFile {
self = [super init];
if (self != nil) {
self.file = inputFile;
 
// load plist
NSDictionary * settingsDictionary = [[NSDictionary alloc] initWithContentsOfFile:InAppSettingsFullPlistPath(self.file)];
NSArray * preferenceSpecifiers = [settingsDictionary objectForKey:InAppSettingsPreferenceSpecifiers];
NSString * stringsTable = [settingsDictionary objectForKey:InAppSettingsStringsTable];
 
// initialize the arrays
headers = [[NSMutableArray alloc] init];
settings = [[NSMutableArray alloc] init];
 
// load the data
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
for (NSDictionary * eachSetting in preferenceSpecifiers) {
InAppSettingsSpecifier * setting = [[InAppSettingsSpecifier alloc] initWithDictionary:eachSetting andStringsTable:stringsTable];
setting.dataSource = dataSource;
if ([setting isValid]) {
if ([setting isType:InAppSettingsPSGroupSpecifier]) {
[self.headers addObject:[setting localizedTitle]];
[self.settings addObject:[NSMutableArray array]];
} else {
// if there are no settings make an initial container
if ([self.settings count] < 1) {
[self.headers addObject:@""];
[self.settings addObject:[NSMutableArray array]];
}
[[self.settings lastObject] addObject:setting];
}
}
[setting release];
}
[pool drain];
[settingsDictionary release];
}
return self;
}
 
- (id) initWithFile:(NSString *)inputFile dataSource:(id<InAppSettingsDatasource>)aDataSource {
dataSource = aDataSource;
return [self initWithFile:inputFile];
}
 
- (void) dealloc {
[file release];
[headers release];
[settings release];
[super dealloc];
}
 
@end
/iKopter/trunk/Classes/InAppSettings/InAppSettingsSpecifier.h
0,0 → 1,47
//
// InAppSetting.h
// InAppSettingsTestApp
//
// Created by David Keegan on 11/21/09.
// Copyright 2009 InScopeApps{+}. All rights reserved.
//
 
#import <Foundation/Foundation.h>
 
@protocol InAppSettingsSpecifierDelegate;
@protocol InAppSettingsDatasource;
 
@interface InAppSettingsSpecifier : NSObject {
NSString * stringsTable;
NSDictionary * settingDictionary;
id<InAppSettingsSpecifierDelegate> delegate;
id<InAppSettingsDatasource> dataSource;
}
 
@property (nonatomic, copy) NSString * stringsTable;
@property (assign) id<InAppSettingsSpecifierDelegate> delegate;
@property (assign) id<InAppSettingsDatasource> dataSource;
 
- (NSString *) getKey;
- (NSString *) getType;
- (BOOL) isType:(NSString *)type;
- (id) getValue;
- (void) setValue:(id)newValue;
- (id) valueForKey:(NSString *)key;
- (NSString *) localizedTitle;
- (NSString *) cellName;
 
- (BOOL) hasTitle;
- (BOOL) hasKey;
- (BOOL) hasDefaultValue;
- (BOOL) isValid;
 
- (id) initWithDictionary:(NSDictionary *)dictionary andStringsTable:(NSString *)table;
 
@end
 
@protocol InAppSettingsSpecifierDelegate < NSObject >
 
- (void) settingsSpecifierUpdated:(InAppSettingsSpecifier *)specifier;
 
@end
/iKopter/trunk/Classes/InAppSettings/InAppSettingsSpecifier.m
0,0 → 1,235
//
// InAppSetting.m
// InAppSettingsTestApp
//
// Created by David Keegan on 11/21/09.
// Copyright 2009 InScopeApps{+}. All rights reserved.
//
 
#import "InAppSettings.h"
#import "InAppSettingsSpecifier.h"
#import "InAppSettingsConstants.h"
 
@implementation InAppSettingsSpecifier
 
@synthesize stringsTable;
@synthesize delegate;
@synthesize dataSource;
 
- (NSString *) getKey {
return [self valueForKey:InAppSettingsSpecifierKey];
}
 
- (NSString *) getType {
return [self valueForKey:InAppSettingsSpecifierType];
}
 
- (BOOL) isType:(NSString *)type {
return [[self getType] isEqualToString:type];
}
 
- (id) valueForKey:(NSString *)key {
return [settingDictionary objectForKey:key];
}
 
- (NSString *) localizedTitle {
NSString * title = [self valueForKey:InAppSettingsSpecifierTitle];
 
if ([self valueForKey:InAppSettingsSpecifierInAppTitle]) {
title = [self valueForKey:InAppSettingsSpecifierInAppTitle];
}
return InAppSettingsLocalize(title, self.stringsTable);
}
 
- (NSString *) cellName {
 
if ([self valueForKey:InAppSettingsSpecifierInAppCellClass]) {
return [self valueForKey:InAppSettingsSpecifierInAppCellClass];
}
 
return [NSString stringWithFormat:@"%@%@Cell", InAppSettingsProjectName, [self getType]];
}
 
- (id) getValue {
 
id value;
 
if ( self.dataSource != nil )
value = [self.dataSource objectForKey:[self getKey]];
else
value = [[NSUserDefaults standardUserDefaults] valueForKey:[self getKey]];
 
if (value == nil) {
value = [self valueForKey:InAppSettingsSpecifierDefaultValue];
}
return value;
}
 
- (void) setValue:(id)newValue {
NSString * key = [self getKey];
 
if ( self.dataSource != nil ) {
[self.dataSource setObject:newValue forKey:key];
} else
[[NSUserDefaults standardUserDefaults] setObject:newValue forKey:key];
 
[self.delegate settingsSpecifierUpdated:self];
}
 
#pragma mark validation
 
- (BOOL) hasTitle {
return ([self valueForKey:InAppSettingsSpecifierTitle]) ? YES : NO;
}
 
- (BOOL) hasKey {
NSString * key = [self getKey];
 
return (key && (![key isEqualToString:@""]));
}
 
- (BOOL) hasDefaultValue {
return ([self valueForKey:InAppSettingsSpecifierDefaultValue]) ? YES : NO;
}
 
- (BOOL) isValid {
if (![self getType]) {
return NO;
}
 
if ([self isType:InAppSettingsPSGroupSpecifier]) {
return YES;
}
 
if ([self isType:InAppSettingsPSMultiValueSpecifier]) {
if (![self hasKey]) {
return NO;
}
 
if (![self hasDefaultValue]) {
return NO;
}
 
// check the localized and un-locatlized values
if (![self hasTitle] || [[self valueForKey:InAppSettingsSpecifierTitle] length] == 0) {
return NO;
}
 
NSArray * titles = [self valueForKey:InAppSettingsSpecifierTitles];
if ((!titles) || ([titles count] == 0)) {
return NO;
}
 
NSArray * values = [self valueForKey:InAppSettingsSpecifierValues];
if ((!values) || ([values count] == 0)) {
return NO;
}
 
if ([titles count] != [values count]) {
return NO;
}
 
return YES;
}
 
if ([self isType:InAppSettingsPSSliderSpecifier]) {
if (![self hasKey]) {
return NO;
}
 
if (![self hasDefaultValue]) {
return NO;
}
 
// The settings app allows min>max
if (![self valueForKey:InAppSettingsSpecifierMinimumValue]) {
return NO;
}
 
if (![self valueForKey:InAppSettingsSpecifierMaximumValue]) {
return NO;
}
 
return YES;
}
 
if ([self isType:InAppSettingsPSToggleSwitchSpecifier]) {
if (![self hasKey]) {
return NO;
}
 
if (![self hasDefaultValue]) {
return NO;
}
 
if (![self hasTitle]) {
return NO;
}
 
return YES;
}
 
if ([self isType:InAppSettingsPSTitleValueSpecifier]) {
if (![self hasKey]) {
return NO;
}
 
if (![self hasDefaultValue]) {
return NO;
}
 
return YES;
}
 
if ([self isType:InAppSettingsPSTextFieldSpecifier]) {
if (![self hasKey]) {
return NO;
}
 
if (![self hasTitle]) {
return NO;
}
 
return YES;
}
 
if ([self isType:InAppSettingsPSChildPaneSpecifier]) {
if (![self hasTitle]) {
return NO;
}
 
if (![self valueForKey:InAppSettingsSpecifierFile]) {
return NO;
}
 
return YES;
}
 
return NO;
}
 
#pragma mark init/dealloc
 
- (id) init {
return [self initWithDictionary:nil andStringsTable:nil];
}
 
- (id) initWithDictionary:(NSDictionary *)dictionary andStringsTable:(NSString *)table {
self = [super init];
if (self != nil) {
if (dictionary) {
self.stringsTable = table;
settingDictionary = [dictionary retain];
}
}
return self;
}
 
- (void) dealloc {
self.delegate = nil;
[stringsTable release];
[settingDictionary release];
[super dealloc];
}
 
@end