From ebabf59947ea2d112168e71b196300a07752da75 Mon Sep 17 00:00:00 2001 From: Ilya Erokhin Date: Fri, 29 Mar 2024 12:23:40 +0300 Subject: [PATCH] [HOS-2301] Update performance measurement Demo Apps --- theme/ThemeDemoBaseline/build-profile.json5 | 4 +- .../demo1case1ability/Demo1Case1Ability.ts | 43 ++++++ .../demo1case2ability/Demo1Case2Ability.ts | 43 ++++++ .../demo2case1ability/Demo2Case1Ability.ts | 43 ++++++ .../demo2case2ability/Demo2Case2Ability.ts | 43 ++++++ .../src/main/ets/pages/tests/Case3Page.ets | 30 ---- .../ets/pages/tests/TestsNavigationPage.ets | 12 +- .../Demo1Case1Page.ets} | 2 +- .../Demo1Case2Page.ets} | 2 +- .../pages/tests/demo1/Demo1NavigationPage.ets | 45 ++++++ .../ets/pages/tests/demo2/Demo2Case1Page.ets | 55 +++++++ .../ets/pages/tests/demo2/Demo2Case2Page.ets | 134 +++++++++++++++++ .../pages/tests/demo2/Demo2NavigationPage.ets | 45 ++++++ .../src/main/ets/theme/CustomColorsImlp.ets | 20 +++ .../entry/src/main/module.json5 | 42 +++++- .../main/resources/base/element/string.json | 48 ++++++ .../resources/base/profile/main_pages.json | 13 +- .../main/resources/en_US/element/string.json | 48 ++++++ .../main/resources/zh_CN/element/string.json | 48 ++++++ .../entry/oh-package.json5 | 8 +- .../demo1case1ability/Demo1Case1Ability.ets | 43 ++++++ .../demo1case2ability/Demo1Case2Ability.ets | 43 ++++++ .../demo2case1ability/Demo2Case1Ability.ets | 43 ++++++ .../demo2case2ability/Demo2Case2Ability.ets | 43 ++++++ .../demo2case3ability/Demo2Case3Ability.ets | 43 ++++++ .../demo2case4ability/Demo2Case4Ability.ets | 43 ++++++ .../demo3case1ability/Demo3Case1Ability.ets | 43 ++++++ .../demo3case2ability/Demo3Case2Ability.ets | 43 ++++++ .../demo3case3ability/Demo3Case3Ability.ets | 43 ++++++ .../demo3case4ability/Demo3Case4Ability.ets | 43 ++++++ .../ets/pages/tests/TestsNavigationPage.ets | 4 + .../ets/pages/tests/demo1/Demo1Case1Page.ets | 1 + .../ets/pages/tests/demo1/Demo1Case2Page.ets | 1 + .../ets/pages/tests/demo1/Demo1Case3Page.ets | 30 ---- .../pages/tests/demo1/Demo1NavigationPage.ets | 19 +-- .../ets/pages/tests/demo2/Demo2Case1Page.ets | 12 +- .../ets/pages/tests/demo2/Demo2Case2Page.ets | 12 +- .../ets/pages/tests/demo2/Demo2Case3Page.ets | 12 +- .../ets/pages/tests/demo2/Demo2Case4Page.ets | 12 +- .../pages/tests/demo2/Demo2NavigationPage.ets | 26 ++-- .../Demo3Case1Page.ets} | 39 +++-- .../Demo3Case2Page.ets} | 41 ++--- .../ets/pages/tests/demo3/Demo3Case3Page.ets | 141 ++++++++++++++++++ .../ets/pages/tests/demo3/Demo3Case4Page.ets | 141 ++++++++++++++++++ .../pages/tests/demo3/Demo3NavigationPage.ets | 55 +++++++ .../src/main/ets/theme/CustomColorsImlp.ets | 30 +--- .../src/main/ets/theme/CustomThemeImpl.ets | 10 +- .../entry/src/main/module.json5 | 100 +++++++++++++ .../main/resources/base/element/string.json | 104 +++++++++++++ .../resources/base/profile/main_pages.json | 12 +- .../main/resources/en_US/element/string.json | 104 +++++++++++++ .../main/resources/zh_CN/element/string.json | 104 +++++++++++++ .../oh-package.json5 | 15 +- 53 files changed, 1980 insertions(+), 203 deletions(-) create mode 100644 theme/ThemeDemoBaseline/entry/src/main/ets/demo1case1ability/Demo1Case1Ability.ts create mode 100644 theme/ThemeDemoBaseline/entry/src/main/ets/demo1case2ability/Demo1Case2Ability.ts create mode 100644 theme/ThemeDemoBaseline/entry/src/main/ets/demo2case1ability/Demo2Case1Ability.ts create mode 100644 theme/ThemeDemoBaseline/entry/src/main/ets/demo2case2ability/Demo2Case2Ability.ts delete mode 100644 theme/ThemeDemoBaseline/entry/src/main/ets/pages/tests/Case3Page.ets rename theme/ThemeDemoBaseline/entry/src/main/ets/pages/tests/{Case1Page.ets => demo1/Demo1Case1Page.ets} (95%) rename theme/ThemeDemoBaseline/entry/src/main/ets/pages/tests/{Case2Page.ets => demo1/Demo1Case2Page.ets} (98%) create mode 100644 theme/ThemeDemoBaseline/entry/src/main/ets/pages/tests/demo1/Demo1NavigationPage.ets create mode 100644 theme/ThemeDemoBaseline/entry/src/main/ets/pages/tests/demo2/Demo2Case1Page.ets create mode 100644 theme/ThemeDemoBaseline/entry/src/main/ets/pages/tests/demo2/Demo2Case2Page.ets create mode 100644 theme/ThemeDemoBaseline/entry/src/main/ets/pages/tests/demo2/Demo2NavigationPage.ets create mode 100644 theme/ThemeDemoBaseline/entry/src/main/ets/theme/CustomColorsImlp.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/demo1case1ability/Demo1Case1Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/demo1case2ability/Demo1Case2Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/demo2case1ability/Demo2Case1Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/demo2case2ability/Demo2Case2Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/demo2case3ability/Demo2Case3Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/demo2case4ability/Demo2Case4Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/demo3case1ability/Demo3Case1Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/demo3case2ability/Demo3Case2Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/demo3case3ability/Demo3Case3Ability.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/demo3case4ability/Demo3Case4Ability.ets delete mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/demo1/Demo1Case3Page.ets rename theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/{demo2/Demo2Case5Page.ets => demo3/Demo3Case1Page.ets} (37%) rename theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/{demo2/Demo2Case6Page.ets => demo3/Demo3Case2Page.ets} (37%) create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/demo3/Demo3Case3Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/demo3/Demo3Case4Page.ets create mode 100644 theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/demo3/Demo3NavigationPage.ets diff --git a/theme/ThemeDemoBaseline/build-profile.json5 b/theme/ThemeDemoBaseline/build-profile.json5 index e5dbeca..1b83704 100644 --- a/theme/ThemeDemoBaseline/build-profile.json5 +++ b/theme/ThemeDemoBaseline/build-profile.json5 @@ -1,10 +1,10 @@ { "app": { "signingConfigs": [], - "compileSdkVersion": 9, - "compatibleSdkVersion": 9, "products": [ { + "compileSdkVersion": 10, + "compatibleSdkVersion": 10, "name": "default", "signingConfig": "default", } diff --git a/theme/ThemeDemoBaseline/entry/src/main/ets/demo1case1ability/Demo1Case1Ability.ts b/theme/ThemeDemoBaseline/entry/src/main/ets/demo1case1ability/Demo1Case1Ability.ts new file mode 100644 index 0000000..96e46b7 --- /dev/null +++ b/theme/ThemeDemoBaseline/entry/src/main/ets/demo1case1ability/Demo1Case1Ability.ts @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class Demo1Case1Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/demo1/Demo1Case1Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemeDemoBaseline/entry/src/main/ets/demo1case2ability/Demo1Case2Ability.ts b/theme/ThemeDemoBaseline/entry/src/main/ets/demo1case2ability/Demo1Case2Ability.ts new file mode 100644 index 0000000..523a62f --- /dev/null +++ b/theme/ThemeDemoBaseline/entry/src/main/ets/demo1case2ability/Demo1Case2Ability.ts @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class Demo1Case2Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/demo1/Demo1Case2Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemeDemoBaseline/entry/src/main/ets/demo2case1ability/Demo2Case1Ability.ts b/theme/ThemeDemoBaseline/entry/src/main/ets/demo2case1ability/Demo2Case1Ability.ts new file mode 100644 index 0000000..0f1f8d3 --- /dev/null +++ b/theme/ThemeDemoBaseline/entry/src/main/ets/demo2case1ability/Demo2Case1Ability.ts @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class Demo2Case1Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/demo2/Demo2Case1Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemeDemoBaseline/entry/src/main/ets/demo2case2ability/Demo2Case2Ability.ts b/theme/ThemeDemoBaseline/entry/src/main/ets/demo2case2ability/Demo2Case2Ability.ts new file mode 100644 index 0000000..1a0c9c9 --- /dev/null +++ b/theme/ThemeDemoBaseline/entry/src/main/ets/demo2case2ability/Demo2Case2Ability.ts @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class Demo2Case2Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/demo2/Demo2Case2Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemeDemoBaseline/entry/src/main/ets/pages/tests/Case3Page.ets b/theme/ThemeDemoBaseline/entry/src/main/ets/pages/tests/Case3Page.ets deleted file mode 100644 index 89c3d18..0000000 --- a/theme/ThemeDemoBaseline/entry/src/main/ets/pages/tests/Case3Page.ets +++ /dev/null @@ -1,30 +0,0 @@ -/* ForEach Vertical Flex Layout with 100 Buttons as elements with no Custom Theme, 1 item per line */ - -@Entry -@Component -struct Case3Page { - data: string[] = [] - - aboutToAppear() { - for (let i = 0; i < 100; i++) { - this.data.push('Item #' + i) - } - } - - build() { - Row() { - Scroll() { - Flex({ direction: FlexDirection.Column, wrap: FlexWrap.Wrap }) { - ForEach(this.data, (item: string) => { - Button(item) - .width('100%') - .margin({ top: '4vp', bottom: '4vp' }) - }, (item: string) => item) - } - .padding({ left: '8vp', right: '8vp' }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/theme/ThemeDemoBaseline/entry/src/main/ets/pages/tests/TestsNavigationPage.ets b/theme/ThemeDemoBaseline/entry/src/main/ets/pages/tests/TestsNavigationPage.ets index 53b5294..054d569 100644 --- a/theme/ThemeDemoBaseline/entry/src/main/ets/pages/tests/TestsNavigationPage.ets +++ b/theme/ThemeDemoBaseline/entry/src/main/ets/pages/tests/TestsNavigationPage.ets @@ -10,16 +10,12 @@ export interface DataClass { struct TestsNavigationPage { data: DataClass[] = [ { - title: 'Case 1: ForEach List with 100 Buttons as elements with no Custom Theme', - page: 'pages/tests/Case1Page' + title: 'Demo 1: SystemTheme', + page: 'pages/tests/demo1/Demo1NavigationPage' }, { - title: 'Case 2: LazyForEach List with 2000 Buttons as elements with no Custom Theme', - page: 'pages/tests/Case2Page' - }, - { - title: 'Case 3: ForEach Vertical Flex Layout with 100 Buttons as elements with no Custom Theme, 1 item per line', - page: 'pages/tests/Case3Page' + title: 'Demo 2: Custom Attributes', + page: 'pages/tests/demo2/Demo2NavigationPage' }, ] diff --git a/theme/ThemeDemoBaseline/entry/src/main/ets/pages/tests/Case1Page.ets b/theme/ThemeDemoBaseline/entry/src/main/ets/pages/tests/demo1/Demo1Case1Page.ets similarity index 95% rename from theme/ThemeDemoBaseline/entry/src/main/ets/pages/tests/Case1Page.ets rename to theme/ThemeDemoBaseline/entry/src/main/ets/pages/tests/demo1/Demo1Case1Page.ets index 9bb3533..fecba96 100644 --- a/theme/ThemeDemoBaseline/entry/src/main/ets/pages/tests/Case1Page.ets +++ b/theme/ThemeDemoBaseline/entry/src/main/ets/pages/tests/demo1/Demo1Case1Page.ets @@ -2,7 +2,7 @@ @Entry @Component -struct Case1Page { +struct Demo1Case1Page { data: string[] = [] aboutToAppear() { diff --git a/theme/ThemeDemoBaseline/entry/src/main/ets/pages/tests/Case2Page.ets b/theme/ThemeDemoBaseline/entry/src/main/ets/pages/tests/demo1/Demo1Case2Page.ets similarity index 98% rename from theme/ThemeDemoBaseline/entry/src/main/ets/pages/tests/Case2Page.ets rename to theme/ThemeDemoBaseline/entry/src/main/ets/pages/tests/demo1/Demo1Case2Page.ets index 39d57a6..88254fa 100644 --- a/theme/ThemeDemoBaseline/entry/src/main/ets/pages/tests/Case2Page.ets +++ b/theme/ThemeDemoBaseline/entry/src/main/ets/pages/tests/demo1/Demo1Case2Page.ets @@ -81,7 +81,7 @@ class MyDataSource extends BasicDataSource { @Entry @Component -struct Case2Page { +struct Demo1Case2Page { private data: MyDataSource = new MyDataSource(); aboutToAppear() { diff --git a/theme/ThemeDemoBaseline/entry/src/main/ets/pages/tests/demo1/Demo1NavigationPage.ets b/theme/ThemeDemoBaseline/entry/src/main/ets/pages/tests/demo1/Demo1NavigationPage.ets new file mode 100644 index 0000000..a247164 --- /dev/null +++ b/theme/ThemeDemoBaseline/entry/src/main/ets/pages/tests/demo1/Demo1NavigationPage.ets @@ -0,0 +1,45 @@ +import common from '@ohos.app.ability.common' + +export interface DataClass { + title: string + ability: string +} + +@Entry +@Component +struct Demo1NavigationPage { + data: DataClass[] = [ + { + title: 'Case 1: ForEach List with 100 Buttons as elements with no Custom Theme', + ability: 'Demo1Case1Ability' + }, + { + title: 'Case 2: LazyForEach List with 2000 Buttons as elements with no Custom Theme', + ability: 'Demo1Case2Ability' + }, + ] + + private context = getContext(this) as common.UIAbilityContext; + + build() { + Stack() { + List({ space: '8vp' }) { + ForEach(this.data, (item: DataClass) => { + ListItem() { + Button(item.title) + .width('100%') + .onClick(() => { + this.context.startAbility({ + bundleName: this.context.abilityInfo.bundleName, + abilityName: item.ability + }) + }) + }.width('100%') + .padding({ left: '8vp', right: '8vp' }) + }, (item: DataClass) => item.title) + }.scrollBar(BarState.Off) + } + .height('100%') + .width('100%') + } +} \ No newline at end of file diff --git a/theme/ThemeDemoBaseline/entry/src/main/ets/pages/tests/demo2/Demo2Case1Page.ets b/theme/ThemeDemoBaseline/entry/src/main/ets/pages/tests/demo2/Demo2Case1Page.ets new file mode 100644 index 0000000..9631432 --- /dev/null +++ b/theme/ThemeDemoBaseline/entry/src/main/ets/pages/tests/demo2/Demo2Case1Page.ets @@ -0,0 +1,55 @@ +/* ForEach List (Custom attrs) with 100 Buttons as elements with no Custom Theme */ +import { BrownThemeColors, GreenThemeColors, RedColors, RedThemeColors } from '../../../theme/CustomColorsImlp' + +@Entry +@Component +struct Demo2Case1Page { + data: string[] = [] + + @State textColor: ResourceColor = RedThemeColors.fontOnPrimary + @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize + count = 0 + + aboutToAppear() { + for (let i = 0; i < 100; i++) { + this.data.push('Item #' + i) + } + } + + build() { + Row() { + List({ space: '8vp' }) { + ForEach(this.data, (item: string) => { + ListItem() { + Button(item) + .fontColor(this.textColor) + .backgroundColor(this.bkgColor) + }.width('100%') + }, (item: string) => item) + } + .width('100%') + } + .height('100%') + .onClick(() => { + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.textColor = RedThemeColors.fontOnPrimary + this.bkgColor = RedThemeColors.backgroundEmphasize + break + case 1: + this.textColor = GreenThemeColors.fontOnPrimary + this.bkgColor = GreenThemeColors.backgroundEmphasize + break + case 2: + default: + this.textColor = BrownThemeColors.fontOnPrimary + this.bkgColor = BrownThemeColors.backgroundEmphasize + break + } + }) + } +} \ No newline at end of file diff --git a/theme/ThemeDemoBaseline/entry/src/main/ets/pages/tests/demo2/Demo2Case2Page.ets b/theme/ThemeDemoBaseline/entry/src/main/ets/pages/tests/demo2/Demo2Case2Page.ets new file mode 100644 index 0000000..8c36a93 --- /dev/null +++ b/theme/ThemeDemoBaseline/entry/src/main/ets/pages/tests/demo2/Demo2Case2Page.ets @@ -0,0 +1,134 @@ +/* LazyForEach (Custom attrs) List with 2000 Buttons as elements with no Custom Theme */ +import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp'; + +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): string { + return ''; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } + + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }) + } +} + +class MyDataSource extends BasicDataSource { + private dataArray: string[] = []; + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): string { + return this.dataArray[index]; + } + + public addData(index: number, data: string): void { + this.dataArray.splice(index, 0, data); + this.notifyDataAdd(index); + } + + public pushData(data: string): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } +} + +@Entry +@Component +struct Demo2Case2Page { + private data: MyDataSource = new MyDataSource() + + @State textColor: ResourceColor = RedThemeColors.fontOnPrimary + @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize + count = 0 + + aboutToAppear() { + for (let i = 0; i < 2000; i++) { + this.data.pushData('Item #' + i) + } + } + + build() { + Row() { + List({ space: '8vp' }) { + LazyForEach(this.data, (item: string) => { + ListItem() { + Button(item) + .fontColor(this.textColor) + .backgroundColor(this.bkgColor) + }.width('100%') + }, (item: string) => item) + } + .width('100%') + } + .height('100%') + .onClick(() => { + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.textColor = RedThemeColors.fontOnPrimary + this.bkgColor = RedThemeColors.backgroundEmphasize + break + case 1: + this.textColor = GreenThemeColors.fontOnPrimary + this.bkgColor = GreenThemeColors.backgroundEmphasize + break + case 2: + default: + this.textColor = BrownThemeColors.fontOnPrimary + this.bkgColor = BrownThemeColors.backgroundEmphasize + break + } + }) + } +} \ No newline at end of file diff --git a/theme/ThemeDemoBaseline/entry/src/main/ets/pages/tests/demo2/Demo2NavigationPage.ets b/theme/ThemeDemoBaseline/entry/src/main/ets/pages/tests/demo2/Demo2NavigationPage.ets new file mode 100644 index 0000000..2f2215f --- /dev/null +++ b/theme/ThemeDemoBaseline/entry/src/main/ets/pages/tests/demo2/Demo2NavigationPage.ets @@ -0,0 +1,45 @@ +import common from '@ohos.app.ability.common'; + +export interface DataClass { + title: string + ability: string +} + +@Entry +@Component +struct Demo2NavigationPage { + data: DataClass[] = [ + { + title: 'Case 1: ForEach (Custom attrs) List with 100 Buttons as elements with no Custom Theme', + ability: 'Demo2Case1Ability' + }, + { + title: 'Case 2: LazyForEach (Custom attrs) List with 2000 Buttons as elements with no Custom Theme', + ability: 'Demo2Case2Ability' + }, + ] + + private context = getContext(this) as common.UIAbilityContext; + + build() { + Stack() { + List({ space: '8vp' }) { + ForEach(this.data, (item: DataClass) => { + ListItem() { + Button(item.title) + .width('100%') + .onClick(() => { + this.context.startAbility({ + bundleName: this.context.abilityInfo.bundleName, + abilityName: item.ability + }) + }) + }.width('100%') + .padding({ left: '8vp', right: '8vp' }) + }, (item: DataClass) => item.title) + }.scrollBar(BarState.Off) + } + .height('100%') + .width('100%') + } +} \ No newline at end of file diff --git a/theme/ThemeDemoBaseline/entry/src/main/ets/theme/CustomColorsImlp.ets b/theme/ThemeDemoBaseline/entry/src/main/ets/theme/CustomColorsImlp.ets new file mode 100644 index 0000000..fd4ed87 --- /dev/null +++ b/theme/ThemeDemoBaseline/entry/src/main/ets/theme/CustomColorsImlp.ets @@ -0,0 +1,20 @@ +export class RedColors { + fontOnPrimary = '#FFFFFFFF' + backgroundEmphasize = '#FFD00000' +} + +export class GreenColors { + fontOnPrimary = '#FFFFFFFF' + backgroundEmphasize = '#FF00541F' +} + +export class BrownColors { + fontOnPrimary = '#FFFFFFFF' + backgroundEmphasize = '#FF8B6B5C' +} + +export const RedThemeColors = new RedColors() + +export const GreenThemeColors = new GreenColors() + +export const BrownThemeColors = new BrownColors() \ No newline at end of file diff --git a/theme/ThemeDemoBaseline/entry/src/main/module.json5 b/theme/ThemeDemoBaseline/entry/src/main/module.json5 index aa0dece..babe12e 100644 --- a/theme/ThemeDemoBaseline/entry/src/main/module.json5 +++ b/theme/ThemeDemoBaseline/entry/src/main/module.json5 @@ -31,7 +31,47 @@ ] } ] - } + }, + { + "name": "Demo1Case1Ability", + "srcEntry": "./ets/demo1case1ability/Demo1Case1Ability.ts", + "description": "$string:Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "Demo1Case2Ability", + "srcEntry": "./ets/demo1case2ability/Demo1Case2Ability.ts", + "description": "$string:Case2Ability_desc", + "icon": "$media:icon", + "label": "$string:Case2Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "Demo2Case1Ability", + "srcEntry": "./ets/demo2case1ability/Demo2Case1Ability.ts", + "description": "$string:Demo2Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo2Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "Demo2Case2Ability", + "srcEntry": "./ets/demo2case2ability/Demo2Case2Ability.ts", + "description": "$string:Demo2Case2Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo2Case2Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, ] } } \ No newline at end of file diff --git a/theme/ThemeDemoBaseline/entry/src/main/resources/base/element/string.json b/theme/ThemeDemoBaseline/entry/src/main/resources/base/element/string.json index f945955..b343fb5 100644 --- a/theme/ThemeDemoBaseline/entry/src/main/resources/base/element/string.json +++ b/theme/ThemeDemoBaseline/entry/src/main/resources/base/element/string.json @@ -10,6 +10,54 @@ }, { "name": "EntryAbility_label", + "value": "Theme Baseline Demo" + }, + { + "name": "Case1Ability_desc", + "value": "description" + }, + { + "name": "Case1Ability_label", + "value": "label" + }, + { + "name": "Case2Ability_desc", + "value": "description" + }, + { + "name": "Case2Ability_label", + "value": "label" + }, + { + "name": "Case3Ability_desc", + "value": "description" + }, + { + "name": "Case3Ability_label", + "value": "label" + }, + { + "name": "Demo2Case1Ability_desc", + "value": "description" + }, + { + "name": "Demo2Case1Ability_label", + "value": "label" + }, + { + "name": "Demo2Case2Ability_desc", + "value": "description" + }, + { + "name": "Demo2Case2Ability_label", + "value": "label" + }, + { + "name": "Demo2Case3Ability_desc", + "value": "description" + }, + { + "name": "Demo2Case3Ability_label", "value": "label" } ] diff --git a/theme/ThemeDemoBaseline/entry/src/main/resources/base/profile/main_pages.json b/theme/ThemeDemoBaseline/entry/src/main/resources/base/profile/main_pages.json index e30930b..04d7c12 100644 --- a/theme/ThemeDemoBaseline/entry/src/main/resources/base/profile/main_pages.json +++ b/theme/ThemeDemoBaseline/entry/src/main/resources/base/profile/main_pages.json @@ -1,9 +1,12 @@ { "src": [ "pages/Index", - "pages/tests/TestsNavigationPage", - "pages/tests/Case1Page", - "pages/tests/Case2Page", - "pages/tests/Case3Page" + "pages/tests/demo1/Demo1NavigationPage", + "pages/tests/demo1/Demo1Case1Page", + "pages/tests/demo1/Demo1Case2Page", + "pages/tests/demo2/Demo2Case1Page", + "pages/tests/demo2/Demo2Case2Page", + "pages/tests/demo2/Demo2NavigationPage", + "pages/tests/TestsNavigationPage" ] -} +} \ No newline at end of file diff --git a/theme/ThemeDemoBaseline/entry/src/main/resources/en_US/element/string.json b/theme/ThemeDemoBaseline/entry/src/main/resources/en_US/element/string.json index f945955..b343fb5 100644 --- a/theme/ThemeDemoBaseline/entry/src/main/resources/en_US/element/string.json +++ b/theme/ThemeDemoBaseline/entry/src/main/resources/en_US/element/string.json @@ -10,6 +10,54 @@ }, { "name": "EntryAbility_label", + "value": "Theme Baseline Demo" + }, + { + "name": "Case1Ability_desc", + "value": "description" + }, + { + "name": "Case1Ability_label", + "value": "label" + }, + { + "name": "Case2Ability_desc", + "value": "description" + }, + { + "name": "Case2Ability_label", + "value": "label" + }, + { + "name": "Case3Ability_desc", + "value": "description" + }, + { + "name": "Case3Ability_label", + "value": "label" + }, + { + "name": "Demo2Case1Ability_desc", + "value": "description" + }, + { + "name": "Demo2Case1Ability_label", + "value": "label" + }, + { + "name": "Demo2Case2Ability_desc", + "value": "description" + }, + { + "name": "Demo2Case2Ability_label", + "value": "label" + }, + { + "name": "Demo2Case3Ability_desc", + "value": "description" + }, + { + "name": "Demo2Case3Ability_label", "value": "label" } ] diff --git a/theme/ThemeDemoBaseline/entry/src/main/resources/zh_CN/element/string.json b/theme/ThemeDemoBaseline/entry/src/main/resources/zh_CN/element/string.json index 597ecf9..8006f64 100644 --- a/theme/ThemeDemoBaseline/entry/src/main/resources/zh_CN/element/string.json +++ b/theme/ThemeDemoBaseline/entry/src/main/resources/zh_CN/element/string.json @@ -10,6 +10,54 @@ }, { "name": "EntryAbility_label", + "value": "Theme Baseline Demo" + }, + { + "name": "Case1Ability_desc", + "value": "description" + }, + { + "name": "Case1Ability_label", + "value": "label" + }, + { + "name": "Case2Ability_desc", + "value": "description" + }, + { + "name": "Case2Ability_label", + "value": "label" + }, + { + "name": "Case3Ability_desc", + "value": "description" + }, + { + "name": "Case3Ability_label", + "value": "label" + }, + { + "name": "Demo2Case1Ability_desc", + "value": "description" + }, + { + "name": "Demo2Case1Ability_label", + "value": "label" + }, + { + "name": "Demo2Case2Ability_desc", + "value": "description" + }, + { + "name": "Demo2Case2Ability_label", + "value": "label" + }, + { + "name": "Demo2Case3Ability_desc", + "value": "description" + }, + { + "name": "Demo2Case3Ability_label", "value": "label" } ] diff --git a/theme/ThemePerformanceMeasurement/entry/oh-package.json5 b/theme/ThemePerformanceMeasurement/entry/oh-package.json5 index 248c3b7..225946c 100644 --- a/theme/ThemePerformanceMeasurement/entry/oh-package.json5 +++ b/theme/ThemePerformanceMeasurement/entry/oh-package.json5 @@ -1,10 +1,10 @@ { + "license": "", + "devDependencies": {}, + "author": "", "name": "entry", - "version": "1.0.0", "description": "Please describe the basic information.", "main": "", - "author": "", - "license": "", + "version": "1.0.0", "dependencies": {} } - diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/demo1case1ability/Demo1Case1Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/demo1case1ability/Demo1Case1Ability.ets new file mode 100644 index 0000000..96e46b7 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/demo1case1ability/Demo1Case1Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class Demo1Case1Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/demo1/Demo1Case1Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/demo1case2ability/Demo1Case2Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/demo1case2ability/Demo1Case2Ability.ets new file mode 100644 index 0000000..523a62f --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/demo1case2ability/Demo1Case2Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class Demo1Case2Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/demo1/Demo1Case2Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/demo2case1ability/Demo2Case1Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/demo2case1ability/Demo2Case1Ability.ets new file mode 100644 index 0000000..0f1f8d3 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/demo2case1ability/Demo2Case1Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class Demo2Case1Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/demo2/Demo2Case1Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/demo2case2ability/Demo2Case2Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/demo2case2ability/Demo2Case2Ability.ets new file mode 100644 index 0000000..1a0c9c9 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/demo2case2ability/Demo2Case2Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class Demo2Case2Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/demo2/Demo2Case2Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/demo2case3ability/Demo2Case3Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/demo2case3ability/Demo2Case3Ability.ets new file mode 100644 index 0000000..74d664a --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/demo2case3ability/Demo2Case3Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class Demo2Case3Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/demo2/Demo2Case3Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/demo2case4ability/Demo2Case4Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/demo2case4ability/Demo2Case4Ability.ets new file mode 100644 index 0000000..8c11d66 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/demo2case4ability/Demo2Case4Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class Demo2Case4Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/demo2/Demo2Case4Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/demo3case1ability/Demo3Case1Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/demo3case1ability/Demo3Case1Ability.ets new file mode 100644 index 0000000..ce1deb2 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/demo3case1ability/Demo3Case1Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class Demo3Case1Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/demo3/Demo3Case1Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/demo3case2ability/Demo3Case2Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/demo3case2ability/Demo3Case2Ability.ets new file mode 100644 index 0000000..ae91540 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/demo3case2ability/Demo3Case2Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class Demo3Case2Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/demo3/Demo3Case2Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/demo3case3ability/Demo3Case3Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/demo3case3ability/Demo3Case3Ability.ets new file mode 100644 index 0000000..6f87625 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/demo3case3ability/Demo3Case3Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class Demo3Case3Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/demo3/Demo3Case3Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/demo3case4ability/Demo3Case4Ability.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/demo3case4ability/Demo3Case4Ability.ets new file mode 100644 index 0000000..14f2684 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/demo3case4ability/Demo3Case4Ability.ets @@ -0,0 +1,43 @@ +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import hilog from '@ohos.hilog'; +import UIAbility from '@ohos.app.ability.UIAbility'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; + +export default class Demo3Case4Ability extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/tests/demo3/Demo3Case4Page', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TestsNavigationPage.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TestsNavigationPage.ets index ad9d255..4ba6318 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TestsNavigationPage.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/TestsNavigationPage.ets @@ -17,6 +17,10 @@ struct TestsNavigationPage { title: 'Demo 2: CustomTheme', page: 'pages/tests/demo2/Demo2NavigationPage' }, + { + title: 'Demo 3: CustomTheme + Custom Attributes', + page: 'pages/tests/demo3/Demo3NavigationPage' + }, ] build() { diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/demo1/Demo1Case1Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/demo1/Demo1Case1Page.ets index fecba96..deb61cf 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/demo1/Demo1Case1Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/demo1/Demo1Case1Page.ets @@ -6,6 +6,7 @@ struct Demo1Case1Page { data: string[] = [] aboutToAppear() { + ThemeControl.enableTheme(true) for (let i = 0; i < 100; i++) { this.data.push('Item #' + i) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/demo1/Demo1Case2Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/demo1/Demo1Case2Page.ets index 88254fa..90d4975 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/demo1/Demo1Case2Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/demo1/Demo1Case2Page.ets @@ -85,6 +85,7 @@ struct Demo1Case2Page { private data: MyDataSource = new MyDataSource(); aboutToAppear() { + ThemeControl.enableTheme(true) for (let i = 0; i < 2000; i++) { this.data.pushData('Item #' + i) } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/demo1/Demo1Case3Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/demo1/Demo1Case3Page.ets deleted file mode 100644 index fadb848..0000000 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/demo1/Demo1Case3Page.ets +++ /dev/null @@ -1,30 +0,0 @@ -/* ForEach Vertical Flex Layout with 100 Buttons as elements with no Custom Theme, 1 item per line */ - -@Entry -@Component -struct Demo1Case3Page { - data: string[] = [] - - aboutToAppear() { - for (let i = 0; i < 100; i++) { - this.data.push('Item #' + i) - } - } - - build() { - Row() { - Scroll() { - Flex({ direction: FlexDirection.Column, wrap: FlexWrap.Wrap }) { - ForEach(this.data, (item: string) => { - Button(item) - .width('100%') - .margin({ top: '4vp', bottom: '4vp' }) - }, (item: string) => item) - } - .padding({ left: '8vp', right: '8vp' }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/demo1/Demo1NavigationPage.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/demo1/Demo1NavigationPage.ets index df0b787..4201ba7 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/demo1/Demo1NavigationPage.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/demo1/Demo1NavigationPage.ets @@ -1,8 +1,8 @@ -import router from '@ohos.router' +import common from '@ohos.app.ability.common' export interface DataClass { title: string - page: string + ability: string } @Entry @@ -11,18 +11,16 @@ struct Demo1NavigationPage { data: DataClass[] = [ { title: 'Case 1: ForEach List with 100 Buttons as elements with no Custom Theme', - page: 'pages/tests/demo1/Demo1Case1Page' + ability: 'Demo1Case1Ability' }, { title: 'Case 2: LazyForEach List with 2000 Buttons as elements with no Custom Theme', - page: 'pages/tests/demo1/Demo1Case2Page' - }, - { - title: 'Case 3: ForEach Vertical Flex Layout with 100 Buttons as elements with no Custom Theme, 1 item per line', - page: 'pages/tests/demo1/Demo1Case3Page' + ability: 'Demo1Case2Ability' }, ] + private context = getContext(this) as common.UIAbilityContext + build() { Stack() { List({ space: '8vp' }) { @@ -31,7 +29,10 @@ struct Demo1NavigationPage { Button(item.title) .width('100%') .onClick(() => { - router.pushUrl({ url: item.page }) + this.context.startAbility({ + bundleName: this.context.abilityInfo.bundleName, + abilityName: item.ability + }) }) }.width('100%') .padding({ left: '8vp', right: '8vp' }) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/demo2/Demo2Case1Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/demo2/Demo2Case1Page.ets index ecbd072..297fc88 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/demo2/Demo2Case1Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/demo2/Demo2Case1Page.ets @@ -1,16 +1,16 @@ /* ForEach List with 100 Buttons as elements with Single Custom Theme for all elements */ -import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp' -import { CustomThemeImpl } from '../../../theme/CustomThemeImpl' +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' @Entry @Component struct Demo2Case1Page { - @State customTheme: CustomTheme = new CustomThemeImpl(RedThemeColors) + @State customTheme: CustomTheme = RedTheme count = 0 data: string[] = [] aboutToAppear() { + ThemeControl.enableTheme(true) for (let i = 0; i < 100; i++) { this.data.push('Item #' + i) } @@ -36,14 +36,14 @@ struct Demo2Case1Page { } switch (this.count) { case 0: - this.customTheme = new CustomThemeImpl(RedThemeColors) + this.customTheme = RedTheme break case 1: - this.customTheme = new CustomThemeImpl(GreenThemeColors) + this.customTheme = GreenTheme break case 2: default: - this.customTheme = new CustomThemeImpl(BrownThemeColors) + this.customTheme = BrownTheme break } }) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/demo2/Demo2Case2Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/demo2/Demo2Case2Page.ets index 00b2053..3763bd2 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/demo2/Demo2Case2Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/demo2/Demo2Case2Page.ets @@ -1,16 +1,16 @@ /* ForEach List with 100 Buttons as elements with Custom Theme for every elements */ -import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp' -import { CustomThemeImpl } from '../../../theme/CustomThemeImpl' +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' @Entry @Component struct Demo2Case2Page { - @State customTheme: CustomTheme = new CustomThemeImpl(RedThemeColors) + @State customTheme: CustomTheme = RedTheme count = 0 data: string[] = [] aboutToAppear() { + ThemeControl.enableTheme(true) for (let i = 0; i < 100; i++) { this.data.push('Item #' + i) } @@ -37,14 +37,14 @@ struct Demo2Case2Page { } switch (this.count) { case 0: - this.customTheme = new CustomThemeImpl(RedThemeColors) + this.customTheme = RedTheme break case 1: - this.customTheme = new CustomThemeImpl(GreenThemeColors) + this.customTheme = GreenTheme break case 2: default: - this.customTheme = new CustomThemeImpl(BrownThemeColors) + this.customTheme = BrownTheme break } }) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/demo2/Demo2Case3Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/demo2/Demo2Case3Page.ets index 4aa25fc..4a99c0d 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/demo2/Demo2Case3Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/demo2/Demo2Case3Page.ets @@ -1,7 +1,6 @@ /* LazyForEach List with 2000 Buttons as elements with Single Custom Theme for all items */ -import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp' -import { CustomThemeImpl } from '../../../theme/CustomThemeImpl' +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; class BasicDataSource implements IDataSource { private listeners: DataChangeListener[] = []; @@ -85,11 +84,12 @@ class MyDataSource extends BasicDataSource { @Entry @Component struct Demo2Case3Page { - @State customTheme: CustomTheme = new CustomThemeImpl(RedThemeColors) + @State customTheme: CustomTheme = RedTheme count = 0 private data: MyDataSource = new MyDataSource(); aboutToAppear() { + ThemeControl.enableTheme(true) for (let i = 0; i < 2000; i++) { this.data.pushData('Item #' + i) } @@ -115,14 +115,14 @@ struct Demo2Case3Page { } switch (this.count) { case 0: - this.customTheme = new CustomThemeImpl(RedThemeColors) + this.customTheme = RedTheme break case 1: - this.customTheme = new CustomThemeImpl(GreenThemeColors) + this.customTheme = GreenTheme break case 2: default: - this.customTheme = new CustomThemeImpl(BrownThemeColors) + this.customTheme = BrownTheme break } }) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/demo2/Demo2Case4Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/demo2/Demo2Case4Page.ets index 10f3d70..0fcce36 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/demo2/Demo2Case4Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/demo2/Demo2Case4Page.ets @@ -1,7 +1,6 @@ /* LazyForEach List with 2000 Buttons as elements with Custom Theme for every items */ -import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp' -import { CustomThemeImpl } from '../../../theme/CustomThemeImpl' +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; class BasicDataSource implements IDataSource { private listeners: DataChangeListener[] = []; @@ -85,11 +84,12 @@ class MyDataSource extends BasicDataSource { @Entry @Component struct Demo2Case4Page { - @State customTheme: CustomTheme = new CustomThemeImpl(RedThemeColors) + @State customTheme: CustomTheme = RedTheme count = 0 private data: MyDataSource = new MyDataSource(); aboutToAppear() { + ThemeControl.enableTheme(true) for (let i = 0; i < 2000; i++) { this.data.pushData('Item #' + i) } @@ -116,14 +116,14 @@ struct Demo2Case4Page { } switch (this.count) { case 0: - this.customTheme = new CustomThemeImpl(RedThemeColors) + this.customTheme = RedTheme break case 1: - this.customTheme = new CustomThemeImpl(GreenThemeColors) + this.customTheme = GreenTheme break case 2: default: - this.customTheme = new CustomThemeImpl(BrownThemeColors) + this.customTheme = BrownTheme break } }) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/demo2/Demo2NavigationPage.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/demo2/Demo2NavigationPage.ets index 6475f65..743f5cf 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/demo2/Demo2NavigationPage.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/demo2/Demo2NavigationPage.ets @@ -1,8 +1,9 @@ import router from '@ohos.router' +import common from '@ohos.app.ability.common' export interface DataClass { title: string - page: string + ability: string } @Entry @@ -11,30 +12,24 @@ struct Demo2NavigationPage { data: DataClass[] = [ { title: 'Case 1: ForEach (1 CustomTheme for all items) List with 100 Buttons as elements', - page: 'pages/tests/demo2/Demo2Case1Page' + ability: 'Demo2Case1Ability' }, { title: 'Case 2: ForEach (1 CustomTheme for every items) List with 100 Buttons as elements', - page: 'pages/tests/demo2/Demo2Case2Page' + ability: 'Demo2Case2Ability' }, { title: 'Case 3: LazyForEach (1 CustomTheme for all items) List with 2000 Buttons as elements', - page: 'pages/tests/demo2/Demo2Case3Page' + ability: 'Demo2Case3Ability' }, { title: 'Case 4: LazyForEach (1 CustomTheme for every items) List with 2000 Buttons as elements', - page: 'pages/tests/demo2/Demo2Case4Page' - }, - { - title: 'Case 5: ForEach Flex (1 CustomTheme for all items) Vertical Layout with 100 Buttons as elements with no Custom Theme, 1 item per line', - page: 'pages/tests/demo2/Demo2Case5Page' - }, - { - title: 'Case 6: ForEach Flex (1 CustomTheme for every items) Vertical Layout with 100 Buttons as elements with no Custom Theme, 1 item per line', - page: 'pages/tests/demo2/Demo2Case6Page' + ability: 'Demo2Case4Ability' }, ] + private context = getContext(this) as common.UIAbilityContext + build() { Stack() { List({ space: '8vp' }) { @@ -43,7 +38,10 @@ struct Demo2NavigationPage { Button(item.title) .width('100%') .onClick(() => { - router.pushUrl({ url: item.page }) + this.context.startAbility({ + bundleName: this.context.abilityInfo.bundleName, + abilityName: item.ability + }) }) }.width('100%') .padding({ left: '8vp', right: '8vp' }) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/demo2/Demo2Case5Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/demo3/Demo3Case1Page.ets similarity index 37% rename from theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/demo2/Demo2Case5Page.ets rename to theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/demo3/Demo3Case1Page.ets index c92130d..39bb4db 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/demo2/Demo2Case5Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/demo3/Demo3Case1Page.ets @@ -1,16 +1,18 @@ -/* ForEach Vertical Flex Layout with 100 Buttons as elements with Single Custom Theme for all items, 1 item per line */ - +/* ForEach List with 100 Buttons as elements with Single Custom Theme for all elements and custom attributes */ import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp' -import { CustomThemeImpl } from '../../../theme/CustomThemeImpl' +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' @Entry @Component -struct Demo2Case5Page { - @State customTheme: CustomTheme = new CustomThemeImpl(RedThemeColors) +struct Demo3Case1Page { + @State customTheme: CustomTheme = RedTheme + @State textColor: ResourceColor = RedThemeColors.fontOnPrimary + @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize count = 0 data: string[] = [] aboutToAppear() { + ThemeControl.enableTheme(true) for (let i = 0; i < 100; i++) { this.data.push('Item #' + i) } @@ -19,15 +21,14 @@ struct Demo2Case5Page { build() { WithTheme({ theme: this.customTheme }) { Row() { - Scroll() { - Flex({ direction: FlexDirection.Column, wrap: FlexWrap.Wrap }) { - ForEach(this.data, (item: string) => { + List({ space: '8vp' }) { + ForEach(this.data, (item: string) => { + ListItem() { Button(item) - .width('100%') - .margin({ top: '4vp', bottom: '4vp' }) - }, (item: string) => item) - } - .padding({ left: '8vp', right: '8vp' }) + .fontColor(this.textColor) + .backgroundColor(this.bkgColor) + }.width('100%') + }, (item: string) => item) } .width('100%') } @@ -39,14 +40,20 @@ struct Demo2Case5Page { } switch (this.count) { case 0: - this.customTheme = new CustomThemeImpl(RedThemeColors) + this.customTheme = RedTheme + this.textColor = RedThemeColors.fontOnPrimary + this.bkgColor = RedThemeColors.backgroundEmphasize break case 1: - this.customTheme = new CustomThemeImpl(GreenThemeColors) + this.customTheme = GreenTheme + this.textColor = GreenThemeColors.fontOnPrimary + this.bkgColor = GreenThemeColors.backgroundEmphasize break case 2: default: - this.customTheme = new CustomThemeImpl(BrownThemeColors) + this.customTheme = BrownTheme + this.textColor = BrownThemeColors.fontOnPrimary + this.bkgColor = BrownThemeColors.backgroundEmphasize break } }) diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/demo2/Demo2Case6Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/demo3/Demo3Case2Page.ets similarity index 37% rename from theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/demo2/Demo2Case6Page.ets rename to theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/demo3/Demo3Case2Page.ets index 6c4b35f..0a856d3 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/demo2/Demo2Case6Page.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/demo3/Demo3Case2Page.ets @@ -1,16 +1,18 @@ -/* ForEach Vertical Flex Layout with 100 Buttons as elements with Custom Themes for every items, 1 item per line */ - +/* ForEach List with 100 Buttons as elements with Custom Theme for every elements and custom attributes */ import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp' -import { CustomThemeImpl } from '../../../theme/CustomThemeImpl' +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl' @Entry @Component -struct Demo2Case6Page { - @State customTheme: CustomTheme = new CustomThemeImpl(RedThemeColors) +struct Demo3Case2Page { + @State customTheme: CustomTheme = RedTheme + @State textColor: ResourceColor = RedThemeColors.fontOnPrimary + @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize count = 0 data: string[] = [] aboutToAppear() { + ThemeControl.enableTheme(true) for (let i = 0; i < 100; i++) { this.data.push('Item #' + i) } @@ -18,20 +20,20 @@ struct Demo2Case6Page { build() { Row() { - Scroll() { - Flex({ direction: FlexDirection.Column, wrap: FlexWrap.Wrap }) { - ForEach(this.data, (item: string) => { + List({ space: '8vp' }) { + ForEach(this.data, (item: string) => { + ListItem() { WithTheme({ theme: this.customTheme }) { Button(item) - .width('100%') - .margin({ top: '4vp', bottom: '4vp' }) + .fontColor(this.textColor) + .backgroundColor(this.bkgColor) } - }, (item: string) => item) - } - .padding({ left: '8vp', right: '8vp' }) + }.width('100%') + }, (item: string) => item) } .width('100%') } + .height('100%') .onClick(() => { this.count++ if (this.count > 2) { @@ -39,17 +41,22 @@ struct Demo2Case6Page { } switch (this.count) { case 0: - this.customTheme = new CustomThemeImpl(RedThemeColors) + this.customTheme = RedTheme + this.textColor = RedThemeColors.fontOnPrimary + this.bkgColor = RedThemeColors.backgroundEmphasize break case 1: - this.customTheme = new CustomThemeImpl(GreenThemeColors) + this.customTheme = GreenTheme + this.textColor = GreenThemeColors.fontOnPrimary + this.bkgColor = GreenThemeColors.backgroundEmphasize break case 2: default: - this.customTheme = new CustomThemeImpl(BrownThemeColors) + this.customTheme = BrownTheme + this.textColor = BrownThemeColors.fontOnPrimary + this.bkgColor = BrownThemeColors.backgroundEmphasize break } }) - .height('100%') } } \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/demo3/Demo3Case3Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/demo3/Demo3Case3Page.ets new file mode 100644 index 0000000..8cfec59 --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/demo3/Demo3Case3Page.ets @@ -0,0 +1,141 @@ +/* LazyForEach List with 2000 Buttons as elements with Single Custom Theme for all items and custom attributes */ +import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp'; +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; + +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): string { + return ''; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } + + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }) + } +} + +class MyDataSource extends BasicDataSource { + private dataArray: string[] = []; + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): string { + return this.dataArray[index]; + } + + public addData(index: number, data: string): void { + this.dataArray.splice(index, 0, data); + this.notifyDataAdd(index); + } + + public pushData(data: string): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } +} + +@Entry +@Component +struct Demo3Case3Page { + @State customTheme: CustomTheme = RedTheme + @State textColor: ResourceColor = RedThemeColors.fontOnPrimary + @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize + count = 0 + private data: MyDataSource = new MyDataSource(); + + aboutToAppear() { + ThemeControl.enableTheme(true) + for (let i = 0; i < 2000; i++) { + this.data.pushData('Item #' + i) + } + } + + build() { + WithTheme({ theme: this.customTheme }) { + Row() { + List({ space: '8vp' }) { + LazyForEach(this.data, (item: string) => { + ListItem() { + Button(item) + .fontColor(this.textColor) + .backgroundColor(this.bkgColor) + }.width('100%') + }, (item: string) => item) + } + .width('100%') + } + .height('100%') + .onClick(() => { + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + this.textColor = RedThemeColors.fontOnPrimary + this.bkgColor = RedThemeColors.backgroundEmphasize + break + case 1: + this.customTheme = GreenTheme + this.textColor = GreenThemeColors.fontOnPrimary + this.bkgColor = GreenThemeColors.backgroundEmphasize + break + case 2: + default: + this.customTheme = BrownTheme + this.textColor = BrownThemeColors.fontOnPrimary + this.bkgColor = BrownThemeColors.backgroundEmphasize + break + } + }) + } + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/demo3/Demo3Case4Page.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/demo3/Demo3Case4Page.ets new file mode 100644 index 0000000..9694eaa --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/demo3/Demo3Case4Page.ets @@ -0,0 +1,141 @@ +/* LazyForEach List with 2000 Buttons as elements with Custom Theme for every items and custom attributes */ +import { BrownThemeColors, GreenThemeColors, RedThemeColors } from '../../../theme/CustomColorsImlp'; +import { BrownTheme, GreenTheme, RedTheme } from '../../../theme/CustomThemeImpl'; + +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + + public totalCount(): number { + return 0; + } + + public getData(index: number): string { + return ''; + } + + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } + + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + }) + } +} + +class MyDataSource extends BasicDataSource { + private dataArray: string[] = []; + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): string { + return this.dataArray[index]; + } + + public addData(index: number, data: string): void { + this.dataArray.splice(index, 0, data); + this.notifyDataAdd(index); + } + + public pushData(data: string): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } +} + +@Entry +@Component +struct Demo3Case4Page { + @State customTheme: CustomTheme = RedTheme + @State textColor: ResourceColor = RedThemeColors.fontOnPrimary + @State bkgColor: ResourceColor = RedThemeColors.backgroundEmphasize + count = 0 + private data: MyDataSource = new MyDataSource(); + + aboutToAppear() { + ThemeControl.enableTheme(true) + for (let i = 0; i < 2000; i++) { + this.data.pushData('Item #' + i) + } + } + + build() { + Row() { + List({ space: '8vp' }) { + LazyForEach(this.data, (item: string) => { + ListItem() { + WithTheme({ theme: this.customTheme }) { + Button(item) + .fontColor(this.textColor) + .backgroundColor(this.bkgColor) + } + }.width('100%') + }, (item: string) => item) + } + .width('100%') + } + .height('100%') + .onClick(() => { + this.count++ + if (this.count > 2) { + this.count = 0 + } + switch (this.count) { + case 0: + this.customTheme = RedTheme + this.textColor = RedThemeColors.fontOnPrimary + this.bkgColor = RedThemeColors.backgroundEmphasize + break + case 1: + this.customTheme = GreenTheme + this.textColor = GreenThemeColors.fontOnPrimary + this.bkgColor = GreenThemeColors.backgroundEmphasize + break + case 2: + default: + this.customTheme = BrownTheme + this.textColor = BrownThemeColors.fontOnPrimary + this.bkgColor = BrownThemeColors.backgroundEmphasize + break + } + }) + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/demo3/Demo3NavigationPage.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/demo3/Demo3NavigationPage.ets new file mode 100644 index 0000000..61221af --- /dev/null +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/pages/tests/demo3/Demo3NavigationPage.ets @@ -0,0 +1,55 @@ +import router from '@ohos.router' +import common from '@ohos.app.ability.common' + +export interface DataClass { + title: string + ability: string +} + +@Entry +@Component +struct Demo3NavigationPage { + data: DataClass[] = [ + { + title: 'Case 1: ForEach (attrs & CustomTheme for all items) List with 100 Buttons as elements', + ability: 'Demo3Case1Ability' + }, + { + title: 'Case 2: ForEach (attrs & CustomTheme for every items) List with 100 Buttons as elements', + ability: 'Demo3Case2Ability' + }, + { + title: 'Case 3: LazyForEach (attrs & CustomTheme for all items) List with 2000 Buttons as elements', + ability: 'Demo3Case3Ability' + }, + { + title: 'Case 4: LazyForEach (attrs & CustomTheme for every items) List with 2000 Buttons as elements', + ability: 'Demo3Case4Ability' + }, + ] + + private context = getContext(this) as common.UIAbilityContext + + build() { + Stack() { + List({ space: '8vp' }) { + ForEach(this.data, (item: DataClass) => { + ListItem() { + Button(item.title) + .width('100%') + .onClick(() => { + this.context.startAbility({ + bundleName: this.context.abilityInfo.bundleName, + abilityName: item.ability + }) + }) + }.width('100%') + .padding({ left: '8vp', right: '8vp' }) + }, (item: DataClass) => item.title) + } + .scrollBar(BarState.Off) + } + .height('100%') + .width('100%') + } +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/theme/CustomColorsImlp.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/theme/CustomColorsImlp.ets index 004e15a..64006aa 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/theme/CustomColorsImlp.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/theme/CustomColorsImlp.ets @@ -1,40 +1,16 @@ export class RedColors implements CustomColors { - fontEmphasize = '#FFD53032' - iconOnPrimary = '#FFFFFFFF' - iconFourth = '#FFD00000' - iconEmphasize = '#FFD53032' - backgroundPrimary = '#FFD53032' - backgroundSecondary = '#33FF1111' - backgroundTertiary = '#44FF2222' + fontOnPrimary = '#FFFFFFFF' backgroundEmphasize = '#FFD00000' - compBackgroundEmphasize = '#FFD00000' - compEmphasizeSecondary = '#33FF1111' } export class GreenColors implements CustomColors { - fontEmphasize = '#FF00541F' - iconOnPrimary = '#FFFFFFFF' - iconFourth = '#FF00541F' - iconEmphasize = '#FF00541F' - backgroundPrimary = '#FF00541F' - backgroundSecondary = '#3322FF22' - backgroundTertiary = '#1111FF11' + fontOnPrimary = '#FFFFFFFF' backgroundEmphasize = '#FF00541F' - compBackgroundEmphasize = '#FF00541F' - compEmphasizeSecondary = '#3322FF22' } export class BrownColors implements CustomColors { - fontEmphasize = '#FF8B6B5C' - iconOnPrimary = '#FFFFFFFF' - iconFourth = '#FF8B6B5C' - iconEmphasize = '#FF8B6B5C' - backgroundPrimary = '#FF8B6B5C' - backgroundSecondary = '#33556B55' - backgroundTertiary = '#44556B55' + fontOnPrimary = '#FFFFFFFF' backgroundEmphasize = '#FF8B6B5C' - compBackgroundEmphasize = '#FF8B6B5C' - compEmphasizeSecondary = '#33556B55' } export const RedThemeColors = new RedColors() diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/ets/theme/CustomThemeImpl.ets b/theme/ThemePerformanceMeasurement/entry/src/main/ets/theme/CustomThemeImpl.ets index 818ba52..e94b466 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/ets/theme/CustomThemeImpl.ets +++ b/theme/ThemePerformanceMeasurement/entry/src/main/ets/theme/CustomThemeImpl.ets @@ -1,7 +1,15 @@ +import { BrownThemeColors, GreenThemeColors, RedThemeColors } from './CustomColorsImlp' + export class CustomThemeImpl implements CustomTheme { colors?: CustomColors constructor(colors: CustomColors) { this.colors = colors } -} \ No newline at end of file +} + +export const RedTheme = new CustomThemeImpl(RedThemeColors) + +export const GreenTheme = new CustomThemeImpl(GreenThemeColors) + +export const BrownTheme = new CustomThemeImpl(BrownThemeColors) \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 b/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 index aa0dece..a2f816e 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 +++ b/theme/ThemePerformanceMeasurement/entry/src/main/module.json5 @@ -31,6 +31,106 @@ ] } ] + }, + { + "name": "Demo1Case1Ability", + "srcEntry": "./ets/demo1case1ability/Demo1Case1Ability.ets", + "description": "$string:Demo1Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "Demo1Case2Ability", + "srcEntry": "./ets/demo1case2ability/Demo1Case2Ability.ets", + "description": "$string:Demo1Case2Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo1Case2Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "Demo2Case1Ability", + "srcEntry": "./ets/demo2case1ability/Demo2Case1Ability.ets", + "description": "$string:Demo2Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo2Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "Demo2Case2Ability", + "srcEntry": "./ets/demo2case2ability/Demo2Case2Ability.ets", + "description": "$string:Demo2Case2Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo2Case2Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "Demo2Case3Ability", + "srcEntry": "./ets/demo2case3ability/Demo2Case3Ability.ets", + "description": "$string:Demo2Case3Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo2Case3Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "Demo2Case4Ability", + "srcEntry": "./ets/demo2case4ability/Demo2Case4Ability.ets", + "description": "$string:Demo2Case4Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo2Case4Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "Demo3Case1Ability", + "srcEntry": "./ets/demo3case1ability/Demo3Case1Ability.ets", + "description": "$string:Demo3Case1Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo3Case1Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "Demo3Case2Ability", + "srcEntry": "./ets/demo3case2ability/Demo3Case2Ability.ets", + "description": "$string:Demo3Case2Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo3Case2Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "Demo3Case3Ability", + "srcEntry": "./ets/demo3case3ability/Demo3Case3Ability.ets", + "description": "$string:Demo3Case3Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo3Case3Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" + }, + { + "name": "Demo3Case4Ability", + "srcEntry": "./ets/demo3case4ability/Demo3Case4Ability.ets", + "description": "$string:Demo3Case4Ability_desc", + "icon": "$media:icon", + "label": "$string:Demo3Case4Ability_label", + "exported": true, + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background" } ] } diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/element/string.json b/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/element/string.json index f945955..538a379 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/element/string.json +++ b/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/element/string.json @@ -10,6 +10,110 @@ }, { "name": "EntryAbility_label", + "value": "Theme Perf Demo" + }, + { + "name": "Demo1Case1Ability_desc", + "value": "description" + }, + { + "name": "Demo1Case1Ability_label", + "value": "label" + }, + { + "name": "Demo1Case2Ability_desc", + "value": "description" + }, + { + "name": "Demo1Case2Ability_label", + "value": "label" + }, + { + "name": "Demo1Case3Ability_desc", + "value": "description" + }, + { + "name": "Demo1Case3Ability_label", + "value": "label" + }, + { + "name": "Demo2Case1Ability_desc", + "value": "description" + }, + { + "name": "Demo2Case1Ability_label", + "value": "label" + }, + { + "name": "Demo2Case2Ability_desc", + "value": "description" + }, + { + "name": "Demo2Case2Ability_label", + "value": "label" + }, + { + "name": "Demo2Case3Ability_desc", + "value": "description" + }, + { + "name": "Demo2Case3Ability_label", + "value": "label" + }, + { + "name": "Demo2Case4Ability_desc", + "value": "description" + }, + { + "name": "Demo2Case4Ability_label", + "value": "label" + }, + { + "name": "Demo2Case5Ability_desc", + "value": "description" + }, + { + "name": "Demo2Case5Ability_label", + "value": "label" + }, + { + "name": "Demo2Case6Ability_desc", + "value": "description" + }, + { + "name": "Demo2Case6Ability_label", + "value": "label" + }, + { + "name": "Demo3Case1Ability_desc", + "value": "description" + }, + { + "name": "Demo3Case1Ability_label", + "value": "label" + }, + { + "name": "Demo3Case2Ability_desc", + "value": "description" + }, + { + "name": "Demo3Case2Ability_label", + "value": "label" + }, + { + "name": "Demo3Case3Ability_desc", + "value": "description" + }, + { + "name": "Demo3Case3Ability_label", + "value": "label" + }, + { + "name": "Demo3Case4Ability_desc", + "value": "description" + }, + { + "name": "Demo3Case4Ability_label", "value": "label" } ] diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json b/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json index 6d09b2b..c82a02c 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json +++ b/theme/ThemePerformanceMeasurement/entry/src/main/resources/base/profile/main_pages.json @@ -3,15 +3,17 @@ "pages/Index", "pages/tests/demo1/Demo1Case1Page", "pages/tests/demo1/Demo1Case2Page", - "pages/tests/demo1/Demo1Case3Page", "pages/tests/demo1/Demo1NavigationPage", "pages/tests/demo2/Demo2Case1Page", "pages/tests/demo2/Demo2Case2Page", "pages/tests/demo2/Demo2Case3Page", "pages/tests/demo2/Demo2Case4Page", - "pages/tests/demo2/Demo2Case5Page", - "pages/tests/demo2/Demo2Case6Page", "pages/tests/demo2/Demo2NavigationPage", - "pages/tests/TestsNavigationPage" + "pages/tests/TestsNavigationPage", + "pages/tests/demo3/Demo3Case1Page", + "pages/tests/demo3/Demo3Case2Page", + "pages/tests/demo3/Demo3Case3Page", + "pages/tests/demo3/Demo3Case4Page", + "pages/tests/demo3/Demo3NavigationPage" ] -} +} \ No newline at end of file diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/resources/en_US/element/string.json b/theme/ThemePerformanceMeasurement/entry/src/main/resources/en_US/element/string.json index f945955..538a379 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/resources/en_US/element/string.json +++ b/theme/ThemePerformanceMeasurement/entry/src/main/resources/en_US/element/string.json @@ -10,6 +10,110 @@ }, { "name": "EntryAbility_label", + "value": "Theme Perf Demo" + }, + { + "name": "Demo1Case1Ability_desc", + "value": "description" + }, + { + "name": "Demo1Case1Ability_label", + "value": "label" + }, + { + "name": "Demo1Case2Ability_desc", + "value": "description" + }, + { + "name": "Demo1Case2Ability_label", + "value": "label" + }, + { + "name": "Demo1Case3Ability_desc", + "value": "description" + }, + { + "name": "Demo1Case3Ability_label", + "value": "label" + }, + { + "name": "Demo2Case1Ability_desc", + "value": "description" + }, + { + "name": "Demo2Case1Ability_label", + "value": "label" + }, + { + "name": "Demo2Case2Ability_desc", + "value": "description" + }, + { + "name": "Demo2Case2Ability_label", + "value": "label" + }, + { + "name": "Demo2Case3Ability_desc", + "value": "description" + }, + { + "name": "Demo2Case3Ability_label", + "value": "label" + }, + { + "name": "Demo2Case4Ability_desc", + "value": "description" + }, + { + "name": "Demo2Case4Ability_label", + "value": "label" + }, + { + "name": "Demo2Case5Ability_desc", + "value": "description" + }, + { + "name": "Demo2Case5Ability_label", + "value": "label" + }, + { + "name": "Demo2Case6Ability_desc", + "value": "description" + }, + { + "name": "Demo2Case6Ability_label", + "value": "label" + }, + { + "name": "Demo3Case1Ability_desc", + "value": "description" + }, + { + "name": "Demo3Case1Ability_label", + "value": "label" + }, + { + "name": "Demo3Case2Ability_desc", + "value": "description" + }, + { + "name": "Demo3Case2Ability_label", + "value": "label" + }, + { + "name": "Demo3Case3Ability_desc", + "value": "description" + }, + { + "name": "Demo3Case3Ability_label", + "value": "label" + }, + { + "name": "Demo3Case4Ability_desc", + "value": "description" + }, + { + "name": "Demo3Case4Ability_label", "value": "label" } ] diff --git a/theme/ThemePerformanceMeasurement/entry/src/main/resources/zh_CN/element/string.json b/theme/ThemePerformanceMeasurement/entry/src/main/resources/zh_CN/element/string.json index 597ecf9..49af466 100644 --- a/theme/ThemePerformanceMeasurement/entry/src/main/resources/zh_CN/element/string.json +++ b/theme/ThemePerformanceMeasurement/entry/src/main/resources/zh_CN/element/string.json @@ -10,6 +10,110 @@ }, { "name": "EntryAbility_label", + "value": "Theme Perf Demo" + }, + { + "name": "Demo1Case1Ability_desc", + "value": "description" + }, + { + "name": "Demo1Case1Ability_label", + "value": "label" + }, + { + "name": "Demo1Case2Ability_desc", + "value": "description" + }, + { + "name": "Demo1Case2Ability_label", + "value": "label" + }, + { + "name": "Demo1Case3Ability_desc", + "value": "description" + }, + { + "name": "Demo1Case3Ability_label", + "value": "label" + }, + { + "name": "Demo2Case1Ability_desc", + "value": "description" + }, + { + "name": "Demo2Case1Ability_label", + "value": "label" + }, + { + "name": "Demo2Case2Ability_desc", + "value": "description" + }, + { + "name": "Demo2Case2Ability_label", + "value": "label" + }, + { + "name": "Demo2Case3Ability_desc", + "value": "description" + }, + { + "name": "Demo2Case3Ability_label", + "value": "label" + }, + { + "name": "Demo2Case4Ability_desc", + "value": "description" + }, + { + "name": "Demo2Case4Ability_label", + "value": "label" + }, + { + "name": "Demo2Case5Ability_desc", + "value": "description" + }, + { + "name": "Demo2Case5Ability_label", + "value": "label" + }, + { + "name": "Demo2Case6Ability_desc", + "value": "description" + }, + { + "name": "Demo2Case6Ability_label", + "value": "label" + }, + { + "name": "Demo3Case1Ability_desc", + "value": "description" + }, + { + "name": "Demo3Case1Ability_label", + "value": "label" + }, + { + "name": "Demo3Case2Ability_desc", + "value": "description" + }, + { + "name": "Demo3Case2Ability_label", + "value": "label" + }, + { + "name": "Demo3Case3Ability_desc", + "value": "description" + }, + { + "name": "Demo3Case3Ability_label", + "value": "label" + }, + { + "name": "Demo3Case4Ability_desc", + "value": "description" + }, + { + "name": "Demo3Case4Ability_label", "value": "label" } ] diff --git a/theme/ThemePerformanceMeasurement/oh-package.json5 b/theme/ThemePerformanceMeasurement/oh-package.json5 index 12faf6e..840b905 100644 --- a/theme/ThemePerformanceMeasurement/oh-package.json5 +++ b/theme/ThemePerformanceMeasurement/oh-package.json5 @@ -1,13 +1,12 @@ { - "name": "themeperformancemeasurement", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", "license": "", - "dependencies": { - }, "devDependencies": { "@ohos/hypium": "1.0.11" - } + }, + "author": "", + "name": "themeperformancemeasurement", + "description": "Please describe the basic information.", + "main": "", + "version": "1.0.0", + "dependencies": {} } -- Gitee