Browse Source

1.app 安装到TV

huangxiaodong 2 months ago
parent
commit
f09c3dbc97

+ 1 - 0
创维盒子/code/NAS/NasPreviewAPPViewController.h

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

+ 51 - 5
创维盒子/code/NAS/NasPreviewAPPViewController.m

@@ -611,8 +611,8 @@
 
 - (void)userCheckFilePreviewByRow:(NSInteger)row
 {
-    if(row < _getInstalledAppListMod.data.count){
-        NASFileAudioDataModel* dataModel = _getInstalledAppListMod.data[row];
+    if(row < _curInstalledAppListMod.data.count){
+        NASFileAudioDataModel* dataModel = _curInstalledAppListMod.data[row];
         
         if(dataModel.isSelectType){
             [_didSelectListArr removeObject:dataModel];
@@ -633,7 +633,7 @@
     
     [_didSelectListArr removeAllObjects];
     
-    for (NASFileAudioDataModel* dataModel in _getInstalledAppListMod.data) {
+    for (NASFileAudioDataModel* dataModel in _curInstalledAppListMod.data) {
         
         if(!button.selected){
             dataModel.isSelectType = button.selected;
@@ -993,6 +993,21 @@
 {
     NSMutableDictionary*paraDict = [NSMutableDictionary new];
     
+    NSArray *diskNameArr = [_defaultDiskPath componentsSeparatedByString:@"/"];
+    if(diskNameArr && diskNameArr.count >= 2){
+        
+        NSString *name = diskNameArr.lastObject;
+        if(name.length == 0)
+        {
+            name = diskNameArr[diskNameArr.count -2];
+        }
+        
+        [paraDict setValue:name forKey:@"path"];
+    }
+    
+//    if(_defaultDiskPath){
+//        [paraDict setValue:_defaultDiskPath forKey:@"path"];
+//    }
     
 //    if(!isMoreDataType){
 //        self.pageIndex = 0;
@@ -1224,9 +1239,40 @@
 #pragma mark 安装APP到TV
 - (void)ClickInstallAPPToTVFun
 {
-    if (_didSelectListArr.count > 5) {
+    [self showInstallTVAlearViewFun];
+}
+
+#pragma mark 弹框二次确认安装到TV
+- (void)showInstallTVAlearViewFun
+{
+    NSInteger  selectNum = _didSelectListArr.count;
+    
+    NSString *titleStr = NSLocalizedString(@"alert_install_TV_title",nil);
+    NSString *tipStr1 = NSLocalizedString(@"alert_install_TV_msg_1",nil);
+    NSString *tipStr2 = NSLocalizedString(@"alert_install_TV_msg_2",nil);
+    NSString *tipStr3 = NSLocalizedString(@"alert_install_TV_msg_3",nil);
+
+    NSString * tipStr = [[NSString alloc] initWithFormat:@"%@%ld%@%ld%@",tipStr1,selectNum,tipStr2,selectNum*15,tipStr3];
+    
+    KWeakSelf
+    ComontAlretViewController *curAlretVC= [[ComontAlretViewController alloc] initWithTiTle:titleStr
+                                                                                      msg:tipStr
+                                                                                 imageStr:@""
+                                                                              cancelTitle:NSLocalizedString(@"other_cancel",nil)
+                                                                                  okTitle:NSLocalizedString(@"other_confirm",nil) isOkBtnHighlight:YES
+                                                                               didClickOk:^{
         
-    }
+        [[appToTVManager shareInstance] addAppToTVByList:weakSelf.didSelectListArr];
+     } didClickCancel:^{
+         
+     }];
+    
+    curAlretVC.modalPresentationStyle = UIModalPresentationCustom;
+     
+     [self presentViewController:curAlretVC animated:YES completion:^{
+         curAlretVC.view.superview.backgroundColor = [UIColor clearColor];
+     }];
 }
+
 @end
 

+ 20 - 0
创维盒子/code/NAS/appToTVManager/appToTVManager.h

@@ -0,0 +1,20 @@
+//
+//  appToTVManager.h
+//  隐私保护
+//
+//  Created by xd h on 2025/3/18.
+//
+
+#import <Foundation/Foundation.h>
+#import "getInstalledAppListModel.h"
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface appToTVManager : NSObject
+
++(instancetype)shareInstance;
+
+- (void)addAppToTVByList:(NSArray*)list;
+@end
+
+NS_ASSUME_NONNULL_END

+ 121 - 0
创维盒子/code/NAS/appToTVManager/appToTVManager.m

@@ -0,0 +1,121 @@
+//
+//  appToTVManager.m
+//  隐私保护
+//
+//  Created by xd h on 2025/3/18.
+//
+
+#import "appToTVManager.h"
+
+@interface appToTVManager ()
+@property(nonatomic,strong)NSMutableArray *waitingArr;//等待安装的app列表
+@property (nonatomic, strong) NSArray *installingArr;//正在安装的APP列表
+@property (nonatomic, assign) NSInteger installindex;//正在安装的顺序
+@end
+
+@implementation appToTVManager
++ (instancetype)shareInstance {
+    static appToTVManager *_instance;
+    static dispatch_once_t onceToken;
+    dispatch_once(&onceToken, ^{
+        _instance = [[self alloc] init];
+    });
+    return _instance;
+}
+
+- (void)addAppToTVByList:(NSArray*)list
+{
+    if(!list || list.count==0){
+        return;
+    }
+    
+    //第一次进入 安装中 待安装的都没有
+    if(!_installingArr && !_waitingArr){
+        _installingArr = [NSArray arrayWithArray:list];
+        
+        _installindex = 0;
+        [self beginToTVFun];
+    }
+    else{
+        
+        NSMutableArray *installList = [NSMutableArray new];
+        
+        if(!_waitingArr){
+            _waitingArr = [NSMutableArray array];
+        }
+        
+        //排重
+        for (getInstalledAppModel*model in list) {
+            BOOL canInstall = YES;
+            
+            for (getInstalledAppModel*waitingModel in _waitingArr) {
+                if([model.path isEqualToString:waitingModel.path]){
+                    canInstall = NO;
+                    break;
+                }
+            }
+            
+            if(canInstall){
+                for (getInstalledAppModel*installModel in _installingArr) {
+                    if([model.path isEqualToString:installModel.path]){
+                        canInstall = NO;
+                        break;
+                    }
+                }
+            }
+            
+            if (canInstall) {
+                [installList addObject:model];
+            }
+            
+        }
+        
+        [_waitingArr addObjectsFromArray:installList];
+    }
+}
+
+- (void)beginToTVFun
+{
+    if (_installindex >= _installingArr.count) {
+        _installindex = 0;
+        
+        if(_waitingArr.count > 0){
+            _installingArr = [NSArray arrayWithArray:_waitingArr];
+            [_waitingArr removeAllObjects];
+            [self beginToTVFun];
+        }
+        else {
+            _installingArr = @[];
+        }
+    }
+    else{
+        getInstalledAppModel*installModel = _installingArr[_installindex];
+        
+        NSMutableDictionary*paraDict = [NSMutableDictionary new];
+        
+        if (installModel.path) {
+            [paraDict setObject:installModel.path forKey:@"path"];
+        }
+        else{
+            _installindex++;
+            [self beginToTVFun];
+        }
+        
+        KWeakSelf
+        [[netWorkManager shareInstance] cloudPhoneGETCallBackCode:@"installApkToTv" Parameters:paraDict success:^(id  _Nonnull responseObject) {
+            SuperModel *model = [[SuperModel alloc] initWithDictionary:responseObject error:nil];
+            
+            if(model && model.status == 0){
+                
+            }
+            
+            weakSelf.installindex++;
+            [weakSelf beginToTVFun];
+            
+        } failure:^(NSError * _Nonnull error) {
+            
+        }];
+        
+    }
+}
+@end

+ 4 - 0
创维盒子/code/zh-Hans.lproj/Localizable.strings

@@ -673,3 +673,7 @@
 "nas_did_install_app_title"      = "已安装应用";
 "nas_un_install_app_title"      = "未安装应用";
 "edit_install_TV_title"      = "安装到TV";
+"alert_install_TV_title"      = "确认将选中应用安装到TV?";
+"alert_install_TV_msg_1"      = "安装成功后可以到“TV-我的-我的应用”查看,本次安装";
+"alert_install_TV_msg_2"      = "个文件预计需要";
+"alert_install_TV_msg_3"      = "秒。";

+ 20 - 0
创维盒子/双子星云手机.xcodeproj/project.pbxproj

@@ -629,6 +629,10 @@
 		6B5ECC942D76FB5D0069CB86 /* searchBarView.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B5ECC922D76FB5D0069CB86 /* searchBarView.m */; };
 		6B5ECC952D76FB5D0069CB86 /* searchBarView.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B5ECC912D76FB5D0069CB86 /* searchBarView.h */; };
 		6B5ECC962D76FB5D0069CB86 /* searchBarView.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B5ECC922D76FB5D0069CB86 /* searchBarView.m */; };
+		6B61F58D2D890E6F00C01A8A /* appToTVManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B61F58B2D890E6F00C01A8A /* appToTVManager.h */; };
+		6B61F58E2D890E6F00C01A8A /* appToTVManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B61F58C2D890E6F00C01A8A /* appToTVManager.m */; };
+		6B61F58F2D890E6F00C01A8A /* appToTVManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B61F58C2D890E6F00C01A8A /* appToTVManager.m */; };
+		6B61F5902D890E6F00C01A8A /* appToTVManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B61F58B2D890E6F00C01A8A /* appToTVManager.h */; };
 		6B63179C2BFD8CA000FF4FB4 /* videoPlayByAVPlayerViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B63179B2BFD8CA000FF4FB4 /* videoPlayByAVPlayerViewController.m */; };
 		6B63179D2BFD8CA000FF4FB4 /* videoPlayByAVPlayerViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B63179A2BFD8CA000FF4FB4 /* videoPlayByAVPlayerViewController.h */; };
 		6B63179E2BFD8CA000FF4FB4 /* videoPlayByAVPlayerViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B63179A2BFD8CA000FF4FB4 /* videoPlayByAVPlayerViewController.h */; };
