How to enable emoji on iPhone (programatically)

November 7, 2009 vinaychavan22 Leave a comment

Emoji is the Japanese term for the picture characters or emoticons used in Japanese wireless messages and webpages. Originally meaning pictograph, the word literally means e “picture” + moji “letter”. The characters are used much like emoticons elsewhere, but a wider range is provided, and the icons are standardized and built into the handsets. The three main Japanese operators, NTT DoCoMo, au and SoftBank Mobile (formerly Vodafone), have each defined their own variants of emoji. – Wikipedia

emoji keypad iPhone

Ok enough of this….Lets see how to enable this keyboard to be used everywhere. (By default this keyboard is only works on iPhones from Japan)

Step1:

 

- (void)enableEmoji {

#define kPreferencesFilePath @"/private/var/mobile/Library/Preferences/com.apple.Preferences.plist"

#define kEmojiKey @"KeyboardEmojiEverywhere"

NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithContentsOfFile:kPreferencesFilePath];

if (!dict) return;

// Toggle the setting from on to off or vice versa

BOOL isSet = [[dict objectForKey:kEmojiKey] boolValue];

if (!isSet) {

[dict setObject:[NSNumber numberWithBool:YES] forKey:kEmojiKey];

[dict writeToFile:kPreferencesFilePath atomically:NO];

}

}

 

Note: This code does not work on iPhone Simulators, Works only on devices.

Step2: After running this code for once, go into “Settings” > “General” > “Keyboard” > “Japanese Keyboard”. Enable the “Emoji” keyboard.

Step3: Open any Notes.app & see the magic.

Flipping bar button like iTunes

September 3, 2009 vinaychavan22 1 comment

This is the example for how to create flipping bar button like iTunes. I faced the same problem while developing solutions for first time, after looking at iTunes app more closely..it seems the flipping thing in Navigation Bar is not a BarButton but button with images ( It does not show highlighted effect ).

Image showing flipping view

Image showing flipping view

All we need to do is use custom UIBarButtonItem with CustomView for this.

Step 1: Create UIBarButton with CustomView

//initialize bar button views

barButtonSuperView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 34, 30)];

barButtonPrimaryView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 34, 30)];

UIButton * primaryButton = [UIButton buttonWithType:UIButtonTypeCustom];

primaryButton.frame = CGRectMake(0, 0, 34, 30);

[primaryButton setBackgroundColor:[UIColor greenColor]];

[primaryButton addTarget:self action:@selector(flipAction:) forControlEvents:UIControlEventTouchUpInside];

[barButtonPrimaryView addSubview:primaryButton];

barButtonSecondaryView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 34, 30)];

UIButton * secondaryButton = [UIButton buttonWithType:UIButtonTypeCustom];

secondaryButton.frame = CGRectMake(0, 0, 34, 30);

[secondaryButton setBackgroundColor:[UIColor redColor]];

[secondaryButton addTarget:self action:@selector(flipAction:) forControlEvents:UIControlEventTouchUpInside];

[barButtonSecondaryView addSubview:secondaryButton];

// self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithCustomView:barButtonSuperView] autorelease];

UIView * barButtonSuperSuperView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 34, 30)];

barButtonSuperSuperView.backgroundColor = [UIColor viewFlipsideBackgroundColor];

[barButtonSuperSuperView addSubview:barButtonSuperView];

self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithCustomView:barButtonSuperSuperView] autorelease];

[barButtonSuperSuperView release], barButtonSuperSuperView = nil;

Step 2: Use UIView transition effects

[UIView beginAnimations:@"BarButtonViewAnimation" context:NULL];

[UIView setAnimationDuration:kTransitionDuration];

[UIView setAnimationTransition:([barButtonPrimaryView superview] ?

UIViewAnimationTransitionFlipFromLeft : UIViewAnimationTransitionFlipFromRight)

forView:barButtonSuperView cache:YES];

if ([barButtonPrimaryView superview])

{

[barButtonPrimaryView removeFromSuperview];

[barButtonSuperView addSubview:barButtonSecondaryView];

}

else

{

[barButtonPrimaryView removeFromSuperview];

[barButtonSuperView addSubview:barButtonPrimaryView];

}

[UIView commitAnimations];


Here is the complete demo code. link

UITableViewCell Selection

August 15, 2009 vinaychavan22 Leave a comment

