已合并
systemui升级api12,IBINV4稳定性加固 #514
rtggg创建于 2025年3月3日
systemui升级api12,IBINV4稳定性加固 #514
已合并
从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": 9 | 8 | + "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"; |
| 36 | const TIME_FORMAT_KEY = settings.date.TIME_FORMAT; | 36 | const TIME_FORMAT_KEY = settings.date.TIME_FORMAT; |
| 37 | const TIME_SUBSCRIBE_INFO = { | 37 | const 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 | + | ||
| 42 | export const WINDOW_SHOW_HIDE_EVENT = 'WindowShowHideEvent'; | 53 | export const WINDOW_SHOW_HIDE_EVENT = 'WindowShowHideEvent'; |
| 43 | 54 | ||
| 44 | export const WINDOW_RESIZE_EVENT = 'WindowResizeEvent'; | 55 | export const WINDOW_RESIZE_EVENT = 'WindowResizeEvent'; |
| @@ -14,6 +14,11 @@ | |||
| 14 | */ | 14 | */ |
| 15 | 15 | ||
| 16 | import { Event } from '../../default/event/EventUtil'; | 16 | import { 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 | ||
| 18 | export default class Constants { | 23 | export 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 | @Component | 21 | @Component |
| 22 | export default struct SimpleToggleBase { | 22 | export default struct SimpleToggleBase { |
| 23 | - private mToggleId: string | 23 | + private mToggleId: string = '' |
| 24 | @Link mIcon: Resource | 24 | @Link mIcon: Resource |
| 25 | @State mIconStr: string = '' | 25 | @State mIconStr: string = '' |
| 26 | private mUseIconStr: boolean = false | 26 | private mUseIconStr: boolean = false |
| 27 | private mAutoIconColor: boolean = false | 27 | private mAutoIconColor: boolean = false |
| 28 | @Link mChangeSwitch: boolean | 28 | @Link mChangeSwitch: boolean |
| 29 | @Link mLabel: Resource | 29 | @Link mLabel: Resource |
| 30 | - private mLabelStr: string | Resource | 30 | + private mLabelStr: string | Resource = '' |
| 31 | private mUseLabelStr: boolean = false | 31 | private mUseLabelStr: boolean = false |
| 32 | - private mIconOnBG: string | Resource | 32 | + private mIconOnBG: string | Resource = '' |
| 33 | private mEditMode: boolean = false | 33 | private mEditMode: boolean = false |
| 34 | private mDragMode: boolean = false | 34 | private mDragMode: boolean = false |
| 35 | - private mClickEvent: Function | 35 | + private mClickEvent: Function = (): void => {} |
| 36 | - private mLongClickEvent: Function | 36 | + private mLongClickEvent: Function = (): void => {} |
| 37 | @State mIconIsHover: boolean = false | 37 | @State mIconIsHover: boolean = false |
| 38 | @State mTextIsHover: boolean = false | 38 | @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 | @Component | 21 | @Component |
| 22 | export default struct iconComponent { | 22 | export default struct iconComponent { |
| 23 | - @State iconOff: string = "" | 23 | + @State iconOff: Resource | string = "" |
| 24 | - @State iconOn: string = "" | 24 | + @State iconOn: Resource | string = "" |
| 25 | @Prop iconOffStr: string | 25 | @Prop iconOffStr: string |
| 26 | @Prop iconOnStr: string | 26 | @Prop iconOnStr: string |
| 27 | private useIconStr = false | 27 | private useIconStr = false |
| @@ -21,16 +21,16 @@ const TAG = 'iconTitleBase' | |||
| 21 | 21 | ||
| 22 | @Component | 22 | @Component |
| 23 | export default struct iconBaseComponent { | 23 | export default struct iconBaseComponent { |
| 24 | - private iconOn: any | 24 | + @Prop iconOn: Resource |
| 25 | - private iconOff: any | 25 | + @Prop iconOff: Resource |
| 26 | @State iconOffStr: string = "" | 26 | @State iconOffStr: string = "" |
| 27 | @State iconOnStr: string = "" | 27 | @State iconOnStr: string = "" |
| 28 | @Link mTitle: Resource | 28 | @Link mTitle: Resource |
| 29 | @State mTitleStr: string = "" | 29 | @State mTitleStr: string = "" |
| 30 | private useIconStr = false | 30 | private useIconStr = false |
| 31 | private useTitleStr = false | 31 | private useTitleStr = false |
| 32 | - private mClickEvent: Function | 32 | + private mClickEvent: Function = (): void => {} |
| 33 | - private mLongClickEvent: Function | 33 | + private mLongClickEvent: Function = (): void => {} |
| 34 | @State mTextIsHover: boolean = false | 34 | @State mTextIsHover: boolean = false |
| 35 | @Link changeSwitch: boolean | 35 | @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" |
Mfeatures/airplanecomponent/src/main/ets/default/pages/ControlCenterSimpleToggleAirplaneComponent.ets+2-2
| @@ -21,7 +21,7 @@ const TAG = 'airplane-ControlCenterSimpleToggleAirplaneComponent'; | |||
| 21 | 21 | ||
| 22 | @Component | 22 | @Component |
| 23 | export default struct ControlCenterSimpleToggleAirplaneComponent { | 23 | export 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'; | |||
| 23 | export default | 23 | export default |
| 24 | struct airplaneComponent { | 24 | struct 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 | @Component | 23 | @Component |
| 24 | export default struct ControlCenterSimpleToggleAutoRotateComponent { | 24 | export 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 | @Component | 24 | @Component |
| 25 | export default struct ControlCenterComplexToggleBluetoothComponent { | 25 | export 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 | ||
| 21 | const TAG = 'Control-brightnessComponent'; | 21 | const 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:number | 26 | 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.mItemData | 55 | 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'; | |||
| 28 | const TAG_ControlCenterComplexToggleLayout = 'Control-ControlCenterComplexToggleLayout'; | 28 | const TAG_ControlCenterComplexToggleLayout = 'Control-ControlCenterComplexToggleLayout'; |
| 29 | const TAG_ControlCenterSimpleToggleLayout = 'Control-ControlCenterSimpleToggleLayout'; | 29 | const TAG_ControlCenterSimpleToggleLayout = 'Control-ControlCenterSimpleToggleLayout'; |
| 30 | 30 | ||
| 31 | -var mUniform; | 31 | +interface IDirection { |
| 32 | + direction: string | ||
| 33 | +} | ||
| 32 | 34 | ||
| 33 | @Component | 35 | @Component |
| 34 | export default struct ControlCenterComponent { | 36 | export 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.titleDisplayInside | 151 | 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: componentName | 186 | 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: componentName | 243 | 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 | @Component | 24 | @Component |
| 25 | export default struct PluginIconItemComponent { | 25 | export 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.data | 55 | 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 | @Component | 25 | @Component |
| 26 | export default struct SimpleToggleComponent { | 26 | export 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: |
Mfeatures/controlcentercomponent/src/main/ets/com/ohos/pages/SimpleToggleLayoutEditComponent.ets+17-20
| @@ -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.Center | 56 | 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.backDialogController | 89 | + this.backDialogController = null |
| 90 | - this.backDialogController = undefined | 90 | + 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 | @Component | 322 | @Component |
| 326 | struct SimpleToggleLayoutEditUpTitle { | 323 | struct 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 | @CustomDialog | 21 | @CustomDialog |
| 22 | export default struct SimpleToggleLayoutEditDialogComponent { | 22 | export 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 | @Component | 28 | @Component |
| 29 | export default struct SimpleToggleLoadComponent { | 29 | export default struct SimpleToggleLoadComponent { |
| 30 | - private keyId: string | 30 | + private keyId: string = '' |
| 31 | private mEditMode: boolean = false | 31 | private mEditMode: boolean = false |
| 32 | private mDragMode: boolean = false | 32 | private mDragMode: boolean = false |
| 33 | 33 | ||
| @@ -21,10 +21,14 @@ import StyleConfiguration, { ControlCenterUpTitleStyle } from '../common/StyleCo | |||
| 21 | 21 | ||
| 22 | const TAG = 'Control-UpTitle'; | 22 | const TAG = 'Control-UpTitle'; |
| 23 | 23 | ||
| 24 | +interface IDirection { | ||
| 25 | + direction: string | ||
| 26 | +} | ||
| 27 | + | ||
| 24 | @Component | 28 | @Component |
| 25 | export default struct UpTitle { | 29 | export 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 | @Component | 25 | @Component |
| 26 | export default struct ControlCenterSimpleToggleLocationComponent { | 26 | export 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'; | |||
| 16 | import Notification from '@ohos.notification'; | 16 | import Notification from '@ohos.notification'; |
| 17 | import NotificationManager from '@ohos.notificationManager'; | 17 | import NotificationManager from '@ohos.notificationManager'; |
| 18 | import NotificationSubscribe from '@ohos.notificationSubscribe'; | 18 | import NotificationSubscribe from '@ohos.notificationSubscribe'; |
| 19 | -import type { NotificationSubscriber } from 'notification/notificationSubscriber'; | ||
| 20 | 19 | ||
| 21 | const TAG = 'NotificationManagenment-NotificationListener'; | 20 | const 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 | ||
| 37 | export class NotificationListener { | 36 | export 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'; | |||
| 16 | import AppItemComponent from './appItemComponent'; | 16 | import AppItemComponent from './appItemComponent'; |
| 17 | import Router from '@system.router'; | 17 | import Router from '@system.router'; |
| 18 | import Log from '../../../../../../../../../common/src/main/ets/default/Log'; | 18 | import 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 | ||
| 21 | const TAG = 'ManagementComponent-AppLstComponent'; | 22 | const TAG = 'ManagementComponent-AppLstComponent'; |
| 22 | 23 | ||
| 23 | @Component | 24 | @Component |
| 24 | export default struct AppLstComponent { | 25 | export 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'; | |||
| 17 | import SlotItemComponent from './slotItemComponent'; | 17 | import SlotItemComponent from './slotItemComponent'; |
| 18 | import Notification from '@ohos.notification'; | 18 | import Notification from '@ohos.notification'; |
| 19 | import Router from '@system.router' | 19 | import Router from '@system.router' |
| 20 | +import { BundleItemData } from '@ohos/common'; | ||
| 21 | +import NotificationManager from '@ohos.notificationManager'; | ||
| 20 | 22 | ||
| 21 | const TAG = 'ManagementComponent-SlotLstComponent'; | 23 | const TAG = 'ManagementComponent-SlotLstComponent'; |
| 22 | 24 | ||
| 23 | @Component | 25 | @Component |
| 24 | export default struct SlotLstComponent { | 26 | export 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 | */ |
| 15 | import ConfigData from '../../common/constants'; | 15 | import ConfigData from '../../common/constants'; |
| 16 | import Log from '../../../../../../../../../common/src/main/ets/default/Log'; | 16 | import Log from '../../../../../../../../../common/src/main/ets/default/Log'; |
| 17 | +import { IOnEnableChanged } from '../../model/notificationListener'; | ||
| 17 | 18 | ||
| 18 | const TAG = 'ManagementComponent-SwitchComponent'; | 19 | const TAG = 'ManagementComponent-SwitchComponent'; |
| 19 | 20 | ||
| 20 | @Component | 21 | @Component |
| 21 | export default struct SwitchComponent { | 22 | export 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?) => void | 26 | + private settingAction?: (params?: boolean) => void |
| 26 | - private register?: (listener) => void | 27 | + private register?: (listener: IOnEnableChanged) => void |
| 27 | @State initState: boolean = false | 28 | @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 @@ | |||
| 16 | import Log from '../../../../../../../../common/src/main/ets/default/Log'; | 16 | import Log from '../../../../../../../../common/src/main/ets/default/Log'; |
| 17 | import EventManager from "../../../../../../../../common/src/main/ets/default/event/EventManager"; | 17 | import EventManager from "../../../../../../../../common/src/main/ets/default/event/EventManager"; |
| 18 | import { obtainStartAbility } from "../../../../../../../../common/src/main/ets/default/event/EventUtil"; | 18 | import { obtainStartAbility } from "../../../../../../../../common/src/main/ets/default/event/EventUtil"; |
| 19 | -import NfcController from '@ohos.nfc.controller'; | 19 | +import { nfcController } from '@kit.ConnectivityKit'; |
| 20 | import ViewModel from '../viewmodel/NFCModeVM'; | 20 | import ViewModel from '../viewmodel/NFCModeVM'; |
| 21 | import SimpleToggleBase from '../../../../../../../../common/src/main/ets/template/SimpleToggleBase'; | 21 | import SimpleToggleBase from '../../../../../../../../common/src/main/ets/template/SimpleToggleBase'; |
| 22 | 22 | ||
| @@ -24,13 +24,13 @@ const TAG = 'nfcmode-ControlCenterSimpleToggleNFComponent'; | |||
| 24 | 24 | ||
| 25 | @Component | 25 | @Component |
| 26 | export default struct ControlCenterSimpleToggleNFComponent { | 26 | export 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 and | 12 | * 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 | ||
| 16 | export default class Constants { | 19 | export 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 | ||
| 16 | import Log from '../../../../../../../../../common/src/main/ets/default/Log'; | 16 | import Log from '../../../../../../../../../common/src/main/ets/default/Log'; |
| 17 | import deviceManager from '@ohos.distributedDeviceManager'; | 17 | import deviceManager from '@ohos.distributedDeviceManager'; |
| 18 | -import DeviceInfo from '@ohos.deviceInfo'; | ||
| 19 | 18 | ||
| 20 | const TAG = 'NotificationDistributionManager'; | 19 | const 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 | ||
| 16 | import Log from '../../../../../../../../../common/src/main/ets/default/Log'; | 16 | import 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'; |
| 18 | import NotificationItem from './item/notificationItem'; | 18 | import NotificationItem from './item/notificationItem'; |
| 19 | import GroupNotificationItem from './item/groupItem'; | 19 | import GroupNotificationItem from './item/groupItem'; |
| 20 | import ExpandInfoManager from '../model/ExpandInfoManager'; | 20 | import ExpandInfoManager from '../model/ExpandInfoManager'; |
| 21 | 21 | ||
| 22 | const TAG = 'NoticeItem-NotificationListComponent'; | 22 | const 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 = { | |||
| 29 | export default struct NotificationListComponent { | 29 | export 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: boolean | 33 | @Link listIsEnd: boolean |
| 34 | private config: NotificationLayoutConfig = { | 34 | private config: NotificationLayoutConfig = { |
| 35 | itemMargin: Layout.ITEM_MARGIN | 35 | 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-3 | 213 | 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 @@ | |||
| 16 | import Log from '../../../../../../../../../../common/src/main/ets/default/Log'; | 16 | import Log from '../../../../../../../../../../common/src/main/ets/default/Log'; |
| 17 | import CheckEmptyUtils from '../../../../../../../../../../common/src/main/ets/default/CheckEmptyUtils'; | 17 | import CheckEmptyUtils from '../../../../../../../../../../common/src/main/ets/default/CheckEmptyUtils'; |
| 18 | import NotificationViewModel from '../../viewmodel/NotificationViewModel'; | 18 | import 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 | ||
| 21 | const TAG = 'NoticeItem-ActionComponent'; | 23 | const TAG = 'NoticeItem-ActionComponent'; |
| 22 | 24 | ||
| 23 | class actionInputData { | 25 | class actionInputData { |
| 24 | - inputKey?; | 26 | + inputKey?: string; |
| 25 | - wantAgent? | 27 | + wantAgent?: WantAgent |
| 26 | } | 28 | } |
| 27 | 29 | ||
| 28 | @Component | 30 | @Component |
| 29 | export default struct ActionComponent { | 31 | export 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.placeholder | 80 | content: this.placeholder |
| @@ -16,7 +16,7 @@ | |||
| 16 | import Constants, {NotificationItemData, NotificationLayout as Layout} from '../../common/constants'; | 16 | import Constants, {NotificationItemData, NotificationLayout as Layout} from '../../common/constants'; |
| 17 | @Component | 17 | @Component |
| 18 | export default struct BasicItem { | 18 | export default struct BasicItem { |
| 19 | - @State itemData: NotificationItemData = undefined | 19 | + @Prop itemData: NotificationItemData |
| 20 | 20 | ||
| 21 | build() { | 21 | build() { |
| 22 | Column() { | 22 | Column() { |
| @@ -26,10 +26,10 @@ const TAG = 'NoticeItem-Confirm'; | |||
| 26 | */ | 26 | */ |
| 27 | @CustomDialog | 27 | @CustomDialog |
| 28 | export default struct ConfirmDialog { | 28 | export default struct ConfirmDialog { |
| 29 | - private title: string | Resource | 29 | + private title: string | Resource = '' |
| 30 | - private bundleName: string | 30 | + private bundleName: string = '' |
| 31 | public controller: CustomDialogController | 31 | public controller: CustomDialogController |
| 32 | - public action: () => void | 32 | + 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'; | |||
| 18 | import NotificationViewModel from '../../viewmodel/NotificationViewModel'; | 18 | import NotificationViewModel from '../../viewmodel/NotificationViewModel'; |
| 19 | import NotificationManager from '../../model/NotificationManager'; | 19 | import NotificationManager from '../../model/NotificationManager'; |
| 20 | import {NotificationLayout as Layout} from '../../common/constants'; | 20 | import {NotificationLayout as Layout} from '../../common/constants'; |
| 21 | +import { NotificationItemData } from '@ohos/common' | ||
| 22 | +import NtfMgr from '@ohos.notificationManager'; | ||
| 21 | 23 | ||
| 22 | const TAG = 'NoticeItem-CustomItem'; | 24 | const TAG = 'NoticeItem-CustomItem'; |
| 23 | 25 | ||
| 24 | @Component | 26 | @Component |
| 25 | export default struct CustomItem { | 27 | export 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: () => void | 33 | + 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.templateData | 48 | 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 @@ | |||
| 16 | import Constants from '../../common/constants'; | 16 | import Constants from '../../common/constants'; |
| 17 | import Log from '../../../../../../../../../../common/src/main/ets/default/Log'; | 17 | import Log from '../../../../../../../../../../common/src/main/ets/default/Log'; |
| 18 | import DistributionManager from '../../model/NotificationDistributionManager'; | 18 | import DistributionManager from '../../model/NotificationDistributionManager'; |
| 19 | +import deviceManager from '@ohos.distributedDeviceManager' | ||
| 19 | 20 | ||
| 20 | const TAG = 'NoticeItem-DevicesDialog'; | 21 | const TAG = 'NoticeItem-DevicesDialog'; |
| 21 | 22 | ||
| @@ -25,9 +26,9 @@ const TAG = 'NoticeItem-DevicesDialog'; | |||
| 25 | */ | 26 | */ |
| 26 | @CustomDialog | 27 | @CustomDialog |
| 27 | export default struct DevicesDialog { | 28 | export default struct DevicesDialog { |
| 28 | - private deviceInfoList: Array<any>; | 29 | + private deviceInfoList: Array<deviceManager.DeviceBasicInfo> = []; |
| 29 | public controller: CustomDialogController | 30 | public controller: CustomDialogController |
| 30 | - public action: (deviceID) => void | 31 | + 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'; |
| 17 | import basicItem from './basicItem'; | 17 | import basicItem from './basicItem'; |
| 18 | import longItem from './longItem'; | 18 | import longItem from './longItem'; |
| 19 | import multiItem from './multiItem'; | 19 | import multiItem from './multiItem'; |
| @@ -33,8 +33,8 @@ export default struct GeneralItem { | |||
| 33 | @State @Watch('expandChange') isExpand: boolean = false | 33 | @State @Watch('expandChange') isExpand: boolean = false |
| 34 | @State needExpand: boolean = true | 34 | @State needExpand: boolean = true |
| 35 | @State distributedDeviceName: string = '' | 35 | @State distributedDeviceName: string = '' |
| 36 | - private itemData: any = {} | 36 | + @Prop itemData: NotificationItemData |
| 37 | - private clickAction: () => void | 37 | + 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 | @Component | 98 | @Component |
| 99 | struct ContentComponent { | 99 | struct 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 | ||
| 16 | import Log from '../../../../../../../../../../common/src/main/ets/default/Log'; | 16 | import 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'; |
| 18 | import NotificationItem from './notificationItem' | 18 | import NotificationItem from './notificationItem' |
| 19 | import NotificationViewModel from '../../viewmodel/NotificationViewModel'; | 19 | import NotificationViewModel from '../../viewmodel/NotificationViewModel'; |
| 20 | import SwipeLayout from './SwipeLayout'; | 20 | import 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 | @Component | 156 | @Component |
| 157 | struct ContentList { | 157 | struct 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'; |
| 17 | import Log from '../../../../../../../../../../common/src/main/ets/default/Log'; | 17 | import Log from '../../../../../../../../../../common/src/main/ets/default/Log'; |
| 18 | import SettingDialog from './settingDialog'; | 18 | import SettingDialog from './settingDialog'; |
| 19 | import ConfirmDialog from './confirmDialog' | 19 | import ConfirmDialog from './confirmDialog' |
| @@ -24,12 +24,12 @@ const deviceTypeInfo = deviceInfo.deviceType; | |||
| 24 | const TAG = 'NoticeItem-IconListComponent'; | 24 | const TAG = 'NoticeItem-IconListComponent'; |
| 25 | let iconSize: number = 0; | 25 | let iconSize: number = 0; |
| 26 | 26 | ||
| 27 | -type IconData = { | 27 | +interface IconData { |
| 28 | src?: Resource; | 28 | src?: Resource; |
| 29 | callback?: () => void | 29 | 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 | @Component | 41 | @Component |
| 42 | export default struct IconListComponent { | 42 | export 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: number | 45 | @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: true | 54 | 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.settingDialogController | 94 | + this.settingDialogController = null |
| 95 | - this.settingDialogController = undefined | 95 | + 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 | @Component | 123 | @Component |
| 128 | export struct BottomLeftItem { | 124 | export 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: true | 136 | 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.settingDialogController | 152 | + this.settingDialogController = null |
| 157 | - this.settingDialogController = undefined | 153 | + 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 | @Component | 18 | @Component |
| 19 | export default | 19 | export default |
| 20 | struct LongItem { | 20 | struct LongItem { |
| 21 | - @State itemData: NotificationItemData= undefined | 21 | + @Prop itemData: NotificationItemData |
| 22 | @Prop isExpand: boolean | 22 | @Prop isExpand: boolean |
| 23 | 23 | ||
| 24 | build() { | 24 | build() { |
| @@ -17,7 +17,7 @@ import Constants, {NotificationItemData, NotificationLayout as Layout} from '../ | |||
| 17 | 17 | ||
| 18 | @Component | 18 | @Component |
| 19 | export default struct MultiItem { | 19 | export default struct MultiItem { |
| 20 | - @State itemData: NotificationItemData= undefined | 20 | + @Prop itemData: NotificationItemData |
| 21 | @Prop isExpand: boolean | 21 | @Prop isExpand: boolean |
| 22 | 22 | ||
| 23 | build() { | 23 | build() { |
| @@ -24,17 +24,27 @@ import {BottomLeftItem} from './iconListComponent'; | |||
| 24 | import deviceInfo from '@ohos.deviceInfo'; | 24 | import deviceInfo from '@ohos.deviceInfo'; |
| 25 | import SwipeLayout from './SwipeLayout'; | 25 | import SwipeLayout from './SwipeLayout'; |
| 26 | import {getId} from '../../model/SwipeLayoutUtils'; | 26 | import {getId} from '../../model/SwipeLayoutUtils'; |
| 27 | +import { NotificationItemData } from '../../common/constants' | ||
| 27 | 28 | ||
| 28 | const TAG = 'NoticeItem-NotificationItem'; | 29 | const TAG = 'NoticeItem-NotificationItem'; |
| 29 | const deviceTypeInfo = deviceInfo.deviceType; | 30 | const 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 | @Component | 41 | @Component |
| 32 | export default struct NotificationItem { | 42 | export 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 | @Component | 94 | @Component |
| 85 | struct FrontItem { | 95 | struct 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.devicesDialogController | 108 | + 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 | @Component | 19 | @Component |
| 20 | export default struct PictureItem { | 20 | export default struct PictureItem { |
| 21 | - @State itemData: NotificationItemData= undefined | 21 | + @Prop itemData: NotificationItemData |
| 22 | @Prop isExpand: boolean | 22 | @Prop isExpand: boolean |
| 23 | 23 | ||
| 24 | build() { | 24 | build() { |
| @@ -30,9 +30,9 @@ const TAG = 'NoticeItem-Setting'; | |||
| 30 | */ | 30 | */ |
| 31 | @CustomDialog | 31 | @CustomDialog |
| 32 | export default struct SettingDialog { | 32 | export default struct SettingDialog { |
| 33 | - private itemData: NotificationItemData | 33 | + @Prop itemData: NotificationItemData |
| 34 | public controller: CustomDialogController | 34 | public controller: CustomDialogController |
| 35 | - public action: () => void | 35 | + public action: () => void = () => {} |
| 36 | 36 | ||
| 37 | build() { | 37 | build() { |
| 38 | Column() { | 38 | Column() { |
| @@ -20,7 +20,7 @@ const TAG = 'NoticeItem-TitleItem'; | |||
| 20 | 20 | ||
| 21 | @Component | 21 | @Component |
| 22 | export default struct TitleItem { | 22 | export default struct TitleItem { |
| 23 | - private notificationSmallIcon: PixelMap | 23 | + private notificationSmallIcon?: PixelMap |
| 24 | @State notificationName: string = '' | 24 | @State notificationName: string = '' |
| 25 | @State notificationTime: string = '' | 25 | @State notificationTime: string = '' |
| 26 | @Link isExpand: boolean | 26 | @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: string | 29 | @Prop distributedDeviceName: string |
| 30 | private isSubItem: boolean= false; | 30 | private isSubItem: boolean= false; |
| 31 | - private clickTitleAction: () => void | 31 | + 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 | @Component | 26 | @Component |
| 27 | export default struct ControlCenterSimpleToggleRingModeComponent { | 27 | export default struct ControlCenterSimpleToggleRingModeComponent { |
| 28 | - private keyId: string | 28 | + private keyId: string = '' |
| 29 | private mEditMode: boolean = false | 29 | private mEditMode: boolean = false |
| 30 | private mDragMode: boolean = false | 30 | 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: 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 = []; |
| 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 type | 91 | * @param {number} type - number of cellular type |
| 92 | * @return {string} typeString type of cellular type | 92 | * @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 signalModel | 130 | * @param {number} level - signal level from signalModel |
| 131 | * @return {string} cellularImage image of cellular signal | 131 | * @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 model | 165 | * @param {string} netWorkState - network state from signal model |
| 166 | * @return {string} vendor's name or signal state | 166 | * @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 @@ | |||
| 16 | import Log from '../../../../../../../../common/src/main/ets/default/Log' | 16 | import Log from '../../../../../../../../common/src/main/ets/default/Log' |
| 17 | import EventManager, { unsubscribe } from '../../../../../../../../common/src/main/ets/default/event/EventManager' | 17 | import EventManager, { unsubscribe } from '../../../../../../../../common/src/main/ets/default/event/EventManager' |
| 18 | import CheckEmptyUtils from '../../../../../../../../common/src/main/ets/default/CheckEmptyUtils' | 18 | import 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' |
| 20 | import { PluginType,itemData } from "../../../../../../../../common/src/main/ets/plugindatasource/common/Constants" | 20 | import { PluginType,itemData } from "../../../../../../../../common/src/main/ets/plugindatasource/common/Constants" |
| 21 | import ViewModel from '../viewmodel/StatusBarVM' | 21 | import ViewModel from '../viewmodel/StatusBarVM' |
| 22 | import StyleConfigurationCommon, { CommonStyle | 22 | import StyleConfigurationCommon, { CommonStyle |
| @@ -24,16 +24,17 @@ import StyleConfigurationCommon, { CommonStyle | |||
| 24 | import StyleConfiguration, { IconItemComponentStyle } from '../common/StyleConfiguration' | 24 | import StyleConfiguration, { IconItemComponentStyle } from '../common/StyleConfiguration' |
| 25 | import MetaIconItemComponent from './MetaIconItemComponent' | 25 | import MetaIconItemComponent from './MetaIconItemComponent' |
| 26 | import PluginIconItemComponent from './PluginIconItemComponent' | 26 | import PluginIconItemComponent from './PluginIconItemComponent' |
| 27 | +import { Event } from '@ohos/common' | ||
| 27 | 28 | ||
| 28 | const TAG = 'IconItemComponent' | 29 | const TAG = 'IconItemComponent' |
| 29 | 30 | ||
| 30 | -class itemStatusData{ | 31 | +interface itemStatusData{ |
| 31 | selected: boolean | 32 | selected: boolean |
| 32 | } | 33 | } |
| 33 | 34 | ||
| 34 | @Component | 35 | @Component |
| 35 | export default struct IconItemComponent { | 36 | export default struct IconItemComponent { |
| 36 | - private keyId: string | 37 | + @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: false | 40 | 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.mItemData | 66 | this.mItemData |
| 64 | .iconUrl}`) | 67 | .iconUrl}`) |
| 65 | 68 | ||
| 66 | const statusBarStatusKey = 'StatusBar_Status_' + this.keyId | 69 | 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?.isShow | 110 | + 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 | @Component | 27 | @Component |
| 28 | export default struct MetaIconItemComponent { | 28 | export default struct MetaIconItemComponent { |
| 29 | - private keyId: string | 29 | + @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.mItemData | 48 | this.mItemData |
| 49 | .iconUrl}`) | 49 | .iconUrl}`) |
| @@ -25,7 +25,7 @@ const TAG = 'PluginIconItemComponent' | |||
| 25 | 25 | ||
| 26 | @Component | 26 | @Component |
| 27 | export default struct PluginIconItemComponent { | 27 | export default struct PluginIconItemComponent { |
| 28 | - private keyId: string | 28 | + @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.data | 78 | 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 | |||
| 35 | import LocationIcon from '../../../../../../../locationcomponent/src/main/ets/com/ohos/pages/StatusBarIconItemLocationComponent' | 35 | import LocationIcon from '../../../../../../../locationcomponent/src/main/ets/com/ohos/pages/StatusBarIconItemLocationComponent' |
| 36 | import RingModeIcon from '../../../../../../../ringmodecomponent/src/main/ets/com/ohos/pages/StatusBarIconItemRingModeComponent' | 36 | import RingModeIcon from '../../../../../../../ringmodecomponent/src/main/ets/com/ohos/pages/StatusBarIconItemRingModeComponent' |
| 37 | import NfcIcon from '../../../../../../../nfccomponent/src/main/ets/com/ohos/pages/StatusBarIconItemNFComponent' | 37 | import NfcIcon from '../../../../../../../nfccomponent/src/main/ets/com/ohos/pages/StatusBarIconItemNFComponent' |
| 38 | +import { NotificationItemData } from '@ohos/common'; | ||
| 38 | 39 | ||
| 39 | const TAG = 'StatusBarComponent' | 40 | const TAG = 'StatusBarComponent' |
| 40 | const TAG_StatusBarGroup = 'StatusBarGroup' | 41 | const TAG_StatusBarGroup = 'StatusBarGroup' |
| @@ -44,9 +45,14 @@ const TAG_StatusBarEmptyIcon = 'StatusBarEmptyIcon' | |||
| 44 | const TAG_StatusBarNotificationIcon = 'StatusBarNotificationIcon' | 45 | const TAG_StatusBarNotificationIcon = 'StatusBarNotificationIcon' |
| 45 | const TAG_StatusBarBackground = 'StatusBarBackground' | 46 | const TAG_StatusBarBackground = 'StatusBarBackground' |
| 46 | 47 | ||
| 48 | +interface Item { | ||
| 49 | + index: number; | ||
| 50 | + data: NotificationItemData[]; | ||
| 51 | +} | ||
| 52 | + | ||
| 47 | @Component | 53 | @Component |
| 48 | export default struct StatusBarComponent { | 54 | export default struct StatusBarComponent { |
| 49 | - private mStatusBarComponentConfig: StatusBarConfig | 55 | + 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 { | |||
| 166 | struct StatusBarGroup { | 172 | struct StatusBarGroup { |
| 167 | @StorageLink('StatusBarLayout') mStatusBarLayout: string[][] = [[], [], []] | 173 | @StorageLink('StatusBarLayout') mStatusBarLayout: string[][] = [[], [], []] |
| 168 | private mLayoutWeight: number = 1 | 174 | 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 | @Component | 219 | @Component |
| 214 | struct VerticalStatusBarItemLoadComponent { | 220 | struct VerticalStatusBarItemLoadComponent { |
| 215 | - private mComponentName: string | 221 | + private mComponentName: string = '' |
| 216 | @State mComponentHeight: number = 0 | 222 | @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 | @Component | 248 | @Component |
| 243 | struct StatusBarItemLoadComponent { | 249 | struct StatusBarItemLoadComponent { |
| 244 | - private mComponentName: string | 250 | + 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 | @Component | 318 | @Component |
| 313 | struct StatusBarNotificationIcon { | 319 | struct StatusBarNotificationIcon { |
| 314 | - @StorageLink('notificationList') notificationList: Array<any> = [] | 320 | + @StorageLink('notificationList') notificationList: NotificationItemData[][] = [] |
| 315 | @StorageLink('StatusCoefficient') StatusCoefficient: number = 1.0 | 321 | @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 icon | 102 | + 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 | @Component | 25 | @Component |
| 26 | export default struct WifiComponent { | 26 | export 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 { | |||
| 129 | export default class DialogServiceExtAbility extends ServiceExtensionAbility { | 129 | export 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'; | |||
| 18 | import Constants from '../common/Constants'; | 18 | import Constants from '../common/Constants'; |
| 19 | import type { IDialogParameters } from '../controller/Controller'; | 19 | import type { IDialogParameters } from '../controller/Controller'; |
| 20 | import inputMethod from '@ohos.inputMethod'; | 20 | import inputMethod from '@ohos.inputMethod'; |
| 21 | +import SystemDialogController from '../controller/Controller'; | ||
| 21 | 22 | ||
| 22 | const TAG = 'Dialog-Index'; | 23 | const TAG = 'Dialog-Index'; |
| 23 | 24 | ||
| @@ -26,10 +27,10 @@ const storage = LocalStorage.GetShared(); | |||
| 26 | @Entry(storage) | 27 | @Entry(storage) |
| 27 | @Component | 28 | @Component |
| 28 | struct Index { | 29 | struct 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/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 | ||
| 25 | const TAG = 'NotificationManagement-BatchSetEnable'; | 25 | const 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 | @Entry | 40 | @Entry |
| 28 | @Component | 41 | @Component |
| 29 | export default struct BatchSetEnable { | 42 | export 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 | |||
| 22 | import {DoNotDisturbType} from '../../../../../../../features/managementcomponent/src/main/ets/com/ohos/common/constants'; | 22 | import {DoNotDisturbType} from '../../../../../../../features/managementcomponent/src/main/ets/com/ohos/common/constants'; |
| 23 | import NoDisturbingModel from '../../../../../../../features/managementcomponent/src/main/ets/com/ohos/model/noDisturbingModel'; | 23 | import NoDisturbingModel from '../../../../../../../features/managementcomponent/src/main/ets/com/ohos/model/noDisturbingModel'; |
| 24 | import ViewModel from '../vm/noDisturbViewModel'; | 24 | import ViewModel from '../vm/noDisturbViewModel'; |
| 25 | +import { data } from '@kit.TelephonyKit'; | ||
| 25 | 26 | ||
| 26 | const deviceTypeInfo = deviceInfo.deviceType; | 27 | const deviceTypeInfo = deviceInfo.deviceType; |
| 27 | const TAG = 'NotificationManagement-NoDisturb'; | 28 | const 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.defaultStartTime | 62 | 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: true | 68 | 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.defaultStartTime | 74 | 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: true | 80 | 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.defaultEndTime | 86 | 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: true | 92 | 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.defaultEndTime | 98 | 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: true | 104 | 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.repeatMode | 110 | selectMode: this.mViewModel.repeatMode |
| 110 | }), | 111 | }), |
| @@ -129,7 +130,7 @@ export default struct NoDisturb { | |||
| 129 | arrow: $arrow | 130 | 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: $arrow | 143 | 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: $arrow | 154 | 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: $arrow | 179 | 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: $arrow | 190 | 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.startTime | 217 | 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.endTime | 227 | 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.startDateDialogController | 291 | + this.startDateDialogController = null |
| 291 | - this.startDateDialogController = undefined | 292 | + this.startTimeDialogController = null |
| 292 | - | 293 | + this.endDateDialogController = null |
| 293 | - delete this.startTimeDialogController | 294 | + this.endTimeDialogController = null |
| 294 | - this.startTimeDialogController = undefined | 295 | + 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 | @CustomDialog | 308 | @CustomDialog |
| 317 | struct DateDialog { | 309 | struct DateDialog { |
| 318 | public controller: CustomDialogController | 310 | public controller: CustomDialogController |
| 319 | - public action: (data) => void | 311 | + 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 | @CustomDialog | 387 | @CustomDialog |
| 396 | struct TimeDialog { | 388 | struct TimeDialog { |
| 397 | public controller: CustomDialogController | 389 | public controller: CustomDialogController |
| 398 | - public action: (data) => void | 390 | + 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 | @CustomDialog | 463 | @CustomDialog |
| 472 | struct RepeatModeDialog { | 464 | struct RepeatModeDialog { |
| 473 | public controller: CustomDialogController | 465 | public controller: CustomDialogController |
| 474 | - public action: (data) => void | 466 | + public action: (data: number) => void = data => {} |
| 475 | private title: string | Resource = '' | 467 | private title: string | Resource = '' |
| 476 | private prevModeSetCnt: number = 0 | 468 | private prevModeSetCnt: number = 0 |
| 477 | @State selectMode: number = DoNotDisturbType.TYPE_NONE | 469 | @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'; | |||
| 23 | import Router from '@system.router' | 23 | import Router from '@system.router' |
| 24 | import notificationListener from '../../../../../../../features/managementcomponent/src/main/ets/com/ohos/model/notificationListener'; | 24 | import notificationListener from '../../../../../../../features/managementcomponent/src/main/ets/com/ohos/model/notificationListener'; |
| 25 | import Notification from '@ohos.notification'; | 25 | import Notification from '@ohos.notification'; |
| 26 | +import NotificationManager from '@ohos.notificationManager'; | ||
| 27 | +import { BundleItemData } from '@ohos/common'; | ||
| 26 | 28 | ||
| 27 | const TAG = 'NotificationManagement-SetEnable'; | 29 | const TAG = 'NotificationManagement-SetEnable'; |
| 28 | 30 | ||
| 29 | -let appInfo; | 31 | +let appInfo: BundleItemData; |
| 30 | 32 | ||
| 31 | @Entry | 33 | @Entry |
| 32 | @Component | 34 | @Component |
| 33 | export default struct SetEnable { | 35 | export 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 | |||
| 22 | import Router from '@system.router'; | 22 | import Router from '@system.router'; |
| 23 | import NotificationListener from '../../../../../../../features/managementcomponent/src/main/ets/com/ohos/model/notificationListener'; | 23 | import NotificationListener from '../../../../../../../features/managementcomponent/src/main/ets/com/ohos/model/notificationListener'; |
| 24 | import notification from '@ohos.notification'; | 24 | import notification from '@ohos.notification'; |
| 25 | +import { BundleItemData } from '@ohos/common'; | ||
| 26 | +import NotificationManager from '@ohos.notificationManager'; | ||
| 25 | 27 | ||
| 26 | const TAG = 'NotificationManagement-SlotSetting'; | 28 | const TAG = 'NotificationManagement-SlotSetting'; |
| 27 | const DEFAULT_SOUND = 'file://system/etc/Light.ogg'; | 29 | const 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 | @Entry | 36 | @Entry |
| 32 | @Component | 37 | @Component |
| 33 | export default struct SlotSetting { | 38 | export 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.slotInfo | 162 | + 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_DEFAULT | 210 | 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 | ||
| 22 | const TAG = 'VolumePanel-Index' | 22 | const 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 | @Entry | 36 | @Entry |
| 25 | @Component | 37 | @Component |
| 26 | struct Index { | 38 | struct 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 Mode | 43 | 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 | @Component | 24 | @Component |
| 25 | export default struct Control { | 25 | export default struct Control { |
| 26 | - private modeChangeCallback: Function | 26 | + 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' | |||
| 22 | import WindowManager, { | 22 | import 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"; |
| 26 | import EventManager, { unsubscribe } from "../../../../../../../common/src/main/ets/default/event/EventManager"; | 27 | import EventManager, { unsubscribe } from "../../../../../../../common/src/main/ets/default/event/EventManager"; |
| 27 | import { START_ABILITY_EVENT } from "../../../../../../../common/src/main/ets/default/event/EventUtil"; | 28 | import { START_ABILITY_EVENT } from "../../../../../../../common/src/main/ets/default/event/EventUtil"; |
| 28 | import MultimodalInputManager, { | 29 | import 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' | ||
| 31 | import display from "@ohos.display" | 33 | import display from "@ohos.display" |
| 32 | 34 | ||
| 33 | const TAG = 'ControlPanel-Index' | 35 | const TAG = 'ControlPanel-Index' |
| 34 | const SHOW_EVENT = "showControlCenter"; | 36 | const SHOW_EVENT = "showControlCenter"; |
| 35 | const HIDE_EVENT = "hideControlCenter"; | 37 | const HIDE_EVENT = "hideControlCenter"; |
| 36 | 38 | ||
| 37 | -let mHeightConfigUtils | 39 | +interface DisplayInfo { |
| 40 | + width: number; | ||
| 41 | + height: number; | ||
| 42 | +} | ||
| 38 | 43 | ||
| 39 | @Entry | 44 | @Entry |
| 40 | @Component | 45 | @Component |
| @@ -46,25 +51,24 @@ struct Index { | |||
| 46 | @State mWidthSize: number = 0.2 | 51 | @State mWidthSize: number = 0.2 |
| 47 | @State mHeightSize: number = 0.2 | 52 | @State mHeightSize: number = 0.2 |
| 48 | @State mHeightPx: number = 0 | 53 | @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.height | 66 | 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 = initRect | 231 | + 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.height | 255 | 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 | } |
| @@ -20,6 +20,7 @@ import Notification from './notification' | |||
| 20 | import WindowManager, { | 20 | import 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"; |
| 24 | import EventManager, {unsubscribe} from "../../../../../../../common/src/main/ets/default/event/EventManager"; | 25 | import EventManager, {unsubscribe} from "../../../../../../../common/src/main/ets/default/event/EventManager"; |
| 25 | import {START_ABILITY_EVENT} from "../../../../../../../common/src/main/ets/default/event/EventUtil"; | 26 | import {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 | |||
| 19 | import {obtainStartAbility} from "../../../../../../../common/src/main/ets/default/event/EventUtil" | 19 | import {obtainStartAbility} from "../../../../../../../common/src/main/ets/default/event/EventUtil" |
| 20 | import NotificationListComponent from '../../../../../../../features/noticeitem/src/main/ets/com/ohos/noticeItem/view/NotificationListComponent' | 20 | import NotificationListComponent from '../../../../../../../features/noticeitem/src/main/ets/com/ohos/noticeItem/view/NotificationListComponent' |
| 21 | import NotificationViewModel from '../../../../../../../features/noticeitem/src/main/ets/com/ohos/noticeItem/viewmodel/NotificationViewModel' | 21 | import NotificationViewModel from '../../../../../../../features/noticeitem/src/main/ets/com/ohos/noticeItem/viewmodel/NotificationViewModel' |
| 22 | +import { NotificationItemData } from '@ohos/common' | ||
| 22 | 23 | ||
| 23 | const TAG = 'NotificationPanel-notification' | 24 | const TAG = 'NotificationPanel-notification' |
| 24 | const NO_NOTIFICATION_TOP_MARGIN = 40; | 25 | const NO_NOTIFICATION_TOP_MARGIN = 40; |
| @@ -32,7 +33,7 @@ const NOTIFICATION_TITLE_ICON_MARGIN = 24; | |||
| 32 | 33 | ||
| 33 | @Component | 34 | @Component |
| 34 | export default struct Notification { | 35 | export default struct Notification { |
| 35 | - @StorageLink('notificationList') notificationList: any[] = [] | 36 | + @StorageLink('notificationList') notificationList: NotificationItemData[][] = [] |
| 36 | @State isEnd: boolean = false | 37 | @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' | |||
| 22 | import AbilityManager from '../../../../../../../common/src/main/ets/default/abilitymanager/abilityManager' | 22 | import AbilityManager from '../../../../../../../common/src/main/ets/default/abilitymanager/abilityManager' |
| 23 | import StatusBarVM from '../../../../../../../features/statusbarcomponent/src/main/ets/com/ohos/viewmodel/StatusBarVM' | 23 | import StatusBarVM from '../../../../../../../features/statusbarcomponent/src/main/ets/com/ohos/viewmodel/StatusBarVM' |
| 24 | import {StatusBarData} from '../../../../../../../features/statusbarcomponent/src/main/ets/com/ohos/common/Constants' | 24 | import {StatusBarData} from '../../../../../../../features/statusbarcomponent/src/main/ets/com/ohos/common/Constants' |
| 25 | +import { ConfigInfo } from '@ohos/common'; | ||
| 25 | 26 | ||
| 26 | const TAG = 'StatusBar-Index' | 27 | const TAG = 'StatusBar-Index' |
| 27 | 28 | ||
| 28 | -let mHeightConfigUtils; | ||
| 29 | - | ||
| 30 | @Entry | 29 | @Entry |
| 31 | @Component | 30 | @Component |
| 32 | struct Index { | 31 | struct Index { |
| 33 | @StorageLink('StatusMinH') StatusMinH: number = 24 | 32 | @StorageLink('StatusMinH') StatusMinH: number = 24 |
| 34 | @StorageLink('StatusCoefficient') StatusCoefficient: number = 1.0 | 33 | @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'; | |||
| 19 | import WindowManager, { WindowType } from '../../../../../../../common/src/main/ets/default/WindowManager'; | 19 | import WindowManager, { WindowType } from '../../../../../../../common/src/main/ets/default/WindowManager'; |
| 20 | import AbilityManager from '../../../../../../../common/src/main/ets/default/abilitymanager/abilityManager'; | 20 | import AbilityManager from '../../../../../../../common/src/main/ets/default/abilitymanager/abilityManager'; |
| 21 | import NavBarConfiguration from '../../../../../../../features/navigationservice/src/main/ets/com/ohos/navigationservice/common/NavBarConfiguration'; | 21 | import 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 | ||
| 25 | const TAG = 'DropdownPanel_ServiceExtAbility'; | 25 | const TAG = 'DropdownPanel_ServiceExtAbility'; |
| @@ -29,12 +29,13 @@ import Log from '../../../../../../../common/src/main/ets/default/Log' | |||
| 29 | import Constants from './common/constants' | 29 | import Constants from './common/constants' |
| 30 | import StyleConfiguration, { ControlStyle } from './common/StyleConfiguration' | 30 | import StyleConfiguration, { ControlStyle } from './common/StyleConfiguration' |
| 31 | import ControlCenterConfig from './common/ControlCenterConfig'; | 31 | import ControlCenterConfig from './common/ControlCenterConfig'; |
| 32 | +import { TouchMoveData } from '@ohos/common'; | ||
| 32 | 33 | ||
| 33 | const TAG = 'DropdownPanel-Control'; | 34 | const TAG = 'DropdownPanel-Control'; |
| 34 | 35 | ||
| 35 | @Component | 36 | @Component |
| 36 | export default struct Control { | 37 | export default struct Control { |
| 37 | - private touchMoveCallback: Function | 38 | + private touchMoveCallback: Function = () => {} |
| 38 | startX: number = 0 | 39 | startX: number = 0 |
| 39 | startY: number = 0 | 40 | startY: number = 0 |
| 40 | @State moveX: number = 0 | 41 | @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 | @Component | 117 | @Component |
| 117 | struct statusBar { | 118 | struct statusBar { |
| 118 | @StorageLink('StatusCoefficient') StatusCoefficient: number = 1.0 | 119 | @StorageLink('StatusCoefficient') StatusCoefficient: number = 1.0 |
| 119 | - private touchMoveCallback: Function | 120 | + private touchMoveCallback: Function = () => {} |
| 120 | startX: number = 0 | 121 | startX: number = 0 |
| 121 | startY: number = 0 | 122 | startY: number = 0 |
| 122 | @State moveX: number = 0 | 123 | @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/ | |||
| 32 | import { START_ABILITY_EVENT } from "../../../../../../../common/src/main/ets/default/event/EventUtil" | 31 | import { START_ABILITY_EVENT } from "../../../../../../../common/src/main/ets/default/event/EventUtil" |
| 33 | import CommonStyleManager from '../../../../../../../common/src/main/ets/default/CommonStyleManager' | 32 | import CommonStyleManager from '../../../../../../../common/src/main/ets/default/CommonStyleManager' |
| 34 | import MultimodalInputManager from '../../../../../../../common/src/main/ets/default/MultimodalInputManager' | 33 | import MultimodalInputManager from '../../../../../../../common/src/main/ets/default/MultimodalInputManager' |
| 35 | -import AbilityManager from '../../../../../../../common/src/main/ets/default/abilitymanager/abilityManager' | ||
| 36 | import HeightConfigUtils from '../../../../../../../common/src/main/ets/default/heightcofigUtils/HeightConfigUtils' | 34 | import HeightConfigUtils from '../../../../../../../common/src/main/ets/default/heightcofigUtils/HeightConfigUtils' |
| 37 | import StatusBarVM from '../../../../../../../features/statusbarcomponent/src/main/ets/com/ohos/viewmodel/StatusBarVM' | 35 | import StatusBarVM from '../../../../../../../features/statusbarcomponent/src/main/ets/com/ohos/viewmodel/StatusBarVM' |
| 38 | -import NavigationEvent from './common/navigationEvent' | 36 | +import NavigationEvent, { NavigationCallBack } from './common/navigationEvent' |
| 39 | import Notification from './notification' | 37 | import Notification from './notification' |
| 40 | import ControlCenterComponent from './control' | 38 | import ControlCenterComponent from './control' |
| 41 | import StyleManager from './common/StyleManager' | 39 | import StyleManager from './common/StyleManager' |
| 42 | import dataShare from '@ohos.data.dataShare'; | 40 | import dataShare from '@ohos.data.dataShare'; |
| 43 | import settings from '@ohos.settings'; | 41 | import settings from '@ohos.settings'; |
| 44 | import Constants from "../../../../../../../common/src/main/ets/default/Constants"; | 42 | import 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 | ||
| 46 | const TAG = 'DropdownPanel-Index' | 47 | const TAG = 'DropdownPanel-Index' |
| 47 | 48 | ||
| 48 | -let mHeightConfigUtils | 49 | +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.Normal | 61 | 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 | ||
| 73 | enum DropdownPanelComponentName { | 64 | enum 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 = undefined | 158 | mClearCallback = undefined |
| 169 | }) | 159 | }) |
| 170 | this.mClearCallbacks = undefined | 160 | 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.NOTIFICATION | 242 | 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 = transitionDelete | 257 | this.mNotificationDelete = transitionDelete |
| 261 | this.mControlCenterDelete = transitionDelete | 258 | 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 = showComponentName | 263 | 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 = showComponentName | 269 | 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 = 0 | 283 | this.backgroundOpacity = 0 |
| 287 | this.showComponentName = DropdownPanelComponentName.NONE | 284 | 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 | |||
| 34 | import TimeManager, { TimeEventArgs, TIME_CHANGE_EVENT | 34 | import TimeManager, { TimeEventArgs, TIME_CHANGE_EVENT |
| 35 | } from '../../../../../../../common/src/main/ets/default/TimeManager'; | 35 | } from '../../../../../../../common/src/main/ets/default/TimeManager'; |
| 36 | import deviceInfo from '@ohos.deviceInfo'; | 36 | import deviceInfo from '@ohos.deviceInfo'; |
| 37 | +import { NotificationItemData, TouchMoveData } from '@ohos/common'; | ||
| 37 | 38 | ||
| 38 | const TAG = 'DropdownPanel-notification'; | 39 | const TAG = 'DropdownPanel-notification'; |
| 39 | const IMAGE_SIZE_L = 24; | 40 | const IMAGE_SIZE_L = 24; |
| @@ -47,13 +48,13 @@ const deviceTypeInfo = deviceInfo.deviceType; | |||
| 47 | 48 | ||
| 48 | @Component | 49 | @Component |
| 49 | export default struct Notification { | 50 | export default struct Notification { |
| 50 | - private touchMoveCallback: Function | 51 | + private touchMoveCallback: Function = () => {} |
| 51 | startX: number = 0 | 52 | startX: number = 0 |
| 52 | startY: number = 0 | 53 | startY: number = 0 |
| 53 | @State moveX: number = 0 | 54 | @State moveX: number = 0 |
| 54 | @State moveY: number = 0 | 55 | @State moveY: number = 0 |
| 55 | @State isEnd: boolean = true | 56 | @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 | @Component | 150 | @Component |
| 150 | struct statusBar { | 151 | struct statusBar { |
| 151 | @StorageLink('StatusCoefficient') StatusCoefficient: number = 1.0 | 152 | @StorageLink('StatusCoefficient') StatusCoefficient: number = 1.0 |
| 152 | - private touchMoveCallback: Function | 153 | + private touchMoveCallback: Function = () => {} |
| 153 | startX: number = 0 | 154 | startX: number = 0 |
| 154 | startY: number = 0 | 155 | startY: number = 0 |
| 155 | @State moveX: number = 0 | 156 | @State moveX: number = 0 |
| @@ -218,11 +219,11 @@ struct statusBar { | |||
| 218 | 219 | ||
| 219 | @Component | 220 | @Component |
| 220 | struct CenterTitle { | 221 | struct CenterTitle { |
| 221 | - private touchMoveCallback: Function | 222 | + private touchMoveCallback: Function = () => {}; |
| 222 | - startX: number = 0 | 223 | + startX: number = 0; |
| 223 | - startY: number = 0 | 224 | + startY: number = 0; |
| 224 | - @State moveX: number = 0 | 225 | + @State moveX: number = 0; |
| 225 | - @State moveY: number = 0 | 226 | + @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/ | |||
| 20 | import AbilityManager from '../../../../../../../common/src/main/ets/default/abilitymanager/abilityManager'; | 20 | import AbilityManager from '../../../../../../../common/src/main/ets/default/abilitymanager/abilityManager'; |
| 21 | import StatusBarConfiguration from '../../../../../../../features/statusbarcomponent/src/main/ets/com/ohos/common/StatusBarConfiguration'; | 21 | import StatusBarConfiguration from '../../../../../../../features/statusbarcomponent/src/main/ets/com/ohos/common/StatusBarConfiguration'; |
| 22 | import StatusBarConstants from '../../../../../../../features/statusbarcomponent/src/main/ets/com/ohos/common/Constants'; | 22 | import StatusBarConstants from '../../../../../../../features/statusbarcomponent/src/main/ets/com/ohos/common/Constants'; |
| 23 | -import { Want } from 'ability/want'; | 23 | +import Want from '@ohos.application.Want'; |
| 24 | import deviceInfo from '@ohos.deviceInfo'; | 24 | import deviceInfo from '@ohos.deviceInfo'; |
| 25 | 25 | ||
| 26 | const TAG = 'StatusBar_ServiceExtAbility'; | 26 | const TAG = 'StatusBar_ServiceExtAbility'; |
| @@ -15,7 +15,7 @@ | |||
| 15 | 15 | ||
| 16 | import Log from '../../../../../../../common/src/main/ets/default/Log' | 16 | import Log from '../../../../../../../common/src/main/ets/default/Log' |
| 17 | import Trace from '../../../../../../../common/src/main/ets/default/Trace' | 17 | import Trace from '../../../../../../../common/src/main/ets/default/Trace' |
| 18 | -import WindowManager, {WindowType, WINDOW_SHOW_HIDE_EVENT | 18 | +import WindowManager, {WindowType, WINDOW_SHOW_HIDE_EVENT, ArgsInfo |
| 19 | } from '../../../../../../../common/src/main/ets/default/WindowManager' | 19 | } from '../../../../../../../common/src/main/ets/default/WindowManager' |
| 20 | import EventManager, {unsubscribe} from "../../../../../../../common/src/main/ets/default/event/EventManager" | 20 | import EventManager, {unsubscribe} from "../../../../../../../common/src/main/ets/default/event/EventManager" |
| 21 | import {obtainLocalEvent} from "../../../../../../../common/src/main/ets/default/event/EventUtil" | 21 | import {obtainLocalEvent} from "../../../../../../../common/src/main/ets/default/event/EventUtil" |
| @@ -23,16 +23,19 @@ import CommonStyleManager from '../../../../../../../common/src/main/ets/default | |||
| 23 | import HeightConfigUtils from '../../../../../../../common/src/main/ets/default/heightcofigUtils/HeightConfigUtils' | 23 | import HeightConfigUtils from '../../../../../../../common/src/main/ets/default/heightcofigUtils/HeightConfigUtils' |
| 24 | import StatusBarComponent from '../../../../../../../features/statusbarcomponent/src/main/ets/com/ohos/pages/StatusBarComponent' | 24 | import StatusBarComponent from '../../../../../../../features/statusbarcomponent/src/main/ets/com/ohos/pages/StatusBarComponent' |
| 25 | import StatusBarVM from '../../../../../../../features/statusbarcomponent/src/main/ets/com/ohos/viewmodel/StatusBarVM' | 25 | import 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' | ||
| 27 | import Constants from './common/constants' | 29 | import Constants from './common/constants' |
| 28 | import StyleManager from './common/StyleManager' | 30 | import StyleManager from './common/StyleManager' |
| 29 | import StatusbarConfig from './common/StatusbarConfig' | 31 | import StatusbarConfig from './common/StatusbarConfig' |
| 30 | import AbilityManager from '../../../../../../../common/src/main/ets/default/abilitymanager/abilityManager' | 32 | import AbilityManager from '../../../../../../../common/src/main/ets/default/abilitymanager/abilityManager' |
| 33 | +import { ConfigInfo } from '@ohos/common'; | ||
| 31 | 34 | ||
| 32 | const TAG = 'StatusBar-Index' | 35 | const TAG = 'StatusBar-Index' |
| 33 | const SLIDING_STATUS_BAR_DISTANCE = 18 | 36 | const SLIDING_STATUS_BAR_DISTANCE = 18 |
| 34 | 37 | ||
| 35 | -let mHeightConfigUtils; | 38 | +let mHeightConfigUtils = new HeightConfigUtils(); |
| 36 | 39 | ||
| 37 | @Entry | 40 | @Entry |
| 38 | @Component | 41 | @Component |
| @@ -45,7 +48,7 @@ struct Index { | |||
| 45 | @StorageLink('StatusMinH') StatusMinH: number = 24 | 48 | @StorageLink('StatusMinH') StatusMinH: number = 24 |
| 46 | @StorageLink('StatusCoefficient') StatusCoefficient: number = 1.0 | 49 | @StorageLink('StatusCoefficient') StatusCoefficient: number = 1.0 |
| 47 | mClearCallback: unsubscribe | undefined | 50 | mClearCallback: unsubscribe | undefined |
| 48 | - dropdownpanelIsOpen:boolean = false | 51 | + 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 | return | 147 | return |
| 148 | } | 148 | } |
| 149 | - let dropdownArea: string = null | 149 | + 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.left | 163 | let rangeStartX = this.mStatusBarData.realWidth * range.startPosition + this.mStatusBarData.left |
| 164 | let rangeEndX = this.mStatusBarData.realWidth * range.endPosition + this.mStatusBarData.left | 164 | 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) { |