diff --git a/WeChatTweak.framework/Versions/A/Resources/Base.lproj/TweakPreferencesController.nib b/WeChatTweak.framework/Versions/A/Resources/Base.lproj/TweakPreferencesController.nib index 02405bd..f10c3ea 100644 Binary files a/WeChatTweak.framework/Versions/A/Resources/Base.lproj/TweakPreferencesController.nib and b/WeChatTweak.framework/Versions/A/Resources/Base.lproj/TweakPreferencesController.nib differ diff --git a/WeChatTweak.framework/Versions/A/Resources/en.lproj/TweakPreferencesController.strings b/WeChatTweak.framework/Versions/A/Resources/en.lproj/TweakPreferencesController.strings index 0059bf3..afe614e 100644 --- a/WeChatTweak.framework/Versions/A/Resources/en.lproj/TweakPreferencesController.strings +++ b/WeChatTweak.framework/Versions/A/Resources/en.lproj/TweakPreferencesController.strings @@ -31,3 +31,6 @@ /* Class = "NSTextFieldCell"; title = "Alfred JSON compressing:"; ObjectID = "jHw-2a-B2t"; */ "jHw-2a-B2t.title" = "Alfred JSON compressing:"; + +/* Class = "NSTextFieldCell"; title = "Message recalled background color:"; ObjectID = "8uI-sB-Jzm"; */ +"8uI-sB-Jzm.title" = "Message recalled background color:"; diff --git a/WeChatTweak.framework/Versions/A/Resources/zh-Hans.lproj/TweakPreferencesController.strings b/WeChatTweak.framework/Versions/A/Resources/zh-Hans.lproj/TweakPreferencesController.strings index 0c7eff4..b27c587 100644 --- a/WeChatTweak.framework/Versions/A/Resources/zh-Hans.lproj/TweakPreferencesController.strings +++ b/WeChatTweak.framework/Versions/A/Resources/zh-Hans.lproj/TweakPreferencesController.strings @@ -31,3 +31,6 @@ /* Class = "NSTextFieldCell"; title = "Alfred JSON compressing:"; ObjectID = "jHw-2a-B2t"; */ "jHw-2a-B2t.title" = "Alfred JSON 压缩:"; + +/* Class = "NSTextFieldCell"; title = "Message recalled background color:"; ObjectID = "8uI-sB-Jzm"; */ +"8uI-sB-Jzm.title" = "消息撤回背景颜色:"; diff --git a/WeChatTweak.framework/Versions/A/Resources/zh-Hant.lproj/TweakPreferencesController.strings b/WeChatTweak.framework/Versions/A/Resources/zh-Hant.lproj/TweakPreferencesController.strings index 9649c05..ed2eaa8 100644 --- a/WeChatTweak.framework/Versions/A/Resources/zh-Hant.lproj/TweakPreferencesController.strings +++ b/WeChatTweak.framework/Versions/A/Resources/zh-Hant.lproj/TweakPreferencesController.strings @@ -31,3 +31,6 @@ /* Class = "NSTextFieldCell"; title = "Alfred JSON compressing:"; ObjectID = "jHw-2a-B2t"; */ "jHw-2a-B2t.title" = "Alfred JSON 壓縮:"; + +/* Class = "NSTextFieldCell"; title = "Message recalled background color:"; ObjectID = "8uI-sB-Jzm"; */ +"8uI-sB-Jzm.title" = "消息撤回背景顏色:"; diff --git a/WeChatTweak.framework/Versions/A/WeChatTweak b/WeChatTweak.framework/Versions/A/WeChatTweak index 65ba1f2..232a691 100755 Binary files a/WeChatTweak.framework/Versions/A/WeChatTweak and b/WeChatTweak.framework/Versions/A/WeChatTweak differ diff --git a/WeChatTweak.xcodeproj/project.pbxproj b/WeChatTweak.xcodeproj/project.pbxproj index ad6ba49..a4774ef 100644 --- a/WeChatTweak.xcodeproj/project.pbxproj +++ b/WeChatTweak.xcodeproj/project.pbxproj @@ -27,6 +27,10 @@ 7DF8425C1F4058DD00D42D79 /* NSBundle+WeChatTweak.m in Sources */ = {isa = PBXBuildFile; fileRef = 7DF842581F4058DD00D42D79 /* NSBundle+WeChatTweak.m */; }; 7DF842601F40590500D42D79 /* WeChatTweakHeaders.h in Headers */ = {isa = PBXBuildFile; fileRef = 7DF8425F1F40590500D42D79 /* WeChatTweakHeaders.h */; }; 7DF842651F40594400D42D79 /* Prefs-Tweak.tiff in Resources */ = {isa = PBXBuildFile; fileRef = 7DF842641F40594400D42D79 /* Prefs-Tweak.tiff */; }; + 9CB3C3CB236BFE38002F060C /* TweakColorView.h in Headers */ = {isa = PBXBuildFile; fileRef = 9CB3C3C9236BFE38002F060C /* TweakColorView.h */; }; + 9CB3C3CC236BFE38002F060C /* TweakColorView.m in Sources */ = {isa = PBXBuildFile; fileRef = 9CB3C3CA236BFE38002F060C /* TweakColorView.m */; }; + 9CB3C3CF236C131D002F060C /* NSColor+WeChatTweak.h in Headers */ = {isa = PBXBuildFile; fileRef = 9CB3C3CD236C131D002F060C /* NSColor+WeChatTweak.h */; }; + 9CB3C3D0236C131D002F060C /* NSColor+WeChatTweak.m in Sources */ = {isa = PBXBuildFile; fileRef = 9CB3C3CE236C131D002F060C /* NSColor+WeChatTweak.m */; }; D84599A16A2504BCF95DB436 /* libPods-WeChatTweak.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 153504EC5C9196C0D85213CF /* libPods-WeChatTweak.a */; }; /* End PBXBuildFile section */ @@ -59,6 +63,10 @@ 7DF842581F4058DD00D42D79 /* NSBundle+WeChatTweak.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSBundle+WeChatTweak.m"; sourceTree = ""; }; 7DF8425F1F40590500D42D79 /* WeChatTweakHeaders.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WeChatTweakHeaders.h; sourceTree = ""; }; 7DF842641F40594400D42D79 /* Prefs-Tweak.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = "Prefs-Tweak.tiff"; sourceTree = ""; }; + 9CB3C3C9236BFE38002F060C /* TweakColorView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TweakColorView.h; sourceTree = ""; }; + 9CB3C3CA236BFE38002F060C /* TweakColorView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TweakColorView.m; sourceTree = ""; }; + 9CB3C3CD236C131D002F060C /* NSColor+WeChatTweak.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSColor+WeChatTweak.h"; sourceTree = ""; }; + 9CB3C3CE236C131D002F060C /* NSColor+WeChatTweak.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSColor+WeChatTweak.m"; sourceTree = ""; }; A82E6F61C63DBD47219BB308 /* Pods-WeChatTweak.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WeChatTweak.debug.xcconfig"; path = "Pods/Target Support Files/Pods-WeChatTweak/Pods-WeChatTweak.debug.xcconfig"; sourceTree = ""; }; B418F83DA5D4A992F73514A9 /* Pods-WeChatTweak.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WeChatTweak.release.xcconfig"; path = "Pods/Target Support Files/Pods-WeChatTweak/Pods-WeChatTweak.release.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ @@ -113,6 +121,8 @@ 7DF842581F4058DD00D42D79 /* NSBundle+WeChatTweak.m */, 7D9049F71F82B6FB004E6370 /* NSString+WeChatTweak.h */, 7D9049F81F82B6FB004E6370 /* NSString+WeChatTweak.m */, + 9CB3C3CD236C131D002F060C /* NSColor+WeChatTweak.h */, + 9CB3C3CE236C131D002F060C /* NSColor+WeChatTweak.m */, ); path = Category; sourceTree = ""; @@ -157,14 +167,15 @@ 7DF842291F40583F00D42D79 /* WeChatTweak */ = { isa = PBXGroup; children = ( - 7DF8422A1F40583F00D42D79 /* WeChatTweak.h */, - 7DF842331F4058AB00D42D79 /* WeChatTweak.m */, - 7D5AAF3720DF4BB300860EEE /* Vendor */, 7D5AAF3620DF4BA400860EEE /* Category */, 7D5AAF3520DF4B9700860EEE /* Controller */, 7D5AAF3320DF4B7B00860EEE /* Manager */, 7DF842631F40594400D42D79 /* Resources */, 7D5AAF3820DF4BC400860EEE /* Supporting Files */, + 7D5AAF3720DF4BB300860EEE /* Vendor */, + 9CB3C3C8236BFE06002F060C /* View */, + 7DF8422A1F40583F00D42D79 /* WeChatTweak.h */, + 7DF842331F4058AB00D42D79 /* WeChatTweak.m */, ); path = WeChatTweak; sourceTree = ""; @@ -177,6 +188,15 @@ path = Resources; sourceTree = ""; }; + 9CB3C3C8236BFE06002F060C /* View */ = { + isa = PBXGroup; + children = ( + 9CB3C3C9236BFE38002F060C /* TweakColorView.h */, + 9CB3C3CA236BFE38002F060C /* TweakColorView.m */, + ); + path = View; + sourceTree = ""; + }; FEFA9C3F34481028661EEC5A /* Pods */ = { isa = PBXGroup; children = ( @@ -197,10 +217,12 @@ 7D9049FA1F82B708004E6370 /* NSString+WeChatTweak.h in Headers */, 7DF8422C1F40583F00D42D79 /* WeChatTweak.h in Headers */, 7DF8425B1F4058DD00D42D79 /* NSBundle+WeChatTweak.h in Headers */, + 9CB3C3CB236BFE38002F060C /* TweakColorView.h in Headers */, 7DB8AFBE206211D900E683AE /* WTConfigManager.h in Headers */, 7D9049F61F82A41A004E6370 /* fishhook.h in Headers */, 7D14E5A41F6447DB00D75132 /* AlfredManager.h in Headers */, 7DF842601F40590500D42D79 /* WeChatTweakHeaders.h in Headers */, + 9CB3C3CF236C131D002F060C /* NSColor+WeChatTweak.h in Headers */, 7DF842521F4058C600D42D79 /* TweakPreferencesController.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; @@ -321,12 +343,14 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 9CB3C3CC236BFE38002F060C /* TweakColorView.m in Sources */, 7D14E5A51F6447DB00D75132 /* AlfredManager.m in Sources */, 7DF842531F4058C600D42D79 /* TweakPreferencesController.m in Sources */, 7D9049F91F82B6FB004E6370 /* NSString+WeChatTweak.m in Sources */, 7DBA4468231812AB004CE2DB /* RecallCacheManager.m in Sources */, 7DF842341F4058AB00D42D79 /* WeChatTweak.m in Sources */, 7DB8AFBF206211D900E683AE /* WTConfigManager.m in Sources */, + 9CB3C3D0236C131D002F060C /* NSColor+WeChatTweak.m in Sources */, 7D9049F51F82A41A004E6370 /* fishhook.c in Sources */, 7DF8425C1F4058DD00D42D79 /* NSBundle+WeChatTweak.m in Sources */, ); diff --git a/WeChatTweak/Category/NSColor+WeChatTweak.h b/WeChatTweak/Category/NSColor+WeChatTweak.h new file mode 100644 index 0000000..1ecd0de --- /dev/null +++ b/WeChatTweak/Category/NSColor+WeChatTweak.h @@ -0,0 +1,21 @@ +// +// NSColor+WeChatTweak.h +// WeChatTweak +// +// Created by Jeason Lee on 2019/11/1. +// Copyright © 2019 Sunnyyoung. All rights reserved. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +static NSString * const WeChatTweakPreferenceRevokeBackgroundColorKey = @"WeChatTweakPreferenceRevokeBackgroundColorKey"; + +@interface NSColor (WeChatTweak) + ++ (NSColor *)tweak_revokeBackgroundColor; + +@end + +NS_ASSUME_NONNULL_END diff --git a/WeChatTweak/Category/NSColor+WeChatTweak.m b/WeChatTweak/Category/NSColor+WeChatTweak.m new file mode 100644 index 0000000..8c74402 --- /dev/null +++ b/WeChatTweak/Category/NSColor+WeChatTweak.m @@ -0,0 +1,26 @@ +// +// NSColor+WeChatTweak.m +// WeChatTweak +// +// Created by Jeason Lee on 2019/11/1. +// Copyright © 2019 Sunnyyoung. All rights reserved. +// + +#import "NSColor+WeChatTweak.h" + +@implementation NSColor (WeChatTweak) + ++ (NSColor *)tweak_revokeBackgroundColor { + NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults]; + NSData *colorData = [userDefaults objectForKey:WeChatTweakPreferenceRevokeBackgroundColorKey]; + NSColor *color = [NSKeyedUnarchiver unarchiveObjectWithData:colorData]; + if(![color isKindOfClass:[NSColor class]]){ + color = [NSColor colorWithRed:250/255.0 green:250/255.0 blue:205/255.0 alpha:1]; + NSData *colorData = [NSKeyedArchiver archivedDataWithRootObject:color]; + [userDefaults setObject:colorData forKey:WeChatTweakPreferenceRevokeBackgroundColorKey]; + [userDefaults synchronize]; + } + return color; +} + +@end diff --git a/WeChatTweak/Controller/Base.lproj/TweakPreferencesController.xib b/WeChatTweak/Controller/Base.lproj/TweakPreferencesController.xib index b975b21..5230f4b 100644 --- a/WeChatTweak/Controller/Base.lproj/TweakPreferencesController.xib +++ b/WeChatTweak/Controller/Base.lproj/TweakPreferencesController.xib @@ -1,8 +1,8 @@ - + - + @@ -11,33 +11,18 @@ + - + - - - - - - - - - - - - - - - - - + @@ -57,7 +42,7 @@ - + @@ -79,16 +64,65 @@ - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + @@ -107,35 +141,29 @@ - - - - - - - - + + + + + + + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + diff --git a/WeChatTweak/Controller/TweakPreferencesController.h b/WeChatTweak/Controller/TweakPreferencesController.h index a62b6b0..d30cef1 100644 --- a/WeChatTweak/Controller/TweakPreferencesController.h +++ b/WeChatTweak/Controller/TweakPreferencesController.h @@ -7,6 +7,7 @@ // #import "WeChatTweakHeaders.h" +#import "NSColor+WeChatTweak.h" typedef NS_ENUM(NSUInteger, RevokeNotificationType) { RevokeNotificationTypeFollow = 0, diff --git a/WeChatTweak/Controller/TweakPreferencesController.m b/WeChatTweak/Controller/TweakPreferencesController.m index b06b890..bfbf773 100644 --- a/WeChatTweak/Controller/TweakPreferencesController.m +++ b/WeChatTweak/Controller/TweakPreferencesController.m @@ -9,12 +9,14 @@ #import "TweakPreferencesController.h" #import "NSBundle+WeChatTweak.h" #import "WTConfigManager.h" +#import "TweakColorView.h" @interface TweakPreferencesController () @property (weak) IBOutlet NSPopUpButton *autoAuthButton; @property (weak) IBOutlet NSPopUpButton *notificationTypeButton; @property (weak) IBOutlet NSPopUpButton *compressedJSONEnabledButton; +@property (weak) IBOutlet TweakColorView *recallColorView; @end @@ -22,6 +24,9 @@ - (void)viewDidLoad { [super viewDidLoad]; + NSClickGestureRecognizer *click = [[NSClickGestureRecognizer alloc] initWithTarget:self action:@selector(recallColorAction:)]; + [self.recallColorView addGestureRecognizer:click]; + self.recallColorView.backgroundColor = [NSColor tweak_revokeBackgroundColor]; } - (void)viewWillAppear { @@ -57,6 +62,24 @@ WTConfigManager.sharedInstance.compressedJSONEnabled = enabled; } +- (void)recallColorAction:(id)sender { + NSColorPanel *colorPanel = [NSColorPanel sharedColorPanel]; + colorPanel.mode = NSColorPanelModeRGB; + [colorPanel setAction:@selector(changeColorAction:)]; + [colorPanel setTarget:self]; + [colorPanel orderFront:nil]; + colorPanel.color = self.recallColorView.backgroundColor; +} + +- (void)changeColorAction:(NSColorPanel *)sender { + NSColor *color = sender.color; + self.recallColorView.backgroundColor = color; + NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults]; + NSData *colorData = [NSKeyedArchiver archivedDataWithRootObject:color]; + [userDefaults setObject:colorData forKey:WeChatTweakPreferenceRevokeBackgroundColorKey]; + [userDefaults synchronize]; +} + #pragma mark - MASPreferencesViewController - (NSString *)identifier { diff --git a/WeChatTweak/Controller/en.lproj/TweakPreferencesController.strings b/WeChatTweak/Controller/en.lproj/TweakPreferencesController.strings index 0059bf3..afe614e 100644 --- a/WeChatTweak/Controller/en.lproj/TweakPreferencesController.strings +++ b/WeChatTweak/Controller/en.lproj/TweakPreferencesController.strings @@ -31,3 +31,6 @@ /* Class = "NSTextFieldCell"; title = "Alfred JSON compressing:"; ObjectID = "jHw-2a-B2t"; */ "jHw-2a-B2t.title" = "Alfred JSON compressing:"; + +/* Class = "NSTextFieldCell"; title = "Message recalled background color:"; ObjectID = "8uI-sB-Jzm"; */ +"8uI-sB-Jzm.title" = "Message recalled background color:"; diff --git a/WeChatTweak/Controller/zh-Hans.lproj/TweakPreferencesController.strings b/WeChatTweak/Controller/zh-Hans.lproj/TweakPreferencesController.strings index 0c7eff4..b27c587 100644 --- a/WeChatTweak/Controller/zh-Hans.lproj/TweakPreferencesController.strings +++ b/WeChatTweak/Controller/zh-Hans.lproj/TweakPreferencesController.strings @@ -31,3 +31,6 @@ /* Class = "NSTextFieldCell"; title = "Alfred JSON compressing:"; ObjectID = "jHw-2a-B2t"; */ "jHw-2a-B2t.title" = "Alfred JSON 压缩:"; + +/* Class = "NSTextFieldCell"; title = "Message recalled background color:"; ObjectID = "8uI-sB-Jzm"; */ +"8uI-sB-Jzm.title" = "消息撤回背景颜色:"; diff --git a/WeChatTweak/Controller/zh-Hant.lproj/TweakPreferencesController.strings b/WeChatTweak/Controller/zh-Hant.lproj/TweakPreferencesController.strings index 9649c05..ed2eaa8 100644 --- a/WeChatTweak/Controller/zh-Hant.lproj/TweakPreferencesController.strings +++ b/WeChatTweak/Controller/zh-Hant.lproj/TweakPreferencesController.strings @@ -31,3 +31,6 @@ /* Class = "NSTextFieldCell"; title = "Alfred JSON compressing:"; ObjectID = "jHw-2a-B2t"; */ "jHw-2a-B2t.title" = "Alfred JSON 壓縮:"; + +/* Class = "NSTextFieldCell"; title = "Message recalled background color:"; ObjectID = "8uI-sB-Jzm"; */ +"8uI-sB-Jzm.title" = "消息撤回背景顏色:"; diff --git a/WeChatTweak/View/TweakColorView.h b/WeChatTweak/View/TweakColorView.h new file mode 100644 index 0000000..58c2254 --- /dev/null +++ b/WeChatTweak/View/TweakColorView.h @@ -0,0 +1,19 @@ +// +// TweakColorView.h +// WeChatTweak +// +// Created by Jeason Lee on 2019/11/1. +// Copyright © 2019 Sunnyyoung. All rights reserved. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface TweakColorView : NSView + +@property (nonatomic, strong) NSColor *backgroundColor; + +@end + +NS_ASSUME_NONNULL_END diff --git a/WeChatTweak/View/TweakColorView.m b/WeChatTweak/View/TweakColorView.m new file mode 100644 index 0000000..74ba570 --- /dev/null +++ b/WeChatTweak/View/TweakColorView.m @@ -0,0 +1,24 @@ +// +// TweakColorView.m +// WeChatTweak +// +// Created by Jeason Lee on 2019/11/1. +// Copyright © 2019 Sunnyyoung. All rights reserved. +// + +#import "TweakColorView.h" + +@implementation TweakColorView + +- (void)mouseDown:(NSEvent *)event { + [NSColorPanel dragColor:self.backgroundColor withEvent:event fromView:self]; +} + +- (void)setBackgroundColor:(NSColor *)backgroundColor { + _backgroundColor = backgroundColor; + dispatch_async(dispatch_get_main_queue(), ^{ + self.layer.backgroundColor = backgroundColor.CGColor; + }); +} + +@end diff --git a/WeChatTweak/WeChatTweak.m b/WeChatTweak/WeChatTweak.m index 1496c2b..7cd093f 100755 --- a/WeChatTweak/WeChatTweak.m +++ b/WeChatTweak/WeChatTweak.m @@ -108,7 +108,8 @@ static void __attribute__((constructor)) tweak(void) { *stop = YES; view.hidden = !style; }]; - ((MMMessageCellView *)self).layer.backgroundColor = style ? [NSColor.yellowColor colorWithAlphaComponent:0.3].CGColor : ((MMMessageCellView *)self).layer.backgroundColor; + NSColor *color = [NSColor tweak_revokeBackgroundColor]; + ((MMMessageCellView *)self).layer.backgroundColor = style ? color.CGColor : ((MMMessageCellView *)self).layer.backgroundColor; } - (void)tweak_layout {