I have seen many many applications so far, i mean really awesome applications. Still one thing  i see which is almost common with all of them except few one is that Custom UITableViewCells does not change text color when selected/highlighted. I am also a developer and i know these kind of things miss out while developing applications in rapid development cycles and under timeline pressure :(. but then it really shows high level of ignorance from developers side.

The solution is simple. Generally what we do is we create custom UIView and add it inside UITableViewCell. Just we need to do some extra coding in UIView. as shown in TableViewSuite.

CustomCellView.h

#import <UIKit/UIKit.h>

@interface CustomCellView : UIView {

BOOL highlighted;

}

@property (nonatomic, getter=isHighlighted) BOOL highlighted;

@end

CustomCellView.m

#import "CustomCellView.h"

@implementation CustomCellView

@synthesize highlighted;

- (id)initWithFrame:(CGRect)frame {

if (self = [super initWithFrame:frame]) {

// Initialization code

}

return self;

}

- (void)setHighlighted:(BOOL)isHighlighted {

// If highlighted state changes, need to redisplay.

if (highlighted != isHighlighted) {

highlighted = isHighlighted;

[self setNeedsDisplay];

}

}

- (void)drawRect:(CGRect)rect {

UIColor *nameTextColor;

if( self.highlighted ) {

nameTextColor = [UIColor whiteColor];

}else {

nameTextColor = [UIColor blackColor];

}

// Draw code

}

- (void)dealloc {

[super dealloc];

}

@end

Happy Coding..

Socha hai(Rock On) tabs

August 1, 2009 vinaychavan22 1 comment

I didn find good tabs for it anywhere so here i am posting my own version…

PART1
E--5----------------------------------------------------
B--7--------------------------3--------------2-3--------
G--7------4~----4-6-7---------2--0-2-4-----4-----2h4p2--
D--5--5-7-------------7h9p7~~---------------------------
A--5----------------------------------------------------
E--5----------------------------------------------------

PART2
E-------------------------------------
B---3-3-3-3-3-3-3-3-3-3-3-3-3-3-3-3---
G----2-2-2-2-0-0-0-0-4-4-4-4-2-2-2-2--
D-------------------------------------
A-------------------------------------
E-------------------------------------

PART1 & PART2 together 2 times

D
aasma hai neela kyun
Bm
paani geela geela kyun
G            A
gol kyun hai zamee
D
silk mein hai narmi kyun
Bm
aag mein hai garmi kyun
G                A
do aur do paanch kyun nahi
.. and so on

Very soon ill be posting full version. :)

YMSG16 Authentication

The new Yahoo messenger v9.0 uses ymsg 16 protocol. For login process client sends username and password to yahoo login server: https://login.yahoo.com, and in response server sends Token which is then used for client authentication process on scs.msg.yahoo.com:5050
This login process goes through multiple steps as follows..

Step 1: Send username and password to login server

Https request url:
https://login.yahoo.com/config/pwtoken_get?src=ymsgr&login=<username>&passwd=<password>
Https response and meaning:

  • Invalid username  : 1235
  • Wrong password  : 1212
  • Information Valid : 0 ymsgr= <token>partnerid=<pid>

data is used in step 2 for further processing.
Note: and seem to appear in pair for given username and password

Step 2: Send token to login server

Https request url:
https://login.yahoo.com/config/pwtoken_login?src=ymsgr&token=<token>
Https response and meaning:

  • Invalid ymsgr  : 100
  • Information Valid : 0 crumb=<crumb> Y=<Y-Cookie> T=<T-Cookie> cookievalidfor=

<crumb>, <Y_Cookie>, <T_Cookie> and <B_Cookie> are used in client authentication on receiving challenge string from Pager server.
Note: is received in header of the reponse.

Step 3: After receiving challenge string from pager server

When client receives challenge string from pager server, it sends encrypted response to server. This response is formed using received in Step 2 and challenge received from pager server.
Process for forming response:

  • crypt = crumb + challenge
  • hash = MD5(crypt)
  • response = BASE64(hash)
  • replace ‘+’ by ‘.’ in response
  • replace ‘/’ by ‘_’ in response
  • replace ‘=’ by ‘-’ in response

Client sends this calculated response for received challenge along with <Y_Cookie>, <T_Cookie> and <B_Cookie>.