Bladeren bron

1.需求:重启盒子功能---后台接口OK 代理为实现

huangxiaodong 3 maanden geleden
bovenliggende
commit
7a8bd83e5e

+ 22 - 0
创维盒子/code/Assets.xcassets/cloudPhone/cloudPhone_restart_box.imageset/Contents.json

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

BIN
创维盒子/code/Assets.xcassets/cloudPhone/cloudPhone_restart_box.imageset/cloudPhone_restart_box@2x.png


BIN
创维盒子/code/Assets.xcassets/cloudPhone/cloudPhone_restart_box.imageset/cloudPhone_restart_box@3x.png


+ 77 - 2
创维盒子/code/cloudPhone/cloudPhoneViewController.m

@@ -14,6 +14,7 @@
 #import "audioPlayerViewController.h"
 #import "webRtcMsgModel.h"
 #import "webRtcPlayerViewController.h"
+#import "customRestartingBoxView.h"
 
 @interface cloudPhoneViewController ()
 @property (nonatomic,strong) cloudPhoneSetView *cloudPhoneSetV;
@@ -227,12 +228,18 @@
             
             KWeakSelf
             _cloudPhoneSetV.didClickButtonFun = ^(NSInteger tag) {
-                if (tag == 10) {//重启
+                if (tag == 10) {//应用上传
+                    
+                }
+                else if (tag == 11){//重启
                     [weakSelf didClickRestartFun];
                 }
-                else if (tag == 11){//恢复出厂
+                else if (tag == 12){//恢复出厂
                     [weakSelf RestoreFactoryAleartFun];
                 }
+                else if (tag == 13){//重启盒子
+                    [weakSelf didClickRestartBoxFun];
+                }
             };
         }
             break;
@@ -378,6 +385,74 @@
 }
 
 
+#pragma mark 点击重启盒子
+- (void)didClickRestartBoxFun
+{
+    KWeakSelf
+    /*弹窗提示恢复出厂*/
+    ComontAlretViewController *nextVC = [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"cloudPhone_restart_box_tip",nil)
+                                                                                     msg:NSLocalizedString(@"cloudPhone_restart_box_msg",nil)
+                                                                                imageStr:@""
+                                                                             cancelTitle:NSLocalizedString(@"other_cancel",nil)
+                                                                                 okTitle:NSLocalizedString(@"my_set_TVP2P_Open_sure",nil) isOkBtnHighlight:YES
+                                                                              didClickOk:^{
+        //点击确定
+        [weakSelf gotoRestartBoxFun];
+    } didClickCancel:^{
+       
+    }];
+    nextVC.modalPresentationStyle = UIModalPresentationCustom;
+    
+    [self presentViewController:nextVC animated:YES completion:^{
+        nextVC.view.superview.backgroundColor = [UIColor clearColor];
+    }];
+}
+
+#pragma mark  重启盒子
+- (void)gotoRestartBoxFun{
+    
+    NSString* curSn = ksharedAppDelegate.DeviceThirdIdMod.data.changeSn;
+    
+    NSMutableDictionary *paraDict = [NSMutableDictionary dictionary];
+    [paraDict setValue:curSn forKey:@"sn"];
+    [paraDict setValue:[NSNumber numberWithBool:YES] forKey:@"restartBox"];
+    
+    KWeakSelf
+    [[netWorkManager shareInstance] CommonPostCallBackCode:restartTheBox Parameters:paraDict success:^(id  _Nonnull responseObject) {
+      SuperModel *model = [[SuperModel alloc] initWithDictionary:responseObject error:nil];
+
+       if (model && model.status == 0) {
+           [weakSelf RestartBoxingFun];
+       }
+       else
+       {
+           
+       }
+
+    } failure:^(NSError * _Nonnull error) {
+        
+    }];
+}
+
+
+#pragma mark 重启盒子中
+- (void)RestartBoxingFun
+{
+    [webRtcManager shareManager].isReRestartIngBoxType = YES;
+    
+    customRestartingBoxView *view = [[customRestartingBoxView alloc] init];
+    [ksharedAppDelegate.window addSubview:view];
+    
+    [view mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.left.mas_equalTo(0.f);
+        make.bottom.mas_equalTo(0.f);
+        make.right.mas_equalTo(0.f);
+        make.top.mas_equalTo(0.f);
+    }];
+}
+
+#pragma mark 重启盒子成功
+
 - (void)viewWillAppear:(BOOL)animated{
     [super viewWillAppear:animated];
     [self handelAudioPlayingViewFun];

+ 6 - 5
创维盒子/code/cloudPhone/view/cloudPhoneSetView.m

@@ -62,16 +62,17 @@
         make.right.mas_equalTo(-12);
         make.width.mas_equalTo(curWhiteWidth);
         //make.width.mas_equalTo(132);
-        make.height.mas_equalTo(100);
+        make.height.mas_equalTo(200);
         //make.height.mas_equalTo(150);
     }];
     
