Permalink
Browse files

Removing unused constants

  • Loading branch information...
1 parent 64c422b commit 5a98586a9ae1c3bf76f994a789b400562e449f0e @kgn committed Feb 9, 2013
@@ -106,12 +106,7 @@ - (void)layoutSubviews{
- (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;
}
@@ -129,6 +129,10 @@ - (BOOL)textFieldShouldReturn:(UITextField *)cellTextField{
#pragma mark keyboard notification
+// TODO: handle the case where the settings are in a popover or sheet modal
+// The offset amount will not be the same as on iPhone
+// Maybe bring in KGKeyboardChangeManager?
+
- (void)registerForKeyboardNotifications{
[[NSNotificationCenter defaultCenter]
addObserver:self selector:@selector(keyboardWillShow:)
@@ -141,20 +145,22 @@ - (void)registerForKeyboardNotifications{
- (void)keyboardWillShow:(NSNotification*)notification{
if(self.firstResponder == nil){
- // get the keybaord rect
-#if InAppSettingsUseNewKeyboard
- CGRect keyboardRect = [[[notification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
-#else
- CGRect keyboardRect = [[[notification userInfo] objectForKey:UIKeyboardBoundsUserInfoKey] CGRectValue];
-#endif
- // determin the bottom inset for the table view
+ CGRect keyboardEndFrame;
+ NSTimeInterval animationDuration;
+ UIViewAnimationCurve animationCurve;
+ NSDictionary *userInfo = [notification userInfo];
+ [userInfo[UIKeyboardAnimationCurveUserInfoKey] getValue:&animationCurve];
+ [userInfo[UIKeyboardAnimationDurationUserInfoKey] getValue:&animationDuration];
+ [userInfo[UIKeyboardFrameEndUserInfoKey] getValue:&keyboardEndFrame];
+
UIEdgeInsets settingsTableInset = self.settingsTableView.contentInset;
CGPoint tableViewScreenSpace = [self.settingsTableView.superview convertPoint:self.settingsTableView.frame.origin toView:nil];
CGFloat tableViewBottomOffset = CGRectGetHeight(self.view.bounds)-(tableViewScreenSpace.y+self.settingsTableView.frame.size.height);
- settingsTableInset.bottom = keyboardRect.size.height-tableViewBottomOffset;
+ settingsTableInset.bottom = CGRectGetHeight(keyboardEndFrame)-tableViewBottomOffset;
[UIView beginAnimations:nil context:nil];
- [UIView setAnimationDuration:InAppSettingsKeyboardAnimation];
+ [UIView setAnimationCurve:animationCurve];
+ [UIView setAnimationDuration:animationDuration];
[UIView setAnimationBeginsFromCurrentState:YES];
self.settingsTableView.contentInset = settingsTableInset;
self.settingsTableView.scrollIndicatorInsets = settingsTableInset;
@@ -164,8 +170,15 @@ - (void)keyboardWillShow:(NSNotification*)notification{
- (void)keyboardWillHide:(NSNotification*)notification{
if(self.firstResponder == nil){
+ NSTimeInterval animationDuration;
+ UIViewAnimationCurve animationCurve;
+ NSDictionary *userInfo = [notification userInfo];
+ [userInfo[UIKeyboardAnimationCurveUserInfoKey] getValue:&animationCurve];
+ [userInfo[UIKeyboardAnimationDurationUserInfoKey] getValue:&animationDuration];
+
[UIView beginAnimations:nil context:nil];
- [UIView setAnimationDuration:InAppSettingsKeyboardAnimation];
+ [UIView setAnimationCurve:animationCurve];
+ [UIView setAnimationDuration:animationDuration];
[UIView setAnimationBeginsFromCurrentState:YES];
self.settingsTableView.contentInset = UIEdgeInsetsZero;
self.settingsTableView.scrollIndicatorInsets = UIEdgeInsetsZero;
@@ -14,20 +14,14 @@
#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 InAppSettingsCellTitleMaxWidth CGRectGetWidth(self.bounds)-(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 InAppSettingsBundlePath [[NSBundle mainBundle] pathForResource:@"Settings" ofType:@"bundle"]
#define InAppSettingsFullPlistPath(file) \
@@ -63,11 +57,5 @@
#define InAppSettingsSpecifierInAppMultiType @"InAppMultiType"
#define InAppSettingsSpecifierTap @"InAppTap"
-// test what cell init code should be used
-#define InAppSettingsUseNewCells __IPHONE_3_0 && __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_3_0
-
-// test if the new keyboard calls should be used
-#define InAppSettingsUseNewKeyboard __IPHONE_3_2 && __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_3_2
-
// test if the value of PSMultiValueSpecifier should be on the right or left if there is no title
#define InAppSettingsUseNewMultiValueLocation [[[UIDevice currentDevice] systemVersion] doubleValue] >= 4.0
@@ -59,16 +59,11 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil){
- #if InAppSettingsUseNewCells
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
- #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;
if([[self.setting valueForKey:InAppSettingsSpecifierInAppMultiType] isEqualToString:@"fonts"]){
if([cellValue isEqualToString:@"system"]){
@@ -77,24 +72,13 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
cell.textLabel.font = [UIFont fontWithName:cellValue size:InAppSettingsFontSize];
}
}
- #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;

0 comments on commit 5a98586

Please sign in to comment.