mirror of
https://github.com/Sunnyyoung/WeChatTweak-macOS.git
synced 2025-05-22 22:36:07 +08:00
Add custom mask color support
This commit is contained in:
parent
46315d09d1
commit
3685d28592
|
@ -83,8 +83,8 @@ static void __attribute__((constructor)) tweak(void) {
|
|||
// Dispatch notification
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
// Deliver notification
|
||||
RevokeNotificationType notificationType = [[NSUserDefaults standardUserDefaults] integerForKey:WeChatTweakPreferenceRevokeNotificationTypeKey];
|
||||
if (notificationType == RevokeNotificationTypeReceiveAll || (notificationType == RevokeNotificationTypeInherited && isChatStatusNotifyOpen)) {
|
||||
WeChatTweakNotificationType notificationType = WeChatTweak.notificationType;
|
||||
if (notificationType == WeChatTweakNotificationTypeReceiveAll || (notificationType == WeChatTweakNotificationTypeInherited && isChatStatusNotifyOpen)) {
|
||||
[[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:userNotification];
|
||||
}
|
||||
});
|
||||
|
@ -119,7 +119,7 @@ static void __attribute__((constructor)) tweak(void) {
|
|||
*stop = YES;
|
||||
view.hidden = !recalled;
|
||||
}];
|
||||
((MMMessageCellView *)self).layer.backgroundColor = recalled ? [NSColor.systemYellowColor colorWithAlphaComponent:0.3].CGColor : nil;
|
||||
((MMMessageCellView *)self).layer.backgroundColor = recalled ? WeChatTweak.maskColor.CGColor : nil;
|
||||
}
|
||||
|
||||
- (void)tweak_layout {
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
<objects>
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="TweakPreferencesController">
|
||||
<connections>
|
||||
<outlet property="maskColorWell" destination="os7-vb-CNH" id="dYW-6g-0zh"/>
|
||||
<outlet property="notificationTypeButton" destination="6x2-KV-p8w" id="Kfn-2a-Yup"/>
|
||||
<outlet property="view" destination="Hz6-mo-xeY" id="0bl-1N-x8E"/>
|
||||
</connections>
|
||||
|
@ -15,11 +16,17 @@
|
|||
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
|
||||
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
|
||||
<customView id="Hz6-mo-xeY">
|
||||
<rect key="frame" x="0.0" y="0.0" width="431" height="56"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="316" height="88"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<subviews>
|
||||
<stackView distribution="fill" orientation="vertical" alignment="leading" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="xTR-Zt-kYC">
|
||||
<rect key="frame" x="20" y="18" width="276" height="52"/>
|
||||
<subviews>
|
||||
<stackView distribution="equalCentering" orientation="horizontal" alignment="centerY" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="RwY-YV-4Af">
|
||||
<rect key="frame" x="0.0" y="32" width="276" height="20"/>
|
||||
<subviews>
|
||||
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="1000" translatesAutoresizingMaskIntoConstraints="NO" id="B87-eD-uhI">
|
||||
<rect key="frame" x="10" y="20" width="186" height="16"/>
|
||||
<rect key="frame" x="-2" y="2" width="186" height="16"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" refusesFirstResponder="YES" sendsActionOnEndEditing="YES" alignment="right" title="Message recalled notification:" usesSingleLineMode="YES" id="UKv-CM-nGt">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
|
||||
|
@ -27,7 +34,7 @@
|
|||
</textFieldCell>
|
||||
</textField>
|
||||
<popUpButton verticalHuggingPriority="750" horizontalCompressionResistancePriority="1000" translatesAutoresizingMaskIntoConstraints="NO" id="6x2-KV-p8w">
|
||||
<rect key="frame" x="199" y="14" width="93" height="25"/>
|
||||
<rect key="frame" x="187" y="-4" width="93" height="25"/>
|
||||
<popUpButtonCell key="cell" type="push" title="Inherited" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" imageScaling="axesIndependently" inset="2" selectedItem="gec-CY-E1x" id="wek-GT-N5V">
|
||||
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="menu"/>
|
||||
|
@ -50,14 +57,62 @@
|
|||
</connections>
|
||||
</popUpButton>
|
||||
</subviews>
|
||||
<visibilityPriorities>
|
||||
<integer value="1000"/>
|
||||
<integer value="1000"/>
|
||||
</visibilityPriorities>
|
||||
<customSpacing>
|
||||
<real value="3.4028234663852886e+38"/>
|
||||
<real value="3.4028234663852886e+38"/>
|
||||
</customSpacing>
|
||||
</stackView>
|
||||
<stackView distribution="fill" orientation="horizontal" alignment="centerY" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="R0D-IF-6iq">
|
||||
<rect key="frame" x="0.0" y="0.0" width="228" height="24"/>
|
||||
<subviews>
|
||||
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="1000" translatesAutoresizingMaskIntoConstraints="NO" id="2Mh-bQ-Asx">
|
||||
<rect key="frame" x="-2" y="4" width="186" height="16"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" refusesFirstResponder="YES" sendsActionOnEndEditing="YES" alignment="right" title="Recall mask color:" usesSingleLineMode="YES" id="3xl-c5-YvI">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<colorWell translatesAutoresizingMaskIntoConstraints="NO" id="os7-vb-CNH">
|
||||
<rect key="frame" x="187" y="-2" width="44" height="28"/>
|
||||
<color key="color" red="1" green="0.80000000000000004" blue="0.0" alpha="0.29833652210884354" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<connections>
|
||||
<action selector="changeMaskColorAction:" target="-2" id="Tfo-FJ-I64"/>
|
||||
</connections>
|
||||
</colorWell>
|
||||
</subviews>
|
||||
<visibilityPriorities>
|
||||
<integer value="1000"/>
|
||||
<integer value="1000"/>
|
||||
</visibilityPriorities>
|
||||
<customSpacing>
|
||||
<real value="3.4028234663852886e+38"/>
|
||||
<real value="3.4028234663852886e+38"/>
|
||||
</customSpacing>
|
||||
</stackView>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstItem="B87-eD-uhI" firstAttribute="leading" secondItem="Hz6-mo-xeY" secondAttribute="leading" constant="12" id="9tt-Vb-9e8"/>
|
||||
<constraint firstItem="B87-eD-uhI" firstAttribute="top" secondItem="Hz6-mo-xeY" secondAttribute="top" constant="20" id="acJ-lS-NeF"/>
|
||||
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="6x2-KV-p8w" secondAttribute="trailing" constant="12" id="e8z-dC-BAg"/>
|
||||
<constraint firstItem="6x2-KV-p8w" firstAttribute="centerY" secondItem="B87-eD-uhI" secondAttribute="centerY" id="gqp-om-e0O"/>
|
||||
<constraint firstItem="6x2-KV-p8w" firstAttribute="leading" secondItem="B87-eD-uhI" secondAttribute="trailing" constant="8" id="i7Z-7c-5cX"/>
|
||||
<constraint firstItem="2Mh-bQ-Asx" firstAttribute="width" secondItem="B87-eD-uhI" secondAttribute="width" id="oUr-AD-5kN"/>
|
||||
</constraints>
|
||||
<point key="canvasLocation" x="138.5" y="146"/>
|
||||
<visibilityPriorities>
|
||||
<integer value="1000"/>
|
||||
<integer value="1000"/>
|
||||
</visibilityPriorities>
|
||||
<customSpacing>
|
||||
<real value="3.4028234663852886e+38"/>
|
||||
<real value="3.4028234663852886e+38"/>
|
||||
</customSpacing>
|
||||
</stackView>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstItem="xTR-Zt-kYC" firstAttribute="centerY" secondItem="Hz6-mo-xeY" secondAttribute="centerY" id="667-ch-Pg7"/>
|
||||
<constraint firstItem="xTR-Zt-kYC" firstAttribute="centerX" secondItem="Hz6-mo-xeY" secondAttribute="centerX" id="h4J-4r-fcC"/>
|
||||
</constraints>
|
||||
<point key="canvasLocation" x="81" y="166"/>
|
||||
</customView>
|
||||
</objects>
|
||||
</document>
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
@interface TweakPreferencesController () <MASPreferencesViewController>
|
||||
|
||||
@property (weak) IBOutlet NSPopUpButton *notificationTypeButton;
|
||||
@property (weak) IBOutlet NSColorWell *maskColorWell;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -19,6 +20,7 @@
|
|||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
[NSColorPanel.sharedColorPanel setShowsAlpha:YES];
|
||||
}
|
||||
|
||||
- (void)viewWillAppear {
|
||||
|
@ -27,13 +29,18 @@
|
|||
}
|
||||
|
||||
- (void)reloadData {
|
||||
[self.notificationTypeButton selectItemAtIndex:[NSUserDefaults.standardUserDefaults integerForKey:WeChatTweakPreferenceRevokeNotificationTypeKey]];
|
||||
self.maskColorWell.color = WeChatTweak.maskColor;
|
||||
[self.notificationTypeButton selectItemAtIndex:WeChatTweak.notificationType];
|
||||
}
|
||||
|
||||
#pragma mark - Event method
|
||||
|
||||
- (IBAction)switchNotificationTypeAction:(NSPopUpButton *)sender {
|
||||
[NSUserDefaults.standardUserDefaults setInteger:sender.indexOfSelectedItem forKey:WeChatTweakPreferenceRevokeNotificationTypeKey];
|
||||
WeChatTweak.notificationType = sender.indexOfSelectedItem;
|
||||
}
|
||||
|
||||
- (IBAction)changeMaskColorAction:(NSColorWell *)sender {
|
||||
WeChatTweak.maskColor = sender.color;
|
||||
}
|
||||
|
||||
#pragma mark - MASPreferencesViewController
|
||||
|
|
|
@ -11,12 +11,6 @@
|
|||
#import <objc/message.h>
|
||||
#import <JRSwizzle/JRSwizzle.h>
|
||||
|
||||
typedef NS_ENUM(NSUInteger, RevokeNotificationType) {
|
||||
RevokeNotificationTypeInherited = 0,
|
||||
RevokeNotificationTypeReceiveAll,
|
||||
RevokeNotificationTypeDisable,
|
||||
};
|
||||
|
||||
typedef NS_ENUM(unsigned int, MessageDataType) {
|
||||
MessageDataTypeText = 1,
|
||||
MessageDataTypeImage = 3,
|
||||
|
@ -27,8 +21,6 @@ typedef NS_ENUM(unsigned int, MessageDataType) {
|
|||
MessageDataTypePrompt = 10000
|
||||
};
|
||||
|
||||
static NSString * const WeChatTweakPreferenceRevokeNotificationTypeKey = @"WeChatTweakPreferenceRevokeNotificationTypeKey";
|
||||
|
||||
@interface NSString (MD5)
|
||||
|
||||
- (NSString *)md5String;
|
||||
|
|
|
@ -11,6 +11,15 @@
|
|||
FOUNDATION_EXPORT double WeChatTweakVersionNumber;
|
||||
FOUNDATION_EXPORT const unsigned char WeChatTweakVersionString[];
|
||||
|
||||
typedef NS_ENUM(NSUInteger, WeChatTweakNotificationType) {
|
||||
WeChatTweakNotificationTypeInherited = 0,
|
||||
WeChatTweakNotificationTypeReceiveAll,
|
||||
WeChatTweakNotificationTypeDisable
|
||||
};
|
||||
|
||||
@interface WeChatTweak : NSObject
|
||||
|
||||
@property (class, assign) WeChatTweakNotificationType notificationType;
|
||||
@property (class, nonnull) NSColor *maskColor;
|
||||
|
||||
@end
|
||||
|
|
|
@ -10,4 +10,22 @@
|
|||
|
||||
@implementation WeChatTweak
|
||||
|
||||
+ (WeChatTweakNotificationType)notificationType {
|
||||
return [NSUserDefaults.standardUserDefaults integerForKey:@"WeChatTweakPreferenceRevokeNotificationTypeKey"];
|
||||
}
|
||||
|
||||
+ (void)setNotificationType:(WeChatTweakNotificationType)notificationType {
|
||||
[NSUserDefaults.standardUserDefaults setInteger:notificationType forKey:@"WeChatTweakPreferenceRevokeNotificationTypeKey"];
|
||||
}
|
||||
|
||||
+ (NSColor *)maskColor {
|
||||
NSData *data = [NSUserDefaults.standardUserDefaults objectForKey:@"WeChatTweakMaskColor"];
|
||||
return data ? [NSUnarchiver unarchiveObjectWithData:data] : [NSColor.systemYellowColor colorWithAlphaComponent:0.3];
|
||||
}
|
||||
|
||||
+ (void)setMaskColor:(NSColor *)maskColor {
|
||||
NSData *data = [NSArchiver archivedDataWithRootObject:maskColor];
|
||||
[NSUserDefaults.standardUserDefaults setObject:data forKey:@"WeChatTweakMaskColor"];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Loading…
Reference in New Issue
Block a user