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 notification
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
// Deliver notification
|
// Deliver notification
|
||||||
RevokeNotificationType notificationType = [[NSUserDefaults standardUserDefaults] integerForKey:WeChatTweakPreferenceRevokeNotificationTypeKey];
|
WeChatTweakNotificationType notificationType = WeChatTweak.notificationType;
|
||||||
if (notificationType == RevokeNotificationTypeReceiveAll || (notificationType == RevokeNotificationTypeInherited && isChatStatusNotifyOpen)) {
|
if (notificationType == WeChatTweakNotificationTypeReceiveAll || (notificationType == WeChatTweakNotificationTypeInherited && isChatStatusNotifyOpen)) {
|
||||||
[[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:userNotification];
|
[[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:userNotification];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -119,7 +119,7 @@ static void __attribute__((constructor)) tweak(void) {
|
||||||
*stop = YES;
|
*stop = YES;
|
||||||
view.hidden = !recalled;
|
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 {
|
- (void)tweak_layout {
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
<objects>
|
<objects>
|
||||||
<customObject id="-2" userLabel="File's Owner" customClass="TweakPreferencesController">
|
<customObject id="-2" userLabel="File's Owner" customClass="TweakPreferencesController">
|
||||||
<connections>
|
<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="notificationTypeButton" destination="6x2-KV-p8w" id="Kfn-2a-Yup"/>
|
||||||
<outlet property="view" destination="Hz6-mo-xeY" id="0bl-1N-x8E"/>
|
<outlet property="view" destination="Hz6-mo-xeY" id="0bl-1N-x8E"/>
|
||||||
</connections>
|
</connections>
|
||||||
|
@ -15,49 +16,103 @@
|
||||||
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
|
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
|
||||||
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
|
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
|
||||||
<customView id="Hz6-mo-xeY">
|
<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"/>
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||||
<subviews>
|
<subviews>
|
||||||
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="1000" translatesAutoresizingMaskIntoConstraints="NO" id="B87-eD-uhI">
|
<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="10" y="20" width="186" height="16"/>
|
<rect key="frame" x="20" y="18" width="276" height="52"/>
|
||||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" refusesFirstResponder="YES" sendsActionOnEndEditing="YES" alignment="right" title="Message recalled notification:" usesSingleLineMode="YES" id="UKv-CM-nGt">
|
<subviews>
|
||||||
<font key="font" metaFont="system"/>
|
<stackView distribution="equalCentering" orientation="horizontal" alignment="centerY" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="RwY-YV-4Af">
|
||||||
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
|
<rect key="frame" x="0.0" y="32" width="276" height="20"/>
|
||||||
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
|
<subviews>
|
||||||
</textFieldCell>
|
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="1000" translatesAutoresizingMaskIntoConstraints="NO" id="B87-eD-uhI">
|
||||||
</textField>
|
<rect key="frame" x="-2" y="2" width="186" height="16"/>
|
||||||
<popUpButton verticalHuggingPriority="750" horizontalCompressionResistancePriority="1000" translatesAutoresizingMaskIntoConstraints="NO" id="6x2-KV-p8w">
|
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" refusesFirstResponder="YES" sendsActionOnEndEditing="YES" alignment="right" title="Message recalled notification:" usesSingleLineMode="YES" id="UKv-CM-nGt">
|
||||||
<rect key="frame" x="199" y="14" width="93" height="25"/>
|
<font key="font" metaFont="system"/>
|
||||||
<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">
|
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
|
||||||
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
|
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||||
<font key="font" metaFont="menu"/>
|
</textFieldCell>
|
||||||
<menu key="menu" id="H2J-gJ-aGD">
|
</textField>
|
||||||
<items>
|
<popUpButton verticalHuggingPriority="750" horizontalCompressionResistancePriority="1000" translatesAutoresizingMaskIntoConstraints="NO" id="6x2-KV-p8w">
|
||||||
<menuItem title="Inherited" state="on" id="gec-CY-E1x">
|
<rect key="frame" x="187" y="-4" width="93" height="25"/>
|
||||||
<modifierMask key="keyEquivalentModifierMask"/>
|
<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">
|
||||||
</menuItem>
|
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
|
||||||
<menuItem title="All" id="da4-aJ-lEy">
|
<font key="font" metaFont="menu"/>
|
||||||
<modifierMask key="keyEquivalentModifierMask"/>
|
<menu key="menu" id="H2J-gJ-aGD">
|
||||||
</menuItem>
|
<items>
|
||||||
<menuItem title="Disabled" id="Uk9-Oc-Jtv">
|
<menuItem title="Inherited" state="on" id="gec-CY-E1x">
|
||||||
<modifierMask key="keyEquivalentModifierMask"/>
|
<modifierMask key="keyEquivalentModifierMask"/>
|
||||||
</menuItem>
|
</menuItem>
|
||||||
</items>
|
<menuItem title="All" id="da4-aJ-lEy">
|
||||||
</menu>
|
<modifierMask key="keyEquivalentModifierMask"/>
|
||||||
</popUpButtonCell>
|
</menuItem>
|
||||||
<connections>
|
<menuItem title="Disabled" id="Uk9-Oc-Jtv">
|
||||||
<action selector="switchNotificationTypeAction:" target="-2" id="xjO-Ck-wem"/>
|
<modifierMask key="keyEquivalentModifierMask"/>
|
||||||
</connections>
|
</menuItem>
|
||||||
</popUpButton>
|
</items>
|
||||||
|
</menu>
|
||||||
|
</popUpButtonCell>
|
||||||
|
<connections>
|
||||||
|
<action selector="switchNotificationTypeAction:" target="-2" id="xjO-Ck-wem"/>
|
||||||
|
</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="2Mh-bQ-Asx" firstAttribute="width" secondItem="B87-eD-uhI" secondAttribute="width" id="oUr-AD-5kN"/>
|
||||||
|
</constraints>
|
||||||
|
<visibilityPriorities>
|
||||||
|
<integer value="1000"/>
|
||||||
|
<integer value="1000"/>
|
||||||
|
</visibilityPriorities>
|
||||||
|
<customSpacing>
|
||||||
|
<real value="3.4028234663852886e+38"/>
|
||||||
|
<real value="3.4028234663852886e+38"/>
|
||||||
|
</customSpacing>
|
||||||
|
</stackView>
|
||||||
</subviews>
|
</subviews>
|
||||||
<constraints>
|
<constraints>
|
||||||
<constraint firstItem="B87-eD-uhI" firstAttribute="leading" secondItem="Hz6-mo-xeY" secondAttribute="leading" constant="12" id="9tt-Vb-9e8"/>
|
<constraint firstItem="xTR-Zt-kYC" firstAttribute="centerY" secondItem="Hz6-mo-xeY" secondAttribute="centerY" id="667-ch-Pg7"/>
|
||||||
<constraint firstItem="B87-eD-uhI" firstAttribute="top" secondItem="Hz6-mo-xeY" secondAttribute="top" constant="20" id="acJ-lS-NeF"/>
|
<constraint firstItem="xTR-Zt-kYC" firstAttribute="centerX" secondItem="Hz6-mo-xeY" secondAttribute="centerX" id="h4J-4r-fcC"/>
|
||||||
<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"/>
|
|
||||||
</constraints>
|
</constraints>
|
||||||
<point key="canvasLocation" x="138.5" y="146"/>
|
<point key="canvasLocation" x="81" y="166"/>
|
||||||
</customView>
|
</customView>
|
||||||
</objects>
|
</objects>
|
||||||
</document>
|
</document>
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
@interface TweakPreferencesController () <MASPreferencesViewController>
|
@interface TweakPreferencesController () <MASPreferencesViewController>
|
||||||
|
|
||||||
@property (weak) IBOutlet NSPopUpButton *notificationTypeButton;
|
@property (weak) IBOutlet NSPopUpButton *notificationTypeButton;
|
||||||
|
@property (weak) IBOutlet NSColorWell *maskColorWell;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@ -19,6 +20,7 @@
|
||||||
|
|
||||||
- (void)viewDidLoad {
|
- (void)viewDidLoad {
|
||||||
[super viewDidLoad];
|
[super viewDidLoad];
|
||||||
|
[NSColorPanel.sharedColorPanel setShowsAlpha:YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)viewWillAppear {
|
- (void)viewWillAppear {
|
||||||
|
@ -27,13 +29,18 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)reloadData {
|
- (void)reloadData {
|
||||||
[self.notificationTypeButton selectItemAtIndex:[NSUserDefaults.standardUserDefaults integerForKey:WeChatTweakPreferenceRevokeNotificationTypeKey]];
|
self.maskColorWell.color = WeChatTweak.maskColor;
|
||||||
|
[self.notificationTypeButton selectItemAtIndex:WeChatTweak.notificationType];
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - Event method
|
#pragma mark - Event method
|
||||||
|
|
||||||
- (IBAction)switchNotificationTypeAction:(NSPopUpButton *)sender {
|
- (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
|
#pragma mark - MASPreferencesViewController
|
||||||
|
|
|
@ -11,12 +11,6 @@
|
||||||
#import <objc/message.h>
|
#import <objc/message.h>
|
||||||
#import <JRSwizzle/JRSwizzle.h>
|
#import <JRSwizzle/JRSwizzle.h>
|
||||||
|
|
||||||
typedef NS_ENUM(NSUInteger, RevokeNotificationType) {
|
|
||||||
RevokeNotificationTypeInherited = 0,
|
|
||||||
RevokeNotificationTypeReceiveAll,
|
|
||||||
RevokeNotificationTypeDisable,
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef NS_ENUM(unsigned int, MessageDataType) {
|
typedef NS_ENUM(unsigned int, MessageDataType) {
|
||||||
MessageDataTypeText = 1,
|
MessageDataTypeText = 1,
|
||||||
MessageDataTypeImage = 3,
|
MessageDataTypeImage = 3,
|
||||||
|
@ -27,8 +21,6 @@ typedef NS_ENUM(unsigned int, MessageDataType) {
|
||||||
MessageDataTypePrompt = 10000
|
MessageDataTypePrompt = 10000
|
||||||
};
|
};
|
||||||
|
|
||||||
static NSString * const WeChatTweakPreferenceRevokeNotificationTypeKey = @"WeChatTweakPreferenceRevokeNotificationTypeKey";
|
|
||||||
|
|
||||||
@interface NSString (MD5)
|
@interface NSString (MD5)
|
||||||
|
|
||||||
- (NSString *)md5String;
|
- (NSString *)md5String;
|
||||||
|
|
|
@ -11,6 +11,15 @@
|
||||||
FOUNDATION_EXPORT double WeChatTweakVersionNumber;
|
FOUNDATION_EXPORT double WeChatTweakVersionNumber;
|
||||||
FOUNDATION_EXPORT const unsigned char WeChatTweakVersionString[];
|
FOUNDATION_EXPORT const unsigned char WeChatTweakVersionString[];
|
||||||
|
|
||||||
|
typedef NS_ENUM(NSUInteger, WeChatTweakNotificationType) {
|
||||||
|
WeChatTweakNotificationTypeInherited = 0,
|
||||||
|
WeChatTweakNotificationTypeReceiveAll,
|
||||||
|
WeChatTweakNotificationTypeDisable
|
||||||
|
};
|
||||||
|
|
||||||
@interface WeChatTweak : NSObject
|
@interface WeChatTweak : NSObject
|
||||||
|
|
||||||
|
@property (class, assign) WeChatTweakNotificationType notificationType;
|
||||||
|
@property (class, nonnull) NSColor *maskColor;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -10,4 +10,22 @@
|
||||||
|
|
||||||
@implementation WeChatTweak
|
@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
|
@end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user