Selaa lähdekoodia

1.需求:清理缓存功能

huangxiaodong 1 vuosi sitten
vanhempi
commit
3a5ab8f4ca
15 muutettua tiedostoa jossa 599 lisäystä ja 41 poistoa
  1. 22 0
      创维盒子/双子星云手机/Assets.xcassets/Set/app_clear_cache.imageset/Contents.json
  2. BIN
      创维盒子/双子星云手机/Assets.xcassets/Set/app_clear_cache.imageset/app_clear_cache@2x.png
  3. BIN
      创维盒子/双子星云手机/Assets.xcassets/Set/app_clear_cache.imageset/app_clear_cache@3x.png
  4. 22 0
      创维盒子/双子星云手机/Assets.xcassets/common/common_did_check.imageset/Contents.json
  5. BIN
      创维盒子/双子星云手机/Assets.xcassets/common/common_did_check.imageset/common_did_check@2x.png
  6. BIN
      创维盒子/双子星云手机/Assets.xcassets/common/common_did_check.imageset/common_did_check@3x.png
  7. 22 0
      创维盒子/双子星云手机/Assets.xcassets/common/common_un_check.imageset/Contents.json
  8. BIN
      创维盒子/双子星云手机/Assets.xcassets/common/common_un_check.imageset/common_un_check@2x.png
  9. BIN
      创维盒子/双子星云手机/Assets.xcassets/common/common_un_check.imageset/common_un_check@3x.png
  10. 1 0
      创维盒子/双子星云手机/Class/Set/MySetViewController.h
  11. 187 1
      创维盒子/双子星云手机/Class/Set/MySetViewController.m
  12. 22 0
      创维盒子/双子星云手机/Class/Set/clearCache/clearCacheAlretViewController.h
  13. 265 0
      创维盒子/双子星云手机/Class/Set/clearCache/clearCacheAlretViewController.m
  14. 54 40
      创维盒子/双子星云手机/Class/Set/view/mySetHeadView.m
  15. 4 0
      创维盒子/双子星云手机/zh-Hans.lproj/Localizable.strings

+ 22 - 0
创维盒子/双子星云手机/Assets.xcassets/Set/app_clear_cache.imageset/Contents.json

@@ -0,0 +1,22 @@
+{
+  "images" : [
+    {
+      "idiom" : "universal",
+      "scale" : "1x"
+    },
+    {
+      "filename" : "app_clear_cache@2x.png",
+      "idiom" : "universal",
+      "scale" : "2x"
+    },
+    {
+      "filename" : "app_clear_cache@3x.png",
+      "idiom" : "universal",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  }
+}

BIN
创维盒子/双子星云手机/Assets.xcassets/Set/app_clear_cache.imageset/app_clear_cache@2x.png


BIN
创维盒子/双子星云手机/Assets.xcassets/Set/app_clear_cache.imageset/app_clear_cache@3x.png


+ 22 - 0
创维盒子/双子星云手机/Assets.xcassets/common/common_did_check.imageset/Contents.json

@@ -0,0 +1,22 @@
+{
+  "images" : [
+    {
+      "idiom" : "universal",
+      "scale" : "1x"
+    },
+    {
+      "filename" : "common_did_check@2x.png",
+      "idiom" : "universal",
+      "scale" : "2x"
+    },
+    {
+      "filename" : "common_did_check@3x.png",
+      "idiom" : "universal",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  }
+}

BIN
创维盒子/双子星云手机/Assets.xcassets/common/common_did_check.imageset/common_did_check@2x.png


BIN
创维盒子/双子星云手机/Assets.xcassets/common/common_did_check.imageset/common_did_check@3x.png


+ 22 - 0
创维盒子/双子星云手机/Assets.xcassets/common/common_un_check.imageset/Contents.json

@@ -0,0 +1,22 @@
+{
+  "images" : [
+    {
+      "idiom" : "universal",
+      "scale" : "1x"
+    },
+    {
+      "filename" : "common_un_check@2x.png",
+      "idiom" : "universal",
+      "scale" : "2x"
+    },
+    {
+      "filename" : "common_un_check@3x.png",
+      "idiom" : "universal",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  }
+}

BIN
创维盒子/双子星云手机/Assets.xcassets/common/common_un_check.imageset/common_un_check@2x.png


BIN
创维盒子/双子星云手机/Assets.xcassets/common/common_un_check.imageset/common_un_check@3x.png


+ 1 - 0
创维盒子/双子星云手机/Class/Set/MySetViewController.h

@@ -6,6 +6,7 @@
 //
 
 #import "BaseViewController.h"
+#import "backupsFileManager.h"
 
 NS_ASSUME_NONNULL_BEGIN
 

+ 187 - 1
创维盒子/双子星云手机/Class/Set/MySetViewController.m

@@ -34,6 +34,7 @@
 #import "uploadFileDataModel.h"
 #import "uploadFileManager.h"
 #import "downloadManager.h"
+#import "clearCacheAlretViewController.h"
 
 @interface MySetViewController ()<HelpDownScrollViewDelegate,UITableViewDelegate,UITableViewDataSource,ComontAlretViewControllerDelegate>
 {
@@ -132,7 +133,7 @@
         CGFloat PrivacyBgW = SCREEN_W - 20;
         CGFloat PrivacyBgH = 116.0 * PrivacyBgW / (345.0);
         
-        CGFloat totalHeight = 10 + PrivacyBgH + (110+15) + (110+15)+(135+15);
+        CGFloat totalHeight = 10 + PrivacyBgH + (110+15) + (110+15)+(135+ 88 + 15);
         
 
         _customTableHeadView = [[mySetHeadView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, totalHeight)];
@@ -298,6 +299,11 @@
                 [self.navigationController pushViewController:vc animated:YES];
             }
             break;
+        case 15:
+            {
+                [self clickClearCacheButtonFun];
+            }
+            break;
         default:
             break;
     }
@@ -879,4 +885,184 @@
 
     });
 }
