diff --git a/build-profile.json5 b/build-profile.json5 index ba43e15d..f26d60a8 100644 --- a/build-profile.json5 +++ b/build-profile.json5 @@ -5,7 +5,21 @@ "name": "default", "signingConfig": "release", "compileSdkVersion": 12, - "compatibleSdkVersion": 12 + "compatibleSdkVersion": 12, + } + ], + "signingConfigs": [ + { + "name": "default", + "material": { + "certpath": "C:/Users/wanghuan/.ohos/config/openharmony/default_applications_systemui_zBXUo9gni2fBvC-EjMlkQtKNasCWggA51ALU78m_VWw=.cer", + "storePassword": "0000001BA46E9456DA9E08ACF2A2BFF895A59A4F04F108BD52CED4DAE31B1534C59A5EEEE14B8200ACB885", + "keyAlias": "debugKey", + "keyPassword": "0000001B90751837A5A320E7821C1065CA3C5C38034D3AD64C3E7FD4B7EAE5A5027537CAB7DC32A5230894", + "profile": "C:/Users/wanghuan/.ohos/config/openharmony/default_applications_systemui_zBXUo9gni2fBvC-EjMlkQtKNasCWggA51ALU78m_VWw=.p7b", + "signAlg": "SHA256withECDSA", + "storeFile": "C:/Users/wanghuan/.ohos/config/openharmony/default_applications_systemui_zBXUo9gni2fBvC-EjMlkQtKNasCWggA51ALU78m_VWw=.p12" + } } ] }, diff --git a/common/index.ets b/common/index.ets new file mode 100644 index 00000000..f908665e --- /dev/null +++ b/common/index.ets @@ -0,0 +1,21 @@ +export { default as Constants } from './src/main/ets/plugindatasource/common/Constants'; +export { FilterData } from './src/main/ets/plugindatasource/common/Constants'; +export { RootConfigInfo } from './src/main/ets/plugindatasource/common/Constants'; +export { LoaderConfigInfo } from './src/main/ets/plugindatasource/common/Constants'; +export { PluginType } from './src/main/ets/plugindatasource/common/Constants'; +export { obtainMsg } from './src/main/ets/plugindatasource/common/Constants'; +export { ItemComponentData } from './src/main/ets/plugindatasource/common/Constants'; +export { ActionData } from './src/main/ets/plugindatasource/common/Constants'; +export { PluginComponentData } from './src/main/ets/plugindatasource/common/Constants'; +export { itemData } from './src/main/ets/plugindatasource/common/Constants'; +export { NotificationItemData } from './src/main/ets/plugindatasource/common/Constants'; +export { RuleData } from './src/main/ets/plugindatasource/common/Constants'; +export { ConfigInfo } from './src/main/ets/plugindatasource/common/Constants'; +export { BundleItemData } from './src/main/ets/plugindatasource/common/Constants'; +export { TouchMoveData } from './src/main/ets/plugindatasource/common/Constants'; + +export { Event } from './src/main/ets/default/event/EventUtil'; + +export { Rect } from './src/main/ets/default/Constants'; + + diff --git a/common/oh-package.json5 b/common/oh-package.json5 index d8743db4..e769abf0 100644 --- a/common/oh-package.json5 +++ b/common/oh-package.json5 @@ -3,5 +3,6 @@ "name": "@ohos/common", "description": "a npm package which contains common function", "version": "1.0.0", + "main": "index.ets", "dependencies": {} } \ No newline at end of file diff --git a/common/src/main/ets/default/WindowManager.ts b/common/src/main/ets/default/WindowManager.ts index e0921837..2cb62d46 100644 --- a/common/src/main/ets/default/WindowManager.ts +++ b/common/src/main/ets/default/WindowManager.ts @@ -39,6 +39,17 @@ export enum WindowType { PRIVACY_INDICATOR = 'SystemUi_PrivacyIndicator' } +export interface ArgsInfo { + windowName: WindowType; + isShow?: boolean; + isDestroy?: boolean; + rect?: Rect; + left?: number; + top?: number; + width?: number; + height?: number; +} + export const WINDOW_SHOW_HIDE_EVENT = 'WindowShowHideEvent'; export const WINDOW_RESIZE_EVENT = 'WindowResizeEvent'; diff --git a/common/src/main/ets/plugindatasource/common/Constants.ts b/common/src/main/ets/plugindatasource/common/Constants.ts index 336ef9fe..6f657a3e 100644 --- a/common/src/main/ets/plugindatasource/common/Constants.ts +++ b/common/src/main/ets/plugindatasource/common/Constants.ts @@ -14,6 +14,11 @@ */ import { Event } from '../../default/event/EventUtil'; +import notificationManager from '@ohos.notificationManager'; +import image from '@ohos.multimedia.image'; +import resourceManager from '@ohos.resourceManager'; +import { WantAgent } from '@ohos.wantAgent'; +import NtfMgr from '@ohos.notificationManager'; export default class Constants { static readonly INIT_CONFIG = 'initConfig'; @@ -104,7 +109,7 @@ export class itemData { isShowIcon? } -export class notificationData { +export interface NotificationItemData { id: string; hashcode: string; userId: number; @@ -113,12 +118,12 @@ export class notificationData { timestamp: number; time: string; appName: string; - want: any; - actionButtons: any[]; + want: WantAgent; + actionButtons: notificationManager.ButtonOptions[]; bundleName: string; - smallIcon?: PixelMap; - largeIcon?: PixelMap; - picture?: PixelMap; + smallIcon?: image.PixelMap | string; + largeIcon?: image.PixelMap | string; + picture?: image.PixelMap; title?: string; text?: string; additionalText?: string; @@ -133,7 +138,7 @@ export class notificationData { sound?: string; vibrationValues?: Array; notificationFlags?: any; - ruleData?; + ruleData?: RuleData; template?: any; isOngoing?: boolean; isUnremovable?: boolean; @@ -143,3 +148,44 @@ export class notificationData { groupName?: string; tapDismissed?: boolean; } + +export interface RuleData { + isAllowBanner?: boolean; + isAllowSound?: boolean; + isAllowVibrationValues?: boolean; + isAllowStatusBarShow?: boolean; + isAllowNotificationListShow?: boolean; +} + +export interface ConfigInfo { + maxWidth: number; + maxHeight: number; + minHeight: number; + showHorizontal: boolean; + direction: number; + realWidth: number; + realHeight: number; + xCoordinate: number; + yCoordinate: number; + ableToMaximize?: boolean; + showNavHorizontal?: boolean; +} + +export interface BundleItemData { + appIcon?: string; + appTitle?: string; + appValue?: string; + appArrow?: string | resourceManager.Resource; + appSummary?: string; + appBundleName?: string; + appIconId?: string; + appUri?: string; + appUid?: number; + systemApp?: boolean; + slotSettingUrl?: string +} + +export interface TouchMoveData { + direction: string, + touchComponent: string +} \ No newline at end of file diff --git a/common/src/main/ets/template/SimpleToggleBase.ets b/common/src/main/ets/template/SimpleToggleBase.ets index 404383b8..12b5c744 100644 --- a/common/src/main/ets/template/SimpleToggleBase.ets +++ b/common/src/main/ets/template/SimpleToggleBase.ets @@ -20,20 +20,20 @@ const TAG = 'SimpleToggleBase' @Component export default struct SimpleToggleBase { - private mToggleId: string + private mToggleId: string = '' @Link mIcon: Resource @State mIconStr: string = '' private mUseIconStr: boolean = false private mAutoIconColor: boolean = false @Link mChangeSwitch: boolean @Link mLabel: Resource - private mLabelStr: string | Resource + private mLabelStr: string | Resource = '' private mUseLabelStr: boolean = false - private mIconOnBG: string | Resource + private mIconOnBG: string | Resource = '' private mEditMode: boolean = false private mDragMode: boolean = false - private mClickEvent: Function - private mLongClickEvent: Function + private mClickEvent: Function = (): void => {} + private mLongClickEvent: Function = (): void => {} @State mIconIsHover: boolean = false @State mTextIsHover: boolean = false @State style: SimpleToggleBaseStyle = StyleConfiguration.getSimpleToggleBaseStyle() diff --git a/common/src/main/ets/template/iconComponent.ets b/common/src/main/ets/template/iconComponent.ets index 8ba45045..02c362f9 100644 --- a/common/src/main/ets/template/iconComponent.ets +++ b/common/src/main/ets/template/iconComponent.ets @@ -20,8 +20,8 @@ const TAG = 'iconComponent' @Component export default struct iconComponent { - @State iconOff: string = "" - @State iconOn: string = "" + @State iconOff: Resource | string = "" + @State iconOn: Resource | string = "" @Prop iconOffStr: string @Prop iconOnStr: string private useIconStr = false diff --git a/common/src/main/ets/template/iconTitleBase.ets b/common/src/main/ets/template/iconTitleBase.ets index 15e753e4..04139565 100644 --- a/common/src/main/ets/template/iconTitleBase.ets +++ b/common/src/main/ets/template/iconTitleBase.ets @@ -21,16 +21,16 @@ const TAG = 'iconTitleBase' @Component export default struct iconBaseComponent { - private iconOn: any - private iconOff: any + @Prop iconOn: Resource + @Prop iconOff: Resource @State iconOffStr: string = "" @State iconOnStr: string = "" @Link mTitle: Resource @State mTitleStr: string = "" private useIconStr = false private useTitleStr = false - private mClickEvent: Function - private mLongClickEvent: Function + private mClickEvent: Function = (): void => {} + private mLongClickEvent: Function = (): void => {} @State mTextIsHover: boolean = false @Link changeSwitch: boolean @State style: IconTitleBaseStyle = StyleConfiguration.getIconTitleBaseStyle() diff --git a/entry/pc/src/main/module.json5 b/entry/pc/src/main/module.json5 index 096c78db..a34908d7 100644 --- a/entry/pc/src/main/module.json5 +++ b/entry/pc/src/main/module.json5 @@ -35,7 +35,13 @@ }, { "name": "ohos.permission.GET_INSTALLED_BUNDLE_LIST", - "reason": "$string:get_installed_bundle_list_reason" + "reason": "$string:get_installed_bundle_list_reason", + "usedScene": { + "abilities": [ + "MainAbility" + ], + "when": "always" + } }, { "name": "ohos.permission.MANAGE_LOCAL_ACCOUNTS" @@ -81,7 +87,13 @@ }, { "name": "ohos.permission.DISTRIBUTED_DATASYNC", - "reason": "$string:distributed_data_sync_reason" + "reason": "$string:distributed_data_sync_reason", + "usedScene": { + "abilities": [ + "MainAbility" + ], + "when": "always" + } }, { "name": "ohos.permission.START_INVISIBLE_ABILITY" diff --git a/entry/phone/src/main/module.json5 b/entry/phone/src/main/module.json5 index fd9507ba..68f69f16 100644 --- a/entry/phone/src/main/module.json5 +++ b/entry/phone/src/main/module.json5 @@ -35,7 +35,13 @@ }, { "name": "ohos.permission.GET_INSTALLED_BUNDLE_LIST", - "reason": "$string:get_installed_bundle_list_reason" + "reason": "$string:get_installed_bundle_list_reason", + "usedScene": { + "abilities": [ + "MainAbility" + ], + "when": "always" + } }, { "name": "ohos.permission.MANAGE_LOCAL_ACCOUNTS" @@ -81,7 +87,13 @@ }, { "name": "ohos.permission.DISTRIBUTED_DATASYNC", - "reason": "$string:distributed_data_sync_reason" + "reason": "$string:distributed_data_sync_reason", + "usedScene": { + "abilities": [ + "MainAbility" + ], + "when": "always" + } }, { "name": "ohos.permission.START_INVISIBLE_ABILITY" diff --git a/features/airplanecomponent/src/main/ets/default/pages/ControlCenterSimpleToggleAirplaneComponent.ets b/features/airplanecomponent/src/main/ets/default/pages/ControlCenterSimpleToggleAirplaneComponent.ets index e462c89f..ec189dff 100644 --- a/features/airplanecomponent/src/main/ets/default/pages/ControlCenterSimpleToggleAirplaneComponent.ets +++ b/features/airplanecomponent/src/main/ets/default/pages/ControlCenterSimpleToggleAirplaneComponent.ets @@ -21,7 +21,7 @@ const TAG = 'airplane-ControlCenterSimpleToggleAirplaneComponent'; @Component export default struct ControlCenterSimpleToggleAirplaneComponent { - private keyId: string; + private keyId: string = ''; private mEditMode: boolean = false; private mDragMode: boolean = false; @State mIcon: Resource = $r("app.media.airplane"); @@ -46,7 +46,7 @@ export default struct ControlCenterSimpleToggleAirplaneComponent { mLabel: $mLabel, mEditMode: this.mEditMode, mDragMode: this.mDragMode, - mClickEvent: () => this.mClickEvent() + mClickEvent: (): void => this.mClickEvent() }) } diff --git a/features/airplanecomponent/src/main/ets/default/pages/airplaneComponent.ets b/features/airplanecomponent/src/main/ets/default/pages/airplaneComponent.ets index 898ac2e0..c1618949 100644 --- a/features/airplanecomponent/src/main/ets/default/pages/airplaneComponent.ets +++ b/features/airplanecomponent/src/main/ets/default/pages/airplaneComponent.ets @@ -23,7 +23,7 @@ const TAG = 'Control-airPlaneComponent'; export default struct airplaneComponent { - private IconInfo: any[] = [ + private IconInfo: Resource[] = [ $r('app.media.airplane_d'), $r('app.media.airplane'), ]; @@ -72,7 +72,7 @@ struct airplaneComponent { iconOn: this.IconInfo[1], mTitle: $flyModelTitle, changeSwitch: $flyModelStatus, - mClickEvent: () => this.mClickEvent() + mClickEvent: (): void => this.mClickEvent() }) }.width('100%') .height('100%') diff --git a/features/autorotatecomponent/src/main/ets/com/ohos/pages/ControlCenterSimpleToggleAutoRotateComponent.ets b/features/autorotatecomponent/src/main/ets/com/ohos/pages/ControlCenterSimpleToggleAutoRotateComponent.ets index 0011be5a..c24d774b 100644 --- a/features/autorotatecomponent/src/main/ets/com/ohos/pages/ControlCenterSimpleToggleAutoRotateComponent.ets +++ b/features/autorotatecomponent/src/main/ets/com/ohos/pages/ControlCenterSimpleToggleAutoRotateComponent.ets @@ -22,7 +22,7 @@ const TAG = 'autorotate-ControlCenterSimpleToggleAutoRotateComponent'; @Component export default struct ControlCenterSimpleToggleAutoRotateComponent { - private keyId: string; + private keyId: string = ''; private mEditMode: boolean = false; private mDragMode: boolean = false; @State mIcon: Resource = $r("app.media.ic_controlcenter_auto_rotate_off"); @@ -53,7 +53,7 @@ export default struct ControlCenterSimpleToggleAutoRotateComponent { mLabel: $mLabel, mEditMode: this.mEditMode, mDragMode: this.mDragMode, - mClickEvent: () => this.mClickEvent() + mClickEvent: (): void => this.mClickEvent() }) } diff --git a/features/batterycomponent/src/main/ets/default/pages/batteryPic.ets b/features/batterycomponent/src/main/ets/default/pages/batteryPic.ets index 5f78a3ca..5b4e1265 100644 --- a/features/batterycomponent/src/main/ets/default/pages/batteryPic.ets +++ b/features/batterycomponent/src/main/ets/default/pages/batteryPic.ets @@ -78,7 +78,7 @@ export default struct BatteryPic { }) } - private getBatteryColor(val, charging) { + private getBatteryColor(val: number, charging: boolean) { Log.showInfo(TAG, `getBatteryColor, val: ${val} charging: ${charging} `); if (charging) { return this.style.picChargingColor; diff --git a/features/bluetoothcomponent/src/main/ets/com/ohos/pages/ControlCenterComplexToggleBluetoothComponent.ets b/features/bluetoothcomponent/src/main/ets/com/ohos/pages/ControlCenterComplexToggleBluetoothComponent.ets index 151efd1a..a6ba486c 100644 --- a/features/bluetoothcomponent/src/main/ets/com/ohos/pages/ControlCenterComplexToggleBluetoothComponent.ets +++ b/features/bluetoothcomponent/src/main/ets/com/ohos/pages/ControlCenterComplexToggleBluetoothComponent.ets @@ -23,7 +23,7 @@ const TAG = 'bluetooth-ControlCenterComplexToggleBluetoothComponent'; @Component export default struct ControlCenterComplexToggleBluetoothComponent { - private IconInfo: any[] = [ + private IconInfo: Resource[] = [ $r("app.media.ic_controlcenter_bt_d"), $r("app.media.ic_controlcenter_bt"), ]; @@ -46,8 +46,8 @@ export default struct ControlCenterComplexToggleBluetoothComponent { iconOn: this.IconInfo[1], mTitle: $mTitle, changeSwitch: $BluetoothOpenStatus, - mClickEvent: () => this.mClickEvent(), - mLongClickEvent: () => this.mLongClickEvent() + mClickEvent: (): void => this.mClickEvent(), + mLongClickEvent: (): void => this.mLongClickEvent() }) }.width('100%') .height('100%') diff --git a/features/brightnesscomponent/src/main/ets/default/pages/brightnessComponent.ets b/features/brightnesscomponent/src/main/ets/default/pages/brightnessComponent.ets index d1f83aba..5ecc8ed0 100644 --- a/features/brightnesscomponent/src/main/ets/default/pages/brightnessComponent.ets +++ b/features/brightnesscomponent/src/main/ets/default/pages/brightnessComponent.ets @@ -20,7 +20,7 @@ import Log from '../../../../../../../common/src/main/ets/default/Log'; const TAG = 'Control-brightnessComponent'; -class brightnessItemData { +interface brightnessItemData { min:number; max:number; value:number diff --git a/features/controlcentercomponent/src/main/ets/com/ohos/pages/ComplexToggleComponent.ets b/features/controlcentercomponent/src/main/ets/com/ohos/pages/ComplexToggleComponent.ets index 973aaf84..66a62a2d 100644 --- a/features/controlcentercomponent/src/main/ets/com/ohos/pages/ComplexToggleComponent.ets +++ b/features/controlcentercomponent/src/main/ets/com/ohos/pages/ComplexToggleComponent.ets @@ -38,7 +38,7 @@ export default struct ComplexToggleComponent { linkItemData() { Log.showDebug(TAG, `linkItemData, keyId: ${this.keyId}`); - this.mItemData = AppStorage.Get('ControlCenter_' + this.keyId); + this.mItemData = AppStorage.Get('ControlCenter_' + this.keyId) as ControlComponentData; Log.showDebug(TAG, `linkItemData, mItemData: ${this.keyId} ${this.mItemData.label} ${this.mItemData.iconUrl}`); } @@ -55,8 +55,8 @@ export default struct ComplexToggleComponent { iconOnStr: this.mItemData .iconUrl, changeSwitch: $mStatus, - mClickEvent: () => this.onIconItemClick(), - mLongClickEvent: () => this.onIconItemLongPressGesture() + mClickEvent: (): void => this.onIconItemClick(), + mLongClickEvent: (): void => this.onIconItemLongPressGesture() }) }.width('100%') .height('100%') diff --git a/features/controlcentercomponent/src/main/ets/com/ohos/pages/ControlCenterComponent.ets b/features/controlcentercomponent/src/main/ets/com/ohos/pages/ControlCenterComponent.ets index 1c004d2c..91852fe1 100644 --- a/features/controlcentercomponent/src/main/ets/com/ohos/pages/ControlCenterComponent.ets +++ b/features/controlcentercomponent/src/main/ets/com/ohos/pages/ControlCenterComponent.ets @@ -28,14 +28,16 @@ const TAG = 'Control-ControlCenter'; const TAG_ControlCenterComplexToggleLayout = 'Control-ControlCenterComplexToggleLayout'; const TAG_ControlCenterSimpleToggleLayout = 'Control-ControlCenterSimpleToggleLayout'; -var mUniform; +interface IDirection { + direction: string +} @Component export default struct ControlCenterComponent { - private touchMoveCallback: Function; - private modeChangeCallback: Function; + private touchMoveCallback: Function = () => {}; + private modeChangeCallback: Function = () => {}; @State mSimpleToggleColumnCount: number = Constants.DEFAULT_SIMPLE_TOGGLE_COLUMN_COUNT; - private mControlCenterComponentConfig: ControlCenterConfig; + private mControlCenterComponentConfig: ControlCenterConfig | undefined = undefined; @State mIsEditSimpleToggleLayout: boolean = false; @State style: ControlCenterComponentStyle = StyleConfiguration.getControlCenterComponentStyle(); private mWidthPx: number = 0; @@ -100,12 +102,12 @@ export default struct ControlCenterComponent { Column() { Column() { UpTitle({ - touchMoveCallback: (data) => { + touchMoveCallback: (data: IDirection) => { if (this.touchMoveCallback) { this.touchMoveCallback(data) } }, - simpleToggleLayoutEditStartCallback: () => this.onSimpleToggleLayoutEditStart() + simpleToggleLayoutEditStartCallback: ():void => this.onSimpleToggleLayoutEditStart() }) } .width('100%') @@ -143,7 +145,7 @@ export default struct ControlCenterComponent { mDisplayingToggles: this.mDisplayingSimpleToggles, mHidingToggles: this.mHidingSimpleToggles, mDefaultDisplayToggles: this.mDefaultDisplaySimpleToggles, - simpleToggleLayoutEditEndCallback: () => this.onSimpleToggleLayoutEditEnd(), + simpleToggleLayoutEditEndCallback: (): void => this.onSimpleToggleLayoutEditEnd(), onSaveDisplayingToggles: (toggles: string[]) => this.onSaveDisplayingToggles(toggles), mColumnCount: this.mSimpleToggleColumnCount, titleDisplayInside: this.titleDisplayInside @@ -178,7 +180,7 @@ struct ControlCenterComplexToggleLayout { build() { Grid() { - ForEach(this.mComplexToggleLayout, (componentName) => { + ForEach(this.mComplexToggleLayout, (componentName: string) => { GridItem() { ComplexToggleLoadComponent({ keyId: componentName @@ -186,17 +188,20 @@ struct ControlCenterComplexToggleLayout { } .width('100%') .height('100%') - }, (componentName) => componentName) + }, (componentName: string) => componentName) } .width('100%') - .height(this.calcGridHeight(Math.ceil(this.mComplexToggleLayout.length / 2), this.style.rowHeight, this.style.rowGap)) + .height(this.calcGridHeight( + Math.ceil(this.mComplexToggleLayout.length / 2), + this.style.rowHeight as number, + this.style.rowGap as number)) .columnsTemplate('1fr 1fr') .rowsTemplate(this.generateRowsTemplate(Math.ceil(this.mComplexToggleLayout.length / 2))) .rowsGap(this.style.rowGap + 'px') .columnsGap(this.style.columnGap) } - calcGridHeight(rowCount, rowHeight, rowGap) { + calcGridHeight(rowCount: number, rowHeight: number, rowGap: number) { Log.showDebug(TAG_ControlCenterComplexToggleLayout, `calcGridHeight, rowCount: ${rowCount} rowHeight: ${rowHeight} rowGap: ${rowGap}`); let height = rowCount * rowHeight + (rowCount - 1) * rowGap; if (height < 0) { @@ -206,7 +211,7 @@ struct ControlCenterComplexToggleLayout { return height + 'px'; } - generateRowsTemplate(rowCount) { + generateRowsTemplate(rowCount: number) { Log.showDebug(TAG_ControlCenterComplexToggleLayout, `generateRowsTemplate, rowCount: ${rowCount}`); let rowsTemplate = '1fr'; for (let i = 1;i < rowCount; i++) { @@ -232,17 +237,21 @@ struct ControlCenterSimpleToggleLayout { build() { Grid() { - ForEach(this.mSimpleToggleLayout, (componentName) => { + ForEach(this.mSimpleToggleLayout, (componentName: string) => { GridItem() { SimpleToggleLoadComponent({ keyId: componentName }) }.width('100%') .height('100%') - }, (componentName) => componentName) + }, (componentName: string) => componentName) } .width('100%') - .height(this.calcGridHeight(Math.ceil(this.mSimpleToggleLayout.length / this.mColumnCount), this.style.rowHeight, this.style.rowGap)) + .height(this.calcGridHeight( + Math.ceil( + this.mSimpleToggleLayout.length / this.mColumnCount), + this.style.rowHeight as number, + this.style.rowGap as number)) .margin({left: this.style.marginLeft, right: this.style.marginRight}) .columnsTemplate(this.generateColumnsTemplate(this.mColumnCount)) .rowsTemplate(this.generateRowsTemplate(Math.ceil(this.mSimpleToggleLayout.length / this.mColumnCount))) @@ -250,7 +259,7 @@ struct ControlCenterSimpleToggleLayout { .columnsGap(this.style.columnGap) } - calcGridHeight(rowCount, rowHeight, rowGap) { + calcGridHeight(rowCount: number, rowHeight: number, rowGap: number) { Log.showDebug(TAG_ControlCenterSimpleToggleLayout, `calcGridHeight, rowCount: ${rowCount} rowHeight: ${rowHeight} rowGap: ${rowGap}`); let height = rowCount * rowHeight + (rowCount - 1) * rowGap; if (height < 0) { @@ -260,7 +269,7 @@ struct ControlCenterSimpleToggleLayout { return height + 'px'; } - generateColumnsTemplate(columnCount) { + generateColumnsTemplate(columnCount: number) { Log.showDebug(TAG_ControlCenterSimpleToggleLayout, `generateColumnsTemplate, columnCount: ${columnCount}`); let columnsTemplate = '1fr'; for (let i = 1;i < columnCount; i++) { @@ -269,7 +278,7 @@ struct ControlCenterSimpleToggleLayout { return columnsTemplate; } - generateRowsTemplate(rowCount) { + generateRowsTemplate(rowCount: number) { Log.showDebug(TAG_ControlCenterSimpleToggleLayout, `generateRowsTemplate, rowCount: ${rowCount}`); let rowsTemplate = '1fr'; for (let i = 1;i < rowCount; i++) { diff --git a/features/controlcentercomponent/src/main/ets/com/ohos/pages/PluginIconItemComponent.ets b/features/controlcentercomponent/src/main/ets/com/ohos/pages/PluginIconItemComponent.ets index f4f8f544..1606861f 100644 --- a/features/controlcentercomponent/src/main/ets/com/ohos/pages/PluginIconItemComponent.ets +++ b/features/controlcentercomponent/src/main/ets/com/ohos/pages/PluginIconItemComponent.ets @@ -23,7 +23,7 @@ const TAG = 'PluginIconItemComponent'; @Component export default struct PluginIconItemComponent { - private keyId: string; + private keyId: string = ''; private mEditMode: boolean = false; private mDragMode: boolean = false; @State @Watch('onPluginDataChange') mPluginData: PluginComponentData = new PluginComponentData(); @@ -55,8 +55,8 @@ export default struct PluginIconItemComponent { data: this.mPluginData.data }).onComplete(() => { Log.showInfo(TAG, `PluginComponent.Complete`) - }).onError(({errcode, msg}) => { - Log.showInfo(TAG, `PluginComponent.Error code:${errcode} message:${msg}`) + }).onError((error) => { + Log.showInfo(TAG, `PluginComponent.Error code:${error.errcode} message:${error.msg}`) }) .size({ width: '100%', height: '100%' }) } diff --git a/features/controlcentercomponent/src/main/ets/com/ohos/pages/SimpleToggleComponent.ets b/features/controlcentercomponent/src/main/ets/com/ohos/pages/SimpleToggleComponent.ets index 30b85c5f..d0372192 100644 --- a/features/controlcentercomponent/src/main/ets/com/ohos/pages/SimpleToggleComponent.ets +++ b/features/controlcentercomponent/src/main/ets/com/ohos/pages/SimpleToggleComponent.ets @@ -24,7 +24,7 @@ const TAG = 'SimpleToggleComponent'; @Component export default struct SimpleToggleComponent { - private keyId: string; + @Prop keyId: string; @State mItemData: ControlComponentData = {}; private mEditMode: boolean = false; private mDragMode: boolean = false; @@ -43,7 +43,7 @@ export default struct SimpleToggleComponent { linkItemData() { Log.showDebug(TAG, `linkItemData, keyId: ${this.keyId}`); - this.mItemData = AppStorage.Get('ControlCenter_' + this.keyId); + this.mItemData = AppStorage.Get('ControlCenter_' + this.keyId) as ControlComponentData; Log.showDebug(TAG, `linkItemData, mItemData: ${this.keyId} ${this.mItemData.label} ${this.mItemData.iconUrl}`); } @@ -70,8 +70,8 @@ export default struct SimpleToggleComponent { mUseLabelStr: true, mEditMode: this.mEditMode, mDragMode: this.mDragMode, - mClickEvent: () => this.onIconItemClick(), - mLongClickEvent: () => this.onIconItemLongPressGesture() + mClickEvent: (): void => this.onIconItemClick(), + mLongClickEvent: (): void => this.onIconItemLongPressGesture() }) } else if (this.mItemData.pluginType == PluginType.DATA_ABILITY) { // TODO: diff --git a/features/controlcentercomponent/src/main/ets/com/ohos/pages/SimpleToggleLayoutEditComponent.ets b/features/controlcentercomponent/src/main/ets/com/ohos/pages/SimpleToggleLayoutEditComponent.ets index 8c30f561..95074ace 100644 --- a/features/controlcentercomponent/src/main/ets/com/ohos/pages/SimpleToggleLayoutEditComponent.ets +++ b/features/controlcentercomponent/src/main/ets/com/ohos/pages/SimpleToggleLayoutEditComponent.ets @@ -30,8 +30,8 @@ export default struct SimpleToggleLayoutEditComponent { private mHidingToggles: string[] = []; private mDefaultDisplayToggles: string[] = []; @Prop mColumnCount: number; - private simpleToggleLayoutEditEndCallback: () => void; - private onSaveDisplayingToggles: (toggles: string[]) => void; + private simpleToggleLayoutEditEndCallback: () => void = () => {}; + private onSaveDisplayingToggles: (toggles: string[]) => void = (toggles) => {}; @State mNewDisplayingToggles: string[] = []; @State mNewHidingToggles: string[] = []; @State style: SimpleToggleLayoutEditComponentStyle = StyleConfiguration.getSimpleToggleLayoutEditComponentStyle(); @@ -42,27 +42,27 @@ export default struct SimpleToggleLayoutEditComponent { private mHidingTogglesMinCount: number = 0; @State mCurrentDragToggleName: string = ''; private titleDisplayInside: boolean = false; - private backDialogController: CustomDialogController = new CustomDialogController({ + private backDialogController: CustomDialogController | null = new CustomDialogController({ builder: SimpleToggleLayoutEditDialogComponent({ title: $r("app.string.control_center_simple_toggle_layout_edit_back_confirm"), leftButton: $r("app.string.control_center_simple_toggle_layout_edit_back_confirm_primary"), rightButton: $r("app.string.control_center_simple_toggle_layout_edit_back_confirm_secondary"), - leftAction: () => this.callSimpleToggleLayoutEditEnd(), - rightAction: () => this.onFinishBtnClick(null), + leftAction: (): void => this.callSimpleToggleLayoutEditEnd(), + rightAction: (): void => this.onFinishBtnClick(), }), autoCancel: false, offset: { dx: 0, dy: 0 }, customStyle: true, alignment: DialogAlignment.Center }); - private resetDialogController: CustomDialogController = new CustomDialogController({ + private resetDialogController: CustomDialogController | null = new CustomDialogController({ builder: SimpleToggleLayoutEditDialogComponent({ title: $r("app.string.control_center_simple_toggle_layout_edit_reset_confirm"), leftButton: $r("app.string.control_center_simple_toggle_layout_edit_reset_confirm_primary"), rightButton: $r("app.string.control_center_simple_toggle_layout_edit_reset_confirm_secondary"), leftAction: () => { }, - rightAction: () => this.editResetConfirm(), + rightAction: (): void => this.editResetConfirm(), }), autoCancel: false, offset: { dx: 0, dy: 0 }, @@ -86,11 +86,8 @@ export default struct SimpleToggleLayoutEditComponent { } aboutToDisappear() { - delete this.backDialogController - this.backDialogController = undefined - - delete this.resetDialogController - this.resetDialogController = undefined + this.backDialogController = null + this.resetDialogController = null Log.showInfo(TAG, 'aboutToDisappear '); } @@ -100,7 +97,7 @@ export default struct SimpleToggleLayoutEditComponent { if (!this.titleDisplayInside) { Column() { SimpleToggleLayoutEditUpTitle({ - simpleToggleLayoutEditEndCallback: () => this.onSimpleToggleLayoutEditEnd() + simpleToggleLayoutEditEndCallback: (): void => this.onSimpleToggleLayoutEditEnd() }) } .width('100%') @@ -112,7 +109,7 @@ export default struct SimpleToggleLayoutEditComponent { if (this.titleDisplayInside) { Column() { SimpleToggleLayoutEditUpTitle({ - simpleToggleLayoutEditEndCallback: () => this.onSimpleToggleLayoutEditEnd() + simpleToggleLayoutEditEndCallback: (): void => this.onSimpleToggleLayoutEditEnd() }) } .width('100%') @@ -206,7 +203,7 @@ export default struct SimpleToggleLayoutEditComponent { let changed = JSON.stringify(this.mDisplayingToggles) != JSON.stringify(this.mNewDisplayingToggles); Log.showDebug(TAG, `onSimpleToggleLayoutEditEnd, changed: ${changed}`); if (changed) { - this.backDialogController.open(); + this.backDialogController?.open(); } else { this.callSimpleToggleLayoutEditEnd(); }; @@ -224,7 +221,7 @@ export default struct SimpleToggleLayoutEditComponent { let equalDefault = JSON.stringify(this.mDefaultDisplayToggles) == JSON.stringify(this.mNewDisplayingToggles); Log.showDebug(TAG, `onResetBtnClick, equalDefault: ${equalDefault}`); if (!equalDefault) { - this.resetDialogController.open(); + this.resetDialogController?.open(); }; } @@ -256,7 +253,7 @@ export default struct SimpleToggleLayoutEditComponent { Log.showDebug(TAG, `resetData, mNewHidingToggles: ${JSON.stringify(this.mNewHidingToggles)}`); } - onFinishBtnClick(event: ClickEvent) { + onFinishBtnClick() { Log.showDebug(TAG, `onFinishBtnClick`); let changed = JSON.stringify(this.mDisplayingToggles) != JSON.stringify(this.mNewDisplayingToggles); Log.showDebug(TAG, `onFinishBtnClick, changed: ${changed}`); @@ -281,7 +278,7 @@ export default struct SimpleToggleLayoutEditComponent { async onDisplayingGridItemDrop(status: string): Promise { Log.showDebug(TAG, `onDisplayingGridItemDrop, status: ${status}`); - this.setOptMsg(null); + this.setOptMsg(''); } async onHidingGridItemDragStart(toggleName: string): Promise { @@ -292,7 +289,7 @@ export default struct SimpleToggleLayoutEditComponent { async onHidingGridItemDrop(status: string): Promise { Log.showDebug(TAG, `onHidingGridItemDrop, status: ${status}`); - this.setOptMsg(null); + this.setOptMsg(''); } setOptMsg(toggleName: string): void { @@ -324,7 +321,7 @@ export default struct SimpleToggleLayoutEditComponent { @Component struct SimpleToggleLayoutEditUpTitle { - private simpleToggleLayoutEditEndCallback: Function; + private simpleToggleLayoutEditEndCallback: Function = () => {}; @State style: SimpleToggleLayoutEditUpTitleStyle = StyleConfiguration.getSimpleToggleLayoutEditUpTitleStyle(); aboutToAppear() { diff --git a/features/controlcentercomponent/src/main/ets/com/ohos/pages/SimpleToggleLayoutEditDialogComponent.ets b/features/controlcentercomponent/src/main/ets/com/ohos/pages/SimpleToggleLayoutEditDialogComponent.ets index b005bdeb..ec884a50 100644 --- a/features/controlcentercomponent/src/main/ets/com/ohos/pages/SimpleToggleLayoutEditDialogComponent.ets +++ b/features/controlcentercomponent/src/main/ets/com/ohos/pages/SimpleToggleLayoutEditDialogComponent.ets @@ -20,12 +20,12 @@ const TAG = 'Control-SimpleToggleLayoutEditDialogComponent'; @CustomDialog export default struct SimpleToggleLayoutEditDialogComponent { - private title: Resource; - private leftButton: Resource; - private rightButton: Resource; + private title: Resource | undefined = undefined; + private leftButton: Resource| undefined = undefined; + private rightButton: Resource| undefined = undefined; private controller: CustomDialogController; - private leftAction: () => void; - private rightAction: () => void; + private leftAction: () => void = () => {}; + private rightAction: () => void = () =>{}; @State style: ControlEditDialogStyle = StyleConfiguration.getControlEditDialogStyle(); aboutToAppear() { diff --git a/features/controlcentercomponent/src/main/ets/com/ohos/pages/SimpleToggleLayoutEditGrid.ets b/features/controlcentercomponent/src/main/ets/com/ohos/pages/SimpleToggleLayoutEditGrid.ets index c8b06ce9..f0438814 100644 --- a/features/controlcentercomponent/src/main/ets/com/ohos/pages/SimpleToggleLayoutEditGrid.ets +++ b/features/controlcentercomponent/src/main/ets/com/ohos/pages/SimpleToggleLayoutEditGrid.ets @@ -28,8 +28,8 @@ export default struct SimpleToggleLayoutEditGrid { @Prop mGlobalDragToggleName: string; private gridTag: string = ''; private logTag: string = ''; - private onItemDragStart: (toggleName: string) => void; - private onItemDrop: (status: string) => void; + private onItemDragStart: (toggleName: string) => void = () => {}; + private onItemDrop: (status: string) => void = () => {}; @State style: SimpleToggleLayoutEditGridStyle = StyleConfiguration.getSimpleToggleLayoutEditGridStyle(); private mCurrentDragToggleName: string = ''; @@ -94,7 +94,7 @@ export default struct SimpleToggleLayoutEditGrid { .onItemDrop(this.onGridItemDrop.bind(this)) } - calcGridHeight(rowCount, rowHeight, rowGap) { + calcGridHeight(rowCount: number, rowHeight: number, rowGap: number) { Log.showDebug(this.logTag, `calcGridHeight, rowCount: ${rowCount} rowHeight: ${rowHeight} rowGap: ${rowGap}`); let height = rowCount * rowHeight + (rowCount - 1) * rowGap; if (height <= 0) { @@ -134,19 +134,19 @@ export default struct SimpleToggleLayoutEditGrid { return minRowCount; } - onItemDragEnter(event) { + onItemDragEnter(event: ItemDragInfo) { Log.showDebug(this.logTag, `onItemDragEnter, event: ${JSON.stringify(event)}`); } - onItemDragMove(event, itemIndex, insertIndex) { + onItemDragMove(event: ItemDragInfo, itemIndex: number, insertIndex: number) { Log.showDebug(this.logTag, `onItemDragMove, itemIndex: ${itemIndex} insertIndex: ${insertIndex} event: ${JSON.stringify(event)}`); } - onItemDragLeave(event, itemIndex) { + onItemDragLeave(event: ItemDragInfo, itemIndex: number) { Log.showDebug(this.logTag, `onItemDragLeave, itemIndex: ${itemIndex} event: ${JSON.stringify(event)}`); } - onGridItemDragStart(event, itemIndex) { + onGridItemDragStart(event: ItemDragInfo, itemIndex: number) { Log.showDebug(this.logTag, `onGridItemDragStart, itemIndex: ${itemIndex} event: ${JSON.stringify(event)}`); this.mCurrentDragToggleName = this.mToggles[itemIndex]; if (this.onItemDragStart) { @@ -155,7 +155,7 @@ export default struct SimpleToggleLayoutEditGrid { Log.showDebug(this.logTag, `onGridItemDragStart, mCurrentDragToggleName: ${this.mCurrentDragToggleName}`); } - onGridItemDrop(event, itemIndex, insertIndex, isSuccess) { + onGridItemDrop(event: ItemDragInfo, itemIndex: number, insertIndex: number, isSuccess: boolean) { Log.showDebug(this.logTag, `onGridItemDrop, itemIndex: ${itemIndex} insertIndex: ${insertIndex} isSuccess: ${isSuccess} event: ${JSON.stringify(event)}`); if (!isSuccess) { this.callOnItemDrop('fail'); diff --git a/features/controlcentercomponent/src/main/ets/com/ohos/pages/SimpleToggleLoadComponent.ets b/features/controlcentercomponent/src/main/ets/com/ohos/pages/SimpleToggleLoadComponent.ets index e7b21027..7f3ea11c 100644 --- a/features/controlcentercomponent/src/main/ets/com/ohos/pages/SimpleToggleLoadComponent.ets +++ b/features/controlcentercomponent/src/main/ets/com/ohos/pages/SimpleToggleLoadComponent.ets @@ -27,7 +27,7 @@ const TAG = 'SimpleToggleLoadComponent'; @Component export default struct SimpleToggleLoadComponent { - private keyId: string + private keyId: string = '' private mEditMode: boolean = false private mDragMode: boolean = false diff --git a/features/controlcentercomponent/src/main/ets/com/ohos/pages/UpTitle.ets b/features/controlcentercomponent/src/main/ets/com/ohos/pages/UpTitle.ets index ae809c6b..bbce067f 100644 --- a/features/controlcentercomponent/src/main/ets/com/ohos/pages/UpTitle.ets +++ b/features/controlcentercomponent/src/main/ets/com/ohos/pages/UpTitle.ets @@ -21,10 +21,14 @@ import StyleConfiguration, { ControlCenterUpTitleStyle } from '../common/StyleCo const TAG = 'Control-UpTitle'; +interface IDirection { + direction: string +} + @Component export default struct UpTitle { - private touchMoveCallback: Function; - private simpleToggleLayoutEditStartCallback: Function; + private touchMoveCallback: Function = (data: IDirection) => {}; + private simpleToggleLayoutEditStartCallback: Function = () => {}; startX: number = 0; startY: number = 0; @State moveX: number = 0; diff --git a/features/locationcomponent/src/main/ets/com/ohos/pages/ControlCenterSimpleToggleLocationComponent.ets b/features/locationcomponent/src/main/ets/com/ohos/pages/ControlCenterSimpleToggleLocationComponent.ets index aca83c1b..85b6bab9 100644 --- a/features/locationcomponent/src/main/ets/com/ohos/pages/ControlCenterSimpleToggleLocationComponent.ets +++ b/features/locationcomponent/src/main/ets/com/ohos/pages/ControlCenterSimpleToggleLocationComponent.ets @@ -24,7 +24,7 @@ const TAG = 'location-ControlCenterSimpleToggleLocationComponent'; @Component export default struct ControlCenterSimpleToggleLocationComponent { - private keyId: string; + private keyId: string = ''; private mEditMode: boolean = false; private mDragMode: boolean = false; @State mIcon: Resource = $r("app.media.ic_controlcenter_gps"); @@ -48,8 +48,8 @@ export default struct ControlCenterSimpleToggleLocationComponent { mLabel: $mLabel, mEditMode: this.mEditMode, mDragMode: this.mDragMode, - mClickEvent: () => this.mClickEvent(), - mLongClickEvent: () => this.mLongClickEvent() + mClickEvent: (): void => this.mClickEvent(), + mLongClickEvent: (): void => this.mLongClickEvent() }) } diff --git a/features/managementcomponent/oh-package.json5 b/features/managementcomponent/oh-package.json5 index 7bf51f40..65c8350f 100644 --- a/features/managementcomponent/oh-package.json5 +++ b/features/managementcomponent/oh-package.json5 @@ -3,5 +3,7 @@ "name": "@ohos/managementcomponent", "description": "a npm package which contains managementcomponent function", "version": "1.0.0", - "dependencies": {} + "dependencies": { + "@ohos/common": "file:../../common" + } } \ No newline at end of file diff --git a/features/managementcomponent/src/main/ets/com/ohos/model/notificationListener.ts b/features/managementcomponent/src/main/ets/com/ohos/model/notificationListener.ts index 5fdbaa12..51444512 100644 --- a/features/managementcomponent/src/main/ets/com/ohos/model/notificationListener.ts +++ b/features/managementcomponent/src/main/ets/com/ohos/model/notificationListener.ts @@ -16,11 +16,10 @@ import Log from '../../../../../../../../common/src/main/ets/default/Log'; import Notification from '@ohos.notification'; import NotificationManager from '@ohos.notificationManager'; import NotificationSubscribe from '@ohos.notificationSubscribe'; -import type { NotificationSubscriber } from 'notification/notificationSubscriber'; const TAG = 'NotificationManagenment-NotificationListener'; -interface IOnEnableChanged { +export interface IOnEnableChanged { (value: boolean): void; } @@ -36,7 +35,7 @@ export interface BundleOption { export class NotificationListener { private readonly listeners = new Map>(); - private subscriber: NotificationSubscriber = { + private subscriber: NotificationSubscribe.NotificationSubscriber = { onEnabledNotificationChanged: this.handleEnabledNotificationChanged.bind(this) }; @@ -126,7 +125,7 @@ export class NotificationListener { }); } - async isNotificationSlotEnabled(bundleOption: BundleOption, slotType: Notification.SlotType, callback?: (data) => void): Promise { + async isNotificationSlotEnabled(bundleOption: BundleOption, slotType: Notification.SlotType, callback?: (data: boolean) => void): Promise { Log.showDebug(TAG, `isNotificationSlotEnabled bundleOption:${JSON.stringify(bundleOption)} `); return new Promise((resolve, reject) => { NotificationManager.isNotificationSlotEnabled(bundleOption, slotType, (err, data) => { @@ -175,7 +174,7 @@ export class NotificationListener { }); } - enableDistributed(data: boolean): void { + enableDistributed(data?: boolean): void { Log.showDebug(TAG, `enableDistributed data:${JSON.stringify(data)}`); let enableValue: boolean = data ? true : false; NotificationManager.setDistributedEnable(enableValue, (err, result) => { diff --git a/features/managementcomponent/src/main/ets/com/ohos/view/component/appItemComponent.ets b/features/managementcomponent/src/main/ets/com/ohos/view/component/appItemComponent.ets index a2f223dc..56652893 100644 --- a/features/managementcomponent/src/main/ets/com/ohos/view/component/appItemComponent.ets +++ b/features/managementcomponent/src/main/ets/com/ohos/view/component/appItemComponent.ets @@ -230,7 +230,7 @@ export default struct AppItemComponent { Log.showInfo(TAG, `NotificationListener.isNotificationEnabled data:${JSON.stringify(stateValue)}`); this.canNotice = stateValue; }) - .catch((error) => { + .catch((error: Error) => { Log.showError(TAG, `NotificationListener.isNotificationEnabled error:${JSON.stringify(error)}`); }); diff --git a/features/managementcomponent/src/main/ets/com/ohos/view/component/appLstComponent.ets b/features/managementcomponent/src/main/ets/com/ohos/view/component/appLstComponent.ets index a97985ef..021b96b1 100644 --- a/features/managementcomponent/src/main/ets/com/ohos/view/component/appLstComponent.ets +++ b/features/managementcomponent/src/main/ets/com/ohos/view/component/appLstComponent.ets @@ -16,16 +16,18 @@ import ConfigData from '../../common/constants'; import AppItemComponent from './appItemComponent'; import Router from '@system.router'; import Log from '../../../../../../../../../common/src/main/ets/default/Log'; -import ViewModel from '../../vm/appLstComponentViewModel' +import ViewModel from '../../vm/appLstComponentViewModel'; +import { BundleItemData }from '../../model/bundleResourceModel'; const TAG = 'ManagementComponent-AppLstComponent'; @Component export default struct AppLstComponent { - @StorageLink('appManagementList') appList: any[]= []; + @StorageLink('appManagementList') appList: BundleItemData[]= []; aboutToAppear(): void{ Log.showInfo(TAG, `aboutToAppear`); + Log.showWarn(TAG, `myTest`); ViewModel.viewModelInit(); } @@ -43,14 +45,14 @@ export default struct AppLstComponent { build() { List() { - ForEach(this.appList, (item) => { + ForEach(this.appList, (item: BundleItemData) => { ListItem() { AppItemComponent({ appIcon: item.appIcon, appTitle: item.appTitle, appSummary: item.appSummary, appValue: item.appValue, - appArrow: item.appArrow, + appArrow: item.appArrow as string, appArrowStyle: '', appUri: item.appUri, appBundleName: item.appBundleName, diff --git a/features/managementcomponent/src/main/ets/com/ohos/view/component/slotLstComponent.ets b/features/managementcomponent/src/main/ets/com/ohos/view/component/slotLstComponent.ets index f5633512..7d4f743a 100644 --- a/features/managementcomponent/src/main/ets/com/ohos/view/component/slotLstComponent.ets +++ b/features/managementcomponent/src/main/ets/com/ohos/view/component/slotLstComponent.ets @@ -17,13 +17,15 @@ import Log from '../../../../../../../../../common/src/main/ets/default/Log'; import SlotItemComponent from './slotItemComponent'; import Notification from '@ohos.notification'; import Router from '@system.router' +import { BundleItemData } from '@ohos/common'; +import NotificationManager from '@ohos.notificationManager'; const TAG = 'ManagementComponent-SlotLstComponent'; @Component export default struct SlotLstComponent { - private appInfo: any= null; - @Link slotLst: any[]; + @Prop appInfo: BundleItemData; + @Link slotLst: NotificationManager.NotificationSlot[]; build() { Flex({ justifyContent: FlexAlign.SpaceBetween }) { @@ -42,13 +44,13 @@ export default struct SlotLstComponent { .align(Alignment.Start); Row() { List() { - ForEach(this.slotLst, (item) => { + ForEach(this.slotLst, (item: NotificationManager.NotificationSlot) => { ListItem() { SlotItemComponent({ slotType: item.type }) } .onClick(() => { Log.showInfo(TAG, `onClick`); - Router.push({ uri: this.appInfo.slotSettingUrl, params: {appInfo:this.appInfo,slotInfo:item} }); + Router.push({ uri: this.appInfo.slotSettingUrl, params: {appInfo:this.appInfo, slotInfo:item} }); }) }); }.divider({ diff --git a/features/managementcomponent/src/main/ets/com/ohos/view/component/switchComponent.ets b/features/managementcomponent/src/main/ets/com/ohos/view/component/switchComponent.ets index 0a8b4288..c7d47fc1 100644 --- a/features/managementcomponent/src/main/ets/com/ohos/view/component/switchComponent.ets +++ b/features/managementcomponent/src/main/ets/com/ohos/view/component/switchComponent.ets @@ -14,16 +14,17 @@ */ import ConfigData from '../../common/constants'; import Log from '../../../../../../../../../common/src/main/ets/default/Log'; +import { IOnEnableChanged } from '../../model/notificationListener'; const TAG = 'ManagementComponent-SwitchComponent'; @Component export default struct SwitchComponent { @Link title: Resource; - describe: Resource; - private initializationAction: (params?) => Promise - private settingAction: (params?) => void - private register?: (listener) => void + @Prop describe: Resource; + private initializationAction?: (params?: boolean) => Promise + private settingAction?: (params?: boolean) => void + private register?: (listener: IOnEnableChanged) => void @State initState: boolean = false build() { @@ -59,7 +60,7 @@ export default struct SwitchComponent { .onChange((data) => { Log.showInfo(TAG, `Toggle onChange data:${data}`); this.initState = data ? true : false; - this.settingAction(data); + this.settingAction && this.settingAction(data); }) } .flexShrink(0) @@ -76,9 +77,11 @@ export default struct SwitchComponent { aboutToAppear(): void{ Log.showInfo(TAG, `aboutToAppear`); - this.initializationAction().then((data) => { - Log.showInfo(TAG, `initializationAction:${data}`); - this.initState = data; - }) + if (this.initializationAction) { + this.initializationAction().then((data) => { + Log.showInfo(TAG, `initializationAction:${data}`); + this.initState = data; + }) + } } } \ No newline at end of file diff --git a/features/nfccomponent/src/main/ets/com/ohos/pages/ControlCenterSimpleToggleNFComponent.ets b/features/nfccomponent/src/main/ets/com/ohos/pages/ControlCenterSimpleToggleNFComponent.ets index e7102646..5f7b5b91 100644 --- a/features/nfccomponent/src/main/ets/com/ohos/pages/ControlCenterSimpleToggleNFComponent.ets +++ b/features/nfccomponent/src/main/ets/com/ohos/pages/ControlCenterSimpleToggleNFComponent.ets @@ -16,7 +16,7 @@ import Log from '../../../../../../../../common/src/main/ets/default/Log'; import EventManager from "../../../../../../../../common/src/main/ets/default/event/EventManager"; import { obtainStartAbility } from "../../../../../../../../common/src/main/ets/default/event/EventUtil"; -import NfcController from '@ohos.nfc.controller'; +import { nfcController } from '@kit.ConnectivityKit'; import ViewModel from '../viewmodel/NFCModeVM'; import SimpleToggleBase from '../../../../../../../../common/src/main/ets/template/SimpleToggleBase'; @@ -24,13 +24,13 @@ const TAG = 'nfcmode-ControlCenterSimpleToggleNFComponent'; @Component export default struct ControlCenterSimpleToggleNFComponent { - private keyId: string; + private keyId: string = ''; private mEditMode: boolean = false; private mDragMode: boolean = false; @State mIcon: Resource = $r("app.media.ic_notification_nfc_filled"); @State mLabel: Resource = $r("app.string.control_center_complex_toggle_nfc_mode_title"); @State mDefaultChangeSwitch: boolean = false; - @StorageLink('NFCModeComponentMode') @Watch('onNFCModeUpdated') NFCModeComponentMode: NfcController.NfcState = NfcController.NfcState.STATE_OFF; + @StorageLink('NFCModeComponentMode') @Watch('onNFCModeUpdated') NFCModeComponentMode: nfcController.NfcState = nfcController.NfcState.STATE_OFF; aboutToAppear() { Log.showInfo(TAG, 'aboutToAppear'); ViewModel.initViewModel(); @@ -43,9 +43,9 @@ export default struct ControlCenterSimpleToggleNFComponent { onNFCModeUpdated(propName: string): void { Log.showInfo(TAG, `onNFCModeUpdated, propName: ${propName} NFCModeComponentMode: ${JSON.stringify(this.NFCModeComponentMode)}`); - if (this.NFCModeComponentMode == NfcController.NfcState.STATE_OFF) { + if (this.NFCModeComponentMode == nfcController.NfcState.STATE_OFF) { this.mDefaultChangeSwitch = false; - } else if (this.NFCModeComponentMode == NfcController.NfcState.STATE_ON) { + } else if (this.NFCModeComponentMode == nfcController.NfcState.STATE_ON) { this.mDefaultChangeSwitch = true; } } @@ -58,16 +58,16 @@ export default struct ControlCenterSimpleToggleNFComponent { mLabel: $mLabel, mEditMode: this.mEditMode, mDragMode: this.mDragMode, - mClickEvent: () => this.mClickEvent() + mClickEvent: (): void => this.mClickEvent() }) } mClickEvent() { Log.showInfo(TAG, `mClickEvent---${this.NFCModeComponentMode}`); - if (this.NFCModeComponentMode == NfcController.NfcState.STATE_OFF) { - ViewModel.setNFCMode(NfcController.NfcState.STATE_OFF) - } else if (this.NFCModeComponentMode == NfcController.NfcState.STATE_ON) { - ViewModel.setNFCMode(NfcController.NfcState.STATE_ON) + if (this.NFCModeComponentMode == nfcController.NfcState.STATE_OFF) { + ViewModel.setNFCMode(nfcController.NfcState.STATE_OFF) + } else if (this.NFCModeComponentMode == nfcController.NfcState.STATE_ON) { + ViewModel.setNFCMode(nfcController.NfcState.STATE_ON) } } } \ No newline at end of file diff --git a/features/nfccomponent/src/main/ets/com/ohos/pages/StatusBarIconItemNFComponent.ets b/features/nfccomponent/src/main/ets/com/ohos/pages/StatusBarIconItemNFComponent.ets index dcceb94b..d2e0ea73 100644 --- a/features/nfccomponent/src/main/ets/com/ohos/pages/StatusBarIconItemNFComponent.ets +++ b/features/nfccomponent/src/main/ets/com/ohos/pages/StatusBarIconItemNFComponent.ets @@ -29,12 +29,11 @@ export default struct StatusBarIconItemNFCModeComponent { @State mTintContentInfo: TintContentInfo = ViewModel.getTintContentInfo(); @State styleCommon: CommonStyle = StyleConfigurationCommon.getCommonStyle(); @State style: StatusRingModeComponentStyle = StyleConfiguration.getStatusRingModeComponentStyle(); - private ringModeIcons: any; + private ringModeIcons: Resource[] = []; aboutToAppear() { Log.showInfo(TAG, 'aboutToAppear'); - this.ringModeIcons = {}; - this.ringModeIcons['0'] = $r("app.media.ic_statusbar_nfc"); + this.ringModeIcons[0] = $r("app.media.ic_statusbar_nfc"); ViewModel.initViewModel(); } @@ -46,7 +45,7 @@ export default struct StatusBarIconItemNFCModeComponent { Row() { if (this.NFCModeComponentMode != NfcController.NfcState.STATE_OFF) { Row().width(this.styleCommon.statusBarMarginLeftRight).height('100%') - Image(this.ringModeIcons['0']) + Image(this.ringModeIcons[0]) .objectFit(ImageFit.Contain) .width(this.style.statusBarRingModeWidth) .height(this.style.statusBarRingModeHeight) diff --git a/features/noticeitem/oh-package.json5 b/features/noticeitem/oh-package.json5 index 497ce024..b76f085e 100644 --- a/features/noticeitem/oh-package.json5 +++ b/features/noticeitem/oh-package.json5 @@ -3,5 +3,7 @@ "name": "@ohos/noticeitem", "description": "a npm package which contains noticeitem function", "version": "1.0.0", - "dependencies": {} + "dependencies": { + "@ohos/common": "file:../../common" + } } \ No newline at end of file diff --git a/features/noticeitem/src/main/ets/com/ohos/noticeItem/common/CommonUtil.ts b/features/noticeitem/src/main/ets/com/ohos/noticeItem/common/CommonUtil.ts index dac86d97..eeae95fe 100644 --- a/features/noticeitem/src/main/ets/com/ohos/noticeItem/common/CommonUtil.ts +++ b/features/noticeitem/src/main/ets/com/ohos/noticeItem/common/CommonUtil.ts @@ -29,6 +29,9 @@ export default class CommonUtil { static startWant(want, triggerInfo?: any): void { let info = (triggerInfo) ? triggerInfo : DEFAULT_INFO; Log.showDebug(TAG, `startWant ${JSON.stringify(want)}, info ${JSON.stringify(info)}`); + if (!want) { + return; + } WantAgent.trigger(want, info, ((data) => { Trace.end(Trace.CORE_METHOD_CLICK_NOTIFICATION); Log.showInfo(TAG, `wantAgent trigger data ${JSON.stringify(data)}`); diff --git a/features/noticeitem/src/main/ets/com/ohos/noticeItem/common/constants.ts b/features/noticeitem/src/main/ets/com/ohos/noticeItem/common/constants.ts index 4a1cfc01..72c847e5 100644 --- a/features/noticeitem/src/main/ets/com/ohos/noticeItem/common/constants.ts +++ b/features/noticeitem/src/main/ets/com/ohos/noticeItem/common/constants.ts @@ -12,6 +12,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import notificationManager from '@ohos.notificationManager'; +import image from '@ohos.multimedia.image'; +import { WantAgent } from '@ohos.wantAgent'; export default class Constants { static readonly NOTIFICATION_TYPE_BASIC = '0'; @@ -90,12 +93,12 @@ export interface NotificationItemData { timestamp: number; time: string; appName: string; - want: any; - actionButtons: any[]; + want: WantAgent; + actionButtons: notificationManager.ButtonOptions[]; bundleName: string; - smallIcon?: PixelMap | string; - largeIcon?: PixelMap | string; - picture?: PixelMap; + smallIcon?: image.PixelMap | string; + largeIcon?: image.PixelMap | string; + picture?: image.PixelMap; title?: string; text?: string; additionalText?: string; diff --git a/features/noticeitem/src/main/ets/com/ohos/noticeItem/model/NotificationDistributionManager.ts b/features/noticeitem/src/main/ets/com/ohos/noticeItem/model/NotificationDistributionManager.ts index 9997c713..2ebf6eb2 100644 --- a/features/noticeitem/src/main/ets/com/ohos/noticeItem/model/NotificationDistributionManager.ts +++ b/features/noticeitem/src/main/ets/com/ohos/noticeItem/model/NotificationDistributionManager.ts @@ -15,7 +15,6 @@ import Log from '../../../../../../../../../common/src/main/ets/default/Log'; import deviceManager from '@ohos.distributedDeviceManager'; -import DeviceInfo from '@ohos.deviceInfo'; const TAG = 'NotificationDistributionManager'; @@ -56,7 +55,7 @@ export default class NotificationDistributionManager { getTrustedDeviceDeviceName(deviceId: string): string { Log.showInfo(TAG, `getTrustedDeviceDeviceName deviceId:${deviceId}`); let deviceName = ''; - let deviceArr: any[] = this.getTrustedDeviceListSync(); + let deviceArr: deviceManager.DeviceBasicInfo[] = this.getTrustedDeviceListSync(); Log.showDebug(TAG, `getTrustedDeviceDeviceName deviceArr:${JSON.stringify(deviceArr)}`); if (deviceArr.length > 0) { for (let item of deviceArr) { @@ -69,7 +68,7 @@ export default class NotificationDistributionManager { return deviceName; } - getTrustedDeviceListSync(): any[] { + getTrustedDeviceListSync(): deviceManager.DeviceBasicInfo[] { Log.showInfo(TAG, 'getTrustedDeviceListSync'); return this.deviceManager.getAvailableDeviceListSync(); } diff --git a/features/noticeitem/src/main/ets/com/ohos/noticeItem/view/NotificationListComponent.ets b/features/noticeitem/src/main/ets/com/ohos/noticeItem/view/NotificationListComponent.ets index 4076ca53..f1c9c5d6 100644 --- a/features/noticeitem/src/main/ets/com/ohos/noticeItem/view/NotificationListComponent.ets +++ b/features/noticeitem/src/main/ets/com/ohos/noticeItem/view/NotificationListComponent.ets @@ -14,14 +14,14 @@ */ import Log from '../../../../../../../../../common/src/main/ets/default/Log'; -import Constants, {NotificationLayout as Layout} from '../common/constants'; +import Constants, {NotificationLayout as Layout, NotificationItemData} from '../common/constants'; import NotificationItem from './item/notificationItem'; import GroupNotificationItem from './item/groupItem'; import ExpandInfoManager from '../model/ExpandInfoManager'; const TAG = 'NoticeItem-NotificationListComponent'; -type NotificationLayoutConfig = { +interface NotificationLayoutConfig { itemMargin: number; } @@ -29,7 +29,7 @@ type NotificationLayoutConfig = { export default struct NotificationListComponent { // 当长通知消息展开时,这里用于重新刷新item布局,扩展高度 @Provide('notificationUpdate') update: number = 0; - @StorageLink('notificationList') notificationList: any[] = []; + @StorageLink('notificationList') notificationList: NotificationItemData[][] = []; @Link listIsEnd: boolean private config: NotificationLayoutConfig = { itemMargin: Layout.ITEM_MARGIN @@ -43,7 +43,7 @@ export default struct NotificationListComponent { Log.showDebug(TAG, `aboutToDisAppear`); } - deleteExpandInfo(itemData){ + deleteExpandInfo(itemData: NotificationItemData){ ExpandInfoManager.deleteExpandInfo(itemData); return true; } @@ -54,7 +54,7 @@ export default struct NotificationListComponent { ListItem() { } } - ForEach(this.notificationList, (item: any) => { + ForEach(this.notificationList, (item: NotificationItemData[]) => { ListItem() { if (item.length > 1) { GroupNotificationItem({ groupData: item }) @@ -65,7 +65,7 @@ export default struct NotificationListComponent { } } } - }, (list: any) => JSON.stringify(list.map((item) => `${item.hashcode}_${item.timestamp}`))) + }, (list: NotificationItemData[]) => JSON.stringify(list.map((item) => `${item.hashcode}_${item.timestamp}`))) } .onReachEnd(() => { this.listIsEnd = true; diff --git a/features/noticeitem/src/main/ets/com/ohos/noticeItem/view/item/SwipeLayout.ets b/features/noticeitem/src/main/ets/com/ohos/noticeItem/view/item/SwipeLayout.ets index 4dd764f3..b312f274 100644 --- a/features/noticeitem/src/main/ets/com/ohos/noticeItem/view/item/SwipeLayout.ets +++ b/features/noticeitem/src/main/ets/com/ohos/noticeItem/view/item/SwipeLayout.ets @@ -37,10 +37,10 @@ export default struct SwipeLayout { bottomRightWidth: number = 0; leftThreshold: number = 0; bottomHeight: number = 92; - deleteButtonCallback: any; - @BuilderParam SurfaceComponent?: () => void; - @BuilderParam BottomLeftComponent?: () => void; - registerEventCapture: (id: string) => boolean = null; + deleteButtonCallback: () => void = () => {}; + @BuilderParam SurfaceComponent: () => void; + @BuilderParam BottomLeftComponent: () => void; + registerEventCapture: (id: string) => boolean = (id) => true; // Page offset, opacity, width height status variable. @State overallX: number = 0; @@ -209,7 +209,7 @@ export default struct SwipeLayout { return; } if(this.angelCalFlag == false){ - var hasChange = Math.abs(touchEvent.touches[0].screenX - this.startX) > 1e-3 || + let hasChange = Math.abs(touchEvent.touches[0].screenX - this.startX) > 1e-3 || Math.abs(touchEvent.touches[0].screenY - this.startY) > 1e-3 if (hasChange) { this.responseSwipeEvent = (Math.abs(touchEvent.touches[0].screenX - this.startX) > Math.abs(touchEvent.touches[0].screenY - this.startY)); diff --git a/features/noticeitem/src/main/ets/com/ohos/noticeItem/view/item/actionComponent.ets b/features/noticeitem/src/main/ets/com/ohos/noticeItem/view/item/actionComponent.ets index 7f52ad21..7ce5f08f 100644 --- a/features/noticeitem/src/main/ets/com/ohos/noticeItem/view/item/actionComponent.ets +++ b/features/noticeitem/src/main/ets/com/ohos/noticeItem/view/item/actionComponent.ets @@ -16,26 +16,28 @@ import Log from '../../../../../../../../../../common/src/main/ets/default/Log'; import CheckEmptyUtils from '../../../../../../../../../../common/src/main/ets/default/CheckEmptyUtils'; import NotificationViewModel from '../../viewmodel/NotificationViewModel'; -import Constants, {InputActionButtonData, NotificationLayout as Layout} from '../../common/constants'; +import Constants, {InputActionButtonData, NotificationLayout as Layout, NotificationItemData} from '../../common/constants'; +import notificationManager from '@ohos.notificationManager'; +import type { WantAgent } from '@kit.AbilityKit'; const TAG = 'NoticeItem-ActionComponent'; class actionInputData { - inputKey?; - wantAgent? + inputKey?: string; + wantAgent?: WantAgent } @Component export default struct ActionComponent { @State showInputText: boolean = false; @State placeholder: string = ''; - @State inputData: actionInputData = undefined; + @State inputData: actionInputData | undefined = undefined; @State inputActionData: InputActionButtonData = new InputActionButtonData(); - private itemData: any = undefined; + @Prop itemData: NotificationItemData; aboutToAppear() { Log.showInfo(TAG, `aboutToAppear Start`); - let actionData = AppStorage.Get(Constants.KEY_INPUT + this.itemData.id); + let actionData = AppStorage.Get(Constants.KEY_INPUT + this.itemData.id) as actionInputData; this.inputActionData = (actionData instanceof InputActionButtonData) ? actionData : this.inputActionData; } @@ -46,14 +48,14 @@ export default struct ActionComponent { build() { Flex({ direction: FlexDirection.Row, justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { if (!this.inputData) { - ForEach(this.itemData.actionButtons, (item: any) => { + ForEach(this.itemData.actionButtons, (item: notificationManager.NotificationActionButton) => { ActionButton({ content: item.title, clickEvent: () => { if (CheckEmptyUtils.isEmpty(item.userInput)) { NotificationViewModel.clickItem(this.itemData, item.wantAgent); } else { - this.inputData = { inputKey: item.userInput.inputKey, wantAgent: item.wantAgent }; + this.inputData = { inputKey: item.userInput?.inputKey, wantAgent: item.wantAgent }; } } }) @@ -72,7 +74,7 @@ export default struct ActionComponent { .width(Layout.INPUT_IMAGE_SIZE) .height(Layout.INPUT_IMAGE_SIZE) .onClick(() => { - NotificationViewModel.clickReply(this.inputData.inputKey, this.placeholder, this.inputData.wantAgent); + NotificationViewModel.clickReply(this.inputData?.inputKey, this.placeholder, this.inputData?.wantAgent); this.inputActionData = { isSending: true, content: this.placeholder diff --git a/features/noticeitem/src/main/ets/com/ohos/noticeItem/view/item/bannerNotificationItem.ets b/features/noticeitem/src/main/ets/com/ohos/noticeItem/view/item/bannerNotificationItem.ets index e1d5fc54..5b20e9a0 100644 --- a/features/noticeitem/src/main/ets/com/ohos/noticeItem/view/item/bannerNotificationItem.ets +++ b/features/noticeitem/src/main/ets/com/ohos/noticeItem/view/item/bannerNotificationItem.ets @@ -16,7 +16,8 @@ import Log from '../../../../../../../../../../common/src/main/ets/default/Log'; import AbilityManager from '../../../../../../../../../../common/src/main/ets/default/abilitymanager/abilityManager'; import WindowManager, { WindowType } from '../../../../../../../../../../common/src/main/ets/default/WindowManager'; -import {notificationData} from '../../../../../../../../../../common/src/main/ets/plugindatasource/common/Constants' +// import {notificationData} from '../../../../../../../../../../common/src/main/ets/plugindatasource/common/Constants' +import { NotificationItemData } from '@ohos/common' import Constants, {NotificationLayout as Layout} from '../../common/constants'; import NotificationViewModel from '../../viewmodel/NotificationViewModel'; import CustomItem from './customItem'; @@ -28,32 +29,47 @@ import pictureItem from './pictureItem'; import ActionComponent from './actionComponent'; import DevicesDialog from './devicesDialog'; import WantAgent from '@ohos.wantAgent'; +import { Rect } from '@ohos/common'; const TAG = 'NoticeItem-BannerNotificationItem'; const INTERVAL = 5 * 1000; +class EmptyObject {} + +interface TriggerInfo { + code: number; + want: Want | undefined; + permission: string; + extraInfo: EmptyObject; +} + @Component export default struct BannerNotificationItem { - @State want : notificationData = new notificationData(); + @State want : NotificationItemData | undefined = undefined; @Link distributedDeviceName: string; @Link mBannerNoticeCnt: number; @Link mLastActionTime: number; @Link needExpand: boolean; @Link isExpand: boolean; @State mCloseEnableFlg: boolean = false; - private nowWant: any; - private onBannerNoticeHide: () => void - private devicesDialogController: CustomDialogController = new CustomDialogController({ + private nowWant: Want | undefined = undefined; + private onBannerNoticeHide: () => void = () => {}; + private devicesDialogController: CustomDialogController | null = new CustomDialogController({ builder: DevicesDialog({ - action: (deviceID) => this.selectedDevice(deviceID) + action: (deviceID): void => this.selectedDevice(deviceID) }), autoCancel: false, offset: { dx: 0, dy: 200 } }); mInterval: number = INTERVAL; - mDefaultBannerRect: any; + mDefaultBannerRect: Rect = { + left: 0, + top: 0, + width: 0, + height: 0 + }; expandPaddingBottom: number = Layout.EXPAND_PADDING_BOTTOM; aboutToAppear() { @@ -68,29 +84,28 @@ export default struct BannerNotificationItem { } aboutToDisappear() { - delete this.devicesDialogController - this.devicesDialogController = undefined + this.devicesDialogController = null; Log.showInfo(TAG, `aboutToDisAppear`); } build() { Column() { if (this.mBannerNoticeCnt > 0) { - if (this.want.template) { + if (this.want?.template) { CustomItem({ customItemData: this.want, isSubItem: false }) } else { Row() { Flex({ alignItems: ItemAlign.Center, justifyContent: FlexAlign.Start }) { Row() { titleItem({ - notificationSmallIcon: this.want.smallIcon, - notificationName: this.want.appName, - notificationTime: this.want.time, + notificationSmallIcon: this.want?.smallIcon as PixelMap, + notificationName: this.want?.appName, + notificationTime: this.want?.time, isExpand: $isExpand, needExpand: this.needExpand, distributedDeviceName: this.distributedDeviceName, isSubItem: false, - clickTitleAction: () => this.refreshLastActionTime() + clickTitleAction: (): void => this.refreshLastActionTime() }) } @@ -113,7 +128,7 @@ export default struct BannerNotificationItem { isExpand: this.isExpand, itemData: this.want }); - if (this.isExpand && this.want.actionButtons.length) { + if (this.isExpand && this.want?.actionButtons.length) { ActionComponent({ itemData: this.want }) } else { Blank() @@ -128,15 +143,15 @@ export default struct BannerNotificationItem { Log.showInfo(TAG, `onAreaChange, e: ${JSON.stringify(e)} e2: ${JSON.stringify(e2)}`); let heightEx = parseInt(String(e['height'])); let heightCur = parseInt(String(e2['height'])); - let heightWin = parseInt(this.mDefaultBannerRect['height']); + let heightWin = this.mDefaultBannerRect?.height; if (this.isExpand) { - heightWin = heightWin + (heightCur - heightEx) + this.expandPaddingBottom; + heightWin = heightWin as number + (heightCur - heightEx) + this.expandPaddingBottom; } - let bannerRect = { - top: this.mDefaultBannerRect['top'], - left: this.mDefaultBannerRect['left'], - width: this.mDefaultBannerRect['width'], - height: heightWin + let bannerRect: Rect = { + top: this.mDefaultBannerRect.top, + left: this.mDefaultBannerRect.left, + width: this.mDefaultBannerRect.width, + height: heightWin as number }; WindowManager.resetSizeWindow(WindowType.BANNER_NOTICE, bannerRect); WindowManager.showWindow(WindowType.BANNER_NOTICE); @@ -198,7 +213,7 @@ export default struct BannerNotificationItem { WantAgent.getWant(wantAgent).then((wantData) => { this.nowWant = wantData if (!wantData?.deviceId) { - this.devicesDialogController.open(); + this.devicesDialogController?.open(); } else{ NotificationViewModel.clickItem(this.want); } @@ -207,10 +222,12 @@ export default struct BannerNotificationItem { } } - selectedDevice(deviceID) { + selectedDevice(deviceID: string) { Log.showInfo(TAG, `selectedDevice deviceID:${deviceID}`); - this.nowWant.deviceId = deviceID; - let triggerInfo = { + if (this.nowWant) { + this.nowWant.deviceId = deviceID; + } + let triggerInfo: TriggerInfo = { code: 0, want: this.nowWant, permission: '', @@ -231,7 +248,7 @@ export default struct BannerNotificationItem { @Component struct ContentComponent { @Prop isExpand: boolean; - itemData: any; + @Prop itemData: NotificationItemData; aboutToAppear() { Log.showInfo(TAG, `aboutToAppear NotificationItemData: ${JSON.stringify(this.itemData)}`); diff --git a/features/noticeitem/src/main/ets/com/ohos/noticeItem/view/item/basicItem.ets b/features/noticeitem/src/main/ets/com/ohos/noticeItem/view/item/basicItem.ets index 03886ba1..67098ab2 100644 --- a/features/noticeitem/src/main/ets/com/ohos/noticeItem/view/item/basicItem.ets +++ b/features/noticeitem/src/main/ets/com/ohos/noticeItem/view/item/basicItem.ets @@ -16,7 +16,7 @@ import Constants, {NotificationItemData, NotificationLayout as Layout} from '../../common/constants'; @Component export default struct BasicItem { - @State itemData: NotificationItemData = undefined + @Prop itemData: NotificationItemData build() { Column() { diff --git a/features/noticeitem/src/main/ets/com/ohos/noticeItem/view/item/confirmDialog.ets b/features/noticeitem/src/main/ets/com/ohos/noticeItem/view/item/confirmDialog.ets index e68de8df..f9d53bef 100644 --- a/features/noticeitem/src/main/ets/com/ohos/noticeItem/view/item/confirmDialog.ets +++ b/features/noticeitem/src/main/ets/com/ohos/noticeItem/view/item/confirmDialog.ets @@ -26,10 +26,10 @@ const TAG = 'NoticeItem-Confirm'; */ @CustomDialog export default struct ConfirmDialog { - private title: string | Resource - private bundleName: string + private title: string | Resource = '' + private bundleName: string = '' public controller: CustomDialogController - public action: () => void + public action: () => void = () => {} build() { Column() { diff --git a/features/noticeitem/src/main/ets/com/ohos/noticeItem/view/item/customItem.ets b/features/noticeitem/src/main/ets/com/ohos/noticeItem/view/item/customItem.ets index 67ba3174..75b24d07 100644 --- a/features/noticeitem/src/main/ets/com/ohos/noticeItem/view/item/customItem.ets +++ b/features/noticeitem/src/main/ets/com/ohos/noticeItem/view/item/customItem.ets @@ -18,22 +18,24 @@ import Log from '../../../../../../../../../../common/src/main/ets/default/Log'; import NotificationViewModel from '../../viewmodel/NotificationViewModel'; import NotificationManager from '../../model/NotificationManager'; import {NotificationLayout as Layout} from '../../common/constants'; +import { NotificationItemData } from '@ohos/common' +import NtfMgr from '@ohos.notificationManager'; const TAG = 'NoticeItem-CustomItem'; @Component export default struct CustomItem { - private customItemData: any = {}; - private template: any = {}; - private templateData: any = {}; + private customItemData: NotificationItemData | undefined = undefined; + private template: PluginComponentTemplate | undefined = undefined; + private templateData: Record = {}; private isSubItem: boolean= false; private isDebugMode: boolean = false; - private clickAction: () => void + private clickAction: () => void = () => {} aboutToAppear() { Log.showInfo(TAG, `aboutToAppear Start`); - this.template = NotificationViewModel.getPluginTempLate(this.customItemData.template.name); - this.templateData = this.customItemData.template.data; + this.template = NotificationViewModel.getPluginTempLate(this.customItemData?.template?.name); + this.templateData = this.customItemData?.template?.data as Record; this.isDebugMode = NotificationManager.isDebugMode(TAG); Log.showInfo(TAG, `template = ${JSON.stringify(this.template)} templateData = ${JSON.stringify(this.templateData)} isDebugMode = ${this.isDebugMode}`); } @@ -46,8 +48,8 @@ export default struct CustomItem { data: this.templateData }).onComplete(() => { Log.showInfo(TAG, `Complete`); - }).onError(({errcode, msg}) => { - Log.showInfo(TAG, `Error code:${errcode} message:${msg}`); + }).onError((error) => { + Log.showInfo(TAG, `Error code:${error.errcode} message:${error.msg}`); }) .size({ width: '100%', height: 110 }) } diff --git a/features/noticeitem/src/main/ets/com/ohos/noticeItem/view/item/devicesDialog.ets b/features/noticeitem/src/main/ets/com/ohos/noticeItem/view/item/devicesDialog.ets index d66b2c4d..fb84df79 100644 --- a/features/noticeitem/src/main/ets/com/ohos/noticeItem/view/item/devicesDialog.ets +++ b/features/noticeitem/src/main/ets/com/ohos/noticeItem/view/item/devicesDialog.ets @@ -16,6 +16,7 @@ import Constants from '../../common/constants'; import Log from '../../../../../../../../../../common/src/main/ets/default/Log'; import DistributionManager from '../../model/NotificationDistributionManager'; +import deviceManager from '@ohos.distributedDeviceManager' const TAG = 'NoticeItem-DevicesDialog'; @@ -25,9 +26,9 @@ const TAG = 'NoticeItem-DevicesDialog'; */ @CustomDialog export default struct DevicesDialog { - private deviceInfoList: Array; + private deviceInfoList: Array = []; public controller: CustomDialogController - public action: (deviceID) => void + public action: (deviceID: string) => void = (deviceID) => {} build() { Column({ space: 30 }) { @@ -40,7 +41,7 @@ export default struct DevicesDialog { Column() { List() { - ForEach(this.deviceInfoList, (item) => { + ForEach(this.deviceInfoList, (item: deviceManager.DeviceBasicInfo) => { ListItem() { Row() { Column() { diff --git a/features/noticeitem/src/main/ets/com/ohos/noticeItem/view/item/generalItem.ets b/features/noticeitem/src/main/ets/com/ohos/noticeItem/view/item/generalItem.ets index 87a24cd8..fcd39b66 100644 --- a/features/noticeitem/src/main/ets/com/ohos/noticeItem/view/item/generalItem.ets +++ b/features/noticeitem/src/main/ets/com/ohos/noticeItem/view/item/generalItem.ets @@ -13,7 +13,7 @@ * limitations under the License. */ -import Constants, { NotificationLayout as Layout } from '../../common/constants'; +import Constants, { NotificationItemData, NotificationLayout as Layout } from '../../common/constants'; import basicItem from './basicItem'; import longItem from './longItem'; import multiItem from './multiItem'; @@ -33,8 +33,8 @@ export default struct GeneralItem { @State @Watch('expandChange') isExpand: boolean = false @State needExpand: boolean = true @State distributedDeviceName: string = '' - private itemData: any = {} - private clickAction: () => void + @Prop itemData: NotificationItemData + private clickAction: () => void = () => {} private isSubItem: boolean= false; expandChange() { @@ -70,7 +70,7 @@ export default struct GeneralItem { build() { Column() { titleItem({ - notificationSmallIcon: this.itemData.smallIcon, + notificationSmallIcon: this.itemData.smallIcon as PixelMap, notificationName: this.itemData.appName, notificationTime: this.itemData.time, isExpand: $isExpand, @@ -98,7 +98,7 @@ export default struct GeneralItem { @Component struct ContentComponent { @Prop isExpand: boolean; - itemData: any; + @Prop itemData: NotificationItemData; aboutToAppear() { Log.showInfo(TAG, `aboutToAppear pict: ${this.itemData.picture}`); diff --git a/features/noticeitem/src/main/ets/com/ohos/noticeItem/view/item/groupItem.ets b/features/noticeitem/src/main/ets/com/ohos/noticeItem/view/item/groupItem.ets index c71141cc..77fbcacb 100644 --- a/features/noticeitem/src/main/ets/com/ohos/noticeItem/view/item/groupItem.ets +++ b/features/noticeitem/src/main/ets/com/ohos/noticeItem/view/item/groupItem.ets @@ -14,7 +14,7 @@ */ import Log from '../../../../../../../../../../common/src/main/ets/default/Log'; -import Constants, { NotificationLayout as Layout } from '../../common/constants'; +import Constants, { NotificationItemData, NotificationLayout as Layout } from '../../common/constants'; import NotificationItem from './notificationItem' import NotificationViewModel from '../../viewmodel/NotificationViewModel'; import SwipeLayout from './SwipeLayout'; @@ -32,7 +32,7 @@ export default struct GroupItem { @Consume('notificationUpdate') updateFlag: number; @State distributedDeviceName: string = ''; @State @Watch('expandChange') toExpand: boolean = false; - private groupData: any[] = []; + private groupData: NotificationItemData[] = []; registerGroupItemEventCapture(id: string){ if(FocusCallBack.getLastFocusId() == getId(this.groupData[0], true)){ @@ -59,7 +59,7 @@ export default struct GroupItem { Log.showInfo(TAG, `aboutToDisAppear`); } - deleteButtonCallback(){ + deleteButtonCallback(): void { ExpandInfoManager.deleteExpandInfo(this.groupData[0]); NotificationViewModel.removeGroupNotification(this.groupData[0], true); } @@ -155,10 +155,10 @@ export default struct GroupItem { @Component struct ContentList { - @State @Watch('remainderChange') groupData: any[] = []; + @State @Watch('remainderChange') groupData: NotificationItemData[] = []; @Prop toExpand: boolean; @State remainderNum: number= 0; - registerEventCapture: (id: string) => boolean = null; + registerEventCapture: (id: string) => boolean = (id) => true; registerContentListEventCapture(id: string){ if(this.registerEventCapture != null && this.registerEventCapture(id)){ @@ -232,11 +232,11 @@ struct ContentList { } else { List() { - ForEach(this.groupData, (item: any) => { + ForEach(this.groupData, (item: NotificationItemData) => { ListItem() { NotificationItem({ itemData: item, isSubItem: true, registerEventCapture: this.registerContentListEventCapture.bind(this) }) } - }, (item: any) => `${item.hashcode}_${item.timestamp}_subitem`) + }, (item: NotificationItemData) => `${item.hashcode}_${item.timestamp}_subitem`) } .divider({ strokeWidth: 1, diff --git a/features/noticeitem/src/main/ets/com/ohos/noticeItem/view/item/iconListComponent.ets b/features/noticeitem/src/main/ets/com/ohos/noticeItem/view/item/iconListComponent.ets index 44f8c805..38084a38 100644 --- a/features/noticeitem/src/main/ets/com/ohos/noticeItem/view/item/iconListComponent.ets +++ b/features/noticeitem/src/main/ets/com/ohos/noticeItem/view/item/iconListComponent.ets @@ -13,7 +13,7 @@ * limitations under the License. */ -import Constants, { NotificationLayout as Layout } from '../../common/constants'; +import Constants, { NotificationItemData, NotificationLayout as Layout } from '../../common/constants'; import Log from '../../../../../../../../../../common/src/main/ets/default/Log'; import SettingDialog from './settingDialog'; import ConfirmDialog from './confirmDialog' @@ -24,12 +24,12 @@ const deviceTypeInfo = deviceInfo.deviceType; const TAG = 'NoticeItem-IconListComponent'; let iconSize: number = 0; -type IconData = { +interface IconData { src?: Resource; callback?: () => void } -export type NotificationUiConfig = { +export interface NotificationUiConfig { iconSize: number; } @@ -40,23 +40,23 @@ export function getIconListSize(list?: IconData[]) { @Component export default struct IconListComponent { - private itemData: any = {} + private itemData: NotificationItemData | undefined = undefined private isGroup: boolean= false; @Prop iconAlpha: number - private settingDialogController: CustomDialogController = new CustomDialogController({ + private settingDialogController: CustomDialogController | null = new CustomDialogController({ builder: SettingDialog({ itemData: this.itemData, - action: () => this.confirmDialogController.open() + action: (): void => this.confirmDialogController?.open() }), autoCancel: false, alignment: deviceTypeInfo === 'phone' ? DialogAlignment.Bottom : DialogAlignment.Default, offset: { dx: 0, dy: $r('app.float.setting_dialog_dy') }, customStyle: true }); - private confirmDialogController: CustomDialogController = new CustomDialogController({ + private confirmDialogController: CustomDialogController | null = new CustomDialogController({ builder: ConfirmDialog({ title: $r('app.string.closeNovice'), - bundleName: this.itemData.name, + bundleName: this.itemData?.appName, action: () => NotificationViewModel.enableNotification(this.itemData, false) }), autoCancel: false, @@ -69,7 +69,7 @@ export default struct IconListComponent { src: $r("app.media.ic_public_settings_filled"), callback: () => { Log.showInfo(TAG, `click settings hashcode: ${this.itemData?.hashcode}`); - this.settingDialogController.open() + this.settingDialogController?.open() } }, { src: $r("app.media.ic_public_delete_filled"), @@ -91,18 +91,14 @@ export default struct IconListComponent { } aboutToDisappear() { - delete this.settingDialogController - this.settingDialogController = undefined - - delete this.confirmDialogController - this.confirmDialogController = undefined - + this.settingDialogController = null + this.confirmDialogController = null Log.showInfo(TAG, 'aboutToDisappear') } build() { Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.End, justifyContent: FlexAlign.End }) { - ForEach(this.iconConfigs, (item) => { + ForEach(this.iconConfigs, (item: IconData) => { Button({ type: ButtonType.Circle, stateEffect: true }) { if (item.src) { Image(item.src) @@ -126,13 +122,13 @@ export default struct IconListComponent { @Component export struct BottomLeftItem { - private itemData: any = {}; + private itemData: NotificationItemData | undefined = undefined; private bottomLeftItemHeight: number = 92; - private settingDialogController: CustomDialogController = new CustomDialogController({ + private settingDialogController: CustomDialogController | null = new CustomDialogController({ builder: SettingDialog({ itemData: this.itemData, - action: () => this.confirmDialogController.open() + action: (): void => this.confirmDialogController?.open() }), autoCancel: false, alignment: deviceTypeInfo === 'phone' ? DialogAlignment.Bottom : DialogAlignment.Default, @@ -140,10 +136,10 @@ export struct BottomLeftItem { customStyle: true }); - private confirmDialogController: CustomDialogController = new CustomDialogController({ + private confirmDialogController: CustomDialogController | null = new CustomDialogController({ builder: ConfirmDialog({ title: $r('app.string.closeNovice'), - bundleName: this.itemData.name, + bundleName: this.itemData?.appName, action: () => NotificationViewModel.enableNotification(this.itemData, false) }), autoCancel: false, @@ -153,12 +149,8 @@ export struct BottomLeftItem { }); aboutToDisappear() { - delete this.settingDialogController - this.settingDialogController = undefined - - delete this.confirmDialogController - this.confirmDialogController = undefined - + this.settingDialogController = null + this.confirmDialogController = null Log.showInfo(TAG, 'BottomLeftItem -> aboutToDisappear') } @@ -172,7 +164,7 @@ export struct BottomLeftItem { .height(Layout.ICON_SIZE) } .backgroundColor($r("app.color.button_background")) - .onClick(() => this.settingDialogController.open()) + .onClick(() => this.settingDialogController?.open()) .width(Layout.BUTTON_SIZE) .height(Layout.BUTTON_SIZE) } diff --git a/features/noticeitem/src/main/ets/com/ohos/noticeItem/view/item/longItem.ets b/features/noticeitem/src/main/ets/com/ohos/noticeItem/view/item/longItem.ets index badcd6aa..198c8546 100644 --- a/features/noticeitem/src/main/ets/com/ohos/noticeItem/view/item/longItem.ets +++ b/features/noticeitem/src/main/ets/com/ohos/noticeItem/view/item/longItem.ets @@ -18,7 +18,7 @@ import Constants, {NotificationItemData, NotificationLayout as Layout} from '../ @Component export default struct LongItem { - @State itemData: NotificationItemData= undefined + @Prop itemData: NotificationItemData @Prop isExpand: boolean build() { diff --git a/features/noticeitem/src/main/ets/com/ohos/noticeItem/view/item/multiItem.ets b/features/noticeitem/src/main/ets/com/ohos/noticeItem/view/item/multiItem.ets index 806da43a..ca88aa8b 100644 --- a/features/noticeitem/src/main/ets/com/ohos/noticeItem/view/item/multiItem.ets +++ b/features/noticeitem/src/main/ets/com/ohos/noticeItem/view/item/multiItem.ets @@ -17,7 +17,7 @@ import Constants, {NotificationItemData, NotificationLayout as Layout} from '../ @Component export default struct MultiItem { - @State itemData: NotificationItemData= undefined + @Prop itemData: NotificationItemData @Prop isExpand: boolean build() { diff --git a/features/noticeitem/src/main/ets/com/ohos/noticeItem/view/item/notificationItem.ets b/features/noticeitem/src/main/ets/com/ohos/noticeItem/view/item/notificationItem.ets index 8d541a78..9081f47a 100644 --- a/features/noticeitem/src/main/ets/com/ohos/noticeItem/view/item/notificationItem.ets +++ b/features/noticeitem/src/main/ets/com/ohos/noticeItem/view/item/notificationItem.ets @@ -24,17 +24,27 @@ import {BottomLeftItem} from './iconListComponent'; import deviceInfo from '@ohos.deviceInfo'; import SwipeLayout from './SwipeLayout'; import {getId} from '../../model/SwipeLayoutUtils'; +import { NotificationItemData } from '../../common/constants' const TAG = 'NoticeItem-NotificationItem'; const deviceTypeInfo = deviceInfo.deviceType; +class EmptyObject {} + +interface TriggerInfo { + code: number; + want: Want | undefined; + permission: string; + extraInfo: EmptyObject; +} + @Component export default struct NotificationItem { @State mIconAlpha: number = 0; @State itemWidth: string = '100%'; - private itemData: any = {}; + @Prop itemData: NotificationItemData; private isSubItem: boolean= false; - registerEventCapture: (id: string) => boolean = null; + registerEventCapture: (id: string) => boolean = (id) => true; registerNotificationItemEventCapture(id: string){ if(this.registerEventCapture != null && this.registerEventCapture(id)){ @@ -83,29 +93,28 @@ export default struct NotificationItem { @Component struct FrontItem { - private itemData: any = {} - private nowWant: any; + @Prop itemData: NotificationItemData + private nowWant: Want | undefined = undefined; private isSubItem: boolean= false; - private devicesDialogController: CustomDialogController = new CustomDialogController({ + private devicesDialogController: CustomDialogController | null = new CustomDialogController({ builder: DevicesDialog({ - action: (deviceID) => this.selectedDevice(deviceID) + action: (deviceID): void => this.selectedDevice(deviceID) }), autoCancel: false, offset: { dx: 0, dy: 200 } }); aboutToDisappear() { - delete this.devicesDialogController - this.devicesDialogController = undefined + this.devicesDialogController = null Log.showInfo(TAG, 'FrontItem -> aboutToDisappear') } build() { Column() { if (this.itemData.template?.name) { - CustomItem({ customItemData: this.itemData, clickAction: () => this.showDevicesDialog(), isSubItem: this.isSubItem }) + CustomItem({ customItemData: this.itemData, clickAction: (): void => this.showDevicesDialog(), isSubItem: this.isSubItem }) } else { - GeneralItem({ itemData: this.itemData, clickAction: () => this.showDevicesDialog(), isSubItem: this.isSubItem }) + GeneralItem({ itemData: this.itemData, clickAction: (): void => this.showDevicesDialog(), isSubItem: this.isSubItem }) } } .width('100%') @@ -125,7 +134,7 @@ struct FrontItem { this.nowWant = want; Log.showInfo(TAG, `showDevicesDialog want: ${JSON.stringify(this.nowWant)}`); if (!want?.deviceId) { - this.devicesDialogController.open(); + this.devicesDialogController?.open(); } else { NotificationViewModel.clickItem(this.itemData); } @@ -135,10 +144,12 @@ struct FrontItem { } } - selectedDevice(deviceID) { + selectedDevice(deviceID: string): void { Log.showInfo(TAG, `selectedDevice deviceID:${deviceID}`); - this.nowWant.deviceId = deviceID; - let triggerInfo = { + if(this.nowWant) { + this.nowWant.deviceId = deviceID; + } + let triggerInfo: TriggerInfo = { code: 0, want: this.nowWant, permission: '', diff --git a/features/noticeitem/src/main/ets/com/ohos/noticeItem/view/item/pictureItem.ets b/features/noticeitem/src/main/ets/com/ohos/noticeItem/view/item/pictureItem.ets index 68737b81..39637294 100644 --- a/features/noticeitem/src/main/ets/com/ohos/noticeItem/view/item/pictureItem.ets +++ b/features/noticeitem/src/main/ets/com/ohos/noticeItem/view/item/pictureItem.ets @@ -18,7 +18,7 @@ import CheckEmptyUtils from '../../../../../../../../../../common/src/main/ets/d @Component export default struct PictureItem { - @State itemData: NotificationItemData= undefined + @Prop itemData: NotificationItemData @Prop isExpand: boolean build() { diff --git a/features/noticeitem/src/main/ets/com/ohos/noticeItem/view/item/settingDialog.ets b/features/noticeitem/src/main/ets/com/ohos/noticeItem/view/item/settingDialog.ets index 4a38a934..324a01d3 100644 --- a/features/noticeitem/src/main/ets/com/ohos/noticeItem/view/item/settingDialog.ets +++ b/features/noticeitem/src/main/ets/com/ohos/noticeItem/view/item/settingDialog.ets @@ -30,9 +30,9 @@ const TAG = 'NoticeItem-Setting'; */ @CustomDialog export default struct SettingDialog { - private itemData: NotificationItemData + @Prop itemData: NotificationItemData public controller: CustomDialogController - public action: () => void + public action: () => void = () => {} build() { Column() { diff --git a/features/noticeitem/src/main/ets/com/ohos/noticeItem/view/item/titleItem.ets b/features/noticeitem/src/main/ets/com/ohos/noticeItem/view/item/titleItem.ets index 880dd188..e4f860c9 100644 --- a/features/noticeitem/src/main/ets/com/ohos/noticeItem/view/item/titleItem.ets +++ b/features/noticeitem/src/main/ets/com/ohos/noticeItem/view/item/titleItem.ets @@ -20,7 +20,7 @@ const TAG = 'NoticeItem-TitleItem'; @Component export default struct TitleItem { - private notificationSmallIcon: PixelMap + private notificationSmallIcon?: PixelMap @State notificationName: string = '' @State notificationTime: string = '' @Link isExpand: boolean @@ -28,7 +28,7 @@ export default struct TitleItem { @State rowSpace: Resource = $r('app.float.titleitem_row_space') @Prop distributedDeviceName: string private isSubItem: boolean= false; - private clickTitleAction: () => void + private clickTitleAction?: () => void aboutToAppear() { Log.showDebug(TAG, `aboutToAppear Start`); diff --git a/features/noticeitem/src/main/ets/com/ohos/noticeItem/viewmodel/NotificationViewModel.ts b/features/noticeitem/src/main/ets/com/ohos/noticeItem/viewmodel/NotificationViewModel.ts index df501e6f..f6372d6a 100644 --- a/features/noticeitem/src/main/ets/com/ohos/noticeItem/viewmodel/NotificationViewModel.ts +++ b/features/noticeitem/src/main/ets/com/ohos/noticeItem/viewmodel/NotificationViewModel.ts @@ -135,12 +135,12 @@ export class NotificationViewModel { AppStorage.SetOrCreate('notificationList', notificationList); } - groupByGroupName(): any[]{ + groupByGroupName(): NotificationItemData[][]{ if (!this.mNotificationList || this.mNotificationList.length < 1) { Log.showWarn(TAG, 'groupByGroupName, list is empty.'); return []; } - let groupArr: any[] = []; + let groupArr: NotificationItemData[][] = []; let groups = {}; this.mNotificationList.forEach((item) => { const groupName = `${item.bundleName}_${item.groupName}`; diff --git a/features/ringmodecomponent/src/main/ets/com/ohos/pages/ControlCenterSimpleToggleRingModeComponent.ets b/features/ringmodecomponent/src/main/ets/com/ohos/pages/ControlCenterSimpleToggleRingModeComponent.ets index 1fee9823..889cfdb5 100644 --- a/features/ringmodecomponent/src/main/ets/com/ohos/pages/ControlCenterSimpleToggleRingModeComponent.ets +++ b/features/ringmodecomponent/src/main/ets/com/ohos/pages/ControlCenterSimpleToggleRingModeComponent.ets @@ -25,7 +25,7 @@ const TAG = 'ringmode-ControlCenterSimpleToggleRingModeComponent' @Component export default struct ControlCenterSimpleToggleRingModeComponent { - private keyId: string + private keyId: string = '' private mEditMode: boolean = false private mDragMode: boolean = false @State mIcon: Resource = $r("app.media.ic_controlcenter_ring_on_filled") @@ -67,8 +67,8 @@ export default struct ControlCenterSimpleToggleRingModeComponent { mIconOnBG: this.style.onBgColor, mEditMode: this.mEditMode, mDragMode: this.mDragMode, - mClickEvent: () => this.mClickEvent(), - mLongClickEvent: () => this.mLongClickEvent() + mClickEvent: (): void => this.mClickEvent(), + mLongClickEvent: (): void => this.mLongClickEvent() }) } diff --git a/features/ringmodecomponent/src/main/ets/com/ohos/pages/StatusBarIconItemRingModeComponent.ets b/features/ringmodecomponent/src/main/ets/com/ohos/pages/StatusBarIconItemRingModeComponent.ets index 31a37f86..4bd98b51 100644 --- a/features/ringmodecomponent/src/main/ets/com/ohos/pages/StatusBarIconItemRingModeComponent.ets +++ b/features/ringmodecomponent/src/main/ets/com/ohos/pages/StatusBarIconItemRingModeComponent.ets @@ -29,13 +29,13 @@ export default struct StatusBarIconItemRingModeComponent { @State mTintContentInfo: TintContentInfo = ViewModel.getTintContentInfo() @State styleCommon: CommonStyle = StyleConfigurationCommon.getCommonStyle() @State style: StatusRingModeComponentStyle = StyleConfiguration.getStatusRingModeComponentStyle() - private ringModeIcons: any + private ringModeIcons: Resource[] = [] aboutToAppear() { Log.showInfo(TAG, 'aboutToAppear'); - this.ringModeIcons = {}; - this.ringModeIcons[AudioRingMode.RINGER_MODE_SILENT.toString()] = $r("app.media.ic_statusbar_ring_off_filled"); - this.ringModeIcons[AudioRingMode.RINGER_MODE_VIBRATE.toString()] = $r("app.media.ic_statusbar_vibration_on"); + this.ringModeIcons = []; + this.ringModeIcons[AudioRingMode.RINGER_MODE_SILENT] = $r("app.media.ic_statusbar_ring_off_filled"); + this.ringModeIcons[AudioRingMode.RINGER_MODE_VIBRATE] = $r("app.media.ic_statusbar_vibration_on"); ViewModel.initViewModel(); } @@ -47,7 +47,7 @@ export default struct StatusBarIconItemRingModeComponent { Row() { if (this.RingModeComponentMode != AudioRingMode.RINGER_MODE_NORMAL) { Row().width(this.styleCommon.statusBarMarginLeftRight).height('100%') - Image(this.ringModeIcons[this.RingModeComponentMode.toString()]) + Image(this.ringModeIcons[this.RingModeComponentMode]) .objectFit(ImageFit.Contain) .width(this.style.statusBarRingModeWidth) .height(this.style.statusBarRingModeHeight) diff --git a/features/signalcomponent/src/main/ets/default/pages/signalIcon.ets b/features/signalcomponent/src/main/ets/default/pages/signalIcon.ets index d4cf6e33..6faa5449 100644 --- a/features/signalcomponent/src/main/ets/default/pages/signalIcon.ets +++ b/features/signalcomponent/src/main/ets/default/pages/signalIcon.ets @@ -91,8 +91,8 @@ export default struct SignalIcon { * @param {number} type - number of cellular type * @return {string} typeString type of cellular type */ - private updateCellularType(signalType): string { - let typeString; + private updateCellularType(signalType: number): Resource { + let typeString: Resource; switch (signalType) { case Constants.RADIO_TECHNOLOGY_UNKNOWN: typeString = $r('app.string.signal_null'); @@ -130,8 +130,8 @@ export default struct SignalIcon { * @param {number} level - signal level from signalModel * @return {string} cellularImage image of cellular signal */ - private updateCellularImage(level) { - let cellularImage; + private updateCellularImage(level: number) { + let cellularImage: Resource; switch (level) { case Constants.CELLULAR_SIGNAL_NO: cellularImage = $r('app.media.ic_statusbar_signal_no'); @@ -165,8 +165,8 @@ export default struct SignalIcon { * @param {string} netWorkState - network state from signal model * @return {string} vendor's name or signal state */ - private updateNetworkState(netWorkState) { - let networkStateName; + private updateNetworkState(netWorkState: string) { + let networkStateName: string | Resource; if (netWorkState == Constants.NET_NULL) { networkStateName = $r('app.string.net_null'); } else { diff --git a/features/signalcomponent/src/main/ets/default/signalModel.ts b/features/signalcomponent/src/main/ets/default/signalModel.ts index 8df6240f..7ce440c9 100644 --- a/features/signalcomponent/src/main/ets/default/signalModel.ts +++ b/features/signalcomponent/src/main/ets/default/signalModel.ts @@ -120,16 +120,20 @@ export class SignalModel { */ initObserver() { Log.showInfo(TAG, 'initObserver'); - isInitObserver = true; - Observer.on('signalInfoChange', (signalInfoChange) => { - this.checkCellularStatus(); - }); - Observer.on('networkStateChange', (networkState) => { - this.checkCellularStatus(); - }); - Observer.on('simStateChange', (simStateInfo) => { - this.checkCellularStatus(); - }); + try { + isInitObserver = true; + Observer.on('signalInfoChange', (signalInfoChange) => { + this.checkCellularStatus(); + }); + Observer.on('networkStateChange', (networkState) => { + this.checkCellularStatus(); + }); + Observer.on('simStateChange', (simStateInfo) => { + this.checkCellularStatus(); + }); + } catch (err) { + Log.showError(TAG, `init observer failed message: ${JSON.stringify(err)}`); + } } /** diff --git a/features/statusbarcomponent/oh-package.json5 b/features/statusbarcomponent/oh-package.json5 index 9f7e9528..35ad89db 100644 --- a/features/statusbarcomponent/oh-package.json5 +++ b/features/statusbarcomponent/oh-package.json5 @@ -3,5 +3,7 @@ "name": "@ohos/statusbarcomponent", "description": "a npm package which contains statusbarcomponent function", "version": "1.0.0", - "dependencies": {} + "dependencies": { + "@ohos/common": "file:../../common" + } } \ No newline at end of file diff --git a/features/statusbarcomponent/src/main/ets/com/ohos/pages/IconItemComponent.ets b/features/statusbarcomponent/src/main/ets/com/ohos/pages/IconItemComponent.ets index 829f0d99..db6edc42 100644 --- a/features/statusbarcomponent/src/main/ets/com/ohos/pages/IconItemComponent.ets +++ b/features/statusbarcomponent/src/main/ets/com/ohos/pages/IconItemComponent.ets @@ -16,7 +16,7 @@ import Log from '../../../../../../../../common/src/main/ets/default/Log' import EventManager, { unsubscribe } from '../../../../../../../../common/src/main/ets/default/event/EventManager' import CheckEmptyUtils from '../../../../../../../../common/src/main/ets/default/CheckEmptyUtils' -import { WINDOW_SHOW_HIDE_EVENT } from '../../../../../../../../common/src/main/ets/default/WindowManager' +import { WINDOW_SHOW_HIDE_EVENT, ArgsInfo } from '../../../../../../../../common/src/main/ets/default/WindowManager' import { PluginType,itemData } from "../../../../../../../../common/src/main/ets/plugindatasource/common/Constants" import ViewModel from '../viewmodel/StatusBarVM' import StyleConfigurationCommon, { CommonStyle @@ -24,16 +24,17 @@ import StyleConfigurationCommon, { CommonStyle import StyleConfiguration, { IconItemComponentStyle } from '../common/StyleConfiguration' import MetaIconItemComponent from './MetaIconItemComponent' import PluginIconItemComponent from './PluginIconItemComponent' +import { Event } from '@ohos/common' const TAG = 'IconItemComponent' -class itemStatusData{ +interface itemStatusData{ selected: boolean } @Component export default struct IconItemComponent { - private keyId: string + @Prop keyId: string @State mItemData: itemData = new itemData() @State mItemStatus: itemStatusData = { selected: false @@ -47,7 +48,9 @@ export default struct IconItemComponent { Log.showInfo(TAG, `aboutToAppear Start, keyId: ${this.keyId} `); this.linkItemData() if (this.mItemData?.relationWindowId) { - this.mClearCallback = EventManager.subscribe(WINDOW_SHOW_HIDE_EVENT, (args) => this.onWindowChange(args)) + this.mClearCallback = EventManager.subscribe( + WINDOW_SHOW_HIDE_EVENT, + (args: ArgsInfo) => this.onWindowChange(args)); } } @@ -58,14 +61,14 @@ export default struct IconItemComponent { } linkItemData() { - this.mItemData = AppStorage.Get('StatusBar_' + this.keyId) + this.mItemData = AppStorage.Get('StatusBar_' + this.keyId) as itemData Log.showInfo(TAG, `linkItemData, mItemData: ${this.keyId} ${this.mItemData.label} ${ this.mItemData .iconUrl}`) const statusBarStatusKey = 'StatusBar_Status_' + this.keyId AppStorage.SetOrCreate(statusBarStatusKey, { selected: false }) - this.mItemStatus = AppStorage.Get(statusBarStatusKey) + this.mItemStatus = AppStorage.Get(statusBarStatusKey) as itemStatusData } build() { @@ -102,9 +105,9 @@ export default struct IconItemComponent { }.height('100%') } - onWindowChange(args) { + onWindowChange(args: ArgsInfo) { if (this.mItemData.canSelect && args?.windowName == this.mItemData.relationWindowId) { - this.mItemStatus.selected = args?.isShow + this.mItemStatus.selected = args?.isShow as boolean } } @@ -133,7 +136,7 @@ export default struct IconItemComponent { onIconItemLongPressGesture(event: GestureEvent) { Log.showInfo(TAG, `onIconItemLongPressGesture, event: ${JSON.stringify(event)}`); - let longClickEvent = this.mItemData.actionData.longClickAction; + let longClickEvent = this.mItemData.actionData?.longClickAction as Event; longClickEvent && EventManager.publish(longClickEvent); } diff --git a/features/statusbarcomponent/src/main/ets/com/ohos/pages/MetaIconItemComponent.ets b/features/statusbarcomponent/src/main/ets/com/ohos/pages/MetaIconItemComponent.ets index c9e493c5..4ea53504 100644 --- a/features/statusbarcomponent/src/main/ets/com/ohos/pages/MetaIconItemComponent.ets +++ b/features/statusbarcomponent/src/main/ets/com/ohos/pages/MetaIconItemComponent.ets @@ -26,7 +26,7 @@ const TAG = 'MetaIconItemComponent' @Component export default struct MetaIconItemComponent { - private keyId: string + @Prop keyId: string @State mItemData: itemData = new itemData() @State mTintContentInfo: TintContentInfo = new TintContentInfo() @State style: IconItemComponentStyle = StyleConfiguration.getIconItemComponentStyle() @@ -43,7 +43,7 @@ export default struct MetaIconItemComponent { } linkItemData() { - this.mItemData = AppStorage.Get('StatusBar_' + this.keyId); + this.mItemData = AppStorage.Get('StatusBar_' + this.keyId) as itemData; Log.showInfo(TAG, `linkItemData, mItemData: ${this.keyId} ${this.mItemData.label} ${ this.mItemData .iconUrl}`) diff --git a/features/statusbarcomponent/src/main/ets/com/ohos/pages/PluginIconItemComponent.ets b/features/statusbarcomponent/src/main/ets/com/ohos/pages/PluginIconItemComponent.ets index b0abe998..8b047ed5 100644 --- a/features/statusbarcomponent/src/main/ets/com/ohos/pages/PluginIconItemComponent.ets +++ b/features/statusbarcomponent/src/main/ets/com/ohos/pages/PluginIconItemComponent.ets @@ -25,7 +25,7 @@ const TAG = 'PluginIconItemComponent' @Component export default struct PluginIconItemComponent { - private keyId: string + @Prop keyId: string @State @Watch('onPluginDataChange') mPluginData: PluginComponentData = new PluginComponentData() @State @Watch('onTintContentChange') mTintContentInfo: TintContentInfo = new TintContentInfo() @State style: PluginIconItemComponentStyle = StyleConfiguration.getPluginIconItemComponentStyle() @@ -78,8 +78,8 @@ export default struct PluginIconItemComponent { data: this.mPluginData.data }).onComplete(() => { Log.showInfo(TAG, `PluginComponent.Complete`) - }).onError(({errcode, msg}) => { - Log.showInfo(TAG, `PluginComponent.Error code:${errcode} message:${msg}`) + }).onError((error) => { + Log.showInfo(TAG, `PluginComponent.Error code:${error.errcode} message:${error.msg}`) }) .size({ width: px2vp(this.style.iconWidth), height: '100%' }) Row().width(this.styleCommon.statusBarMarginLeftRight).height('100%') diff --git a/features/statusbarcomponent/src/main/ets/com/ohos/pages/StatusBarComponent.ets b/features/statusbarcomponent/src/main/ets/com/ohos/pages/StatusBarComponent.ets index 308e50b4..9097add6 100644 --- a/features/statusbarcomponent/src/main/ets/com/ohos/pages/StatusBarComponent.ets +++ b/features/statusbarcomponent/src/main/ets/com/ohos/pages/StatusBarComponent.ets @@ -35,6 +35,7 @@ import CapsuleIcon from '../../../../../../../capsulecomponent/src/main/ets/defa import LocationIcon from '../../../../../../../locationcomponent/src/main/ets/com/ohos/pages/StatusBarIconItemLocationComponent' import RingModeIcon from '../../../../../../../ringmodecomponent/src/main/ets/com/ohos/pages/StatusBarIconItemRingModeComponent' import NfcIcon from '../../../../../../../nfccomponent/src/main/ets/com/ohos/pages/StatusBarIconItemNFComponent' +import { NotificationItemData } from '@ohos/common'; const TAG = 'StatusBarComponent' const TAG_StatusBarGroup = 'StatusBarGroup' @@ -44,9 +45,14 @@ const TAG_StatusBarEmptyIcon = 'StatusBarEmptyIcon' const TAG_StatusBarNotificationIcon = 'StatusBarNotificationIcon' const TAG_StatusBarBackground = 'StatusBarBackground' +interface Item { + index: number; + data: NotificationItemData[]; +} + @Component export default struct StatusBarComponent { - private mStatusBarComponentConfig: StatusBarConfig + private mStatusBarComponentConfig: StatusBarConfig | undefined = undefined @State mStatusBarData: StatusBarData = ViewModel.getStatusBarData() private moduleName: string = '' @@ -166,7 +172,7 @@ struct StatusBarBackground { struct StatusBarGroup { @StorageLink('StatusBarLayout') mStatusBarLayout: string[][] = [[], [], []] private mLayoutWeight: number = 1 - private mAlignItems: any = HorizontalAlign.Center; + private mAlignItems: number = HorizontalAlign.Center; private index: number = -1; @State mStatusBarData: StatusBarData = ViewModel.getStatusBarData() @@ -212,7 +218,7 @@ struct StatusBarGroup { @Component struct VerticalStatusBarItemLoadComponent { - private mComponentName: string + private mComponentName: string = '' @State mComponentHeight: number = 0 @State style: VerticalStatusBarItemLoadComponentStyle = StyleConfiguration.getVerticalStatusBarItemLoadComponentStyle() @@ -241,7 +247,7 @@ struct VerticalStatusBarItemLoadComponent { @Component struct StatusBarItemLoadComponent { - private mComponentName: string + private mComponentName: string = '' aboutToAppear() { Log.showInfo(TAG_StatusBarItemLoadComponent, `aboutToAppear, mComponentName: ${this.mComponentName} `) } @@ -311,7 +317,7 @@ struct StatusBarEmptyIcon { @Component struct StatusBarNotificationIcon { - @StorageLink('notificationList') notificationList: Array = [] + @StorageLink('notificationList') notificationList: NotificationItemData[][] = [] @StorageLink('StatusCoefficient') StatusCoefficient: number = 1.0 @State mTintContentInfo: TintContentInfo = ViewModel.getNotificationTintContentInfo() @State styleCommon: CommonStyle = StyleConfigurationCommon.getCommonStyle() @@ -331,7 +337,7 @@ struct StatusBarNotificationIcon { Row().height(1).width(this.styleCommon.statusBarMarginLeftRight) } if (this.notificationList.length > 3) { - ForEach(this.notificationList.slice(0, 3), (item: any) => { + ForEach(this.notificationList.slice(0, 3), (item: NotificationItemData[]) => { Image(item[0].smallIcon) .objectFit(ImageFit.ScaleDown) .height(this.style.iconHeight) @@ -346,12 +352,13 @@ struct StatusBarNotificationIcon { } } else { ForEach(this.notificationList.map((item, index1) => { - return { i: index1, data: item } - }), (item) => { - if (item.i > 0) { + let res: Item = { index: index1, data: item } + return res + }), (res: Item) => { + if (res.index > 0) { Row().height(1).width(this.style.iconSpace) } - Image(item.data[0].smallIcon) + Image(res.data[0].smallIcon) .objectFit(ImageFit.ScaleDown) .height(this.style.iconHeight) .width(this.style.iconWidth) diff --git a/features/statusbarcomponent/src/main/resources/base/element/float.json b/features/statusbarcomponent/src/main/resources/base/element/float.json index 4fd08171..86e372d8 100644 --- a/features/statusbarcomponent/src/main/resources/base/element/float.json +++ b/features/statusbarcomponent/src/main/resources/base/element/float.json @@ -51,6 +51,10 @@ { "name": "status_bar_padding_end", "value": "0vp" + }, + { + "name": "status_bar_margin_left_right", + "value": "3vp" } ] } \ No newline at end of file diff --git a/features/volumepanelcomponent/src/main/ets/com/ohos/pages/VolumePanelComponent.ets b/features/volumepanelcomponent/src/main/ets/com/ohos/pages/VolumePanelComponent.ets index 55ca6ee4..6c93acc4 100644 --- a/features/volumepanelcomponent/src/main/ets/com/ohos/pages/VolumePanelComponent.ets +++ b/features/volumepanelcomponent/src/main/ets/com/ohos/pages/VolumePanelComponent.ets @@ -97,9 +97,9 @@ export default struct VolumePanelComponent { .backgroundColor(this.style.volumePanelBackground) } - getVolumeIcon(isMute, volume, maxVolume, minVolume) { + getVolumeIcon(isMute: boolean, volume: number, maxVolume: number, minVolume: number) { Log.showInfo(TAG, `getVolumeIcon, isMute: ${isMute} volume: ${volume} maxVolume: ${maxVolume} minVolume: ${minVolume}`); - let icon + let icon: Resource if (isMute) { icon = $r('app.media.ic_public_mute') } else { diff --git a/features/wificomponent/src/main/ets/default/pages/wifiComponent.ets b/features/wificomponent/src/main/ets/default/pages/wifiComponent.ets index 74052e3f..0477d201 100644 --- a/features/wificomponent/src/main/ets/default/pages/wifiComponent.ets +++ b/features/wificomponent/src/main/ets/default/pages/wifiComponent.ets @@ -24,7 +24,7 @@ const TAG = 'Control-wifiComponent' @Component export default struct WifiComponent { - private IconInfo: any[] = [ + private IconInfo: Resource[] = [ $r('app.media.wifi_d'), $r('app.media.wifi'), ] @@ -64,8 +64,8 @@ export default struct WifiComponent { iconOn: this.IconInfo[1], mTitle: $wifiName, changeSwitch: $wifiOpenStatus, - mClickEvent: () => this.mClickEvent(), - mLongClickEvent: () => this.mLongClickEvent() + mClickEvent: (): void => this.mClickEvent(), + mLongClickEvent: (): void => this.mLongClickEvent() }) }.width('100%') .height('100%') diff --git a/features/wificomponent/src/main/ets/default/pages/wifiIcon.ets b/features/wificomponent/src/main/ets/default/pages/wifiIcon.ets index d8cd535d..c2690b98 100644 --- a/features/wificomponent/src/main/ets/default/pages/wifiIcon.ets +++ b/features/wificomponent/src/main/ets/default/pages/wifiIcon.ets @@ -59,7 +59,7 @@ export default struct WifiIcon { private getImage(wifiInfo: number) { Log.showInfo(TAG, `getImage`); - let wifiImage; + let wifiImage: Resource; switch (wifiInfo) { case Constants.WIFI_SIGNAL_NO: wifiImage = $r('app.media.ic_statusbar_wifi_no'); diff --git a/oh-package.json5 b/oh-package.json5 index d10b59cc..840b0f14 100644 --- a/oh-package.json5 +++ b/oh-package.json5 @@ -1,4 +1,5 @@ { + "modelVersion": "5.0.1", "devDependencies": { "@ohos/hypium": "1.0.6" }, diff --git a/product/default/dialog/src/main/ets/ServiceExtAbility/ExtAbility.ts b/product/default/dialog/src/main/ets/ServiceExtAbility/ExtAbility.ts index 661f9d46..ed065b2a 100644 --- a/product/default/dialog/src/main/ets/ServiceExtAbility/ExtAbility.ts +++ b/product/default/dialog/src/main/ets/ServiceExtAbility/ExtAbility.ts @@ -38,7 +38,7 @@ class Stub extends rpc.RemoteObject { if (code === ServiceStubCode.COMMAND_SEND_REMOTE_OBJECT) { Log.showInfo(TAG, `onRemoteRequest code:${ServiceStubCode.COMMAND_SEND_REMOTE_OBJECT} start ${connectId}`); - const controller = globalThis[Constants.SYSTEM_DIALOG_CONTROLLER]; + const controller = globalThis.SystemDialog_Controller; const remoteObject = data.readRemoteObject(); Log.showDebug(TAG, `onRemoteRequest code:${ServiceStubCode.COMMAND_SEND_REMOTE_OBJECT} ${remoteObject}`); @@ -86,7 +86,7 @@ class Stub extends rpc.RemoteObject { } async createWindow(connectId: string, parameters: IDialogParameters) { - const controller = globalThis[Constants.SYSTEM_DIALOG_CONTROLLER]; + const controller = globalThis.SystemDialog_Controller; const current = controller.getData().get(connectId); if (current && current.windowName) { Log.showInfo(TAG, `createWindow connectId:${connectId}`); @@ -129,7 +129,7 @@ class Stub extends rpc.RemoteObject { export default class DialogServiceExtAbility extends ServiceExtensionAbility { onCreate(want: Want) { Log.showInfo(TAG, 'onCreate'); - globalThis[Constants.SYSTEM_DIALOG_CONTROLLER] = new SystemDialogController(this.context); + globalThis.SystemDialog_Controller = new SystemDialogController(this.context); } onConnect() { @@ -142,9 +142,9 @@ export default class DialogServiceExtAbility extends ServiceExtensionAbility { } onDestroy() { - const controller = globalThis[Constants.SYSTEM_DIALOG_CONTROLLER]; + const controller = globalThis.SystemDialog_Controller; controller.destroyAllWindow(); - globalThis[Constants.SYSTEM_DIALOG_CONTROLLER] = undefined; + globalThis.SystemDialog_Controller = undefined; Log.showInfo(TAG, 'onDestroy end'); } diff --git a/product/default/dialog/src/main/ets/pages/ExtIndex.ets b/product/default/dialog/src/main/ets/pages/ExtIndex.ets index 4b6d004a..d5978cd3 100644 --- a/product/default/dialog/src/main/ets/pages/ExtIndex.ets +++ b/product/default/dialog/src/main/ets/pages/ExtIndex.ets @@ -18,6 +18,7 @@ import Log from '../../../../../../../common/src/main/ets/default/Log'; import Constants from '../common/Constants'; import type { IDialogParameters } from '../controller/Controller'; import inputMethod from '@ohos.inputMethod'; +import SystemDialogController from '../controller/Controller'; const TAG = 'Dialog-Index'; @@ -26,10 +27,10 @@ const storage = LocalStorage.GetShared(); @Entry(storage) @Component struct Index { - @LocalStorageProp('connectId') connectId: string = undefined; - @LocalStorageProp('windowName') windowName: string = undefined; - @LocalStorageProp('parameters') parameters: IDialogParameters = undefined; - @State inputMethodSetting: inputMethod.InputMethodSetting = undefined; + @LocalStorageProp('connectId') connectId: string = ''; + @LocalStorageProp('windowName') windowName: string = ''; + @LocalStorageProp('parameters') parameters: IDialogParameters = {}; + @State inputMethodSetting: inputMethod.InputMethodSetting | undefined = undefined; @State keyboardHeight: number = 0; aboutToAppear() { @@ -62,8 +63,8 @@ struct Index { cancelListenKeyboard() { Log.showInfo(TAG, 'cancelListenKeyboard in'); try { - this.inputMethodSetting.off('imeShow'); - this.inputMethodSetting.off('imeHide'); + this.inputMethodSetting?.off('imeShow'); + this.inputMethodSetting?.off('imeHide'); } catch (e) { Log.showError('cancelListenKeyboard error', e); } @@ -72,8 +73,8 @@ struct Index { onOk() { Log.showDebug(TAG, `onOk start`); - const controller = globalThis[Constants.SYSTEM_DIALOG_CONTROLLER]; - const { remoteObject } = controller.getData().get(this.connectId); + const controller = globalThis.SystemDialog_Controller as SystemDialogController; + const remoteObject = controller.getData().get(this.connectId)?.remoteObject; if (remoteObject) { Log.showDebug(TAG, `onOk ${remoteObject}`); @@ -82,8 +83,8 @@ struct Index { let option = new rpc.MessageOption(); remoteObject.sendMessageRequest(1, data, reply, option) .then( - (result) => Log.showDebug(TAG, `onOk success ${JSON.stringify(result)}`), - (error) => { + (result: rpc.RequestResult): void => Log.showDebug(TAG, `onOk success ${JSON.stringify(result)}`), + (error: Error) => { Log.showDebug(TAG, `onOk error ${JSON.stringify(error)}`); this.onClose(); } @@ -98,7 +99,7 @@ struct Index { onClose() { Log.showDebug(TAG, `onClose start`); - const controller = globalThis[Constants.SYSTEM_DIALOG_CONTROLLER]; + const controller = globalThis.SystemDialog_Controller as SystemDialogController; controller?.destroyWindow(this.connectId); Log.showInfo(TAG, `onClose end`); } diff --git a/product/default/navigationBar/oh-package.json5 b/product/default/navigationBar/oh-package.json5 index 009685c9..46a1002d 100644 --- a/product/default/navigationBar/oh-package.json5 +++ b/product/default/navigationBar/oh-package.json5 @@ -4,6 +4,7 @@ "description": "", "version": "1.0.0", "dependencies": { - "@ohos/navigationservice": "file:../../../features/navigationservice" + "@ohos/navigationservice": "file:../../../features/navigationservice", + "@ohos/common": "file:../../../common" } } \ No newline at end of file diff --git a/product/default/navigationBar/src/main/ets/common/constants.ts b/product/default/navigationBar/src/main/ets/common/constants.ts index 550d9677..d1d515e0 100644 --- a/product/default/navigationBar/src/main/ets/common/constants.ts +++ b/product/default/navigationBar/src/main/ets/common/constants.ts @@ -12,6 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import resourceManager from '@ohos.resourceManager'; export default class Constants { static readonly KEY_DOWN: number = 0; @@ -33,3 +34,8 @@ export class NavigationBarComponentData { backgroundColor = '#00000000'; contentColor = '#FFFFFFFF'; } + +export interface KeyCode { + uri: resourceManager.Resource, + keyCode: number +} diff --git a/product/default/navigationBar/src/main/ets/pages/PrivacyIndicatorComponent.ets b/product/default/navigationBar/src/main/ets/pages/PrivacyIndicatorComponent.ets index 12be103a..73cd3600 100644 --- a/product/default/navigationBar/src/main/ets/pages/PrivacyIndicatorComponent.ets +++ b/product/default/navigationBar/src/main/ets/pages/PrivacyIndicatorComponent.ets @@ -19,12 +19,12 @@ import IndicatorStyle, { IndicatorType } from '../common/IndicatorConfig'; @Entry @Component export default struct PrivacyIndicatorComponent { - private mViewModel: ViewModel; + private mViewModel: ViewModel | undefined = undefined; @State mBackgroundColor: Resource = $r("app.color.transparent"); aboutToAppear(): void { this.mViewModel = new ViewModel(); - this.mViewModel.setCallback((type) => { + this.mViewModel.setCallback((type: number) => { if (type == IndicatorType.TYPE_ORANGE) { this.mBackgroundColor = $r("sys.color.ohos_id_color_alert"); } else if (type == IndicatorType.TYPE_GREEN) { diff --git a/product/default/navigationBar/src/main/ets/pages/SplitBarIndex.ets b/product/default/navigationBar/src/main/ets/pages/SplitBarIndex.ets index cb81a3b8..69b3fdd2 100644 --- a/product/default/navigationBar/src/main/ets/pages/SplitBarIndex.ets +++ b/product/default/navigationBar/src/main/ets/pages/SplitBarIndex.ets @@ -15,6 +15,7 @@ import Log from '../../../../../../../common/src/main/ets/default/Log' import AbilityManager from '../../../../../../../common/src/main/ets/default/abilitymanager/abilityManager' +import { ConfigInfo } from '@ohos/common' const TAG = 'Navigation-SplitBar' @@ -35,7 +36,7 @@ struct Index { aboutToAppear() { Log.showInfo(TAG, `aboutToAppear, start`); - let configInfo = AbilityManager.getAbilityData(AbilityManager.ABILITY_NAME_NAVIGATION_BAR, 'config'); + let configInfo = AbilityManager.getAbilityData(AbilityManager.ABILITY_NAME_NAVIGATION_BAR, 'config') as ConfigInfo; if (configInfo.maxWidth > configInfo.maxHeight) { this.mHorizontalScreen = true; } else { diff --git a/product/default/navigationBar/src/main/ets/pages/index.ets b/product/default/navigationBar/src/main/ets/pages/index.ets index 22eba5d0..00bab892 100644 --- a/product/default/navigationBar/src/main/ets/pages/index.ets +++ b/product/default/navigationBar/src/main/ets/pages/index.ets @@ -22,25 +22,25 @@ import {NavigationBarComponentData} from '../common/constants' import StyleManager from '../common/StyleManager' import configManager from '../../../../../../../features/navigationservice/src/main/ets/com/ohos/navigationservice/ConfigManager' import WindowManager, { WindowType } from '../../../../../../../common/src/main/ets/default/WindowManager'; +import { ConfigInfo } from '@ohos/common' const TAG = 'NavigationBar-Index'; let mConfigManager = configManager @Entry @Component struct Index { - @StorageLink('navigationLayoutConfig') mConfig: object = {} + // @StorageLink('navigationLayoutConfig') mConfig: object = {} @StorageLink('minNavHeight') minNavHeight: number = 32 @StorageLink("showNavHorizontal") showNavHorizontal: boolean = true @State mNavigationBarComponentData: NavigationBarComponentData = new NavigationBarComponentData() onBackPress(): boolean { - return true; } aboutToAppear() { Log.showInfo(TAG, `aboutToAppear Start`); - let configInfo = AbilityManager.getAbilityData(AbilityManager.ABILITY_NAME_NAVIGATION_BAR, 'config'); + let configInfo = AbilityManager.getAbilityData(AbilityManager.ABILITY_NAME_NAVIGATION_BAR, 'config') as ConfigInfo; AppStorage.SetOrCreate("showNavHorizontal", configInfo.showNavHorizontal); mConfigManager.initConfig(); WindowManager.setWindowBgColor(WindowType.NAVIGATION_BAR ,'#00000000') diff --git a/product/default/navigationBar/src/main/ets/pages/keyButton.ets b/product/default/navigationBar/src/main/ets/pages/keyButton.ets index 339faec7..345f7919 100644 --- a/product/default/navigationBar/src/main/ets/pages/keyButton.ets +++ b/product/default/navigationBar/src/main/ets/pages/keyButton.ets @@ -24,7 +24,7 @@ const TAG = 'NavigationBar-KeyButton'; @Component export default struct keyButton { - private uri: any; + @Prop uri: Resource; @State keyCode: number = 0; @Link currentTouchItem: number; @State backGroundColor: Resource = $r('app.color.button_default_background'); diff --git a/product/default/navigationBar/src/main/ets/pages/threeLayout.ets b/product/default/navigationBar/src/main/ets/pages/threeLayout.ets index 45359fd0..69db5e04 100644 --- a/product/default/navigationBar/src/main/ets/pages/threeLayout.ets +++ b/product/default/navigationBar/src/main/ets/pages/threeLayout.ets @@ -14,11 +14,11 @@ */ import keyButton from './keyButton'; -import Constants from '../common/constants' +import Constants, { KeyCode } from '../common/constants' import Log from '../../../../../../../common/src/main/ets/default/Log'; const TAG = 'NavigationBar-ThreeLayout'; -let KeyCodeArr: any[] = [ +let KeyCodeArr: KeyCode[] = [ { "uri": $r('app.media.ic_systemui_back'), "keyCode": Constants.KEYCODE_BACK @@ -49,7 +49,7 @@ struct threeLayout { build() { if (this.showNavHorizontal) { Grid() { - ForEach(KeyCodeArr, (item: any) => { + ForEach(KeyCodeArr, (item: KeyCode) => { GridItem() { Row() { keyButton({ uri: item.uri, keyCode: item.keyCode, currentTouchItem: $currentTouchItem }) @@ -65,7 +65,7 @@ struct threeLayout { .align(Alignment.Center); } else { Grid() { - ForEach(KeyCodeArr, (item: any) => { + ForEach(KeyCodeArr, (item: KeyCode) => { GridItem() { Column() { keyButton({ uri: item.uri, keyCode: item.keyCode, currentTouchItem: $currentTouchItem }) diff --git a/product/default/notificationmanagement/oh-package.json5 b/product/default/notificationmanagement/oh-package.json5 index 3d61311a..56c2ecae 100644 --- a/product/default/notificationmanagement/oh-package.json5 +++ b/product/default/notificationmanagement/oh-package.json5 @@ -4,6 +4,7 @@ "description": "", "version": "1.0.0", "dependencies": { - "@ohos/managementcomponent": "file:../../../features/managementcomponent" + "@ohos/managementcomponent": "file:../../../features/managementcomponent", + "@ohos/common": "file:../../../common" } } \ No newline at end of file diff --git a/product/default/notificationmanagement/src/main/ets/pages/batchSetEnable.ets b/product/default/notificationmanagement/src/main/ets/pages/batchSetEnable.ets index 6d140be1..37d1fea7 100644 --- a/product/default/notificationmanagement/src/main/ets/pages/batchSetEnable.ets +++ b/product/default/notificationmanagement/src/main/ets/pages/batchSetEnable.ets @@ -24,11 +24,24 @@ import ViewModel from '../vm/notificationManagenmentViewModel' const TAG = 'NotificationManagement-BatchSetEnable'; +interface BundleItemData { + appIcon?: string; + appTitle?: string; + appValue?: string; + appArrow?: string|Resource; + appSummary?: string; + appBundleName?: string; + appIconId?: string; + appUri?: string; + appUid?: number; + systemApp?: boolean; +} + @Entry @Component export default struct BatchSetEnable { @State mViewModel: ViewModel = new ViewModel(); - @StorageLink('appManagementList') appList: any[]= []; + @StorageLink('appManagementList') appList: BundleItemData[]= []; @State headName:Resource = $r('app.string.batch_Management') build() { @@ -38,14 +51,14 @@ export default struct BatchSetEnable { Column() { HeadComponent({ headName: $headName, isActive: true }); List() { - ForEach(this.appList, (item) => { + ForEach(this.appList, (item: BundleItemData) => { ListItem() { AppItemComponent({ appIcon: item.appIcon, appTitle: item.appTitle, appSummary: item.appSummary, appValue: item.appValue, - appArrow: item.appArrow, + appArrow: item.appArrow as string, appArrowStyle: '', appUri: '', appBundleName:item.appBundleName, diff --git a/product/default/notificationmanagement/src/main/ets/pages/noDisturb.ets b/product/default/notificationmanagement/src/main/ets/pages/noDisturb.ets index 768b545b..6f335739 100644 --- a/product/default/notificationmanagement/src/main/ets/pages/noDisturb.ets +++ b/product/default/notificationmanagement/src/main/ets/pages/noDisturb.ets @@ -22,6 +22,7 @@ import ItemComponent from '../../../../../../../features/managementcomponent/src import {DoNotDisturbType} from '../../../../../../../features/managementcomponent/src/main/ets/com/ohos/common/constants'; import NoDisturbingModel from '../../../../../../../features/managementcomponent/src/main/ets/com/ohos/model/noDisturbingModel'; import ViewModel from '../vm/noDisturbViewModel'; +import { data } from '@kit.TelephonyKit'; const deviceTypeInfo = deviceInfo.deviceType; const TAG = 'NotificationManagement-NoDisturb'; @@ -54,9 +55,9 @@ export default struct NoDisturb { Log.showInfo(TAG, `mViewModel onChange repeatName: ${this.mViewModel.repeatName} startDateClue: ${this.mViewModel.startDateClue} endDateClue: ${this.mViewModel.endDateClue} endTimeClue: ${this.mViewModel.endTimeClue}`) } - startDateDialogController: CustomDialogController = new CustomDialogController({ + startDateDialogController: CustomDialogController | null = new CustomDialogController({ builder: DateDialog({ - action:(data)=> this.setStartDate(data), + action:(data: string): void => this.setStartDate(data), title: $r('app.string.startDate'), defaultDate: this.mViewModel.defaultStartTime }), @@ -66,9 +67,9 @@ export default struct NoDisturb { offset: ({ dx: 0, dy: deviceTypeInfo === "phone" ? '-16dp' : 0 }), customStyle: true }); - startTimeDialogController: CustomDialogController = new CustomDialogController({ + startTimeDialogController: CustomDialogController | null = new CustomDialogController({ builder: TimeDialog({ - action:(data)=> this.setStartTime(data), + action:(data: string): void=> this.setStartTime(data), title: $r('app.string.startTime'), defaultDate: this.mViewModel.defaultStartTime }), @@ -78,9 +79,9 @@ export default struct NoDisturb { offset: ({ dx: 0, dy: deviceTypeInfo === "phone" ? '-16dp' : 0 }), customStyle: true }); - endDateDialogController: CustomDialogController = new CustomDialogController({ + endDateDialogController: CustomDialogController | null = new CustomDialogController({ builder: DateDialog({ - action:(data)=> this.setEndDate(data), + action:(data: string): void => this.setEndDate(data), title: $r('app.string.endDate'), defaultDate: this.mViewModel.defaultEndTime }), @@ -90,9 +91,9 @@ export default struct NoDisturb { offset: ({ dx: 0, dy: deviceTypeInfo === "phone" ? '-16dp' : 0 }), customStyle: true }); - endTimeDialogController: CustomDialogController = new CustomDialogController({ + endTimeDialogController: CustomDialogController | null = new CustomDialogController({ builder: TimeDialog({ - action:(data)=> this.setEndTime(data), + action:(data: string): void => this.setEndTime(data), title: $r('app.string.endTime'), defaultDate: this.mViewModel.defaultEndTime }), @@ -102,9 +103,9 @@ export default struct NoDisturb { offset: ({ dx: 0, dy: deviceTypeInfo === "phone" ? '-16dp' : 0 }), customStyle: true }); - repeatDialogController: CustomDialogController = new CustomDialogController({ + repeatDialogController: CustomDialogController | null = new CustomDialogController({ builder: RepeatModeDialog({ - action: (data) => this.setRepeatMode(data), + action: (data: number): void => this.setRepeatMode(data), title: $r('app.string.repeat'), selectMode: this.mViewModel.repeatMode }), @@ -129,7 +130,7 @@ export default struct NoDisturb { arrow: $arrow }) }.onClick(() => { - this.repeatDialogController.open() + this.repeatDialogController?.open() }).margin({ bottom: $r('app.float.itemComp_margin_b') }) if (this.mViewModel.repeatMode == DoNotDisturbType.TYPE_CLEARLY) { @@ -142,7 +143,7 @@ export default struct NoDisturb { arrow: $arrow }) }.onClick(() => { - this.startDateDialogController.open() + this.startDateDialogController?.open() }) } ListItem() { @@ -153,7 +154,7 @@ export default struct NoDisturb { arrow: $arrow }) }.onClick(() => { - this.startTimeDialogController.open() + this.startTimeDialogController?.open() }) } }.divider({ @@ -178,7 +179,7 @@ export default struct NoDisturb { arrow: $arrow }) }.onClick(() => { - this.endDateDialogController.open() + this.endDateDialogController?.open() }) } ListItem() { @@ -189,7 +190,7 @@ export default struct NoDisturb { arrow: $arrow }) }.onClick(() => { - this.endTimeDialogController.open() + this.endTimeDialogController?.open() }) } }.divider({ @@ -214,7 +215,7 @@ export default struct NoDisturb { }) }.onClick(() => { this.mPrevData = this.mViewModel.startTime - this.startTimeDialogController.open() + this.startTimeDialogController?.open() }).margin({ bottom: $r('app.float.itemComp_margin_b')}) Row() { ItemComponent({ @@ -224,7 +225,7 @@ export default struct NoDisturb { }) }.onClick(() => { this.mPrevData = this.mViewModel.endTime - this.endTimeDialogController.open() + this.endTimeDialogController?.open() }).margin({ bottom: $r('app.float.itemComp_margin_b')}) } } @@ -287,20 +288,11 @@ export default struct NoDisturb { } aboutToDisappear() { - delete this.startDateDialogController - this.startDateDialogController = undefined - - delete this.startTimeDialogController - this.startTimeDialogController = undefined - - delete this.endDateDialogController - this.endDateDialogController = undefined - - delete this.endTimeDialogController - this.endTimeDialogController = undefined - - delete this.repeatDialogController - this.repeatDialogController = undefined + this.startDateDialogController = null + this.startTimeDialogController = null + this.endDateDialogController = null + this.endTimeDialogController = null + this.repeatDialogController = null Log.showInfo(TAG, `aboutToDisappear`) } @@ -316,7 +308,7 @@ export default struct NoDisturb { @CustomDialog struct DateDialog { public controller: CustomDialogController - public action: (data) => void + public action: (data: string) => void = data => {} private selectedDate: string = '' private title: string | Resource = '' private defaultDate: Date = new Date() @@ -335,7 +327,7 @@ struct DateDialog { .fontWeight(FontWeight.Medium) DatePicker({ start: this.minDate, end: this.maxDate, selected: this.defaultDate }) .onChange((date: DatePickerResult) => { - let dateSource = new Date(date.year, date.month, date.day); + let dateSource = new Date(date.year as number, date.month as number, date.day); this.selectedDate = NoDisturbingModel.formatDate(dateSource); }) .width(ConfigData.WH_100_100) @@ -395,7 +387,7 @@ struct DateDialog { @CustomDialog struct TimeDialog { public controller: CustomDialogController - public action: (data) => void + public action: (data: string) => void = data => {} private selectedTime: string = '' private title: string | Resource = '' private defaultDate: Date = new Date() @@ -471,7 +463,7 @@ struct TimeDialog { @CustomDialog struct RepeatModeDialog { public controller: CustomDialogController - public action: (data) => void + public action: (data: number) => void = data => {} private title: string | Resource = '' private prevModeSetCnt: number = 0 @State selectMode: number = DoNotDisturbType.TYPE_NONE diff --git a/product/default/notificationmanagement/src/main/ets/pages/notificationManagenment.ets b/product/default/notificationmanagement/src/main/ets/pages/notificationManagenment.ets index bd1cac65..95f2e835 100644 --- a/product/default/notificationmanagement/src/main/ets/pages/notificationManagenment.ets +++ b/product/default/notificationmanagement/src/main/ets/pages/notificationManagenment.ets @@ -121,8 +121,8 @@ export default struct notificationManagenment { SwitchComponent({ title: $allowDistribut, describe: this.allowDistributDescribe, - initializationAction: () => this.switchComponentInit(), - settingAction: (params) => this.switchComponentSet(params) + initializationAction: (): Promise => this.switchComponentInit(), + settingAction: (params): void => this.switchComponentSet(params) }) }.margin({ bottom: $r('app.float.noDisturb_margin_lf') }) } @@ -202,7 +202,7 @@ export default struct notificationManagenment { return Notification.isDistributedEnabled(); } - switchComponentSet(params) { + switchComponentSet(params?: boolean) { Log.showDebug(TAG, `switchComponentSet`) Notification.enableDistributed(params); } diff --git a/product/default/notificationmanagement/src/main/ets/pages/setEnable.ets b/product/default/notificationmanagement/src/main/ets/pages/setEnable.ets index 3b1ede91..d6f001b2 100644 --- a/product/default/notificationmanagement/src/main/ets/pages/setEnable.ets +++ b/product/default/notificationmanagement/src/main/ets/pages/setEnable.ets @@ -23,18 +23,19 @@ import ConfigData from '../common/constants'; import Router from '@system.router' import notificationListener from '../../../../../../../features/managementcomponent/src/main/ets/com/ohos/model/notificationListener'; import Notification from '@ohos.notification'; +import NotificationManager from '@ohos.notificationManager'; +import { BundleItemData } from '@ohos/common'; const TAG = 'NotificationManagement-SetEnable'; -let appInfo; +let appInfo: BundleItemData; @Entry @Component export default struct SetEnable { - private listeners: any[] = []; @State headName:Resource = $r('app.string.notificationManagement'); @State allowNotice:Resource = $r('app.string.allowNotification'); - @State slotLst: any[] = []; + @State slotLst: NotificationManager.NotificationSlot[] = []; @State initState: boolean = false; build() { Flex({ justifyContent: FlexAlign.SpaceBetween }) { @@ -49,7 +50,7 @@ export default struct SetEnable { appTitle: appInfo.appTitle, appSummary: appInfo.appSummary, appValue: '', - appArrow: appInfo.appArrow, + appArrow: appInfo.appArrow as string, appArrowStyle: '', appUri: appInfo.appUri, appBundleName: appInfo.appBundleName, @@ -64,8 +65,8 @@ export default struct SetEnable { Row() { SwitchComponent({ title: $allowNotice, - initializationAction: () => this.switchComponentInit(), - settingAction: (params) => this.switchComponentSet(params), + initializationAction: (): Promise => this.switchComponentInit(), + settingAction: (params?: boolean): void => this.switchComponentSet(params), register: (listener) => notificationListener.register({bundle:appInfo.appBundleName,onEnableChanged:listener}) }) } @@ -128,15 +129,15 @@ export default struct SetEnable { switchComponentInit() { Log.showDebug(TAG, `switchComponentInit`) - return notificationListener.isNotificationEnabled({ bundle: appInfo.appBundleName, uid: appInfo.appUid }, (data) => { + return notificationListener.isNotificationEnabled({ bundle: appInfo.appBundleName, uid: appInfo.appUid }, (data: boolean) => { Log.showDebug(TAG, 'switchComponentInit callback' + data); this.initState = data; }); } - switchComponentSet(params) { + switchComponentSet(params?: boolean) { Log.showDebug(TAG, `switchComponentSet`) - this.initState = params; + this.initState = params as boolean; notificationListener.enableNotification({ bundle: appInfo.appBundleName, uid: appInfo.appUid }, params); } } \ No newline at end of file diff --git a/product/default/notificationmanagement/src/main/ets/pages/slotSetting.ets b/product/default/notificationmanagement/src/main/ets/pages/slotSetting.ets index f63e08d8..564c2086 100644 --- a/product/default/notificationmanagement/src/main/ets/pages/slotSetting.ets +++ b/product/default/notificationmanagement/src/main/ets/pages/slotSetting.ets @@ -22,17 +22,23 @@ import NotificationConfigData from '../../../../../../../features/managementcomp import Router from '@system.router'; import NotificationListener from '../../../../../../../features/managementcomponent/src/main/ets/com/ohos/model/notificationListener'; import notification from '@ohos.notification'; +import { BundleItemData } from '@ohos/common'; +import NotificationManager from '@ohos.notificationManager'; const TAG = 'NotificationManagement-SlotSetting'; const DEFAULT_SOUND = 'file://system/etc/Light.ogg'; -let slotParams; +interface ISlotParams { + appInfo?: BundleItemData, + slotInfo?: NotificationManager.NotificationSlot +}; @Entry @Component export default struct SlotSetting { - private appInfo: any = null; - private slotInfo: any = null; + private slotParams: ISlotParams = {}; + private appInfo: BundleItemData = {}; + private slotInfo: NotificationManager.NotificationSlot = {}; @State headName: Resource = $r('app.string.notificationManagement') @State allowNotice: Resource = $r('app.string.allowNotification') @State noticeStyleBanner: Resource = $r('app.string.notificationStyle_banner') @@ -56,8 +62,8 @@ export default struct SlotSetting { appIcon: this.appInfo.appIcon, appTitle: this.appInfo.appTitle, appSummary: this.appInfo.appSummary, - appValue: this.slotInfo.type, - appArrow: this.appInfo.appArrow, + appValue: this.slotInfo.type?.toString(), + appArrow: this.appInfo.appArrow as string, appArrowStyle: '', appUri: this.appInfo.appUri, appBundleName: this.appInfo.appBundleName, @@ -74,8 +80,8 @@ export default struct SlotSetting { Row() { SwitchComponent({ title: $allowNotice, - initializationAction: () => this.notificationSlotEnableInit(), - settingAction: (params) => this.notificationSlotEnableSet(params) + initializationAction: (): Promise => this.notificationSlotEnableInit(), + settingAction: (params): void => this.notificationSlotEnableSet(params as boolean) }) } .margin({ top: $r('app.float.page_notice_title_margin_t') }) @@ -105,8 +111,8 @@ export default struct SlotSetting { Row() { SwitchComponent({ title: $noticeStyleBanner, - initializationAction: () => this.bannerEnableInit(), - settingAction: (params) => this.bannerEnableSet(params) + initializationAction: (): Promise => this.bannerEnableInit(), + settingAction: (params): void => this.bannerEnableSet(params as boolean) }) } .padding({ @@ -120,8 +126,8 @@ export default struct SlotSetting { Row() { SwitchComponent({ title: $noticeSound, - initializationAction: () => this.soundEnableInit(), - settingAction: (params) => this.soundEnableSet(params) + initializationAction: (): Promise => this.soundEnableInit(), + settingAction: (params): void => this.soundEnableSet(params as boolean) }) } .padding({ @@ -151,9 +157,9 @@ export default struct SlotSetting { } aboutToAppear(): void{ - slotParams = Router.getParams(); - this.appInfo = slotParams.appInfo; - this.slotInfo = slotParams.slotInfo + this.slotParams = Router.getParams(); + this.appInfo = this.slotParams.appInfo as BundleItemData; + this.slotInfo = this.slotParams.slotInfo as NotificationManager.NotificationSlot; Log.showDebug(TAG, `aboutToAppear ${JSON.stringify(this.slotInfo)}`) } @@ -173,13 +179,13 @@ export default struct SlotSetting { }); } - notificationSlotEnableSet(data) { + notificationSlotEnableSet(data: boolean) { Log.showDebug(TAG, `notificationEnableSet data:${JSON.stringify(data)}`) this.initState = data; NotificationListener.enableNotificationSlot({ bundle: this.appInfo.appBundleName, uid: this.appInfo.appUid }, this.slotInfo.type, data); } - soundEnableInit() { + soundEnableInit(): Promise { Log.showDebug(TAG, `soundEnableInit`) return new Promise((resolve, reject) => { let result: boolean = false; @@ -191,23 +197,23 @@ export default struct SlotSetting { }); } - soundEnableSet(params) { + soundEnableSet(params: boolean) { Log.showDebug(TAG, `soundEnableSet params:${JSON.stringify(params)}`) - if (params == 0) { + if (!params) { this.slotInfo.sound = ''; if (this.slotInfo.level != notification.SlotLevel.LEVEL_HIGH) { this.slotInfo.level = notification.SlotLevel.LEVEL_LOW; } - } else if (params == 1) { + } else if (params) { this.slotInfo.sound = DEFAULT_SOUND; - if (this.slotInfo.level < notification.SlotLevel.LEVEL_DEFAULT) { + if (this.slotInfo.level && this.slotInfo.level < notification.SlotLevel.LEVEL_DEFAULT) { this.slotInfo.level = notification.SlotLevel.LEVEL_DEFAULT } } this.notificationSlotSet(); } - bannerEnableInit() { + bannerEnableInit(): Promise { Log.showDebug(TAG, `bannerEnableInit`) return new Promise((resolve, reject) => { let result: boolean = false; @@ -219,15 +225,15 @@ export default struct SlotSetting { }); } - bannerEnableSet(params) { + bannerEnableSet(params: boolean) { Log.showDebug(TAG, `bannerEnableSet params:${JSON.stringify(params)}`) - if (params == 0) { + if (!params) { if (this.slotInfo.sound) { this.slotInfo.level = notification.SlotLevel.LEVEL_DEFAULT; } else { this.slotInfo.level = notification.SlotLevel.LEVEL_LOW; } - } else if (params == 1) { + } else if (params) { this.slotInfo.level = notification.SlotLevel.LEVEL_HIGH; } this.notificationSlotSet(); diff --git a/product/default/notificationmanagement/src/main/module.json5 b/product/default/notificationmanagement/src/main/module.json5 index 27fe683a..0cd7f781 100644 --- a/product/default/notificationmanagement/src/main/module.json5 +++ b/product/default/notificationmanagement/src/main/module.json5 @@ -21,6 +21,7 @@ "pages": "$profile:main_pages", "abilities": [ { + "srcEntry": "./ets/MainAbility/MainAbility.ts", "visible": true, "srcEntrance": "./ets/MainAbility/MainAbility.ts", "name": "com.ohos.systemui.notificationmanagement.MainAbility", diff --git a/product/default/volumepanel/src/main/ets/pages/index.ets b/product/default/volumepanel/src/main/ets/pages/index.ets index 3e59a1c4..ab6f2c9d 100644 --- a/product/default/volumepanel/src/main/ets/pages/index.ets +++ b/product/default/volumepanel/src/main/ets/pages/index.ets @@ -21,13 +21,25 @@ import WindowManager, { WindowType } from '../../../../../../../common/src/main/ const TAG = 'VolumePanel-Index' +interface DisConfigInfo { + width: number, + height: number +} + +interface IvolumeRect { + left: number, + top: number, + width: number, + height: number +} + @Entry @Component struct Index { aboutToAppear() { Log.showInfo(TAG, `aboutToAppear Start`); - let configInfo = AbilityManager.getAbilityData(AbilityManager.ABILITY_NAME_VOLUME_PANEL, 'dis'); - let volumeRect; + let configInfo: DisConfigInfo = AbilityManager.getAbilityData(AbilityManager.ABILITY_NAME_VOLUME_PANEL, 'dis'); + let volumeRect: IvolumeRect; if (configInfo.width > configInfo.height) { // Pad、PC Mode const realWidth = 48; const realHeight = 284; diff --git a/product/pc/controlpanel/oh-package.json5 b/product/pc/controlpanel/oh-package.json5 index 3e76b4a1..08f03237 100644 --- a/product/pc/controlpanel/oh-package.json5 +++ b/product/pc/controlpanel/oh-package.json5 @@ -6,6 +6,7 @@ "dependencies": { "@ohos/controlcentercomponent": "file:../../../features/controlcentercomponent", "@ohos/autorotatecomponent": "file:../../../features/autorotatecomponent", - "@ohos/airplanecomponent": "file:../../../features/airplanecomponent" + "@ohos/airplanecomponent": "file:../../../features/airplanecomponent", + "@ohos/common": "file:../../../common", } } \ No newline at end of file diff --git a/product/pc/controlpanel/src/main/ets/pages/control.ets b/product/pc/controlpanel/src/main/ets/pages/control.ets index 14354243..ba97f5eb 100644 --- a/product/pc/controlpanel/src/main/ets/pages/control.ets +++ b/product/pc/controlpanel/src/main/ets/pages/control.ets @@ -23,7 +23,7 @@ const TAG = 'ControlPanel-Control'; @Component export default struct Control { - private modeChangeCallback: Function + private modeChangeCallback: Function = () => {} aboutToAppear() { Log.showInfo(TAG, `aboutToAppear Start`) @@ -39,7 +39,7 @@ export default struct Control { ControlCenterComponent({ mControlCenterComponentConfig: ControlCenterConfig, mSimpleToggleColumnCount: Constants.DEFAULT_SIMPLE_TOGGLE_COLUMN_COUNT, - modeChangeCallback: (isEdit) => this.modeChangeCallback(isEdit), + modeChangeCallback: (isEdit: boolean): void => this.modeChangeCallback(isEdit), titleDisplayInside: true, moduleName: 'pc_controlpanel', }) diff --git a/product/pc/controlpanel/src/main/ets/pages/index.ets b/product/pc/controlpanel/src/main/ets/pages/index.ets index e76fea85..14e81473 100644 --- a/product/pc/controlpanel/src/main/ets/pages/index.ets +++ b/product/pc/controlpanel/src/main/ets/pages/index.ets @@ -22,19 +22,24 @@ import ControlCenterComponent from './control' import WindowManager, { WindowType, WINDOW_SHOW_HIDE_EVENT, + ArgsInfo, } from "../../../../../../../common/src/main/ets/default/WindowManager"; import EventManager, { unsubscribe } from "../../../../../../../common/src/main/ets/default/event/EventManager"; import { START_ABILITY_EVENT } from "../../../../../../../common/src/main/ets/default/event/EventUtil"; import MultimodalInputManager, { MultiKeyCode, } from "../../../../../../../common/src/main/ets/default/MultimodalInputManager"; +import { Rect } from '@ohos/common' import display from "@ohos.display" const TAG = 'ControlPanel-Index' const SHOW_EVENT = "showControlCenter"; const HIDE_EVENT = "hideControlCenter"; -let mHeightConfigUtils +interface DisplayInfo { + width: number; + height: number; +} @Entry @Component @@ -46,25 +51,24 @@ struct Index { @State mWidthSize: number = 0.2 @State mHeightSize: number = 0.2 @State mHeightPx: number = 0 + @State mHeightConfigUtils: HeightConfigUtils | undefined = undefined; mClearCallbacks: Array = []; mShowAnimReady: boolean = false; aboutToAppear() { Log.showInfo(TAG, `aboutToAppear, start`) - setAppBgColor('#00000000') CommonStyleManager.setAbilityPageName(TAG) this.style = StyleConfiguration.getIndexStyle() StyleManager.setStyle() - let rect = AbilityManager.getAbilityData(AbilityManager.ABILITY_NAME_CONTROL_PANEL, 'rect') + let rect: Rect = AbilityManager.getAbilityData(AbilityManager.ABILITY_NAME_CONTROL_PANEL, 'rect') this.mHeightPx = rect.height - mHeightConfigUtils = new HeightConfigUtils(); - let StatusCoefficient; + this.mHeightConfigUtils = new HeightConfigUtils(); - StatusCoefficient = AppStorage.SetAndLink("StatusCoefficient", 1.0); - StatusCoefficient.set(mHeightConfigUtils.getStatusCoefficient()); + let StatusCoefficient = AppStorage.SetAndLink("StatusCoefficient", 1.0); + StatusCoefficient.set(this.mHeightConfigUtils.getStatusCoefficient()); this.initWindowPolicy(); Log.showDebug(TAG, `aboutToAppear, end`) @@ -94,7 +98,7 @@ struct Index { Scroll(new Scroller()) { Column() { ControlCenterComponent({ - modeChangeCallback: (isEdit) => this.onModeChange(isEdit) + modeChangeCallback: (isEdit: boolean): void => this.onModeChange(isEdit) }) } .width('100%') @@ -132,14 +136,16 @@ struct Index { EventManager.subscribe(SHOW_EVENT, () => this.showWindow()), EventManager.subscribe(HIDE_EVENT, () => this.hideWindow()), EventManager.subscribe(START_ABILITY_EVENT, () => this.hideWindow()), - EventManager.subscribe(WINDOW_SHOW_HIDE_EVENT, (args) => { - let { windowName, isShow } = args; + EventManager.subscribe(WINDOW_SHOW_HIDE_EVENT, (args: ArgsInfo) => { + let windowName = args.windowName; + let isShow = args?.isShow; Log.showInfo(TAG, `WINDOW_SHOW_HIDE_EVENT windowName: ${windowName}, isShow: ${isShow}`); windowName == WindowType.NOTIFICATION_PANEL && isShow && this.hideWindow(); windowName == WindowType.CONTROL_PANEL && isShow && (this.mShowAnimReady = true); }), - EventManager.subscribe('ControlWindowResizeEvent',async (args) => { - let { windowName, rect } = args; + EventManager.subscribe('ControlWindowResizeEvent',async (args: ArgsInfo) => { + let windowName = args.windowName; + let rect = args?.rect; let dis = await display.getDefaultDisplaySync(); Log.showInfo(TAG, `ControlWindowResizeEvent: ${windowName}, isShow: ${rect}`); AbilityManager.setAbilityData(AbilityManager.ABILITY_NAME_CONTROL_PANEL, 'rect', rect); @@ -149,7 +155,7 @@ struct Index { }); WindowManager.resetSizeWindow(windowName, rect).then( ).then(() => { - }).catch((err) => { + }).catch((err: Error) => { }); }), MultimodalInputManager.subscribeCombinationKey([MultiKeyCode.WIN, MultiKeyCode.I], (data) => { @@ -164,9 +170,9 @@ struct Index { ); } - _animateTo(config, callback) { + _animateTo(config: AnimateParam, callback: () => void) { animateTo(config, callback) - setTimeout(config.onFinish, config.duration + config.delay) + setTimeout(config.onFinish, config.duration as number + Number(config.delay)) } showAnimation(){ @@ -219,13 +225,13 @@ struct Index { this.showAnimation(); } - onModeChange(isEdit) { + onModeChange(isEdit: boolean): void { Log.showDebug(TAG, `onModeChange, isEdit: ${isEdit}`) - let initRect = AbilityManager.getAbilityData(AbilityManager.ABILITY_NAME_CONTROL_PANEL, 'rect') - let newRect = initRect + let initRect = AbilityManager.getAbilityData(AbilityManager.ABILITY_NAME_CONTROL_PANEL, 'rect') as ArgsInfo + let newRect = initRect as Rect if (isEdit) { - let dis = AbilityManager.getAbilityData(AbilityManager.ABILITY_NAME_CONTROL_PANEL, 'dis') - newRect = { ...initRect, height: StyleManager.calcScaleSize(346) } + let dis = AbilityManager.getAbilityData(AbilityManager.ABILITY_NAME_CONTROL_PANEL, 'dis') as DisplayInfo + newRect.height = StyleManager.calcScaleSize(346) } Log.showDebug(TAG, `onModeChange, newRect: ${JSON.stringify(newRect)}`) this._animateTo({ @@ -237,13 +243,13 @@ struct Index { playMode: PlayMode.Normal, onFinish: () => { Log.showInfo(TAG, `onModeChange, show anim finish.`) - if (newRect.height <= initRect.height) { + if (initRect.height && newRect.height <= initRect.height) { WindowManager.resetSizeWindow(WindowType.CONTROL_PANEL, newRect) } } }, () => { Log.showInfo(TAG, `onModeChange, animateTo`) - if (newRect.height > initRect.height) { + if (initRect.height && newRect.height > initRect.height) { WindowManager.resetSizeWindow(WindowType.CONTROL_PANEL, newRect) } this.mHeightPx = newRect.height diff --git a/product/pc/notificationpanel/oh-package.json5 b/product/pc/notificationpanel/oh-package.json5 index af0b25c5..27f12c50 100644 --- a/product/pc/notificationpanel/oh-package.json5 +++ b/product/pc/notificationpanel/oh-package.json5 @@ -4,6 +4,7 @@ "description": "", "version": "1.0.0", "dependencies": { - "@ohos/noticeitem": "file:../../../features/noticeitem" + "@ohos/noticeitem": "file:../../../features/noticeitem", + "@ohos/common": "file:../../../common" } } \ No newline at end of file diff --git a/product/pc/notificationpanel/src/main/ets/pages/bannerNotification.ets b/product/pc/notificationpanel/src/main/ets/pages/bannerNotification.ets index 468650b2..6dd80382 100644 --- a/product/pc/notificationpanel/src/main/ets/pages/bannerNotification.ets +++ b/product/pc/notificationpanel/src/main/ets/pages/bannerNotification.ets @@ -14,17 +14,17 @@ */ import Log from '../../../../../../../common/src/main/ets/default/Log'; -import {notificationData} from '../../../../../../../common/src/main/ets/plugindatasource/common/Constants' import AbilityManager from '../../../../../../../common/src/main/ets/default/abilitymanager/abilityManager'; import WindowManager, { WindowType } from '../../../../../../../common/src/main/ets/default/WindowManager'; import EventManager, {unsubscribe} from "../../../../../../../common/src/main/ets/default/event/EventManager"; import BannerNotification from '../../../../../../../features/noticeitem/src/main/ets/com/ohos/noticeItem/view/item/bannerNotificationItem'; import NotificationViewModel from '../../../../../../../features/noticeitem/src/main/ets/com/ohos/noticeItem/viewmodel/NotificationViewModel'; import NotificationConstants, { ScreenLockStatus } from '../../../../../../../features/noticeitem/src/main/ets/com/ohos/noticeItem/common/constants'; +import { NotificationItemData, Rect } from '@ohos/common'; const TAG = 'NotificationPanel-BannerNotification'; const TRANSLATE_SIZE = '382vp'; -const ANIM_CONFIG = { +const ANIM_CONFIG: AnimateParam = { duration: 250, tempo: 1.0, curve: Curve.Friction, @@ -32,7 +32,7 @@ const ANIM_CONFIG = { iterations: 1, playMode: PlayMode.Normal, } -const OPACITY_SHOW_ANIM_CONFIG = { +const OPACITY_SHOW_ANIM_CONFIG: AnimateParam = { duration: 200, tempo: 1.0, curve: Curve.Friction, @@ -40,7 +40,7 @@ const OPACITY_SHOW_ANIM_CONFIG = { iterations: 1, playMode: PlayMode.Normal, } -const OPACITY_HIDE_ANIM_CONFIG = { +const OPACITY_HIDE_ANIM_CONFIG: AnimateParam = { duration: 200, tempo: 1.0, curve: Curve.Friction, @@ -57,18 +57,22 @@ struct Index { @State mLastActionTime: number = 0; @State needExpand: boolean = true @State isExpand: boolean = false; - @State pageData: notificationData = new notificationData(); + @State pageData: NotificationItemData | undefined = undefined; @State mOpacity: number = 0.0; @State mWidthSize: number = 0.8; @State mTranslate: string = TRANSLATE_SIZE; - mClearCallbacks: unsubscribe[] - mDefaultBannerRect: any; + mClearCallbacks: unsubscribe[] = [] + mDefaultBannerRect: Rect = { + left: 0, + top: 0, + width: 0, + height: 0 + }; aboutToAppear() { Log.showInfo(TAG, `aboutToAppear Start`); AbilityManager.setContextName(AbilityManager.ABILITY_NAME_NOTIFICATION_PANEL, AbilityManager.ABILITY_NAME_NOTIFICATION_PANEL); - setAppBgColor('#00000000') this.mClearCallbacks = [] this.mClearCallbacks.push(EventManager.subscribe('onBannerNoticeShow', () => this.onBannerNoticeShow())) this.mClearCallbacks.push(EventManager.subscribe('onBannerNoticeHide', () => this.onBannerNoticeHide())) @@ -77,11 +81,11 @@ struct Index { aboutToDisappear() { Log.showInfo(TAG, `aboutToDisAppear`) - this.mClearCallbacks.forEach((mClearCallback: Function) => { - mClearCallback() - mClearCallback = undefined + this.mClearCallbacks.forEach((mClearCallback: Function | null) => { + mClearCallback&&mClearCallback(); + mClearCallback = null }) - this.mClearCallbacks = undefined + this.mClearCallbacks = [] } build() { @@ -95,7 +99,7 @@ struct Index { mBannerNoticeCnt: $mBannerNoticeCnt, needExpand: $needExpand, isExpand: $isExpand, - onBannerNoticeHide: () => this.onBannerNoticeHide() + onBannerNoticeHide: ():void => this.onBannerNoticeHide() }) } else { Blank() @@ -149,7 +153,7 @@ struct Index { } checkItemNeedExpand() { - if (this.pageData.contentType === NotificationConstants.NOTIFICATION_TYPE_BASIC + if (this.pageData?.contentType === NotificationConstants.NOTIFICATION_TYPE_BASIC && (!(this.pageData.actionButtons?.length > 0))) { return false; } else { @@ -157,41 +161,42 @@ struct Index { } } - _animateTo(config, callback) { + _animateTo(config: AnimateParam, callback: () => void) { animateTo(config, callback); - setTimeout(config.onFinish, config.duration + config.delay); + setTimeout(config.onFinish, Number(config.duration) + Number(config.delay)); } showWindowAnim() { Log.showDebug(TAG, `show anim start`); - this._animateTo({ ...ANIM_CONFIG, onFinish: () => { + ANIM_CONFIG.onFinish = () => { Log.showInfo(TAG, `show anim finish`); - } }, () => { + }; + this._animateTo(ANIM_CONFIG, () => { Log.showInfo(TAG, `do show anim`); this.mWidthSize = 1.0; this.mTranslate = '0vp'; }); - this._animateTo({ ...OPACITY_SHOW_ANIM_CONFIG, onFinish: () => { - } }, () => { + OPACITY_SHOW_ANIM_CONFIG.onFinish = () => {} + this._animateTo(OPACITY_SHOW_ANIM_CONFIG, () => { this.mOpacity = 1.0; }); } hideWindowAnim() { Log.showDebug(TAG, `hide anim start`); - this._animateTo({ ...ANIM_CONFIG, onFinish: () => { + ANIM_CONFIG.onFinish = () => { Log.showInfo(TAG, `hide anim finish`); this.mBannerNoticeCnt = 0; WindowManager.resetSizeWindow(WindowType.BANNER_NOTICE, this.mDefaultBannerRect); WindowManager.hideWindow(WindowType.BANNER_NOTICE); - } - }, () => { + }; + this._animateTo(ANIM_CONFIG, () => { Log.showInfo(TAG, `do hide anim`); this.mWidthSize = 0.8; this.mTranslate = TRANSLATE_SIZE; }); - this._animateTo({ ...OPACITY_HIDE_ANIM_CONFIG, onFinish: () => {} - }, () => { + OPACITY_HIDE_ANIM_CONFIG.onFinish = () => {}; + this._animateTo(OPACITY_HIDE_ANIM_CONFIG, () => { this.mOpacity = 0.0; }); } diff --git a/product/pc/notificationpanel/src/main/ets/pages/index.ets b/product/pc/notificationpanel/src/main/ets/pages/index.ets index 4cf8c2c2..cd7f1889 100644 --- a/product/pc/notificationpanel/src/main/ets/pages/index.ets +++ b/product/pc/notificationpanel/src/main/ets/pages/index.ets @@ -20,6 +20,7 @@ import Notification from './notification' import WindowManager, { WindowType, WINDOW_SHOW_HIDE_EVENT, + ArgsInfo, } from "../../../../../../../common/src/main/ets/default/WindowManager"; import EventManager, {unsubscribe} from "../../../../../../../common/src/main/ets/default/event/EventManager"; import {START_ABILITY_EVENT} from "../../../../../../../common/src/main/ets/default/event/EventUtil"; @@ -44,7 +45,6 @@ struct Index { aboutToAppear() { Log.showInfo(TAG, `aboutToAppear, start`) - setAppBgColor('#00000000') this.initWindowPolicy(); } @@ -100,14 +100,16 @@ struct Index { EventManager.subscribe(SHOW_EVENT, () => this.showWindow()), EventManager.subscribe(HIDE_EVENT, () => this.hideWindow()), EventManager.subscribe(START_ABILITY_EVENT, () => this.hideWindow()), - EventManager.subscribe(WINDOW_SHOW_HIDE_EVENT, (args) => { - let { windowName, isShow } = args; + EventManager.subscribe(WINDOW_SHOW_HIDE_EVENT, (args: ArgsInfo) => { + let windowName = args.windowName; + let isShow = args?.isShow; Log.showInfo(TAG, `WINDOW_SHOW_HIDE_EVENT windowName: ${windowName}, isShow: ${isShow}`); windowName == WindowType.CONTROL_PANEL && isShow && this.hideWindow(); windowName == WindowType.NOTIFICATION_PANEL && isShow && (this.mShowAnimReady = true); }), - EventManager.subscribe('NotificationWindowResizeEvent',async (args) => { - let { windowName, rect } = args; + EventManager.subscribe('NotificationWindowResizeEvent',async (args: ArgsInfo) => { + let windowName = args.windowName; + let rect = args?.rect; let dis = await display.getDefaultDisplaySync(); Log.showInfo(TAG, `NotificationWindowResizeEvent: ${windowName}, isShow: ${rect}`); AbilityManager.setAbilityData(AbilityManager.ABILITY_NAME_NOTIFICATION_PANEL, 'rect', rect); @@ -117,7 +119,7 @@ struct Index { }); WindowManager.resetSizeWindow(windowName, rect).then( ).then(() => { - }).catch((err) => { + }).catch((error: Error) => { }); }), MultimodalInputManager.subscribeCombinationKey([MultiKeyCode.WIN, MultiKeyCode.N], (data) => { @@ -132,9 +134,9 @@ struct Index { ); } - _animateTo(config, callback) { + _animateTo(config: AnimateParam, callback: () => void) { animateTo(config, callback) - setTimeout(config.onFinish, config.duration + config.delay) + setTimeout(config.onFinish, Number(config.duration) + Number(config.delay)) } showAnimation(){ diff --git a/product/pc/notificationpanel/src/main/ets/pages/notification.ets b/product/pc/notificationpanel/src/main/ets/pages/notification.ets index d6aba97b..3c7af70e 100644 --- a/product/pc/notificationpanel/src/main/ets/pages/notification.ets +++ b/product/pc/notificationpanel/src/main/ets/pages/notification.ets @@ -19,6 +19,7 @@ import EventManager from "../../../../../../../common/src/main/ets/default/event import {obtainStartAbility} from "../../../../../../../common/src/main/ets/default/event/EventUtil" import NotificationListComponent from '../../../../../../../features/noticeitem/src/main/ets/com/ohos/noticeItem/view/NotificationListComponent' import NotificationViewModel from '../../../../../../../features/noticeitem/src/main/ets/com/ohos/noticeItem/viewmodel/NotificationViewModel' +import { NotificationItemData } from '@ohos/common' const TAG = 'NotificationPanel-notification' const NO_NOTIFICATION_TOP_MARGIN = 40; @@ -32,7 +33,7 @@ const NOTIFICATION_TITLE_ICON_MARGIN = 24; @Component export default struct Notification { - @StorageLink('notificationList') notificationList: any[] = [] + @StorageLink('notificationList') notificationList: NotificationItemData[][] = [] @State isEnd: boolean = false aboutToAppear() { diff --git a/product/pc/statusbar/oh-package.json5 b/product/pc/statusbar/oh-package.json5 index ba828b02..e34d9848 100644 --- a/product/pc/statusbar/oh-package.json5 +++ b/product/pc/statusbar/oh-package.json5 @@ -13,6 +13,7 @@ "@ohos/batterycomponent": "file:../../../features/batterycomponent", "@ohos/ringmodecomponent": "file:../../../features/ringmodecomponent", "@ohos/capsulecomponent": "file:../../../features/capsulecomponent", - "@ohos/airplanecomponent": "file:../../../features/airplanecomponent" + "@ohos/airplanecomponent": "file:../../../features/airplanecomponent", + "@ohos/common": "file:../../../common" } } \ No newline at end of file diff --git a/product/pc/statusbar/src/main/ets/pages/index.ets b/product/pc/statusbar/src/main/ets/pages/index.ets index 560309fa..4f527432 100644 --- a/product/pc/statusbar/src/main/ets/pages/index.ets +++ b/product/pc/statusbar/src/main/ets/pages/index.ets @@ -22,16 +22,16 @@ import StatusbarConfig from './common/StatusbarConfig' import AbilityManager from '../../../../../../../common/src/main/ets/default/abilitymanager/abilityManager' import StatusBarVM from '../../../../../../../features/statusbarcomponent/src/main/ets/com/ohos/viewmodel/StatusBarVM' import {StatusBarData} from '../../../../../../../features/statusbarcomponent/src/main/ets/com/ohos/common/Constants' +import { ConfigInfo } from '@ohos/common'; const TAG = 'StatusBar-Index' -let mHeightConfigUtils; - @Entry @Component struct Index { @StorageLink('StatusMinH') StatusMinH: number = 24 @StorageLink('StatusCoefficient') StatusCoefficient: number = 1.0 + private mHeightConfigUtils: HeightConfigUtils = new HeightConfigUtils onBackPress(): boolean { return true; @@ -40,30 +40,24 @@ struct Index { aboutToAppear() { Log.showInfo(TAG, `aboutToAppear, start`); - let configInfo = AbilityManager.getAbilityData(AbilityManager.ABILITY_NAME_STATUS_BAR, 'config') + let configInfo = AbilityManager.getAbilityData(AbilityManager.ABILITY_NAME_STATUS_BAR, 'config') as ConfigInfo let statusBarData: StatusBarData = new StatusBarData(); statusBarData.displayWidth = configInfo.maxWidth; statusBarData.displayHeight = configInfo.maxHeight; statusBarData.showHorizontal = configInfo.showHorizontal; - statusBarData.ableToMaximize = configInfo.ableToMaximize; + statusBarData.ableToMaximize = configInfo.ableToMaximize as boolean; statusBarData.realWidth = configInfo.realWidth; statusBarData.realHeight = configInfo.realHeight; statusBarData.left = configInfo.xCoordinate; statusBarData.top = configInfo.yCoordinate; StatusBarVM.updateStatusBarData(statusBarData); - - setAppBgColor('#00000000'); CommonStyleManager.setAbilityPageName(TAG); StyleManager.setStyle(); - mHeightConfigUtils = new HeightConfigUtils(); - let StatusMinH; - let StatusCoefficient; - - StatusMinH = AppStorage.SetAndLink("StatusMinH", 24); - StatusCoefficient = AppStorage.SetAndLink("StatusCoefficient", 1.0); - StatusMinH.set(mHeightConfigUtils.getStatusMinH()); - StatusCoefficient.set(mHeightConfigUtils.getStatusCoefficient()); + let StatusMinH = AppStorage.SetAndLink("StatusMinH", 24); + let StatusCoefficient = AppStorage.SetAndLink("StatusCoefficient", 1.0); + StatusMinH.set(this.mHeightConfigUtils.getStatusMinH()); + StatusCoefficient.set(this.mHeightConfigUtils.getStatusCoefficient()); let signalObserved = AppStorage.SetAndLink("signalObserved", false); signalObserved.set(false); diff --git a/product/phone/dropdownpanel/oh-package.json5 b/product/phone/dropdownpanel/oh-package.json5 index 3e149858..0402a651 100644 --- a/product/phone/dropdownpanel/oh-package.json5 +++ b/product/phone/dropdownpanel/oh-package.json5 @@ -15,6 +15,7 @@ "@ohos/ringmodecomponent": "file:../../../features/ringmodecomponent", "@ohos/autorotatecomponent": "file:../../../features/autorotatecomponent", "@ohos/noticeitem": "file:../../../features/noticeitem", - "@ohos/airplanecomponent": "file:../../../features/airplanecomponent" + "@ohos/airplanecomponent": "file:../../../features/airplanecomponent", + "@ohos/common": "file:../../../common" } } \ No newline at end of file diff --git a/product/phone/dropdownpanel/src/main/ets/ServiceExtAbility/ServiceExtAbility.ts b/product/phone/dropdownpanel/src/main/ets/ServiceExtAbility/ServiceExtAbility.ts index 4d86ce41..c3aa4aaf 100644 --- a/product/phone/dropdownpanel/src/main/ets/ServiceExtAbility/ServiceExtAbility.ts +++ b/product/phone/dropdownpanel/src/main/ets/ServiceExtAbility/ServiceExtAbility.ts @@ -19,7 +19,7 @@ import Log from '../../../../../../../common/src/main/ets/default/Log'; import WindowManager, { WindowType } from '../../../../../../../common/src/main/ets/default/WindowManager'; import AbilityManager from '../../../../../../../common/src/main/ets/default/abilitymanager/abilityManager'; import NavBarConfiguration from '../../../../../../../features/navigationservice/src/main/ets/com/ohos/navigationservice/common/NavBarConfiguration'; -import { Want } from 'ability/want'; +import { Want } from '@kit.AbilityKit'; const TAG = 'DropdownPanel_ServiceExtAbility'; diff --git a/product/phone/dropdownpanel/src/main/ets/pages/bannerNotification.ets b/product/phone/dropdownpanel/src/main/ets/pages/bannerNotification.ets index 91f6a71a..acd6c910 100644 --- a/product/phone/dropdownpanel/src/main/ets/pages/bannerNotification.ets +++ b/product/phone/dropdownpanel/src/main/ets/pages/bannerNotification.ets @@ -14,17 +14,18 @@ */ import Log from '../../../../../../../common/src/main/ets/default/Log'; -import {notificationData} from '../../../../../../../common/src/main/ets/plugindatasource/common/Constants' +import { NotificationItemData } from '../../../../../../../common/src/main/ets/plugindatasource/common/Constants' import AbilityManager from '../../../../../../../common/src/main/ets/default/abilitymanager/abilityManager'; import WindowManager, { WindowType } from '../../../../../../../common/src/main/ets/default/WindowManager'; import EventManager, {unsubscribe} from "../../../../../../../common/src/main/ets/default/event/EventManager"; import BannerNotification from '../../../../../../../features/noticeitem/src/main/ets/com/ohos/noticeItem/view/item/bannerNotificationItem'; import NotificationViewModel from '../../../../../../../features/noticeitem/src/main/ets/com/ohos/noticeItem/viewmodel/NotificationViewModel'; import NotificationConstants, { ScreenLockStatus } from '../../../../../../../features/noticeitem/src/main/ets/com/ohos/noticeItem/common/constants'; +import { Rect } from '@ohos/common'; const TAG = 'DropdownPanel-BannerNotification'; const TRANSLATE_SIZE = '382vp'; -const ANIM_CONFIG = { +const ANIM_CONFIG: AnimateParam = { duration: 250, tempo: 1.0, curve: Curve.Friction, @@ -32,7 +33,7 @@ const ANIM_CONFIG = { iterations: 1, playMode: PlayMode.Normal, } -const OPACITY_SHOW_ANIM_CONFIG = { +const OPACITY_SHOW_ANIM_CONFIG: AnimateParam = { duration: 200, tempo: 1.0, curve: Curve.Friction, @@ -40,7 +41,7 @@ const OPACITY_SHOW_ANIM_CONFIG = { iterations: 1, playMode: PlayMode.Normal, } -const OPACITY_HIDE_ANIM_CONFIG = { +const OPACITY_HIDE_ANIM_CONFIG: AnimateParam = { duration: 200, tempo: 1.0, curve: Curve.Friction, @@ -57,13 +58,18 @@ struct Index { @State mLastActionTime: number = 0; @State needExpand: boolean = true @State isExpand: boolean = false; - @State pageData: notificationData = new notificationData(); + @State pageData: NotificationItemData | undefined = undefined; @State mOpacity: number = 0.0; @State mWidthSize: number = 0.8; @State mTranslate: string = TRANSLATE_SIZE; - mClearCallbacks: unsubscribe[] - mDefaultBannerRect: any; + mClearCallbacks: unsubscribe[] = []; + mDefaultBannerRect: Rect = { + left: 0, + top: 0, + width: 0, + height: 0 + }; aboutToAppear() { Log.showInfo(TAG, `aboutToAppear Start`); @@ -77,11 +83,11 @@ struct Index { aboutToDisappear() { Log.showInfo(TAG, `aboutToDisAppear`) - this.mClearCallbacks.forEach((mClearCallback: Function) => { - mClearCallback() + this.mClearCallbacks.forEach((mClearCallback: Function | undefined) => { + mClearCallback&&mClearCallback() mClearCallback = undefined }) - this.mClearCallbacks = undefined + this.mClearCallbacks = [] } build() { @@ -95,7 +101,7 @@ struct Index { mBannerNoticeCnt: $mBannerNoticeCnt, needExpand: $needExpand, isExpand: $isExpand, - onBannerNoticeHide: () => this.onBannerNoticeHide() + onBannerNoticeHide: (): void => this.onBannerNoticeHide() }) } else { Blank() @@ -149,7 +155,7 @@ struct Index { } checkItemNeedExpand() { - if (this.pageData.contentType === NotificationConstants.NOTIFICATION_TYPE_BASIC + if (this.pageData?.contentType === NotificationConstants.NOTIFICATION_TYPE_BASIC && (!(this.pageData.actionButtons?.length > 0))) { return false; } else { @@ -157,41 +163,42 @@ struct Index { } } - _animateTo(config, callback) { + _animateTo(config: AnimateParam, callback: () => void) { animateTo(config, callback); - setTimeout(config.onFinish, config.duration + config.delay); + setTimeout(config.onFinish, Number(config.duration) + Number(config.delay)); } showWindowAnim() { Log.showDebug(TAG, `show anim start`); - this._animateTo({ ...ANIM_CONFIG, onFinish: () => { + ANIM_CONFIG.onFinish = () => { Log.showInfo(TAG, `show anim finish`); - } }, () => { + }; + this._animateTo(ANIM_CONFIG, () => { Log.showInfo(TAG, `do show anim`); this.mWidthSize = 1.0; this.mTranslate = '0vp'; }); - this._animateTo({ ...OPACITY_SHOW_ANIM_CONFIG, onFinish: () => { - } }, () => { + OPACITY_SHOW_ANIM_CONFIG.onFinish = () => {} + this._animateTo(OPACITY_SHOW_ANIM_CONFIG, () => { this.mOpacity = 1.0; }); } hideWindowAnim() { Log.showDebug(TAG, `hide anim start`); - this._animateTo({ ...ANIM_CONFIG, onFinish: () => { + ANIM_CONFIG.onFinish = () => { Log.showInfo(TAG, `hide anim finish`); this.mBannerNoticeCnt = 0; WindowManager.resetSizeWindow(WindowType.BANNER_NOTICE, this.mDefaultBannerRect); WindowManager.hideWindow(WindowType.BANNER_NOTICE); - } - }, () => { + }; + this._animateTo(ANIM_CONFIG, () => { Log.showInfo(TAG, `do hide anim`); this.mWidthSize = 0.8; this.mTranslate = TRANSLATE_SIZE; }); - this._animateTo({ ...OPACITY_HIDE_ANIM_CONFIG, onFinish: () => {} - }, () => { + OPACITY_HIDE_ANIM_CONFIG.onFinish = () => {}; + this._animateTo(OPACITY_HIDE_ANIM_CONFIG, () => { this.mOpacity = 0.0; }); } diff --git a/product/phone/dropdownpanel/src/main/ets/pages/common/navigationEvent.ts b/product/phone/dropdownpanel/src/main/ets/pages/common/navigationEvent.ts index fc205730..5773dee0 100644 --- a/product/phone/dropdownpanel/src/main/ets/pages/common/navigationEvent.ts +++ b/product/phone/dropdownpanel/src/main/ets/pages/common/navigationEvent.ts @@ -15,6 +15,7 @@ import commonEvent from '@ohos.commonEvent'; import Log from '../../../../../../../../common/src/main/ets/default/Log'; +import { inputConsumer } from '@kit.InputKit'; const TAG = 'navigationEvent'; @@ -24,8 +25,14 @@ let commonEventSubscribeInfo = { let commonEventSubscriber = null; +export interface NavigationCallBack { + "onStateChange": (data: string) => void; + "onNotificationShowOrHide": (data: inputConsumer.KeyOptions) => void; + "onControlShowOrHide": (data: inputConsumer.KeyOptions) => void; +} + export class navigationEvent { - mCallback: any; + mCallback: NavigationCallBack; registerCallback(callback): void { Log.showDebug(TAG, 'registerCallback'); diff --git a/product/phone/dropdownpanel/src/main/ets/pages/control.ets b/product/phone/dropdownpanel/src/main/ets/pages/control.ets index 83939f9e..5ae3691f 100644 --- a/product/phone/dropdownpanel/src/main/ets/pages/control.ets +++ b/product/phone/dropdownpanel/src/main/ets/pages/control.ets @@ -29,12 +29,13 @@ import Log from '../../../../../../../common/src/main/ets/default/Log' import Constants from './common/constants' import StyleConfiguration, { ControlStyle } from './common/StyleConfiguration' import ControlCenterConfig from './common/ControlCenterConfig'; +import { TouchMoveData } from '@ohos/common'; const TAG = 'DropdownPanel-Control'; @Component export default struct Control { - private touchMoveCallback: Function + private touchMoveCallback: Function = () => {} startX: number = 0 startY: number = 0 @State moveX: number = 0 @@ -53,7 +54,7 @@ export default struct Control { build() { Column() { Column() { - statusBar({ touchMoveCallback: (data) => this.touchMoveCallback(data) }) + statusBar({ touchMoveCallback: (data: TouchMoveData): void => this.touchMoveCallback(data) }) } .width('100%') .height(this.style.statusBarHeight) @@ -68,7 +69,7 @@ export default struct Control { Scroll(new Scroller()) { Column() { ControlCenterComponent({ - touchMoveCallback: (data) => this.controlCenterTouchMoveCallback(data), + touchMoveCallback: (data: TouchMoveData): void => this.controlCenterTouchMoveCallback(data), mControlCenterComponentConfig: ControlCenterConfig, moduleName: 'phone_dropdownpanel', }) @@ -104,9 +105,9 @@ export default struct Control { } } - controlCenterTouchMoveCallback(data) { + controlCenterTouchMoveCallback(data: TouchMoveData) { Log.showDebug(TAG, `controlCenterTouchMoveCallback data: ${JSON.stringify(data)}`) - data['touchComponent'] = 'control' + data.touchComponent = 'control' if (this.touchMoveCallback) { this.touchMoveCallback(data) } @@ -116,7 +117,7 @@ export default struct Control { @Component struct statusBar { @StorageLink('StatusCoefficient') StatusCoefficient: number = 1.0 - private touchMoveCallback: Function + private touchMoveCallback: Function = () => {} startX: number = 0 startY: number = 0 @State moveX: number = 0 diff --git a/product/phone/dropdownpanel/src/main/ets/pages/index.ets b/product/phone/dropdownpanel/src/main/ets/pages/index.ets index ff50ec78..e8c4886f 100644 --- a/product/phone/dropdownpanel/src/main/ets/pages/index.ets +++ b/product/phone/dropdownpanel/src/main/ets/pages/index.ets @@ -1,4 +1,3 @@ -//@ts-nocheck /* * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -32,22 +31,28 @@ import EventManager, { unsubscribe } from "../../../../../../../common/src/main/ import { START_ABILITY_EVENT } from "../../../../../../../common/src/main/ets/default/event/EventUtil" import CommonStyleManager from '../../../../../../../common/src/main/ets/default/CommonStyleManager' import MultimodalInputManager from '../../../../../../../common/src/main/ets/default/MultimodalInputManager' -import AbilityManager from '../../../../../../../common/src/main/ets/default/abilitymanager/abilityManager' import HeightConfigUtils from '../../../../../../../common/src/main/ets/default/heightcofigUtils/HeightConfigUtils' import StatusBarVM from '../../../../../../../features/statusbarcomponent/src/main/ets/com/ohos/viewmodel/StatusBarVM' -import NavigationEvent from './common/navigationEvent' +import NavigationEvent, { NavigationCallBack } from './common/navigationEvent' import Notification from './notification' import ControlCenterComponent from './control' import StyleManager from './common/StyleManager' import dataShare from '@ohos.data.dataShare'; import settings from '@ohos.settings'; import Constants from "../../../../../../../common/src/main/ets/default/Constants"; +import { TouchMoveData, Rect, ConfigInfo } from '@ohos/common'; +import { Context } from '@kit.AbilityKit'; +import { inputConsumer } from '@kit.InputKit'; const TAG = 'DropdownPanel-Index' -let mHeightConfigUtils +interface IArg { + dropdownArea?: string +} -const SHOW_ANIM_CONFIG = { +let mHeightConfigUtils: HeightConfigUtils + +const SHOW_ANIM_CONFIG: AnimateParam = { duration: 300, tempo: 1.0, curve: Curve.Friction, @@ -55,20 +60,6 @@ const SHOW_ANIM_CONFIG = { iterations: 1, playMode: PlayMode.Normal }; -const HIDE_ANIM_CONFIG = { - duration: 200, - tempo: 1.0, - curve: Curve.EaseOut, - delay: 0, - iterations: 1, - playMode: PlayMode.Normal, -} - -class insertTemplate{ - type: TransitionType; - opacity: number; - scale: Object -} enum DropdownPanelComponentName { NONE = 'None', @@ -82,19 +73,19 @@ struct Index { @State showComponentName: DropdownPanelComponentName = DropdownPanelComponentName.NONE; @State componentOptAreaHeightPX: number = 0; @StorageLink('StatusCoefficient') StatusCoefficient: number = 1.0; - mCallback: any; - mClearCallbacks: unsubscribe[]; + private mCallback?: NavigationCallBack; + private mClearCallbacks?: unsubscribe[]; settingDataKey = 'settings.display.navigationbar_status'; - urivar: string = null; - helper: dataShare.DataShareHelper = null; + private urivar?: string; + private helper?: dataShare.DataShareHelper; mNavigationBarStatusDefaultValue: string = '1'; navigationBarWidth: number = 0; mNeedUpdate: boolean = false; - mWidthPx: number = 0; - @State mNotificationInsert: insertTemplate = new insertTemplate(); - @State mNotificationDelete: insertTemplate = new insertTemplate(); - @State mControlCenterInsert: insertTemplate = new insertTemplate(); - @State mControlCenterDelete: insertTemplate = new insertTemplate(); + @State mWidthPx: number = 0; + @State mNotificationInsert: TransitionOptions = {}; + @State mNotificationDelete: TransitionOptions = {}; + @State mControlCenterInsert: TransitionOptions = {}; + @State mControlCenterDelete: TransitionOptions = {}; @State componentOptAreaTranslateY: string = '0px'; @State backgroundOpacity: number = 0; @@ -108,8 +99,8 @@ struct Index { CommonStyleManager.setAbilityPageName(TAG); StyleManager.setStyle(); - let dropdownRect = AbilityManager.getAbilityData(AbilityManager.ABILITY_NAME_DROPDOWN_PANEL, 'rect'); - let navigationBarRect = AbilityManager.getAbilityData(AbilityManager.ABILITY_NAME_NAVIGATION_BAR, 'config'); + let dropdownRect: Rect = AbilityManager.getAbilityData(AbilityManager.ABILITY_NAME_DROPDOWN_PANEL, 'rect'); + let navigationBarRect: ConfigInfo = AbilityManager.getAbilityData(AbilityManager.ABILITY_NAME_NAVIGATION_BAR, 'config'); this.initHelper(dropdownRect, navigationBarRect); this.resizeDropdownPanelAndNavigationBar(dropdownRect, navigationBarRect); Log.showDebug(TAG, `getValueSync componentOptAreaHeightPX: ${this.componentOptAreaHeightPX}`); @@ -118,14 +109,13 @@ struct Index { this.mClearCallbacks = []; this.mClearCallbacks.push( - EventManager.subscribe('DropdownEvent', (args) => this.onDropdownEvent(args)), - EventManager.subscribe(START_ABILITY_EVENT, (args) => this.onStartAbility(args)), - EventManager.subscribe('hideNotificationWindowEvent', (args) => this.onHideNotificationWindowEvent(args))); + EventManager.subscribe('DropdownEvent', (args: IArg) => this.onDropdownEvent(args)), + EventManager.subscribe(START_ABILITY_EVENT, (args: IArg) => this.onStartAbility(args)), + EventManager.subscribe('hideNotificationWindowEvent', (args: IArg) => this.onHideNotificationWindowEvent(args))); mHeightConfigUtils = new HeightConfigUtils(); - let StatusCoefficient; - StatusCoefficient = AppStorage.SetAndLink("StatusCoefficient", 1.0); + let StatusCoefficient = AppStorage.SetAndLink("StatusCoefficient", 1.0); StatusCoefficient.set(mHeightConfigUtils.getStatusCoefficient()); let signalObserved = AppStorage.SetAndLink("signalObserved", false); @@ -142,7 +132,7 @@ struct Index { Log.showDebug(TAG, `aboutToAppear, end`); } - private async initHelper(dropdownRect, navigationBarRect): Promise { + private async initHelper(dropdownRect: Rect, navigationBarRect: ConfigInfo): Promise { this.urivar = Constants.getUriSync(Constants.KEY_NAVIGATIONBAR_STATUS); this.helper = await dataShare.createDataShareHelper(AbilityManager.getContext(AbilityManager.ABILITY_NAME_DROPDOWN_PANEL), this.urivar); Log.showDebug(TAG, `initHelper ${this.helper}, uri: ${JSON.stringify(this.urivar)}`); @@ -163,16 +153,16 @@ struct Index { aboutToDisappear() { Log.showInfo(TAG, `aboutToDisappear`) - this.mClearCallbacks.forEach((mClearCallback: Function) => { - mClearCallback() + this.mClearCallbacks&&this.mClearCallbacks.forEach((mClearCallback: Function | undefined) => { + mClearCallback&&mClearCallback() mClearCallback = undefined }) this.mClearCallbacks = undefined } - resizeDropdownPanelAndNavigationBar(dropdownRect, navigationBarRect) { + resizeDropdownPanelAndNavigationBar(dropdownRect: Rect, navigationBarRect: ConfigInfo) { Log.showDebug(TAG, `resizeDropdownPanelAndNavigationBar, dropdownRect: ${JSON.stringify(dropdownRect)} navigationBarRect: ${JSON.stringify(navigationBarRect)}`) - let context = AbilityManager.getContext(AbilityManager.ABILITY_NAME_DROPDOWN_PANEL); + let context: Context = AbilityManager.getContext(AbilityManager.ABILITY_NAME_DROPDOWN_PANEL); if (context == undefined || context == null) { Log.showInfo(TAG, `resizeDropdownPanelAndNavigationBar: ${context}`); return; @@ -180,37 +170,44 @@ struct Index { try { this.mNavigationBarStatusDefaultValue = settings.getValueSync(context, this.settingDataKey, '1'); this.componentOptAreaHeightPX = this.mNavigationBarStatusDefaultValue == '1' ? dropdownRect.height - navigationBarRect.realHeight : dropdownRect.height; - this.navigationBarWidth = this.mNavigationBarStatusDefaultValue == '1' ? navigationBarRect.height : 0; + this.navigationBarWidth = this.mNavigationBarStatusDefaultValue == '1' ? navigationBarRect.realHeight : 0; } catch (err) { Log.showError(TAG, `resizeDropdownPanelAndNavigationBar: ${context}, ${JSON.stringify(err)}`); } - WindowManager.resetSizeWindow(WindowType.NAVIGATION_BAR, { ...navigationBarRect, height: this.navigationBarWidth }) - WindowManager.resetSizeWindow(WindowType.DROPDOWN_PANEL, { ...dropdownRect, height: this.componentOptAreaHeightPX }) + const currRect: Rect = { + left: 0, + top: 0, + width: 0, + height: this.navigationBarWidth + }; + dropdownRect.height = this.componentOptAreaHeightPX; + WindowManager.resetSizeWindow(WindowType.NAVIGATION_BAR, currRect); + WindowManager.resetSizeWindow(WindowType.DROPDOWN_PANEL, dropdownRect ); } - onNotificationShowOrHide(data) { + onNotificationShowOrHide(data: inputConsumer.KeyOptions) { Log.showDebug(TAG, `mNotificationAsyncCallback preKeys: ${data.preKeys}, finalKey: ${data.finalKey}`); Log.showDebug(TAG, `this.showComponentName: ${this.showComponentName}`); if (this.showComponentName === DropdownPanelComponentName.NOTIFICATION) { this.hideSelf(); } else { - this.showSelf('Notification'); + this.showSelf(DropdownPanelComponentName.NOTIFICATION); } Log.showDebug(TAG, `mNotificationAsyncCallback end`); } - onControlShowOrHide(data) { + onControlShowOrHide(data: inputConsumer.KeyOptions) { Log.showDebug(TAG, `mControlAsyncCallback preKeys: ${data.preKeys}, finalKey: ${data.finalKey}`); Log.showDebug(TAG, `this.showComponentName: ${this.showComponentName}`); if (this.showComponentName === DropdownPanelComponentName.CONTROL_CENTER) { this.hideSelf(); } else { - this.showSelf('ControlCenter'); + this.showSelf(DropdownPanelComponentName.CONTROL_CENTER); } Log.showDebug(TAG, `mControlAsyncCallback end`); } - onStateChange(data) { + onStateChange(data: string) { Log.showDebug(TAG, `onStateChange, data: ${JSON.stringify(data)}`) Log.showDebug(TAG, `onStateChange, showComponentName: ${this.showComponentName}`) if (this.showComponentName !== DropdownPanelComponentName.NONE) { @@ -218,29 +215,29 @@ struct Index { } } - onDropdownEvent(args) { + onDropdownEvent(args: IArg) { Log.showDebug(TAG, `onDropdownEvent, args: ${JSON.stringify(args)}`) - this.showSelf(args.dropdownArea == 'left' ? 'Notification' : 'ControlCenter') + this.showSelf(args.dropdownArea == 'left' ? DropdownPanelComponentName.NOTIFICATION : DropdownPanelComponentName.CONTROL_CENTER) } - onStartAbility(args) { + onStartAbility(args: IArg) { Log.showDebug(TAG, `onStartAbility, args: ${args}`) this.hideSelf() } - onHideNotificationWindowEvent(args) { + onHideNotificationWindowEvent(args: IArg) { Log.showDebug(TAG, `onHideNotificationWindowEvent, args: ${args}`) this.hideSelf() } - onTouchMove(data) { + onTouchMove(data: TouchMoveData) { Log.showDebug(TAG, `onTouchMove, data: ${JSON.stringify(data)}`) if (data.direction == 'top') { this.hideSelf() } else if (data.direction == 'left' && data.touchComponent == 'notification') { - this.switchNotificationOrControlCenter('ControlCenter') + this.switchNotificationOrControlCenter(DropdownPanelComponentName.CONTROL_CENTER) } else if (data.direction == 'right' && data.touchComponent == 'control') { - this.switchNotificationOrControlCenter('Notification') + this.switchNotificationOrControlCenter(DropdownPanelComponentName.NOTIFICATION) } else if (data.direction == 'drop_left' && data.touchComponent == 'control') { this.showComponentName = DropdownPanelComponentName.NOTIFICATION } else if (data.direction == 'drop_right' && data.touchComponent == 'notification') { @@ -248,25 +245,26 @@ struct Index { } } - switchNotificationOrControlCenter(showComponentName) { + switchNotificationOrControlCenter(showComponentName: DropdownPanelComponentName) { Log.showDebug(TAG, `switchNotificationOrControlCenter, showComponentName: ${showComponentName}`) this.mNotificationInsert = { type: TransitionType.Insert, opacity: 0, translate: { x: (-this.mWidthPx) + 'px' } } this.mControlCenterInsert = { type: TransitionType.Insert, opacity: 0, translate: { x: (this.mWidthPx) + 'px' } } - let transitionDelete = { + let transitionDelete: TransitionOptions = { type: TransitionType.Delete, opacity: 0, scale: { x: 0.8, y: 0.8, centerX: '50%', centerY: '50%' } } this.mNotificationDelete = transitionDelete this.mControlCenterDelete = transitionDelete - this._animateTo({ ...SHOW_ANIM_CONFIG, onFinish: () => { + SHOW_ANIM_CONFIG.onFinish = () => { Log.showInfo(TAG, `switchNotificationOrControlCenter, show anim finish.`); - } }, () => { + } + this._animateTo(SHOW_ANIM_CONFIG, () => { this.showComponentName = showComponentName }) } - showSelf(showComponentName) { + showSelf(showComponentName: DropdownPanelComponentName) { Log.showDebug(TAG, `showSelf, showComponentName: ${showComponentName}`) this.showComponentName = showComponentName WindowManager.showWindow(WindowType.DROPDOWN_PANEL) @@ -277,21 +275,23 @@ struct Index { hideSelf() { Log.showDebug(TAG, `hideSelf`) - this._animateTo({...SHOW_ANIM_CONFIG, onFinish: () => { + SHOW_ANIM_CONFIG.onFinish = () => { Log.showInfo(TAG, `hideSelf, hide anim finish.`); - }, finishCallback:()=>{ - WindowManager.hideWindow(WindowType.DROPDOWN_PANEL) - }}, () => { + }; + this._animateTo(SHOW_ANIM_CONFIG, () => { this.componentOptAreaTranslateY = (-this.componentOptAreaHeightPX * 0.1) + 'px' this.backgroundOpacity = 0 this.showComponentName = DropdownPanelComponentName.NONE - }) + }, true) } - _animateTo(config, callback) { + _animateTo(config: AnimateParam, callback: () => void, ishideWindow: boolean = false) { Log.showDebug(TAG, `_animateTo, config: ${JSON.stringify(config)}`) animateTo(config, callback) - setTimeout(config.finishCallback, config.duration + config.delay) + if (ishideWindow) { + const delay = Number(config.duration) + Number(config.delay) + setTimeout(() => WindowManager.hideWindow(WindowType.DROPDOWN_PANEL), delay) + } } build() { @@ -304,13 +304,13 @@ struct Index { .opacity(1) Column() { if (this.showComponentName === DropdownPanelComponentName.NOTIFICATION) { - Notification({ touchMoveCallback: (data) => this.onTouchMove(data) }) + Notification({ touchMoveCallback: (data: TouchMoveData): void => this.onTouchMove(data) }) .transition(this.mNotificationInsert) .transition(this.mNotificationDelete) } if (this.showComponentName === DropdownPanelComponentName.CONTROL_CENTER) { ControlCenterComponent({ - touchMoveCallback: (data) => this.onTouchMove(data) + touchMoveCallback: (data: TouchMoveData): void => this.onTouchMove(data) }) .transition(this.mControlCenterInsert) .transition(this.mControlCenterDelete) diff --git a/product/phone/dropdownpanel/src/main/ets/pages/notification.ets b/product/phone/dropdownpanel/src/main/ets/pages/notification.ets index f5b8ed56..5e55f2f3 100644 --- a/product/phone/dropdownpanel/src/main/ets/pages/notification.ets +++ b/product/phone/dropdownpanel/src/main/ets/pages/notification.ets @@ -34,6 +34,7 @@ import ResourceUtil from '../../../../../../../common/src/main/ets/default/Resou import TimeManager, { TimeEventArgs, TIME_CHANGE_EVENT } from '../../../../../../../common/src/main/ets/default/TimeManager'; import deviceInfo from '@ohos.deviceInfo'; +import { NotificationItemData, TouchMoveData } from '@ohos/common'; const TAG = 'DropdownPanel-notification'; const IMAGE_SIZE_L = 24; @@ -47,13 +48,13 @@ const deviceTypeInfo = deviceInfo.deviceType; @Component export default struct Notification { - private touchMoveCallback: Function + private touchMoveCallback: Function = () => {} startX: number = 0 startY: number = 0 @State moveX: number = 0 @State moveY: number = 0 @State isEnd: boolean = true - @StorageLink('notificationList') notificationList: any[] = [] + @StorageLink('notificationList') notificationList: NotificationItemData[][] = [] aboutToAppear() { Log.showInfo(TAG, `aboutToAppear Start`); @@ -71,9 +72,9 @@ export default struct Notification { Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start, justifyContent: FlexAlign.Start }) { - statusBar({ touchMoveCallback: (data) => this.touchMoveCallback(data) }) + statusBar({ touchMoveCallback: (data: TouchMoveData): void => this.touchMoveCallback(data) }) CenterTitle({ - touchMoveCallback: (data) => this.CenterTitleTouchMoveCallback(data) + touchMoveCallback: (data: TouchMoveData):void => this.CenterTitleTouchMoveCallback(data) }) if (this.notificationList.length == 0) { Text($r("app.string.no_notification")) @@ -137,9 +138,9 @@ export default struct Notification { } } - CenterTitleTouchMoveCallback(data) { + CenterTitleTouchMoveCallback(data: TouchMoveData) { Log.showDebug(TAG, `CenterTitleTouchMoveCallback, data: ${JSON.stringify(data)}`) - data['touchComponent'] = 'notification' + data.touchComponent = 'notification' if (this.touchMoveCallback) { this.touchMoveCallback(data) } @@ -149,7 +150,7 @@ export default struct Notification { @Component struct statusBar { @StorageLink('StatusCoefficient') StatusCoefficient: number = 1.0 - private touchMoveCallback: Function + private touchMoveCallback: Function = () => {} startX: number = 0 startY: number = 0 @State moveX: number = 0 @@ -218,11 +219,11 @@ struct statusBar { @Component struct CenterTitle { - private touchMoveCallback: Function - startX: number = 0 - startY: number = 0 - @State moveX: number = 0 - @State moveY: number = 0 + private touchMoveCallback: Function = () => {}; + startX: number = 0; + startY: number = 0; + @State moveX: number = 0; + @State moveY: number = 0; @State mTimeString: string = ''; @State mTime: string = '01:01' unSubscriber?: unsubscribe; diff --git a/product/phone/statusbar/oh-package.json5 b/product/phone/statusbar/oh-package.json5 index 2624f048..3a1c8d06 100644 --- a/product/phone/statusbar/oh-package.json5 +++ b/product/phone/statusbar/oh-package.json5 @@ -4,6 +4,7 @@ "description": "", "version": "1.0.0", "dependencies": { - "@ohos/statusbarcomponent": "file:../../../features/statusbarcomponent" + "@ohos/statusbarcomponent": "file:../../../features/statusbarcomponent", + "@ohos/common": "file:../../../common" } } \ No newline at end of file diff --git a/product/phone/statusbar/src/main/ets/ServiceExtAbility/ServiceExtAbility.ts b/product/phone/statusbar/src/main/ets/ServiceExtAbility/ServiceExtAbility.ts index 72b743e7..c8395b0c 100644 --- a/product/phone/statusbar/src/main/ets/ServiceExtAbility/ServiceExtAbility.ts +++ b/product/phone/statusbar/src/main/ets/ServiceExtAbility/ServiceExtAbility.ts @@ -20,7 +20,7 @@ import WindowManager, { WindowType } from '../../../../../../../common/src/main/ import AbilityManager from '../../../../../../../common/src/main/ets/default/abilitymanager/abilityManager'; import StatusBarConfiguration from '../../../../../../../features/statusbarcomponent/src/main/ets/com/ohos/common/StatusBarConfiguration'; import StatusBarConstants from '../../../../../../../features/statusbarcomponent/src/main/ets/com/ohos/common/Constants'; -import { Want } from 'ability/want'; +import Want from '@ohos.application.Want'; import deviceInfo from '@ohos.deviceInfo'; const TAG = 'StatusBar_ServiceExtAbility'; diff --git a/product/phone/statusbar/src/main/ets/pages/index.ets b/product/phone/statusbar/src/main/ets/pages/index.ets index 21e32ed8..7ccd9ab2 100644 --- a/product/phone/statusbar/src/main/ets/pages/index.ets +++ b/product/phone/statusbar/src/main/ets/pages/index.ets @@ -15,7 +15,7 @@ import Log from '../../../../../../../common/src/main/ets/default/Log' import Trace from '../../../../../../../common/src/main/ets/default/Trace' -import WindowManager, {WindowType, WINDOW_SHOW_HIDE_EVENT +import WindowManager, {WindowType, WINDOW_SHOW_HIDE_EVENT, ArgsInfo } from '../../../../../../../common/src/main/ets/default/WindowManager' import EventManager, {unsubscribe} from "../../../../../../../common/src/main/ets/default/event/EventManager" import {obtainLocalEvent} from "../../../../../../../common/src/main/ets/default/event/EventUtil" @@ -23,16 +23,19 @@ import CommonStyleManager from '../../../../../../../common/src/main/ets/default import HeightConfigUtils from '../../../../../../../common/src/main/ets/default/heightcofigUtils/HeightConfigUtils' import StatusBarComponent from '../../../../../../../features/statusbarcomponent/src/main/ets/com/ohos/pages/StatusBarComponent' import StatusBarVM from '../../../../../../../features/statusbarcomponent/src/main/ets/com/ohos/viewmodel/StatusBarVM' -import {StatusBarData} from '../../../../../../../features/statusbarcomponent/src/main/ets/com/ohos/common/Constants' +import { StatusBarData, + DropdownRange +} from '../../../../../../../features/statusbarcomponent/src/main/ets/com/ohos/common/Constants' import Constants from './common/constants' import StyleManager from './common/StyleManager' import StatusbarConfig from './common/StatusbarConfig' import AbilityManager from '../../../../../../../common/src/main/ets/default/abilitymanager/abilityManager' +import { ConfigInfo } from '@ohos/common'; const TAG = 'StatusBar-Index' const SLIDING_STATUS_BAR_DISTANCE = 18 -let mHeightConfigUtils; +let mHeightConfigUtils = new HeightConfigUtils(); @Entry @Component @@ -45,7 +48,7 @@ struct Index { @StorageLink('StatusMinH') StatusMinH: number = 24 @StorageLink('StatusCoefficient') StatusCoefficient: number = 1.0 mClearCallback: unsubscribe | undefined - dropdownpanelIsOpen:boolean = false + dropdownpanelIsOpen:boolean = false onBackPress(): boolean { return true; } @@ -58,14 +61,11 @@ struct Index { CommonStyleManager.setAbilityPageName(TAG); StyleManager.setStyle(); - this.mClearCallback = EventManager.subscribe(WINDOW_SHOW_HIDE_EVENT, (args) => this.onWindowShowHideEvent(args)); - - mHeightConfigUtils = new HeightConfigUtils(); - let StatusMinH; - let StatusCoefficient; - - StatusMinH = AppStorage.SetAndLink("StatusMinH", 24); - StatusCoefficient = AppStorage.SetAndLink("StatusCoefficient", 1.0); + this.mClearCallback = EventManager.subscribe( + WINDOW_SHOW_HIDE_EVENT, + (args: ArgsInfo) => this.onWindowShowHideEvent(args)); + let StatusMinH = AppStorage.SetAndLink("StatusMinH", 24); + let StatusCoefficient = AppStorage.SetAndLink("StatusCoefficient", 1.0); StatusMinH.set(mHeightConfigUtils.getStatusMinH()); StatusCoefficient.set(mHeightConfigUtils.getStatusCoefficient()); @@ -103,12 +103,12 @@ struct Index { } updateStatusBarData() { - let configInfo = AbilityManager.getAbilityData(AbilityManager.ABILITY_NAME_STATUS_BAR, 'config'); + let configInfo = AbilityManager.getAbilityData(AbilityManager.ABILITY_NAME_STATUS_BAR, 'config') as ConfigInfo; let statusBarData: StatusBarData = new StatusBarData(); statusBarData.displayWidth = configInfo.maxWidth; statusBarData.displayHeight = configInfo.maxHeight; statusBarData.showHorizontal = configInfo.showHorizontal; - statusBarData.ableToMaximize = configInfo.ableToMaximize; + statusBarData.ableToMaximize = configInfo.ableToMaximize??false; statusBarData.realWidth = configInfo.realWidth; statusBarData.realHeight = configInfo.realHeight; statusBarData.left = configInfo.xCoordinate; @@ -146,10 +146,10 @@ struct Index { if (!this.mStatusBarData.showHorizontal || !this.mStatusBarData.ableToMaximize) { return } - let dropdownArea: string = null - if (this.checkDropdownShowStatus(StatusbarConfig.dropdownRanges.notification)) { + let dropdownArea: string = '' + if (this.checkDropdownShowStatus(StatusbarConfig.dropdownRanges?.notification as DropdownRange)) { dropdownArea = 'left' - } else if (this.checkDropdownShowStatus(StatusbarConfig.dropdownRanges.control)) { + } else if (this.checkDropdownShowStatus(StatusbarConfig.dropdownRanges?.control as DropdownRange)) { dropdownArea = 'right' } if (dropdownArea) { @@ -159,13 +159,13 @@ struct Index { } } - checkDropdownShowStatus(range) { + checkDropdownShowStatus(range: DropdownRange) { let rangeStartX = this.mStatusBarData.realWidth * range.startPosition + this.mStatusBarData.left let rangeEndX = this.mStatusBarData.realWidth * range.endPosition + this.mStatusBarData.left return (vp2px(this.startX) >= rangeStartX) && (vp2px(this.startX) <= rangeEndX) } - onWindowShowHideEvent(args) { + onWindowShowHideEvent(args: ArgsInfo) { Log.showDebug(TAG, `onWindowShowHideEvent, args: ${JSON.stringify(args)}`) if (args.windowName == WindowType.DROPDOWN_PANEL) { if (args.isShow) {