-    NSArray *butImageArr = @[//@"cloudPhone_uploadApp",
-                              @"cloudPhone_reStart",@"cloudPhone_reset"];
+    NSArray *butImageArr = @[@"cloudPhone_uploadApp",
+                              @"cloudPhone_reStart",@"cloudPhone_reset",@"cloudPhone_restart_box"];
     
-    NSArray *butTextArr = @[//NSLocalizedString(@"cloudPhone_upload_app",nil),
+    NSArray *butTextArr = @[NSLocalizedString(@"cloudPhone_upload_app",nil),
                             NSLocalizedString(@"my_set_no_restart_phone",nil),
-                            NSLocalizedString(@"my_set_no_Restore_Factory",nil)];
+                            NSLocalizedString(@"my_set_no_Restore_Factory",nil),
+                            NSLocalizedString(@"cloudPhone_restart_box_title",nil)];
     
 
     CGFloat butHeight = 50.0;

+ 16 - 0
创维盒子/code/cloudPhone/view/customRestartingBoxView.h

@@ -0,0 +1,16 @@
+//
+//  customRestartingBoxView.h
+//  双子星云手机
+//
+//  Created by xd h on 2025/3/6.
+//
+
+#import <UIKit/UIKit.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface customRestartingBoxView : UIView
+- (void)colseFun;
+@end
+
+NS_ASSUME_NONNULL_END

+ 160 - 0
创维盒子/code/cloudPhone/view/customRestartingBoxView.m