+
+#pragma mark 清理缓存相关
+- (void)clickClearCacheButtonFun
+{
+    KWeakSelf
+    /*弹窗提示清除缓存*/
+    clearCacheAlretViewController *nextVC = [[clearCacheAlretViewController alloc] initWithTiTle:NSLocalizedString(@"my_set_no_clear_cache",nil)
+                                                                                     msg:NSLocalizedString(@"clear_cache_tip",nil)
+                                                                                imageStr:nil
+                                                                             cancelTitle:NSLocalizedString(@"other_cancel",nil)
+                                                                                 okTitle:NSLocalizedString(@"other_clear",nil) isOkBtnHighlight:YES
+                                                                                      didClickOk:^(BOOL isSelect) {
+        [weakSelf handleClearCacheFunWith:isSelect];
+    } didClickCancel:^{
+        
+    }];
+    nextVC.modalPresentationStyle = UIModalPresentationCustom;
+    [self presentViewController:nextVC animated:YES completion:^{
+        nextVC.view.superview.backgroundColor = [UIColor clearColor];
+    }];
+    
+}
+
+
+- (void)handleClearCacheFunWith:(BOOL)isSelectFileTransfer
+{
+    [self ClearCommonCacheFun];
+    
+    if(isSelectFileTransfer){
+        [self clearCacheByFileTransferFun];
+    }
+}
+
+- (void)ClearCommonCacheFun
+{
+    NSString *ruiyunLogPath = [NSString stringWithFormat:@"%@/logs/debug_0.log",CachesPatch];
+    [[NSFileManager defaultManager] removeItemAtPath:ruiyunLogPath error:nil];
+    
+    NSString *appLogPath = [NSString stringWithFormat:@"%@/logs/app.log",CachesPatch];
+    [[NSFileManager defaultManager] removeItemAtPath:appLogPath error:nil];
+    
+    //
+    NSString *downLoadThumbnailPath = [NSString stringWithFormat:@"%@/DownLoadThumbnail",CachesPatch];
+    [[NSFileManager defaultManager] removeItemAtPath:downLoadThumbnailPath error:nil];
+}
+
+- (void)clearCacheByFileTransferFun
+{
+    //清理图片
+    BOOL needReUploadingType = NO;
+    NSString *ImagePath = [NSString stringWithFormat:@"%@/Image",CachesPatch];
+    if([uploadFileManager shareInstance].curUploadFileDataModel
+       && [uploadFileManager shareInstance].curUploadFileDataModel.curUploadFileType == uploadFileTypeImage
+       && [uploadFileManager shareInstance].curUploadFileDataModel.curUploadStateType == uploadStateUploading){
+        
+        [uploadFileManager shareInstance].curUploadFileDataModel.curUploadStateType = uploadStateSuspend;
+        needReUploadingType  = YES;
+    }
+    
+    [[NSFileManager defaultManager] removeItemAtPath:ImagePath error:nil];
+    
+    if(needReUploadingType){
+        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
+            [uploadFileManager shareInstance].curUploadFileDataModel.curUploadStateType = uploadStateUploading;
+        });
+    }
+    
+    //清理视频文件
+    NSString *videoPath = [NSString stringWithFormat:@"%@/Video",CachesPatch];
+    
+    NSString *backupsingVideoName = nil;
+    if([backupsFileManager shareInstance].curPhotosBackupsTaskMod
+       && [backupsFileManager shareInstance].curPhotosBackupsTaskMod.curUploadFileType == uploadFileTypeVideo){
+        backupsingVideoName = [backupsFileManager shareInstance].curPhotosBackupsTaskMod.filename;
+    }
+    
+    NSString *uploadingVideoName = nil;
+    if([uploadFileManager shareInstance].curUploadFileDataModel
+       && [uploadFileManager shareInstance].curUploadFileDataModel.curUploadFileType == uploadFileTypeVideo){
+        uploadingVideoName = [uploadFileManager shareInstance].curUploadFileDataModel.filename;
+    }
+    
+    if(backupsingVideoName || uploadingVideoName){
+        
+        NSMutableString *fileName = [NSMutableString new];
+        
+        if(backupsingVideoName){
+            [fileName appendString:backupsingVideoName];
+        }
+        
+        if(uploadingVideoName){
+            if(fileName.length > 0){
+                [fileName appendString:@"|"];
+            }
+            
+            [fileName appendString:uploadingVideoName];
+        }
+        
+        [self deleteFilesInDirectoryAtPath:videoPath withOutFileName:fileName];
+    }
+    else{
+        [[NSFileManager defaultManager] removeItemAtPath:videoPath error:nil];
+    }
+    
+    
+    //清理下载中
+    NSString *downLoadingPath = [NSString stringWithFormat:@"%@/DownLoadFlie",CachesPatch];
+    
+    NSString *downLoadingFileName = nil;
+    if([downloadManager shareInstance].curDownloadFileModel
+       && ([downloadManager shareInstance].curDownloadFileModel.curDownloadStateType == downloadStateUploading
+           ||[downloadManager shareInstance].curDownloadFileModel.curDownloadStateType == downloadStateSuspend)){
+        downLoadingFileName = [[downloadManager shareInstance].curDownloadFileModel getFileNameFun];
+        
+        [self deleteFilesInDirectoryAtPath:downLoadingPath withOutFileName:downLoadingFileName];
+    }
+    else{
+        [[NSFileManager defaultManager] removeItemAtPath:downLoadingPath error:nil];
+    }
+    
+    //清理数据库表 完成的
+    
+    //下载完成
+    NSMutableString* where = [[NSMutableString alloc] initWithString:@"where "];
+    NSString *curStr =  [NSString stringWithFormat:@"%@=%@ ",bg_sqlKey(@"curDownloadStateType"),bg_sqlValue([NSNumber numberWithInt:downloadStateDone])];
+    [where appendString:curStr];
+    
+    [couldPhoneFileModel bg_deleteAsync:download_tableName where:where complete:^(BOOL isSuccess) {
+    }];
+    
+    //上传完成
+    NSMutableString* where2 = [[NSMutableString alloc] initWithString:@"where "];
+    NSString *curStr2 =  [NSString stringWithFormat:@"%@=%@ ",bg_sqlKey(@"curUploadStateType"),bg_sqlValue([NSNumber numberWithInt:uploadStateDone])];
+    [where2 appendString:curStr2];
+    
+    [uploadFileDataModel bg_deleteAsync:upLoadFile_image_tableName where:where2 complete:^(BOOL isSuccess) {
+    }];
+    
+}
+
+- (BOOL)deleteFilesInDirectoryAtPath:(NSString *)path withOutFileName:(NSString*)fileNames {
+    NSFileManager *fileManager = [NSFileManager defaultManager];
+    
+    NSArray *fileNameArr = [fileNames componentsSeparatedByString:@"|"];
+    
+    
+    // 使用NSDirectoryEnumerator遍历目录
+    NSDirectoryEnumerator *directoryEnumerator = [fileManager enumeratorAtPath:path];
+    NSString *fileName;
+    while ((fileName = [directoryEnumerator nextObject])) {
+        
+        BOOL canDelType = YES;
+        
+        for (NSString*noDelfileName in fileNameArr) {
+            if([noDelfileName isEqualToString:fileName]){
+                canDelType = NO;
+                break;
+            }
+        }
+        
+        if(canDelType){
+            NSString *filePath = [path stringByAppendingPathComponent:fileName];
+              
+            // 如果是文件,则删除它
+            if ([fileManager fileExistsAtPath:filePath]) {
+                BOOL success = [fileManager removeItemAtPath:filePath error:nil];
+                if (!success) {
+                    // 如果删除失败,返回NO并处理错误
+                    return NO;
+                }
+            }
+        }
+        
+    }
+      
+    // 所有文件都成功删除,返回YES
+    return YES;
+}
+
+
 @end

