systemui升级api12,IBINV4稳定性加固

Signed-off-by: 王环 <18108170464@163.com>
This commit is contained in:
王环
2025-03-03 11:03:27 +08:00
parent 05ede6f5d1
commit 99be4c0ce4
106 changed files with 893 additions and 642 deletions
+15 -1
View File
@@ -5,7 +5,21 @@
"name": "default",
"signingConfig": "release",
"compileSdkVersion": 12,
"compatibleSdkVersion": 12
"compatibleSdkVersion": 12,
}
],
"signingConfigs": [
{
"name": "default",
"material": {
"certpath": "C:/Users/wanghuan/.ohos/config/openharmony/default_applications_systemui_zBXUo9gni2fBvC-EjMlkQtKNasCWggA51ALU78m_VWw=.cer",
"storePassword": "0000001BA46E9456DA9E08ACF2A2BFF895A59A4F04F108BD52CED4DAE31B1534C59A5EEEE14B8200ACB885",
"keyAlias": "debugKey",
"keyPassword": "0000001B90751837A5A320E7821C1065CA3C5C38034D3AD64C3E7FD4B7EAE5A5027537CAB7DC32A5230894",
"profile": "C:/Users/wanghuan/.ohos/config/openharmony/default_applications_systemui_zBXUo9gni2fBvC-EjMlkQtKNasCWggA51ALU78m_VWw=.p7b",
"signAlg": "SHA256withECDSA",
"storeFile": "C:/Users/wanghuan/.ohos/config/openharmony/default_applications_systemui_zBXUo9gni2fBvC-EjMlkQtKNasCWggA51ALU78m_VWw=.p12"
}
}
]
},
+21
View File
@@ -0,0 +1,21 @@
export { default as Constants } from './src/main/ets/plugindatasource/common/Constants';
export { FilterData } from './src/main/ets/plugindatasource/common/Constants';
export { RootConfigInfo } from './src/main/ets/plugindatasource/common/Constants';
export { LoaderConfigInfo } from './src/main/ets/plugindatasource/common/Constants';
export { PluginType } from './src/main/ets/plugindatasource/common/Constants';
export { obtainMsg } from './src/main/ets/plugindatasource/common/Constants';
export { ItemComponentData } from './src/main/ets/plugindatasource/common/Constants';
export { ActionData } from './src/main/ets/plugindatasource/common/Constants';
export { PluginComponentData } from './src/main/ets/plugindatasource/common/Constants';
export { itemData } from './src/main/ets/plugindatasource/common/Constants';
export { NotificationItemData } from './src/main/ets/plugindatasource/common/Constants';
export { RuleData } from './src/main/ets/plugindatasource/common/Constants';
export { ConfigInfo } from './src/main/ets/plugindatasource/common/Constants';
export { BundleItemData } from './src/main/ets/plugindatasource/common/Constants';
export { TouchMoveData } from './src/main/ets/plugindatasource/common/Constants';
export { Event } from './src/main/ets/default/event/EventUtil';
export { Rect } from './src/main/ets/default/Constants';
+1
View File
@@ -3,5 +3,6 @@
"name": "@ohos/common",
"description": "a npm package which contains common function",
"version": "1.0.0",
"main": "index.ets",
"dependencies": {}
}
@@ -39,6 +39,17 @@ export enum WindowType {
PRIVACY_INDICATOR = 'SystemUi_PrivacyIndicator'
}
export interface ArgsInfo {
windowName: WindowType;
isShow?: boolean;
isDestroy?: boolean;
rect?: Rect;
left?: number;
top?: number;
width?: number;
height?: number;
}
export const WINDOW_SHOW_HIDE_EVENT = 'WindowShowHideEvent';
export const WINDOW_RESIZE_EVENT = 'WindowResizeEvent';
@@ -14,6 +14,11 @@
*/
import { Event } from '../../default/event/EventUtil';
import notificationManager from '@ohos.notificationManager';
import image from '@ohos.multimedia.image';
import resourceManager from '@ohos.resourceManager';
import { WantAgent } from '@ohos.wantAgent';
import NtfMgr from '@ohos.notificationManager';
export default class Constants {
static readonly INIT_CONFIG = 'initConfig';
@@ -104,7 +109,7 @@ export class itemData {
isShowIcon?
}
export class notificationData {
export interface NotificationItemData {
id: string;
hashcode: string;
userId: number;
@@ -113,12 +118,12 @@ export class notificationData {
timestamp: number;
time: string;
appName: string;
want: any;
actionButtons: any[];
want: WantAgent;
actionButtons: notificationManager.ButtonOptions[];
bundleName: string;
smallIcon?: PixelMap;
largeIcon?: PixelMap;
picture?: PixelMap;
smallIcon?: image.PixelMap | string;
largeIcon?: image.PixelMap | string;
picture?: image.PixelMap;
title?: string;
text?: string;
additionalText?: string;
@@ -133,7 +138,7 @@ export class notificationData {
sound?: string;
vibrationValues?: Array<number>;
notificationFlags?: any;
ruleData?;
ruleData?: RuleData;
template?: any;
isOngoing?: boolean;
isUnremovable?: boolean;
@@ -143,3 +148,44 @@ export class notificationData {
groupName?: string;
tapDismissed?: boolean;
}
export interface RuleData {
isAllowBanner?: boolean;
isAllowSound?: boolean;
isAllowVibrationValues?: boolean;
isAllowStatusBarShow?: boolean;
isAllowNotificationListShow?: boolean;
}
export interface ConfigInfo {
maxWidth: number;
maxHeight: number;
minHeight: number;
showHorizontal: boolean;
direction: number;
realWidth: number;
realHeight: number;
xCoordinate: number;
yCoordinate: number;
ableToMaximize?: boolean;
showNavHorizontal?: boolean;
}
export interface BundleItemData {
appIcon?: string;
appTitle?: string;
appValue?: string;
appArrow?: string | resourceManager.Resource;
appSummary?: string;
appBundleName?: string;
appIconId?: string;
appUri?: string;
appUid?: number;
systemApp?: boolean;
slotSettingUrl?: string
}
export interface TouchMoveData {
direction: string,
touchComponent: string
}
@@ -20,20 +20,20 @@ const TAG = 'SimpleToggleBase'
@Component
export default struct SimpleToggleBase {
private mToggleId: string
private mToggleId: string = ''
@Link mIcon: Resource
@State mIconStr: string = ''
private mUseIconStr: boolean = false
private mAutoIconColor: boolean = false
@Link mChangeSwitch: boolean
@Link mLabel: Resource
private mLabelStr: string | Resource
private mLabelStr: string | Resource = ''
private mUseLabelStr: boolean = false
private mIconOnBG: string | Resource
private mIconOnBG: string | Resource = ''
private mEditMode: boolean = false
private mDragMode: boolean = false
private mClickEvent: Function
private mLongClickEvent: Function
private mClickEvent: Function = (): void => {}
private mLongClickEvent: Function = (): void => {}
@State mIconIsHover: boolean = false
@State mTextIsHover: boolean = false
@State style: SimpleToggleBaseStyle = StyleConfiguration.getSimpleToggleBaseStyle()
@@ -20,8 +20,8 @@ const TAG = 'iconComponent'
@Component
export default struct iconComponent {
@State iconOff: string = ""
@State iconOn: string = ""
@State iconOff: Resource | string = ""
@State iconOn: Resource | string = ""
@Prop iconOffStr: string
@Prop iconOnStr: string
private useIconStr = false
@@ -21,16 +21,16 @@ const TAG = 'iconTitleBase'
@Component
export default struct iconBaseComponent {
private iconOn: any
private iconOff: any
@Prop iconOn: Resource
@Prop iconOff: Resource
@State iconOffStr: string = ""
@State iconOnStr: string = ""
@Link mTitle: Resource
@State mTitleStr: string = ""
private useIconStr = false
private useTitleStr = false
private mClickEvent: Function
private mLongClickEvent: Function
private mClickEvent: Function = (): void => {}
private mLongClickEvent: Function = (): void => {}
@State mTextIsHover: boolean = false
@Link changeSwitch: boolean
@State style: IconTitleBaseStyle = StyleConfiguration.getIconTitleBaseStyle()
+14 -2
View File
@@ -35,7 +35,13 @@
},
{
"name": "ohos.permission.GET_INSTALLED_BUNDLE_LIST",
"reason": "$string:get_installed_bundle_list_reason"
"reason": "$string:get_installed_bundle_list_reason",
"usedScene": {
"abilities": [
"MainAbility"
],
"when": "always"
}
},
{
"name": "ohos.permission.MANAGE_LOCAL_ACCOUNTS"
@@ -81,7 +87,13 @@
},
{
"name": "ohos.permission.DISTRIBUTED_DATASYNC",
"reason": "$string:distributed_data_sync_reason"
"reason": "$string:distributed_data_sync_reason",
"usedScene": {
"abilities": [
"MainAbility"
],
"when": "always"
}
},
{
"name": "ohos.permission.START_INVISIBLE_ABILITY"
+14 -2
View File
@@ -35,7 +35,13 @@
},
{
"name": "ohos.permission.GET_INSTALLED_BUNDLE_LIST",
"reason": "$string:get_installed_bundle_list_reason"
"reason": "$string:get_installed_bundle_list_reason",
"usedScene": {
"abilities": [
"MainAbility"
],
"when": "always"
}
},
{
"name": "ohos.permission.MANAGE_LOCAL_ACCOUNTS"
@@ -81,7 +87,13 @@
},
{
"name": "ohos.permission.DISTRIBUTED_DATASYNC",
"reason": "$string:distributed_data_sync_reason"
"reason": "$string:distributed_data_sync_reason",
"usedScene": {
"abilities": [
"MainAbility"
],
"when": "always"
}
},
{
"name": "ohos.permission.START_INVISIBLE_ABILITY"
@@ -21,7 +21,7 @@ const TAG = 'airplane-ControlCenterSimpleToggleAirplaneComponent';
@Component
export default struct ControlCenterSimpleToggleAirplaneComponent {
private keyId: string;
private keyId: string = '';
private mEditMode: boolean = false;
private mDragMode: boolean = false;
@State mIcon: Resource = $r("app.media.airplane");
@@ -46,7 +46,7 @@ export default struct ControlCenterSimpleToggleAirplaneComponent {
mLabel: $mLabel,
mEditMode: this.mEditMode,
mDragMode: this.mDragMode,
mClickEvent: () => this.mClickEvent()
mClickEvent: (): void => this.mClickEvent()
})
}
@@ -23,7 +23,7 @@ const TAG = 'Control-airPlaneComponent';
export default
struct airplaneComponent {
private IconInfo: any[] = [
private IconInfo: Resource[] = [
$r('app.media.airplane_d'),
$r('app.media.airplane'),
];
@@ -72,7 +72,7 @@ struct airplaneComponent {
iconOn: this.IconInfo[1],
mTitle: $flyModelTitle,
changeSwitch: $flyModelStatus,
mClickEvent: () => this.mClickEvent()
mClickEvent: (): void => this.mClickEvent()
})
}.width('100%')
.height('100%')
@@ -22,7 +22,7 @@ const TAG = 'autorotate-ControlCenterSimpleToggleAutoRotateComponent';
@Component
export default struct ControlCenterSimpleToggleAutoRotateComponent {
private keyId: string;
private keyId: string = '';
private mEditMode: boolean = false;
private mDragMode: boolean = false;
@State mIcon: Resource = $r("app.media.ic_controlcenter_auto_rotate_off");
@@ -53,7 +53,7 @@ export default struct ControlCenterSimpleToggleAutoRotateComponent {
mLabel: $mLabel,
mEditMode: this.mEditMode,
mDragMode: this.mDragMode,
mClickEvent: () => this.mClickEvent()
mClickEvent: (): void => this.mClickEvent()
})
}
@@ -78,7 +78,7 @@ export default struct BatteryPic {
})
}
private getBatteryColor(val, charging) {
private getBatteryColor(val: number, charging: boolean) {
Log.showInfo(TAG, `getBatteryColor, val: ${val} charging: ${charging} `);
if (charging) {
return this.style.picChargingColor;
@@ -23,7 +23,7 @@ const TAG = 'bluetooth-ControlCenterComplexToggleBluetoothComponent';
@Component
export default struct ControlCenterComplexToggleBluetoothComponent {
private IconInfo: any[] = [
private IconInfo: Resource[] = [
$r("app.media.ic_controlcenter_bt_d"),
$r("app.media.ic_controlcenter_bt"),
];
@@ -46,8 +46,8 @@ export default struct ControlCenterComplexToggleBluetoothComponent {
iconOn: this.IconInfo[1],
mTitle: $mTitle,
changeSwitch: $BluetoothOpenStatus,
mClickEvent: () => this.mClickEvent(),
mLongClickEvent: () => this.mLongClickEvent()
mClickEvent: (): void => this.mClickEvent(),
mLongClickEvent: (): void => this.mLongClickEvent()
})
}.width('100%')
.height('100%')
@@ -20,7 +20,7 @@ import Log from '../../../../../../../common/src/main/ets/default/Log';
const TAG = 'Control-brightnessComponent';
class brightnessItemData {
interface brightnessItemData {
min:number;
max:number;
value:number
@@ -38,7 +38,7 @@ export default struct ComplexToggleComponent {
linkItemData() {
Log.showDebug(TAG, `linkItemData, keyId: ${this.keyId}`);
this.mItemData = AppStorage.Get('ControlCenter_' + this.keyId);
this.mItemData = AppStorage.Get('ControlCenter_' + this.keyId) as ControlComponentData;
Log.showDebug(TAG, `linkItemData, mItemData: ${this.keyId} ${this.mItemData.label} ${this.mItemData.iconUrl}`);
}
@@ -55,8 +55,8 @@ export default struct ComplexToggleComponent {
iconOnStr: this.mItemData
.iconUrl,
changeSwitch: $mStatus,
mClickEvent: () => this.onIconItemClick(),
mLongClickEvent: () => this.onIconItemLongPressGesture()
mClickEvent: (): void => this.onIconItemClick(),
mLongClickEvent: (): void => this.onIconItemLongPressGesture()
})
}.width('100%')
.height('100%')
@@ -28,14 +28,16 @@ const TAG = 'Control-ControlCenter';
const TAG_ControlCenterComplexToggleLayout = 'Control-ControlCenterComplexToggleLayout';
const TAG_ControlCenterSimpleToggleLayout = 'Control-ControlCenterSimpleToggleLayout';
var mUniform;
interface IDirection {
direction: string
}
@Component
export default struct ControlCenterComponent {
private touchMoveCallback: Function;
private modeChangeCallback: Function;
private touchMoveCallback: Function = () => {};
private modeChangeCallback: Function = () => {};
@State mSimpleToggleColumnCount: number = Constants.DEFAULT_SIMPLE_TOGGLE_COLUMN_COUNT;
private mControlCenterComponentConfig: ControlCenterConfig;
private mControlCenterComponentConfig: ControlCenterConfig | undefined = undefined;
@State mIsEditSimpleToggleLayout: boolean = false;
@State style: ControlCenterComponentStyle = StyleConfiguration.getControlCenterComponentStyle();
private mWidthPx: number = 0;
@@ -100,12 +102,12 @@ export default struct ControlCenterComponent {
Column() {
Column() {
UpTitle({
touchMoveCallback: (data) => {
touchMoveCallback: (data: IDirection) => {
if (this.touchMoveCallback) {
this.touchMoveCallback(data)
}
},
simpleToggleLayoutEditStartCallback: () => this.onSimpleToggleLayoutEditStart()
simpleToggleLayoutEditStartCallback: ():void => this.onSimpleToggleLayoutEditStart()
})
}
.width('100%')
@@ -143,7 +145,7 @@ export default struct ControlCenterComponent {
mDisplayingToggles: this.mDisplayingSimpleToggles,
mHidingToggles: this.mHidingSimpleToggles,
mDefaultDisplayToggles: this.mDefaultDisplaySimpleToggles,
simpleToggleLayoutEditEndCallback: () => this.onSimpleToggleLayoutEditEnd(),
simpleToggleLayoutEditEndCallback: (): void => this.onSimpleToggleLayoutEditEnd(),
onSaveDisplayingToggles: (toggles: string[]) => this.onSaveDisplayingToggles(toggles),
mColumnCount: this.mSimpleToggleColumnCount,
titleDisplayInside: this.titleDisplayInside
@@ -178,7 +180,7 @@ struct ControlCenterComplexToggleLayout {
build() {
Grid() {
ForEach(this.mComplexToggleLayout, (componentName) => {
ForEach(this.mComplexToggleLayout, (componentName: string) => {
GridItem() {
ComplexToggleLoadComponent({
keyId: componentName
@@ -186,17 +188,20 @@ struct ControlCenterComplexToggleLayout {
}
.width('100%')
.height('100%')
}, (componentName) => componentName)
}, (componentName: string) => componentName)
}
.width('100%')
.height(this.calcGridHeight(Math.ceil(this.mComplexToggleLayout.length / 2), this.style.rowHeight, this.style.rowGap))
.height(this.calcGridHeight(
Math.ceil(this.mComplexToggleLayout.length / 2),
this.style.rowHeight as number,
this.style.rowGap as number))
.columnsTemplate('1fr 1fr')
.rowsTemplate(this.generateRowsTemplate(Math.ceil(this.mComplexToggleLayout.length / 2)))
.rowsGap(this.style.rowGap + 'px')
.columnsGap(this.style.columnGap)
}
calcGridHeight(rowCount, rowHeight, rowGap) {
calcGridHeight(rowCount: number, rowHeight: number, rowGap: number) {
Log.showDebug(TAG_ControlCenterComplexToggleLayout, `calcGridHeight, rowCount: ${rowCount} rowHeight: ${rowHeight} rowGap: ${rowGap}`);
let height = rowCount * rowHeight + (rowCount - 1) * rowGap;
if (height < 0) {
@@ -206,7 +211,7 @@ struct ControlCenterComplexToggleLayout {
return height + 'px';
}
generateRowsTemplate(rowCount) {
generateRowsTemplate(rowCount: number) {
Log.showDebug(TAG_ControlCenterComplexToggleLayout, `generateRowsTemplate, rowCount: ${rowCount}`);
let rowsTemplate = '1fr';
for (let i = 1;i < rowCount; i++) {
@@ -232,17 +237,21 @@ struct ControlCenterSimpleToggleLayout {
build() {
Grid() {
ForEach(this.mSimpleToggleLayout, (componentName) => {
ForEach(this.mSimpleToggleLayout, (componentName: string) => {
GridItem() {
SimpleToggleLoadComponent({
keyId: componentName
})
}.width('100%')
.height('100%')
}, (componentName) => componentName)
}, (componentName: string) => componentName)
}
.width('100%')
.height(this.calcGridHeight(Math.ceil(this.mSimpleToggleLayout.length / this.mColumnCount), this.style.rowHeight, this.style.rowGap))
.height(this.calcGridHeight(
Math.ceil(
this.mSimpleToggleLayout.length / this.mColumnCount),
this.style.rowHeight as number,
this.style.rowGap as number))
.margin({left: this.style.marginLeft, right: this.style.marginRight})
.columnsTemplate(this.generateColumnsTemplate(this.mColumnCount))
.rowsTemplate(this.generateRowsTemplate(Math.ceil(this.mSimpleToggleLayout.length / this.mColumnCount)))
@@ -250,7 +259,7 @@ struct ControlCenterSimpleToggleLayout {
.columnsGap(this.style.columnGap)
}
calcGridHeight(rowCount, rowHeight, rowGap) {
calcGridHeight(rowCount: number, rowHeight: number, rowGap: number) {
Log.showDebug(TAG_ControlCenterSimpleToggleLayout, `calcGridHeight, rowCount: ${rowCount} rowHeight: ${rowHeight} rowGap: ${rowGap}`);
let height = rowCount * rowHeight + (rowCount - 1) * rowGap;
if (height < 0) {
@@ -260,7 +269,7 @@ struct ControlCenterSimpleToggleLayout {
return height + 'px';
}
generateColumnsTemplate(columnCount) {
generateColumnsTemplate(columnCount: number) {
Log.showDebug(TAG_ControlCenterSimpleToggleLayout, `generateColumnsTemplate, columnCount: ${columnCount}`);
let columnsTemplate = '1fr';
for (let i = 1;i < columnCount; i++) {
@@ -269,7 +278,7 @@ struct ControlCenterSimpleToggleLayout {
return columnsTemplate;
}
generateRowsTemplate(rowCount) {
generateRowsTemplate(rowCount: number) {
Log.showDebug(TAG_ControlCenterSimpleToggleLayout, `generateRowsTemplate, rowCount: ${rowCount}`);
let rowsTemplate = '1fr';
for (let i = 1;i < rowCount; i++) {
@@ -23,7 +23,7 @@ const TAG = 'PluginIconItemComponent';
@Component
export default struct PluginIconItemComponent {
private keyId: string;
private keyId: string = '';
private mEditMode: boolean = false;
private mDragMode: boolean = false;
@State @Watch('onPluginDataChange') mPluginData: PluginComponentData = new PluginComponentData();
@@ -55,8 +55,8 @@ export default struct PluginIconItemComponent {
data: this.mPluginData.data
}).onComplete(() => {
Log.showInfo(TAG, `PluginComponent.Complete`)
}).onError(({errcode, msg}) => {
Log.showInfo(TAG, `PluginComponent.Error code:${errcode} message:${msg}`)
}).onError((error) => {
Log.showInfo(TAG, `PluginComponent.Error code:${error.errcode} message:${error.msg}`)
})
.size({ width: '100%', height: '100%' })
}
@@ -24,7 +24,7 @@ const TAG = 'SimpleToggleComponent';
@Component
export default struct SimpleToggleComponent {
private keyId: string;
@Prop keyId: string;
@State mItemData: ControlComponentData = {};
private mEditMode: boolean = false;
private mDragMode: boolean = false;
@@ -43,7 +43,7 @@ export default struct SimpleToggleComponent {
linkItemData() {
Log.showDebug(TAG, `linkItemData, keyId: ${this.keyId}`);
this.mItemData = AppStorage.Get('ControlCenter_' + this.keyId);
this.mItemData = AppStorage.Get('ControlCenter_' + this.keyId) as ControlComponentData;
Log.showDebug(TAG, `linkItemData, mItemData: ${this.keyId} ${this.mItemData.label} ${this.mItemData.iconUrl}`);
}
@@ -70,8 +70,8 @@ export default struct SimpleToggleComponent {
mUseLabelStr: true,
mEditMode: this.mEditMode,
mDragMode: this.mDragMode,
mClickEvent: () => this.onIconItemClick(),
mLongClickEvent: () => this.onIconItemLongPressGesture()
mClickEvent: (): void => this.onIconItemClick(),
mLongClickEvent: (): void => this.onIconItemLongPressGesture()
})
} else if (this.mItemData.pluginType == PluginType.DATA_ABILITY) {
// TODO:
@@ -30,8 +30,8 @@ export default struct SimpleToggleLayoutEditComponent {
private mHidingToggles: string[] = [];
private mDefaultDisplayToggles: string[] = [];
@Prop mColumnCount: number;
private simpleToggleLayoutEditEndCallback: () => void;
private onSaveDisplayingToggles: (toggles: string[]) => void;
private simpleToggleLayoutEditEndCallback: () => void = () => {};
private onSaveDisplayingToggles: (toggles: string[]) => void = (toggles) => {};
@State mNewDisplayingToggles: string[] = [];
@State mNewHidingToggles: string[] = [];
@State style: SimpleToggleLayoutEditComponentStyle = StyleConfiguration.getSimpleToggleLayoutEditComponentStyle();
@@ -42,27 +42,27 @@ export default struct SimpleToggleLayoutEditComponent {
private mHidingTogglesMinCount: number = 0;
@State mCurrentDragToggleName: string = '';
private titleDisplayInside: boolean = false;
private backDialogController: CustomDialogController = new CustomDialogController({
private backDialogController: CustomDialogController | null = new CustomDialogController({
builder: SimpleToggleLayoutEditDialogComponent({
title: $r("app.string.control_center_simple_toggle_layout_edit_back_confirm"),
leftButton: $r("app.string.control_center_simple_toggle_layout_edit_back_confirm_primary"),
rightButton: $r("app.string.control_center_simple_toggle_layout_edit_back_confirm_secondary"),
leftAction: () => this.callSimpleToggleLayoutEditEnd(),
rightAction: () => this.onFinishBtnClick(null),
leftAction: (): void => this.callSimpleToggleLayoutEditEnd(),
rightAction: (): void => this.onFinishBtnClick(),
}),
autoCancel: false,
offset: { dx: 0, dy: 0 },
customStyle: true,
alignment: DialogAlignment.Center
});
private resetDialogController: CustomDialogController = new CustomDialogController({
private resetDialogController: CustomDialogController | null = new CustomDialogController({
builder: SimpleToggleLayoutEditDialogComponent({
title: $r("app.string.control_center_simple_toggle_layout_edit_reset_confirm"),
leftButton: $r("app.string.control_center_simple_toggle_layout_edit_reset_confirm_primary"),
rightButton: $r("app.string.control_center_simple_toggle_layout_edit_reset_confirm_secondary"),
leftAction: () => {
},
rightAction: () => this.editResetConfirm(),
rightAction: (): void => this.editResetConfirm(),
}),
autoCancel: false,
offset: { dx: 0, dy: 0 },
@@ -86,11 +86,8 @@ export default struct SimpleToggleLayoutEditComponent {
}
aboutToDisappear() {
delete this.backDialogController
this.backDialogController = undefined
delete this.resetDialogController
this.resetDialogController = undefined
this.backDialogController = null
this.resetDialogController = null
Log.showInfo(TAG, 'aboutToDisappear ');
}
@@ -100,7 +97,7 @@ export default struct SimpleToggleLayoutEditComponent {
if (!this.titleDisplayInside) {
Column() {
SimpleToggleLayoutEditUpTitle({
simpleToggleLayoutEditEndCallback: () => this.onSimpleToggleLayoutEditEnd()
simpleToggleLayoutEditEndCallback: (): void => this.onSimpleToggleLayoutEditEnd()
})
}
.width('100%')
@@ -112,7 +109,7 @@ export default struct SimpleToggleLayoutEditComponent {
if (this.titleDisplayInside) {
Column() {
SimpleToggleLayoutEditUpTitle({
simpleToggleLayoutEditEndCallback: () => this.onSimpleToggleLayoutEditEnd()
simpleToggleLayoutEditEndCallback: (): void => this.onSimpleToggleLayoutEditEnd()
})
}
.width('100%')
@@ -206,7 +203,7 @@ export default struct SimpleToggleLayoutEditComponent {
let changed = JSON.stringify(this.mDisplayingToggles) != JSON.stringify(this.mNewDisplayingToggles);
Log.showDebug(TAG, `onSimpleToggleLayoutEditEnd, changed: ${changed}`);
if (changed) {
this.backDialogController.open();
this.backDialogController?.open();
} else {
this.callSimpleToggleLayoutEditEnd();
};
@@ -224,7 +221,7 @@ export default struct SimpleToggleLayoutEditComponent {
let equalDefault = JSON.stringify(this.mDefaultDisplayToggles) == JSON.stringify(this.mNewDisplayingToggles);
Log.showDebug(TAG, `onResetBtnClick, equalDefault: ${equalDefault}`);
if (!equalDefault) {
this.resetDialogController.open();
this.resetDialogController?.open();
};
}
@@ -256,7 +253,7 @@ export default struct SimpleToggleLayoutEditComponent {
Log.showDebug(TAG, `resetData, mNewHidingToggles: ${JSON.stringify(this.mNewHidingToggles)}`);
}
onFinishBtnClick(event: ClickEvent) {
onFinishBtnClick() {
Log.showDebug(TAG, `onFinishBtnClick`);
let changed = JSON.stringify(this.mDisplayingToggles) != JSON.stringify(this.mNewDisplayingToggles);
Log.showDebug(TAG, `onFinishBtnClick, changed: ${changed}`);
@@ -281,7 +278,7 @@ export default struct SimpleToggleLayoutEditComponent {
async onDisplayingGridItemDrop(status: string): Promise<void> {
Log.showDebug(TAG, `onDisplayingGridItemDrop, status: ${status}`);
this.setOptMsg(null);
this.setOptMsg('');
}
async onHidingGridItemDragStart(toggleName: string): Promise<void> {
@@ -292,7 +289,7 @@ export default struct SimpleToggleLayoutEditComponent {
async onHidingGridItemDrop(status: string): Promise<void> {
Log.showDebug(TAG, `onHidingGridItemDrop, status: ${status}`);
this.setOptMsg(null);
this.setOptMsg('');
}
setOptMsg(toggleName: string): void {
@@ -324,7 +321,7 @@ export default struct SimpleToggleLayoutEditComponent {
@Component
struct SimpleToggleLayoutEditUpTitle {
private simpleToggleLayoutEditEndCallback: Function;
private simpleToggleLayoutEditEndCallback: Function = () => {};
@State style: SimpleToggleLayoutEditUpTitleStyle = StyleConfiguration.getSimpleToggleLayoutEditUpTitleStyle();
aboutToAppear() {
@@ -20,12 +20,12 @@ const TAG = 'Control-SimpleToggleLayoutEditDialogComponent';
@CustomDialog
export default struct SimpleToggleLayoutEditDialogComponent {
private title: Resource;
private leftButton: Resource;
private rightButton: Resource;
private title: Resource | undefined = undefined;
private leftButton: Resource| undefined = undefined;
private rightButton: Resource| undefined = undefined;
private controller: CustomDialogController;
private leftAction: () => void;
private rightAction: () => void;
private leftAction: () => void = () => {};
private rightAction: () => void = () =>{};
@State style: ControlEditDialogStyle = StyleConfiguration.getControlEditDialogStyle();
aboutToAppear() {
@@ -28,8 +28,8 @@ export default struct SimpleToggleLayoutEditGrid {
@Prop mGlobalDragToggleName: string;
private gridTag: string = '';
private logTag: string = '';
private onItemDragStart: (toggleName: string) => void;
private onItemDrop: (status: string) => void;
private onItemDragStart: (toggleName: string) => void = () => {};
private onItemDrop: (status: string) => void = () => {};
@State style: SimpleToggleLayoutEditGridStyle = StyleConfiguration.getSimpleToggleLayoutEditGridStyle();
private mCurrentDragToggleName: string = '';
@@ -94,7 +94,7 @@ export default struct SimpleToggleLayoutEditGrid {
.onItemDrop(this.onGridItemDrop.bind(this))
}
calcGridHeight(rowCount, rowHeight, rowGap) {
calcGridHeight(rowCount: number, rowHeight: number, rowGap: number) {
Log.showDebug(this.logTag, `calcGridHeight, rowCount: ${rowCount} rowHeight: ${rowHeight} rowGap: ${rowGap}`);
let height = rowCount * rowHeight + (rowCount - 1) * rowGap;
if (height <= 0) {
@@ -134,19 +134,19 @@ export default struct SimpleToggleLayoutEditGrid {
return minRowCount;
}
onItemDragEnter(event) {
onItemDragEnter(event: ItemDragInfo) {
Log.showDebug(this.logTag, `onItemDragEnter, event: ${JSON.stringify(event)}`);
}
onItemDragMove(event, itemIndex, insertIndex) {
onItemDragMove(event: ItemDragInfo, itemIndex: number, insertIndex: number) {
Log.showDebug(this.logTag, `onItemDragMove, itemIndex: ${itemIndex} insertIndex: ${insertIndex} event: ${JSON.stringify(event)}`);
}
onItemDragLeave(event, itemIndex) {
onItemDragLeave(event: ItemDragInfo, itemIndex: number) {
Log.showDebug(this.logTag, `onItemDragLeave, itemIndex: ${itemIndex} event: ${JSON.stringify(event)}`);
}
onGridItemDragStart(event, itemIndex) {
onGridItemDragStart(event: ItemDragInfo, itemIndex: number) {
Log.showDebug(this.logTag, `onGridItemDragStart, itemIndex: ${itemIndex} event: ${JSON.stringify(event)}`);
this.mCurrentDragToggleName = this.mToggles[itemIndex];
if (this.onItemDragStart) {
@@ -155,7 +155,7 @@ export default struct SimpleToggleLayoutEditGrid {
Log.showDebug(this.logTag, `onGridItemDragStart, mCurrentDragToggleName: ${this.mCurrentDragToggleName}`);
}
onGridItemDrop(event, itemIndex, insertIndex, isSuccess) {
onGridItemDrop(event: ItemDragInfo, itemIndex: number, insertIndex: number, isSuccess: boolean) {
Log.showDebug(this.logTag, `onGridItemDrop, itemIndex: ${itemIndex} insertIndex: ${insertIndex} isSuccess: ${isSuccess} event: ${JSON.stringify(event)}`);
if (!isSuccess) {
this.callOnItemDrop('fail');
@@ -27,7 +27,7 @@ const TAG = 'SimpleToggleLoadComponent';
@Component
export default struct SimpleToggleLoadComponent {
private keyId: string
private keyId: string = ''
private mEditMode: boolean = false
private mDragMode: boolean = false
@@ -21,10 +21,14 @@ import StyleConfiguration, { ControlCenterUpTitleStyle } from '../common/StyleCo
const TAG = 'Control-UpTitle';
interface IDirection {
direction: string
}
@Component
export default struct UpTitle {
private touchMoveCallback: Function;
private simpleToggleLayoutEditStartCallback: Function;
private touchMoveCallback: Function = (data: IDirection) => {};
private simpleToggleLayoutEditStartCallback: Function = () => {};
startX: number = 0;
startY: number = 0;
@State moveX: number = 0;
@@ -24,7 +24,7 @@ const TAG = 'location-ControlCenterSimpleToggleLocationComponent';
@Component
export default struct ControlCenterSimpleToggleLocationComponent {
private keyId: string;
private keyId: string = '';
private mEditMode: boolean = false;
private mDragMode: boolean = false;
@State mIcon: Resource = $r("app.media.ic_controlcenter_gps");
@@ -48,8 +48,8 @@ export default struct ControlCenterSimpleToggleLocationComponent {
mLabel: $mLabel,
mEditMode: this.mEditMode,
mDragMode: this.mDragMode,
mClickEvent: () => this.mClickEvent(),
mLongClickEvent: () => this.mLongClickEvent()
mClickEvent: (): void => this.mClickEvent(),
mLongClickEvent: (): void => this.mLongClickEvent()
})
}
@@ -3,5 +3,7 @@
"name": "@ohos/managementcomponent",
"description": "a npm package which contains managementcomponent function",
"version": "1.0.0",
"dependencies": {}
"dependencies": {
"@ohos/common": "file:../../common"
}
}
@@ -16,11 +16,10 @@ import Log from '../../../../../../../../common/src/main/ets/default/Log';
import Notification from '@ohos.notification';
import NotificationManager from '@ohos.notificationManager';
import NotificationSubscribe from '@ohos.notificationSubscribe';
import type { NotificationSubscriber } from 'notification/notificationSubscriber';
const TAG = 'NotificationManagenment-NotificationListener';
interface IOnEnableChanged {
export interface IOnEnableChanged {
(value: boolean): void;
}
@@ -36,7 +35,7 @@ export interface BundleOption {
export class NotificationListener {
private readonly listeners = new Map<string, Set<IOnEnableChanged>>();
private subscriber: NotificationSubscriber = {
private subscriber: NotificationSubscribe.NotificationSubscriber = {
onEnabledNotificationChanged: this.handleEnabledNotificationChanged.bind(this)
};
@@ -126,7 +125,7 @@ export class NotificationListener {
});
}
async isNotificationSlotEnabled(bundleOption: BundleOption, slotType: Notification.SlotType, callback?: (data) => void): Promise<boolean> {
async isNotificationSlotEnabled(bundleOption: BundleOption, slotType: Notification.SlotType, callback?: (data: boolean) => void): Promise<boolean> {
Log.showDebug(TAG, `isNotificationSlotEnabled bundleOption:${JSON.stringify(bundleOption)} `);
return new Promise((resolve, reject) => {
NotificationManager.isNotificationSlotEnabled(bundleOption, slotType, (err, data) => {
@@ -175,7 +174,7 @@ export class NotificationListener {
});
}
enableDistributed(data: boolean): void {
enableDistributed(data?: boolean): void {
Log.showDebug(TAG, `enableDistributed data:${JSON.stringify(data)}`);
let enableValue: boolean = data ? true : false;
NotificationManager.setDistributedEnable(enableValue, (err, result) => {
@@ -230,7 +230,7 @@ export default struct AppItemComponent {
Log.showInfo(TAG, `NotificationListener.isNotificationEnabled data:${JSON.stringify(stateValue)}`);
this.canNotice = stateValue;
})
.catch((error) => {
.catch((error: Error) => {
Log.showError(TAG, `NotificationListener.isNotificationEnabled error:${JSON.stringify(error)}`);
});
@@ -16,16 +16,18 @@ import ConfigData from '../../common/constants';
import AppItemComponent from './appItemComponent';
import Router from '@system.router';
import Log from '../../../../../../../../../common/src/main/ets/default/Log';
import ViewModel from '../../vm/appLstComponentViewModel'
import ViewModel from '../../vm/appLstComponentViewModel';
import { BundleItemData }from '../../model/bundleResourceModel';
const TAG = 'ManagementComponent-AppLstComponent';
@Component
export default struct AppLstComponent {
@StorageLink('appManagementList') appList: any[]= [];
@StorageLink('appManagementList') appList: BundleItemData[]= [];
aboutToAppear(): void{
Log.showInfo(TAG, `aboutToAppear`);
Log.showWarn(TAG, `myTest`);
ViewModel.viewModelInit();
}
@@ -43,14 +45,14 @@ export default struct AppLstComponent {
build() {
List() {
ForEach(this.appList, (item) => {
ForEach(this.appList, (item: BundleItemData) => {
ListItem() {
AppItemComponent({
appIcon: item.appIcon,
appTitle: item.appTitle,
appSummary: item.appSummary,
appValue: item.appValue,
appArrow: item.appArrow,
appArrow: item.appArrow as string,
appArrowStyle: '',
appUri: item.appUri,
appBundleName: item.appBundleName,
@@ -17,13 +17,15 @@ import Log from '../../../../../../../../../common/src/main/ets/default/Log';
import SlotItemComponent from './slotItemComponent';
import Notification from '@ohos.notification';
import Router from '@system.router'
import { BundleItemData } from '@ohos/common';
import NotificationManager from '@ohos.notificationManager';
const TAG = 'ManagementComponent-SlotLstComponent';
@Component
export default struct SlotLstComponent {
private appInfo: any= null;
@Link slotLst: any[];
@Prop appInfo: BundleItemData;
@Link slotLst: NotificationManager.NotificationSlot[];
build() {
Flex({ justifyContent: FlexAlign.SpaceBetween }) {
@@ -42,13 +44,13 @@ export default struct SlotLstComponent {
.align(Alignment.Start);
Row() {
List() {
ForEach(this.slotLst, (item) => {
ForEach(this.slotLst, (item: NotificationManager.NotificationSlot) => {
ListItem() {
SlotItemComponent({ slotType: item.type })
}
.onClick(() => {
Log.showInfo(TAG, `onClick`);
Router.push({ uri: this.appInfo.slotSettingUrl, params: {appInfo:this.appInfo,slotInfo:item} });
Router.push({ uri: this.appInfo.slotSettingUrl, params: {appInfo:this.appInfo, slotInfo:item} });
})
});
}.divider({
@@ -14,16 +14,17 @@
*/
import ConfigData from '../../common/constants';
import Log from '../../../../../../../../../common/src/main/ets/default/Log';
import { IOnEnableChanged } from '../../model/notificationListener';
const TAG = 'ManagementComponent-SwitchComponent';
@Component
export default struct SwitchComponent {
@Link title: Resource;
describe: Resource;
private initializationAction: (params?) => Promise<any>
private settingAction: (params?) => void
private register?: (listener) => void
@Prop describe: Resource;
private initializationAction?: (params?: boolean) => Promise<boolean>
private settingAction?: (params?: boolean) => void
private register?: (listener: IOnEnableChanged) => void
@State initState: boolean = false
build() {
@@ -59,7 +60,7 @@ export default struct SwitchComponent {
.onChange((data) => {
Log.showInfo(TAG, `Toggle onChange data:${data}`);
this.initState = data ? true : false;
this.settingAction(data);
this.settingAction && this.settingAction(data);
})
}
.flexShrink(0)
@@ -76,9 +77,11 @@ export default struct SwitchComponent {
aboutToAppear(): void{
Log.showInfo(TAG, `aboutToAppear`);
this.initializationAction().then((data) => {
Log.showInfo(TAG, `initializationAction:${data}`);
this.initState = data;
})
if (this.initializationAction) {
this.initializationAction().then((data) => {
Log.showInfo(TAG, `initializationAction:${data}`);
this.initState = data;
})
}
}
}
@@ -16,7 +16,7 @@
import Log from '../../../../../../../../common/src/main/ets/default/Log';
import EventManager from "../../../../../../../../common/src/main/ets/default/event/EventManager";
import { obtainStartAbility } from "../../../../../../../../common/src/main/ets/default/event/EventUtil";
import NfcController from '@ohos.nfc.controller';
import { nfcController } from '@kit.ConnectivityKit';
import ViewModel from '../viewmodel/NFCModeVM';
import SimpleToggleBase from '../../../../../../../../common/src/main/ets/template/SimpleToggleBase';
@@ -24,13 +24,13 @@ const TAG = 'nfcmode-ControlCenterSimpleToggleNFComponent';
@Component
export default struct ControlCenterSimpleToggleNFComponent {
private keyId: string;
private keyId: string = '';
private mEditMode: boolean = false;
private mDragMode: boolean = false;
@State mIcon: Resource = $r("app.media.ic_notification_nfc_filled");
@State mLabel: Resource = $r("app.string.control_center_complex_toggle_nfc_mode_title");
@State mDefaultChangeSwitch: boolean = false;
@StorageLink('NFCModeComponentMode') @Watch('onNFCModeUpdated') NFCModeComponentMode: NfcController.NfcState = NfcController.NfcState.STATE_OFF;
@StorageLink('NFCModeComponentMode') @Watch('onNFCModeUpdated') NFCModeComponentMode: nfcController.NfcState = nfcController.NfcState.STATE_OFF;
aboutToAppear() {
Log.showInfo(TAG, 'aboutToAppear');
ViewModel.initViewModel();
@@ -43,9 +43,9 @@ export default struct ControlCenterSimpleToggleNFComponent {
onNFCModeUpdated(propName: string): void {
Log.showInfo(TAG, `onNFCModeUpdated, propName: ${propName} NFCModeComponentMode: ${JSON.stringify(this.NFCModeComponentMode)}`);
if (this.NFCModeComponentMode == NfcController.NfcState.STATE_OFF) {
if (this.NFCModeComponentMode == nfcController.NfcState.STATE_OFF) {
this.mDefaultChangeSwitch = false;
} else if (this.NFCModeComponentMode == NfcController.NfcState.STATE_ON) {
} else if (this.NFCModeComponentMode == nfcController.NfcState.STATE_ON) {
this.mDefaultChangeSwitch = true;
}
}
@@ -58,16 +58,16 @@ export default struct ControlCenterSimpleToggleNFComponent {
mLabel: $mLabel,
mEditMode: this.mEditMode,
mDragMode: this.mDragMode,
mClickEvent: () => this.mClickEvent()
mClickEvent: (): void => this.mClickEvent()
})
}
mClickEvent() {
Log.showInfo(TAG, `mClickEvent---${this.NFCModeComponentMode}`);
if (this.NFCModeComponentMode == NfcController.NfcState.STATE_OFF) {
ViewModel.setNFCMode(NfcController.NfcState.STATE_OFF)
} else if (this.NFCModeComponentMode == NfcController.NfcState.STATE_ON) {
ViewModel.setNFCMode(NfcController.NfcState.STATE_ON)
if (this.NFCModeComponentMode == nfcController.NfcState.STATE_OFF) {
ViewModel.setNFCMode(nfcController.NfcState.STATE_OFF)
} else if (this.NFCModeComponentMode == nfcController.NfcState.STATE_ON) {
ViewModel.setNFCMode(nfcController.NfcState.STATE_ON)
}
}
}
@@ -29,12 +29,11 @@ export default struct StatusBarIconItemNFCModeComponent {
@State mTintContentInfo: TintContentInfo = ViewModel.getTintContentInfo();
@State styleCommon: CommonStyle = StyleConfigurationCommon.getCommonStyle();
@State style: StatusRingModeComponentStyle = StyleConfiguration.getStatusRingModeComponentStyle();
private ringModeIcons: any;
private ringModeIcons: Resource[] = [];
aboutToAppear() {
Log.showInfo(TAG, 'aboutToAppear');
this.ringModeIcons = {};
this.ringModeIcons['0'] = $r("app.media.ic_statusbar_nfc");
this.ringModeIcons[0] = $r("app.media.ic_statusbar_nfc");
ViewModel.initViewModel();
}
@@ -46,7 +45,7 @@ export default struct StatusBarIconItemNFCModeComponent {
Row() {
if (this.NFCModeComponentMode != NfcController.NfcState.STATE_OFF) {
Row().width(this.styleCommon.statusBarMarginLeftRight).height('100%')
Image(this.ringModeIcons['0'])
Image(this.ringModeIcons[0])
.objectFit(ImageFit.Contain)
.width(this.style.statusBarRingModeWidth)
.height(this.style.statusBarRingModeHeight)
+3 -1
View File
@@ -3,5 +3,7 @@
"name": "@ohos/noticeitem",
"description": "a npm package which contains noticeitem function",
"version": "1.0.0",
"dependencies": {}
"dependencies": {
"@ohos/common": "file:../../common"
}
}
@@ -29,6 +29,9 @@ export default class CommonUtil {
static startWant(want, triggerInfo?: any): void {
let info = (triggerInfo) ? triggerInfo : DEFAULT_INFO;
Log.showDebug(TAG, `startWant ${JSON.stringify(want)}, info ${JSON.stringify(info)}`);
if (!want) {
return;
}
WantAgent.trigger(want, info, ((data) => {
Trace.end(Trace.CORE_METHOD_CLICK_NOTIFICATION);
Log.showInfo(TAG, `wantAgent trigger data ${JSON.stringify(data)}`);
@@ -12,6 +12,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import notificationManager from '@ohos.notificationManager';
import image from '@ohos.multimedia.image';
import { WantAgent } from '@ohos.wantAgent';
export default class Constants {
static readonly NOTIFICATION_TYPE_BASIC = '0';
@@ -90,12 +93,12 @@ export interface NotificationItemData {
timestamp: number;
time: string;
appName: string;
want: any;
actionButtons: any[];
want: WantAgent;
actionButtons: notificationManager.ButtonOptions[];
bundleName: string;
smallIcon?: PixelMap | string;
largeIcon?: PixelMap | string;
picture?: PixelMap;
smallIcon?: image.PixelMap | string;
largeIcon?: image.PixelMap | string;
picture?: image.PixelMap;
title?: string;
text?: string;
additionalText?: string;
@@ -15,7 +15,6 @@
import Log from '../../../../../../../../../common/src/main/ets/default/Log';
import deviceManager from '@ohos.distributedDeviceManager';
import DeviceInfo from '@ohos.deviceInfo';
const TAG = 'NotificationDistributionManager';
@@ -56,7 +55,7 @@ export default class NotificationDistributionManager {
getTrustedDeviceDeviceName(deviceId: string): string {
Log.showInfo(TAG, `getTrustedDeviceDeviceName deviceId:${deviceId}`);
let deviceName = '';
let deviceArr: any[] = this.getTrustedDeviceListSync();
let deviceArr: deviceManager.DeviceBasicInfo[] = this.getTrustedDeviceListSync();
Log.showDebug(TAG, `getTrustedDeviceDeviceName deviceArr:${JSON.stringify(deviceArr)}`);
if (deviceArr.length > 0) {
for (let item of deviceArr) {
@@ -69,7 +68,7 @@ export default class NotificationDistributionManager {
return deviceName;
}
getTrustedDeviceListSync(): any[] {
getTrustedDeviceListSync(): deviceManager.DeviceBasicInfo[] {
Log.showInfo(TAG, 'getTrustedDeviceListSync');
return this.deviceManager.getAvailableDeviceListSync();
}
@@ -14,14 +14,14 @@
*/
import Log from '../../../../../../../../../common/src/main/ets/default/Log';
import Constants, {NotificationLayout as Layout} from '../common/constants';
import Constants, {NotificationLayout as Layout, NotificationItemData} from '../common/constants';
import NotificationItem from './item/notificationItem';
import GroupNotificationItem from './item/groupItem';
import ExpandInfoManager from '../model/ExpandInfoManager';
const TAG = 'NoticeItem-NotificationListComponent';
type NotificationLayoutConfig = {
interface NotificationLayoutConfig {
itemMargin: number;
}
@@ -29,7 +29,7 @@ type NotificationLayoutConfig = {
export default struct NotificationListComponent {
// 当长通知消息展开时,这里用于重新刷新item布局,扩展高度
@Provide('notificationUpdate') update: number = 0;
@StorageLink('notificationList') notificationList: any[] = [];
@StorageLink('notificationList') notificationList: NotificationItemData[][] = [];
@Link listIsEnd: boolean
private config: NotificationLayoutConfig = {
itemMargin: Layout.ITEM_MARGIN
@@ -43,7 +43,7 @@ export default struct NotificationListComponent {
Log.showDebug(TAG, `aboutToDisAppear`);
}
deleteExpandInfo(itemData){
deleteExpandInfo(itemData: NotificationItemData){
ExpandInfoManager.deleteExpandInfo(itemData);
return true;
}
@@ -54,7 +54,7 @@ export default struct NotificationListComponent {
ListItem() {
}
}
ForEach(this.notificationList, (item: any) => {
ForEach(this.notificationList, (item: NotificationItemData[]) => {
ListItem() {
if (item.length > 1) {
GroupNotificationItem({ groupData: item })
@@ -65,7 +65,7 @@ export default struct NotificationListComponent {
}
}
}
}, (list: any) => JSON.stringify(list.map((item) => `${item.hashcode}_${item.timestamp}`)))
}, (list: NotificationItemData[]) => JSON.stringify(list.map((item) => `${item.hashcode}_${item.timestamp}`)))
}
.onReachEnd(() => {
this.listIsEnd = true;
@@ -37,10 +37,10 @@ export default struct SwipeLayout {
bottomRightWidth: number = 0;
leftThreshold: number = 0;
bottomHeight: number = 92;
deleteButtonCallback: any;
@BuilderParam SurfaceComponent?: () => void;
@BuilderParam BottomLeftComponent?: () => void;
registerEventCapture: (id: string) => boolean = null;
deleteButtonCallback: () => void = () => {};
@BuilderParam SurfaceComponent: () => void;
@BuilderParam BottomLeftComponent: () => void;
registerEventCapture: (id: string) => boolean = (id) => true;
// Page offset, opacity, width height status variable.
@State overallX: number = 0;
@@ -209,7 +209,7 @@ export default struct SwipeLayout {
return;
}
if(this.angelCalFlag == false){
var hasChange = Math.abs(touchEvent.touches[0].screenX - this.startX) > 1e-3 ||
let hasChange = Math.abs(touchEvent.touches[0].screenX - this.startX) > 1e-3 ||
Math.abs(touchEvent.touches[0].screenY - this.startY) > 1e-3
if (hasChange) {
this.responseSwipeEvent = (Math.abs(touchEvent.touches[0].screenX - this.startX) > Math.abs(touchEvent.touches[0].screenY - this.startY));
@@ -16,26 +16,28 @@
import Log from '../../../../../../../../../../common/src/main/ets/default/Log';
import CheckEmptyUtils from '../../../../../../../../../../common/src/main/ets/default/CheckEmptyUtils';
import NotificationViewModel from '../../viewmodel/NotificationViewModel';
import Constants, {InputActionButtonData, NotificationLayout as Layout} from '../../common/constants';
import Constants, {InputActionButtonData, NotificationLayout as Layout, NotificationItemData} from '../../common/constants';
import notificationManager from '@ohos.notificationManager';
import type { WantAgent } from '@kit.AbilityKit';
const TAG = 'NoticeItem-ActionComponent';
class actionInputData {
inputKey?;
wantAgent?
inputKey?: string;
wantAgent?: WantAgent
}
@Component
export default struct ActionComponent {
@State showInputText: boolean = false;
@State placeholder: string = '';
@State inputData: actionInputData = undefined;
@State inputData: actionInputData | undefined = undefined;
@State inputActionData: InputActionButtonData = new InputActionButtonData();
private itemData: any = undefined;
@Prop itemData: NotificationItemData;
aboutToAppear() {
Log.showInfo(TAG, `aboutToAppear Start`);
let actionData = AppStorage.Get(Constants.KEY_INPUT + this.itemData.id);
let actionData = AppStorage.Get(Constants.KEY_INPUT + this.itemData.id) as actionInputData;
this.inputActionData = (actionData instanceof InputActionButtonData) ? actionData : this.inputActionData;
}
@@ -46,14 +48,14 @@ export default struct ActionComponent {
build() {
Flex({ direction: FlexDirection.Row, justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) {
if (!this.inputData) {
ForEach(this.itemData.actionButtons, (item: any) => {
ForEach(this.itemData.actionButtons, (item: notificationManager.NotificationActionButton) => {
ActionButton({
content: item.title,
clickEvent: () => {
if (CheckEmptyUtils.isEmpty(item.userInput)) {
NotificationViewModel.clickItem(this.itemData, item.wantAgent);
} else {
this.inputData = { inputKey: item.userInput.inputKey, wantAgent: item.wantAgent };
this.inputData = { inputKey: item.userInput?.inputKey, wantAgent: item.wantAgent };
}
}
})
@@ -72,7 +74,7 @@ export default struct ActionComponent {
.width(Layout.INPUT_IMAGE_SIZE)
.height(Layout.INPUT_IMAGE_SIZE)
.onClick(() => {
NotificationViewModel.clickReply(this.inputData.inputKey, this.placeholder, this.inputData.wantAgent);
NotificationViewModel.clickReply(this.inputData?.inputKey, this.placeholder, this.inputData?.wantAgent);
this.inputActionData = {
isSending: true,
content: this.placeholder
@@ -16,7 +16,8 @@
import Log from '../../../../../../../../../../common/src/main/ets/default/Log';
import AbilityManager from '../../../../../../../../../../common/src/main/ets/default/abilitymanager/abilityManager';
import WindowManager, { WindowType } from '../../../../../../../../../../common/src/main/ets/default/WindowManager';
import {notificationData} from '../../../../../../../../../../common/src/main/ets/plugindatasource/common/Constants'
// import {notificationData} from '../../../../../../../../../../common/src/main/ets/plugindatasource/common/Constants'
import { NotificationItemData } from '@ohos/common'
import Constants, {NotificationLayout as Layout} from '../../common/constants';
import NotificationViewModel from '../../viewmodel/NotificationViewModel';
import CustomItem from './customItem';
@@ -28,32 +29,47 @@ import pictureItem from './pictureItem';
import ActionComponent from './actionComponent';
import DevicesDialog from './devicesDialog';
import WantAgent from '@ohos.wantAgent';
import { Rect } from '@ohos/common';
const TAG = 'NoticeItem-BannerNotificationItem';
const INTERVAL = 5 * 1000;
class EmptyObject {}
interface TriggerInfo {
code: number;
want: Want | undefined;
permission: string;
extraInfo: EmptyObject;
}
@Component
export default struct BannerNotificationItem {
@State want : notificationData = new notificationData();
@State want : NotificationItemData | undefined = undefined;
@Link distributedDeviceName: string;
@Link mBannerNoticeCnt: number;
@Link mLastActionTime: number;
@Link needExpand: boolean;
@Link isExpand: boolean;
@State mCloseEnableFlg: boolean = false;
private nowWant: any;
private onBannerNoticeHide: () => void
private devicesDialogController: CustomDialogController = new CustomDialogController({
private nowWant: Want | undefined = undefined;
private onBannerNoticeHide: () => void = () => {};
private devicesDialogController: CustomDialogController | null = new CustomDialogController({
builder: DevicesDialog({
action: (deviceID) => this.selectedDevice(deviceID)
action: (deviceID): void => this.selectedDevice(deviceID)
}),
autoCancel: false,
offset: { dx: 0, dy: 200 }
});
mInterval: number = INTERVAL;
mDefaultBannerRect: any;
mDefaultBannerRect: Rect = {
left: 0,
top: 0,
width: 0,
height: 0
};
expandPaddingBottom: number = Layout.EXPAND_PADDING_BOTTOM;
aboutToAppear() {
@@ -68,29 +84,28 @@ export default struct BannerNotificationItem {
}
aboutToDisappear() {
delete this.devicesDialogController
this.devicesDialogController = undefined
this.devicesDialogController = null;
Log.showInfo(TAG, `aboutToDisAppear`);
}
build() {
Column() {
if (this.mBannerNoticeCnt > 0) {
if (this.want.template) {
if (this.want?.template) {
CustomItem({ customItemData: this.want, isSubItem: false })
} else {
Row() {
Flex({ alignItems: ItemAlign.Center, justifyContent: FlexAlign.Start }) {
Row() {
titleItem({
notificationSmallIcon: this.want.smallIcon,
notificationName: this.want.appName,
notificationTime: this.want.time,
notificationSmallIcon: this.want?.smallIcon as PixelMap,
notificationName: this.want?.appName,
notificationTime: this.want?.time,
isExpand: $isExpand,
needExpand: this.needExpand,
distributedDeviceName: this.distributedDeviceName,
isSubItem: false,
clickTitleAction: () => this.refreshLastActionTime()
clickTitleAction: (): void => this.refreshLastActionTime()
})
}
@@ -113,7 +128,7 @@ export default struct BannerNotificationItem {
isExpand: this.isExpand,
itemData: this.want
});
if (this.isExpand && this.want.actionButtons.length) {
if (this.isExpand && this.want?.actionButtons.length) {
ActionComponent({ itemData: this.want })
} else {
Blank()
@@ -128,15 +143,15 @@ export default struct BannerNotificationItem {
Log.showInfo(TAG, `onAreaChange, e: ${JSON.stringify(e)} e2: ${JSON.stringify(e2)}`);
let heightEx = parseInt(String(e['height']));
let heightCur = parseInt(String(e2['height']));
let heightWin = parseInt(this.mDefaultBannerRect['height']);
let heightWin = this.mDefaultBannerRect?.height;
if (this.isExpand) {
heightWin = heightWin + (heightCur - heightEx) + this.expandPaddingBottom;
heightWin = heightWin as number + (heightCur - heightEx) + this.expandPaddingBottom;
}
let bannerRect = {
top: this.mDefaultBannerRect['top'],
left: this.mDefaultBannerRect['left'],
width: this.mDefaultBannerRect['width'],
height: heightWin
let bannerRect: Rect = {
top: this.mDefaultBannerRect.top,
left: this.mDefaultBannerRect.left,
width: this.mDefaultBannerRect.width,
height: heightWin as number
};
WindowManager.resetSizeWindow(WindowType.BANNER_NOTICE, bannerRect);
WindowManager.showWindow(WindowType.BANNER_NOTICE);
@@ -198,7 +213,7 @@ export default struct BannerNotificationItem {
WantAgent.getWant(wantAgent).then((wantData) => {
this.nowWant = wantData
if (!wantData?.deviceId) {
this.devicesDialogController.open();
this.devicesDialogController?.open();
} else{
NotificationViewModel.clickItem(this.want);
}
@@ -207,10 +222,12 @@ export default struct BannerNotificationItem {
}
}
selectedDevice(deviceID) {
selectedDevice(deviceID: string) {
Log.showInfo(TAG, `selectedDevice deviceID:${deviceID}`);
this.nowWant.deviceId = deviceID;
let triggerInfo = {
if (this.nowWant) {
this.nowWant.deviceId = deviceID;
}
let triggerInfo: TriggerInfo = {
code: 0,
want: this.nowWant,
permission: '',
@@ -231,7 +248,7 @@ export default struct BannerNotificationItem {
@Component
struct ContentComponent {
@Prop isExpand: boolean;
itemData: any;
@Prop itemData: NotificationItemData;
aboutToAppear() {
Log.showInfo(TAG, `aboutToAppear NotificationItemData: ${JSON.stringify(this.itemData)}`);
@@ -16,7 +16,7 @@
import Constants, {NotificationItemData, NotificationLayout as Layout} from '../../common/constants';
@Component
export default struct BasicItem {
@State itemData: NotificationItemData = undefined
@Prop itemData: NotificationItemData
build() {
Column() {
@@ -26,10 +26,10 @@ const TAG = 'NoticeItem-Confirm';
*/
@CustomDialog
export default struct ConfirmDialog {
private title: string | Resource
private bundleName: string
private title: string | Resource = ''
private bundleName: string = ''
public controller: CustomDialogController
public action: () => void
public action: () => void = () => {}
build() {
Column() {
@@ -18,22 +18,24 @@ import Log from '../../../../../../../../../../common/src/main/ets/default/Log';
import NotificationViewModel from '../../viewmodel/NotificationViewModel';
import NotificationManager from '../../model/NotificationManager';
import {NotificationLayout as Layout} from '../../common/constants';
import { NotificationItemData } from '@ohos/common'
import NtfMgr from '@ohos.notificationManager';
const TAG = 'NoticeItem-CustomItem';
@Component
export default struct CustomItem {
private customItemData: any = {};
private template: any = {};
private templateData: any = {};
private customItemData: NotificationItemData | undefined = undefined;
private template: PluginComponentTemplate | undefined = undefined;
private templateData: Record<string, Object> = {};
private isSubItem: boolean= false;
private isDebugMode: boolean = false;
private clickAction: () => void
private clickAction: () => void = () => {}
aboutToAppear() {
Log.showInfo(TAG, `aboutToAppear Start`);
this.template = NotificationViewModel.getPluginTempLate(this.customItemData.template.name);
this.templateData = this.customItemData.template.data;
this.template = NotificationViewModel.getPluginTempLate(this.customItemData?.template?.name);
this.templateData = this.customItemData?.template?.data as Record<string, Object>;
this.isDebugMode = NotificationManager.isDebugMode(TAG);
Log.showInfo(TAG, `template = ${JSON.stringify(this.template)} templateData = ${JSON.stringify(this.templateData)} isDebugMode = ${this.isDebugMode}`);
}
@@ -46,8 +48,8 @@ export default struct CustomItem {
data: this.templateData
}).onComplete(() => {
Log.showInfo(TAG, `Complete`);
}).onError(({errcode, msg}) => {
Log.showInfo(TAG, `Error code:${errcode} message:${msg}`);
}).onError((error) => {
Log.showInfo(TAG, `Error code:${error.errcode} message:${error.msg}`);
})
.size({ width: '100%', height: 110 })
}
@@ -16,6 +16,7 @@
import Constants from '../../common/constants';
import Log from '../../../../../../../../../../common/src/main/ets/default/Log';
import DistributionManager from '../../model/NotificationDistributionManager';
import deviceManager from '@ohos.distributedDeviceManager'
const TAG = 'NoticeItem-DevicesDialog';
@@ -25,9 +26,9 @@ const TAG = 'NoticeItem-DevicesDialog';
*/
@CustomDialog
export default struct DevicesDialog {
private deviceInfoList: Array<any>;
private deviceInfoList: Array<deviceManager.DeviceBasicInfo> = [];
public controller: CustomDialogController
public action: (deviceID) => void
public action: (deviceID: string) => void = (deviceID) => {}
build() {
Column({ space: 30 }) {
@@ -40,7 +41,7 @@ export default struct DevicesDialog {
Column() {
List() {
ForEach(this.deviceInfoList, (item) => {
ForEach(this.deviceInfoList, (item: deviceManager.DeviceBasicInfo) => {
ListItem() {
Row() {
Column() {
@@ -13,7 +13,7 @@
* limitations under the License.
*/
import Constants, { NotificationLayout as Layout } from '../../common/constants';
import Constants, { NotificationItemData, NotificationLayout as Layout } from '../../common/constants';
import basicItem from './basicItem';
import longItem from './longItem';
import multiItem from './multiItem';
@@ -33,8 +33,8 @@ export default struct GeneralItem {
@State @Watch('expandChange') isExpand: boolean = false
@State needExpand: boolean = true
@State distributedDeviceName: string = ''
private itemData: any = {}
private clickAction: () => void
@Prop itemData: NotificationItemData
private clickAction: () => void = () => {}
private isSubItem: boolean= false;
expandChange() {
@@ -70,7 +70,7 @@ export default struct GeneralItem {
build() {
Column() {
titleItem({
notificationSmallIcon: this.itemData.smallIcon,
notificationSmallIcon: this.itemData.smallIcon as PixelMap,
notificationName: this.itemData.appName,
notificationTime: this.itemData.time,
isExpand: $isExpand,
@@ -98,7 +98,7 @@ export default struct GeneralItem {
@Component
struct ContentComponent {
@Prop isExpand: boolean;
itemData: any;
@Prop itemData: NotificationItemData;
aboutToAppear() {
Log.showInfo(TAG, `aboutToAppear pict: ${this.itemData.picture}`);
@@ -14,7 +14,7 @@
*/
import Log from '../../../../../../../../../../common/src/main/ets/default/Log';
import Constants, { NotificationLayout as Layout } from '../../common/constants';
import Constants, { NotificationItemData, NotificationLayout as Layout } from '../../common/constants';
import NotificationItem from './notificationItem'
import NotificationViewModel from '../../viewmodel/NotificationViewModel';
import SwipeLayout from './SwipeLayout';
@@ -32,7 +32,7 @@ export default struct GroupItem {
@Consume('notificationUpdate') updateFlag: number;
@State distributedDeviceName: string = '';
@State @Watch('expandChange') toExpand: boolean = false;
private groupData: any[] = [];
private groupData: NotificationItemData[] = [];
registerGroupItemEventCapture(id: string){
if(FocusCallBack.getLastFocusId() == getId(this.groupData[0], true)){
@@ -59,7 +59,7 @@ export default struct GroupItem {
Log.showInfo(TAG, `aboutToDisAppear`);
}
deleteButtonCallback(){
deleteButtonCallback(): void {
ExpandInfoManager.deleteExpandInfo(this.groupData[0]);
NotificationViewModel.removeGroupNotification(this.groupData[0], true);
}
@@ -155,10 +155,10 @@ export default struct GroupItem {
@Component
struct ContentList {
@State @Watch('remainderChange') groupData: any[] = [];
@State @Watch('remainderChange') groupData: NotificationItemData[] = [];
@Prop toExpand: boolean;
@State remainderNum: number= 0;
registerEventCapture: (id: string) => boolean = null;
registerEventCapture: (id: string) => boolean = (id) => true;
registerContentListEventCapture(id: string){
if(this.registerEventCapture != null && this.registerEventCapture(id)){
@@ -232,11 +232,11 @@ struct ContentList {
} else {
List() {
ForEach(this.groupData, (item: any) => {
ForEach(this.groupData, (item: NotificationItemData) => {
ListItem() {
NotificationItem({ itemData: item, isSubItem: true, registerEventCapture: this.registerContentListEventCapture.bind(this) })
}
}, (item: any) => `${item.hashcode}_${item.timestamp}_subitem`)
}, (item: NotificationItemData) => `${item.hashcode}_${item.timestamp}_subitem`)
}
.divider({
strokeWidth: 1,
@@ -13,7 +13,7 @@
* limitations under the License.
*/
import Constants, { NotificationLayout as Layout } from '../../common/constants';
import Constants, { NotificationItemData, NotificationLayout as Layout } from '../../common/constants';
import Log from '../../../../../../../../../../common/src/main/ets/default/Log';
import SettingDialog from './settingDialog';
import ConfirmDialog from './confirmDialog'
@@ -24,12 +24,12 @@ const deviceTypeInfo = deviceInfo.deviceType;
const TAG = 'NoticeItem-IconListComponent';
let iconSize: number = 0;
type IconData = {
interface IconData {
src?: Resource;
callback?: () => void
}
export type NotificationUiConfig = {
export interface NotificationUiConfig {
iconSize: number;
}
@@ -40,23 +40,23 @@ export function getIconListSize(list?: IconData[]) {
@Component
export default struct IconListComponent {
private itemData: any = {}
private itemData: NotificationItemData | undefined = undefined
private isGroup: boolean= false;
@Prop iconAlpha: number
private settingDialogController: CustomDialogController = new CustomDialogController({
private settingDialogController: CustomDialogController | null = new CustomDialogController({
builder: SettingDialog({
itemData: this.itemData,
action: () => this.confirmDialogController.open()
action: (): void => this.confirmDialogController?.open()
}),
autoCancel: false,
alignment: deviceTypeInfo === 'phone' ? DialogAlignment.Bottom : DialogAlignment.Default,
offset: { dx: 0, dy: $r('app.float.setting_dialog_dy') },
customStyle: true
});
private confirmDialogController: CustomDialogController = new CustomDialogController({
private confirmDialogController: CustomDialogController | null = new CustomDialogController({
builder: ConfirmDialog({
title: $r('app.string.closeNovice'),
bundleName: this.itemData.name,
bundleName: this.itemData?.appName,
action: () => NotificationViewModel.enableNotification(this.itemData, false)
}),
autoCancel: false,
@@ -69,7 +69,7 @@ export default struct IconListComponent {
src: $r("app.media.ic_public_settings_filled"),
callback: () => {
Log.showInfo(TAG, `click settings hashcode: ${this.itemData?.hashcode}`);
this.settingDialogController.open()
this.settingDialogController?.open()
}
}, {
src: $r("app.media.ic_public_delete_filled"),
@@ -91,18 +91,14 @@ export default struct IconListComponent {
}
aboutToDisappear() {
delete this.settingDialogController
this.settingDialogController = undefined
delete this.confirmDialogController
this.confirmDialogController = undefined
this.settingDialogController = null
this.confirmDialogController = null
Log.showInfo(TAG, 'aboutToDisappear')
}
build() {
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.End, justifyContent: FlexAlign.End }) {
ForEach(this.iconConfigs, (item) => {
ForEach(this.iconConfigs, (item: IconData) => {
Button({ type: ButtonType.Circle, stateEffect: true }) {
if (item.src) {
Image(item.src)
@@ -126,13 +122,13 @@ export default struct IconListComponent {
@Component
export struct BottomLeftItem {
private itemData: any = {};
private itemData: NotificationItemData | undefined = undefined;
private bottomLeftItemHeight: number = 92;
private settingDialogController: CustomDialogController = new CustomDialogController({
private settingDialogController: CustomDialogController | null = new CustomDialogController({
builder: SettingDialog({
itemData: this.itemData,
action: () => this.confirmDialogController.open()
action: (): void => this.confirmDialogController?.open()
}),
autoCancel: false,
alignment: deviceTypeInfo === 'phone' ? DialogAlignment.Bottom : DialogAlignment.Default,
@@ -140,10 +136,10 @@ export struct BottomLeftItem {
customStyle: true
});
private confirmDialogController: CustomDialogController = new CustomDialogController({
private confirmDialogController: CustomDialogController | null = new CustomDialogController({
builder: ConfirmDialog({
title: $r('app.string.closeNovice'),
bundleName: this.itemData.name,
bundleName: this.itemData?.appName,
action: () => NotificationViewModel.enableNotification(this.itemData, false)
}),
autoCancel: false,
@@ -153,12 +149,8 @@ export struct BottomLeftItem {
});
aboutToDisappear() {
delete this.settingDialogController
this.settingDialogController = undefined
delete this.confirmDialogController
this.confirmDialogController = undefined
this.settingDialogController = null
this.confirmDialogController = null
Log.showInfo(TAG, 'BottomLeftItem -> aboutToDisappear')
}
@@ -172,7 +164,7 @@ export struct BottomLeftItem {
.height(Layout.ICON_SIZE)
}
.backgroundColor($r("app.color.button_background"))
.onClick(() => this.settingDialogController.open())
.onClick(() => this.settingDialogController?.open())
.width(Layout.BUTTON_SIZE)
.height(Layout.BUTTON_SIZE)
}
@@ -18,7 +18,7 @@ import Constants, {NotificationItemData, NotificationLayout as Layout} from '../
@Component
export default
struct LongItem {
@State itemData: NotificationItemData= undefined
@Prop itemData: NotificationItemData
@Prop isExpand: boolean
build() {
@@ -17,7 +17,7 @@ import Constants, {NotificationItemData, NotificationLayout as Layout} from '../
@Component
export default struct MultiItem {
@State itemData: NotificationItemData= undefined
@Prop itemData: NotificationItemData
@Prop isExpand: boolean
build() {
@@ -24,17 +24,27 @@ import {BottomLeftItem} from './iconListComponent';
import deviceInfo from '@ohos.deviceInfo';
import SwipeLayout from './SwipeLayout';
import {getId} from '../../model/SwipeLayoutUtils';
import { NotificationItemData } from '../../common/constants'
const TAG = 'NoticeItem-NotificationItem';
const deviceTypeInfo = deviceInfo.deviceType;
class EmptyObject {}
interface TriggerInfo {
code: number;
want: Want | undefined;
permission: string;
extraInfo: EmptyObject;
}
@Component
export default struct NotificationItem {
@State mIconAlpha: number = 0;
@State itemWidth: string = '100%';
private itemData: any = {};
@Prop itemData: NotificationItemData;
private isSubItem: boolean= false;
registerEventCapture: (id: string) => boolean = null;
registerEventCapture: (id: string) => boolean = (id) => true;
registerNotificationItemEventCapture(id: string){
if(this.registerEventCapture != null && this.registerEventCapture(id)){
@@ -83,29 +93,28 @@ export default struct NotificationItem {
@Component
struct FrontItem {
private itemData: any = {}
private nowWant: any;
@Prop itemData: NotificationItemData
private nowWant: Want | undefined = undefined;
private isSubItem: boolean= false;
private devicesDialogController: CustomDialogController = new CustomDialogController({
private devicesDialogController: CustomDialogController | null = new CustomDialogController({
builder: DevicesDialog({
action: (deviceID) => this.selectedDevice(deviceID)
action: (deviceID): void => this.selectedDevice(deviceID)
}),
autoCancel: false,
offset: { dx: 0, dy: 200 }
});
aboutToDisappear() {
delete this.devicesDialogController
this.devicesDialogController = undefined
this.devicesDialogController = null
Log.showInfo(TAG, 'FrontItem -> aboutToDisappear')
}
build() {
Column() {
if (this.itemData.template?.name) {
CustomItem({ customItemData: this.itemData, clickAction: () => this.showDevicesDialog(), isSubItem: this.isSubItem })
CustomItem({ customItemData: this.itemData, clickAction: (): void => this.showDevicesDialog(), isSubItem: this.isSubItem })
} else {
GeneralItem({ itemData: this.itemData, clickAction: () => this.showDevicesDialog(), isSubItem: this.isSubItem })
GeneralItem({ itemData: this.itemData, clickAction: (): void => this.showDevicesDialog(), isSubItem: this.isSubItem })
}
}
.width('100%')
@@ -125,7 +134,7 @@ struct FrontItem {
this.nowWant = want;
Log.showInfo(TAG, `showDevicesDialog want: ${JSON.stringify(this.nowWant)}`);
if (!want?.deviceId) {
this.devicesDialogController.open();
this.devicesDialogController?.open();
} else {
NotificationViewModel.clickItem(this.itemData);
}
@@ -135,10 +144,12 @@ struct FrontItem {
}
}
selectedDevice(deviceID) {
selectedDevice(deviceID: string): void {
Log.showInfo(TAG, `selectedDevice deviceID:${deviceID}`);
this.nowWant.deviceId = deviceID;
let triggerInfo = {
if(this.nowWant) {
this.nowWant.deviceId = deviceID;
}
let triggerInfo: TriggerInfo = {
code: 0,
want: this.nowWant,
permission: '',
@@ -18,7 +18,7 @@ import CheckEmptyUtils from '../../../../../../../../../../common/src/main/ets/d
@Component
export default struct PictureItem {
@State itemData: NotificationItemData= undefined
@Prop itemData: NotificationItemData
@Prop isExpand: boolean
build() {
@@ -30,9 +30,9 @@ const TAG = 'NoticeItem-Setting';
*/
@CustomDialog
export default struct SettingDialog {
private itemData: NotificationItemData
@Prop itemData: NotificationItemData
public controller: CustomDialogController
public action: () => void
public action: () => void = () => {}
build() {
Column() {
@@ -20,7 +20,7 @@ const TAG = 'NoticeItem-TitleItem';
@Component
export default struct TitleItem {
private notificationSmallIcon: PixelMap
private notificationSmallIcon?: PixelMap
@State notificationName: string = ''
@State notificationTime: string = ''
@Link isExpand: boolean
@@ -28,7 +28,7 @@ export default struct TitleItem {
@State rowSpace: Resource = $r('app.float.titleitem_row_space')
@Prop distributedDeviceName: string
private isSubItem: boolean= false;
private clickTitleAction: () => void
private clickTitleAction?: () => void
aboutToAppear() {
Log.showDebug(TAG, `aboutToAppear Start`);
@@ -135,12 +135,12 @@ export class NotificationViewModel {
AppStorage.SetOrCreate('notificationList', notificationList);
}
groupByGroupName(): any[]{
groupByGroupName(): NotificationItemData[][]{
if (!this.mNotificationList || this.mNotificationList.length < 1) {
Log.showWarn(TAG, 'groupByGroupName, list is empty.');
return [];
}
let groupArr: any[] = [];
let groupArr: NotificationItemData[][] = [];
let groups = {};
this.mNotificationList.forEach((item) => {
const groupName = `${item.bundleName}_${item.groupName}`;
@@ -25,7 +25,7 @@ const TAG = 'ringmode-ControlCenterSimpleToggleRingModeComponent'
@Component
export default struct ControlCenterSimpleToggleRingModeComponent {
private keyId: string
private keyId: string = ''
private mEditMode: boolean = false
private mDragMode: boolean = false
@State mIcon: Resource = $r("app.media.ic_controlcenter_ring_on_filled")
@@ -67,8 +67,8 @@ export default struct ControlCenterSimpleToggleRingModeComponent {
mIconOnBG: this.style.onBgColor,
mEditMode: this.mEditMode,
mDragMode: this.mDragMode,
mClickEvent: () => this.mClickEvent(),
mLongClickEvent: () => this.mLongClickEvent()
mClickEvent: (): void => this.mClickEvent(),
mLongClickEvent: (): void => this.mLongClickEvent()
})
}
@@ -29,13 +29,13 @@ export default struct StatusBarIconItemRingModeComponent {
@State mTintContentInfo: TintContentInfo = ViewModel.getTintContentInfo()
@State styleCommon: CommonStyle = StyleConfigurationCommon.getCommonStyle()
@State style: StatusRingModeComponentStyle = StyleConfiguration.getStatusRingModeComponentStyle()
private ringModeIcons: any
private ringModeIcons: Resource[] = []
aboutToAppear() {
Log.showInfo(TAG, 'aboutToAppear');
this.ringModeIcons = {};
this.ringModeIcons[AudioRingMode.RINGER_MODE_SILENT.toString()] = $r("app.media.ic_statusbar_ring_off_filled");
this.ringModeIcons[AudioRingMode.RINGER_MODE_VIBRATE.toString()] = $r("app.media.ic_statusbar_vibration_on");
this.ringModeIcons = [];
this.ringModeIcons[AudioRingMode.RINGER_MODE_SILENT] = $r("app.media.ic_statusbar_ring_off_filled");
this.ringModeIcons[AudioRingMode.RINGER_MODE_VIBRATE] = $r("app.media.ic_statusbar_vibration_on");
ViewModel.initViewModel();
}
@@ -47,7 +47,7 @@ export default struct StatusBarIconItemRingModeComponent {
Row() {
if (this.RingModeComponentMode != AudioRingMode.RINGER_MODE_NORMAL) {
Row().width(this.styleCommon.statusBarMarginLeftRight).height('100%')
Image(this.ringModeIcons[this.RingModeComponentMode.toString()])
Image(this.ringModeIcons[this.RingModeComponentMode])
.objectFit(ImageFit.Contain)
.width(this.style.statusBarRingModeWidth)
.height(this.style.statusBarRingModeHeight)
@@ -91,8 +91,8 @@ export default struct SignalIcon {
* @param {number} type - number of cellular type
* @return {string} typeString type of cellular type
*/
private updateCellularType(signalType): string {
let typeString;
private updateCellularType(signalType: number): Resource {
let typeString: Resource;
switch (signalType) {
case Constants.RADIO_TECHNOLOGY_UNKNOWN:
typeString = $r('app.string.signal_null');
@@ -130,8 +130,8 @@ export default struct SignalIcon {
* @param {number} level - signal level from signalModel
* @return {string} cellularImage image of cellular signal
*/
private updateCellularImage(level) {
let cellularImage;
private updateCellularImage(level: number) {
let cellularImage: Resource;
switch (level) {
case Constants.CELLULAR_SIGNAL_NO:
cellularImage = $r('app.media.ic_statusbar_signal_no');
@@ -165,8 +165,8 @@ export default struct SignalIcon {
* @param {string} netWorkState - network state from signal model
* @return {string} vendor's name or signal state
*/
private updateNetworkState(netWorkState) {
let networkStateName;
private updateNetworkState(netWorkState: string) {
let networkStateName: string | Resource;
if (netWorkState == Constants.NET_NULL) {
networkStateName = $r('app.string.net_null');
} else {
@@ -120,16 +120,20 @@ export class SignalModel {
*/
initObserver() {
Log.showInfo(TAG, 'initObserver');
isInitObserver = true;
Observer.on('signalInfoChange', (signalInfoChange) => {
this.checkCellularStatus();
});
Observer.on('networkStateChange', (networkState) => {
this.checkCellularStatus();
});
Observer.on('simStateChange', (simStateInfo) => {
this.checkCellularStatus();
});
try {
isInitObserver = true;
Observer.on('signalInfoChange', (signalInfoChange) => {
this.checkCellularStatus();
});
Observer.on('networkStateChange', (networkState) => {
this.checkCellularStatus();
});
Observer.on('simStateChange', (simStateInfo) => {
this.checkCellularStatus();
});
} catch (err) {
Log.showError(TAG, `init observer failed message: ${JSON.stringify(err)}`);
}
}
/**
+3 -1
View File
@@ -3,5 +3,7 @@
"name": "@ohos/statusbarcomponent",
"description": "a npm package which contains statusbarcomponent function",
"version": "1.0.0",
"dependencies": {}
"dependencies": {
"@ohos/common": "file:../../common"
}
}
@@ -16,7 +16,7 @@
import Log from '../../../../../../../../common/src/main/ets/default/Log'
import EventManager, { unsubscribe } from '../../../../../../../../common/src/main/ets/default/event/EventManager'
import CheckEmptyUtils from '../../../../../../../../common/src/main/ets/default/CheckEmptyUtils'
import { WINDOW_SHOW_HIDE_EVENT } from '../../../../../../../../common/src/main/ets/default/WindowManager'
import { WINDOW_SHOW_HIDE_EVENT, ArgsInfo } from '../../../../../../../../common/src/main/ets/default/WindowManager'
import { PluginType,itemData } from "../../../../../../../../common/src/main/ets/plugindatasource/common/Constants"
import ViewModel from '../viewmodel/StatusBarVM'
import StyleConfigurationCommon, { CommonStyle
@@ -24,16 +24,17 @@ import StyleConfigurationCommon, { CommonStyle
import StyleConfiguration, { IconItemComponentStyle } from '../common/StyleConfiguration'
import MetaIconItemComponent from './MetaIconItemComponent'
import PluginIconItemComponent from './PluginIconItemComponent'
import { Event } from '@ohos/common'
const TAG = 'IconItemComponent'
class itemStatusData{
interface itemStatusData{
selected: boolean
}
@Component
export default struct IconItemComponent {
private keyId: string
@Prop keyId: string
@State mItemData: itemData = new itemData()
@State mItemStatus: itemStatusData = {
selected: false
@@ -47,7 +48,9 @@ export default struct IconItemComponent {
Log.showInfo(TAG, `aboutToAppear Start, keyId: ${this.keyId} `);
this.linkItemData()
if (this.mItemData?.relationWindowId) {
this.mClearCallback = EventManager.subscribe(WINDOW_SHOW_HIDE_EVENT, (args) => this.onWindowChange(args))
this.mClearCallback = EventManager.subscribe(
WINDOW_SHOW_HIDE_EVENT,
(args: ArgsInfo) => this.onWindowChange(args));
}
}
@@ -58,14 +61,14 @@ export default struct IconItemComponent {
}
linkItemData() {
this.mItemData = AppStorage.Get('StatusBar_' + this.keyId)
this.mItemData = AppStorage.Get('StatusBar_' + this.keyId) as itemData
Log.showInfo(TAG, `linkItemData, mItemData: ${this.keyId} ${this.mItemData.label} ${
this.mItemData
.iconUrl}`)
const statusBarStatusKey = 'StatusBar_Status_' + this.keyId
AppStorage.SetOrCreate(statusBarStatusKey, { selected: false })
this.mItemStatus = AppStorage.Get(statusBarStatusKey)
this.mItemStatus = AppStorage.Get(statusBarStatusKey) as itemStatusData
}
build() {
@@ -102,9 +105,9 @@ export default struct IconItemComponent {
}.height('100%')
}
onWindowChange(args) {
onWindowChange(args: ArgsInfo) {
if (this.mItemData.canSelect && args?.windowName == this.mItemData.relationWindowId) {
this.mItemStatus.selected = args?.isShow
this.mItemStatus.selected = args?.isShow as boolean
}
}
@@ -133,7 +136,7 @@ export default struct IconItemComponent {
onIconItemLongPressGesture(event: GestureEvent) {
Log.showInfo(TAG, `onIconItemLongPressGesture, event: ${JSON.stringify(event)}`);
let longClickEvent = this.mItemData.actionData.longClickAction;
let longClickEvent = this.mItemData.actionData?.longClickAction as Event;
longClickEvent && EventManager.publish(longClickEvent);
}
@@ -26,7 +26,7 @@ const TAG = 'MetaIconItemComponent'
@Component
export default struct MetaIconItemComponent {
private keyId: string
@Prop keyId: string
@State mItemData: itemData = new itemData()
@State mTintContentInfo: TintContentInfo = new TintContentInfo()
@State style: IconItemComponentStyle = StyleConfiguration.getIconItemComponentStyle()
@@ -43,7 +43,7 @@ export default struct MetaIconItemComponent {
}
linkItemData() {
this.mItemData = AppStorage.Get('StatusBar_' + this.keyId);
this.mItemData = AppStorage.Get('StatusBar_' + this.keyId) as itemData;
Log.showInfo(TAG, `linkItemData, mItemData: ${this.keyId} ${this.mItemData.label} ${
this.mItemData
.iconUrl}`)
@@ -25,7 +25,7 @@ const TAG = 'PluginIconItemComponent'
@Component
export default struct PluginIconItemComponent {
private keyId: string
@Prop keyId: string
@State @Watch('onPluginDataChange') mPluginData: PluginComponentData = new PluginComponentData()
@State @Watch('onTintContentChange') mTintContentInfo: TintContentInfo = new TintContentInfo()
@State style: PluginIconItemComponentStyle = StyleConfiguration.getPluginIconItemComponentStyle()
@@ -78,8 +78,8 @@ export default struct PluginIconItemComponent {
data: this.mPluginData.data
}).onComplete(() => {
Log.showInfo(TAG, `PluginComponent.Complete`)
}).onError(({errcode, msg}) => {
Log.showInfo(TAG, `PluginComponent.Error code:${errcode} message:${msg}`)
}).onError((error) => {
Log.showInfo(TAG, `PluginComponent.Error code:${error.errcode} message:${error.msg}`)
})
.size({ width: px2vp(this.style.iconWidth), height: '100%' })
Row().width(this.styleCommon.statusBarMarginLeftRight).height('100%')
@@ -35,6 +35,7 @@ import CapsuleIcon from '../../../../../../../capsulecomponent/src/main/ets/defa
import LocationIcon from '../../../../../../../locationcomponent/src/main/ets/com/ohos/pages/StatusBarIconItemLocationComponent'
import RingModeIcon from '../../../../../../../ringmodecomponent/src/main/ets/com/ohos/pages/StatusBarIconItemRingModeComponent'
import NfcIcon from '../../../../../../../nfccomponent/src/main/ets/com/ohos/pages/StatusBarIconItemNFComponent'
import { NotificationItemData } from '@ohos/common';
const TAG = 'StatusBarComponent'
const TAG_StatusBarGroup = 'StatusBarGroup'
@@ -44,9 +45,14 @@ const TAG_StatusBarEmptyIcon = 'StatusBarEmptyIcon'
const TAG_StatusBarNotificationIcon = 'StatusBarNotificationIcon'
const TAG_StatusBarBackground = 'StatusBarBackground'
interface Item {
index: number;
data: NotificationItemData[];
}
@Component
export default struct StatusBarComponent {
private mStatusBarComponentConfig: StatusBarConfig
private mStatusBarComponentConfig: StatusBarConfig | undefined = undefined
@State mStatusBarData: StatusBarData = ViewModel.getStatusBarData()
private moduleName: string = ''
@@ -166,7 +172,7 @@ struct StatusBarBackground {
struct StatusBarGroup {
@StorageLink('StatusBarLayout') mStatusBarLayout: string[][] = [[], [], []]
private mLayoutWeight: number = 1
private mAlignItems: any = HorizontalAlign.Center;
private mAlignItems: number = HorizontalAlign.Center;
private index: number = -1;
@State mStatusBarData: StatusBarData = ViewModel.getStatusBarData()
@@ -212,7 +218,7 @@ struct StatusBarGroup {
@Component
struct VerticalStatusBarItemLoadComponent {
private mComponentName: string
private mComponentName: string = ''
@State mComponentHeight: number = 0
@State style: VerticalStatusBarItemLoadComponentStyle = StyleConfiguration.getVerticalStatusBarItemLoadComponentStyle()
@@ -241,7 +247,7 @@ struct VerticalStatusBarItemLoadComponent {
@Component
struct StatusBarItemLoadComponent {
private mComponentName: string
private mComponentName: string = ''
aboutToAppear() {
Log.showInfo(TAG_StatusBarItemLoadComponent, `aboutToAppear, mComponentName: ${this.mComponentName} `)
}
@@ -311,7 +317,7 @@ struct StatusBarEmptyIcon {
@Component
struct StatusBarNotificationIcon {
@StorageLink('notificationList') notificationList: Array<any> = []
@StorageLink('notificationList') notificationList: NotificationItemData[][] = []
@StorageLink('StatusCoefficient') StatusCoefficient: number = 1.0
@State mTintContentInfo: TintContentInfo = ViewModel.getNotificationTintContentInfo()
@State styleCommon: CommonStyle = StyleConfigurationCommon.getCommonStyle()
@@ -331,7 +337,7 @@ struct StatusBarNotificationIcon {
Row().height(1).width(this.styleCommon.statusBarMarginLeftRight)
}
if (this.notificationList.length > 3) {
ForEach(this.notificationList.slice(0, 3), (item: any) => {
ForEach(this.notificationList.slice(0, 3), (item: NotificationItemData[]) => {
Image(item[0].smallIcon)
.objectFit(ImageFit.ScaleDown)
.height(this.style.iconHeight)
@@ -346,12 +352,13 @@ struct StatusBarNotificationIcon {
}
} else {
ForEach(this.notificationList.map((item, index1) => {
return { i: index1, data: item }
}), (item) => {
if (item.i > 0) {
let res: Item = { index: index1, data: item }
return res
}), (res: Item) => {
if (res.index > 0) {
Row().height(1).width(this.style.iconSpace)
}
Image(item.data[0].smallIcon)
Image(res.data[0].smallIcon)
.objectFit(ImageFit.ScaleDown)
.height(this.style.iconHeight)
.width(this.style.iconWidth)
@@ -51,6 +51,10 @@
{
"name": "status_bar_padding_end",
"value": "0vp"
},
{
"name": "status_bar_margin_left_right",
"value": "3vp"
}
]
}
@@ -97,9 +97,9 @@ export default struct VolumePanelComponent {
.backgroundColor(this.style.volumePanelBackground)
}
getVolumeIcon(isMute, volume, maxVolume, minVolume) {
getVolumeIcon(isMute: boolean, volume: number, maxVolume: number, minVolume: number) {
Log.showInfo(TAG, `getVolumeIcon, isMute: ${isMute} volume: ${volume} maxVolume: ${maxVolume} minVolume: ${minVolume}`);
let icon
let icon: Resource
if (isMute) {
icon = $r('app.media.ic_public_mute')
} else {
@@ -24,7 +24,7 @@ const TAG = 'Control-wifiComponent'
@Component
export default struct WifiComponent {
private IconInfo: any[] = [
private IconInfo: Resource[] = [
$r('app.media.wifi_d'),
$r('app.media.wifi'),
]
@@ -64,8 +64,8 @@ export default struct WifiComponent {
iconOn: this.IconInfo[1],
mTitle: $wifiName,
changeSwitch: $wifiOpenStatus,
mClickEvent: () => this.mClickEvent(),
mLongClickEvent: () => this.mLongClickEvent()
mClickEvent: (): void => this.mClickEvent(),
mLongClickEvent: (): void => this.mLongClickEvent()
})
}.width('100%')
.height('100%')
@@ -59,7 +59,7 @@ export default struct WifiIcon {
private getImage(wifiInfo: number) {
Log.showInfo(TAG, `getImage`);
let wifiImage;
let wifiImage: Resource;
switch (wifiInfo) {
case Constants.WIFI_SIGNAL_NO:
wifiImage = $r('app.media.ic_statusbar_wifi_no');
+1
View File
@@ -1,4 +1,5 @@
{
"modelVersion": "5.0.1",
"devDependencies": {
"@ohos/hypium": "1.0.6"
},
@@ -38,7 +38,7 @@ class Stub extends rpc.RemoteObject {
if (code === ServiceStubCode.COMMAND_SEND_REMOTE_OBJECT) {
Log.showInfo(TAG, `onRemoteRequest code:${ServiceStubCode.COMMAND_SEND_REMOTE_OBJECT} start ${connectId}`);
const controller = globalThis[Constants.SYSTEM_DIALOG_CONTROLLER];
const controller = globalThis.SystemDialog_Controller;
const remoteObject = data.readRemoteObject();
Log.showDebug(TAG, `onRemoteRequest code:${ServiceStubCode.COMMAND_SEND_REMOTE_OBJECT} ${remoteObject}`);
@@ -86,7 +86,7 @@ class Stub extends rpc.RemoteObject {
}
async createWindow(connectId: string, parameters: IDialogParameters) {
const controller = globalThis[Constants.SYSTEM_DIALOG_CONTROLLER];
const controller = globalThis.SystemDialog_Controller;
const current = controller.getData().get(connectId);
if (current && current.windowName) {
Log.showInfo(TAG, `createWindow <this same> connectId:${connectId}`);
@@ -129,7 +129,7 @@ class Stub extends rpc.RemoteObject {
export default class DialogServiceExtAbility extends ServiceExtensionAbility {
onCreate(want: Want) {
Log.showInfo(TAG, 'onCreate');
globalThis[Constants.SYSTEM_DIALOG_CONTROLLER] = new SystemDialogController(this.context);
globalThis.SystemDialog_Controller = new SystemDialogController(this.context);
}
onConnect() {
@@ -142,9 +142,9 @@ export default class DialogServiceExtAbility extends ServiceExtensionAbility {
}
onDestroy() {
const controller = globalThis[Constants.SYSTEM_DIALOG_CONTROLLER];
const controller = globalThis.SystemDialog_Controller;
controller.destroyAllWindow();
globalThis[Constants.SYSTEM_DIALOG_CONTROLLER] = undefined;
globalThis.SystemDialog_Controller = undefined;
Log.showInfo(TAG, 'onDestroy end');
}
@@ -18,6 +18,7 @@ import Log from '../../../../../../../common/src/main/ets/default/Log';
import Constants from '../common/Constants';
import type { IDialogParameters } from '../controller/Controller';
import inputMethod from '@ohos.inputMethod';
import SystemDialogController from '../controller/Controller';
const TAG = 'Dialog-Index';
@@ -26,10 +27,10 @@ const storage = LocalStorage.GetShared();
@Entry(storage)
@Component
struct Index {
@LocalStorageProp('connectId') connectId: string = undefined;
@LocalStorageProp('windowName') windowName: string = undefined;
@LocalStorageProp('parameters') parameters: IDialogParameters = undefined;
@State inputMethodSetting: inputMethod.InputMethodSetting = undefined;
@LocalStorageProp('connectId') connectId: string = '';
@LocalStorageProp('windowName') windowName: string = '';
@LocalStorageProp('parameters') parameters: IDialogParameters = {};
@State inputMethodSetting: inputMethod.InputMethodSetting | undefined = undefined;
@State keyboardHeight: number = 0;
aboutToAppear() {
@@ -62,8 +63,8 @@ struct Index {
cancelListenKeyboard() {
Log.showInfo(TAG, 'cancelListenKeyboard in');
try {
this.inputMethodSetting.off('imeShow');
this.inputMethodSetting.off('imeHide');
this.inputMethodSetting?.off('imeShow');
this.inputMethodSetting?.off('imeHide');
} catch (e) {
Log.showError('cancelListenKeyboard error', e);
}
@@ -72,8 +73,8 @@ struct Index {
onOk() {
Log.showDebug(TAG, `onOk start`);
const controller = globalThis[Constants.SYSTEM_DIALOG_CONTROLLER];
const { remoteObject } = controller.getData().get(this.connectId);
const controller = globalThis.SystemDialog_Controller as SystemDialogController;
const remoteObject = controller.getData().get(this.connectId)?.remoteObject;
if (remoteObject) {
Log.showDebug(TAG, `onOk ${remoteObject}`);
@@ -82,8 +83,8 @@ struct Index {
let option = new rpc.MessageOption();
remoteObject.sendMessageRequest(1, data, reply, option)
.then(
(result) => Log.showDebug(TAG, `onOk success ${JSON.stringify(result)}`),
(error) => {
(result: rpc.RequestResult): void => Log.showDebug(TAG, `onOk success ${JSON.stringify(result)}`),
(error: Error) => {
Log.showDebug(TAG, `onOk error ${JSON.stringify(error)}`);
this.onClose();
}
@@ -98,7 +99,7 @@ struct Index {
onClose() {
Log.showDebug(TAG, `onClose start`);
const controller = globalThis[Constants.SYSTEM_DIALOG_CONTROLLER];
const controller = globalThis.SystemDialog_Controller as SystemDialogController;
controller?.destroyWindow(this.connectId);
Log.showInfo(TAG, `onClose end`);
}
@@ -4,6 +4,7 @@
"description": "",
"version": "1.0.0",
"dependencies": {
"@ohos/navigationservice": "file:../../../features/navigationservice"
"@ohos/navigationservice": "file:../../../features/navigationservice",
"@ohos/common": "file:../../../common"
}
}
@@ -12,6 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import resourceManager from '@ohos.resourceManager';
export default class Constants {
static readonly KEY_DOWN: number = 0;
@@ -33,3 +34,8 @@ export class NavigationBarComponentData {
backgroundColor = '#00000000';
contentColor = '#FFFFFFFF';
}
export interface KeyCode {
uri: resourceManager.Resource,
keyCode: number
}
@@ -19,12 +19,12 @@ import IndicatorStyle, { IndicatorType } from '../common/IndicatorConfig';
@Entry
@Component
export default struct PrivacyIndicatorComponent {
private mViewModel: ViewModel;
private mViewModel: ViewModel | undefined = undefined;
@State mBackgroundColor: Resource = $r("app.color.transparent");
aboutToAppear(): void {
this.mViewModel = new ViewModel();
this.mViewModel.setCallback((type) => {
this.mViewModel.setCallback((type: number) => {
if (type == IndicatorType.TYPE_ORANGE) {
this.mBackgroundColor = $r("sys.color.ohos_id_color_alert");
} else if (type == IndicatorType.TYPE_GREEN) {
@@ -15,6 +15,7 @@
import Log from '../../../../../../../common/src/main/ets/default/Log'
import AbilityManager from '../../../../../../../common/src/main/ets/default/abilitymanager/abilityManager'
import { ConfigInfo } from '@ohos/common'
const TAG = 'Navigation-SplitBar'
@@ -35,7 +36,7 @@ struct Index {
aboutToAppear() {
Log.showInfo(TAG, `aboutToAppear, start`);
let configInfo = AbilityManager.getAbilityData(AbilityManager.ABILITY_NAME_NAVIGATION_BAR, 'config');
let configInfo = AbilityManager.getAbilityData(AbilityManager.ABILITY_NAME_NAVIGATION_BAR, 'config') as ConfigInfo;
if (configInfo.maxWidth > configInfo.maxHeight) {
this.mHorizontalScreen = true;
} else {
@@ -22,25 +22,25 @@ import {NavigationBarComponentData} from '../common/constants'
import StyleManager from '../common/StyleManager'
import configManager from '../../../../../../../features/navigationservice/src/main/ets/com/ohos/navigationservice/ConfigManager'
import WindowManager, { WindowType } from '../../../../../../../common/src/main/ets/default/WindowManager';
import { ConfigInfo } from '@ohos/common'
const TAG = 'NavigationBar-Index';
let mConfigManager = configManager
@Entry
@Component
struct Index {
@StorageLink('navigationLayoutConfig') mConfig: object = {}
// @StorageLink('navigationLayoutConfig') mConfig: object = {}
@StorageLink('minNavHeight') minNavHeight: number = 32
@StorageLink("showNavHorizontal") showNavHorizontal: boolean = true
@State mNavigationBarComponentData: NavigationBarComponentData = new NavigationBarComponentData()
onBackPress(): boolean {
return true;
}
aboutToAppear() {
Log.showInfo(TAG, `aboutToAppear Start`);
let configInfo = AbilityManager.getAbilityData(AbilityManager.ABILITY_NAME_NAVIGATION_BAR, 'config');
let configInfo = AbilityManager.getAbilityData(AbilityManager.ABILITY_NAME_NAVIGATION_BAR, 'config') as ConfigInfo;
AppStorage.SetOrCreate("showNavHorizontal", configInfo.showNavHorizontal);
mConfigManager.initConfig();
WindowManager.setWindowBgColor(WindowType.NAVIGATION_BAR ,'#00000000')
@@ -24,7 +24,7 @@ const TAG = 'NavigationBar-KeyButton';
@Component
export default struct keyButton {
private uri: any;
@Prop uri: Resource;
@State keyCode: number = 0;
@Link currentTouchItem: number;
@State backGroundColor: Resource = $r('app.color.button_default_background');
@@ -14,11 +14,11 @@
*/
import keyButton from './keyButton';
import Constants from '../common/constants'
import Constants, { KeyCode } from '../common/constants'
import Log from '../../../../../../../common/src/main/ets/default/Log';
const TAG = 'NavigationBar-ThreeLayout';
let KeyCodeArr: any[] = [
let KeyCodeArr: KeyCode[] = [
{
"uri": $r('app.media.ic_systemui_back'),
"keyCode": Constants.KEYCODE_BACK
@@ -49,7 +49,7 @@ struct threeLayout {
build() {
if (this.showNavHorizontal) {
Grid() {
ForEach(KeyCodeArr, (item: any) => {
ForEach(KeyCodeArr, (item: KeyCode) => {
GridItem() {
Row() {
keyButton({ uri: item.uri, keyCode: item.keyCode, currentTouchItem: $currentTouchItem })
@@ -65,7 +65,7 @@ struct threeLayout {
.align(Alignment.Center);
} else {
Grid() {
ForEach(KeyCodeArr, (item: any) => {
ForEach(KeyCodeArr, (item: KeyCode) => {
GridItem() {
Column() {
keyButton({ uri: item.uri, keyCode: item.keyCode, currentTouchItem: $currentTouchItem })
@@ -4,6 +4,7 @@
"description": "",
"version": "1.0.0",
"dependencies": {
"@ohos/managementcomponent": "file:../../../features/managementcomponent"
"@ohos/managementcomponent": "file:../../../features/managementcomponent",
"@ohos/common": "file:../../../common"
}
}
@@ -24,11 +24,24 @@ import ViewModel from '../vm/notificationManagenmentViewModel'
const TAG = 'NotificationManagement-BatchSetEnable';
interface BundleItemData {
appIcon?: string;
appTitle?: string;
appValue?: string;
appArrow?: string|Resource;
appSummary?: string;
appBundleName?: string;
appIconId?: string;
appUri?: string;
appUid?: number;
systemApp?: boolean;
}
@Entry
@Component
export default struct BatchSetEnable {
@State mViewModel: ViewModel = new ViewModel();
@StorageLink('appManagementList') appList: any[]= [];
@StorageLink('appManagementList') appList: BundleItemData[]= [];
@State headName:Resource = $r('app.string.batch_Management')
build() {
@@ -38,14 +51,14 @@ export default struct BatchSetEnable {
Column() {
HeadComponent({ headName: $headName, isActive: true });
List() {
ForEach(this.appList, (item) => {
ForEach(this.appList, (item: BundleItemData) => {
ListItem() {
AppItemComponent({
appIcon: item.appIcon,
appTitle: item.appTitle,
appSummary: item.appSummary,
appValue: item.appValue,
appArrow: item.appArrow,
appArrow: item.appArrow as string,
appArrowStyle: '',
appUri: '',
appBundleName:item.appBundleName,
@@ -22,6 +22,7 @@ import ItemComponent from '../../../../../../../features/managementcomponent/src
import {DoNotDisturbType} from '../../../../../../../features/managementcomponent/src/main/ets/com/ohos/common/constants';
import NoDisturbingModel from '../../../../../../../features/managementcomponent/src/main/ets/com/ohos/model/noDisturbingModel';
import ViewModel from '../vm/noDisturbViewModel';
import { data } from '@kit.TelephonyKit';
const deviceTypeInfo = deviceInfo.deviceType;
const TAG = 'NotificationManagement-NoDisturb';
@@ -54,9 +55,9 @@ export default struct NoDisturb {
Log.showInfo(TAG, `mViewModel onChange repeatName: ${this.mViewModel.repeatName} startDateClue: ${this.mViewModel.startDateClue}
endDateClue: ${this.mViewModel.endDateClue} endTimeClue: ${this.mViewModel.endTimeClue}`)
}
startDateDialogController: CustomDialogController = new CustomDialogController({
startDateDialogController: CustomDialogController | null = new CustomDialogController({
builder: DateDialog({
action:(data)=> this.setStartDate(data),
action:(data: string): void => this.setStartDate(data),
title: $r('app.string.startDate'),
defaultDate: this.mViewModel.defaultStartTime
}),
@@ -66,9 +67,9 @@ export default struct NoDisturb {
offset: ({ dx: 0, dy: deviceTypeInfo === "phone" ? '-16dp' : 0 }),
customStyle: true
});
startTimeDialogController: CustomDialogController = new CustomDialogController({
startTimeDialogController: CustomDialogController | null = new CustomDialogController({
builder: TimeDialog({
action:(data)=> this.setStartTime(data),
action:(data: string): void=> this.setStartTime(data),
title: $r('app.string.startTime'),
defaultDate: this.mViewModel.defaultStartTime
}),
@@ -78,9 +79,9 @@ export default struct NoDisturb {
offset: ({ dx: 0, dy: deviceTypeInfo === "phone" ? '-16dp' : 0 }),
customStyle: true
});
endDateDialogController: CustomDialogController = new CustomDialogController({
endDateDialogController: CustomDialogController | null = new CustomDialogController({
builder: DateDialog({
action:(data)=> this.setEndDate(data),
action:(data: string): void => this.setEndDate(data),
title: $r('app.string.endDate'),
defaultDate: this.mViewModel.defaultEndTime
}),
@@ -90,9 +91,9 @@ export default struct NoDisturb {
offset: ({ dx: 0, dy: deviceTypeInfo === "phone" ? '-16dp' : 0 }),
customStyle: true
});
endTimeDialogController: CustomDialogController = new CustomDialogController({
endTimeDialogController: CustomDialogController | null = new CustomDialogController({
builder: TimeDialog({
action:(data)=> this.setEndTime(data),
action:(data: string): void => this.setEndTime(data),
title: $r('app.string.endTime'),
defaultDate: this.mViewModel.defaultEndTime
}),
@@ -102,9 +103,9 @@ export default struct NoDisturb {
offset: ({ dx: 0, dy: deviceTypeInfo === "phone" ? '-16dp' : 0 }),
customStyle: true
});
repeatDialogController: CustomDialogController = new CustomDialogController({
repeatDialogController: CustomDialogController | null = new CustomDialogController({
builder: RepeatModeDialog({
action: (data) => this.setRepeatMode(data),
action: (data: number): void => this.setRepeatMode(data),
title: $r('app.string.repeat'),
selectMode: this.mViewModel.repeatMode
}),
@@ -129,7 +130,7 @@ export default struct NoDisturb {
arrow: $arrow
})
}.onClick(() => {
this.repeatDialogController.open()
this.repeatDialogController?.open()
}).margin({ bottom: $r('app.float.itemComp_margin_b') })
if (this.mViewModel.repeatMode == DoNotDisturbType.TYPE_CLEARLY) {
@@ -142,7 +143,7 @@ export default struct NoDisturb {
arrow: $arrow
})
}.onClick(() => {
this.startDateDialogController.open()
this.startDateDialogController?.open()
})
}
ListItem() {
@@ -153,7 +154,7 @@ export default struct NoDisturb {
arrow: $arrow
})
}.onClick(() => {
this.startTimeDialogController.open()
this.startTimeDialogController?.open()
})
}
}.divider({
@@ -178,7 +179,7 @@ export default struct NoDisturb {
arrow: $arrow
})
}.onClick(() => {
this.endDateDialogController.open()
this.endDateDialogController?.open()
})
}
ListItem() {
@@ -189,7 +190,7 @@ export default struct NoDisturb {
arrow: $arrow
})
}.onClick(() => {
this.endTimeDialogController.open()
this.endTimeDialogController?.open()
})
}
}.divider({
@@ -214,7 +215,7 @@ export default struct NoDisturb {
})
}.onClick(() => {
this.mPrevData = this.mViewModel.startTime
this.startTimeDialogController.open()
this.startTimeDialogController?.open()
}).margin({ bottom: $r('app.float.itemComp_margin_b')})
Row() {
ItemComponent({
@@ -224,7 +225,7 @@ export default struct NoDisturb {
})
}.onClick(() => {
this.mPrevData = this.mViewModel.endTime
this.endTimeDialogController.open()
this.endTimeDialogController?.open()
}).margin({ bottom: $r('app.float.itemComp_margin_b')})
}
}
@@ -287,20 +288,11 @@ export default struct NoDisturb {
}
aboutToDisappear() {
delete this.startDateDialogController
this.startDateDialogController = undefined
delete this.startTimeDialogController
this.startTimeDialogController = undefined
delete this.endDateDialogController
this.endDateDialogController = undefined
delete this.endTimeDialogController
this.endTimeDialogController = undefined
delete this.repeatDialogController
this.repeatDialogController = undefined
this.startDateDialogController = null
this.startTimeDialogController = null
this.endDateDialogController = null
this.endTimeDialogController = null
this.repeatDialogController = null
Log.showInfo(TAG, `aboutToDisappear`)
}
@@ -316,7 +308,7 @@ export default struct NoDisturb {
@CustomDialog
struct DateDialog {
public controller: CustomDialogController
public action: (data) => void
public action: (data: string) => void = data => {}
private selectedDate: string = ''
private title: string | Resource = ''
private defaultDate: Date = new Date()
@@ -335,7 +327,7 @@ struct DateDialog {
.fontWeight(FontWeight.Medium)
DatePicker({ start: this.minDate, end: this.maxDate, selected: this.defaultDate })
.onChange((date: DatePickerResult) => {
let dateSource = new Date(date.year, date.month, date.day);
let dateSource = new Date(date.year as number, date.month as number, date.day);
this.selectedDate = NoDisturbingModel.formatDate(dateSource);
})
.width(ConfigData.WH_100_100)
@@ -395,7 +387,7 @@ struct DateDialog {
@CustomDialog
struct TimeDialog {
public controller: CustomDialogController
public action: (data) => void
public action: (data: string) => void = data => {}
private selectedTime: string = ''
private title: string | Resource = ''
private defaultDate: Date = new Date()
@@ -471,7 +463,7 @@ struct TimeDialog {
@CustomDialog
struct RepeatModeDialog {
public controller: CustomDialogController
public action: (data) => void
public action: (data: number) => void = data => {}
private title: string | Resource = ''
private prevModeSetCnt: number = 0
@State selectMode: number = DoNotDisturbType.TYPE_NONE
@@ -121,8 +121,8 @@ export default struct notificationManagenment {
SwitchComponent({
title: $allowDistribut,
describe: this.allowDistributDescribe,
initializationAction: () => this.switchComponentInit(),
settingAction: (params) => this.switchComponentSet(params)
initializationAction: (): Promise<boolean> => this.switchComponentInit(),
settingAction: (params): void => this.switchComponentSet(params)
})
}.margin({ bottom: $r('app.float.noDisturb_margin_lf') })
}
@@ -202,7 +202,7 @@ export default struct notificationManagenment {
return Notification.isDistributedEnabled();
}
switchComponentSet(params) {
switchComponentSet(params?: boolean) {
Log.showDebug(TAG, `switchComponentSet`)
Notification.enableDistributed(params);
}
@@ -23,18 +23,19 @@ import ConfigData from '../common/constants';
import Router from '@system.router'
import notificationListener from '../../../../../../../features/managementcomponent/src/main/ets/com/ohos/model/notificationListener';
import Notification from '@ohos.notification';
import NotificationManager from '@ohos.notificationManager';
import { BundleItemData } from '@ohos/common';
const TAG = 'NotificationManagement-SetEnable';
let appInfo;
let appInfo: BundleItemData;
@Entry
@Component
export default struct SetEnable {
private listeners: any[] = [];
@State headName:Resource = $r('app.string.notificationManagement');
@State allowNotice:Resource = $r('app.string.allowNotification');
@State slotLst: any[] = [];
@State slotLst: NotificationManager.NotificationSlot[] = [];
@State initState: boolean = false;
build() {
Flex({ justifyContent: FlexAlign.SpaceBetween }) {
@@ -49,7 +50,7 @@ export default struct SetEnable {
appTitle: appInfo.appTitle,
appSummary: appInfo.appSummary,
appValue: '',
appArrow: appInfo.appArrow,
appArrow: appInfo.appArrow as string,
appArrowStyle: '',
appUri: appInfo.appUri,
appBundleName: appInfo.appBundleName,
@@ -64,8 +65,8 @@ export default struct SetEnable {
Row() {
SwitchComponent({
title: $allowNotice,
initializationAction: () => this.switchComponentInit(),
settingAction: (params) => this.switchComponentSet(params),
initializationAction: (): Promise<boolean> => this.switchComponentInit(),
settingAction: (params?: boolean): void => this.switchComponentSet(params),
register: (listener) => notificationListener.register({bundle:appInfo.appBundleName,onEnableChanged:listener})
})
}
@@ -128,15 +129,15 @@ export default struct SetEnable {
switchComponentInit() {
Log.showDebug(TAG, `switchComponentInit`)
return notificationListener.isNotificationEnabled({ bundle: appInfo.appBundleName, uid: appInfo.appUid }, (data) => {
return notificationListener.isNotificationEnabled({ bundle: appInfo.appBundleName, uid: appInfo.appUid }, (data: boolean) => {
Log.showDebug(TAG, 'switchComponentInit callback' + data);
this.initState = data;
});
}
switchComponentSet(params) {
switchComponentSet(params?: boolean) {
Log.showDebug(TAG, `switchComponentSet`)
this.initState = params;
this.initState = params as boolean;
notificationListener.enableNotification({ bundle: appInfo.appBundleName, uid: appInfo.appUid }, params);
}
}
@@ -22,17 +22,23 @@ import NotificationConfigData from '../../../../../../../features/managementcomp
import Router from '@system.router';
import NotificationListener from '../../../../../../../features/managementcomponent/src/main/ets/com/ohos/model/notificationListener';
import notification from '@ohos.notification';
import { BundleItemData } from '@ohos/common';
import NotificationManager from '@ohos.notificationManager';
const TAG = 'NotificationManagement-SlotSetting';
const DEFAULT_SOUND = 'file://system/etc/Light.ogg';
let slotParams;
interface ISlotParams {
appInfo?: BundleItemData,
slotInfo?: NotificationManager.NotificationSlot
};
@Entry
@Component
export default struct SlotSetting {
private appInfo: any = null;
private slotInfo: any = null;
private slotParams: ISlotParams = {};
private appInfo: BundleItemData = {};
private slotInfo: NotificationManager.NotificationSlot = {};
@State headName: Resource = $r('app.string.notificationManagement')
@State allowNotice: Resource = $r('app.string.allowNotification')
@State noticeStyleBanner: Resource = $r('app.string.notificationStyle_banner')
@@ -56,8 +62,8 @@ export default struct SlotSetting {
appIcon: this.appInfo.appIcon,
appTitle: this.appInfo.appTitle,
appSummary: this.appInfo.appSummary,
appValue: this.slotInfo.type,
appArrow: this.appInfo.appArrow,
appValue: this.slotInfo.type?.toString(),
appArrow: this.appInfo.appArrow as string,
appArrowStyle: '',
appUri: this.appInfo.appUri,
appBundleName: this.appInfo.appBundleName,
@@ -74,8 +80,8 @@ export default struct SlotSetting {
Row() {
SwitchComponent({
title: $allowNotice,
initializationAction: () => this.notificationSlotEnableInit(),
settingAction: (params) => this.notificationSlotEnableSet(params)
initializationAction: (): Promise<boolean> => this.notificationSlotEnableInit(),
settingAction: (params): void => this.notificationSlotEnableSet(params as boolean)
})
}
.margin({ top: $r('app.float.page_notice_title_margin_t') })
@@ -105,8 +111,8 @@ export default struct SlotSetting {
Row() {
SwitchComponent({
title: $noticeStyleBanner,
initializationAction: () => this.bannerEnableInit(),
settingAction: (params) => this.bannerEnableSet(params)
initializationAction: (): Promise<boolean> => this.bannerEnableInit(),
settingAction: (params): void => this.bannerEnableSet(params as boolean)
})
}
.padding({
@@ -120,8 +126,8 @@ export default struct SlotSetting {
Row() {
SwitchComponent({
title: $noticeSound,
initializationAction: () => this.soundEnableInit(),
settingAction: (params) => this.soundEnableSet(params)
initializationAction: (): Promise<boolean> => this.soundEnableInit(),
settingAction: (params): void => this.soundEnableSet(params as boolean)
})
}
.padding({
@@ -151,9 +157,9 @@ export default struct SlotSetting {
}
aboutToAppear(): void{
slotParams = Router.getParams();
this.appInfo = slotParams.appInfo;
this.slotInfo = slotParams.slotInfo
this.slotParams = Router.getParams();
this.appInfo = this.slotParams.appInfo as BundleItemData;
this.slotInfo = this.slotParams.slotInfo as NotificationManager.NotificationSlot;
Log.showDebug(TAG, `aboutToAppear ${JSON.stringify(this.slotInfo)}`)
}
@@ -173,13 +179,13 @@ export default struct SlotSetting {
});
}
notificationSlotEnableSet(data) {
notificationSlotEnableSet(data: boolean) {
Log.showDebug(TAG, `notificationEnableSet data:${JSON.stringify(data)}`)
this.initState = data;
NotificationListener.enableNotificationSlot({ bundle: this.appInfo.appBundleName, uid: this.appInfo.appUid }, this.slotInfo.type, data);
}
soundEnableInit() {
soundEnableInit(): Promise<boolean> {
Log.showDebug(TAG, `soundEnableInit`)
return new Promise((resolve, reject) => {
let result: boolean = false;
@@ -191,23 +197,23 @@ export default struct SlotSetting {
});
}
soundEnableSet(params) {
soundEnableSet(params: boolean) {
Log.showDebug(TAG, `soundEnableSet params:${JSON.stringify(params)}`)
if (params == 0) {
if (!params) {
this.slotInfo.sound = '';
if (this.slotInfo.level != notification.SlotLevel.LEVEL_HIGH) {
this.slotInfo.level = notification.SlotLevel.LEVEL_LOW;
}
} else if (params == 1) {
} else if (params) {
this.slotInfo.sound = DEFAULT_SOUND;
if (this.slotInfo.level < notification.SlotLevel.LEVEL_DEFAULT) {
if (this.slotInfo.level && this.slotInfo.level < notification.SlotLevel.LEVEL_DEFAULT) {
this.slotInfo.level = notification.SlotLevel.LEVEL_DEFAULT
}
}
this.notificationSlotSet();
}
bannerEnableInit() {
bannerEnableInit(): Promise<boolean> {
Log.showDebug(TAG, `bannerEnableInit`)
return new Promise((resolve, reject) => {
let result: boolean = false;
@@ -219,15 +225,15 @@ export default struct SlotSetting {
});
}
bannerEnableSet(params) {
bannerEnableSet(params: boolean) {
Log.showDebug(TAG, `bannerEnableSet params:${JSON.stringify(params)}`)
if (params == 0) {
if (!params) {
if (this.slotInfo.sound) {
this.slotInfo.level = notification.SlotLevel.LEVEL_DEFAULT;
} else {
this.slotInfo.level = notification.SlotLevel.LEVEL_LOW;
}
} else if (params == 1) {
} else if (params) {
this.slotInfo.level = notification.SlotLevel.LEVEL_HIGH;
}
this.notificationSlotSet();
@@ -21,6 +21,7 @@
"pages": "$profile:main_pages",
"abilities": [
{
"srcEntry": "./ets/MainAbility/MainAbility.ts",
"visible": true,
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"name": "com.ohos.systemui.notificationmanagement.MainAbility",
@@ -21,13 +21,25 @@ import WindowManager, { WindowType } from '../../../../../../../common/src/main/
const TAG = 'VolumePanel-Index'
interface DisConfigInfo {
width: number,
height: number
}
interface IvolumeRect {
left: number,
top: number,
width: number,
height: number
}
@Entry
@Component
struct Index {
aboutToAppear() {
Log.showInfo(TAG, `aboutToAppear Start`);
let configInfo = AbilityManager.getAbilityData(AbilityManager.ABILITY_NAME_VOLUME_PANEL, 'dis');
let volumeRect;
let configInfo: DisConfigInfo = AbilityManager.getAbilityData(AbilityManager.ABILITY_NAME_VOLUME_PANEL, 'dis');
let volumeRect: IvolumeRect;
if (configInfo.width > configInfo.height) { // Pad、PC Mode
const realWidth = 48;
const realHeight = 284;
+2 -1
View File
@@ -6,6 +6,7 @@
"dependencies": {
"@ohos/controlcentercomponent": "file:../../../features/controlcentercomponent",
"@ohos/autorotatecomponent": "file:../../../features/autorotatecomponent",
"@ohos/airplanecomponent": "file:../../../features/airplanecomponent"
"@ohos/airplanecomponent": "file:../../../features/airplanecomponent",
"@ohos/common": "file:../../../common",
}
}
@@ -23,7 +23,7 @@ const TAG = 'ControlPanel-Control';
@Component
export default struct Control {
private modeChangeCallback: Function
private modeChangeCallback: Function = () => {}
aboutToAppear() {
Log.showInfo(TAG, `aboutToAppear Start`)
@@ -39,7 +39,7 @@ export default struct Control {
ControlCenterComponent({
mControlCenterComponentConfig: ControlCenterConfig,
mSimpleToggleColumnCount: Constants.DEFAULT_SIMPLE_TOGGLE_COLUMN_COUNT,
modeChangeCallback: (isEdit) => this.modeChangeCallback(isEdit),
modeChangeCallback: (isEdit: boolean): void => this.modeChangeCallback(isEdit),
titleDisplayInside: true,
moduleName: 'pc_controlpanel',
})
@@ -22,19 +22,24 @@ import ControlCenterComponent from './control'
import WindowManager, {
WindowType,
WINDOW_SHOW_HIDE_EVENT,
ArgsInfo,
} from "../../../../../../../common/src/main/ets/default/WindowManager";
import EventManager, { unsubscribe } from "../../../../../../../common/src/main/ets/default/event/EventManager";
import { START_ABILITY_EVENT } from "../../../../../../../common/src/main/ets/default/event/EventUtil";
import MultimodalInputManager, {
MultiKeyCode,
} from "../../../../../../../common/src/main/ets/default/MultimodalInputManager";
import { Rect } from '@ohos/common'
import display from "@ohos.display"
const TAG = 'ControlPanel-Index'
const SHOW_EVENT = "showControlCenter";
const HIDE_EVENT = "hideControlCenter";
let mHeightConfigUtils
interface DisplayInfo {
width: number;
height: number;
}
@Entry
@Component
@@ -46,25 +51,24 @@ struct Index {
@State mWidthSize: number = 0.2
@State mHeightSize: number = 0.2
@State mHeightPx: number = 0
@State mHeightConfigUtils: HeightConfigUtils | undefined = undefined;
mClearCallbacks: Array<unsubscribe> = [];
mShowAnimReady: boolean = false;
aboutToAppear() {
Log.showInfo(TAG, `aboutToAppear, start`)
setAppBgColor('#00000000')
CommonStyleManager.setAbilityPageName(TAG)
this.style = StyleConfiguration.getIndexStyle()
StyleManager.setStyle()
let rect = AbilityManager.getAbilityData(AbilityManager.ABILITY_NAME_CONTROL_PANEL, 'rect')
let rect: Rect = AbilityManager.getAbilityData(AbilityManager.ABILITY_NAME_CONTROL_PANEL, 'rect')
this.mHeightPx = rect.height
mHeightConfigUtils = new HeightConfigUtils();
let StatusCoefficient;
this.mHeightConfigUtils = new HeightConfigUtils();
StatusCoefficient = AppStorage.SetAndLink("StatusCoefficient", 1.0);
StatusCoefficient.set(mHeightConfigUtils.getStatusCoefficient());
let StatusCoefficient = AppStorage.SetAndLink("StatusCoefficient", 1.0);
StatusCoefficient.set(this.mHeightConfigUtils.getStatusCoefficient());
this.initWindowPolicy();
Log.showDebug(TAG, `aboutToAppear, end`)
@@ -94,7 +98,7 @@ struct Index {
Scroll(new Scroller()) {
Column() {
ControlCenterComponent({
modeChangeCallback: (isEdit) => this.onModeChange(isEdit)
modeChangeCallback: (isEdit: boolean): void => this.onModeChange(isEdit)
})
}
.width('100%')
@@ -132,14 +136,16 @@ struct Index {
EventManager.subscribe(SHOW_EVENT, () => this.showWindow()),
EventManager.subscribe(HIDE_EVENT, () => this.hideWindow()),
EventManager.subscribe(START_ABILITY_EVENT, () => this.hideWindow()),
EventManager.subscribe(WINDOW_SHOW_HIDE_EVENT, (args) => {
let { windowName, isShow } = args;
EventManager.subscribe(WINDOW_SHOW_HIDE_EVENT, (args: ArgsInfo) => {
let windowName = args.windowName;
let isShow = args?.isShow;
Log.showInfo(TAG, `WINDOW_SHOW_HIDE_EVENT windowName: ${windowName}, isShow: ${isShow}`);
windowName == WindowType.NOTIFICATION_PANEL && isShow && this.hideWindow();
windowName == WindowType.CONTROL_PANEL && isShow && (this.mShowAnimReady = true);
}),
EventManager.subscribe('ControlWindowResizeEvent',async (args) => {
let { windowName, rect } = args;
EventManager.subscribe('ControlWindowResizeEvent',async (args: ArgsInfo) => {
let windowName = args.windowName;
let rect = args?.rect;
let dis = await display.getDefaultDisplaySync();
Log.showInfo(TAG, `ControlWindowResizeEvent: ${windowName}, isShow: ${rect}`);
AbilityManager.setAbilityData(AbilityManager.ABILITY_NAME_CONTROL_PANEL, 'rect', rect);
@@ -149,7 +155,7 @@ struct Index {
});
WindowManager.resetSizeWindow(windowName, rect).then(
).then(() => {
}).catch((err) => {
}).catch((err: Error) => {
});
}),
MultimodalInputManager.subscribeCombinationKey([MultiKeyCode.WIN, MultiKeyCode.I], (data) => {
@@ -164,9 +170,9 @@ struct Index {
);
}
_animateTo(config, callback) {
_animateTo(config: AnimateParam, callback: () => void) {
animateTo(config, callback)
setTimeout(config.onFinish, config.duration + config.delay)
setTimeout(config.onFinish, config.duration as number + Number(config.delay))
}
showAnimation(){
@@ -219,13 +225,13 @@ struct Index {
this.showAnimation();
}
onModeChange(isEdit) {
onModeChange(isEdit: boolean): void {
Log.showDebug(TAG, `onModeChange, isEdit: ${isEdit}`)
let initRect = AbilityManager.getAbilityData(AbilityManager.ABILITY_NAME_CONTROL_PANEL, 'rect')
let newRect = initRect
let initRect = AbilityManager.getAbilityData(AbilityManager.ABILITY_NAME_CONTROL_PANEL, 'rect') as ArgsInfo
let newRect = initRect as Rect
if (isEdit) {
let dis = AbilityManager.getAbilityData(AbilityManager.ABILITY_NAME_CONTROL_PANEL, 'dis')
newRect = { ...initRect, height: StyleManager.calcScaleSize(346) }
let dis = AbilityManager.getAbilityData(AbilityManager.ABILITY_NAME_CONTROL_PANEL, 'dis') as DisplayInfo
newRect.height = StyleManager.calcScaleSize(346)
}
Log.showDebug(TAG, `onModeChange, newRect: ${JSON.stringify(newRect)}`)
this._animateTo({
@@ -237,13 +243,13 @@ struct Index {
playMode: PlayMode.Normal,
onFinish: () => {
Log.showInfo(TAG, `onModeChange, show anim finish.`)
if (newRect.height <= initRect.height) {
if (initRect.height && newRect.height <= initRect.height) {
WindowManager.resetSizeWindow(WindowType.CONTROL_PANEL, newRect)
}
}
}, () => {
Log.showInfo(TAG, `onModeChange, animateTo`)
if (newRect.height > initRect.height) {
if (initRect.height && newRect.height > initRect.height) {
WindowManager.resetSizeWindow(WindowType.CONTROL_PANEL, newRect)
}
this.mHeightPx = newRect.height
@@ -4,6 +4,7 @@
"description": "",
"version": "1.0.0",
"dependencies": {
"@ohos/noticeitem": "file:../../../features/noticeitem"
"@ohos/noticeitem": "file:../../../features/noticeitem",
"@ohos/common": "file:../../../common"
}
}
@@ -14,17 +14,17 @@
*/
import Log from '../../../../../../../common/src/main/ets/default/Log';
import {notificationData} from '../../../../../../../common/src/main/ets/plugindatasource/common/Constants'
import AbilityManager from '../../../../../../../common/src/main/ets/default/abilitymanager/abilityManager';
import WindowManager, { WindowType } from '../../../../../../../common/src/main/ets/default/WindowManager';
import EventManager, {unsubscribe} from "../../../../../../../common/src/main/ets/default/event/EventManager";
import BannerNotification from '../../../../../../../features/noticeitem/src/main/ets/com/ohos/noticeItem/view/item/bannerNotificationItem';
import NotificationViewModel from '../../../../../../../features/noticeitem/src/main/ets/com/ohos/noticeItem/viewmodel/NotificationViewModel';
import NotificationConstants, { ScreenLockStatus } from '../../../../../../../features/noticeitem/src/main/ets/com/ohos/noticeItem/common/constants';
import { NotificationItemData, Rect } from '@ohos/common';
const TAG = 'NotificationPanel-BannerNotification';
const TRANSLATE_SIZE = '382vp';
const ANIM_CONFIG = {
const ANIM_CONFIG: AnimateParam = {
duration: 250,
tempo: 1.0,
curve: Curve.Friction,
@@ -32,7 +32,7 @@ const ANIM_CONFIG = {
iterations: 1,
playMode: PlayMode.Normal,
}
const OPACITY_SHOW_ANIM_CONFIG = {
const OPACITY_SHOW_ANIM_CONFIG: AnimateParam = {
duration: 200,
tempo: 1.0,
curve: Curve.Friction,
@@ -40,7 +40,7 @@ const OPACITY_SHOW_ANIM_CONFIG = {
iterations: 1,
playMode: PlayMode.Normal,
}
const OPACITY_HIDE_ANIM_CONFIG = {
const OPACITY_HIDE_ANIM_CONFIG: AnimateParam = {
duration: 200,
tempo: 1.0,
curve: Curve.Friction,
@@ -57,18 +57,22 @@ struct Index {
@State mLastActionTime: number = 0;
@State needExpand: boolean = true
@State isExpand: boolean = false;
@State pageData: notificationData = new notificationData();
@State pageData: NotificationItemData | undefined = undefined;
@State mOpacity: number = 0.0;
@State mWidthSize: number = 0.8;
@State mTranslate: string = TRANSLATE_SIZE;
mClearCallbacks: unsubscribe[]
mDefaultBannerRect: any;
mClearCallbacks: unsubscribe[] = []
mDefaultBannerRect: Rect = {
left: 0,
top: 0,
width: 0,
height: 0
};
aboutToAppear() {
Log.showInfo(TAG, `aboutToAppear Start`);
AbilityManager.setContextName(AbilityManager.ABILITY_NAME_NOTIFICATION_PANEL, AbilityManager.ABILITY_NAME_NOTIFICATION_PANEL);
setAppBgColor('#00000000')
this.mClearCallbacks = []
this.mClearCallbacks.push(EventManager.subscribe('onBannerNoticeShow', () => this.onBannerNoticeShow()))
this.mClearCallbacks.push(EventManager.subscribe('onBannerNoticeHide', () => this.onBannerNoticeHide()))
@@ -77,11 +81,11 @@ struct Index {
aboutToDisappear() {
Log.showInfo(TAG, `aboutToDisAppear`)
this.mClearCallbacks.forEach((mClearCallback: Function) => {
mClearCallback()
mClearCallback = undefined
this.mClearCallbacks.forEach((mClearCallback: Function | null) => {
mClearCallback&&mClearCallback();
mClearCallback = null
})
this.mClearCallbacks = undefined
this.mClearCallbacks = []
}
build() {
@@ -95,7 +99,7 @@ struct Index {
mBannerNoticeCnt: $mBannerNoticeCnt,
needExpand: $needExpand,
isExpand: $isExpand,
onBannerNoticeHide: () => this.onBannerNoticeHide()
onBannerNoticeHide: ():void => this.onBannerNoticeHide()
})
} else {
Blank()
@@ -149,7 +153,7 @@ struct Index {
}
checkItemNeedExpand() {
if (this.pageData.contentType === NotificationConstants.NOTIFICATION_TYPE_BASIC
if (this.pageData?.contentType === NotificationConstants.NOTIFICATION_TYPE_BASIC
&& (!(this.pageData.actionButtons?.length > 0))) {
return false;
} else {
@@ -157,41 +161,42 @@ struct Index {
}
}
_animateTo(config, callback) {
_animateTo(config: AnimateParam, callback: () => void) {
animateTo(config, callback);
setTimeout(config.onFinish, config.duration + config.delay);
setTimeout(config.onFinish, Number(config.duration) + Number(config.delay));
}
showWindowAnim() {
Log.showDebug(TAG, `show anim start`);
this._animateTo({ ...ANIM_CONFIG, onFinish: () => {
ANIM_CONFIG.onFinish = () => {
Log.showInfo(TAG, `show anim finish`);
} }, () => {
};
this._animateTo(ANIM_CONFIG, () => {
Log.showInfo(TAG, `do show anim`);
this.mWidthSize = 1.0;
this.mTranslate = '0vp';
});
this._animateTo({ ...OPACITY_SHOW_ANIM_CONFIG, onFinish: () => {
} }, () => {
OPACITY_SHOW_ANIM_CONFIG.onFinish = () => {}
this._animateTo(OPACITY_SHOW_ANIM_CONFIG, () => {
this.mOpacity = 1.0;
});
}
hideWindowAnim() {
Log.showDebug(TAG, `hide anim start`);
this._animateTo({ ...ANIM_CONFIG, onFinish: () => {
ANIM_CONFIG.onFinish = () => {
Log.showInfo(TAG, `hide anim finish`);
this.mBannerNoticeCnt = 0;
WindowManager.resetSizeWindow(WindowType.BANNER_NOTICE, this.mDefaultBannerRect);
WindowManager.hideWindow(WindowType.BANNER_NOTICE);
}
}, () => {
};
this._animateTo(ANIM_CONFIG, () => {
Log.showInfo(TAG, `do hide anim`);
this.mWidthSize = 0.8;
this.mTranslate = TRANSLATE_SIZE;
});
this._animateTo({ ...OPACITY_HIDE_ANIM_CONFIG, onFinish: () => {}
}, () => {
OPACITY_HIDE_ANIM_CONFIG.onFinish = () => {};
this._animateTo(OPACITY_HIDE_ANIM_CONFIG, () => {
this.mOpacity = 0.0;
});
}
@@ -20,6 +20,7 @@ import Notification from './notification'
import WindowManager, {
WindowType,
WINDOW_SHOW_HIDE_EVENT,
ArgsInfo,
} from "../../../../../../../common/src/main/ets/default/WindowManager";
import EventManager, {unsubscribe} from "../../../../../../../common/src/main/ets/default/event/EventManager";
import {START_ABILITY_EVENT} from "../../../../../../../common/src/main/ets/default/event/EventUtil";
@@ -44,7 +45,6 @@ struct Index {
aboutToAppear() {
Log.showInfo(TAG, `aboutToAppear, start`)
setAppBgColor('#00000000')
this.initWindowPolicy();
}
@@ -100,14 +100,16 @@ struct Index {
EventManager.subscribe(SHOW_EVENT, () => this.showWindow()),
EventManager.subscribe(HIDE_EVENT, () => this.hideWindow()),
EventManager.subscribe(START_ABILITY_EVENT, () => this.hideWindow()),
EventManager.subscribe(WINDOW_SHOW_HIDE_EVENT, (args) => {
let { windowName, isShow } = args;
EventManager.subscribe(WINDOW_SHOW_HIDE_EVENT, (args: ArgsInfo) => {
let windowName = args.windowName;
let isShow = args?.isShow;
Log.showInfo(TAG, `WINDOW_SHOW_HIDE_EVENT windowName: ${windowName}, isShow: ${isShow}`);
windowName == WindowType.CONTROL_PANEL && isShow && this.hideWindow();
windowName == WindowType.NOTIFICATION_PANEL && isShow && (this.mShowAnimReady = true);
}),
EventManager.subscribe('NotificationWindowResizeEvent',async (args) => {
let { windowName, rect } = args;
EventManager.subscribe('NotificationWindowResizeEvent',async (args: ArgsInfo) => {
let windowName = args.windowName;
let rect = args?.rect;
let dis = await display.getDefaultDisplaySync();
Log.showInfo(TAG, `NotificationWindowResizeEvent: ${windowName}, isShow: ${rect}`);
AbilityManager.setAbilityData(AbilityManager.ABILITY_NAME_NOTIFICATION_PANEL, 'rect', rect);
@@ -117,7 +119,7 @@ struct Index {
});
WindowManager.resetSizeWindow(windowName, rect).then(
).then(() => {
}).catch((err) => {
}).catch((error: Error) => {
});
}),
MultimodalInputManager.subscribeCombinationKey([MultiKeyCode.WIN, MultiKeyCode.N], (data) => {
@@ -132,9 +134,9 @@ struct Index {
);
}
_animateTo(config, callback) {
_animateTo(config: AnimateParam, callback: () => void) {
animateTo(config, callback)
setTimeout(config.onFinish, config.duration + config.delay)
setTimeout(config.onFinish, Number(config.duration) + Number(config.delay))
}
showAnimation(){
@@ -19,6 +19,7 @@ import EventManager from "../../../../../../../common/src/main/ets/default/event
import {obtainStartAbility} from "../../../../../../../common/src/main/ets/default/event/EventUtil"
import NotificationListComponent from '../../../../../../../features/noticeitem/src/main/ets/com/ohos/noticeItem/view/NotificationListComponent'
import NotificationViewModel from '../../../../../../../features/noticeitem/src/main/ets/com/ohos/noticeItem/viewmodel/NotificationViewModel'
import { NotificationItemData } from '@ohos/common'
const TAG = 'NotificationPanel-notification'
const NO_NOTIFICATION_TOP_MARGIN = 40;
@@ -32,7 +33,7 @@ const NOTIFICATION_TITLE_ICON_MARGIN = 24;
@Component
export default struct Notification {
@StorageLink('notificationList') notificationList: any[] = []
@StorageLink('notificationList') notificationList: NotificationItemData[][] = []
@State isEnd: boolean = false
aboutToAppear() {
+2 -1
View File
@@ -13,6 +13,7 @@
"@ohos/batterycomponent": "file:../../../features/batterycomponent",
"@ohos/ringmodecomponent": "file:../../../features/ringmodecomponent",
"@ohos/capsulecomponent": "file:../../../features/capsulecomponent",
"@ohos/airplanecomponent": "file:../../../features/airplanecomponent"
"@ohos/airplanecomponent": "file:../../../features/airplanecomponent",
"@ohos/common": "file:../../../common"
}
}
@@ -22,16 +22,16 @@ import StatusbarConfig from './common/StatusbarConfig'
import AbilityManager from '../../../../../../../common/src/main/ets/default/abilitymanager/abilityManager'
import StatusBarVM from '../../../../../../../features/statusbarcomponent/src/main/ets/com/ohos/viewmodel/StatusBarVM'
import {StatusBarData} from '../../../../../../../features/statusbarcomponent/src/main/ets/com/ohos/common/Constants'
import { ConfigInfo } from '@ohos/common';
const TAG = 'StatusBar-Index'
let mHeightConfigUtils;
@Entry
@Component
struct Index {
@StorageLink('StatusMinH') StatusMinH: number = 24
@StorageLink('StatusCoefficient') StatusCoefficient: number = 1.0
private mHeightConfigUtils: HeightConfigUtils = new HeightConfigUtils
onBackPress(): boolean {
return true;
@@ -40,30 +40,24 @@ struct Index {
aboutToAppear() {
Log.showInfo(TAG, `aboutToAppear, start`);
let configInfo = AbilityManager.getAbilityData(AbilityManager.ABILITY_NAME_STATUS_BAR, 'config')
let configInfo = AbilityManager.getAbilityData(AbilityManager.ABILITY_NAME_STATUS_BAR, 'config') as ConfigInfo
let statusBarData: StatusBarData = new StatusBarData();
statusBarData.displayWidth = configInfo.maxWidth;
statusBarData.displayHeight = configInfo.maxHeight;
statusBarData.showHorizontal = configInfo.showHorizontal;
statusBarData.ableToMaximize = configInfo.ableToMaximize;
statusBarData.ableToMaximize = configInfo.ableToMaximize as boolean;
statusBarData.realWidth = configInfo.realWidth;
statusBarData.realHeight = configInfo.realHeight;
statusBarData.left = configInfo.xCoordinate;
statusBarData.top = configInfo.yCoordinate;
StatusBarVM.updateStatusBarData(statusBarData);
setAppBgColor('#00000000');
CommonStyleManager.setAbilityPageName(TAG);
StyleManager.setStyle();
mHeightConfigUtils = new HeightConfigUtils();
let StatusMinH;
let StatusCoefficient;
StatusMinH = AppStorage.SetAndLink("StatusMinH", 24);
StatusCoefficient = AppStorage.SetAndLink("StatusCoefficient", 1.0);
StatusMinH.set(mHeightConfigUtils.getStatusMinH());
StatusCoefficient.set(mHeightConfigUtils.getStatusCoefficient());
let StatusMinH = AppStorage.SetAndLink("StatusMinH", 24);
let StatusCoefficient = AppStorage.SetAndLink("StatusCoefficient", 1.0);
StatusMinH.set(this.mHeightConfigUtils.getStatusMinH());
StatusCoefficient.set(this.mHeightConfigUtils.getStatusCoefficient());
let signalObserved = AppStorage.SetAndLink("signalObserved", false);
signalObserved.set(false);
+2 -1
View File
@@ -15,6 +15,7 @@
"@ohos/ringmodecomponent": "file:../../../features/ringmodecomponent",
"@ohos/autorotatecomponent": "file:../../../features/autorotatecomponent",
"@ohos/noticeitem": "file:../../../features/noticeitem",
"@ohos/airplanecomponent": "file:../../../features/airplanecomponent"
"@ohos/airplanecomponent": "file:../../../features/airplanecomponent",
"@ohos/common": "file:../../../common"
}
}
@@ -19,7 +19,7 @@ import Log from '../../../../../../../common/src/main/ets/default/Log';
import WindowManager, { WindowType } from '../../../../../../../common/src/main/ets/default/WindowManager';
import AbilityManager from '../../../../../../../common/src/main/ets/default/abilitymanager/abilityManager';
import NavBarConfiguration from '../../../../../../../features/navigationservice/src/main/ets/com/ohos/navigationservice/common/NavBarConfiguration';
import { Want } from 'ability/want';
import { Want } from '@kit.AbilityKit';
const TAG = 'DropdownPanel_ServiceExtAbility';
@@ -14,17 +14,18 @@
*/
import Log from '../../../../../../../common/src/main/ets/default/Log';
import {notificationData} from '../../../../../../../common/src/main/ets/plugindatasource/common/Constants'
import { NotificationItemData } from '../../../../../../../common/src/main/ets/plugindatasource/common/Constants'
import AbilityManager from '../../../../../../../common/src/main/ets/default/abilitymanager/abilityManager';
import WindowManager, { WindowType } from '../../../../../../../common/src/main/ets/default/WindowManager';
import EventManager, {unsubscribe} from "../../../../../../../common/src/main/ets/default/event/EventManager";
import BannerNotification from '../../../../../../../features/noticeitem/src/main/ets/com/ohos/noticeItem/view/item/bannerNotificationItem';
import NotificationViewModel from '../../../../../../../features/noticeitem/src/main/ets/com/ohos/noticeItem/viewmodel/NotificationViewModel';
import NotificationConstants, { ScreenLockStatus } from '../../../../../../../features/noticeitem/src/main/ets/com/ohos/noticeItem/common/constants';
import { Rect } from '@ohos/common';
const TAG = 'DropdownPanel-BannerNotification';
const TRANSLATE_SIZE = '382vp';
const ANIM_CONFIG = {
const ANIM_CONFIG: AnimateParam = {
duration: 250,
tempo: 1.0,
curve: Curve.Friction,
@@ -32,7 +33,7 @@ const ANIM_CONFIG = {
iterations: 1,
playMode: PlayMode.Normal,
}
const OPACITY_SHOW_ANIM_CONFIG = {
const OPACITY_SHOW_ANIM_CONFIG: AnimateParam = {
duration: 200,
tempo: 1.0,
curve: Curve.Friction,
@@ -40,7 +41,7 @@ const OPACITY_SHOW_ANIM_CONFIG = {
iterations: 1,
playMode: PlayMode.Normal,
}
const OPACITY_HIDE_ANIM_CONFIG = {
const OPACITY_HIDE_ANIM_CONFIG: AnimateParam = {
duration: 200,
tempo: 1.0,
curve: Curve.Friction,
@@ -57,13 +58,18 @@ struct Index {
@State mLastActionTime: number = 0;
@State needExpand: boolean = true
@State isExpand: boolean = false;
@State pageData: notificationData = new notificationData();
@State pageData: NotificationItemData | undefined = undefined;
@State mOpacity: number = 0.0;
@State mWidthSize: number = 0.8;
@State mTranslate: string = TRANSLATE_SIZE;
mClearCallbacks: unsubscribe[]
mDefaultBannerRect: any;
mClearCallbacks: unsubscribe[] = [];
mDefaultBannerRect: Rect = {
left: 0,
top: 0,
width: 0,
height: 0
};
aboutToAppear() {
Log.showInfo(TAG, `aboutToAppear Start`);
@@ -77,11 +83,11 @@ struct Index {
aboutToDisappear() {
Log.showInfo(TAG, `aboutToDisAppear`)
this.mClearCallbacks.forEach((mClearCallback: Function) => {
mClearCallback()
this.mClearCallbacks.forEach((mClearCallback: Function | undefined) => {
mClearCallback&&mClearCallback()
mClearCallback = undefined
})
this.mClearCallbacks = undefined
this.mClearCallbacks = []
}
build() {
@@ -95,7 +101,7 @@ struct Index {
mBannerNoticeCnt: $mBannerNoticeCnt,
needExpand: $needExpand,
isExpand: $isExpand,
onBannerNoticeHide: () => this.onBannerNoticeHide()
onBannerNoticeHide: (): void => this.onBannerNoticeHide()
})
} else {
Blank()
@@ -149,7 +155,7 @@ struct Index {
}
checkItemNeedExpand() {
if (this.pageData.contentType === NotificationConstants.NOTIFICATION_TYPE_BASIC
if (this.pageData?.contentType === NotificationConstants.NOTIFICATION_TYPE_BASIC
&& (!(this.pageData.actionButtons?.length > 0))) {
return false;
} else {
@@ -157,41 +163,42 @@ struct Index {
}
}
_animateTo(config, callback) {
_animateTo(config: AnimateParam, callback: () => void) {
animateTo(config, callback);
setTimeout(config.onFinish, config.duration + config.delay);
setTimeout(config.onFinish, Number(config.duration) + Number(config.delay));
}
showWindowAnim() {
Log.showDebug(TAG, `show anim start`);
this._animateTo({ ...ANIM_CONFIG, onFinish: () => {
ANIM_CONFIG.onFinish = () => {
Log.showInfo(TAG, `show anim finish`);
} }, () => {
};
this._animateTo(ANIM_CONFIG, () => {
Log.showInfo(TAG, `do show anim`);
this.mWidthSize = 1.0;
this.mTranslate = '0vp';
});
this._animateTo({ ...OPACITY_SHOW_ANIM_CONFIG, onFinish: () => {
} }, () => {
OPACITY_SHOW_ANIM_CONFIG.onFinish = () => {}
this._animateTo(OPACITY_SHOW_ANIM_CONFIG, () => {
this.mOpacity = 1.0;
});
}
hideWindowAnim() {
Log.showDebug(TAG, `hide anim start`);
this._animateTo({ ...ANIM_CONFIG, onFinish: () => {
ANIM_CONFIG.onFinish = () => {
Log.showInfo(TAG, `hide anim finish`);
this.mBannerNoticeCnt = 0;
WindowManager.resetSizeWindow(WindowType.BANNER_NOTICE, this.mDefaultBannerRect);
WindowManager.hideWindow(WindowType.BANNER_NOTICE);
}
}, () => {
};
this._animateTo(ANIM_CONFIG, () => {
Log.showInfo(TAG, `do hide anim`);
this.mWidthSize = 0.8;
this.mTranslate = TRANSLATE_SIZE;
});
this._animateTo({ ...OPACITY_HIDE_ANIM_CONFIG, onFinish: () => {}
}, () => {
OPACITY_HIDE_ANIM_CONFIG.onFinish = () => {};
this._animateTo(OPACITY_HIDE_ANIM_CONFIG, () => {
this.mOpacity = 0.0;
});
}
@@ -15,6 +15,7 @@
import commonEvent from '@ohos.commonEvent';
import Log from '../../../../../../../../common/src/main/ets/default/Log';
import { inputConsumer } from '@kit.InputKit';
const TAG = 'navigationEvent';
@@ -24,8 +25,14 @@ let commonEventSubscribeInfo = {
let commonEventSubscriber = null;
export interface NavigationCallBack {
"onStateChange": (data: string) => void;
"onNotificationShowOrHide": (data: inputConsumer.KeyOptions) => void;
"onControlShowOrHide": (data: inputConsumer.KeyOptions) => void;
}
export class navigationEvent {
mCallback: any;
mCallback: NavigationCallBack;
registerCallback(callback): void {
Log.showDebug(TAG, 'registerCallback');

Some files were not shown because too many files have changed in this diff Show More