@@ -0,0 +1,160 @@
+//
+//  customRestartingBoxView.m
+//  双子星云手机
+//
+//  Created by xd h on 2025/3/6.
+//
+
+#import "customRestartingBoxView.h"
+
+@interface customRestartingBoxView ()
+@property (nonatomic,strong)UIImageView *topImage;
+@end
+
+@implementation customRestartingBoxView
+
+- (id)initWithFrame:(CGRect)frame{
+    self = [super initWithFrame:frame];
+    self.backgroundColor = [UIColor hwColor:@"000000" alpha:0.6];
+    [self drawAnyView];
+    
+    return self;
+}
+
+- (void)drawAnyView{
+    UIView*whiteBgView = [UIView new];
+    whiteBgView.layer.cornerRadius = 8;
+    whiteBgView.backgroundColor = [UIColor whiteColor];
+    [self addSubview:whiteBgView];
+    
+    CGFloat curWhiteBgHeight = 300.f;
+    
+    ///获取设备当前地区的代码和APP语言环境
+    NSString *languageCode = [NSLocale preferredLanguages][0];
+
+    //目前支持 中文(简体 繁体) 英文 日语
+    if([languageCode rangeOfString:@"zh-Hans"].location != NSNotFound)
+    {
+    }
+    else if([languageCode rangeOfString:@"zh-Hant"].location != NSNotFound)
+    {
+    }
+    else{
+        curWhiteBgHeight = 500;
+    }
+    
+    [whiteBgView mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.height.mas_equalTo(curWhiteBgHeight);
+        make.width.mas_equalTo(300.f);
+        make.centerY.mas_equalTo(-40.f);
+        make.centerX.mas_equalTo(0.f);
+    }];
+    
+    _topImage = [[UIImageView alloc] init];
+    _topImage.image = [UIImage imageNamed:@"restart_loading"];
+    //_topImage.backgroundColor = [UIColor lightGrayColor];
+    [whiteBgView addSubview:_topImage];
+    
+    [_topImage mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.height.mas_equalTo(65.f);
+        make.width.mas_equalTo(63.f);
+        make.centerX.mas_equalTo(0.f);
+        make.top.mas_equalTo(30.f);
+    }];
+    
+    NSString *curTitleStr = NSLocalizedString(@"cloudPhone_restarting_box_title",nil);
+    UILabel *titleLab = [[UILabel alloc] init];
+    titleLab.text = curTitleStr;
+    titleLab.numberOfLines = 0;
+    titleLab.textColor = [UIColor hwColor:@"151515" alpha:1.0];
+    titleLab.font = [UIFont boldSystemFontOfSize:18.0];
+    titleLab.textAlignment = NSTextAlignmentCenter;
+    [whiteBgView addSubview:titleLab];
+    
+    [titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
+        //make.height.mas_equalTo(60);
+        make.right.mas_equalTo(-20.f);
+        make.left.mas_equalTo(20.f);
+        make.top.equalTo(_topImage.mas_bottom).offset(20);
+    }];
+    
+    NSString *tip1Str = NSLocalizedString(@"cloudPhone_restarting_box_msg",nil);
+    
+    
+    NSString*allTipStr = tip1Str;//[[NSString alloc] initWithFormat:@"%@%@%@",tip1Str,tip2Str,tip3Str];
+    
+    UILabel *tipaLab = [[UILabel alloc] init];
+    tipaLab.text = allTipStr;
+    tipaLab.numberOfLines = 0;
+    tipaLab.textColor = [UIColor hwColor:@"#666666"];
+    tipaLab.font = [UIFont systemFontOfSize:14.0];
+    tipaLab.textAlignment = NSTextAlignmentCenter;
+    [whiteBgView addSubview:tipaLab];
+    
+    [tipaLab mas_makeConstraints:^(MASConstraintMaker *make) {
+        //make.height.mas_equalTo(60);
+        make.right.mas_equalTo(-20.f);
+        make.left.mas_equalTo(20.f);
+        make.top.equalTo(titleLab.mas_bottom).offset(20);
+    }];
+    
+    
+    UIButton *knowBut = [[UIButton alloc] init];
+    [knowBut setTitle:NSLocalizedString(@"common_I_know",nil) forState:UIControlStateNormal];
+    //knowBut.layer.cornerRadius = 8;
+    //knowBut.layer.masksToBounds = YES;
+    [knowBut setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
+    [knowBut addTarget:self action:@selector(colseFun) forControlEvents:UIControlEventTouchUpInside];
+    [whiteBgView addSubview:knowBut];
+    
+    CAGradientLayer *gradientLayer = [CAGradientLayer layer];
+    gradientLayer.frame = CGRectMake(0, 0, 268, 40);
+    gradientLayer.colors = @[(__bridge NSString *)[UIColor hwColor:@"#0CDEFD" alpha:1.0].CGColor, (__bridge NSString *)[UIColor hwColor:@"#058DFB" alpha:1.0].CGColor];
+    gradientLayer.locations = @[@(0), @(1.0f)];
+    gradientLayer.startPoint = CGPointMake(0, 0.5);
+    gradientLayer.endPoint = CGPointMake(0.97, 0.5);
+    gradientLayer.cornerRadius = 8;
+    [knowBut.layer addSublayer:gradientLayer];
+
+//    knowBut.layer.shadowColor = [UIColor hwColor:@"#058DFB"].CGColor;
+//    // 设置阴影透明度(0.0到1.0)
+//    knowBut.layer.shadowOpacity = 0.5;
+//    // 设置阴影偏移量(x, y)
+//    knowBut.layer.shadowOffset = CGSizeMake(0, 3);
+//    // 设置阴影模糊半径
+//    knowBut.layer.shadowRadius = 5.0;
+//    // 为了使阴影在按钮外部可见,需要设置masksToBounds为NO
+//    // 注意:如果父视图设置了masksToBounds为YES,那么阴影可能仍然不可见
+//    knowBut.layer.masksToBounds = NO;
+    
+    [knowBut mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.height.mas_equalTo(40.f);
+        make.width.mas_equalTo(268.f);
+        make.centerX.mas_equalTo(0.f);
+        make.bottom.mas_equalTo(-30);
+    }];
+    
+    
+    [self startContinuousRotation];
+}
+
+
+- (void)colseFun
+{
+    [self stopContinuousRotation];
+    [self removeFromSuperview];
+}
+
+- (void)startContinuousRotation {
+    CABasicAnimation *rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
+    rotationAnimation.toValue = [NSNumber numberWithFloat:M_PI * 2.0]; // 旋转360度
+    rotationAnimation.duration = 2.0; // 旋转一圈的时间
+    rotationAnimation.repeatCount = HUGE_VALF; // 无限重复
+    [_topImage.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];
+}
+
+- (void)stopContinuousRotation {
+    [_topImage.layer removeAnimationForKey:@"rotationAnimation"];
+}
+@end
+

+ 5 - 0
创维盒子/code/netWork/newWorkInterface.h

@@ -186,5 +186,10 @@
  返回数据模型 */
 #define queryHeartbeat  @"/box/heartbeat/check/queryHeartbeat"
 