+ 22 - 0
创维盒子/双子星云手机/Class/Set/clearCache/clearCacheAlretViewController.h

@@ -0,0 +1,22 @@
+//
+//  clearCacheAlretViewController.h
+//  双子星云手机
+//
+//  Created by xd h on 2024/3/29.
+//
+
+#import "BaseViewController.h"
+#import "ComontAlretViewController.h"
+
+NS_ASSUME_NONNULL_BEGIN
+
+/**
+ *  点击确定
+ */
+typedef void (^clearCacheAlert_ClickOkBtn) (BOOL isSelect);
+
+@interface clearCacheAlretViewController : BaseViewController
+- (id)initWithTiTle:(NSString *)title msg:(NSString *)msg imageStr:(NSString *)images cancelTitle:(NSString *)cancelTitle okTitle:(NSString *)okTitle isOkBtnHighlight:(BOOL)okBtnHighlight didClickOk:(clearCacheAlert_ClickOkBtn)ok didClickCancel:(CommonAlert_ClickCancelBtn)Cancel;
+@end
+
+NS_ASSUME_NONNULL_END

+ 265 - 0
创维盒子/双子星云手机/Class/Set/clearCache/clearCacheAlretViewController.m

@@ -0,0 +1,265 @@
+//
+//  clearCacheAlretViewController.m
+//  双子星云手机
+//
+//  Created by xd h on 2024/3/29.
+//
+
+#import "clearCacheAlretViewController.h"
+
+@interface clearCacheAlretViewController (){
+    NSString *titleStr;
+    NSString *msgStr;
+    NSString *imageStr;
+    NSString *cancelTitleStr;
+    NSString *okTitleStr;
+    BOOL isOkBtnHighlight;
+    
+    clearCacheAlert_ClickOkBtn didClickOkBtn;
+    CommonAlert_ClickCancelBtn didClickCanaelBtn;
+    
+    UIButton *selectBut;
+}
+
+@end
+
+@implementation clearCacheAlretViewController
+
+- (id)initWithTiTle:(NSString *)title msg:(NSString *)msg imageStr:(NSString *)image cancelTitle:(NSString *)cancelTitle okTitle:(NSString *)okTitle isOkBtnHighlight:(BOOL)okBtnHighlight didClickOk:(clearCacheAlert_ClickOkBtn)ok didClickCancel:(CommonAlert_ClickCancelBtn)Cancel{
+    self = [super init];
+    
+    titleStr = title;
+    msgStr = msg;
+    imageStr = image;
+    cancelTitleStr = cancelTitle;
+    okTitleStr = okTitle;
+    isOkBtnHighlight = okBtnHighlight;
+    
+    didClickOkBtn = ok;
+    didClickCanaelBtn = Cancel;
+    return  self;
+}
+
+- (void)viewDidLoad {
+    [super viewDidLoad];
+    // Do any additional setup after loading the view.
+    
+    [self drawAnyView];
+}
+
+- (void)drawAnyView{
+    [self.view setBackgroundColor:HW000000Color60];
+    
+    [self.toolBar setHidden:YES];
+    [self.navigationBar setHidden:YES];
+        
+    UIView *bgView = [[UIView alloc] init];
+    [bgView setBackgroundColor:[UIColor whiteColor]];
+    [bgView.layer setCornerRadius:8.f];
+    
+    [self.view addSubview:bgView];
+        
+    [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.centerY.equalTo(self.view.mas_centerY).offset(10*HAUTOSCALE);
+        make.centerX.equalTo(self.view.mas_centerX);
+        make.width.mas_equalTo(300.f);
+    }];
+    
+    CGFloat curTop = 30.0;
+    
+    //图片
+    UIImageView *topImageView = [[UIImageView alloc] init];
+    //topImageView.backgroundColor = [UIColor redColor];
+    
+    if(imageStr && imageStr.length > 0){
+        topImageView.image = [UIImage imageNamed:imageStr];
+        [bgView addSubview:topImageView];
+        [topImageView mas_makeConstraints:^(MASConstraintMaker *make) {
+            make.width.mas_equalTo(80.f);
+            make.height.mas_equalTo(80.f);
+            make.centerX.equalTo(bgView.mas_centerX);;
+            make.top.mas_equalTo(curTop);
+        }];
+        
+        curTop = 30 + 80 + 10.0;
+    }
+    
+    /*主标题*/
+    UILabel *titleLabel = [[UILabel alloc] init];
+    [titleLabel setTextColor:HW0A132BColor];
+    [titleLabel setFont:[UIFont boldSystemFontOfSize:16.f]];
+    [titleLabel setTextAlignment:(NSTextAlignmentCenter)];
+    [titleLabel setText:titleStr];
+    [titleLabel setNumberOfLines:0];
+    
+    if (titleStr.length > 0){
+        [bgView addSubview:titleLabel];
+        [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
+            make.left.mas_equalTo(8.f);
+            make.right.mas_equalTo(-8.f);
+            make.top.mas_equalTo(curTop);
+        }];
+    }
+    
+    /*副标题*/
+    UILabel *msgLabel = [[UILabel alloc] init];
+    [msgLabel setTextColor:HW333333Color];
+    [msgLabel setFont:[UIFont systemFontOfSize:15.f]];
+    [msgLabel setTextAlignment:(NSTextAlignmentCenter)];
+    [msgLabel setText:msgStr];
+    [msgLabel setNumberOfLines:0];
+    
+    if (msgStr.length > 0){
+        [bgView addSubview:msgLabel];
+        [msgLabel mas_makeConstraints:^(MASConstraintMaker *make) {
+            make.left.mas_equalTo(8.f);
+            make.right.mas_equalTo(-8.f);
+            if (titleStr.length > 0){
+                make.top.equalTo(titleLabel.mas_bottom).offset(15.f);
+            }else{
+                make.top.mas_equalTo(curTop);
+            }
+        }];
+    }
+    
+    
+    //清理缓存中间添加另外的按钮
+    selectBut = [[UIButton alloc] init];
+    [selectBut setImage:[UIImage imageNamed:@"common_did_check"] forState:UIControlStateSelected];
+    [selectBut setImage:[UIImage imageNamed:@"common_un_check"] forState:UIControlStateNormal];
+    [selectBut setTitle:NSLocalizedString(@"clear_cache_include_file_Transfer",nil) forState:UIControlStateNormal];
+    selectBut.titleLabel.font = [UIFont systemFontOfSize:12.0];
+    [selectBut setTitleColor:[UIColor hwColor:@"#151515" alpha:1.0] forState:UIControlStateNormal];
+    [selectBut addTarget:self action:@selector(didClickSelectButtonFun:) forControlEvents:UIControlEventTouchUpInside];
+    
+    [bgView addSubview:selectBut];
+    [selectBut mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.left.mas_equalTo(8.f);
+        make.right.mas_equalTo(-8.f);
+        if (msgStr.length > 0){
+            make.top.equalTo(msgLabel.mas_bottom).offset(15.f);
+        }else{
+            make.top.equalTo(titleLabel.mas_bottom).offset(25.f);
+        }
+        make.height.mas_equalTo(20);
+    }];
+    
+    /*双按钮*/
+    /*取消*/
+    
+    /*取消按钮*/
+    UIButton *cancelBtn = [[UIButton alloc] init];
+    cancelBtn.frame = CGRectMake(0, 0, 115, 48.f);
+    CGFloat w_btn = 200;
+    if (okTitleStr.length > 0){
+        w_btn = 115;
+    }
+    
+    // gradient
+    CAGradientLayer *gl = [CAGradientLayer layer];
+    gl.frame = CGRectMake(0,0,w_btn,48.f);
+    gl.startPoint = CGPointMake(0, 0.5);
+    gl.endPoint = CGPointMake(1, 0.5);
+    gl.colors = @[(__bridge id)HW0CDEFDColor.CGColor, (__bridge id)HW058DFBColor.CGColor];
+    gl.locations = @[@(0), @(1.0f)];
+    
+    
+    if(!isOkBtnHighlight){
+        [cancelBtn.layer addSublayer:gl];
+        [cancelBtn setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
+    }
+    else{
+        [cancelBtn setTitleColor:HW0A132BColor forState:(UIControlStateNormal)];
+        [cancelBtn setBackgroundColor:HWE3E8F1Color];
+    }
+    
+    [cancelBtn addTarget:self action:@selector(cancelBtnClick) forControlEvents:(UIControlEventTouchUpInside)];
+    [cancelBtn setTitle:cancelTitleStr forState:(UIControlStateNormal)];
+    [cancelBtn.titleLabel setFont:[UIFont systemFontOfSize:16.f]];
+    [cancelBtn.layer setCornerRadius:8.f];
+    cancelBtn.clipsToBounds = YES;
+    cancelBtn.tag = 999;
+    [bgView addSubview:cancelBtn];
+    [cancelBtn mas_makeConstraints:^(MASConstraintMaker *make) {
+        if (okTitleStr.length > 0){
+            make.left.mas_equalTo(24);
+        }else{
+            make.centerX.equalTo(bgView.mas_centerX);
+        }
+//        if (msgStr.length > 0){
+//            make.top.equalTo(msgLabel.mas_bottom).offset(15.f);
+//        }else{
+//            make.top.equalTo(titleLabel.mas_bottom).offset(25.f);
+//        }
+        
+        make.top.equalTo(selectBut.mas_bottom).offset(25.f);
+        
+        make.width.mas_equalTo(w_btn);
+        make.bottom.equalTo(bgView.mas_bottom).offset(-30.f);
+        make.height.mas_equalTo(48.f);
+    }];
+    
+    
+    if (okTitleStr.length > 0){
+        /*残忍拒绝*/
+        UIButton *okBtn = [[UIButton alloc] init];
+        
+        if(!isOkBtnHighlight){
+            [okBtn setTitleColor:HW0A132BColor forState:(UIControlStateNormal)];
+            [okBtn setBackgroundColor:HWE3E8F1Color];
+        }
+        else{
+            [okBtn.layer addSublayer:gl];
+            [okBtn setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
+        }
+        
+        [okBtn addTarget:self action:@selector(okBtnClick) forControlEvents:(UIControlEventTouchUpInside)];
+        [okBtn setTitle:okTitleStr forState:(UIControlStateNormal)];
+        //[okBtn setTitleColor:HW0A132BColor forState:(UIControlStateNormal)];
+        [okBtn.titleLabel setFont:[UIFont systemFontOfSize:16.f]];
+        [okBtn.layer setCornerRadius:8.f];
+        //[okBtn setBackgroundColor:HWE3E8F1Color];
+        okBtn.clipsToBounds = YES;
+        
+        
+        
+        [bgView addSubview:okBtn];
+        [okBtn mas_makeConstraints:^(MASConstraintMaker *make) {
+            make.right.mas_equalTo(-24.f);
+            make.width.mas_equalTo(w_btn);
+            make.top.equalTo(cancelBtn.mas_top);
+            make.height.mas_equalTo(48.f);
+        }];
+    }
+}
+
+
+
+- (void)cancelBtnClick{
+    [self dismissViewControllerAnimated:YES completion:^{
+        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
+            
+            
+            if(self->didClickCanaelBtn){
+                self->didClickCanaelBtn();
+            }
+        });
+    }];
+}
+
+- (void)okBtnClick{
+    [self dismissViewControllerAnimated:YES completion:^{
+        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
+            
+            if(self->didClickOkBtn){
+                self->didClickOkBtn(self->selectBut.selected);
+            }
+        });
+    }];
+}
+
+- (void)didClickSelectButtonFun:(UIButton*)but
+{
+    but.selected = !but.selected;
+}
+@end

