<commit_before>/**
 * Name: ShowCase
 * Type: iOS SpringBoard extension (MobileSubstrate-based)
 * Desc: Make keyboard show current case.
 *
 * Author: <NAME> (aka. ashikase)
 * License: New BSD (See LICENSE file for details)
 *
 * Last-modified: 2012-01-23 17:53:59
 */


#include <objc/runtime.h>

// Class declarations
// NOTE: These are not 100% accurate; protocol information has been stripped,
//       and super classes may change between firmware versions.
@interface CALayer : NSObject
- (void)_display;
@end

@interface CPBitmapStore : NSObject
- (id)allGroups;
- (void)removeImagesInGroups:(id)groups;
@end

// 4.2.1+
@interface UIKeyboardCache : NSObject
+ (id)sharedInstance;
@end

@interface UIKeyboardImpl : UIView
+ (id)activeInstance;
@end

@interface UIKeyboardLayout : UIView @end
@interface UIKeyboardLayoutStar : UIKeyboardLayout
@property(assign, nonatomic) BOOL shift;
@end

@interface UIKBKeyplaneView : UIView @end
@interface UIKBKeyplaneView (Firmware5x)
@property(assign, nonatomic) UIKeyboardLayoutStar *layout;
@end

@interface UIKBShape : NSObject @end
@interface UIKBKey : UIKBShape
@property(copy, nonatomic) NSString *name;
@end

// 5.x
@interface UIKBTree : NSObject
@property(copy, nonatomic) NSString *name;
@end

//==============================================================================

static inline void updateKeyplaneView(id object)
{
    UIKBKeyplaneView *_keyplaneView = NULL;
    if (object_getInstanceVariable(object, "_keyplaneView", (void **)&_keyplaneView) == NULL) {
        object_getInstanceVariable(object, "m_keyplaneView", (void **)&_keyplaneView);
    }
    [_keyplaneView setNeedsDisplay];
}

//==============================================================================

%hook UIKeyboard %group GFirmware4x

- (void)activate
{
    %orig;

    // Force keys to redraw to prevent cached uppercase letters from showing
    // FIXME: Determine why redraw is needed and prevent this need.
    UIKeyboardImpl *impl = [objc_getClass("UIKeyboardImpl") activeInstance];
    if (impl != nil) {
        UIKeyboardLayout *m_layout = MSHookIvar<UIKeyboardLayout *>(impl, "m_layout");
        if ([m_layout isKindOfClass:objc_getClass("UIKeyboardLayoutStar")]) {
            updateKeyplaneView(m_layout);
        }
    }
}

%end %end

//==============================================================================

%hook UIKeyboardLayoutStar

- (void)setShift:(BOOL)shift
{
    BOOL currentShiftState = self.shift;

    %orig;

    // If shift state changed, force keys to redraw
    if (currentShiftState != shift) {
        updateKeyplaneView(self);
    }
}

%end

//==============================================================================
<commit_msg>Ext: Redraw keyboard when keyplane name changes.<commit_after>/**
 * Name: ShowCase
 * Type: iOS SpringBoard extension (MobileSubstrate-based)
 * Desc: Make keyboard show current case.
 *
 * Author: <NAME> (aka. ashikase)
 * License: New BSD (See LICENSE file for details)
 *
 * Last-modified: 2012-01-24 15:26:49
 */


#include <objc/runtime.h>

// Class declarations
// NOTE: These are not 100% accurate; protocol information has been stripped,
//       and super classes may change between firmware versions.
@interface CALayer : NSObject
- (void)_display;
@end

@interface CPBitmapStore : NSObject
- (id)allGroups;
- (void)removeImagesInGroups:(id)groups;
@end

// 4.2.1+
@interface UIKeyboardCache : NSObject
+ (id)sharedInstance;
@end

@interface UIKeyboardImpl : UIView
+ (id)activeInstance;
@end

@interface UIKeyboardLayout : UIView @end
@interface UIKeyboardLayoutStar : UIKeyboardLayout
@property(copy, nonatomic) NSString *keyplaneName;
@property(assign, nonatomic) BOOL shift;
@end

@interface UIKBKeyplaneView : UIView @end
@interface UIKBKeyplaneView (Firmware5x)
@property(assign, nonatomic) UIKeyboardLayoutStar *layout;
@end

@interface UIKBShape : NSObject @end
@interface UIKBKey : UIKBShape
@property(copy, nonatomic) NSString *name;
@end

// 5.x
@interface UIKBTree : NSObject
@property(copy, nonatomic) NSString *name;
@end

//==============================================================================

static inline void updateKeyplaneView(id object)
{
    UIKBKeyplaneView *_keyplaneView = NULL;
    if (object_getInstanceVariable(object, "_keyplaneView", (void **)&_keyplaneView) == NULL) {
        object_getInstanceVariable(object, "m_keyplaneView", (void **)&_keyplaneView);
    }
    [_keyplaneView setNeedsDisplay];
}

%hook UIKeyboardLayoutStar

- (void)setKeyplaneName:(id)name
{
    NSString *oldName = self.keyplaneName;

    %orig;

    // If keyplane name changed, force a redraw
    if (name != nil && ![name isEqualToString:oldName]) {
        updateKeyplaneView(self);
    }
}

%end

//==============================================================================

{'fraction_non_alphanumeric': 0.20066334991708126, 'fraction_numerical': 0.009328358208955223, 'mean_word_length': 5.053952321204517, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1611212', 'n_tokens_mistral': 1481, 'n_tokens_neox': 1406, 'n_words': 374}