+/*27 重启盒子接口  POST请求
+输入参数 restartBox true=重启 false=不重启
+ 
+ 返回数据模型 */
+#define restartTheBox  @"/box/restartTheBox"
 
 #endif /* newWorkInterface_h */

+ 2 - 0
创维盒子/code/webRtc/webRtcManager/webRtcManager.h

@@ -16,6 +16,7 @@
 #import "queryHeartbeatModel.h"
 #import "BoxHeartbeatReStartSucView.h"
 #import "BoxHeartbeatReStartView.h"
+#import "customRestartingBoxView.h"
 
 NS_ASSUME_NONNULL_BEGIN
 
@@ -38,6 +39,7 @@ NS_ASSUME_NONNULL_BEGIN
 @property(nonatomic,assign)BOOL isChangeBoxType;//是否更换盒子
 @property(nonatomic,assign)BOOL isLogoutByOtherType;//被挤下线
 @property(nonatomic,assign)BOOL isWaitShowLogoutAlert;//隐私模式等待被挤下线弹框是否弹出
+@property(nonatomic,assign)BOOL isReRestartIngBoxType;//是否重启盒子中
 
 @property(nonatomic,assign)BOOL isDiDChangePhoneSizeType;//是否修改了分辨率(如果是 进去云机需要重设解码器)
 

+ 9 - 1
创维盒子/code/webRtc/webRtcManager/webRtcManager.m

@@ -228,6 +228,13 @@
         });
     }
     
+    if(self.isReRestartIngBoxType){
+        self.isReRestartIngBoxType = NO;
+        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
+            [self showReStartSucFun];
+        });
+    }
+    
 }
 
 #pragma mark 盒子第一次连接成功  给ws发送信息 单点登录 把其他账号挤下去
@@ -1213,7 +1220,8 @@
     NSArray * subViews = ksharedAppDelegate.window.subviews;
     
     for (BoxHeartbeatReStartView*view in subViews) {
-        if([view isKindOfClass:[BoxHeartbeatReStartView class]]){
+        if([view isKindOfClass:[BoxHeartbeatReStartView class]]
+           || [view isKindOfClass:[customRestartingBoxView class]]){
             [view colseFun];
             break;
         }

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

@@ -664,3 +664,9 @@
 
 //1.4.5
 "Search_nas_title"      = "搜索";
+"cloudPhone_restart_box_title"      = "重启盒子";
+"cloudPhone_restart_box_tip"      = "你确定要重启盒子?";
+"cloudPhone_restart_box_msg"      = "重启设备过程中功能将暂时无法使用?";
+"cloudPhone_restarting_box_title"      = "盒子重启中...";
+"cloudPhone_restarting_box_msg"      = "重启设备预计需要5分钟";
+

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

@@ -246,6 +246,10 @@
 		6B257EA02C95964E00CBB70A /* backupPathListModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B257E9E2C95964E00CBB70A /* backupPathListModel.m */; };
 		6B257EA12C95964E00CBB70A /* backupPathListModel.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B257E9D2C95964E00CBB70A /* backupPathListModel.h */; };
 		6B257EA22C95964E00CBB70A /* backupPathListModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B257E9E2C95964E00CBB70A /* backupPathListModel.m */; };
+		6B2A63612D7994660044057A /* customRestartingBoxView.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B2A635F2D7994660044057A /* customRestartingBoxView.h */; };
+		6B2A63622D7994660044057A /* customRestartingBoxView.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B2A63602D7994660044057A /* customRestartingBoxView.m */; };
+		6B2A63632D7994660044057A /* customRestartingBoxView.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B2A63602D7994660044057A /* customRestartingBoxView.m */; };
+		6B2A63642D7994660044057A /* customRestartingBoxView.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B2A635F2D7994660044057A /* customRestartingBoxView.h */; };
 		6B2C1E1C2C070ADE00FDCF82 /* ZFAVPlayerManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B2C1DCC2C070ADE00FDCF82 /* ZFAVPlayerManager.h */; };
 		6B2C1E1D2C070ADE00FDCF82 /* ZFAVPlayerManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B2C1DCC2C070ADE00FDCF82 /* ZFAVPlayerManager.h */; };
 		6B2C1E1E2C070ADE00FDCF82 /* ZFAVPlayerManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B2C1DCD2C070ADE00FDCF82 /* ZFAVPlayerManager.m */; };
