JXSettingVC.mm 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784
  1. //
  2. // myViewController.m
  3. // sjvodios
  4. //
  5. // Created by on 12-5-29.
  6. // Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
  7. //
  8. #import "JXSettingVC.h"
  9. #import "JXImageView.h"
  10. #import "JXLabel.h"
  11. #import "AppDelegate.h"
  12. #import "JXServer.h"
  13. #import "JXConnection.h"
  14. #import "UIFactory.h"
  15. #import "JXTableView.h"
  16. #import "JXFriendViewController.h"
  17. #import "ImageResize.h"
  18. #import "userWeiboVC.h"
  19. #import "myMediaVC.h"
  20. #import "webpageVC.h"
  21. #import "loginVC.h"
  22. #import "JXNewFriendViewController.h"
  23. #import "forgetPwdVC.h"
  24. #import "JXSelectorVC.h"
  25. #import "JXSetChatBackgroundVC.h"
  26. #import "JXSetChatTextFontVC.h"
  27. #import "PSRegisterBaseVC.h"
  28. #import "photosViewController.h"
  29. #import "JXAboutVC.h"
  30. #import "JXMessageObject.h"
  31. #import "JXMediaObject.h"
  32. #import <StoreKit/StoreKit.h>
  33. #import "JXGroupMessagesSelectFriendVC.h"
  34. #import "JXAccountBindingVC.h"
  35. #import "JXSecuritySettingVC.h"
  36. #import "JXChatLogMoveVC.h"
  37. #import "JXSelThemeColorsVC.h"
  38. #import "CYFacePackageViewController.h"
  39. #import "CYGroupSendHelperViewController.h"
  40. #import "JLBubbleViewController.h"
  41. #define HEIGHT 56
  42. @interface JXSettingVC ()<JXSelectorVCDelegate,SKStoreProductViewControllerDelegate>
  43. @property (nonatomic, assign) NSInteger currentLanguageIndex;
  44. @property (nonatomic, assign) NSInteger currentSkin;
  45. @property (atomic,assign) BOOL reLogin;
  46. @property (nonatomic, strong) UILabel *fileSizelab;
  47. @property (nonatomic, strong) UIView *baseView;
  48. @end
  49. @implementation JXSettingVC
  50. - (id)init
  51. {
  52. self = [super init];
  53. if (self) {
  54. self.isGotoBack = YES;
  55. self.title = Localized(@"JXSettingVC_Set");
  56. self.heightHeader = JX_SCREEN_TOP;
  57. self.heightFooter = 0;
  58. //self.view.frame = CGRectMake(0, 0, JX_SCREEN_WIDTH, JX_SCREEN_HEIGHT);
  59. [self createHeadAndFoot];
  60. self.tableBody.backgroundColor = HEXCOLOR(0xF2F2F2);
  61. self.tableBody.scrollEnabled = YES;
  62. self.baseView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, JX_SCREEN_WIDTH, 0)];
  63. self.baseView.backgroundColor = [UIColor clearColor];
  64. [self.tableBody addSubview:self.baseView];
  65. UIButton* btn;
  66. int h=0;
  67. int w=JX_SCREEN_WIDTH;
  68. JXImageView* iv;
  69. iv = [self createButton:Localized(@"JXSettingVC_ClearCache") drawTop:NO drawBottom:YES icon:nil click:@selector(onClear)];
  70. iv.frame = CGRectMake(0,h, w, HEIGHT);
  71. self.fileSizelab = [[UILabel alloc] initWithFrame:CGRectMake(JX_SCREEN_WIDTH/2 - 35, (HEIGHT-20)/2, JX_SCREEN_WIDTH / 2, 20)];
  72. self.fileSizelab.textColor = HEXCOLOR(0x999999);
  73. self.fileSizelab.font = SYSFONT(15);
  74. self.fileSizelab.textAlignment = NSTextAlignmentRight;
  75. self.fileSizelab.text = [self folderSizeAtPath:tempFilePath];
  76. [iv addSubview:self.fileSizelab];
  77. h+=iv.frame.size.height;
  78. iv = [self createButton:Localized(@"JX_ClearAllChatRecords") drawTop:NO drawBottom:YES icon:nil click:@selector(onClearChatLog)];
  79. iv.frame = CGRectMake(0,h, w, HEIGHT);
  80. h+=iv.frame.size.height;
  81. iv = [self createButton:Localized(@"JX_ChatLogMove") drawTop:NO drawBottom:NO icon:nil click:@selector(onChatLogMove)];
  82. iv.frame = CGRectMake(0, h, w, HEIGHT);
  83. h += iv.frame.size.height+8;
  84. iv = [self createButton:Localized(@"JX_UpdatePassWord") drawTop:NO drawBottom:NO icon:nil click:@selector(onForgetPassWord)];
  85. iv.frame = CGRectMake(0, h, w, HEIGHT);
  86. h += iv.frame.size.height+8;
  87. // iv = [self createButton:Localized(@"JXSettingVC_Help") drawTop:NO drawBottom:YES icon:nil click:@selector(onHelp)];
  88. // iv.frame = CGRectMake(0,h, w, HEIGHT);
  89. // h+=iv.frame.size.height;
  90. //语言切换
  91. NSString *lang = g_constant.sysLanguage;
  92. NSString *currentLanguage;
  93. // if ([lang isEqualToString:@"zh"]) {
  94. // currentLanguage = @"简体中文";
  95. // _currentLanguageIndex = 0;
  96. //
  97. // }else if ([lang isEqualToString:@"big5"]) {
  98. // currentLanguage = @"繁體中文(香港)";
  99. // _currentLanguageIndex = 1;
  100. // }
  101. //// else if ([lang isEqualToString:@"malay"]) {
  102. //// currentLanguage = @"Bahasa Melayu";
  103. //// _currentLanguageIndex = 3;
  104. //// }else if ([lang isEqualToString:@"th"]) {
  105. //// currentLanguage = @"ภาษาไทย";
  106. //// _currentLanguageIndex = 4;
  107. //// }
  108. // else {
  109. // currentLanguage = @"English";
  110. // _currentLanguageIndex = 2;
  111. // }
  112. currentLanguage = [@{@"zh":@"简体中文", @"big5":@"繁體中文(香港)", @"en":@"English",
  113. // @"ja":@"日本語",@"ko":@"한국어",
  114. @"idy":@"Indonesia",@"vi":@"ViệtName",
  115. // @"ms":@"Melayu",
  116. @"fy":@"Pilipino"} objectForKey:lang];
  117. iv = [self createButton:Localized(@"JX_LanguageSwitching") drawTop:NO drawBottom:YES icon:nil click:@selector(languageSwitch)];
  118. UILabel *arrTitle = [[UILabel alloc] initWithFrame:CGRectMake(JX_SCREEN_WIDTH/2 - 35, (HEIGHT-20)/2, JX_SCREEN_WIDTH / 2, 20)];
  119. arrTitle.text = currentLanguage;
  120. arrTitle.textColor = HEXCOLOR(0x999999);
  121. arrTitle.font = SYSFONT(15);
  122. arrTitle.textAlignment = NSTextAlignmentRight;
  123. [iv addSubview:arrTitle];
  124. iv.frame = CGRectMake(0,h, w, HEIGHT);
  125. h+=iv.frame.size.height;
  126. iv = [self createButton:Localized(@"JXTheme_switch") drawTop:NO drawBottom:NO icon:nil click:@selector(changeSkin)];
  127. UILabel *skinTitle = [[UILabel alloc] initWithFrame:CGRectMake(JX_SCREEN_WIDTH/2 - 35, (HEIGHT-20)/2, JX_SCREEN_WIDTH / 2, 20)];
  128. skinTitle.text = g_theme.themeName;
  129. skinTitle.textColor = HEXCOLOR(0x999999);
  130. skinTitle.font = SYSFONT(15);
  131. skinTitle.textAlignment = NSTextAlignmentRight;
  132. [iv addSubview:skinTitle];
  133. iv.frame = CGRectMake(0, h, w, HEIGHT);
  134. h+=iv.frame.size.height+8;
  135. iv = [self createButton:Localized(@"JX_ChatFonts") drawTop:NO drawBottom:YES icon:nil click:@selector(setChatTextFont)];
  136. iv.frame = CGRectMake(0, h, w, HEIGHT);
  137. h += iv.frame.size.height;
  138. //聊天表情
  139. // iv = [self createButton:@"聊天表情" drawTop:NO drawBottom:YES icon:nil click:@selector(setFaceClick)];
  140. // iv.frame = CGRectMake(0, h, w, HEIGHT);
  141. // h += iv.frame.size.height+8;
  142. //气泡
  143. iv = [self createButton:@"气泡" drawTop:NO drawBottom:YES icon:nil click:@selector(setBubble)];
  144. iv.frame = CGRectMake(0, h, w, HEIGHT);
  145. h += iv.frame.size.height+8;
  146. iv = [self createButton:Localized(@"JXGroupMessages") drawTop:YES drawBottom:NO icon:nil click:@selector(groupMessages)];
  147. iv.frame = CGRectMake(0,h, w, HEIGHT);
  148. h+=iv.frame.size.height+8;
  149. iv = [self createButton:Localized(@"JX_PrivacySettings") drawTop:NO drawBottom:YES icon:nil click:@selector(onSet)];
  150. iv.frame = CGRectMake(0,h, w, HEIGHT);
  151. h+=iv.frame.size.height;
  152. iv = [self createButton:Localized(@"JX_SecuritySettings") drawTop:NO drawBottom:YES icon:nil click:@selector(onSecuritySetting)];
  153. iv.frame = CGRectMake(0,h, w, HEIGHT);
  154. h+=iv.frame.size.height;
  155. iv = [self createButton:Localized(@"JX_SettingUpChatBackground") drawTop:NO drawBottom:YES icon:nil click:@selector(setChatBackground)];
  156. iv.frame = CGRectMake(0, h, w, HEIGHT);
  157. h += iv.frame.size.height;
  158. iv = [self createButton:Localized(@"JX_AccountAndBindSettings") drawTop:NO drawBottom:NO icon:nil click:@selector(setAccountBinding)];
  159. iv.frame = CGRectMake(0, h, w, HEIGHT);
  160. h += iv.frame.size.height+8;
  161. if (THE_APP_OUR) {
  162. iv = [self createButton:Localized(@"JXSettingViewController_Evaluate") drawTop:NO drawBottom:YES icon:nil click:@selector(webAppStoreBtnAction)];
  163. iv.frame = CGRectMake(0,h, w, HEIGHT);
  164. h+=iv.frame.size.height;
  165. iv = [self createButton:Localized(@"JXAboutVC_AboutUS") drawTop:NO drawBottom:NO icon:nil click:@selector(onAbout)];
  166. iv.frame = CGRectMake(0,h, w, HEIGHT);
  167. h+=iv.frame.size.height+8;
  168. }
  169. CGRect frame = self.baseView.frame;
  170. frame.size.height = h;
  171. self.baseView.frame = frame;
  172. btn = [UIFactory createCommonButton:Localized(@"JXSettingVC_LogOut") target:self action:@selector(onLogout)];
  173. [btn setBackgroundImage:nil forState:UIControlStateHighlighted];
  174. btn.custom_acceptEventInterval = 1.f;
  175. btn.frame = CGRectMake(15,CGRectGetMaxY(self.baseView.frame)+20, JX_SCREEN_WIDTH-30, 40);
  176. [btn setBackgroundImage:nil forState:UIControlStateNormal];
  177. btn.backgroundColor = THEMECOLOR;
  178. btn.layer.masksToBounds = YES;
  179. btn.layer.cornerRadius = 7.f;
  180. [self.tableBody addSubview:btn];
  181. if (self.tableBody.frame.size.height < CGRectGetMaxY(btn.frame)+51) {
  182. self.tableBody.contentSize = CGSizeMake(0, CGRectGetMaxY(btn.frame)+51);
  183. }
  184. }
  185. return self;
  186. }
  187. -(void)dealloc{
  188. // NSLog(@"JXSettingVC.dealloc");
  189. // [super dealloc];
  190. }
  191. - (void)didReceiveMemoryWarning
  192. {
  193. // Releases the view if it doesn't have a superview.
  194. [super didReceiveMemoryWarning];
  195. // Release any cached data, images, etc that aren't in use.
  196. }
  197. - (void)viewWillAppear:(BOOL)animated
  198. {
  199. [super viewWillAppear:animated];
  200. }
  201. - (void)viewDidAppear:(BOOL)animated
  202. {
  203. [super viewDidAppear:animated];
  204. }
  205. - (void)viewDidUnload
  206. {
  207. [super viewDidUnload];
  208. // Release any retained subviews of the main view.
  209. // e.g. self.myOutlet = nil;
  210. }
  211. - (void)actionLogout{
  212. [self.view endEditing:YES];
  213. [_wait stop];
  214. [g_server stopConnection:self];
  215. // if ([self.delegate respondsToSelector:@selector(admobDidQuit)]) {
  216. // [self.delegate admobDidQuit];
  217. // }
  218. [self actionQuit];
  219. // [self.view removeFromSuperview];
  220. // _pSelf = nil;
  221. }
  222. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
  223. {
  224. // Return YES for supported orientations
  225. return (interfaceOrientation == UIInterfaceOrientationPortrait);
  226. }
  227. -(void) didServerResultSucces:(JXConnection*)aDownload dict:(NSDictionary*)dict array:(NSArray*)array1{
  228. if( [aDownload.action isEqualToString:act_UserLogout] ){
  229. [g_default setObject:nil forKey:kMY_USER_PrivateKey_DH];
  230. [g_default setObject:nil forKey:kMY_USER_PrivateKey_RSA];
  231. if (self.reLogin) {
  232. // [g_notify postNotificationName:kLogOutNotifaction object:nil];
  233. // [g_default setObject:nil forKey:kMY_USER_TOKEN];
  234. // g_server.access_token = nil;
  235. self.reLogin = NO;
  236. [self relogin];
  237. // g_mainVC = nil;
  238. // [JXMyTools showTipView:Localized(@"SignOuted")];
  239. //
  240. // [[JXXMPP sharedInstance] logout];
  241. // [self actionLogout];
  242. // [self admobDidQuit];
  243. return;
  244. }
  245. [self performSelector:@selector(doSwitch) withObject:nil afterDelay:1];
  246. }else if ([aDownload.action isEqualToString:act_Settings]){
  247. //跳转新的页面
  248. JXSettingsViewController* vc = [[JXSettingsViewController alloc]init];
  249. vc.dataSorce = dict;
  250. // [g_window addSubview:vc.view];
  251. [g_navigation pushViewController:vc animated:YES];
  252. [_wait stop];
  253. }
  254. if ([aDownload.action isEqualToString:act_EmptyMsg]){
  255. [g_App showAlert:Localized(@"JX_ClearSuccess")];
  256. }
  257. }
  258. -(int) didServerResultFailed:(JXConnection*)aDownload dict:(NSDictionary*)dict{
  259. if( [aDownload.action isEqualToString:act_UserLogout] ){
  260. [self performSelector:@selector(doSwitch) withObject:nil afterDelay:1];
  261. }
  262. return hide_error;
  263. }
  264. -(int) didServerConnectError:(JXConnection*)aDownload error:(NSError *)error{//error为空时,代表超时
  265. [_wait stop];
  266. return show_error;
  267. }
  268. -(void) didServerConnectStart:(JXConnection*)aDownload{
  269. [_wait start];
  270. }
  271. -(void)onClear{
  272. [g_App showAlert:Localized(@"JX_ConfirmClearData") delegate:self tag:1345 onlyConfirm:NO];
  273. }
  274. // 清除所有聊天记录
  275. - (void) onClearChatLog {
  276. [g_App showAlert:Localized(@"JX_ConfirmClearAllLogs") delegate:self tag:1134 onlyConfirm:NO];
  277. }
  278. // 群发消息
  279. - (void)groupMessages {
  280. // JXGroupMessagesSelectFriendVC *vc = [[JXGroupMessagesSelectFriendVC alloc] init];
  281. CYGroupSendHelperViewController *vc = [[CYGroupSendHelperViewController alloc] init];
  282. [g_navigation pushViewController:vc animated:YES];
  283. }
  284. //切换皮肤主题
  285. -(void)changeSkin{
  286. JXSelThemeColorsVC *vc = [[JXSelThemeColorsVC alloc] init];
  287. vc.title = Localized(@"JXTheme_choose");
  288. vc.array = g_theme.skinNameList;
  289. vc.selectIndex = g_theme.themeIndex;
  290. [g_navigation pushViewController:vc animated:YES];
  291. }
  292. // 设置聊天背景
  293. - (void)setChatBackground{
  294. JXSetChatBackgroundVC *vc = [[JXSetChatBackgroundVC alloc] init];
  295. [g_navigation pushViewController:vc animated:YES];
  296. }
  297. // 账号和绑定设置
  298. - (void)setAccountBinding {
  299. JXAccountBindingVC *bindVC = [[JXAccountBindingVC alloc] init];
  300. [g_navigation pushViewController:bindVC animated:YES];
  301. }
  302. // 聊天字体
  303. - (void)setChatTextFont {
  304. JXSetChatTextFontVC *vc = [[JXSetChatTextFontVC alloc] init];
  305. [g_navigation pushViewController:vc animated:YES];
  306. }
  307. // 气泡
  308. - (void)setBubble {
  309. JLBubbleViewController *vc = [[JLBubbleViewController alloc] init];
  310. [g_navigation pushViewController:vc animated:YES];
  311. }
  312. -(void)setFaceClick{
  313. CYFacePackageViewController *vc = [[CYFacePackageViewController alloc] init];
  314. [g_navigation pushViewController:vc animated:YES];
  315. }
  316. // 切换语言
  317. - (void)languageSwitch {
  318. NSString *lang = g_constant.sysLanguage;
  319. // if ([lang isEqualToString:@"zh"]) {
  320. // _currentLanguageIndex = 0;
  321. // }else if ([lang isEqualToString:@"big5"]) {
  322. // _currentLanguageIndex = 1;
  323. // }else {
  324. // _currentLanguageIndex = 2;
  325. // }
  326. _currentLanguageIndex = [@[@"zh",@"big5",@"en",
  327. // @"ja",@"ko",
  328. @"idy",@"vi",
  329. // @"ms",
  330. @"fy"] indexOfObject:lang];
  331. JXSelectorVC *vc = [[JXSelectorVC alloc] init];
  332. vc.title = Localized(@"JX_SelectLanguage");
  333. vc.array = @[@"简体中文", @"繁體中文(香港)", @"English",
  334. // @"日本語",@"한국어",
  335. @"Indonesia",@"ViệtName",
  336. // @"Melayu"
  337. @"Pilipino"];
  338. // vc.array = @[@"简体中文", @"繁體中文(香港)", @"English",@"Bahasa Melayu",@"ภาษาไทย"];
  339. vc.selectIndex = _currentLanguageIndex;
  340. vc.selectorDelegate = self;
  341. // [g_window addSubview:vc.view];
  342. [g_navigation pushViewController:vc animated:YES];
  343. }
  344. - (void)selector:(JXSelectorVC *)selector selectorAction:(NSInteger)selectIndex {
  345. if ([selector.title isEqualToString:Localized(@"JX_SelectLanguage")]) {
  346. self.currentLanguageIndex = selectIndex;
  347. [g_App showAlert:Localized(@"JX_SwitchLanguageNeed") delegate:self tag:3333 onlyConfirm:NO];
  348. }else{
  349. self.currentSkin = selectIndex;
  350. [g_App showAlert:Localized(@"JXTheme_confirm") delegate:self tag:4444 onlyConfirm:NO];
  351. }
  352. }
  353. - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
  354. if (alertView.tag == 3333 && buttonIndex == 1) {
  355. NSString *currentLanguage;
  356. switch (self.currentLanguageIndex) {
  357. case 0:
  358. currentLanguage = @"zh";
  359. break;
  360. case 1:
  361. currentLanguage = @"big5";
  362. break;
  363. case 2:
  364. currentLanguage = @"en";
  365. break;
  366. // case 3:
  367. //
  368. // currentLanguage = @"ja";
  369. // break;
  370. // case 4:
  371. //
  372. // currentLanguage = @"ko";
  373. // break;
  374. case 3:
  375. currentLanguage = @"idy";
  376. break;
  377. case 4:
  378. currentLanguage = @"vi";
  379. break;
  380. // case 7:
  381. //
  382. // currentLanguage = @"ms";
  383. // break;
  384. case 5:
  385. currentLanguage = @"fy";
  386. break;
  387. default:
  388. break;
  389. }
  390. [g_default setObject:currentLanguage forKey:kLocalLanguage];
  391. [g_default synchronize];
  392. [g_constant resetlocalized];
  393. self.reLogin = NO;
  394. // // 更新系统好友的显示
  395. [[JXUserObject sharedInstance] createSystemFriend];
  396. // [[JXUserObject sharedInstance] createAddressBookFriend];
  397. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  398. // [g_server logout:self];
  399. [self doLogout];
  400. });
  401. }else if (alertView.tag == 4444 && buttonIndex == 1) {
  402. [g_theme switchSkinIndex:self.currentSkin];
  403. [g_mainVC.view removeFromSuperview];
  404. g_mainVC = nil;
  405. [self.view removeFromSuperview];
  406. self.view = nil;
  407. g_navigation.lastVC = nil;
  408. [g_navigation.subViews removeAllObjects];
  409. [g_App showMainUI];
  410. }else if (alertView.tag == 1134 && buttonIndex == 1) {
  411. NSMutableArray* p = [[JXMessageObject sharedInstance] fetchRecentChat];
  412. for (NSInteger i = 0; i < p.count; i ++) {
  413. JXMsgAndUserObject *obj = p[i];
  414. if ([obj.user.userId isEqualToString:@"10000"] || [obj.user.userId isEqualToString:FRIEND_CENTER_USERID]) {
  415. continue;
  416. }
  417. [obj.user reset];
  418. [obj.message deleteAll];
  419. }
  420. // 本地时间
  421. long time = [[NSDate date] timeIntervalSince1970] * 1000;
  422. NSString *lastClearRecordTime = [NSString stringWithFormat:@"%ld", time];
  423. [g_default setValue:lastClearRecordTime forKey:@"CLEARALLMSGRECORDTIME"];
  424. [g_default synchronize];
  425. [g_server emptyMsgWithTouserId:nil type:[NSNumber numberWithInt:1] toView:self];
  426. [g_notify postNotificationName:kDeleteAllChatLog object:nil];
  427. }else if (alertView.tag == 1345 && buttonIndex == 1) {
  428. [_wait start:Localized(@"JXAlert_ClearCache")];
  429. [FileInfo deleleFileAndDir:tempFilePath];
  430. // 录制的视频也会被清除,所以要清除视频记录表
  431. [[JXMediaObject sharedInstance] deleteAll];
  432. self.fileSizelab.text = [self folderSizeAtPath:tempFilePath];
  433. [_wait performSelector:@selector(stop) withObject:nil afterDelay:1];
  434. }
  435. }
  436. - (NSString *)folderSizeAtPath:(NSString *)folderPath
  437. {
  438. NSFileManager* manager = [NSFileManager defaultManager];
  439. if (![manager fileExistsAtPath:folderPath]) return 0;
  440. NSEnumerator *childFilesEnumerator = [[manager subpathsAtPath:folderPath] objectEnumerator];
  441. NSString* fileName;
  442. long long folderSize = 0;
  443. while ((fileName = [childFilesEnumerator nextObject]) != nil)
  444. {
  445. NSString* fileAbsolutePath = [folderPath stringByAppendingPathComponent:fileName];
  446. folderSize += [self fileSizeAtPath:fileAbsolutePath];
  447. }
  448. return [NSString stringWithFormat:@"%.2fM",folderSize/(1024.0*1024.0)];
  449. }
  450. - (long long)fileSizeAtPath:(NSString*)filePath
  451. {
  452. NSFileManager* manager = [NSFileManager defaultManager];
  453. if ([manager fileExistsAtPath:filePath]){
  454. return [[manager attributesOfItemAtPath:filePath error:nil] fileSize];
  455. }
  456. return 0;
  457. }
  458. #pragma mark-----修改密码
  459. - (void)onForgetPassWord{
  460. forgetPwdVC *forgetVC = [[forgetPwdVC alloc]init];
  461. forgetVC.isModify = YES;
  462. // [g_App.window addSubview:forgetVC.view];
  463. [g_navigation pushViewController:forgetVC animated:YES];
  464. }
  465. // 聊天记录迁移
  466. - (void)onChatLogMove {
  467. JXChatLogMoveVC *vc = [[JXChatLogMoveVC alloc] init];
  468. [g_navigation pushViewController:vc animated:YES];
  469. }
  470. - (void)onSet{
  471. // 获取设置状态
  472. [g_server getFriendSettings:[NSString stringWithFormat:@"%ld",g_server.user_id] toView:self];
  473. }
  474. - (void)onSecuritySetting {
  475. JXSecuritySettingVC *vc = [[JXSecuritySettingVC alloc] init];
  476. [g_navigation pushViewController:vc animated:YES];
  477. }
  478. -(void)onLogout{
  479. [g_App showAlert:Localized(@"JXAlert_LoginOut") delegate:self];
  480. }
  481. - (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex{
  482. if(alertView.tag == 3333){
  483. }else if(alertView.tag == 4444){
  484. }else if(alertView.tag == 1134){
  485. }else if(alertView.tag == 1345){
  486. }else if(buttonIndex==1){
  487. //保存未读消息条数
  488. // [g_notify postNotificationName:kSaveBadgeNotifaction object:nil];
  489. [self doLogout];
  490. }
  491. }
  492. -(void)doLogout{
  493. JXUserObject *user = [JXUserObject sharedInstance];
  494. [g_server logout:user.areaCode toView:self];
  495. }
  496. -(void)relogin{
  497. // [g_default removeObjectForKey:kMY_USER_PASSWORD];
  498. // [g_default setObject:nil forKey:kMY_USER_TOKEN];
  499. g_server.access_token = nil;
  500. [g_notify postNotificationName:kSystemLogoutNotifaction object:nil];
  501. [[JXXMPP sharedInstance] logout];
  502. NSLog(@"XMPP ---- jxsettingVC relogin");
  503. loginVC* vc = [loginVC alloc];
  504. vc.isAutoLogin = NO;
  505. vc.isSwitchUser= NO;
  506. vc = [vc init];
  507. [g_mainVC.view removeFromSuperview];
  508. g_mainVC = nil;
  509. [self.view removeFromSuperview];
  510. self.view = nil;
  511. g_navigation.rootViewController = vc;
  512. // g_navigation.lastVC = nil;
  513. // [g_navigation.subViews removeAllObjects];
  514. // [g_navigation pushViewController:vc];
  515. // g_App.window.rootViewController = vc;
  516. // [g_App.window makeKeyAndVisible];
  517. // loginVC* vc = [loginVC alloc];
  518. // vc.isAutoLogin = NO;
  519. // vc.isSwitchUser= NO;
  520. // vc = [vc init];
  521. // [g_window addSubview:vc.view];
  522. // [self actionQuit];
  523. // [_wait performSelector:@selector(stop) withObject:nil afterDelay:1];
  524. [_wait stop];
  525. #if TAR_IM
  526. #ifdef Meeting_Version
  527. [g_meeting stopMeeting];
  528. #endif
  529. #endif
  530. }
  531. -(void)doSwitch{
  532. [g_default removeObjectForKey:kMY_USER_PASSWORD];
  533. [g_default removeObjectForKey:kMY_USER_TOKEN];
  534. [g_notify postNotificationName:kSystemLogoutNotifaction object:nil];
  535. g_xmpp.isReconnect = NO;
  536. [[JXXMPP sharedInstance] logout];
  537. NSLog(@"XMPP ---- jxsettingVC doSwitch");
  538. // 退出登录到登陆界面 隐藏悬浮窗
  539. g_App.subWindow.hidden = YES;
  540. loginVC* vc = [loginVC alloc];
  541. vc.isAutoLogin = NO;
  542. vc.isSwitchUser= NO;
  543. vc = [vc init];
  544. [g_mainVC.view removeFromSuperview];
  545. g_mainVC = nil;
  546. [self.view removeFromSuperview];
  547. self.view = nil;
  548. g_navigation.rootViewController = vc;
  549. // g_navigation.lastVC = nil;
  550. // [g_navigation.subViews removeAllObjects];
  551. // [g_navigation pushViewController:vc];
  552. // g_App.window.rootViewController = vc;
  553. // [g_App.window makeKeyAndVisible];
  554. // loginVC* vc = [loginVC alloc];
  555. // vc.isAutoLogin = NO;
  556. // vc.isSwitchUser= YES;
  557. // vc = [vc init];
  558. // [g_navigation.subViews removeAllObjects];
  559. //// [g_window addSubview:vc.view];
  560. // [g_navigation pushViewController:vc];
  561. // [self actionQuit];
  562. // [_wait performSelector:@selector(stop) withObject:nil afterDelay:1];
  563. // [_wait stop];
  564. #if TAR_IM
  565. #ifdef Meeting_Version
  566. [g_meeting stopMeeting];
  567. #endif
  568. #endif
  569. }
  570. // 去评价
  571. -(void)webAppStoreBtnAction {
  572. if (g_App.config.appleId.length > 0) {
  573. [_wait start];
  574. SKStoreProductViewController *vc = [[SKStoreProductViewController alloc] init];
  575. vc.delegate = self;
  576. //加载App Store视图展示
  577. [vc loadProductWithParameters:@{SKStoreProductParameterITunesItemIdentifier:g_App.config.appleId} completionBlock:^(BOOL result, NSError * _Nullable error) {
  578. [_wait stop];
  579. if (!error) {
  580. [self presentViewController:vc animated:YES completion:nil];
  581. }
  582. }];
  583. }
  584. }
  585. - (void)productViewControllerDidFinish:(SKStoreProductViewController *)viewController {
  586. [self dismissViewControllerAnimated:YES completion:nil];
  587. }
  588. -(void)onAbout{
  589. JXAboutVC* vc = [[JXAboutVC alloc]init];
  590. // [g_window addSubview:vc.view];
  591. [g_navigation pushViewController:vc animated:YES];
  592. }
  593. -(void)onHelp{
  594. [g_server showWebPage:g_config.helpUrl title:Localized(@"JXSettingVC_Help")];
  595. }
  596. -(JXImageView*)createButton:(NSString*)title drawTop:(BOOL)drawTop drawBottom:(BOOL)drawBottom icon:(NSString*)icon click:(SEL)click{
  597. JXImageView* btn = [[JXImageView alloc] init];
  598. btn.backgroundColor = [UIColor whiteColor];
  599. btn.userInteractionEnabled = YES;
  600. btn.didTouch = click;
  601. btn.delegate = self;
  602. [self.baseView addSubview:btn];
  603. JXLabel* p = [[JXLabel alloc] initWithFrame:CGRectMake(15, 0, JX_SCREEN_WIDTH-100, HEIGHT)];
  604. p.text = title;
  605. p.font = g_factory.font16;
  606. p.backgroundColor = [UIColor clearColor];
  607. p.textColor = [UIColor blackColor];
  608. p.delegate = self;
  609. p.didTouch = click;
  610. [btn addSubview:p];
  611. if(icon){
  612. UIImageView* iv = [[UIImageView alloc] initWithFrame:CGRectMake(10, (HEIGHT-20)/2, 20, 20)];
  613. iv.image = [UIImage imageNamed:icon];
  614. [btn addSubview:iv];
  615. }
  616. if(drawTop){
  617. UIView* line = [[UIView alloc] initWithFrame:CGRectMake(15,0,JX_SCREEN_WIDTH-15,LINE_WH)];
  618. line.backgroundColor = THE_LINE_COLOR;
  619. [btn addSubview:line];
  620. }
  621. if(drawBottom){
  622. UIView* line = [[UIView alloc] initWithFrame:CGRectMake(15,HEIGHT-LINE_WH,JX_SCREEN_WIDTH-15,LINE_WH)];
  623. line.backgroundColor = THE_LINE_COLOR;
  624. [btn addSubview:line];
  625. }
  626. if(click){
  627. UIImageView* iv;
  628. iv = [[UIImageView alloc] initWithFrame:CGRectMake(JX_SCREEN_WIDTH-15-7, (HEIGHT-13)/2, 7, 13)];
  629. iv.image = [UIImage imageNamed:@"new_icon_>"];
  630. [btn addSubview:iv];
  631. }
  632. return btn;
  633. }
  634. -(void)onVideoSize{
  635. NSString* s = [[NSUserDefaults standardUserDefaults] objectForKey:@"chatVideoSize"];
  636. if(s==nil)
  637. s = @"1";
  638. JXSelectorVC* vc = [[JXSelectorVC alloc]init];
  639. vc.title = Localized(@"JX_ChatVideoSize");
  640. vc.array = @[@"1920*1080", @"1280*720", @"640*480",@"320*240"];
  641. vc.selectIndex = [s intValue];
  642. vc.delegate = self;
  643. vc.didSelected = @selector(didSelected:);
  644. // [g_window addSubview:vc.view];
  645. [g_navigation pushViewController:vc animated:YES];
  646. }
  647. - (void)didSelected:(JXSelectorVC*)vc{
  648. [g_default setObject:[NSString stringWithFormat:@"%ld",vc.selectIndex] forKey:@"chatVideoSize"];
  649. }
  650. @end