已合并
systemui升级api12,IBINV4稳定性加固 #514
rtggg创建于 2025年3月3日
systemui升级api12,IBINV4稳定性加固 #514
已合并
rtggg创建于 2025年3月3日
refs/pull/514/head合入到master
107 个文件变更+898-646
@@ -4,8 +4,22 @@
4 {4 {
5 "name": "default",5 "name": "default",
6 "signingConfig": "release",6 "signingConfig": "release",
7- "compileSdkVersion": 10,7+ "compileSdkVersion": 12,
8- "compatibleSdkVersion": 98+ "compatibleSdkVersion": 12,
9+ }
10+ ],
11+ "signingConfigs": [
12+ {
13+ "name": "default",
14+ "material": {
15+ "certpath": "C:/Users/wanghuan/.ohos/config/openharmony/default_applications_systemui_zBXUo9gni2fBvC-EjMlkQtKNasCWggA51ALU78m_VWw=.cer",
16+ "storePassword": "0000001BA46E9456DA9E08ACF2A2BFF895A59A4F04F108BD52CED4DAE31B1534C59A5EEEE14B8200ACB885",
17+ "keyAlias": "debugKey",
18+ "keyPassword": "0000001B90751837A5A320E7821C1065CA3C5C38034D3AD64C3E7FD4B7EAE5A5027537CAB7DC32A5230894",
19+ "profile": "C:/Users/wanghuan/.ohos/config/openharmony/default_applications_systemui_zBXUo9gni2fBvC-EjMlkQtKNasCWggA51ALU78m_VWw=.p7b",
20+ "signAlg": "SHA256withECDSA",
21+ "storeFile": "C:/Users/wanghuan/.ohos/config/openharmony/default_applications_systemui_zBXUo9gni2fBvC-EjMlkQtKNasCWggA51ALU78m_VWw=.p12"
22+ }
9 }23 }
10 ]24 ]
11 },25 },
@@ -0,0 +1,21 @@
1+export { default as Constants } from './src/main/ets/plugindatasource/common/Constants';
2+export { FilterData } from './src/main/ets/plugindatasource/common/Constants';
3+export { RootConfigInfo } from './src/main/ets/plugindatasource/common/Constants';
4+export { LoaderConfigInfo } from './src/main/ets/plugindatasource/common/Constants';
5+export { PluginType } from './src/main/ets/plugindatasource/common/Constants';
6+export { obtainMsg } from './src/main/ets/plugindatasource/common/Constants';
7+export { ItemComponentData } from './src/main/ets/plugindatasource/common/Constants';
8+export { ActionData } from './src/main/ets/plugindatasource/common/Constants';
9+export { PluginComponentData } from './src/main/ets/plugindatasource/common/Constants';
10+export { itemData } from './src/main/ets/plugindatasource/common/Constants';
11+export { NotificationItemData } from './src/main/ets/plugindatasource/common/Constants';
12+export { RuleData } from './src/main/ets/plugindatasource/common/Constants';
13+export { ConfigInfo } from './src/main/ets/plugindatasource/common/Constants';
14+export { BundleItemData } from './src/main/ets/plugindatasource/common/Constants';
15+export { TouchMoveData } from './src/main/ets/plugindatasource/common/Constants';
16+ 
17+export { Event } from './src/main/ets/default/event/EventUtil';
18+ 
19+export { Rect } from './src/main/ets/default/Constants';
20+ 
21+ 
@@ -3,5 +3,6 @@
3 "name": "@ohos/common",3 "name": "@ohos/common",
4 "description": "a npm package which contains common function",4 "description": "a npm package which contains common function",
5 "version": "1.0.0",5 "version": "1.0.0",
6+ "main": "index.ets",
6 "dependencies": {}7 "dependencies": {}
7}8}
@@ -32,7 +32,7 @@ export type TimeEventArgs = {
32 timeFormat: boolean;32 timeFormat: boolean;
33};33};
34 34 
35-const TAG = "TimeManager";35+const TAG = "TimeManager_SysUI";
36const TIME_FORMAT_KEY = settings.date.TIME_FORMAT;36const TIME_FORMAT_KEY = settings.date.TIME_FORMAT;
37const TIME_SUBSCRIBE_INFO = {37const TIME_SUBSCRIBE_INFO = {
38 events: [38 events: [
@@ -74,8 +74,9 @@ class TimeManager {
74 }74 }
75 75 
76 public formatTime(date: Date, as24Hour: boolean = false) {76 public formatTime(date: Date, as24Hour: boolean = false) {
77- this.mUse24hFormat = as24Hour ? true : i18n.System.is24HourClock();77+ this.mUse24hFormat = i18n.System.is24HourClock();
78- return concatTime(date.getHours() % (this.mUse24hFormat ? 24 : 12), date.getMinutes());78+ let format = as24Hour ? 24 : this.mUse24hFormat;
79+ return concatTime(date.getHours() % (format ? 24 : 12), date.getMinutes());
79 }80 }
80 81 
81 private async initTimeFormat(context: any): Promise<void> {82 private async initTimeFormat(context: any): Promise<void> {
@@ -39,6 +39,17 @@ export enum WindowType {
39 PRIVACY_INDICATOR = 'SystemUi_PrivacyIndicator'39 PRIVACY_INDICATOR = 'SystemUi_PrivacyIndicator'
40}40}
41 41 
42+export interface ArgsInfo {
43+ windowName: WindowType;
44+ isShow?: boolean;
45+ isDestroy?: boolean;
46+ rect?: Rect;
47+ left?: number;
48+ top?: number;
49+ width?: number;
50+ height?: number;
51+}
52+ 
42export const WINDOW_SHOW_HIDE_EVENT = 'WindowShowHideEvent';53export const WINDOW_SHOW_HIDE_EVENT = 'WindowShowHideEvent';
43 54 
44export const WINDOW_RESIZE_EVENT = 'WindowResizeEvent';55export const WINDOW_RESIZE_EVENT = 'WindowResizeEvent';
@@ -14,6 +14,11 @@
14 */14 */
15 15 
16import { Event } from '../../default/event/EventUtil';16import { Event } from '../../default/event/EventUtil';
17+import notificationManager from '@ohos.notificationManager';
18+import image from '@ohos.multimedia.image';
19+import resourceManager from '@ohos.resourceManager';
20+import { WantAgent } from '@ohos.wantAgent';
21+import NtfMgr from '@ohos.notificationManager';
17 22 
18export default class Constants {23export default class Constants {
19 static readonly INIT_CONFIG = 'initConfig';24 static readonly INIT_CONFIG = 'initConfig';
@@ -104,7 +109,7 @@ export class itemData {
104 isShowIcon?109 isShowIcon?
105}110}
106 111 
107-export class notificationData {112+export interface NotificationItemData {
108 id: string;113 id: string;
109 hashcode: string;114 hashcode: string;
110 userId: number;115 userId: number;
@@ -113,12 +118,12 @@ export class notificationData {
113 timestamp: number;118 timestamp: number;
114 time: string;119 time: string;
115 appName: string;120 appName: string;
116- want: any;121+ want: WantAgent;
117- actionButtons: any[];122+ actionButtons: notificationManager.ButtonOptions[];
118 bundleName: string;123 bundleName: string;
119- smallIcon?: PixelMap;124+ smallIcon?: image.PixelMap | string;
120- largeIcon?: PixelMap;125+ largeIcon?: image.PixelMap | string;
121- picture?: PixelMap;126+ picture?: image.PixelMap;
122 title?: string;127 title?: string;
123 text?: string;128 text?: string;
124 additionalText?: string;129 additionalText?: string;
@@ -133,7 +138,7 @@ export class notificationData {
133 sound?: string;138 sound?: string;
134 vibrationValues?: Array<number>;139 vibrationValues?: Array<number>;
135 notificationFlags?: any;140 notificationFlags?: any;
136- ruleData?;141+ ruleData?: RuleData;
137 template?: any;142 template?: any;
138 isOngoing?: boolean;143 isOngoing?: boolean;
139 isUnremovable?: boolean;144 isUnremovable?: boolean;
@@ -143,3 +148,44 @@ export class notificationData {
143 groupName?: string;148 groupName?: string;
144 tapDismissed?: boolean;149 tapDismissed?: boolean;
145}150}
151+ 
152+export interface RuleData {
153+ isAllowBanner?: boolean;
154+ isAllowSound?: boolean;
155+ isAllowVibrationValues?: boolean;
156+ isAllowStatusBarShow?: boolean;
157+ isAllowNotificationListShow?: boolean;
158+}
159+ 
160+export interface ConfigInfo {
161+ maxWidth: number;
162+ maxHeight: number;
163+ minHeight: number;
164+ showHorizontal: boolean;
165+ direction: number;
166+ realWidth: number;
167+ realHeight: number;
168+ xCoordinate: number;
169+ yCoordinate: number;
170+ ableToMaximize?: boolean;
171+ showNavHorizontal?: boolean;
172+}
173+ 
174+export interface BundleItemData {
175+ appIcon?: string;
176+ appTitle?: string;
177+ appValue?: string;
178+ appArrow?: string | resourceManager.Resource;
179+ appSummary?: string;
180+ appBundleName?: string;
181+ appIconId?: string;
182+ appUri?: string;
183+ appUid?: number;
184+ systemApp?: boolean;
185+ slotSettingUrl?: string
186+}
187+ 
188+export interface TouchMoveData {
189+ direction: string,
190+ touchComponent: string
191+}
@@ -20,20 +20,20 @@ const TAG = 'SimpleToggleBase'
20 20 
21@Component21@Component
22export default struct SimpleToggleBase {22export default struct SimpleToggleBase {
23- private mToggleId: string23+ private mToggleId: string = ''
24 @Link mIcon: Resource24 @Link mIcon: Resource
25 @State mIconStr: string = ''25 @State mIconStr: string = ''
26 private mUseIconStr: boolean = false26 private mUseIconStr: boolean = false
27 private mAutoIconColor: boolean = false27 private mAutoIconColor: boolean = false
28 @Link mChangeSwitch: boolean28 @Link mChangeSwitch: boolean
29 @Link mLabel: Resource29 @Link mLabel: Resource
30- private mLabelStr: string | Resource30+ private mLabelStr: string | Resource = ''
31 private mUseLabelStr: boolean = false31 private mUseLabelStr: boolean = false
32- private mIconOnBG: string | Resource32+ private mIconOnBG: string | Resource = ''
33 private mEditMode: boolean = false33 private mEditMode: boolean = false
34 private mDragMode: boolean = false34 private mDragMode: boolean = false
35- private mClickEvent: Function35+ private mClickEvent: Function = (): void => {}
36- private mLongClickEvent: Function36+ private mLongClickEvent: Function = (): void => {}
37 @State mIconIsHover: boolean = false37 @State mIconIsHover: boolean = false
38 @State mTextIsHover: boolean = false38 @State mTextIsHover: boolean = false
39 @State style: SimpleToggleBaseStyle = StyleConfiguration.getSimpleToggleBaseStyle()39 @State style: SimpleToggleBaseStyle = StyleConfiguration.getSimpleToggleBaseStyle()
@@ -20,8 +20,8 @@ const TAG = 'iconComponent'
20 20 
21@Component21@Component
22export default struct iconComponent {22export default struct iconComponent {
23- @State iconOff: string = ""23+ @State iconOff: Resource | string = ""
24- @State iconOn: string = ""24+ @State iconOn: Resource | string = ""
25 @Prop iconOffStr: string25 @Prop iconOffStr: string
26 @Prop iconOnStr: string26 @Prop iconOnStr: string
27 private useIconStr = false27 private useIconStr = false
@@ -21,16 +21,16 @@ const TAG = 'iconTitleBase'
21 21 
22@Component22@Component
23export default struct iconBaseComponent {23export default struct iconBaseComponent {
24- private iconOn: any24+ @Prop iconOn: Resource
25- private iconOff: any25+ @Prop iconOff: Resource
26 @State iconOffStr: string = ""26 @State iconOffStr: string = ""
27 @State iconOnStr: string = ""27 @State iconOnStr: string = ""
28 @Link mTitle: Resource28 @Link mTitle: Resource
29 @State mTitleStr: string = ""29 @State mTitleStr: string = ""
30 private useIconStr = false30 private useIconStr = false
31 private useTitleStr = false31 private useTitleStr = false
32- private mClickEvent: Function32+ private mClickEvent: Function = (): void => {}
33- private mLongClickEvent: Function33+ private mLongClickEvent: Function = (): void => {}
34 @State mTextIsHover: boolean = false34 @State mTextIsHover: boolean = false
35 @Link changeSwitch: boolean35 @Link changeSwitch: boolean
36 @State style: IconTitleBaseStyle = StyleConfiguration.getIconTitleBaseStyle()36 @State style: IconTitleBaseStyle = StyleConfiguration.getIconTitleBaseStyle()
@@ -35,7 +35,13 @@
35 },35 },
36 {36 {
37 "name": "ohos.permission.GET_INSTALLED_BUNDLE_LIST",37 "name": "ohos.permission.GET_INSTALLED_BUNDLE_LIST",
38- "reason": "$string:get_installed_bundle_list_reason"38+ "reason": "$string:get_installed_bundle_list_reason",
39+ "usedScene": {
40+ "abilities": [
41+ "MainAbility"
42+ ],
43+ "when": "always"
44+ }
39 },45 },
40 {46 {
41 "name": "ohos.permission.MANAGE_LOCAL_ACCOUNTS"47 "name": "ohos.permission.MANAGE_LOCAL_ACCOUNTS"
@@ -81,7 +87,13 @@
81 },87 },
82 {88 {
83 "name": "ohos.permission.DISTRIBUTED_DATASYNC",89 "name": "ohos.permission.DISTRIBUTED_DATASYNC",
84- "reason": "$string:distributed_data_sync_reason"90+ "reason": "$string:distributed_data_sync_reason",
91+ "usedScene": {
92+ "abilities": [
93+ "MainAbility"
94+ ],
95+ "when": "always"
96+ }
85 },97 },
86 {98 {
87 "name": "ohos.permission.START_INVISIBLE_ABILITY"99 "name": "ohos.permission.START_INVISIBLE_ABILITY"
@@ -35,7 +35,13 @@
35 },35 },
36 {36 {
37 "name": "ohos.permission.GET_INSTALLED_BUNDLE_LIST",37 "name": "ohos.permission.GET_INSTALLED_BUNDLE_LIST",
38- "reason": "$string:get_installed_bundle_list_reason"38+ "reason": "$string:get_installed_bundle_list_reason",
39+ "usedScene": {
40+ "abilities": [
41+ "MainAbility"
42+ ],
43+ "when": "always"
44+ }
39 },45 },
40 {46 {
41 "name": "ohos.permission.MANAGE_LOCAL_ACCOUNTS"47 "name": "ohos.permission.MANAGE_LOCAL_ACCOUNTS"
@@ -81,7 +87,13 @@
81 },87 },
82 {88 {
83 "name": "ohos.permission.DISTRIBUTED_DATASYNC",89 "name": "ohos.permission.DISTRIBUTED_DATASYNC",
84- "reason": "$string:distributed_data_sync_reason"90+ "reason": "$string:distributed_data_sync_reason",
91+ "usedScene": {
92+ "abilities": [
93+ "MainAbility"
94+ ],
95+ "when": "always"
96+ }
85 },97 },
86 {98 {
87 "name": "ohos.permission.START_INVISIBLE_ABILITY"99 "name": "ohos.permission.START_INVISIBLE_ABILITY"
@@ -21,7 +21,7 @@ const TAG = 'airplane-ControlCenterSimpleToggleAirplaneComponent';
21 21 
22@Component22@Component
23export default struct ControlCenterSimpleToggleAirplaneComponent {23export default struct ControlCenterSimpleToggleAirplaneComponent {
24- private keyId: string;24+ private keyId: string = '';
25 private mEditMode: boolean = false;25 private mEditMode: boolean = false;
26 private mDragMode: boolean = false;26 private mDragMode: boolean = false;
27 @State mIcon: Resource = $r("app.media.airplane");27 @State mIcon: Resource = $r("app.media.airplane");
@@ -46,7 +46,7 @@ export default struct ControlCenterSimpleToggleAirplaneComponent {
46 mLabel: $mLabel,46 mLabel: $mLabel,
47 mEditMode: this.mEditMode,47 mEditMode: this.mEditMode,
48 mDragMode: this.mDragMode,48 mDragMode: this.mDragMode,
49- mClickEvent: () => this.mClickEvent()49+ mClickEvent: (): void => this.mClickEvent()
50 })50 })
51 }51 }
52 52 
@@ -23,7 +23,7 @@ const TAG = 'Control-airPlaneComponent';
23export default23export default
24struct airplaneComponent {24struct airplaneComponent {
25 25 
26- private IconInfo: any[] = [26+ private IconInfo: Resource[] = [
27 $r('app.media.airplane_d'),27 $r('app.media.airplane_d'),
28 $r('app.media.airplane'),28 $r('app.media.airplane'),
29 ];29 ];
@@ -72,7 +72,7 @@ struct airplaneComponent {
72 iconOn: this.IconInfo[1],72 iconOn: this.IconInfo[1],
73 mTitle: $flyModelTitle,73 mTitle: $flyModelTitle,
74 changeSwitch: $flyModelStatus,74 changeSwitch: $flyModelStatus,
75- mClickEvent: () => this.mClickEvent()75+ mClickEvent: (): void => this.mClickEvent()
76 })76 })
77 }.width('100%')77 }.width('100%')
78 .height('100%')78 .height('100%')
@@ -22,7 +22,7 @@ const TAG = 'autorotate-ControlCenterSimpleToggleAutoRotateComponent';
22 22 
23@Component23@Component
24export default struct ControlCenterSimpleToggleAutoRotateComponent {24export default struct ControlCenterSimpleToggleAutoRotateComponent {
25- private keyId: string;25+ private keyId: string = '';
26 private mEditMode: boolean = false;26 private mEditMode: boolean = false;
27 private mDragMode: boolean = false;27 private mDragMode: boolean = false;
28 @State mIcon: Resource = $r("app.media.ic_controlcenter_auto_rotate_off");28 @State mIcon: Resource = $r("app.media.ic_controlcenter_auto_rotate_off");
@@ -53,7 +53,7 @@ export default struct ControlCenterSimpleToggleAutoRotateComponent {
53 mLabel: $mLabel,53 mLabel: $mLabel,
54 mEditMode: this.mEditMode,54 mEditMode: this.mEditMode,
55 mDragMode: this.mDragMode,55 mDragMode: this.mDragMode,
56- mClickEvent: () => this.mClickEvent()56+ mClickEvent: (): void => this.mClickEvent()
57 })57 })
58 }58 }
59 59 
@@ -78,7 +78,7 @@ export default struct BatteryPic {
78 })78 })
79 }79 }
80 80 
81- private getBatteryColor(val, charging) {81+ private getBatteryColor(val: number, charging: boolean) {
82 Log.showInfo(TAG, `getBatteryColor, val: ${val} charging: ${charging} `);82 Log.showInfo(TAG, `getBatteryColor, val: ${val} charging: ${charging} `);
83 if (charging) {83 if (charging) {
84 return this.style.picChargingColor;84 return this.style.picChargingColor;
@@ -23,7 +23,7 @@ const TAG = 'bluetooth-ControlCenterComplexToggleBluetoothComponent';
23 23 
24@Component24@Component
25export default struct ControlCenterComplexToggleBluetoothComponent {25export default struct ControlCenterComplexToggleBluetoothComponent {
26- private IconInfo: any[] = [26+ private IconInfo: Resource[] = [
27 $r("app.media.ic_controlcenter_bt_d"),27 $r("app.media.ic_controlcenter_bt_d"),
28 $r("app.media.ic_controlcenter_bt"),28 $r("app.media.ic_controlcenter_bt"),
29 ];29 ];
@@ -46,8 +46,8 @@ export default struct ControlCenterComplexToggleBluetoothComponent {
46 iconOn: this.IconInfo[1],46 iconOn: this.IconInfo[1],
47 mTitle: $mTitle,47 mTitle: $mTitle,
48 changeSwitch: $BluetoothOpenStatus,48 changeSwitch: $BluetoothOpenStatus,
49- mClickEvent: () => this.mClickEvent(),49+ mClickEvent: (): void => this.mClickEvent(),
50- mLongClickEvent: () => this.mLongClickEvent()50+ mLongClickEvent: (): void => this.mLongClickEvent()
51 })51 })
52 }.width('100%')52 }.width('100%')
53 .height('100%')53 .height('100%')
@@ -20,7 +20,7 @@ import Log from '../../../../../../../common/src/main/ets/default/Log';
20 20 
21const TAG = 'Control-brightnessComponent';21const TAG = 'Control-brightnessComponent';
22 22 
23-class brightnessItemData {23+interface brightnessItemData {
24 min:number;24 min:number;
25 max:number;25 max:number;
26 value:number26 value:number
@@ -38,7 +38,7 @@ export default struct ComplexToggleComponent {
38 38 
39 linkItemData() {39 linkItemData() {
40 Log.showDebug(TAG, `linkItemData, keyId: ${this.keyId}`);40 Log.showDebug(TAG, `linkItemData, keyId: ${this.keyId}`);
41- this.mItemData = AppStorage.Get('ControlCenter_' + this.keyId);41+ this.mItemData = AppStorage.Get('ControlCenter_' + this.keyId) as ControlComponentData;
42 Log.showDebug(TAG, `linkItemData, mItemData: ${this.keyId} ${this.mItemData.label} ${this.mItemData.iconUrl}`);42 Log.showDebug(TAG, `linkItemData, mItemData: ${this.keyId} ${this.mItemData.label} ${this.mItemData.iconUrl}`);
43 }43 }
44 44 
@@ -55,8 +55,8 @@ export default struct ComplexToggleComponent {
55 iconOnStr: this.mItemData55 iconOnStr: this.mItemData
56 .iconUrl,56 .iconUrl,
57 changeSwitch: $mStatus,57 changeSwitch: $mStatus,
58- mClickEvent: () => this.onIconItemClick(),58+ mClickEvent: (): void => this.onIconItemClick(),
59- mLongClickEvent: () => this.onIconItemLongPressGesture()59+ mLongClickEvent: (): void => this.onIconItemLongPressGesture()
60 })60 })
61 }.width('100%')61 }.width('100%')
62 .height('100%')62 .height('100%')
@@ -28,14 +28,16 @@ const TAG = 'Control-ControlCenter';
28const TAG_ControlCenterComplexToggleLayout = 'Control-ControlCenterComplexToggleLayout';28const TAG_ControlCenterComplexToggleLayout = 'Control-ControlCenterComplexToggleLayout';
29const TAG_ControlCenterSimpleToggleLayout = 'Control-ControlCenterSimpleToggleLayout';29const TAG_ControlCenterSimpleToggleLayout = 'Control-ControlCenterSimpleToggleLayout';
30 30 
31-var mUniform;31+interface IDirection {
32+ direction: string
33+}
32 34 
33@Component35@Component
34export default struct ControlCenterComponent {36export default struct ControlCenterComponent {
35- private touchMoveCallback: Function;37+ private touchMoveCallback: Function = () => {};
36- private modeChangeCallback: Function;38+ private modeChangeCallback: Function = () => {};
37 @State mSimpleToggleColumnCount: number = Constants.DEFAULT_SIMPLE_TOGGLE_COLUMN_COUNT;39 @State mSimpleToggleColumnCount: number = Constants.DEFAULT_SIMPLE_TOGGLE_COLUMN_COUNT;
38- private mControlCenterComponentConfig: ControlCenterConfig;40+ private mControlCenterComponentConfig: ControlCenterConfig | undefined = undefined;
39 @State mIsEditSimpleToggleLayout: boolean = false;41 @State mIsEditSimpleToggleLayout: boolean = false;
40 @State style: ControlCenterComponentStyle = StyleConfiguration.getControlCenterComponentStyle();42 @State style: ControlCenterComponentStyle = StyleConfiguration.getControlCenterComponentStyle();
41 private mWidthPx: number = 0;43 private mWidthPx: number = 0;
@@ -100,12 +102,12 @@ export default struct ControlCenterComponent {
100 Column() {102 Column() {
101 Column() {103 Column() {
102 UpTitle({104 UpTitle({
103- touchMoveCallback: (data) => {105+ touchMoveCallback: (data: IDirection) => {
104 if (this.touchMoveCallback) {106 if (this.touchMoveCallback) {
105 this.touchMoveCallback(data)107 this.touchMoveCallback(data)
106 }108 }
107 },109 },
108- simpleToggleLayoutEditStartCallback: () => this.onSimpleToggleLayoutEditStart()110+ simpleToggleLayoutEditStartCallback: ():void => this.onSimpleToggleLayoutEditStart()
109 })111 })
110 }112 }
111 .width('100%')113 .width('100%')
@@ -143,7 +145,7 @@ export default struct ControlCenterComponent {
143 mDisplayingToggles: this.mDisplayingSimpleToggles,145 mDisplayingToggles: this.mDisplayingSimpleToggles,
144 mHidingToggles: this.mHidingSimpleToggles,146 mHidingToggles: this.mHidingSimpleToggles,
145 mDefaultDisplayToggles: this.mDefaultDisplaySimpleToggles,147 mDefaultDisplayToggles: this.mDefaultDisplaySimpleToggles,
146- simpleToggleLayoutEditEndCallback: () => this.onSimpleToggleLayoutEditEnd(),148+ simpleToggleLayoutEditEndCallback: (): void => this.onSimpleToggleLayoutEditEnd(),
147 onSaveDisplayingToggles: (toggles: string[]) => this.onSaveDisplayingToggles(toggles),149 onSaveDisplayingToggles: (toggles: string[]) => this.onSaveDisplayingToggles(toggles),
148 mColumnCount: this.mSimpleToggleColumnCount,150 mColumnCount: this.mSimpleToggleColumnCount,
149 titleDisplayInside: this.titleDisplayInside151 titleDisplayInside: this.titleDisplayInside
@@ -178,7 +180,7 @@ struct ControlCenterComplexToggleLayout {
178 180 
179 build() {181 build() {
180 Grid() {182 Grid() {
181- ForEach(this.mComplexToggleLayout, (componentName) => {183+ ForEach(this.mComplexToggleLayout, (componentName: string) => {
182 GridItem() {184 GridItem() {
183 ComplexToggleLoadComponent({185 ComplexToggleLoadComponent({
184 keyId: componentName186 keyId: componentName
@@ -186,17 +188,20 @@ struct ControlCenterComplexToggleLayout {
186 }188 }
187 .width('100%')189 .width('100%')
188 .height('100%')190 .height('100%')
189- }, (componentName) => componentName)191+ }, (componentName: string) => componentName)
190 }192 }
191 .width('100%')193 .width('100%')
192- .height(this.calcGridHeight(Math.ceil(this.mComplexToggleLayout.length / 2), this.style.rowHeight, this.style.rowGap))194+ .height(this.calcGridHeight(
195+ Math.ceil(this.mComplexToggleLayout.length / 2),
196+ this.style.rowHeight as number,
197+ this.style.rowGap as number))
193 .columnsTemplate('1fr 1fr')198 .columnsTemplate('1fr 1fr')
194 .rowsTemplate(this.generateRowsTemplate(Math.ceil(this.mComplexToggleLayout.length / 2)))199 .rowsTemplate(this.generateRowsTemplate(Math.ceil(this.mComplexToggleLayout.length / 2)))
195 .rowsGap(this.style.rowGap + 'px')200 .rowsGap(this.style.rowGap + 'px')
196 .columnsGap(this.style.columnGap)201 .columnsGap(this.style.columnGap)
197 }202 }
198 203 
199- calcGridHeight(rowCount, rowHeight, rowGap) {204+ calcGridHeight(rowCount: number, rowHeight: number, rowGap: number) {
200 Log.showDebug(TAG_ControlCenterComplexToggleLayout, `calcGridHeight, rowCount: ${rowCount} rowHeight: ${rowHeight} rowGap: ${rowGap}`);205 Log.showDebug(TAG_ControlCenterComplexToggleLayout, `calcGridHeight, rowCount: ${rowCount} rowHeight: ${rowHeight} rowGap: ${rowGap}`);
201 let height = rowCount * rowHeight + (rowCount - 1) * rowGap;206 let height = rowCount * rowHeight + (rowCount - 1) * rowGap;
202 if (height < 0) {207 if (height < 0) {
@@ -206,7 +211,7 @@ struct ControlCenterComplexToggleLayout {
206 return height + 'px';211 return height + 'px';
207 }212 }
208 213 
209- generateRowsTemplate(rowCount) {214+ generateRowsTemplate(rowCount: number) {
210 Log.showDebug(TAG_ControlCenterComplexToggleLayout, `generateRowsTemplate, rowCount: ${rowCount}`);215 Log.showDebug(TAG_ControlCenterComplexToggleLayout, `generateRowsTemplate, rowCount: ${rowCount}`);
211 let rowsTemplate = '1fr';216 let rowsTemplate = '1fr';
212 for (let i = 1;i < rowCount; i++) {217 for (let i = 1;i < rowCount; i++) {
@@ -232,17 +237,21 @@ struct ControlCenterSimpleToggleLayout {
232 237 
233 build() {238 build() {
234 Grid() {239 Grid() {
235- ForEach(this.mSimpleToggleLayout, (componentName) => {240+ ForEach(this.mSimpleToggleLayout, (componentName: string) => {
236 GridItem() {241 GridItem() {
237 SimpleToggleLoadComponent({242 SimpleToggleLoadComponent({
238 keyId: componentName243 keyId: componentName
239 })244 })
240 }.width('100%')245 }.width('100%')
241 .height('100%')246 .height('100%')
242- }, (componentName) => componentName)247+ }, (componentName: string) => componentName)
243 }248 }
244 .width('100%')249 .width('100%')
245- .height(this.calcGridHeight(Math.ceil(this.mSimpleToggleLayout.length / this.mColumnCount), this.style.rowHeight, this.style.rowGap))250+ .height(this.calcGridHeight(
251+ Math.ceil(
252+ this.mSimpleToggleLayout.length / this.mColumnCount),
253+ this.style.rowHeight as number,
254+ this.style.rowGap as number))
246 .margin({left: this.style.marginLeft, right: this.style.marginRight})255 .margin({left: this.style.marginLeft, right: this.style.marginRight})
247 .columnsTemplate(this.generateColumnsTemplate(this.mColumnCount))256 .columnsTemplate(this.generateColumnsTemplate(this.mColumnCount))
248 .rowsTemplate(this.generateRowsTemplate(Math.ceil(this.mSimpleToggleLayout.length / this.mColumnCount)))257 .rowsTemplate(this.generateRowsTemplate(Math.ceil(this.mSimpleToggleLayout.length / this.mColumnCount)))
@@ -250,7 +259,7 @@ struct ControlCenterSimpleToggleLayout {
250 .columnsGap(this.style.columnGap)259 .columnsGap(this.style.columnGap)
251 }260 }
252 261 
253- calcGridHeight(rowCount, rowHeight, rowGap) {262+ calcGridHeight(rowCount: number, rowHeight: number, rowGap: number) {
254 Log.showDebug(TAG_ControlCenterSimpleToggleLayout, `calcGridHeight, rowCount: ${rowCount} rowHeight: ${rowHeight} rowGap: ${rowGap}`);263 Log.showDebug(TAG_ControlCenterSimpleToggleLayout, `calcGridHeight, rowCount: ${rowCount} rowHeight: ${rowHeight} rowGap: ${rowGap}`);
255 let height = rowCount * rowHeight + (rowCount - 1) * rowGap;264 let height = rowCount * rowHeight + (rowCount - 1) * rowGap;
256 if (height < 0) {265 if (height < 0) {
@@ -260,7 +269,7 @@ struct ControlCenterSimpleToggleLayout {
260 return height + 'px';269 return height + 'px';
261 }270 }
262 271 
263- generateColumnsTemplate(columnCount) {272+ generateColumnsTemplate(columnCount: number) {
264 Log.showDebug(TAG_ControlCenterSimpleToggleLayout, `generateColumnsTemplate, columnCount: ${columnCount}`);273 Log.showDebug(TAG_ControlCenterSimpleToggleLayout, `generateColumnsTemplate, columnCount: ${columnCount}`);
265 let columnsTemplate = '1fr';274 let columnsTemplate = '1fr';
266 for (let i = 1;i < columnCount; i++) {275 for (let i = 1;i < columnCount; i++) {
@@ -269,7 +278,7 @@ struct ControlCenterSimpleToggleLayout {
269 return columnsTemplate;278 return columnsTemplate;
270 }279 }
271 280 
272- generateRowsTemplate(rowCount) {281+ generateRowsTemplate(rowCount: number) {
273 Log.showDebug(TAG_ControlCenterSimpleToggleLayout, `generateRowsTemplate, rowCount: ${rowCount}`);282 Log.showDebug(TAG_ControlCenterSimpleToggleLayout, `generateRowsTemplate, rowCount: ${rowCount}`);
274 let rowsTemplate = '1fr';283 let rowsTemplate = '1fr';
275 for (let i = 1;i < rowCount; i++) {284 for (let i = 1;i < rowCount; i++) {
@@ -23,7 +23,7 @@ const TAG = 'PluginIconItemComponent';
23 23 
24@Component24@Component
25export default struct PluginIconItemComponent {25export default struct PluginIconItemComponent {
26- private keyId: string;26+ private keyId: string = '';
27 private mEditMode: boolean = false;27 private mEditMode: boolean = false;
28 private mDragMode: boolean = false;28 private mDragMode: boolean = false;
29 @State @Watch('onPluginDataChange') mPluginData: PluginComponentData = new PluginComponentData();29 @State @Watch('onPluginDataChange') mPluginData: PluginComponentData = new PluginComponentData();
@@ -55,8 +55,8 @@ export default struct PluginIconItemComponent {
55 data: this.mPluginData.data55 data: this.mPluginData.data
56 }).onComplete(() => {56 }).onComplete(() => {
57 Log.showInfo(TAG, `PluginComponent.Complete`)57 Log.showInfo(TAG, `PluginComponent.Complete`)
58- }).onError(({errcode, msg}) => {58+ }).onError((error) => {
59- Log.showInfo(TAG, `PluginComponent.Error code:${errcode} message:${msg}`)59+ Log.showInfo(TAG, `PluginComponent.Error code:${error.errcode} message:${error.msg}`)
60 })60 })
61 .size({ width: '100%', height: '100%' })61 .size({ width: '100%', height: '100%' })
62 }62 }
@@ -24,7 +24,7 @@ const TAG = 'SimpleToggleComponent';
24 24 
25@Component25@Component
26export default struct SimpleToggleComponent {26export default struct SimpleToggleComponent {
27- private keyId: string;27+ @Prop keyId: string;
28 @State mItemData: ControlComponentData = {};28 @State mItemData: ControlComponentData = {};
29 private mEditMode: boolean = false;29 private mEditMode: boolean = false;
30 private mDragMode: boolean = false;30 private mDragMode: boolean = false;
@@ -43,7 +43,7 @@ export default struct SimpleToggleComponent {
43 43 
44 linkItemData() {44 linkItemData() {
45 Log.showDebug(TAG, `linkItemData, keyId: ${this.keyId}`);45 Log.showDebug(TAG, `linkItemData, keyId: ${this.keyId}`);
46- this.mItemData = AppStorage.Get('ControlCenter_' + this.keyId);46+ this.mItemData = AppStorage.Get('ControlCenter_' + this.keyId) as ControlComponentData;
47 Log.showDebug(TAG, `linkItemData, mItemData: ${this.keyId} ${this.mItemData.label} ${this.mItemData.iconUrl}`);47 Log.showDebug(TAG, `linkItemData, mItemData: ${this.keyId} ${this.mItemData.label} ${this.mItemData.iconUrl}`);
48 }48 }
49 49 
@@ -70,8 +70,8 @@ export default struct SimpleToggleComponent {
70 mUseLabelStr: true,70 mUseLabelStr: true,
71 mEditMode: this.mEditMode,71 mEditMode: this.mEditMode,
72 mDragMode: this.mDragMode,72 mDragMode: this.mDragMode,
73- mClickEvent: () => this.onIconItemClick(),73+ mClickEvent: (): void => this.onIconItemClick(),
74- mLongClickEvent: () => this.onIconItemLongPressGesture()74+ mLongClickEvent: (): void => this.onIconItemLongPressGesture()
75 })75 })
76 } else if (this.mItemData.pluginType == PluginType.DATA_ABILITY) {76 } else if (this.mItemData.pluginType == PluginType.DATA_ABILITY) {
77 // TODO:77 // TODO:
@@ -30,8 +30,8 @@ export default struct SimpleToggleLayoutEditComponent {
30 private mHidingToggles: string[] = [];30 private mHidingToggles: string[] = [];
31 private mDefaultDisplayToggles: string[] = [];31 private mDefaultDisplayToggles: string[] = [];
32 @Prop mColumnCount: number;32 @Prop mColumnCount: number;
33- private simpleToggleLayoutEditEndCallback: () => void;33+ private simpleToggleLayoutEditEndCallback: () => void = () => {};
34- private onSaveDisplayingToggles: (toggles: string[]) => void;34+ private onSaveDisplayingToggles: (toggles: string[]) => void = (toggles) => {};
35 @State mNewDisplayingToggles: string[] = [];35 @State mNewDisplayingToggles: string[] = [];
36 @State mNewHidingToggles: string[] = [];36 @State mNewHidingToggles: string[] = [];
37 @State style: SimpleToggleLayoutEditComponentStyle = StyleConfiguration.getSimpleToggleLayoutEditComponentStyle();37 @State style: SimpleToggleLayoutEditComponentStyle = StyleConfiguration.getSimpleToggleLayoutEditComponentStyle();
@@ -42,27 +42,27 @@ export default struct SimpleToggleLayoutEditComponent {
42 private mHidingTogglesMinCount: number = 0;42 private mHidingTogglesMinCount: number = 0;
43 @State mCurrentDragToggleName: string = '';43 @State mCurrentDragToggleName: string = '';
44 private titleDisplayInside: boolean = false;44 private titleDisplayInside: boolean = false;
45- private backDialogController: CustomDialogController = new CustomDialogController({45+ private backDialogController: CustomDialogController | null = new CustomDialogController({
46 builder: SimpleToggleLayoutEditDialogComponent({46 builder: SimpleToggleLayoutEditDialogComponent({
47 title: $r("app.string.control_center_simple_toggle_layout_edit_back_confirm"),47 title: $r("app.string.control_center_simple_toggle_layout_edit_back_confirm"),
48 leftButton: $r("app.string.control_center_simple_toggle_layout_edit_back_confirm_primary"),48 leftButton: $r("app.string.control_center_simple_toggle_layout_edit_back_confirm_primary"),
49 rightButton: $r("app.string.control_center_simple_toggle_layout_edit_back_confirm_secondary"),49 rightButton: $r("app.string.control_center_simple_toggle_layout_edit_back_confirm_secondary"),
50- leftAction: () => this.callSimpleToggleLayoutEditEnd(),50+ leftAction: (): void => this.callSimpleToggleLayoutEditEnd(),
51- rightAction: () => this.onFinishBtnClick(null),51+ rightAction: (): void => this.onFinishBtnClick(),
52 }),52 }),
53 autoCancel: false,53 autoCancel: false,
54 offset: { dx: 0, dy: 0 },54 offset: { dx: 0, dy: 0 },
55 customStyle: true,55 customStyle: true,
56 alignment: DialogAlignment.Center56 alignment: DialogAlignment.Center
57 });57 });
58- private resetDialogController: CustomDialogController = new CustomDialogController({58+ private resetDialogController: CustomDialogController | null = new CustomDialogController({
59 builder: SimpleToggleLayoutEditDialogComponent({59 builder: SimpleToggleLayoutEditDialogComponent({
60 title: $r("app.string.control_center_simple_toggle_layout_edit_reset_confirm"),60 title: $r("app.string.control_center_simple_toggle_layout_edit_reset_confirm"),
61 leftButton: $r("app.string.control_center_simple_toggle_layout_edit_reset_confirm_primary"),61 leftButton: $r("app.string.control_center_simple_toggle_layout_edit_reset_confirm_primary"),
62 rightButton: $r("app.string.control_center_simple_toggle_layout_edit_reset_confirm_secondary"),62 rightButton: $r("app.string.control_center_simple_toggle_layout_edit_reset_confirm_secondary"),
63 leftAction: () => {63 leftAction: () => {
64 },64 },
65- rightAction: () => this.editResetConfirm(),65+ rightAction: (): void => this.editResetConfirm(),
66 }),66 }),
67 autoCancel: false,67 autoCancel: false,
68 offset: { dx: 0, dy: 0 },68 offset: { dx: 0, dy: 0 },
@@ -86,11 +86,8 @@ export default struct SimpleToggleLayoutEditComponent {
86 }86 }
87 87 
88 aboutToDisappear() {88 aboutToDisappear() {
89- delete this.backDialogController89+ this.backDialogController = null
90- this.backDialogController = undefined90+ this.resetDialogController = null
91- 
92- delete this.resetDialogController
93- this.resetDialogController = undefined
94 91 
95 Log.showInfo(TAG, 'aboutToDisappear ');92 Log.showInfo(TAG, 'aboutToDisappear ');
96 }93 }
@@ -100,7 +97,7 @@ export default struct SimpleToggleLayoutEditComponent {
100 if (!this.titleDisplayInside) {97 if (!this.titleDisplayInside) {
101 Column() {98 Column() {
102 SimpleToggleLayoutEditUpTitle({99 SimpleToggleLayoutEditUpTitle({
103- simpleToggleLayoutEditEndCallback: () => this.onSimpleToggleLayoutEditEnd()100+ simpleToggleLayoutEditEndCallback: (): void => this.onSimpleToggleLayoutEditEnd()
104 })101 })
105 }102 }
106 .width('100%')103 .width('100%')
@@ -112,7 +109,7 @@ export default struct SimpleToggleLayoutEditComponent {
112 if (this.titleDisplayInside) {109 if (this.titleDisplayInside) {
113 Column() {110 Column() {
114 SimpleToggleLayoutEditUpTitle({111 SimpleToggleLayoutEditUpTitle({
115- simpleToggleLayoutEditEndCallback: () => this.onSimpleToggleLayoutEditEnd()112+ simpleToggleLayoutEditEndCallback: (): void => this.onSimpleToggleLayoutEditEnd()
116 })113 })
117 }114 }
118 .width('100%')115 .width('100%')
@@ -206,7 +203,7 @@ export default struct SimpleToggleLayoutEditComponent {
206 let changed = JSON.stringify(this.mDisplayingToggles) != JSON.stringify(this.mNewDisplayingToggles);203 let changed = JSON.stringify(this.mDisplayingToggles) != JSON.stringify(this.mNewDisplayingToggles);
207 Log.showDebug(TAG, `onSimpleToggleLayoutEditEnd, changed: ${changed}`);204 Log.showDebug(TAG, `onSimpleToggleLayoutEditEnd, changed: ${changed}`);
208 if (changed) {205 if (changed) {
209- this.backDialogController.open();206+ this.backDialogController?.open();
210 } else {207 } else {
211 this.callSimpleToggleLayoutEditEnd();208 this.callSimpleToggleLayoutEditEnd();
212 };209 };
@@ -224,7 +221,7 @@ export default struct SimpleToggleLayoutEditComponent {
224 let equalDefault = JSON.stringify(this.mDefaultDisplayToggles) == JSON.stringify(this.mNewDisplayingToggles);221 let equalDefault = JSON.stringify(this.mDefaultDisplayToggles) == JSON.stringify(this.mNewDisplayingToggles);
225 Log.showDebug(TAG, `onResetBtnClick, equalDefault: ${equalDefault}`);222 Log.showDebug(TAG, `onResetBtnClick, equalDefault: ${equalDefault}`);
226 if (!equalDefault) {223 if (!equalDefault) {
227- this.resetDialogController.open();224+ this.resetDialogController?.open();
228 };225 };
229 }226 }
230 227 
@@ -256,7 +253,7 @@ export default struct SimpleToggleLayoutEditComponent {
256 Log.showDebug(TAG, `resetData, mNewHidingToggles: ${JSON.stringify(this.mNewHidingToggles)}`);253 Log.showDebug(TAG, `resetData, mNewHidingToggles: ${JSON.stringify(this.mNewHidingToggles)}`);
257 }254 }
258 255 
259- onFinishBtnClick(event: ClickEvent) {256+ onFinishBtnClick() {
260 Log.showDebug(TAG, `onFinishBtnClick`);257 Log.showDebug(TAG, `onFinishBtnClick`);
261 let changed = JSON.stringify(this.mDisplayingToggles) != JSON.stringify(this.mNewDisplayingToggles);258 let changed = JSON.stringify(this.mDisplayingToggles) != JSON.stringify(this.mNewDisplayingToggles);
262 Log.showDebug(TAG, `onFinishBtnClick, changed: ${changed}`);259 Log.showDebug(TAG, `onFinishBtnClick, changed: ${changed}`);
@@ -281,7 +278,7 @@ export default struct SimpleToggleLayoutEditComponent {
281 278 
282 async onDisplayingGridItemDrop(status: string): Promise<void> {279 async onDisplayingGridItemDrop(status: string): Promise<void> {
283 Log.showDebug(TAG, `onDisplayingGridItemDrop, status: ${status}`);280 Log.showDebug(TAG, `onDisplayingGridItemDrop, status: ${status}`);
284- this.setOptMsg(null);281+ this.setOptMsg('');
285 }282 }
286 283 
287 async onHidingGridItemDragStart(toggleName: string): Promise<void> {284 async onHidingGridItemDragStart(toggleName: string): Promise<void> {
@@ -292,7 +289,7 @@ export default struct SimpleToggleLayoutEditComponent {
292 289 
293 async onHidingGridItemDrop(status: string): Promise<void> {290 async onHidingGridItemDrop(status: string): Promise<void> {
294 Log.showDebug(TAG, `onHidingGridItemDrop, status: ${status}`);291 Log.showDebug(TAG, `onHidingGridItemDrop, status: ${status}`);
295- this.setOptMsg(null);292+ this.setOptMsg('');
296 }293 }
297 294 
298 setOptMsg(toggleName: string): void {295 setOptMsg(toggleName: string): void {
@@ -324,7 +321,7 @@ export default struct SimpleToggleLayoutEditComponent {
324 321 
325@Component322@Component
326struct SimpleToggleLayoutEditUpTitle {323struct SimpleToggleLayoutEditUpTitle {
327- private simpleToggleLayoutEditEndCallback: Function;324+ private simpleToggleLayoutEditEndCallback: Function = () => {};
328 @State style: SimpleToggleLayoutEditUpTitleStyle = StyleConfiguration.getSimpleToggleLayoutEditUpTitleStyle();325 @State style: SimpleToggleLayoutEditUpTitleStyle = StyleConfiguration.getSimpleToggleLayoutEditUpTitleStyle();
329 326 
330 aboutToAppear() {327 aboutToAppear() {
@@ -20,12 +20,12 @@ const TAG = 'Control-SimpleToggleLayoutEditDialogComponent';
20 20 
21@CustomDialog21@CustomDialog
22export default struct SimpleToggleLayoutEditDialogComponent {22export default struct SimpleToggleLayoutEditDialogComponent {
23- private title: Resource;23+ private title: Resource | undefined = undefined;
24- private leftButton: Resource;24+ private leftButton: Resource| undefined = undefined;
25- private rightButton: Resource;25+ private rightButton: Resource| undefined = undefined;
26 private controller: CustomDialogController;26 private controller: CustomDialogController;
27- private leftAction: () => void;27+ private leftAction: () => void = () => {};
28- private rightAction: () => void;28+ private rightAction: () => void = () =>{};
29 @State style: ControlEditDialogStyle = StyleConfiguration.getControlEditDialogStyle();29 @State style: ControlEditDialogStyle = StyleConfiguration.getControlEditDialogStyle();
30 30 
31 aboutToAppear() {31 aboutToAppear() {
@@ -28,8 +28,8 @@ export default struct SimpleToggleLayoutEditGrid {
28 @Prop mGlobalDragToggleName: string;28 @Prop mGlobalDragToggleName: string;
29 private gridTag: string = '';29 private gridTag: string = '';
30 private logTag: string = '';30 private logTag: string = '';
31- private onItemDragStart: (toggleName: string) => void;31+ private onItemDragStart: (toggleName: string) => void = () => {};
32- private onItemDrop: (status: string) => void;32+ private onItemDrop: (status: string) => void = () => {};
33 @State style: SimpleToggleLayoutEditGridStyle = StyleConfiguration.getSimpleToggleLayoutEditGridStyle();33 @State style: SimpleToggleLayoutEditGridStyle = StyleConfiguration.getSimpleToggleLayoutEditGridStyle();
34 private mCurrentDragToggleName: string = '';34 private mCurrentDragToggleName: string = '';
35 35 
@@ -94,7 +94,7 @@ export default struct SimpleToggleLayoutEditGrid {
94 .onItemDrop(this.onGridItemDrop.bind(this))94 .onItemDrop(this.onGridItemDrop.bind(this))
95 }95 }
96 96 
97- calcGridHeight(rowCount, rowHeight, rowGap) {97+ calcGridHeight(rowCount: number, rowHeight: number, rowGap: number) {
98 Log.showDebug(this.logTag, `calcGridHeight, rowCount: ${rowCount} rowHeight: ${rowHeight} rowGap: ${rowGap}`);98 Log.showDebug(this.logTag, `calcGridHeight, rowCount: ${rowCount} rowHeight: ${rowHeight} rowGap: ${rowGap}`);
99 let height = rowCount * rowHeight + (rowCount - 1) * rowGap;99 let height = rowCount * rowHeight + (rowCount - 1) * rowGap;
100 if (height <= 0) {100 if (height <= 0) {
@@ -134,19 +134,19 @@ export default struct SimpleToggleLayoutEditGrid {
134 return minRowCount;134 return minRowCount;
135 }135 }
136 136 
137- onItemDragEnter(event) {137+ onItemDragEnter(event: ItemDragInfo) {
138 Log.showDebug(this.logTag, `onItemDragEnter, event: ${JSON.stringify(event)}`);138 Log.showDebug(this.logTag, `onItemDragEnter, event: ${JSON.stringify(event)}`);
139 }139 }
140 140 
141- onItemDragMove(event, itemIndex, insertIndex) {141+ onItemDragMove(event: ItemDragInfo, itemIndex: number, insertIndex: number) {
142 Log.showDebug(this.logTag, `onItemDragMove, itemIndex: ${itemIndex} insertIndex: ${insertIndex} event: ${JSON.stringify(event)}`);142 Log.showDebug(this.logTag, `onItemDragMove, itemIndex: ${itemIndex} insertIndex: ${insertIndex} event: ${JSON.stringify(event)}`);
143 }143 }
144 144 
145- onItemDragLeave(event, itemIndex) {145+ onItemDragLeave(event: ItemDragInfo, itemIndex: number) {
146 Log.showDebug(this.logTag, `onItemDragLeave, itemIndex: ${itemIndex} event: ${JSON.stringify(event)}`);146 Log.showDebug(this.logTag, `onItemDragLeave, itemIndex: ${itemIndex} event: ${JSON.stringify(event)}`);
147 }147 }
148 148 
149- onGridItemDragStart(event, itemIndex) {149+ onGridItemDragStart(event: ItemDragInfo, itemIndex: number) {
150 Log.showDebug(this.logTag, `onGridItemDragStart, itemIndex: ${itemIndex} event: ${JSON.stringify(event)}`);150 Log.showDebug(this.logTag, `onGridItemDragStart, itemIndex: ${itemIndex} event: ${JSON.stringify(event)}`);
151 this.mCurrentDragToggleName = this.mToggles[itemIndex];151 this.mCurrentDragToggleName = this.mToggles[itemIndex];
152 if (this.onItemDragStart) {152 if (this.onItemDragStart) {
@@ -155,7 +155,7 @@ export default struct SimpleToggleLayoutEditGrid {
155 Log.showDebug(this.logTag, `onGridItemDragStart, mCurrentDragToggleName: ${this.mCurrentDragToggleName}`);155 Log.showDebug(this.logTag, `onGridItemDragStart, mCurrentDragToggleName: ${this.mCurrentDragToggleName}`);
156 }156 }
157 157 
158- onGridItemDrop(event, itemIndex, insertIndex, isSuccess) {158+ onGridItemDrop(event: ItemDragInfo, itemIndex: number, insertIndex: number, isSuccess: boolean) {
159 Log.showDebug(this.logTag, `onGridItemDrop, itemIndex: ${itemIndex} insertIndex: ${insertIndex} isSuccess: ${isSuccess} event: ${JSON.stringify(event)}`);159 Log.showDebug(this.logTag, `onGridItemDrop, itemIndex: ${itemIndex} insertIndex: ${insertIndex} isSuccess: ${isSuccess} event: ${JSON.stringify(event)}`);
160 if (!isSuccess) {160 if (!isSuccess) {
161 this.callOnItemDrop('fail');161 this.callOnItemDrop('fail');
@@ -27,7 +27,7 @@ const TAG = 'SimpleToggleLoadComponent';
27 27 
28@Component28@Component
29export default struct SimpleToggleLoadComponent {29export default struct SimpleToggleLoadComponent {
30- private keyId: string30+ private keyId: string = ''
31 private mEditMode: boolean = false31 private mEditMode: boolean = false
32 private mDragMode: boolean = false32 private mDragMode: boolean = false
33 33 
@@ -21,10 +21,14 @@ import StyleConfiguration, { ControlCenterUpTitleStyle } from '../common/StyleCo
21 21 
22const TAG = 'Control-UpTitle';22const TAG = 'Control-UpTitle';
23 23 
24+interface IDirection {
25+ direction: string
26+}
27+ 
24@Component28@Component
25export default struct UpTitle {29export default struct UpTitle {
26- private touchMoveCallback: Function;30+ private touchMoveCallback: Function = (data: IDirection) => {};
27- private simpleToggleLayoutEditStartCallback: Function;31+ private simpleToggleLayoutEditStartCallback: Function = () => {};
28 startX: number = 0;32 startX: number = 0;
29 startY: number = 0;33 startY: number = 0;
30 @State moveX: number = 0;34 @State moveX: number = 0;
@@ -24,7 +24,7 @@ const TAG = 'location-ControlCenterSimpleToggleLocationComponent';
24 24 
25@Component25@Component
26export default struct ControlCenterSimpleToggleLocationComponent {26export default struct ControlCenterSimpleToggleLocationComponent {
27- private keyId: string;27+ private keyId: string = '';
28 private mEditMode: boolean = false;28 private mEditMode: boolean = false;
29 private mDragMode: boolean = false;29 private mDragMode: boolean = false;
30 @State mIcon: Resource = $r("app.media.ic_controlcenter_gps");30 @State mIcon: Resource = $r("app.media.ic_controlcenter_gps");
@@ -48,8 +48,8 @@ export default struct ControlCenterSimpleToggleLocationComponent {
48 mLabel: $mLabel,48 mLabel: $mLabel,
49 mEditMode: this.mEditMode,49 mEditMode: this.mEditMode,
50 mDragMode: this.mDragMode,50 mDragMode: this.mDragMode,
51- mClickEvent: () => this.mClickEvent(),51+ mClickEvent: (): void => this.mClickEvent(),
52- mLongClickEvent: () => this.mLongClickEvent()52+ mLongClickEvent: (): void => this.mLongClickEvent()
53 })53 })
54 }54 }
55 55 
@@ -3,5 +3,7 @@
3 "name": "@ohos/managementcomponent",3 "name": "@ohos/managementcomponent",
4 "description": "a npm package which contains managementcomponent function",4 "description": "a npm package which contains managementcomponent function",
5 "version": "1.0.0",5 "version": "1.0.0",
6- "dependencies": {}6+ "dependencies": {
7+ "@ohos/common": "file:../../common"
8+ }
7}9}
@@ -16,11 +16,10 @@ import Log from '../../../../../../../../common/src/main/ets/default/Log';
16import Notification from '@ohos.notification';16import Notification from '@ohos.notification';
17import NotificationManager from '@ohos.notificationManager';17import NotificationManager from '@ohos.notificationManager';
18import NotificationSubscribe from '@ohos.notificationSubscribe';18import NotificationSubscribe from '@ohos.notificationSubscribe';
19-import type { NotificationSubscriber } from 'notification/notificationSubscriber';
20 19 
21const TAG = 'NotificationManagenment-NotificationListener';20const TAG = 'NotificationManagenment-NotificationListener';
22 21 
23-interface IOnEnableChanged {22+export interface IOnEnableChanged {
24 (value: boolean): void;23 (value: boolean): void;
25}24}
26 25 
@@ -36,7 +35,7 @@ export interface BundleOption {
36 35 
37export class NotificationListener {36export class NotificationListener {
38 private readonly listeners = new Map<string, Set<IOnEnableChanged>>();37 private readonly listeners = new Map<string, Set<IOnEnableChanged>>();
39- private subscriber: NotificationSubscriber = {38+ private subscriber: NotificationSubscribe.NotificationSubscriber = {
40 onEnabledNotificationChanged: this.handleEnabledNotificationChanged.bind(this)39 onEnabledNotificationChanged: this.handleEnabledNotificationChanged.bind(this)
41 };40 };
42 41 
@@ -126,7 +125,7 @@ export class NotificationListener {
126 });125 });
127 }126 }
128 127 
129- async isNotificationSlotEnabled(bundleOption: BundleOption, slotType: Notification.SlotType, callback?: (data) => void): Promise<boolean> {128+ async isNotificationSlotEnabled(bundleOption: BundleOption, slotType: Notification.SlotType, callback?: (data: boolean) => void): Promise<boolean> {
130 Log.showDebug(TAG, `isNotificationSlotEnabled bundleOption:${JSON.stringify(bundleOption)} `);129 Log.showDebug(TAG, `isNotificationSlotEnabled bundleOption:${JSON.stringify(bundleOption)} `);
131 return new Promise((resolve, reject) => {130 return new Promise((resolve, reject) => {
132 NotificationManager.isNotificationSlotEnabled(bundleOption, slotType, (err, data) => {131 NotificationManager.isNotificationSlotEnabled(bundleOption, slotType, (err, data) => {
@@ -175,7 +174,7 @@ export class NotificationListener {
175 });174 });
176 }175 }
177 176 
178- enableDistributed(data: boolean): void {177+ enableDistributed(data?: boolean): void {
179 Log.showDebug(TAG, `enableDistributed data:${JSON.stringify(data)}`);178 Log.showDebug(TAG, `enableDistributed data:${JSON.stringify(data)}`);
180 let enableValue: boolean = data ? true : false;179 let enableValue: boolean = data ? true : false;
181 NotificationManager.setDistributedEnable(enableValue, (err, result) => {180 NotificationManager.setDistributedEnable(enableValue, (err, result) => {
@@ -230,7 +230,7 @@ export default struct AppItemComponent {
230 Log.showInfo(TAG, `NotificationListener.isNotificationEnabled data:${JSON.stringify(stateValue)}`);230 Log.showInfo(TAG, `NotificationListener.isNotificationEnabled data:${JSON.stringify(stateValue)}`);
231 this.canNotice = stateValue;231 this.canNotice = stateValue;
232 })232 })
233- .catch((error) => {233+ .catch((error: Error) => {
234 Log.showError(TAG, `NotificationListener.isNotificationEnabled error:${JSON.stringify(error)}`);234 Log.showError(TAG, `NotificationListener.isNotificationEnabled error:${JSON.stringify(error)}`);
235 });235 });
236 236 
@@ -16,16 +16,18 @@ import ConfigData from '../../common/constants';
16import AppItemComponent from './appItemComponent';16import AppItemComponent from './appItemComponent';
17import Router from '@system.router';17import Router from '@system.router';
18import Log from '../../../../../../../../../common/src/main/ets/default/Log';18import Log from '../../../../../../../../../common/src/main/ets/default/Log';
19-import ViewModel from '../../vm/appLstComponentViewModel'19+import ViewModel from '../../vm/appLstComponentViewModel';
20+import { BundleItemData }from '../../model/bundleResourceModel';
20 21 
21const TAG = 'ManagementComponent-AppLstComponent';22const TAG = 'ManagementComponent-AppLstComponent';
22 23 
23@Component24@Component
24export default struct AppLstComponent {25export default struct AppLstComponent {
25- @StorageLink('appManagementList') appList: any[]= [];26+ @StorageLink('appManagementList') appList: BundleItemData[]= [];
26 27 
27 aboutToAppear(): void{28 aboutToAppear(): void{
28 Log.showInfo(TAG, `aboutToAppear`);29 Log.showInfo(TAG, `aboutToAppear`);
30+ Log.showWarn(TAG, `myTest`);
29 ViewModel.viewModelInit();31 ViewModel.viewModelInit();
30 }32 }
31 33 
@@ -43,14 +45,14 @@ export default struct AppLstComponent {
43 45 
44 build() {46 build() {
45 List() {47 List() {
46- ForEach(this.appList, (item) => {48+ ForEach(this.appList, (item: BundleItemData) => {
47 ListItem() {49 ListItem() {
48 AppItemComponent({50 AppItemComponent({
49 appIcon: item.appIcon,51 appIcon: item.appIcon,
50 appTitle: item.appTitle,52 appTitle: item.appTitle,
51 appSummary: item.appSummary,53 appSummary: item.appSummary,
52 appValue: item.appValue,54 appValue: item.appValue,
53- appArrow: item.appArrow,55+ appArrow: item.appArrow as string,
54 appArrowStyle: '',56 appArrowStyle: '',
55 appUri: item.appUri,57 appUri: item.appUri,
56 appBundleName: item.appBundleName,58 appBundleName: item.appBundleName,
@@ -17,13 +17,15 @@ import Log from '../../../../../../../../../common/src/main/ets/default/Log';
17import SlotItemComponent from './slotItemComponent';17import SlotItemComponent from './slotItemComponent';
18import Notification from '@ohos.notification';18import Notification from '@ohos.notification';
19import Router from '@system.router'19import Router from '@system.router'
20+import { BundleItemData } from '@ohos/common';
21+import NotificationManager from '@ohos.notificationManager';
20 22 
21const TAG = 'ManagementComponent-SlotLstComponent';23const TAG = 'ManagementComponent-SlotLstComponent';
22 24 
23@Component25@Component
24export default struct SlotLstComponent {26export default struct SlotLstComponent {
25- private appInfo: any= null;27+ @Prop appInfo: BundleItemData;
26- @Link slotLst: any[];28+ @Link slotLst: NotificationManager.NotificationSlot[];
27 29 
28 build() {30 build() {
29 Flex({ justifyContent: FlexAlign.SpaceBetween }) {31 Flex({ justifyContent: FlexAlign.SpaceBetween }) {
@@ -42,13 +44,13 @@ export default struct SlotLstComponent {
42 .align(Alignment.Start);44 .align(Alignment.Start);
43 Row() {45 Row() {
44 List() {46 List() {
45- ForEach(this.slotLst, (item) => {47+ ForEach(this.slotLst, (item: NotificationManager.NotificationSlot) => {
46 ListItem() {48 ListItem() {
47 SlotItemComponent({ slotType: item.type })49 SlotItemComponent({ slotType: item.type })
48 }50 }
49 .onClick(() => {51 .onClick(() => {
50 Log.showInfo(TAG, `onClick`);52 Log.showInfo(TAG, `onClick`);
51- Router.push({ uri: this.appInfo.slotSettingUrl, params: {appInfo:this.appInfo,slotInfo:item} });53+ Router.push({ uri: this.appInfo.slotSettingUrl, params: {appInfo:this.appInfo, slotInfo:item} });
52 })54 })
53 });55 });
54 }.divider({56 }.divider({
@@ -14,16 +14,17 @@
14 */14 */
15import ConfigData from '../../common/constants';15import ConfigData from '../../common/constants';
16import Log from '../../../../../../../../../common/src/main/ets/default/Log';16import Log from '../../../../../../../../../common/src/main/ets/default/Log';
17+import { IOnEnableChanged } from '../../model/notificationListener';
17 18 
18const TAG = 'ManagementComponent-SwitchComponent';19const TAG = 'ManagementComponent-SwitchComponent';
19 20 
20@Component21@Component
21export default struct SwitchComponent {22export default struct SwitchComponent {
22 @Link title: Resource;23 @Link title: Resource;
23- describe: Resource;24+ @Prop describe: Resource;
24- private initializationAction: (params?) => Promise<any>25+ private initializationAction?: (params?: boolean) => Promise<boolean>
25- private settingAction: (params?) => void26+ private settingAction?: (params?: boolean) => void
26- private register?: (listener) => void27+ private register?: (listener: IOnEnableChanged) => void
27 @State initState: boolean = false28 @State initState: boolean = false
28 29 
29 build() {30 build() {
@@ -59,7 +60,7 @@ export default struct SwitchComponent {
59 .onChange((data) => {60 .onChange((data) => {
60 Log.showInfo(TAG, `Toggle onChange data:${data}`);61 Log.showInfo(TAG, `Toggle onChange data:${data}`);
61 this.initState = data ? true : false;62 this.initState = data ? true : false;
62- this.settingAction(data);63+ this.settingAction && this.settingAction(data);
63 })64 })
64 }65 }
65 .flexShrink(0)66 .flexShrink(0)
@@ -76,9 +77,11 @@ export default struct SwitchComponent {
76 77 
77 aboutToAppear(): void{78 aboutToAppear(): void{
78 Log.showInfo(TAG, `aboutToAppear`);79 Log.showInfo(TAG, `aboutToAppear`);
79- this.initializationAction().then((data) => {80+ if (this.initializationAction) {
80- Log.showInfo(TAG, `initializationAction:${data}`);81+ this.initializationAction().then((data) => {
81- this.initState = data;82+ Log.showInfo(TAG, `initializationAction:${data}`);
82- })83+ this.initState = data;
84+ })
85+ }
83 }86 }
84}87}
@@ -16,7 +16,7 @@
16import Log from '../../../../../../../../common/src/main/ets/default/Log';16import Log from '../../../../../../../../common/src/main/ets/default/Log';
17import EventManager from "../../../../../../../../common/src/main/ets/default/event/EventManager";17import EventManager from "../../../../../../../../common/src/main/ets/default/event/EventManager";
18import { obtainStartAbility } from "../../../../../../../../common/src/main/ets/default/event/EventUtil";18import { obtainStartAbility } from "../../../../../../../../common/src/main/ets/default/event/EventUtil";
19-import NfcController from '@ohos.nfc.controller';19+import { nfcController } from '@kit.ConnectivityKit';
20import ViewModel from '../viewmodel/NFCModeVM';20import ViewModel from '../viewmodel/NFCModeVM';
21import SimpleToggleBase from '../../../../../../../../common/src/main/ets/template/SimpleToggleBase';21import SimpleToggleBase from '../../../../../../../../common/src/main/ets/template/SimpleToggleBase';
22 22 
@@ -24,13 +24,13 @@ const TAG = 'nfcmode-ControlCenterSimpleToggleNFComponent';
24 24 
25@Component25@Component
26export default struct ControlCenterSimpleToggleNFComponent {26export default struct ControlCenterSimpleToggleNFComponent {
27- private keyId: string;27+ private keyId: string = '';
28 private mEditMode: boolean = false;28 private mEditMode: boolean = false;
29 private mDragMode: boolean = false;29 private mDragMode: boolean = false;
30 @State mIcon: Resource = $r("app.media.ic_notification_nfc_filled");30 @State mIcon: Resource = $r("app.media.ic_notification_nfc_filled");
31 @State mLabel: Resource = $r("app.string.control_center_complex_toggle_nfc_mode_title");31 @State mLabel: Resource = $r("app.string.control_center_complex_toggle_nfc_mode_title");
32 @State mDefaultChangeSwitch: boolean = false;32 @State mDefaultChangeSwitch: boolean = false;
33- @StorageLink('NFCModeComponentMode') @Watch('onNFCModeUpdated') NFCModeComponentMode: NfcController.NfcState = NfcController.NfcState.STATE_OFF;33+ @StorageLink('NFCModeComponentMode') @Watch('onNFCModeUpdated') NFCModeComponentMode: nfcController.NfcState = nfcController.NfcState.STATE_OFF;
34 aboutToAppear() {34 aboutToAppear() {
35 Log.showInfo(TAG, 'aboutToAppear');35 Log.showInfo(TAG, 'aboutToAppear');
36 ViewModel.initViewModel();36 ViewModel.initViewModel();
@@ -43,9 +43,9 @@ export default struct ControlCenterSimpleToggleNFComponent {
43 43 
44 onNFCModeUpdated(propName: string): void {44 onNFCModeUpdated(propName: string): void {
45 Log.showInfo(TAG, `onNFCModeUpdated, propName: ${propName} NFCModeComponentMode: ${JSON.stringify(this.NFCModeComponentMode)}`);45 Log.showInfo(TAG, `onNFCModeUpdated, propName: ${propName} NFCModeComponentMode: ${JSON.stringify(this.NFCModeComponentMode)}`);
46- if (this.NFCModeComponentMode == NfcController.NfcState.STATE_OFF) {46+ if (this.NFCModeComponentMode == nfcController.NfcState.STATE_OFF) {
47 this.mDefaultChangeSwitch = false;47 this.mDefaultChangeSwitch = false;
48- } else if (this.NFCModeComponentMode == NfcController.NfcState.STATE_ON) {48+ } else if (this.NFCModeComponentMode == nfcController.NfcState.STATE_ON) {
49 this.mDefaultChangeSwitch = true;49 this.mDefaultChangeSwitch = true;
50 }50 }
51 }51 }
@@ -58,16 +58,16 @@ export default struct ControlCenterSimpleToggleNFComponent {
58 mLabel: $mLabel,58 mLabel: $mLabel,
59 mEditMode: this.mEditMode,59 mEditMode: this.mEditMode,
60 mDragMode: this.mDragMode,60 mDragMode: this.mDragMode,
61- mClickEvent: () => this.mClickEvent()61+ mClickEvent: (): void => this.mClickEvent()
62 })62 })
63 }63 }
64 64 
65 mClickEvent() {65 mClickEvent() {
66 Log.showInfo(TAG, `mClickEvent---${this.NFCModeComponentMode}`);66 Log.showInfo(TAG, `mClickEvent---${this.NFCModeComponentMode}`);
67- if (this.NFCModeComponentMode == NfcController.NfcState.STATE_OFF) {67+ if (this.NFCModeComponentMode == nfcController.NfcState.STATE_OFF) {
68- ViewModel.setNFCMode(NfcController.NfcState.STATE_OFF)68+ ViewModel.setNFCMode(nfcController.NfcState.STATE_OFF)
69- } else if (this.NFCModeComponentMode == NfcController.NfcState.STATE_ON) {69+ } else if (this.NFCModeComponentMode == nfcController.NfcState.STATE_ON) {
70- ViewModel.setNFCMode(NfcController.NfcState.STATE_ON)70+ ViewModel.setNFCMode(nfcController.NfcState.STATE_ON)
71 }71 }
72 }72 }
73}73}
@@ -29,12 +29,11 @@ export default struct StatusBarIconItemNFCModeComponent {
29 @State mTintContentInfo: TintContentInfo = ViewModel.getTintContentInfo();29 @State mTintContentInfo: TintContentInfo = ViewModel.getTintContentInfo();
30 @State styleCommon: CommonStyle = StyleConfigurationCommon.getCommonStyle();30 @State styleCommon: CommonStyle = StyleConfigurationCommon.getCommonStyle();
31 @State style: StatusRingModeComponentStyle = StyleConfiguration.getStatusRingModeComponentStyle();31 @State style: StatusRingModeComponentStyle = StyleConfiguration.getStatusRingModeComponentStyle();
32- private ringModeIcons: any;32+ private ringModeIcons: Resource[] = [];
33 33 
34 aboutToAppear() {34 aboutToAppear() {
35 Log.showInfo(TAG, 'aboutToAppear');35 Log.showInfo(TAG, 'aboutToAppear');
36- this.ringModeIcons = {};36+ this.ringModeIcons[0] = $r("app.media.ic_statusbar_nfc");
37- this.ringModeIcons['0'] = $r("app.media.ic_statusbar_nfc");
38 ViewModel.initViewModel();37 ViewModel.initViewModel();
39 }38 }
40 39 
@@ -46,7 +45,7 @@ export default struct StatusBarIconItemNFCModeComponent {
46 Row() {45 Row() {
47 if (this.NFCModeComponentMode != NfcController.NfcState.STATE_OFF) {46 if (this.NFCModeComponentMode != NfcController.NfcState.STATE_OFF) {
48 Row().width(this.styleCommon.statusBarMarginLeftRight).height('100%')47 Row().width(this.styleCommon.statusBarMarginLeftRight).height('100%')
49- Image(this.ringModeIcons['0'])48+ Image(this.ringModeIcons[0])
50 .objectFit(ImageFit.Contain)49 .objectFit(ImageFit.Contain)
51 .width(this.style.statusBarRingModeWidth)50 .width(this.style.statusBarRingModeWidth)
52 .height(this.style.statusBarRingModeHeight)51 .height(this.style.statusBarRingModeHeight)
@@ -3,5 +3,7 @@
3 "name": "@ohos/noticeitem",3 "name": "@ohos/noticeitem",
4 "description": "a npm package which contains noticeitem function",4 "description": "a npm package which contains noticeitem function",
5 "version": "1.0.0",5 "version": "1.0.0",
6- "dependencies": {}6+ "dependencies": {
7+ "@ohos/common": "file:../../common"
8+ }
7}9}
@@ -29,6 +29,9 @@ export default class CommonUtil {
29 static startWant(want, triggerInfo?: any): void {29 static startWant(want, triggerInfo?: any): void {
30 let info = (triggerInfo) ? triggerInfo : DEFAULT_INFO;30 let info = (triggerInfo) ? triggerInfo : DEFAULT_INFO;
31 Log.showDebug(TAG, `startWant ${JSON.stringify(want)}, info ${JSON.stringify(info)}`);31 Log.showDebug(TAG, `startWant ${JSON.stringify(want)}, info ${JSON.stringify(info)}`);
32+ if (!want) {
33+ return;
34+ }
32 WantAgent.trigger(want, info, ((data) => {35 WantAgent.trigger(want, info, ((data) => {
33 Trace.end(Trace.CORE_METHOD_CLICK_NOTIFICATION);36 Trace.end(Trace.CORE_METHOD_CLICK_NOTIFICATION);
34 Log.showInfo(TAG, `wantAgent trigger data ${JSON.stringify(data)}`);37 Log.showInfo(TAG, `wantAgent trigger data ${JSON.stringify(data)}`);
@@ -12,6 +12,9 @@
12 * See the License for the specific language governing permissions and12 * See the License for the specific language governing permissions and
13 * limitations under the License.13 * limitations under the License.
14 */14 */
15+import notificationManager from '@ohos.notificationManager';
16+import image from '@ohos.multimedia.image';
17+import { WantAgent } from '@ohos.wantAgent';
15 18 
16export default class Constants {19export default class Constants {
17 static readonly NOTIFICATION_TYPE_BASIC = '0';20 static readonly NOTIFICATION_TYPE_BASIC = '0';
@@ -90,12 +93,12 @@ export interface NotificationItemData {
90 timestamp: number;93 timestamp: number;
91 time: string;94 time: string;
92 appName: string;95 appName: string;
93- want: any;96+ want: WantAgent;
94- actionButtons: any[];97+ actionButtons: notificationManager.ButtonOptions[];
95 bundleName: string;98 bundleName: string;
96- smallIcon?: PixelMap | string;99+ smallIcon?: image.PixelMap | string;
97- largeIcon?: PixelMap | string;100+ largeIcon?: image.PixelMap | string;
98- picture?: PixelMap;101+ picture?: image.PixelMap;
99 title?: string;102 title?: string;
100 text?: string;103 text?: string;
101 additionalText?: string;104 additionalText?: string;
@@ -15,7 +15,6 @@
15 15 
16import Log from '../../../../../../../../../common/src/main/ets/default/Log';16import Log from '../../../../../../../../../common/src/main/ets/default/Log';
17import deviceManager from '@ohos.distributedDeviceManager';17import deviceManager from '@ohos.distributedDeviceManager';
18-import DeviceInfo from '@ohos.deviceInfo';
19 18 
20const TAG = 'NotificationDistributionManager';19const TAG = 'NotificationDistributionManager';
21 20 
@@ -56,7 +55,7 @@ export default class NotificationDistributionManager {
56 getTrustedDeviceDeviceName(deviceId: string): string {55 getTrustedDeviceDeviceName(deviceId: string): string {
57 Log.showInfo(TAG, `getTrustedDeviceDeviceName deviceId:${deviceId}`);56 Log.showInfo(TAG, `getTrustedDeviceDeviceName deviceId:${deviceId}`);
58 let deviceName = '';57 let deviceName = '';
59- let deviceArr: any[] = this.getTrustedDeviceListSync();58+ let deviceArr: deviceManager.DeviceBasicInfo[] = this.getTrustedDeviceListSync();
60 Log.showDebug(TAG, `getTrustedDeviceDeviceName deviceArr:${JSON.stringify(deviceArr)}`);59 Log.showDebug(TAG, `getTrustedDeviceDeviceName deviceArr:${JSON.stringify(deviceArr)}`);
61 if (deviceArr.length > 0) {60 if (deviceArr.length > 0) {
62 for (let item of deviceArr) {61 for (let item of deviceArr) {
@@ -69,7 +68,7 @@ export default class NotificationDistributionManager {
69 return deviceName;68 return deviceName;
70 }69 }
71 70 
72- getTrustedDeviceListSync(): any[] {71+ getTrustedDeviceListSync(): deviceManager.DeviceBasicInfo[] {
73 Log.showInfo(TAG, 'getTrustedDeviceListSync');72 Log.showInfo(TAG, 'getTrustedDeviceListSync');
74 return this.deviceManager.getAvailableDeviceListSync();73 return this.deviceManager.getAvailableDeviceListSync();
75 }74 }
@@ -14,14 +14,14 @@
14 */14 */
15 15 
16import Log from '../../../../../../../../../common/src/main/ets/default/Log';16import Log from '../../../../../../../../../common/src/main/ets/default/Log';
17-import Constants, {NotificationLayout as Layout} from '../common/constants';17+import Constants, {NotificationLayout as Layout, NotificationItemData} from '../common/constants';
18import NotificationItem from './item/notificationItem';18import NotificationItem from './item/notificationItem';
19import GroupNotificationItem from './item/groupItem';19import GroupNotificationItem from './item/groupItem';
20import ExpandInfoManager from '../model/ExpandInfoManager';20import ExpandInfoManager from '../model/ExpandInfoManager';
21 21 
22const TAG = 'NoticeItem-NotificationListComponent';22const TAG = 'NoticeItem-NotificationListComponent';
23 23 
24-type NotificationLayoutConfig = {24+interface NotificationLayoutConfig {
25 itemMargin: number;25 itemMargin: number;
26}26}
27 27 
@@ -29,7 +29,7 @@ type NotificationLayoutConfig = {
29export default struct NotificationListComponent {29export default struct NotificationListComponent {
30 // 当长通知消息展开时,这里用于重新刷新item布局,扩展高度30 // 当长通知消息展开时,这里用于重新刷新item布局,扩展高度
31 @Provide('notificationUpdate') update: number = 0;31 @Provide('notificationUpdate') update: number = 0;
32- @StorageLink('notificationList') notificationList: any[] = [];32+ @StorageLink('notificationList') notificationList: NotificationItemData[][] = [];
33 @Link listIsEnd: boolean33 @Link listIsEnd: boolean
34 private config: NotificationLayoutConfig = {34 private config: NotificationLayoutConfig = {
35 itemMargin: Layout.ITEM_MARGIN35 itemMargin: Layout.ITEM_MARGIN
@@ -43,7 +43,7 @@ export default struct NotificationListComponent {
43 Log.showDebug(TAG, `aboutToDisAppear`);43 Log.showDebug(TAG, `aboutToDisAppear`);
44 }44 }
45 45 
46- deleteExpandInfo(itemData){46+ deleteExpandInfo(itemData: NotificationItemData){
47 ExpandInfoManager.deleteExpandInfo(itemData);47 ExpandInfoManager.deleteExpandInfo(itemData);
48 return true;48 return true;
49 }49 }
@@ -54,7 +54,7 @@ export default struct NotificationListComponent {
54 ListItem() {54 ListItem() {
55 }55 }
56 }56 }
57- ForEach(this.notificationList, (item: any) => {57+ ForEach(this.notificationList, (item: NotificationItemData[]) => {
58 ListItem() {58 ListItem() {
59 if (item.length > 1) {59 if (item.length > 1) {
60 GroupNotificationItem({ groupData: item })60 GroupNotificationItem({ groupData: item })
@@ -65,7 +65,7 @@ export default struct NotificationListComponent {
65 }65 }
66 }66 }
67 }67 }
68- }, (list: any) => JSON.stringify(list.map((item) => `${item.hashcode}_${item.timestamp}`)))68+ }, (list: NotificationItemData[]) => JSON.stringify(list.map((item) => `${item.hashcode}_${item.timestamp}`)))
69 }69 }
70 .onReachEnd(() => {70 .onReachEnd(() => {
71 this.listIsEnd = true;71 this.listIsEnd = true;
@@ -37,10 +37,10 @@ export default struct SwipeLayout {
37 bottomRightWidth: number = 0;37 bottomRightWidth: number = 0;
38 leftThreshold: number = 0;38 leftThreshold: number = 0;
39 bottomHeight: number = 92;39 bottomHeight: number = 92;
40- deleteButtonCallback: any;40+ deleteButtonCallback: () => void = () => {};
41- @BuilderParam SurfaceComponent?: () => void;41+ @BuilderParam SurfaceComponent: () => void;
42- @BuilderParam BottomLeftComponent?: () => void;42+ @BuilderParam BottomLeftComponent: () => void;
43- registerEventCapture: (id: string) => boolean = null;43+ registerEventCapture: (id: string) => boolean = (id) => true;
44 44 
45 // Page offset, opacity, width height status variable.45 // Page offset, opacity, width height status variable.
46 @State overallX: number = 0;46 @State overallX: number = 0;
@@ -209,7 +209,7 @@ export default struct SwipeLayout {
209 return;209 return;
210 }210 }
211 if(this.angelCalFlag == false){211 if(this.angelCalFlag == false){
212- var hasChange = Math.abs(touchEvent.touches[0].screenX - this.startX) > 1e-3 ||212+ let hasChange = Math.abs(touchEvent.touches[0].screenX - this.startX) > 1e-3 ||
213 Math.abs(touchEvent.touches[0].screenY - this.startY) > 1e-3213 Math.abs(touchEvent.touches[0].screenY - this.startY) > 1e-3
214 if (hasChange) {214 if (hasChange) {
215 this.responseSwipeEvent = (Math.abs(touchEvent.touches[0].screenX - this.startX) > Math.abs(touchEvent.touches[0].screenY - this.startY));215 this.responseSwipeEvent = (Math.abs(touchEvent.touches[0].screenX - this.startX) > Math.abs(touchEvent.touches[0].screenY - this.startY));
@@ -16,26 +16,28 @@
16import Log from '../../../../../../../../../../common/src/main/ets/default/Log';16import Log from '../../../../../../../../../../common/src/main/ets/default/Log';
17import CheckEmptyUtils from '../../../../../../../../../../common/src/main/ets/default/CheckEmptyUtils';17import CheckEmptyUtils from '../../../../../../../../../../common/src/main/ets/default/CheckEmptyUtils';
18import NotificationViewModel from '../../viewmodel/NotificationViewModel';18import NotificationViewModel from '../../viewmodel/NotificationViewModel';
19-import Constants, {InputActionButtonData, NotificationLayout as Layout} from '../../common/constants';19+import Constants, {InputActionButtonData, NotificationLayout as Layout, NotificationItemData} from '../../common/constants';
20+import notificationManager from '@ohos.notificationManager';
21+import type { WantAgent } from '@kit.AbilityKit';
20 22 
21const TAG = 'NoticeItem-ActionComponent';23const TAG = 'NoticeItem-ActionComponent';
22 24 
23class actionInputData {25class actionInputData {
24- inputKey?;26+ inputKey?: string;
25- wantAgent?27+ wantAgent?: WantAgent
26}28}
27 29 
28@Component30@Component
29export default struct ActionComponent {31export default struct ActionComponent {
30 @State showInputText: boolean = false;32 @State showInputText: boolean = false;
31 @State placeholder: string = '';33 @State placeholder: string = '';
32- @State inputData: actionInputData = undefined;34+ @State inputData: actionInputData | undefined = undefined;
33 @State inputActionData: InputActionButtonData = new InputActionButtonData();35 @State inputActionData: InputActionButtonData = new InputActionButtonData();
34- private itemData: any = undefined;36+ @Prop itemData: NotificationItemData;
35 37 
36 aboutToAppear() {38 aboutToAppear() {
37 Log.showInfo(TAG, `aboutToAppear Start`);39 Log.showInfo(TAG, `aboutToAppear Start`);
38- let actionData = AppStorage.Get(Constants.KEY_INPUT + this.itemData.id);40+ let actionData = AppStorage.Get(Constants.KEY_INPUT + this.itemData.id) as actionInputData;
39 this.inputActionData = (actionData instanceof InputActionButtonData) ? actionData : this.inputActionData;41 this.inputActionData = (actionData instanceof InputActionButtonData) ? actionData : this.inputActionData;
40 }42 }
41 43 
@@ -46,14 +48,14 @@ export default struct ActionComponent {
46 build() {48 build() {
47 Flex({ direction: FlexDirection.Row, justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) {49 Flex({ direction: FlexDirection.Row, justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) {
48 if (!this.inputData) {50 if (!this.inputData) {
49- ForEach(this.itemData.actionButtons, (item: any) => {51+ ForEach(this.itemData.actionButtons, (item: notificationManager.NotificationActionButton) => {
50 ActionButton({52 ActionButton({
51 content: item.title,53 content: item.title,
52 clickEvent: () => {54 clickEvent: () => {
53 if (CheckEmptyUtils.isEmpty(item.userInput)) {55 if (CheckEmptyUtils.isEmpty(item.userInput)) {
54 NotificationViewModel.clickItem(this.itemData, item.wantAgent);56 NotificationViewModel.clickItem(this.itemData, item.wantAgent);
55 } else {57 } else {
56- this.inputData = { inputKey: item.userInput.inputKey, wantAgent: item.wantAgent };58+ this.inputData = { inputKey: item.userInput?.inputKey, wantAgent: item.wantAgent };
57 }59 }
58 }60 }
59 })61 })
@@ -72,7 +74,7 @@ export default struct ActionComponent {
72 .width(Layout.INPUT_IMAGE_SIZE)74 .width(Layout.INPUT_IMAGE_SIZE)
73 .height(Layout.INPUT_IMAGE_SIZE)75 .height(Layout.INPUT_IMAGE_SIZE)
74 .onClick(() => {76 .onClick(() => {
75- NotificationViewModel.clickReply(this.inputData.inputKey, this.placeholder, this.inputData.wantAgent);77+ NotificationViewModel.clickReply(this.inputData?.inputKey, this.placeholder, this.inputData?.wantAgent);
76 this.inputActionData = {78 this.inputActionData = {
77 isSending: true,79 isSending: true,
78 content: this.placeholder80 content: this.placeholder
@@ -16,7 +16,8 @@
16import Log from '../../../../../../../../../../common/src/main/ets/default/Log';16import Log from '../../../../../../../../../../common/src/main/ets/default/Log';
17import AbilityManager from '../../../../../../../../../../common/src/main/ets/default/abilitymanager/abilityManager';17import AbilityManager from '../../../../../../../../../../common/src/main/ets/default/abilitymanager/abilityManager';
18import WindowManager, { WindowType } from '../../../../../../../../../../common/src/main/ets/default/WindowManager';18import WindowManager, { WindowType } from '../../../../../../../../../../common/src/main/ets/default/WindowManager';
19-import {notificationData} from '../../../../../../../../../../common/src/main/ets/plugindatasource/common/Constants'19+// import {notificationData} from '../../../../../../../../../../common/src/main/ets/plugindatasource/common/Constants'
20+import { NotificationItemData } from '@ohos/common'
20import Constants, {NotificationLayout as Layout} from '../../common/constants';21import Constants, {NotificationLayout as Layout} from '../../common/constants';
21import NotificationViewModel from '../../viewmodel/NotificationViewModel';22import NotificationViewModel from '../../viewmodel/NotificationViewModel';
22import CustomItem from './customItem';23import CustomItem from './customItem';
@@ -28,32 +29,47 @@ import pictureItem from './pictureItem';
28import ActionComponent from './actionComponent';29import ActionComponent from './actionComponent';
29import DevicesDialog from './devicesDialog';30import DevicesDialog from './devicesDialog';
30import WantAgent from '@ohos.wantAgent';31import WantAgent from '@ohos.wantAgent';
32+import { Rect } from '@ohos/common';
31 33 
32const TAG = 'NoticeItem-BannerNotificationItem';34const TAG = 'NoticeItem-BannerNotificationItem';
33const INTERVAL = 5 * 1000;35const INTERVAL = 5 * 1000;
34 36 
37+class EmptyObject {}
38+ 
39+interface TriggerInfo {
40+ code: number;
41+ want: Want | undefined;
42+ permission: string;
43+ extraInfo: EmptyObject;
44+}
45+ 
35 46 
36@Component47@Component
37export default struct BannerNotificationItem {48export default struct BannerNotificationItem {
38- @State want : notificationData = new notificationData();49+ @State want : NotificationItemData | undefined = undefined;
39 @Link distributedDeviceName: string;50 @Link distributedDeviceName: string;
40 @Link mBannerNoticeCnt: number;51 @Link mBannerNoticeCnt: number;
41 @Link mLastActionTime: number;52 @Link mLastActionTime: number;
42 @Link needExpand: boolean;53 @Link needExpand: boolean;
43 @Link isExpand: boolean;54 @Link isExpand: boolean;
44 @State mCloseEnableFlg: boolean = false;55 @State mCloseEnableFlg: boolean = false;
45- private nowWant: any;56+ private nowWant: Want | undefined = undefined;
46- private onBannerNoticeHide: () => void57+ private onBannerNoticeHide: () => void = () => {};
47- private devicesDialogController: CustomDialogController = new CustomDialogController({58+ private devicesDialogController: CustomDialogController | null = new CustomDialogController({
48 builder: DevicesDialog({59 builder: DevicesDialog({
49- action: (deviceID) => this.selectedDevice(deviceID)60+ action: (deviceID): void => this.selectedDevice(deviceID)
50 }),61 }),
51 autoCancel: false,62 autoCancel: false,
52 offset: { dx: 0, dy: 200 }63 offset: { dx: 0, dy: 200 }
53 });64 });
54 65 
55 mInterval: number = INTERVAL;66 mInterval: number = INTERVAL;
56- mDefaultBannerRect: any;67+ mDefaultBannerRect: Rect = {
68+ left: 0,
69+ top: 0,
70+ width: 0,
71+ height: 0
72+ };
57 expandPaddingBottom: number = Layout.EXPAND_PADDING_BOTTOM;73 expandPaddingBottom: number = Layout.EXPAND_PADDING_BOTTOM;
58 74 
59 aboutToAppear() {75 aboutToAppear() {
@@ -68,29 +84,28 @@ export default struct BannerNotificationItem {
68 }84 }
69 85 
70 aboutToDisappear() {86 aboutToDisappear() {
71- delete this.devicesDialogController87+ this.devicesDialogController = null;
72- this.devicesDialogController = undefined
73 Log.showInfo(TAG, `aboutToDisAppear`);88 Log.showInfo(TAG, `aboutToDisAppear`);
74 }89 }
75 90 
76 build() {91 build() {
77 Column() {92 Column() {
78 if (this.mBannerNoticeCnt > 0) {93 if (this.mBannerNoticeCnt > 0) {
79- if (this.want.template) {94+ if (this.want?.template) {
80 CustomItem({ customItemData: this.want, isSubItem: false })95 CustomItem({ customItemData: this.want, isSubItem: false })
81 } else {96 } else {
82 Row() {97 Row() {
83 Flex({ alignItems: ItemAlign.Center, justifyContent: FlexAlign.Start }) {98 Flex({ alignItems: ItemAlign.Center, justifyContent: FlexAlign.Start }) {
84 Row() {99 Row() {
85 titleItem({100 titleItem({
86- notificationSmallIcon: this.want.smallIcon,101+ notificationSmallIcon: this.want?.smallIcon as PixelMap,
87- notificationName: this.want.appName,102+ notificationName: this.want?.appName,
88- notificationTime: this.want.time,103+ notificationTime: this.want?.time,
89 isExpand: $isExpand,104 isExpand: $isExpand,
90 needExpand: this.needExpand,105 needExpand: this.needExpand,
91 distributedDeviceName: this.distributedDeviceName,106 distributedDeviceName: this.distributedDeviceName,
92 isSubItem: false,107 isSubItem: false,
93- clickTitleAction: () => this.refreshLastActionTime()108+ clickTitleAction: (): void => this.refreshLastActionTime()
94 })109 })
95 }110 }
96 111 
@@ -113,7 +128,7 @@ export default struct BannerNotificationItem {
113 isExpand: this.isExpand,128 isExpand: this.isExpand,
114 itemData: this.want129 itemData: this.want
115 });130 });
116- if (this.isExpand && this.want.actionButtons.length) {131+ if (this.isExpand && this.want?.actionButtons.length) {
117 ActionComponent({ itemData: this.want })132 ActionComponent({ itemData: this.want })
118 } else {133 } else {
119 Blank()134 Blank()
@@ -128,15 +143,15 @@ export default struct BannerNotificationItem {
128 Log.showInfo(TAG, `onAreaChange, e: ${JSON.stringify(e)} e2: ${JSON.stringify(e2)}`);143 Log.showInfo(TAG, `onAreaChange, e: ${JSON.stringify(e)} e2: ${JSON.stringify(e2)}`);
129 let heightEx = parseInt(String(e['height']));144 let heightEx = parseInt(String(e['height']));
130 let heightCur = parseInt(String(e2['height']));145 let heightCur = parseInt(String(e2['height']));
131- let heightWin = parseInt(this.mDefaultBannerRect['height']);146+ let heightWin = this.mDefaultBannerRect?.height;
132 if (this.isExpand) {147 if (this.isExpand) {
133- heightWin = heightWin + (heightCur - heightEx) + this.expandPaddingBottom;148+ heightWin = heightWin as number + (heightCur - heightEx) + this.expandPaddingBottom;
134 }149 }
135- let bannerRect = {150+ let bannerRect: Rect = {
136- top: this.mDefaultBannerRect['top'],151+ top: this.mDefaultBannerRect.top,
137- left: this.mDefaultBannerRect['left'],152+ left: this.mDefaultBannerRect.left,
138- width: this.mDefaultBannerRect['width'],153+ width: this.mDefaultBannerRect.width,
139- height: heightWin154+ height: heightWin as number
140 };155 };
141 WindowManager.resetSizeWindow(WindowType.BANNER_NOTICE, bannerRect);156 WindowManager.resetSizeWindow(WindowType.BANNER_NOTICE, bannerRect);
142 WindowManager.showWindow(WindowType.BANNER_NOTICE);157 WindowManager.showWindow(WindowType.BANNER_NOTICE);
@@ -198,7 +213,7 @@ export default struct BannerNotificationItem {
198 WantAgent.getWant(wantAgent).then((wantData) => {213 WantAgent.getWant(wantAgent).then((wantData) => {
199 this.nowWant = wantData214 this.nowWant = wantData
200 if (!wantData?.deviceId) {215 if (!wantData?.deviceId) {
201- this.devicesDialogController.open();216+ this.devicesDialogController?.open();
202 } else{217 } else{
203 NotificationViewModel.clickItem(this.want);218 NotificationViewModel.clickItem(this.want);
204 }219 }
@@ -207,10 +222,12 @@ export default struct BannerNotificationItem {
207 }222 }
208 }223 }
209 224 
210- selectedDevice(deviceID) {225+ selectedDevice(deviceID: string) {
211 Log.showInfo(TAG, `selectedDevice deviceID:${deviceID}`);226 Log.showInfo(TAG, `selectedDevice deviceID:${deviceID}`);
212- this.nowWant.deviceId = deviceID;227+ if (this.nowWant) {
213- let triggerInfo = {228+ this.nowWant.deviceId = deviceID;
229+ }
230+ let triggerInfo: TriggerInfo = {
214 code: 0,231 code: 0,
215 want: this.nowWant,232 want: this.nowWant,
216 permission: '',233 permission: '',
@@ -231,7 +248,7 @@ export default struct BannerNotificationItem {
231@Component248@Component
232struct ContentComponent {249struct ContentComponent {
233 @Prop isExpand: boolean;250 @Prop isExpand: boolean;
234- itemData: any;251+ @Prop itemData: NotificationItemData;
235 252 
236 aboutToAppear() {253 aboutToAppear() {
237 Log.showInfo(TAG, `aboutToAppear NotificationItemData: ${JSON.stringify(this.itemData)}`);254 Log.showInfo(TAG, `aboutToAppear NotificationItemData: ${JSON.stringify(this.itemData)}`);
@@ -16,7 +16,7 @@
16import Constants, {NotificationItemData, NotificationLayout as Layout} from '../../common/constants';16import Constants, {NotificationItemData, NotificationLayout as Layout} from '../../common/constants';
17@Component17@Component
18export default struct BasicItem {18export default struct BasicItem {
19- @State itemData: NotificationItemData = undefined19+ @Prop itemData: NotificationItemData
20 20 
21 build() {21 build() {
22 Column() {22 Column() {
@@ -26,10 +26,10 @@ const TAG = 'NoticeItem-Confirm';
26 */26 */
27@CustomDialog27@CustomDialog
28export default struct ConfirmDialog {28export default struct ConfirmDialog {
29- private title: string | Resource29+ private title: string | Resource = ''
30- private bundleName: string30+ private bundleName: string = ''
31 public controller: CustomDialogController31 public controller: CustomDialogController
32- public action: () => void32+ public action: () => void = () => {}
33 33 
34 build() {34 build() {
35 Column() {35 Column() {
@@ -18,22 +18,24 @@ import Log from '../../../../../../../../../../common/src/main/ets/default/Log';
18import NotificationViewModel from '../../viewmodel/NotificationViewModel';18import NotificationViewModel from '../../viewmodel/NotificationViewModel';
19import NotificationManager from '../../model/NotificationManager';19import NotificationManager from '../../model/NotificationManager';
20import {NotificationLayout as Layout} from '../../common/constants';20import {NotificationLayout as Layout} from '../../common/constants';
21+import { NotificationItemData } from '@ohos/common'
22+import NtfMgr from '@ohos.notificationManager';
21 23 
22const TAG = 'NoticeItem-CustomItem';24const TAG = 'NoticeItem-CustomItem';
23 25 
24@Component26@Component
25export default struct CustomItem {27export default struct CustomItem {
26- private customItemData: any = {};28+ private customItemData: NotificationItemData | undefined = undefined;
27- private template: any = {};29+ private template: PluginComponentTemplate | undefined = undefined;
28- private templateData: any = {};30+ private templateData: Record<string, Object> = {};
29 private isSubItem: boolean= false;31 private isSubItem: boolean= false;
30 private isDebugMode: boolean = false;32 private isDebugMode: boolean = false;
31- private clickAction: () => void33+ private clickAction: () => void = () => {}
32 34 
33 aboutToAppear() {35 aboutToAppear() {
34 Log.showInfo(TAG, `aboutToAppear Start`);36 Log.showInfo(TAG, `aboutToAppear Start`);
35- this.template = NotificationViewModel.getPluginTempLate(this.customItemData.template.name);37+ this.template = NotificationViewModel.getPluginTempLate(this.customItemData?.template?.name);
36- this.templateData = this.customItemData.template.data;38+ this.templateData = this.customItemData?.template?.data as Record<string, Object>;
37 this.isDebugMode = NotificationManager.isDebugMode(TAG);39 this.isDebugMode = NotificationManager.isDebugMode(TAG);
38 Log.showInfo(TAG, `template = ${JSON.stringify(this.template)} templateData = ${JSON.stringify(this.templateData)} isDebugMode = ${this.isDebugMode}`);40 Log.showInfo(TAG, `template = ${JSON.stringify(this.template)} templateData = ${JSON.stringify(this.templateData)} isDebugMode = ${this.isDebugMode}`);
39 }41 }
@@ -46,8 +48,8 @@ export default struct CustomItem {
46 data: this.templateData48 data: this.templateData
47 }).onComplete(() => {49 }).onComplete(() => {
48 Log.showInfo(TAG, `Complete`);50 Log.showInfo(TAG, `Complete`);
49- }).onError(({errcode, msg}) => {51+ }).onError((error) => {
50- Log.showInfo(TAG, `Error code:${errcode} message:${msg}`);52+ Log.showInfo(TAG, `Error code:${error.errcode} message:${error.msg}`);
51 })53 })
52 .size({ width: '100%', height: 110 })54 .size({ width: '100%', height: 110 })
53 }55 }
@@ -16,6 +16,7 @@
16import Constants from '../../common/constants';16import Constants from '../../common/constants';
17import Log from '../../../../../../../../../../common/src/main/ets/default/Log';17import Log from '../../../../../../../../../../common/src/main/ets/default/Log';
18import DistributionManager from '../../model/NotificationDistributionManager';18import DistributionManager from '../../model/NotificationDistributionManager';
19+import deviceManager from '@ohos.distributedDeviceManager'
19 20 
20const TAG = 'NoticeItem-DevicesDialog';21const TAG = 'NoticeItem-DevicesDialog';
21 22 
@@ -25,9 +26,9 @@ const TAG = 'NoticeItem-DevicesDialog';
25 */26 */
26@CustomDialog27@CustomDialog
27export default struct DevicesDialog {28export default struct DevicesDialog {
28- private deviceInfoList: Array<any>;29+ private deviceInfoList: Array<deviceManager.DeviceBasicInfo> = [];
29 public controller: CustomDialogController30 public controller: CustomDialogController
30- public action: (deviceID) => void31+ public action: (deviceID: string) => void = (deviceID) => {}
31 32 
32 build() {33 build() {
33 Column({ space: 30 }) {34 Column({ space: 30 }) {
@@ -40,7 +41,7 @@ export default struct DevicesDialog {
40 41 
41 Column() {42 Column() {
42 List() {43 List() {
43- ForEach(this.deviceInfoList, (item) => {44+ ForEach(this.deviceInfoList, (item: deviceManager.DeviceBasicInfo) => {
44 ListItem() {45 ListItem() {
45 Row() {46 Row() {
46 Column() {47 Column() {
@@ -13,7 +13,7 @@
13 * limitations under the License.13 * limitations under the License.
14 */14 */
15 15 
16-import Constants, { NotificationLayout as Layout } from '../../common/constants';16+import Constants, { NotificationItemData, NotificationLayout as Layout } from '../../common/constants';
17import basicItem from './basicItem';17import basicItem from './basicItem';
18import longItem from './longItem';18import longItem from './longItem';
19import multiItem from './multiItem';19import multiItem from './multiItem';
@@ -33,8 +33,8 @@ export default struct GeneralItem {
33 @State @Watch('expandChange') isExpand: boolean = false33 @State @Watch('expandChange') isExpand: boolean = false
34 @State needExpand: boolean = true34 @State needExpand: boolean = true
35 @State distributedDeviceName: string = ''35 @State distributedDeviceName: string = ''
36- private itemData: any = {}36+ @Prop itemData: NotificationItemData
37- private clickAction: () => void37+ private clickAction: () => void = () => {}
38 private isSubItem: boolean= false;38 private isSubItem: boolean= false;
39 39 
40 expandChange() {40 expandChange() {
@@ -70,7 +70,7 @@ export default struct GeneralItem {
70 build() {70 build() {
71 Column() {71 Column() {
72 titleItem({72 titleItem({
73- notificationSmallIcon: this.itemData.smallIcon,73+ notificationSmallIcon: this.itemData.smallIcon as PixelMap,
74 notificationName: this.itemData.appName,74 notificationName: this.itemData.appName,
75 notificationTime: this.itemData.time,75 notificationTime: this.itemData.time,
76 isExpand: $isExpand,76 isExpand: $isExpand,
@@ -98,7 +98,7 @@ export default struct GeneralItem {
98@Component98@Component
99struct ContentComponent {99struct ContentComponent {
100 @Prop isExpand: boolean;100 @Prop isExpand: boolean;
101- itemData: any;101+ @Prop itemData: NotificationItemData;
102 102 
103 aboutToAppear() {103 aboutToAppear() {
104 Log.showInfo(TAG, `aboutToAppear pict: ${this.itemData.picture}`);104 Log.showInfo(TAG, `aboutToAppear pict: ${this.itemData.picture}`);
@@ -14,7 +14,7 @@
14 */14 */
15 15 
16import Log from '../../../../../../../../../../common/src/main/ets/default/Log';16import Log from '../../../../../../../../../../common/src/main/ets/default/Log';
17-import Constants, { NotificationLayout as Layout } from '../../common/constants';17+import Constants, { NotificationItemData, NotificationLayout as Layout } from '../../common/constants';
18import NotificationItem from './notificationItem'18import NotificationItem from './notificationItem'
19import NotificationViewModel from '../../viewmodel/NotificationViewModel';19import NotificationViewModel from '../../viewmodel/NotificationViewModel';
20import SwipeLayout from './SwipeLayout';20import SwipeLayout from './SwipeLayout';
@@ -32,7 +32,7 @@ export default struct GroupItem {
32 @Consume('notificationUpdate') updateFlag: number;32 @Consume('notificationUpdate') updateFlag: number;
33 @State distributedDeviceName: string = '';33 @State distributedDeviceName: string = '';
34 @State @Watch('expandChange') toExpand: boolean = false;34 @State @Watch('expandChange') toExpand: boolean = false;
35- private groupData: any[] = [];35+ private groupData: NotificationItemData[] = [];
36 36 
37 registerGroupItemEventCapture(id: string){37 registerGroupItemEventCapture(id: string){
38 if(FocusCallBack.getLastFocusId() == getId(this.groupData[0], true)){38 if(FocusCallBack.getLastFocusId() == getId(this.groupData[0], true)){
@@ -59,7 +59,7 @@ export default struct GroupItem {
59 Log.showInfo(TAG, `aboutToDisAppear`);59 Log.showInfo(TAG, `aboutToDisAppear`);
60 }60 }
61 61 
62- deleteButtonCallback(){62+ deleteButtonCallback(): void {
63 ExpandInfoManager.deleteExpandInfo(this.groupData[0]);63 ExpandInfoManager.deleteExpandInfo(this.groupData[0]);
64 NotificationViewModel.removeGroupNotification(this.groupData[0], true);64 NotificationViewModel.removeGroupNotification(this.groupData[0], true);
65 }65 }
@@ -155,10 +155,10 @@ export default struct GroupItem {
155 155 
156@Component156@Component
157struct ContentList {157struct ContentList {
158- @State @Watch('remainderChange') groupData: any[] = [];158+ @State @Watch('remainderChange') groupData: NotificationItemData[] = [];
159 @Prop toExpand: boolean;159 @Prop toExpand: boolean;
160 @State remainderNum: number= 0;160 @State remainderNum: number= 0;
161- registerEventCapture: (id: string) => boolean = null;161+ registerEventCapture: (id: string) => boolean = (id) => true;
162 162 
163 registerContentListEventCapture(id: string){163 registerContentListEventCapture(id: string){
164 if(this.registerEventCapture != null && this.registerEventCapture(id)){164 if(this.registerEventCapture != null && this.registerEventCapture(id)){
@@ -232,11 +232,11 @@ struct ContentList {
232 232 
233 } else {233 } else {
234 List() {234 List() {
235- ForEach(this.groupData, (item: any) => {235+ ForEach(this.groupData, (item: NotificationItemData) => {
236 ListItem() {236 ListItem() {
237 NotificationItem({ itemData: item, isSubItem: true, registerEventCapture: this.registerContentListEventCapture.bind(this) })237 NotificationItem({ itemData: item, isSubItem: true, registerEventCapture: this.registerContentListEventCapture.bind(this) })
238 }238 }
239- }, (item: any) => `${item.hashcode}_${item.timestamp}_subitem`)239+ }, (item: NotificationItemData) => `${item.hashcode}_${item.timestamp}_subitem`)
240 }240 }
241 .divider({241 .divider({
242 strokeWidth: 1,242 strokeWidth: 1,
@@ -13,7 +13,7 @@
13 * limitations under the License.13 * limitations under the License.
14 */14 */
15 15 
16-import Constants, { NotificationLayout as Layout } from '../../common/constants';16+import Constants, { NotificationItemData, NotificationLayout as Layout } from '../../common/constants';
17import Log from '../../../../../../../../../../common/src/main/ets/default/Log';17import Log from '../../../../../../../../../../common/src/main/ets/default/Log';
18import SettingDialog from './settingDialog';18import SettingDialog from './settingDialog';
19import ConfirmDialog from './confirmDialog'19import ConfirmDialog from './confirmDialog'
@@ -24,12 +24,12 @@ const deviceTypeInfo = deviceInfo.deviceType;
24const TAG = 'NoticeItem-IconListComponent';24const TAG = 'NoticeItem-IconListComponent';
25let iconSize: number = 0;25let iconSize: number = 0;
26 26 
27-type IconData = {27+interface IconData {
28 src?: Resource;28 src?: Resource;
29 callback?: () => void29 callback?: () => void
30}30}
31 31 
32-export type NotificationUiConfig = {32+export interface NotificationUiConfig {
33 iconSize: number;33 iconSize: number;
34}34}
35 35 
@@ -40,23 +40,23 @@ export function getIconListSize(list?: IconData[]) {
40 40 
41@Component41@Component
42export default struct IconListComponent {42export default struct IconListComponent {
43- private itemData: any = {}43+ private itemData: NotificationItemData | undefined = undefined
44 private isGroup: boolean= false;44 private isGroup: boolean= false;
45 @Prop iconAlpha: number45 @Prop iconAlpha: number
46- private settingDialogController: CustomDialogController = new CustomDialogController({46+ private settingDialogController: CustomDialogController | null = new CustomDialogController({
47 builder: SettingDialog({47 builder: SettingDialog({
48 itemData: this.itemData,48 itemData: this.itemData,
49- action: () => this.confirmDialogController.open()49+ action: (): void => this.confirmDialogController?.open()
50 }),50 }),
51 autoCancel: false,51 autoCancel: false,
52 alignment: deviceTypeInfo === 'phone' ? DialogAlignment.Bottom : DialogAlignment.Default,52 alignment: deviceTypeInfo === 'phone' ? DialogAlignment.Bottom : DialogAlignment.Default,
53 offset: { dx: 0, dy: $r('app.float.setting_dialog_dy') },53 offset: { dx: 0, dy: $r('app.float.setting_dialog_dy') },
54 customStyle: true54 customStyle: true
55 });55 });
56- private confirmDialogController: CustomDialogController = new CustomDialogController({56+ private confirmDialogController: CustomDialogController | null = new CustomDialogController({
57 builder: ConfirmDialog({57 builder: ConfirmDialog({
58 title: $r('app.string.closeNovice'),58 title: $r('app.string.closeNovice'),
59- bundleName: this.itemData.name,59+ bundleName: this.itemData?.appName,
60 action: () => NotificationViewModel.enableNotification(this.itemData, false)60 action: () => NotificationViewModel.enableNotification(this.itemData, false)
61 }),61 }),
62 autoCancel: false,62 autoCancel: false,
@@ -69,7 +69,7 @@ export default struct IconListComponent {
69 src: $r("app.media.ic_public_settings_filled"),69 src: $r("app.media.ic_public_settings_filled"),
70 callback: () => {70 callback: () => {
71 Log.showInfo(TAG, `click settings hashcode: ${this.itemData?.hashcode}`);71 Log.showInfo(TAG, `click settings hashcode: ${this.itemData?.hashcode}`);
72- this.settingDialogController.open()72+ this.settingDialogController?.open()
73 }73 }
74 }, {74 }, {
75 src: $r("app.media.ic_public_delete_filled"),75 src: $r("app.media.ic_public_delete_filled"),
@@ -91,18 +91,14 @@ export default struct IconListComponent {
91 }91 }
92 92 
93 aboutToDisappear() {93 aboutToDisappear() {
94- delete this.settingDialogController94+ this.settingDialogController = null
95- this.settingDialogController = undefined95+ this.confirmDialogController = null
96- 
97- delete this.confirmDialogController
98- this.confirmDialogController = undefined
99- 
100 Log.showInfo(TAG, 'aboutToDisappear')96 Log.showInfo(TAG, 'aboutToDisappear')
101 }97 }
102 98 
103 build() {99 build() {
104 Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.End, justifyContent: FlexAlign.End }) {100 Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.End, justifyContent: FlexAlign.End }) {
105- ForEach(this.iconConfigs, (item) => {101+ ForEach(this.iconConfigs, (item: IconData) => {
106 Button({ type: ButtonType.Circle, stateEffect: true }) {102 Button({ type: ButtonType.Circle, stateEffect: true }) {
107 if (item.src) {103 if (item.src) {
108 Image(item.src)104 Image(item.src)
@@ -126,13 +122,13 @@ export default struct IconListComponent {
126 122 
127@Component123@Component
128export struct BottomLeftItem {124export struct BottomLeftItem {
129- private itemData: any = {};125+ private itemData: NotificationItemData | undefined = undefined;
130 private bottomLeftItemHeight: number = 92;126 private bottomLeftItemHeight: number = 92;
131 127 
132- private settingDialogController: CustomDialogController = new CustomDialogController({128+ private settingDialogController: CustomDialogController | null = new CustomDialogController({
133 builder: SettingDialog({129 builder: SettingDialog({
134 itemData: this.itemData,130 itemData: this.itemData,
135- action: () => this.confirmDialogController.open()131+ action: (): void => this.confirmDialogController?.open()
136 }),132 }),
137 autoCancel: false,133 autoCancel: false,
138 alignment: deviceTypeInfo === 'phone' ? DialogAlignment.Bottom : DialogAlignment.Default,134 alignment: deviceTypeInfo === 'phone' ? DialogAlignment.Bottom : DialogAlignment.Default,
@@ -140,10 +136,10 @@ export struct BottomLeftItem {
140 customStyle: true136 customStyle: true
141 });137 });
142 138 
143- private confirmDialogController: CustomDialogController = new CustomDialogController({139+ private confirmDialogController: CustomDialogController | null = new CustomDialogController({
144 builder: ConfirmDialog({140 builder: ConfirmDialog({
145 title: $r('app.string.closeNovice'),141 title: $r('app.string.closeNovice'),
146- bundleName: this.itemData.name,142+ bundleName: this.itemData?.appName,
147 action: () => NotificationViewModel.enableNotification(this.itemData, false)143 action: () => NotificationViewModel.enableNotification(this.itemData, false)
148 }),144 }),
149 autoCancel: false,145 autoCancel: false,
@@ -153,12 +149,8 @@ export struct BottomLeftItem {
153 });149 });
154 150 
155 aboutToDisappear() {151 aboutToDisappear() {
156- delete this.settingDialogController152+ this.settingDialogController = null
157- this.settingDialogController = undefined153+ this.confirmDialogController = null
158- 
159- delete this.confirmDialogController
160- this.confirmDialogController = undefined
161- 
162 Log.showInfo(TAG, 'BottomLeftItem -> aboutToDisappear')154 Log.showInfo(TAG, 'BottomLeftItem -> aboutToDisappear')
163 }155 }
164 156 
@@ -172,7 +164,7 @@ export struct BottomLeftItem {
172 .height(Layout.ICON_SIZE)164 .height(Layout.ICON_SIZE)
173 }165 }
174 .backgroundColor($r("app.color.button_background"))166 .backgroundColor($r("app.color.button_background"))
175- .onClick(() => this.settingDialogController.open())167+ .onClick(() => this.settingDialogController?.open())
176 .width(Layout.BUTTON_SIZE)168 .width(Layout.BUTTON_SIZE)
177 .height(Layout.BUTTON_SIZE)169 .height(Layout.BUTTON_SIZE)
178 }170 }
@@ -18,7 +18,7 @@ import Constants, {NotificationItemData, NotificationLayout as Layout} from '../
18@Component18@Component
19export default19export default
20struct LongItem {20struct LongItem {
21- @State itemData: NotificationItemData= undefined21+ @Prop itemData: NotificationItemData
22 @Prop isExpand: boolean22 @Prop isExpand: boolean
23 23 
24 build() {24 build() {
@@ -17,7 +17,7 @@ import Constants, {NotificationItemData, NotificationLayout as Layout} from '../
17 17 
18@Component18@Component
19export default struct MultiItem {19export default struct MultiItem {
20- @State itemData: NotificationItemData= undefined20+ @Prop itemData: NotificationItemData
21 @Prop isExpand: boolean21 @Prop isExpand: boolean
22 22 
23 build() {23 build() {
@@ -24,17 +24,27 @@ import {BottomLeftItem} from './iconListComponent';
24import deviceInfo from '@ohos.deviceInfo';24import deviceInfo from '@ohos.deviceInfo';
25import SwipeLayout from './SwipeLayout';25import SwipeLayout from './SwipeLayout';
26import {getId} from '../../model/SwipeLayoutUtils';26import {getId} from '../../model/SwipeLayoutUtils';
27+import { NotificationItemData } from '../../common/constants'
27 28 
28const TAG = 'NoticeItem-NotificationItem';29const TAG = 'NoticeItem-NotificationItem';
29const deviceTypeInfo = deviceInfo.deviceType;30const deviceTypeInfo = deviceInfo.deviceType;
30 31 
32+class EmptyObject {}
33+ 
34+interface TriggerInfo {
35+ code: number;
36+ want: Want | undefined;
37+ permission: string;
38+ extraInfo: EmptyObject;
39+}
40+ 
31@Component41@Component
32export default struct NotificationItem {42export default struct NotificationItem {
33 @State mIconAlpha: number = 0;43 @State mIconAlpha: number = 0;
34 @State itemWidth: string = '100%';44 @State itemWidth: string = '100%';
35- private itemData: any = {};45+ @Prop itemData: NotificationItemData;
36 private isSubItem: boolean= false;46 private isSubItem: boolean= false;
37- registerEventCapture: (id: string) => boolean = null;47+ registerEventCapture: (id: string) => boolean = (id) => true;
38 48 
39 registerNotificationItemEventCapture(id: string){49 registerNotificationItemEventCapture(id: string){
40 if(this.registerEventCapture != null && this.registerEventCapture(id)){50 if(this.registerEventCapture != null && this.registerEventCapture(id)){
@@ -83,29 +93,28 @@ export default struct NotificationItem {
83 93 
84@Component94@Component
85struct FrontItem {95struct FrontItem {
86- private itemData: any = {}96+ @Prop itemData: NotificationItemData
87- private nowWant: any;97+ private nowWant: Want | undefined = undefined;
88 private isSubItem: boolean= false;98 private isSubItem: boolean= false;
89- private devicesDialogController: CustomDialogController = new CustomDialogController({99+ private devicesDialogController: CustomDialogController | null = new CustomDialogController({
90 builder: DevicesDialog({100 builder: DevicesDialog({
91- action: (deviceID) => this.selectedDevice(deviceID)101+ action: (deviceID): void => this.selectedDevice(deviceID)
92 }),102 }),
93 autoCancel: false,103 autoCancel: false,
94 offset: { dx: 0, dy: 200 }104 offset: { dx: 0, dy: 200 }
95 });105 });
96 106 
97 aboutToDisappear() {107 aboutToDisappear() {
98- delete this.devicesDialogController108+ this.devicesDialogController = null
99- this.devicesDialogController = undefined
100 Log.showInfo(TAG, 'FrontItem -> aboutToDisappear')109 Log.showInfo(TAG, 'FrontItem -> aboutToDisappear')
101 }110 }
102 111 
103 build() {112 build() {
104 Column() {113 Column() {
105 if (this.itemData.template?.name) {114 if (this.itemData.template?.name) {
106- CustomItem({ customItemData: this.itemData, clickAction: () => this.showDevicesDialog(), isSubItem: this.isSubItem })115+ CustomItem({ customItemData: this.itemData, clickAction: (): void => this.showDevicesDialog(), isSubItem: this.isSubItem })
107 } else {116 } else {
108- GeneralItem({ itemData: this.itemData, clickAction: () => this.showDevicesDialog(), isSubItem: this.isSubItem })117+ GeneralItem({ itemData: this.itemData, clickAction: (): void => this.showDevicesDialog(), isSubItem: this.isSubItem })
109 }118 }
110 }119 }
111 .width('100%')120 .width('100%')
@@ -125,7 +134,7 @@ struct FrontItem {
125 this.nowWant = want;134 this.nowWant = want;
126 Log.showInfo(TAG, `showDevicesDialog want: ${JSON.stringify(this.nowWant)}`);135 Log.showInfo(TAG, `showDevicesDialog want: ${JSON.stringify(this.nowWant)}`);
127 if (!want?.deviceId) {136 if (!want?.deviceId) {
128- this.devicesDialogController.open();137+ this.devicesDialogController?.open();
129 } else {138 } else {
130 NotificationViewModel.clickItem(this.itemData);139 NotificationViewModel.clickItem(this.itemData);
131 }140 }
@@ -135,10 +144,12 @@ struct FrontItem {
135 }144 }
136 }145 }
137 146 
138- selectedDevice(deviceID) {147+ selectedDevice(deviceID: string): void {
139 Log.showInfo(TAG, `selectedDevice deviceID:${deviceID}`);148 Log.showInfo(TAG, `selectedDevice deviceID:${deviceID}`);
140- this.nowWant.deviceId = deviceID;149+ if(this.nowWant) {
141- let triggerInfo = {150+ this.nowWant.deviceId = deviceID;
151+ }
152+ let triggerInfo: TriggerInfo = {
142 code: 0,153 code: 0,
143 want: this.nowWant,154 want: this.nowWant,
144 permission: '',155 permission: '',
@@ -18,7 +18,7 @@ import CheckEmptyUtils from '../../../../../../../../../../common/src/main/ets/d
18 18 
19@Component19@Component
20export default struct PictureItem {20export default struct PictureItem {
21- @State itemData: NotificationItemData= undefined21+ @Prop itemData: NotificationItemData
22 @Prop isExpand: boolean22 @Prop isExpand: boolean
23 23 
24 build() {24 build() {
@@ -30,9 +30,9 @@ const TAG = 'NoticeItem-Setting';
30 */30 */
31@CustomDialog31@CustomDialog
32export default struct SettingDialog {32export default struct SettingDialog {
33- private itemData: NotificationItemData33+ @Prop itemData: NotificationItemData
34 public controller: CustomDialogController34 public controller: CustomDialogController
35- public action: () => void35+ public action: () => void = () => {}
36 36 
37 build() {37 build() {
38 Column() {38 Column() {
@@ -20,7 +20,7 @@ const TAG = 'NoticeItem-TitleItem';
20 20 
21@Component21@Component
22export default struct TitleItem {22export default struct TitleItem {
23- private notificationSmallIcon: PixelMap23+ private notificationSmallIcon?: PixelMap
24 @State notificationName: string = ''24 @State notificationName: string = ''
25 @State notificationTime: string = ''25 @State notificationTime: string = ''
26 @Link isExpand: boolean26 @Link isExpand: boolean
@@ -28,7 +28,7 @@ export default struct TitleItem {
28 @State rowSpace: Resource = $r('app.float.titleitem_row_space')28 @State rowSpace: Resource = $r('app.float.titleitem_row_space')
29 @Prop distributedDeviceName: string29 @Prop distributedDeviceName: string
30 private isSubItem: boolean= false;30 private isSubItem: boolean= false;
31- private clickTitleAction: () => void31+ private clickTitleAction?: () => void
32 32 
33 aboutToAppear() {33 aboutToAppear() {
34 Log.showDebug(TAG, `aboutToAppear Start`);34 Log.showDebug(TAG, `aboutToAppear Start`);
@@ -135,12 +135,12 @@ export class NotificationViewModel {
135 AppStorage.SetOrCreate('notificationList', notificationList);135 AppStorage.SetOrCreate('notificationList', notificationList);
136 }136 }
137 137 
138- groupByGroupName(): any[]{138+ groupByGroupName(): NotificationItemData[][]{
139 if (!this.mNotificationList || this.mNotificationList.length < 1) {139 if (!this.mNotificationList || this.mNotificationList.length < 1) {
140 Log.showWarn(TAG, 'groupByGroupName, list is empty.');140 Log.showWarn(TAG, 'groupByGroupName, list is empty.');
141 return [];141 return [];
142 }142 }
143- let groupArr: any[] = [];143+ let groupArr: NotificationItemData[][] = [];
144 let groups = {};144 let groups = {};
145 this.mNotificationList.forEach((item) => {145 this.mNotificationList.forEach((item) => {
146 const groupName = `${item.bundleName}_${item.groupName}`;146 const groupName = `${item.bundleName}_${item.groupName}`;
@@ -25,7 +25,7 @@ const TAG = 'ringmode-ControlCenterSimpleToggleRingModeComponent'
25 25 
26@Component26@Component
27export default struct ControlCenterSimpleToggleRingModeComponent {27export default struct ControlCenterSimpleToggleRingModeComponent {
28- private keyId: string28+ private keyId: string = ''
29 private mEditMode: boolean = false29 private mEditMode: boolean = false
30 private mDragMode: boolean = false30 private mDragMode: boolean = false
31 @State mIcon: Resource = $r("app.media.ic_controlcenter_ring_on_filled")31 @State mIcon: Resource = $r("app.media.ic_controlcenter_ring_on_filled")
@@ -67,8 +67,8 @@ export default struct ControlCenterSimpleToggleRingModeComponent {
67 mIconOnBG: this.style.onBgColor,67 mIconOnBG: this.style.onBgColor,
68 mEditMode: this.mEditMode,68 mEditMode: this.mEditMode,
69 mDragMode: this.mDragMode,69 mDragMode: this.mDragMode,
70- mClickEvent: () => this.mClickEvent(),70+ mClickEvent: (): void => this.mClickEvent(),
71- mLongClickEvent: () => this.mLongClickEvent()71+ mLongClickEvent: (): void => this.mLongClickEvent()
72 })72 })
73 }73 }
74 74 
@@ -29,13 +29,13 @@ export default struct StatusBarIconItemRingModeComponent {
29 @State mTintContentInfo: TintContentInfo = ViewModel.getTintContentInfo()29 @State mTintContentInfo: TintContentInfo = ViewModel.getTintContentInfo()
30 @State styleCommon: CommonStyle = StyleConfigurationCommon.getCommonStyle()30 @State styleCommon: CommonStyle = StyleConfigurationCommon.getCommonStyle()
31 @State style: StatusRingModeComponentStyle = StyleConfiguration.getStatusRingModeComponentStyle()31 @State style: StatusRingModeComponentStyle = StyleConfiguration.getStatusRingModeComponentStyle()
32- private ringModeIcons: any32+ private ringModeIcons: Resource[] = []
33 33 
34 aboutToAppear() {34 aboutToAppear() {
35 Log.showInfo(TAG, 'aboutToAppear');35 Log.showInfo(TAG, 'aboutToAppear');
36- this.ringModeIcons = {};36+ this.ringModeIcons = [];
37- this.ringModeIcons[AudioRingMode.RINGER_MODE_SILENT.toString()] = $r("app.media.ic_statusbar_ring_off_filled");37+ this.ringModeIcons[AudioRingMode.RINGER_MODE_SILENT] = $r("app.media.ic_statusbar_ring_off_filled");
38- this.ringModeIcons[AudioRingMode.RINGER_MODE_VIBRATE.toString()] = $r("app.media.ic_statusbar_vibration_on");38+ this.ringModeIcons[AudioRingMode.RINGER_MODE_VIBRATE] = $r("app.media.ic_statusbar_vibration_on");
39 ViewModel.initViewModel();39 ViewModel.initViewModel();
40 }40 }
41 41 
@@ -47,7 +47,7 @@ export default struct StatusBarIconItemRingModeComponent {
47 Row() {47 Row() {
48 if (this.RingModeComponentMode != AudioRingMode.RINGER_MODE_NORMAL) {48 if (this.RingModeComponentMode != AudioRingMode.RINGER_MODE_NORMAL) {
49 Row().width(this.styleCommon.statusBarMarginLeftRight).height('100%')49 Row().width(this.styleCommon.statusBarMarginLeftRight).height('100%')
50- Image(this.ringModeIcons[this.RingModeComponentMode.toString()])50+ Image(this.ringModeIcons[this.RingModeComponentMode])
51 .objectFit(ImageFit.Contain)51 .objectFit(ImageFit.Contain)
52 .width(this.style.statusBarRingModeWidth)52 .width(this.style.statusBarRingModeWidth)
53 .height(this.style.statusBarRingModeHeight)53 .height(this.style.statusBarRingModeHeight)
@@ -91,8 +91,8 @@ export default struct SignalIcon {
91 * @param {number} type - number of cellular type91 * @param {number} type - number of cellular type
92 * @return {string} typeString type of cellular type92 * @return {string} typeString type of cellular type
93 */93 */
94- private updateCellularType(signalType): string {94+ private updateCellularType(signalType: number): Resource {
95- let typeString;95+ let typeString: Resource;
96 switch (signalType) {96 switch (signalType) {
97 case Constants.RADIO_TECHNOLOGY_UNKNOWN:97 case Constants.RADIO_TECHNOLOGY_UNKNOWN:
98 typeString = $r('app.string.signal_null');98 typeString = $r('app.string.signal_null');
@@ -130,8 +130,8 @@ export default struct SignalIcon {
130 * @param {number} level - signal level from signalModel130 * @param {number} level - signal level from signalModel
131 * @return {string} cellularImage image of cellular signal131 * @return {string} cellularImage image of cellular signal
132 */132 */
133- private updateCellularImage(level) {133+ private updateCellularImage(level: number) {
134- let cellularImage;134+ let cellularImage: Resource;
135 switch (level) {135 switch (level) {
136 case Constants.CELLULAR_SIGNAL_NO:136 case Constants.CELLULAR_SIGNAL_NO:
137 cellularImage = $r('app.media.ic_statusbar_signal_no');137 cellularImage = $r('app.media.ic_statusbar_signal_no');
@@ -165,8 +165,8 @@ export default struct SignalIcon {
165 * @param {string} netWorkState - network state from signal model165 * @param {string} netWorkState - network state from signal model
166 * @return {string} vendor's name or signal state166 * @return {string} vendor's name or signal state
167 */167 */
168- private updateNetworkState(netWorkState) {168+ private updateNetworkState(netWorkState: string) {
169- let networkStateName;169+ let networkStateName: string | Resource;
170 if (netWorkState == Constants.NET_NULL) {170 if (netWorkState == Constants.NET_NULL) {
171 networkStateName = $r('app.string.net_null');171 networkStateName = $r('app.string.net_null');
172 } else {172 } else {
@@ -120,16 +120,20 @@ export class SignalModel {
120 */120 */
121 initObserver() {121 initObserver() {
122 Log.showInfo(TAG, 'initObserver');122 Log.showInfo(TAG, 'initObserver');
123- isInitObserver = true;123+ try {
124- Observer.on('signalInfoChange', (signalInfoChange) => {124+ isInitObserver = true;
125- this.checkCellularStatus();125+ Observer.on('signalInfoChange', (signalInfoChange) => {
126- });126+ this.checkCellularStatus();
127- Observer.on('networkStateChange', (networkState) => {127+ });
128- this.checkCellularStatus();128+ Observer.on('networkStateChange', (networkState) => {
129- });129+ this.checkCellularStatus();
130- Observer.on('simStateChange', (simStateInfo) => {130+ });
131- this.checkCellularStatus();131+ Observer.on('simStateChange', (simStateInfo) => {
132- });132+ this.checkCellularStatus();
133+ });
134+ } catch (err) {
135+ Log.showError(TAG, `init observer failed message: ${JSON.stringify(err)}`);
136+ }
133 }137 }
134 138 
135 /**139 /**
@@ -3,5 +3,7 @@
3 "name": "@ohos/statusbarcomponent",3 "name": "@ohos/statusbarcomponent",
4 "description": "a npm package which contains statusbarcomponent function",4 "description": "a npm package which contains statusbarcomponent function",
5 "version": "1.0.0",5 "version": "1.0.0",
6- "dependencies": {}6+ "dependencies": {
7+ "@ohos/common": "file:../../common"
8+ }
7}9}
@@ -16,7 +16,7 @@
16import Log from '../../../../../../../../common/src/main/ets/default/Log'16import Log from '../../../../../../../../common/src/main/ets/default/Log'
17import EventManager, { unsubscribe } from '../../../../../../../../common/src/main/ets/default/event/EventManager'17import EventManager, { unsubscribe } from '../../../../../../../../common/src/main/ets/default/event/EventManager'
18import CheckEmptyUtils from '../../../../../../../../common/src/main/ets/default/CheckEmptyUtils'18import CheckEmptyUtils from '../../../../../../../../common/src/main/ets/default/CheckEmptyUtils'
19-import { WINDOW_SHOW_HIDE_EVENT } from '../../../../../../../../common/src/main/ets/default/WindowManager'19+import { WINDOW_SHOW_HIDE_EVENT, ArgsInfo } from '../../../../../../../../common/src/main/ets/default/WindowManager'
20import { PluginType,itemData } from "../../../../../../../../common/src/main/ets/plugindatasource/common/Constants"20import { PluginType,itemData } from "../../../../../../../../common/src/main/ets/plugindatasource/common/Constants"
21import ViewModel from '../viewmodel/StatusBarVM'21import ViewModel from '../viewmodel/StatusBarVM'
22import StyleConfigurationCommon, { CommonStyle22import StyleConfigurationCommon, { CommonStyle
@@ -24,16 +24,17 @@ import StyleConfigurationCommon, { CommonStyle
24import StyleConfiguration, { IconItemComponentStyle } from '../common/StyleConfiguration'24import StyleConfiguration, { IconItemComponentStyle } from '../common/StyleConfiguration'
25import MetaIconItemComponent from './MetaIconItemComponent'25import MetaIconItemComponent from './MetaIconItemComponent'
26import PluginIconItemComponent from './PluginIconItemComponent'26import PluginIconItemComponent from './PluginIconItemComponent'
27+import { Event } from '@ohos/common'
27 28 
28const TAG = 'IconItemComponent'29const TAG = 'IconItemComponent'
29 30 
30-class itemStatusData{31+interface itemStatusData{
31 selected: boolean32 selected: boolean
32}33}
33 34 
34@Component35@Component
35export default struct IconItemComponent {36export default struct IconItemComponent {
36- private keyId: string37+ @Prop keyId: string
37 @State mItemData: itemData = new itemData()38 @State mItemData: itemData = new itemData()
38 @State mItemStatus: itemStatusData = {39 @State mItemStatus: itemStatusData = {
39 selected: false40 selected: false
@@ -47,7 +48,9 @@ export default struct IconItemComponent {
47 Log.showInfo(TAG, `aboutToAppear Start, keyId: ${this.keyId} `);48 Log.showInfo(TAG, `aboutToAppear Start, keyId: ${this.keyId} `);
48 this.linkItemData()49 this.linkItemData()
49 if (this.mItemData?.relationWindowId) {50 if (this.mItemData?.relationWindowId) {
50- this.mClearCallback = EventManager.subscribe(WINDOW_SHOW_HIDE_EVENT, (args) => this.onWindowChange(args))51+ this.mClearCallback = EventManager.subscribe(
52+ WINDOW_SHOW_HIDE_EVENT,
53+ (args: ArgsInfo) => this.onWindowChange(args));
51 }54 }
52 }55 }
53 56 
@@ -58,14 +61,14 @@ export default struct IconItemComponent {
58 }61 }
59 62 
60 linkItemData() {63 linkItemData() {
61- this.mItemData = AppStorage.Get('StatusBar_' + this.keyId)64+ this.mItemData = AppStorage.Get('StatusBar_' + this.keyId) as itemData
62 Log.showInfo(TAG, `linkItemData, mItemData: ${this.keyId} ${this.mItemData.label} ${65 Log.showInfo(TAG, `linkItemData, mItemData: ${this.keyId} ${this.mItemData.label} ${
63 this.mItemData66 this.mItemData
64 .iconUrl}`)67 .iconUrl}`)
65 68 
66 const statusBarStatusKey = 'StatusBar_Status_' + this.keyId69 const statusBarStatusKey = 'StatusBar_Status_' + this.keyId
67 AppStorage.SetOrCreate(statusBarStatusKey, { selected: false })70 AppStorage.SetOrCreate(statusBarStatusKey, { selected: false })
68- this.mItemStatus = AppStorage.Get(statusBarStatusKey)71+ this.mItemStatus = AppStorage.Get(statusBarStatusKey) as itemStatusData
69 }72 }
70 73 
71 build() {74 build() {
@@ -102,9 +105,9 @@ export default struct IconItemComponent {
102 }.height('100%')105 }.height('100%')
103 }106 }
104 107 
105- onWindowChange(args) {108+ onWindowChange(args: ArgsInfo) {
106 if (this.mItemData.canSelect && args?.windowName == this.mItemData.relationWindowId) {109 if (this.mItemData.canSelect && args?.windowName == this.mItemData.relationWindowId) {
107- this.mItemStatus.selected = args?.isShow110+ this.mItemStatus.selected = args?.isShow as boolean
108 }111 }
109 }112 }
110 113 
@@ -133,7 +136,7 @@ export default struct IconItemComponent {
133 136 
134 onIconItemLongPressGesture(event: GestureEvent) {137 onIconItemLongPressGesture(event: GestureEvent) {
135 Log.showInfo(TAG, `onIconItemLongPressGesture, event: ${JSON.stringify(event)}`);138 Log.showInfo(TAG, `onIconItemLongPressGesture, event: ${JSON.stringify(event)}`);
136- let longClickEvent = this.mItemData.actionData.longClickAction;139+ let longClickEvent = this.mItemData.actionData?.longClickAction as Event;
137 longClickEvent && EventManager.publish(longClickEvent);140 longClickEvent && EventManager.publish(longClickEvent);
138 }141 }
139 142 
@@ -26,7 +26,7 @@ const TAG = 'MetaIconItemComponent'
26 26 
27@Component27@Component
28export default struct MetaIconItemComponent {28export default struct MetaIconItemComponent {
29- private keyId: string29+ @Prop keyId: string
30 @State mItemData: itemData = new itemData()30 @State mItemData: itemData = new itemData()
31 @State mTintContentInfo: TintContentInfo = new TintContentInfo()31 @State mTintContentInfo: TintContentInfo = new TintContentInfo()
32 @State style: IconItemComponentStyle = StyleConfiguration.getIconItemComponentStyle()32 @State style: IconItemComponentStyle = StyleConfiguration.getIconItemComponentStyle()
@@ -43,7 +43,7 @@ export default struct MetaIconItemComponent {
43 }43 }
44 44 
45 linkItemData() {45 linkItemData() {
46- this.mItemData = AppStorage.Get('StatusBar_' + this.keyId);46+ this.mItemData = AppStorage.Get('StatusBar_' + this.keyId) as itemData;
47 Log.showInfo(TAG, `linkItemData, mItemData: ${this.keyId} ${this.mItemData.label} ${47 Log.showInfo(TAG, `linkItemData, mItemData: ${this.keyId} ${this.mItemData.label} ${
48 this.mItemData48 this.mItemData
49 .iconUrl}`)49 .iconUrl}`)
@@ -25,7 +25,7 @@ const TAG = 'PluginIconItemComponent'
25 25 
26@Component26@Component
27export default struct PluginIconItemComponent {27export default struct PluginIconItemComponent {
28- private keyId: string28+ @Prop keyId: string
29 @State @Watch('onPluginDataChange') mPluginData: PluginComponentData = new PluginComponentData()29 @State @Watch('onPluginDataChange') mPluginData: PluginComponentData = new PluginComponentData()
30 @State @Watch('onTintContentChange') mTintContentInfo: TintContentInfo = new TintContentInfo()30 @State @Watch('onTintContentChange') mTintContentInfo: TintContentInfo = new TintContentInfo()
31 @State style: PluginIconItemComponentStyle = StyleConfiguration.getPluginIconItemComponentStyle()31 @State style: PluginIconItemComponentStyle = StyleConfiguration.getPluginIconItemComponentStyle()
@@ -78,8 +78,8 @@ export default struct PluginIconItemComponent {
78 data: this.mPluginData.data78 data: this.mPluginData.data
79 }).onComplete(() => {79 }).onComplete(() => {
80 Log.showInfo(TAG, `PluginComponent.Complete`)80 Log.showInfo(TAG, `PluginComponent.Complete`)
81- }).onError(({errcode, msg}) => {81+ }).onError((error) => {
82- Log.showInfo(TAG, `PluginComponent.Error code:${errcode} message:${msg}`)82+ Log.showInfo(TAG, `PluginComponent.Error code:${error.errcode} message:${error.msg}`)
83 })83 })
84 .size({ width: px2vp(this.style.iconWidth), height: '100%' })84 .size({ width: px2vp(this.style.iconWidth), height: '100%' })
85 Row().width(this.styleCommon.statusBarMarginLeftRight).height('100%')85 Row().width(this.styleCommon.statusBarMarginLeftRight).height('100%')
@@ -35,6 +35,7 @@ import CapsuleIcon from '../../../../../../../capsulecomponent/src/main/ets/defa
35import LocationIcon from '../../../../../../../locationcomponent/src/main/ets/com/ohos/pages/StatusBarIconItemLocationComponent'35import LocationIcon from '../../../../../../../locationcomponent/src/main/ets/com/ohos/pages/StatusBarIconItemLocationComponent'
36import RingModeIcon from '../../../../../../../ringmodecomponent/src/main/ets/com/ohos/pages/StatusBarIconItemRingModeComponent'36import RingModeIcon from '../../../../../../../ringmodecomponent/src/main/ets/com/ohos/pages/StatusBarIconItemRingModeComponent'
37import NfcIcon from '../../../../../../../nfccomponent/src/main/ets/com/ohos/pages/StatusBarIconItemNFComponent'37import NfcIcon from '../../../../../../../nfccomponent/src/main/ets/com/ohos/pages/StatusBarIconItemNFComponent'
38+import { NotificationItemData } from '@ohos/common';
38 39 
39const TAG = 'StatusBarComponent'40const TAG = 'StatusBarComponent'
40const TAG_StatusBarGroup = 'StatusBarGroup'41const TAG_StatusBarGroup = 'StatusBarGroup'
@@ -44,9 +45,14 @@ const TAG_StatusBarEmptyIcon = 'StatusBarEmptyIcon'
44const TAG_StatusBarNotificationIcon = 'StatusBarNotificationIcon'45const TAG_StatusBarNotificationIcon = 'StatusBarNotificationIcon'
45const TAG_StatusBarBackground = 'StatusBarBackground'46const TAG_StatusBarBackground = 'StatusBarBackground'
46 47 
48+interface Item {
49+ index: number;
50+ data: NotificationItemData[];
51+}
52+ 
47@Component53@Component
48export default struct StatusBarComponent {54export default struct StatusBarComponent {
49- private mStatusBarComponentConfig: StatusBarConfig55+ private mStatusBarComponentConfig: StatusBarConfig | undefined = undefined
50 @State mStatusBarData: StatusBarData = ViewModel.getStatusBarData()56 @State mStatusBarData: StatusBarData = ViewModel.getStatusBarData()
51 private moduleName: string = ''57 private moduleName: string = ''
52 58 
@@ -166,7 +172,7 @@ struct StatusBarBackground {
166struct StatusBarGroup {172struct StatusBarGroup {
167 @StorageLink('StatusBarLayout') mStatusBarLayout: string[][] = [[], [], []]173 @StorageLink('StatusBarLayout') mStatusBarLayout: string[][] = [[], [], []]
168 private mLayoutWeight: number = 1174 private mLayoutWeight: number = 1
169- private mAlignItems: any = HorizontalAlign.Center;175+ private mAlignItems: number = HorizontalAlign.Center;
170 private index: number = -1;176 private index: number = -1;
171 @State mStatusBarData: StatusBarData = ViewModel.getStatusBarData()177 @State mStatusBarData: StatusBarData = ViewModel.getStatusBarData()
172 178 
@@ -212,7 +218,7 @@ struct StatusBarGroup {
212 218 
213@Component219@Component
214struct VerticalStatusBarItemLoadComponent {220struct VerticalStatusBarItemLoadComponent {
215- private mComponentName: string221+ private mComponentName: string = ''
216 @State mComponentHeight: number = 0222 @State mComponentHeight: number = 0
217 @State style: VerticalStatusBarItemLoadComponentStyle = StyleConfiguration.getVerticalStatusBarItemLoadComponentStyle()223 @State style: VerticalStatusBarItemLoadComponentStyle = StyleConfiguration.getVerticalStatusBarItemLoadComponentStyle()
218 224 
@@ -241,7 +247,7 @@ struct VerticalStatusBarItemLoadComponent {
241 247 
242@Component248@Component
243struct StatusBarItemLoadComponent {249struct StatusBarItemLoadComponent {
244- private mComponentName: string250+ private mComponentName: string = ''
245 aboutToAppear() {251 aboutToAppear() {
246 Log.showInfo(TAG_StatusBarItemLoadComponent, `aboutToAppear, mComponentName: ${this.mComponentName} `)252 Log.showInfo(TAG_StatusBarItemLoadComponent, `aboutToAppear, mComponentName: ${this.mComponentName} `)
247 }253 }
@@ -311,7 +317,7 @@ struct StatusBarEmptyIcon {
311 317 
312@Component318@Component
313struct StatusBarNotificationIcon {319struct StatusBarNotificationIcon {
314- @StorageLink('notificationList') notificationList: Array<any> = []320+ @StorageLink('notificationList') notificationList: NotificationItemData[][] = []
315 @StorageLink('StatusCoefficient') StatusCoefficient: number = 1.0321 @StorageLink('StatusCoefficient') StatusCoefficient: number = 1.0
316 @State mTintContentInfo: TintContentInfo = ViewModel.getNotificationTintContentInfo()322 @State mTintContentInfo: TintContentInfo = ViewModel.getNotificationTintContentInfo()
317 @State styleCommon: CommonStyle = StyleConfigurationCommon.getCommonStyle()323 @State styleCommon: CommonStyle = StyleConfigurationCommon.getCommonStyle()
@@ -331,7 +337,7 @@ struct StatusBarNotificationIcon {
331 Row().height(1).width(this.styleCommon.statusBarMarginLeftRight)337 Row().height(1).width(this.styleCommon.statusBarMarginLeftRight)
332 }338 }
333 if (this.notificationList.length > 3) {339 if (this.notificationList.length > 3) {
334- ForEach(this.notificationList.slice(0, 3), (item: any) => {340+ ForEach(this.notificationList.slice(0, 3), (item: NotificationItemData[]) => {
335 Image(item[0].smallIcon)341 Image(item[0].smallIcon)
336 .objectFit(ImageFit.ScaleDown)342 .objectFit(ImageFit.ScaleDown)
337 .height(this.style.iconHeight)343 .height(this.style.iconHeight)
@@ -346,12 +352,13 @@ struct StatusBarNotificationIcon {
346 }352 }
347 } else {353 } else {
348 ForEach(this.notificationList.map((item, index1) => {354 ForEach(this.notificationList.map((item, index1) => {
349- return { i: index1, data: item }355+ let res: Item = { index: index1, data: item }
350- }), (item) => {356+ return res
351- if (item.i > 0) {357+ }), (res: Item) => {
358+ if (res.index > 0) {
352 Row().height(1).width(this.style.iconSpace)359 Row().height(1).width(this.style.iconSpace)
353 }360 }
354- Image(item.data[0].smallIcon)361+ Image(res.data[0].smallIcon)
355 .objectFit(ImageFit.ScaleDown)362 .objectFit(ImageFit.ScaleDown)
356 .height(this.style.iconHeight)363 .height(this.style.iconHeight)
357 .width(this.style.iconWidth)364 .width(this.style.iconWidth)
@@ -51,6 +51,10 @@
51 {51 {
52 "name": "status_bar_padding_end",52 "name": "status_bar_padding_end",
53 "value": "0vp"53 "value": "0vp"
54+ },
55+ {
56+ "name": "status_bar_margin_left_right",
57+ "value": "3vp"
54 }58 }
55 ]59 ]
56}60}
@@ -97,9 +97,9 @@ export default struct VolumePanelComponent {
97 .backgroundColor(this.style.volumePanelBackground)97 .backgroundColor(this.style.volumePanelBackground)
98 }98 }
99 99 
100- getVolumeIcon(isMute, volume, maxVolume, minVolume) {100+ getVolumeIcon(isMute: boolean, volume: number, maxVolume: number, minVolume: number) {
101 Log.showInfo(TAG, `getVolumeIcon, isMute: ${isMute} volume: ${volume} maxVolume: ${maxVolume} minVolume: ${minVolume}`);101 Log.showInfo(TAG, `getVolumeIcon, isMute: ${isMute} volume: ${volume} maxVolume: ${maxVolume} minVolume: ${minVolume}`);
102- let icon102+ let icon: Resource
103 if (isMute) {103 if (isMute) {
104 icon = $r('app.media.ic_public_mute')104 icon = $r('app.media.ic_public_mute')
105 } else {105 } else {
@@ -24,7 +24,7 @@ const TAG = 'Control-wifiComponent'
24 24 
25@Component25@Component
26export default struct WifiComponent {26export default struct WifiComponent {
27- private IconInfo: any[] = [27+ private IconInfo: Resource[] = [
28 $r('app.media.wifi_d'),28 $r('app.media.wifi_d'),
29 $r('app.media.wifi'),29 $r('app.media.wifi'),
30 ]30 ]
@@ -64,8 +64,8 @@ export default struct WifiComponent {
64 iconOn: this.IconInfo[1],64 iconOn: this.IconInfo[1],
65 mTitle: $wifiName,65 mTitle: $wifiName,
66 changeSwitch: $wifiOpenStatus,66 changeSwitch: $wifiOpenStatus,
67- mClickEvent: () => this.mClickEvent(),67+ mClickEvent: (): void => this.mClickEvent(),
68- mLongClickEvent: () => this.mLongClickEvent()68+ mLongClickEvent: (): void => this.mLongClickEvent()
69 })69 })
70 }.width('100%')70 }.width('100%')
71 .height('100%')71 .height('100%')
@@ -59,7 +59,7 @@ export default struct WifiIcon {
59 59 
60 private getImage(wifiInfo: number) {60 private getImage(wifiInfo: number) {
61 Log.showInfo(TAG, `getImage`);61 Log.showInfo(TAG, `getImage`);
62- let wifiImage;62+ let wifiImage: Resource;
63 switch (wifiInfo) {63 switch (wifiInfo) {
64 case Constants.WIFI_SIGNAL_NO:64 case Constants.WIFI_SIGNAL_NO:
65 wifiImage = $r('app.media.ic_statusbar_wifi_no');65 wifiImage = $r('app.media.ic_statusbar_wifi_no');
@@ -1,4 +1,5 @@
1{1{
2+ "modelVersion": "5.0.1",
2 "devDependencies": {3 "devDependencies": {
3 "@ohos/hypium": "1.0.6"4 "@ohos/hypium": "1.0.6"
4 },5 },
@@ -38,7 +38,7 @@ class Stub extends rpc.RemoteObject {
38 38 
39 if (code === ServiceStubCode.COMMAND_SEND_REMOTE_OBJECT) {39 if (code === ServiceStubCode.COMMAND_SEND_REMOTE_OBJECT) {
40 Log.showInfo(TAG, `onRemoteRequest code:${ServiceStubCode.COMMAND_SEND_REMOTE_OBJECT} start ${connectId}`);40 Log.showInfo(TAG, `onRemoteRequest code:${ServiceStubCode.COMMAND_SEND_REMOTE_OBJECT} start ${connectId}`);
41- const controller = globalThis[Constants.SYSTEM_DIALOG_CONTROLLER];41+ const controller = globalThis.SystemDialog_Controller;
42 const remoteObject = data.readRemoteObject();42 const remoteObject = data.readRemoteObject();
43 Log.showDebug(TAG, `onRemoteRequest code:${ServiceStubCode.COMMAND_SEND_REMOTE_OBJECT} ${remoteObject}`);43 Log.showDebug(TAG, `onRemoteRequest code:${ServiceStubCode.COMMAND_SEND_REMOTE_OBJECT} ${remoteObject}`);
44 44 
@@ -86,7 +86,7 @@ class Stub extends rpc.RemoteObject {
86 }86 }
87 87 
88 async createWindow(connectId: string, parameters: IDialogParameters) {88 async createWindow(connectId: string, parameters: IDialogParameters) {
89- const controller = globalThis[Constants.SYSTEM_DIALOG_CONTROLLER];89+ const controller = globalThis.SystemDialog_Controller;
90 const current = controller.getData().get(connectId);90 const current = controller.getData().get(connectId);
91 if (current && current.windowName) {91 if (current && current.windowName) {
92 Log.showInfo(TAG, `createWindow <this same> connectId:${connectId}`);92 Log.showInfo(TAG, `createWindow <this same> connectId:${connectId}`);
@@ -129,7 +129,7 @@ class Stub extends rpc.RemoteObject {
129export default class DialogServiceExtAbility extends ServiceExtensionAbility {129export default class DialogServiceExtAbility extends ServiceExtensionAbility {
130 onCreate(want: Want) {130 onCreate(want: Want) {
131 Log.showInfo(TAG, 'onCreate');131 Log.showInfo(TAG, 'onCreate');
132- globalThis[Constants.SYSTEM_DIALOG_CONTROLLER] = new SystemDialogController(this.context);132+ globalThis.SystemDialog_Controller = new SystemDialogController(this.context);
133 }133 }
134 134 
135 onConnect() {135 onConnect() {
@@ -142,9 +142,9 @@ export default class DialogServiceExtAbility extends ServiceExtensionAbility {
142 }142 }
143 143 
144 onDestroy() {144 onDestroy() {
145- const controller = globalThis[Constants.SYSTEM_DIALOG_CONTROLLER];145+ const controller = globalThis.SystemDialog_Controller;
146 controller.destroyAllWindow();146 controller.destroyAllWindow();
147- globalThis[Constants.SYSTEM_DIALOG_CONTROLLER] = undefined;147+ globalThis.SystemDialog_Controller = undefined;
148 148 
149 Log.showInfo(TAG, 'onDestroy end');149 Log.showInfo(TAG, 'onDestroy end');
150 }150 }
@@ -18,6 +18,7 @@ import Log from '../../../../../../../common/src/main/ets/default/Log';
18import Constants from '../common/Constants';18import Constants from '../common/Constants';
19import type { IDialogParameters } from '../controller/Controller';19import type { IDialogParameters } from '../controller/Controller';
20import inputMethod from '@ohos.inputMethod';20import inputMethod from '@ohos.inputMethod';
21+import SystemDialogController from '../controller/Controller';
21 22 
22const TAG = 'Dialog-Index';23const TAG = 'Dialog-Index';
23 24 
@@ -26,10 +27,10 @@ const storage = LocalStorage.GetShared();
26@Entry(storage)27@Entry(storage)
27@Component28@Component
28struct Index {29struct Index {
29- @LocalStorageProp('connectId') connectId: string = undefined;30+ @LocalStorageProp('connectId') connectId: string = '';
30- @LocalStorageProp('windowName') windowName: string = undefined;31+ @LocalStorageProp('windowName') windowName: string = '';
31- @LocalStorageProp('parameters') parameters: IDialogParameters = undefined;32+ @LocalStorageProp('parameters') parameters: IDialogParameters = {};
32- @State inputMethodSetting: inputMethod.InputMethodSetting = undefined;33+ @State inputMethodSetting: inputMethod.InputMethodSetting | undefined = undefined;
33 @State keyboardHeight: number = 0;34 @State keyboardHeight: number = 0;
34 35 
35 aboutToAppear() {36 aboutToAppear() {
@@ -62,8 +63,8 @@ struct Index {
62 cancelListenKeyboard() {63 cancelListenKeyboard() {
63 Log.showInfo(TAG, 'cancelListenKeyboard in');64 Log.showInfo(TAG, 'cancelListenKeyboard in');
64 try {65 try {
65- this.inputMethodSetting.off('imeShow');66+ this.inputMethodSetting?.off('imeShow');
66- this.inputMethodSetting.off('imeHide');67+ this.inputMethodSetting?.off('imeHide');
67 } catch (e) {68 } catch (e) {
68 Log.showError('cancelListenKeyboard error', e);69 Log.showError('cancelListenKeyboard error', e);
69 }70 }
@@ -72,8 +73,8 @@ struct Index {
72 onOk() {73 onOk() {
73 Log.showDebug(TAG, `onOk start`);74 Log.showDebug(TAG, `onOk start`);
74 75 
75- const controller = globalThis[Constants.SYSTEM_DIALOG_CONTROLLER];76+ const controller = globalThis.SystemDialog_Controller as SystemDialogController;
76- const { remoteObject } = controller.getData().get(this.connectId);77+ const remoteObject = controller.getData().get(this.connectId)?.remoteObject;
77 if (remoteObject) {78 if (remoteObject) {
78 Log.showDebug(TAG, `onOk ${remoteObject}`);79 Log.showDebug(TAG, `onOk ${remoteObject}`);
79 80 
@@ -82,8 +83,8 @@ struct Index {
82 let option = new rpc.MessageOption();83 let option = new rpc.MessageOption();
83 remoteObject.sendMessageRequest(1, data, reply, option)84 remoteObject.sendMessageRequest(1, data, reply, option)
84 .then(85 .then(
85- (result) => Log.showDebug(TAG, `onOk success ${JSON.stringify(result)}`),86+ (result: rpc.RequestResult): void => Log.showDebug(TAG, `onOk success ${JSON.stringify(result)}`),
86- (error) => {87+ (error: Error) => {
87 Log.showDebug(TAG, `onOk error ${JSON.stringify(error)}`);88 Log.showDebug(TAG, `onOk error ${JSON.stringify(error)}`);
88 this.onClose();89 this.onClose();
89 }90 }
@@ -98,7 +99,7 @@ struct Index {
98 99 
99 onClose() {100 onClose() {
100 Log.showDebug(TAG, `onClose start`);101 Log.showDebug(TAG, `onClose start`);
101- const controller = globalThis[Constants.SYSTEM_DIALOG_CONTROLLER];102+ const controller = globalThis.SystemDialog_Controller as SystemDialogController;
102 controller?.destroyWindow(this.connectId);103 controller?.destroyWindow(this.connectId);
103 Log.showInfo(TAG, `onClose end`);104 Log.showInfo(TAG, `onClose end`);
104 }105 }
@@ -4,6 +4,7 @@
4 "description": "",4 "description": "",
5 "version": "1.0.0",5 "version": "1.0.0",
6 "dependencies": {6 "dependencies": {
7- "@ohos/navigationservice": "file:../../../features/navigationservice"7+ "@ohos/navigationservice": "file:../../../features/navigationservice",
8+ "@ohos/common": "file:../../../common"
8 }9 }
9}10}
@@ -12,6 +12,7 @@
12 * See the License for the specific language governing permissions and12 * See the License for the specific language governing permissions and
13 * limitations under the License.13 * limitations under the License.
14 */14 */
15+import resourceManager from '@ohos.resourceManager';
15 16 
16export default class Constants {17export default class Constants {
17 static readonly KEY_DOWN: number = 0;18 static readonly KEY_DOWN: number = 0;
@@ -33,3 +34,8 @@ export class NavigationBarComponentData {
33 backgroundColor = '#00000000';34 backgroundColor = '#00000000';
34 contentColor = '#FFFFFFFF';35 contentColor = '#FFFFFFFF';
35}36}
37+ 
38+export interface KeyCode {
39+ uri: resourceManager.Resource,
40+ keyCode: number
41+}
@@ -19,12 +19,12 @@ import IndicatorStyle, { IndicatorType } from '../common/IndicatorConfig';
19@Entry19@Entry
20@Component20@Component
21export default struct PrivacyIndicatorComponent {21export default struct PrivacyIndicatorComponent {
22- private mViewModel: ViewModel;22+ private mViewModel: ViewModel | undefined = undefined;
23 @State mBackgroundColor: Resource = $r("app.color.transparent");23 @State mBackgroundColor: Resource = $r("app.color.transparent");
24 24 
25 aboutToAppear(): void {25 aboutToAppear(): void {
26 this.mViewModel = new ViewModel();26 this.mViewModel = new ViewModel();
27- this.mViewModel.setCallback((type) => {27+ this.mViewModel.setCallback((type: number) => {
28 if (type == IndicatorType.TYPE_ORANGE) {28 if (type == IndicatorType.TYPE_ORANGE) {
29 this.mBackgroundColor = $r("sys.color.ohos_id_color_alert");29 this.mBackgroundColor = $r("sys.color.ohos_id_color_alert");
30 } else if (type == IndicatorType.TYPE_GREEN) {30 } else if (type == IndicatorType.TYPE_GREEN) {
@@ -15,6 +15,7 @@
15 15 
16import Log from '../../../../../../../common/src/main/ets/default/Log'16import Log from '../../../../../../../common/src/main/ets/default/Log'
17import AbilityManager from '../../../../../../../common/src/main/ets/default/abilitymanager/abilityManager'17import AbilityManager from '../../../../../../../common/src/main/ets/default/abilitymanager/abilityManager'
18+import { ConfigInfo } from '@ohos/common'
18 19 
19const TAG = 'Navigation-SplitBar'20const TAG = 'Navigation-SplitBar'
20 21 
@@ -35,7 +36,7 @@ struct Index {
35 36 
36 aboutToAppear() {37 aboutToAppear() {
37 Log.showInfo(TAG, `aboutToAppear, start`);38 Log.showInfo(TAG, `aboutToAppear, start`);
38- let configInfo = AbilityManager.getAbilityData(AbilityManager.ABILITY_NAME_NAVIGATION_BAR, 'config');39+ let configInfo = AbilityManager.getAbilityData(AbilityManager.ABILITY_NAME_NAVIGATION_BAR, 'config') as ConfigInfo;
39 if (configInfo.maxWidth > configInfo.maxHeight) {40 if (configInfo.maxWidth > configInfo.maxHeight) {
40 this.mHorizontalScreen = true;41 this.mHorizontalScreen = true;
41 } else {42 } else {
@@ -22,25 +22,25 @@ import {NavigationBarComponentData} from '../common/constants'
22import StyleManager from '../common/StyleManager'22import StyleManager from '../common/StyleManager'
23import configManager from '../../../../../../../features/navigationservice/src/main/ets/com/ohos/navigationservice/ConfigManager'23import configManager from '../../../../../../../features/navigationservice/src/main/ets/com/ohos/navigationservice/ConfigManager'
24import WindowManager, { WindowType } from '../../../../../../../common/src/main/ets/default/WindowManager';24import WindowManager, { WindowType } from '../../../../../../../common/src/main/ets/default/WindowManager';
25+import { ConfigInfo } from '@ohos/common'
25const TAG = 'NavigationBar-Index';26const TAG = 'NavigationBar-Index';
26let mConfigManager = configManager27let mConfigManager = configManager
27 28 
28@Entry29@Entry
29@Component30@Component
30struct Index {31struct Index {
31- @StorageLink('navigationLayoutConfig') mConfig: object = {}32+ // @StorageLink('navigationLayoutConfig') mConfig: object = {}
32 @StorageLink('minNavHeight') minNavHeight: number = 3233 @StorageLink('minNavHeight') minNavHeight: number = 32
33 @StorageLink("showNavHorizontal") showNavHorizontal: boolean = true34 @StorageLink("showNavHorizontal") showNavHorizontal: boolean = true
34 @State mNavigationBarComponentData: NavigationBarComponentData = new NavigationBarComponentData()35 @State mNavigationBarComponentData: NavigationBarComponentData = new NavigationBarComponentData()
35 36 
36 onBackPress(): boolean {37 onBackPress(): boolean {
37- 
38 return true;38 return true;
39 }39 }
40 40 
41 aboutToAppear() {41 aboutToAppear() {
42 Log.showInfo(TAG, `aboutToAppear Start`);42 Log.showInfo(TAG, `aboutToAppear Start`);
43- let configInfo = AbilityManager.getAbilityData(AbilityManager.ABILITY_NAME_NAVIGATION_BAR, 'config');43+ let configInfo = AbilityManager.getAbilityData(AbilityManager.ABILITY_NAME_NAVIGATION_BAR, 'config') as ConfigInfo;
44 AppStorage.SetOrCreate("showNavHorizontal", configInfo.showNavHorizontal);44 AppStorage.SetOrCreate("showNavHorizontal", configInfo.showNavHorizontal);
45 mConfigManager.initConfig();45 mConfigManager.initConfig();
46 WindowManager.setWindowBgColor(WindowType.NAVIGATION_BAR ,'#00000000')46 WindowManager.setWindowBgColor(WindowType.NAVIGATION_BAR ,'#00000000')
@@ -24,7 +24,7 @@ const TAG = 'NavigationBar-KeyButton';
24 24 
25@Component25@Component
26export default struct keyButton {26export default struct keyButton {
27- private uri: any;27+ @Prop uri: Resource;
28 @State keyCode: number = 0;28 @State keyCode: number = 0;
29 @Link currentTouchItem: number;29 @Link currentTouchItem: number;
30 @State backGroundColor: Resource = $r('app.color.button_default_background');30 @State backGroundColor: Resource = $r('app.color.button_default_background');
@@ -14,11 +14,11 @@
14 */14 */
15 15 
16import keyButton from './keyButton';16import keyButton from './keyButton';
17-import Constants from '../common/constants'17+import Constants, { KeyCode } from '../common/constants'
18import Log from '../../../../../../../common/src/main/ets/default/Log';18import Log from '../../../../../../../common/src/main/ets/default/Log';
19const TAG = 'NavigationBar-ThreeLayout';19const TAG = 'NavigationBar-ThreeLayout';
20 20 
21-let KeyCodeArr: any[] = [21+let KeyCodeArr: KeyCode[] = [
22 {22 {
23 "uri": $r('app.media.ic_systemui_back'),23 "uri": $r('app.media.ic_systemui_back'),
24 "keyCode": Constants.KEYCODE_BACK24 "keyCode": Constants.KEYCODE_BACK
@@ -49,7 +49,7 @@ struct threeLayout {
49 build() {49 build() {
50 if (this.showNavHorizontal) {50 if (this.showNavHorizontal) {
51 Grid() {51 Grid() {
52- ForEach(KeyCodeArr, (item: any) => {52+ ForEach(KeyCodeArr, (item: KeyCode) => {
53 GridItem() {53 GridItem() {
54 Row() {54 Row() {
55 keyButton({ uri: item.uri, keyCode: item.keyCode, currentTouchItem: $currentTouchItem })55 keyButton({ uri: item.uri, keyCode: item.keyCode, currentTouchItem: $currentTouchItem })
@@ -65,7 +65,7 @@ struct threeLayout {
65 .align(Alignment.Center);65 .align(Alignment.Center);
66 } else {66 } else {
67 Grid() {67 Grid() {
68- ForEach(KeyCodeArr, (item: any) => {68+ ForEach(KeyCodeArr, (item: KeyCode) => {
69 GridItem() {69 GridItem() {
70 Column() {70 Column() {
71 keyButton({ uri: item.uri, keyCode: item.keyCode, currentTouchItem: $currentTouchItem })71 keyButton({ uri: item.uri, keyCode: item.keyCode, currentTouchItem: $currentTouchItem })
@@ -4,6 +4,7 @@
4 "description": "",4 "description": "",
5 "version": "1.0.0",5 "version": "1.0.0",
6 "dependencies": {6 "dependencies": {
7- "@ohos/managementcomponent": "file:../../../features/managementcomponent"7+ "@ohos/managementcomponent": "file:../../../features/managementcomponent",
8+ "@ohos/common": "file:../../../common"
8 }9 }
9}10}
@@ -24,11 +24,24 @@ import ViewModel from '../vm/notificationManagenmentViewModel'
24 24 
25const TAG = 'NotificationManagement-BatchSetEnable';25const TAG = 'NotificationManagement-BatchSetEnable';
26 26 
27+interface BundleItemData {
28+ appIcon?: string;
29+ appTitle?: string;
30+ appValue?: string;
31+ appArrow?: string|Resource;
32+ appSummary?: string;
33+ appBundleName?: string;
34+ appIconId?: string;
35+ appUri?: string;
36+ appUid?: number;
37+ systemApp?: boolean;
38+}
39+ 
27@Entry40@Entry
28@Component41@Component
29export default struct BatchSetEnable {42export default struct BatchSetEnable {
30 @State mViewModel: ViewModel = new ViewModel();43 @State mViewModel: ViewModel = new ViewModel();
31- @StorageLink('appManagementList') appList: any[]= [];44+ @StorageLink('appManagementList') appList: BundleItemData[]= [];
32 @State headName:Resource = $r('app.string.batch_Management')45 @State headName:Resource = $r('app.string.batch_Management')
33 46 
34 build() {47 build() {
@@ -38,14 +51,14 @@ export default struct BatchSetEnable {
38 Column() {51 Column() {
39 HeadComponent({ headName: $headName, isActive: true });52 HeadComponent({ headName: $headName, isActive: true });
40 List() {53 List() {
41- ForEach(this.appList, (item) => {54+ ForEach(this.appList, (item: BundleItemData) => {
42 ListItem() {55 ListItem() {
43 AppItemComponent({56 AppItemComponent({
44 appIcon: item.appIcon,57 appIcon: item.appIcon,
45 appTitle: item.appTitle,58 appTitle: item.appTitle,
46 appSummary: item.appSummary,59 appSummary: item.appSummary,
47 appValue: item.appValue,60 appValue: item.appValue,
48- appArrow: item.appArrow,61+ appArrow: item.appArrow as string,
49 appArrowStyle: '',62 appArrowStyle: '',
50 appUri: '',63 appUri: '',
51 appBundleName:item.appBundleName,64 appBundleName:item.appBundleName,
@@ -22,6 +22,7 @@ import ItemComponent from '../../../../../../../features/managementcomponent/src
22import {DoNotDisturbType} from '../../../../../../../features/managementcomponent/src/main/ets/com/ohos/common/constants';22import {DoNotDisturbType} from '../../../../../../../features/managementcomponent/src/main/ets/com/ohos/common/constants';
23import NoDisturbingModel from '../../../../../../../features/managementcomponent/src/main/ets/com/ohos/model/noDisturbingModel';23import NoDisturbingModel from '../../../../../../../features/managementcomponent/src/main/ets/com/ohos/model/noDisturbingModel';
24import ViewModel from '../vm/noDisturbViewModel';24import ViewModel from '../vm/noDisturbViewModel';
25+import { data } from '@kit.TelephonyKit';
25 26 
26const deviceTypeInfo = deviceInfo.deviceType;27const deviceTypeInfo = deviceInfo.deviceType;
27const TAG = 'NotificationManagement-NoDisturb';28const TAG = 'NotificationManagement-NoDisturb';
@@ -54,9 +55,9 @@ export default struct NoDisturb {
54 Log.showInfo(TAG, `mViewModel onChange repeatName: ${this.mViewModel.repeatName} startDateClue: ${this.mViewModel.startDateClue}55 Log.showInfo(TAG, `mViewModel onChange repeatName: ${this.mViewModel.repeatName} startDateClue: ${this.mViewModel.startDateClue}
55 endDateClue: ${this.mViewModel.endDateClue} endTimeClue: ${this.mViewModel.endTimeClue}`)56 endDateClue: ${this.mViewModel.endDateClue} endTimeClue: ${this.mViewModel.endTimeClue}`)
56 }57 }
57- startDateDialogController: CustomDialogController = new CustomDialogController({58+ startDateDialogController: CustomDialogController | null = new CustomDialogController({
58 builder: DateDialog({59 builder: DateDialog({
59- action:(data)=> this.setStartDate(data),60+ action:(data: string): void => this.setStartDate(data),
60 title: $r('app.string.startDate'),61 title: $r('app.string.startDate'),
61 defaultDate: this.mViewModel.defaultStartTime62 defaultDate: this.mViewModel.defaultStartTime
62 }),63 }),
@@ -66,9 +67,9 @@ export default struct NoDisturb {
66 offset: ({ dx: 0, dy: deviceTypeInfo === "phone" ? '-16dp' : 0 }),67 offset: ({ dx: 0, dy: deviceTypeInfo === "phone" ? '-16dp' : 0 }),
67 customStyle: true68 customStyle: true
68 });69 });
69- startTimeDialogController: CustomDialogController = new CustomDialogController({70+ startTimeDialogController: CustomDialogController | null = new CustomDialogController({
70 builder: TimeDialog({71 builder: TimeDialog({
71- action:(data)=> this.setStartTime(data),72+ action:(data: string): void=> this.setStartTime(data),
72 title: $r('app.string.startTime'),73 title: $r('app.string.startTime'),
73 defaultDate: this.mViewModel.defaultStartTime74 defaultDate: this.mViewModel.defaultStartTime
74 }),75 }),
@@ -78,9 +79,9 @@ export default struct NoDisturb {
78 offset: ({ dx: 0, dy: deviceTypeInfo === "phone" ? '-16dp' : 0 }),79 offset: ({ dx: 0, dy: deviceTypeInfo === "phone" ? '-16dp' : 0 }),
79 customStyle: true80 customStyle: true
80 });81 });
81- endDateDialogController: CustomDialogController = new CustomDialogController({82+ endDateDialogController: CustomDialogController | null = new CustomDialogController({
82 builder: DateDialog({83 builder: DateDialog({
83- action:(data)=> this.setEndDate(data),84+ action:(data: string): void => this.setEndDate(data),
84 title: $r('app.string.endDate'),85 title: $r('app.string.endDate'),
85 defaultDate: this.mViewModel.defaultEndTime86 defaultDate: this.mViewModel.defaultEndTime
86 }),87 }),
@@ -90,9 +91,9 @@ export default struct NoDisturb {
90 offset: ({ dx: 0, dy: deviceTypeInfo === "phone" ? '-16dp' : 0 }),91 offset: ({ dx: 0, dy: deviceTypeInfo === "phone" ? '-16dp' : 0 }),
91 customStyle: true92 customStyle: true
92 });93 });
93- endTimeDialogController: CustomDialogController = new CustomDialogController({94+ endTimeDialogController: CustomDialogController | null = new CustomDialogController({
94 builder: TimeDialog({95 builder: TimeDialog({
95- action:(data)=> this.setEndTime(data),96+ action:(data: string): void => this.setEndTime(data),
96 title: $r('app.string.endTime'),97 title: $r('app.string.endTime'),
97 defaultDate: this.mViewModel.defaultEndTime98 defaultDate: this.mViewModel.defaultEndTime
98 }),99 }),
@@ -102,9 +103,9 @@ export default struct NoDisturb {
102 offset: ({ dx: 0, dy: deviceTypeInfo === "phone" ? '-16dp' : 0 }),103 offset: ({ dx: 0, dy: deviceTypeInfo === "phone" ? '-16dp' : 0 }),
103 customStyle: true104 customStyle: true
104 });105 });
105- repeatDialogController: CustomDialogController = new CustomDialogController({106+ repeatDialogController: CustomDialogController | null = new CustomDialogController({
106 builder: RepeatModeDialog({107 builder: RepeatModeDialog({
107- action: (data) => this.setRepeatMode(data),108+ action: (data: number): void => this.setRepeatMode(data),
108 title: $r('app.string.repeat'),109 title: $r('app.string.repeat'),
109 selectMode: this.mViewModel.repeatMode110 selectMode: this.mViewModel.repeatMode
110 }),111 }),
@@ -129,7 +130,7 @@ export default struct NoDisturb {
129 arrow: $arrow130 arrow: $arrow
130 })131 })
131 }.onClick(() => {132 }.onClick(() => {
132- this.repeatDialogController.open()133+ this.repeatDialogController?.open()
133 }).margin({ bottom: $r('app.float.itemComp_margin_b') })134 }).margin({ bottom: $r('app.float.itemComp_margin_b') })
134 135 
135 if (this.mViewModel.repeatMode == DoNotDisturbType.TYPE_CLEARLY) {136 if (this.mViewModel.repeatMode == DoNotDisturbType.TYPE_CLEARLY) {
@@ -142,7 +143,7 @@ export default struct NoDisturb {
142 arrow: $arrow143 arrow: $arrow
143 })144 })
144 }.onClick(() => {145 }.onClick(() => {
145- this.startDateDialogController.open()146+ this.startDateDialogController?.open()
146 })147 })
147 }148 }
148 ListItem() {149 ListItem() {
@@ -153,7 +154,7 @@ export default struct NoDisturb {
153 arrow: $arrow154 arrow: $arrow
154 })155 })
155 }.onClick(() => {156 }.onClick(() => {
156- this.startTimeDialogController.open()157+ this.startTimeDialogController?.open()
157 })158 })
158 }159 }
159 }.divider({160 }.divider({
@@ -178,7 +179,7 @@ export default struct NoDisturb {
178 arrow: $arrow179 arrow: $arrow
179 })180 })
180 }.onClick(() => {181 }.onClick(() => {
181- this.endDateDialogController.open()182+ this.endDateDialogController?.open()
182 })183 })
183 }184 }
184 ListItem() {185 ListItem() {
@@ -189,7 +190,7 @@ export default struct NoDisturb {
189 arrow: $arrow190 arrow: $arrow
190 })191 })
191 }.onClick(() => {192 }.onClick(() => {
192- this.endTimeDialogController.open()193+ this.endTimeDialogController?.open()
193 })194 })
194 }195 }
195 }.divider({196 }.divider({
@@ -214,7 +215,7 @@ export default struct NoDisturb {
214 })215 })
215 }.onClick(() => {216 }.onClick(() => {
216 this.mPrevData = this.mViewModel.startTime217 this.mPrevData = this.mViewModel.startTime
217- this.startTimeDialogController.open()218+ this.startTimeDialogController?.open()
218 }).margin({ bottom: $r('app.float.itemComp_margin_b')})219 }).margin({ bottom: $r('app.float.itemComp_margin_b')})
219 Row() {220 Row() {
220 ItemComponent({221 ItemComponent({
@@ -224,7 +225,7 @@ export default struct NoDisturb {
224 })225 })
225 }.onClick(() => {226 }.onClick(() => {
226 this.mPrevData = this.mViewModel.endTime227 this.mPrevData = this.mViewModel.endTime
227- this.endTimeDialogController.open()228+ this.endTimeDialogController?.open()
228 }).margin({ bottom: $r('app.float.itemComp_margin_b')})229 }).margin({ bottom: $r('app.float.itemComp_margin_b')})
229 }230 }
230 }231 }
@@ -287,20 +288,11 @@ export default struct NoDisturb {
287 }288 }
288 289 
289 aboutToDisappear() {290 aboutToDisappear() {
290- delete this.startDateDialogController291+ this.startDateDialogController = null
291- this.startDateDialogController = undefined292+ this.startTimeDialogController = null
292- 293+ this.endDateDialogController = null
293- delete this.startTimeDialogController294+ this.endTimeDialogController = null
294- this.startTimeDialogController = undefined295+ this.repeatDialogController = null
295- 
296- delete this.endDateDialogController
297- this.endDateDialogController = undefined
298- 
299- delete this.endTimeDialogController
300- this.endTimeDialogController = undefined
301- 
302- delete this.repeatDialogController
303- this.repeatDialogController = undefined
304 296 
305 Log.showInfo(TAG, `aboutToDisappear`)297 Log.showInfo(TAG, `aboutToDisappear`)
306 }298 }
@@ -316,7 +308,7 @@ export default struct NoDisturb {
316@CustomDialog308@CustomDialog
317struct DateDialog {309struct DateDialog {
318 public controller: CustomDialogController310 public controller: CustomDialogController
319- public action: (data) => void311+ public action: (data: string) => void = data => {}
320 private selectedDate: string = ''312 private selectedDate: string = ''
321 private title: string | Resource = ''313 private title: string | Resource = ''
322 private defaultDate: Date = new Date()314 private defaultDate: Date = new Date()
@@ -335,7 +327,7 @@ struct DateDialog {
335 .fontWeight(FontWeight.Medium)327 .fontWeight(FontWeight.Medium)
336 DatePicker({ start: this.minDate, end: this.maxDate, selected: this.defaultDate })328 DatePicker({ start: this.minDate, end: this.maxDate, selected: this.defaultDate })
337 .onChange((date: DatePickerResult) => {329 .onChange((date: DatePickerResult) => {
338- let dateSource = new Date(date.year, date.month, date.day);330+ let dateSource = new Date(date.year as number, date.month as number, date.day);
339 this.selectedDate = NoDisturbingModel.formatDate(dateSource);331 this.selectedDate = NoDisturbingModel.formatDate(dateSource);
340 })332 })
341 .width(ConfigData.WH_100_100)333 .width(ConfigData.WH_100_100)
@@ -395,7 +387,7 @@ struct DateDialog {
395@CustomDialog387@CustomDialog
396struct TimeDialog {388struct TimeDialog {
397 public controller: CustomDialogController389 public controller: CustomDialogController
398- public action: (data) => void390+ public action: (data: string) => void = data => {}
399 private selectedTime: string = ''391 private selectedTime: string = ''
400 private title: string | Resource = ''392 private title: string | Resource = ''
401 private defaultDate: Date = new Date()393 private defaultDate: Date = new Date()
@@ -471,7 +463,7 @@ struct TimeDialog {
471@CustomDialog463@CustomDialog
472struct RepeatModeDialog {464struct RepeatModeDialog {
473 public controller: CustomDialogController465 public controller: CustomDialogController
474- public action: (data) => void466+ public action: (data: number) => void = data => {}
475 private title: string | Resource = ''467 private title: string | Resource = ''
476 private prevModeSetCnt: number = 0468 private prevModeSetCnt: number = 0
477 @State selectMode: number = DoNotDisturbType.TYPE_NONE469 @State selectMode: number = DoNotDisturbType.TYPE_NONE
@@ -121,8 +121,8 @@ export default struct notificationManagenment {
121 SwitchComponent({121 SwitchComponent({
122 title: $allowDistribut,122 title: $allowDistribut,
123 describe: this.allowDistributDescribe,123 describe: this.allowDistributDescribe,
124- initializationAction: () => this.switchComponentInit(),124+ initializationAction: (): Promise<boolean> => this.switchComponentInit(),
125- settingAction: (params) => this.switchComponentSet(params)125+ settingAction: (params): void => this.switchComponentSet(params)
126 })126 })
127 }.margin({ bottom: $r('app.float.noDisturb_margin_lf') })127 }.margin({ bottom: $r('app.float.noDisturb_margin_lf') })
128 }128 }
@@ -202,7 +202,7 @@ export default struct notificationManagenment {
202 return Notification.isDistributedEnabled();202 return Notification.isDistributedEnabled();
203 }203 }
204 204 
205- switchComponentSet(params) {205+ switchComponentSet(params?: boolean) {
206 Log.showDebug(TAG, `switchComponentSet`)206 Log.showDebug(TAG, `switchComponentSet`)
207 Notification.enableDistributed(params);207 Notification.enableDistributed(params);
208 }208 }
@@ -23,18 +23,19 @@ import ConfigData from '../common/constants';
23import Router from '@system.router'23import Router from '@system.router'
24import notificationListener from '../../../../../../../features/managementcomponent/src/main/ets/com/ohos/model/notificationListener';24import notificationListener from '../../../../../../../features/managementcomponent/src/main/ets/com/ohos/model/notificationListener';
25import Notification from '@ohos.notification';25import Notification from '@ohos.notification';
26+import NotificationManager from '@ohos.notificationManager';
27+import { BundleItemData } from '@ohos/common';
26 28 
27const TAG = 'NotificationManagement-SetEnable';29const TAG = 'NotificationManagement-SetEnable';
28 30 
29-let appInfo;31+let appInfo: BundleItemData;
30 32 
31@Entry33@Entry
32@Component34@Component
33export default struct SetEnable {35export default struct SetEnable {
34- private listeners: any[] = [];
35 @State headName:Resource = $r('app.string.notificationManagement');36 @State headName:Resource = $r('app.string.notificationManagement');
36 @State allowNotice:Resource = $r('app.string.allowNotification');37 @State allowNotice:Resource = $r('app.string.allowNotification');
37- @State slotLst: any[] = [];38+ @State slotLst: NotificationManager.NotificationSlot[] = [];
38 @State initState: boolean = false;39 @State initState: boolean = false;
39 build() {40 build() {
40 Flex({ justifyContent: FlexAlign.SpaceBetween }) {41 Flex({ justifyContent: FlexAlign.SpaceBetween }) {
@@ -49,7 +50,7 @@ export default struct SetEnable {
49 appTitle: appInfo.appTitle,50 appTitle: appInfo.appTitle,
50 appSummary: appInfo.appSummary,51 appSummary: appInfo.appSummary,
51 appValue: '',52 appValue: '',
52- appArrow: appInfo.appArrow,53+ appArrow: appInfo.appArrow as string,
53 appArrowStyle: '',54 appArrowStyle: '',
54 appUri: appInfo.appUri,55 appUri: appInfo.appUri,
55 appBundleName: appInfo.appBundleName,56 appBundleName: appInfo.appBundleName,
@@ -64,8 +65,8 @@ export default struct SetEnable {
64 Row() {65 Row() {
65 SwitchComponent({66 SwitchComponent({
66 title: $allowNotice,67 title: $allowNotice,
67- initializationAction: () => this.switchComponentInit(),68+ initializationAction: (): Promise<boolean> => this.switchComponentInit(),
68- settingAction: (params) => this.switchComponentSet(params),69+ settingAction: (params?: boolean): void => this.switchComponentSet(params),
69 register: (listener) => notificationListener.register({bundle:appInfo.appBundleName,onEnableChanged:listener})70 register: (listener) => notificationListener.register({bundle:appInfo.appBundleName,onEnableChanged:listener})
70 })71 })
71 }72 }
@@ -128,15 +129,15 @@ export default struct SetEnable {
128 129 
129 switchComponentInit() {130 switchComponentInit() {
130 Log.showDebug(TAG, `switchComponentInit`)131 Log.showDebug(TAG, `switchComponentInit`)
131- return notificationListener.isNotificationEnabled({ bundle: appInfo.appBundleName, uid: appInfo.appUid }, (data) => {132+ return notificationListener.isNotificationEnabled({ bundle: appInfo.appBundleName, uid: appInfo.appUid }, (data: boolean) => {
132 Log.showDebug(TAG, 'switchComponentInit callback' + data);133 Log.showDebug(TAG, 'switchComponentInit callback' + data);
133 this.initState = data;134 this.initState = data;
134 });135 });
135 }136 }
136 137 
137- switchComponentSet(params) {138+ switchComponentSet(params?: boolean) {
138 Log.showDebug(TAG, `switchComponentSet`)139 Log.showDebug(TAG, `switchComponentSet`)
139- this.initState = params;140+ this.initState = params as boolean;
140 notificationListener.enableNotification({ bundle: appInfo.appBundleName, uid: appInfo.appUid }, params);141 notificationListener.enableNotification({ bundle: appInfo.appBundleName, uid: appInfo.appUid }, params);
141 }142 }
142}143}
@@ -22,17 +22,23 @@ import NotificationConfigData from '../../../../../../../features/managementcomp
22import Router from '@system.router';22import Router from '@system.router';
23import NotificationListener from '../../../../../../../features/managementcomponent/src/main/ets/com/ohos/model/notificationListener';23import NotificationListener from '../../../../../../../features/managementcomponent/src/main/ets/com/ohos/model/notificationListener';
24import notification from '@ohos.notification';24import notification from '@ohos.notification';
25+import { BundleItemData } from '@ohos/common';
26+import NotificationManager from '@ohos.notificationManager';
25 27 
26const TAG = 'NotificationManagement-SlotSetting';28const TAG = 'NotificationManagement-SlotSetting';
27const DEFAULT_SOUND = 'file://system/etc/Light.ogg';29const DEFAULT_SOUND = 'file://system/etc/Light.ogg';
28 30 
29-let slotParams;31+interface ISlotParams {
32+ appInfo?: BundleItemData,
33+ slotInfo?: NotificationManager.NotificationSlot
34+};
30 35 
31@Entry36@Entry
32@Component37@Component
33export default struct SlotSetting {38export default struct SlotSetting {
34- private appInfo: any = null;39+ private slotParams: ISlotParams = {};
35- private slotInfo: any = null;40+ private appInfo: BundleItemData = {};
41+ private slotInfo: NotificationManager.NotificationSlot = {};
36 @State headName: Resource = $r('app.string.notificationManagement')42 @State headName: Resource = $r('app.string.notificationManagement')
37 @State allowNotice: Resource = $r('app.string.allowNotification')43 @State allowNotice: Resource = $r('app.string.allowNotification')
38 @State noticeStyleBanner: Resource = $r('app.string.notificationStyle_banner')44 @State noticeStyleBanner: Resource = $r('app.string.notificationStyle_banner')
@@ -56,8 +62,8 @@ export default struct SlotSetting {
56 appIcon: this.appInfo.appIcon,62 appIcon: this.appInfo.appIcon,
57 appTitle: this.appInfo.appTitle,63 appTitle: this.appInfo.appTitle,
58 appSummary: this.appInfo.appSummary,64 appSummary: this.appInfo.appSummary,
59- appValue: this.slotInfo.type,65+ appValue: this.slotInfo.type?.toString(),
60- appArrow: this.appInfo.appArrow,66+ appArrow: this.appInfo.appArrow as string,
61 appArrowStyle: '',67 appArrowStyle: '',
62 appUri: this.appInfo.appUri,68 appUri: this.appInfo.appUri,
63 appBundleName: this.appInfo.appBundleName,69 appBundleName: this.appInfo.appBundleName,
@@ -74,8 +80,8 @@ export default struct SlotSetting {
74 Row() {80 Row() {
75 SwitchComponent({81 SwitchComponent({
76 title: $allowNotice,82 title: $allowNotice,
77- initializationAction: () => this.notificationSlotEnableInit(),83+ initializationAction: (): Promise<boolean> => this.notificationSlotEnableInit(),
78- settingAction: (params) => this.notificationSlotEnableSet(params)84+ settingAction: (params): void => this.notificationSlotEnableSet(params as boolean)
79 })85 })
80 }86 }
81 .margin({ top: $r('app.float.page_notice_title_margin_t') })87 .margin({ top: $r('app.float.page_notice_title_margin_t') })
@@ -105,8 +111,8 @@ export default struct SlotSetting {
105 Row() {111 Row() {
106 SwitchComponent({112 SwitchComponent({
107 title: $noticeStyleBanner,113 title: $noticeStyleBanner,
108- initializationAction: () => this.bannerEnableInit(),114+ initializationAction: (): Promise<boolean> => this.bannerEnableInit(),
109- settingAction: (params) => this.bannerEnableSet(params)115+ settingAction: (params): void => this.bannerEnableSet(params as boolean)
110 })116 })
111 }117 }
112 .padding({118 .padding({
@@ -120,8 +126,8 @@ export default struct SlotSetting {
120 Row() {126 Row() {
121 SwitchComponent({127 SwitchComponent({
122 title: $noticeSound,128 title: $noticeSound,
123- initializationAction: () => this.soundEnableInit(),129+ initializationAction: (): Promise<boolean> => this.soundEnableInit(),
124- settingAction: (params) => this.soundEnableSet(params)130+ settingAction: (params): void => this.soundEnableSet(params as boolean)
125 })131 })
126 }132 }
127 .padding({133 .padding({
@@ -151,9 +157,9 @@ export default struct SlotSetting {
151 }157 }
152 158 
153 aboutToAppear(): void{159 aboutToAppear(): void{
154- slotParams = Router.getParams();160+ this.slotParams = Router.getParams();
155- this.appInfo = slotParams.appInfo;161+ this.appInfo = this.slotParams.appInfo as BundleItemData;
156- this.slotInfo = slotParams.slotInfo162+ this.slotInfo = this.slotParams.slotInfo as NotificationManager.NotificationSlot;
157 Log.showDebug(TAG, `aboutToAppear ${JSON.stringify(this.slotInfo)}`)163 Log.showDebug(TAG, `aboutToAppear ${JSON.stringify(this.slotInfo)}`)
158 }164 }
159 165 
@@ -173,13 +179,13 @@ export default struct SlotSetting {
173 });179 });
174 }180 }
175 181 
176- notificationSlotEnableSet(data) {182+ notificationSlotEnableSet(data: boolean) {
177 Log.showDebug(TAG, `notificationEnableSet data:${JSON.stringify(data)}`)183 Log.showDebug(TAG, `notificationEnableSet data:${JSON.stringify(data)}`)
178 this.initState = data;184 this.initState = data;
179 NotificationListener.enableNotificationSlot({ bundle: this.appInfo.appBundleName, uid: this.appInfo.appUid }, this.slotInfo.type, data);185 NotificationListener.enableNotificationSlot({ bundle: this.appInfo.appBundleName, uid: this.appInfo.appUid }, this.slotInfo.type, data);
180 }186 }
181 187 
182- soundEnableInit() {188+ soundEnableInit(): Promise<boolean> {
183 Log.showDebug(TAG, `soundEnableInit`)189 Log.showDebug(TAG, `soundEnableInit`)
184 return new Promise((resolve, reject) => {190 return new Promise((resolve, reject) => {
185 let result: boolean = false;191 let result: boolean = false;
@@ -191,23 +197,23 @@ export default struct SlotSetting {
191 });197 });
192 }198 }
193 199 
194- soundEnableSet(params) {200+ soundEnableSet(params: boolean) {
195 Log.showDebug(TAG, `soundEnableSet params:${JSON.stringify(params)}`)201 Log.showDebug(TAG, `soundEnableSet params:${JSON.stringify(params)}`)
196- if (params == 0) {202+ if (!params) {
197 this.slotInfo.sound = '';203 this.slotInfo.sound = '';
198 if (this.slotInfo.level != notification.SlotLevel.LEVEL_HIGH) {204 if (this.slotInfo.level != notification.SlotLevel.LEVEL_HIGH) {
199 this.slotInfo.level = notification.SlotLevel.LEVEL_LOW;205 this.slotInfo.level = notification.SlotLevel.LEVEL_LOW;
200 }206 }
201- } else if (params == 1) {207+ } else if (params) {
202 this.slotInfo.sound = DEFAULT_SOUND;208 this.slotInfo.sound = DEFAULT_SOUND;
203- if (this.slotInfo.level < notification.SlotLevel.LEVEL_DEFAULT) {209+ if (this.slotInfo.level && this.slotInfo.level < notification.SlotLevel.LEVEL_DEFAULT) {
204 this.slotInfo.level = notification.SlotLevel.LEVEL_DEFAULT210 this.slotInfo.level = notification.SlotLevel.LEVEL_DEFAULT
205 }211 }
206 }212 }
207 this.notificationSlotSet();213 this.notificationSlotSet();
208 }214 }
209 215 
210- bannerEnableInit() {216+ bannerEnableInit(): Promise<boolean> {
211 Log.showDebug(TAG, `bannerEnableInit`)217 Log.showDebug(TAG, `bannerEnableInit`)
212 return new Promise((resolve, reject) => {218 return new Promise((resolve, reject) => {
213 let result: boolean = false;219 let result: boolean = false;
@@ -219,15 +225,15 @@ export default struct SlotSetting {
219 });225 });
220 }226 }
221 227 
222- bannerEnableSet(params) {228+ bannerEnableSet(params: boolean) {
223 Log.showDebug(TAG, `bannerEnableSet params:${JSON.stringify(params)}`)229 Log.showDebug(TAG, `bannerEnableSet params:${JSON.stringify(params)}`)
224- if (params == 0) {230+ if (!params) {
225 if (this.slotInfo.sound) {231 if (this.slotInfo.sound) {
226 this.slotInfo.level = notification.SlotLevel.LEVEL_DEFAULT;232 this.slotInfo.level = notification.SlotLevel.LEVEL_DEFAULT;
227 } else {233 } else {
228 this.slotInfo.level = notification.SlotLevel.LEVEL_LOW;234 this.slotInfo.level = notification.SlotLevel.LEVEL_LOW;
229 }235 }
230- } else if (params == 1) {236+ } else if (params) {
231 this.slotInfo.level = notification.SlotLevel.LEVEL_HIGH;237 this.slotInfo.level = notification.SlotLevel.LEVEL_HIGH;
232 }238 }
233 this.notificationSlotSet();239 this.notificationSlotSet();
@@ -21,6 +21,7 @@
21 "pages": "$profile:main_pages",21 "pages": "$profile:main_pages",
22 "abilities": [22 "abilities": [
23 {23 {
24+ "srcEntry": "./ets/MainAbility/MainAbility.ts",
24 "visible": true,25 "visible": true,
25 "srcEntrance": "./ets/MainAbility/MainAbility.ts",26 "srcEntrance": "./ets/MainAbility/MainAbility.ts",
26 "name": "com.ohos.systemui.notificationmanagement.MainAbility",27 "name": "com.ohos.systemui.notificationmanagement.MainAbility",
@@ -21,13 +21,25 @@ import WindowManager, { WindowType } from '../../../../../../../common/src/main/
21 21 
22const TAG = 'VolumePanel-Index'22const TAG = 'VolumePanel-Index'
23 23 
24+interface DisConfigInfo {
25+ width: number,
26+ height: number
27+}
28+ 
29+interface IvolumeRect {
30+ left: number,
31+ top: number,
32+ width: number,
33+ height: number
34+}
35+ 
24@Entry36@Entry
25@Component37@Component
26struct Index {38struct Index {
27 aboutToAppear() {39 aboutToAppear() {
28 Log.showInfo(TAG, `aboutToAppear Start`);40 Log.showInfo(TAG, `aboutToAppear Start`);
29- let configInfo = AbilityManager.getAbilityData(AbilityManager.ABILITY_NAME_VOLUME_PANEL, 'dis');41+ let configInfo: DisConfigInfo = AbilityManager.getAbilityData(AbilityManager.ABILITY_NAME_VOLUME_PANEL, 'dis');
30- let volumeRect;42+ let volumeRect: IvolumeRect;
31 if (configInfo.width > configInfo.height) { // Pad、PC Mode43 if (configInfo.width > configInfo.height) { // Pad、PC Mode
32 const realWidth = 48;44 const realWidth = 48;
33 const realHeight = 284;45 const realHeight = 284;
@@ -6,6 +6,7 @@
6 "dependencies": {6 "dependencies": {
7 "@ohos/controlcentercomponent": "file:../../../features/controlcentercomponent",7 "@ohos/controlcentercomponent": "file:../../../features/controlcentercomponent",
8 "@ohos/autorotatecomponent": "file:../../../features/autorotatecomponent",8 "@ohos/autorotatecomponent": "file:../../../features/autorotatecomponent",
9- "@ohos/airplanecomponent": "file:../../../features/airplanecomponent"9+ "@ohos/airplanecomponent": "file:../../../features/airplanecomponent",
10+ "@ohos/common": "file:../../../common",
10 }11 }
11}12}
@@ -23,7 +23,7 @@ const TAG = 'ControlPanel-Control';
23 23 
24@Component24@Component
25export default struct Control {25export default struct Control {
26- private modeChangeCallback: Function26+ private modeChangeCallback: Function = () => {}
27 27 
28 aboutToAppear() {28 aboutToAppear() {
29 Log.showInfo(TAG, `aboutToAppear Start`)29 Log.showInfo(TAG, `aboutToAppear Start`)
@@ -39,7 +39,7 @@ export default struct Control {
39 ControlCenterComponent({39 ControlCenterComponent({
40 mControlCenterComponentConfig: ControlCenterConfig,40 mControlCenterComponentConfig: ControlCenterConfig,
41 mSimpleToggleColumnCount: Constants.DEFAULT_SIMPLE_TOGGLE_COLUMN_COUNT,41 mSimpleToggleColumnCount: Constants.DEFAULT_SIMPLE_TOGGLE_COLUMN_COUNT,
42- modeChangeCallback: (isEdit) => this.modeChangeCallback(isEdit),42+ modeChangeCallback: (isEdit: boolean): void => this.modeChangeCallback(isEdit),
43 titleDisplayInside: true,43 titleDisplayInside: true,
44 moduleName: 'pc_controlpanel',44 moduleName: 'pc_controlpanel',
45 })45 })
@@ -22,19 +22,24 @@ import ControlCenterComponent from './control'
22import WindowManager, {22import WindowManager, {
23 WindowType,23 WindowType,
24 WINDOW_SHOW_HIDE_EVENT,24 WINDOW_SHOW_HIDE_EVENT,
25+ ArgsInfo,
25} from "../../../../../../../common/src/main/ets/default/WindowManager";26} from "../../../../../../../common/src/main/ets/default/WindowManager";
26import EventManager, { unsubscribe } from "../../../../../../../common/src/main/ets/default/event/EventManager";27import EventManager, { unsubscribe } from "../../../../../../../common/src/main/ets/default/event/EventManager";
27import { START_ABILITY_EVENT } from "../../../../../../../common/src/main/ets/default/event/EventUtil";28import { START_ABILITY_EVENT } from "../../../../../../../common/src/main/ets/default/event/EventUtil";
28import MultimodalInputManager, {29import MultimodalInputManager, {
29 MultiKeyCode,30 MultiKeyCode,
30} from "../../../../../../../common/src/main/ets/default/MultimodalInputManager";31} from "../../../../../../../common/src/main/ets/default/MultimodalInputManager";
32+import { Rect } from '@ohos/common'
31import display from "@ohos.display"33import display from "@ohos.display"
32 34 
33const TAG = 'ControlPanel-Index'35const TAG = 'ControlPanel-Index'
34const SHOW_EVENT = "showControlCenter";36const SHOW_EVENT = "showControlCenter";
35const HIDE_EVENT = "hideControlCenter";37const HIDE_EVENT = "hideControlCenter";
36 38 
37-let mHeightConfigUtils39+interface DisplayInfo {
40+ width: number;
41+ height: number;
42+}
38 43 
39@Entry44@Entry
40@Component45@Component
@@ -46,25 +51,24 @@ struct Index {
46 @State mWidthSize: number = 0.251 @State mWidthSize: number = 0.2
47 @State mHeightSize: number = 0.252 @State mHeightSize: number = 0.2
48 @State mHeightPx: number = 053 @State mHeightPx: number = 0
54+ @State mHeightConfigUtils: HeightConfigUtils | undefined = undefined;
49 mClearCallbacks: Array<unsubscribe> = [];55 mClearCallbacks: Array<unsubscribe> = [];
50 mShowAnimReady: boolean = false;56 mShowAnimReady: boolean = false;
51 57 
52 aboutToAppear() {58 aboutToAppear() {
53 Log.showInfo(TAG, `aboutToAppear, start`)59 Log.showInfo(TAG, `aboutToAppear, start`)
54 60 
55- setAppBgColor('#00000000')
56 CommonStyleManager.setAbilityPageName(TAG)61 CommonStyleManager.setAbilityPageName(TAG)
57 this.style = StyleConfiguration.getIndexStyle()62 this.style = StyleConfiguration.getIndexStyle()
58 StyleManager.setStyle()63 StyleManager.setStyle()
59 64 
60- let rect = AbilityManager.getAbilityData(AbilityManager.ABILITY_NAME_CONTROL_PANEL, 'rect')65+ let rect: Rect = AbilityManager.getAbilityData(AbilityManager.ABILITY_NAME_CONTROL_PANEL, 'rect')
61 this.mHeightPx = rect.height66 this.mHeightPx = rect.height
62 67 
63- mHeightConfigUtils = new HeightConfigUtils();68+ this.mHeightConfigUtils = new HeightConfigUtils();
64- let StatusCoefficient;
65 69 
66- StatusCoefficient = AppStorage.SetAndLink("StatusCoefficient", 1.0);70+ let StatusCoefficient = AppStorage.SetAndLink("StatusCoefficient", 1.0);
67- StatusCoefficient.set(mHeightConfigUtils.getStatusCoefficient());71+ StatusCoefficient.set(this.mHeightConfigUtils.getStatusCoefficient());
68 72 
69 this.initWindowPolicy();73 this.initWindowPolicy();
70 Log.showDebug(TAG, `aboutToAppear, end`)74 Log.showDebug(TAG, `aboutToAppear, end`)
@@ -94,7 +98,7 @@ struct Index {
94 Scroll(new Scroller()) {98 Scroll(new Scroller()) {
95 Column() {99 Column() {
96 ControlCenterComponent({100 ControlCenterComponent({
97- modeChangeCallback: (isEdit) => this.onModeChange(isEdit)101+ modeChangeCallback: (isEdit: boolean): void => this.onModeChange(isEdit)
98 })102 })
99 }103 }
100 .width('100%')104 .width('100%')
@@ -132,14 +136,16 @@ struct Index {
132 EventManager.subscribe(SHOW_EVENT, () => this.showWindow()),136 EventManager.subscribe(SHOW_EVENT, () => this.showWindow()),
133 EventManager.subscribe(HIDE_EVENT, () => this.hideWindow()),137 EventManager.subscribe(HIDE_EVENT, () => this.hideWindow()),
134 EventManager.subscribe(START_ABILITY_EVENT, () => this.hideWindow()),138 EventManager.subscribe(START_ABILITY_EVENT, () => this.hideWindow()),
135- EventManager.subscribe(WINDOW_SHOW_HIDE_EVENT, (args) => {139+ EventManager.subscribe(WINDOW_SHOW_HIDE_EVENT, (args: ArgsInfo) => {
136- let { windowName, isShow } = args;140+ let windowName = args.windowName;
141+ let isShow = args?.isShow;
137 Log.showInfo(TAG, `WINDOW_SHOW_HIDE_EVENT windowName: ${windowName}, isShow: ${isShow}`);142 Log.showInfo(TAG, `WINDOW_SHOW_HIDE_EVENT windowName: ${windowName}, isShow: ${isShow}`);
138 windowName == WindowType.NOTIFICATION_PANEL && isShow && this.hideWindow();143 windowName == WindowType.NOTIFICATION_PANEL && isShow && this.hideWindow();
139 windowName == WindowType.CONTROL_PANEL && isShow && (this.mShowAnimReady = true);144 windowName == WindowType.CONTROL_PANEL && isShow && (this.mShowAnimReady = true);
140 }),145 }),
141- EventManager.subscribe('ControlWindowResizeEvent',async (args) => {146+ EventManager.subscribe('ControlWindowResizeEvent',async (args: ArgsInfo) => {
142- let { windowName, rect } = args;147+ let windowName = args.windowName;
148+ let rect = args?.rect;
143 let dis = await display.getDefaultDisplaySync();149 let dis = await display.getDefaultDisplaySync();
144 Log.showInfo(TAG, `ControlWindowResizeEvent: ${windowName}, isShow: ${rect}`);150 Log.showInfo(TAG, `ControlWindowResizeEvent: ${windowName}, isShow: ${rect}`);
145 AbilityManager.setAbilityData(AbilityManager.ABILITY_NAME_CONTROL_PANEL, 'rect', rect);151 AbilityManager.setAbilityData(AbilityManager.ABILITY_NAME_CONTROL_PANEL, 'rect', rect);
@@ -149,7 +155,7 @@ struct Index {
149 });155 });
150 WindowManager.resetSizeWindow(windowName, rect).then(156 WindowManager.resetSizeWindow(windowName, rect).then(
151 ).then(() => {157 ).then(() => {
152- }).catch((err) => {158+ }).catch((err: Error) => {
153 });159 });
154 }),160 }),
155 MultimodalInputManager.subscribeCombinationKey([MultiKeyCode.WIN, MultiKeyCode.I], (data) => {161 MultimodalInputManager.subscribeCombinationKey([MultiKeyCode.WIN, MultiKeyCode.I], (data) => {
@@ -164,9 +170,9 @@ struct Index {
164 );170 );
165 }171 }
166 172 
167- _animateTo(config, callback) {173+ _animateTo(config: AnimateParam, callback: () => void) {
168 animateTo(config, callback)174 animateTo(config, callback)
169- setTimeout(config.onFinish, config.duration + config.delay)175+ setTimeout(config.onFinish, config.duration as number + Number(config.delay))
170 }176 }
171 177 
172 showAnimation(){178 showAnimation(){
@@ -219,13 +225,13 @@ struct Index {
219 this.showAnimation();225 this.showAnimation();
220 }226 }
221 227 
222- onModeChange(isEdit) {228+ onModeChange(isEdit: boolean): void {
223 Log.showDebug(TAG, `onModeChange, isEdit: ${isEdit}`)229 Log.showDebug(TAG, `onModeChange, isEdit: ${isEdit}`)
224- let initRect = AbilityManager.getAbilityData(AbilityManager.ABILITY_NAME_CONTROL_PANEL, 'rect')230+ let initRect = AbilityManager.getAbilityData(AbilityManager.ABILITY_NAME_CONTROL_PANEL, 'rect') as ArgsInfo
225- let newRect = initRect231+ let newRect = initRect as Rect
226 if (isEdit) {232 if (isEdit) {
227- let dis = AbilityManager.getAbilityData(AbilityManager.ABILITY_NAME_CONTROL_PANEL, 'dis')233+ let dis = AbilityManager.getAbilityData(AbilityManager.ABILITY_NAME_CONTROL_PANEL, 'dis') as DisplayInfo
228- newRect = { ...initRect, height: StyleManager.calcScaleSize(346) }234+ newRect.height = StyleManager.calcScaleSize(346)
229 }235 }
230 Log.showDebug(TAG, `onModeChange, newRect: ${JSON.stringify(newRect)}`)236 Log.showDebug(TAG, `onModeChange, newRect: ${JSON.stringify(newRect)}`)
231 this._animateTo({237 this._animateTo({
@@ -237,13 +243,13 @@ struct Index {
237 playMode: PlayMode.Normal,243 playMode: PlayMode.Normal,
238 onFinish: () => {244 onFinish: () => {
239 Log.showInfo(TAG, `onModeChange, show anim finish.`)245 Log.showInfo(TAG, `onModeChange, show anim finish.`)
240- if (newRect.height <= initRect.height) {246+ if (initRect.height && newRect.height <= initRect.height) {
241 WindowManager.resetSizeWindow(WindowType.CONTROL_PANEL, newRect)247 WindowManager.resetSizeWindow(WindowType.CONTROL_PANEL, newRect)
242 }248 }
243 }249 }
244 }, () => {250 }, () => {
245 Log.showInfo(TAG, `onModeChange, animateTo`)251 Log.showInfo(TAG, `onModeChange, animateTo`)
246- if (newRect.height > initRect.height) {252+ if (initRect.height && newRect.height > initRect.height) {
247 WindowManager.resetSizeWindow(WindowType.CONTROL_PANEL, newRect)253 WindowManager.resetSizeWindow(WindowType.CONTROL_PANEL, newRect)
248 }254 }
249 this.mHeightPx = newRect.height255 this.mHeightPx = newRect.height
@@ -4,6 +4,7 @@
4 "description": "",4 "description": "",
5 "version": "1.0.0",5 "version": "1.0.0",
6 "dependencies": {6 "dependencies": {
7- "@ohos/noticeitem": "file:../../../features/noticeitem"7+ "@ohos/noticeitem": "file:../../../features/noticeitem",
8+ "@ohos/common": "file:../../../common"
8 }9 }
9}10}
@@ -14,17 +14,17 @@
14 */14 */
15 15 
16import Log from '../../../../../../../common/src/main/ets/default/Log';16import Log from '../../../../../../../common/src/main/ets/default/Log';
17-import {notificationData} from '../../../../../../../common/src/main/ets/plugindatasource/common/Constants'
18import AbilityManager from '../../../../../../../common/src/main/ets/default/abilitymanager/abilityManager';17import AbilityManager from '../../../../../../../common/src/main/ets/default/abilitymanager/abilityManager';
19import WindowManager, { WindowType } from '../../../../../../../common/src/main/ets/default/WindowManager';18import WindowManager, { WindowType } from '../../../../../../../common/src/main/ets/default/WindowManager';
20import EventManager, {unsubscribe} from "../../../../../../../common/src/main/ets/default/event/EventManager";19import EventManager, {unsubscribe} from "../../../../../../../common/src/main/ets/default/event/EventManager";
21import BannerNotification from '../../../../../../../features/noticeitem/src/main/ets/com/ohos/noticeItem/view/item/bannerNotificationItem';20import BannerNotification from '../../../../../../../features/noticeitem/src/main/ets/com/ohos/noticeItem/view/item/bannerNotificationItem';
22import NotificationViewModel from '../../../../../../../features/noticeitem/src/main/ets/com/ohos/noticeItem/viewmodel/NotificationViewModel';21import NotificationViewModel from '../../../../../../../features/noticeitem/src/main/ets/com/ohos/noticeItem/viewmodel/NotificationViewModel';
23import NotificationConstants, { ScreenLockStatus } from '../../../../../../../features/noticeitem/src/main/ets/com/ohos/noticeItem/common/constants';22import NotificationConstants, { ScreenLockStatus } from '../../../../../../../features/noticeitem/src/main/ets/com/ohos/noticeItem/common/constants';
23+import { NotificationItemData, Rect } from '@ohos/common';
24 24 
25const TAG = 'NotificationPanel-BannerNotification';25const TAG = 'NotificationPanel-BannerNotification';
26const TRANSLATE_SIZE = '382vp';26const TRANSLATE_SIZE = '382vp';
27-const ANIM_CONFIG = {27+const ANIM_CONFIG: AnimateParam = {
28 duration: 250,28 duration: 250,
29 tempo: 1.0,29 tempo: 1.0,
30 curve: Curve.Friction,30 curve: Curve.Friction,
@@ -32,7 +32,7 @@ const ANIM_CONFIG = {
32 iterations: 1,32 iterations: 1,
33 playMode: PlayMode.Normal,33 playMode: PlayMode.Normal,
34}34}
35-const OPACITY_SHOW_ANIM_CONFIG = {35+const OPACITY_SHOW_ANIM_CONFIG: AnimateParam = {
36 duration: 200,36 duration: 200,
37 tempo: 1.0,37 tempo: 1.0,
38 curve: Curve.Friction,38 curve: Curve.Friction,
@@ -40,7 +40,7 @@ const OPACITY_SHOW_ANIM_CONFIG = {
40 iterations: 1,40 iterations: 1,
41 playMode: PlayMode.Normal,41 playMode: PlayMode.Normal,
42}42}
43-const OPACITY_HIDE_ANIM_CONFIG = {43+const OPACITY_HIDE_ANIM_CONFIG: AnimateParam = {
44 duration: 200,44 duration: 200,
45 tempo: 1.0,45 tempo: 1.0,
46 curve: Curve.Friction,46 curve: Curve.Friction,
@@ -57,18 +57,22 @@ struct Index {
57 @State mLastActionTime: number = 0;57 @State mLastActionTime: number = 0;
58 @State needExpand: boolean = true58 @State needExpand: boolean = true
59 @State isExpand: boolean = false;59 @State isExpand: boolean = false;
60- @State pageData: notificationData = new notificationData();60+ @State pageData: NotificationItemData | undefined = undefined;
61 @State mOpacity: number = 0.0;61 @State mOpacity: number = 0.0;
62 @State mWidthSize: number = 0.8;62 @State mWidthSize: number = 0.8;
63 @State mTranslate: string = TRANSLATE_SIZE;63 @State mTranslate: string = TRANSLATE_SIZE;
64 64 
65- mClearCallbacks: unsubscribe[]65+ mClearCallbacks: unsubscribe[] = []
66- mDefaultBannerRect: any;66+ mDefaultBannerRect: Rect = {
67+ left: 0,
68+ top: 0,
69+ width: 0,
70+ height: 0
71+ };
67 72 
68 aboutToAppear() {73 aboutToAppear() {
69 Log.showInfo(TAG, `aboutToAppear Start`);74 Log.showInfo(TAG, `aboutToAppear Start`);
70 AbilityManager.setContextName(AbilityManager.ABILITY_NAME_NOTIFICATION_PANEL, AbilityManager.ABILITY_NAME_NOTIFICATION_PANEL);75 AbilityManager.setContextName(AbilityManager.ABILITY_NAME_NOTIFICATION_PANEL, AbilityManager.ABILITY_NAME_NOTIFICATION_PANEL);
71- setAppBgColor('#00000000')
72 this.mClearCallbacks = []76 this.mClearCallbacks = []
73 this.mClearCallbacks.push(EventManager.subscribe('onBannerNoticeShow', () => this.onBannerNoticeShow()))77 this.mClearCallbacks.push(EventManager.subscribe('onBannerNoticeShow', () => this.onBannerNoticeShow()))
74 this.mClearCallbacks.push(EventManager.subscribe('onBannerNoticeHide', () => this.onBannerNoticeHide()))78 this.mClearCallbacks.push(EventManager.subscribe('onBannerNoticeHide', () => this.onBannerNoticeHide()))
@@ -77,11 +81,11 @@ struct Index {
77 81 
78 aboutToDisappear() {82 aboutToDisappear() {
79 Log.showInfo(TAG, `aboutToDisAppear`)83 Log.showInfo(TAG, `aboutToDisAppear`)
80- this.mClearCallbacks.forEach((mClearCallback: Function) => {84+ this.mClearCallbacks.forEach((mClearCallback: Function | null) => {
81- mClearCallback()85+ mClearCallback&&mClearCallback();
82- mClearCallback = undefined86+ mClearCallback = null
83 })87 })
84- this.mClearCallbacks = undefined88+ this.mClearCallbacks = []
85 }89 }
86 90 
87 build() {91 build() {
@@ -95,7 +99,7 @@ struct Index {
95 mBannerNoticeCnt: $mBannerNoticeCnt,99 mBannerNoticeCnt: $mBannerNoticeCnt,
96 needExpand: $needExpand,100 needExpand: $needExpand,
97 isExpand: $isExpand,101 isExpand: $isExpand,
98- onBannerNoticeHide: () => this.onBannerNoticeHide()102+ onBannerNoticeHide: ():void => this.onBannerNoticeHide()
99 })103 })
100 } else {104 } else {
101 Blank()105 Blank()
@@ -149,7 +153,7 @@ struct Index {
149 }153 }
150 154 
151 checkItemNeedExpand() {155 checkItemNeedExpand() {
152- if (this.pageData.contentType === NotificationConstants.NOTIFICATION_TYPE_BASIC156+ if (this.pageData?.contentType === NotificationConstants.NOTIFICATION_TYPE_BASIC
153 && (!(this.pageData.actionButtons?.length > 0))) {157 && (!(this.pageData.actionButtons?.length > 0))) {
154 return false;158 return false;
155 } else {159 } else {
@@ -157,41 +161,42 @@ struct Index {
157 }161 }
158 }162 }
159 163 
160- _animateTo(config, callback) {164+ _animateTo(config: AnimateParam, callback: () => void) {
161 animateTo(config, callback);165 animateTo(config, callback);
162- setTimeout(config.onFinish, config.duration + config.delay);166+ setTimeout(config.onFinish, Number(config.duration) + Number(config.delay));
163 }167 }
164 168 
165 showWindowAnim() {169 showWindowAnim() {
166 Log.showDebug(TAG, `show anim start`);170 Log.showDebug(TAG, `show anim start`);
167- this._animateTo({ ...ANIM_CONFIG, onFinish: () => {171+ ANIM_CONFIG.onFinish = () => {
168 Log.showInfo(TAG, `show anim finish`);172 Log.showInfo(TAG, `show anim finish`);
169- } }, () => {173+ };
174+ this._animateTo(ANIM_CONFIG, () => {
170 Log.showInfo(TAG, `do show anim`);175 Log.showInfo(TAG, `do show anim`);
171 this.mWidthSize = 1.0;176 this.mWidthSize = 1.0;
172 this.mTranslate = '0vp';177 this.mTranslate = '0vp';
173 });178 });
174- this._animateTo({ ...OPACITY_SHOW_ANIM_CONFIG, onFinish: () => {179+ OPACITY_SHOW_ANIM_CONFIG.onFinish = () => {}
175- } }, () => {180+ this._animateTo(OPACITY_SHOW_ANIM_CONFIG, () => {
176 this.mOpacity = 1.0;181 this.mOpacity = 1.0;
177 });182 });
178 }183 }
179 184 
180 hideWindowAnim() {185 hideWindowAnim() {
181 Log.showDebug(TAG, `hide anim start`);186 Log.showDebug(TAG, `hide anim start`);
182- this._animateTo({ ...ANIM_CONFIG, onFinish: () => {187+ ANIM_CONFIG.onFinish = () => {
183 Log.showInfo(TAG, `hide anim finish`);188 Log.showInfo(TAG, `hide anim finish`);
184 this.mBannerNoticeCnt = 0;189 this.mBannerNoticeCnt = 0;
185 WindowManager.resetSizeWindow(WindowType.BANNER_NOTICE, this.mDefaultBannerRect);190 WindowManager.resetSizeWindow(WindowType.BANNER_NOTICE, this.mDefaultBannerRect);
186 WindowManager.hideWindow(WindowType.BANNER_NOTICE);191 WindowManager.hideWindow(WindowType.BANNER_NOTICE);
187- }192+ };
188- }, () => {193+ this._animateTo(ANIM_CONFIG, () => {
189 Log.showInfo(TAG, `do hide anim`);194 Log.showInfo(TAG, `do hide anim`);
190 this.mWidthSize = 0.8;195 this.mWidthSize = 0.8;
191 this.mTranslate = TRANSLATE_SIZE;196 this.mTranslate = TRANSLATE_SIZE;
192 });197 });
193- this._animateTo({ ...OPACITY_HIDE_ANIM_CONFIG, onFinish: () => {}198+ OPACITY_HIDE_ANIM_CONFIG.onFinish = () => {};
194- }, () => {199+ this._animateTo(OPACITY_HIDE_ANIM_CONFIG, () => {
195 this.mOpacity = 0.0;200 this.mOpacity = 0.0;
196 });201 });
197 }202 }
@@ -20,6 +20,7 @@ import Notification from './notification'
20import WindowManager, {20import WindowManager, {
21 WindowType,21 WindowType,
22 WINDOW_SHOW_HIDE_EVENT,22 WINDOW_SHOW_HIDE_EVENT,
23+ ArgsInfo,
23} from "../../../../../../../common/src/main/ets/default/WindowManager";24} from "../../../../../../../common/src/main/ets/default/WindowManager";
24import EventManager, {unsubscribe} from "../../../../../../../common/src/main/ets/default/event/EventManager";25import EventManager, {unsubscribe} from "../../../../../../../common/src/main/ets/default/event/EventManager";
25import {START_ABILITY_EVENT} from "../../../../../../../common/src/main/ets/default/event/EventUtil";26import {START_ABILITY_EVENT} from "../../../../../../../common/src/main/ets/default/event/EventUtil";
@@ -44,7 +45,6 @@ struct Index {
44 45 
45 aboutToAppear() {46 aboutToAppear() {
46 Log.showInfo(TAG, `aboutToAppear, start`)47 Log.showInfo(TAG, `aboutToAppear, start`)
47- setAppBgColor('#00000000')
48 this.initWindowPolicy();48 this.initWindowPolicy();
49 }49 }
50 50 
@@ -100,14 +100,16 @@ struct Index {
100 EventManager.subscribe(SHOW_EVENT, () => this.showWindow()),100 EventManager.subscribe(SHOW_EVENT, () => this.showWindow()),
101 EventManager.subscribe(HIDE_EVENT, () => this.hideWindow()),101 EventManager.subscribe(HIDE_EVENT, () => this.hideWindow()),
102 EventManager.subscribe(START_ABILITY_EVENT, () => this.hideWindow()),102 EventManager.subscribe(START_ABILITY_EVENT, () => this.hideWindow()),
103- EventManager.subscribe(WINDOW_SHOW_HIDE_EVENT, (args) => {103+ EventManager.subscribe(WINDOW_SHOW_HIDE_EVENT, (args: ArgsInfo) => {
104- let { windowName, isShow } = args;104+ let windowName = args.windowName;
105+ let isShow = args?.isShow;
105 Log.showInfo(TAG, `WINDOW_SHOW_HIDE_EVENT windowName: ${windowName}, isShow: ${isShow}`);106 Log.showInfo(TAG, `WINDOW_SHOW_HIDE_EVENT windowName: ${windowName}, isShow: ${isShow}`);
106 windowName == WindowType.CONTROL_PANEL && isShow && this.hideWindow();107 windowName == WindowType.CONTROL_PANEL && isShow && this.hideWindow();
107 windowName == WindowType.NOTIFICATION_PANEL && isShow && (this.mShowAnimReady = true);108 windowName == WindowType.NOTIFICATION_PANEL && isShow && (this.mShowAnimReady = true);
108 }),109 }),
109- EventManager.subscribe('NotificationWindowResizeEvent',async (args) => {110+ EventManager.subscribe('NotificationWindowResizeEvent',async (args: ArgsInfo) => {
110- let { windowName, rect } = args;111+ let windowName = args.windowName;
112+ let rect = args?.rect;
111 let dis = await display.getDefaultDisplaySync();113 let dis = await display.getDefaultDisplaySync();
112 Log.showInfo(TAG, `NotificationWindowResizeEvent: ${windowName}, isShow: ${rect}`);114 Log.showInfo(TAG, `NotificationWindowResizeEvent: ${windowName}, isShow: ${rect}`);
113 AbilityManager.setAbilityData(AbilityManager.ABILITY_NAME_NOTIFICATION_PANEL, 'rect', rect);115 AbilityManager.setAbilityData(AbilityManager.ABILITY_NAME_NOTIFICATION_PANEL, 'rect', rect);
@@ -117,7 +119,7 @@ struct Index {
117 });119 });
118 WindowManager.resetSizeWindow(windowName, rect).then(120 WindowManager.resetSizeWindow(windowName, rect).then(
119 ).then(() => {121 ).then(() => {
120- }).catch((err) => {122+ }).catch((error: Error) => {
121 });123 });
122 }),124 }),
123 MultimodalInputManager.subscribeCombinationKey([MultiKeyCode.WIN, MultiKeyCode.N], (data) => {125 MultimodalInputManager.subscribeCombinationKey([MultiKeyCode.WIN, MultiKeyCode.N], (data) => {
@@ -132,9 +134,9 @@ struct Index {
132 );134 );
133 }135 }
134 136 
135- _animateTo(config, callback) {137+ _animateTo(config: AnimateParam, callback: () => void) {
136 animateTo(config, callback)138 animateTo(config, callback)
137- setTimeout(config.onFinish, config.duration + config.delay)139+ setTimeout(config.onFinish, Number(config.duration) + Number(config.delay))
138 }140 }
139 141 
140 showAnimation(){142 showAnimation(){
@@ -19,6 +19,7 @@ import EventManager from "../../../../../../../common/src/main/ets/default/event
19import {obtainStartAbility} from "../../../../../../../common/src/main/ets/default/event/EventUtil"19import {obtainStartAbility} from "../../../../../../../common/src/main/ets/default/event/EventUtil"
20import NotificationListComponent from '../../../../../../../features/noticeitem/src/main/ets/com/ohos/noticeItem/view/NotificationListComponent'20import NotificationListComponent from '../../../../../../../features/noticeitem/src/main/ets/com/ohos/noticeItem/view/NotificationListComponent'
21import NotificationViewModel from '../../../../../../../features/noticeitem/src/main/ets/com/ohos/noticeItem/viewmodel/NotificationViewModel'21import NotificationViewModel from '../../../../../../../features/noticeitem/src/main/ets/com/ohos/noticeItem/viewmodel/NotificationViewModel'
22+import { NotificationItemData } from '@ohos/common'
22 23 
23const TAG = 'NotificationPanel-notification'24const TAG = 'NotificationPanel-notification'
24const NO_NOTIFICATION_TOP_MARGIN = 40;25const NO_NOTIFICATION_TOP_MARGIN = 40;
@@ -32,7 +33,7 @@ const NOTIFICATION_TITLE_ICON_MARGIN = 24;
32 33 
33@Component34@Component
34export default struct Notification {35export default struct Notification {
35- @StorageLink('notificationList') notificationList: any[] = []36+ @StorageLink('notificationList') notificationList: NotificationItemData[][] = []
36 @State isEnd: boolean = false37 @State isEnd: boolean = false
37 38 
38 aboutToAppear() {39 aboutToAppear() {
@@ -13,6 +13,7 @@
13 "@ohos/batterycomponent": "file:../../../features/batterycomponent",13 "@ohos/batterycomponent": "file:../../../features/batterycomponent",
14 "@ohos/ringmodecomponent": "file:../../../features/ringmodecomponent",14 "@ohos/ringmodecomponent": "file:../../../features/ringmodecomponent",
15 "@ohos/capsulecomponent": "file:../../../features/capsulecomponent",15 "@ohos/capsulecomponent": "file:../../../features/capsulecomponent",
16- "@ohos/airplanecomponent": "file:../../../features/airplanecomponent"16+ "@ohos/airplanecomponent": "file:../../../features/airplanecomponent",
17+ "@ohos/common": "file:../../../common"
17 }18 }
18}19}
@@ -22,16 +22,16 @@ import StatusbarConfig from './common/StatusbarConfig'
22import AbilityManager from '../../../../../../../common/src/main/ets/default/abilitymanager/abilityManager'22import AbilityManager from '../../../../../../../common/src/main/ets/default/abilitymanager/abilityManager'
23import StatusBarVM from '../../../../../../../features/statusbarcomponent/src/main/ets/com/ohos/viewmodel/StatusBarVM'23import StatusBarVM from '../../../../../../../features/statusbarcomponent/src/main/ets/com/ohos/viewmodel/StatusBarVM'
24import {StatusBarData} from '../../../../../../../features/statusbarcomponent/src/main/ets/com/ohos/common/Constants'24import {StatusBarData} from '../../../../../../../features/statusbarcomponent/src/main/ets/com/ohos/common/Constants'
25+import { ConfigInfo } from '@ohos/common';
25 26 
26const TAG = 'StatusBar-Index'27const TAG = 'StatusBar-Index'
27 28 
28-let mHeightConfigUtils;
29- 
30@Entry29@Entry
31@Component30@Component
32struct Index {31struct Index {
33 @StorageLink('StatusMinH') StatusMinH: number = 2432 @StorageLink('StatusMinH') StatusMinH: number = 24
34 @StorageLink('StatusCoefficient') StatusCoefficient: number = 1.033 @StorageLink('StatusCoefficient') StatusCoefficient: number = 1.0
34+ private mHeightConfigUtils: HeightConfigUtils = new HeightConfigUtils
35 35 
36 onBackPress(): boolean {36 onBackPress(): boolean {
37 return true;37 return true;
@@ -40,30 +40,24 @@ struct Index {
40 aboutToAppear() {40 aboutToAppear() {
41 Log.showInfo(TAG, `aboutToAppear, start`);41 Log.showInfo(TAG, `aboutToAppear, start`);
42 42 
43- let configInfo = AbilityManager.getAbilityData(AbilityManager.ABILITY_NAME_STATUS_BAR, 'config')43+ let configInfo = AbilityManager.getAbilityData(AbilityManager.ABILITY_NAME_STATUS_BAR, 'config') as ConfigInfo
44 let statusBarData: StatusBarData = new StatusBarData();44 let statusBarData: StatusBarData = new StatusBarData();
45 statusBarData.displayWidth = configInfo.maxWidth;45 statusBarData.displayWidth = configInfo.maxWidth;
46 statusBarData.displayHeight = configInfo.maxHeight;46 statusBarData.displayHeight = configInfo.maxHeight;
47 statusBarData.showHorizontal = configInfo.showHorizontal;47 statusBarData.showHorizontal = configInfo.showHorizontal;
48- statusBarData.ableToMaximize = configInfo.ableToMaximize;48+ statusBarData.ableToMaximize = configInfo.ableToMaximize as boolean;
49 statusBarData.realWidth = configInfo.realWidth;49 statusBarData.realWidth = configInfo.realWidth;
50 statusBarData.realHeight = configInfo.realHeight;50 statusBarData.realHeight = configInfo.realHeight;
51 statusBarData.left = configInfo.xCoordinate;51 statusBarData.left = configInfo.xCoordinate;
52 statusBarData.top = configInfo.yCoordinate;52 statusBarData.top = configInfo.yCoordinate;
53 StatusBarVM.updateStatusBarData(statusBarData);53 StatusBarVM.updateStatusBarData(statusBarData);
54- 
55- setAppBgColor('#00000000');
56 CommonStyleManager.setAbilityPageName(TAG);54 CommonStyleManager.setAbilityPageName(TAG);
57 StyleManager.setStyle();55 StyleManager.setStyle();
58 56 
59- mHeightConfigUtils = new HeightConfigUtils();57+ let StatusMinH = AppStorage.SetAndLink("StatusMinH", 24);
60- let StatusMinH;58+ let StatusCoefficient = AppStorage.SetAndLink("StatusCoefficient", 1.0);
61- let StatusCoefficient;59+ StatusMinH.set(this.mHeightConfigUtils.getStatusMinH());
62- 60+ StatusCoefficient.set(this.mHeightConfigUtils.getStatusCoefficient());
63- StatusMinH = AppStorage.SetAndLink("StatusMinH", 24);
64- StatusCoefficient = AppStorage.SetAndLink("StatusCoefficient", 1.0);
65- StatusMinH.set(mHeightConfigUtils.getStatusMinH());
66- StatusCoefficient.set(mHeightConfigUtils.getStatusCoefficient());
67 61 
68 let signalObserved = AppStorage.SetAndLink("signalObserved", false);62 let signalObserved = AppStorage.SetAndLink("signalObserved", false);
69 signalObserved.set(false);63 signalObserved.set(false);
@@ -15,6 +15,7 @@
15 "@ohos/ringmodecomponent": "file:../../../features/ringmodecomponent",15 "@ohos/ringmodecomponent": "file:../../../features/ringmodecomponent",
16 "@ohos/autorotatecomponent": "file:../../../features/autorotatecomponent",16 "@ohos/autorotatecomponent": "file:../../../features/autorotatecomponent",
17 "@ohos/noticeitem": "file:../../../features/noticeitem",17 "@ohos/noticeitem": "file:../../../features/noticeitem",
18- "@ohos/airplanecomponent": "file:../../../features/airplanecomponent"18+ "@ohos/airplanecomponent": "file:../../../features/airplanecomponent",
19+ "@ohos/common": "file:../../../common"
19 }20 }
20}21}
@@ -19,7 +19,7 @@ import Log from '../../../../../../../common/src/main/ets/default/Log';
19import WindowManager, { WindowType } from '../../../../../../../common/src/main/ets/default/WindowManager';19import WindowManager, { WindowType } from '../../../../../../../common/src/main/ets/default/WindowManager';
20import AbilityManager from '../../../../../../../common/src/main/ets/default/abilitymanager/abilityManager';20import AbilityManager from '../../../../../../../common/src/main/ets/default/abilitymanager/abilityManager';
21import NavBarConfiguration from '../../../../../../../features/navigationservice/src/main/ets/com/ohos/navigationservice/common/NavBarConfiguration';21import NavBarConfiguration from '../../../../../../../features/navigationservice/src/main/ets/com/ohos/navigationservice/common/NavBarConfiguration';
22-import { Want } from 'ability/want';22+import { Want } from '@kit.AbilityKit';
23 23 
24 24 
25const TAG = 'DropdownPanel_ServiceExtAbility';25const TAG = 'DropdownPanel_ServiceExtAbility';
@@ -14,17 +14,18 @@
14 */14 */
15 15 
16import Log from '../../../../../../../common/src/main/ets/default/Log';16import Log from '../../../../../../../common/src/main/ets/default/Log';
17-import {notificationData} from '../../../../../../../common/src/main/ets/plugindatasource/common/Constants'17+import { NotificationItemData } from '../../../../../../../common/src/main/ets/plugindatasource/common/Constants'
18import AbilityManager from '../../../../../../../common/src/main/ets/default/abilitymanager/abilityManager';18import AbilityManager from '../../../../../../../common/src/main/ets/default/abilitymanager/abilityManager';
19import WindowManager, { WindowType } from '../../../../../../../common/src/main/ets/default/WindowManager';19import WindowManager, { WindowType } from '../../../../../../../common/src/main/ets/default/WindowManager';
20import EventManager, {unsubscribe} from "../../../../../../../common/src/main/ets/default/event/EventManager";20import EventManager, {unsubscribe} from "../../../../../../../common/src/main/ets/default/event/EventManager";
21import BannerNotification from '../../../../../../../features/noticeitem/src/main/ets/com/ohos/noticeItem/view/item/bannerNotificationItem';21import BannerNotification from '../../../../../../../features/noticeitem/src/main/ets/com/ohos/noticeItem/view/item/bannerNotificationItem';
22import NotificationViewModel from '../../../../../../../features/noticeitem/src/main/ets/com/ohos/noticeItem/viewmodel/NotificationViewModel';22import NotificationViewModel from '../../../../../../../features/noticeitem/src/main/ets/com/ohos/noticeItem/viewmodel/NotificationViewModel';
23import NotificationConstants, { ScreenLockStatus } from '../../../../../../../features/noticeitem/src/main/ets/com/ohos/noticeItem/common/constants';23import NotificationConstants, { ScreenLockStatus } from '../../../../../../../features/noticeitem/src/main/ets/com/ohos/noticeItem/common/constants';
24+import { Rect } from '@ohos/common';
24 25 
25const TAG = 'DropdownPanel-BannerNotification';26const TAG = 'DropdownPanel-BannerNotification';
26const TRANSLATE_SIZE = '382vp';27const TRANSLATE_SIZE = '382vp';
27-const ANIM_CONFIG = {28+const ANIM_CONFIG: AnimateParam = {
28 duration: 250,29 duration: 250,
29 tempo: 1.0,30 tempo: 1.0,
30 curve: Curve.Friction,31 curve: Curve.Friction,
@@ -32,7 +33,7 @@ const ANIM_CONFIG = {
32 iterations: 1,33 iterations: 1,
33 playMode: PlayMode.Normal,34 playMode: PlayMode.Normal,
34}35}
35-const OPACITY_SHOW_ANIM_CONFIG = {36+const OPACITY_SHOW_ANIM_CONFIG: AnimateParam = {
36 duration: 200,37 duration: 200,
37 tempo: 1.0,38 tempo: 1.0,
38 curve: Curve.Friction,39 curve: Curve.Friction,
@@ -40,7 +41,7 @@ const OPACITY_SHOW_ANIM_CONFIG = {
40 iterations: 1,41 iterations: 1,
41 playMode: PlayMode.Normal,42 playMode: PlayMode.Normal,
42}43}
43-const OPACITY_HIDE_ANIM_CONFIG = {44+const OPACITY_HIDE_ANIM_CONFIG: AnimateParam = {
44 duration: 200,45 duration: 200,
45 tempo: 1.0,46 tempo: 1.0,
46 curve: Curve.Friction,47 curve: Curve.Friction,
@@ -57,13 +58,18 @@ struct Index {
57 @State mLastActionTime: number = 0;58 @State mLastActionTime: number = 0;
58 @State needExpand: boolean = true59 @State needExpand: boolean = true
59 @State isExpand: boolean = false;60 @State isExpand: boolean = false;
60- @State pageData: notificationData = new notificationData();61+ @State pageData: NotificationItemData | undefined = undefined;
61 @State mOpacity: number = 0.0;62 @State mOpacity: number = 0.0;
62 @State mWidthSize: number = 0.8;63 @State mWidthSize: number = 0.8;
63 @State mTranslate: string = TRANSLATE_SIZE;64 @State mTranslate: string = TRANSLATE_SIZE;
64 65 
65- mClearCallbacks: unsubscribe[]66+ mClearCallbacks: unsubscribe[] = [];
66- mDefaultBannerRect: any;67+ mDefaultBannerRect: Rect = {
68+ left: 0,
69+ top: 0,
70+ width: 0,
71+ height: 0
72+ };
67 73 
68 aboutToAppear() {74 aboutToAppear() {
69 Log.showInfo(TAG, `aboutToAppear Start`);75 Log.showInfo(TAG, `aboutToAppear Start`);
@@ -77,11 +83,11 @@ struct Index {
77 83 
78 aboutToDisappear() {84 aboutToDisappear() {
79 Log.showInfo(TAG, `aboutToDisAppear`)85 Log.showInfo(TAG, `aboutToDisAppear`)
80- this.mClearCallbacks.forEach((mClearCallback: Function) => {86+ this.mClearCallbacks.forEach((mClearCallback: Function | undefined) => {
81- mClearCallback()87+ mClearCallback&&mClearCallback()
82 mClearCallback = undefined88 mClearCallback = undefined
83 })89 })
84- this.mClearCallbacks = undefined90+ this.mClearCallbacks = []
85 }91 }
86 92 
87 build() {93 build() {
@@ -95,7 +101,7 @@ struct Index {
95 mBannerNoticeCnt: $mBannerNoticeCnt,101 mBannerNoticeCnt: $mBannerNoticeCnt,
96 needExpand: $needExpand,102 needExpand: $needExpand,
97 isExpand: $isExpand,103 isExpand: $isExpand,
98- onBannerNoticeHide: () => this.onBannerNoticeHide()104+ onBannerNoticeHide: (): void => this.onBannerNoticeHide()
99 })105 })
100 } else {106 } else {
101 Blank()107 Blank()
@@ -149,7 +155,7 @@ struct Index {
149 }155 }
150 156 
151 checkItemNeedExpand() {157 checkItemNeedExpand() {
152- if (this.pageData.contentType === NotificationConstants.NOTIFICATION_TYPE_BASIC158+ if (this.pageData?.contentType === NotificationConstants.NOTIFICATION_TYPE_BASIC
153 && (!(this.pageData.actionButtons?.length > 0))) {159 && (!(this.pageData.actionButtons?.length > 0))) {
154 return false;160 return false;
155 } else {161 } else {
@@ -157,41 +163,42 @@ struct Index {
157 }163 }
158 }164 }
159 165 
160- _animateTo(config, callback) {166+ _animateTo(config: AnimateParam, callback: () => void) {
161 animateTo(config, callback);167 animateTo(config, callback);
162- setTimeout(config.onFinish, config.duration + config.delay);168+ setTimeout(config.onFinish, Number(config.duration) + Number(config.delay));
163 }169 }
164 170 
165 showWindowAnim() {171 showWindowAnim() {
166 Log.showDebug(TAG, `show anim start`);172 Log.showDebug(TAG, `show anim start`);
167- this._animateTo({ ...ANIM_CONFIG, onFinish: () => {173+ ANIM_CONFIG.onFinish = () => {
168 Log.showInfo(TAG, `show anim finish`);174 Log.showInfo(TAG, `show anim finish`);
169- } }, () => {175+ };
176+ this._animateTo(ANIM_CONFIG, () => {
170 Log.showInfo(TAG, `do show anim`);177 Log.showInfo(TAG, `do show anim`);
171 this.mWidthSize = 1.0;178 this.mWidthSize = 1.0;
172 this.mTranslate = '0vp';179 this.mTranslate = '0vp';
173 });180 });
174- this._animateTo({ ...OPACITY_SHOW_ANIM_CONFIG, onFinish: () => {181+ OPACITY_SHOW_ANIM_CONFIG.onFinish = () => {}
175- } }, () => {182+ this._animateTo(OPACITY_SHOW_ANIM_CONFIG, () => {
176 this.mOpacity = 1.0;183 this.mOpacity = 1.0;
177 });184 });
178 }185 }
179 186 
180 hideWindowAnim() {187 hideWindowAnim() {
181 Log.showDebug(TAG, `hide anim start`);188 Log.showDebug(TAG, `hide anim start`);
182- this._animateTo({ ...ANIM_CONFIG, onFinish: () => {189+ ANIM_CONFIG.onFinish = () => {
183 Log.showInfo(TAG, `hide anim finish`);190 Log.showInfo(TAG, `hide anim finish`);
184 this.mBannerNoticeCnt = 0;191 this.mBannerNoticeCnt = 0;
185 WindowManager.resetSizeWindow(WindowType.BANNER_NOTICE, this.mDefaultBannerRect);192 WindowManager.resetSizeWindow(WindowType.BANNER_NOTICE, this.mDefaultBannerRect);
186 WindowManager.hideWindow(WindowType.BANNER_NOTICE);193 WindowManager.hideWindow(WindowType.BANNER_NOTICE);
187- }194+ };
188- }, () => {195+ this._animateTo(ANIM_CONFIG, () => {
189 Log.showInfo(TAG, `do hide anim`);196 Log.showInfo(TAG, `do hide anim`);
190 this.mWidthSize = 0.8;197 this.mWidthSize = 0.8;
191 this.mTranslate = TRANSLATE_SIZE;198 this.mTranslate = TRANSLATE_SIZE;
192 });199 });
193- this._animateTo({ ...OPACITY_HIDE_ANIM_CONFIG, onFinish: () => {}200+ OPACITY_HIDE_ANIM_CONFIG.onFinish = () => {};
194- }, () => {201+ this._animateTo(OPACITY_HIDE_ANIM_CONFIG, () => {
195 this.mOpacity = 0.0;202 this.mOpacity = 0.0;
196 });203 });
197 }204 }
@@ -15,6 +15,7 @@
15 15 
16import commonEvent from '@ohos.commonEvent';16import commonEvent from '@ohos.commonEvent';
17import Log from '../../../../../../../../common/src/main/ets/default/Log';17import Log from '../../../../../../../../common/src/main/ets/default/Log';
18+import { inputConsumer } from '@kit.InputKit';
18 19 
19const TAG = 'navigationEvent';20const TAG = 'navigationEvent';
20 21 
@@ -24,8 +25,14 @@ let commonEventSubscribeInfo = {
24 25 
25let commonEventSubscriber = null;26let commonEventSubscriber = null;
26 27 
28+export interface NavigationCallBack {
29+ "onStateChange": (data: string) => void;
30+ "onNotificationShowOrHide": (data: inputConsumer.KeyOptions) => void;
31+ "onControlShowOrHide": (data: inputConsumer.KeyOptions) => void;
32+}
33+ 
27export class navigationEvent {34export class navigationEvent {
28- mCallback: any;35+ mCallback: NavigationCallBack;
29 36 
30 registerCallback(callback): void {37 registerCallback(callback): void {
31 Log.showDebug(TAG, 'registerCallback');38 Log.showDebug(TAG, 'registerCallback');
@@ -29,12 +29,13 @@ import Log from '../../../../../../../common/src/main/ets/default/Log'
29import Constants from './common/constants'29import Constants from './common/constants'
30import StyleConfiguration, { ControlStyle } from './common/StyleConfiguration'30import StyleConfiguration, { ControlStyle } from './common/StyleConfiguration'
31import ControlCenterConfig from './common/ControlCenterConfig';31import ControlCenterConfig from './common/ControlCenterConfig';
32+import { TouchMoveData } from '@ohos/common';
32 33 
33const TAG = 'DropdownPanel-Control';34const TAG = 'DropdownPanel-Control';
34 35 
35@Component36@Component
36export default struct Control {37export default struct Control {
37- private touchMoveCallback: Function38+ private touchMoveCallback: Function = () => {}
38 startX: number = 039 startX: number = 0
39 startY: number = 040 startY: number = 0
40 @State moveX: number = 041 @State moveX: number = 0
@@ -53,7 +54,7 @@ export default struct Control {
53 build() {54 build() {
54 Column() {55 Column() {
55 Column() {56 Column() {
56- statusBar({ touchMoveCallback: (data) => this.touchMoveCallback(data) })57+ statusBar({ touchMoveCallback: (data: TouchMoveData): void => this.touchMoveCallback(data) })
57 }58 }
58 .width('100%')59 .width('100%')
59 .height(this.style.statusBarHeight)60 .height(this.style.statusBarHeight)
@@ -68,7 +69,7 @@ export default struct Control {
68 Scroll(new Scroller()) {69 Scroll(new Scroller()) {
69 Column() {70 Column() {
70 ControlCenterComponent({71 ControlCenterComponent({
71- touchMoveCallback: (data) => this.controlCenterTouchMoveCallback(data),72+ touchMoveCallback: (data: TouchMoveData): void => this.controlCenterTouchMoveCallback(data),
72 mControlCenterComponentConfig: ControlCenterConfig,73 mControlCenterComponentConfig: ControlCenterConfig,
73 moduleName: 'phone_dropdownpanel',74 moduleName: 'phone_dropdownpanel',
74 })75 })
@@ -104,9 +105,9 @@ export default struct Control {
104 }105 }
105 }106 }
106 107 
107- controlCenterTouchMoveCallback(data) {108+ controlCenterTouchMoveCallback(data: TouchMoveData) {
108 Log.showDebug(TAG, `controlCenterTouchMoveCallback data: ${JSON.stringify(data)}`)109 Log.showDebug(TAG, `controlCenterTouchMoveCallback data: ${JSON.stringify(data)}`)
109- data['touchComponent'] = 'control'110+ data.touchComponent = 'control'
110 if (this.touchMoveCallback) {111 if (this.touchMoveCallback) {
111 this.touchMoveCallback(data)112 this.touchMoveCallback(data)
112 }113 }
@@ -116,7 +117,7 @@ export default struct Control {
116@Component117@Component
117struct statusBar {118struct statusBar {
118 @StorageLink('StatusCoefficient') StatusCoefficient: number = 1.0119 @StorageLink('StatusCoefficient') StatusCoefficient: number = 1.0
119- private touchMoveCallback: Function120+ private touchMoveCallback: Function = () => {}
120 startX: number = 0121 startX: number = 0
121 startY: number = 0122 startY: number = 0
122 @State moveX: number = 0123 @State moveX: number = 0
@@ -1,4 +1,3 @@
1-//@ts-nocheck
2/*1/*
3 * Copyright (c) 2021-2022 Huawei Device Co., Ltd.2 * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");3 * Licensed under the Apache License, Version 2.0 (the "License");
@@ -32,22 +31,28 @@ import EventManager, { unsubscribe } from "../../../../../../../common/src/main/
32import { START_ABILITY_EVENT } from "../../../../../../../common/src/main/ets/default/event/EventUtil"31import { START_ABILITY_EVENT } from "../../../../../../../common/src/main/ets/default/event/EventUtil"
33import CommonStyleManager from '../../../../../../../common/src/main/ets/default/CommonStyleManager'32import CommonStyleManager from '../../../../../../../common/src/main/ets/default/CommonStyleManager'
34import MultimodalInputManager from '../../../../../../../common/src/main/ets/default/MultimodalInputManager'33import MultimodalInputManager from '../../../../../../../common/src/main/ets/default/MultimodalInputManager'
35-import AbilityManager from '../../../../../../../common/src/main/ets/default/abilitymanager/abilityManager'
36import HeightConfigUtils from '../../../../../../../common/src/main/ets/default/heightcofigUtils/HeightConfigUtils'34import HeightConfigUtils from '../../../../../../../common/src/main/ets/default/heightcofigUtils/HeightConfigUtils'
37import StatusBarVM from '../../../../../../../features/statusbarcomponent/src/main/ets/com/ohos/viewmodel/StatusBarVM'35import StatusBarVM from '../../../../../../../features/statusbarcomponent/src/main/ets/com/ohos/viewmodel/StatusBarVM'
38-import NavigationEvent from './common/navigationEvent'36+import NavigationEvent, { NavigationCallBack } from './common/navigationEvent'
39import Notification from './notification'37import Notification from './notification'
40import ControlCenterComponent from './control'38import ControlCenterComponent from './control'
41import StyleManager from './common/StyleManager'39import StyleManager from './common/StyleManager'
42import dataShare from '@ohos.data.dataShare';40import dataShare from '@ohos.data.dataShare';
43import settings from '@ohos.settings';41import settings from '@ohos.settings';
44import Constants from "../../../../../../../common/src/main/ets/default/Constants";42import Constants from "../../../../../../../common/src/main/ets/default/Constants";
43+import { TouchMoveData, Rect, ConfigInfo } from '@ohos/common';
44+import { Context } from '@kit.AbilityKit';
45+import { inputConsumer } from '@kit.InputKit';
45 46 
46const TAG = 'DropdownPanel-Index'47const TAG = 'DropdownPanel-Index'
47 48 
48-let mHeightConfigUtils49+interface IArg {
50+ dropdownArea?: string
51+}
49 52 
50-const SHOW_ANIM_CONFIG = {53+let mHeightConfigUtils: HeightConfigUtils
54+ 
55+const SHOW_ANIM_CONFIG: AnimateParam = {
51 duration: 300,56 duration: 300,
52 tempo: 1.0,57 tempo: 1.0,
53 curve: Curve.Friction,58 curve: Curve.Friction,
@@ -55,20 +60,6 @@ const SHOW_ANIM_CONFIG = {
55 iterations: 1,60 iterations: 1,
56 playMode: PlayMode.Normal61 playMode: PlayMode.Normal
57};62};
58-const HIDE_ANIM_CONFIG = {
59- duration: 200,
60- tempo: 1.0,
61- curve: Curve.EaseOut,
62- delay: 0,
63- iterations: 1,
64- playMode: PlayMode.Normal,
65-}
66- 
67-class insertTemplate{
68- type: TransitionType;
69- opacity: number;
70- scale: Object
71-}
72 63 
73enum DropdownPanelComponentName {64enum DropdownPanelComponentName {
74 NONE = 'None',65 NONE = 'None',
@@ -82,19 +73,19 @@ struct Index {
82 @State showComponentName: DropdownPanelComponentName = DropdownPanelComponentName.NONE;73 @State showComponentName: DropdownPanelComponentName = DropdownPanelComponentName.NONE;
83 @State componentOptAreaHeightPX: number = 0;74 @State componentOptAreaHeightPX: number = 0;
84 @StorageLink('StatusCoefficient') StatusCoefficient: number = 1.0;75 @StorageLink('StatusCoefficient') StatusCoefficient: number = 1.0;
85- mCallback: any;76+ private mCallback?: NavigationCallBack;
86- mClearCallbacks: unsubscribe[];77+ private mClearCallbacks?: unsubscribe[];
87 settingDataKey = 'settings.display.navigationbar_status';78 settingDataKey = 'settings.display.navigationbar_status';
88- urivar: string = null;79+ private urivar?: string;
89- helper: dataShare.DataShareHelper = null;80+ private helper?: dataShare.DataShareHelper;
90 mNavigationBarStatusDefaultValue: string = '1';81 mNavigationBarStatusDefaultValue: string = '1';
91 navigationBarWidth: number = 0;82 navigationBarWidth: number = 0;
92 mNeedUpdate: boolean = false;83 mNeedUpdate: boolean = false;
93- mWidthPx: number = 0;84+ @State mWidthPx: number = 0;
94- @State mNotificationInsert: insertTemplate = new insertTemplate();85+ @State mNotificationInsert: TransitionOptions = {};
95- @State mNotificationDelete: insertTemplate = new insertTemplate();86+ @State mNotificationDelete: TransitionOptions = {};
96- @State mControlCenterInsert: insertTemplate = new insertTemplate();87+ @State mControlCenterInsert: TransitionOptions = {};
97- @State mControlCenterDelete: insertTemplate = new insertTemplate();88+ @State mControlCenterDelete: TransitionOptions = {};
98 @State componentOptAreaTranslateY: string = '0px';89 @State componentOptAreaTranslateY: string = '0px';
99 @State backgroundOpacity: number = 0;90 @State backgroundOpacity: number = 0;
100 91 
@@ -108,8 +99,8 @@ struct Index {
108 CommonStyleManager.setAbilityPageName(TAG);99 CommonStyleManager.setAbilityPageName(TAG);
109 StyleManager.setStyle();100 StyleManager.setStyle();
110 101 
111- let dropdownRect = AbilityManager.getAbilityData(AbilityManager.ABILITY_NAME_DROPDOWN_PANEL, 'rect');102+ let dropdownRect: Rect = AbilityManager.getAbilityData(AbilityManager.ABILITY_NAME_DROPDOWN_PANEL, 'rect');
112- let navigationBarRect = AbilityManager.getAbilityData(AbilityManager.ABILITY_NAME_NAVIGATION_BAR, 'config');103+ let navigationBarRect: ConfigInfo = AbilityManager.getAbilityData(AbilityManager.ABILITY_NAME_NAVIGATION_BAR, 'config');
113 this.initHelper(dropdownRect, navigationBarRect);104 this.initHelper(dropdownRect, navigationBarRect);
114 this.resizeDropdownPanelAndNavigationBar(dropdownRect, navigationBarRect);105 this.resizeDropdownPanelAndNavigationBar(dropdownRect, navigationBarRect);
115 Log.showDebug(TAG, `getValueSync componentOptAreaHeightPX: ${this.componentOptAreaHeightPX}`);106 Log.showDebug(TAG, `getValueSync componentOptAreaHeightPX: ${this.componentOptAreaHeightPX}`);
@@ -118,14 +109,13 @@ struct Index {
118 109 
119 this.mClearCallbacks = [];110 this.mClearCallbacks = [];
120 this.mClearCallbacks.push(111 this.mClearCallbacks.push(
121- EventManager.subscribe('DropdownEvent', (args) => this.onDropdownEvent(args)),112+ EventManager.subscribe('DropdownEvent', (args: IArg) => this.onDropdownEvent(args)),
122- EventManager.subscribe(START_ABILITY_EVENT, (args) => this.onStartAbility(args)),113+ EventManager.subscribe(START_ABILITY_EVENT, (args: IArg) => this.onStartAbility(args)),
123- EventManager.subscribe('hideNotificationWindowEvent', (args) => this.onHideNotificationWindowEvent(args)));114+ EventManager.subscribe('hideNotificationWindowEvent', (args: IArg) => this.onHideNotificationWindowEvent(args)));
124 115 
125 mHeightConfigUtils = new HeightConfigUtils();116 mHeightConfigUtils = new HeightConfigUtils();
126- let StatusCoefficient;
127 117 
128- StatusCoefficient = AppStorage.SetAndLink("StatusCoefficient", 1.0);118+ let StatusCoefficient = AppStorage.SetAndLink("StatusCoefficient", 1.0);
129 StatusCoefficient.set(mHeightConfigUtils.getStatusCoefficient());119 StatusCoefficient.set(mHeightConfigUtils.getStatusCoefficient());
130 120 
131 let signalObserved = AppStorage.SetAndLink("signalObserved", false);121 let signalObserved = AppStorage.SetAndLink("signalObserved", false);
@@ -142,7 +132,7 @@ struct Index {
142 Log.showDebug(TAG, `aboutToAppear, end`);132 Log.showDebug(TAG, `aboutToAppear, end`);
143 }133 }
144 134 
145- private async initHelper(dropdownRect, navigationBarRect): Promise<void> {135+ private async initHelper(dropdownRect: Rect, navigationBarRect: ConfigInfo): Promise<void> {
146 this.urivar = Constants.getUriSync(Constants.KEY_NAVIGATIONBAR_STATUS);136 this.urivar = Constants.getUriSync(Constants.KEY_NAVIGATIONBAR_STATUS);
147 this.helper = await dataShare.createDataShareHelper(AbilityManager.getContext(AbilityManager.ABILITY_NAME_DROPDOWN_PANEL), this.urivar);137 this.helper = await dataShare.createDataShareHelper(AbilityManager.getContext(AbilityManager.ABILITY_NAME_DROPDOWN_PANEL), this.urivar);
148 Log.showDebug(TAG, `initHelper ${this.helper}, uri: ${JSON.stringify(this.urivar)}`);138 Log.showDebug(TAG, `initHelper ${this.helper}, uri: ${JSON.stringify(this.urivar)}`);
@@ -163,16 +153,16 @@ struct Index {
163 153 
164 aboutToDisappear() {154 aboutToDisappear() {
165 Log.showInfo(TAG, `aboutToDisappear`)155 Log.showInfo(TAG, `aboutToDisappear`)
166- this.mClearCallbacks.forEach((mClearCallback: Function) => {156+ this.mClearCallbacks&&this.mClearCallbacks.forEach((mClearCallback: Function | undefined) => {
167- mClearCallback()157+ mClearCallback&&mClearCallback()
168 mClearCallback = undefined158 mClearCallback = undefined
169 })159 })
170 this.mClearCallbacks = undefined160 this.mClearCallbacks = undefined
171 }161 }
172 162 
173- resizeDropdownPanelAndNavigationBar(dropdownRect, navigationBarRect) {163+ resizeDropdownPanelAndNavigationBar(dropdownRect: Rect, navigationBarRect: ConfigInfo) {
174 Log.showDebug(TAG, `resizeDropdownPanelAndNavigationBar, dropdownRect: ${JSON.stringify(dropdownRect)} navigationBarRect: ${JSON.stringify(navigationBarRect)}`)164 Log.showDebug(TAG, `resizeDropdownPanelAndNavigationBar, dropdownRect: ${JSON.stringify(dropdownRect)} navigationBarRect: ${JSON.stringify(navigationBarRect)}`)
175- let context = AbilityManager.getContext(AbilityManager.ABILITY_NAME_DROPDOWN_PANEL);165+ let context: Context = AbilityManager.getContext(AbilityManager.ABILITY_NAME_DROPDOWN_PANEL);
176 if (context == undefined || context == null) {166 if (context == undefined || context == null) {
177 Log.showInfo(TAG, `resizeDropdownPanelAndNavigationBar: ${context}`);167 Log.showInfo(TAG, `resizeDropdownPanelAndNavigationBar: ${context}`);
178 return;168 return;
@@ -180,37 +170,44 @@ struct Index {
180 try {170 try {
181 this.mNavigationBarStatusDefaultValue = settings.getValueSync(context, this.settingDataKey, '1');171 this.mNavigationBarStatusDefaultValue = settings.getValueSync(context, this.settingDataKey, '1');
182 this.componentOptAreaHeightPX = this.mNavigationBarStatusDefaultValue == '1' ? dropdownRect.height - navigationBarRect.realHeight : dropdownRect.height;172 this.componentOptAreaHeightPX = this.mNavigationBarStatusDefaultValue == '1' ? dropdownRect.height - navigationBarRect.realHeight : dropdownRect.height;
183- this.navigationBarWidth = this.mNavigationBarStatusDefaultValue == '1' ? navigationBarRect.height : 0;173+ this.navigationBarWidth = this.mNavigationBarStatusDefaultValue == '1' ? navigationBarRect.realHeight : 0;
184 } catch (err) {174 } catch (err) {
185 Log.showError(TAG, `resizeDropdownPanelAndNavigationBar: ${context}, ${JSON.stringify(err)}`);175 Log.showError(TAG, `resizeDropdownPanelAndNavigationBar: ${context}, ${JSON.stringify(err)}`);
186 }176 }
187- WindowManager.resetSizeWindow(WindowType.NAVIGATION_BAR, { ...navigationBarRect, height: this.navigationBarWidth })177+ const currRect: Rect = {
188- WindowManager.resetSizeWindow(WindowType.DROPDOWN_PANEL, { ...dropdownRect, height: this.componentOptAreaHeightPX })178+ left: 0,
179+ top: 0,
180+ width: 0,
181+ height: this.navigationBarWidth
182+ };
183+ dropdownRect.height = this.componentOptAreaHeightPX;
184+ WindowManager.resetSizeWindow(WindowType.NAVIGATION_BAR, currRect);
185+ WindowManager.resetSizeWindow(WindowType.DROPDOWN_PANEL, dropdownRect );
189 }186 }
190 187 
191- onNotificationShowOrHide(data) {188+ onNotificationShowOrHide(data: inputConsumer.KeyOptions) {
192 Log.showDebug(TAG, `mNotificationAsyncCallback preKeys: ${data.preKeys}, finalKey: ${data.finalKey}`);189 Log.showDebug(TAG, `mNotificationAsyncCallback preKeys: ${data.preKeys}, finalKey: ${data.finalKey}`);
193 Log.showDebug(TAG, `this.showComponentName: ${this.showComponentName}`);190 Log.showDebug(TAG, `this.showComponentName: ${this.showComponentName}`);
194 if (this.showComponentName === DropdownPanelComponentName.NOTIFICATION) {191 if (this.showComponentName === DropdownPanelComponentName.NOTIFICATION) {
195 this.hideSelf();192 this.hideSelf();
196 } else {193 } else {
197- this.showSelf('Notification');194+ this.showSelf(DropdownPanelComponentName.NOTIFICATION);
198 }195 }
199 Log.showDebug(TAG, `mNotificationAsyncCallback end`);196 Log.showDebug(TAG, `mNotificationAsyncCallback end`);
200 }197 }
201 198 
202- onControlShowOrHide(data) {199+ onControlShowOrHide(data: inputConsumer.KeyOptions) {
203 Log.showDebug(TAG, `mControlAsyncCallback preKeys: ${data.preKeys}, finalKey: ${data.finalKey}`);200 Log.showDebug(TAG, `mControlAsyncCallback preKeys: ${data.preKeys}, finalKey: ${data.finalKey}`);
204 Log.showDebug(TAG, `this.showComponentName: ${this.showComponentName}`);201 Log.showDebug(TAG, `this.showComponentName: ${this.showComponentName}`);
205 if (this.showComponentName === DropdownPanelComponentName.CONTROL_CENTER) {202 if (this.showComponentName === DropdownPanelComponentName.CONTROL_CENTER) {
206 this.hideSelf();203 this.hideSelf();
207 } else {204 } else {
208- this.showSelf('ControlCenter');205+ this.showSelf(DropdownPanelComponentName.CONTROL_CENTER);
209 }206 }
210 Log.showDebug(TAG, `mControlAsyncCallback end`);207 Log.showDebug(TAG, `mControlAsyncCallback end`);
211 }208 }
212 209 
213- onStateChange(data) {210+ onStateChange(data: string) {
214 Log.showDebug(TAG, `onStateChange, data: ${JSON.stringify(data)}`)211 Log.showDebug(TAG, `onStateChange, data: ${JSON.stringify(data)}`)
215 Log.showDebug(TAG, `onStateChange, showComponentName: ${this.showComponentName}`)212 Log.showDebug(TAG, `onStateChange, showComponentName: ${this.showComponentName}`)
216 if (this.showComponentName !== DropdownPanelComponentName.NONE) {213 if (this.showComponentName !== DropdownPanelComponentName.NONE) {
@@ -218,29 +215,29 @@ struct Index {
218 }215 }
219 }216 }
220 217 
221- onDropdownEvent(args) {218+ onDropdownEvent(args: IArg) {
222 Log.showDebug(TAG, `onDropdownEvent, args: ${JSON.stringify(args)}`)219 Log.showDebug(TAG, `onDropdownEvent, args: ${JSON.stringify(args)}`)
223- this.showSelf(args.dropdownArea == 'left' ? 'Notification' : 'ControlCenter')220+ this.showSelf(args.dropdownArea == 'left' ? DropdownPanelComponentName.NOTIFICATION : DropdownPanelComponentName.CONTROL_CENTER)
224 }221 }
225 222 
226- onStartAbility(args) {223+ onStartAbility(args: IArg) {
227 Log.showDebug(TAG, `onStartAbility, args: ${args}`)224 Log.showDebug(TAG, `onStartAbility, args: ${args}`)
228 this.hideSelf()225 this.hideSelf()
229 }226 }
230 227 
231- onHideNotificationWindowEvent(args) {228+ onHideNotificationWindowEvent(args: IArg) {
232 Log.showDebug(TAG, `onHideNotificationWindowEvent, args: ${args}`)229 Log.showDebug(TAG, `onHideNotificationWindowEvent, args: ${args}`)
233 this.hideSelf()230 this.hideSelf()
234 }231 }
235 232 
236- onTouchMove(data) {233+ onTouchMove(data: TouchMoveData) {
237 Log.showDebug(TAG, `onTouchMove, data: ${JSON.stringify(data)}`)234 Log.showDebug(TAG, `onTouchMove, data: ${JSON.stringify(data)}`)
238 if (data.direction == 'top') {235 if (data.direction == 'top') {
239 this.hideSelf()236 this.hideSelf()
240 } else if (data.direction == 'left' && data.touchComponent == 'notification') {237 } else if (data.direction == 'left' && data.touchComponent == 'notification') {
241- this.switchNotificationOrControlCenter('ControlCenter')238+ this.switchNotificationOrControlCenter(DropdownPanelComponentName.CONTROL_CENTER)
242 } else if (data.direction == 'right' && data.touchComponent == 'control') {239 } else if (data.direction == 'right' && data.touchComponent == 'control') {
243- this.switchNotificationOrControlCenter('Notification')240+ this.switchNotificationOrControlCenter(DropdownPanelComponentName.NOTIFICATION)
244 } else if (data.direction == 'drop_left' && data.touchComponent == 'control') {241 } else if (data.direction == 'drop_left' && data.touchComponent == 'control') {
245 this.showComponentName = DropdownPanelComponentName.NOTIFICATION242 this.showComponentName = DropdownPanelComponentName.NOTIFICATION
246 } else if (data.direction == 'drop_right' && data.touchComponent == 'notification') {243 } else if (data.direction == 'drop_right' && data.touchComponent == 'notification') {
@@ -248,25 +245,26 @@ struct Index {
248 }245 }
249 }246 }
250 247 
251- switchNotificationOrControlCenter(showComponentName) {248+ switchNotificationOrControlCenter(showComponentName: DropdownPanelComponentName) {
252 Log.showDebug(TAG, `switchNotificationOrControlCenter, showComponentName: ${showComponentName}`)249 Log.showDebug(TAG, `switchNotificationOrControlCenter, showComponentName: ${showComponentName}`)
253 this.mNotificationInsert = { type: TransitionType.Insert, opacity: 0, translate: { x: (-this.mWidthPx) + 'px' } }250 this.mNotificationInsert = { type: TransitionType.Insert, opacity: 0, translate: { x: (-this.mWidthPx) + 'px' } }
254 this.mControlCenterInsert = { type: TransitionType.Insert, opacity: 0, translate: { x: (this.mWidthPx) + 'px' } }251 this.mControlCenterInsert = { type: TransitionType.Insert, opacity: 0, translate: { x: (this.mWidthPx) + 'px' } }
255- let transitionDelete = {252+ let transitionDelete: TransitionOptions = {
256 type: TransitionType.Delete,253 type: TransitionType.Delete,
257 opacity: 0,254 opacity: 0,
258 scale: { x: 0.8, y: 0.8, centerX: '50%', centerY: '50%' }255 scale: { x: 0.8, y: 0.8, centerX: '50%', centerY: '50%' }
259 }256 }
260 this.mNotificationDelete = transitionDelete257 this.mNotificationDelete = transitionDelete
261 this.mControlCenterDelete = transitionDelete258 this.mControlCenterDelete = transitionDelete
262- this._animateTo({ ...SHOW_ANIM_CONFIG, onFinish: () => {259+ SHOW_ANIM_CONFIG.onFinish = () => {
263 Log.showInfo(TAG, `switchNotificationOrControlCenter, show anim finish.`);260 Log.showInfo(TAG, `switchNotificationOrControlCenter, show anim finish.`);
264- } }, () => {261+ }
262+ this._animateTo(SHOW_ANIM_CONFIG, () => {
265 this.showComponentName = showComponentName263 this.showComponentName = showComponentName
266 })264 })
267 }265 }
268 266 
269- showSelf(showComponentName) {267+ showSelf(showComponentName: DropdownPanelComponentName) {
270 Log.showDebug(TAG, `showSelf, showComponentName: ${showComponentName}`)268 Log.showDebug(TAG, `showSelf, showComponentName: ${showComponentName}`)
271 this.showComponentName = showComponentName269 this.showComponentName = showComponentName
272 WindowManager.showWindow(WindowType.DROPDOWN_PANEL)270 WindowManager.showWindow(WindowType.DROPDOWN_PANEL)
@@ -277,21 +275,23 @@ struct Index {
277 275 
278 hideSelf() {276 hideSelf() {
279 Log.showDebug(TAG, `hideSelf`)277 Log.showDebug(TAG, `hideSelf`)
280- this._animateTo({...SHOW_ANIM_CONFIG, onFinish: () => {278+ SHOW_ANIM_CONFIG.onFinish = () => {
281 Log.showInfo(TAG, `hideSelf, hide anim finish.`);279 Log.showInfo(TAG, `hideSelf, hide anim finish.`);
282- }, finishCallback:()=>{280+ };
283- WindowManager.hideWindow(WindowType.DROPDOWN_PANEL)281+ this._animateTo(SHOW_ANIM_CONFIG, () => {
284- }}, () => {
285 this.componentOptAreaTranslateY = (-this.componentOptAreaHeightPX * 0.1) + 'px'282 this.componentOptAreaTranslateY = (-this.componentOptAreaHeightPX * 0.1) + 'px'
286 this.backgroundOpacity = 0283 this.backgroundOpacity = 0
287 this.showComponentName = DropdownPanelComponentName.NONE284 this.showComponentName = DropdownPanelComponentName.NONE
288- })285+ }, true)
289 }286 }
290 287 
291- _animateTo(config, callback) {288+ _animateTo(config: AnimateParam, callback: () => void, ishideWindow: boolean = false) {
292 Log.showDebug(TAG, `_animateTo, config: ${JSON.stringify(config)}`)289 Log.showDebug(TAG, `_animateTo, config: ${JSON.stringify(config)}`)
293 animateTo(config, callback)290 animateTo(config, callback)
294- setTimeout(config.finishCallback, config.duration + config.delay)291+ if (ishideWindow) {
292+ const delay = Number(config.duration) + Number(config.delay)
293+ setTimeout(() => WindowManager.hideWindow(WindowType.DROPDOWN_PANEL), delay)
294+ }
295 }295 }
296 296 
297 build() {297 build() {
@@ -304,13 +304,13 @@ struct Index {
304 .opacity(1)304 .opacity(1)
305 Column() {305 Column() {
306 if (this.showComponentName === DropdownPanelComponentName.NOTIFICATION) {306 if (this.showComponentName === DropdownPanelComponentName.NOTIFICATION) {
307- Notification({ touchMoveCallback: (data) => this.onTouchMove(data) })307+ Notification({ touchMoveCallback: (data: TouchMoveData): void => this.onTouchMove(data) })
308 .transition(this.mNotificationInsert)308 .transition(this.mNotificationInsert)
309 .transition(this.mNotificationDelete)309 .transition(this.mNotificationDelete)
310 }310 }
311 if (this.showComponentName === DropdownPanelComponentName.CONTROL_CENTER) {311 if (this.showComponentName === DropdownPanelComponentName.CONTROL_CENTER) {
312 ControlCenterComponent({312 ControlCenterComponent({
313- touchMoveCallback: (data) => this.onTouchMove(data)313+ touchMoveCallback: (data: TouchMoveData): void => this.onTouchMove(data)
314 })314 })
315 .transition(this.mControlCenterInsert)315 .transition(this.mControlCenterInsert)
316 .transition(this.mControlCenterDelete)316 .transition(this.mControlCenterDelete)
@@ -34,6 +34,7 @@ import ResourceUtil from '../../../../../../../common/src/main/ets/default/Resou
34import TimeManager, { TimeEventArgs, TIME_CHANGE_EVENT34import TimeManager, { TimeEventArgs, TIME_CHANGE_EVENT
35} from '../../../../../../../common/src/main/ets/default/TimeManager';35} from '../../../../../../../common/src/main/ets/default/TimeManager';
36import deviceInfo from '@ohos.deviceInfo';36import deviceInfo from '@ohos.deviceInfo';
37+import { NotificationItemData, TouchMoveData } from '@ohos/common';
37 38 
38const TAG = 'DropdownPanel-notification';39const TAG = 'DropdownPanel-notification';
39const IMAGE_SIZE_L = 24;40const IMAGE_SIZE_L = 24;
@@ -47,13 +48,13 @@ const deviceTypeInfo = deviceInfo.deviceType;
47 48 
48@Component49@Component
49export default struct Notification {50export default struct Notification {
50- private touchMoveCallback: Function51+ private touchMoveCallback: Function = () => {}
51 startX: number = 052 startX: number = 0
52 startY: number = 053 startY: number = 0
53 @State moveX: number = 054 @State moveX: number = 0
54 @State moveY: number = 055 @State moveY: number = 0
55 @State isEnd: boolean = true56 @State isEnd: boolean = true
56- @StorageLink('notificationList') notificationList: any[] = []57+ @StorageLink('notificationList') notificationList: NotificationItemData[][] = []
57 58 
58 aboutToAppear() {59 aboutToAppear() {
59 Log.showInfo(TAG, `aboutToAppear Start`);60 Log.showInfo(TAG, `aboutToAppear Start`);
@@ -71,9 +72,9 @@ export default struct Notification {
71 72 
72 Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {73 Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
73 Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start, justifyContent: FlexAlign.Start }) {74 Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start, justifyContent: FlexAlign.Start }) {
74- statusBar({ touchMoveCallback: (data) => this.touchMoveCallback(data) })75+ statusBar({ touchMoveCallback: (data: TouchMoveData): void => this.touchMoveCallback(data) })
75 CenterTitle({76 CenterTitle({
76- touchMoveCallback: (data) => this.CenterTitleTouchMoveCallback(data)77+ touchMoveCallback: (data: TouchMoveData):void => this.CenterTitleTouchMoveCallback(data)
77 })78 })
78 if (this.notificationList.length == 0) {79 if (this.notificationList.length == 0) {
79 Text($r("app.string.no_notification"))80 Text($r("app.string.no_notification"))
@@ -137,9 +138,9 @@ export default struct Notification {
137 }138 }
138 }139 }
139 140 
140- CenterTitleTouchMoveCallback(data) {141+ CenterTitleTouchMoveCallback(data: TouchMoveData) {
141 Log.showDebug(TAG, `CenterTitleTouchMoveCallback, data: ${JSON.stringify(data)}`)142 Log.showDebug(TAG, `CenterTitleTouchMoveCallback, data: ${JSON.stringify(data)}`)
142- data['touchComponent'] = 'notification'143+ data.touchComponent = 'notification'
143 if (this.touchMoveCallback) {144 if (this.touchMoveCallback) {
144 this.touchMoveCallback(data)145 this.touchMoveCallback(data)
145 }146 }
@@ -149,7 +150,7 @@ export default struct Notification {
149@Component150@Component
150struct statusBar {151struct statusBar {
151 @StorageLink('StatusCoefficient') StatusCoefficient: number = 1.0152 @StorageLink('StatusCoefficient') StatusCoefficient: number = 1.0
152- private touchMoveCallback: Function153+ private touchMoveCallback: Function = () => {}
153 startX: number = 0154 startX: number = 0
154 startY: number = 0155 startY: number = 0
155 @State moveX: number = 0156 @State moveX: number = 0
@@ -218,11 +219,11 @@ struct statusBar {
218 219 
219@Component220@Component
220struct CenterTitle {221struct CenterTitle {
221- private touchMoveCallback: Function222+ private touchMoveCallback: Function = () => {};
222- startX: number = 0223+ startX: number = 0;
223- startY: number = 0224+ startY: number = 0;
224- @State moveX: number = 0225+ @State moveX: number = 0;
225- @State moveY: number = 0226+ @State moveY: number = 0;
226 @State mTimeString: string = '';227 @State mTimeString: string = '';
227 @State mTime: string = '01:01'228 @State mTime: string = '01:01'
228 unSubscriber?: unsubscribe;229 unSubscriber?: unsubscribe;
@@ -4,6 +4,7 @@
4 "description": "",4 "description": "",
5 "version": "1.0.0",5 "version": "1.0.0",
6 "dependencies": {6 "dependencies": {
7- "@ohos/statusbarcomponent": "file:../../../features/statusbarcomponent"7+ "@ohos/statusbarcomponent": "file:../../../features/statusbarcomponent",
8+ "@ohos/common": "file:../../../common"
8 }9 }
9}10}
@@ -20,7 +20,7 @@ import WindowManager, { WindowType } from '../../../../../../../common/src/main/
20import AbilityManager from '../../../../../../../common/src/main/ets/default/abilitymanager/abilityManager';20import AbilityManager from '../../../../../../../common/src/main/ets/default/abilitymanager/abilityManager';
21import StatusBarConfiguration from '../../../../../../../features/statusbarcomponent/src/main/ets/com/ohos/common/StatusBarConfiguration';21import StatusBarConfiguration from '../../../../../../../features/statusbarcomponent/src/main/ets/com/ohos/common/StatusBarConfiguration';
22import StatusBarConstants from '../../../../../../../features/statusbarcomponent/src/main/ets/com/ohos/common/Constants';22import StatusBarConstants from '../../../../../../../features/statusbarcomponent/src/main/ets/com/ohos/common/Constants';
23-import { Want } from 'ability/want';23+import Want from '@ohos.application.Want';
24import deviceInfo from '@ohos.deviceInfo';24import deviceInfo from '@ohos.deviceInfo';
25 25 
26const TAG = 'StatusBar_ServiceExtAbility';26const TAG = 'StatusBar_ServiceExtAbility';
@@ -15,7 +15,7 @@
15 15 
16import Log from '../../../../../../../common/src/main/ets/default/Log'16import Log from '../../../../../../../common/src/main/ets/default/Log'
17import Trace from '../../../../../../../common/src/main/ets/default/Trace'17import Trace from '../../../../../../../common/src/main/ets/default/Trace'
18-import WindowManager, {WindowType, WINDOW_SHOW_HIDE_EVENT18+import WindowManager, {WindowType, WINDOW_SHOW_HIDE_EVENT, ArgsInfo
19} from '../../../../../../../common/src/main/ets/default/WindowManager'19} from '../../../../../../../common/src/main/ets/default/WindowManager'
20import EventManager, {unsubscribe} from "../../../../../../../common/src/main/ets/default/event/EventManager"20import EventManager, {unsubscribe} from "../../../../../../../common/src/main/ets/default/event/EventManager"
21import {obtainLocalEvent} from "../../../../../../../common/src/main/ets/default/event/EventUtil"21import {obtainLocalEvent} from "../../../../../../../common/src/main/ets/default/event/EventUtil"
@@ -23,16 +23,19 @@ import CommonStyleManager from '../../../../../../../common/src/main/ets/default
23import HeightConfigUtils from '../../../../../../../common/src/main/ets/default/heightcofigUtils/HeightConfigUtils'23import HeightConfigUtils from '../../../../../../../common/src/main/ets/default/heightcofigUtils/HeightConfigUtils'
24import StatusBarComponent from '../../../../../../../features/statusbarcomponent/src/main/ets/com/ohos/pages/StatusBarComponent'24import StatusBarComponent from '../../../../../../../features/statusbarcomponent/src/main/ets/com/ohos/pages/StatusBarComponent'
25import StatusBarVM from '../../../../../../../features/statusbarcomponent/src/main/ets/com/ohos/viewmodel/StatusBarVM'25import StatusBarVM from '../../../../../../../features/statusbarcomponent/src/main/ets/com/ohos/viewmodel/StatusBarVM'
26-import {StatusBarData} from '../../../../../../../features/statusbarcomponent/src/main/ets/com/ohos/common/Constants'26+import { StatusBarData,
27+ DropdownRange
28+} from '../../../../../../../features/statusbarcomponent/src/main/ets/com/ohos/common/Constants'
27import Constants from './common/constants'29import Constants from './common/constants'
28import StyleManager from './common/StyleManager'30import StyleManager from './common/StyleManager'
29import StatusbarConfig from './common/StatusbarConfig'31import StatusbarConfig from './common/StatusbarConfig'
30import AbilityManager from '../../../../../../../common/src/main/ets/default/abilitymanager/abilityManager'32import AbilityManager from '../../../../../../../common/src/main/ets/default/abilitymanager/abilityManager'
33+import { ConfigInfo } from '@ohos/common';
31 34 
32const TAG = 'StatusBar-Index'35const TAG = 'StatusBar-Index'
33const SLIDING_STATUS_BAR_DISTANCE = 1836const SLIDING_STATUS_BAR_DISTANCE = 18
34 37 
35-let mHeightConfigUtils;38+let mHeightConfigUtils = new HeightConfigUtils();
36 39 
37@Entry40@Entry
38@Component41@Component
@@ -45,7 +48,7 @@ struct Index {
45 @StorageLink('StatusMinH') StatusMinH: number = 2448 @StorageLink('StatusMinH') StatusMinH: number = 24
46 @StorageLink('StatusCoefficient') StatusCoefficient: number = 1.049 @StorageLink('StatusCoefficient') StatusCoefficient: number = 1.0
47 mClearCallback: unsubscribe | undefined50 mClearCallback: unsubscribe | undefined
48- dropdownpanelIsOpen:boolean = false51+ dropdownpanelIsOpen:boolean = false
49 onBackPress(): boolean {52 onBackPress(): boolean {
50 return true;53 return true;
51 }54 }
@@ -58,14 +61,11 @@ struct Index {
58 CommonStyleManager.setAbilityPageName(TAG);61 CommonStyleManager.setAbilityPageName(TAG);
59 StyleManager.setStyle();62 StyleManager.setStyle();
60 63 
61- this.mClearCallback = EventManager.subscribe(WINDOW_SHOW_HIDE_EVENT, (args) => this.onWindowShowHideEvent(args));64+ this.mClearCallback = EventManager.subscribe(
62- 65+ WINDOW_SHOW_HIDE_EVENT,
63- mHeightConfigUtils = new HeightConfigUtils();66+ (args: ArgsInfo) => this.onWindowShowHideEvent(args));
64- let StatusMinH;67+ let StatusMinH = AppStorage.SetAndLink("StatusMinH", 24);
65- let StatusCoefficient;68+ let StatusCoefficient = AppStorage.SetAndLink("StatusCoefficient", 1.0);
66- 
67- StatusMinH = AppStorage.SetAndLink("StatusMinH", 24);
68- StatusCoefficient = AppStorage.SetAndLink("StatusCoefficient", 1.0);
69 StatusMinH.set(mHeightConfigUtils.getStatusMinH());69 StatusMinH.set(mHeightConfigUtils.getStatusMinH());
70 StatusCoefficient.set(mHeightConfigUtils.getStatusCoefficient());70 StatusCoefficient.set(mHeightConfigUtils.getStatusCoefficient());
71 71 
@@ -103,12 +103,12 @@ struct Index {
103 }103 }
104 104 
105 updateStatusBarData() {105 updateStatusBarData() {
106- let configInfo = AbilityManager.getAbilityData(AbilityManager.ABILITY_NAME_STATUS_BAR, 'config');106+ let configInfo = AbilityManager.getAbilityData(AbilityManager.ABILITY_NAME_STATUS_BAR, 'config') as ConfigInfo;
107 let statusBarData: StatusBarData = new StatusBarData();107 let statusBarData: StatusBarData = new StatusBarData();
108 statusBarData.displayWidth = configInfo.maxWidth;108 statusBarData.displayWidth = configInfo.maxWidth;
109 statusBarData.displayHeight = configInfo.maxHeight;109 statusBarData.displayHeight = configInfo.maxHeight;
110 statusBarData.showHorizontal = configInfo.showHorizontal;110 statusBarData.showHorizontal = configInfo.showHorizontal;
111- statusBarData.ableToMaximize = configInfo.ableToMaximize;111+ statusBarData.ableToMaximize = configInfo.ableToMaximize??false;
112 statusBarData.realWidth = configInfo.realWidth;112 statusBarData.realWidth = configInfo.realWidth;
113 statusBarData.realHeight = configInfo.realHeight;113 statusBarData.realHeight = configInfo.realHeight;
114 statusBarData.left = configInfo.xCoordinate;114 statusBarData.left = configInfo.xCoordinate;
@@ -146,10 +146,10 @@ struct Index {
146 if (!this.mStatusBarData.showHorizontal || !this.mStatusBarData.ableToMaximize) {146 if (!this.mStatusBarData.showHorizontal || !this.mStatusBarData.ableToMaximize) {
147 return147 return
148 }148 }
149- let dropdownArea: string = null149+ let dropdownArea: string = ''
150- if (this.checkDropdownShowStatus(StatusbarConfig.dropdownRanges.notification)) {150+ if (this.checkDropdownShowStatus(StatusbarConfig.dropdownRanges?.notification as DropdownRange)) {
151 dropdownArea = 'left'151 dropdownArea = 'left'
152- } else if (this.checkDropdownShowStatus(StatusbarConfig.dropdownRanges.control)) {152+ } else if (this.checkDropdownShowStatus(StatusbarConfig.dropdownRanges?.control as DropdownRange)) {
153 dropdownArea = 'right'153 dropdownArea = 'right'
154 }154 }
155 if (dropdownArea) {155 if (dropdownArea) {
@@ -159,13 +159,13 @@ struct Index {
159 }159 }
160 }160 }
161 161 
162- checkDropdownShowStatus(range) {162+ checkDropdownShowStatus(range: DropdownRange) {
163 let rangeStartX = this.mStatusBarData.realWidth * range.startPosition + this.mStatusBarData.left163 let rangeStartX = this.mStatusBarData.realWidth * range.startPosition + this.mStatusBarData.left
164 let rangeEndX = this.mStatusBarData.realWidth * range.endPosition + this.mStatusBarData.left164 let rangeEndX = this.mStatusBarData.realWidth * range.endPosition + this.mStatusBarData.left
165 return (vp2px(this.startX) >= rangeStartX) && (vp2px(this.startX) <= rangeEndX)165 return (vp2px(this.startX) >= rangeStartX) && (vp2px(this.startX) <= rangeEndX)
166 }166 }
167 167 
168- onWindowShowHideEvent(args) {168+ onWindowShowHideEvent(args: ArgsInfo) {
169 Log.showDebug(TAG, `onWindowShowHideEvent, args: ${JSON.stringify(args)}`)169 Log.showDebug(TAG, `onWindowShowHideEvent, args: ${JSON.stringify(args)}`)
170 if (args.windowName == WindowType.DROPDOWN_PANEL) {170 if (args.windowName == WindowType.DROPDOWN_PANEL) {
171 if (args.isShow) {171 if (args.isShow) {