@@ -1741,6 +1745,8 @@
 		6B238C932C60AF6A00C5AC2F /* nasDownloadFileManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = nasDownloadFileManager.m; sourceTree = "<group>"; };
 		6B257E9D2C95964E00CBB70A /* backupPathListModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = backupPathListModel.h; sourceTree = "<group>"; };
 		6B257E9E2C95964E00CBB70A /* backupPathListModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = backupPathListModel.m; sourceTree = "<group>"; };
+		6B2A635F2D7994660044057A /* customRestartingBoxView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = customRestartingBoxView.h; sourceTree = "<group>"; };
+		6B2A63602D7994660044057A /* customRestartingBoxView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = customRestartingBoxView.m; sourceTree = "<group>"; };
 		6B2C1DCC2C070ADE00FDCF82 /* ZFAVPlayerManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ZFAVPlayerManager.h; sourceTree = "<group>"; };
 		6B2C1DCD2C070ADE00FDCF82 /* ZFAVPlayerManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ZFAVPlayerManager.m; sourceTree = "<group>"; };
 		6B2C1DCF2C070ADE00FDCF82 /* UIImageView+ZFCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImageView+ZFCache.h"; sourceTree = "<group>"; };
@@ -3420,6 +3426,8 @@
 			children = (
 				6B6D42E92C290A06006CAE3A /* cloudPhoneSetView.h */,
 				6B6D42EA2C290A06006CAE3A /* cloudPhoneSetView.m */,
+				6B2A635F2D7994660044057A /* customRestartingBoxView.h */,
+				6B2A63602D7994660044057A /* customRestartingBoxView.m */,
 			);
 			path = view;
 			sourceTree = "<group>";
@@ -4196,6 +4204,7 @@
 				6B5B60652B3D5FD8009A2AE2 /* fileTransfeSetViewController.h in Headers */,
 				6B4D23B12B33DDBC005B718A /* imageVersionRenewTipView.h in Headers */,
 				6B0582892B045E0B00D37290 /* uploadFileDataModel.h in Headers */,
+				6B2A63612D7994660044057A /* customRestartingBoxView.h in Headers */,
 				6BA08F082C0187DD00A2242D /* boxDownloadFileRecordCell.h in Headers */,
 				6BA08F572C01D05B00A2242D /* CWUploadTask+CheckInfo.h in Headers */,
 				6BF52C972AD5546500A617DB /* SimplePing.h in Headers */,
@@ -4496,6 +4505,7 @@
 				6BD506CF2B9576A4006E7CB0 /* fileTransfeSetViewController.h in Headers */,
 				6BD506D02B9576A4006E7CB0 /* imageVersionRenewTipView.h in Headers */,
 				6BD506D12B9576A4006E7CB0 /* uploadFileDataModel.h in Headers */,
+				6B2A63642D7994660044057A /* customRestartingBoxView.h in Headers */,
 				6BA08F0A2C0187DD00A2242D /* boxDownloadFileRecordCell.h in Headers */,
 				6BA08F582C01D05B00A2242D /* CWUploadTask+CheckInfo.h in Headers */,
 				6BD506D22B9576A4006E7CB0 /* SimplePing.h in Headers */,
@@ -5137,6 +5147,7 @@
 				6BD5077E2B9576A4006E7CB0 /* RSATool.m in Sources */,
 				6B5BE5822BFC81E300A1B9B3 /* NASFileAndFolderModel.m in Sources */,
 				6BD5077F2B9576A4006E7CB0 /* iPhone.m in Sources */,
+				6B2A63632D7994660044057A /* customRestartingBoxView.m in Sources */,
 				6BD507802B9576A4006E7CB0 /* UIRefreshControl+AFNetworking.m in Sources */,
 				6BD507812B9576A4006E7CB0 /* SceneDelegate.m in Sources */,
 				6BD507822B9576A4006E7CB0 /* privacyModeTipViewController.m in Sources */,
@@ -5519,6 +5530,7 @@
 				18BA24882AA5C57900BA01EE /* RSATool.m in Sources */,
 				6B5BE5802BFC81E300A1B9B3 /* NASFileAndFolderModel.m in Sources */,
 				1866F99E2A136DC700B31E22 /* iPhone.m in Sources */,
+				6B2A63622D7994660044057A /* customRestartingBoxView.m in Sources */,
 				183AE64D2A8A2CF000B11CB0 /* UIRefreshControl+AFNetworking.m in Sources */,
 				A003F6E327D8428200715CBF /* SceneDelegate.m in Sources */,
 				6B2170A12B15D39900656670 /* privacyModeTipViewController.m in Sources */,