Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add support for iOS 5.0

  • Loading branch information...
commit 33703304901c85324fa028672b1214381162833d 1 parent b7f2e1e
@rpetrich authored
Showing with 232 additions and 9 deletions.
  1. +58 −9 IconRenamer.m
  2. +174 −0 SBIconView.h
View
67 IconRenamer.m
@@ -1,6 +1,8 @@
#import <SpringBoard/SpringBoard.h>
#import <CaptainHook/CaptainHook.h>
+#import "SBIconView.h"
+
@interface SBIcon (OS40)
- (NSString *)leafIdentifier;
- (void)updateLabel;
@@ -14,9 +16,11 @@ - (void)updateLabel;
@interface IconRenamer : NSObject <UIAlertViewDelegate, UITextFieldDelegate> {
@private
SBIcon *_icon;
+ SBIconView *_iconView;
UIAlertView *_av;
BOOL _hasTouch;
}
+- (id)initWithIcon:(SBIcon *)icon iconView:(SBIconView *)iconView;
- (void)receiveTouch;
@end
@@ -26,16 +30,17 @@ @implementation IconRenamer
static IconRenamer *currentRenamer;
-+ (id)renamerWithIcon:(SBIcon *)icon
++ (id)renamerWithIcon:(SBIcon *)icon iconView:(SBIconView *)iconView
{
- return [[[self alloc] initWithIcon:icon] autorelease];
+ return [[[self alloc] initWithIcon:icon iconView:iconView] autorelease];
}
-- (id)initWithIcon:(SBIcon *)icon
+- (id)initWithIcon:(SBIcon *)icon iconView:(SBIconView *)iconView
{
if ((self = [super init])) {
currentRenamer = self;
_icon = [icon retain];
+ _iconView = [iconView retain];
}
return self;
}
@@ -77,7 +82,10 @@ - (void)save
if (![[_icon displayName] isEqualToString:newDisplayName]) {
[iconMappings setObject:newDisplayName forKey:identifier];
[iconMappings writeToFile:@kSettingsFilePath atomically:YES];
- [_icon updateLabel];
+ if (_iconView)
+ [_iconView updateLabel];
+ else
+ [_icon updateLabel];
}
}
@@ -109,6 +117,7 @@ - (void)dealloc
if (currentRenamer == self)
currentRenamer = nil;
[_icon release];
+ [_iconView release];
[super dealloc];
}
@@ -128,6 +137,8 @@ - (void)dealloc
}
static BOOL inTap;
+static NSTimeInterval lastTapTime;
+static SBApplicationIcon *lastTapIcon;
CHOptimizedMethod(2, super, void, SBApplicationIcon, touchesBegan, NSSet *, touches, withEvent, UIEvent *, event)
{
@@ -141,9 +152,6 @@ - (void)dealloc
CHSuper(2, SBApplicationIcon, touchesMoved, touches, withEvent, event);
}
-static NSTimeInterval lastTapTime;
-static SBApplicationIcon *lastTapIcon;
-
CHOptimizedMethod(2, super, void, SBApplicationIcon, touchesEnded, NSSet *, touches, withEvent, UIEvent *, event)
{
if (inTap) {
@@ -151,17 +159,54 @@ - (void)dealloc
UITouch *touch = [touches anyObject];
NSTimeInterval currentTapTime = touch.timestamp;
if ((currentTapTime - lastTapTime < 0.5) && (lastTapIcon == self))
- [[IconRenamer renamerWithIcon:self] show];
+ [[IconRenamer renamerWithIcon:self iconView:nil] show];
[lastTapIcon autorelease];
lastTapIcon = [self retain];
lastTapTime = currentTapTime;
} else {
- [currentRenamer ?: [IconRenamer renamerWithIcon:self] receiveTouch];
+ [currentRenamer ?: [IconRenamer renamerWithIcon:self iconView:nil] receiveTouch];
}
}
CHSuper(2, SBApplicationIcon, touchesEnded, touches, withEvent, event);
}
+CHDeclareClass(SBIconView)
+
+static SBIconView *lastTapIconView;
+
+CHOptimizedMethod(2, super, void, SBIconView, touchesBegan, NSSet *, touches, withEvent, UIEvent *, event)
+{
+ inTap = [CHSharedInstance(SBIconController) isEditing];
+ CHSuper(2, SBIconView, touchesBegan, touches, withEvent, event);
+}
+
+CHOptimizedMethod(2, super, void, SBIconView, touchesMoved, NSSet *, touches, withEvent, UIEvent *, event)
+{
+ inTap = NO;
+ CHSuper(2, SBIconView, touchesMoved, touches, withEvent, event);
+}
+
+CHOptimizedMethod(2, super, void, SBIconView, touchesEnded, NSSet *, touches, withEvent, UIEvent *, event)
+{
+ if (inTap) {
+ SBIcon *icon = self.icon;
+ if ([icon isKindOfClass:CHClass(SBApplicationIcon)]) {
+ if ([[iconMappings objectForKey:@"IRRequiresDoubleTap"] boolValue]) {
+ UITouch *touch = [touches anyObject];
+ NSTimeInterval currentTapTime = touch.timestamp;
+ if ((currentTapTime - lastTapTime < 0.5) && (lastTapIconView == self))
+ [[IconRenamer renamerWithIcon:self.icon iconView:self] show];
+ [lastTapIconView autorelease];
+ lastTapIconView = [self retain];
+ lastTapTime = currentTapTime;
+ } else {
+ [currentRenamer ?: [IconRenamer renamerWithIcon:self.icon iconView:self] receiveTouch];
+ }
+ }
+ }
+ CHSuper(2, SBIconView, touchesEnded, touches, withEvent, event);
+}
+
static void LoadSettings()
{
[iconMappings release];
@@ -174,6 +219,10 @@ static void LoadSettings()
CHHook(2, SBApplicationIcon, touchesBegan, withEvent);
CHHook(2, SBApplicationIcon, touchesMoved, withEvent);
CHHook(2, SBApplicationIcon, touchesEnded, withEvent);
+ CHLoadLateClass(SBIconView);
+ CHHook(2, SBIconView, touchesBegan, withEvent);
+ CHHook(2, SBIconView, touchesMoved, withEvent);
+ CHHook(2, SBIconView, touchesEnded, withEvent);
CHLoadLateClass(SBIconController);
CHAutoreleasePoolForScope();
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, (void *)LoadSettings, CFSTR("ch.rpetri.iconrenamer/settingschanged"), NULL, CFNotificationSuspensionBehaviorCoalesce);
View
174 SBIconView.h
@@ -0,0 +1,174 @@
+#import <SpringBoard/SpringBoard.h>
+#import <QuartzCore/QuartzCore.h>
+
+@protocol SBIconObserver
+@optional
+- (void)iconImageDidUpdate:(SBIcon *)icon;
+- (void)iconAccessoriesDidUpdate:(SBIcon *)icon;
+- (void)iconLaunchEnabledDidChange:(SBIcon *)icon;
+@end
+
+@protocol SBIconViewDelegate, SBIconViewLocker, SBIconObserver;
+@class SBIconImageContainerView, SBIconBadgeImage;
+
+@interface SBIconView : UIView <SBIconObserver> {
+ SBIcon *_icon;
+ id<SBIconViewDelegate> _delegate;
+ id<SBIconViewLocker> _locker;
+ SBIconImageContainerView *_iconImageContainer;
+ SBIconImageView *_iconImageView;
+ UIImageView *_iconDarkeningOverlay;
+ UIImageView *_ghostlyImageView;
+ UIImageView *_reflection;
+ UIImageView *_shadow;
+ SBIconBadgeImage *_badgeImage;
+ UIImageView *_badgeView;
+ SBIconLabel *_label;
+ BOOL _labelHidden;
+ BOOL _labelOnWallpaper;
+ UIView *_closeBox;
+ int _closeBoxType;
+ UIImageView *_dropGlow;
+ unsigned _drawsLabel : 1;
+ unsigned _isHidden : 1;
+ unsigned _isGrabbed : 1;
+ unsigned _isOverlapping : 1;
+ unsigned _refusesRecipientStatus : 1;
+ unsigned _highlighted : 1;
+ unsigned _launchDisabled : 1;
+ unsigned _isJittering : 1;
+ unsigned _allowJitter : 1;
+ unsigned _touchDownInIcon : 1;
+ unsigned _hideShadow : 1;
+ NSTimer *_delayedUnhighlightTimer;
+ unsigned _onWallpaper : 1;
+ unsigned _ghostlyRequesters;
+ int _iconLocation;
+ CGFloat _iconImageAlpha;
+ CGFloat _iconImageBrightness;
+ CGFloat _iconLabelAlpha;
+ CGFloat _accessoryAlpha;
+ CGPoint _unjitterPoint;
+ CGPoint _grabPoint;
+ NSTimer *_longPressTimer;
+ unsigned _ghostlyTag;
+ UIImage *_ghostlyImage;
+ BOOL _ghostlyPending;
+}
++(CGSize)defaultIconSize;
++(CGSize)defaultIconImageSize;
++(BOOL)allowsRecycling;
++(CAAnimation *)_jitterPositionAnimation;
++(CAAnimation *)_jitterTransformAnimation;
+
+@property(assign) id<SBIconViewDelegate> delegate;
+@property(assign) id<SBIconViewLocker> locker;
+@property(readonly, retain) SBIcon *icon;
+
+- (id)initWithDefaultSize;
+- (void)dealloc;
+- (void)setIcon:(SBIcon *)icon;
+
+- (int)location;
+- (void)setLocation:(int)location;
+
+- (void)showIconAnimationDidStop:(id)showIconAnimation didFinish:(id)finish icon:(id)icon;
+- (void)setIsHidden:(BOOL)hidden animate:(BOOL)animate;
+- (BOOL)isHidden;
+- (BOOL)isRevealable;
+- (void)positionIconImageView;
+- (void)applyIconImageTransform:(CATransform3D)transform duration:(float)duration delay:(float)delay;
+- (void)setDisplayedIconImage:(id)image;
+- (id)snapshotSettings;
+- (id)iconImageSnapshot:(id)snapshot;
+- (id)reflectedIconWithBrightness:(float)brightness;
+- (void)setIconImageAlpha:(CGFloat)alpha;
+- (void)setIconLabelAlpha:(CGFloat)alpha;
+- (UIImageView *)iconImageView;
+- (void)setLabelHidden:(BOOL)hidden;
+- (void)positionLabel;
+- (CGSize)_labelSize;
+- (Class)_labelClass;
+- (void)updateLabel;
+- (void)_updateBadgePosition;
+- (NSString *)_overriddenBadgeTextForText:(NSString *)text;
+- (void)updateBadge;
+- (id)_automationID;
+- (BOOL)pointMostlyInside:(CGPoint)point withEvent:(UIEvent *)event;
+- (CGRect)frameForIconOverlay;
+- (void)placeIconOverlayView;
+- (void)updateIconOverlayView;
+- (void)_updateIconBrightness;
+- (BOOL)allowsTapWhileEditing;
+- (BOOL)delaysUnhighlightWhenTapped;
+- (BOOL)isHighlighted;
+- (void)setHighlighted:(BOOL)highlighted;
+- (void)setHighlighted:(BOOL)highlighted delayUnhighlight:(BOOL)unhighlight;
+- (void)_delayedUnhighlight;
+- (BOOL)isInDock;
+- (UIImage *)_shadowImage;
+- (void)_updateShadow;
+- (void)updateReflection;
+- (void)setDisplaysOnWallpaper:(BOOL)displaysOnWallpaper;
+- (void)setLabelDisplaysOnWallpaper:(BOOL)labelDisplaysOnWallpaper;
+- (BOOL)showsReflection;
+- (CGFloat)_reflectionImageOffset;
+- (void)setFrame:(CGRect)frame;
+- (void)setIsJittering:(BOOL)isJittering;
+- (void)setAllowJitter:(BOOL)allowJitter;
+- (BOOL)allowJitter;
+- (void)removeAllIconAnimations;
+- (void)setIconPosition:(CGPoint)position;
+- (void)setRefusesRecipientStatus:(BOOL)refusesRecipientStatus;
+- (BOOL)canReceiveGrabbedIcon:(SBIcon *)icon;
+- (NSTimeInterval)grabDurationForEvent:(UIEvent *)event;
+- (void)setIsGrabbed:(BOOL)isGrabbed;
+- (BOOL)isGrabbed;
+- (void)setIsOverlapping:(BOOL)isOverlapping;
+- (CGAffineTransform)transformToMakeDropGlowShrinkToIconSize;
+- (void)prepareDropGlow;
+- (void)showDropGlow:(BOOL)glow;
+- (void)removeDropGlow;
+- (id)dropGlow;
+- (BOOL)isShowingDropGlow;
+- (void)placeGhostlyImageView;
+- (id)_genGhostlyImage:(id)image;
+- (void)prepareGhostlyImageIfNeeded;
+- (void)prepareGhostlyImage;
+- (void)prepareGhostlyImageView;
+- (void)setGhostly:(BOOL)ghostly requester:(int)requester;
+- (void)setPartialGhostly:(float)ghostly requester:(int)requester;
+- (void)removeGhostlyImageView;
+- (BOOL)isGhostly;
+- (int)ghostlyRequesters;
+- (void)longPressTimerFired;
+- (void)cancelLongPressTimer;
+- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event;
+- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
+- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;
+- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;
+- (BOOL)isTouchDownInIcon;
+- (void)setTouchDownInIcon:(BOOL)touchDownInIcon;
+- (void)hideCloseBoxAnimationDidStop:(id)hideCloseBoxAnimation didFinish:(id)finish closeBox:(id)box;
+- (void)positionCloseBoxOfType:(int)type;
+- (id)_newCloseBoxOfType:(int)type;
+- (void)setShowsCloseBox:(BOOL)box;
+- (void)setShowsCloseBox:(BOOL)box animated:(BOOL)animated;
+- (BOOL)isShowingCloseBox;
+- (void)closeBoxTapped;
+- (BOOL)pointInside:(CGPoint)inside withEvent:(id)event;
+- (UIEdgeInsets)snapshotEdgeInsets;
+- (void)setShadowsHidden:(BOOL)hidden;
+- (void)_updateShadowFrameForShadow:(id)shadow;
+- (void)_updateShadowFrame;
+- (BOOL)_delegatePositionIsEditable;
+- (void)_delegateTouchEnded:(BOOL)ended;
+- (BOOL)_delegateTapAllowed;
+- (int)_delegateCloseBoxType;
+- (id)createShadowImageView;
+- (void)prepareForRecycling;
+- (CGRect)defaultFrameForProgressBar;
+- (void)iconImageDidUpdate:(id)iconImage;
+- (void)iconAccessoriesDidUpdate:(id)iconAccessories;
+- (void)iconLaunchEnabledDidChange:(id)iconLaunchEnabled;
+@end

0 comments on commit 3370330

Please sign in to comment.
Something went wrong with that request. Please try again.