diff --git a/AppScope/resources/base/media/app_start_window_icon.svg b/AppScope/resources/base/media/app_start_window_icon.svg new file mode 100644 index 0000000..97ef616 --- /dev/null +++ b/AppScope/resources/base/media/app_start_window_icon.svg @@ -0,0 +1,22 @@ + + + Public/ic_back + + + + + \ No newline at end of file diff --git a/entry/src/main/ets/MainAbility/MainAbility.ts b/entry/src/main/ets/MainAbility/MainAbility.ts index d9d34dc..b1f80d3 100644 --- a/entry/src/main/ets/MainAbility/MainAbility.ts +++ b/entry/src/main/ets/MainAbility/MainAbility.ts @@ -1,16 +1,14 @@ import Ability from '@ohos.app.ability.UIAbility' import LogUtils from '../common/utils/LogUtils' import CallManager from '../model/CallManager' -import GlobalThisHelper from '../common/utils/GlobalThisHelper' -import Constants from '../common/utils/Constants' const TAG = "MainAbility"; export default class MainAbility extends Ability { onCreate(want, launchParam) { LogUtils.i(TAG, "onCreate") - GlobalThisHelper.set(Constants.GLOBALTHIS_ABILITY_WANT, want); - GlobalThisHelper.set(Constants.GLOBALTHIS_CONTEXT, this.context); + globalThis.abilityWant = want; + globalThis.calluiAbilityContext = this.context; } onWindowStageCreate(windowStage) { diff --git a/entry/src/main/ets/ServiceAbility/CallManagerService.ts b/entry/src/main/ets/ServiceAbility/CallManagerService.ts index 2edeeb8..8e026f4 100644 --- a/entry/src/main/ets/ServiceAbility/CallManagerService.ts +++ b/entry/src/main/ets/ServiceAbility/CallManagerService.ts @@ -40,9 +40,21 @@ export default class CallManagerService { private mTelephonyCall: TelephonyCall ; private callData = null; private callList = []; - private context: any; + private context; + private static sCallManagerService: CallManagerService; - public constructor(context: any) { + public static getInstance(): CallManagerService { + if (!CallManagerService.sCallManagerService) { + CallManagerService.sCallManagerService = new CallManagerService(); + } + return CallManagerService.sCallManagerService; + } + + public constructor() { + } + + + public init(context) { this.mTelephonyCall = new TelephonyCall; this.addRegisterListener(); this.addSubscriber(); @@ -131,10 +143,10 @@ export default class CallManagerService { * single call or dialing pull up the application */ if (callState === CALL_STATUS_INCOMING || callState === CALL_STATUS_WAITING || callState === CALL_STATUS_DIALING) { - if (this.callList.length > 1) { - this.publishData(callData) - } this.startAbility(callData); + if (this.callList.length > 1) { + this.publishData(callData); + } } else if (callState !== CALL_STATUS_DISCONNECTING) { this.publishData(callData); } diff --git a/entry/src/main/ets/ServiceAbility/ServiceAbility.ts b/entry/src/main/ets/ServiceAbility/ServiceAbility.ts index 19b07b2..16a6b16 100644 --- a/entry/src/main/ets/ServiceAbility/ServiceAbility.ts +++ b/entry/src/main/ets/ServiceAbility/ServiceAbility.ts @@ -2,7 +2,8 @@ import Want from '@ohos.application.Want'; import ServiceExtension from '@ohos.app.ability.ServiceExtensionAbility'; import CallManagerService from './CallManagerService'; import rpc from '@ohos.rpc'; -import LogUtils from "../common/utils/LogUtils" +import LogUtils from "../common/utils/LogUtils"; +import DefaultCallData from '../common/struct/TypeUtils' const TAG = "ServiceAbility"; @@ -11,12 +12,13 @@ export default class ServiceAbility extends ServiceExtension { onCreate(want) { LogUtils.i(TAG, "onCreate callUI service"); - this.callManagerService = new CallManagerService(this.context); + this.callManagerService = CallManagerService.getInstance(); + this.callManagerService.init(this.context); } onConnect(want: Want) { LogUtils.i(TAG, "onConnect callUI service"); - let callData: any = {}; + let callData: DefaultCallData = new DefaultCallData(); callData.accountNumber = want.parameters?.accountNumber; callData.videoState = want.parameters?.videoState; callData.callType = want.parameters?.callType; diff --git a/entry/src/main/ets/assets/picture/addCall.png b/entry/src/main/ets/assets/picture/addCall.png deleted file mode 100644 index de11916..0000000 Binary files a/entry/src/main/ets/assets/picture/addCall.png and /dev/null differ diff --git a/entry/src/main/ets/assets/picture/addCallGrey.png b/entry/src/main/ets/assets/picture/addCallGrey.png deleted file mode 100644 index ed58c79..0000000 Binary files a/entry/src/main/ets/assets/picture/addCallGrey.png and /dev/null differ diff --git a/entry/src/main/ets/assets/picture/exchange.png b/entry/src/main/ets/assets/picture/exchange.png deleted file mode 100644 index 647f83f..0000000 Binary files a/entry/src/main/ets/assets/picture/exchange.png and /dev/null differ diff --git a/entry/src/main/ets/assets/picture/exchangeGrey.png b/entry/src/main/ets/assets/picture/exchangeGrey.png deleted file mode 100644 index 96dfc05..0000000 Binary files a/entry/src/main/ets/assets/picture/exchangeGrey.png and /dev/null differ diff --git a/entry/src/main/ets/assets/picture/exchangeIcon.png b/entry/src/main/ets/assets/picture/exchangeIcon.png deleted file mode 100644 index 30f7731..0000000 Binary files a/entry/src/main/ets/assets/picture/exchangeIcon.png and /dev/null differ diff --git a/entry/src/main/ets/assets/picture/remindDisabled.png b/entry/src/main/ets/assets/picture/remindDisabled.png deleted file mode 100644 index 9717d77..0000000 Binary files a/entry/src/main/ets/assets/picture/remindDisabled.png and /dev/null differ diff --git a/entry/src/main/ets/assets/picture/shunt.png b/entry/src/main/ets/assets/picture/shunt.png deleted file mode 100644 index 4c09239..0000000 Binary files a/entry/src/main/ets/assets/picture/shunt.png and /dev/null differ diff --git a/entry/src/main/ets/assets/picture/shuntHang.png b/entry/src/main/ets/assets/picture/shuntHang.png deleted file mode 100644 index 6a35388..0000000 Binary files a/entry/src/main/ets/assets/picture/shuntHang.png and /dev/null differ diff --git a/entry/src/main/ets/assets/picture/userCall.png b/entry/src/main/ets/assets/picture/userCall.png deleted file mode 100644 index 6a35388..0000000 Binary files a/entry/src/main/ets/assets/picture/userCall.png and /dev/null differ diff --git a/entry/src/main/ets/common/components/BottomBtn.ets b/entry/src/main/ets/common/components/BottomBtn.ets index d846bdf..8a4e014 100644 --- a/entry/src/main/ets/common/components/BottomBtn.ets +++ b/entry/src/main/ets/common/components/BottomBtn.ets @@ -19,13 +19,16 @@ import CallServiceProxy from '../../model/CallServiceProxy'; import LogUtils from '../utils/LogUtils'; +import DefaultCallData from '../struct/TypeUtils'; +import CallListStruct from '../struct/CallListStruct' const TAG = "BottomBtn"; @Component export default struct BottomBtn { onItemClick: Function = null; - @Link callData: any; + @Link callData: DefaultCallData; + @Link callList: Array; private mCallServiceProxy: CallServiceProxy; private imageList; @@ -60,6 +63,11 @@ export default struct BottomBtn { */ onHangUp() { this.mCallServiceProxy.hangUpCall(this.callData.callId); + if (this.callList.length === 1) { + globalThis.calluiAbilityContext?.terminateSelf().then((data) => { + LogUtils.i(TAG, "onHangUp terminateSelfCallBack"); + }); + } LogUtils.i(TAG, "onHangUp this.callData.callId : " + this.callData.callId); } diff --git a/entry/src/main/ets/common/components/CallList.ets b/entry/src/main/ets/common/components/CallList.ets index b2205b8..7361d3b 100644 --- a/entry/src/main/ets/common/components/CallList.ets +++ b/entry/src/main/ets/common/components/CallList.ets @@ -20,17 +20,17 @@ import CallStateConst from '../constant/CallStateConst'; import CallServiceProxy from '../../model/CallServiceProxy'; import LogUtils from '../utils/LogUtils'; -import GlobalThisHelper from '../utils/GlobalThisHelper' -import Constants from '../utils/Constants' +import DefaultCallData from '../struct/TypeUtils'; +import CallListStruct from '../struct/CallListStruct' +import CallTimeListStruct from '../struct/CallTimeListStruct' const TAG = "CallList"; @Component export default struct CallList { - @Link callList: Array; - @Link callData: any; - @StorageLink("CallTimeList") callTimeList: any = []; - + @Link callList: Array; + @Link callData: DefaultCallData; + @StorageLink("CallTimeList") callTimeList: Array = []; private mCallStateConst: CallStateConst; private mCallServiceProxy: CallServiceProxy; @@ -93,7 +93,7 @@ export default struct CallList { LogUtils.i(TAG, "onHangUp : " + callId); this.mCallServiceProxy.hangUpCall(callId); if (this.callList.length === 1) { - GlobalThisHelper.get(Constants.GLOBALTHIS_CONTEXT)?.terminateSelf().then((data) => { + globalThis.calluiAbilityContext?.terminateSelf().then((data) => { LogUtils.i(TAG, "onHangUp terminateSelfCallBack"); }); } @@ -115,6 +115,17 @@ export default struct CallList { }); } + getInComingCallState() { + let incomingState = false; + this.callList.forEach((v) => { + if (v.callState === CallStateConst.callStateObj.CALL_STATUS_WAITING || v.callState === CallStateConst.callStateObj.CALL_STATUS_INCOMING) { + incomingState = true; + } + }); + LogUtils.i(TAG, "getInComingCallState incomingState:" + JSON.stringify(incomingState)); + return incomingState; + } + build() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center }) { List() { @@ -146,8 +157,7 @@ export default struct CallList { .opacity(0.60) } - if (this.callState() === CallStateConst.callStateObj.CALL_STATUS_WAITING - || this.callState() === CallStateConst.callStateObj.CALL_STATUS_INCOMING) { + if (this.getInComingCallState()) { Image($r("app.media.ic_hangup_list")) .width(30) .height(30) @@ -171,11 +181,11 @@ export default struct CallList { .margin({ left: 24, right: 24 }) .width("100%") .listDirection(Axis.Vertical) + Divider() .color($r('app.color.divider_calllist')) .strokeWidth(1) } - .height(128) - + .height(128) } } \ No newline at end of file diff --git a/entry/src/main/ets/common/components/ContactCard.ets b/entry/src/main/ets/common/components/ContactCard.ets index d82eb63..671b368 100644 --- a/entry/src/main/ets/common/components/ContactCard.ets +++ b/entry/src/main/ets/common/components/ContactCard.ets @@ -20,6 +20,9 @@ import LogUtils from '../utils/LogUtils'; import callStateConst from '../constant/CallStateConst'; import Utils from '../utils/utils' import CallUtils from '../utils/CallUtils' +import DefaultCallData from '../struct/TypeUtils' +import CallListStruct from '../struct/CallListStruct' +import CallTimeListStruct from '../struct/CallTimeListStruct' const TAG = "contactCard"; @@ -28,11 +31,11 @@ export default struct ContactCard { @State callStateText: string = ''; @State dialing: string = '.'; @Prop isShowKeyboard: boolean; - @Link callList: Array; - @Link callData: any; + @Link callList: Array; + @Link callData: DefaultCallData; @StorageLink("TextInput") textInput: string = ''; @StorageLink("TextInputValue") textInputValue: string = ''; - @StorageLink("CallTimeList") callTimeList: any = []; + @StorageLink("CallTimeList") callTimeList: Array = []; @StorageLink("AccountNumber") accountNumber: string = ''; @StorageLink("IsEmergencyPhoneNumber") isEmergencyPhoneNumber: boolean = false; @StorageLink("hasSimCard1") hasSimCard1: boolean = false; diff --git a/entry/src/main/ets/common/components/DtmfBtn.ets b/entry/src/main/ets/common/components/DtmfBtn.ets index c086846..6d354f4 100644 --- a/entry/src/main/ets/common/components/DtmfBtn.ets +++ b/entry/src/main/ets/common/components/DtmfBtn.ets @@ -15,19 +15,24 @@ import CallServiceProxy from "../../model/CallServiceProxy"; import LogUtils from '../utils/LogUtils'; +import DefaultCallData from '../struct/TypeUtils'; const TAG = "DtmfBtn"; +class DataListStruct { + value + sign +} @Component export default struct DtmfBtn { @State color: string = "rgba(255, 255, 255, 0)"; @State subStr:string = ''; - @Link dataList: any; + @Link dataList: Array; @Link textInput: string; @Link textInputValue: string; - private item: any; + private item: DataListStruct; private mCallServiceProxy; - callData :any; + callData: DefaultCallData; public aboutToAppear(): void { this.mCallServiceProxy = new CallServiceProxy(); diff --git a/entry/src/main/ets/common/components/FuncBtnGroup.ets b/entry/src/main/ets/common/components/FuncBtnGroup.ets index b4bf60f..8ac45f5 100644 --- a/entry/src/main/ets/common/components/FuncBtnGroup.ets +++ b/entry/src/main/ets/common/components/FuncBtnGroup.ets @@ -21,10 +21,21 @@ import Clone from '../utils/Clone'; import BtnGroupConfig from '../configs/BtnGroupConfig'; import LogUtils from '../utils/LogUtils'; import screenLock from '@ohos.screenLock'; -import GlobalThisHelper from '../utils/GlobalThisHelper'; -import Constants from '../utils/Constants'; +import DefaultCallData from '../struct/TypeUtils' +import CallListStruct from '../struct/CallListStruct' +import FunctonBtnVM from '../../viewmodel/FunctonBtnVIewModel'; const TAG = 'FuncBtnGroup'; + +class BtnStruct { + type + iconDisableUrl + iconDefaultUrl + iconActiveUrl + isDisable + isActive + iconText +} const textMap = { 'record': $r('app.string.recording'), @@ -39,16 +50,17 @@ const textMap = @Component export default struct FuncBtnGroup { - @Link @Watch("updateBtnList") callData: any; - @Link @Watch("updateBtnList") callList: Array; + @Link @Watch("updateBtnList") callData: DefaultCallData; + @Link @Watch("updateBtnList") callList: Array; @State count: number = 0; - @State btnList: Array = []; + @State btnList: Array = []; @State m: number = 0; @State n: number = 0; - @State oldCallState: any = CallStateConst.CALL_STATUS_IDLE; + @State oldCallState: number = CallStateConst.CALL_STATUS_IDLE; + @State mFunctonBtnVM: FunctonBtnVM = FunctonBtnVM.getInstance(); private mCallServiceProxy: CallServiceProxy; private mBtnGroupConfig = BtnGroupConfig; - private timer: any = null; + private timer: number = null; private mClone: Clone; private btnListCall; private btnListDialing; @@ -110,7 +122,7 @@ export default struct FuncBtnGroup { */ onCallStateChange(newVal) { LogUtils.i(TAG, "Calling status changed newState : " + JSON.stringify(newVal)); - const BtnName = ['video', 'record', 'add', 'contact'] + const BtnName = ['video', 'record', 'add', 'contact', 'merge'] if (newVal === CallStateConst.CALL_STATUS_ACTIVE || newVal === CallStateConst.CALL_STATUS_HOLDING) { this.btnList.forEach((item) => { if (!Method.includes(BtnName, (item.type))) { @@ -206,7 +218,7 @@ export default struct FuncBtnGroup { } startContactAbility(pageFlag) { - GlobalThisHelper.get(Constants.GLOBALTHIS_CONTEXT)?.startAbility({ + globalThis.calluiAbilityContext?.startAbility({ bundleName: 'com.ohos.contacts', abilityName: 'com.ohos.contacts.MainAbility', parameters: { diff --git a/entry/src/main/ets/common/components/IncomingCom.ets b/entry/src/main/ets/common/components/IncomingCom.ets index 5eae74e..1c78243 100644 --- a/entry/src/main/ets/common/components/IncomingCom.ets +++ b/entry/src/main/ets/common/components/IncomingCom.ets @@ -22,12 +22,12 @@ import sms from '@ohos.telephony.sms'; import resourceManager from '@ohos.resourceManager'; import prompt from '@system.prompt'; import LogUtils from '../utils/LogUtils'; -import GlobalThisHelper from '../utils/GlobalThisHelper'; -import Constants from '../utils/Constants'; +import DefaultCallData from '../struct/TypeUtils'; +import CallListStruct from '../struct/CallListStruct' + const TAG = "IncomingCom"; const SMS_REJECTION = `${ImagePathConst.BASE_URL}ic_public_message.svg`; -const SMS_REMINDER = `${ImagePathConst.BASE_URL}remindDisabled.png`; /** * SMS sent successfully @@ -51,7 +51,8 @@ const SEND_SMS_FAILURE_SERVICE_UNAVAILABLE = 3; @Component export default struct IncomingCom { - @Link callData: any; + @Link callList: Array; + @Link callData: DefaultCallData; private btnList = []; private msgList = []; mCallServiceProxy: CallServiceProxy = null; @@ -85,10 +86,10 @@ export default struct IncomingCom { * @param obj */ private sendMessage(obj) { - let slotId = this.callData.accountId + let slotId = this.callData.accountId; let destinationHost = this.callData.accountNumber let contactName = this.callData.contactName - GlobalThisHelper.get(Constants.GLOBALTHIS_CONTEXT)?.resourceManager.getString(obj.msg.id, (err, typeName) => { + globalThis.calluiAbilityContext?.resourceManager.getString(obj.msg.id, (err, typeName) => { LogUtils.i(TAG, "sendMessage"); sms.sendMessage({ slotId: slotId, @@ -99,7 +100,7 @@ export default struct IncomingCom { return; } if (sendResult.result === SEND_SMS_SUCCESS) { - GlobalThisHelper.get(Constants.GLOBALTHIS_CONTEXT)?.resourceManager.getString($r("app.string.SMS_Sent") + globalThis.calluiAbilityContext?.resourceManager.getString($r("app.string.SMS_Sent") .id, (err, typeName) => { if (err) { return; @@ -110,7 +111,7 @@ export default struct IncomingCom { }); }) } else { - GlobalThisHelper.get(Constants.GLOBALTHIS_CONTEXT)?.resourceManager.getString($r("app.string.message_Failed").id, (err, typeName) => { + globalThis.calluiAbilityContext?.resourceManager.getString($r("app.string.message_Failed").id, (err, typeName) => { if (err) { return; } @@ -155,7 +156,6 @@ export default struct IncomingCom { iconDisableUrl: SMS_REJECTION, isDisable: false }, - ]; } @@ -174,6 +174,10 @@ export default struct IncomingCom { * Handling interface call hangup and rejection */ private async onReject() { + const incomingData = this.callList.find((v) => v.callState === CallStateConst.callStateObj.CALL_STATUS_WAITING || v.callState === CallStateConst.callStateObj.CALL_STATUS_INCOMING); + Object.assign(this.callData, { + ...incomingData + }); const {callId, callState} = this.callData; if (callState !== CallStateConst.CALL_STATUS_WAITING) { this.mCallServiceProxy.rejectCall(callId); @@ -199,7 +203,12 @@ export default struct IncomingCom { */ private onAnswer() { LogUtils.i(TAG, "onAnswer :"); - this.mCallServiceProxy.acceptCall(this.callData.callId); + const incomingData = this.callList.find((v) => v.callState === CallStateConst.callStateObj.CALL_STATUS_WAITING || v.callState === CallStateConst.callStateObj.CALL_STATUS_INCOMING); + if (incomingData !== undefined) { + this.mCallServiceProxy.acceptCall(incomingData.callId); + } else { + this.mCallServiceProxy.acceptCall(this.callData.callId); + } } build() { diff --git a/entry/src/main/ets/common/components/Keyboard.ets b/entry/src/main/ets/common/components/Keyboard.ets index 99862e8..d6721f1 100644 --- a/entry/src/main/ets/common/components/Keyboard.ets +++ b/entry/src/main/ets/common/components/Keyboard.ets @@ -15,15 +15,20 @@ import CallServiceProxy from '../../model/CallServiceProxy'; import DtmfBtn from '../components/DtmfBtn'; +import DefaultCallData from '../struct/TypeUtils'; +class DataListStruct { + value + sign +} const TAG = "Keyboard"; @Component export default struct Keyboard { - @Link callData: any; + @Link callData: DefaultCallData; @StorageLink("TextInput") textInput: string = ''; @StorageLink("TextInputValue") textInputValue: string = ''; - @State dataList: any = + @State dataList: Array = [ { value: '1', diff --git a/entry/src/main/ets/common/components/MultiContactCard.ets b/entry/src/main/ets/common/components/MultiContactCard.ets index a5a052f..a5adf74 100644 --- a/entry/src/main/ets/common/components/MultiContactCard.ets +++ b/entry/src/main/ets/common/components/MultiContactCard.ets @@ -22,6 +22,9 @@ import Utils from '../utils/utils' import CallList from './CallList' import callStateConst from '../constant/CallStateConst'; import CallUtils from '../utils/CallUtils' +import DefaultCallData from '../struct/TypeUtils' +import CallListStruct from '../struct/CallListStruct' +import CallTimeListStruct from '../struct/CallTimeListStruct' const TAG = "MultiContactCard"; @@ -30,15 +33,18 @@ export default struct MultiContactCard { @State callStateText: string = ''; @State dialing: string = '.'; @Prop isShowKeyboard: boolean; - @Link callList: Array; - @Link callData: any; + @Link callList: Array; + @Link callData: DefaultCallData; + @Link incomingData: DefaultCallData; @StorageLink("TextInput") textInput: string = ''; @StorageLink("TextInputValue") textInputValue: string = ''; - @StorageLink("CallTimeList") callTimeList: any = []; + @StorageLink("CallTimeList") callTimeList: Array = []; @StorageLink("AccountNumber") accountNumber: string = ''; @StorageLink("IsEmergencyPhoneNumber") isEmergencyPhoneNumber: boolean = false; @StorageLink("hasSimCard1") hasSimCard1: boolean = false; @StorageLink("hasSimCard2") hasSimCard2: boolean = false; + @State multiContactName: string = ''; + @State multiContactNumber: string = ''; private mUtils: Utils; private timer; private emergency = $r('app.string.emergency'); @@ -67,6 +73,20 @@ export default struct MultiContactCard { || this.callData.callState === CallStateConst.callStateObj.CALL_STATUS_INCOMING) && this.hasSimCard1 && this.hasSimCard2; } + getInComingCallState() { + let incomingState = false; + this.callList.forEach((v) => { + if (v.callState === CallStateConst.callStateObj.CALL_STATUS_WAITING || v.callState === CallStateConst.callStateObj.CALL_STATUS_INCOMING) { + this.incomingData = v; + this.multiContactName = v.contactName; + this.multiContactNumber = v.accountNumber; + incomingState = true; + } + }); + LogUtils.i(TAG, "getInComingCallState incomingState:" + JSON.stringify(incomingState)); + return incomingState; + } + build() { GridRow({ columns: { sm: 4, md: 8, lg: 12 }, gutter: 24 }) { GridCol({ span: { sm: 4, md: 6, lg: 6 }, offset: { md: 1, lg: 3 } }) { @@ -77,11 +97,10 @@ export default struct MultiContactCard { callData: $callData }) - if (this.callData.callState === CallStateConst.callStateObj.CALL_STATUS_WAITING - || this.callData.callState === CallStateConst.callStateObj.CALL_STATUS_INCOMING) { + if (this.getInComingCallState()) { Column() { if (!this.isShowKeyboard || this.isShowKeyboard && this.textInput.length === 0) { - Text(this.isEmergencyPhoneNumber ? this.emergency : this.callData.contactName ? this.callData.contactName : this.callData.accountNumber) + Text(this.isEmergencyPhoneNumber ? this.emergency : this.multiContactName ? this.multiContactName : this.multiContactNumber) .fontSize(30) .height(40) .lineHeight(40) @@ -89,13 +108,13 @@ export default struct MultiContactCard { .fontColor('#FFFFFF') .margin({ bottom: 8 }) - Text((this.callData.contactName || this.isEmergencyPhoneNumber) ? this.callData.accountNumber : '') + Text((this.multiContactName || this.isEmergencyPhoneNumber) ? this.multiContactNumber : '') .fontSize(14) .height(19) .lineHeight(19) .fontColor('#FFFFFF') .opacity(0.60) - .visibility((this.callData.contactName || this.isEmergencyPhoneNumber) && !this.isShowKeyboard ? Visibility.Visible : Visibility.None) + .visibility((this.multiContactName || this.isEmergencyPhoneNumber) && !this.isShowKeyboard ? Visibility.Visible : Visibility.None) } } .margin({ top: 56 }) diff --git a/entry/src/main/ets/common/configs/BtnGroupConfig.ets b/entry/src/main/ets/common/configs/BtnGroupConfig.ets index f633230..7868265 100644 --- a/entry/src/main/ets/common/configs/BtnGroupConfig.ets +++ b/entry/src/main/ets/common/configs/BtnGroupConfig.ets @@ -91,7 +91,7 @@ const secondBtns = [ iconDisableUrl: 'ic_merge_Grey', iconDefaultUrl: 'ic_merge', iconActiveUrl: 'ic_merge_Enabled', - isDisable: false, + isDisable: true, isActive: false, iconText: '' } diff --git a/mobiledatasettings/src/main/ets/common/model/api.ets b/entry/src/main/ets/common/constant/DeviceTypeConst.ts similarity index 65% rename from mobiledatasettings/src/main/ets/common/model/api.ets rename to entry/src/main/ets/common/constant/DeviceTypeConst.ts index 2402f64..fbea1da 100644 --- a/mobiledatasettings/src/main/ets/common/model/api.ets +++ b/entry/src/main/ets/common/constant/DeviceTypeConst.ts @@ -1,4 +1,4 @@ -/* +/** * Copyright (c) 2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,15 +13,13 @@ * limitations under the License. */ -/** - * @file: SIM card,mobile data,Card Status,Operators so - */ - -import sim from '@ohos.telephony.sim'; -import telephonyData from '@ohos.telephony.data'; -import observer from '@ohos.telephony.observer'; -import radio from '@ohos.telephony.radio'; - -export { sim, telephonyData, radio, observer }; - - +export default class DeviceTypeConst { + //DEVICE_EARPIECE + public static DEVICE_EARPIECE = 0; + //DEVICE_SPEAKER + public static DEVICE_SPEAKER = 1; + //DEVICE_WIRED_HEADSET + public static DEVICE_WIRED_HEADSET = 2; + //DEVICE_BLUETOOTH_SCO + public static DEVICE_BLUETOOTH_SCO = 3; +} \ No newline at end of file diff --git a/entry/src/main/ets/common/struct/CallListStruct.ets b/entry/src/main/ets/common/struct/CallListStruct.ets new file mode 100644 index 0000000..08dc481 --- /dev/null +++ b/entry/src/main/ets/common/struct/CallListStruct.ets @@ -0,0 +1,13 @@ +export default class DefaultCallData { + accountNumber + videoState + callType + callState + callId + startTime + accountId + isEcc + conferenceState + oldCallState + contactName +} \ No newline at end of file diff --git a/entry/src/main/ets/common/struct/CallTimeListStruct.ets b/entry/src/main/ets/common/struct/CallTimeListStruct.ets new file mode 100644 index 0000000..595c58b --- /dev/null +++ b/entry/src/main/ets/common/struct/CallTimeListStruct.ets @@ -0,0 +1,6 @@ +export default class CallTimeListStruct { + callId + callTime + startTimestamp + endTimestamp +} \ No newline at end of file diff --git a/entry/src/main/ets/common/struct/TypeUtils.ets b/entry/src/main/ets/common/struct/TypeUtils.ets new file mode 100644 index 0000000..653435e --- /dev/null +++ b/entry/src/main/ets/common/struct/TypeUtils.ets @@ -0,0 +1,12 @@ +export default class DefaultCallData { + callId + callState + accountNumber: string + videoState: number + callType: number + conferenceState: number + contactName: string + accountId: number + isEcc: number + startTime: number +} diff --git a/entry/src/main/ets/common/utils/Constants.ts b/entry/src/main/ets/common/utils/Constants.ts index 5ea87eb..cad93ec 100644 --- a/entry/src/main/ets/common/utils/Constants.ts +++ b/entry/src/main/ets/common/utils/Constants.ts @@ -22,8 +22,6 @@ export class Constants { public CALL_ABILITY_NAME = 'com.ohos.callui.MainAbility'; public GLOBALTHIS_CALLMANAGER = 'callManager'; public GLOBALTHIS_ABILITY_WANT = 'abilityWant'; - public GLOBALTHIS_CONTEXT = 'calluiAbilityContext'; - public GLOBALTHIS_APPINACTIVE_STATE = 'appInactiveState'; } let mConstants = new Constants(); diff --git a/entry/src/main/ets/common/utils/GlobalThisHelper.ts b/entry/src/main/ets/common/utils/GlobalThisHelper.ts deleted file mode 100644 index 6ca93e8..0000000 --- a/entry/src/main/ets/common/utils/GlobalThisHelper.ts +++ /dev/null @@ -1,35 +0,0 @@ -import LogUtils from '../utils/LogUtils' - -const TAG = "GlobalThisHelper" - -export default class GlobalThisHelper { - private static registerKeys = [ - "calluiAbilityContext", - "callManager", - "aaa", - 'abilityWant', - 'appInactiveState' - ]; - - public static set(key: string, value: T) : T { - const element = GlobalThisHelper.registerKeys.find((ele) => ele === key); - if (element === undefined) { - LogUtils.i(TAG, "Cant't find register key: " + JSON.stringify(key)) - return undefined; - } - - if (!globalThis[key]) { - globalThis[key] = value; - } - LogUtils.i(TAG, "GlobalThisHelper.set succeed, key:" + JSON.stringify(key)); - return globalThis[key]; - } - - public static get(key: string): T{ - if (!globalThis[key]) { - LogUtils.i(TAG, "the key is not exist, key" + JSON.stringify(key)); - return undefined; - } - return (globalThis[key] as T); - } -} \ No newline at end of file diff --git a/entry/src/main/ets/model/CallDataManager.ets b/entry/src/main/ets/model/CallDataManager.ets index ba1b5a8..b2f4457 100644 --- a/entry/src/main/ets/model/CallDataManager.ets +++ b/entry/src/main/ets/model/CallDataManager.ets @@ -21,18 +21,19 @@ import CallStateConst from '../common/constant/CallStateConst'; import ContactManager from './ContactManager'; import NotificationManager from '../model/NotificationManager'; import LogUtils from '../common/utils/LogUtils'; -import GlobalThisHelper from '../common/utils/GlobalThisHelper'; -import Constants from '../common/utils/Constants'; +import CallTimeListStruct from '../common/struct/CallTimeListStruct'; +import CallListStruct from '../common/struct/CallListStruct'; +import DefaultCallData from '../common/struct/TypeUtils'; const TAG = "CallDataManager"; /** * class CallDataManager */ export default class CallDataManager { - callData: any = {}; - callList: any = []; - callTimeList: any = []; - private callStateChange: any; + callData: DefaultCallData = new DefaultCallData(); + callList: Array = []; + callTimeList: Array = []; + private callStateChange: Function; private mCallStateManager: CallStateManager ; private NotificationManager; private contactManager; @@ -52,9 +53,36 @@ export default class CallDataManager { this.NotificationManager = new NotificationManager(); this.contactManager = new ContactManager(); this.mCallStateManager = CallStateManager.getInstance() - this.callData = callData; - this.callList = callList; - this.callTimeList = callTimeList; + if (this.callData) { + this.callData = callData; + } else { + let oldCallData = this.callData; + this.callData = callData; + Object.assign(this.callData, { + ...oldCallData + }); + } + if (this.callList.length === 0) { + LogUtils.i(TAG, "init callList: undefined"); + this.callList = callList; + } else { + let oldCallList = this.callList; + this.callList = callList; + Object.assign(this.callList, { + ...oldCallList + }); + } + if (this.callTimeList.length === 0) { + LogUtils.i(TAG, "init callTimeList: undefined"); + this.callTimeList = callTimeList; + } else { + LogUtils.i(TAG, "init callTimeList else : " + JSON.stringify(this.callTimeList)); + let oldCallTimeList = this.callTimeList; + this.callTimeList = callTimeList; + Object.assign(this.callTimeList, { + ...oldCallTimeList + }); + } this.callStateChange = (arg) => arg; this.mCallStateManager = new CallStateManager(this.callData); } @@ -74,7 +102,7 @@ export default class CallDataManager { ...callData }); if (oldCallState != callState) { - AppStorage.Get('notificationManager').sendCapsuleNotification(callData, GlobalThisHelper.get(Constants.GLOBALTHIS_APPINACTIVE_STATE)); + AppStorage.Get('notificationManager').sendCapsuleNotification(callData, globalThis.appInactiveState); } } else { this.addCallList({ @@ -106,7 +134,7 @@ export default class CallDataManager { this.NotificationManager.cancelNotification(); AppStorage.Get('notificationManager').sendCapsuleNotification(callData, true); AppStorage.Delete("CallTimeList"); - GlobalThisHelper.get(Constants.GLOBALTHIS_CONTEXT)?.terminateSelf().then((data) => { + globalThis.calluiAbilityContext?.terminateSelf().then((data) => { LogUtils.i(TAG, "calluiAbility terminateSelf"); }); } else { @@ -115,14 +143,23 @@ export default class CallDataManager { if (activeCallData) { this.mCallStateManager.update(activeCallData); this.callStateChange(activeCallData); + this.sendNotification(activeCallData); } else if (this.callList[0]) { this.mCallStateManager.update(this.callList[0]); this.callStateChange(this.callList[0].callState); + this.sendNotification(this.callList[0]); } } } } + sendNotification(callData) { + if (globalThis.appInactiveState && callData) { + AppStorage.Get('notificationManager')?.sendNotification(callData); + AppStorage.Get('notificationManager')?.sendCapsuleNotification(callData, globalThis.appInactiveState); + } + } + /** * Judge whether the call exists. */ @@ -137,16 +174,18 @@ export default class CallDataManager { * Judge whether the call exists. */ public hasActiveCall(): boolean { - return this.callList.find((call) => call.callState === CallStateConst.CALL_STATUS_ACTIVE - || call.callState === CallStateConst.CALL_STATUS_HOLDING); + const callData = this.callList.find((call) => (call.callState === CallStateConst.CALL_STATUS_ACTIVE + || call.callState === CallStateConst.CALL_STATUS_HOLDING)); + return callData !== undefined; } /** * Judge whether the call is active or holding. */ public isActiveCall(callId): boolean { - return this.callList.find((call) => call.callId === callId && (call.callState === CallStateConst.CALL_STATUS_ACTIVE + const callData = this.callList.find((call) => call.callId === callId && (call.callState === CallStateConst.CALL_STATUS_ACTIVE || call.callState === CallStateConst.CALL_STATUS_HOLDING)); + return callData !== undefined; } /** diff --git a/entry/src/main/ets/model/CallManager.ets b/entry/src/main/ets/model/CallManager.ets index c7d6a21..8afb3af 100644 --- a/entry/src/main/ets/model/CallManager.ets +++ b/entry/src/main/ets/model/CallManager.ets @@ -23,8 +23,8 @@ import CallServiceProxy from './CallServiceProxy'; import LogUtils from '../common/utils/LogUtils' import call from '@ohos.telephony.call'; import CallStateConst from '../common/constant/CallStateConst'; -import GlobalThisHelper from '../common/utils/GlobalThisHelper' -import Constants from '../common/utils/Constants' +import DefaultCallData from '../common/struct/TypeUtils'; +import CallListStruct from '../common/struct/CallListStruct'; const TAG = "CallManager"; const TIMING = 1000; @@ -33,11 +33,12 @@ const TIMING = 1000; * class CallManager */ export default class CallManager { - private callData: any = {}; + private callData: DefaultCallData = new DefaultCallData(); + private callList: Array = []; private timer = null ; callTimeList = []; private ctx = []; - private sendNotificationHandle: any; + private sendNotificationHandle: Function; private mCallDataManager: CallDataManager; private mCallServiceProxy: CallServiceProxy ; private mUtils: Utils; @@ -45,10 +46,10 @@ export default class CallManager { private mTimeMeter public static getInstance(): CallManager { - if (GlobalThisHelper.get(Constants.GLOBALTHIS_CALLMANAGER) === undefined) { - GlobalThisHelper.set(Constants.GLOBALTHIS_CALLMANAGER, new CallManager()); + if (!globalThis.callManager) { + globalThis.callManager = new CallManager(); } - return GlobalThisHelper.get(Constants.GLOBALTHIS_CALLMANAGER); + return globalThis.callManager; } private constructor() { @@ -57,9 +58,9 @@ export default class CallManager { this.timer = null; this.mCallDataManager = CallDataManager.getInstance(); } + init(ctx) { this.callData = ctx.callData; - this.timer = null; this.ctx = ctx; this.callTimeList = ctx.callTimeList; this.mCallDataManager?.init(ctx.callData, ctx.callList, ctx.callTimeList); @@ -72,10 +73,8 @@ export default class CallManager { * init CallData */ private initCallData() { - if (!GlobalThisHelper.get(Constants.GLOBALTHIS_ABILITY_WANT) - && GlobalThisHelper.get(Constants.GLOBALTHIS_ABILITY_WANT)?.parameters - && ('callState' in GlobalThisHelper.get(Constants.GLOBALTHIS_ABILITY_WANT)?.parameters)) { - let callData = this.getCallDataFromWant(GlobalThisHelper.get(Constants.GLOBALTHIS_ABILITY_WANT).parameters); + if (globalThis.abilityWant && globalThis.abilityWant.parameters && ('callState' in globalThis.abilityWant.parameters)) { + let callData = this.getCallDataFromWant(globalThis.abilityWant.parameters); this.update(callData); LogUtils.i(TAG, "initCallData featureAbility.getWant :") } else { @@ -111,8 +110,8 @@ export default class CallManager { LogUtils.i(TAG, "update calldata:") if (this.callData != undefined && this.callData.callId === callData.callId) { const { callState } = this.callData; - if (callState === 6) { - GlobalThisHelper.get(Constants.GLOBALTHIS_CONTEXT)?.terminateSelf().then((data) => { + if (callState === 6 && this.callList.length === 1) { + globalThis.calluiAbilityContext?.terminateSelf().then((data) => { LogUtils.i(TAG, "calluiAbility terminateSelf because service disconnected"); }); return; @@ -121,14 +120,17 @@ export default class CallManager { this.callData = callData; this.mCallDataManager.update(callData); call.formatPhoneNumber(callData.accountNumber, (err, data) => { - if (data === undefined) { - AppStorage.SetOrCreate("AccountNumber", callData.accountNumber) + if (err) { + LogUtils.i(TAG, "updata calldata formatPhoneNumber err:" + JSON.stringify(err)); + } else if (data === undefined) { + AppStorage.SetOrCreate("AccountNumber", callData.accountNumber); } else { - AppStorage.SetOrCreate("AccountNumber", data) + LogUtils.i(TAG, "updata calldata formatPhoneNumber success:" + JSON.stringify(data)); + AppStorage.SetOrCreate("AccountNumber", data); } }); - CallUtils.isEmergencyPhoneNumber(callData.accountNumber) - LogUtils.i(TAG, "update :") + CallUtils.isEmergencyPhoneNumber(callData.accountNumber); + LogUtils.i(TAG, "update :"); } /** @@ -167,7 +169,7 @@ export default class CallManager { openTimer() { this.timer = setInterval(() => { this.updateCallTimeList(); - if (this.callData.callState === CallStateConst.CALL_STATUS_ACTIVE) { + if (this.callData.callState === CallStateConst.CALL_STATUS_ACTIVE && this.callList.length === 1) { clearInterval(this.timer); } }, TIMING); diff --git a/entry/src/main/ets/model/ContactManager.ts b/entry/src/main/ets/model/ContactManager.ts index 6545f40..b961413 100644 --- a/entry/src/main/ets/model/ContactManager.ts +++ b/entry/src/main/ets/model/ContactManager.ts @@ -20,8 +20,6 @@ import dataShare from '@ohos.data.dataShare'; import dataSharePredicates from '@ohos.data.dataSharePredicates'; import LogUtils from '../common/utils/LogUtils'; import CallManager from '../model/CallManager'; -import GlobalThisHelper from '../common/utils/GlobalThisHelper'; -import Constants from '../common/utils/Constants'; const TAG = "ContactManager"; const DBbaseUri = 'datashare:///com.ohos.contactsdataability'; @@ -45,16 +43,19 @@ export default class ContactManager { const predicates = new dataSharePredicates.DataSharePredicates(); predicates.equalTo('detail_info', callData.accountNumber); predicates.equalTo('is_deleted', 0); - const dataAbilityHelper = await dataShare.createDataShareHelper(GlobalThisHelper.get(Constants.GLOBALTHIS_CONTEXT), DBbaseUri); + let context = globalThis.calluiAbilityContext; + const dataAbilityHelper = await dataShare.createDataShareHelper(context, DBbaseUri); const resSet = await dataAbilityHelper.query(DBUri, predicates, columns); - LogUtils.i(TAG, "getContactInfo resSet : " + JSON.stringify(resSet.rowCount)) + LogUtils.i(TAG, "getContactInfo resSet : " + JSON.stringify(resSet.rowCount)); if (resSet.rowCount > 0) { resSet.goToFirstRow(); callData.contactName = resSet.getString(resSet.getColumnIndex('display_name')); - CallManager.getInstance().update(callData); + } else { + callData.contactName = ""; } + CallManager.getInstance().update(callData); } catch (err) { - LogUtils.i(TAG, "getContactInfo catch err : %s" + JSON.stringify(err)) + LogUtils.i(TAG, "getContactInfo catch err : %s" + JSON.stringify(err)); } } } \ No newline at end of file diff --git a/entry/src/main/ets/model/NotificationManager.ets b/entry/src/main/ets/model/NotificationManager.ets index 1e84e3a..ac328da 100644 --- a/entry/src/main/ets/model/NotificationManager.ets +++ b/entry/src/main/ets/model/NotificationManager.ets @@ -81,36 +81,34 @@ export default class NotificationManager { } notificationRequest.wantAgent = wantAgentObj; notificationRequest.actionButtons = []; + if (actionBtnKeys.length) { for (const key of actionBtnKeys) { const data = { callId, btnType: key }; + LogUtils.i(TAG, "sendNotification getResourceManager key:" + JSON.stringify(key)); const wantAgentObj = await this.getWantAgent(data, SEND_COMMON_EVENT); - GlobalThisHelper.get(Constants.GLOBALTHIS_CONTEXT)?.resourceManager.getString(textMap[key].id, (error, value) => { - if (error != null) { - LogUtils.i(TAG, "sendNotification getResourceManager getString err"); - } else { - LogUtils.i(TAG, "sendNotification getResourceManager getString value" + value); - notificationRequest.actionButtons.push({ - title: value, - wantAgent: wantAgentObj - }); - Object.assign(notificationRequest.content.longText, { - title: titleName, - text: expandedName, - expandedTitle: titleName, - longText: expandedName - }); - notification.publish(notificationRequest).then((data) => { - LogUtils.i(TAG, "sendNotification publish success") - }).catch((err) => { - LogUtils.i(TAG, "sendNotification public err" + JSON.stringify(err)) - }); - } + const title = globalThis.calluiAbilityContext?.resourceManager.getStringSync(textMap[key]); + LogUtils.i(TAG, "sendNotification getResourceManager textMap[key].id:" + JSON.stringify(title)); + notificationRequest.actionButtons.push({ + title: title, + wantAgent: wantAgentObj }); + LogUtils.i(TAG, "sendNotification getResourceManager notificationRequest.actionButtons.push:" + JSON.stringify(notificationRequest.actionButtons)); } } + Object.assign(notificationRequest.content.longText, { + title: titleName, + text: expandedName, + expandedTitle: titleName, + longText: expandedName + }); + notification.publish(notificationRequest).then((data) => { + LogUtils.i(TAG, "sendNotification publish success") + }).catch((err) => { + LogUtils.i(TAG, "sendNotification public err" + JSON.stringify(err)) + }); LogUtils.i(TAG, "sendNotification end :") } diff --git a/entry/src/main/ets/pages/index.ets b/entry/src/main/ets/pages/index.ets index a3c79af..67765d7 100644 --- a/entry/src/main/ets/pages/index.ets +++ b/entry/src/main/ets/pages/index.ets @@ -29,7 +29,9 @@ import backgroundTaskManager from '@ohos.backgroundTaskManager'; import Constants from '../common/utils/Constants'; import CallDataManager from '../model/CallDataManager'; import MultiContactCard from '../common/components/MultiContactCard'; -import GlobalThisHelper from '../common/utils/GlobalThisHelper'; +import DefaultCallData from '../common/struct/TypeUtils' +import CallListStruct from '../common/struct/CallListStruct' +import CallTimeListStruct from '../common/struct/CallTimeListStruct' const TAG = "Index"; @@ -39,14 +41,14 @@ const TAG = "Index"; @Entry @Component struct Index { - @StorageLink("InputNum") inputNum: any = []; - @State callData: any = CallStateConst.defaultCallData; + @State callData: DefaultCallData = new DefaultCallData(); @State isShowKeyboard: boolean = false; - @State callList: Array = []; - @State callTimeList: Array = []; + @State callList: Array = []; + @State callTimeList: Array = []; private notificationManager: NotificationManager; private mCallDataManager: CallDataManager; @State curBp: string = 'md'; + @State incomingData: DefaultCallData = new DefaultCallData(); private smListener: mediaQuery.MediaQueryListener; private mdListener: mediaQuery.MediaQueryListener; private lgListener: mediaQuery.MediaQueryListener; @@ -88,17 +90,17 @@ struct Index { onPageShow() { LogUtils.i(TAG, "onPageShow"); byTrace.startTrace('onPageShow', 1); - GlobalThisHelper.set(Constants.GLOBALTHIS_APPINACTIVE_STATE, false); + globalThis.appInactiveState = false; this.stopBackgroundRunning(); this.notificationManager?.cancelNotification(); - this.notificationManager?.sendCapsuleNotification(this.callData, false); + this.notificationManager?.sendCapsuleNotification(this.incomingData ? this.callData : this.incomingData, false); byTrace.finishTrace('onPageShow', 1); LogUtils.i(TAG, "onPageShow end"); } onPageHide() { LogUtils.i(TAG, "onPageHide"); - GlobalThisHelper.set(Constants.GLOBALTHIS_APPINACTIVE_STATE, true); + globalThis.appInactiveState = true; this.updateNotification(); LogUtils.i(TAG, "onPageHide end"); } @@ -109,23 +111,25 @@ struct Index { if (this.mCallDataManager.hasAliveCall()) { this.startBackgroundRunning(); } - this.notificationManager?.sendNotification(this.callData); - this.notificationManager?.sendCapsuleNotification(this.callData, true); + this.notificationManager?.sendNotification(this.incomingData ? this.callData : this.incomingData); + this.notificationManager?.sendCapsuleNotification(this.incomingData ? this.callData : this.incomingData, true); } } - aboutToDisappear() { LogUtils.i(TAG, "aboutToDisappear"); this.stopBackgroundRunning(); - this.updateNotification(); this.smListener.off('change', this.isBreakpointSM); this.mdListener.off('change', this.isBreakpointMD); this.lgListener.off('change', this.isBreakpointLG); } + onBackPress() { + LogUtils.i(TAG, "onBackPress"); + } + private stopBackgroundRunning() { - backgroundTaskManager.stopBackgroundRunning(GlobalThisHelper.get(Constants.GLOBALTHIS_CONTEXT)).then(() => { + backgroundTaskManager.stopBackgroundRunning(globalThis.calluiAbilityContext).then(() => { LogUtils.i(TAG, "stopBackgroundRunning succeeded"); }).catch((err) => { LogUtils.i(TAG, "stopBackgroundRunning failed"); @@ -135,16 +139,16 @@ struct Index { private startBackgroundRunning() { let wantAgentInfo = { wants: [{ - bundleName: Constants.CALL_BUNDLE_NAME, - abilityName: Constants.CALL_ABILITY_NAME, - }], + bundleName: Constants.CALL_BUNDLE_NAME, + abilityName: Constants.CALL_ABILITY_NAME, + }], requestCode: 0, operationType: wantAgent.OperationType.START_ABILITY, wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG] }; wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => { - backgroundTaskManager.startBackgroundRunning(GlobalThisHelper.get(Constants.GLOBALTHIS_CONTEXT), - backgroundTaskManager.BackgroundMode.VOIP, wantAgentObj).then(() => { + backgroundTaskManager.startBackgroundRunning(globalThis.calluiAbilityContext, + backgroundTaskManager.BackgroundMode.VOIP, wantAgentObj).then(() => { LogUtils.i(TAG, "startBackgroundRunning succeeded") }).catch((err) => { LogUtils.i(TAG, "startBackgroundRunning failed cause:" + JSON.stringify(err)) @@ -182,6 +186,26 @@ struct Index { && this.callList.length === 3; } + pageTransition() { + PageTransitionEnter({ duration: 0 }); + PageTransitionExit({ duration: 0 }); + } + + getBtnCallState() { + if (this.callList.length > 1) { + let btnState = true; + this.callList.forEach((v) => { + if (v.callState === CallStateConst.callStateObj.CALL_STATUS_WAITING || v.callState === CallStateConst.callStateObj.CALL_STATUS_INCOMING) { + btnState = false; + } + }); + return btnState; + } else { + return this.callState() !== CallStateConst.callStateObj.CALL_STATUS_WAITING + && this.callState() !== CallStateConst.callStateObj.CALL_STATUS_INCOMING + } + } + build() { Flex({ direction: FlexDirection.Column, @@ -192,7 +216,8 @@ struct Index { MultiContactCard({ callData: $callData, isShowKeyboard: this.isShowKeyboard, - callList: $callList + callList: $callList, + incomingData: $incomingData }) .margin({ top: this.isShowKeyboard ? 0 : 56 }) .layoutWeight(this.isShowKeyboard ? 1 : 0) @@ -206,8 +231,7 @@ struct Index { .layoutWeight(this.isShowKeyboard ? 1 : 0) } - if (this.callState() !== CallStateConst.callStateObj.CALL_STATUS_WAITING - && this.callState() !== CallStateConst.callStateObj.CALL_STATUS_INCOMING) { + if (this.getBtnCallState()) { Column() { if (!this.isShowKeyboard) { FuncBtnGroup({ callData: $callData, callList: $callList }) @@ -218,6 +242,7 @@ struct Index { } BottomBtn({ callData: $callData, + callList: $callList, onItemClick: () => { this.showKeyboard() } @@ -225,7 +250,9 @@ struct Index { } } else { Column() { - IncomingCom({ callData: $callData }) + IncomingCom({ + callList: $callList, + callData: $callData }) if (this.isTripleCall()) { Column() { diff --git a/entry/src/main/ets/viewmodel/FunctonBtnVIewModel.ets b/entry/src/main/ets/viewmodel/FunctonBtnVIewModel.ets new file mode 100644 index 0000000..72417a7 --- /dev/null +++ b/entry/src/main/ets/viewmodel/FunctonBtnVIewModel.ets @@ -0,0 +1,19 @@ +import BaseViewModel from './base/BaseViewModel'; +import LogUtils from '../common/utils/LogUtils'; +const TAG = 'FunctonBtnViewModel'; + +export default class FunctonBtnViewModel extends BaseViewModel{ + private static sFunctonBtnViewModel: FunctonBtnViewModel; + public isMuted: boolean; + public mMuteEnabledListener: (boolean) => void = (arg) => arg; + public static getInstance(): FunctonBtnViewModel { + if (!FunctonBtnViewModel.sFunctonBtnViewModel) { + FunctonBtnViewModel.sFunctonBtnViewModel = new FunctonBtnViewModel(); + } + return FunctonBtnViewModel.sFunctonBtnViewModel; + } + + public setMuteEnabled(isMuted) { + this.isMuted = isMuted; + } +} \ No newline at end of file diff --git a/entry/src/main/ets/viewmodel/base/BaseViewModel.ets b/entry/src/main/ets/viewmodel/base/BaseViewModel.ets new file mode 100644 index 0000000..c4fcfc9 --- /dev/null +++ b/entry/src/main/ets/viewmodel/base/BaseViewModel.ets @@ -0,0 +1,6 @@ +export default class BaseViewModel { + constructor() { + } + aboutToAppear(): void { + } +} \ No newline at end of file diff --git a/entry/src/main/module.json b/entry/src/main/module.json index 0050503..a185323 100644 --- a/entry/src/main/module.json +++ b/entry/src/main/module.json @@ -26,7 +26,8 @@ "description": "$string:callui_description", "icon": "$media:app_icon", "label": "$string:callui_description", - "startWindowIcon": "$media:app_icon", + "supportWindowMode": ["fullscreen", "floating"], + "startWindowIcon": "$media:app_start_window_icon", "startWindowBackground": "$color:black", "removeMissionAfterTerminate": true, "visible": true, @@ -60,28 +61,36 @@ ], "requestPermissions": [ { - "name": "ohos.permission.READ_CONTACTS" + "name": "ohos.permission.READ_CONTACTS", + "reason": "$string:READ_CONTACTS" }, { - "name": "ohos.permission.SEND_MESSAGES" + "name": "ohos.permission.SEND_MESSAGES", + "reason": "$string:SEND_MESSAGES" }, { - "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" + "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", + "reason": "$string:GET_BUNDLE_INFO_PRIVILEGED" }, { - "name": "ohos.permission.GET_TELEPHONY_STATE" + "name": "ohos.permission.GET_TELEPHONY_STATE", + "reason": "$string:GET_TELEPHONY_STATE" }, { - "name": "ohos.permission.NOTIFICATION_CONTROLLER" + "name": "ohos.permission.NOTIFICATION_CONTROLLER", + "reason": "$string:NOTIFICATION_CONTROLLER" }, { - "name": "ohos.permission.START_ABILITIES_FROM_BACKGROUND" + "name": "ohos.permission.START_ABILITIES_FROM_BACKGROUND", + "reason": "$string:START_ABILITIES_FROM_BACKGROUND" }, { - "name": "ohos.permission.KEEP_BACKGROUND_RUNNING" + "name": "ohos.permission.KEEP_BACKGROUND_RUNNING", + "reason": "$string:KEEP_BACKGROUND_RUNNING" }, { - "name": "ohos.permission.ANSWER_CALL" + "name": "ohos.permission.ANSWER_CALL", + "reason": "$string:ANSWER_CALL" } ] } diff --git a/entry/src/main/module.json5 b/entry/src/main/module.json5 index bd5c427..4416816 100644 --- a/entry/src/main/module.json5 +++ b/entry/src/main/module.json5 @@ -41,7 +41,8 @@ "description": "$string:callui_description", "icon": "$media:app_icon", "label": "$string:callui_description", - "startWindowIcon": "$media:app_icon", + "supportWindowMode": ["fullscreen", "floating"], + "startWindowIcon": "$media:app_start_window_icon", "startWindowBackground": "$color:black", "removeMissionAfterTerminate": true, "visible": true, @@ -75,28 +76,36 @@ ], "requestPermissions": [ { - "name": "ohos.permission.READ_CONTACTS" + "name": "ohos.permission.READ_CONTACTS", + "reason": "$string:READ_CONTACTS" }, { - "name": "ohos.permission.SEND_MESSAGES" + "name": "ohos.permission.SEND_MESSAGES", + "reason": "$string:SEND_MESSAGES" }, { - "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" + "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", + "reason": "$string:GET_BUNDLE_INFO_PRIVILEGED" }, { - "name": "ohos.permission.GET_TELEPHONY_STATE" + "name": "ohos.permission.GET_TELEPHONY_STATE", + "reason": "$string:GET_TELEPHONY_STATE" }, { - "name": "ohos.permission.NOTIFICATION_CONTROLLER" + "name": "ohos.permission.NOTIFICATION_CONTROLLER", + "reason": "$string:NOTIFICATION_CONTROLLER" }, { - "name": "ohos.permission.START_ABILITIES_FROM_BACKGROUND" + "name": "ohos.permission.START_ABILITIES_FROM_BACKGROUND", + "reason": "$string:START_ABILITIES_FROM_BACKGROUND" }, { - "name": "ohos.permission.KEEP_BACKGROUND_RUNNING" + "name": "ohos.permission.KEEP_BACKGROUND_RUNNING", + "reason": "$string:KEEP_BACKGROUND_RUNNING" }, { - "name": "ohos.permission.ANSWER_CALL" + "name": "ohos.permission.ANSWER_CALL", + "reason": "$string:ANSWER_CALL" } ] } diff --git a/entry/src/main/resources/base/element/string.json b/entry/src/main/resources/base/element/string.json index 30bc7be..04b6ec8 100644 --- a/entry/src/main/resources/base/element/string.json +++ b/entry/src/main/resources/base/element/string.json @@ -204,9 +204,45 @@ "name": "emergency", "value": "Emergency" }, + { + "name": "wiredHeadset", + "value": "WiredHeadset" + }, { "name": "end_holding_call", "value": "Answering this call will end the one currently on hold" + }, + { + "name": "READ_CONTACTS", + "value": "Read contacts" + }, + { + "name": "SEND_MESSAGES", + "value": "Send messages" + }, + { + "name": "GET_BUNDLE_INFO_PRIVILEGED", + "value": "Get bundle info privileged" + }, + { + "name": "GET_TELEPHONY_STATE", + "value": "Get telephony state" + }, + { + "name": "NOTIFICATION_CONTROLLER", + "value": "Notification controller" + }, + { + "name": "START_ABILITIES_FROM_BACKGROUND", + "value": "Start abilities from background" + }, + { + "name": "KEEP_BACKGROUND_RUNNING", + "value": "Keep background running" + }, + { + "name": "ANSWER_CALL", + "value": "Answer call" } ] } \ No newline at end of file diff --git a/entry/src/main/resources/base/media/audio_arrow.svg b/entry/src/main/resources/base/media/audio_arrow.svg new file mode 100644 index 0000000..2767751 --- /dev/null +++ b/entry/src/main/resources/base/media/audio_arrow.svg @@ -0,0 +1,32 @@ + + + Public/ic_public_arrow_right + Created with Sketch. + + + + + + + + + + \ No newline at end of file diff --git a/entry/src/main/resources/base/media/audio_mode_bluetooth.svg b/entry/src/main/resources/base/media/audio_mode_bluetooth.svg new file mode 100644 index 0000000..c7eb5c0 --- /dev/null +++ b/entry/src/main/resources/base/media/audio_mode_bluetooth.svg @@ -0,0 +1,31 @@ + + + Public/ic_public_bluetooth + + + + + + + + + + \ No newline at end of file diff --git a/entry/src/main/resources/base/media/audio_mode_bluetooth_selected.svg b/entry/src/main/resources/base/media/audio_mode_bluetooth_selected.svg new file mode 100644 index 0000000..c36a048 --- /dev/null +++ b/entry/src/main/resources/base/media/audio_mode_bluetooth_selected.svg @@ -0,0 +1,31 @@ + + + Public/ic_public_bluetooth + + + + + + + + + + \ No newline at end of file diff --git a/entry/src/main/resources/base/media/audio_mode_earphone.svg b/entry/src/main/resources/base/media/audio_mode_earphone.svg new file mode 100644 index 0000000..cb4cf4b --- /dev/null +++ b/entry/src/main/resources/base/media/audio_mode_earphone.svg @@ -0,0 +1,32 @@ + + + Linear/ic_device_earphone_hero + Created with Sketch. + + + + + + + + + + \ No newline at end of file diff --git a/entry/src/main/resources/base/media/audio_mode_earphone_selected.svg b/entry/src/main/resources/base/media/audio_mode_earphone_selected.svg new file mode 100644 index 0000000..6979bb3 --- /dev/null +++ b/entry/src/main/resources/base/media/audio_mode_earphone_selected.svg @@ -0,0 +1,32 @@ + + + Linear/ic_device_earphone_hero + Created with Sketch. + + + + + + + + + + \ No newline at end of file diff --git a/entry/src/main/resources/base/media/audio_mode_earpiece.svg b/entry/src/main/resources/base/media/audio_mode_earpiece.svg new file mode 100644 index 0000000..f79e91e --- /dev/null +++ b/entry/src/main/resources/base/media/audio_mode_earpiece.svg @@ -0,0 +1,31 @@ + + + ic_Earpiece Emergency + + + + + + + + + + \ No newline at end of file diff --git a/entry/src/main/resources/base/media/audio_mode_earpiece_selected.svg b/entry/src/main/resources/base/media/audio_mode_earpiece_selected.svg new file mode 100644 index 0000000..ea032f2 --- /dev/null +++ b/entry/src/main/resources/base/media/audio_mode_earpiece_selected.svg @@ -0,0 +1,31 @@ + + + ic_Earpiece Emergency + + + + + + + + + + \ No newline at end of file diff --git a/entry/src/main/resources/base/media/audio_mode_sound.svg b/entry/src/main/resources/base/media/audio_mode_sound.svg new file mode 100644 index 0000000..2e3ab01 --- /dev/null +++ b/entry/src/main/resources/base/media/audio_mode_sound.svg @@ -0,0 +1,31 @@ + + + Public/ic_public_sound + + + + + + + + + + \ No newline at end of file diff --git a/entry/src/main/resources/base/media/audio_mode_wired_headset.svg b/entry/src/main/resources/base/media/audio_mode_wired_headset.svg new file mode 100644 index 0000000..b3f809d --- /dev/null +++ b/entry/src/main/resources/base/media/audio_mode_wired_headset.svg @@ -0,0 +1,22 @@ + + + Linear/ic_device_earphone + Created with Sketch. + + + + \ No newline at end of file diff --git a/entry/src/main/resources/base/media/audio_mode_wired_headset_selected.svg b/entry/src/main/resources/base/media/audio_mode_wired_headset_selected.svg new file mode 100644 index 0000000..ec5da59 --- /dev/null +++ b/entry/src/main/resources/base/media/audio_mode_wired_headset_selected.svg @@ -0,0 +1,22 @@ + + + Linear/ic_device_earphone + Created with Sketch. + + + + \ No newline at end of file diff --git a/entry/src/main/resources/base/media/contact_default_avatar_dark.svg b/entry/src/main/resources/base/media/contact_default_avatar_dark.svg deleted file mode 100644 index 92101e2..0000000 --- a/entry/src/main/resources/base/media/contact_default_avatar_dark.svg +++ /dev/null @@ -1,12 +0,0 @@ - - - 默认头像_dark - - - - - - - - - \ No newline at end of file diff --git a/entry/src/main/resources/base/media/contact_default_avatar_light.svg b/entry/src/main/resources/base/media/contact_default_avatar_light.svg deleted file mode 100644 index 8ed976b..0000000 --- a/entry/src/main/resources/base/media/contact_default_avatar_light.svg +++ /dev/null @@ -1,11 +0,0 @@ - - - 默认头像_light - - - - - - - - \ No newline at end of file diff --git a/entry/src/main/resources/base/media/divider.svg b/entry/src/main/resources/base/media/divider.svg deleted file mode 100644 index 5a901c8..0000000 --- a/entry/src/main/resources/base/media/divider.svg +++ /dev/null @@ -1,8 +0,0 @@ - - - divider - - - - - \ No newline at end of file diff --git a/entry/src/main/resources/base/media/ic_add_filled.svg b/entry/src/main/resources/base/media/ic_add_filled.svg deleted file mode 100644 index ab1667d..0000000 --- a/entry/src/main/resources/base/media/ic_add_filled.svg +++ /dev/null @@ -1,10 +0,0 @@ - - - Public/ic_add_filled - - - - - - - \ No newline at end of file diff --git a/entry/src/main/resources/base/media/ic_me.svg b/entry/src/main/resources/base/media/ic_me.svg deleted file mode 100644 index c24d7af..0000000 --- a/entry/src/main/resources/base/media/ic_me.svg +++ /dev/null @@ -1,8 +0,0 @@ - - - Public/ic_me - - - - - \ No newline at end of file diff --git a/entry/src/main/resources/base/media/ic_message.svg b/entry/src/main/resources/base/media/ic_message.svg deleted file mode 100644 index c7bfdd4..0000000 --- a/entry/src/main/resources/base/media/ic_message.svg +++ /dev/null @@ -1,10 +0,0 @@ - - - Public/ic_message - - - - - - - \ No newline at end of file diff --git a/entry/src/main/resources/base/media/ic_public_Smart_Speaker_filed.svg b/entry/src/main/resources/base/media/ic_public_Smart_Speaker_filed.svg deleted file mode 100644 index e97b1a5..0000000 --- a/entry/src/main/resources/base/media/ic_public_Smart_Speaker_filed.svg +++ /dev/null @@ -1,8 +0,0 @@ - - - ic_publicSmart Speakerfiled - - - - - \ No newline at end of file diff --git a/entry/src/main/resources/base/media/ic_public_add_filled.svg b/entry/src/main/resources/base/media/ic_public_add_filled.svg deleted file mode 100644 index e02c678..0000000 --- a/entry/src/main/resources/base/media/ic_public_add_filled.svg +++ /dev/null @@ -1,13 +0,0 @@ - - - ic_public_add_filled - - - - - - - - - - \ No newline at end of file diff --git a/entry/src/main/resources/base/media/ic_public_add_filled_Grey.svg b/entry/src/main/resources/base/media/ic_public_add_filled_Grey.svg deleted file mode 100644 index 24192c1..0000000 --- a/entry/src/main/resources/base/media/ic_public_add_filled_Grey.svg +++ /dev/null @@ -1,31 +0,0 @@ - - - ic_public_add_filled_置灰 - - - - - - - - - - \ No newline at end of file diff --git a/entry/src/main/resources/base/media/ic_public_clock.svg b/entry/src/main/resources/base/media/ic_public_clock.svg deleted file mode 100644 index febb13c..0000000 --- a/entry/src/main/resources/base/media/ic_public_clock.svg +++ /dev/null @@ -1,7 +0,0 @@ - - - Public/ic_public_clock - - - - \ No newline at end of file diff --git a/entry/src/main/resources/base/media/ic_public_contacts.svg b/entry/src/main/resources/base/media/ic_public_contacts.svg deleted file mode 100644 index fb8e87b..0000000 --- a/entry/src/main/resources/base/media/ic_public_contacts.svg +++ /dev/null @@ -1,13 +0,0 @@ - - - ic_public_contacts - - - - - - - - - - \ No newline at end of file diff --git a/entry/src/main/resources/base/media/ic_public_contacts_Grey.svg b/entry/src/main/resources/base/media/ic_public_contacts_Grey.svg deleted file mode 100644 index 80bc251..0000000 --- a/entry/src/main/resources/base/media/ic_public_contacts_Grey.svg +++ /dev/null @@ -1,32 +0,0 @@ - - - ic_public_contacts_置灰 - - - - - - - - - - \ No newline at end of file diff --git a/entry/src/main/resources/base/media/ic_public_hangUP.svg b/entry/src/main/resources/base/media/ic_public_hangUP.svg deleted file mode 100644 index 0afecdc..0000000 --- a/entry/src/main/resources/base/media/ic_public_hangUP.svg +++ /dev/null @@ -1,25 +0,0 @@ - - - 挂断备份 3 - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/entry/src/main/resources/base/media/ic_public_keyboard.svg b/entry/src/main/resources/base/media/ic_public_keyboard.svg deleted file mode 100644 index f610e3c..0000000 --- a/entry/src/main/resources/base/media/ic_public_keyboard.svg +++ /dev/null @@ -1,10 +0,0 @@ - - - Public/ic_dialer - - - - - - - \ No newline at end of file diff --git a/entry/src/main/resources/base/media/ic_public_pause.svg b/entry/src/main/resources/base/media/ic_public_pause.svg deleted file mode 100644 index a0bdf05..0000000 --- a/entry/src/main/resources/base/media/ic_public_pause.svg +++ /dev/null @@ -1,7 +0,0 @@ - - - ic_public_pause - - - - \ No newline at end of file diff --git a/entry/src/main/resources/base/media/ic_public_pause_Enabled.svg b/entry/src/main/resources/base/media/ic_public_pause_Enabled.svg deleted file mode 100644 index 7e05b16..0000000 --- a/entry/src/main/resources/base/media/ic_public_pause_Enabled.svg +++ /dev/null @@ -1,7 +0,0 @@ - - - ic_public_pause_高亮 - - - - \ No newline at end of file diff --git a/entry/src/main/resources/base/media/ic_public_pause_Grey.svg b/entry/src/main/resources/base/media/ic_public_pause_Grey.svg deleted file mode 100644 index 41cd39f..0000000 --- a/entry/src/main/resources/base/media/ic_public_pause_Grey.svg +++ /dev/null @@ -1,7 +0,0 @@ - - - ic_public_pause_置灰 - - - - \ No newline at end of file diff --git a/entry/src/main/resources/base/media/ic_public_recording_.svg b/entry/src/main/resources/base/media/ic_public_recording_.svg deleted file mode 100644 index c5e16ce..0000000 --- a/entry/src/main/resources/base/media/ic_public_recording_.svg +++ /dev/null @@ -1,13 +0,0 @@ - - - ic_public_recording_ - - - - - - - - - - \ No newline at end of file diff --git a/entry/src/main/resources/base/media/ic_public_recording_Grey.svg b/entry/src/main/resources/base/media/ic_public_recording_Grey.svg deleted file mode 100644 index ec296ce..0000000 --- a/entry/src/main/resources/base/media/ic_public_recording_Grey.svg +++ /dev/null @@ -1,32 +0,0 @@ - - - ic_public_recording_置灰 - - - - - - - - - - \ No newline at end of file diff --git a/entry/src/main/resources/base/media/ic_public_sound_louder_unselected.svg b/entry/src/main/resources/base/media/ic_public_sound_louder_unselected.svg new file mode 100644 index 0000000..4d9d700 --- /dev/null +++ b/entry/src/main/resources/base/media/ic_public_sound_louder_unselected.svg @@ -0,0 +1,30 @@ + + + ic_public_sound_高亮 + + + + + + + + + + \ No newline at end of file diff --git a/entry/src/main/resources/base/media/ic_public_video.svg b/entry/src/main/resources/base/media/ic_public_video.svg deleted file mode 100644 index 39dc3f3..0000000 --- a/entry/src/main/resources/base/media/ic_public_video.svg +++ /dev/null @@ -1,16 +0,0 @@ - - - Public/ic_public_video - - - - - - - - - - - - - \ No newline at end of file diff --git a/entry/src/main/resources/base/media/ic_public_video_Grey.svg b/entry/src/main/resources/base/media/ic_public_video_Grey.svg deleted file mode 100644 index 126c774..0000000 --- a/entry/src/main/resources/base/media/ic_public_video_Grey.svg +++ /dev/null @@ -1,32 +0,0 @@ - - - ic_public_video_置灰 - - - - - - - - - - \ No newline at end of file diff --git a/entry/src/main/resources/base/media/ic_public_video_filled.svg b/entry/src/main/resources/base/media/ic_public_video_filled.svg deleted file mode 100644 index 33fb141..0000000 --- a/entry/src/main/resources/base/media/ic_public_video_filled.svg +++ /dev/null @@ -1,15 +0,0 @@ - - - Public/ic_public_video_filled - - - - - - - - - - - - \ No newline at end of file diff --git a/entry/src/main/resources/base/media/ic_public_voice.svg b/entry/src/main/resources/base/media/ic_public_voice.svg deleted file mode 100644 index 751ee81..0000000 --- a/entry/src/main/resources/base/media/ic_public_voice.svg +++ /dev/null @@ -1,13 +0,0 @@ - - - ic_public_voice - - - - - - - - - - \ No newline at end of file diff --git a/entry/src/main/resources/base/media/ic_public_voice_Enabled.svg b/entry/src/main/resources/base/media/ic_public_voice_Enabled.svg deleted file mode 100644 index 3dccf85..0000000 --- a/entry/src/main/resources/base/media/ic_public_voice_Enabled.svg +++ /dev/null @@ -1,13 +0,0 @@ - - - ic_public_voice_置灰备份 - - - - - - - - - - \ No newline at end of file diff --git a/entry/src/main/resources/base/media/ic_public_voice_Grey.svg b/entry/src/main/resources/base/media/ic_public_voice_Grey.svg deleted file mode 100644 index 9a97c44..0000000 --- a/entry/src/main/resources/base/media/ic_public_voice_Grey.svg +++ /dev/null @@ -1,32 +0,0 @@ - - - ic_public_voice_置灰 - - - - - - - - - - \ No newline at end of file diff --git a/entry/src/main/resources/base/media/ic_rocerder.svg b/entry/src/main/resources/base/media/ic_rocerder.svg deleted file mode 100644 index eca98e6..0000000 --- a/entry/src/main/resources/base/media/ic_rocerder.svg +++ /dev/null @@ -1,22 +0,0 @@ - - - Public/ic_rocerder - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/entry/src/main/resources/base/media/ic_video_filled.svg b/entry/src/main/resources/base/media/ic_video_filled.svg deleted file mode 100644 index d0a7f50..0000000 --- a/entry/src/main/resources/base/media/ic_video_filled.svg +++ /dev/null @@ -1,18 +0,0 @@ - - - Public/ic_video_filled - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/entry/src/main/resources/base/media/ic_voice.svg b/entry/src/main/resources/base/media/ic_voice.svg deleted file mode 100644 index 267057c..0000000 --- a/entry/src/main/resources/base/media/ic_voice.svg +++ /dev/null @@ -1,10 +0,0 @@ - - - Public/ic_voice - - - - - - - \ No newline at end of file diff --git a/entry/src/main/resources/base/media/ic_voice_filled.svg b/entry/src/main/resources/base/media/ic_voice_filled.svg deleted file mode 100644 index cd22a21..0000000 --- a/entry/src/main/resources/base/media/ic_voice_filled.svg +++ /dev/null @@ -1,9 +0,0 @@ - - - Public/ic_voice_filled - - - - - - \ No newline at end of file diff --git a/entry/src/main/resources/base/media/ic_volume.svg b/entry/src/main/resources/base/media/ic_volume.svg deleted file mode 100644 index 94f1073..0000000 --- a/entry/src/main/resources/base/media/ic_volume.svg +++ /dev/null @@ -1,8 +0,0 @@ - - - Public/ic_volume - - - - - \ No newline at end of file diff --git a/entry/src/main/resources/base/media/ic_volume_filled.svg b/entry/src/main/resources/base/media/ic_volume_filled.svg deleted file mode 100644 index c96624b..0000000 --- a/entry/src/main/resources/base/media/ic_volume_filled.svg +++ /dev/null @@ -1,16 +0,0 @@ - - - Public/ic_volume_filled - - - - - - - - - - - - - \ No newline at end of file diff --git a/entry/src/main/resources/base/media/phone_default_avatar.svg b/entry/src/main/resources/base/media/phone_default_avatar.svg deleted file mode 100644 index 42245ec..0000000 --- a/entry/src/main/resources/base/media/phone_default_avatar.svg +++ /dev/null @@ -1,13 +0,0 @@ - - - 编组 2 - - - - - - - - - - \ No newline at end of file diff --git a/entry/src/main/resources/zh_CN/element/string.json b/entry/src/main/resources/zh_CN/element/string.json index b6fbdb1..6ee0adb 100644 --- a/entry/src/main/resources/zh_CN/element/string.json +++ b/entry/src/main/resources/zh_CN/element/string.json @@ -124,6 +124,14 @@ "name": "phoneHandset", "value": "手机听筒" }, + { + "name": "wiredHeadset", + "value": "有线耳机" + }, + { + "name": "blueetoothDevice", + "value": "蓝牙设备" + }, { "name": "mobileNetwork", "value": "无法访问移动网络。" @@ -207,6 +215,38 @@ { "name": "end_holding_call", "value": "接听来电将挂断之前保持的通话" + }, + { + "name": "READ_CONTACTS", + "value": "读取联系人" + }, + { + "name": "SEND_MESSAGES", + "value": "发送短信" + }, + { + "name": "GET_BUNDLE_INFO_PRIVILEGED", + "value": "获取绑定信息特权" + }, + { + "name": "GET_TELEPHONY_STATE", + "value": "获取电话状态" + }, + { + "name": "NOTIFICATION_CONTROLLER", + "value": "发送通知" + }, + { + "name": "START_ABILITIES_FROM_BACKGROUND", + "value": "从后台启动的能力" + }, + { + "name": "KEEP_BACKGROUND_RUNNING", + "value": "后台运行能力" + }, + { + "name": "ANSWER_CALL", + "value": "接听电话" } ] } \ No newline at end of file diff --git a/mobiledatasettings/src/main/ets/common/components/headComponent.ets b/mobiledatasettings/src/main/ets/common/components/headComponent.ets index e3426b2..a4748f8 100644 --- a/mobiledatasettings/src/main/ets/common/components/headComponent.ets +++ b/mobiledatasettings/src/main/ets/common/components/headComponent.ets @@ -51,7 +51,7 @@ export default struct HeadComponent { .fontSize(20) .fontFamily('HarmonyHeiTi-Bold') .fontWeight(FontWeight.Medium) - .fontColor($r('app.color.font_color_182431')) + .fontColor($r('sys.color.ohos_id_color_text_primary')) .maxLines(1) .textOverflow({ overflow: TextOverflow.Ellipsis }) .textAlign(TextAlign.Start) diff --git a/mobiledatasettings/src/main/ets/common/components/listItem/listItem.ets b/mobiledatasettings/src/main/ets/common/components/listItem/listItem.ets index c909192..8ccbd9f 100644 --- a/mobiledatasettings/src/main/ets/common/components/listItem/listItem.ets +++ b/mobiledatasettings/src/main/ets/common/components/listItem/listItem.ets @@ -36,8 +36,8 @@ export default struct listItem { @Prop isDisabled: boolean; @Prop cardType: number; @Link controlSwitch: boolean; - @State title: any = ''; - @State describe: any = ''; + @State title: Resource = $r('app.string.mobile_data_dataRoaming'); + @State describe: Resource = $r('app.string.mobile_data_enableDataWhileRoaming'); @Prop isSupport: boolean; @State titleopacity: boolean = false; @Prop isCon: number; @@ -48,7 +48,7 @@ export default struct listItem { builder: dataRomingDialog({ isCon: this.isCon, isMsg: $controlSwitch, cardType: this.cardType }), alignment: DialogAlignment.Bottom, autoCancel: false, - offset: { dx: 0, dy: -10 } + offset: { dx: 0, dy: -16 } }) clickHandle() { @@ -71,14 +71,14 @@ export default struct listItem { build() { Column() { - Row({}) { + Row() { Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { Column() { Text(this.title) .fontFamily('HarmonyHeiTi') - .fontSize(16) + .fontSize($r('sys.float.ohos_id_text_size_body1')) .fontWeight(FontWeight.Medium) - .fontColor('#000') + .fontColor($r('sys.color.ohos_id_color_text_primary')) .opacity(this.controlSwitch ? 0.9 : 0.6) .visibility(this.isSupport ? Visibility.None : Visibility.Visible) .letterSpacing(1) @@ -87,12 +87,13 @@ export default struct listItem { Text(this.describe) .margin({ top: 2 }) .fontFamily('HarmonyHeiTi') - .fontSize(14) - .fontColor('#555') + .fontWeight(FontWeight.Regular) + .fontSize($r('sys.float.ohos_id_text_size_body2')) + .fontColor($r('sys.color.ohos_id_color_text_secondary')) .opacity(0.6) .lineHeight(19) .letterSpacing(1) - .visibility(this.describe == '' ? Visibility.None : Visibility.Visible) + .visibility(this.describe == $r("app.string.mobile_empty_string") ? Visibility.None : Visibility.Visible) } .width('100%') .alignItems(HorizontalAlign.Start) @@ -103,10 +104,6 @@ export default struct listItem { }) .enabled(this.isDisabled) - Image($r('app.media.right')) - .width(16) - .height(18) - .visibility(!this.isBtn ? Visibility.Visible : Visibility.None) Toggle({ type: ToggleType.Switch, isOn: this.controlSwitch }) .width(36) .height(20) @@ -115,7 +112,6 @@ export default struct listItem { this.controlSwitch = !this.controlSwitch; LogUtils.i(TAG, 'onclick cardType is :' + JSON.stringify(this.cardType) + 'switcher is:' + JSON.stringify(this.isCon) + "Switch status:" + this.controlSwitch); if (this.controlSwitch && this.isCon === 0) { - this.dialogTitle = this.title; this.recordTypeDialog.open(); } else if (this.controlSwitch == false && this.isCon === 0) { this.cardType === 0 ? disableCellularDataRoamingCardOne() : disableCellularDataRoamingCardTwo(); @@ -132,7 +128,7 @@ export default struct listItem { } .backgroundColor($r("sys.color.ohos_id_color_foreground_contrary")) .opacity(this.isDisabled ? 1 : 0.4) - .margin({ top: 10, bottom: this.isSupport ? 5 : 11 }) + .margin({ top: 8, bottom: this.isSupport ? 5 : 11 }) .onClick(() => { if (!this.isDisabled) { return; @@ -163,7 +159,6 @@ struct dataRomingDialog { .fontSize($r('sys.float.ohos_id_text_size_body1')) .fontWeight(FontWeight.Regular) .textAlign(TextAlign.Start) - .height(56) .fontFamily('HarmonyHeiTi') .letterSpacing(3) .visibility(this.isCon == 0 ? Visibility.Visible : Visibility.None) @@ -174,9 +169,9 @@ struct dataRomingDialog { Text(publiccontent.strings.cancel) .fontWeight(FontWeight.Medium) .fontFamily("HarmonnyHeiTi") - .lineHeight(21) + .height(21) .fontColor($r('sys.color.ohos_id_color_text_primary_activated')) - .fontSize(16) + .fontSize($r('sys.float.ohos_id_text_size_button1')) .onClick(() => { LogUtils.i(TAG, "dataRomingDialog onclick cancel"); this.controller.close(); @@ -187,19 +182,20 @@ struct dataRomingDialog { Text(publiccontent.strings.confirm) .fontWeight(FontWeight.Medium) .fontFamily("HarmonnyHeiTi") - .lineHeight(21) + .height(21) .fontColor($r('sys.color.ohos_id_color_text_primary_activated')) - .fontSize(16) + .fontSize($r('sys.float.ohos_id_text_size_button1')) .onClick(() => { LogUtils.i(TAG, "dataRomingDialog onclick confim toggletype: " + JSON.stringify(this.isCon) + " for cardtype:" + JSON.stringify(this.cardType)); this.controller.close(); this.isMsg = true; - this.cardType == 0 ? enableCellularDataRoamingCardOne() : enableCellularDataRoamingCardTwo(); + this.cardType == 0 ? enableCellularDataRoamingCardOne() : enableCellularDataRoamingCardTwo(); }) } - .margin({ top: 18 }) + .margin({ top: 8 }) + .height(56) + .padding({top: 12}) } - .height(183) .padding({ left: 24, right: 24 }) .borderRadius(20) } diff --git a/mobiledatasettings/src/main/ets/common/components/subHeader.ets b/mobiledatasettings/src/main/ets/common/components/subHeader.ets index e7fb423..b501edd 100644 --- a/mobiledatasettings/src/main/ets/common/components/subHeader.ets +++ b/mobiledatasettings/src/main/ets/common/components/subHeader.ets @@ -14,7 +14,7 @@ */ @Component export struct SubHeader { - @State titleContent: any = ''; + @State titleContent: Resource = $r('app.string.mobile_data_card1'); @Prop subTitleContent: string; titleContenet() { diff --git a/mobiledatasettings/src/main/ets/common/model/getCellularDataRoamingEnabledApi.ets b/mobiledatasettings/src/main/ets/common/model/getCellularDataRoamingEnabledApi.ets index 5cf326b..3925613 100644 --- a/mobiledatasettings/src/main/ets/common/model/getCellularDataRoamingEnabledApi.ets +++ b/mobiledatasettings/src/main/ets/common/model/getCellularDataRoamingEnabledApi.ets @@ -17,7 +17,7 @@ * @file: Move data interface call */ -import { telephonyData } from './api'; +import telephonyData from '@ohos.telephony.data'; import radio from '@ohos.telephony.radio'; import LogUtils from '../utils/LogUtils' diff --git a/mobiledatasettings/src/main/ets/common/model/getPreferredNetworkModeApi.ets b/mobiledatasettings/src/main/ets/common/model/getPreferredNetworkModeApi.ets index 45612b4..c82e011 100644 --- a/mobiledatasettings/src/main/ets/common/model/getPreferredNetworkModeApi.ets +++ b/mobiledatasettings/src/main/ets/common/model/getPreferredNetworkModeApi.ets @@ -16,7 +16,7 @@ /** * @file: Network mode interface */ -import {radio} from './api'; +import radio from '@ohos.telephony.radio'; import LogUtils from '../utils/LogUtils' const TAG = "getPreferredNetworkModelApi" diff --git a/mobiledatasettings/src/main/ets/common/model/getSimStateApi.ets b/mobiledatasettings/src/main/ets/common/model/getSimStateApi.ets index 9be8041..b1044e2 100644 --- a/mobiledatasettings/src/main/ets/common/model/getSimStateApi.ets +++ b/mobiledatasettings/src/main/ets/common/model/getSimStateApi.ets @@ -17,8 +17,7 @@ * @file: Obtaining card status */ -import { sim } from './api'; -import LogUtils from '../utils/LogUtils' +import sim from '@ohos.telephony.sim'; const TAG = "GetSimStateApi" diff --git a/mobiledatasettings/src/main/ets/common/model/getSimTelephoneNumberApi.ets b/mobiledatasettings/src/main/ets/common/model/getSimTelephoneNumberApi.ets index 8776c5d..e65ec6d 100644 --- a/mobiledatasettings/src/main/ets/common/model/getSimTelephoneNumberApi.ets +++ b/mobiledatasettings/src/main/ets/common/model/getSimTelephoneNumberApi.ets @@ -17,7 +17,7 @@ * @file: Interface for obtaining the card number */ -import { sim } from './api'; +import sim from '@ohos.telephony.sim'; /** * Get cardOnePhoneNumber diff --git a/mobiledatasettings/src/main/ets/common/model/setPreferredNetworkApi.ets b/mobiledatasettings/src/main/ets/common/model/setPreferredNetworkApi.ets index 02c29c4..7dfbb49 100644 --- a/mobiledatasettings/src/main/ets/common/model/setPreferredNetworkApi.ets +++ b/mobiledatasettings/src/main/ets/common/model/setPreferredNetworkApi.ets @@ -16,8 +16,8 @@ /** * @file: Network mode interface */ -import { radio } from './api'; -import LogUtils from '../utils/LogUtils' +import radio from '@ohos.telephony.radio'; +import LogUtils from '../utils/LogUtils'; const TAG = "setPreferredNetworkModelApi" diff --git a/mobiledatasettings/src/main/ets/pages/index.ets b/mobiledatasettings/src/main/ets/pages/index.ets index 039cb68..6fda50c 100644 --- a/mobiledatasettings/src/main/ets/pages/index.ets +++ b/mobiledatasettings/src/main/ets/pages/index.ets @@ -25,8 +25,6 @@ import { getSimCardOnePhoneNumber, getSimCardTwoPhoneNumber } from '../common/mo import { isCellularDataRoamingEnabledCardOne, isCellularDataRoamingEnabledCardTwo, - enableCellularDataRoaming, - disableCellularDataRoaming, getSupportNetwork } from '../common/model/getCellularDataRoamingEnabledApi'; import { setPreferredNetwork } from '../common/model/setPreferredNetworkApi'; @@ -47,10 +45,9 @@ const TAG = "Index"; @Component struct Index { scroller: Scroller = new Scroller(); - @State byValueWLMS: any = publiccontent.strings.fourAuto; - @State publicheader: any = publiccontent.strings.mobileData; + @State byValueWLMS: Resource = publiccontent.strings.fourAuto; + @State publicheader: Resource = publiccontent.strings.mobileData; @State isLoading: boolean = true; - @State simState: string = ''; @State moisBtn: boolean = true; @State isBtn: boolean = true; @State gqBtn: boolean = true; @@ -71,7 +68,7 @@ struct Index { @State simStateStatusCardTwo: boolean = false; @State ControlswitchWLMS: boolean = false; @State slotId: number = 0; - @State dialogTitle: any = publiccontent.strings.preferredNetworkMode; + @State dialogTitle: Resource = publiccontent.strings.preferredNetworkMode; setCache_cun_name = 'DISTRIBUTEDDATA_CUN_NAME'; setCache_wl_name = 'SETCACHE_WL_NAME'; @State enable5g: boolean = false; @@ -105,7 +102,7 @@ struct Index { * This interface is used to obtain sim cardOne status */ getSimStateDataCardOne() { - getSimStateCardOne().then((res: any) => { + getSimStateCardOne().then((res: number) => { LogUtils.i(TAG, "getSimStateData Card1 :success " + JSON.stringify(res)) const simState = { SIM_STATE_UNKNOWN: 0, @@ -115,7 +112,6 @@ struct Index { SIM_STATE_READY: 4, SIM_STATE_LOADED: 5 }; - this.simState = res; if (res == simState.SIM_STATE_LOADED || res == simState.SIM_STATE_READY) { this.simStateStatusCardOne = true; } else { @@ -131,7 +127,7 @@ struct Index { * This interface is used to obtain sim cardTwo status */ getSimStateDataCardTwo() { - getSimStateCardTwo().then((res: any) => { + getSimStateCardTwo().then((res: number) => { LogUtils.i(TAG, "getSimState Card2 :success then" + JSON.stringify(res)); const simState = { SIM_STATE_UNKNOWN: 0, @@ -217,7 +213,7 @@ struct Index { } isImsSwitchEnabled(slotId) { - call.isImsSwitchEnabled(slotId).then((res: any) => { + call.isImsSwitchEnabled(slotId).then((res: boolean) => { if (slotId) { this.enableISM2 = res; LogUtils.i(TAG, "isImsSwitchEnable enable 1:" + JSON.stringify(this.enableISM2)); @@ -225,6 +221,15 @@ struct Index { this.enableISM = res; LogUtils.i(TAG, "isImsSwitchEnable enable 0:" + JSON.stringify(this.enableISM)); } + }).catch((err) => { + if (slotId) { + this.enableISM2 = true; + LogUtils.i(TAG, "isImsSwitchEnable err 1:" + JSON.stringify(this.enableISM2)); + } else { + this.enableISM = true; + LogUtils.i(TAG, "isImsSwitchEnable err 0:" + JSON.stringify(this.enableISM)); + } + LogUtils.i(TAG, "isImsSwitchEnabled card catch:" + JSON.stringify(err)); }); } @@ -309,7 +314,6 @@ struct Index { .fontFamily('HarmonyHeiTi') .lineHeight(22) .fontColor($r('app.color.font_color_182431')) - .opacity(this.isDataEnable ? 0.9 : 0.6) } Row() { @@ -356,7 +360,7 @@ struct Index { }) .height(90) .width("100%") - .borderRadius(24) + .borderRadius(16) .backgroundColor($r("sys.color.ohos_id_color_foreground_contrary")) .opacity((this.simStateStatusCardOne || this.simStateStatusCardTwo) ? 1 : 0.4) @@ -403,7 +407,7 @@ struct Index { bottom: 4 }) .width("100%") - .borderRadius(24) + .borderRadius(16) .backgroundColor($r("sys.color.ohos_id_color_foreground_contrary")) .opacity(this.simStateStatusCardOne ? 1 : 0.4) @@ -455,7 +459,7 @@ struct Index { bottom: 4 }) .width("100%") - .borderRadius(24) + .borderRadius(16) .backgroundColor($r("sys.color.ohos_id_color_foreground_contrary")) .opacity(this.simStateStatusCardTwo ? 1 : 0.4) .visibility(getMaxSimCount() === 2 ? Visibility.Visible : Visibility.Hidden) diff --git a/mobiledatasettings/src/main/module.json b/mobiledatasettings/src/main/module.json index 371b3a1..41b3ab0 100644 --- a/mobiledatasettings/src/main/module.json +++ b/mobiledatasettings/src/main/module.json @@ -32,13 +32,16 @@ ], "requestPermissions" : [ { - "name": "ohos.permission.GET_NETWORK_INFO" + "name": "ohos.permission.GET_NETWORK_INFO", + "reason": "$string:GET_NETWORK_INFO" }, { - "name": "ohos.permission.SET_TELEPHONY_STATE" + "name": "ohos.permission.SET_TELEPHONY_STATE", + "reason": "$string:SET_TELEPHONY_STATE" }, { - "name": "ohos.permission.GET_TELEPHONY_STATE" + "name": "ohos.permission.GET_TELEPHONY_STATE", + "reason": "$string:GET_TELEPHONY_STATE" } ] } diff --git a/mobiledatasettings/src/main/module.json5 b/mobiledatasettings/src/main/module.json5 index 719e8ea..1d027fd 100644 --- a/mobiledatasettings/src/main/module.json5 +++ b/mobiledatasettings/src/main/module.json5 @@ -45,15 +45,18 @@ "visible": true } ], - "requestPermissions" : [ + "requestPermissions": [ { - "name": "ohos.permission.GET_NETWORK_INFO" + "name": "ohos.permission.GET_NETWORK_INFO", + "reason": "$string:GET_NETWORK_INFO" }, { - "name": "ohos.permission.SET_TELEPHONY_STATE" + "name": "ohos.permission.SET_TELEPHONY_STATE", + "reason": "$string:SET_TELEPHONY_STATE" }, { - "name": "ohos.permission.GET_TELEPHONY_STATE" + "name": "ohos.permission.GET_TELEPHONY_STATE", + "reason": "$string:GET_TELEPHONY_STATE" } ] } diff --git a/mobiledatasettings/src/main/resources/base/element/string.json b/mobiledatasettings/src/main/resources/base/element/string.json index 78b1acc..af35dab 100644 --- a/mobiledatasettings/src/main/resources/base/element/string.json +++ b/mobiledatasettings/src/main/resources/base/element/string.json @@ -147,6 +147,22 @@ { "name": "confim_space", "value": "Confim" + }, + { + "name": "GET_NETWORK_INFO", + "value": "get network info" + }, + { + "name": "SET_TELEPHONY_STATE", + "value": "set telephony state" + }, + { + "name": "GET_TELEPHONY_STATE", + "value": "get telephony state" + }, + { + "name": "mobile_empty_string", + "value": " " } ] } \ No newline at end of file diff --git a/mobiledatasettings/src/main/resources/base/media/Refresh.png b/mobiledatasettings/src/main/resources/base/media/Refresh.png deleted file mode 100644 index 2a32ab7..0000000 Binary files a/mobiledatasettings/src/main/resources/base/media/Refresh.png and /dev/null differ diff --git a/mobiledatasettings/src/main/resources/base/media/back.png b/mobiledatasettings/src/main/resources/base/media/back.png deleted file mode 100644 index 0243569..0000000 Binary files a/mobiledatasettings/src/main/resources/base/media/back.png and /dev/null differ diff --git a/mobiledatasettings/src/main/resources/base/media/cancel_icon.png b/mobiledatasettings/src/main/resources/base/media/cancel_icon.png deleted file mode 100644 index 54ea0c9..0000000 Binary files a/mobiledatasettings/src/main/resources/base/media/cancel_icon.png and /dev/null differ diff --git a/mobiledatasettings/src/main/resources/base/media/del.png b/mobiledatasettings/src/main/resources/base/media/del.png deleted file mode 100644 index 4a6454b..0000000 Binary files a/mobiledatasettings/src/main/resources/base/media/del.png and /dev/null differ diff --git a/mobiledatasettings/src/main/resources/base/media/determine_icon.png b/mobiledatasettings/src/main/resources/base/media/determine_icon.png deleted file mode 100644 index 3e194ca..0000000 Binary files a/mobiledatasettings/src/main/resources/base/media/determine_icon.png and /dev/null differ diff --git a/mobiledatasettings/src/main/resources/base/media/icon.png b/mobiledatasettings/src/main/resources/base/media/icon.png deleted file mode 100644 index ce307a8..0000000 Binary files a/mobiledatasettings/src/main/resources/base/media/icon.png and /dev/null differ diff --git a/mobiledatasettings/src/main/resources/base/media/img.png b/mobiledatasettings/src/main/resources/base/media/img.png deleted file mode 100644 index 5b80806..0000000 Binary files a/mobiledatasettings/src/main/resources/base/media/img.png and /dev/null differ diff --git a/mobiledatasettings/src/main/resources/base/media/img_1.png b/mobiledatasettings/src/main/resources/base/media/img_1.png deleted file mode 100644 index 92a552b..0000000 Binary files a/mobiledatasettings/src/main/resources/base/media/img_1.png and /dev/null differ diff --git a/mobiledatasettings/src/main/resources/base/media/message_icon.png b/mobiledatasettings/src/main/resources/base/media/message_icon.png deleted file mode 100644 index a855723..0000000 Binary files a/mobiledatasettings/src/main/resources/base/media/message_icon.png and /dev/null differ diff --git a/mobiledatasettings/src/main/resources/base/media/more_icon.png b/mobiledatasettings/src/main/resources/base/media/more_icon.png deleted file mode 100644 index 11f7017..0000000 Binary files a/mobiledatasettings/src/main/resources/base/media/more_icon.png and /dev/null differ diff --git a/mobiledatasettings/src/main/resources/base/media/radio.svg b/mobiledatasettings/src/main/resources/base/media/radio.svg deleted file mode 100644 index 01882a1..0000000 --- a/mobiledatasettings/src/main/resources/base/media/radio.svg +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/mobiledatasettings/src/main/resources/base/media/radio_checked.svg b/mobiledatasettings/src/main/resources/base/media/radio_checked.svg deleted file mode 100644 index f7de110..0000000 --- a/mobiledatasettings/src/main/resources/base/media/radio_checked.svg +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/mobiledatasettings/src/main/resources/base/media/right.png b/mobiledatasettings/src/main/resources/base/media/right.png deleted file mode 100644 index 633f04b..0000000 Binary files a/mobiledatasettings/src/main/resources/base/media/right.png and /dev/null differ diff --git a/mobiledatasettings/src/main/resources/zh_CN/element/string.json b/mobiledatasettings/src/main/resources/zh_CN/element/string.json index a81dfef..ae740d4 100644 --- a/mobiledatasettings/src/main/resources/zh_CN/element/string.json +++ b/mobiledatasettings/src/main/resources/zh_CN/element/string.json @@ -147,6 +147,22 @@ { "name": "confim_space", "value": "确 定" + }, + { + "name": "GET_NETWORK_INFO", + "value": "获取网络信息权限" + }, + { + "name": "SET_TELEPHONY_STATE", + "value": "设置卡的状态" + }, + { + "name": "GET_TELEPHONY_STATE", + "value": "获取卡的状态" + }, + { + "name": "mobile_empty_string", + "value": " " } ] } \ No newline at end of file diff --git a/simcardmanagement/src/main/ets/common/components/back.ets b/simcardmanagement/src/main/ets/common/components/back.ets deleted file mode 100644 index 98e9071..0000000 --- a/simcardmanagement/src/main/ets/common/components/back.ets +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import router from '@system.router'; - -@Component -export default struct Back { - @State head: string = ''; - @State isChange: boolean = false; - @State isShow: boolean = false; - @State isShow2: boolean = false; - - deleteClick() { - this.isChange = !this.isChange; - }; - - build() { - Flex({ alignContent: FlexAlign.Center }) { - Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { - Image($r('app.media.back')) - .width('40vp') - .height('40vp') - .margin({ right: '10vp' }) - .onClick(() => { - router.back(); - }) - Text(this.head) - .fontSize('32vp') - .fontWeight(500) - } - .width('100%') - }.padding({ left: '24vp', top: '24vp' }) - .width('100%') - .backgroundColor('#fff') - } - - aboutToAppear() { - }; - - onPageShow() { - }; - - onPageHide() { - }; -} - diff --git a/simcardmanagement/src/main/ets/common/components/cardInfomation.ets b/simcardmanagement/src/main/ets/common/components/cardInfomation.ets index a146fbc..a60d8e0 100644 --- a/simcardmanagement/src/main/ets/common/components/cardInfomation.ets +++ b/simcardmanagement/src/main/ets/common/components/cardInfomation.ets @@ -12,71 +12,54 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import UpdataInfo from './dialog/upDataInfo' -import StopSim from './dialog/stopSim' -import EditSimInfo from './dialog/editSimInfo' -import simServiceProxy from '../../model/simServiceProxy' -import radioServiceProxy from '../../model/radioServiceProxy' -import { registerSimStateChange, getMaxSimCount } from '../../model/registerSimStateApi' +import UpdataInfo from './dialog/upDataInfo'; +import StopSim from './dialog/stopSim'; +import EditSimInfo from './dialog/editSimInfo'; +import simServiceProxy from '../../model/simServiceProxy'; +import radioServiceProxy from '../../model/radioServiceProxy'; +import { registerSimStateChange, getMaxSimCount } from '../../model/registerSimStateApi'; import dataServiceProxy from '../../model/dataServiceProxy'; -import LogUtils from '../../common/utils/LogUtils' +import LogUtils from '../../common/utils/LogUtils'; +import SimStateConst from '../utils/SimStateConst'; +import OperaNameStruct from '../struct/operaNameStruct'; +import SubscriberManager from '../utils/SubscriberManager'; const TAG = "cardInformation" +class CardInfoStruct { + id + title + isOpened + disabled + name + info + isSimCardClosed +} + @Component export default struct eSimSet { - @State list: any = [ - { - id: 0, - title: $r('app.string.sim_card_one_no_space'), - isOpened: true, - disabled: true, - name: $r('app.string.sim_null_character'), - info: '' - }, - { - id: 1, - title: $r('app.string.sim_card_two_no_space'), - isOpened: true, - disabled: true, - name: $r('app.string.sim_null_character'), - info: '' - } - ]; -/* @State eSimCard: any = - { - title: '卡2', - subTitle: 'eSIM', - name: '添加eSIM', - info: '2G/3G/4G/5G' - };*/ + @Link list: Array; @State flowCardId: number = 1; @State phone1Number: string = ''; @State phone2Number: string = ''; - @State title: any = ''; - @State curEditList : any = []; + @State title: Resource = $r('app.string.sim_card_one_no_space'); + @State curEditList: CardInfoStruct = new CardInfoStruct(); @State isSimCardClosed: boolean = true; @State simName: string = ''; @State phoneNumber: string = ''; - @State simId: string = ''; - @State index: number = 0; - @State storage: any = []; @State isChange: boolean = true; @State diaLing: number = 0; @State upisChange: boolean = true; @State isCancel: boolean = false; - @State isCard: boolean = true; - @Link isCardChange: boolean; - @State listIndex: number = 0; - @State upDataTitle: any = ''; - @State card1: boolean = true; - @State card2: boolean = true; + @Link isCardChange: boolean; + @State upDataTitle: Resource = $r('app.string.sim_card_one_no_space'); @State isStop1: boolean = true; @State isStop2: boolean = true; - @Link simCardStop: boolean; + @State simCardStop: boolean = false; @Link changeCard: boolean; @Link isCardChange2: boolean; - @Link defaultSetString: any; + @Link defaultSetString: Resource; + @StorageLink("operatorName") @Watch('updateOperatorName') operatorRes: OperaNameStruct = new OperaNameStruct(); timer = null; SIM_CARD_DEFAULT = 'sim_card_management_card_default_call'; SIM_CARD_INFO = 'sim_card_management_storage_card_info'; @@ -121,24 +104,29 @@ export default struct eSimSet { } }), alignment: DialogAlignment.Bottom, autoCancel: false, - offset: { dx: 0, dy: -30 } + offset: { dx: 0, dy: -16 } }) stopSim: CustomDialogController = new CustomDialogController({ - builder: StopSim({ curEditList: this.curEditList, title: this.title, isChange: $isChange, cancel: (isChange) => { - this.isCancel = true; - if (this.curEditList.id === 0) { - this.list[0].isOpened = true; - } else { - this.list[1].isOpened = true; - }; - this.simCardStop = isChange - }, + builder: StopSim({ + curEditList: this.curEditList, + title: this.title, + isChange: $isChange, + cancel: (isChange) => { + this.isCancel = true; + if (this.curEditList.id === 0) { + this.list[0].isOpened = true; + } else { + this.list[1].isOpened = true; + }; + this.simCardStop = isChange; + }, action: (stop) => { this.defaultSetString = $r('app.string.sim_null_character'); if (this.curEditList.id === 0) { this.setSimActive(0, false) this.list[0].name = $r('app.string.sim_not_enabled'); this.isStop1 = false; + this.list[0].isOpened = false; this.isStop2 = true; this.changeCard = false; this.isCardChange = false @@ -146,6 +134,7 @@ export default struct eSimSet { this.changeCard = true; this.setSimActive(1, false) this.list[1].name = $r('app.string.sim_not_enabled'); + this.list[1].isOpened = false; this.isStop1 = true; this.isStop2 = false; this.isCardChange = true; @@ -154,7 +143,7 @@ export default struct eSimSet { }), alignment: DialogAlignment.Bottom, autoCancel: false, - offset: { dx: 0, dy: -30 } + offset: { dx: 0, dy: -16 } }) updataInfo: CustomDialogController = new CustomDialogController({ builder: UpdataInfo({ title: this.upDataTitle, isChange: this.upisChange }), @@ -188,6 +177,7 @@ export default struct eSimSet { if (!boolean) { }; this.upisChange = boolean; + item.isOpened = boolean; }; UpdataInfo(v) { @@ -203,26 +193,18 @@ export default struct eSimSet { * Get the customized mobile phone number set by the user */ getShowNumber(slotId) { - simServiceProxy.getShowNumber(slotId).then((res: any) => { + simServiceProxy.getShowNumber(slotId).then((res: string) => { if (!slotId) { if (res === 'null') { this.getPhoneNumber(0) } else { - if (slotId) { - this.phone2Number = res; - } else { - this.phone1Number = res; - } + this.phone1Number = res; } } else { if (res === 'null') { this.getPhoneNumber(1) } else { - if (slotId) { - this.phone2Number = res; - } else { - this.phone1Number = res; - } + this.phone2Number = res; } }; }).catch((err) => { @@ -274,30 +256,39 @@ export default struct eSimSet { */ hasSimCard(slotId) { simServiceProxy.hasSimCard(slotId).then((res: boolean) => { - this.isSimCardClosed = res; + LogUtils.i(TAG, "getSimState: hasSimCard card : " + JSON.stringify(slotId) + " " + JSON.stringify(res)); + this.list[slotId].isSimCardClosed = res; + this.list[slotId] = { ...this.list[slotId] } this.isChange = !this.isChange; }).catch((err) => { }) } + updateOperatorName() { + this.list[this.operatorRes.CUR_SLOT_ID].name = this.operatorRes.CUR_PLMN; + this.hasSimCard(0); + this.hasSimCard(1); + this.onInit(); + this.list[this.operatorRes.CUR_SLOT_ID] = { ...this.list[this.operatorRes.CUR_SLOT_ID] } + } /** * Get card status */ async getSimState(slotId) { this.getSupportNetwork(slotId); this.hasSimCard(slotId); - this.isSimActive(slotId); simServiceProxy.getSimState(slotId).then((res: number) => { - if (![4, 5].indexOf(res)) { + LogUtils.i(TAG, "getSimstate: id" + JSON.stringify(slotId) + JSON.stringify(res)); + if (res === SimStateConst.SIM_STATE_READY || res === SimStateConst.SIM_STATE_LOADED) { this.list[slotId].disabled = true; this.list[slotId].isOpened = true; this.getShowName(slotId); this.getShowNumber(slotId); - } else if (![2, 3].indexOf(res)) { + } else if (res === SimStateConst.SIM_STATE_NOT_READY || res === SimStateConst.SIM_STATE_LOCKED) { this.list[slotId].name = $r('app.string.sim_no_service'); this.list[slotId].isOpened = false; this.getShowNumber(slotId); - } else if (![1].indexOf(res) && !this.isSimCardClosed) { + } else if (res === SimStateConst.SIM_STATE_NOT_PRESENT) { this.list[slotId].name = $r('app.string.sim_no_card_inserted'); this.list[slotId].isOpened = false; if (slotId) { @@ -307,11 +298,10 @@ export default struct eSimSet { } this.list[slotId].disabled = false; this.list[slotId].info = '4G/3G/2G'; - } else if (![-1].indexOf(res)) { + } else { this.list[slotId].info = '4G/3G/2G'; this.list[slotId].disabled = false; this.list[slotId].isOpened = false; - this.list[slotId].isOpened = false; if (slotId) { this.phone2Number = ''; } else { @@ -352,7 +342,7 @@ export default struct eSimSet { } else { this.phone2Number = res; } - }).catch((err) => { + }).catch(() => { this.phone2Number = ''; }) } @@ -376,25 +366,32 @@ export default struct eSimSet { */ isSimActive(slotId) { simServiceProxy.isSimActive(slotId).then((res) => { - if (!res && this.isSimCardClosed) { + LogUtils.i(TAG, "isSimActive id" + JSON.stringify(slotId) + " " + JSON.stringify(res)); + if (!res && this.list[slotId].isSimCardClosed) { this.list[slotId].isOpened = false; - this.list[slotId].name = $r('app.string.sim_not_enabled'); + this.list[slotId].name = $r('app.string.not_set'); this.list[slotId].info = '4G/3G/2G'; + } else if (res && this.list[slotId].isSimCardClosed) { + this.list[slotId].isOpened = true; + this.getShowName(slotId); + this.getShowNumber(slotId); + this.list[slotId] = { ...this.list[slotId] }; } }).catch((err) => { this.list[slotId].isOpened = false; - }) + }); } getSupportNetwork(slotId) { radioServiceProxy.getSupportNetwork(slotId).then((res) => { + LogUtils.i(TAG, "4g/3g/2g/:" + JSON.stringify(slotId) + " " + JSON.stringify(res)); if (res) { this.list[slotId].info = '5G/4G/3G/2G'; } else { this.list[slotId].info = '4G/3G/2G'; } }).catch((err) => { - }) + }); } /** @@ -418,20 +415,26 @@ export default struct eSimSet { addRegisterSimStateChange(slotId) { registerSimStateChange(slotId, async () => { this.getSimState(slotId); - this.isChange = !this.isChange + this.isChange = !this.isChange; + this.simCardStop = this.list[0].isOpened && this.list[1].isOpened; + this.list[slotId] = { ...this.list[slotId] }; + this.editSimInfo.close(); }) } setDefaultDataSlotId(slotId) { - dataServiceProxy.setDefaultDataSlotId(slotId) + dataServiceProxy.setDefaultDataSlotId(slotId); } aboutToAppear() { + LogUtils.i(TAG, "aboutToAppear"); this.onInit(); if (getMaxSimCount() === 2) { this.addRegisterSimStateChange(1); + this.isSimActive(1); } this.addRegisterSimStateChange(0); + this.isSimActive(0); this.isChange = !this.isChange; } @@ -441,29 +444,49 @@ export default struct eSimSet { Row() { Stack() { Image($r('app.media.phone')).width(62).height(42) - Text(this.list[0].title).fontSize('12vp').fontColor('#333333') - .align(Alignment.Start) + Text(this.list[0].title) + .fontSize('12vp') + .fontColor('#333333') .lineHeight(21) .fontWeight(FontWeight.Regular) .fontFamily("HarmonyHeiTi") + .margin({ right: 30 }) } Column() { - Text(this.list[0].name).fontSize('16vp').margin({ - bottom: 2 - }).fontFamily("HarmonyHeiTi").fontWeight(FontWeight.Medium) + Text(this.list[0].name) + .fontSize('16vp') + .margin({ + bottom: 2 + }) + .fontFamily("HarmonyHeiTi") + .fontWeight(FontWeight.Medium) .lineHeight(22) - Text(this.phone1Number).fontColor('#555').fontSize('14vp').margin({ bottom: this.phone2Number ? 0 : 2 }) - .lineHeight(19).fontFamily("HarmonyHeiTi").fontWeight(FontWeight.Regular) - Text(this.list[0].info).fontColor(this.isChange ? '#555' : '#555').fontSize('14vp') - .lineHeight(19).fontFamily("HarmonyHeiTi").fontWeight(FontWeight.Regular) + Text(this.phone1Number) + .fontColor('#555') + .fontSize('14vp') + .margin({ bottom: this.phone2Number ? 0 : 2 }) + .lineHeight(19) + .fontFamily("HarmonyHeiTi") + .fontWeight(FontWeight.Regular) + Text(this.list[0].info) + .fontColor(this.isChange ? '#555' : '#555') + .fontSize('14vp') + .lineHeight(19) + .fontFamily("HarmonyHeiTi") + .fontWeight(FontWeight.Regular) } .margin({ left: 16 }) + .opacity(this.list[0].isOpened ? 1 : 0.4) - Image($r('app.media.redact')).width('15vp').height('15vp') + Image($r('app.media.redact')) + .width('15vp') + .height('15vp') .onClick(() => { this.edit(this.list[0]) - }).margin({ left: 20 }).enabled(this.list[0].isOpened) + }) + .margin({ left: 20 }) + .enabled(this.list[0].isOpened) } Row() { @@ -522,7 +545,7 @@ export default struct eSimSet { }) } } - .opacity(this.list[0].isOpened ? 1 : 0.4) + .opacity(this.list[0].isOpened ? 1 : 0.6) .enabled(this.list[0].disabled) .padding({ left: 12, @@ -532,10 +555,9 @@ export default struct eSimSet { }) .height(104) .width("100%") - .borderRadius($r('app.float.radius_24')) + .borderRadius($r('app.float.radius_16')) .backgroundColor($r("sys.color.ohos_id_color_foreground_contrary")) - Column() { } .height(16) @@ -545,28 +567,48 @@ export default struct eSimSet { Row() { Stack() { Image($r('app.media.phone')).width(62).height(42) - Text(this.list[1].title).fontSize('12vp').fontColor('#333333') + Text(this.list[1].title) + .fontSize('12vp') + .fontColor('#333333') .align(Alignment.Start) .lineHeight(21) .fontWeight(FontWeight.Regular) .fontFamily("HarmonyHeiTi") + .margin({ right: 30 }) } Column() { - Text(this.list[1].name).fontSize('16vp').margin({ bottom: 2 }) - .fontFamily("HarmonyHeiTi").fontWeight(FontWeight.Medium) + Text(this.list[1].name) + .fontSize('16vp') + .margin({ bottom: 2 }) + .fontFamily("HarmonyHeiTi") + .fontWeight(FontWeight.Medium) .lineHeight(22) - Text(this.phone2Number).fontColor('#555').fontSize('14vp').margin({ bottom: this.phone2Number ? 0 : 2 }) - .lineHeight(19).fontFamily("HarmonyHeiTi").fontWeight(FontWeight.Regular) - Text(this.list[1].info).fontColor(this.isChange ? '#555' : '#555').fontSize('14vp') - .lineHeight(19).fontFamily("HarmonyHeiTi").fontWeight(FontWeight.Regular) + Text(this.phone2Number) + .fontColor('#555') + .fontSize('14vp') + .margin({ bottom: this.phone2Number ? 0 : 2 }) + .lineHeight(19) + .fontFamily("HarmonyHeiTi") + .fontWeight(FontWeight.Regular) + Text(this.list[1].info) + .fontColor(this.isChange ? '#555' : '#555') + .fontSize('14vp') + .lineHeight(19) + .fontFamily("HarmonyHeiTi") + .fontWeight(FontWeight.Regular) } .margin({ left: 16 }) + .opacity(this.list[1].isOpened ? 1 : 0.4) - Image($r('app.media.redact')).width('15vp').height('15vp') + Image($r('app.media.redact')) + .width('12vp') + .height('12vp') .onClick(() => { this.edit(this.list[1]); - }).margin({ left: 20 }).enabled(this.list[1].isOpened) + }) + .margin({ left: 4 }) + .enabled(this.list[1].isOpened) } Row() { @@ -625,7 +667,8 @@ export default struct eSimSet { }) } } - .opacity(this.list[1].isOpened ? 1 : 0.4) + .height(104) + .opacity(this.list[1].isOpened ? 1 : 0.6) .enabled(this.list[1].disabled) .padding({ left: 12, @@ -635,7 +678,7 @@ export default struct eSimSet { }) .width("100%") .backgroundColor($r("sys.color.ohos_id_color_foreground_contrary")) - .borderRadius($r('app.float.radius_24')) + .borderRadius($r('app.float.radius_16')) } .width('100%') } diff --git a/simcardmanagement/src/main/ets/common/components/defaultCard.ets b/simcardmanagement/src/main/ets/common/components/defaultCard.ets index 31b635e..1b2acd5 100644 --- a/simcardmanagement/src/main/ets/common/components/defaultCard.ets +++ b/simcardmanagement/src/main/ets/common/components/defaultCard.ets @@ -19,7 +19,7 @@ @Component export default struct DefaultCard { @State cardTextBackgrounColor: string = " #0A59F7"; - @State cardName: any = ""; + @State cardName: Resource = $r('app.string.card_1'); @State cardTextColor: string = "#FFFFFF" build() { diff --git a/simcardmanagement/src/main/ets/common/components/dialog/defalutDialing.ets b/simcardmanagement/src/main/ets/common/components/dialog/defalutDialing.ets index 261e745..0c970b6 100644 --- a/simcardmanagement/src/main/ets/common/components/dialog/defalutDialing.ets +++ b/simcardmanagement/src/main/ets/common/components/dialog/defalutDialing.ets @@ -21,12 +21,12 @@ const TAG = "DefaultDialCard:" export default struct DefaultDialCard { controller: CustomDialogController; action: (cardname) => void; + @Link defaultSet: Resource; @State changeDefault: boolean = true; @State changeCard1: boolean = false; @State changeCard2: boolean = false; @State phoneNumber1: string = ''; @State phoneNumber2: string = ''; - @State defaultSetCard: any = ''; SIM_CARD_DEFAULT = 'sim_card_management_card_default_call'; SIM_CARD_KEYWORD = 'sim_card_keyword'; @@ -41,7 +41,7 @@ export default struct DefaultDialCard { this.phoneNumber2 = res; } }).catch((err) => { - }) + }); } /** @@ -56,47 +56,34 @@ export default struct DefaultDialCard { this.phoneNumber2 = res; } } else { - this.getPhoneNumber(slotId) + this.getPhoneNumber(slotId); } }).catch((err) => { - }) - } - - /** - * Get default voice - */ - getDefaultVoiceSlotId() { - simServiceProxy.getDefaultVoiceSlotId().then((res: string) => { - if (res == '0') { - this.changeCard1 = true; - this.changeCard2 = false; - this.changeDefault = false; - } else if (res == '1') { - this.changeCard1 = false; - this.changeCard2 = true; - this.changeDefault = false; - } else { - this.changeCard1 = false; - this.changeCard2 = false; - this.changeDefault = true; - } - }).catch((err) => { - }) + }); } /** * Set default voice */ setDefaultVoiceSlotId(slotId) { - simServiceProxy.setDefaultVoiceSlotId(slotId).catch((err) => { - }) + simServiceProxy.setDefaultVoiceSlotId(slotId).then((res) => { + if (res) { + if (slotId === -1) { + this.action($r('app.string.not_set')); + } else if (slotId === 0) { + this.action($r('app.string.sim_card_one_no_space')); + } else if (slotId === 1) { + this.action($r('app.string.sim_card_two_no_space')); + } + } + }).catch((err) => { + }); } aboutToAppear() { LogUtils.i(TAG, "aboutToAppear:") this.getShowNumber(0); this.getShowNumber(1); - this.getDefaultVoiceSlotId() } build() { @@ -111,19 +98,18 @@ export default struct DefaultDialCard { .fontFamily("HarmonyHeiTi") .align(Alignment.Start) Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { - Text($r('app.string.not_set')).fontSize(16) - .fontWeight(FontWeight.Medium) + Text($r('app.string.not_set')) + .fontSize($r('sys.float.ohos_id_text_size_body2')) + .fontWeight(FontWeight.Regular) .fontFamily("HarmonyHeiTi") .align(Alignment.Center | Alignment.Start) .lineHeight(21) - Image(this.changeDefault ? $r('app.media.ic_Radiobtn_on') : $r('app.media.ic_Radiobtn_off')).height(24).width(24) + Image(JSON.stringify(this.defaultSet) === JSON.stringify($r('app.string.not_set')) ? $r('app.media.ic_Radiobtn_on') : $r('app.media.ic_Radiobtn_off')) + .height(24) + .width(24) }.height(48) .onClick(() => { - this.action($r('app.string.not_set')); - this.setDefaultVoiceSlotId(-1) - this.changeCard1 = false; - this.changeCard2 = false; - this.changeDefault = true; + this.setDefaultVoiceSlotId(-1); this.controller.close(); }) @@ -131,8 +117,8 @@ export default struct DefaultDialCard { Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { Column() { Text($r('app.string.card_1')) - .fontSize(16) - .fontWeight(FontWeight.Medium) + .fontSize($r('sys.float.ohos_id_text_size_body2')) + .fontWeight(FontWeight.Regular) .fontFamily("HarmonyHeiTi") .align(Alignment.Start) .lineHeight(22) @@ -142,19 +128,17 @@ export default struct DefaultDialCard { .fontFamily("HarmonyHeiTi") .align(Alignment.Start) .lineHeight(19) - .fontColor('#555') + .fontColor($r('sys.color.ohos_id_color_text_secondary')) }.alignItems(HorizontalAlign.Start) Column() { - Image(this.changeCard1 ? $r('app.media.ic_Radiobtn_on') : $r('app.media.ic_Radiobtn_off')).height(24).width(24) + Image(JSON.stringify(this.defaultSet) == JSON.stringify($r('app.string.sim_card_one_no_space')) ? $r('app.media.ic_Radiobtn_on') : $r('app.media.ic_Radiobtn_off')) + .height(24) + .width(24) } }.height(64) .onClick(() => { - this.action($r('app.string.sim_card_one_no_space')); - this.changeCard1 = true; this.setDefaultVoiceSlotId(0) - this.changeCard2 = false; - this.changeDefault = false; this.controller.close(); }) @@ -162,8 +146,8 @@ export default struct DefaultDialCard { Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { Column() { Text($r('app.string.card_2')) - .fontSize(16) - .fontWeight(FontWeight.Medium) + .fontSize($r('sys.float.ohos_id_text_size_body2')) + .fontWeight(FontWeight.Regular) .fontFamily("HarmonyHeiTi") .align(Alignment.Start) .lineHeight(22) @@ -173,19 +157,17 @@ export default struct DefaultDialCard { .fontFamily("HarmonyHeiTi") .align(Alignment.Start) .lineHeight(19) - .fontColor('#555') + .fontColor($r('sys.color.ohos_id_color_text_secondary')) }.alignItems(HorizontalAlign.Start) Column() { - Image(this.changeCard2 ? $r('app.media.ic_Radiobtn_on') : $r('app.media.ic_Radiobtn_off')).height(24).width(24) + Image(JSON.stringify(this.defaultSet) == JSON.stringify($r('app.string.sim_card_two_no_space')) ? $r('app.media.ic_Radiobtn_on') : $r('app.media.ic_Radiobtn_off')) + .height(24) + .width(24) } }.height(64) .onClick(() => { - this.action($r('app.string.sim_card_two_no_space')); - this.changeCard1 = false; this.setDefaultVoiceSlotId(1) - this.changeCard2 = true; - this.changeDefault = false; this.controller.close(); }) @@ -195,7 +177,7 @@ export default struct DefaultDialCard { .fontSize('16vp') .fontWeight(FontWeight.Medium) .fontFamily("HarmonyHeiTi") - .fontColor('#2871d4') + .fontColor($r('sys.color.ohos_id_color_text_primary')) } .onClick(() => { this.controller.close(); diff --git a/simcardmanagement/src/main/ets/common/components/dialog/editSimInfo.ets b/simcardmanagement/src/main/ets/common/components/dialog/editSimInfo.ets index 6eaaa54..5cd2395 100644 --- a/simcardmanagement/src/main/ets/common/components/dialog/editSimInfo.ets +++ b/simcardmanagement/src/main/ets/common/components/dialog/editSimInfo.ets @@ -20,6 +20,16 @@ import { getString } from '../../utils/Utils' const TAG = "EditSimInfo" +class CardInfoStruct { + id + title + isOpened + disabled + name + info + isSimCardClosed +} + @CustomDialog export default struct EditSimInfo { controller: CustomDialogController; @@ -27,7 +37,7 @@ export default struct EditSimInfo { disabledState: true; inputVal: ''; isShow: true; - curEditList: any = []; + curEditList: CardInfoStruct = new CardInfoStruct(); MinLength: number = 0; MaxLength: number = 17; @State simName: string = ''; @@ -141,6 +151,7 @@ export default struct EditSimInfo { this.simName = value; LogUtils.i(TAG, "simName: " + JSON.stringify(this.simName)) }) + Divider().vertical(false).strokeWidth(0.5).color('#ccc') TextInput({ text: this.phoneNumber, placeholder: $r('app.string.sim_phone_number') }) .maxLength(15) .height(48) @@ -156,13 +167,14 @@ export default struct EditSimInfo { ; this.isChange = !this.isChange; }) + Divider().vertical(false).strokeWidth(0.5).color('#ccc') Flex({ justifyContent: FlexAlign.SpaceAround }) { Text($r('app.string.cancel')) .fontSize(16) .fontWeight(FontWeight.Medium) .fontFamily("HarmonyHeiTi") .lineHeight(21) - .fontColor('#2871d4') + .fontColor($r('sys.color.ohos_id_color_text_primary_activated')) .onClick(() => { this.controller.close(); this.phoneNumber = ''; @@ -171,6 +183,7 @@ export default struct EditSimInfo { Divider().vertical(true).height(0.5).strokeWidth(1).opacity(0.5) Text($r('app.string.confirm')) .fontSize(16) + .fontColor($r('sys.color.ohos_id_color_text_primary_activated')) .fontWeight(FontWeight.Medium) .fontFamily("HarmonyHeiTi") .lineHeight(21) @@ -212,14 +225,16 @@ export default struct EditSimInfo { } this.isChange = !this.isChange; this.controller.close() - }).fontColor(this.isChange ? '#2871d4' : '#2871d4') + }) + .fontColor(this.isChange ? '#2871d4' : '#2871d4') } .margin({ left: 12, right: 12, top: 18 }) .height(56) } } .height(216) + .padding({ left: 24, right: 24 }) .backgroundColor($r("sys.color.ohos_id_color_list_card_bg")) - .padding({ left: 12, right: 12 }) + .borderRadius(26) } } \ No newline at end of file diff --git a/simcardmanagement/src/main/ets/common/components/dialog/stopSim.ets b/simcardmanagement/src/main/ets/common/components/dialog/stopSim.ets index e7dfee9..db7a199 100644 --- a/simcardmanagement/src/main/ets/common/components/dialog/stopSim.ets +++ b/simcardmanagement/src/main/ets/common/components/dialog/stopSim.ets @@ -14,12 +14,22 @@ */ import { getString } from '../../utils/Utils' +class CardInfoStruct { + id + title + isOpened + disabled + name + info + isSimCardClosed +} + @CustomDialog export default struct StopSim { controller: CustomDialogController; action: (stop) => void; - curEditList: any = []; - title: any = ''; + curEditList: CardInfoStruct = new CardInfoStruct(); + title: Resource = $r('app.string.sim_card_one_no_space'); cancel: (boolean) => void; @State isChange: boolean = false; SIM_CARD_Change = 'sim_card_management_card_change_boolean'; @@ -39,10 +49,9 @@ export default struct StopSim { .fontSize($r('sys.float.ohos_id_text_size_body1')) .fontWeight(FontWeight.Regular) .textAlign(TextAlign.Start) - .height(56) Flex({ justifyContent: FlexAlign.SpaceAround }) { Text($r('app.string.cancel')) - .fontSize('16vp') + .fontSize($r('sys.float.ohos_id_text_size_button1')) .onClick(() => { this.isChange = true; this.controller.close(); @@ -52,9 +61,14 @@ export default struct StopSim { .fontFamily("HarmonnyHeiTi") .lineHeight(21) .fontColor($r('sys.color.ohos_id_color_text_primary_activated')) - Divider().vertical(true).height(1).strokeWidth(1).lineCap(LineCapStyle.Round).opacity(0.5) + Divider() + .vertical(true) + .height(1) + .strokeWidth(1) + .lineCap(LineCapStyle.Round) + .opacity(0.5) Text($r('app.string.stop_use')) - .fontSize('16vp') + .fontSize($r('sys.float.ohos_id_text_size_button1')) .onClick(() => { this.isChange = false; this.controller.close(); @@ -66,10 +80,11 @@ export default struct StopSim { .fontColor($r('sys.color.ohos_id_color_text_primary_activated')) } .height(56) - .margin({ top: 18 }) + .margin({ top: 8 }) + .padding({ top: 12 }) } } - .height(183) + .height(180) .padding({ left: 24, right: 24 }) } } diff --git a/simcardmanagement/src/main/ets/common/components/dialog/upDataInfo.ets b/simcardmanagement/src/main/ets/common/components/dialog/upDataInfo.ets index a7da171..80ef2b9 100644 --- a/simcardmanagement/src/main/ets/common/components/dialog/upDataInfo.ets +++ b/simcardmanagement/src/main/ets/common/components/dialog/upDataInfo.ets @@ -18,7 +18,7 @@ import { getString } from '../../utils/Utils' export default struct UpdataInfo { controller: CustomDialogController; action: () => void; - title: any = ''; + title: Resource = $r('app.string.sim_card_one_no_space'); cancel: () => void; isChange: boolean; diff --git a/simcardmanagement/src/main/ets/common/components/headComponent.ets b/simcardmanagement/src/main/ets/common/components/headComponent.ets index 6df1877..4cd5cd3 100644 --- a/simcardmanagement/src/main/ets/common/components/headComponent.ets +++ b/simcardmanagement/src/main/ets/common/components/headComponent.ets @@ -19,12 +19,12 @@ @Component export default struct HeadComponent { @State isTouch: boolean = false; - @State headName: any = ''; + @State headName: Resource = $r('app.string.sim_headName'); build() { Row() { Stack({ alignContent: Alignment.Center }) { - Image($r('app.media.back')) + Image($r('app.media.ic_back')) .width(24) .height(24) .fillColor($r("sys.color.ohos_id_color_primary")) @@ -46,14 +46,13 @@ export default struct HeadComponent { Text(this.headName) .fontSize(20) - .lineHeight(33) .fontFamily('HarmonyHeiTi-Bold') .fontWeight(FontWeight.Medium) - .fontColor($r('app.color.font_color_182431')) + .fontColor($r('sys.color.ohos_id_color_text_primary')) .maxLines(1) .textOverflow({ overflow: TextOverflow.Ellipsis }) .textAlign(TextAlign.Start) - .margin({ top: 13, bottom: 15 }); + .margin({ top: 15, bottom: 15 }); } .width("100%") .padding({ left: 12 }) diff --git a/simcardmanagement/src/main/ets/common/struct/operaNameStruct.ets b/simcardmanagement/src/main/ets/common/struct/operaNameStruct.ets new file mode 100644 index 0000000..6973d53 --- /dev/null +++ b/simcardmanagement/src/main/ets/common/struct/operaNameStruct.ets @@ -0,0 +1,8 @@ +export default class CardInfoStruct { + CUR_PLMN + CUR_PLMN_SHOW + CUR_SLOT_ID + CUR_SPN + CUR_SPN_SHOW + moduleName +} \ No newline at end of file diff --git a/simcardmanagement/src/main/ets/common/utils/SimStateConst.ets b/simcardmanagement/src/main/ets/common/utils/SimStateConst.ets new file mode 100644 index 0000000..56126c0 --- /dev/null +++ b/simcardmanagement/src/main/ets/common/utils/SimStateConst.ets @@ -0,0 +1,8 @@ +export default class SimStateConst { + public static SIM_STATE_UNKNOWN = 0; + public static SIM_STATE_NOT_PRESENT = 1; + public static SIM_STATE_LOCKED = 2; + public static SIM_STATE_NOT_READY = 3; + public static SIM_STATE_READY = 4; + public static SIM_STATE_LOADED = 5; +} \ No newline at end of file diff --git a/simcardmanagement/src/main/ets/common/utils/SubscriberManager.ets b/simcardmanagement/src/main/ets/common/utils/SubscriberManager.ets new file mode 100644 index 0000000..24963ee --- /dev/null +++ b/simcardmanagement/src/main/ets/common/utils/SubscriberManager.ets @@ -0,0 +1,50 @@ +import commonEvent from '@ohos.commonEvent'; +import LogUtils from './LogUtils' +let subscriber; +const TAG = "SubscriberManager" +const events = ['usual.event.SPN_INFO_CHANGED', 'usual.event.SIM_STATE_CHANGE']; + +export class SubscriberManager { + + /** + * Registered subscribers + */ + public async registerSubscriber() { + subscriber = await new Promise((resolve) => { + commonEvent.createSubscriber({ + events, + priority: 1000 + }, + (err, data) => { + resolve(data); + } + ); + }); + + commonEvent.subscribe(subscriber, (err, res) => { + LogUtils.i(TAG, "commonEvent subscribe 1 : %s" + JSON.stringify(res)); + if (err.code === 0) { + LogUtils.i(TAG, "commonEvent subscribe : %s" + JSON.stringify(res)); + if (!!res.parameters.CUR_PLMN) { + AppStorage.SetOrCreate("operatorName", res.parameters); + } + } else { + LogUtils.i(TAG, "commonEvent.subscribe err : %s" + JSON.stringify(err)); + } + }); + } + /** + * unsubscribe + */ + public unsubscribe() { + commonEvent.unsubscribe(subscriber, (err) => { + if (err.code !== 0) { + LogUtils.i(TAG, "commonEvent.unsubscribe err: %s" + JSON.stringify(err)) + } + }); + } +} + +let mSubscriberManager = new SubscriberManager(); + +export default mSubscriberManager as SubscriberManager; \ No newline at end of file diff --git a/simcardmanagement/src/main/ets/common/utils/Utils.ets b/simcardmanagement/src/main/ets/common/utils/Utils.ets index 506ac1e..4df5ce6 100644 --- a/simcardmanagement/src/main/ets/common/utils/Utils.ets +++ b/simcardmanagement/src/main/ets/common/utils/Utils.ets @@ -20,4 +20,3 @@ export function getString(value: Resource) { return globalThis.simCardAbilityContext.resourceManager.getStringSync(value); } - diff --git a/simcardmanagement/src/main/ets/model/radioServiceProxy.ets b/simcardmanagement/src/main/ets/model/radioServiceProxy.ets index e8427b9..3e97f62 100644 --- a/simcardmanagement/src/main/ets/model/radioServiceProxy.ets +++ b/simcardmanagement/src/main/ets/model/radioServiceProxy.ets @@ -36,7 +36,7 @@ let getSupportNetwork = function (slotId = 0) { LogUtils.i(TAG, "getSupportNetwork isNrSupported:" + isSupported); resolve(isSupported); } catch (error) { - LogUtils.i(TAG, "getSupportNetwork isNrSupported:catch" + JSON.stringify(error)); + LogUtils.i(TAG, "getSupportNetwork isNrSupported:catch" + JSON.stringify(error)); reject(error); } }); @@ -72,6 +72,31 @@ let getOperatorName = function (slotId = 0) { }); }; +/** + * Get show name + * + * @param {number} slotId - slot ID + * @return {Promise} + */ +export function getPrimarySlotId() { + return new Promise(function (resolve, reject) { + try { + radio.getPrimarySlotId((error, value) => { + if (error) { + LogUtils.i(TAG, "getPrimarySlotId error:" + JSON.stringify(error)); + reject(error); + } else { + LogUtils.i(TAG, "getPrimarySlotId data:" + JSON.stringify(value)); + resolve(value); + } + }); + } catch (error) { + LogUtils.i(TAG, "getPrimarySlotId catch:" + JSON.stringify(error)); + reject(error); + } + }); +} + export default { getSupportNetwork, getOperatorName diff --git a/simcardmanagement/src/main/ets/model/registerSimStateApi.ets b/simcardmanagement/src/main/ets/model/registerSimStateApi.ets index c6c981e..8c86468 100644 --- a/simcardmanagement/src/main/ets/model/registerSimStateApi.ets +++ b/simcardmanagement/src/main/ets/model/registerSimStateApi.ets @@ -17,7 +17,7 @@ * @file: registerSimStateApi */ -import { observer } from './api'; +import observer from '@ohos.telephony.observer'; import LogUtils from '../common/utils/LogUtils' import sim from '@ohos.telephony.sim'; @@ -33,7 +33,7 @@ export function registerSimStateChange(slotId, callBack) { return observer.on('simStateChange', { slotId: slotId }, (callStateInfo) => { - LogUtils.i(TAG, "registerSimStateChange: then" + JSON.stringify(callStateInfo)); + LogUtils.i(TAG, "registerSimStateChange: then" + "slotid: " + JSON.stringify(slotId) + " callstateinfo:" + JSON.stringify(callStateInfo)); callBack(callStateInfo); return callStateInfo }); diff --git a/simcardmanagement/src/main/ets/model/simServiceProxy.ets b/simcardmanagement/src/main/ets/model/simServiceProxy.ets index 9e039e5..3ae846b 100644 --- a/simcardmanagement/src/main/ets/model/simServiceProxy.ets +++ b/simcardmanagement/src/main/ets/model/simServiceProxy.ets @@ -59,16 +59,16 @@ export function hasSimCard(slotId = 0) { try { sim.hasSimCard(slotId, (error, data) => { if (error) { - LogUtils.i(TAG, "hasSimCard error:" + JSON.stringify(error)); + LogUtils.i(TAG, "hasSimCard error card : " + JSON.stringify(slotId) + " " + JSON.stringify(error)); reject(error); } else { - LogUtils.i(TAG, "hasSimCard data:" + JSON.stringify(data)); + LogUtils.i(TAG, "hasSimCard data card : " + JSON.stringify(slotId) + " " + JSON.stringify(data)); resolve(data); } ; }); } catch (error) { - LogUtils.i(TAG, "hasSimCard catch:" + JSON.stringify(error)); + LogUtils.i(TAG, "hasSimCard catch card : " + JSON.stringify(slotId) + " " + JSON.stringify(error)); reject(error); } }); @@ -135,15 +135,15 @@ export function isSimActive(slotId = 0) { try { sim.isSimActive(slotId, (error, value) => { if (error) { - LogUtils.i(TAG, "isSimActive error:" + JSON.stringify(error)); + LogUtils.i(TAG, "isSimActive error slotId: " + JSON.stringify(slotId) + " " + JSON.stringify(error)); reject(error); } else { - LogUtils.i(TAG, "isSimActive data:" + JSON.stringify(value)); + LogUtils.i(TAG, "isSimActive data slotId: " + JSON.stringify(slotId) + " " + JSON.stringify(value)); resolve(value); } }); } catch (error) { - LogUtils.i(TAG, "isSimActive catch:" + JSON.stringify(error)); + LogUtils.i(TAG, "isSimActive catch slotId: " + JSON.stringify(slotId) + " " + JSON.stringify(error)); reject(error); } }); @@ -160,15 +160,15 @@ export function getSimState(slotId = 0) { try { sim.getSimState(slotId, (error, value) => { if (error) { - LogUtils.i(TAG, "getSimState error:" + JSON.stringify(error)); + LogUtils.i(TAG, "getSimState card :" + JSON.stringify(slotId) + " error: " + JSON.stringify(error)); reject(error); } else { - LogUtils.i(TAG, "getSimState data:" + JSON.stringify(value)); + LogUtils.i(TAG, "getSimState data:" + JSON.stringify(slotId) + " data: " + JSON.stringify(value)); resolve(value); } }); } catch (error) { - LogUtils.i(TAG, "getSimState catch:" + JSON.stringify(error)); + LogUtils.i(TAG, "getSimState catch:" + JSON.stringify(slotId) + " catch: " + JSON.stringify(error)); reject(error); } }); @@ -209,15 +209,15 @@ export function setDefaultVoiceSlotId(slotId = 0) { try { sim.setDefaultVoiceSlotId(slotId, (error, data) => { if (error) { - LogUtils.i(TAG, "setDefaultVoiceSlotId error:" + JSON.stringify(error)); + LogUtils.i(TAG, "setDefaultVoiceSlotId error:" + JSON.stringify(slotId) + " " + JSON.stringify(error)); reject(error); } else { - LogUtils.i(TAG, "setDefaultVoiceSlotId data:" + JSON.stringify(data)); + LogUtils.i(TAG, "setDefaultVoiceSlotId data:" + JSON.stringify(slotId) + " " + JSON.stringify(data)); resolve(true); } }); } catch (error) { - LogUtils.i(TAG, "setDefaultVoiceSlotId catch:" + JSON.stringify(error)); + LogUtils.i(TAG, "setDefaultVoiceSlotId catch:" + JSON.stringify(slotId) + " " + JSON.stringify(error)); reject(error); } }); diff --git a/simcardmanagement/src/main/ets/pages/index.ets b/simcardmanagement/src/main/ets/pages/index.ets index 329a016..afa02d8 100644 --- a/simcardmanagement/src/main/ets/pages/index.ets +++ b/simcardmanagement/src/main/ets/pages/index.ets @@ -16,14 +16,16 @@ SIM_CARD_INFO */ import HeadComponent from '../common/components/headComponent' import CardInfomation from '../common/components/cardInfomation' -import CardSetData from '../common/config/cardSetData'; import SetFlowLimit from '../common/components/dialog/setFlowLimit' import DefaultDialCard from '../common/components/dialog/defalutDialing' -import cardInfoData from '../common/config/cardInfoData'; import dataServiceProxy from '../model/dataServiceProxy'; import simServiceProxy from '../model/simServiceProxy' import DefaultCard from '../common/components/defaultCard' import LogUtils from '../common/utils/LogUtils' +import { registerSimStateChange, getMaxSimCount } from '../model/registerSimStateApi' +import SubscriberManager from '../common/utils/SubscriberManager' +import { getPrimarySlotId } from '../model/radioServiceProxy' +import OperaNameStruct from '../common/struct/operaNameStruct'; export const CARD_HOT_PULL_PLUG = { HOT_PULL: 1, @@ -31,33 +33,55 @@ export const CARD_HOT_PULL_PLUG = { }; const TAG = "Index" +class CardInfoStruct { + id + title + isOpened + disabled + name + info + isSimCardClosed +} @Entry @Component struct Index { scroller: Scroller = new Scroller(); - @State simId: string = ''; + @State list: Array = [ + { + id: 0, + title: $r('app.string.sim_card_one_no_space'), + isOpened: false, + disabled: true, + name: $r('app.string.sim_null_character'), + info: '', + isSimCardClosed: false + }, + { + id: 1, + title: $r('app.string.sim_card_two_no_space'), + isOpened: false, + disabled: true, + name: $r('app.string.sim_null_character'), + info: '', + isSimCardClosed: false + } + ]; @State isShow: boolean = false; @State isShow2: boolean = false; private number1: string = ''; private number2: string = ''; - @State phoneNumber: boolean = false; - @State cardData: any = JSON.parse(JSON.stringify(CardSetData)); - @State isRegisterObserver: boolean = false; @State defaultDataChange: boolean = true; @State isStop: boolean = true; - @State defaultset: any = ''; - @State closeTransfer: boolean = false; - @State list: any = [ - JSON.parse(JSON.stringify(cardInfoData)), - JSON.parse(JSON.stringify(cardInfoData)) - ]; + @State defaultSet: Resource = $r('app.string.not_set'); + @State simActive: boolean = false; + @StorageLink("operatorName") @Watch('updateInfo') operatorInfo: OperaNameStruct = new OperaNameStruct(); SIM_CARD_STOP = 'sim_card_management_card_stop_boolean'; SIM_CARD_Change = 'sim_card_management_card_change_boolean'; SIM_CARD_DEFAULT = 'sim_card_management_card_default_call'; SIM_CARD_TRANSFER = 'sim_card_management_transfer'; SIM_CARD_TRANSFER2 = 'sim_card_management_transfer2'; - SHOW_CHANGE = 'sim_change_data' + SHOW_CHANGE = 'sim_change_data'; setFlowLimit: CustomDialogController = new CustomDialogController({ builder: SetFlowLimit({ change: this.defaultDataChange }), alignment: DialogAlignment.Bottom, @@ -65,18 +89,15 @@ struct Index { offset: { dx: 0, dy: -30 } }) defaultDialCard: CustomDialogController = new CustomDialogController({ - builder: DefaultDialCard({ action: (v) => { - this.defaultset = v; - }}), + builder: DefaultDialCard({ defaultSet: $defaultSet, + action: (v) => { + this.defaultSet = v; + } }), alignment: DialogAlignment.Bottom, autoCancel: false, - offset: { dx: 0, dy: -30 } + offset: { dx: 0, dy: -16 } }) - /* set(item) { - this.setFlowLimit.open(); - };*/ - defaultCard() { LogUtils.i(TAG, "onclick defaultDialCard open") this.defaultDialCard.open(); @@ -96,7 +117,7 @@ struct Index { } else { this.getPhoneNumber(slotId); } - }) + }); } /** @@ -116,45 +137,99 @@ struct Index { * Get the default voice sim card */ getDefaultVoiceSlotld() { - simServiceProxy.getDefaultVoiceSlotId().then((res: string) => { - if (res == '0') { - this.defaultset = $r('app.string.sim_card_one_no_space'); - } else if (res == '1') { - this.defaultset = $r('app.string.sim_card_two_no_space'); + simServiceProxy.getDefaultVoiceSlotId().then((res: number) => { + LogUtils.i(TAG, "isSimActive getDefaultVoiceSlotId:" + " " + JSON.stringify(res)); + if (res === 0 || res === 1) { + this.isSimActive(res); } else { - this.defaultset = $r('app.string.not_set'); + this.defaultSet = $r('app.string.not_set'); } + }).catch((err) => { + this.defaultSet = $r('app.string.not_set'); }) } + isSimActive(slotId) { + simServiceProxy.isSimActive(slotId).then((res: boolean) => { + LogUtils.i(TAG, "isSimActive simServiceProxy.isSimActive:" + JSON.stringify(slotId) + " " + JSON.stringify(res)); + this.simActive = res; + if (res) { + if (slotId === 0) { + this.defaultSet = $r('app.string.sim_card_one_no_space'); + } + else if (slotId === 1) { + this.defaultSet = $r('app.string.sim_card_two_no_space'); + } else { + this.defaultSet = $r('app.string.not_set'); + } + } else { + this.defaultSet = $r('app.string.not_set'); + } + }).catch((err) => { + this.defaultSet = $r('app.string.not_set'); + }) + } + + updateInfo() { + this.getShowNumber(0); + this.getShowNumber(1); + this.getDefaultVoiceSlotld(); + this.getDefaultDataSlotId(); + } + setDefaultDataSlotId(slotId) { dataServiceProxy.setDefaultDataSlotId(slotId) } aboutToAppear() { - LogUtils.i(TAG, "aboutToAppear") + LogUtils.i(TAG, "aboutToAppear:"); + SubscriberManager.registerSubscriber(); + + if (getMaxSimCount() >= 2) { + this.addRegisterSimStateChange(1); + } + this.addRegisterSimStateChange(0); } getDefaultDataSlotId() { - dataServiceProxy.getDefaultDataSlotId().then((res) => { - if (res === 1) { - this.defaultDataChange = false; - } else { - this.defaultDataChange = true; - } - }) + if (this.list[0].isSimCardClosed && this.list[1].isSimCardClosed) { + dataServiceProxy.getDefaultDataSlotId().then((res) => { + this.setDefaultDataChange(res); + }) + } else { + getPrimarySlotId().then((res) => { + LogUtils.i(TAG, "getPrimarySlotId: then: " + JSON.stringify(res)); + this.setDefaultDataChange(res); + }); + } + } + + setDefaultDataChange(res) { + if (res === 1) { + this.defaultDataChange = false; + } else { + this.defaultDataChange = true; + } } onPageShow() { - LogUtils.i(TAG, "onPageShow start ") - this.getShowNumber(0); - this.getShowNumber(1); - this.getDefaultVoiceSlotld(); - this.getDefaultDataSlotId(); - + LogUtils.i(TAG, "onPageShow start "); + this.updateInfo(); LogUtils.i(TAG, "onPageShow end ") } + addRegisterSimStateChange(slotId) { + registerSimStateChange(slotId, async (callStateInfo) => { + LogUtils.i(TAG, "registerSimStateChange:" + JSON.stringify(callStateInfo)); + this.updateInfo(); + this.defaultDialCard.close(); + }) + } + + aboutToDisappear() { + SubscriberManager.unsubscribe(); + } + build() { GridRow({ columns: { sm: 4, md: 8, lg: 12 }, gutter: { x: 12 } }) { GridCol({ span: { sm: 4, md: 8, lg: 8 }, offset: { sm: 0, md: 1, lg: 2 } }) { @@ -168,13 +243,13 @@ struct Index { .width("100%") CardInfomation({ - simCardStop: $isStop, + list: $list, changeCard: $defaultDataChange, phone1Number: this.number1, phone2Number: this.number2, isCardChange: $defaultDataChange, isCardChange2: $isShow, - defaultSetString: $defaultset, + defaultSetString: $defaultSet, }) Column() { @@ -187,16 +262,17 @@ struct Index { Text($r('app.string.default_mobile_data')).fontSize('16vp').fontFamily("HarmonyHeiTi").fontWeight(FontWeight.Medium).maxLines(1) } .opacity(this.isStop ? 1 : 0.4) + .opacity((this.list[0].isOpened && this.list[1].isOpened) ? 1 : 0.4) .align(Alignment.Center) Row() { DefaultCard({ cardName: $r('app.string.card_1'), cardTextBackgrounColor: this.defaultDataChange ? "#0A59F7" : "#FFFFFF", cardTextColor: this.defaultDataChange ? "#FFFFFF" : "#0A59F7" }) - .opacity(this.isStop ? 1 : 0.4) + .opacity((this.list[0].isOpened && this.list[1].isOpened) ? 1 : 0.4) .onClick(() => { LogUtils.i(TAG, "onclick defaultcard card one") - this.setDefaultDataSlotId(0) + this.setDefaultDataSlotId(0); this.defaultDataChange = !this.defaultDataChange; }) .margin({ right: 6 }) @@ -204,14 +280,14 @@ struct Index { DefaultCard({ cardName: $r('app.string.card_2'), cardTextBackgrounColor: this.defaultDataChange ? "#FFFFFF" : "#0A59F7", cardTextColor: this.defaultDataChange ? "#0A59F7" : "#FFFFFF" }) - .opacity(this.isStop ? 1 : 0.4) + .opacity((this.list[0].isOpened && this.list[1].isOpened) ? 1 : 0.4) .onClick(() => { LogUtils.i(TAG, "onclick defaultcard card two") - this.setDefaultDataSlotId(1) + this.setDefaultDataSlotId(1); this.defaultDataChange = !this.defaultDataChange; }) } - .enabled(this.isStop) + .enabled((this.list[0].isOpened && this.list[1].isOpened)) .margin({ right: 1 }) .width(148) .height(40) @@ -232,7 +308,8 @@ struct Index { }) .width("100%") .backgroundColor($r("sys.color.ohos_id_color_foreground_contrary")) - .borderRadius($r('app.float.radius_24')) + .opacity((this.list[0].isOpened && this.list[1].isOpened) ? 1 : 0.6) + .borderRadius($r('app.float.radius_16')) Column() { } @@ -242,21 +319,23 @@ struct Index { Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { Text($r('app.string.default_dial_card')).fontSize('16vp').fontFamily("HarmonyHeiTi").fontWeight(FontWeight.Medium).maxLines(1) .lineHeight(21) + .opacity((this.list[0].isOpened && this.list[1].isOpened) ? 1 : 0.4) + Row() { - Text(this.defaultset ? this.defaultset : $r('app.string.not_set')).fontSize(14).fontColor('#555').margin({ + Text(this.defaultSet ? this.defaultSet : $r('app.string.not_set')).fontSize(14).fontColor('#555').margin({ right: 5 }).lineHeight(19) .fontFamily("HarmonyHeiTi").fontWeight(FontWeight.Regular) Image($r('app.media.next_icon')).height(20).width(12) } + .opacity((this.list[0].isOpened && this.list[1].isOpened) ? 1 : 0.4) } - .opacity(this.isStop ? 1 : 0.4) - .enabled(this.isStop) + .opacity((this.list[0].isOpened && this.list[1].isOpened) ? 1 : 0.6) + .enabled((this.list[0].isOpened && this.list[1].isOpened)) .onClick(() => { this.defaultCard(); }) .height(60) - .backgroundColor('rgba(255, 255, 255, 1)') .padding({ left: 12, right: 12, @@ -265,7 +344,7 @@ struct Index { }) .width("100%") .backgroundColor($r("sys.color.ohos_id_color_foreground_contrary")) - .borderRadius($r('app.float.radius_24')) + .borderRadius($r('app.float.radius_16')) } .useSizeType({ sm: { span: 4, offset: 0 }, diff --git a/simcardmanagement/src/main/module.json b/simcardmanagement/src/main/module.json index 36a740d..a63647f 100644 --- a/simcardmanagement/src/main/module.json +++ b/simcardmanagement/src/main/module.json @@ -23,22 +23,25 @@ "name": "com.ohos.simcardmanagement.MainAbility", "srcEntrance": "./ets/MainAbility/MainAbility.ts", "description": "$string:MainAbility_desc", - "icon": "$media:icon", + "icon": "$media:app_icon", "label": "$string:MainAbility_label", - "startWindowIcon": "$media:icon", + "startWindowIcon": "$media:app_start_window_icon", "startWindowBackground": "$color:white", "visible": true } ], "requestPermissions" : [ { - "name": "ohos.permission.GET_NETWORK_INFO" + "name": "ohos.permission.GET_NETWORK_INFO", + "reason": "$string:GET_NETWORK_INFO" }, { - "name" : "ohos.permission.SET_TELEPHONY_STATE" + "name": "ohos.permission.SET_TELEPHONY_STATE", + "reason": "$string:SET_TELEPHONY_STATE" }, { - "name" : "ohos.permission.GET_TELEPHONY_STATE" + "name": "ohos.permission.GET_TELEPHONY_STATE", + "reason": "$string:GET_TELEPHONY_STATE" } ] } diff --git a/simcardmanagement/src/main/module.json5 b/simcardmanagement/src/main/module.json5 index f86eabd..ad9a6a9 100644 --- a/simcardmanagement/src/main/module.json5 +++ b/simcardmanagement/src/main/module.json5 @@ -38,22 +38,25 @@ "name": "com.ohos.simcardmanagement.MainAbility", "srcEntrance": "./ets/MainAbility/MainAbility.ts", "description": "$string:MainAbility_desc", - "icon": "$media:icon", + "icon": "$media:app_icon", "label": "$string:MainAbility_label", - "startWindowIcon": "$media:icon", + "startWindowIcon": "$media:app_start_window_icon", "startWindowBackground": "$color:white", "visible": true } ], "requestPermissions" : [ { - "name": "ohos.permission.GET_NETWORK_INFO" + "name": "ohos.permission.GET_NETWORK_INFO", + "reason": "$string:GET_NETWORK_INFO" }, { - "name" : "ohos.permission.SET_TELEPHONY_STATE" + "name": "ohos.permission.SET_TELEPHONY_STATE", + "reason": "$string:SET_TELEPHONY_STATE" }, { - "name" : "ohos.permission.GET_TELEPHONY_STATE" + "name": "ohos.permission.GET_TELEPHONY_STATE", + "reason": "$string:GET_TELEPHONY_STATE" } ] } diff --git a/simcardmanagement/src/main/resources/base/element/float.json b/simcardmanagement/src/main/resources/base/element/float.json index 3fb9fe0..1c2104b 100644 --- a/simcardmanagement/src/main/resources/base/element/float.json +++ b/simcardmanagement/src/main/resources/base/element/float.json @@ -123,6 +123,10 @@ { "name": "radius_24", "value": "24vp" + }, + { + "name": "radius_16", + "value": "16vp" } ] } \ No newline at end of file diff --git a/simcardmanagement/src/main/resources/base/element/string.json b/simcardmanagement/src/main/resources/base/element/string.json index aa7d028..47c1784 100644 --- a/simcardmanagement/src/main/resources/base/element/string.json +++ b/simcardmanagement/src/main/resources/base/element/string.json @@ -227,6 +227,18 @@ { "name": "china_mobile", "value": "中国移动" + }, + { + "name": "GET_NETWORK_INFO", + "value": "获取网络信息权限" + }, + { + "name": "SET_TELEPHONY_STATE", + "value": "设置卡的状态" + }, + { + "name": "GET_TELEPHONY_STATE", + "value": "获取卡的状态" } ] } \ No newline at end of file diff --git a/simcardmanagement/src/main/resources/base/media/back.png b/simcardmanagement/src/main/resources/base/media/back.png deleted file mode 100644 index 0243569..0000000 Binary files a/simcardmanagement/src/main/resources/base/media/back.png and /dev/null differ diff --git a/simcardmanagement/src/main/resources/base/media/determine_icon.png b/simcardmanagement/src/main/resources/base/media/determine_icon.png deleted file mode 100644 index 3e194ca..0000000 Binary files a/simcardmanagement/src/main/resources/base/media/determine_icon.png and /dev/null differ diff --git a/simcardmanagement/src/main/resources/base/media/eSIM.png b/simcardmanagement/src/main/resources/base/media/eSIM.png deleted file mode 100644 index d790046..0000000 Binary files a/simcardmanagement/src/main/resources/base/media/eSIM.png and /dev/null differ diff --git a/entry/src/main/resources/base/media/ic_back.svg b/simcardmanagement/src/main/resources/base/media/ic_back.svg similarity index 100% rename from entry/src/main/resources/base/media/ic_back.svg rename to simcardmanagement/src/main/resources/base/media/ic_back.svg diff --git a/simcardmanagement/src/main/resources/base/media/ic_right_big11.png b/simcardmanagement/src/main/resources/base/media/ic_right_big11.png deleted file mode 100644 index 3e6c11c..0000000 Binary files a/simcardmanagement/src/main/resources/base/media/ic_right_big11.png and /dev/null differ diff --git a/simcardmanagement/src/main/resources/base/media/icon.png b/simcardmanagement/src/main/resources/base/media/icon.png deleted file mode 100644 index ce307a8..0000000 Binary files a/simcardmanagement/src/main/resources/base/media/icon.png and /dev/null differ diff --git a/simcardmanagement/src/main/resources/base/media/loading.gif b/simcardmanagement/src/main/resources/base/media/loading.gif deleted file mode 100644 index a390be6..0000000 Binary files a/simcardmanagement/src/main/resources/base/media/loading.gif and /dev/null differ diff --git a/simcardmanagement/src/main/resources/base/media/nav_check.png b/simcardmanagement/src/main/resources/base/media/nav_check.png deleted file mode 100644 index 3e194ca..0000000 Binary files a/simcardmanagement/src/main/resources/base/media/nav_check.png and /dev/null differ diff --git a/simcardmanagement/src/main/resources/base/media/right.png b/simcardmanagement/src/main/resources/base/media/right.png deleted file mode 100644 index 633f04b..0000000 Binary files a/simcardmanagement/src/main/resources/base/media/right.png and /dev/null differ diff --git a/simcardmanagement/src/main/resources/base/media/user_icon.png b/simcardmanagement/src/main/resources/base/media/user_icon.png deleted file mode 100644 index ab91488..0000000 Binary files a/simcardmanagement/src/main/resources/base/media/user_icon.png and /dev/null differ diff --git a/simcardmanagement/src/main/resources/en_US/element/string.json b/simcardmanagement/src/main/resources/en_US/element/string.json index 0a96ace..8f652d8 100644 --- a/simcardmanagement/src/main/resources/en_US/element/string.json +++ b/simcardmanagement/src/main/resources/en_US/element/string.json @@ -227,6 +227,18 @@ { "name": "china_mobile", "value": "China Mobile" + }, + { + "name": "GET_NETWORK_INFO", + "value": "get network info" + }, + { + "name": "SET_TELEPHONY_STATE", + "value": "set telephony state" + }, + { + "name": "GET_TELEPHONY_STATE", + "value": "get telephony state" } ] } \ No newline at end of file