1048147e0Sopenharmony_ci/** 2048147e0Sopenharmony_ci * Copyright (c) 2022 Huawei Device Co., Ltd. 3048147e0Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4048147e0Sopenharmony_ci * you may not use this file except in compliance with the License. 5048147e0Sopenharmony_ci * You may obtain a copy of the License at 6048147e0Sopenharmony_ci * 7048147e0Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8048147e0Sopenharmony_ci * 9048147e0Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10048147e0Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11048147e0Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12048147e0Sopenharmony_ci * See the License for the specific language governing permissions and 13048147e0Sopenharmony_ci * limitations under the License. 14048147e0Sopenharmony_ci */ 15048147e0Sopenharmony_ciimport router from '@system.router'; 16048147e0Sopenharmony_ciimport Prompt from '@system.prompt'; 17048147e0Sopenharmony_ciimport emitter from '@ohos.events.emitter'; 18048147e0Sopenharmony_ci 19048147e0Sopenharmony_ciimport HiLog from '../../utils/HiLog' 20048147e0Sopenharmony_ciimport common from '../../data/commonData' 21048147e0Sopenharmony_ciimport commonEvent from '@ohos.commonEventManager'; 22048147e0Sopenharmony_ciimport ContactsService from '../../service/ContactsService'; 23048147e0Sopenharmony_ciimport ConversationService from '../../service/ConversationService'; 24048147e0Sopenharmony_ciimport ConversationListService from '../../service/ConversationListService'; 25048147e0Sopenharmony_ciimport LooseObject from '../../data/LooseObject' 26048147e0Sopenharmony_ciimport commonService from '../../service/CommonService'; 27048147e0Sopenharmony_ciimport settingService from '../../service/SettingService'; 28048147e0Sopenharmony_ciimport { commonPasteboard } from '../../data/Pasteboard'; 29048147e0Sopenharmony_ciimport telephoneUtil from '../../utils/TelephoneUtil'; 30048147e0Sopenharmony_ciimport callService from '../../service/CallService'; 31048147e0Sopenharmony_ciimport sendMsgService from '../../service/SendMsgService' 32048147e0Sopenharmony_ciimport MmsPreferences from '../../utils/MmsPreferences'; 33048147e0Sopenharmony_ciimport dateUtil from '../../utils/DateUtil'; 34048147e0Sopenharmony_ciimport NotificationService from '../../service/NotificationService'; 35048147e0Sopenharmony_ciimport simCardService from '../../service/SimCardService'; 36048147e0Sopenharmony_ciimport commonCtrl from './common'; 37048147e0Sopenharmony_ciimport AvatarColor from '../../model/common/AvatarColor'; 38048147e0Sopenharmony_ci 39048147e0Sopenharmony_ciconst TAG = 'ConversationController'; 40048147e0Sopenharmony_ciconst ANIMATION_DURATION = 1500; 41048147e0Sopenharmony_ciconst TRANSFORM_SCALE_MIN = '1.0'; 42048147e0Sopenharmony_ciconst TRANSFORM_SCALE_MAX = '3.0'; 43048147e0Sopenharmony_ciconst COMMON_FILE_SIZE_STRING = '/300KB'; 44048147e0Sopenharmony_ci 45048147e0Sopenharmony_ciexport default class ConversationController { 46048147e0Sopenharmony_ci private static sInstance: ConversationController; 47048147e0Sopenharmony_ci commonEventData: any = null; 48048147e0Sopenharmony_ci commonCtrl = commonCtrl.getInstance(); 49048147e0Sopenharmony_ci // SMS message list update flag 50048147e0Sopenharmony_ci refresh: boolean = false; 51048147e0Sopenharmony_ci // Message deletion prompt 52048147e0Sopenharmony_ci strMsgDeleteDialogTip: Resource; 53048147e0Sopenharmony_ci // Click Status 54048147e0Sopenharmony_ci isClickStatus: boolean = false; 55048147e0Sopenharmony_ci // Whether information is locked 56048147e0Sopenharmony_ci hasLockMsg: boolean = false; 57048147e0Sopenharmony_ci // Select Status 58048147e0Sopenharmony_ci isSelectStatus: boolean = false; 59048147e0Sopenharmony_ci // Whether to select lock information 60048147e0Sopenharmony_ci isSelectLockMsg: boolean = false; 61048147e0Sopenharmony_ci // More Actions 62048147e0Sopenharmony_ci isShowMoreOperation: boolean = false; 63048147e0Sopenharmony_ci // The default value is false for determining whether the current day is the same. 64048147e0Sopenharmony_ci isLessOneDay: boolean = false; 65048147e0Sopenharmony_ci // Check whether full-screen conditions are met. 66048147e0Sopenharmony_ci isShowFullScreen: boolean = false; 67048147e0Sopenharmony_ci // Check whether all the options are selected. 68048147e0Sopenharmony_ci isMessageCheckAll: boolean = false; 69048147e0Sopenharmony_ci // Is it just a recording? 70048147e0Sopenharmony_ci isOnlyAudio: boolean = false; 71048147e0Sopenharmony_ci // Deleted Count 72048147e0Sopenharmony_ci selectDeleteMsgCount: number = 0; 73048147e0Sopenharmony_ci // Text entered in the text box, which is also the content of the SMS message to be sent. 74048147e0Sopenharmony_ci textValue: string = ''; 75048147e0Sopenharmony_ci // Recording Animation Tasks 76048147e0Sopenharmony_ci drawRecordingTaskId: number = 0; 77048147e0Sopenharmony_ci // Tab option page. 0: Take a photo; 1: Take a picture; 2: Record a record; 3: More 78048147e0Sopenharmony_ci tabIndex: number = 1; 79048147e0Sopenharmony_ci // Text content of the tab option page 80048147e0Sopenharmony_ci tabTextList: Array<any> = []; 81048147e0Sopenharmony_ci // Recording Status 82048147e0Sopenharmony_ci isRecordingStatus: boolean = true; 83048147e0Sopenharmony_ci // Current recording time 84048147e0Sopenharmony_ci curRecordingTime: string = '00:00'; 85048147e0Sopenharmony_ci // Size of the current recording file (KB) 86048147e0Sopenharmony_ci curSize: number = 0; 87048147e0Sopenharmony_ci // Recording Start Time 88048147e0Sopenharmony_ci startRecordTime: number = 0; 89048147e0Sopenharmony_ci // Airplane mode 90048147e0Sopenharmony_ci isFlightMode: boolean = false; 91048147e0Sopenharmony_ci // Information Attachment Size Tips 92048147e0Sopenharmony_ci msgSendTip: string = ''; 93048147e0Sopenharmony_ci // Whether SMS messages can be sent. 94048147e0Sopenharmony_ci canSendMessage: boolean = false; 95048147e0Sopenharmony_ci // Whether the currently edited message is an MMS message 96048147e0Sopenharmony_ci isEditMms: boolean = false; 97048147e0Sopenharmony_ci // Size of the MM attachment to be edited. 98048147e0Sopenharmony_ci curEdtFileSize: number = 0; 99048147e0Sopenharmony_ci // Obtains the time display of a single selection. 100048147e0Sopenharmony_ci mmsTime: string = ''; 101048147e0Sopenharmony_ci // SMS and MMS 102048147e0Sopenharmony_ci isMmsType: Resource; 103048147e0Sopenharmony_ci // Recipient 104048147e0Sopenharmony_ci isSendRecipient: boolean; 105048147e0Sopenharmony_ci // Contact First Name 106048147e0Sopenharmony_ci strContactsName: string = ''; 107048147e0Sopenharmony_ci // Contact Phone Number 108048147e0Sopenharmony_ci strContactsNumber: string = ''; 109048147e0Sopenharmony_ci // Contact Phone Number Formatting 110048147e0Sopenharmony_ci strContactsNumberFormat: string = ''; 111048147e0Sopenharmony_ci // The attachment type is business card. 112048147e0Sopenharmony_ci isVCard: boolean = false; 113048147e0Sopenharmony_ci // Indicates whether the information is created. 114048147e0Sopenharmony_ci isNewMsg: boolean = false; 115048147e0Sopenharmony_ci // Number of Contacts 116048147e0Sopenharmony_ci contactsNum: number = 0; 117048147e0Sopenharmony_ci // business card 118048147e0Sopenharmony_ci vCard: {}; 119048147e0Sopenharmony_ci // MM Edit List 120048147e0Sopenharmony_ci mmsEditList: Array<any> = []; 121048147e0Sopenharmony_ci // Information List 122048147e0Sopenharmony_ci mmsList: Array<any> = []; 123048147e0Sopenharmony_ci // Index of the selected information 124048147e0Sopenharmony_ci mmsIndex: number = 0; 125048147e0Sopenharmony_ci // Initial x-position 126048147e0Sopenharmony_ci rawX: string = ''; 127048147e0Sopenharmony_ci // Initial y-position 128048147e0Sopenharmony_ci rawY: string = ''; 129048147e0Sopenharmony_ci // Thumbnails in Gallery 130048147e0Sopenharmony_ci pictureListFromGallery: Array<any> = []; 131048147e0Sopenharmony_ci // Tab Title 132048147e0Sopenharmony_ci tabTitleText: Resource; 133048147e0Sopenharmony_ci // Send Toolbar Distance from Bottom Position 134048147e0Sopenharmony_ci sendBarMarginBottom: number = 0; 135048147e0Sopenharmony_ci // Tab Height 136048147e0Sopenharmony_ci tabHeight: number = common.int.TAB_HEIGHT; 137048147e0Sopenharmony_ci // Restoration task ID. 138048147e0Sopenharmony_ci restoreTimeoutId: number = 0; 139048147e0Sopenharmony_ci // Whether the animation is actually executed 140048147e0Sopenharmony_ci isTabHeightAnimation: boolean = false; 141048147e0Sopenharmony_ci // 0: default; 1: slide; 2: full screen 142048147e0Sopenharmony_ci tabSlideStatus: number = 0; 143048147e0Sopenharmony_ci // Sliding distance 144048147e0Sopenharmony_ci slideDistance: number = 0; 145048147e0Sopenharmony_ci // Start point coordinate of the slide 146048147e0Sopenharmony_ci slideStartPoint: LooseObject = { 147048147e0Sopenharmony_ci 'x': 0, 148048147e0Sopenharmony_ci 'y': 0 149048147e0Sopenharmony_ci }; 150048147e0Sopenharmony_ci // Whether to slide up 151048147e0Sopenharmony_ci isTabSlideUp: number = 0; 152048147e0Sopenharmony_ci // Contact list, which is obtained from the contact app and used as an attachment for sending MMS messages. 153048147e0Sopenharmony_ci contactListFromContactApp: Array<any> = []; 154048147e0Sopenharmony_ci // Card slot 155048147e0Sopenharmony_ci slotId: number = 0; 156048147e0Sopenharmony_ci // Selected Contacts 157048147e0Sopenharmony_ci selectContacts: Array<any> = []; 158048147e0Sopenharmony_ci // Content in the recipient text box 159048147e0Sopenharmony_ci receiveContactValue: string = ''; 160048147e0Sopenharmony_ci // Controls the display and hiding of the last div. 161048147e0Sopenharmony_ci isSendStatus: boolean = false; 162048147e0Sopenharmony_ci // ID of the session list. 163048147e0Sopenharmony_ci threadId: number = 0; 164048147e0Sopenharmony_ci // Indicates whether the page is a details page. 165048147e0Sopenharmony_ci isDetail: boolean = true; 166048147e0Sopenharmony_ci // Subscript to be resent 167048147e0Sopenharmony_ci reSendIndex: number = 0; 168048147e0Sopenharmony_ci // Whether the replication option is visible 169048147e0Sopenharmony_ci showText: boolean = true; 170048147e0Sopenharmony_ci // Search for the value passed 171048147e0Sopenharmony_ci searchKey: string = ''; 172048147e0Sopenharmony_ci // Is it grass? 173048147e0Sopenharmony_ci isDraft: boolean = false; 174048147e0Sopenharmony_ci // Contents of the draft 175048147e0Sopenharmony_ci draftContent: string = ''; 176048147e0Sopenharmony_ci draftGroupId: number = 0; 177048147e0Sopenharmony_ci // Can I double-click to cancel sending 178048147e0Sopenharmony_ci recallMessagesFlag: boolean = false; 179048147e0Sopenharmony_ci // Double-click Cancel Status 180048147e0Sopenharmony_ci doubleClickStatus: boolean = false; 181048147e0Sopenharmony_ci // Dynamic change sign from bottom 182048147e0Sopenharmony_ci distanceBottomFlag: boolean = false; 183048147e0Sopenharmony_ci // Deleting a Details Page 184048147e0Sopenharmony_ci hasDetailDelete: boolean = false; 185048147e0Sopenharmony_ci // Whether a contact exists 186048147e0Sopenharmony_ci hasExitContact: boolean = false; 187048147e0Sopenharmony_ci // Create a page for fetching and sending. 188048147e0Sopenharmony_ci isNewRecallMessagesFlag: boolean = false; 189048147e0Sopenharmony_ci // Recording animation 190048147e0Sopenharmony_ci recordingAnimation: LooseObject = {}; 191048147e0Sopenharmony_ci // Animation Style Properties 192048147e0Sopenharmony_ci animationOptions: LooseObject = {}; 193048147e0Sopenharmony_ci // Animation Style Attribute Object 194048147e0Sopenharmony_ci animationFrames: LooseObject = {}; 195048147e0Sopenharmony_ci // Default rear camera 196048147e0Sopenharmony_ci cameraPattern: string = 'back'; 197048147e0Sopenharmony_ci pattern: string = ''; 198048147e0Sopenharmony_ci // Lock or Not 199048147e0Sopenharmony_ci hasLock: boolean = false; 200048147e0Sopenharmony_ci // Highlight Message Type 201048147e0Sopenharmony_ci highlightsType: number = 0; 202048147e0Sopenharmony_ci // Highlight Message Content 203048147e0Sopenharmony_ci highlightsText: string = ''; 204048147e0Sopenharmony_ci timeFormat: string = '00:01'; 205048147e0Sopenharmony_ci // 0: normal; 1: notification 206048147e0Sopenharmony_ci smsType: number = 0; 207048147e0Sopenharmony_ci isPicCheckboxClicked: boolean = false; 208048147e0Sopenharmony_ci // Whether to support sending reports 209048147e0Sopenharmony_ci hasReport: boolean = false; 210048147e0Sopenharmony_ci messageType: number = common.MESSAGE_TYPE.NORMAL; 211048147e0Sopenharmony_ci textareaDatasource: Array<any> = []; 212048147e0Sopenharmony_ci pptTotalCount: number = 0; 213048147e0Sopenharmony_ci selectedTextareaIdx: -1; 214048147e0Sopenharmony_ci hasImage: boolean = false; 215048147e0Sopenharmony_ci hasContent: boolean = false; 216048147e0Sopenharmony_ci hasVcard: boolean = false; 217048147e0Sopenharmony_ci mmsAddType: number = 0; 218048147e0Sopenharmony_ci picItemSelectedIndex: number = -1; 219048147e0Sopenharmony_ci slideDuration: number = 5; 220048147e0Sopenharmony_ci slideDurations: Array<any> = []; 221048147e0Sopenharmony_ci hasDouble: boolean = true; 222048147e0Sopenharmony_ci searchContent: string = ''; 223048147e0Sopenharmony_ci // Time 224048147e0Sopenharmony_ci mmsDateSet: Set<any> = new Set(); 225048147e0Sopenharmony_ci photoFirstName: string = ''; 226048147e0Sopenharmony_ci portraitColor: string = ''; 227048147e0Sopenharmony_ci reg: RegExp = /^[\u4e00-\u9fa5_a-zA-Z]+$/; 228048147e0Sopenharmony_ci scroller: Scroller = new Scroller(); 229048147e0Sopenharmony_ci 230048147e0Sopenharmony_ci static getInstance() { 231048147e0Sopenharmony_ci if (ConversationController.sInstance == null) { 232048147e0Sopenharmony_ci ConversationController.sInstance = new ConversationController(); 233048147e0Sopenharmony_ci } 234048147e0Sopenharmony_ci return ConversationController.sInstance; 235048147e0Sopenharmony_ci } 236048147e0Sopenharmony_ci 237048147e0Sopenharmony_ci onInit() { 238048147e0Sopenharmony_ci HiLog.i(TAG, 'onInit'); 239048147e0Sopenharmony_ci this.initRouterData(); 240048147e0Sopenharmony_ci this.initData(); 241048147e0Sopenharmony_ci if (this.hasDouble) { 242048147e0Sopenharmony_ci this.initNewPageContacts(); 243048147e0Sopenharmony_ci this.hasDouble = false; 244048147e0Sopenharmony_ci } 245048147e0Sopenharmony_ci // Obtains the actual data. You do not need to query the data when creating new data. 246048147e0Sopenharmony_ci if (!this.isNewMsg) { 247048147e0Sopenharmony_ci this.queryMessageDetail(this.strContactsNumber, this.threadId, () => { 248048147e0Sopenharmony_ci }); 249048147e0Sopenharmony_ci this.scroller.scrollToIndex(this.mmsList.length - 1) 250048147e0Sopenharmony_ci } 251048147e0Sopenharmony_ci let actionData: LooseObject = {}; 252048147e0Sopenharmony_ci actionData.threadId = this.threadId; 253048147e0Sopenharmony_ci actionData.hasRead = common.is_read.UN_READ; 254048147e0Sopenharmony_ci NotificationService.getInstance().cancelMessageNotify(actionData); 255048147e0Sopenharmony_ci NotificationService.getInstance().updateBadgeNumber(); 256048147e0Sopenharmony_ci } 257048147e0Sopenharmony_ci 258048147e0Sopenharmony_ci onShow() { 259048147e0Sopenharmony_ci HiLog.i(TAG, 'onShow'); 260048147e0Sopenharmony_ci // Check whether the Send button can be clicked. 261048147e0Sopenharmony_ci this.judgeSendBtnCanClicked(); 262048147e0Sopenharmony_ci // Subscribe to PA 263048147e0Sopenharmony_ci this.subscribeDetail(); 264048147e0Sopenharmony_ci // Check whether a contact exists. 265048147e0Sopenharmony_ci this.judgeContactExists(); 266048147e0Sopenharmony_ci // Initialize the forwarded data 267048147e0Sopenharmony_ci this.initTransmitMeg(); 268048147e0Sopenharmony_ci // Forwarding and sending 269048147e0Sopenharmony_ci this.transmitSend(); 270048147e0Sopenharmony_ci } 271048147e0Sopenharmony_ci 272048147e0Sopenharmony_ci onHide() { 273048147e0Sopenharmony_ci HiLog.i(TAG, 'onHide'); 274048147e0Sopenharmony_ci this.unSubscribeDetail(); 275048147e0Sopenharmony_ci } 276048147e0Sopenharmony_ci 277048147e0Sopenharmony_ci initData() { 278048147e0Sopenharmony_ci this.strMsgDeleteDialogTip = $r('app.string.msg_delete_dialog_con_tip2', 279048147e0Sopenharmony_ci this.selectDeleteMsgCount 280048147e0Sopenharmony_ci ); 281048147e0Sopenharmony_ci this.tabTextList = [ 282048147e0Sopenharmony_ci // $r('app.string.msg_take_photos'), 283048147e0Sopenharmony_ci // $r('app.string.msg_picture'), 284048147e0Sopenharmony_ci // $r('app.string.msg_record'), 285048147e0Sopenharmony_ci // $r('app.string.more_low') 286048147e0Sopenharmony_ci ]; 287048147e0Sopenharmony_ci this.animationOptions = { 288048147e0Sopenharmony_ci duration: ANIMATION_DURATION, 289048147e0Sopenharmony_ci easing: 'linear', 290048147e0Sopenharmony_ci fill: 'forwards', 291048147e0Sopenharmony_ci iterations: 'Infinity', 292048147e0Sopenharmony_ci }; 293048147e0Sopenharmony_ci this.animationFrames = [ 294048147e0Sopenharmony_ci { 295048147e0Sopenharmony_ci transform: { 296048147e0Sopenharmony_ci scale: TRANSFORM_SCALE_MIN 297048147e0Sopenharmony_ci } 298048147e0Sopenharmony_ci }, 299048147e0Sopenharmony_ci { 300048147e0Sopenharmony_ci transform: { 301048147e0Sopenharmony_ci scale: TRANSFORM_SCALE_MAX 302048147e0Sopenharmony_ci } 303048147e0Sopenharmony_ci } 304048147e0Sopenharmony_ci ]; 305048147e0Sopenharmony_ci // this.pattern = $r('app.string.camera_post'); 306048147e0Sopenharmony_ci this.initSlideDurations(); 307048147e0Sopenharmony_ci } 308048147e0Sopenharmony_ci 309048147e0Sopenharmony_ci initSlideDurations() { 310048147e0Sopenharmony_ci let arr = []; 311048147e0Sopenharmony_ci for (let i = 1; i <= 10; i++) { 312048147e0Sopenharmony_ci arr.push(i); 313048147e0Sopenharmony_ci } 314048147e0Sopenharmony_ci this.slideDurations = arr; 315048147e0Sopenharmony_ci } 316048147e0Sopenharmony_ci 317048147e0Sopenharmony_ci release() { 318048147e0Sopenharmony_ci this.textValue = ''; 319048147e0Sopenharmony_ci this.receiveContactValue = ''; 320048147e0Sopenharmony_ci this.isDraft = false; 321048147e0Sopenharmony_ci this.mmsList = []; 322048147e0Sopenharmony_ci } 323048147e0Sopenharmony_ci 324048147e0Sopenharmony_ci initNewPageContacts() { 325048147e0Sopenharmony_ci let transmitContacts = []; 326048147e0Sopenharmony_ci if (this.strContactsNumber) { 327048147e0Sopenharmony_ci let contactsNames = this.strContactsName.split(','); 328048147e0Sopenharmony_ci let telephones = this.strContactsNumber.split(','); 329048147e0Sopenharmony_ci let telephoneFormat = this.strContactsNumberFormat.split(','); 330048147e0Sopenharmony_ci for (let index in contactsNames) { 331048147e0Sopenharmony_ci let item: LooseObject = {}; 332048147e0Sopenharmony_ci item.contactName = contactsNames[index]; 333048147e0Sopenharmony_ci item.telephone = telephones[index]; 334048147e0Sopenharmony_ci if (contactsNames[index] == common.string.EMPTY_STR && 335048147e0Sopenharmony_ci telephoneFormat[index] == common.string.EMPTY_STR) { 336048147e0Sopenharmony_ci item.telephoneFormat = telephones[index]; 337048147e0Sopenharmony_ci } else { 338048147e0Sopenharmony_ci item.telephoneFormat = telephoneFormat[index]; 339048147e0Sopenharmony_ci } 340048147e0Sopenharmony_ci item.headImage = common.string.EMPTY_STR; 341048147e0Sopenharmony_ci item.select = false; 342048147e0Sopenharmony_ci transmitContacts.push(item); 343048147e0Sopenharmony_ci } 344048147e0Sopenharmony_ci } 345048147e0Sopenharmony_ci this.commonCtrl.paramContact.transmitContacts = transmitContacts; 346048147e0Sopenharmony_ci this.commonCtrl.paramContact.isSelectContact = false; 347048147e0Sopenharmony_ci this.commonCtrl.paramContact.isNewRecallMessagesFlag = false; 348048147e0Sopenharmony_ci } 349048147e0Sopenharmony_ci 350048147e0Sopenharmony_ci initRouterData() { 351048147e0Sopenharmony_ci let routerParams: LooseObject = router.getParams(); 352048147e0Sopenharmony_ci this.strContactsName = 353048147e0Sopenharmony_ci routerParams.strContactsName == undefined ? '' : routerParams.strContactsName; 354048147e0Sopenharmony_ci this.strContactsNumber = 355048147e0Sopenharmony_ci routerParams.strContactsNumber == undefined ? '' : routerParams.strContactsNumber; 356048147e0Sopenharmony_ci this.strContactsNumberFormat = 357048147e0Sopenharmony_ci routerParams.strContactsNumberFormat == undefined ? '' : routerParams.strContactsNumberFormat; 358048147e0Sopenharmony_ci this.contactsNum = routerParams.contactsNum == undefined ? 0 : routerParams.contactsNum; 359048147e0Sopenharmony_ci this.threadId = routerParams.threadId == undefined ? 0 : routerParams.threadId; 360048147e0Sopenharmony_ci this.isDraft = routerParams.isDraft == undefined ? false : routerParams.isDraft; 361048147e0Sopenharmony_ci this.draftContent = routerParams.draftContent == undefined ? '' : routerParams.draftContent; 362048147e0Sopenharmony_ci this.searchContent = routerParams.searchContent == undefined ? '' : routerParams.searchContent; 363048147e0Sopenharmony_ci this.isNewMsg = routerParams.isNewMsg == undefined ? false : routerParams.isNewMsg; 364048147e0Sopenharmony_ci this.portraitColor = AvatarColor.background.Color[Math.abs(this.threadId) % 6]; 365048147e0Sopenharmony_ci this.photoFirstNameDeal(this.strContactsName); 366048147e0Sopenharmony_ci this.dealSpecialPhoneNumber(); 367048147e0Sopenharmony_ci } 368048147e0Sopenharmony_ci 369048147e0Sopenharmony_ci photoFirstNameDeal(strContactsName) { 370048147e0Sopenharmony_ci if (strContactsName !== common.string.EMPTY_STR && this.reg.test(strContactsName.substring(0, 1))) { 371048147e0Sopenharmony_ci this.photoFirstName = strContactsName.substring(0, 1).toUpperCase() 372048147e0Sopenharmony_ci } else { 373048147e0Sopenharmony_ci this.photoFirstName = '-1' 374048147e0Sopenharmony_ci } 375048147e0Sopenharmony_ci } 376048147e0Sopenharmony_ci 377048147e0Sopenharmony_ci // Handle invalid phone numbers that contain #, *, and dots in redirection from other applications. 378048147e0Sopenharmony_ci // Replace them with spaces. 379048147e0Sopenharmony_ci dealSpecialPhoneNumber() { 380048147e0Sopenharmony_ci if (!this.isPhoneNumber(this.strContactsNumber)) { 381048147e0Sopenharmony_ci this.strContactsNumber = this.replaceCode(this.strContactsNumber); 382048147e0Sopenharmony_ci this.strContactsNumberFormat = this.replaceCode(this.strContactsNumberFormat); 383048147e0Sopenharmony_ci if (this.strContactsName != common.string.EMPTY_STR) { 384048147e0Sopenharmony_ci this.strContactsName = common.string.EMPTY_STR; 385048147e0Sopenharmony_ci } 386048147e0Sopenharmony_ci } 387048147e0Sopenharmony_ci } 388048147e0Sopenharmony_ci 389048147e0Sopenharmony_ci replaceCode(str) { 390048147e0Sopenharmony_ci if (str != null && str.length != 0) { 391048147e0Sopenharmony_ci return str.replace(new RegExp(/e|-|#|\*|\./, 'g'), common.string.EMPTY_STR); 392048147e0Sopenharmony_ci } else { 393048147e0Sopenharmony_ci return common.string.EMPTY_STR; 394048147e0Sopenharmony_ci } 395048147e0Sopenharmony_ci } 396048147e0Sopenharmony_ci 397048147e0Sopenharmony_ci titleBarCancel() { 398048147e0Sopenharmony_ci // Cancel button 399048147e0Sopenharmony_ci this.cancelCheckedAll(); 400048147e0Sopenharmony_ci this.setSelectStatus(false); 401048147e0Sopenharmony_ci } 402048147e0Sopenharmony_ci 403048147e0Sopenharmony_ci onBackPress() { 404048147e0Sopenharmony_ci if (this.isSelectStatus) { 405048147e0Sopenharmony_ci // Multi-choice status 406048147e0Sopenharmony_ci this.isSelectStatus = false; 407048147e0Sopenharmony_ci this.cancelCheckedAll(); 408048147e0Sopenharmony_ci return true; 409048147e0Sopenharmony_ci } 410048147e0Sopenharmony_ci let source = this.getMmsSource(); 411048147e0Sopenharmony_ci this.insertAndUpdateSessionDraft(source, () => { 412048147e0Sopenharmony_ci this.release(); 413048147e0Sopenharmony_ci router.back(); 414048147e0Sopenharmony_ci }); 415048147e0Sopenharmony_ci return true; 416048147e0Sopenharmony_ci } 417048147e0Sopenharmony_ci 418048147e0Sopenharmony_ci insertAndUpdateSessionDraft(source, callback) { 419048147e0Sopenharmony_ci // Create a draft. If the selected contact or content is empty, delete the draft. 420048147e0Sopenharmony_ci if (this.isNewMsg && this.isDraft) { 421048147e0Sopenharmony_ci if ((this.selectContacts.length == 0 && this.receiveContactValue == common.string.EMPTY_STR) || 422048147e0Sopenharmony_ci (this.textValue == common.string.EMPTY_STR && source.length == 0)) { 423048147e0Sopenharmony_ci let condition: LooseObject = {}; 424048147e0Sopenharmony_ci condition.threadId = this.threadId; 425048147e0Sopenharmony_ci ConversationListService.getInstance().deleteSessionByCondition(condition, null, null); 426048147e0Sopenharmony_ci this.deleteDraftData(); 427048147e0Sopenharmony_ci } 428048147e0Sopenharmony_ci } 429048147e0Sopenharmony_ci let actionData: LooseObject = {}; 430048147e0Sopenharmony_ci actionData.slotId = this.slotId; 431048147e0Sopenharmony_ci actionData.threadId = this.threadId; 432048147e0Sopenharmony_ci actionData.receiveContactValue = common.string.EMPTY_STR; 433048147e0Sopenharmony_ci actionData.selectContacts = []; 434048147e0Sopenharmony_ci actionData.content = this.textValue; 435048147e0Sopenharmony_ci actionData.isReceive = false; 436048147e0Sopenharmony_ci actionData.ownNumber = common.string.EMPTY_STR; 437048147e0Sopenharmony_ci actionData.isSender = common.is_sender.NO; 438048147e0Sopenharmony_ci actionData.hasDraft = common.has_draft.HAVE; 439048147e0Sopenharmony_ci actionData.hasReport = settingService.judgeIsDeliveryReport(this.isEditMms); 440048147e0Sopenharmony_ci actionData.isMms = this.isEditMms; 441048147e0Sopenharmony_ci actionData.mmsSource = source; 442048147e0Sopenharmony_ci actionData.groupId = this.draftGroupId; 443048147e0Sopenharmony_ci actionData.messageType = this.messageType; 444048147e0Sopenharmony_ci actionData.hasAttachment = commonService.judgeIsAttachment(source); 445048147e0Sopenharmony_ci actionData.isDraft = this.isDraft; 446048147e0Sopenharmony_ci // The draft does not exist or the draft needs to be updated. The draft data on the new page needs to be saved. 447048147e0Sopenharmony_ci if (this.textValue != common.string.EMPTY_STR || source.length !== 0) { 448048147e0Sopenharmony_ci actionData.isNewMsg = this.isNewMsg; 449048147e0Sopenharmony_ci if (this.isNewMsg) { 450048147e0Sopenharmony_ci // If the selected contact is not empty 451048147e0Sopenharmony_ci if (this.selectContacts.length > 0) { 452048147e0Sopenharmony_ci actionData.selectContacts = this.selectContacts; 453048147e0Sopenharmony_ci ConversationListService.getInstance().insertSessionDraft(actionData, callback, null); 454048147e0Sopenharmony_ci } 455048147e0Sopenharmony_ci // If the recipient input field is not empty 456048147e0Sopenharmony_ci else if (this.receiveContactValue != common.string.EMPTY_STR) { 457048147e0Sopenharmony_ci actionData.receiveContactValue = this.receiveContactValue; 458048147e0Sopenharmony_ci // If the number entered in the text box is invalid, the system does not save the draft when the 459048147e0Sopenharmony_ci // Back key is pressed. 460048147e0Sopenharmony_ci if (this.isPhoneNumber(this.receiveContactValue)) { 461048147e0Sopenharmony_ci ConversationListService.getInstance().insertSessionDraft(actionData, callback, null); 462048147e0Sopenharmony_ci } else if (this.isDraft) { 463048147e0Sopenharmony_ci // If the current draft is in draft state and the entered number is invalid, the current draft 464048147e0Sopenharmony_ci // is deleted. 465048147e0Sopenharmony_ci let condition: LooseObject = {}; 466048147e0Sopenharmony_ci condition.threadId = this.threadId; 467048147e0Sopenharmony_ci ConversationListService.getInstance().deleteSessionByCondition(condition, null, null); 468048147e0Sopenharmony_ci this.deleteDraftData(); 469048147e0Sopenharmony_ci callback(); 470048147e0Sopenharmony_ci } else { 471048147e0Sopenharmony_ci callback(); 472048147e0Sopenharmony_ci } 473048147e0Sopenharmony_ci } else { 474048147e0Sopenharmony_ci callback(); 475048147e0Sopenharmony_ci } 476048147e0Sopenharmony_ci } else { 477048147e0Sopenharmony_ci // This is not a new scenario. 478048147e0Sopenharmony_ci actionData.telephone = this.strContactsNumber; 479048147e0Sopenharmony_ci ConversationListService.getInstance().insertSessionDraft(actionData, callback, null); 480048147e0Sopenharmony_ci } 481048147e0Sopenharmony_ci } else if (!this.isNewMsg && this.isDraft) { 482048147e0Sopenharmony_ci // If a draft exists, perform the following operations: 483048147e0Sopenharmony_ci this.dealSessionDraft(source); 484048147e0Sopenharmony_ci callback(); 485048147e0Sopenharmony_ci } else { 486048147e0Sopenharmony_ci callback(); 487048147e0Sopenharmony_ci } 488048147e0Sopenharmony_ci } 489048147e0Sopenharmony_ci 490048147e0Sopenharmony_ci // When the draft logic is set, the text content is empty and the page is not created, the session list data needs 491048147e0Sopenharmony_ci // to be updated. 492048147e0Sopenharmony_ci dealSessionDraft(source) { 493048147e0Sopenharmony_ci let valueBucket: LooseObject = { 494048147e0Sopenharmony_ci 'content': common.string.EMPTY_STR, 495048147e0Sopenharmony_ci 'has_draft': common.has_draft.NO, 496048147e0Sopenharmony_ci 'time': new Date().getTime(), 497048147e0Sopenharmony_ci 'has_mms': common.has_mms.NO, 498048147e0Sopenharmony_ci 'has_attachment': common.has_attachment.NO 499048147e0Sopenharmony_ci } 500048147e0Sopenharmony_ci // Query the last content in the list 501048147e0Sopenharmony_ci let length: number = this.mmsList.length; 502048147e0Sopenharmony_ci if (length > 0) { 503048147e0Sopenharmony_ci let item: LooseObject = this.mmsList[length - 1]; 504048147e0Sopenharmony_ci valueBucket.content = item.content; 505048147e0Sopenharmony_ci valueBucket.has_mms = item.isMsm ? common.has_mms.HAVE : common.has_mms.NO; 506048147e0Sopenharmony_ci valueBucket.has_attachment = item.isMsm ? common.has_attachment.HAVE : common.has_attachment.NO; 507048147e0Sopenharmony_ci } 508048147e0Sopenharmony_ci let condition: LooseObject = {}; 509048147e0Sopenharmony_ci condition.threadId = this.threadId; 510048147e0Sopenharmony_ci ConversationListService.getInstance().updateSessionByCondition(condition, valueBucket, null, null); 511048147e0Sopenharmony_ci this.deleteDraftData(); 512048147e0Sopenharmony_ci this.isDraft = false; 513048147e0Sopenharmony_ci } 514048147e0Sopenharmony_ci 515048147e0Sopenharmony_ci cancelCheckedAll() { 516048147e0Sopenharmony_ci for (let element of this.mmsList) { 517048147e0Sopenharmony_ci element.isCbChecked = false; 518048147e0Sopenharmony_ci } 519048147e0Sopenharmony_ci } 520048147e0Sopenharmony_ci 521048147e0Sopenharmony_ci clickGroupCheckAll() { 522048147e0Sopenharmony_ci for (let element of this.mmsList) { 523048147e0Sopenharmony_ci element.isCbChecked = !this.isMessageCheckAll; 524048147e0Sopenharmony_ci } 525048147e0Sopenharmony_ci if (this.isMessageCheckAll) { 526048147e0Sopenharmony_ci this.setMessageCheckAll(common.int.CHECKBOX_SELECT_NONE); 527048147e0Sopenharmony_ci } else { 528048147e0Sopenharmony_ci this.setMessageCheckAll(common.int.CHECKBOX_SELECT_ALL); 529048147e0Sopenharmony_ci } 530048147e0Sopenharmony_ci } 531048147e0Sopenharmony_ci 532048147e0Sopenharmony_ci setMessageCheckAll(type) { 533048147e0Sopenharmony_ci HiLog.i(TAG, 'setMessageCheckAll, isSelectStatus=' + this.isSelectStatus); 534048147e0Sopenharmony_ci if (!this.isSelectStatus) { 535048147e0Sopenharmony_ci return; 536048147e0Sopenharmony_ci } 537048147e0Sopenharmony_ci if (type == common.int.CHECKBOX_SELECT_ALL) { 538048147e0Sopenharmony_ci HiLog.i(TAG, 'setMessageCheckAll, CHECKBOX_SELECT_ALL'); 539048147e0Sopenharmony_ci this.selectDeleteMsgCount = this.mmsList.length; 540048147e0Sopenharmony_ci this.isMessageCheckAll = true; 541048147e0Sopenharmony_ci this.hasReport = false; 542048147e0Sopenharmony_ci let countLock = 0; 543048147e0Sopenharmony_ci // Check whether all of them are locked. 544048147e0Sopenharmony_ci for (let element of this.mmsList) { 545048147e0Sopenharmony_ci if (element.isCbChecked && element.isLock) { 546048147e0Sopenharmony_ci countLock++; 547048147e0Sopenharmony_ci } 548048147e0Sopenharmony_ci } 549048147e0Sopenharmony_ci if (this.selectDeleteMsgCount == countLock) { 550048147e0Sopenharmony_ci this.hasLock = true; 551048147e0Sopenharmony_ci } 552048147e0Sopenharmony_ci } else if (type == common.int.CHECKBOX_SELECT_NONE) { 553048147e0Sopenharmony_ci HiLog.i(TAG, 'setMessageCheckAll, CHECKBOX_SELECT_NONE'); 554048147e0Sopenharmony_ci this.selectDeleteMsgCount = 0; 555048147e0Sopenharmony_ci this.isMessageCheckAll = false; 556048147e0Sopenharmony_ci this.hasLock = false; 557048147e0Sopenharmony_ci this.hasReport = false; 558048147e0Sopenharmony_ci } else { 559048147e0Sopenharmony_ci // The default value is CHECKBOX_SELECT_UNKNOWN. Check whether there is any unselected item. 560048147e0Sopenharmony_ci HiLog.i(TAG, 'setMessageCheckAll, else'); 561048147e0Sopenharmony_ci this.checkBoxSelectUnknow(); 562048147e0Sopenharmony_ci } 563048147e0Sopenharmony_ci } 564048147e0Sopenharmony_ci 565048147e0Sopenharmony_ci checkBoxSelectUnknow() { 566048147e0Sopenharmony_ci HiLog.i(TAG, 'checkBoxSelectUnknow, start'); 567048147e0Sopenharmony_ci // The default value is CHECKBOX_SELECT_UNKNOWN. Check whether there is any unselected item. 568048147e0Sopenharmony_ci this.isMessageCheckAll = true; 569048147e0Sopenharmony_ci this.selectDeleteMsgCount = 0; 570048147e0Sopenharmony_ci let countLock = 0; 571048147e0Sopenharmony_ci let countReport = 0; 572048147e0Sopenharmony_ci for (let element of this.mmsList) { 573048147e0Sopenharmony_ci if (element.isCbChecked) { 574048147e0Sopenharmony_ci this.selectDeleteMsgCount++; 575048147e0Sopenharmony_ci } else if (this.isMessageCheckAll) { 576048147e0Sopenharmony_ci this.isMessageCheckAll = false; 577048147e0Sopenharmony_ci } 578048147e0Sopenharmony_ci if (element.isCbChecked && element.isLock) { 579048147e0Sopenharmony_ci countLock++; 580048147e0Sopenharmony_ci } 581048147e0Sopenharmony_ci if (element.isCbChecked && element.hasReport) { 582048147e0Sopenharmony_ci countReport++; 583048147e0Sopenharmony_ci } 584048147e0Sopenharmony_ci } 585048147e0Sopenharmony_ci // If one is selected and there is a lock 586048147e0Sopenharmony_ci if (this.selectDeleteMsgCount == 1 && countLock > 0) { 587048147e0Sopenharmony_ci this.hasLock = true; 588048147e0Sopenharmony_ci } else { 589048147e0Sopenharmony_ci this.hasLock = false; 590048147e0Sopenharmony_ci } 591048147e0Sopenharmony_ci // If all are checked and all are locked 592048147e0Sopenharmony_ci if (this.selectDeleteMsgCount == countLock) { 593048147e0Sopenharmony_ci this.hasLock = true; 594048147e0Sopenharmony_ci } 595048147e0Sopenharmony_ci if (countReport == 1) { 596048147e0Sopenharmony_ci this.hasReport = true; 597048147e0Sopenharmony_ci } else { 598048147e0Sopenharmony_ci this.hasReport = false; 599048147e0Sopenharmony_ci } 600048147e0Sopenharmony_ci } 601048147e0Sopenharmony_ci 602048147e0Sopenharmony_ci listCheckBoxChange(index, e) { 603048147e0Sopenharmony_ci // When API 7 is used, the isOn type is not boolean but is of the number type. If the isOn type is displayed, 604048147e0Sopenharmony_ci // an error may occur. 605048147e0Sopenharmony_ci let isCheck: string = e 606048147e0Sopenharmony_ci // this.messageList[index].isCbChecked = isCheck == '1' ? true : false; 607048147e0Sopenharmony_ci let item = this.mmsList[index]; 608048147e0Sopenharmony_ci item.isCbChecked = isCheck == '1' ? true : false; 609048147e0Sopenharmony_ci HiLog.i(TAG, `listCheckBoxChange, isCbChecked=${item.isCbChecked}, index=${index}, mmsIndex=${this.mmsIndex}`); 610048147e0Sopenharmony_ci this.mmsIndex = index; 611048147e0Sopenharmony_ci this.hasReport = item.hasReport; 612048147e0Sopenharmony_ci this.setMessageCheckAll(common.int.CHECKBOX_SELECT_UNKNOWN); 613048147e0Sopenharmony_ci if (this.selectDeleteMsgCount == 1) { 614048147e0Sopenharmony_ci let item; 615048147e0Sopenharmony_ci for (let element of this.mmsList) { 616048147e0Sopenharmony_ci if (element.isCbChecked) { 617048147e0Sopenharmony_ci item = element; 618048147e0Sopenharmony_ci break; 619048147e0Sopenharmony_ci } 620048147e0Sopenharmony_ci } 621048147e0Sopenharmony_ci if (item != null) { 622048147e0Sopenharmony_ci this.setGroupMoreMenu(item); 623048147e0Sopenharmony_ci } 624048147e0Sopenharmony_ci } 625048147e0Sopenharmony_ci } 626048147e0Sopenharmony_ci 627048147e0Sopenharmony_ci setGroupMoreMenu(item) { 628048147e0Sopenharmony_ci if (!item.isMsm) { 629048147e0Sopenharmony_ci this.hasContent = true; 630048147e0Sopenharmony_ci return; 631048147e0Sopenharmony_ci } 632048147e0Sopenharmony_ci this.hasContent = commonService.judgeIsSelectText(item.mms); 633048147e0Sopenharmony_ci this.hasImage = commonService.judgeIsImage(item.mms); 634048147e0Sopenharmony_ci if (item.isMsm && item.mms.length == 1 && item.mms[0].type == common.MSG_ITEM_TYPE.CARD) { 635048147e0Sopenharmony_ci this.hasVcard = true; 636048147e0Sopenharmony_ci } else { 637048147e0Sopenharmony_ci this.hasVcard = false; 638048147e0Sopenharmony_ci } 639048147e0Sopenharmony_ci } 640048147e0Sopenharmony_ci 641048147e0Sopenharmony_ci longPressSelected(index) { 642048147e0Sopenharmony_ci switch (index) { 643048147e0Sopenharmony_ci case 0: 644048147e0Sopenharmony_ci // duplicating 645048147e0Sopenharmony_ci this.copyText(); 646048147e0Sopenharmony_ci break; 647048147e0Sopenharmony_ci case 1: 648048147e0Sopenharmony_ci // Forwarding 649048147e0Sopenharmony_ci this.transmitMsgSingle(); 650048147e0Sopenharmony_ci break; 651048147e0Sopenharmony_ci case 2: 652048147e0Sopenharmony_ci // Delete 653048147e0Sopenharmony_ci this.deleteDialogShow(); 654048147e0Sopenharmony_ci break; 655048147e0Sopenharmony_ci case 3: 656048147e0Sopenharmony_ci // Select Text 657048147e0Sopenharmony_ci this.gotoTextSelect(this.mmsIndex); 658048147e0Sopenharmony_ci break; 659048147e0Sopenharmony_ci case 4: 660048147e0Sopenharmony_ci // more 661048147e0Sopenharmony_ci this.more(); 662048147e0Sopenharmony_ci break; 663048147e0Sopenharmony_ci case 5: 664048147e0Sopenharmony_ci // Save 665048147e0Sopenharmony_ci this.saveImage(); 666048147e0Sopenharmony_ci break; 667048147e0Sopenharmony_ci default: 668048147e0Sopenharmony_ci break; 669048147e0Sopenharmony_ci } 670048147e0Sopenharmony_ci } 671048147e0Sopenharmony_ci 672048147e0Sopenharmony_ci // Initializing Forwarding Data 673048147e0Sopenharmony_ci initTransmitMeg() { 674048147e0Sopenharmony_ci let routerParams: LooseObject = router.getParams(); 675048147e0Sopenharmony_ci if (routerParams.transmitFlag) { 676048147e0Sopenharmony_ci this.threadId = routerParams.threadId; 677048147e0Sopenharmony_ci this.slotId = MmsPreferences.getInstance().getSendMessageSlotId(); 678048147e0Sopenharmony_ci this.contactsNum = this.contactsNum; 679048147e0Sopenharmony_ci this.strContactsName = routerParams.strContactsName; 680048147e0Sopenharmony_ci this.strContactsNumber = routerParams.strContactsNumber; 681048147e0Sopenharmony_ci this.strContactsNumberFormat = routerParams.strContactsNumberFormat; 682048147e0Sopenharmony_ci this.initNewPageContacts(); 683048147e0Sopenharmony_ci } 684048147e0Sopenharmony_ci } 685048147e0Sopenharmony_ci 686048147e0Sopenharmony_ci // Forwarding and sending 687048147e0Sopenharmony_ci transmitSend() { 688048147e0Sopenharmony_ci // Send Flag 689048147e0Sopenharmony_ci let transmitFlag = router.getParams().transmitFlag; 690048147e0Sopenharmony_ci //Indicates whether the slide page is an MMS message. 691048147e0Sopenharmony_ci let isSlideDetail = router.getParams().isSlideDetail; 692048147e0Sopenharmony_ci if (transmitFlag) { 693048147e0Sopenharmony_ci if (isSlideDetail) { 694048147e0Sopenharmony_ci // Indicates whether the currently edited message is an MMS message. 695048147e0Sopenharmony_ci this.isEditMms = true; 696048147e0Sopenharmony_ci //this.mmsTransmitSend(); 697048147e0Sopenharmony_ci } else { 698048147e0Sopenharmony_ci this.generalTransmitSend(); 699048147e0Sopenharmony_ci } 700048147e0Sopenharmony_ci } 701048147e0Sopenharmony_ci } 702048147e0Sopenharmony_ci 703048147e0Sopenharmony_ci generalTransmitSend() { 704048147e0Sopenharmony_ci let transmitSource: Array<LooseObject> = <Array<LooseObject>> router.getParams().transmitSource; 705048147e0Sopenharmony_ci let isSource = router.getParams().isContainerOriginSource; 706048147e0Sopenharmony_ci this.canSendMessage = false; 707048147e0Sopenharmony_ci for (let element of transmitSource) { 708048147e0Sopenharmony_ci let content = common.string.EMPTY_STR; 709048147e0Sopenharmony_ci if (isSource && !element.isMsm) { 710048147e0Sopenharmony_ci content = element.contentInfo + element.content; 711048147e0Sopenharmony_ci } else { 712048147e0Sopenharmony_ci content = element.content; 713048147e0Sopenharmony_ci } 714048147e0Sopenharmony_ci let actionData = { 715048147e0Sopenharmony_ci content: content, 716048147e0Sopenharmony_ci mmsSource: element.mms, 717048147e0Sopenharmony_ci msgUriPath: element.msgUriPath 718048147e0Sopenharmony_ci }; 719048147e0Sopenharmony_ci this.delayTransmitSend(actionData, element.isMsm); 720048147e0Sopenharmony_ci } 721048147e0Sopenharmony_ci } 722048147e0Sopenharmony_ci 723048147e0Sopenharmony_ci delayTransmitSend(element, isMms) { 724048147e0Sopenharmony_ci this.queryMessageDetail(this.strContactsNumber, this.threadId, () => { 725048147e0Sopenharmony_ci this.sendSms(element.content, element.msgUriPath, isMms, element.mmsSource); 726048147e0Sopenharmony_ci }); 727048147e0Sopenharmony_ci } 728048147e0Sopenharmony_ci 729048147e0Sopenharmony_ci sendSms(content, msgUriPath, isMms, mmsSource): void { 730048147e0Sopenharmony_ci // Sending an SMS Message on a Full-Screen Page 731048147e0Sopenharmony_ci this.isSendStatus = true; 732048147e0Sopenharmony_ci // Initialize the data to be sent. 733048147e0Sopenharmony_ci this.initSendSms(content, msgUriPath, isMms, mmsSource); 734048147e0Sopenharmony_ci this.slotId = MmsPreferences.getInstance().getSendMessageSlotId(); 735048147e0Sopenharmony_ci let actionData: LooseObject = {}; 736048147e0Sopenharmony_ci actionData.slotId = this.slotId; 737048147e0Sopenharmony_ci actionData.destinationHost = this.strContactsNumber; 738048147e0Sopenharmony_ci actionData.content = content; 739048147e0Sopenharmony_ci actionData.isEditMms = isMms; 740048147e0Sopenharmony_ci this.dealNewRecallMessagesFlag(this.mmsList); 741048147e0Sopenharmony_ci HiLog.i(TAG, 'sendSms send start'); 742048147e0Sopenharmony_ci // Cancel Sending and Normal Sending Methods 743048147e0Sopenharmony_ci this.sendInterval(actionData, this.mmsList); 744048147e0Sopenharmony_ci HiLog.i(TAG, 'sendSms send end'); 745048147e0Sopenharmony_ci if (this.isEditMms) { 746048147e0Sopenharmony_ci this.isEditMms = false; 747048147e0Sopenharmony_ci } 748048147e0Sopenharmony_ci } 749048147e0Sopenharmony_ci 750048147e0Sopenharmony_ci initSendSms(content, msgUriPath, isMms, mmsSource) { 751048147e0Sopenharmony_ci // Obtain the day of the week. 752048147e0Sopenharmony_ci let item: LooseObject = {}; 753048147e0Sopenharmony_ci item.date = common.string.EMPTY_STR; 754048147e0Sopenharmony_ci item.time = $r('app.string.just'); 755048147e0Sopenharmony_ci item.timeMillisecond = new Date().getTime(); 756048147e0Sopenharmony_ci dateUtil.convertTimeStampToDateWeek(item, false); 757048147e0Sopenharmony_ci dateUtil.fullDate(item); 758048147e0Sopenharmony_ci item.content = content; 759048147e0Sopenharmony_ci if (isMms) { 760048147e0Sopenharmony_ci item.msgType = common.MSG_ITEM_TYPE.IMAGE; 761048147e0Sopenharmony_ci item.msgUriPath = msgUriPath; 762048147e0Sopenharmony_ci } 763048147e0Sopenharmony_ci item.isFullScreenImg = false; 764048147e0Sopenharmony_ci let time = (this.mmsEditList.length != 0 && (this.mmsEditList[0].type == 3 || this.mmsEditList[0].type == 5)) ? 765048147e0Sopenharmony_ci this.mmsEditList[0].time : common.string.SUCCESS; 766048147e0Sopenharmony_ci item.audioTime = time; 767048147e0Sopenharmony_ci item.isCbChecked = false; 768048147e0Sopenharmony_ci item.isLock = false; 769048147e0Sopenharmony_ci item.isStared = false; 770048147e0Sopenharmony_ci item.isReceive = false; 771048147e0Sopenharmony_ci item.sendStatus = 1; 772048147e0Sopenharmony_ci item.subId = this.slotId; 773048147e0Sopenharmony_ci item.isMsm = isMms; 774048147e0Sopenharmony_ci this.contactsNum = this.strContactsNumber.split(',').length; 775048147e0Sopenharmony_ci item.contactsNum = this.contactsNum; 776048147e0Sopenharmony_ci item.cancelTimeCount = common.int.CANCEL_TIME_COUNT; 777048147e0Sopenharmony_ci item.mmsEditListTemp = this.fillmmsEditListTemp(msgUriPath, isMms); 778048147e0Sopenharmony_ci if (this.contactsNum > 1) { 779048147e0Sopenharmony_ci item.completeNumber = 0; 780048147e0Sopenharmony_ci item.failuresNumber = 0; 781048147e0Sopenharmony_ci } 782048147e0Sopenharmony_ci item.hasReport = settingService.judgeIsDeliveryReport(item.isMsm); 783048147e0Sopenharmony_ci item.mmsSource = mmsSource; 784048147e0Sopenharmony_ci if (this.isEditMms || isMms) { 785048147e0Sopenharmony_ci item.msgShowType = commonService.getDisplay(mmsSource); 786048147e0Sopenharmony_ci commonService.setItemMmsContent(item, mmsSource); 787048147e0Sopenharmony_ci item.content = this.dealItemContent(item.msgShowType, item.content, mmsSource); 788048147e0Sopenharmony_ci } else { 789048147e0Sopenharmony_ci item.msgShowType = common.MESSAGE_SHOW_TYPE.NORMAL; 790048147e0Sopenharmony_ci } 791048147e0Sopenharmony_ci this.mmsList.push(item); 792048147e0Sopenharmony_ci } 793048147e0Sopenharmony_ci 794048147e0Sopenharmony_ci fillmmsEditListTemp(msgUriPath, isMsm) { 795048147e0Sopenharmony_ci let mmsEditListTemp = []; 796048147e0Sopenharmony_ci if (this.recallMessagesFlag && isMsm) { 797048147e0Sopenharmony_ci let item: LooseObject = {}; 798048147e0Sopenharmony_ci item.type = common.MSG_ITEM_TYPE.IMAGE; 799048147e0Sopenharmony_ci item.uriPath = msgUriPath; 800048147e0Sopenharmony_ci mmsEditListTemp.push(item); 801048147e0Sopenharmony_ci } 802048147e0Sopenharmony_ci return mmsEditListTemp; 803048147e0Sopenharmony_ci } 804048147e0Sopenharmony_ci 805048147e0Sopenharmony_ci dealNewRecallMessagesFlag(mmsList) { 806048147e0Sopenharmony_ci let count = common.int.MESSAGE_CODE_ZERO; 807048147e0Sopenharmony_ci for (let index in mmsList) { 808048147e0Sopenharmony_ci let item = mmsList[index]; 809048147e0Sopenharmony_ci if (!item.isDraft) { 810048147e0Sopenharmony_ci count++; 811048147e0Sopenharmony_ci } 812048147e0Sopenharmony_ci } 813048147e0Sopenharmony_ci if (count == common.int.MESSAGE_CODE_ONE) { 814048147e0Sopenharmony_ci this.isNewRecallMessagesFlag = true; 815048147e0Sopenharmony_ci this.commonCtrl.paramContact.isNewRecallMessagesFlag = true; 816048147e0Sopenharmony_ci } 817048147e0Sopenharmony_ci if (count == common.int.MESSAGE_CODE_ZERO && this.isNewRecallMessagesFlag) { 818048147e0Sopenharmony_ci this.isNewMsg = true; 819048147e0Sopenharmony_ci this.isNewRecallMessagesFlag = false; 820048147e0Sopenharmony_ci } 821048147e0Sopenharmony_ci } 822048147e0Sopenharmony_ci 823048147e0Sopenharmony_ci // Single Forwarding 824048147e0Sopenharmony_ci transmitMsgSingle() { 825048147e0Sopenharmony_ci // Forwarding a single message 826048147e0Sopenharmony_ci let item: LooseObject = this.mmsList[this.mmsIndex]; 827048147e0Sopenharmony_ci let transmitObj: LooseObject = {}; 828048147e0Sopenharmony_ci let contactsName: string | Resource = common.string.EMPTY_STR; 829048147e0Sopenharmony_ci if (this.strContactsName && this.strContactsName != common.string.EMPTY_STR) { 830048147e0Sopenharmony_ci contactsName = $r('app.string.transmitContentReceive', this.strContactsName); 831048147e0Sopenharmony_ci } else { 832048147e0Sopenharmony_ci contactsName = $r('app.string.transmitContentReceive', this.strContactsNumberFormat); 833048147e0Sopenharmony_ci } 834048147e0Sopenharmony_ci transmitObj.contactsName = contactsName; 835048147e0Sopenharmony_ci transmitObj.isMsm = item.isMsm; 836048147e0Sopenharmony_ci transmitObj.msgShowType = item.msgShowType; 837048147e0Sopenharmony_ci transmitObj.mms = item.mms; 838048147e0Sopenharmony_ci transmitObj.content = item.content; 839048147e0Sopenharmony_ci transmitObj.msgUriPath = item.msgUriPath ? item.msgUriPath : common.string.EMPTY_STR; 840048147e0Sopenharmony_ci transmitObj.contentInfo = common.string.EMPTY_STR; 841048147e0Sopenharmony_ci transmitObj.msgType = item.msgType; 842048147e0Sopenharmony_ci let transmitContentList = []; 843048147e0Sopenharmony_ci transmitContentList.push(transmitObj); 844048147e0Sopenharmony_ci let transmitContent = item.isReceive ? contactsName : $r('app.string.transmitContent'); 845048147e0Sopenharmony_ci this.jumpTransmitMsg(transmitContent, transmitContentList, item.isMsm); 846048147e0Sopenharmony_ci } 847048147e0Sopenharmony_ci 848048147e0Sopenharmony_ci jumpTransmitMsg(transmitContent, transmitContentList, isMms) { 849048147e0Sopenharmony_ci router.push({ 850048147e0Sopenharmony_ci uri: 'pages/transmitmsg/transmitMsg', 851048147e0Sopenharmony_ci params: { 852048147e0Sopenharmony_ci threadId: this.threadId, 853048147e0Sopenharmony_ci doubleCard: false, 854048147e0Sopenharmony_ci transmitContent: transmitContent, 855048147e0Sopenharmony_ci transmitContentList: transmitContentList, 856048147e0Sopenharmony_ci isMulti: true, 857048147e0Sopenharmony_ci isMms: isMms, 858048147e0Sopenharmony_ci isMyStartPage: false 859048147e0Sopenharmony_ci } 860048147e0Sopenharmony_ci }); 861048147e0Sopenharmony_ci } 862048147e0Sopenharmony_ci 863048147e0Sopenharmony_ci // Delete a dialog box. 864048147e0Sopenharmony_ci deleteDialogShow() { 865048147e0Sopenharmony_ci this.strMsgDeleteDialogTip = $r('app.string.msg_delete_dialog_con_tip1'); 866048147e0Sopenharmony_ci let item = this.mmsList[this.mmsIndex]; 867048147e0Sopenharmony_ci item.isShowMsgLongMenu = false 868048147e0Sopenharmony_ci HiLog.i(TAG, 'deleteDialogShow, isShowMsgLongMenu=' + item.isShowMsgLongMenu); 869048147e0Sopenharmony_ci this.hasLockMsg = item.isLock; 870048147e0Sopenharmony_ci if (!item.isMsm) { 871048147e0Sopenharmony_ci this.hasContent = true; 872048147e0Sopenharmony_ci return; 873048147e0Sopenharmony_ci } 874048147e0Sopenharmony_ci } 875048147e0Sopenharmony_ci 876048147e0Sopenharmony_ci // more 877048147e0Sopenharmony_ci more() { 878048147e0Sopenharmony_ci this.setTabOperationStatus(false); 879048147e0Sopenharmony_ci this.distanceBottomFlag = false; 880048147e0Sopenharmony_ci let item = this.mmsList[this.mmsIndex]; 881048147e0Sopenharmony_ci 882048147e0Sopenharmony_ci item.isCbChecked = !item.isCbChecked; 883048147e0Sopenharmony_ci item.isShowMsgLongMenu = false; 884048147e0Sopenharmony_ci HiLog.i(TAG, 'more, isShowMsgLongMenu=' + item.isShowMsgLongMenu); 885048147e0Sopenharmony_ci this.setSelectStatus(true); 886048147e0Sopenharmony_ci this.hasDetailDelete = false; 887048147e0Sopenharmony_ci this.setMessageCheckAll(common.int.CHECKBOX_SELECT_UNKNOWN); 888048147e0Sopenharmony_ci this.hasReport = item.hasReport; 889048147e0Sopenharmony_ci this.setGroupMoreMenu(item); 890048147e0Sopenharmony_ci } 891048147e0Sopenharmony_ci 892048147e0Sopenharmony_ci setTabOperationStatus(flag) { 893048147e0Sopenharmony_ci this.isShowMoreOperation = flag; 894048147e0Sopenharmony_ci // Value type. The HTML page is refreshed only when the value type is numeric. 895048147e0Sopenharmony_ci if (flag) { 896048147e0Sopenharmony_ci this.sendBarMarginBottom = common.int.TAB_HEIGHT; 897048147e0Sopenharmony_ci } else { 898048147e0Sopenharmony_ci this.sendBarMarginBottom = 0; 899048147e0Sopenharmony_ci } 900048147e0Sopenharmony_ci } 901048147e0Sopenharmony_ci 902048147e0Sopenharmony_ci setSelectStatus(isSelect) { 903048147e0Sopenharmony_ci this.isSelectStatus = isSelect; 904048147e0Sopenharmony_ci } 905048147e0Sopenharmony_ci 906048147e0Sopenharmony_ci // Event of pressing and holding an SMS message 907048147e0Sopenharmony_ci mmsListLongPress(index) { 908048147e0Sopenharmony_ci for (let i = 0; i < this.mmsList.length; i++) { 909048147e0Sopenharmony_ci if (index == i) { 910048147e0Sopenharmony_ci this.mmsList[index].isShowMsgLongMenu = true; 911048147e0Sopenharmony_ci } else { 912048147e0Sopenharmony_ci this.mmsList[i].isShowMsgLongMenu = false; 913048147e0Sopenharmony_ci } 914048147e0Sopenharmony_ci } 915048147e0Sopenharmony_ci this.refresh = !this.refresh 916048147e0Sopenharmony_ci this.mmsIndex = index; 917048147e0Sopenharmony_ci if (this.isSelectStatus) { 918048147e0Sopenharmony_ci this.mmsList[index].isCbChecked = !this.mmsList[index].isCbChecked; 919048147e0Sopenharmony_ci this.setMessageCheckAll(common.int.CHECKBOX_SELECT_UNKNOWN); 920048147e0Sopenharmony_ci return; 921048147e0Sopenharmony_ci } 922048147e0Sopenharmony_ci this.hasContent = false; 923048147e0Sopenharmony_ci this.hasImage = false; 924048147e0Sopenharmony_ci let item = this.mmsList[index]; 925048147e0Sopenharmony_ci let menuId = common.string.EMPTY_STR; 926048147e0Sopenharmony_ci if (item.isMsm) { 927048147e0Sopenharmony_ci this.setGroupMoreMenu(item); 928048147e0Sopenharmony_ci // menuId = 'menu_long_press_mms'; 929048147e0Sopenharmony_ci } else { 930048147e0Sopenharmony_ci // menuId = 'menu_long_press'; 931048147e0Sopenharmony_ci } 932048147e0Sopenharmony_ci // setTimeout(() => { 933048147e0Sopenharmony_ci // this.$element(menuId).show({ 934048147e0Sopenharmony_ci // x: this.rawX, 935048147e0Sopenharmony_ci // y: this.rawY 936048147e0Sopenharmony_ci // }); 937048147e0Sopenharmony_ci // },100); 938048147e0Sopenharmony_ci } 939048147e0Sopenharmony_ci 940048147e0Sopenharmony_ci touchStart(e) { 941048147e0Sopenharmony_ci this.rawX = e.globalX; 942048147e0Sopenharmony_ci this.rawY = e.globalY; 943048147e0Sopenharmony_ci 944048147e0Sopenharmony_ci } 945048147e0Sopenharmony_ci 946048147e0Sopenharmony_ci deleteDialogCancel() { 947048147e0Sopenharmony_ci // Cancel Ejection 948048147e0Sopenharmony_ci this.isSelectLockMsg = false; 949048147e0Sopenharmony_ci HiLog.i(TAG, 'deleteDialogCancel, isSelectLockMsg=false') 950048147e0Sopenharmony_ci } 951048147e0Sopenharmony_ci 952048147e0Sopenharmony_ci deleteDialogConfirm() { 953048147e0Sopenharmony_ci let groupIds = []; 954048147e0Sopenharmony_ci let mmsListCopy = []; 955048147e0Sopenharmony_ci HiLog.i(TAG, 'deleteDialogConfirm, isSelectStatus=' + this.isSelectStatus); 956048147e0Sopenharmony_ci if (this.isSelectStatus) { 957048147e0Sopenharmony_ci // Delete the selected item through the filter. 958048147e0Sopenharmony_ci for (let element of this.mmsList) { 959048147e0Sopenharmony_ci if (!element.isCbChecked || (element.isLock && !this.isSelectLockMsg)) { 960048147e0Sopenharmony_ci this.setDateShow(element, mmsListCopy); 961048147e0Sopenharmony_ci mmsListCopy.push(element); 962048147e0Sopenharmony_ci } else { 963048147e0Sopenharmony_ci groupIds.push(element.groupId); 964048147e0Sopenharmony_ci } 965048147e0Sopenharmony_ci } 966048147e0Sopenharmony_ci // Set to non-multi-choice status 967048147e0Sopenharmony_ci this.setSelectStatus(false); 968048147e0Sopenharmony_ci this.mmsList = mmsListCopy; 969048147e0Sopenharmony_ci } else if ((this.mmsList[this.mmsIndex] != undefined && !this.mmsList[this.mmsIndex].isLock) || this.isSelectLockMsg) { 970048147e0Sopenharmony_ci let item = this.mmsList[this.mmsIndex]; 971048147e0Sopenharmony_ci for (let i = 0; i < this.mmsList.length; i++) { 972048147e0Sopenharmony_ci if (this.mmsIndex == i) { 973048147e0Sopenharmony_ci continue; 974048147e0Sopenharmony_ci } else { 975048147e0Sopenharmony_ci this.setDateShow(this.mmsList[i], mmsListCopy); 976048147e0Sopenharmony_ci mmsListCopy.push(this.mmsList[i]); 977048147e0Sopenharmony_ci } 978048147e0Sopenharmony_ci } 979048147e0Sopenharmony_ci this.mmsList = mmsListCopy; 980048147e0Sopenharmony_ci HiLog.i(TAG, 'deleteDialogConfirm, mmsList.length=' + this.mmsList.length); 981048147e0Sopenharmony_ci groupIds.push(item.groupId); 982048147e0Sopenharmony_ci } 983048147e0Sopenharmony_ci this.isSelectLockMsg = false; 984048147e0Sopenharmony_ci this.cancelCheckedAll(); 985048147e0Sopenharmony_ci if (groupIds.length > 0) { 986048147e0Sopenharmony_ci this.deleteMessageByGroupIds(groupIds); 987048147e0Sopenharmony_ci // Check whether the length of the deleted list is 0. 988048147e0Sopenharmony_ci if (this.mmsList.length === 0 && this.textValue === common.string.EMPTY_STR) { 989048147e0Sopenharmony_ci globalThis.needToUpdate = true; 990048147e0Sopenharmony_ci this.deleteMessageById(this.threadId); 991048147e0Sopenharmony_ci router.back(); 992048147e0Sopenharmony_ci } else { 993048147e0Sopenharmony_ci this.updateSessionLock(false); 994048147e0Sopenharmony_ci this.updateLastItemContent(); 995048147e0Sopenharmony_ci } 996048147e0Sopenharmony_ci } 997048147e0Sopenharmony_ci // After the deletion is complete, check whether all data is deleted. 998048147e0Sopenharmony_ci } 999048147e0Sopenharmony_ci 1000048147e0Sopenharmony_ci deleteMessageByGroupIds(groupIds): void { 1001048147e0Sopenharmony_ci let actionData: LooseObject = {}; 1002048147e0Sopenharmony_ci if (groupIds.length == 1) { 1003048147e0Sopenharmony_ci actionData.groupId = groupIds[0]; 1004048147e0Sopenharmony_ci } else { 1005048147e0Sopenharmony_ci actionData.groupIds = groupIds; 1006048147e0Sopenharmony_ci } 1007048147e0Sopenharmony_ci // Invoke the database deletion method. 1008048147e0Sopenharmony_ci ConversationService.getInstance().deleteSmsMmsInfoByCondition(actionData, null, null); 1009048147e0Sopenharmony_ci } 1010048147e0Sopenharmony_ci 1011048147e0Sopenharmony_ci // Updates the lock status of the session list. 1012048147e0Sopenharmony_ci updateSessionLock(isLock) { 1013048147e0Sopenharmony_ci let threadIds = [this.threadId]; 1014048147e0Sopenharmony_ci let hasLock = isLock ? 1 : 0; 1015048147e0Sopenharmony_ci let valueBucket = { 1016048147e0Sopenharmony_ci 'has_lock': hasLock, 1017048147e0Sopenharmony_ci } 1018048147e0Sopenharmony_ci if (!isLock) { 1019048147e0Sopenharmony_ci // If you want to unlock the status, you must unlock all the statuses before unlocking the statuses. 1020048147e0Sopenharmony_ci let unlockCount = 0; 1021048147e0Sopenharmony_ci for (let element of this.mmsList) { 1022048147e0Sopenharmony_ci if (!element.isLock) { 1023048147e0Sopenharmony_ci unlockCount++; 1024048147e0Sopenharmony_ci } 1025048147e0Sopenharmony_ci } 1026048147e0Sopenharmony_ci if (unlockCount != this.mmsList.length) { 1027048147e0Sopenharmony_ci HiLog.w(TAG, 'updateSessionLock, it is not all select unlock'); 1028048147e0Sopenharmony_ci return; 1029048147e0Sopenharmony_ci } 1030048147e0Sopenharmony_ci } 1031048147e0Sopenharmony_ci let condition: LooseObject = {}; 1032048147e0Sopenharmony_ci condition.threadId = this.threadId; 1033048147e0Sopenharmony_ci ConversationListService.getInstance().updateSessionByCondition(condition, valueBucket, null, null); 1034048147e0Sopenharmony_ci } 1035048147e0Sopenharmony_ci 1036048147e0Sopenharmony_ci updateLastItemContent() { 1037048147e0Sopenharmony_ci let actionData: LooseObject = { 1038048147e0Sopenharmony_ci 'mmsList': this.mmsList, 1039048147e0Sopenharmony_ci 'threadId': this.threadId, 1040048147e0Sopenharmony_ci }; 1041048147e0Sopenharmony_ci ConversationListService.getInstance().updateLastItemContent(actionData, null, null); 1042048147e0Sopenharmony_ci } 1043048147e0Sopenharmony_ci 1044048147e0Sopenharmony_ci deleteMessageById(threadId) { 1045048147e0Sopenharmony_ci let threadIds = [threadId]; 1046048147e0Sopenharmony_ci // Deleting Database Data 1047048147e0Sopenharmony_ci let actionData = { 1048048147e0Sopenharmony_ci threadIds: threadIds, 1049048147e0Sopenharmony_ci }; 1050048147e0Sopenharmony_ci ConversationListService.getInstance().deleteMessageById(actionData, null, null); 1051048147e0Sopenharmony_ci } 1052048147e0Sopenharmony_ci 1053048147e0Sopenharmony_ci clickGroupDelete() { 1054048147e0Sopenharmony_ci if (this.selectDeleteMsgCount == 0) { 1055048147e0Sopenharmony_ci return; 1056048147e0Sopenharmony_ci } 1057048147e0Sopenharmony_ci if (this.selectDeleteMsgCount == 1) { 1058048147e0Sopenharmony_ci this.strMsgDeleteDialogTip = $r('app.string.msg_delete_dialog_con_tip1'); 1059048147e0Sopenharmony_ci } else if (this.selectDeleteMsgCount == this.mmsList.length) { 1060048147e0Sopenharmony_ci this.strMsgDeleteDialogTip = $r('app.string.msg_delete_dialog_con_tip3'); 1061048147e0Sopenharmony_ci } else { 1062048147e0Sopenharmony_ci this.strMsgDeleteDialogTip = $r('app.string.msg_delete_dialog_con_tip2', this.selectDeleteMsgCount); 1063048147e0Sopenharmony_ci } 1064048147e0Sopenharmony_ci this.hasLockMsg = (this.mmsList.some((element, index) => element.isCbChecked && element.isLock)); 1065048147e0Sopenharmony_ci } 1066048147e0Sopenharmony_ci 1067048147e0Sopenharmony_ci // Check whether a contact exists. 1068048147e0Sopenharmony_ci judgeContactExists() { 1069048147e0Sopenharmony_ci let actionData: LooseObject = {}; 1070048147e0Sopenharmony_ci actionData.telephones = [this.strContactsNumber]; 1071048147e0Sopenharmony_ci ContactsService.getInstance().judgeContactExist(actionData, result => { 1072048147e0Sopenharmony_ci this.hasExitContact = result; 1073048147e0Sopenharmony_ci }, globalThis.mmsContext); 1074048147e0Sopenharmony_ci if (this.strContactsName == common.string.EMPTY_STR) { 1075048147e0Sopenharmony_ci this.hasExitContact = false; 1076048147e0Sopenharmony_ci } else { 1077048147e0Sopenharmony_ci this.hasExitContact = true; 1078048147e0Sopenharmony_ci } 1079048147e0Sopenharmony_ci } 1080048147e0Sopenharmony_ci 1081048147e0Sopenharmony_ci /** 1082048147e0Sopenharmony_ci * Obtain information details. 1083048147e0Sopenharmony_ci * 1084048147e0Sopenharmony_ci * @param telephone 1085048147e0Sopenharmony_ci * @param threadId 1086048147e0Sopenharmony_ci * @param callback 1087048147e0Sopenharmony_ci */ 1088048147e0Sopenharmony_ci queryMessageDetail(telephone, threadId, callback) { 1089048147e0Sopenharmony_ci let actionData: LooseObject = {}; 1090048147e0Sopenharmony_ci if (telephone != common.string.EMPTY_STR) { 1091048147e0Sopenharmony_ci actionData.telephone = telephone; 1092048147e0Sopenharmony_ci } 1093048147e0Sopenharmony_ci if (threadId != common.string.EMPTY_STR) { 1094048147e0Sopenharmony_ci actionData.threadId = threadId; 1095048147e0Sopenharmony_ci } 1096048147e0Sopenharmony_ci actionData.contactsNum = this.contactsNum; 1097048147e0Sopenharmony_ci ConversationService.getInstance().queryMessageDetail(actionData, result => { 1098048147e0Sopenharmony_ci if (result.code == common.int.SUCCESS) { 1099048147e0Sopenharmony_ci this.initIsShowMsgLongMenu(result); 1100048147e0Sopenharmony_ci this.dealMessageDetailTime(result); 1101048147e0Sopenharmony_ci this.dealMessageDetailContent(result); 1102048147e0Sopenharmony_ci if (this.mmsList.length == 0 && this.isDraft) { 1103048147e0Sopenharmony_ci HiLog.i(TAG, 'queryMessageDetail, isNewMsg = true'); 1104048147e0Sopenharmony_ci this.isNewMsg = true; 1105048147e0Sopenharmony_ci } 1106048147e0Sopenharmony_ci } else { 1107048147e0Sopenharmony_ci HiLog.w(TAG, 'queryMessageDetail, failed'); 1108048147e0Sopenharmony_ci } 1109048147e0Sopenharmony_ci if (this.isDraft) { 1110048147e0Sopenharmony_ci this.setDraft(); 1111048147e0Sopenharmony_ci } 1112048147e0Sopenharmony_ci this.deleteDraftData(); 1113048147e0Sopenharmony_ci }, null); 1114048147e0Sopenharmony_ci if (callback) { 1115048147e0Sopenharmony_ci callback(); 1116048147e0Sopenharmony_ci } 1117048147e0Sopenharmony_ci } 1118048147e0Sopenharmony_ci 1119048147e0Sopenharmony_ci initIsShowMsgLongMenu(result) { 1120048147e0Sopenharmony_ci for (let item of result.response) { 1121048147e0Sopenharmony_ci item.isShowMsgLongMenu = false; 1122048147e0Sopenharmony_ci } 1123048147e0Sopenharmony_ci } 1124048147e0Sopenharmony_ci 1125048147e0Sopenharmony_ci dealItemContent(showType, content, mmsSource) { 1126048147e0Sopenharmony_ci let strContent = content; 1127048147e0Sopenharmony_ci if (showType == common.MESSAGE_SHOW_TYPE.THEME_NO_IMAGE || showType == common.MESSAGE_SHOW_TYPE.THEME_IMAGE) { 1128048147e0Sopenharmony_ci if (content !== common.string.EMPTY_STR) { 1129048147e0Sopenharmony_ci strContent = $r('app.string.msg_theme') + ': ' + content; 1130048147e0Sopenharmony_ci } 1131048147e0Sopenharmony_ci } else if (showType == common.MESSAGE_SHOW_TYPE.PPT_NO_IMAGE) { 1132048147e0Sopenharmony_ci strContent = (content == common.string.EMPTY_STR) ? $r('app.string.msg_slide') : content; 1133048147e0Sopenharmony_ci } else if (showType == common.MESSAGE_SHOW_TYPE.PPT_IMAGE) { 1134048147e0Sopenharmony_ci if (mmsSource[0].msgType == common.MSG_ITEM_TYPE.THEME && content !== common.string.EMPTY_STR) { 1135048147e0Sopenharmony_ci strContent = $r('app.string.msg_theme') + ': ' + content; 1136048147e0Sopenharmony_ci } else { 1137048147e0Sopenharmony_ci strContent = (content == common.string.EMPTY_STR) ? $r('app.string.msg_slide') : content; 1138048147e0Sopenharmony_ci } 1139048147e0Sopenharmony_ci } 1140048147e0Sopenharmony_ci return strContent; 1141048147e0Sopenharmony_ci } 1142048147e0Sopenharmony_ci 1143048147e0Sopenharmony_ci dealMessageDetailContent(result) { 1144048147e0Sopenharmony_ci for (let item of result.response) { 1145048147e0Sopenharmony_ci item.content = this.dealItemContent(item.msgShowType, item.content, item.mms); 1146048147e0Sopenharmony_ci } 1147048147e0Sopenharmony_ci } 1148048147e0Sopenharmony_ci 1149048147e0Sopenharmony_ci dealMessageDetailTime(result) { 1150048147e0Sopenharmony_ci if (result.response && result.response.length > 0) { 1151048147e0Sopenharmony_ci let resultList = []; 1152048147e0Sopenharmony_ci for (let item of result.response) { 1153048147e0Sopenharmony_ci item.timeMillisecond = parseInt(item.timeMillisecond); 1154048147e0Sopenharmony_ci dateUtil.fullDate(item); 1155048147e0Sopenharmony_ci dateUtil.convertTimeStampToDateWeek(item, false); 1156048147e0Sopenharmony_ci this.setDateShow(item, resultList); 1157048147e0Sopenharmony_ci dateUtil.convertDateFormatForItem(item, false); 1158048147e0Sopenharmony_ci if (item.sendStatus == common.int.SEND_DRAFT) { 1159048147e0Sopenharmony_ci this.dealDraftData(item); 1160048147e0Sopenharmony_ci } else { 1161048147e0Sopenharmony_ci resultList.push(item); 1162048147e0Sopenharmony_ci } 1163048147e0Sopenharmony_ci } 1164048147e0Sopenharmony_ci this.mmsList = resultList; 1165048147e0Sopenharmony_ci } 1166048147e0Sopenharmony_ci } 1167048147e0Sopenharmony_ci 1168048147e0Sopenharmony_ci deleteDraftData() { 1169048147e0Sopenharmony_ci if (this.isDraft && this.draftGroupId > 0) { 1170048147e0Sopenharmony_ci let groupIds = [this.draftGroupId]; 1171048147e0Sopenharmony_ci this.deleteMessageByGroupIds(groupIds); 1172048147e0Sopenharmony_ci this.draftGroupId = 0; 1173048147e0Sopenharmony_ci } 1174048147e0Sopenharmony_ci } 1175048147e0Sopenharmony_ci 1176048147e0Sopenharmony_ci getMmsDataSource(mmsSource, first) { 1177048147e0Sopenharmony_ci this.pptTotalCount = (first.msgType == common.MSG_ITEM_TYPE.THEME) ? -1 : 0; 1178048147e0Sopenharmony_ci let mms = []; 1179048147e0Sopenharmony_ci let textareas = []; 1180048147e0Sopenharmony_ci mmsSource.forEach((source, index) => { 1181048147e0Sopenharmony_ci this.pptTotalCount++; 1182048147e0Sopenharmony_ci let mmsObj = null; 1183048147e0Sopenharmony_ci if (source.msgType == common.MSG_ITEM_TYPE.AUDIO || 1184048147e0Sopenharmony_ci source.msgType == common.MSG_ITEM_TYPE.IMAGE || 1185048147e0Sopenharmony_ci source.msgType == common.MSG_ITEM_TYPE.VIDEO) { 1186048147e0Sopenharmony_ci mmsObj = { 1187048147e0Sopenharmony_ci type: source.msgType, 1188048147e0Sopenharmony_ci uriPath: source.msgUriPath, 1189048147e0Sopenharmony_ci time: source.time, 1190048147e0Sopenharmony_ci index: this.pptTotalCount, 1191048147e0Sopenharmony_ci fileSize: first.fileSize 1192048147e0Sopenharmony_ci }; 1193048147e0Sopenharmony_ci mms.push(mmsObj); 1194048147e0Sopenharmony_ci } 1195048147e0Sopenharmony_ci let placeholder = $r('app.string.enter_text'); 1196048147e0Sopenharmony_ci if (source.msgType == common.MSG_ITEM_TYPE.THEME) { 1197048147e0Sopenharmony_ci placeholder = $r('app.string.msg_theme'); 1198048147e0Sopenharmony_ci } else if (mmsSource[0].msgType == common.MSG_ITEM_TYPE.THEME && mmsSource.length == 2) { 1199048147e0Sopenharmony_ci if (mmsObj) { 1200048147e0Sopenharmony_ci placeholder = $r('app.string.msg_note_mms2'); 1201048147e0Sopenharmony_ci } else { 1202048147e0Sopenharmony_ci placeholder = $r('app.string.msg_note_mms'); 1203048147e0Sopenharmony_ci } 1204048147e0Sopenharmony_ci this.pptTotalCount = 0; 1205048147e0Sopenharmony_ci } 1206048147e0Sopenharmony_ci let obj = { 1207048147e0Sopenharmony_ci textValue: source.content, 1208048147e0Sopenharmony_ci placeholder: placeholder, 1209048147e0Sopenharmony_ci pptIndex: this.pptTotalCount, 1210048147e0Sopenharmony_ci mms: mmsObj 1211048147e0Sopenharmony_ci }; 1212048147e0Sopenharmony_ci textareas.push(obj); 1213048147e0Sopenharmony_ci }); 1214048147e0Sopenharmony_ci this.mmsEditList = mms; 1215048147e0Sopenharmony_ci this.textareaDatasource = textareas; 1216048147e0Sopenharmony_ci } 1217048147e0Sopenharmony_ci 1218048147e0Sopenharmony_ci setMmsDataSource(mmsSource) { 1219048147e0Sopenharmony_ci this.mmsEditList = []; 1220048147e0Sopenharmony_ci this.textareaDatasource = []; 1221048147e0Sopenharmony_ci let first = mmsSource[0]; 1222048147e0Sopenharmony_ci this.messageType = first.messageType; 1223048147e0Sopenharmony_ci if (this.messageType == common.MESSAGE_TYPE.NORMAL) { 1224048147e0Sopenharmony_ci let arr = []; 1225048147e0Sopenharmony_ci mmsSource.forEach(item => { 1226048147e0Sopenharmony_ci let obj = { 1227048147e0Sopenharmony_ci type: item.msgType, 1228048147e0Sopenharmony_ci uriPath: item.msgUriPath, 1229048147e0Sopenharmony_ci time: item.time, 1230048147e0Sopenharmony_ci fileSize: item.fileSize 1231048147e0Sopenharmony_ci } 1232048147e0Sopenharmony_ci arr.push(obj); 1233048147e0Sopenharmony_ci }); 1234048147e0Sopenharmony_ci this.mmsEditList = arr; 1235048147e0Sopenharmony_ci } else { 1236048147e0Sopenharmony_ci this.getMmsDataSource(mmsSource, first); 1237048147e0Sopenharmony_ci } 1238048147e0Sopenharmony_ci } 1239048147e0Sopenharmony_ci 1240048147e0Sopenharmony_ci dealDraftData(item) { 1241048147e0Sopenharmony_ci // this.isDraft = true; 1242048147e0Sopenharmony_ci this.draftContent = item.content; 1243048147e0Sopenharmony_ci this.draftGroupId = item.groupId; 1244048147e0Sopenharmony_ci if (item.isMsm) { 1245048147e0Sopenharmony_ci this.isEditMms = true; 1246048147e0Sopenharmony_ci this.setMmsDataSource(item.mms); 1247048147e0Sopenharmony_ci } else { 1248048147e0Sopenharmony_ci this.messageType = common.MESSAGE_TYPE.NORMAL; 1249048147e0Sopenharmony_ci } 1250048147e0Sopenharmony_ci } 1251048147e0Sopenharmony_ci 1252048147e0Sopenharmony_ci // Set Draft Content 1253048147e0Sopenharmony_ci setDraft() { 1254048147e0Sopenharmony_ci // If the content is a draft, the draft content needs to be displayed. 1255048147e0Sopenharmony_ci if (this.isDraft) { 1256048147e0Sopenharmony_ci this.textValue = this.draftContent; 1257048147e0Sopenharmony_ci this.canSendMessage = MmsPreferences.getInstance().haveSimCardReady(); 1258048147e0Sopenharmony_ci } 1259048147e0Sopenharmony_ci } 1260048147e0Sopenharmony_ci 1261048147e0Sopenharmony_ci updateDetail(threadId, sendResult) { 1262048147e0Sopenharmony_ci let sendResults: Array<LooseObject> = []; 1263048147e0Sopenharmony_ci sendResults.push(sendResult); 1264048147e0Sopenharmony_ci let actionData: LooseObject = {}; 1265048147e0Sopenharmony_ci actionData.sendResults = sendResults; 1266048147e0Sopenharmony_ci actionData.threadId = threadId; 1267048147e0Sopenharmony_ci ConversationService.getInstance().updateSessionAndDetail(actionData); 1268048147e0Sopenharmony_ci let sendStatus: number = sendResult.sendStatus; 1269048147e0Sopenharmony_ci let deliveryReportSwitch: string = MmsPreferences.getInstance().getValueOfDeliveryReportSwitch(); 1270048147e0Sopenharmony_ci HiLog.i(TAG, 'updateDetail, sendStatus=' + sendStatus + ', deliveryReportSwitch=' + deliveryReportSwitch); 1271048147e0Sopenharmony_ci if ((deliveryReportSwitch == common.DELIVERY_REPORTS.SMS_AND_MMS || 1272048147e0Sopenharmony_ci deliveryReportSwitch == common.DELIVERY_REPORTS.SMS) && sendStatus == common.int.SEND_MESSAGE_SUCCESS) { 1273048147e0Sopenharmony_ci let msg: string = this.strContactsNumber + ' 已收到消息!' 1274048147e0Sopenharmony_ci this.showToast(msg) 1275048147e0Sopenharmony_ci } 1276048147e0Sopenharmony_ci } 1277048147e0Sopenharmony_ci 1278048147e0Sopenharmony_ci showToast(msg) { 1279048147e0Sopenharmony_ci Prompt.showToast({ 1280048147e0Sopenharmony_ci message: msg, 1281048147e0Sopenharmony_ci duration: 2000, 1282048147e0Sopenharmony_ci }); 1283048147e0Sopenharmony_ci } 1284048147e0Sopenharmony_ci 1285048147e0Sopenharmony_ci // Setting the Sending Status 1286048147e0Sopenharmony_ci setCanSendMsgStatus() { 1287048147e0Sopenharmony_ci if (this.receiveContactValue == common.string.EMPTY_STR && this.selectContacts.length == 0) { 1288048147e0Sopenharmony_ci this.canSendMessage = false; 1289048147e0Sopenharmony_ci } 1290048147e0Sopenharmony_ci } 1291048147e0Sopenharmony_ci 1292048147e0Sopenharmony_ci // Obtains the size of the current MMS file. 1293048147e0Sopenharmony_ci getCurEdtFileSize() { 1294048147e0Sopenharmony_ci this.curEdtFileSize = 0; 1295048147e0Sopenharmony_ci if (!this.isEditMms || this.mmsEditList.length == 0) { 1296048147e0Sopenharmony_ci return; 1297048147e0Sopenharmony_ci } 1298048147e0Sopenharmony_ci for (let element of this.mmsEditList) { 1299048147e0Sopenharmony_ci this.curEdtFileSize += element.fileSize; 1300048147e0Sopenharmony_ci } 1301048147e0Sopenharmony_ci } 1302048147e0Sopenharmony_ci 1303048147e0Sopenharmony_ci dealMmsSendResult(sendNumber, item, sendResult) { 1304048147e0Sopenharmony_ci HiLog.i(TAG, 'dealMmsSendResult, start') 1305048147e0Sopenharmony_ci // MMS Sending 1306048147e0Sopenharmony_ci sendResult.sendStatus = common.int.SEND_MESSAGE_SUCCESS; 1307048147e0Sopenharmony_ci item.sendStatus = common.int.SEND_MESSAGE_SUCCESS; 1308048147e0Sopenharmony_ci this.updateDetail(this.threadId, sendResult); 1309048147e0Sopenharmony_ci // The MMS message will be sent for receiving and using. 1310048147e0Sopenharmony_ci if (sendNumber.length == 1 && sendResult.sendStatus == common.int.SEND_MESSAGE_SUCCESS) { 1311048147e0Sopenharmony_ci setTimeout(() => { 1312048147e0Sopenharmony_ci // this.publishData(sendResult.telephone, item.mmsSource); 1313048147e0Sopenharmony_ci }, 1000); 1314048147e0Sopenharmony_ci } 1315048147e0Sopenharmony_ci let params = { 1316048147e0Sopenharmony_ci mmsSource: item.mmsSource 1317048147e0Sopenharmony_ci }; 1318048147e0Sopenharmony_ci sendMsgService.sendMmsMessage(params, (sendStatus) => { 1319048147e0Sopenharmony_ci }); 1320048147e0Sopenharmony_ci } 1321048147e0Sopenharmony_ci 1322048147e0Sopenharmony_ci dealSmsSendResult(params, item, sendResult) { 1323048147e0Sopenharmony_ci sendMsgService.sendMessage(params, (sendStatus) => { 1324048147e0Sopenharmony_ci HiLog.i(TAG, 'dealSmsSendResult, sendMessage sendStatus: ' + sendStatus); 1325048147e0Sopenharmony_ci item.sendStatus = sendStatus; 1326048147e0Sopenharmony_ci if (sendStatus === common.int.SEND_MESSAGE_FAILED) { 1327048147e0Sopenharmony_ci item.failuresNumber = item.failuresNumber + 1; 1328048147e0Sopenharmony_ci } 1329048147e0Sopenharmony_ci item.completeNumber = item.completeNumber + 1; 1330048147e0Sopenharmony_ci sendResult.sendStatus = sendStatus; 1331048147e0Sopenharmony_ci // Update sending status 1332048147e0Sopenharmony_ci this.updateDetail(this.threadId, sendResult); 1333048147e0Sopenharmony_ci this.refresh = !this.refresh 1334048147e0Sopenharmony_ci }); 1335048147e0Sopenharmony_ci } 1336048147e0Sopenharmony_ci 1337048147e0Sopenharmony_ci getSendMessageId(initDatas, telephone): number { 1338048147e0Sopenharmony_ci for (let initData of initDatas) { 1339048147e0Sopenharmony_ci if (initData == undefined || initData == null) { 1340048147e0Sopenharmony_ci return; 1341048147e0Sopenharmony_ci } 1342048147e0Sopenharmony_ci if (initData.telephone == telephone) { 1343048147e0Sopenharmony_ci try { 1344048147e0Sopenharmony_ci if (initData.id == undefined || initData.id == null) { 1345048147e0Sopenharmony_ci return; 1346048147e0Sopenharmony_ci } 1347048147e0Sopenharmony_ci } catch (err) { 1348048147e0Sopenharmony_ci HiLog.e(TAG, 'this initData.id is undefined ' + JSON.stringify(err)); 1349048147e0Sopenharmony_ci } 1350048147e0Sopenharmony_ci return initData.id; 1351048147e0Sopenharmony_ci } 1352048147e0Sopenharmony_ci } 1353048147e0Sopenharmony_ci } 1354048147e0Sopenharmony_ci 1355048147e0Sopenharmony_ci convertingSms() { 1356048147e0Sopenharmony_ci // Convert to SMS 1357048147e0Sopenharmony_ci this.isEditMms = false; 1358048147e0Sopenharmony_ci this.showToast($r('app.string.converting_sms')); 1359048147e0Sopenharmony_ci } 1360048147e0Sopenharmony_ci 1361048147e0Sopenharmony_ci dealSendResult(actionData, item, initDatas) { 1362048147e0Sopenharmony_ci HiLog.i(TAG, 'dealSendResult, start') 1363048147e0Sopenharmony_ci // Add sending information to the list. 1364048147e0Sopenharmony_ci let sendNumbers: Array<string> = actionData.hosts; 1365048147e0Sopenharmony_ci let content: string = actionData.content; 1366048147e0Sopenharmony_ci for (let i = 0; i < sendNumbers.length; i++) { 1367048147e0Sopenharmony_ci let params: LooseObject = { 1368048147e0Sopenharmony_ci 'slotId': actionData.slotId, 1369048147e0Sopenharmony_ci 'destinationHost': sendNumbers[i], 1370048147e0Sopenharmony_ci 'content': content, 1371048147e0Sopenharmony_ci }; 1372048147e0Sopenharmony_ci let id: number = this.getSendMessageId(initDatas, sendNumbers[i]); 1373048147e0Sopenharmony_ci if (id == undefined || id == null) { 1374048147e0Sopenharmony_ci return; 1375048147e0Sopenharmony_ci } 1376048147e0Sopenharmony_ci let sendResult: LooseObject = { 1377048147e0Sopenharmony_ci 'id': id, 1378048147e0Sopenharmony_ci 'telephone': sendNumbers[i], 1379048147e0Sopenharmony_ci 'content': content, 1380048147e0Sopenharmony_ci } 1381048147e0Sopenharmony_ci if (!item.isMsm) { 1382048147e0Sopenharmony_ci this.dealSmsSendResult(params, item, sendResult); 1383048147e0Sopenharmony_ci } else { 1384048147e0Sopenharmony_ci this.dealMmsSendResult(sendNumbers, item, sendResult); 1385048147e0Sopenharmony_ci } 1386048147e0Sopenharmony_ci } 1387048147e0Sopenharmony_ci } 1388048147e0Sopenharmony_ci 1389048147e0Sopenharmony_ci insertInitData(actionData, item, callback): void { 1390048147e0Sopenharmony_ci let sendNumbers: Array<string> = actionData.hosts; 1391048147e0Sopenharmony_ci let insertSendResults: Array<LooseObject> = []; 1392048147e0Sopenharmony_ci for (let i = 0; i < sendNumbers.length; i++) { 1393048147e0Sopenharmony_ci let sendResult: LooseObject = { 1394048147e0Sopenharmony_ci 'slotId': actionData.slotId, 1395048147e0Sopenharmony_ci 'telephone': sendNumbers[i], 1396048147e0Sopenharmony_ci 'content': actionData.content, 1397048147e0Sopenharmony_ci 'sendStatus': common.int.SEND_MESSAGE_SENDING 1398048147e0Sopenharmony_ci } 1399048147e0Sopenharmony_ci if (item.isMsm) { 1400048147e0Sopenharmony_ci sendResult.content = commonService.getMmsContent(item.mmsSource); 1401048147e0Sopenharmony_ci } 1402048147e0Sopenharmony_ci insertSendResults.push(sendResult); 1403048147e0Sopenharmony_ci } 1404048147e0Sopenharmony_ci let actionData_: LooseObject = {}; 1405048147e0Sopenharmony_ci actionData_.sendResults = insertSendResults; 1406048147e0Sopenharmony_ci actionData_.isReceive = false; 1407048147e0Sopenharmony_ci actionData_.ownNumber = common.string.EMPTY_STR; 1408048147e0Sopenharmony_ci actionData_.isSender = common.is_sender.NO; 1409048147e0Sopenharmony_ci actionData_.hasDraft = this.isDraft; 1410048147e0Sopenharmony_ci actionData_.hasReport = settingService.judgeIsDeliveryReport(item.isMsm) ? 1 : 0; 1411048147e0Sopenharmony_ci actionData_.isMms = item.isMsm; 1412048147e0Sopenharmony_ci actionData_.mmsSource = item.mmsSource; 1413048147e0Sopenharmony_ci actionData_.hasAttachment = commonService.judgeIsAttachment(item.mmsSource); 1414048147e0Sopenharmony_ci ConversationService.getInstance().insertSessionAndDetail(actionData_, callback, globalThis.mmsContext); 1415048147e0Sopenharmony_ci } 1416048147e0Sopenharmony_ci 1417048147e0Sopenharmony_ci changeReceiveContactValue(value) { 1418048147e0Sopenharmony_ci this.receiveContactValue = value 1419048147e0Sopenharmony_ci } 1420048147e0Sopenharmony_ci 1421048147e0Sopenharmony_ci updatePreview(idx) { 1422048147e0Sopenharmony_ci // Delete Preview 1423048147e0Sopenharmony_ci HiLog.i(TAG, 'updatePreview, idx: ' + idx); 1424048147e0Sopenharmony_ci // If not audio (picture or video) is deleted from the preview, you need to change the value of 1425048147e0Sopenharmony_ci // checkbox in the thumbnail of the gallery. 1426048147e0Sopenharmony_ci if (this.mmsEditList[idx].type != common.MSG_ITEM_TYPE.AUDIO) { 1427048147e0Sopenharmony_ci let that = this; 1428048147e0Sopenharmony_ci this.pictureListFromGallery.forEach(function (item) { 1429048147e0Sopenharmony_ci if (item.path == that.mmsEditList[idx].uriPath) { 1430048147e0Sopenharmony_ci item.checkedValue = false; 1431048147e0Sopenharmony_ci that.curEdtFileSize -= that.mmsEditList[idx].fileSize; 1432048147e0Sopenharmony_ci that.msgSendTip = Math.ceil(that.curEdtFileSize) + COMMON_FILE_SIZE_STRING; 1433048147e0Sopenharmony_ci } 1434048147e0Sopenharmony_ci }); 1435048147e0Sopenharmony_ci } 1436048147e0Sopenharmony_ci this.isOnlyAudio = !this.mmsEditList.some((item, index) => item.type != common.MSG_ITEM_TYPE.AUDIO); 1437048147e0Sopenharmony_ci if (this.mmsEditList.length == 0) { 1438048147e0Sopenharmony_ci this.convertingSms(); 1439048147e0Sopenharmony_ci } 1440048147e0Sopenharmony_ci } 1441048147e0Sopenharmony_ci 1442048147e0Sopenharmony_ci initSendItem() { 1443048147e0Sopenharmony_ci // Obtains the day of the week. 1444048147e0Sopenharmony_ci HiLog.i(TAG, 'initSendItem, start') 1445048147e0Sopenharmony_ci let item: LooseObject = {}; 1446048147e0Sopenharmony_ci item.date = common.string.EMPTY_STR; 1447048147e0Sopenharmony_ci item.time = $r('app.string.justNow'); 1448048147e0Sopenharmony_ci item.timeMillisecond = new Date().getTime(); 1449048147e0Sopenharmony_ci dateUtil.convertTimeStampToDateWeek(item, false); 1450048147e0Sopenharmony_ci dateUtil.fullDate(item); 1451048147e0Sopenharmony_ci item.content = this.textValue; 1452048147e0Sopenharmony_ci item.msgType = this.mmsEditList.length != 0 ? this.mmsEditList[0].type : common.MSG_ITEM_TYPE.TEXT; 1453048147e0Sopenharmony_ci item.isFullScreenImg = false; 1454048147e0Sopenharmony_ci item.msgUriPath = this.mmsEditList.length != 0 ? this.mmsEditList[0].uriPath : common.string.EMPTY_STR; 1455048147e0Sopenharmony_ci let time = (this.mmsEditList.length != 0 && (this.mmsEditList[0].type == 3 || this.mmsEditList[0].type == 5)) ? 1456048147e0Sopenharmony_ci this.mmsEditList[0].time : common.string.SUCCESS; 1457048147e0Sopenharmony_ci item.audioTime = time; 1458048147e0Sopenharmony_ci item.isCbChecked = false; 1459048147e0Sopenharmony_ci item.isLock = false; 1460048147e0Sopenharmony_ci item.isStared = false; 1461048147e0Sopenharmony_ci item.isReceive = false; 1462048147e0Sopenharmony_ci item.sendStatus = 1; 1463048147e0Sopenharmony_ci item.cancelTimeCount = common.int.CANCEL_TIME_COUNT; 1464048147e0Sopenharmony_ci item.subId = this.slotId; 1465048147e0Sopenharmony_ci item.mmsEditListTemp = this.mmsEditList; 1466048147e0Sopenharmony_ci if (this.contactsNum > 1) { 1467048147e0Sopenharmony_ci item.completeNumber = 0; 1468048147e0Sopenharmony_ci item.failuresNumber = 0; 1469048147e0Sopenharmony_ci } 1470048147e0Sopenharmony_ci item.hasReport = settingService.judgeIsDeliveryReport(item.isMsm); 1471048147e0Sopenharmony_ci item.msgShowType = this.getMsgShowType(item); 1472048147e0Sopenharmony_ci item.mmsSource = this.getMmsSource(); 1473048147e0Sopenharmony_ci item.isMsm = this.isEditMms; 1474048147e0Sopenharmony_ci this.setDateShow(item, this.mmsList); 1475048147e0Sopenharmony_ci this.mmsList.push(item); 1476048147e0Sopenharmony_ci this.refresh = !this.refresh 1477048147e0Sopenharmony_ci } 1478048147e0Sopenharmony_ci 1479048147e0Sopenharmony_ci // Check whether the time on the top of each SMS message is displayed. 1480048147e0Sopenharmony_ci setDateShow(item, list) { 1481048147e0Sopenharmony_ci item.dateShow = true; 1482048147e0Sopenharmony_ci if (item.date == undefined || item.date == null) { 1483048147e0Sopenharmony_ci return; 1484048147e0Sopenharmony_ci } 1485048147e0Sopenharmony_ci if (item.date.id == undefined || item.date.id == null) { 1486048147e0Sopenharmony_ci return; 1487048147e0Sopenharmony_ci } 1488048147e0Sopenharmony_ci let tempDateId = item.date?.id; 1489048147e0Sopenharmony_ci if (item.week == undefined || item.week == null) { 1490048147e0Sopenharmony_ci return; 1491048147e0Sopenharmony_ci } 1492048147e0Sopenharmony_ci if (item.week.id == undefined || item.week.id == null) { 1493048147e0Sopenharmony_ci return; 1494048147e0Sopenharmony_ci } 1495048147e0Sopenharmony_ci let tempWeekId = item.week?.id; 1496048147e0Sopenharmony_ci if (list.length > 0) { 1497048147e0Sopenharmony_ci item.dateShow = 1498048147e0Sopenharmony_ci (tempDateId != (list[list.length-1]).date.id) 1499048147e0Sopenharmony_ci && (tempWeekId != (list[list.length-1]).week.id) 1500048147e0Sopenharmony_ci } 1501048147e0Sopenharmony_ci } 1502048147e0Sopenharmony_ci 1503048147e0Sopenharmony_ci getMmsSource() { 1504048147e0Sopenharmony_ci HiLog.i(TAG, 'getMmsSource, start') 1505048147e0Sopenharmony_ci let sources = []; 1506048147e0Sopenharmony_ci this.dealTextareaDataSource(); 1507048147e0Sopenharmony_ci if (this.messageType === common.MESSAGE_TYPE.NORMAL) { 1508048147e0Sopenharmony_ci sources = this.dealMmsEditList(); 1509048147e0Sopenharmony_ci } else { 1510048147e0Sopenharmony_ci sources = this.getMmsSourceFromDataSource(); 1511048147e0Sopenharmony_ci } 1512048147e0Sopenharmony_ci return sources; 1513048147e0Sopenharmony_ci } 1514048147e0Sopenharmony_ci 1515048147e0Sopenharmony_ci dealTextareaDataSource() { 1516048147e0Sopenharmony_ci HiLog.i(TAG, 'dealTextareaDataSource, start') 1517048147e0Sopenharmony_ci if (this.messageType == common.MESSAGE_TYPE.THEME) { 1518048147e0Sopenharmony_ci let first = this.textareaDatasource[0]; 1519048147e0Sopenharmony_ci if (first.textValue == common.string.EMPTY_STR) { 1520048147e0Sopenharmony_ci this.messageType = common.MESSAGE_TYPE.NORMAL; 1521048147e0Sopenharmony_ci this.textValue = this.textareaDatasource[1].textValue; 1522048147e0Sopenharmony_ci this.textareaDatasource = []; 1523048147e0Sopenharmony_ci } 1524048147e0Sopenharmony_ci } 1525048147e0Sopenharmony_ci } 1526048147e0Sopenharmony_ci 1527048147e0Sopenharmony_ci dealMmsEditList() { 1528048147e0Sopenharmony_ci HiLog.i(TAG, 'dealMmsEditList, start') 1529048147e0Sopenharmony_ci let sources = []; 1530048147e0Sopenharmony_ci if (this.mmsEditList.length != 0) { 1531048147e0Sopenharmony_ci this.mmsEditList.forEach((item, index) => { 1532048147e0Sopenharmony_ci let mms = { 1533048147e0Sopenharmony_ci msgType: item.type, 1534048147e0Sopenharmony_ci msgUriPath: item.uriPath, 1535048147e0Sopenharmony_ci content: common.string.EMPTY_STR, 1536048147e0Sopenharmony_ci time: item.time, 1537048147e0Sopenharmony_ci fileSize: item.fileSize 1538048147e0Sopenharmony_ci } 1539048147e0Sopenharmony_ci if (index === 0) { 1540048147e0Sopenharmony_ci mms.content = this.textValue; 1541048147e0Sopenharmony_ci } 1542048147e0Sopenharmony_ci sources.push(mms); 1543048147e0Sopenharmony_ci }); 1544048147e0Sopenharmony_ci } 1545048147e0Sopenharmony_ci return sources; 1546048147e0Sopenharmony_ci } 1547048147e0Sopenharmony_ci 1548048147e0Sopenharmony_ci getMmsSourceFromDataSource() { 1549048147e0Sopenharmony_ci HiLog.i(TAG, 'getMmsSourceFromDataSource, start') 1550048147e0Sopenharmony_ci let sources = []; 1551048147e0Sopenharmony_ci this.textareaDatasource.forEach((item, index) => { 1552048147e0Sopenharmony_ci let mms = { 1553048147e0Sopenharmony_ci msgType: common.MSG_ITEM_TYPE.TEXT, 1554048147e0Sopenharmony_ci msgUriPath: '', 1555048147e0Sopenharmony_ci content: item.textValue, 1556048147e0Sopenharmony_ci time: '', 1557048147e0Sopenharmony_ci fileSize: 0 1558048147e0Sopenharmony_ci }; 1559048147e0Sopenharmony_ci if (index === 0 && (this.messageType === common.MESSAGE_TYPE.THEME || 1560048147e0Sopenharmony_ci this.messageType === common.MESSAGE_TYPE.THEME_AND_PPT)) { 1561048147e0Sopenharmony_ci mms.msgType = common.MSG_ITEM_TYPE.THEME; 1562048147e0Sopenharmony_ci sources.push(mms); 1563048147e0Sopenharmony_ci } else if (this.messageType === common.MESSAGE_TYPE.THEME) { 1564048147e0Sopenharmony_ci sources.push(mms); 1565048147e0Sopenharmony_ci sources = this.getMmsSourceByTheme(sources, item, mms); 1566048147e0Sopenharmony_ci } else { 1567048147e0Sopenharmony_ci if (item.mms) { 1568048147e0Sopenharmony_ci mms.msgType = item.mms.type; 1569048147e0Sopenharmony_ci mms.msgUriPath = item.mms.uriPath; 1570048147e0Sopenharmony_ci mms.time = item.mms.time; 1571048147e0Sopenharmony_ci mms.fileSize = item.mms.fileSize; 1572048147e0Sopenharmony_ci } 1573048147e0Sopenharmony_ci sources.push(mms); 1574048147e0Sopenharmony_ci } 1575048147e0Sopenharmony_ci }); 1576048147e0Sopenharmony_ci return sources; 1577048147e0Sopenharmony_ci } 1578048147e0Sopenharmony_ci 1579048147e0Sopenharmony_ci getMmsSourceByTheme(sources, item, mms) { 1580048147e0Sopenharmony_ci HiLog.i(TAG, 'getMmsSourceByTheme, start') 1581048147e0Sopenharmony_ci if (this.mmsEditList.length === 1) { 1582048147e0Sopenharmony_ci let first = this.mmsEditList[0]; 1583048147e0Sopenharmony_ci sources.unshift({ 1584048147e0Sopenharmony_ci msgType: first.type, 1585048147e0Sopenharmony_ci msgUriPath: first.uriPath, 1586048147e0Sopenharmony_ci content: item.textValue, 1587048147e0Sopenharmony_ci time: first.time, 1588048147e0Sopenharmony_ci fileSize: first.fileSize 1589048147e0Sopenharmony_ci }); 1590048147e0Sopenharmony_ci } else { 1591048147e0Sopenharmony_ci this.getMmsSourceByItem(sources, mms); 1592048147e0Sopenharmony_ci } 1593048147e0Sopenharmony_ci let arr = JSON.parse(JSON.stringify(sources)); 1594048147e0Sopenharmony_ci return arr; 1595048147e0Sopenharmony_ci } 1596048147e0Sopenharmony_ci 1597048147e0Sopenharmony_ci getMmsSourceByItem(sources, mms) { 1598048147e0Sopenharmony_ci HiLog.i(TAG, 'getMmsSourceByItem, start') 1599048147e0Sopenharmony_ci this.mmsEditList.forEach((list, i) => { 1600048147e0Sopenharmony_ci if (i === 0) { 1601048147e0Sopenharmony_ci mms.msgType = list.type; 1602048147e0Sopenharmony_ci mms.msgUriPath = list.uriPath; 1603048147e0Sopenharmony_ci mms.time = list.time; 1604048147e0Sopenharmony_ci mms.fileSize = list.fileSize; 1605048147e0Sopenharmony_ci } else { 1606048147e0Sopenharmony_ci let mmsObj = { 1607048147e0Sopenharmony_ci msgType: list.type, 1608048147e0Sopenharmony_ci msgUriPath: list.uriPath, 1609048147e0Sopenharmony_ci content: common.string.EMPTY_STR, 1610048147e0Sopenharmony_ci time: list.time, 1611048147e0Sopenharmony_ci fileSize: list.fileSize 1612048147e0Sopenharmony_ci }; 1613048147e0Sopenharmony_ci sources.push(mmsObj); 1614048147e0Sopenharmony_ci } 1615048147e0Sopenharmony_ci }); 1616048147e0Sopenharmony_ci } 1617048147e0Sopenharmony_ci 1618048147e0Sopenharmony_ci getMsgShowType(item) { 1619048147e0Sopenharmony_ci HiLog.i(TAG, 'getMsgShowType, start') 1620048147e0Sopenharmony_ci let type = common.MESSAGE_SHOW_TYPE.NORMAL; 1621048147e0Sopenharmony_ci let slideString = 'msg_slide'; 1622048147e0Sopenharmony_ci if (this.messageType === common.MESSAGE_TYPE.NORMAL && this.mmsEditList.length <= 1) { 1623048147e0Sopenharmony_ci type = common.MESSAGE_SHOW_TYPE.NORMAL; 1624048147e0Sopenharmony_ci item.content = this.textValue; 1625048147e0Sopenharmony_ci } else if (this.messageType === common.MESSAGE_TYPE.THEME && this.mmsEditList.length === 1) { 1626048147e0Sopenharmony_ci type = common.MESSAGE_SHOW_TYPE.THEME_IMAGE; 1627048147e0Sopenharmony_ci item.content = this.getThemeContent(); 1628048147e0Sopenharmony_ci } else { 1629048147e0Sopenharmony_ci type = this.getMsgShowTypePpt(item, slideString); 1630048147e0Sopenharmony_ci } 1631048147e0Sopenharmony_ci if (type == common.MESSAGE_SHOW_TYPE.PPT_NO_IMAGE || type == common.MESSAGE_SHOW_TYPE.PPT_IMAGE) { 1632048147e0Sopenharmony_ci if (item.content == common.string.EMPTY_STR) { 1633048147e0Sopenharmony_ci item.content = slideString; 1634048147e0Sopenharmony_ci } 1635048147e0Sopenharmony_ci } 1636048147e0Sopenharmony_ci return type; 1637048147e0Sopenharmony_ci } 1638048147e0Sopenharmony_ci 1639048147e0Sopenharmony_ci getMsgShowTypePpt(item, slideString) { 1640048147e0Sopenharmony_ci HiLog.i(TAG, 'getMsgShowTypePpt, start') 1641048147e0Sopenharmony_ci let type = common.MESSAGE_SHOW_TYPE.NORMAL; 1642048147e0Sopenharmony_ci let hasSource = this.textareaDatasource.length > 0 ? true : false; 1643048147e0Sopenharmony_ci let firstStr = hasSource ? this.textareaDatasource[0].textValue : common.string.EMPTY_STR; 1644048147e0Sopenharmony_ci if (this.mmsEditList.length === 0) { 1645048147e0Sopenharmony_ci type = common.MESSAGE_SHOW_TYPE.PPT_NO_IMAGE; 1646048147e0Sopenharmony_ci if (this.messageType === common.MESSAGE_TYPE.THEME || 1647048147e0Sopenharmony_ci this.messageType === common.MESSAGE_TYPE.THEME_AND_PPT) { 1648048147e0Sopenharmony_ci item.content = this.getThemeContent(); 1649048147e0Sopenharmony_ci } else { 1650048147e0Sopenharmony_ci item.content = (firstStr == common.string.EMPTY_STR) ? slideString : firstStr; 1651048147e0Sopenharmony_ci } 1652048147e0Sopenharmony_ci } else { 1653048147e0Sopenharmony_ci type = this.getPPTType(); 1654048147e0Sopenharmony_ci this.getMsgShowTypeContent(item, firstStr, slideString); 1655048147e0Sopenharmony_ci } 1656048147e0Sopenharmony_ci return type; 1657048147e0Sopenharmony_ci } 1658048147e0Sopenharmony_ci 1659048147e0Sopenharmony_ci getPPTType() { 1660048147e0Sopenharmony_ci HiLog.i(TAG, 'getPPTType, start') 1661048147e0Sopenharmony_ci let type = common.MESSAGE_SHOW_TYPE.NORMAL; 1662048147e0Sopenharmony_ci if (this.messageType === common.MESSAGE_TYPE.NORMAL && this.mmsEditList.length > 0) { 1663048147e0Sopenharmony_ci type = common.MESSAGE_SHOW_TYPE.PPT_IMAGE; 1664048147e0Sopenharmony_ci } else { 1665048147e0Sopenharmony_ci let firstMms = null; 1666048147e0Sopenharmony_ci if (this.messageType === common.MESSAGE_TYPE.THEME && this.mmsEditList.length > 1) { 1667048147e0Sopenharmony_ci firstMms = this.mmsEditList[0]; 1668048147e0Sopenharmony_ci } else if (this.messageType === common.MESSAGE_TYPE.THEME_AND_PPT) { 1669048147e0Sopenharmony_ci firstMms = this.textareaDatasource[1].mms; 1670048147e0Sopenharmony_ci } else { 1671048147e0Sopenharmony_ci firstMms = this.textareaDatasource[0].mms; 1672048147e0Sopenharmony_ci } 1673048147e0Sopenharmony_ci if (this.mmsEditList.length >= 1 && firstMms && 1674048147e0Sopenharmony_ci (firstMms.type === common.MSG_ITEM_TYPE.IMAGE || firstMms.type === common.MSG_ITEM_TYPE.VIDEO)) { 1675048147e0Sopenharmony_ci type = common.MESSAGE_SHOW_TYPE.PPT_IMAGE; 1676048147e0Sopenharmony_ci } else { 1677048147e0Sopenharmony_ci type = common.MESSAGE_SHOW_TYPE.PPT_NO_IMAGE; 1678048147e0Sopenharmony_ci } 1679048147e0Sopenharmony_ci } 1680048147e0Sopenharmony_ci return type; 1681048147e0Sopenharmony_ci } 1682048147e0Sopenharmony_ci 1683048147e0Sopenharmony_ci getMsgShowTypeContent(item, firstStr, slideString) { 1684048147e0Sopenharmony_ci HiLog.i(TAG, 'getMsgShowTypeContent, start') 1685048147e0Sopenharmony_ci if (this.messageType === common.MESSAGE_TYPE.THEME_AND_PPT || 1686048147e0Sopenharmony_ci this.messageType === common.MESSAGE_TYPE.THEME) { 1687048147e0Sopenharmony_ci item.content = this.getThemeContent(); 1688048147e0Sopenharmony_ci } else { 1689048147e0Sopenharmony_ci let content = common.string.EMPTY_STR; 1690048147e0Sopenharmony_ci if (this.messageType === common.MESSAGE_TYPE.NORMAL) { 1691048147e0Sopenharmony_ci content = (this.textValue == common.string.EMPTY_STR) ? slideString : this.textValue; 1692048147e0Sopenharmony_ci } else { 1693048147e0Sopenharmony_ci content = (firstStr == common.string.EMPTY_STR) ? slideString : firstStr; 1694048147e0Sopenharmony_ci } 1695048147e0Sopenharmony_ci item.content = content; 1696048147e0Sopenharmony_ci } 1697048147e0Sopenharmony_ci } 1698048147e0Sopenharmony_ci 1699048147e0Sopenharmony_ci getThemeContent() { 1700048147e0Sopenharmony_ci HiLog.i(TAG, 'getThemeContent, start') 1701048147e0Sopenharmony_ci this.isEditMms = true; 1702048147e0Sopenharmony_ci let content = ''; 1703048147e0Sopenharmony_ci let first = this.textareaDatasource[0].textValue; 1704048147e0Sopenharmony_ci let text = this.textareaDatasource[1].textValue; 1705048147e0Sopenharmony_ci if (first !== common.string.EMPTY_STR) { 1706048147e0Sopenharmony_ci content = $r('app.string.msg_theme') + ': ' + first; 1707048147e0Sopenharmony_ci } 1708048147e0Sopenharmony_ci if (text !== common.string.EMPTY_STR) { 1709048147e0Sopenharmony_ci if (content === common.string.EMPTY_STR) { 1710048147e0Sopenharmony_ci content = text; 1711048147e0Sopenharmony_ci } else { 1712048147e0Sopenharmony_ci content = content + '\n' + text; 1713048147e0Sopenharmony_ci } 1714048147e0Sopenharmony_ci } 1715048147e0Sopenharmony_ci return content; 1716048147e0Sopenharmony_ci } 1717048147e0Sopenharmony_ci 1718048147e0Sopenharmony_ci sendMassMessage(actionData, item) { 1719048147e0Sopenharmony_ci this.insertInitData(actionData, item, result => { 1720048147e0Sopenharmony_ci // Processing the sent result 1721048147e0Sopenharmony_ci if (this.threadId != result.rowId) { 1722048147e0Sopenharmony_ci // When modifying the recipient information, click Send and delete the session before the modification. 1723048147e0Sopenharmony_ci let condition: LooseObject = {}; 1724048147e0Sopenharmony_ci condition.threadId = this.threadId; 1725048147e0Sopenharmony_ci ConversationListService.getInstance().deleteSessionByCondition(condition, null, null); 1726048147e0Sopenharmony_ci } 1727048147e0Sopenharmony_ci this.threadId = result.rowId; 1728048147e0Sopenharmony_ci this.portraitColor = AvatarColor.background.Color[Math.abs(this.threadId) % 6]; 1729048147e0Sopenharmony_ci item.groupId = result.groupId; 1730048147e0Sopenharmony_ci if (result.initDatas[0] == undefined || result.initDatas[0] == null) { 1731048147e0Sopenharmony_ci return; 1732048147e0Sopenharmony_ci } 1733048147e0Sopenharmony_ci if (result.initDatas[0].id == undefined || result.initDatas[0].id == null) { 1734048147e0Sopenharmony_ci return; 1735048147e0Sopenharmony_ci } 1736048147e0Sopenharmony_ci item.id = result.initDatas[0].id; 1737048147e0Sopenharmony_ci this.refresh = !this.refresh 1738048147e0Sopenharmony_ci // Sending and processing the sending result 1739048147e0Sopenharmony_ci this.dealSendResult(actionData, item, result.initDatas); 1740048147e0Sopenharmony_ci }); 1741048147e0Sopenharmony_ci } 1742048147e0Sopenharmony_ci 1743048147e0Sopenharmony_ci clearMsm() { 1744048147e0Sopenharmony_ci if (this.isEditMms) { 1745048147e0Sopenharmony_ci this.isEditMms = false; 1746048147e0Sopenharmony_ci } 1747048147e0Sopenharmony_ci // Deleting the preview image of an MMS message 1748048147e0Sopenharmony_ci if (this.mmsEditList.length != 0) { 1749048147e0Sopenharmony_ci for (let index in this.mmsEditList) { 1750048147e0Sopenharmony_ci this.updatePreview(index); 1751048147e0Sopenharmony_ci } 1752048147e0Sopenharmony_ci this.mmsEditList = []; 1753048147e0Sopenharmony_ci } 1754048147e0Sopenharmony_ci } 1755048147e0Sopenharmony_ci 1756048147e0Sopenharmony_ci resetMmsSource() { 1757048147e0Sopenharmony_ci this.textareaDatasource = []; 1758048147e0Sopenharmony_ci this.mmsEditList = []; 1759048147e0Sopenharmony_ci this.pptTotalCount = 0; 1760048147e0Sopenharmony_ci this.messageType = common.MESSAGE_TYPE.NORMAL; 1761048147e0Sopenharmony_ci this.selectedTextareaIdx = -1; 1762048147e0Sopenharmony_ci } 1763048147e0Sopenharmony_ci 1764048147e0Sopenharmony_ci send() { 1765048147e0Sopenharmony_ci HiLog.i(TAG, 'send, start'); 1766048147e0Sopenharmony_ci // The Send button is dimmed and messages cannot be sent. 1767048147e0Sopenharmony_ci if (!this.canSendMessage) { 1768048147e0Sopenharmony_ci HiLog.w(TAG, 'send, canSendMessage=false'); 1769048147e0Sopenharmony_ci return; 1770048147e0Sopenharmony_ci } 1771048147e0Sopenharmony_ci // Switching from the new state to the session state 1772048147e0Sopenharmony_ci if (this.isNewMsg) { 1773048147e0Sopenharmony_ci HiLog.i(TAG, 'send, isNewMsg=true'); 1774048147e0Sopenharmony_ci this.newSend(() => { 1775048147e0Sopenharmony_ci this.sendDataRefresh(); 1776048147e0Sopenharmony_ci }); 1777048147e0Sopenharmony_ci } else { 1778048147e0Sopenharmony_ci this.sendDataRefresh(); 1779048147e0Sopenharmony_ci } 1780048147e0Sopenharmony_ci } 1781048147e0Sopenharmony_ci 1782048147e0Sopenharmony_ci sendDataRefresh() { 1783048147e0Sopenharmony_ci this.isSendStatus = true; 1784048147e0Sopenharmony_ci this.slotId = MmsPreferences.getInstance().getSendMessageSlotId(); 1785048147e0Sopenharmony_ci if (this.textValue != common.string.EMPTY_STR || this.mmsEditList.length != 0 || 1786048147e0Sopenharmony_ci this.textareaDatasource.length != 0) { 1787048147e0Sopenharmony_ci this.initSendItem(); 1788048147e0Sopenharmony_ci } 1789048147e0Sopenharmony_ci let actionData: LooseObject = {}; 1790048147e0Sopenharmony_ci actionData.slotId = this.slotId; 1791048147e0Sopenharmony_ci actionData.destinationHost = this.strContactsNumber; 1792048147e0Sopenharmony_ci actionData.content = this.textValue; 1793048147e0Sopenharmony_ci actionData.isEditMms = this.isEditMms; 1794048147e0Sopenharmony_ci // Real SMS Sending 1795048147e0Sopenharmony_ci this.sendInterval(actionData, this.mmsList); 1796048147e0Sopenharmony_ci this.textValue = common.string.EMPTY_STR; 1797048147e0Sopenharmony_ci this.canSendMessage = false; 1798048147e0Sopenharmony_ci this.isShowFullScreen = false; 1799048147e0Sopenharmony_ci this.clearMsm(); 1800048147e0Sopenharmony_ci this.resetMmsSource(); 1801048147e0Sopenharmony_ci this.setTabOperationStatus(false); 1802048147e0Sopenharmony_ci this.distanceBottomFlag = false; 1803048147e0Sopenharmony_ci this.receiveContactValue = common.string.EMPTY_STR; 1804048147e0Sopenharmony_ci this.selectContacts = []; 1805048147e0Sopenharmony_ci this.isNewMsg = false; 1806048147e0Sopenharmony_ci } 1807048147e0Sopenharmony_ci 1808048147e0Sopenharmony_ci isPhoneNumber(str) { 1809048147e0Sopenharmony_ci // Determine whether the value is a number. 1810048147e0Sopenharmony_ci let reg = /^\d{1,}$/; 1811048147e0Sopenharmony_ci let pattern = new RegExp(reg); 1812048147e0Sopenharmony_ci return pattern.test(str); 1813048147e0Sopenharmony_ci } 1814048147e0Sopenharmony_ci 1815048147e0Sopenharmony_ci newSend(callback) { 1816048147e0Sopenharmony_ci // Check whether the entered content has a value. 1817048147e0Sopenharmony_ci if (this.receiveContactValue != common.string.EMPTY_STR) { 1818048147e0Sopenharmony_ci if (!this.isPhoneNumber(this.receiveContactValue)) { 1819048147e0Sopenharmony_ci // Invalid Recipient 1820048147e0Sopenharmony_ci this.showToast($r('app.string.invalid_receive', this.receiveContactValue)) 1821048147e0Sopenharmony_ci HiLog.w(TAG, 'newSend, PhoneNumber is invalidate'); 1822048147e0Sopenharmony_ci return; 1823048147e0Sopenharmony_ci } 1824048147e0Sopenharmony_ci } 1825048147e0Sopenharmony_ci if (this.selectContacts.length > 0 && this.receiveContactValue != common.string.EMPTY_STR) { 1826048147e0Sopenharmony_ci let selectContact = { 1827048147e0Sopenharmony_ci telephone: this.receiveContactValue, 1828048147e0Sopenharmony_ci telephoneFormat: this.receiveContactValue, 1829048147e0Sopenharmony_ci contactName: common.string.EMPTY_STR 1830048147e0Sopenharmony_ci } 1831048147e0Sopenharmony_ci let selectContacts = this.selectContacts; 1832048147e0Sopenharmony_ci selectContacts.push(selectContact); 1833048147e0Sopenharmony_ci this.initNewSelectContacts(selectContacts); 1834048147e0Sopenharmony_ci } else if (this.selectContacts.length > 0) { 1835048147e0Sopenharmony_ci this.initNewSelectContacts(this.selectContacts); 1836048147e0Sopenharmony_ci } else if (this.receiveContactValue != common.string.EMPTY_STR) { 1837048147e0Sopenharmony_ci this.contactsNum = 1; 1838048147e0Sopenharmony_ci this.strContactsNumber = this.receiveContactValue; 1839048147e0Sopenharmony_ci this.strContactsNumberFormat = this.receiveContactValue; 1840048147e0Sopenharmony_ci } else { 1841048147e0Sopenharmony_ci HiLog.w(TAG, 'newSend, the contact condition is not met.') 1842048147e0Sopenharmony_ci return; 1843048147e0Sopenharmony_ci } 1844048147e0Sopenharmony_ci this.isNewMsg = false; 1845048147e0Sopenharmony_ci // To cancel sending, set this parameter to true. 1846048147e0Sopenharmony_ci if (this.recallMessagesFlag) { 1847048147e0Sopenharmony_ci this.isNewRecallMessagesFlag = true; 1848048147e0Sopenharmony_ci this.commonCtrl.paramContact.isNewRecallMessagesFlag = true; 1849048147e0Sopenharmony_ci } 1850048147e0Sopenharmony_ci // When the new page is displayed in full screen mode, the following table data needs to be obtained. 1851048147e0Sopenharmony_ci if (true) { 1852048147e0Sopenharmony_ci this.queryOldMessageList(this.strContactsNumber, callback); 1853048147e0Sopenharmony_ci } 1854048147e0Sopenharmony_ci } 1855048147e0Sopenharmony_ci 1856048147e0Sopenharmony_ci queryOldMessageList(telephone, callback) { 1857048147e0Sopenharmony_ci HiLog.i(TAG, 'queryOldMessageList, start'); 1858048147e0Sopenharmony_ci if (telephone == common.string.EMPTY_STR) { 1859048147e0Sopenharmony_ci return; 1860048147e0Sopenharmony_ci } 1861048147e0Sopenharmony_ci let number: string = telephoneUtil.dealTelephoneSort(telephone); 1862048147e0Sopenharmony_ci ConversationListService.getInstance().querySessionByTelephone(number, res => { 1863048147e0Sopenharmony_ci if (res.response == undefined || res.response == null) { 1864048147e0Sopenharmony_ci return; 1865048147e0Sopenharmony_ci } 1866048147e0Sopenharmony_ci if (res.response.id == undefined || res.response.id == null) { 1867048147e0Sopenharmony_ci return; 1868048147e0Sopenharmony_ci } 1869048147e0Sopenharmony_ci HiLog.i(TAG, 'queryOldMessageList, querySessionByTelephone res.response.id: ' + res.response.id); 1870048147e0Sopenharmony_ci if (res.code == common.int.SUCCESS && res.response.id > 0) { 1871048147e0Sopenharmony_ci if (this.threadId != res.response.id) { 1872048147e0Sopenharmony_ci // When modifying the recipient information, click Send and delete the session before the 1873048147e0Sopenharmony_ci // modification. 1874048147e0Sopenharmony_ci let condition: LooseObject = {}; 1875048147e0Sopenharmony_ci condition.threadId = this.threadId; 1876048147e0Sopenharmony_ci ConversationListService.getInstance().deleteSessionByCondition(condition, null, null); 1877048147e0Sopenharmony_ci } 1878048147e0Sopenharmony_ci this.isDraft = res.response.hasDraft; 1879048147e0Sopenharmony_ci this.threadId = res.response.id; 1880048147e0Sopenharmony_ci this.portraitColor = AvatarColor.background.Color[Math.abs(this.threadId) % 6]; 1881048147e0Sopenharmony_ci this.queryMessageDetail(telephone, res.response.id, callback); 1882048147e0Sopenharmony_ci this.scroller.scrollToIndex(this.mmsList.length - 1); 1883048147e0Sopenharmony_ci } else { 1884048147e0Sopenharmony_ci callback(); 1885048147e0Sopenharmony_ci } 1886048147e0Sopenharmony_ci }, null); 1887048147e0Sopenharmony_ci } 1888048147e0Sopenharmony_ci 1889048147e0Sopenharmony_ci initNewSelectContacts(selectContacts) { 1890048147e0Sopenharmony_ci HiLog.i(TAG, 'initNewSelectContacts, start'); 1891048147e0Sopenharmony_ci let contactsNumber = common.string.EMPTY_STR; 1892048147e0Sopenharmony_ci let contactsName = common.string.EMPTY_STR; 1893048147e0Sopenharmony_ci let contactsNumberFormat = common.string.EMPTY_STR; 1894048147e0Sopenharmony_ci let contacts = telephoneUtil.dealSelectContactsSort(selectContacts); 1895048147e0Sopenharmony_ci let length = contacts.length; 1896048147e0Sopenharmony_ci for (let index in contacts) { 1897048147e0Sopenharmony_ci let item = contacts[index]; 1898048147e0Sopenharmony_ci contactsNumber = contactsNumber + item.telephone + common.string.COMMA; 1899048147e0Sopenharmony_ci contactsNumberFormat = contactsNumberFormat + item.telephoneFormat + common.string.COMMA; 1900048147e0Sopenharmony_ci if (item.contactName != common.string.EMPTY_STR) { 1901048147e0Sopenharmony_ci contactsName += (item.contactName + common.string.COMMA); 1902048147e0Sopenharmony_ci } 1903048147e0Sopenharmony_ci } 1904048147e0Sopenharmony_ci this.strContactsNumber = contactsNumber.substring(0, contactsNumber.length - 1); 1905048147e0Sopenharmony_ci this.strContactsName = contactsName.substring(0, contactsName.length - 1); 1906048147e0Sopenharmony_ci this.photoFirstNameDeal(this.strContactsName); 1907048147e0Sopenharmony_ci this.strContactsNumberFormat = contactsNumberFormat.substring(0, contactsNumberFormat.length - 1); 1908048147e0Sopenharmony_ci this.contactsNum = length; 1909048147e0Sopenharmony_ci } 1910048147e0Sopenharmony_ci 1911048147e0Sopenharmony_ci handleWithSend(actionData, item) { 1912048147e0Sopenharmony_ci // Sending request processing 1913048147e0Sopenharmony_ci let hosts: Array<string> = []; 1914048147e0Sopenharmony_ci if (actionData.destinationHost.indexOf(',') == -1) { 1915048147e0Sopenharmony_ci // single-shot 1916048147e0Sopenharmony_ci hosts.push(actionData.destinationHost); 1917048147e0Sopenharmony_ci } else { 1918048147e0Sopenharmony_ci // Group Sending 1919048147e0Sopenharmony_ci for (let host of actionData.destinationHost.split(',')) { 1920048147e0Sopenharmony_ci hosts.push(telephoneUtil.formatTelephone(host)); 1921048147e0Sopenharmony_ci } 1922048147e0Sopenharmony_ci } 1923048147e0Sopenharmony_ci actionData.hosts = hosts; 1924048147e0Sopenharmony_ci this.sendMassMessage(actionData, item); 1925048147e0Sopenharmony_ci } 1926048147e0Sopenharmony_ci 1927048147e0Sopenharmony_ci sendInterval(actionData, mmsList) { 1928048147e0Sopenharmony_ci // Send Timer 1929048147e0Sopenharmony_ci let item = mmsList[mmsList.length - 1]; 1930048147e0Sopenharmony_ci if (this.recallMessagesFlag) { 1931048147e0Sopenharmony_ci item.intervalSendStatus = true; 1932048147e0Sopenharmony_ci // Second countdown timer after the Send button is clicked 1933048147e0Sopenharmony_ci item.sendIntervalId = setInterval(function () { 1934048147e0Sopenharmony_ci item.cancelTimeCount--; 1935048147e0Sopenharmony_ci }, 1000); 1936048147e0Sopenharmony_ci // Transmit timer, which is sent after 6s. 1937048147e0Sopenharmony_ci item.sendTimeoutId = setTimeout(() => { 1938048147e0Sopenharmony_ci item.cancelTimeCount = 0; 1939048147e0Sopenharmony_ci // Clear Timer 1940048147e0Sopenharmony_ci clearTimeout(item.sendTimeoutId); 1941048147e0Sopenharmony_ci clearInterval(item.sendIntervalId); 1942048147e0Sopenharmony_ci this.handleWithSend(actionData, item); 1943048147e0Sopenharmony_ci }, 6000); 1944048147e0Sopenharmony_ci } else { 1945048147e0Sopenharmony_ci this.handleWithSend(actionData, item); 1946048147e0Sopenharmony_ci } 1947048147e0Sopenharmony_ci } 1948048147e0Sopenharmony_ci 1949048147e0Sopenharmony_ci changeValue(e) { 1950048147e0Sopenharmony_ci this.textValue = e; 1951048147e0Sopenharmony_ci if (e == null || e == common.string.EMPTY_STR) { 1952048147e0Sopenharmony_ci if (this.mmsEditList.length != 0) { 1953048147e0Sopenharmony_ci this.canSendMessage = true; 1954048147e0Sopenharmony_ci } else { 1955048147e0Sopenharmony_ci this.canSendMessage = false; 1956048147e0Sopenharmony_ci } 1957048147e0Sopenharmony_ci return; 1958048147e0Sopenharmony_ci } 1959048147e0Sopenharmony_ci // Whether to display full screen 1960048147e0Sopenharmony_ci if (this.isEditMms) { 1961048147e0Sopenharmony_ci this.isShowFullScreen = false; 1962048147e0Sopenharmony_ci } else { 1963048147e0Sopenharmony_ci this.isShowFullScreen = true; 1964048147e0Sopenharmony_ci } 1965048147e0Sopenharmony_ci if (this.isNewMsg) { 1966048147e0Sopenharmony_ci if (this.receiveContactValue == '' && this.selectContacts.length == 0) { 1967048147e0Sopenharmony_ci this.canSendMessage = false; 1968048147e0Sopenharmony_ci return; 1969048147e0Sopenharmony_ci } 1970048147e0Sopenharmony_ci } 1971048147e0Sopenharmony_ci if (this.textValue.length == 0) { 1972048147e0Sopenharmony_ci this.canSendMessage = false; 1973048147e0Sopenharmony_ci return; 1974048147e0Sopenharmony_ci } else { 1975048147e0Sopenharmony_ci this.canSendMessage = MmsPreferences.getInstance().haveSimCardReady() && !this.isFlightMode; 1976048147e0Sopenharmony_ci } 1977048147e0Sopenharmony_ci if (this.isNewMsg) { 1978048147e0Sopenharmony_ci this.setCanSendMsgStatus(); 1979048147e0Sopenharmony_ci } 1980048147e0Sopenharmony_ci } 1981048147e0Sopenharmony_ci 1982048147e0Sopenharmony_ci setTabTitleText() { 1983048147e0Sopenharmony_ci // TabTitleText selected globally 1984048147e0Sopenharmony_ci if (this.tabIndex != 1) { 1985048147e0Sopenharmony_ci // Non-picture page 1986048147e0Sopenharmony_ci this.tabTitleText = this.tabTextList[this.tabIndex]; 1987048147e0Sopenharmony_ci return; 1988048147e0Sopenharmony_ci } 1989048147e0Sopenharmony_ci // On the image selection page, the number of selected images is displayed. 1990048147e0Sopenharmony_ci let size = 0; 1991048147e0Sopenharmony_ci for (let element of this.pictureListFromGallery) { 1992048147e0Sopenharmony_ci if (element.checkedValue) { 1993048147e0Sopenharmony_ci size++; 1994048147e0Sopenharmony_ci } 1995048147e0Sopenharmony_ci } 1996048147e0Sopenharmony_ci this.tabTitleText = size == 0 ? $r('app.string.msg_unselected_tip') : $r('app.string.msg_selected_tip', { 1997048147e0Sopenharmony_ci number: size 1998048147e0Sopenharmony_ci }); 1999048147e0Sopenharmony_ci } 2000048147e0Sopenharmony_ci 2001048147e0Sopenharmony_ci // Check whether the sending icon can be highlighted. 2002048147e0Sopenharmony_ci judgeSendBtnCanClicked() { 2003048147e0Sopenharmony_ci if (MmsPreferences.getInstance().haveSimCardReady() && (this.mmsEditList.length != 0 || 2004048147e0Sopenharmony_ci this.textValue != common.string.EMPTY_STR || this.textareaDatasource.length !== 0)) { 2005048147e0Sopenharmony_ci if (this.isNewMsg) { 2006048147e0Sopenharmony_ci if ((this.receiveContactValue !== '' && this.isPhoneNumber(this.receiveContactValue)) 2007048147e0Sopenharmony_ci || this.selectContacts.length !== 0) { 2008048147e0Sopenharmony_ci this.canSendMessage = true; 2009048147e0Sopenharmony_ci } 2010048147e0Sopenharmony_ci } else { 2011048147e0Sopenharmony_ci this.canSendMessage = true; 2012048147e0Sopenharmony_ci } 2013048147e0Sopenharmony_ci } 2014048147e0Sopenharmony_ci } 2015048147e0Sopenharmony_ci 2016048147e0Sopenharmony_ci // Subscribing to Public Events 2017048147e0Sopenharmony_ci subscribeDetail() { 2018048147e0Sopenharmony_ci HiLog.i(TAG, 'subscribeDetail, start'); 2019048147e0Sopenharmony_ci let events = [common.string.RECEIVE_TRANSMIT_EVENT] 2020048147e0Sopenharmony_ci let commonEventSubscribeInfo = { 2021048147e0Sopenharmony_ci events: events 2022048147e0Sopenharmony_ci }; 2023048147e0Sopenharmony_ci // Creating Subscription Information 2024048147e0Sopenharmony_ci commonEvent.createSubscriber(commonEventSubscribeInfo, this.createSubscriberCallBack.bind(this)); 2025048147e0Sopenharmony_ci } 2026048147e0Sopenharmony_ci 2027048147e0Sopenharmony_ci createSubscriberCallBack(err, data) { 2028048147e0Sopenharmony_ci this.commonEventData = data; 2029048147e0Sopenharmony_ci // Received subscription 2030048147e0Sopenharmony_ci commonEvent.subscribe(this.commonEventData, this.subscriberCallBack.bind(this)); 2031048147e0Sopenharmony_ci } 2032048147e0Sopenharmony_ci 2033048147e0Sopenharmony_ci subscriberCallBack(err, data) { 2034048147e0Sopenharmony_ci HiLog.i(TAG, 'subscriberCallBack, start'); 2035048147e0Sopenharmony_ci globalThis.needToUpdate = true; 2036048147e0Sopenharmony_ci // Receiving SMS Updates 2037048147e0Sopenharmony_ci this.queryMessageDetail(this.strContactsNumber, this.threadId, () => { 2038048147e0Sopenharmony_ci }); 2039048147e0Sopenharmony_ci setTimeout(() => { 2040048147e0Sopenharmony_ci this.scroller.scrollToIndex(this.mmsList.length - 1); 2041048147e0Sopenharmony_ci let actionData: LooseObject = {}; 2042048147e0Sopenharmony_ci actionData.threadId = this.threadId; 2043048147e0Sopenharmony_ci actionData.hasRead = common.is_read.UN_READ; 2044048147e0Sopenharmony_ci NotificationService.getInstance().cancelMessageNotify(actionData); 2045048147e0Sopenharmony_ci NotificationService.getInstance().updateBadgeNumber(); 2046048147e0Sopenharmony_ci ConversationListService.getInstance().markAllToRead(actionData); 2047048147e0Sopenharmony_ci let lastItem: LooseObject = this.mmsList[this.mmsList.length - 1]; 2048048147e0Sopenharmony_ci if (lastItem != null && lastItem.subId != null) { 2049048147e0Sopenharmony_ci this.notifySlotIdChange(lastItem.subId); 2050048147e0Sopenharmony_ci } 2051048147e0Sopenharmony_ci }, 500); 2052048147e0Sopenharmony_ci } 2053048147e0Sopenharmony_ci 2054048147e0Sopenharmony_ci // Unsubscribe 2055048147e0Sopenharmony_ci unSubscribeDetail() { 2056048147e0Sopenharmony_ci if (this.commonEventData != null) { 2057048147e0Sopenharmony_ci commonEvent.unsubscribe(this.commonEventData, () => { 2058048147e0Sopenharmony_ci HiLog.i(TAG, 'unSubscribeDetail, unsubscribe'); 2059048147e0Sopenharmony_ci }); 2060048147e0Sopenharmony_ci } 2061048147e0Sopenharmony_ci } 2062048147e0Sopenharmony_ci 2063048147e0Sopenharmony_ci notifySlotIdChange(slotId: number): void { 2064048147e0Sopenharmony_ci if (MmsPreferences.getInstance().getSelectedSlotId() != slotId) { 2065048147e0Sopenharmony_ci MmsPreferences.getInstance().setValueToMap(common.string.KEY_OF_SELECTED_SLOTID, slotId); 2066048147e0Sopenharmony_ci HiLog.i(TAG, 'notifySlotIdChange, emit slotId: ' + slotId); 2067048147e0Sopenharmony_ci emitter.emit(simCardService.SLOTID_CHANGE_EVENT, { 2068048147e0Sopenharmony_ci data: { 2069048147e0Sopenharmony_ci 'slotId': slotId 2070048147e0Sopenharmony_ci } 2071048147e0Sopenharmony_ci }); 2072048147e0Sopenharmony_ci } 2073048147e0Sopenharmony_ci } 2074048147e0Sopenharmony_ci 2075048147e0Sopenharmony_ci // In the selection mode, tap More. In the displayed menu, select 2076048147e0Sopenharmony_ci moreSelected(e) { 2077048147e0Sopenharmony_ci HiLog.i(TAG, 'moreSelected, e: ' + JSON.stringify(e)) 2078048147e0Sopenharmony_ci switch (e) { 2079048147e0Sopenharmony_ci case '0': 2080048147e0Sopenharmony_ci // duplicating 2081048147e0Sopenharmony_ci this.copyText(); 2082048147e0Sopenharmony_ci break; 2083048147e0Sopenharmony_ci case 1: 2084048147e0Sopenharmony_ci // Share 2085048147e0Sopenharmony_ci this.share(); 2086048147e0Sopenharmony_ci break; 2087048147e0Sopenharmony_ci case 2: 2088048147e0Sopenharmony_ci // Select Text 2089048147e0Sopenharmony_ci this.gotoTextSelect(this.mmsIndex); 2090048147e0Sopenharmony_ci break; 2091048147e0Sopenharmony_ci case 3: 2092048147e0Sopenharmony_ci // lock 2093048147e0Sopenharmony_ci //this.lock(); 2094048147e0Sopenharmony_ci break; 2095048147e0Sopenharmony_ci case 4: 2096048147e0Sopenharmony_ci // Show Details 2097048147e0Sopenharmony_ci this.showDetails(); 2098048147e0Sopenharmony_ci break; 2099048147e0Sopenharmony_ci case 5: 2100048147e0Sopenharmony_ci // Unlock 2101048147e0Sopenharmony_ci //this.unlock(); 2102048147e0Sopenharmony_ci break; 2103048147e0Sopenharmony_ci case 6: 2104048147e0Sopenharmony_ci // View Reports 2105048147e0Sopenharmony_ci this.showReport(this.mmsIndex); 2106048147e0Sopenharmony_ci break; 2107048147e0Sopenharmony_ci case 7: 2108048147e0Sopenharmony_ci // Save Attachments 2109048147e0Sopenharmony_ci this.saveImage(); 2110048147e0Sopenharmony_ci break; 2111048147e0Sopenharmony_ci case 8: 2112048147e0Sopenharmony_ci // Querying vCard Details 2113048147e0Sopenharmony_ci this.showVcarDetail(this.mmsIndex); 2114048147e0Sopenharmony_ci break; 2115048147e0Sopenharmony_ci default: 2116048147e0Sopenharmony_ci break; 2117048147e0Sopenharmony_ci } 2118048147e0Sopenharmony_ci // Exit the multi-selection mode. 2119048147e0Sopenharmony_ci this.exitMultiselect(); 2120048147e0Sopenharmony_ci } 2121048147e0Sopenharmony_ci 2122048147e0Sopenharmony_ci copyText() { 2123048147e0Sopenharmony_ci commonPasteboard.setPasteboard(this.mmsList[this.mmsIndex].content); 2124048147e0Sopenharmony_ci } 2125048147e0Sopenharmony_ci 2126048147e0Sopenharmony_ci share() { 2127048147e0Sopenharmony_ci for (let i = 0; i < this.mmsList.length; i++) { 2128048147e0Sopenharmony_ci if (this.mmsList[i].isCbChecked == true) { 2129048147e0Sopenharmony_ci let actionData: LooseObject = {}; 2130048147e0Sopenharmony_ci actionData.content = this.mmsList[i].content; 2131048147e0Sopenharmony_ci ConversationService.getInstance().gotoShare(actionData, null, null); 2132048147e0Sopenharmony_ci } 2133048147e0Sopenharmony_ci } 2134048147e0Sopenharmony_ci } 2135048147e0Sopenharmony_ci 2136048147e0Sopenharmony_ci gotoTextSelect(idx) { 2137048147e0Sopenharmony_ci router.push({ 2138048147e0Sopenharmony_ci uri: 'pages/text_select/text_select', 2139048147e0Sopenharmony_ci params: this.mmsList[idx] 2140048147e0Sopenharmony_ci }) 2141048147e0Sopenharmony_ci } 2142048147e0Sopenharmony_ci 2143048147e0Sopenharmony_ci showDetails() { 2144048147e0Sopenharmony_ci for (let index = 0; index < this.mmsList.length; index++) { 2145048147e0Sopenharmony_ci if (this.mmsList[index].isCbChecked == true) { 2146048147e0Sopenharmony_ci var time = this.mmsList[index].timeMillisecond; 2147048147e0Sopenharmony_ci var timeStash = this.getTime(time); 2148048147e0Sopenharmony_ci this.mmsTime = timeStash + this.mmsList[index].time; 2149048147e0Sopenharmony_ci if (this.mmsList[index].msgType == 0) { 2150048147e0Sopenharmony_ci this.isMmsType = $r('app.string.sms'); 2151048147e0Sopenharmony_ci } else { 2152048147e0Sopenharmony_ci this.isMmsType = $r('app.string.mms'); 2153048147e0Sopenharmony_ci } 2154048147e0Sopenharmony_ci 2155048147e0Sopenharmony_ci if (this.mmsList[index].isReceive) { 2156048147e0Sopenharmony_ci this.isSendRecipient = true; 2157048147e0Sopenharmony_ci } else { 2158048147e0Sopenharmony_ci this.isSendRecipient = false; 2159048147e0Sopenharmony_ci } 2160048147e0Sopenharmony_ci } 2161048147e0Sopenharmony_ci } 2162048147e0Sopenharmony_ci // this.$element('mms_details_dialog').show(); 2163048147e0Sopenharmony_ci } 2164048147e0Sopenharmony_ci 2165048147e0Sopenharmony_ci showReport(mmsIndex) { 2166048147e0Sopenharmony_ci // View Reports 2167048147e0Sopenharmony_ci let item = this.mmsList[mmsIndex]; 2168048147e0Sopenharmony_ci router.push({ 2169048147e0Sopenharmony_ci uri: 'pages/queryreport/queryReport', 2170048147e0Sopenharmony_ci params: { 2171048147e0Sopenharmony_ci isMsm: item.isMsm, 2172048147e0Sopenharmony_ci telephone: this.strContactsNumber, 2173048147e0Sopenharmony_ci sendStatus: item.sendStatus, 2174048147e0Sopenharmony_ci timeMillisecond: item.timeMillisecond 2175048147e0Sopenharmony_ci }, 2176048147e0Sopenharmony_ci }); 2177048147e0Sopenharmony_ci } 2178048147e0Sopenharmony_ci 2179048147e0Sopenharmony_ci saveImage() { 2180048147e0Sopenharmony_ci var actionData: LooseObject = {}; 2181048147e0Sopenharmony_ci actionData.threadId = this.mmsList[this.mmsIndex]?.threadId; 2182048147e0Sopenharmony_ci actionData.pduId = this.mmsList[this.mmsIndex]?.pduId; 2183048147e0Sopenharmony_ci ConversationService.getInstance().saveImage(actionData, result => { 2184048147e0Sopenharmony_ci this.showToast(result); 2185048147e0Sopenharmony_ci }, null); 2186048147e0Sopenharmony_ci } 2187048147e0Sopenharmony_ci 2188048147e0Sopenharmony_ci showVcarDetail(mmsIndex) { 2189048147e0Sopenharmony_ci 2190048147e0Sopenharmony_ci } 2191048147e0Sopenharmony_ci 2192048147e0Sopenharmony_ci exitMultiselect() { 2193048147e0Sopenharmony_ci // Exit the multi-selection state. 2194048147e0Sopenharmony_ci this.isSelectStatus = false; 2195048147e0Sopenharmony_ci this.cancelCheckedAll(); 2196048147e0Sopenharmony_ci } 2197048147e0Sopenharmony_ci 2198048147e0Sopenharmony_ci longPressMore(e) { 2199048147e0Sopenharmony_ci switch (e) { 2200048147e0Sopenharmony_ci case 0: 2201048147e0Sopenharmony_ci // delete 2202048147e0Sopenharmony_ci this.deleteDetail(); 2203048147e0Sopenharmony_ci break; 2204048147e0Sopenharmony_ci case 1: 2205048147e0Sopenharmony_ci // New Contact 2206048147e0Sopenharmony_ci this.createNewContact(this.strContactsNumber); 2207048147e0Sopenharmony_ci break; 2208048147e0Sopenharmony_ci case 2: 2209048147e0Sopenharmony_ci // Save to Existing Contacts 2210048147e0Sopenharmony_ci this.existingContact(this.strContactsNumber); 2211048147e0Sopenharmony_ci break; 2212048147e0Sopenharmony_ci case 3: 2213048147e0Sopenharmony_ci // Edit Before Call 2214048147e0Sopenharmony_ci this.callEditor(this.strContactsNumber); 2215048147e0Sopenharmony_ci break; 2216048147e0Sopenharmony_ci case 4: 2217048147e0Sopenharmony_ci // Add to Blocklist 2218048147e0Sopenharmony_ci this.callEditor(this.strContactsNumber); 2219048147e0Sopenharmony_ci break; 2220048147e0Sopenharmony_ci case 5: 2221048147e0Sopenharmony_ci // View Contacts 2222048147e0Sopenharmony_ci this.titleBarAvatar(); 2223048147e0Sopenharmony_ci break; 2224048147e0Sopenharmony_ci default: 2225048147e0Sopenharmony_ci break; 2226048147e0Sopenharmony_ci } 2227048147e0Sopenharmony_ci } 2228048147e0Sopenharmony_ci 2229048147e0Sopenharmony_ci // Delete 2230048147e0Sopenharmony_ci deleteDetail() { 2231048147e0Sopenharmony_ci if (this.mmsList.length == 1) { 2232048147e0Sopenharmony_ci this.strMsgDeleteDialogTip = $r('app.string.msg_delete_dialog_con_tip3'); 2233048147e0Sopenharmony_ci } else { 2234048147e0Sopenharmony_ci this.hasDetailDelete = false; 2235048147e0Sopenharmony_ci this.isSelectStatus = true; 2236048147e0Sopenharmony_ci } 2237048147e0Sopenharmony_ci } 2238048147e0Sopenharmony_ci 2239048147e0Sopenharmony_ci // New Contact 2240048147e0Sopenharmony_ci createNewContact(number) { 2241048147e0Sopenharmony_ci var actionData: LooseObject = {}; 2242048147e0Sopenharmony_ci actionData.phoneNumber = number; 2243048147e0Sopenharmony_ci actionData.pageFlag = common.contactPage.PAGE_FLAG_SAVE_CONTACT; 2244048147e0Sopenharmony_ci this.jumpToContact(actionData); 2245048147e0Sopenharmony_ci } 2246048147e0Sopenharmony_ci 2247048147e0Sopenharmony_ci // Edit Before Call 2248048147e0Sopenharmony_ci callEditor(number) { 2249048147e0Sopenharmony_ci var actionData: LooseObject = {}; 2250048147e0Sopenharmony_ci actionData.phoneNumber = number; 2251048147e0Sopenharmony_ci actionData.pageFlag = common.contactPage.PAGE_FLAG_EDIT_BEFORE_CALLING; 2252048147e0Sopenharmony_ci this.jumpToContact(actionData); 2253048147e0Sopenharmony_ci } 2254048147e0Sopenharmony_ci 2255048147e0Sopenharmony_ci // Save to Existing Contacts 2256048147e0Sopenharmony_ci existingContact(number) { 2257048147e0Sopenharmony_ci var actionData: LooseObject = {}; 2258048147e0Sopenharmony_ci actionData.phoneNumber = number; 2259048147e0Sopenharmony_ci actionData.pageFlag = common.contactPage.PAGE_FLAG_SAVE_EXIST_CONTACT; 2260048147e0Sopenharmony_ci this.jumpToContact(actionData); 2261048147e0Sopenharmony_ci } 2262048147e0Sopenharmony_ci 2263048147e0Sopenharmony_ci // Switching to the Contacts app 2264048147e0Sopenharmony_ci jumpToContact(actionData) { 2265048147e0Sopenharmony_ci let str = commonService.commonContactParam(actionData); 2266048147e0Sopenharmony_ci globalThis.mmsContext.startAbility(str).then((data) => { 2267048147e0Sopenharmony_ci HiLog.i(TAG, 'jumpToContact, startAbility Success'); 2268048147e0Sopenharmony_ci }).catch((error) => { 2269048147e0Sopenharmony_ci HiLog.e(TAG, 'jumpToContact, failed. Cause: ' + JSON.stringify(error.message)); 2270048147e0Sopenharmony_ci }) 2271048147e0Sopenharmony_ci } 2272048147e0Sopenharmony_ci 2273048147e0Sopenharmony_ci // Tap a contact's avatar to go to the contact details page. 2274048147e0Sopenharmony_ci titleBarAvatar() { 2275048147e0Sopenharmony_ci var actionData = { 2276048147e0Sopenharmony_ci phoneNumber: this.strContactsNumber, 2277048147e0Sopenharmony_ci pageFlag: common.contactPage.PAGE_FLAG_CONTACT_DETAILS 2278048147e0Sopenharmony_ci }; 2279048147e0Sopenharmony_ci this.jumpToContact(actionData); 2280048147e0Sopenharmony_ci } 2281048147e0Sopenharmony_ci 2282048147e0Sopenharmony_ci clickCall() { 2283048147e0Sopenharmony_ci this.call(this.strContactsNumber); 2284048147e0Sopenharmony_ci } 2285048147e0Sopenharmony_ci 2286048147e0Sopenharmony_ci call(telephone) { 2287048147e0Sopenharmony_ci // Calling 2288048147e0Sopenharmony_ci callService.call(telephone, result => { 2289048147e0Sopenharmony_ci if (result.code == common.int.SUCCESS) { 2290048147e0Sopenharmony_ci HiLog.i(TAG, 'call success'); 2291048147e0Sopenharmony_ci } else { 2292048147e0Sopenharmony_ci HiLog.w(TAG, 'call failed'); 2293048147e0Sopenharmony_ci } 2294048147e0Sopenharmony_ci }); 2295048147e0Sopenharmony_ci } 2296048147e0Sopenharmony_ci 2297048147e0Sopenharmony_ci getTime(nS) { 2298048147e0Sopenharmony_ci var date = new Date(parseInt(nS)); 2299048147e0Sopenharmony_ci var year = date.getFullYear(); 2300048147e0Sopenharmony_ci var mon = date.getMonth() + 1; 2301048147e0Sopenharmony_ci var day = date.getDate(); 2302048147e0Sopenharmony_ci return year; // + $r('app.string.year') + mon + $r('app.string.month') + day + $r('app.string.day'); 2303048147e0Sopenharmony_ci } 2304048147e0Sopenharmony_ci 2305048147e0Sopenharmony_ci // Contact data returned on the new page 2306048147e0Sopenharmony_ci setReceiveContactValue(receiverData) { 2307048147e0Sopenharmony_ci let selectContacts = receiverData.selectContacts; 2308048147e0Sopenharmony_ci let receiveContactValue = selectContacts.length > 0 ? common.string.EMPTY_STR : receiverData.contactValue; 2309048147e0Sopenharmony_ci let hasBlur = receiverData.hasBlur; 2310048147e0Sopenharmony_ci let telephone = common.string.EMPTY_STR; 2311048147e0Sopenharmony_ci this.setCanSendMessage(selectContacts, receiveContactValue) 2312048147e0Sopenharmony_ci if (receiveContactValue != this.strContactsName && router.getParams[0]?.isDraft == null) { 2313048147e0Sopenharmony_ci this.isDraft = false; 2314048147e0Sopenharmony_ci } 2315048147e0Sopenharmony_ci if (hasBlur && receiveContactValue != common.string.EMPTY_STR) { 2316048147e0Sopenharmony_ci let index = -1; 2317048147e0Sopenharmony_ci for (let i = 0; i < selectContacts.length; i++) { 2318048147e0Sopenharmony_ci let contact = selectContacts[i]; 2319048147e0Sopenharmony_ci if (contact.telephone == receiveContactValue) { 2320048147e0Sopenharmony_ci index = i; 2321048147e0Sopenharmony_ci break; 2322048147e0Sopenharmony_ci } 2323048147e0Sopenharmony_ci } 2324048147e0Sopenharmony_ci if (index >= 0) { 2325048147e0Sopenharmony_ci selectContacts.splice(index, 1); 2326048147e0Sopenharmony_ci } 2327048147e0Sopenharmony_ci } 2328048147e0Sopenharmony_ci if (receiveContactValue != common.string.EMPTY_STR) { 2329048147e0Sopenharmony_ci this.receiveContactValue = receiveContactValue; 2330048147e0Sopenharmony_ci } else { 2331048147e0Sopenharmony_ci this.receiveContactValue = common.string.EMPTY_STR; 2332048147e0Sopenharmony_ci } 2333048147e0Sopenharmony_ci if (selectContacts.length > 0) { 2334048147e0Sopenharmony_ci for (let item of selectContacts) { 2335048147e0Sopenharmony_ci if (!this.isPhoneNumber(item.telephone)) { 2336048147e0Sopenharmony_ci item.telephone = this.replaceCode(item.telephone); 2337048147e0Sopenharmony_ci item.telephoneFormat = this.replaceCode(item.telephoneFormat); 2338048147e0Sopenharmony_ci if (item.contactName != common.string.EMPTY_STR) { 2339048147e0Sopenharmony_ci item.contactName = common.string.EMPTY_STR; 2340048147e0Sopenharmony_ci } 2341048147e0Sopenharmony_ci } 2342048147e0Sopenharmony_ci if (this.selectContacts.length > 1) { 2343048147e0Sopenharmony_ci break 2344048147e0Sopenharmony_ci } 2345048147e0Sopenharmony_ci this.selectContacts = selectContacts; 2346048147e0Sopenharmony_ci } 2347048147e0Sopenharmony_ci } else { 2348048147e0Sopenharmony_ci this.selectContacts = []; 2349048147e0Sopenharmony_ci } 2350048147e0Sopenharmony_ci if (this.selectContacts.length > 0) { 2351048147e0Sopenharmony_ci for (let element of this.selectContacts) { 2352048147e0Sopenharmony_ci telephone += element.telephone + common.string.COMMA; 2353048147e0Sopenharmony_ci } 2354048147e0Sopenharmony_ci } 2355048147e0Sopenharmony_ci if (this.receiveContactValue != common.string.EMPTY_STR) { 2356048147e0Sopenharmony_ci telephone += this.receiveContactValue + common.string.COMMA; 2357048147e0Sopenharmony_ci } 2358048147e0Sopenharmony_ci if (telephone != common.string.EMPTY_STR) { 2359048147e0Sopenharmony_ci telephone = telephone.substring(0, telephone.length - 1); 2360048147e0Sopenharmony_ci } 2361048147e0Sopenharmony_ci if (!hasBlur && telephone != '') { 2362048147e0Sopenharmony_ci this.queryOldMessageList(telephone, () => { 2363048147e0Sopenharmony_ci }); 2364048147e0Sopenharmony_ci } 2365048147e0Sopenharmony_ci } 2366048147e0Sopenharmony_ci 2367048147e0Sopenharmony_ci setCanSendMessage(selectContacts, receiveContactValue) { 2368048147e0Sopenharmony_ci if (this.textValue != common.string.EMPTY_STR || this.isEditMms) { 2369048147e0Sopenharmony_ci if (this.canSendMessage) { 2370048147e0Sopenharmony_ci if (selectContacts.length == 0 && receiveContactValue == common.string.EMPTY_STR) { 2371048147e0Sopenharmony_ci this.canSendMessage = false; 2372048147e0Sopenharmony_ci } 2373048147e0Sopenharmony_ci } else if ((selectContacts.length != 0 || receiveContactValue != common.string.EMPTY_STR) 2374048147e0Sopenharmony_ci && MmsPreferences.getInstance().haveSimCardReady()) { 2375048147e0Sopenharmony_ci this.canSendMessage = true; 2376048147e0Sopenharmony_ci } 2377048147e0Sopenharmony_ci } 2378048147e0Sopenharmony_ci } 2379048147e0Sopenharmony_ci}