Temporarily disable ripple on protected contents

This commit is contained in:
Isaac 2024-08-12 23:09:32 +08:00
parent 7313e25029
commit 127fdcbfbf
4 changed files with 90 additions and 0 deletions

View file

@ -32,4 +32,6 @@ NSObject * _Nullable makeLuminanceToAlphaFilter();
NSObject * _Nullable makeMonochromeFilter();
void setLayerDisableScreenshots(CALayer * _Nonnull layer, bool disableScreenshots);
bool getLayerDisableScreenshots(CALayer * _Nonnull layer);
void setLayerContentsMaskMode(CALayer * _Nonnull layer, bool maskMode);

View file

@ -1,5 +1,7 @@
#import "UIKitUtils.h"
#import <ObjCRuntimeUtils/RuntimeUtils.h>
#import <objc/runtime.h>
#if TARGET_IPHONE_SIMULATOR
@ -236,6 +238,7 @@ NSObject * _Nullable makeMonochromeFilter() {
return [(id<GraphicsFilterProtocol>)NSClassFromString(@"CAFilter") filterWithName:@"colorMonochrome"];
}
static const void *layerDisableScreenshotsKey = &layerDisableScreenshotsKey;
void setLayerDisableScreenshots(CALayer * _Nonnull layer, bool disableScreenshots) {
static UITextField *textField = nil;
@ -264,6 +267,17 @@ void setLayerDisableScreenshots(CALayer * _Nonnull layer, bool disableScreenshot
textField.secureTextEntry = false;
}
[secureView setValue:previousLayer forKey:@"layer"];
[layer setAssociatedObject:@(disableScreenshots) forKey:layerDisableScreenshotsKey associationPolicy:NSObjectAssociationPolicyRetain];
}
bool getLayerDisableScreenshots(CALayer * _Nonnull layer) {
id result = [layer associatedObjectForKey:layerDisableScreenshotsKey];
if ([result respondsToSelector:@selector(boolValue)]) {
return [(NSNumber *)result boolValue];
} else {
return false;
}
}
void setLayerContentsMaskMode(CALayer * _Nonnull layer, bool maskMode) {