Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Initial commit

  • Loading branch information...
commit b7cc20ba9894d78c8d901cd1d796ea33bc225e13 0 parents
Ryan Petrich authored January 24, 2011
7  .gitignore
... ...
@@ -0,0 +1,7 @@
  1
+._*
  2
+*.deb
  3
+.debmake
  4
+_
  5
+obj
  6
+.theos
  7
+.DS_Store
3  .gitmodules
... ...
@@ -0,0 +1,3 @@
  1
+[submodule "framework"]
  2
+	path = framework
  3
+	url = git://github.com/rpetrich/theos.git
70  KBThemer.m
... ...
@@ -0,0 +1,70 @@
  1
+#import <UIKit/UIKit.h>
  2
+#import <CoreGraphics/CoreGraphics.h>
  3
+#import <substrate.h>
  4
+
  5
+extern CGColorRef UIKBGetNamedColor(CFStringRef gradientName);
  6
+
  7
+#define kColorSettingsPath @"/var/mobile/Library/Preferences/com.rpetrich.kbthemer.colors.plist"
  8
+
  9
+static NSMutableDictionary *colorSettings;
  10
+static CFMutableDictionaryRef namedColors;
  11
+
  12
+MSHook(CGColorRef, UIKBGetNamedColor, CFStringRef colorName)
  13
+{
  14
+	if (!namedColors) {
  15
+		namedColors = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
  16
+		colorSettings = [[NSMutableDictionary alloc] initWithContentsOfFile:kColorSettingsPath];
  17
+		if (colorSettings) {
  18
+			CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
  19
+			for (NSString *settingName in [colorSettings allKeys]) {
  20
+				NSArray *c = [colorSettings objectForKey:settingName];
  21
+				const CGFloat components[] = { [[c objectAtIndex:0] floatValue], [[c objectAtIndex:1] floatValue], [[c objectAtIndex:2] floatValue], [[c objectAtIndex:3] floatValue] };
  22
+				CGColorRef color = CGColorCreate(colorSpace, components);
  23
+				CFDictionarySetValue(namedColors, settingName, color);
  24
+				CFRelease(color);
  25
+			}
  26
+			CGColorSpaceRelease(colorSpace);
  27
+		} else {
  28
+			colorSettings = [[NSMutableDictionary alloc] init];
  29
+		}
  30
+	}
  31
+	CGColorRef result = (CGColorRef)CFDictionaryGetValue(namedColors, colorName);
  32
+	if (!result) {
  33
+		result = _UIKBGetNamedColor(colorName);
  34
+		CFDictionarySetValue(namedColors, colorName, result);
  35
+		CGFloat components[4];
  36
+		const CGFloat *colorComponents = CGColorGetComponents(result);
  37
+		size_t count = CGColorGetNumberOfComponents(result);
  38
+		switch (count) {
  39
+			case 4:
  40
+				components[3] = colorComponents[3];
  41
+				components[2] = colorComponents[2];
  42
+				components[1] = colorComponents[1];
  43
+				components[0] = colorComponents[0];
  44
+				break;
  45
+			case 2:
  46
+				components[3] = colorComponents[1];
  47
+				components[2] = colorComponents[0];
  48
+				components[1] = colorComponents[0];
  49
+				components[0] = colorComponents[0];
  50
+				break;
  51
+			default:
  52
+				return result;
  53
+		}
  54
+		NSArray *c = [NSArray arrayWithObjects:
  55
+			[NSNumber numberWithFloat:components[0]],
  56
+			[NSNumber numberWithFloat:components[1]],
  57
+			[NSNumber numberWithFloat:components[2]],
  58
+			[NSNumber numberWithFloat:components[3]],
  59
+		nil];
  60
+		[colorSettings setObject:c forKey:(id)colorName];
  61
+		[colorSettings writeToFile:kColorSettingsPath atomically:YES];
  62
+	}
  63
+	return result;
  64
+}
  65
+
  66
+__attribute__((constructor))
  67
+static void constructor()
  68
+{
  69
+	MSHookFunction(&UIKBGetNamedColor, $UIKBGetNamedColor, (void **)&_UIKBGetNamedColor);
  70
+}
8  Makefile
... ...
@@ -0,0 +1,8 @@
  1
+TWEAK_NAME = KBThemer
  2
+KBThemer_FILES = KBThemer.m
  3
+KBThemer_FRAMEWORKS = Foundation UIKit CoreGraphics
  4
+
  5
+ADDITIONAL_CFLAGS = -std=c99
  6
+
  7
+include framework/makefiles/common.mk
  8
+include framework/makefiles/tweak.mk
1  framework
... ...
@@ -0,0 +1 @@
  1
+Subproject commit f33d1d531dc2ec1baa450c9a29880a3314ee21dd
9  layout/DEBIAN/control
... ...
@@ -0,0 +1,9 @@
  1
+Package: com.rpetrich.kbthemer
  2
+Priority: optional
  3
+Section: Tweaks
  4
+Architecture: iphoneos-arm
  5
+Version: 0.1
  6
+Description: Theme the keyboard
  7
+Name: KBThemer
  8
+Depends: firmware (>= 4.0), mobilesubstrate
  9
+Author: Ryan Petrich <rpetrich+kbthemer@gmail.com>
1  layout/Library/MobileSubstrate/DynamicLibraries/KBThemer.plist
... ...
@@ -0,0 +1 @@
  1
+Filter = {Bundles = ("com.apple.UIKit");};
23  notes.txt
... ...
@@ -0,0 +1,23 @@
  1
+-[UIPeripheralHost setInputViews:]
  2
+-[UIKeyboardImpl updateLayout]
  3
+-[UIKeyboardImpl callLayoutUpdateLocalizedKeys]
  4
+-[UIKeyboardLayoutStar initWithFrame:]
  5
+
  6
+UIKBDrawKeyboardBackground(CGContextRef c, something...);
  7
+CGColorRef UIKBGetNamedColor(CFStringRef colorName);
  8
+UIKBColorDefLookup(chat *)
  9
+CGColorRef UIKBColorCreate(int r, int g, int b);
  10
+void UIKBAddRoundedRect(CGContextRef c);
  11
+CGGradient UIKBGetNamedLinearGradient(NSString *gradientName);
  12
+void UIKBDrawLinearGradient(CGContextRef c, CGGradientRef g);
  13
+void UIKBDrawKey(CGContextRef c, UIKBKeyboard *keyboard, UIKBKey *key, int);
  14
+void UIKBDrawStringKey(CGContextRef c, UIKBKeyboard *keyboard, UIKBKey *key, int);
  15
+void UIKBDrawStringKey_iPhone(CGContextRef c, UIKBKeyboard *keyboard, UIKBKey *key, int);
  16
+void UIKBDrawRoundRectKeyBackground(CGContextRef c, UIKBKeyboard *keyboard, UIKBKey *key, int);
  17
+void UIKBDrawRoundRectKeyBackground_iPhone(CGContextRef c, UIKBKeyboard *keyboard, UIKBKey *key, int);
  18
+void *UIKBThemeCreate(UIKBKeyboard *keyboard, UIKBKey *key);
  19
+UIKBThemeInit_iPhone
  20
+CGGradientRef UIKBThemeGetForegroundGradient(UIKBThemeRef theme)
  21
+uint32_t UIKBScale() == 0x4000 0000
  22
+void *UIKBDrawEtchedSymbolString(CGContextRef context, NSString *string);
  23
+void UIKBKeyboardDrawOverlay(CGContextRef context);

0 notes on commit b7cc20b

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