@@ -1977,6 +1981,8 @@
 		6B5D867E2C22EA5B008D25EA /* lastFileManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = lastFileManager.m; sourceTree = "<group>"; };
 		6B5ECC912D76FB5D0069CB86 /* searchBarView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = searchBarView.h; sourceTree = "<group>"; };
 		6B5ECC922D76FB5D0069CB86 /* searchBarView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = searchBarView.m; sourceTree = "<group>"; };
+		6B61F58B2D890E6F00C01A8A /* appToTVManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = appToTVManager.h; sourceTree = "<group>"; };
+		6B61F58C2D890E6F00C01A8A /* appToTVManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = appToTVManager.m; sourceTree = "<group>"; };
 		6B63179A2BFD8CA000FF4FB4 /* videoPlayByAVPlayerViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = videoPlayByAVPlayerViewController.h; sourceTree = "<group>"; };
 		6B63179B2BFD8CA000FF4FB4 /* videoPlayByAVPlayerViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = videoPlayByAVPlayerViewController.m; sourceTree = "<group>"; };
 		6B6317A02BFD9DB500FF4FB4 /* ZFCustomControlView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ZFCustomControlView.h; sourceTree = "<group>"; };
@@ -3345,6 +3351,7 @@
 		6B5D86632C227C4A008D25EA /* NAS */ = {
 			isa = PBXGroup;
 			children = (
+				6B61F58A2D890E3100C01A8A /* appToTVManager */,
 				6B5ECC902D76FADD0069CB86 /* search */,
 				6BDB85B42D572FDC00526D1F /* BoxHeartbeatAlertTool */,
 				6BF62B122D55D57700E7A98A /* model */,
@@ -3405,6 +3412,15 @@
 			path = search;
 			sourceTree = "<group>";
 		};
+		6B61F58A2D890E3100C01A8A /* appToTVManager */ = {
+			isa = PBXGroup;
+			children = (
+				6B61F58B2D890E6F00C01A8A /* appToTVManager.h */,
+				6B61F58C2D890E6F00C01A8A /* appToTVManager.m */,
+			);
+			path = appToTVManager;
+			sourceTree = "<group>";
+		};
 		6B679DF42C25593800D0DC03 /* mine */ = {
 			isa = PBXGroup;
 			children = (
@@ -4289,6 +4305,7 @@
 				6B9354892BF2FE8700AA8D31 /* editTypeHeadView.h in Headers */,
 				6BC7414C2C240A670049BA8D /* webSocketManager+downloadFile.h in Headers */,
 				6B03C0D32D7A9A82001DE5CB /* NasPreviewAPPViewController.h in Headers */,
+				6B61F5902D890E6F00C01A8A /* appToTVManager.h in Headers */,
 				6B2C1E4A2C070ADE00FDCF82 /* ZFSpeedLoadingView.h in Headers */,
 				6BED888A2B4E819000F76DDC /* downloadFileRecordTableView.h in Headers */,
 				6B2C1E562C070ADE00FDCF82 /* UIScrollView+ZFPlayer.h in Headers */,
@@ -4594,6 +4611,7 @@
 				6B93548A2BF2FE8700AA8D31 /* editTypeHeadView.h in Headers */,
 				6BC7414E2C240A670049BA8D /* webSocketManager+downloadFile.h in Headers */,
 				6B03C0D12D7A9A82001DE5CB /* NasPreviewAPPViewController.h in Headers */,
+				6B61F58D2D890E6F00C01A8A /* appToTVManager.h in Headers */,
 				6B2C1E4B2C070ADE00FDCF82 /* ZFSpeedLoadingView.h in Headers */,
 				6BD506E52B9576A4006E7CB0 /* downloadFileRecordTableView.h in Headers */,
 				6B2C1E572C070ADE00FDCF82 /* UIScrollView+ZFPlayer.h in Headers */,
@@ -5054,6 +5072,7 @@
 				6B42A2142C40DC3D000555BB /* previewLandscapeTopMoreView.m in Sources */,
 				6BD507392B9576A4006E7CB0 /* downloadManager.m in Sources */,
 				6BD5073A2B9576A4006E7CB0 /* FMDatabaseQueue.m in Sources */,
+				6B61F58E2D890E6F00C01A8A /* appToTVManager.m in Sources */,
 				6B49BFCA2C943CE800E17406 /* webRtcManager+downloadNasFile.m in Sources */,
 				6B2C1E412C070ADE00FDCF82 /* ZFPortraitControlView.m in Sources */,
 				6BD5073B2B9576A4006E7CB0 /* customLaunchView.m in Sources */,
@@ -5441,6 +5460,7 @@
 				6B42A2122C40DC3D000555BB /* previewLandscapeTopMoreView.m in Sources */,
 				6B5D40402B4CE40F000965CF /* downloadManager.m in Sources */,
 				A08A950027E9A4E400C544BB /* FMDatabaseQueue.m in Sources */,
+				6B61F58F2D890E6F00C01A8A /* appToTVManager.m in Sources */,
 				6B49BFC72C943CE800E17406 /* webRtcManager+downloadNasFile.m in Sources */,
 				6B2C1E402C070ADE00FDCF82 /* ZFPortraitControlView.m in Sources */,
 				6BF52CA72AD7D3BE00A617DB /* customLaunchView.m in Sources */,