Skip to content

Commit

Permalink
Update: 优化首页扫描 (#84)
Browse files Browse the repository at this point in the history
Co-authored-by: yvanpeng <[email protected]>
  • Loading branch information
yuanyuan100 and yvanpeng authored May 22, 2024
1 parent 57b42d8 commit 1cbaebf
Show file tree
Hide file tree
Showing 54 changed files with 5,290 additions and 5,214 deletions.
4 changes: 2 additions & 2 deletions Lemon/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>5.1.7</string>
<string>5.1.8</string>
<key>CFBundleVersion</key>
<string>1014</string>
<string>1015</string>
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>NSAppTransportSecurity</key>
Expand Down
20 changes: 20 additions & 0 deletions LemonClener/LemonClener.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,13 @@
7AE9F5F72865B8A60063E28E /* garbage_appstore_en.xml in Resources */ = {isa = PBXBuildFile; fileRef = 7AE9F5F32865B8A60063E28E /* garbage_appstore_en.xml */; };
7AE9F5F82865B8A60063E28E /* garbage_appstore_zh.xml in Resources */ = {isa = PBXBuildFile; fileRef = 7AE9F5F42865B8A60063E28E /* garbage_appstore_zh.xml */; };
805D3473EBC42DA7B37B9A80 /* Pods_LemonClener.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0CAB11E4EF733879C425039A /* Pods_LemonClener.framework */; };
B7302C432BDB9155001A81FC /* QMScanFileSizeCacheManager.h in Headers */ = {isa = PBXBuildFile; fileRef = B7302C412BDB9155001A81FC /* QMScanFileSizeCacheManager.h */; };
B7302C442BDB9155001A81FC /* QMScanFileSizeCacheManager.m in Sources */ = {isa = PBXBuildFile; fileRef = B7302C422BDB9155001A81FC /* QMScanFileSizeCacheManager.m */; };
B79FF4FC2BFB3A6F00F99813 /* LMCleanerDataCenter+LMCleanPatch.h in Headers */ = {isa = PBXBuildFile; fileRef = B79FF4FA2BFB3A6F00F99813 /* LMCleanerDataCenter+LMCleanPatch.h */; };
B79FF4FD2BFB3A6F00F99813 /* LMCleanerDataCenter+LMCleanPatch.m in Sources */ = {isa = PBXBuildFile; fileRef = B79FF4FB2BFB3A6F00F99813 /* LMCleanerDataCenter+LMCleanPatch.m */; };
B7B7038D2AFB7571002420C1 /* QMBaseScan.h in Headers */ = {isa = PBXBuildFile; fileRef = B7B7038B2AFB7571002420C1 /* QMBaseScan.h */; };
B7B7038E2AFB7571002420C1 /* QMBaseScan.m in Sources */ = {isa = PBXBuildFile; fileRef = B7B7038C2AFB7571002420C1 /* QMBaseScan.m */; };
B7CE30782BF6083A00F4AF89 /* QMCleanerDefine.h in Headers */ = {isa = PBXBuildFile; fileRef = B7CE30772BF6075B00F4AF89 /* QMCleanerDefine.h */; settings = {ATTRIBUTES = (Public, ); }; };
B7E252E72AFA75C600201DF9 /* QMWechatScan.h in Headers */ = {isa = PBXBuildFile; fileRef = B7E252E52AFA75C600201DF9 /* QMWechatScan.h */; };
B7E252E82AFA75C600201DF9 /* QMWechatScan.m in Sources */ = {isa = PBXBuildFile; fileRef = B7E252E62AFA75C600201DF9 /* QMWechatScan.m */; };
BC215A1C215C737100CBC906 /* QMMailUtil.h in Headers */ = {isa = PBXBuildFile; fileRef = BC215A1A215C737000CBC906 /* QMMailUtil.h */; };
Expand Down Expand Up @@ -557,8 +562,13 @@
7AE9F5F32865B8A60063E28E /* garbage_appstore_en.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = garbage_appstore_en.xml; sourceTree = "<group>"; };
7AE9F5F42865B8A60063E28E /* garbage_appstore_zh.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = garbage_appstore_zh.xml; sourceTree = "<group>"; };
A9034E812C8560B577617437 /* Pods-LemonClener.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-LemonClener.debug.xcconfig"; path = "../Pods/Target Support Files/Pods-LemonClener/Pods-LemonClener.debug.xcconfig"; sourceTree = "<group>"; };
B7302C412BDB9155001A81FC /* QMScanFileSizeCacheManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = QMScanFileSizeCacheManager.h; sourceTree = "<group>"; };
B7302C422BDB9155001A81FC /* QMScanFileSizeCacheManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = QMScanFileSizeCacheManager.m; sourceTree = "<group>"; };
B79FF4FA2BFB3A6F00F99813 /* LMCleanerDataCenter+LMCleanPatch.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "LMCleanerDataCenter+LMCleanPatch.h"; sourceTree = "<group>"; };
B79FF4FB2BFB3A6F00F99813 /* LMCleanerDataCenter+LMCleanPatch.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "LMCleanerDataCenter+LMCleanPatch.m"; sourceTree = "<group>"; };
B7B7038B2AFB7571002420C1 /* QMBaseScan.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = QMBaseScan.h; sourceTree = "<group>"; };
B7B7038C2AFB7571002420C1 /* QMBaseScan.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = QMBaseScan.m; sourceTree = "<group>"; };
B7CE30772BF6075B00F4AF89 /* QMCleanerDefine.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = QMCleanerDefine.h; sourceTree = "<group>"; };
B7E252E52AFA75C600201DF9 /* QMWechatScan.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = QMWechatScan.h; sourceTree = "<group>"; };
B7E252E62AFA75C600201DF9 /* QMWechatScan.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = QMWechatScan.m; sourceTree = "<group>"; };
BC215A1A215C737000CBC906 /* QMMailUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QMMailUtil.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1108,6 +1118,7 @@
F854B1F620F77677009102CF /* QMCleanerManager */ = {
isa = PBXGroup;
children = (
B7CE30772BF6075B00F4AF89 /* QMCleanerDefine.h */,
F854B1FD20F77677009102CF /* QMCleanerUtils.h */,
F854B1F720F77677009102CF /* QMCleanerUtils.m */,
F854B1FF20F77677009102CF /* QMRemoveManager.h */,
Expand Down Expand Up @@ -1155,6 +1166,8 @@
F854B25320F89D3E009102CF /* QMXMLItem */,
BC215A1A215C737000CBC906 /* QMMailUtil.h */,
BC215A1B215C737000CBC906 /* QMMailUtil.m */,
B7302C412BDB9155001A81FC /* QMScanFileSizeCacheManager.h */,
B7302C422BDB9155001A81FC /* QMScanFileSizeCacheManager.m */,
F854B24820F89D3E009102CF /* QMCleanUtils.h */,
F854B26520F89D3E009102CF /* QMCleanUtils.m */,
F854B26620F89D3E009102CF /* QMScanCategory.h */,
Expand Down Expand Up @@ -1228,6 +1241,8 @@
F86CE17221411C88009352F1 /* LMCleanResultModel.m */,
F893D5C72134193A00208817 /* LMCleanerDataCenter.h */,
F893D5C82134193A00208817 /* LMCleanerDataCenter.m */,
B79FF4FA2BFB3A6F00F99813 /* LMCleanerDataCenter+LMCleanPatch.h */,
B79FF4FB2BFB3A6F00F99813 /* LMCleanerDataCenter+LMCleanPatch.m */,
F86CE17A21412152009352F1 /* LMCleanShowModel.h */,
F86CE17B21412152009352F1 /* LMCleanShowModel.m */,
);
Expand Down Expand Up @@ -1292,6 +1307,7 @@
F85E76AE21C8ACFD005A3A19 /* InstallAppHelper.h in Headers */,
DEE6CED327BFB1F400B557C7 /* SubCategoryCellView.h in Headers */,
F871ED7621DDAA0000F178ED /* QMSoftScan.h in Headers */,
B79FF4FC2BFB3A6F00F99813 /* LMCleanerDataCenter+LMCleanPatch.h in Headers */,
F8457F81212BF121006D8ECB /* LMCleanScanViewController.h in Headers */,
F854B20320F77677009102CF /* QMLiteCleanerManager.h in Headers */,
DEA5D585279D06A800E96666 /* LMFileMoveIntroduceVC.h in Headers */,
Expand All @@ -1301,6 +1317,7 @@
F86CE17521411C89009352F1 /* LMCleanResultModel.h in Headers */,
F81C9074225F30C8008F260B /* LMAppSandboxHelper.h in Headers */,
DE7EA4072744D83F00187F73 /* LMWebViewController.h in Headers */,
B7302C432BDB9155001A81FC /* QMScanFileSizeCacheManager.h in Headers */,
F8457FA3212ECFC7006D8ECB /* CleanerCantant.h in Headers */,
F854B1F520F774D8009102CF /* QMDataConst.h in Headers */,
F820953B219BC9ED004B58C8 /* LMCleanerTableView.h in Headers */,
Expand Down Expand Up @@ -1353,6 +1370,7 @@
DEE6CED527BFB1F400B557C7 /* BigCleanParaentCellView.h in Headers */,
DE9E4F262797F5F200474163 /* LMMaskView.h in Headers */,
BC215A20215C750600CBC906 /* QMMailScan.h in Headers */,
B7CE30782BF6083A00F4AF89 /* QMCleanerDefine.h in Headers */,
B7B7038D2AFB7571002420C1 /* QMBaseScan.h in Headers */,
5C9AD2F821DDA5AF002AB2A2 /* AnimationHelper.h in Headers */,
DEE6CED627BFB1F400B557C7 /* CategoryCellView.h in Headers */,
Expand Down Expand Up @@ -1710,6 +1728,7 @@
F854B20120F77677009102CF /* QMCleanerUtils.m in Sources */,
DEE6CED427BFB1F400B557C7 /* ActionItemCellView.m in Sources */,
DEE6CED827BFB1F400B557C7 /* QMResultTableRowView.m in Sources */,
B7302C442BDB9155001A81FC /* QMScanFileSizeCacheManager.m in Sources */,
F86C7006222D05880070F9E0 /* QMItemCreateHelper.m in Sources */,
F8538A6A2190352F00BED180 /* LMBackImageButton.m in Sources */,
F854B27820F89D3F009102CF /* QMBaseItem.m in Sources */,
Expand All @@ -1733,6 +1752,7 @@
DE9E4F272797F5F200474163 /* LMMaskView.m in Sources */,
B7B7038E2AFB7571002420C1 /* QMBaseScan.m in Sources */,
F899F791215DC6E600947003 /* MacDeviceHelper.m in Sources */,
B79FF4FD2BFB3A6F00F99813 /* LMCleanerDataCenter+LMCleanPatch.m in Sources */,
F86CE17421411C89009352F1 /* LMCleanResultModel.m in Sources */,
F854B28720F89D3F009102CF /* QMCleanUtils.m in Sources */,
BC215A21215C750600CBC906 /* QMMailScan.m in Sources */,
Expand Down
8 changes: 6 additions & 2 deletions LemonClener/LemonClener/Controller/LMCleanBigViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -1005,6 +1005,7 @@ - (void)refreshStateValue:(QMBaseItem *)item {
}

if ([item isKindOfClass:[QMCategorySubItem class]]) {
// Category - item
QMCategorySubItem *currentItem = (QMCategorySubItem *)item;
if (totalSubCount == 0) {
if (item.m_stateValue != NSOffState) {
Expand All @@ -1018,10 +1019,11 @@ - (void)refreshStateValue:(QMBaseItem *)item {
} else if (checkOnFlags == 0 && checkMixFlags ==0) {
[[LMCleanerDataCenter shareInstance] addSubcateStatusToDatabaseWithId:[currentItem subCategoryID] selectStatus:CleanSubcateSelectStatusDeselect];
} else {
[[LMCleanerDataCenter shareInstance] addSubcateStatusToDatabaseWithId:[currentItem subCategoryID] selectStatus:CleanSubcateSelectStatusSelect];
[[LMCleanerDataCenter shareInstance] addSubcateStatusToDatabaseWithId:[currentItem subCategoryID] selectStatus:CleanSubcateSelectStatusDeselect];
}
}
} else if ([item isKindOfClass:[QMActionItem class]]) {
// Category - item - action
QMActionItem *currentItem = (QMActionItem *)item;
if (totalSubCount == 0) {
if (item.m_stateValue != NSOffState) {
Expand All @@ -1031,11 +1033,13 @@ - (void)refreshStateValue:(QMBaseItem *)item {
}
} else {
if (checkOnFlags == totalSubCount) {
// 子项全选
[[LMCleanerDataCenter shareInstance] addSubcateStatusToDatabaseWithId:[currentItem actionID ] selectStatus:CleanSubcateSelectStatusSelect];
} else if (checkOnFlags == 0 && checkMixFlags ==0) {
// 子项全选数量等于0 且 子项混合选中数量等于0(子项下还有子项)
[[LMCleanerDataCenter shareInstance] addSubcateStatusToDatabaseWithId:[currentItem actionID ] selectStatus:CleanSubcateSelectStatusDeselect];
} else {
[[LMCleanerDataCenter shareInstance] addSubcateStatusToDatabaseWithId:[currentItem actionID ] selectStatus:CleanSubcateSelectStatusSelect];
[[LMCleanerDataCenter shareInstance] addSubcateStatusToDatabaseWithId:[currentItem actionID ] selectStatus:CleanSubcateSelectStatusDeselect];
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions LemonClener/LemonClener/QMCleanerManager/QMCleanManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#import "QMResultItem.h"
#import <QMCoreFunction/McCoreFunction.h>
#import "QMCleanerUtils.h"
#import "QMCleanUtils.h"
#import "QMDataConst.h"
#import <QMCoreFunction/QMDataCenter.h>
#import "QMScanCategory.h"
Expand Down Expand Up @@ -391,7 +390,7 @@ - (BOOL)startCleaner
[removeItemDict setObject:removeSubItemDict forKey:categoryItem.categoryID];
}

return [_removeManager startCleaner:removeItemDict];
return [_removeManager startCleaner:removeItemDict actionSource:QMCleanerActionSourceHome];
}

- (void)cleanCategoryStart:(NSString *)categoryId{
Expand Down
16 changes: 16 additions & 0 deletions LemonClener/LemonClener/QMCleanerManager/QMCleanerDefine.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// QMCleanerDefine.h
// LemonClener
//
// Copyright © 2024 Tencent. All rights reserved.
//

#ifndef QMCleanerDefine_h
#define QMCleanerDefine_h

typedef NS_ENUM(NSUInteger, QMCleanerActionSource) {
QMCleanerActionSourceHome, // 首页清理
QMCleanerActionSourceMonitor, //状态栏清理
};

#endif /* QMCleanerDefine_h */
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

#import <Foundation/Foundation.h>
#import "QMCleanerDefine.h"

@protocol QMLiteCleanerDelegate <NSObject>

Expand All @@ -31,7 +32,7 @@
- (void)startScan; // 同步方法, 需在子线程调用.
- (void)stopScan;

- (void)startClean; // 同步方法, 需在子线程调用.
- (void)startCleanWithActionSource:(QMCleanerActionSource)source; // 同步方法, 需在子线程调用.

- (UInt64)resultSize;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#import "QMScanCategory.h"
#import "QMRemoveManager.h"
#import "QMXMLParseManager.h"
#import "QMCleanUtils.h"
#import "LMCleanerDataCenter.h"

@interface QMLiteCleanerManager()
Expand Down Expand Up @@ -117,7 +116,7 @@ - (void)stopScan
[_scanCategory setIsStopScan:YES];
}

- (void)startClean
- (void)startCleanWithActionSource:(QMCleanerActionSource)source
{
//在进入方法时,判断是否有清理在执行. 如果在执行,等待这次清理结束,采用这次清理的结果,否则,重新进行清理.
BOOL needWait = cleanning ? YES: NO;
Expand Down Expand Up @@ -150,7 +149,7 @@ - (void)startClean

[removeItemDict setObject:removeSubItemDict forKey:categoryItem.categoryID];
}
[_removeManager startCleaner:removeItemDict];
[_removeManager startCleaner:removeItemDict actionSource:source];

cleanning = NO;
[mTrashCleaningLock unlock];
Expand Down
3 changes: 2 additions & 1 deletion LemonClener/LemonClener/QMCleanerManager/QMRemoveManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#import <Foundation/Foundation.h>
#import "QMCategoryItem.h"
#import "QMWarnReultItem.h"
#import "QMCleanerDefine.h"

@protocol QMRemoveManagerDelegate <NSObject>

Expand Down Expand Up @@ -44,7 +45,7 @@

+ (QMRemoveManager *)getInstance;

- (BOOL)startCleaner:(NSDictionary *)categoryDict;
- (BOOL)startCleaner:(NSDictionary *)categoryDict actionSource:(QMCleanerActionSource)source;

- (NSArray *)warnResultItemArray;
- (BOOL)canRemoveWarnItem;
Expand Down
9 changes: 5 additions & 4 deletions LemonClener/LemonClener/QMCleanerManager/QMRemoveManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,8 @@ - (NSInteger)getTotalCount:(NSMutableDictionary *)dict



- (void)processClean:(NSMutableDictionary *)resultDict {
- (void)processClean:(NSMutableDictionary *)resultDict actionSource:(QMCleanerActionSource)source {

NSInteger totalwarnSize = 0;
self->cleanedItemCount = 0;
[self processLanguageItemArray:resultDict];
Expand All @@ -665,7 +666,7 @@ - (void)processClean:(NSMutableDictionary *)resultDict {
});
}

- (BOOL)startCleaner:(NSMutableDictionary *)resultDict
- (BOOL)startCleaner:(NSMutableDictionary *)resultDict actionSource:(QMCleanerActionSource)source
{
__weak QMRemoveManager *weakSelf = self;
NSLog(@"%p, %p, startCleaner", self, self.class);
Expand Down Expand Up @@ -715,12 +716,12 @@ - (BOOL)startCleaner:(NSMutableDictionary *)resultDict
dispatch_async(dispatch_get_global_queue(0, 0), ^{
QMRemoveManager *strongSelf = weakSelf;

[strongSelf processClean:removeItemDict];
[strongSelf processClean:removeItemDict actionSource:source];
});
}
else
{
[self processClean:removeItemDict];
[self processClean:removeItemDict actionSource:source];
}
return YES;
}
Expand Down
18 changes: 15 additions & 3 deletions LemonClener/LemonClener/Util/InstallAppHelper.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@
//

#import "InstallAppHelper.h"
#import "QMCleanUtils.h"

@implementation InstallAppHelper

//白名单 比如有的软件适配始终无垃圾的白名单过滤
static NSArray * getWhiteAppList() {
static NSArray * getWhiteAppList(void) {
static NSArray *whiteAppLists = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
Expand All @@ -35,10 +34,23 @@ +(NSMutableDictionary *)getInstallBundleIds{
NSArray *properties = nil;
NSArray *installArr = nil;
@try {
/*
在macOS13.0之后 '/Applications/Safari.app' 默认为隐藏文件。
因此不能再使用NSDirectoryEnumerationSkipsHiddenFiles,修改为NSDirectoryEnumerationSkipsSubdirectoryDescendants|NSDirectoryEnumerationSkipsPackageDescendants,浅层遍历,不会遍历子目录,也不会遍历Package,更加符合需求
后续判断(扩展名 != .app)会将隐藏的非应用的路径过滤掉
NSString *path = [appUrl path];
if (![[[path pathExtension] lowercaseString] isEqualToString:@"app"]){
continue;
}
*/

installArr = [[NSFileManager defaultManager]
contentsOfDirectoryAtURL:[urls objectAtIndex:0]
includingPropertiesForKeys:properties
options:(NSDirectoryEnumerationSkipsHiddenFiles)
options:NSDirectoryEnumerationSkipsSubdirectoryDescendants|NSDirectoryEnumerationSkipsPackageDescendants
error:&error];
} @catch (NSException *exception) {
NSLog(@"getInstallBundleIds exception = %@", exception);
Expand Down
Loading

0 comments on commit 1cbaebf

Please sign in to comment.