mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-13 22:52:26 +00:00
using nicer API for containsString
This commit is contained in:
@@ -32,13 +32,13 @@
|
|||||||
+ (BOOL)isCandidateForMalformedAutotype:(id)item {
|
+ (BOOL)isCandidateForMalformedAutotype:(id)item {
|
||||||
|
|
||||||
NSString *keystrokeSequence = @"";
|
NSString *keystrokeSequence = @"";
|
||||||
if([item isKindOfClass:[KPKEntry class]] && ![((KPKEntry *)item).autotype hasDefaultKeystrokeSequence]) {
|
if([item isKindOfClass:KPKEntry.class] && ![((KPKEntry *)item).autotype hasDefaultKeystrokeSequence]) {
|
||||||
keystrokeSequence = ((KPKEntry *)item).autotype.defaultKeystrokeSequence;
|
keystrokeSequence = ((KPKEntry *)item).autotype.defaultKeystrokeSequence;
|
||||||
}
|
}
|
||||||
else if( [item isKindOfClass:[KPKGroup class]] && ![item hasDefaultAutotypeSequence]) {
|
else if( [item isKindOfClass:KPKGroup.class] && ![item hasDefaultAutotypeSequence]) {
|
||||||
keystrokeSequence = ((KPKGroup *)item).defaultAutoTypeSequence;
|
keystrokeSequence = ((KPKGroup *)item).defaultAutoTypeSequence;
|
||||||
}
|
}
|
||||||
else if( [item isKindOfClass:[KPKWindowAssociation class]] && ![item hasDefaultKeystrokeSequence]){
|
else if( [item isKindOfClass:KPKWindowAssociation.class] && ![item hasDefaultKeystrokeSequence]){
|
||||||
keystrokeSequence = ((KPKWindowAssociation *)item).keystrokeSequence;
|
keystrokeSequence = ((KPKWindowAssociation *)item).keystrokeSequence;
|
||||||
}
|
}
|
||||||
/* if nothing is true, keystrokeSequence is nil an hence return is NO */
|
/* if nothing is true, keystrokeSequence is nil an hence return is NO */
|
||||||
@@ -57,10 +57,10 @@
|
|||||||
NSArray *autotypeEntries = usePreferredEntry ? [[NSArray alloc] initWithObjects:entry, nil] : [self.root autotypeableChildEntries];
|
NSArray *autotypeEntries = usePreferredEntry ? [[NSArray alloc] initWithObjects:entry, nil] : [self.root autotypeableChildEntries];
|
||||||
NSMutableArray *contexts = [[NSMutableArray alloc] initWithCapacity:MAX(1,ceil(autotypeEntries.count / 4.0))];
|
NSMutableArray *contexts = [[NSMutableArray alloc] initWithCapacity:MAX(1,ceil(autotypeEntries.count / 4.0))];
|
||||||
|
|
||||||
BOOL matchTitle = [[NSUserDefaults standardUserDefaults] boolForKey:kMPSettingsKeyAutotypeMatchTitle];
|
BOOL matchTitle = [NSUserDefaults.standardUserDefaults boolForKey:kMPSettingsKeyAutotypeMatchTitle];
|
||||||
BOOL matchURL = [[NSUserDefaults standardUserDefaults] boolForKey:kMPSettingsKeyAutotypeMatchURL];
|
BOOL matchURL = [NSUserDefaults.standardUserDefaults boolForKey:kMPSettingsKeyAutotypeMatchURL];
|
||||||
BOOL matchHost = [[NSUserDefaults standardUserDefaults] boolForKey:kMPSettingsKeyAutotypeMatchHost];
|
BOOL matchHost = [NSUserDefaults.standardUserDefaults boolForKey:kMPSettingsKeyAutotypeMatchHost];
|
||||||
BOOL matchTags = [[NSUserDefaults standardUserDefaults] boolForKey:kMPSettingsKeyAutotypeMatchTags];
|
BOOL matchTags = [NSUserDefaults.standardUserDefaults boolForKey:kMPSettingsKeyAutotypeMatchTags];
|
||||||
|
|
||||||
MPAutotypeContext *context;
|
MPAutotypeContext *context;
|
||||||
for(KPKEntry *entry in autotypeEntries) {
|
for(KPKEntry *entry in autotypeEntries) {
|
||||||
@@ -80,21 +80,22 @@
|
|||||||
/* Test for entry title in window title */
|
/* Test for entry title in window title */
|
||||||
if(matchTitle && !foundMatch) {
|
if(matchTitle && !foundMatch) {
|
||||||
/* TODO use kpk_finalValueForEntry */
|
/* TODO use kpk_finalValueForEntry */
|
||||||
foundMatch = [windowTitle rangeOfString:entry.title options:NSCaseInsensitiveSearch].length != 0 || [entry.title rangeOfString:windowTitle options:NSCaseInsensitiveSearch].length != 0;
|
foundMatch = ([windowTitle localizedCaseInsensitiveContainsString:entry.title]
|
||||||
|
|| [entry.title localizedCaseInsensitiveContainsString:windowTitle]);
|
||||||
}
|
}
|
||||||
/* test for URL */
|
/* test for URL */
|
||||||
if(matchURL && !foundMatch) {
|
if(matchURL && !foundMatch) {
|
||||||
foundMatch = [windowTitle rangeOfString:entry.url options:NSCaseInsensitiveSearch].length != 0;
|
foundMatch = [windowTitle localizedCaseInsensitiveContainsString:entry.url];
|
||||||
}
|
}
|
||||||
/* test for host */
|
/* test for host */
|
||||||
if(matchHost && !foundMatch) {
|
if(matchHost && !foundMatch) {
|
||||||
NSURL *url = [NSURL URLWithString:entry.url];
|
NSURL *url = [NSURL URLWithString:entry.url];
|
||||||
foundMatch = url.host != nil && [windowTitle rangeOfString:url.host options:NSCaseInsensitiveSearch].length != 0;
|
foundMatch = url.host != nil && [windowTitle localizedCaseInsensitiveContainsString:url.host];
|
||||||
}
|
}
|
||||||
/* test for tags */
|
/* test for tags */
|
||||||
if(matchTags && !foundMatch) {
|
if(matchTags && !foundMatch) {
|
||||||
for(NSString *tag in entry.tags) {
|
for(NSString *tag in entry.tags) {
|
||||||
foundMatch = ([windowTitle rangeOfString:tag options:NSCaseInsensitiveSearch].length != 0);
|
foundMatch = [windowTitle localizedCaseInsensitiveContainsString:tag];
|
||||||
if(foundMatch) {
|
if(foundMatch) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user