+++ /dev/null
-#import <Foundation/Foundation.h>
-
-extern "C" {
- #include <mach-o/nlist.h>
-}
-
-#include <unistd.h>
-#include <dlfcn.h>
-
-#include <mach/mach_init.h>
-#include <mach/vm_map.h>
-
-extern "C" void __clear_cache (char *beg, char *end);
-
-extern "C" CFStringRef CPPhoneNumberCopyNetworkCountryCode();
-
-static void ASReplace(void *symbol, void *replace) {
- //NSLog(@"AS:Notice: Remapping %p to %p", symbol, replace);
- if (symbol == NULL)
- return;
-
- int page = getpagesize();
- uintptr_t base = (uintptr_t) symbol / page * page;
-
- mach_port_t self = mach_task_self();
-
- if (kern_return_t error = vm_protect(self, base, page, FALSE, VM_PROT_READ | VM_PROT_WRITE | VM_PROT_COPY)) {
- NSLog(@"AS:Error:vm_protect():%d", error);
- return;
- }
-
- uint32_t *code = (uint32_t *) symbol;
-
- code[0] = 0xe51ff004; // ldr pc, [pc, #-4]
- code[1] = (uint32_t) replace;
-
- __clear_cache(reinterpret_cast<char *>(code), reinterpret_cast<char *>(code + 2));
-
- if (kern_return_t error = vm_protect(self, base, page, FALSE, VM_PROT_READ | VM_PROT_EXECUTE))
- NSLog(@"AS:Error:vm_protect():%d", error);
-}
-
-/*static CFStringRef UIDefaultCountryCode_() {
- return CPPhoneNumberCopyNetworkCountryCode();
-}*/
-
-#define UIKit "/System/Library/Frameworks/UIKit.framework/UIKit"
-
-extern "C" void ASInitialize() {
- if (dlopen(UIKit, RTLD_LAZY | RTLD_NOLOAD) == NULL)
- return;
- //NSLog(@"AS:Notice: Installing AppSupport...");
-
- struct nlist nl[2];
- memset(nl, 0, sizeof(nl));
- nl[0].n_un.n_name = (char *) "_UIDefaultCountryCode";
- nlist(UIKit, nl);
- CFStringRef (*UIDefaultCountryCode)() = reinterpret_cast<CFStringRef (*)()>(nl[0].n_value);
- ASReplace(reinterpret_cast<void *>(UIDefaultCountryCode), reinterpret_cast<void *>(&CPPhoneNumberCopyNetworkCountryCode));
-
- //NSLog(@"AS:Notice: Done");
-}
--- /dev/null
+#include <substrate.h>
+
+#import <Foundation/NSArray.h>
+#import <Foundation/NSNull.h>
+#import <CoreGraphics/CGGeometry.h>
+#import <SpringBoard/SBButtonBar.h>
+#import <SpringBoard/SBIcon.h>
+
+@protocol Tweak
+- (float) fid_leftMarginForIconRowArray:(NSArray *)row;
+- (void) fid_setOrigin:(CGPoint)origin;
+- (float) fid_topIconPadding;
+@end
+
+static bool $SBButtonBar$$isCrowded(SBButtonBar<Tweak> *self) {
+ NSArray *matrix;
+ object_getInstanceVariable(self, "_iconMatrix", reinterpret_cast<void **>(&matrix));
+ NSArray *row([matrix objectAtIndex:0]);
+ return row != nil && [row indexOfObject:[NSNull null]] == NSNotFound;
+}
+
+static float $SBButtonBar$leftMarginForIconRowArray$(SBButtonBar<Tweak> *self, SEL sel, NSArray *row) {
+ return [row indexOfObject:[NSNull null]] == NSNotFound ? 4 : [self fid_leftMarginForIconRowArray:row];
+}
+
+static int $SBButtonBar$maxIconColumns(SBButtonBar<Tweak> *self, SEL sel) {
+ return 5;
+}
+
+static float $SBButtonBar$topIconPadding(SBButtonBar<Tweak> *self, SEL sel) {
+ float padding([self fid_topIconPadding]);
+ if ($SBButtonBar$$isCrowded(self))
+ --padding;
+ return padding;
+}
+
+static float $SBButtonBar$verticalIconPadding(SBButtonBar<Tweak> *self, SEL sel) {
+ return 0;
+}
+
+static void $SBIcon$setOrigin$(SBIcon<Tweak> *self, SEL sel, CGPoint origin) {
+ if (origin.y == 10)
+ origin.x = (origin.x - 4) / 76 * 63 + 4;
+ else if (origin.y == 84) {
+ origin.y -= 74;
+ origin.x = 256;
+ } else goto set;
+ ++origin.y;
+ set:
+ [self fid_setOrigin:origin];
+}
+
+extern "C" void TweakInitialize() {
+ if (objc_getClass("SpringBoard") == nil)
+ return;
+
+ Class $SBButtonBar(objc_getClass("SBButtonBar"));
+ MSHookMessage($SBButtonBar, @selector(leftMarginForIconRowArray:), (IMP) &$SBButtonBar$leftMarginForIconRowArray$, "fid_");
+ MSHookMessage($SBButtonBar, @selector(maxIconColumns), (IMP) &$SBButtonBar$maxIconColumns, "fid_");
+ MSHookMessage($SBButtonBar, @selector(topIconPadding), (IMP) &$SBButtonBar$topIconPadding, "fid_");
+ MSHookMessage($SBButtonBar, @selector(verticalIconPadding), (IMP) &$SBButtonBar$verticalIconPadding, "fid_");
+
+ Class $SBIcon(objc_getClass("SBIcon"));
+ MSHookMessage($SBIcon, @selector(setOrigin:), (IMP) $SBIcon$setOrigin$, "fid_");
+}
-Package: com.saurik.iphone.nlnf
+Package: com.saurik.iphone.fid
Priority: optional
Section: Tweaks
Maintainer: Jay Freeman (saurik) <saurik@saurik.com>
Architecture: iphoneos-arm
-Version: 0.9.2526-1
+Version: 0.9.2557-1
Description: fix phone numbers for roaming and locales
Name: Net.-Local Number Format
-Depends: mobilesubstrate (>= 0.9.2550-1)
+Depends: mobilesubstrate (>= 0.9.2555-1)
Author: Jay Freeman (saurik) <saurik@saurik.com>
Depiction: http://cydia.saurik.com/info/com.saurik.iphone.fid/
export PKG_ARCH=${PKG_ARCH-iphoneos-arm}
PATH=/apl/n42/pre/bin:$PATH /apl/tel/exec.sh com.saurik.winterboard make "$@"
export CODESIGN_ALLOCATE=$(which arm-apple-darwin9-codesign_allocate)
-/apl/tel/util/ldid -S PhoneNumberFormatting.dylib
+/apl/tel/util/ldid -S *.dylib
+make package