+ 54 - 40
创维盒子/双子星云手机/Class/Set/view/mySetHeadView.m

@@ -397,7 +397,7 @@
         make.left.mas_equalTo(10);
         make.top.mas_equalTo(fileBackupsBgView.mas_bottom).offset(15);
         make.right.mas_equalTo(-10);
-        make.height.mas_equalTo(135);
+        make.height.mas_equalTo(135 + 88);
     }];
     
     UILabel *otherTitleLabel = [[UILabel alloc] init];
@@ -418,61 +418,75 @@
                           NSLocalizedString(@"my_set_no_restart_phone",nil),
                           NSLocalizedString(@"my_set_no_Restore_Factory",nil),
                           NSLocalizedString(@"my_set_no_common_problem",nil),
-                          NSLocalizedString(@"my_set_no_check_update",nil)];
+                          NSLocalizedString(@"my_set_no_check_update",nil),
+                          NSLocalizedString(@"my_set_no_clear_cache",nil)];
     
-    NSArray *imageArr = @[@"icon_change_ohone",@"icon-gengxin",@"icon_Restore_Factory",@"icon_common_problem",@"app_update"];
+    NSArray *imageArr = @[@"icon_change_ohone",@"icon-gengxin",
+                          @"icon_Restore_Factory",@"icon_common_problem",
+                          @"app_update",@"app_clear_cache"];
     
