[PREVIEW-INPUT REQUEST] PocketTouch.framework 2.0 (for firmware 3.0)

Discussion in 'iOS Development' started by SkylarEC, May 28, 2009.

  1. SkylarEC

    SkylarEC Super Moderator Emeritus Staff Member

    Joined:
    Sep 19, 2007
    Messages:
    6,642
    Likes Received:
    129
    Now that PocketTouch is ~95% done, and its framework can be released right now (it won't be, I want to improve it some), I am ready to get your input.

    I will be pasting the headers for the PocketTouch framework into this thread, and I would like to know if there is anything extra that you guys want me to add; or if there is anything that you guys want me to improve or explain in better detail.


    PocketTouch.h http://www.pastie.org/492592
    Code:
    /*
     *  PocketTouch.h
     *  PocketTouch
     *
     *  Created by Skylar Cantu on 5/11/09.
     *  Copyright 2009 Skylar Cantu. All rights reserved.
     *
     */
    
    #ifndef __PocketTouchFramework__
    #define __PocketTouchFramework__
    
    #include "Global.h"
    
    #include "ColorConversion.h"		
    #include "GlossColors.h"			
    #include "PrivateColors.h"			
    #import "UIKit-UndocumentedAdditions.h"
    #import "NSDictionary-PocketTouchAdditions.h"
    
    #import	"PTColorConverter.h"		//Contains methods to convert a color from an int or array. Also, can convert from monchrome to rgb.
    #import "PTHelpController.h"		//Drop in advanced controller that loads your help pages in HTML format and displays them. Supports internet web browsing as well as local.
    #import "PTMusicController.h"		//Controls the [MPMusicPlayerController iPodController] with a little more intelligence.
    									//TODO: add support for [MPMusicController applicationMusicPlayer];
    #import "PTStringFormatter.h"		//Tool that takes a string and converts it into a PTFormattedString
    
    #import "PTFormattedString.h"		//An object that contains an NSString and the appropriate PTStringFormat.
    #import "PTGlossyView.h"			//Draws a view with an Aqua style gloss over it.	
    #import	"PTNavigationBar.h"			//Draws a better UInavigationBar than Apple's bar, but will still draw Apple's bar if desired.
    #import "PTProgressHUD.h"			//Convenience UIProgressHUD that auto performs its methods on the main thread.
    #import "PTRoundedRectangleView.h"	//Convenience UIView that draws as a Rounded Rect
    #import "PTShinyLabel.h"			//Draws a label with a gradient applied only to the text.
    #import "PTTableViewColoredCell.h"	//UITableViewCell subclass that allows for easy coloring. Auto adds separators
    #import "PTTableViewColoredLabelCell.h"	//PTTableViewColoredCell subclass with UILabel
    #import "PTTableViewTextAndSubtextCell.h"	//Speedy table cell that replaces all the cell's UILabels and manually draws strings
    
    #endif //__PocketTouchFramework__
    Combined Additions Headers
    Code:
    /*
     *  UIKit-UndocumentedAdditions.h
     *  PocketTouch
     *
     *  Created by Skylar Cantu on 5/10/09.
     *  Copyright 2009 Skylar Cantu. All rights reserved.
     *
     *	A series of method prototypes that exist solely to 
     *	get rid of warnings that pop up while using undocumented
     *	methods of public classes
     */
    
    #ifndef __UIKIT_UNDOCUMENTEDADDITIONS_H__
    #define __UIKIT_UNDOCUMENTEDADDITIONS_H__
    
    @interface UIApplication (UndocumentedAdditions)
    - (void)setSystemVolumeHUDEnabled:(BOOL)enabled;
    @end
    
    @interface UIScrollView (UndocumentedAdditions)
    - (void)setShowBackgroundShadow:(BOOL)show;
    @end
    
    @interface UISwitch (UndocumentedAdditions)
    - (void)setAlternateColors:(BOOL)alternateColors;
    @end
    
    @interface UIView (UndocumentedAdditions)
    - (void)setOrigin:(CGPoint)origin;
    @end
    @class UIScroller;
    @interface UIWebView (UndocumentedAdditions)
    - (UIScroller *)_scroller;
    - (void)_setCheckeredPatternEnabled:(BOOL)enabled;
    - (void)_setDrawsCheckeredPattern:(BOOL)draws;
    @end
    
    #endif //__UIKIT_UNDOCUMENTEDADDITIONS_H__
    
    
    //
    //  NSDictionary-PocketTouchAdditions.h
    //  PocketTouch
    //
    //  Created by Skylar Cantu on 5/10/09.
    //  Copyright 2009 Skylar Cantu. All rights reserved.
    //
    
    #import <Foundation/Foundation.h>
    
    @interface NSDictionary (PocketTouchAdditions)
    - (BOOL)writeToDocumentsWithName:(NSString *)name;
    @end
    
    
    //
    //  UIViewController-PocketTouchAdditions.h
    //  PocketTouch
    //
    //  Created by Skylar Cantu on 5/13/09.
    //  Copyright 2009 Skylar Cantu. All rights reserved.
    //
    
    #import <UIKit/UIKit.h>
    
    //TODO Check compliance with:
    //- (void)presentModalViewController:(UIViewController *)modalViewController animated:(BOOL)animated; // Display another view controller as a modal child. Uses a vertical sheet transition if animated.
    //- (void)dismissModalViewControllerAnimated:(BOOL)animated;
    @interface UIViewController (PocketTouchAdditions) 
    - (void)presentModalViewController:(UIViewController *)viewController;
    - (void)presentModalViewController:(UIViewController *)viewController animated:(BOOL)animated;
    - (void)dismissModalViewController:(UIViewController *)viewController;
    - (void)dismissModalViewController:(UIViewController *)viewController animated:(BOOL)animated;
    @end
    PTMusicController.h
    Code:
    //
    //  PTMusicController.h
    //  PocketTouch
    //
    //  Created by Skylar Cantu on 3/31/09.
    //  Copyright 2009 __MyCompanyName__. All rights reserved.
    //
    
    #import <MediaPlayer/MediaPlayer.h>
    #import "VolumeController.h"
    
    #if TARGET_IPHONE_SIMULATOR
    @class MPMediaQuery, MPMusicPlayerController;
    #endif //TARGET_IPHONE_SIMULATOR
    
    @interface PTMusicController : NSObject {
    	MPMediaQuery		*query;
    	int					queryCount;
    	float				lastVolume;
    	int					lastTime;
    
    	BOOL				isPlaying;
    	BOOL				isPaused;
    	BOOL				isStopped;
    	NSArray				*trackInfo;
    }
    
    @property (readonly, getter=getPlayingStatus) BOOL isPlaying;
    @property (readonly, getter=getPausedStatus) BOOL isPaused;
    @property (readonly, getter=getStoppedStatus) BOOL isStopped;
    @property (nonatomic, readonly, getter=readTrackInfo) NSArray *trackInfo;
    @property (nonatomic, retain, setter=setQuery:) MPMediaQuery *query;
    
    - (id)init;
    - (int)playOrPauseSong;
    - (void)playNextSong;
    - (void)playPreviousSong;
    - (void)playRandomSong;
    - (void)playSong:(MPMediaItem *)song;
    - (float)raiseVolume:(float)_volumeSensitivity fromVolume:(float)_currentVolume;
    - (float)lowerVolume:(float)_volumeSensitivity fromVolume:(float)_currentVolume;
    - (NSArray *)readTrackInfo;
    - (NSString *)updatedTime;		//Returns the time preformatted into time format, ie, MM:SS (or HH:MM:SS if necessary)
    - (UIImage *)getAlbumArtWithSize:(CGSize)artSize;
    
    @end
    PTColorConverter.h
    Code:
    //
    //  PTColorConverter.h
    //  PocketTouch
    //
    //  Created by Skylar Cantu on 5/6/09.
    //  Copyright 2009 Skylar Cantu. All rights reserved.
    //
    
    #import <Foundation/Foundation.h>
    
    #import "Global.h"
    #import "PrivateColors.h"
    
    @class UIColor;
    
    @interface PTColorConverter : NSObject {
    }
    
    + (UIColor *)undefinedColor;
    + (UIColor *)colorFromInteger:(int)colorInt;
    + (UIColor *)colorFromInteger:(int)colorInt withUndocumentedAdditions:(BOOL)additions;
    + (UIColor *)colorFromInteger:(int)colorInt withUndocumentedAdditions:(BOOL)additions usesAllColors:(BOOL)allColors;
    + (UIColor *)colorWithRGBArray:(NSArray *)rgbArray;
    + (UIColor *)colorWithRGBAArray:(NSArray *)rgbaArray;
    + (UIColor *)convertColorFromGrayScaleToRGBIfNecessary:(UIColor *)color;
    + (UIColor *)lightenColor:(UIColor *)color byFactor:(CGFloat)factor;
    + (UIColor *)darkenColor:(UIColor *)color byFactor:(CGFloat)factor;
    
    @end
    PTHelpController.h
    Code:
    //
    //  SettingsHelpWebController.h
    //  PocketTouch
    //
    //  Created by Skylar Cantu on 3/27/09.
    //  Copyright 2009 __MyCompanyName__. All rights reserved.
    //
    
    /*		PTHelpControllers are desgned to be nested
    		Opening a new local web page will cause the
    		controller to spawn a new instance of itself
    		and push that to the top of the stack
     
    		Given the nature of its pushing/popping, the 
    		controller MUST, MUST, MUST be in a 
    		UINavigationController.
    															*/
    
    /*		Files located locally are handled differently 
    		from files loaded from the internet.
     
    		Local files will load and there will be no scroller
    		shadow.  This is to emulate the appearance of the 
    		standard UITableView.  Links to other local files
    		will cause a new PTHelpController to be spawned and
    		pushed to the top of the stack.  Local pages have 
    		their title displayed as the UINavigationBar only, 
    		their location on the device is not displayed.
     
    		Internet loaded pages will have the standard UIWebView
    		shadow applied.  Pages loaded form the internet will
    		have their title displayed on the UINavigationBar and
    		will have their location present as a UINavigationBar
    		prompt.  They are not pushed in a new controller, but
    		reloaded into the current controller.
     
    															*/
    
    #import <QuartzCore/QuartzCore.h>
    #import <UIKit/UIKit.h>
    
    #import "Global.h"
    
    @interface PTHelpController : UIViewController <UIWebViewDelegate> {
    	NSURLRequest	*_request;
    	BOOL			isFirstLoad;		//Flag that is raised on the webview's first load, but is turned off for all other loads
    	BOOL			isVisible;			//YES is this is the current visible PTHelpController
    	UIWebView		*helpWebView;
    	UIBarButtonItem	*backButton;
    	UIBarButtonItem	*refreshButton;
    	BOOL			hasAboutButton;		//Should we create an about button?		//Button is a UIBarButtonItem
    	BOOL			showAboutButton;	//Should we show our about button?
    	BOOL			doneLoading;		//Is the web page done laoding?
    	BOOL			backButtonPressed;
    	BOOL			stopButtonPressed;
    	BOOL			currentPageIsWebPage;	//Page from the web as opposed to a local page //TODO: Change verbiage
    	BOOL			animationStarted;
    	int				loadingStatus;		//Used for displaying Loading...
    }
    
    - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil andLoadRequest:(NSURLRequest *)request;
    //	If no loadRequest is provided, the PTHelpController will look for your help page using this command:
    //	[NSString pathWithComponents:[NSArray arrayWithObjects:[[NSBundle mainBundle] bundlePath], @"HTML", @"Help.html", nil]]
    //	If you go this route, make sure to keep a folder in your application called HTML, and in that, include an html file called Help.html
    //  If you do provide your own request, then you can store your own HTML anywhere in or out of your application that you like.
    
    @end
    PTFormattedString.h
    Code:
    //
    //  PTFormattedString.h
    //  PocketTouch
    //
    //  Created by Skylar Cantu on 5/19/09.
    //  Copyright 2009 Skylar Cantu. All rights reserved.
    //
    
    #import <Foundation/Foundation.h>
    
    typedef enum {
    	PTStringFormatPlain,
    	PTStringFormatBold,
    	PTStringFormatItalic,
    	PTStringFormatBoldItalics
    } PTStringFormat;
    
    @interface PTFormattedString : NSObject {
    	NSString *text;
    	PTStringFormat format;
    }
    
    @property (nonatomic, retain) NSString *text;
    @property (nonatomic) PTStringFormat format;
    
    - (PTFormattedString *)initWithString:(NSString *)inStr andFormat:(PTStringFormat)fmt;
    
    @end
    PTGlossyView.h
    Code:
    //
    //  PTStatusBar.h
    //  PocketTouch
    //
    //  Created by Skylar Cantu on 3/30/09.
    //  Copyright 2009 __MyCompanyName__. All rights reserved.
    //
    
    
    #import <UIKit/UIKit.h>
    
    #include "Global.h"
    #include "GlossColors.h"
    #include "PTColorConverter.h"
    
    @interface PTGlossyView : UIView {
    	UIColor			*backgroundColor;
    	CGShadingRef	mShading;
    	CGFunctionRef	mGradientFunction;
    	CGColorSpaceRef mColorspace;
    	GlossParameters mParams;
    }
    
    @property(nonatomic, retain) UIColor *backgroundColor;
    
    @end
    PTNavigationBar.h
    Code:
    //
    //  PTNavigationBar.h
    //  PocketTouch
    //
    //  Created by Skylar Cantu on 5/5/09.
    //  Copyright 2009 Skylar Cantu. All rights reserved.
    //
    
    #import <UIKit/UIKit.h>
    
    #include "Global.h"
    #include "GlossColors.h"
    #include "PTColorConverter.h"
    
    @interface PTNavigationBar : UINavigationBar {
    	UIColor			*tintColor;
    	CGShadingRef	mShading;
    	CGFunctionRef	mGradientFunction;
    	CGColorSpaceRef mColorspace;
    	GlossParameters mParams;
    }
    
    - (void)addShadow;
    
    @property (nonatomic, retain) UIColor *tintColor;
    
    @end
    PTProgressView.h
    Code:
    //
    //  PTProgressHud.h
    //  PocketTouch
    //
    //  Created by Skylar Cantu on 5/10/09.
    //  Copyright 2009 Skylar Cantu. All rights reserved.
    //
    //	Subclassed implementation of UIProgressHUD that
    //	automatically calls its methods on the main thread.
    //
    
    #import <UIKit/UIKit.h>
    
    @interface UIProgressHUD : NSObject
    - (id)_progressIndicator;
    - (id)initWithFrame:(struct CGRect)fp8;
    - (void)setText:(id)fp8;
    - (void)setShowsText:(BOOL)fp8;
    - (void)setFontSize:(int)fp8;
    - (void)drawRect:(struct CGRect)fp8;
    - (void)layoutSubviews;
    - (void)showInView:(id)fp8;
    - (void)hide;
    - (void)done;
    - (void)dealloc;
    @end
    
    @interface PTProgressHUD : UIProgressHUD {
    	UIView *parentView;
    }
    
    - (void)showInsideOfView:(UIView *)view;
    - (void)updateHUDTextWithText:(NSString *)HUDText;
    - (void)hideHUD;
    - (void)setHUDDone;
    
    @end
    PTRoundedRectangleView.h
    Code:
    //
    //  LabelContainerView.h
    //  PocketTouch
    //
    //  Created by Skylar Cantu on 3/26/09.
    //  Copyright 2009 __MyCompanyName__. All rights reserved.
    //
    
    #import <UIKit/UIKit.h>
    
    @interface PTRoundedRectangleView : UIView {
    	CGFloat red;
    	CGFloat green;
    	CGFloat blue;
    	CGFloat alpha;
    	CGFloat sred;
    	CGFloat sgreen;
    	CGFloat sblue;
    	CGFloat salpha;
    	CGFloat _width;
    	BOOL	_stroke;
    }
    
    - (void)setColor:(UIColor *)color;
    - (void)setRed:(CGFloat)_red green:(CGFloat)_green blue:(CGFloat)_blue alpha:(CGFloat)_alpha;
    - (void)setStrokeColor:(UIColor *)color;
    - (void)strokesPath:(BOOL)stroke withWidth:(CGFloat)width;
    
    PTStringFormatter.h
    Code:
    //
    //  PTStringFormatter.h
    //  PocketTouch
    //
    //  Created by Skylar Cantu on 5/19/09.
    //  Copyright 2009 Skylar Cantu. All rights reserved.
    //
    
    /*		
    		Acceptable tags are
    		[BOLD][/BOLD],
    		[ITALIC][/ITALIC]		*/
    
    
    #import <Foundation/Foundation.h>
    #import "Global.h"
    #import "PTFormattedString.h"
    
    
    #define BOLDTAG @"BOLD"
    #define BOLDLENGTH 4
    #define BOLDTAGLENGTH 6
    #define BOLDTAGCLOSELENGTH 7
    #define ITALTAG @"ITALICS"
    #define ITALLENGTH 7
    #define ITALTAGLENGTH 9
    #define ITALTAGCLOSELENGTH 10
    
    @interface PTStringFormatter : NSObject {
    }
    
    + (NSArray *)arrayOfFormattedSubstringsFromString:(NSString *)inStr;	//Returns an array of PTFormattedStrings;
    
    @end
    PTTableViewColoredCell.h
    Code:
    //
    //  PTTableViewCell.h
    //  PocketTouch
    //
    //  Created by Skylar Cantu on 5/11/09.
    //  Copyright 2009 Skylar Cantu. All rights reserved.
    //
    
    #import <QuartzCore/QuartzCore.h>
    #import <UIKit/UIKit.h>
    #import "PTColorConverter.h"
    
    typedef enum  {
        PTGroupedTableViewCellGroupPositionTop, 
        PTGroupedTableViewCellGroupPositionMiddle, 
        PTGroupedTableViewCellGroupPositionBottom,
        PTGroupedTableViewCellGroupPositionSingle
    } PTGroupedTableViewCellGroupPosition;
    
    @interface PTTableViewColoredCell: UITableViewCell {
    	BOOL		drawsSeparator;
    	UIColor 	*cellColor;
    	BOOL		isGroupCell;
    	CALayer	*gtcLayer;
    @private
    	BOOL	addedToTableAtLeastOnce;
    }
    
    @property (nonatomic) BOOL drawsSeparator;		//Defaults to YES;
    @property (nonatomic, retain, setter=setCellColor:) UIColor *cellColor;
    
    @end
    PTTableViewColoredLabelCell.h
    Code:
    //
    //  PTTableViewColoredLabelCell.h
    //  PocketTouch
    //
    //  Created by Skylar Cantu on 5/12/09.
    //  Copyright 2009 Skylar Cantu. All rights reserved.
    //
    
    #import "PTTableViewColoredCell.h"
    #import <UIKit/UIKit.h>
    
    @interface PTTableViewColoredLabelCell : PTTableViewColoredCell {
    	UILabel *textLabel;
    }
    
    @property (nonatomic, retain) UILabel *textLabel;
    
    @end
    PTTableViewTextAndSubtextCell.h
    Code:
    //
    //  PTTableTextAndSubtextCell.h
    //  PocketTouch
    //
    //  Created by Skylar Cantu on 5/12/09.
    //  Copyright 2009 Skylar Cantu. All rights reserved.
    //
    
    #import "PTTableViewColoredCell.h"
    #import <UIKit/UIKit.h>
    
    @interface PTTableViewTextAndSubtextCell : PTTableViewColoredCell {
    	NSString *title;
    	NSString *subTitle;
    }
    
    @property (nonatomic, retain, setter=setTitleString:) NSString *title;
    @property (nonatomic, retain, setter=setSubtitleString:) NSString *subTitle;
    
    @end
    
  2. SkylarEC

    SkylarEC Super Moderator Emeritus Staff Member

    Joined:
    Sep 19, 2007
    Messages:
    6,642
    Likes Received:
    129
    Some sample images. Of course, when you use (or subclass and use) these, they may look wildly different. Your imagination is paramount.

    PTFormattedString:

    Please Register or Log in to view images


    What you are looking at is ONE string with tags.

    PTGlossyView:

    Please Register or Log in to view images



    PTHelpController:

    Please Register or Log in to view images



    PTNavigationBar:

    Please Register or Log in to view images



    PTProgressHUD:

    Please Register or Log in to view images



    PTRoundedRectangleView:

    Please Register or Log in to view images



    PTShinyLabel:

    Please Register or Log in to view images

  3. SkylarEC

    SkylarEC Super Moderator Emeritus Staff Member

    Joined:
    Sep 19, 2007
    Messages:
    6,642
    Likes Received:
    129
    AND I am giving serious thought to adding my image converter to the PocketTouch framework, although it isn't necessary to add it. I may not.

    IPFImageManipulater.h [Will become PTImageManipulator if added]:
    Code:
    - (CGBlendMode)translateBlendModeFromInt:(int)intValue;
    
    - (UIImage *)convertToBlackAndWhite:(UIImage *)anImage;
    - (UIImage *)convertToSepiaTone:(UIImage *)anImage;
    - (UIImage *)convertToRedTone:(UIImage *)anImage;
    - (UIImage *)convertToGreenTone:(UIImage *)anImage;
    - (UIImage *)convertToBlueTone:(UIImage *)anImage;
    
    - (UIImage *)addBlackAndWhiteOverlay:(UIImage *)anImage;
    - (UIImage *)addSepiaOverlay:(UIImage *)anImage;
    - (UIImage *)addRedOverlay:(UIImage *)anImage;
    - (UIImage *)addGreenOverlay:(UIImage *)anImage;
    - (UIImage *)addBlueOverlay:(UIImage *)anImage;
    
    - (UIImage *)blendBlackAndWhite:(UIImage *)anImage;
    - (UIImage *)blendSepia:(UIImage *)anImage;
    - (UIImage *)blendRed:(UIImage *)anImage;
    - (UIImage *)blendGreen:(UIImage *)anImage;
    - (UIImage *)blendBlue:(UIImage *)anImage;
    
    - (UIImage *)rotateImageClockwise:(UIImage *)anImage;
    - (UIImage *)rotateImageCounterClockwise:(UIImage *)anImage;
    - (UIImage *)flipHorizontal:(UIImage *)anImage;
    - (UIImage *)flipVertical:(UIImage *)anImage;
    - (UIImage *)lightenImage:(UIImage *)anImage;
    - (UIImage *)darkenImage:(UIImage *)anImage;
    
    - (UIImage *)convertToVariableMonochrome:(UIImage *)anImage;
    
    - (UIImage *)applyImageOverlay:(UIImage *)anImage toImage:(UIImage *)baseImage withOffsetSize:(float)offsetSize;
    - (UIImage *)drawTextLabel:(UILabel *)label toImage:(UIImage *)baseImage withFontSize:(int)fontSize;
    Obviously, I only included a bit of the header, but enough to give you an idea.
  4. Steaps

    Steaps New Member

    Joined:
    Oct 24, 2007
    Messages:
    5,074
    Likes Received:
    41
    Device:
    iPod touch
    Looks great! Can't wait for some of these (Rounded rectangle UIView

    Please Register or Log in to view images

    ).
  5. bamhm182

    bamhm182 Member

    Joined:
    Mar 2, 2009
    Messages:
    544
    Likes Received:
    0
    Device:
    3G iPod touch
    Just an idea, but will you be able to put it out on the App Store once 3.0 drops? If so, you should do that. I'm going to be jailbreaking my 3.0 ASAP, but PocketTouch is a GREAT app and people without jailbroken devices should be able to use it as well. If I'm not mistaken, 3.0 allows Apps to manage your music, so this idea doesn't seem too farfetched, unless I'm wrong about that last bit.

    Either way, can't wait for it. From the screenshots and code, it looks like a great improvement from the previous PocketTouch.
  6. NolesFans

    NolesFans New Member

    Joined:
    Sep 23, 2008
    Messages:
    404
    Likes Received:
    0
    Device:
    iPod touch
    One of the Apple SDK restrictions said "No custom framework." Since PocketTouch is a custom framework, Apple would denied any application to uses it.
  7. Steaps

    Steaps New Member

    Joined:
    Oct 24, 2007
    Messages:
    5,074
    Likes Received:
    41
    Device:
    iPod touch
    Skylar is creating Pocket Touch for the App Store.
    Since custom frameworks are banned, he's probably using the official SDK frameworks for 3.0 to allow music access.
    Looks like an awesome application.

Share This Page