-    CGFloat butWidth = (SCREEN_W -20)/titleArr.count;
+    //CGFloat butWidth = (SCREEN_W -20)/titleArr.count;
+    CGFloat butWidth = (SCREEN_W -20)/5;
     CGFloat butHeight = 88.0;
     
     for (int i=0; i<titleArr.count; i++) {
         
-        UILabel *curlab = [[UILabel alloc] init];
-        curlab.text = titleArr[i];
-        curlab.font = [UIFont systemFontOfSize:12.0];
-        curlab.textColor = [UIColor hwColor:@"#0A132B" alpha:1.0];
-        curlab.numberOfLines = 0;
-        curlab.textAlignment = NSTextAlignmentCenter;
-        [otherBgView addSubview:curlab];
-        
-        [curlab mas_makeConstraints:^(MASConstraintMaker *make) {
-            make.left.mas_equalTo(butWidth*i);
-            make.bottom.mas_equalTo(-10);
-            make.width.mas_equalTo(butWidth);
-            make.height.mas_equalTo(30);
-        }];
-        
-        UIButton *curImageV = [[UIButton alloc] init];
-        curImageV.userInteractionEnabled = NO;
-        [curImageV setImage:[UIImage imageNamed:imageArr[i]] forState:UIControlStateNormal];;
-        [otherBgView addSubview:curImageV];
+        UIButton *curButton = [UIButton buttonWithType:UIButtonTypeCustom];
+        curButton.tag = 10 + i;
         
-        [curImageV mas_makeConstraints:^(MASConstraintMaker *make) {
-            make.left.mas_equalTo(butWidth*i);
-            make.bottom.mas_equalTo(curlab.mas_top);
-            make.width.mas_equalTo(butWidth);
-            make.height.mas_equalTo(40);
-        }];
+        [curButton setImage:[UIImage imageNamed:imageArr[i]] forState:UIControlStateNormal];
+        [curButton setTitle:titleArr[i] forState:UIControlStateNormal];
+        [curButton setTitleColor:[UIColor hwColor:@"#0A132B" alpha:1.0] forState:UIControlStateNormal];
+        curButton.titleLabel.font = [UIFont systemFontOfSize:12.0];
         
-        UIButton *curButton = [[UIButton alloc] init];
-        //curButton.backgroundColor = [UIColor greenColor];
-        curButton.tag = 10 + i;
         [curButton addTarget:self action:@selector(didClickButFun:) forControlEvents:UIControlEventTouchUpInside];
-        //[curButton setTitle:titleArr[i] forState:UIControlStateNormal];
-        //[curButton setTitleColor:[UIColor hwColor:@"#0A132B" alpha:1.0] forState:UIControlStateNormal];
-        //[curButton setImage:[UIImage imageNamed:imageArr[i]] forState:UIControlStateNormal];
-        //curButton.titleLabel.font = [UIFont systemFontOfSize:12.0];
         [otherBgView addSubview:curButton];
+        //curButton.backgroundColor = [UIColor redColor];
 
         [curButton mas_makeConstraints:^(MASConstraintMaker *make) {
-            make.left.mas_equalTo(butWidth*i);
-            make.bottom.mas_equalTo(0);
+            make.left.mas_equalTo(butWidth*(i%5));
+            make.top.mas_equalTo(otherTitleLabel.mas_bottom).offset((i/5) * (butHeight));
             make.width.mas_equalTo(butWidth);
             make.height.mas_equalTo(butHeight);
         }];
         
-    
-
+        CGFloat titleOffset = 0.0;
+        
+        [curButton setTitleEdgeInsets:UIEdgeInsetsMake(curButton.imageView.frame.size.height+5,-curButton.imageView.frame.size.width, 0.0,0.0)];
+        [curButton setImageEdgeInsets:UIEdgeInsetsMake(-curButton.bounds.size.width/4+5, curButton.bounds.size.width/4-titleOffset, curButton.titleLabel.bounds.size.height, -curButton.bounds.size.width/4)];
+        
+        
+//        UILabel *curlab = [[UILabel alloc] init];
+//        curlab.text = titleArr[i];
+//        curlab.font = [UIFont systemFontOfSize:12.0];
+//        curlab.textColor = [UIColor hwColor:@"#0A132B" alpha:1.0];
+//        curlab.numberOfLines = 0;
+//        curlab.textAlignment = NSTextAlignmentCenter;
+//        [otherBgView addSubview:curlab];
+//        
+//        [curlab mas_makeConstraints:^(MASConstraintMaker *make) {
+//            make.left.mas_equalTo(butWidth);//* (i%5)
+//            make.bottom.mas_equalTo(-10);
+//            make.width.mas_equalTo(butWidth);
+//            make.height.mas_equalTo(30); //+ (i/5) * (butHeight + 12.0)
+//        }];
+//        curButton.backgroundColor = [UIColor greenColor];
+        
+//        UIButton *curImageV = [[UIButton alloc] init];
+//        curImageV.userInteractionEnabled = NO;
+//        [curImageV setImage:[UIImage imageNamed:imageArr[i]] forState:UIControlStateNormal];;
+//        [otherBgView addSubview:curImageV];
+//        
+//        [curImageV mas_makeConstraints:^(MASConstraintMaker *make) {
+//            make.left.mas_equalTo(butWidth*i);
+//            make.bottom.mas_equalTo(curlab.mas_top);
+//            make.width.mas_equalTo(butWidth);
+//            make.height.mas_equalTo(40);
+//        }];
+//        
+//        curImageV.backgroundColor = [UIColor orangeColor];
+        
+        
     }
 }
 

+ 4 - 0
创维盒子/双子星云手机/zh-Hans.lproj/Localizable.strings

@@ -423,3 +423,7 @@
 "File_Transfer_full_speed"   = "全速模式";
 "File_Transfer_full_speed_tip"   = "开启全速模式传输速度将会加快。建议在不使用云机的情况下开启,开启可能会影响云机操作体验";
 "File_backups_path_way_tip2"   = "相册文件默认备份至:";
+"my_set_no_clear_cache"   = "清理缓存";
+"other_clear"      = "清理";
+"clear_cache_tip"      = "清理的缓存包括上传下载图片、视频等缓存,请问是否清理?";
+"clear_cache_include_file_Transfer"      = "勾选清除上传/下载/备份完成及失败的记录";