diff --git a/AppDataSecurity/entry/src/main/ets/pages/Index.ets b/AppDataSecurity/entry/src/main/ets/pages/Index.ets index 3eddabf5286abb23a20b48523f42500462f39412..50ec8c5eb5acd0e94b5ae97c327b6c6f6e1168d5 100644 --- a/AppDataSecurity/entry/src/main/ets/pages/Index.ets +++ b/AppDataSecurity/entry/src/main/ets/pages/Index.ets @@ -65,14 +65,14 @@ struct Index { } getEl2Path() { - let context = getContext(this) as common.UIAbilityContext; + let context = this.getUIContext().getHostContext() as common.UIAbilityContext; context.area = contextConstant.AreaMode.EL2; let filePath = context.filesDir + '/health_data.txt'; this.message = filePath; } getEl1Path() { - let context = getContext(this) as common.UIAbilityContext; + let context = this.getUIContext().getHostContext() as common.UIAbilityContext; context.area = contextConstant.AreaMode.EL1; let filePath = context.filesDir + '/health_data.txt'; this.message = filePath; diff --git a/AvoidTimeComsume/entry/src/main/ets/entryability/EntryAbility.ets b/AvoidTimeComsume/entry/src/main/ets/entryability/EntryAbility.ets index 567c1d90258a23974f05716ee7472a01584224e8..80c495ede2460b86c56489c6c654126b77f31de6 100644 --- a/AvoidTimeComsume/entry/src/main/ets/entryability/EntryAbility.ets +++ b/AvoidTimeComsume/entry/src/main/ets/entryability/EntryAbility.ets @@ -39,6 +39,7 @@ export default class EntryAbility extends UIAbility { return; } hilog.info(0x0000, 'Sample', 'Succeeded in loading the content.'); + AppStorage.setOrCreate('uiContext', windowStage.getMainWindowSync().getUIContext()); }); windowStage.getMainWindow().then((windowObj) => { diff --git a/AvoidTimeComsume/entry/src/main/ets/views/GetStrOfId.ets b/AvoidTimeComsume/entry/src/main/ets/views/GetStrOfId.ets index 94a019ced609222d16d4b2cd3278e7a5e447912d..ecc471e77ed5a1bb01633712b9c8186c5d6c8893 100644 --- a/AvoidTimeComsume/entry/src/main/ets/views/GetStrOfId.ets +++ b/AvoidTimeComsume/entry/src/main/ets/views/GetStrOfId.ets @@ -25,7 +25,7 @@ struct GetStrOfId { aboutToAppear(): void { hiTraceMeter.startTrace('getStringSyncAfter', 1); // The input parameter of the getStringSync operation directly uses the resource and does use the resource ID - getContext().resourceManager.getStringSync($r('app.string.test').id) + this.getUIContext().getHostContext()!.resourceManager.getStringSync($r('app.string.test').id) hiTraceMeter.finishTrace('getStringSyncAfter', 1) } diff --git a/AvoidTimeComsume/entry/src/main/ets/views/GetStrOfResource.ets b/AvoidTimeComsume/entry/src/main/ets/views/GetStrOfResource.ets index 79bbc1d82b6d9e8dcbcc1ef26b9a88b624444e74..e7c469abbf74be0b95019ec466a98f7d515a1422 100644 --- a/AvoidTimeComsume/entry/src/main/ets/views/GetStrOfResource.ets +++ b/AvoidTimeComsume/entry/src/main/ets/views/GetStrOfResource.ets @@ -17,6 +17,8 @@ import { hiTraceMeter } from '@kit.PerformanceAnalysisKit'; import { router } from '@kit.ArkUI'; +const uiContext: UIContext | undefined = AppStorage.get('uiContext'); + @Entry @Component struct GetStrOfResource { @@ -25,7 +27,7 @@ struct GetStrOfResource { aboutToAppear(): void { hiTraceMeter.startTrace('getStringSync', 1); // The input parameter of the getStringSync operation directly uses the resource and does not use the resource ID - getContext().resourceManager.getStringSync($r('app.string.test')) + this.getUIContext().getHostContext()!.resourceManager.getStringSync($r('app.string.test')) hiTraceMeter.finishTrace('getStringSync', 1) } diff --git a/AvoidTimeComsume/entry/src/main/ets/views/UseAsync.ets b/AvoidTimeComsume/entry/src/main/ets/views/UseAsync.ets index 9f43eb568e23d4eb975fd247d1e0eb19139e13ce..4657ba75a43ad3186f9a19d8e263526312ee3049 100644 --- a/AvoidTimeComsume/entry/src/main/ets/views/UseAsync.ets +++ b/AvoidTimeComsume/entry/src/main/ets/views/UseAsync.ets @@ -18,6 +18,8 @@ import { WaterFlowDataSource } from './WaterFlowDataSource'; import { buffer } from '@kit.ArkTS'; import { router } from '@kit.ArkUI'; +const uiContext: UIContext | undefined = AppStorage.get('uiContext'); + @Entry @Component struct WaterFlowExample2 { @@ -120,7 +122,7 @@ struct WaterFlowExample2 { async mockRequestData(): Promise { let res: ResponseData = new ResponseData(); // data.json is the local json data, which is about 20 MB in size, and simulates getting data from the network - await getContext().resourceManager.getRawFileContent('data.json').then((data: Uint8Array) => { + await this.getUIContext().getHostContext()!.resourceManager.getRawFileContent('data.json').then((data: Uint8Array) => { // parse json let str = buffer.from(data).toString(); res = JSON.parse(str); diff --git a/AvoidTimeComsume/entry/src/main/ets/views/UseTaskPool.ets b/AvoidTimeComsume/entry/src/main/ets/views/UseTaskPool.ets index 5bbb328bc3276ea1fff60509ff70d349a550ec41..154a62004c726052f7067fdf87629b2504ae6ebb 100644 --- a/AvoidTimeComsume/entry/src/main/ets/views/UseTaskPool.ets +++ b/AvoidTimeComsume/entry/src/main/ets/views/UseTaskPool.ets @@ -119,10 +119,12 @@ struct WaterFlowExample { // DocsCode 1 } +const uiContext: UIContext | undefined = AppStorage.get('uiContext'); + // DocsCode 2 // The following methods are defined outside of the component async function taskPoolExecute(): Promise { - let task: taskpool.Task = new taskpool.Task(mockRequestData, getContext()); + let task: taskpool.Task = new taskpool.Task(mockRequestData, uiContext?.getHostContext()!); return await taskpool.execute(task) as Item[]; } diff --git a/CanvasDraw/.clang-format b/CanvasDraw/.clang-format new file mode 100644 index 0000000000000000000000000000000000000000..48439ed68073b99be118d374d1ebd43d04d4c4eb --- /dev/null +++ b/CanvasDraw/.clang-format @@ -0,0 +1,64 @@ +Language: Cpp +# BasedOnStyle: LLVM +ColumnLimit: 120 +SortIncludes: CaseSensitive +TabWidth: 4 +IndentWidth: 4 +UseTab: Never +AccessModifierOffset: -4 +ContinuationIndentWidth: 4 +IndentCaseBlocks: false +IndentCaseLabels: false +IndentGotoLabels: true +IndentWrappedFunctionNames: false +SortUsingDeclarations: false +NamespaceIndentation: None +SpaceAfterCStyleCast: false +SpaceAfterLogicalNot: false +SpaceAfterTemplateKeyword: true +SpaceBeforeAssignmentOperators: true +SpaceBeforeCaseColon: false +SpaceBeforeCpp11BracedList: false +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true +SpaceBeforeRangeBasedForLoopColon: true +SpaceBeforeSquareBrackets: false +SpaceInEmptyBlock: false +SpaceInEmptyParentheses: false +SpacesInAngles: false +SpacesInCStyleCastParentheses: false +SpacesInConditionalStatement: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +AlignTrailingComments: true +AlignAfterOpenBracket: true +AllowShortCaseLabelsOnASingleLine: false +AllowShortEnumsOnASingleLine: true +AllowShortFunctionsOnASingleLine: All +AllowShortIfStatementsOnASingleLine: Never +AllowShortLambdasOnASingleLine: All +AllowShortLoopsOnASingleLine: false +AlwaysBreakTemplateDeclarations: MultiLine +BinPackArguments: true +BinPackParameters: true +BreakBeforeTernaryOperators: true +BreakConstructorInitializers: BeforeColon +BreakInheritanceList: BeforeColon +BreakStringLiterals: true +InsertBraces: false +IndentExternBlock: NoIndent +BreakBeforeBraces: Custom +BraceWrapping: + AfterCaseLabel: false + AfterClass: false + AfterControlStatement: Never + AfterEnum: false + AfterFunction: false + AfterNamespace: false + AfterStruct: false + AfterUnion: false + AfterExternBlock: false + BeforeCatch: false + BeforeElse: false +ReflowComments: true +MaxEmptyLinesToKeep: 2 \ No newline at end of file diff --git a/CanvasDraw/.hvigor/cache/meta.json b/CanvasDraw/.hvigor/cache/meta.json new file mode 100644 index 0000000000000000000000000000000000000000..18f86af95573be1ca58a8494f7aac0c780d0dfac --- /dev/null +++ b/CanvasDraw/.hvigor/cache/meta.json @@ -0,0 +1 @@ +{"compileSdkVersion":"5.0.4(16)","hvigorVersion":"5.16.2","toolChainsVersion":"5.0.4.150"} diff --git a/CanvasDraw/.hvigor/dependencyMap/dependencyMap.json5 b/CanvasDraw/.hvigor/dependencyMap/dependencyMap.json5 new file mode 100644 index 0000000000000000000000000000000000000000..ac99240f00067c1fd0eab347274d414be8e1dec5 --- /dev/null +++ b/CanvasDraw/.hvigor/dependencyMap/dependencyMap.json5 @@ -0,0 +1 @@ +{"basePath":"C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\CanvasDraw\\.hvigor\\dependencyMap\\dependencyMap.json5","rootDependency":"./oh-package.json5","dependencyMap":{"entry":"./entry/oh-package.json5"},"modules":[{"name":"entry","srcPath":"..\\..\\..\\entry"}]} \ No newline at end of file diff --git a/CanvasDraw/.hvigor/dependencyMap/entry/oh-package.json5 b/CanvasDraw/.hvigor/dependencyMap/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..50a51753855fc6efdf037d5db6ab2cc001f17bbc --- /dev/null +++ b/CanvasDraw/.hvigor/dependencyMap/entry/oh-package.json5 @@ -0,0 +1 @@ +{"name":"entry","version":"1.0.0","description":"Please describe the basic information.","main":"","author":"","license":"","dependencies":{}} \ No newline at end of file diff --git a/CanvasDraw/.hvigor/dependencyMap/oh-package.json5 b/CanvasDraw/.hvigor/dependencyMap/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..7548331ca118580824abab8328632210cb4354fa --- /dev/null +++ b/CanvasDraw/.hvigor/dependencyMap/oh-package.json5 @@ -0,0 +1 @@ +{"modelVersion":"5.0.0","description":"Please describe the basic information.","dependencies":{},"devDependencies":{}} \ No newline at end of file diff --git a/CanvasDraw/.hvigor/outputs/build-logs/build.log b/CanvasDraw/.hvigor/outputs/build-logs/build.log new file mode 100644 index 0000000000000000000000000000000000000000..9aa107b070804ad0e4bf0862a991a9ff433ef0c7 --- /dev/null +++ b/CanvasDraw/.hvigor/outputs/build-logs/build.log @@ -0,0 +1,129 @@ +[2025-05-14T16:13:04.891] [DEBUG] debug-file - env: nodejsVersion=v18.20.1 +[2025-05-14T16:13:05.424] [DEBUG] debug-file - Hvigor init with startParameters:{ + hvigorfileTypeCheck: false, + parallelExecution: true, + incrementalExecution: true, + printStackTrace: false, + daemon: false, + analyze: 0, + logLevel: Level { level: 20000, levelStr: 'INFO', colour: 'green' } +} +[2025-05-14T16:13:05.447] [DEBUG] debug-file - hvigorfile, resolving C:\Users\fy\Desktop\noproject\BestPracticeSnippets\CanvasDraw\hvigorfile.ts +[2025-05-14T16:13:07.345] [DEBUG] debug-file - hvigorfile, require result: { default: { system: [Function: appTasks], plugins: [] } } +[2025-05-14T16:13:07.655] [DEBUG] debug-file - Start initialize project's product build option map with build mode debug. +[2025-05-14T16:13:07.661] [DEBUG] debug-file - Product 'default' using build option: { + "debuggable": true +} in this build. +[2025-05-14T16:13:07.681] [DEBUG] debug-file - Local scan or download hmscore sdk components toolchains,ets,native +[2025-05-14T16:13:07.676] [DEBUG] debug-file - Local scan or download HarmonyOS sdk components toolchains,ets,js,native,previewer +[2025-05-14T16:13:07.692] [DEBUG] debug-file - Start recording SDK configuration permission data. +[2025-05-14T16:13:07.731] [DEBUG] debug-file - Sdk init in 60 ms +[2025-05-14T16:13:07.765] [DEBUG] debug-file - Project task initialization takes 33 ms +[2025-05-14T16:13:07.778] [DEBUG] debug-file - hvigorfile, resolving C:\Users\fy\Desktop\noproject\BestPracticeSnippets\CanvasDraw\entry\hvigorfile.ts +[2025-05-14T16:13:07.803] [DEBUG] debug-file - Start initialize module-target build option map, moduleName=entry, buildMode=debug +[2025-05-14T16:13:07.815] [DEBUG] debug-file - Module entry task initialization takes 5 ms +[2025-05-14T16:13:07.818] [DEBUG] debug-file - project has submodules:entry +[2025-05-14T16:13:07.844] [DEBUG] debug-file - Configuration task cost before running: 2 s 440 ms +[2025-05-14T16:13:07.850] [DEBUG] debug-file - Executing task :entry:clean +[2025-05-14T16:13:07.855] [DEBUG] debug-file - entry : clean cost memory 0.25634765625 +[2025-05-14T16:13:07.883] [DEBUG] debug-file - Module 'entry' target 'default' using build option: { + "debuggable": true, + "copyFrom": "default", + "name": "debug" +} in this build. +[2025-05-14T16:13:04.893] [DEBUG] debug-file - env: hvigor-config.json5 content = { + modelVersion: '5.0.0', + dependencies: {}, + execution: {}, + logging: {}, + debugging: {}, + nodeOptions: {} +} +[2025-05-14T16:13:05.426] [DEBUG] debug-file - Since current hvigor version 5.16.2 differs from last hvigor version + undefined, delete file-cache.json and task-cache.json. +[2025-05-14T16:13:07.909] [DEBUG] debug-file - Create resident worker with id: 0. +[2025-05-14T16:13:07.346] [DEBUG] debug-file - hvigorfile, binding system plugins [Function: appTasks] +[2025-05-14T16:13:07.655] [DEBUG] debug-file - Picking option from product 'default' with build mode 'debug'. +[2025-05-14T16:13:07.662] [DEBUG] debug-file - not found resModel json file in : C:\Users\fy\Desktop\noproject\BestPracticeSnippets\CanvasDraw\entry\src\ohosTest\module.json5 +[2025-05-14T16:13:07.766] [DEBUG] debug-file - hvigorfile, binding custom plugins [] +[2025-05-14T16:13:07.785] [DEBUG] debug-file - hvigorfile, require result: { default: { system: [Function: hapTasks], plugins: [] } } +[2025-05-14T16:13:07.804] [DEBUG] debug-file - Target 'default' config: {} +[2025-05-14T16:13:07.815] [DEBUG] debug-file - hvigorfile, binding custom plugins [] +[2025-05-14T16:13:07.820] [DEBUG] debug-file - start to load updatedOhPackageInfo to the disk +[2025-05-14T16:13:07.851] [DEBUG] debug-file - clean: Worker pool is inactive. +[2025-05-14T16:13:07.856] [DEBUG] debug-file - runTaskFromQueue task cost before running: 2 s 451 ms +[2025-05-14T16:13:07.888] [DEBUG] debug-file - Module 'entry' target 'ohosTest' using build option: { + "debuggable": true, + "name": "default" +} in this build. +[2025-05-14T16:13:04.896] [DEBUG] debug-file - env: daemon=false +[2025-05-14T16:13:05.426] [DEBUG] debug-file - Cache service initialization finished in 2 ms +[2025-05-14T16:13:07.912] [DEBUG] debug-file - Create resident worker with id: 1. +[2025-05-14T16:13:07.655] [DEBUG] debug-file - Product 'default' build option: {} +[2025-05-14T16:13:07.670] [DEBUG] debug-file - No signingConfig found, initRemoteHspCache failed. +[2025-05-14T16:13:07.766] [DEBUG] debug-file - hvigorfile, no custom plugins were found in C:\Users\fy\Desktop\noproject\BestPracticeSnippets\CanvasDraw\hvigorfile.ts +[2025-05-14T16:13:07.786] [DEBUG] debug-file - hvigorfile, binding system plugins [Function: hapTasks] +[2025-05-14T16:13:07.804] [DEBUG] debug-file - Target 'ohosTest' config: {} +[2025-05-14T16:13:07.815] [DEBUG] debug-file - hvigorfile, no custom plugins were found in C:\Users\fy\Desktop\noproject\BestPracticeSnippets\CanvasDraw\entry\hvigorfile.ts +[2025-05-14T16:13:07.825] [DEBUG] debug-file - load to the disk finished +[2025-05-14T16:13:07.857] [INFO] debug-file - Finished :entry:clean... after 6 ms +[2025-05-14T16:13:07.906] [DEBUG] debug-file - Since there is no instance or instance is terminated, create a new worker pool. +[2025-05-14T16:13:04.896] [DEBUG] debug-file - no-daemon, use the parent process.execArgv --max-old-space-size=8192,--expose-gc +[2025-05-14T16:13:07.914] [DEBUG] debug-file - Current worker pool is stopped or closed. +[2025-05-14T16:13:07.655] [DEBUG] debug-file - End initialize project's product build option map with build mode 'debug'. +[2025-05-14T16:13:07.766] [DEBUG] debug-file - hvigorfile, resolve finished C:\Users\fy\Desktop\noproject\BestPracticeSnippets\CanvasDraw\hvigorfile.ts +[2025-05-14T16:13:07.804] [DEBUG] debug-file - Module 'entry' target 'default' build option: { + "debuggable": true, + "copyFrom": "default", + "name": "debug" +} +[2025-05-14T16:13:07.815] [DEBUG] debug-file - hvigorfile, resolve finished C:\Users\fy\Desktop\noproject\BestPracticeSnippets\CanvasDraw\entry\hvigorfile.ts +[2025-05-14T16:13:07.826] [DEBUG] debug-file - Start to initialize dependency information. +[2025-05-14T16:13:07.858] [DEBUG] debug-file - Executing task ::clean +[2025-05-14T16:13:07.906] [DEBUG] debug-file - Worker pool is initialized with config: { + minPoolNum: 2, + maxPoolNum: undefined, + maxCoreSize: undefined, + cacheCapacity: undefined, + cacheTtl: undefined +} +[2025-05-14T16:13:07.914] [DEBUG] debug-file - Clear worker 0. +[2025-05-14T16:13:07.804] [DEBUG] debug-file - Module 'entry' target 'ohosTest' build option: { + "debuggable": true, + "name": "default" +} +[2025-05-14T16:13:07.829] [DEBUG] debug-file - Module CanvasDraw Collected Dependency: +[2025-05-14T16:13:07.858] [DEBUG] debug-file - clean: Worker pool is inactive. +[2025-05-14T16:13:07.914] [DEBUG] debug-file - Worker 0 has been cleared. +[2025-05-14T16:13:07.804] [DEBUG] debug-file - End initialize module-target build option map, moduleName=entry +[2025-05-14T16:13:07.829] [DEBUG] debug-file - Module CanvasDraw's total dependency: 0 +[2025-05-14T16:13:07.859] [DEBUG] debug-file - CanvasDraw : clean cost memory 0.03314208984375 +[2025-05-14T16:13:07.914] [DEBUG] debug-file - Current idle worker size: 1. +[2025-05-14T16:13:07.805] [DEBUG] debug-file - Module 'entry' target 'default' using build option: { + "debuggable": true, + "copyFrom": "default", + "name": "debug" +} in this build. +[2025-05-14T16:13:07.830] [DEBUG] debug-file - Start to initialize dependency information. +[2025-05-14T16:13:07.859] [DEBUG] debug-file - runTaskFromQueue task cost before running: 2 s 455 ms +[2025-05-14T16:13:07.914] [DEBUG] debug-file - Current busy worker size: 0. +[2025-05-14T16:13:07.833] [DEBUG] debug-file - Module entry Collected Dependency: +[2025-05-14T16:13:07.860] [INFO] debug-file - Finished ::clean... after 2 ms +[2025-05-14T16:13:07.914] [DEBUG] debug-file - Clear worker 1. +[2025-05-14T16:13:07.833] [DEBUG] debug-file - Module entry's total dependency: 0 +[2025-05-14T16:13:07.860] [DEBUG] debug-file - Executing task :entry:init +[2025-05-14T16:13:07.914] [DEBUG] debug-file - Worker 1 has been cleared. +[2025-05-14T16:13:07.838] [DEBUG] debug-file - Configuration phase cost:2 s 404 ms +[2025-05-14T16:13:07.861] [DEBUG] debug-file - entry : init cost memory 0.01019287109375 +[2025-05-14T16:13:07.914] [DEBUG] debug-file - Current idle worker size: 0. +[2025-05-14T16:13:07.861] [DEBUG] debug-file - runTaskFromQueue task cost before running: 2 s 457 ms +[2025-05-14T16:13:07.914] [DEBUG] debug-file - Current busy worker size: 0. +[2025-05-14T16:13:07.861] [INFO] debug-file - Finished :entry:init... after 1 ms +[2025-05-14T16:13:07.915] [DEBUG] debug-file - hvigor build process will be closed. +[2025-05-14T16:13:07.861] [DEBUG] debug-file - Executing task ::init +[2025-05-14T16:13:07.924] [DEBUG] debug-file - worker[0] exits with exit code 0. +[2025-05-14T16:13:07.862] [DEBUG] debug-file - CanvasDraw : init cost memory 0.00897216796875 +[2025-05-14T16:13:07.924] [DEBUG] debug-file - worker[1] exits with exit code 0. +[2025-05-14T16:13:07.862] [DEBUG] debug-file - runTaskFromQueue task cost before running: 2 s 458 ms +[2025-05-14T16:13:07.925] [DEBUG] debug-file - Current worker pool is terminated. +[2025-05-14T16:13:07.862] [INFO] debug-file - Finished ::init... after 1 ms diff --git a/CanvasDraw/.hvigor/outputs/sync/fileCache.json b/CanvasDraw/.hvigor/outputs/sync/fileCache.json new file mode 100644 index 0000000000000000000000000000000000000000..03068082028f5dd84af8cfce50bcb3de33c502b0 --- /dev/null +++ b/CanvasDraw/.hvigor/outputs/sync/fileCache.json @@ -0,0 +1 @@ +{"CACHE_SYNC_FILE_HASH":{"C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\CanvasDraw\\hvigor\\hvigor-config.json5":"6c445df15dcd74b809e2c7a3c3636728abb61617904453e0addaf6ba8b03a6a9","C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\CanvasDraw\\build-profile.json5":"a11f40b3c74b61434e12c25866d25010d87070362233c6b1d620128aa1106830","C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\CanvasDraw\\hvigorfile.ts":"2752b03b69ae6d13651db4d18b47df8ed90db55b21d0a5956c68c78859e22789","C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\CanvasDraw\\oh-package.json5":"14cf054c918b4fb275ba91407a3eae01faca681169a7849dd5c104892765d85f","C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\CanvasDraw\\entry\\build-profile.json5":"ac0caabf379cc1ee12ed75b9c6ff0585a45a390b2cd905ab20fc77fb952bbc4d","C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\CanvasDraw\\entry\\hvigorfile.ts":"a3bc81893eb000aeafc8c8325183efeb4b404ebdf7353a2a325d594ab4a77733","C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\CanvasDraw\\entry\\oh-package.json5":"9524e20c37b30f483042fdbd339aefa14d6cb395f05dfe9cfea8b704e5522b24","C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\CanvasDraw\\.hvigor\\outputs\\sync\\output.json":"d62e50ec7f435733d79d4fe5dba1b0d3212533257eb4c7cac18688b26d36c33a","SDK_LOCATION":"C:/Program Files/Huawei/DevEco Studio/sdk"},"OHPM_INSTALL_FILE_HASH":{"C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\CanvasDraw\\oh-package.json5":"14cf054c918b4fb275ba91407a3eae01faca681169a7849dd5c104892765d85f","C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\CanvasDraw\\entry\\oh-package.json5":"9524e20c37b30f483042fdbd339aefa14d6cb395f05dfe9cfea8b704e5522b24","C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\CanvasDraw\\oh_modules":false,"C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\CanvasDraw\\entry\\oh_modules":false}} \ No newline at end of file diff --git a/CanvasDraw/.hvigor/outputs/sync/output.json b/CanvasDraw/.hvigor/outputs/sync/output.json new file mode 100644 index 0000000000000000000000000000000000000000..4d1f19f199b9f63bb4bc38a49870083c927086e2 --- /dev/null +++ b/CanvasDraw/.hvigor/outputs/sync/output.json @@ -0,0 +1,164 @@ +{ + "ohos-module-entry": { + "SELECT_TARGET": "default", + "MODULE_BUILD_DIR": "C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\CanvasDraw\\entry\\build", + "DEPENDENCY_INFO": {}, + "TARGETS": { + "default": { + "SOURCE_ROOT": "C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\CanvasDraw\\entry\\src\\main", + "RESOURCES_PATH": [ + "C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\CanvasDraw\\entry\\src\\main\\resources" + ], + "BUILD_PATH": { + "OUTPUT_PATH": "C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\CanvasDraw\\entry\\build\\default\\outputs\\default", + "INTERMEDIA_PATH": "C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\CanvasDraw\\entry\\build\\default\\intermediates", + "JS_ASSETS_PATH": "C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\CanvasDraw\\entry\\build\\default\\intermediates\\loader_out\\default", + "JS_LITE_ASSETS_PATH": "C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\CanvasDraw\\entry\\build\\default\\intermediates\\loader_out_lite\\default", + "RES_PATH": "C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\CanvasDraw\\entry\\build\\default\\intermediates\\res\\default", + "RES_PROFILE_PATH": "C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\CanvasDraw\\entry\\build\\default\\intermediates\\res\\default\\resources\\base\\profile", + "ETS_SUPER_VISUAL_PATH": "C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\CanvasDraw\\entry\\build\\default\\cache\\default\\default@CompileArkTS\\esmodule", + "JS_SUPER_VISUAL_PATH": "C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\CanvasDraw\\entry\\build\\default\\cache\\default\\default@CompileJS\\jsbundle", + "WORKER_LOADER": "C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\CanvasDraw\\entry\\build\\default\\intermediates\\loader\\default\\loader.json", + "MANIFEST_JSON": "C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\CanvasDraw\\entry\\build\\default\\intermediates\\manifest\\default", + "OUTPUT_METADATA_JSON": "C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\CanvasDraw\\entry\\build\\default\\intermediates\\hap_metadata\\default\\output_metadata.json", + "SOURCE_MAP_DIR": "C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\CanvasDraw\\entry\\build\\default\\intermediates\\source_map\\default" + }, + "BUILD_OPTION": { + "debuggable": true + } + }, + "ohosTest": { + "SOURCE_ROOT": "C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\CanvasDraw\\entry\\src\\ohosTest", + "RESOURCES_PATH": [ + "C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\CanvasDraw\\entry\\src\\ohosTest\\resources" + ], + "BUILD_PATH": { + "OUTPUT_PATH": "C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\CanvasDraw\\entry\\build\\default\\outputs\\ohosTest", + "INTERMEDIA_PATH": "C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\CanvasDraw\\entry\\build\\default\\intermediates", + "JS_ASSETS_PATH": "C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\CanvasDraw\\entry\\build\\default\\intermediates\\loader_out\\ohosTest", + "JS_LITE_ASSETS_PATH": "C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\CanvasDraw\\entry\\build\\default\\intermediates\\loader_out_lite\\ohosTest", + "RES_PATH": "C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\CanvasDraw\\entry\\build\\default\\intermediates\\res\\ohosTest", + "RES_PROFILE_PATH": "C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\CanvasDraw\\entry\\build\\default\\intermediates\\res\\ohosTest\\resources\\base\\profile", + "ETS_SUPER_VISUAL_PATH": "C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\CanvasDraw\\entry\\build\\default\\cache\\ohosTest\\ohosTest@OhosTestCompileArkTS\\esmodule", + "JS_SUPER_VISUAL_PATH": "C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\CanvasDraw\\entry\\build\\default\\cache\\ohosTest\\ohosTest@OhosTestCompileJS\\jsbundle", + "WORKER_LOADER": "C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\CanvasDraw\\entry\\build\\default\\intermediates\\loader\\ohosTest\\loader.json", + "MANIFEST_JSON": "C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\CanvasDraw\\entry\\build\\default\\intermediates\\manifest\\ohosTest", + "OUTPUT_METADATA_JSON": "C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\CanvasDraw\\entry\\build\\default\\intermediates\\hap_metadata\\ohosTest\\output_metadata.json", + "SOURCE_MAP_DIR": "C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\CanvasDraw\\entry\\build\\default\\intermediates\\source_map\\ohosTest" + }, + "BUILD_OPTION": { + "debuggable": true + } + } + }, + "BUILD_OPTION": { + "default-default": { + "debuggable": true, + "copyFrom": "default", + "name": "debug" + } + }, + "BUILD_PROFILE_OPT": { + "apiType": "stageMode", + "buildOption": {}, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": true, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + { + "name": "default" + }, + { + "name": "debug" + } + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest" + } + ] + }, + "BUILD_CACHE_DIR": "" + }, + "ohos-project": { + "SELECT_PRODUCT_NAME": "default", + "MODULE_BUILD_DIR": "C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\CanvasDraw\\build", + "BUNDLE_NAME": "com.example.canvasdraw", + "BUILD_PATH": { + "OUTPUT_PATH": "C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\CanvasDraw\\build\\outputs\\default" + }, + "MODULES": [ + { + "name": "entry", + "srcPath": "C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\CanvasDraw\\entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ], + "belongProjectPath": "C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\CanvasDraw" + } + ], + "PROFILE_OPT": { + "app": { + "signingConfigs": [], + "products": [ + { + "name": "default", + "signingConfig": "default", + "compatibleSdkVersion": "5.0.0(12)", + "runtimeOS": "HarmonyOS" + } + ], + "buildModeSet": [ + { + "name": "debug" + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] + }, + "CONFIG_PROPERTIES": { + "enableSignTask": true, + "skipNativeIncremental": false, + "hvigor.keepDependency": true + }, + "OVERALL_PROJECT_PATHS": [ + "C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\CanvasDraw" + ], + "BUILD_CACHE_DIR": "" + }, + "version": 1 +} \ No newline at end of file diff --git a/CanvasDraw/.idea/.deveco/module/entry.cache.json b/CanvasDraw/.idea/.deveco/module/entry.cache.json new file mode 100644 index 0000000000000000000000000000000000000000..54edc66465716fee2816e7a01971b7c735481154 --- /dev/null +++ b/CanvasDraw/.idea/.deveco/module/entry.cache.json @@ -0,0 +1,22 @@ +{ + "CommonInfo":{ + "current.select.target":"default" + }, + "BuildOptions":{ + "SELECT_BUILD_TARGET":"default", + "BUILD_PATH":{ + "OUTPUT_METADATA_JSON":"C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\CanvasDraw\\entry\\build\\default\\intermediates\\hap_metadata\\default\\output_metadata.json", + "OUTPUT_PATH":"C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\CanvasDraw\\entry\\build\\default\\outputs\\default", + "RES_PATH":"C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\CanvasDraw\\entry\\build\\default\\intermediates\\res\\default", + "ETS_SUPER_VISUAL_PATH":"C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\CanvasDraw\\entry\\build\\default\\cache\\default\\default@CompileArkTS\\esmodule", + "JS_ASSETS_PATH":"C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\CanvasDraw\\entry\\build\\default\\intermediates\\loader_out\\default", + "SOURCE_MAP_DIR":"C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\CanvasDraw\\entry\\build\\default\\intermediates\\source_map\\default", + "INTERMEDIA_PATH":"C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\CanvasDraw\\entry\\build\\default\\intermediates", + "RES_PROFILE_PATH":"C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\CanvasDraw\\entry\\build\\default\\intermediates\\res\\default\\resources\\base\\profile", + "WORKER_LOADER":"C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\CanvasDraw\\entry\\build\\default\\intermediates\\loader\\default\\loader.json", + "MANIFEST_JSON":"C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\CanvasDraw\\entry\\build\\default\\intermediates\\manifest\\default", + "JS_LITE_ASSETS_PATH":"C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\CanvasDraw\\entry\\build\\default\\intermediates\\loader_out_lite\\default", + "JS_SUPER_VISUAL_PATH":"C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\CanvasDraw\\entry\\build\\default\\cache\\default\\default@CompileJS\\jsbundle" + } + } +} \ No newline at end of file diff --git a/CanvasDraw/.idea/.deveco/project.cache.json b/CanvasDraw/.idea/.deveco/project.cache.json new file mode 100644 index 0000000000000000000000000000000000000000..855cde22a310d98415187752f456745fadc302a0 --- /dev/null +++ b/CanvasDraw/.idea/.deveco/project.cache.json @@ -0,0 +1,16 @@ +{ + "CommonInfo":{ + "project.ide.version":"5.0.11.100", + "current.select.product":"default", + "current.select.buildMode":"", + "crossplatform.projectType":"" + }, + "BuildOptions":{ + "SELECT_BUILD_PRODUCT":"default", + "BUNDLE_NAME":"com.example.canvasdraw", + "BUILD_PATH":{ + "OUTPUT_PATH":"C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\CanvasDraw\\build\\outputs\\default" + }, + "SELECT_BUILD_MODE":"" + } +} \ No newline at end of file diff --git a/CanvasDraw/.idea/.gitignore b/CanvasDraw/.idea/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..359bb5307e8535ab7d59faf27a7377033291821e --- /dev/null +++ b/CanvasDraw/.idea/.gitignore @@ -0,0 +1,3 @@ +# 默认忽略的文件 +/shelf/ +/workspace.xml diff --git a/CanvasDraw/.idea/modules.xml b/CanvasDraw/.idea/modules.xml new file mode 100644 index 0000000000000000000000000000000000000000..5a50c64e729f7a6a762b843a8d060a1085b23163 --- /dev/null +++ b/CanvasDraw/.idea/modules.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/CanvasDraw/.idea/modules/CanvasDraw.iml b/CanvasDraw/.idea/modules/CanvasDraw.iml new file mode 100644 index 0000000000000000000000000000000000000000..c0be1d7c491147540d199ce55f0721012b7ff7b5 --- /dev/null +++ b/CanvasDraw/.idea/modules/CanvasDraw.iml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/CanvasDraw/.idea/modules/entry/entry.iml b/CanvasDraw/.idea/modules/entry/entry.iml new file mode 100644 index 0000000000000000000000000000000000000000..b630fe7f2a024b997f55fc5a52dea6c90a18c45d --- /dev/null +++ b/CanvasDraw/.idea/modules/entry/entry.iml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/CanvasDraw/.idea/vcs.xml b/CanvasDraw/.idea/vcs.xml new file mode 100644 index 0000000000000000000000000000000000000000..6c0b8635858dc7ad44b93df54b762707ce49eefc --- /dev/null +++ b/CanvasDraw/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/CanvasDraw/AppScope/app.json5 b/CanvasDraw/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..adcc636b756dcb57c562985804cc78fb88f542b8 --- /dev/null +++ b/CanvasDraw/AppScope/app.json5 @@ -0,0 +1,10 @@ +{ + "app": { + "bundleName": "com.example.canvasdraw", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/CanvasDraw/AppScope/resources/base/element/string.json b/CanvasDraw/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..a50ca60841b3b8af64d240dcadae6e55e983896d --- /dev/null +++ b/CanvasDraw/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "CanvasDraw" + } + ] +} diff --git a/CanvasDraw/AppScope/resources/base/media/app_icon.png b/CanvasDraw/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..a39445dc87828b76fed6d2ec470dd455c45319e3 Binary files /dev/null and b/CanvasDraw/AppScope/resources/base/media/app_icon.png differ diff --git a/CanvasDraw/LICENSE b/CanvasDraw/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..338e5b0bc22082e0ffcc7121c2ed3897a3ddccb0 --- /dev/null +++ b/CanvasDraw/LICENSE @@ -0,0 +1,78 @@ + Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +Apache License, Version 2.0 +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. + +"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. + +2. Grant of Copyright License. + +Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. + +Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. + +4. Redistribution. + +You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: +1.You must give any other recipients of the Work or Derivative Works a copy of this License; and +2.You must cause any modified files to carry prominent notices stating that You changed the files; and +3.You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and +4.If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. + +You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. + +5. Submission of Contributions. + +Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. + +6. Trademarks. + +This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. + +Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. + +In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. + +While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS \ No newline at end of file diff --git a/CanvasDraw/build-profile.json5 b/CanvasDraw/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..19b2d1d0b868064df8c461ecdbbdbb5f6755b07f --- /dev/null +++ b/CanvasDraw/build-profile.json5 @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "app": { + "signingConfigs": [], + "products": [ + { + "name": "default", + "signingConfig": "default", + "compatibleSdkVersion": "5.0.0(12)", + "runtimeOS": "HarmonyOS", + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/CanvasDraw/entry/build-profile.json5 b/CanvasDraw/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..63b88fb1a0053e40acb2391457a7e9d71af748fe --- /dev/null +++ b/CanvasDraw/entry/build-profile.json5 @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": true, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/CanvasDraw/entry/hvigorfile.ts b/CanvasDraw/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..c6edcd90486dd5a853cf7d34c8647f08414ca7a3 --- /dev/null +++ b/CanvasDraw/entry/hvigorfile.ts @@ -0,0 +1,6 @@ +import { hapTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/CanvasDraw/entry/obfuscation-rules.txt b/CanvasDraw/entry/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..69c4d6a8a5531548e4886fa766090c5c157a87d9 --- /dev/null +++ b/CanvasDraw/entry/obfuscation-rules.txt @@ -0,0 +1,18 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope \ No newline at end of file diff --git a/CanvasDraw/entry/oh-package.json5 b/CanvasDraw/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..248c3b7541a589682a250f86a6d3ecf7414d2d6a --- /dev/null +++ b/CanvasDraw/entry/oh-package.json5 @@ -0,0 +1,10 @@ +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/CanvasDraw/entry/src/main/ets/entryability/EntryAbility.ets b/CanvasDraw/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..a42e55815e1fa92666784cf9e030ad4a51dea075 --- /dev/null +++ b/CanvasDraw/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; +import { BusinessError } from '@kit.BasicServicesKit'; + +export default class EntryAbility extends UIAbility { + windowClass: window.Window | undefined = undefined; + isLayoutFullScreen = true; + + 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.getMainWindow((err: BusinessError, data) => { + const errCode: number = err.code; + if (errCode) { + console.error(`Failed to obtain the main window. Cause code: ${err.code}, message: ${err.message}`); + return; + } + this.windowClass = data; + let isLayoutFullScreen = true; + try { + let promise = this.windowClass.setWindowLayoutFullScreen(isLayoutFullScreen); + promise.then(() => { + console.info('Succeeded in setting the window layout to full-screen mode.'); + }).catch((err: BusinessError) => { + console.error(`Failed to set the window layout to full-screen mode. Cause code: ${err.code}, + message: ${err.message}`); + }); + } catch (exception) { + console.error(`Failed to set the window layout to full-screen mode. Cause code: ${exception.code}, + message: ${exception.message}`); + } + this.windowClass.setSpecificSystemBarEnabled('navigationIndicator', false); + this.windowClass.setSpecificSystemBarEnabled('status', false); + }); + windowStage.loadContent('pages/Index', (err) => { + 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.'); + }); + } + + 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/CanvasDraw/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/CanvasDraw/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..6b744d7eaa66e51e79fc4e0896e251292ee767c5 --- /dev/null +++ b/CanvasDraw/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit'; + +export default class EntryBackupAbility extends BackupExtensionAbility { + async onBackup() { + hilog.info(0x0000, 'testTag', 'onBackup ok'); + } + + async onRestore(bundleVersion: BundleVersion) { + hilog.info(0x0000, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion)); + } +} \ No newline at end of file diff --git a/CanvasDraw/entry/src/main/ets/pages/Index.ets b/CanvasDraw/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..82dd39554385aecbf34cd2d3b12618c966e93402 --- /dev/null +++ b/CanvasDraw/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* +* Best Practices: Enhancing Performance with Custom Drawing Capabilities +* Use the custom component GlassCoverView to implement a transparent circle. On the homepage, click the "Begin Draw" button to randomly generate a list of 1000 positions ranging from 0 to 1. +*/ +// [Start index] +// entry\src\main\ets\pages\Index.ets +import GlassCoverView from '../view/GlassCoverView'; + +@Entry +@Component +struct Index { + @State pointsToDraw: number[][] = []; + + /** + * Generate a list of 1000 random positions between 0 and 1, and draw circles at the corresponding positions. + */ + startDraw(): void { + this.pointsToDraw = []; + for (let index = 0; index < 1000; index++) { + this.pointsToDraw.push([Math.random(), Math.random()]); + } + } + + build() { + Stack() { + Image($r('app.media.drawImage')) + .width('100%') + .height('100%') + // "Transparent circle custom component, draw 1000 transparent circles in this component." + GlassCoverView({ pointsToDraw: this.pointsToDraw }) + .width('100%') + .height('100%') + Row() { + Button('Begin Draw') + .width('100%') + .height(40) + } + .padding({ + right: 16, + bottom: 16, + left: 16 + }) + .onClick(() => { + this.startDraw(); + }) + } + .alignContent(Alignment.Bottom) + .width('100%') + .height('100%') + } +} +// [End index] \ No newline at end of file diff --git a/CanvasDraw/entry/src/main/ets/view/GlassCoverView.ets b/CanvasDraw/entry/src/main/ets/view/GlassCoverView.ets new file mode 100644 index 0000000000000000000000000000000000000000..f94b3ea4124b23a767c674f851b06096ed688e22 --- /dev/null +++ b/CanvasDraw/entry/src/main/ets/view/GlassCoverView.ets @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* +* Best Practices: Enhancing Performance with Self-Drawing Capabilities +* Task: When the GlassCoverView subpage uses the @Watch decorator to detect updates in the homepage position list data +* pointsToDraw, it will render 1,000 transparent hollow circles on the page (refer to the onDraw() method for details). +*/ +// [Start glass_cover_view] +// entry\src\main\ets\view\GlassCoverView.ets +import { hiTraceMeter } from '@kit.PerformanceAnalysisKit'; + +/** + * glass overlay effect + */ +@Preview +@Component +export default struct GlassCoverView { + @Prop @Watch('onDraw') pointsToDraw: number[][] = []; + private settings = new RenderingContextSettings(true); + private renderContext = new CanvasRenderingContext2D(this.settings); + private viewWidth: number = 0; + private viewHeight: number = 0; + + build() { + Stack() { + Canvas(this.renderContext) + .width('100%') + .height('100%') + .onAreaChange((_: Area, newValue: Area) => { + this.handleAreaChange(newValue); + }) + } + .height('100%') + .width('100%') + } + + private handleAreaChange(area: Area): void { + this.viewWidth = parseInt(area.width.toString()); + this.viewHeight = parseInt(area.height.toString()); + this.onDraw(); + } + + private onDraw(): void { + const canvas = this.renderContext; + canvas.reset(); + if (canvas === undefined) { + return; + } + // hollow transparent circle + hiTraceMeter.startTrace('slow', 1); + console.info('debug: slow start'); + // Save drawing context + canvas.save(); + // Clear specified pixels within the given rectangle. + canvas.clearRect(0, 0, this.viewWidth, this.viewHeight); + // Specify the fill color to be drawn + canvas.fillStyle = '#77CCCCCC'; + // Fill a rectangle + canvas.fillRect(0, 0, this.viewWidth, this.viewHeight); + // draw hollow circles + canvas.globalCompositeOperation = 'destination-out'; + canvas.fillStyle = '#CCCCCC'; + this.pointsToDraw.forEach((xy: number[]) => { + this.drawOneCell(canvas, xy[0] * this.viewWidth, xy[1] * this.viewHeight, this.getUIContext().px2vp(15)); + }) + canvas.fill(); + // Restore the saved drawing context + canvas.restore(); + console.info('debug: slow end'); + hiTraceMeter.finishTrace('slow', 1); + } + + /** + * Draw a circle based on the specified position and width. + */ + private drawOneCell(canvas: CanvasRenderer, x: number, y: number, width: number): void { + canvas.moveTo(x + width, y); + canvas.arc(x, y, width, 0, Math.PI * 2); + } +} +// [End glass_cover_view] \ No newline at end of file diff --git a/CanvasDraw/entry/src/main/module.json5 b/CanvasDraw/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..b058dbff7a7999b5e3db9d05be1a0a740fa4a36f --- /dev/null +++ b/CanvasDraw/entry/src/main/module.json5 @@ -0,0 +1,52 @@ +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "phone", + "tablet", + "2in1","default" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:layered_image", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "EntryBackupAbility", + "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets", + "type": "backup", + "exported": false, + "metadata": [ + { + "name": "ohos.extension.backup", + "resource": "$profile:backup_config" + } + ], + } + ] + } +} \ No newline at end of file diff --git a/CanvasDraw/entry/src/main/resources/base/element/color.json b/CanvasDraw/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/CanvasDraw/entry/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/CanvasDraw/entry/src/main/resources/base/element/string.json b/CanvasDraw/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..0b4fd42d4bb5fcb13e4a51833303ad566ce70a03 --- /dev/null +++ b/CanvasDraw/entry/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "CanvasDraw" + } + ] +} \ No newline at end of file diff --git a/CanvasDraw/entry/src/main/resources/base/media/background.png b/CanvasDraw/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d Binary files /dev/null and b/CanvasDraw/entry/src/main/resources/base/media/background.png differ diff --git a/CanvasDraw/entry/src/main/resources/base/media/drawImage.jpg b/CanvasDraw/entry/src/main/resources/base/media/drawImage.jpg new file mode 100644 index 0000000000000000000000000000000000000000..77e9ce2be855a0325da8a06bfe5098a664f74e98 Binary files /dev/null and b/CanvasDraw/entry/src/main/resources/base/media/drawImage.jpg differ diff --git a/CanvasDraw/entry/src/main/resources/base/media/foreground.png b/CanvasDraw/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902 Binary files /dev/null and b/CanvasDraw/entry/src/main/resources/base/media/foreground.png differ diff --git a/CanvasDraw/entry/src/main/resources/base/media/layered_image.json b/CanvasDraw/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/CanvasDraw/entry/src/main/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/CanvasDraw/entry/src/main/resources/base/media/startIcon.png b/CanvasDraw/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/CanvasDraw/entry/src/main/resources/base/media/startIcon.png differ diff --git a/CanvasDraw/entry/src/main/resources/base/profile/backup_config.json b/CanvasDraw/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a --- /dev/null +++ b/CanvasDraw/entry/src/main/resources/base/profile/backup_config.json @@ -0,0 +1,3 @@ +{ + "allowToBackupRestore": true +} \ No newline at end of file diff --git a/CanvasDraw/entry/src/main/resources/base/profile/main_pages.json b/CanvasDraw/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce --- /dev/null +++ b/CanvasDraw/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/CanvasDraw/entry/src/main/resources/en_US/element/string.json b/CanvasDraw/entry/src/main/resources/en_US/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..0b4fd42d4bb5fcb13e4a51833303ad566ce70a03 --- /dev/null +++ b/CanvasDraw/entry/src/main/resources/en_US/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "CanvasDraw" + } + ] +} \ No newline at end of file diff --git a/CanvasDraw/entry/src/main/resources/zh_CN/element/string.json b/CanvasDraw/entry/src/main/resources/zh_CN/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..c97bcd4cfd73ea885a3fbf4a5d478c8a9057c960 --- /dev/null +++ b/CanvasDraw/entry/src/main/resources/zh_CN/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "模块描述" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "CanvasDraw" + } + ] +} \ No newline at end of file diff --git a/CanvasDraw/hvigor/hvigor-config.json5 b/CanvasDraw/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..06b2783670a348f95533b352c1ceda909a842bbc --- /dev/null +++ b/CanvasDraw/hvigor/hvigor-config.json5 @@ -0,0 +1,22 @@ +{ + "modelVersion": "5.0.0", + "dependencies": { + }, + "execution": { + // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */ + // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */ + // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */ + // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */ + // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */ + }, + "logging": { + // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ + }, + "debugging": { + // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */ + }, + "nodeOptions": { + // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/ + // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/ + } +} diff --git a/CanvasDraw/hvigorfile.ts b/CanvasDraw/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..f3cb9f1a87a81687554a76283af8df27d8bda775 --- /dev/null +++ b/CanvasDraw/hvigorfile.ts @@ -0,0 +1,6 @@ +import { appTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/CanvasDraw/oh-package.json5 b/CanvasDraw/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..8bf916d4a165e0466c65bc49f58ab2e3c27e8931 --- /dev/null +++ b/CanvasDraw/oh-package.json5 @@ -0,0 +1,8 @@ +{ + "modelVersion": "5.0.0", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + } +} diff --git a/PreHttpRequestUseFiles/entry/src/main/ets/entryability/EntryAbility.ets b/PreHttpRequestUseFiles/entry/src/main/ets/entryability/EntryAbility.ets index e8c1e5db6d8cfa8003414ebb28f6a5321f3403ed..ad2c48d29169945d918a7da53538d4df73a3211d 100644 --- a/PreHttpRequestUseFiles/entry/src/main/ets/entryability/EntryAbility.ets +++ b/PreHttpRequestUseFiles/entry/src/main/ets/entryability/EntryAbility.ets @@ -36,6 +36,7 @@ export default class EntryAbility extends UIAbility { return; } hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + AppStorage.setOrCreate('uiContext', windowStage.getMainWindowSync().getUIContext()); }); } diff --git a/PreHttpRequestUseFiles/entry/src/main/ets/pages/MainPage.ets b/PreHttpRequestUseFiles/entry/src/main/ets/pages/MainPage.ets index f39541d3b133a5f5580d144af36ff0071a9723df..31fb2d0a0d8bc084278e686c3eb3ed7179b1bca3 100644 --- a/PreHttpRequestUseFiles/entry/src/main/ets/pages/MainPage.ets +++ b/PreHttpRequestUseFiles/entry/src/main/ets/pages/MainPage.ets @@ -20,7 +20,8 @@ import { httpRequest } from '../utils/NetRequest'; import Logger from '../utils/Logger'; // Obtain the path of the application file -let context = getContext(this) as common.UIAbilityContext; +const uiContext: UIContext | undefined = AppStorage.get('uiContext'); +let context = uiContext?.getHostContext() as common.UIAbilityContext; let filesDir = context.filesDir; let fileUrl = filesDir + '/xxx.png'; // The image's network address suffix needs to be replaced by the real url. let para: Record = { 'imageData': undefined }; diff --git a/PreHttpRequestUseFiles/entry/src/main/ets/utils/NetRequest.ets b/PreHttpRequestUseFiles/entry/src/main/ets/utils/NetRequest.ets index 3caea6fdbd56060df1a422b5b8811376af8c1f28..ff96dd3c6b4efcbc06f3e512633a4889e3bf3785 100644 --- a/PreHttpRequestUseFiles/entry/src/main/ets/utils/NetRequest.ets +++ b/PreHttpRequestUseFiles/entry/src/main/ets/utils/NetRequest.ets @@ -19,7 +19,8 @@ import { fileIo as fs } from '@kit.CoreFileKit'; import { common } from '@kit.AbilityKit'; // Obtain the path of the application file -let context = getContext(this) as common.UIAbilityContext; +const uiContext: UIContext | undefined = AppStorage.get('uiContext'); +let context = uiContext?.getHostContext() as common.UIAbilityContext; let filesDir = context.filesDir; let fileUrl = filesDir + '/xxx.png'; // The image's network address suffix needs to be replaced by the real url. diff --git a/animation/.clang-format b/animation/.clang-format new file mode 100644 index 0000000000000000000000000000000000000000..48439ed68073b99be118d374d1ebd43d04d4c4eb --- /dev/null +++ b/animation/.clang-format @@ -0,0 +1,64 @@ +Language: Cpp +# BasedOnStyle: LLVM +ColumnLimit: 120 +SortIncludes: CaseSensitive +TabWidth: 4 +IndentWidth: 4 +UseTab: Never +AccessModifierOffset: -4 +ContinuationIndentWidth: 4 +IndentCaseBlocks: false +IndentCaseLabels: false +IndentGotoLabels: true +IndentWrappedFunctionNames: false +SortUsingDeclarations: false +NamespaceIndentation: None +SpaceAfterCStyleCast: false +SpaceAfterLogicalNot: false +SpaceAfterTemplateKeyword: true +SpaceBeforeAssignmentOperators: true +SpaceBeforeCaseColon: false +SpaceBeforeCpp11BracedList: false +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true +SpaceBeforeRangeBasedForLoopColon: true +SpaceBeforeSquareBrackets: false +SpaceInEmptyBlock: false +SpaceInEmptyParentheses: false +SpacesInAngles: false +SpacesInCStyleCastParentheses: false +SpacesInConditionalStatement: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +AlignTrailingComments: true +AlignAfterOpenBracket: true +AllowShortCaseLabelsOnASingleLine: false +AllowShortEnumsOnASingleLine: true +AllowShortFunctionsOnASingleLine: All +AllowShortIfStatementsOnASingleLine: Never +AllowShortLambdasOnASingleLine: All +AllowShortLoopsOnASingleLine: false +AlwaysBreakTemplateDeclarations: MultiLine +BinPackArguments: true +BinPackParameters: true +BreakBeforeTernaryOperators: true +BreakConstructorInitializers: BeforeColon +BreakInheritanceList: BeforeColon +BreakStringLiterals: true +InsertBraces: false +IndentExternBlock: NoIndent +BreakBeforeBraces: Custom +BraceWrapping: + AfterCaseLabel: false + AfterClass: false + AfterControlStatement: Never + AfterEnum: false + AfterFunction: false + AfterNamespace: false + AfterStruct: false + AfterUnion: false + AfterExternBlock: false + BeforeCatch: false + BeforeElse: false +ReflowComments: true +MaxEmptyLinesToKeep: 2 \ No newline at end of file diff --git a/animation/.hvigor/cache/meta.json b/animation/.hvigor/cache/meta.json new file mode 100644 index 0000000000000000000000000000000000000000..18f86af95573be1ca58a8494f7aac0c780d0dfac --- /dev/null +++ b/animation/.hvigor/cache/meta.json @@ -0,0 +1 @@ +{"compileSdkVersion":"5.0.4(16)","hvigorVersion":"5.16.2","toolChainsVersion":"5.0.4.150"} diff --git a/animation/.hvigor/dependencyMap/dependencyMap.json5 b/animation/.hvigor/dependencyMap/dependencyMap.json5 new file mode 100644 index 0000000000000000000000000000000000000000..23dfe3afbb302ceb2d7f911f573df42924a8086c --- /dev/null +++ b/animation/.hvigor/dependencyMap/dependencyMap.json5 @@ -0,0 +1 @@ +{"basePath":"C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\animation\\.hvigor\\dependencyMap\\dependencyMap.json5","rootDependency":"./oh-package.json5","dependencyMap":{"entry":"./entry/oh-package.json5"},"modules":[{"name":"entry","srcPath":"..\\..\\..\\entry"}]} \ No newline at end of file diff --git a/animation/.hvigor/dependencyMap/entry/oh-package.json5 b/animation/.hvigor/dependencyMap/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..50a51753855fc6efdf037d5db6ab2cc001f17bbc --- /dev/null +++ b/animation/.hvigor/dependencyMap/entry/oh-package.json5 @@ -0,0 +1 @@ +{"name":"entry","version":"1.0.0","description":"Please describe the basic information.","main":"","author":"","license":"","dependencies":{}} \ No newline at end of file diff --git a/animation/.hvigor/dependencyMap/oh-package.json5 b/animation/.hvigor/dependencyMap/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..0936308543ae8d95029dfc66391bef10a402c7ef --- /dev/null +++ b/animation/.hvigor/dependencyMap/oh-package.json5 @@ -0,0 +1 @@ +{"modelVersion":"5.0.2","description":"Please describe the basic information.","dependencies":{},"devDependencies":{"@ohos/hypium":"1.0.21","@ohos/hamock":"1.0.1-rc2"}} \ No newline at end of file diff --git a/animation/.hvigor/outputs/build-logs/build.log b/animation/.hvigor/outputs/build-logs/build.log new file mode 100644 index 0000000000000000000000000000000000000000..dbdd58a23753c14f79d997a7b84c0ca93e754b83 --- /dev/null +++ b/animation/.hvigor/outputs/build-logs/build.log @@ -0,0 +1,153 @@ +[2025-05-14T16:09:39.463] [DEBUG] debug-file - env: nodejsVersion=v18.20.1 +[2025-05-14T16:09:40.069] [DEBUG] debug-file - Hvigor init with startParameters:{ + hvigorfileTypeCheck: false, + parallelExecution: true, + incrementalExecution: true, + printStackTrace: false, + daemon: false, + analyze: 0, + logLevel: Level { level: 20000, levelStr: 'INFO', colour: 'green' } +} +[2025-05-14T16:09:40.103] [DEBUG] debug-file - hvigorfile, resolving C:\Users\fy\Desktop\noproject\BestPracticeSnippets\animation\hvigorfile.ts +[2025-05-14T16:09:42.422] [DEBUG] debug-file - Start initialize project's product build option map with build mode debug. +[2025-05-14T16:09:42.428] [DEBUG] debug-file - Product 'default' using build option: { + "debuggable": true, + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } +} in this build. +[2025-05-14T16:09:42.443] [DEBUG] debug-file - Local scan or download HarmonyOS sdk components toolchains,ets,js,native,previewer +[2025-05-14T16:09:42.183] [DEBUG] debug-file - hvigorfile, require result: { default: { system: [Function: appTasks], plugins: [] } } +[2025-05-14T16:09:42.448] [DEBUG] debug-file - Local scan or download hmscore sdk components toolchains,ets,native +[2025-05-14T16:09:42.459] [DEBUG] debug-file - Start recording SDK configuration permission data. +[2025-05-14T16:09:42.494] [DEBUG] debug-file - Sdk init in 55 ms +[2025-05-14T16:09:42.539] [DEBUG] debug-file - Project task initialization takes 41 ms +[2025-05-14T16:09:42.554] [DEBUG] debug-file - hvigorfile, resolving C:\Users\fy\Desktop\noproject\BestPracticeSnippets\animation\entry\hvigorfile.ts +[2025-05-14T16:09:42.588] [DEBUG] debug-file - Start initialize module-target build option map, moduleName=entry, buildMode=debug +[2025-05-14T16:09:42.605] [DEBUG] debug-file - project has submodules:entry +[2025-05-14T16:09:42.633] [DEBUG] debug-file - Configuration task cost before running: 2 s 595 ms +[2025-05-14T16:09:42.599] [DEBUG] debug-file - Module entry task initialization takes 6 ms +[2025-05-14T16:09:42.640] [DEBUG] debug-file - Executing task :entry:clean +[2025-05-14T16:09:42.646] [DEBUG] debug-file - entry : clean cost memory 0.25525665283203125 +[2025-05-14T16:09:42.676] [DEBUG] debug-file - Module 'entry' target 'default' using build option: { + "debuggable": true, + "copyFrom": "default", + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + }, + "name": "debug" +} in this build. +[2025-05-14T16:09:39.465] [DEBUG] debug-file - env: hvigor-config.json5 content = { + modelVersion: '5.0.2', + dependencies: {}, + execution: {}, + logging: {}, + debugging: {}, + nodeOptions: {} +} +[2025-05-14T16:09:42.706] [DEBUG] debug-file - Create resident worker with id: 0. +[2025-05-14T16:09:40.072] [DEBUG] debug-file - Since current hvigor version 5.16.2 differs from last hvigor version + undefined, delete file-cache.json and task-cache.json. +[2025-05-14T16:09:42.422] [DEBUG] debug-file - Picking option from product 'default' with build mode 'debug'. +[2025-05-14T16:09:42.429] [DEBUG] debug-file - not found resModel json file in : C:\Users\fy\Desktop\noproject\BestPracticeSnippets\animation\entry\src\ohosTest\module.json5 +[2025-05-14T16:09:42.184] [DEBUG] debug-file - hvigorfile, binding system plugins [Function: appTasks] +[2025-05-14T16:09:42.539] [DEBUG] debug-file - hvigorfile, binding custom plugins [] +[2025-05-14T16:09:42.565] [DEBUG] debug-file - hvigorfile, require result: { default: { system: [Function: hapTasks], plugins: [] } } +[2025-05-14T16:09:42.588] [DEBUG] debug-file - Target 'default' config: {} +[2025-05-14T16:09:42.606] [DEBUG] debug-file - start to load updatedOhPackageInfo to the disk +[2025-05-14T16:09:42.600] [DEBUG] debug-file - hvigorfile, binding custom plugins [] +[2025-05-14T16:09:42.641] [DEBUG] debug-file - clean: Worker pool is inactive. +[2025-05-14T16:09:42.646] [DEBUG] debug-file - runTaskFromQueue task cost before running: 2 s 607 ms +[2025-05-14T16:09:42.683] [DEBUG] debug-file - Module 'entry' target 'ohosTest' using build option: { + "debuggable": true, + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + }, + "name": "default" +} in this build. +[2025-05-14T16:09:39.467] [DEBUG] debug-file - env: daemon=false +[2025-05-14T16:09:42.708] [DEBUG] debug-file - Create resident worker with id: 1. +[2025-05-14T16:09:40.073] [DEBUG] debug-file - Cache service initialization finished in 3 ms +[2025-05-14T16:09:42.423] [DEBUG] debug-file - Product 'default' build option: {} +[2025-05-14T16:09:42.438] [DEBUG] debug-file - No signingConfig found, initRemoteHspCache failed. +[2025-05-14T16:09:42.539] [DEBUG] debug-file - hvigorfile, no custom plugins were found in C:\Users\fy\Desktop\noproject\BestPracticeSnippets\animation\hvigorfile.ts +[2025-05-14T16:09:42.565] [DEBUG] debug-file - hvigorfile, binding system plugins [Function: hapTasks] +[2025-05-14T16:09:42.589] [DEBUG] debug-file - Target 'ohosTest' config: {} +[2025-05-14T16:09:42.611] [DEBUG] debug-file - load to the disk finished +[2025-05-14T16:09:42.600] [DEBUG] debug-file - hvigorfile, no custom plugins were found in C:\Users\fy\Desktop\noproject\BestPracticeSnippets\animation\entry\hvigorfile.ts +[2025-05-14T16:09:42.647] [INFO] debug-file - Finished :entry:clean... after 6 ms +[2025-05-14T16:09:42.702] [DEBUG] debug-file - Since there is no instance or instance is terminated, create a new worker pool. +[2025-05-14T16:09:39.467] [DEBUG] debug-file - no-daemon, use the parent process.execArgv --max-old-space-size=8192,--expose-gc +[2025-05-14T16:09:42.712] [DEBUG] debug-file - Current worker pool is stopped or closed. +[2025-05-14T16:09:42.423] [DEBUG] debug-file - End initialize project's product build option map with build mode 'debug'. +[2025-05-14T16:09:42.539] [DEBUG] debug-file - hvigorfile, resolve finished C:\Users\fy\Desktop\noproject\BestPracticeSnippets\animation\hvigorfile.ts +[2025-05-14T16:09:42.590] [DEBUG] debug-file - Module 'entry' target 'default' build option: { + "debuggable": true, + "copyFrom": "default", + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + }, + "name": "debug" +} +[2025-05-14T16:09:42.612] [DEBUG] debug-file - Start to initialize dependency information. +[2025-05-14T16:09:42.600] [DEBUG] debug-file - hvigorfile, resolve finished C:\Users\fy\Desktop\noproject\BestPracticeSnippets\animation\entry\hvigorfile.ts +[2025-05-14T16:09:42.647] [DEBUG] debug-file - Executing task ::clean +[2025-05-14T16:09:42.702] [DEBUG] debug-file - Worker pool is initialized with config: { + minPoolNum: 2, + maxPoolNum: undefined, + maxCoreSize: undefined, + cacheCapacity: undefined, + cacheTtl: undefined +} +[2025-05-14T16:09:42.712] [DEBUG] debug-file - Clear worker 0. +[2025-05-14T16:09:42.590] [DEBUG] debug-file - Module 'entry' target 'ohosTest' build option: { + "debuggable": true, + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + }, + "name": "default" +} +[2025-05-14T16:09:42.617] [DEBUG] debug-file - Module animation Collected Dependency: +[2025-05-14T16:09:42.647] [DEBUG] debug-file - clean: Worker pool is inactive. +[2025-05-14T16:09:42.712] [DEBUG] debug-file - Worker 0 has been cleared. +[2025-05-14T16:09:42.590] [DEBUG] debug-file - End initialize module-target build option map, moduleName=entry +[2025-05-14T16:09:42.617] [DEBUG] debug-file - Module animation's total dependency: 0 +[2025-05-14T16:09:42.648] [DEBUG] debug-file - animation : clean cost memory 0.03330230712890625 +[2025-05-14T16:09:42.712] [DEBUG] debug-file - Current idle worker size: 1. +[2025-05-14T16:09:42.590] [DEBUG] debug-file - Module 'entry' target 'default' using build option: { + "debuggable": true, + "copyFrom": "default", + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + }, + "name": "debug" +} in this build. +[2025-05-14T16:09:42.619] [DEBUG] debug-file - Start to initialize dependency information. +[2025-05-14T16:09:42.648] [DEBUG] debug-file - runTaskFromQueue task cost before running: 2 s 610 ms +[2025-05-14T16:09:42.712] [DEBUG] debug-file - Current busy worker size: 0. +[2025-05-14T16:09:42.623] [DEBUG] debug-file - Module entry Collected Dependency: +[2025-05-14T16:09:42.648] [INFO] debug-file - Finished ::clean... after 1 ms +[2025-05-14T16:09:42.712] [DEBUG] debug-file - Clear worker 1. +[2025-05-14T16:09:42.623] [DEBUG] debug-file - Module entry's total dependency: 0 +[2025-05-14T16:09:42.649] [DEBUG] debug-file - Executing task :entry:init +[2025-05-14T16:09:42.712] [DEBUG] debug-file - Worker 1 has been cleared. +[2025-05-14T16:09:42.712] [DEBUG] debug-file - Current idle worker size: 0. +[2025-05-14T16:09:42.629] [DEBUG] debug-file - Configuration phase cost:2 s 543 ms +[2025-05-14T16:09:42.649] [DEBUG] debug-file - entry : init cost memory 0.01021575927734375 +[2025-05-14T16:09:42.712] [DEBUG] debug-file - Current busy worker size: 0. +[2025-05-14T16:09:42.649] [DEBUG] debug-file - runTaskFromQueue task cost before running: 2 s 610 ms +[2025-05-14T16:09:42.714] [DEBUG] debug-file - hvigor build process will be closed. +[2025-05-14T16:09:42.649] [INFO] debug-file - Finished :entry:init... after 1 ms +[2025-05-14T16:09:42.720] [DEBUG] debug-file - worker[0] exits with exit code 0. +[2025-05-14T16:09:42.649] [DEBUG] debug-file - Executing task ::init +[2025-05-14T16:09:42.725] [DEBUG] debug-file - worker[1] exits with exit code 0. +[2025-05-14T16:09:42.649] [DEBUG] debug-file - animation : init cost memory 0.00897216796875 +[2025-05-14T16:09:42.726] [DEBUG] debug-file - Current worker pool is terminated. +[2025-05-14T16:09:42.649] [DEBUG] debug-file - runTaskFromQueue task cost before running: 2 s 611 ms +[2025-05-14T16:09:42.649] [INFO] debug-file - Finished ::init... after 1 ms diff --git a/animation/.hvigor/outputs/sync/fileCache.json b/animation/.hvigor/outputs/sync/fileCache.json new file mode 100644 index 0000000000000000000000000000000000000000..4808c3eaab8f234afc7952953ceec2cd3368db9f --- /dev/null +++ b/animation/.hvigor/outputs/sync/fileCache.json @@ -0,0 +1 @@ +{"CACHE_SYNC_FILE_HASH":{"C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\animation\\hvigor\\hvigor-config.json5":"e009c3e201887d5ff58922c9bca69f856521fdaedafd57bc145de6902f716f4f","C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\animation\\build-profile.json5":"eee615171f4e7512acd9accee9ac4a97161415b98f13ad8b01844894df100408","C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\animation\\hvigorfile.ts":"a2eed1714e57c09354a399245457c72417fc985659f20acf3dac697d92dedbe0","C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\animation\\oh-package.json5":"5cc9339e8b272a4b1cd2a427341724e076c4fd291ed4af7d516f134b99620685","C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\animation\\entry\\build-profile.json5":"8e9d18f03982155d6089df3dbe9926a8664a1756d5b4b05949c7dd01ca065695","C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\animation\\entry\\hvigorfile.ts":"47a33472c33b4c8d38bdac2f3b18b3b7e8d34f60677bd5d5ecf14b49fecc1117","C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\animation\\entry\\oh-package.json5":"79f0a85349331763382c95ae7267af8e5aefff06a36554bd04d407be5b4c24ea","C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\animation\\.hvigor\\outputs\\sync\\output.json":"ecc8be5aa1e7442a0818961a397e5fd1b40c75a5ca79f7008483bc282bb130f6","SDK_LOCATION":"C:/Program Files/Huawei/DevEco Studio/sdk"}} \ No newline at end of file diff --git a/animation/.hvigor/outputs/sync/output.json b/animation/.hvigor/outputs/sync/output.json new file mode 100644 index 0000000000000000000000000000000000000000..14b28cf961e7b324d82877aca4dc1dee43cc157a --- /dev/null +++ b/animation/.hvigor/outputs/sync/output.json @@ -0,0 +1,174 @@ +{ + "ohos-module-entry": { + "SELECT_TARGET": "default", + "MODULE_BUILD_DIR": "C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\animation\\entry\\build", + "DEPENDENCY_INFO": {}, + "TARGETS": { + "default": { + "SOURCE_ROOT": "C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\animation\\entry\\src\\main", + "RESOURCES_PATH": [ + "C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\animation\\entry\\src\\main\\resources" + ], + "BUILD_PATH": { + "OUTPUT_PATH": "C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\animation\\entry\\build\\default\\outputs\\default", + "INTERMEDIA_PATH": "C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\animation\\entry\\build\\default\\intermediates", + "JS_ASSETS_PATH": "C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\animation\\entry\\build\\default\\intermediates\\loader_out\\default", + "JS_LITE_ASSETS_PATH": "C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\animation\\entry\\build\\default\\intermediates\\loader_out_lite\\default", + "RES_PATH": "C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\animation\\entry\\build\\default\\intermediates\\res\\default", + "RES_PROFILE_PATH": "C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\animation\\entry\\build\\default\\intermediates\\res\\default\\resources\\base\\profile", + "ETS_SUPER_VISUAL_PATH": "C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\animation\\entry\\build\\default\\cache\\default\\default@CompileArkTS\\esmodule", + "JS_SUPER_VISUAL_PATH": "C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\animation\\entry\\build\\default\\cache\\default\\default@CompileJS\\jsbundle", + "WORKER_LOADER": "C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\animation\\entry\\build\\default\\intermediates\\loader\\default\\loader.json", + "MANIFEST_JSON": "C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\animation\\entry\\build\\default\\intermediates\\manifest\\default", + "OUTPUT_METADATA_JSON": "C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\animation\\entry\\build\\default\\intermediates\\hap_metadata\\default\\output_metadata.json", + "SOURCE_MAP_DIR": "C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\animation\\entry\\build\\default\\intermediates\\source_map\\default" + }, + "BUILD_OPTION": { + "debuggable": true + } + }, + "ohosTest": { + "SOURCE_ROOT": "C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\animation\\entry\\src\\ohosTest", + "RESOURCES_PATH": [ + "C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\animation\\entry\\src\\ohosTest\\resources" + ], + "BUILD_PATH": { + "OUTPUT_PATH": "C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\animation\\entry\\build\\default\\outputs\\ohosTest", + "INTERMEDIA_PATH": "C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\animation\\entry\\build\\default\\intermediates", + "JS_ASSETS_PATH": "C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\animation\\entry\\build\\default\\intermediates\\loader_out\\ohosTest", + "JS_LITE_ASSETS_PATH": "C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\animation\\entry\\build\\default\\intermediates\\loader_out_lite\\ohosTest", + "RES_PATH": "C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\animation\\entry\\build\\default\\intermediates\\res\\ohosTest", + "RES_PROFILE_PATH": "C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\animation\\entry\\build\\default\\intermediates\\res\\ohosTest\\resources\\base\\profile", + "ETS_SUPER_VISUAL_PATH": "C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\animation\\entry\\build\\default\\cache\\ohosTest\\ohosTest@OhosTestCompileArkTS\\esmodule", + "JS_SUPER_VISUAL_PATH": "C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\animation\\entry\\build\\default\\cache\\ohosTest\\ohosTest@OhosTestCompileJS\\jsbundle", + "WORKER_LOADER": "C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\animation\\entry\\build\\default\\intermediates\\loader\\ohosTest\\loader.json", + "MANIFEST_JSON": "C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\animation\\entry\\build\\default\\intermediates\\manifest\\ohosTest", + "OUTPUT_METADATA_JSON": "C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\animation\\entry\\build\\default\\intermediates\\hap_metadata\\ohosTest\\output_metadata.json", + "SOURCE_MAP_DIR": "C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\animation\\entry\\build\\default\\intermediates\\source_map\\ohosTest" + }, + "BUILD_OPTION": { + "debuggable": true + } + } + }, + "BUILD_OPTION": { + "default-default": { + "debuggable": true, + "copyFrom": "default", + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + }, + "name": "debug" + } + }, + "BUILD_PROFILE_OPT": { + "apiType": "stageMode", + "buildOption": {}, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + { + "name": "default" + }, + { + "name": "debug" + } + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest" + } + ] + }, + "BUILD_CACHE_DIR": "" + }, + "ohos-project": { + "SELECT_PRODUCT_NAME": "default", + "MODULE_BUILD_DIR": "C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\animation\\build", + "BUNDLE_NAME": "com.example.animation", + "BUILD_PATH": { + "OUTPUT_PATH": "C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\animation\\build\\outputs\\default" + }, + "MODULES": [ + { + "name": "entry", + "srcPath": "C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\animation\\entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ], + "belongProjectPath": "C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\animation" + } + ], + "PROFILE_OPT": { + "app": { + "signingConfigs": [], + "products": [ + { + "name": "default", + "signingConfig": "default", + "compatibleSdkVersion": "5.0.0(12)", + "runtimeOS": "HarmonyOS", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug" + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] + }, + "CONFIG_PROPERTIES": { + "enableSignTask": true, + "skipNativeIncremental": false, + "hvigor.keepDependency": true + }, + "OVERALL_PROJECT_PATHS": [ + "C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\animation" + ], + "BUILD_CACHE_DIR": "" + }, + "version": 1 +} \ No newline at end of file diff --git a/animation/.idea/.deveco/module/entry.cache.json b/animation/.idea/.deveco/module/entry.cache.json new file mode 100644 index 0000000000000000000000000000000000000000..ca593aa946a46802fcc3b9d530f593d8fceacd62 --- /dev/null +++ b/animation/.idea/.deveco/module/entry.cache.json @@ -0,0 +1,22 @@ +{ + "CommonInfo":{ + "current.select.target":"default" + }, + "BuildOptions":{ + "SELECT_BUILD_TARGET":"default", + "BUILD_PATH":{ + "OUTPUT_METADATA_JSON":"C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\animation\\entry\\build\\default\\intermediates\\hap_metadata\\default\\output_metadata.json", + "OUTPUT_PATH":"C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\animation\\entry\\build\\default\\outputs\\default", + "RES_PATH":"C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\animation\\entry\\build\\default\\intermediates\\res\\default", + "ETS_SUPER_VISUAL_PATH":"C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\animation\\entry\\build\\default\\cache\\default\\default@CompileArkTS\\esmodule", + "JS_ASSETS_PATH":"C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\animation\\entry\\build\\default\\intermediates\\loader_out\\default", + "SOURCE_MAP_DIR":"C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\animation\\entry\\build\\default\\intermediates\\source_map\\default", + "INTERMEDIA_PATH":"C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\animation\\entry\\build\\default\\intermediates", + "RES_PROFILE_PATH":"C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\animation\\entry\\build\\default\\intermediates\\res\\default\\resources\\base\\profile", + "WORKER_LOADER":"C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\animation\\entry\\build\\default\\intermediates\\loader\\default\\loader.json", + "MANIFEST_JSON":"C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\animation\\entry\\build\\default\\intermediates\\manifest\\default", + "JS_LITE_ASSETS_PATH":"C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\animation\\entry\\build\\default\\intermediates\\loader_out_lite\\default", + "JS_SUPER_VISUAL_PATH":"C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\animation\\entry\\build\\default\\cache\\default\\default@CompileJS\\jsbundle" + } + } +} \ No newline at end of file diff --git a/animation/.idea/.deveco/project.cache.json b/animation/.idea/.deveco/project.cache.json new file mode 100644 index 0000000000000000000000000000000000000000..889c855c8f85eae2d637711584b3b9f4662782c4 --- /dev/null +++ b/animation/.idea/.deveco/project.cache.json @@ -0,0 +1,16 @@ +{ + "CommonInfo":{ + "project.ide.version":"5.0.11.100", + "current.select.product":"default", + "current.select.buildMode":"", + "crossplatform.projectType":"" + }, + "BuildOptions":{ + "SELECT_BUILD_PRODUCT":"default", + "BUNDLE_NAME":"com.example.animation", + "BUILD_PATH":{ + "OUTPUT_PATH":"C:\\Users\\fy\\Desktop\\noproject\\BestPracticeSnippets\\animation\\build\\outputs\\default" + }, + "SELECT_BUILD_MODE":"" + } +} \ No newline at end of file diff --git a/animation/.idea/.gitignore b/animation/.idea/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..359bb5307e8535ab7d59faf27a7377033291821e --- /dev/null +++ b/animation/.idea/.gitignore @@ -0,0 +1,3 @@ +# 默认忽略的文件 +/shelf/ +/workspace.xml diff --git a/animation/.idea/modules.xml b/animation/.idea/modules.xml new file mode 100644 index 0000000000000000000000000000000000000000..11f57feea8f8052d3ae946815edb53c0ec30f355 --- /dev/null +++ b/animation/.idea/modules.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/animation/.idea/modules/animation.iml b/animation/.idea/modules/animation.iml new file mode 100644 index 0000000000000000000000000000000000000000..c0be1d7c491147540d199ce55f0721012b7ff7b5 --- /dev/null +++ b/animation/.idea/modules/animation.iml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/animation/.idea/modules/entry/entry.iml b/animation/.idea/modules/entry/entry.iml new file mode 100644 index 0000000000000000000000000000000000000000..b630fe7f2a024b997f55fc5a52dea6c90a18c45d --- /dev/null +++ b/animation/.idea/modules/entry/entry.iml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/animation/.idea/vcs.xml b/animation/.idea/vcs.xml new file mode 100644 index 0000000000000000000000000000000000000000..6c0b8635858dc7ad44b93df54b762707ce49eefc --- /dev/null +++ b/animation/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/animation/AppScope/app.json5 b/animation/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..cb06f6a228fc0a083d3cf6e40774d61449e465f0 --- /dev/null +++ b/animation/AppScope/app.json5 @@ -0,0 +1,10 @@ +{ + "app": { + "bundleName": "com.example.animation", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/animation/AppScope/resources/base/element/string.json b/animation/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..b86e4d568762b2d514c1bf734000d12e6a04e9d1 --- /dev/null +++ b/animation/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "animation" + } + ] +} diff --git a/animation/AppScope/resources/base/media/app_icon.png b/animation/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..a39445dc87828b76fed6d2ec470dd455c45319e3 Binary files /dev/null and b/animation/AppScope/resources/base/media/app_icon.png differ diff --git a/animation/build-profile.json5 b/animation/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..ed2b75e17797558b7d6146c8745dc6bb1b25d2ba --- /dev/null +++ b/animation/build-profile.json5 @@ -0,0 +1,42 @@ +{ + "app": { + "signingConfigs": [ + ], + "products": [ + { + "name": "default", + "signingConfig": "default", + "compatibleSdkVersion": "5.0.0(12)", + "runtimeOS": "HarmonyOS", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/animation/code-linter.json5 b/animation/code-linter.json5 new file mode 100644 index 0000000000000000000000000000000000000000..5e042bfba88bf05d37c0c56807925ee1a28eac6e --- /dev/null +++ b/animation/code-linter.json5 @@ -0,0 +1,37 @@ +{ + "files": [ + "**/*.ets" + ], + "ignore": [ + "**/src/ohosTest/**/*", + "**/src/test/**/*", + "**/src/mock/**/*", + "**/node_modules/**/*", + "**/oh_modules/**/*", + "**/build/**/*", + "**/.preview/**/*" + ], + "ruleSet": [ + "plugin:@performance/recommended", + "plugin:@typescript-eslint/recommended" + ], + "rules": { + "@security/no-unsafe-js-mac": "warn", + "@security/no-unsafe-js-sha1": "warn", + "@security/no-unsafe-js-md5": "warn", + "@security/no-unsafe-aes": "error", + "@security/no-unsafe-hash": "error", + "@security/no-unsafe-mac": "error", + "@security/no-unsafe-dh": "error", + "@security/no-unsafe-dsa": "error", + "@security/no-unsafe-ecdsa": "error", + "@security/no-unsafe-rsa-encrypt": "error", + "@security/no-unsafe-rsa-sign": "error", + "@security/no-unsafe-rsa-key": "error", + "@security/no-unsafe-dsa-key": "error", + "@security/no-unsafe-dh-key": "error", + "@security/no-unsafe-rsa": "error", + "@security/no-unsafe-sha224": "error", + "@security/no-unsafe-3des": "error" + } +} \ No newline at end of file diff --git a/animation/entry/build-profile.json5 b/animation/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..4d611879c7913fb0610c686e2399258ab3a6dad1 --- /dev/null +++ b/animation/entry/build-profile.json5 @@ -0,0 +1,28 @@ +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/animation/entry/hvigorfile.ts b/animation/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..c6edcd90486dd5a853cf7d34c8647f08414ca7a3 --- /dev/null +++ b/animation/entry/hvigorfile.ts @@ -0,0 +1,6 @@ +import { hapTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/animation/entry/obfuscation-rules.txt b/animation/entry/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/animation/entry/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/animation/entry/oh-package.json5 b/animation/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..248c3b7541a589682a250f86a6d3ecf7414d2d6a --- /dev/null +++ b/animation/entry/oh-package.json5 @@ -0,0 +1,10 @@ +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/animation/entry/src/main/ets/entryability/EntryAbility.ets b/animation/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..508880af8c33aa838016d1cd4b2c68be2f447540 --- /dev/null +++ b/animation/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,44 @@ +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +const DOMAIN = 0x0000; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(DOMAIN, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err)); + return; + } + hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onBackground'); + } +} \ No newline at end of file diff --git a/animation/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/animation/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..8e4de99282050bad799ac892eb85ac5449364a51 --- /dev/null +++ b/animation/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -0,0 +1,16 @@ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit'; + +const DOMAIN = 0x0000; + +export default class EntryBackupAbility extends BackupExtensionAbility { + async onBackup() { + hilog.info(DOMAIN, 'testTag', 'onBackup ok'); + await Promise.resolve(); + } + + async onRestore(bundleVersion: BundleVersion) { + hilog.info(DOMAIN, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion)); + await Promise.resolve(); + } +} \ No newline at end of file diff --git a/animation/entry/src/main/ets/pages/CustomAnimation.ets b/animation/entry/src/main/ets/pages/CustomAnimation.ets new file mode 100644 index 0000000000000000000000000000000000000000..9c90f2bc6d0189fdf46df0dae175bc8d88c385f8 --- /dev/null +++ b/animation/entry/src/main/ets/pages/CustomAnimation.ets @@ -0,0 +1,172 @@ +// [Start custom_animation] +@Component +export struct CustomAnimation { + @State widthSize: number = 80 + @State heightSize: number = 40 + @State flag: boolean = true + + // Custom animation function + computeSize() { + let duration = 2000 + // Set the loop cycle + let period = 1 + let widthSizeEnd = 0 + let heightSizeEnd = 0 + if (this.flag) { + widthSizeEnd = 50 + heightSizeEnd = 25 + } else { + widthSizeEnd = 80 + heightSizeEnd = 40 + } + // Calculate loop count + let doTimes = duration / period + // Calculate the variation per cycle + let deltaHeight = (heightSizeEnd - this.heightSize) / doTimes + let deltaWeight = (widthSizeEnd - this.widthSize) / doTimes + // Loop, with each cycle the component increases in width and height by a portion. + for (let i = 1; i <= doTimes; i++) { + let t = period * (i); + setTimeout(() => { + this.heightSize = this.heightSize + deltaHeight + this.widthSize = this.widthSize + deltaWeight + }, t) + } + this.flag = !this.flag + } + + build() { + Column() { + Column() { + Row() { + Button() + .width(this.widthSize) + .height(this.heightSize) + .margin(20) + Button() + .width(this.widthSize) + .height(this.heightSize) + .margin(20) + Button() + .width(this.widthSize) + .height(this.heightSize) + .margin(20) + } + // [StartExclude custom_animation] + Row() { + Button() + .width(this.widthSize) + .height(this.heightSize) + .margin(20) + Button() + .width(this.widthSize) + .height(this.heightSize) + .margin(20) + Button() + .width(this.widthSize) + .height(this.heightSize) + .margin(20) + } + + Row() { + Button() + .width(this.widthSize) + .height(this.heightSize) + .margin(20) + Button() + .width(this.widthSize) + .height(this.heightSize) + .margin(20) + Button() + .width(this.widthSize) + .height(this.heightSize) + .margin(20) + } + + Row() { + Button() + .width(this.widthSize) + .height(this.heightSize) + .margin(20) + Button() + .width(this.widthSize) + .height(this.heightSize) + .margin(20) + Button() + .width(this.widthSize) + .height(this.heightSize) + .margin(20) + } + + Row() { + Button() + .width(this.widthSize) + .height(this.heightSize) + .margin(20) + Button() + .width(this.widthSize) + .height(this.heightSize) + .margin(20) + Button() + .width(this.widthSize) + .height(this.heightSize) + .margin(20) + } + + Row() { + Button() + .width(this.widthSize) + .height(this.heightSize) + .margin(20) + Button() + .width(this.widthSize) + .height(this.heightSize) + .margin(20) + Button() + .width(this.widthSize) + .height(this.heightSize) + .margin(20) + } + + Row() { + Button() + .width(this.widthSize) + .height(this.heightSize) + .margin(20) + Button() + .width(this.widthSize) + .height(this.heightSize) + .margin(20) + Button() + .width(this.widthSize) + .height(this.heightSize) + .margin(20) + } + // [EndExclude custom_animation] + } + .height('85%') + + Column() { + Button('Tap me') + .width('100%') + .onClick(() => { + setTimeout(() => { + this.computeSize() + }, 500) + }) + } + .justifyContent(FlexAlign.End) + .width('100%') + .height('15%') + } + .padding({ + left: 16, + right: 16, + bottom: 16 + }) + .width('100%') + .height('100%') + .justifyContent(FlexAlign.Start) + } +} +// [End custom_animation] \ No newline at end of file diff --git a/animation/entry/src/main/ets/pages/ExplicitAnimateTo.ets b/animation/entry/src/main/ets/pages/ExplicitAnimateTo.ets new file mode 100644 index 0000000000000000000000000000000000000000..6d96829492338e5d798eea514196821fd0885785 --- /dev/null +++ b/animation/entry/src/main/ets/pages/ExplicitAnimateTo.ets @@ -0,0 +1,166 @@ +// [Start explicit_animate_to] +@Component +export struct ExplicitAnimateTo { + @State widthSize: number = 80; + @State heightSize: number = 40; + @State flag: boolean = true; + + build() { + Column() { + Column() { + Row() { + Button() + .width(this.widthSize) + .height(this.heightSize) + .margin(20) + // [StartExclude explicit_animate_to] + Button() + .width(this.widthSize) + .height(this.heightSize) + .margin(20) + Button() + .width(this.widthSize) + .height(this.heightSize) + .margin(20) + // [EndExclude explicit_animate_to] + } + + // [StartExclude explicit_animate_to] + Row() { + Button() + .width(this.widthSize) + .height(this.heightSize) + .margin(20) + Button() + .width(this.widthSize) + .height(this.heightSize) + .margin(20) + Button() + .width(this.widthSize) + .height(this.heightSize) + .margin(20) + } + + Row() { + Button() + .width(this.widthSize) + .height(this.heightSize) + .margin(20) + Button() + .width(this.widthSize) + .height(this.heightSize) + .margin(20) + Button() + .width(this.widthSize) + .height(this.heightSize) + .margin(20) + } + + Row() { + Button() + .width(this.widthSize) + .height(this.heightSize) + .margin(20) + Button() + .width(this.widthSize) + .height(this.heightSize) + .margin(20) + Button() + .width(this.widthSize) + .height(this.heightSize) + .margin(20) + } + + Row() { + Button() + .width(this.widthSize) + .height(this.heightSize) + .margin(20) + Button() + .width(this.widthSize) + .height(this.heightSize) + .margin(20) + Button() + .width(this.widthSize) + .height(this.heightSize) + .margin(20) + } + + Row() { + Button() + .width(this.widthSize) + .height(this.heightSize) + .margin(20) + Button() + .width(this.widthSize) + .height(this.heightSize) + .margin(20) + Button() + .width(this.widthSize) + .height(this.heightSize) + .margin(20) + } + + Row() { + Button() + .width(this.widthSize) + .height(this.heightSize) + .margin(20) + Button() + .width(this.widthSize) + .height(this.heightSize) + .margin(20) + Button() + .width(this.widthSize) + .height(this.heightSize) + .margin(20) + } + + // [EndExclude explicit_animate_to] + } + .height('85%') + + Column() { + Button('Tap me') + .width('100%') + .onClick((event?: ClickEvent | undefined) => { + // Animate the width and height properties of the Button component + if (this.flag) { + animateTo({ + duration: 2000, + curve: Curve.Linear, + delay: 500, + iterations: 1, + playMode: PlayMode.Normal + }, () => { + this.widthSize = 50; + this.heightSize = 25; + }) + } else { + animateTo({ + duration: 2000, + curve: Curve.Linear, + delay: 500, + iterations: 1, + playMode: PlayMode.Normal + }, () => { + this.widthSize = 80; + this.heightSize = 40; + }) + } + this.flag = !this.flag; + }) + } + .height('15%') + } + .padding({ + left: 16, + right: 16, + bottom: 16 + }) + .width('100%') + .height('100%') + .justifyContent(FlexAlign.Start) + } +} +// [End explicit_animate_to] \ No newline at end of file diff --git a/animation/entry/src/main/ets/pages/IconItem.ets b/animation/entry/src/main/ets/pages/IconItem.ets new file mode 100644 index 0000000000000000000000000000000000000000..51fa9c31e7fce2f4703ca2a3aa65580155d66314 --- /dev/null +++ b/animation/entry/src/main/ets/pages/IconItem.ets @@ -0,0 +1,36 @@ +// [Start icon_item] +@Component +export struct IconItem { + @StorageLink('renderGroupFlag') renderGroupFlag: boolean = false; + image: string | Resource = ''; + text: string | Resource = ''; + + build() { + Flex({ + direction: FlexDirection.Column, + justifyContent: FlexAlign.Center, + alignContent: FlexAlign.Center + }) { + Image(this.image) + .height(20) + .width(20) + .objectFit(ImageFit.Contain) + .margin({ left: 15 }) + + Text(this.text) + .fontSize(10) + .fontColor('#182431') + .margin({ top: 5 }) + .width(50) + .opacity(0.8) + .textAlign(TextAlign.Center) + } + .backgroundColor('#e3e3e3') + .width(50) + .height(50) + .borderRadius(25) + // Call renderGroup within IconItem, false to disable, true to enable. + .renderGroup(this.renderGroupFlag) + } +} +// [End icon_item] \ No newline at end of file diff --git a/animation/entry/src/main/ets/pages/ImageAnimation.ets b/animation/entry/src/main/ets/pages/ImageAnimation.ets new file mode 100644 index 0000000000000000000000000000000000000000..7e8027baba2888cef23caa27d09464fed6a77db9 --- /dev/null +++ b/animation/entry/src/main/ets/pages/ImageAnimation.ets @@ -0,0 +1,232 @@ +// [Start image_animation] +// [Start change_animation] +@Component +export struct ImageAnimation { + @State imageWidth: number = 60; + @State imageHeight: number = 60; + @State xPosition: number = 0; + @State yPosition: number = 0; + @State imageScaleX: number = 1; + @State imageScaleY: number = 1; + @State imageTranslateX: number = 0; + @State imageTranslateY: number = 0; + + build() { + Column() { + Row() { + Row() { + Image($r('app.media.startIcon')) + .width(this.imageWidth) + .height(this.imageHeight) + .position({ x: this.xPosition, y: this.yPosition }) + .scale({ + x: this.imageScaleX, + y: this.imageScaleY, + centerX: 0, + centerY: 0 + }) + .translate({ x: this.imageTranslateX, y: this.imageTranslateY }) + }.width('33%') + // [StartExclude image_animation] + // [StartExclude change_animation] + Row() { + Image($r('app.media.startIcon')) + .width(this.imageWidth) + .height(this.imageHeight) + .position({ x: this.xPosition, y: this.yPosition }) + .scale({ + x: this.imageScaleX, + y: this.imageScaleY, + centerX: 0, + centerY: 0 + }) + .translate({ x: this.imageTranslateX, y: this.imageTranslateY }) + }.width('33%') + + Row() { + Image($r('app.media.startIcon')) + .width(this.imageWidth) + .height(this.imageHeight) + .position({ x: this.xPosition, y: this.yPosition }) + .scale({ + x: this.imageScaleX, + y: this.imageScaleY, + centerX: 0, + centerY: 0 + }) + .translate({ x: this.imageTranslateX, y: this.imageTranslateY }) + }.width('33%') + // [EndExclude image_animation] + // [EndExclude change_animation] + } + .height('25%') + // [StartExclude image_animation] + // [StartExclude change_animation] + Row() { + Row() { + Image($r('app.media.startIcon')) + .width(this.imageWidth) + .height(this.imageHeight) + .position({ x: this.xPosition, y: this.yPosition }) + .scale({ + x: this.imageScaleX, + y: this.imageScaleY, + centerX: 0, + centerY: 0 + }) + .translate({ x: this.imageTranslateX, y: this.imageTranslateY }) + }.width('33%') + + Row() { + Image($r('app.media.startIcon')) + .width(this.imageWidth) + .height(this.imageHeight) + .position({ x: this.xPosition, y: this.yPosition }) + .scale({ + x: this.imageScaleX, + y: this.imageScaleY, + centerX: 0, + centerY: 0 + }) + .translate({ x: this.imageTranslateX, y: this.imageTranslateY }) + }.width('33%') + + Row() { + Image($r('app.media.startIcon')) + .width(this.imageWidth) + .height(this.imageHeight) + .position({ x: this.xPosition, y: this.yPosition }) + .scale({ + x: this.imageScaleX, + y: this.imageScaleY, + centerX: 0, + centerY: 0 + }) + .translate({ x: this.imageTranslateX, y: this.imageTranslateY }) + }.width('33%') + } + .height('25%') + + Row() { + Row() { + Image($r('app.media.startIcon')) + .width(this.imageWidth) + .height(this.imageHeight) + .position({ x: this.xPosition, y: this.yPosition }) + .scale({ + x: this.imageScaleX, + y: this.imageScaleY, + centerX: 0, + centerY: 0 + }) + .translate({ x: this.imageTranslateX, y: this.imageTranslateY }) + }.width('33%') + + Row() { + Image($r('app.media.startIcon')) + .width(this.imageWidth) + .height(this.imageHeight) + .position({ x: this.xPosition, y: this.yPosition }) + .scale({ + x: this.imageScaleX, + y: this.imageScaleY, + centerX: 0, + centerY: 0 + }) + .translate({ x: this.imageTranslateX, y: this.imageTranslateY }) + }.width('33%') + + Row() { + Image($r('app.media.startIcon')) + .width(this.imageWidth) + .height(this.imageHeight) + .position({ x: this.xPosition, y: this.yPosition }) + .scale({ + x: this.imageScaleX, + y: this.imageScaleY, + centerX: 0, + centerY: 0 + }) + .translate({ x: this.imageTranslateX, y: this.imageTranslateY }) + }.width('33%') + // [EndExclude change_animation] + // [EndExclude image_animation] + } + .height('25%') + + Column() { + // [StartExclude change_animation] + Button('Change Layout Properties') + .width('100%') + // Key Attribute Settings + .onClick(() => { + // Loop animation by play count + for (let i = 0; i < 10; i++) { + // Interval playback position, width and height changes + if (i % 2 == 0) { + setTimeout(() => { + animateTo({ duration: 1000 }, () => { + this.imageWidth = 100; + this.imageHeight = 100; + this.xPosition = 12; + this.yPosition = 12; + }) + }, 1000 * i) + } else { + setTimeout(() => { + animateTo({ duration: 1000 }, () => { + this.imageWidth = 60; + this.imageHeight = 60; + this.xPosition = 0; + this.yPosition = 0; + }) + }, 1000 * i) + } + } + }) + // [EndExclude change_animation] + // [StartExclude image_animation] + Button('Change Image Properties') + .width('100%') + .margin({ top: 12 }) + .onClick(() => { + // Loop animation by play count + for (let i = 0; i < 10; i++) { + if (i % 2 == 0) { + setTimeout(() => { + animateTo({ duration: 1000 }, () => { + this.imageScaleX = 2; + this.imageScaleY = 2; + this.imageTranslateX = 12; + this.imageTranslateY = 12; + }) + }, 1000 * i) + } else { + setTimeout(() => { + animateTo({ duration: 1000 }, () => { + this.imageScaleX = 1; + this.imageScaleY = 1; + this.imageTranslateX = 0; + this.imageTranslateY = 0; + }) + }, 1000 * i) + } + } + }) + // [EndExclude image_animation] + } + .justifyContent(FlexAlign.End) + .height('25%') + } + .padding({ + left: 16, + right: 16, + bottom: 16 + }) + .width('100%') + .height('100%') + .justifyContent(FlexAlign.Start) + } +} +// [End image_animation] +// [End change_animation] \ No newline at end of file diff --git a/animation/entry/src/main/ets/pages/Index.ets b/animation/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..8d5ce7893a15268c924b355d59368997fc62f9f3 --- /dev/null +++ b/animation/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,104 @@ +import { CustomAnimation } from './CustomAnimation'; +import { PropertyAnimateTo } from './PropertyAnimateTo'; +import { ExplicitAnimateTo } from './ExplicitAnimateTo'; +import { ImageAnimation } from './ImageAnimation'; +import { MultipleProperties } from './MultipleProperties'; +import { UpdateMultipleProperties } from './UpdateMultipleProperties'; +import { RenderGroup } from './RenderGroup'; + +@Entry +@Component +struct Index { + @Provide('NavPathStack') pageStack: NavPathStack = new NavPathStack(); + + @Builder + PagesMap(name: string) { + NavDestination() { + if (name === 'CustomAnimation') { + CustomAnimation() + } else if (name === 'PropertyAnimateTo') { + PropertyAnimateTo() + } else if (name === 'ExplicitAnimateTo') { + ExplicitAnimateTo() + } else if (name === 'ImageAnimation') { + ImageAnimation() + } else if (name === 'MultipleProperties') { + MultipleProperties() + } else if (name === 'UpdateMultipleProperties') { + UpdateMultipleProperties() + } else if (name === 'RenderGroup') { + RenderGroup() + } + + } + .hideTitleBar(true) + .backgroundColor('#F1F3F5') + .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM]) + + } + + build() { + Navigation(this.pageStack) { + Column() { + + Blank() + + Button('CustomAnimation') + .width('100%') + .margin({ top: 12 }) + .onClick(() => { + this.pageStack.pushPathByName('CustomAnimation', ''); + }) + Button('PropertyAnimateTo') + .width('100%') + .margin({ top: 12 }) + .onClick(() => { + this.pageStack.pushPathByName('PropertyAnimateTo', ''); + }) + Button('ExplicitAnimateTo') + .width('100%') + .margin({ top: 12 }) + .onClick(() => { + this.pageStack.pushPathByName('ExplicitAnimateTo', ''); + }) + Button('ImageAnimation') + .width('100%') + .margin({ top: 12 }) + .onClick(() => { + this.pageStack.pushPathByName('ImageAnimation', ''); + }) + Button('MultipleProperties') + .width('100%') + .margin({ top: 12 }) + .onClick(() => { + this.pageStack.pushPathByName('MultipleProperties', ''); + }) + Button('UpdateMultipleProperties') + .width('100%') + .margin({ top: 12 }) + .onClick(() => { + this.pageStack.pushPathByName('UpdateMultipleProperties', ''); + }) + Button('RenderGroup') + .width('100%') + .margin({ top: 12 }) + .onClick(() => { + this.pageStack.pushPathByName('RenderGroup', ''); + }) + } + .padding({ + left: 16, + right: 16, + bottom: 16 + }) + .width('100%') + .height('100%') + .justifyContent(FlexAlign.Start) + } + .hideTitleBar(true) + .mode(NavigationMode.Stack) + .backgroundColor('#F1F3F5') + .navDestination(this.PagesMap) + .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM]) + } +} \ No newline at end of file diff --git a/animation/entry/src/main/ets/pages/MultipleProperties.ets b/animation/entry/src/main/ets/pages/MultipleProperties.ets new file mode 100644 index 0000000000000000000000000000000000000000..eaa58890dd625eed28e6eb63b0e28a9e868cffdd --- /dev/null +++ b/animation/entry/src/main/ets/pages/MultipleProperties.ets @@ -0,0 +1,169 @@ +// [Start multiple_properties] +// [Start one_func] +@Component +export struct MultipleProperties { + @State w:number = 150 + @State h:number = 2 + @State brightNum:number = 1.5 + @State color:Color = Color.Red + // [StartExclude one_func] + // Animation closure 1, set width change + func1() { + animateTo({curve: Curve.Sharp, duration: 1000}, () => { + this.w = (this.w === 80 ? 150 : 80); + }); + } + // Animation Closure 2, Set Color Change + func2() { + animateTo({curve: Curve.Sharp, duration: 1000}, () => { + this.color = (this.color === Color.Yellow ? Color.Red : Color.Yellow); + }); + } + // Animation closure 3, set height variation + func3() { + animateTo({curve: Curve.Sharp, duration: 1000}, () => { + this.h = (this.h === 2 ? 5 : 2); + }); + } + // Animation Closure 4, Set Highlight Variation + func4() { + animateTo({curve: Curve.Sharp, duration: 1000}, () => { + this.brightNum= (this.brightNum=== 1.5 ? 1 : 1.5); + }); + } + // [EndExclude one_func] + // [StartExclude multiple_properties] + // Unify animation closures while simultaneously setting changes for four properties + func() { + animateTo({curve: Curve.Sharp, duration: 1000}, () => { + this.w = (this.w === 80 ? 150 : 80); + this.color = (this.color === Color.Yellow ? Color.Red : Color.Yellow); + this.h = (this.h === 2 ? 5 : 2); + this.brightNum= (this.brightNum=== 1.5 ? 1 : 1.5); + }); + } + // [EndExclude multiple_properties] + build() { + Column() { + Row() { + Row() { + Row() + .width(this.w) + .backgroundColor(this.color) + .height(this.h) + .brightness(this.brightNum) + } + .justifyContent(FlexAlign.Center) + .width('50%') + + Row() { + Row() + .width(this.w) + .backgroundColor(this.color) + .height(this.h) + .brightness(this.brightNum) + } + .justifyContent(FlexAlign.Center) + .width('50%') + } + .height('25%') + .width('100%') + // [StartExclude multiple_properties] + // [StartExclude one_func] + Row() { + Row() { + Row() + .width(this.w) + .backgroundColor(this.color) + .height(this.h) + .brightness(this.brightNum) + } + .justifyContent(FlexAlign.Center) + .width('50%') + + Row() { + Row() + .width(this.w) + .backgroundColor(this.color) + .height(this.h) + .brightness(this.brightNum) + } + .justifyContent(FlexAlign.Center) + .width('50%') + } + .height('25%') + .width('100%') + + Row() { + Row() { + Row() + .width(this.w) + .backgroundColor(this.color) + .height(this.h) + .brightness(this.brightNum) + } + .justifyContent(FlexAlign.Center) + .width('50%') + + Row() { + Row() + .width(this.w) + .backgroundColor(this.color) + .height(this.h) + .brightness(this.brightNum) + } + .justifyContent(FlexAlign.Center) + .width('50%') + } + .height('25%') + .width('100%') + // [EndExclude one_func] + // [EndExclude multiple_properties] + + Column() { + // [StartExclude one_func] + Button("Tap nFunc") + .width('100%') + // Key Attribute Settings + .onClick(() => { + // Loop animation by play count + for (let i = 0; i < 10; i++) { + setTimeout(() => { + this.func1(); + this.func2(); + this.func3(); + this.func4(); + }, 1000 * i) + } + }) + // [EndExclude one_func] + // [StartExclude multiple_properties] + Button("Tap oneFunc") + .width('100%') + .margin({ top: 12 }) + // Key Attribute Settings + .onClick(() => { + // Loop animation by play count + for (let i = 0; i < 10; i++) { + setTimeout(() => { + this.func(); + }, 1000 * i) + } + }) + // [EndExclude multiple_properties] + } + .justifyContent(FlexAlign.End) + .height('25%') + } + .padding({ + left: 16, + right: 16, + bottom: 16 + }) + .width('100%') + .height('100%') + .justifyContent(FlexAlign.Start) + } +} +// [End one_func] +// [End multiple_properties] \ No newline at end of file diff --git a/animation/entry/src/main/ets/pages/PropertyAnimateTo.ets b/animation/entry/src/main/ets/pages/PropertyAnimateTo.ets new file mode 100644 index 0000000000000000000000000000000000000000..cd3133e7951ed5ec40d9b286714ec40108591a03 --- /dev/null +++ b/animation/entry/src/main/ets/pages/PropertyAnimateTo.ets @@ -0,0 +1,261 @@ +// [Start property_animate_to] +@Component +export struct PropertyAnimateTo { + @State widthSize: number = 80; + @State heightSize: number = 40; + @State flag: boolean = true; + + build() { + Column() { + Column() { + Row() { + Button() + .width(this.widthSize) + .height(this.heightSize) + .animation({ + duration: 2000, + curve: Curve.Linear, + delay: 500, + iterations: 1, + playMode: PlayMode.Normal + }) + .margin(20) + // [StartExclude property_animate_to] + Button() + .width(this.widthSize) + .height(this.heightSize) + .animation({ + duration: 2000, + curve: Curve.Linear, + delay: 500, + iterations: 1, + playMode: PlayMode.Normal + }) + .margin(20) + Button() + .width(this.widthSize) + .height(this.heightSize) + .animation({ + duration: 2000, + curve: Curve.Linear, + delay: 500, + iterations: 1, + playMode: PlayMode.Normal + }) + .margin(20) + // [EndExclude property_animate_to] + } + + // [StartExclude property_animate_to] + Row() { + Button() + .width(this.widthSize) + .height(this.heightSize) + .animation({ + duration: 2000, + curve: Curve.Linear, + delay: 500, + iterations: 1, + playMode: PlayMode.Normal + }) + .margin(20) + Button() + .width(this.widthSize) + .height(this.heightSize) + .animation({ + duration: 2000, + curve: Curve.Linear, + delay: 500, + iterations: 1, + playMode: PlayMode.Normal + }) + .margin(20) + Button() + .width(this.widthSize) + .height(this.heightSize) + .animation({ + duration: 2000, + curve: Curve.Linear, + delay: 500, + iterations: 1, + playMode: PlayMode.Normal + }) + .margin(20) + } + + Row() { + Button() + .width(this.widthSize) + .height(this.heightSize) + .animation({ + duration: 2000, + curve: Curve.Linear, + delay: 500, + iterations: 1, + playMode: PlayMode.Normal + }) + .margin(20) + Button() + .width(this.widthSize) + .height(this.heightSize) + .animation({ + duration: 2000, + curve: Curve.Linear, + delay: 500, + iterations: 1, + playMode: PlayMode.Normal + }) + .margin(20) + Button() + .width(this.widthSize) + .height(this.heightSize) + .animation({ + duration: 2000, + curve: Curve.Linear, + delay: 500, + iterations: 1, + playMode: PlayMode.Normal + }) + .margin(20) + } + + Row() { + Button() + .width(this.widthSize) + .height(this.heightSize) + .animation({ + duration: 2000, + curve: Curve.Linear, + delay: 500, + iterations: 1, + playMode: PlayMode.Normal + }) + .margin(20) + Button() + .width(this.widthSize) + .height(this.heightSize) + .animation({ + duration: 2000, + curve: Curve.Linear, + delay: 500, + iterations: 1, + playMode: PlayMode.Normal + }) + .margin(20) + Button() + .width(this.widthSize) + .height(this.heightSize) + .animation({ + duration: 2000, + curve: Curve.Linear, + delay: 500, + iterations: 1, + playMode: PlayMode.Normal + }) + .margin(20) + } + + Row() { + Button() + .width(this.widthSize) + .height(this.heightSize) + .animation({ + duration: 2000, + curve: Curve.Linear, + delay: 500, + iterations: 1, + playMode: PlayMode.Normal + }) + .margin(20) + Button() + .width(this.widthSize) + .height(this.heightSize) + .animation({ + duration: 2000, + curve: Curve.Linear, + delay: 500, + iterations: 1, + playMode: PlayMode.Normal + }) + .margin(20) + Button() + .width(this.widthSize) + .height(this.heightSize) + .animation({ + duration: 2000, + curve: Curve.Linear, + delay: 500, + iterations: 1, + playMode: PlayMode.Normal + }) + .margin(20) + } + + Row() { + Button() + .width(this.widthSize) + .height(this.heightSize) + .animation({ + duration: 2000, + curve: Curve.Linear, + delay: 500, + iterations: 1, + playMode: PlayMode.Normal + }) + .margin(20) + Button() + .width(this.widthSize) + .height(this.heightSize) + .animation({ + duration: 2000, + curve: Curve.Linear, + delay: 500, + iterations: 1, + playMode: PlayMode.Normal + }) + .margin(20) + Button() + .width(this.widthSize) + .height(this.heightSize) + .animation({ + duration: 2000, + curve: Curve.Linear, + delay: 500, + iterations: 1, + playMode: PlayMode.Normal + }) + .margin(20) + } + + // [EndExclude property_animate_to] + } + .height('85%') + + Column() { + Button('Tap me') + .width('100%') + .onClick((event?: ClickEvent | undefined) => { + if (this.flag) { + this.widthSize = 50 + this.heightSize = 25 + } else { + this.widthSize = 80 + this.heightSize = 40 + } + this.flag = !this.flag + }) + } + .height('15%') + } + .padding({ + left: 16, + right: 16, + bottom: 16 + }) + .width('100%') + .height('100%') + .justifyContent(FlexAlign.Start) + } +} + +// [End property_animate_to] \ No newline at end of file diff --git a/animation/entry/src/main/ets/pages/RenderGroup.ets b/animation/entry/src/main/ets/pages/RenderGroup.ets new file mode 100644 index 0000000000000000000000000000000000000000..66a05277de1fb6ad67cacdc14565e3a6664811c6 --- /dev/null +++ b/animation/entry/src/main/ets/pages/RenderGroup.ets @@ -0,0 +1,94 @@ +// [Start render_group] +import { IconItem } from './IconItem' + +class IconItemSource { + image: string | Resource = '' + text: string | Resource = '' + + constructor(image: string | Resource = '', text: string | Resource = '') { + this.image = image; + this.text = text; + } +} + +@Component +export struct RenderGroup { + @State renderGroupFlag: boolean = false; + private iconItemSourceList: IconItemSource[] = []; + + aboutToAppear() { + for (let index = 0; index < 20; index++) { + const numStart: number = index * 3; + this.iconItemSourceList.push( + new IconItemSource($r('app.media.app_icon'), `item${numStart + 1}`), + new IconItemSource($r('app.media.app_icon'), `item${numStart + 2}`), + new IconItemSource($r('app.media.app_icon'), `item${numStart + 3}`), + ); + } + } + + build() { + Column() { + Row() { + Row() { + Text('Example') + .fontSize(24) + .lineHeight(24) + .fontColor(Color.Black) + .fontWeight(FontWeight.Bold) + .margin({ left: 30 }) + } + + // Dynamic switching of renderGroup functionality + Stack({ alignContent: Alignment.End }) { + Button(this.renderGroupFlag ? 'renderGroup On' : 'renderGroup Off', { + type: ButtonType.Normal, + stateEffect: true + }) + .fontSize(12) + .borderRadius(8) + .width(150) + .height(30) + .margin({ right: 30 }) + .onClick(() => { + this.renderGroupFlag = !this.renderGroupFlag; + AppStorage.setOrCreate('renderGroupFlag', this.renderGroupFlag) + }) + } + } + .height(56) + .width('100%') + .justifyContent(FlexAlign.SpaceBetween) + + GridRow({ + columns: 6, + gutter: { x: 0, y: 0 }, + breakpoints: { + value: ['400vp', '600vp', '800vp'], + reference: BreakpointsReference.WindowSize + }, + direction: GridRowDirection.Row + }) { + ForEach(this.iconItemSourceList, (item: IconItemSource) => { + GridCol() { + IconItem({ image: item.image, text: item.text }) + .transition( + TransitionEffect.scale({ x: 0.5, y: 0.5 }) + .animation({ duration: 3000, curve: Curve.FastOutSlowIn, iterations: -1 }) + .combine(TransitionEffect.rotate({ z: 1, angle: 360 }) + .animation({ duration: 3000, curve: Curve.Linear, iterations: -1 })) + ) + } + .height(70) + .width('25%') + }) + } + .width('100%') + .height('100%') + } + .width('100%') + .height('100%') + .alignItems(HorizontalAlign.Center) + } +} +// [End render_group] \ No newline at end of file diff --git a/animation/entry/src/main/ets/pages/UpdateMultipleProperties.ets b/animation/entry/src/main/ets/pages/UpdateMultipleProperties.ets new file mode 100644 index 0000000000000000000000000000000000000000..b1dc22514073d9765365766941a6a2cc29441ffe --- /dev/null +++ b/animation/entry/src/main/ets/pages/UpdateMultipleProperties.ets @@ -0,0 +1,169 @@ +// [Start update_multiple_properties1] +// [Start update_multiple_properties2] +// [Start update_multiple_properties3] +@Component +export struct UpdateMultipleProperties { + @State w: number = 100 + @State h: number = 2 + @State color: Color = Color.Red + + build() { + Column() { + Row() { + Row() { + Row() + .width(this.w) + .backgroundColor(this.color) + .height(this.h) + } + .justifyContent(FlexAlign.Center) + .width('50%') + + Row() { + Row() + .width(this.w) + .backgroundColor(this.color) + .height(this.h) + } + .justifyContent(FlexAlign.Center) + .width('50%') + } + .height('25%') + .width('100%') + + // [StartExclude update_multiple_properties1] + // [StartExclude update_multiple_properties2] + // [StartExclude update_multiple_properties3] + Row() { + Row() { + Row() + .width(this.w) + .backgroundColor(this.color) + .height(this.h) + + } + .justifyContent(FlexAlign.Center) + .width('50%') + + Row() { + Row() + .width(this.w) + .backgroundColor(this.color) + .height(this.h) + + } + .justifyContent(FlexAlign.Center) + .width('50%') + } + .height('25%') + .width('100%') + + Row() { + Row() { + Row() + .width(this.w) + .backgroundColor(this.color) + .height(this.h) + + } + .justifyContent(FlexAlign.Center) + .width('50%') + + Row() { + Row() + .width(this.w) + .backgroundColor(this.color) + .height(this.h) + + } + .justifyContent(FlexAlign.Center) + .width('50%') + } + .height('25%') + .width('100%') + // [EndExclude update_multiple_properties3] + // [EndExclude update_multiple_properties2] + // [EndExclude update_multiple_properties1] + Column() { + // [StartExclude update_multiple_properties2] + // [StartExclude update_multiple_properties3] + Button('Tap1') + .width('100%') + .margin({ top: 12 }) + .onClick(() => { + let doTimes = 5; + for (let i = 0; i < doTimes; i++) { + setTimeout(() => { + this.w = 80 + this.h = 4 + animateTo({ curve: Curve.Sharp, duration: 1000 }, () => { + this.w = (this.w === 80 ? 150 : 80); + }); + // Updating state variables between two animateTo calls + this.color = Color.Yellow + animateTo({ curve: Curve.Linear, duration: 2000 }, () => { + this.color = (this.color === Color.Yellow ? Color.Red : Color.Yellow); + }); + }, 2000 * i) + } + }) + // [EndExclude update_multiple_properties2] + // [StartExclude update_multiple_properties1] + Button('Tap2') + .width('100%') + .margin({ top: 12 }) + .onClick(() => { + let doTimes = 5; + for (let i = 0; i < doTimes; i++) { + setTimeout(() => { + // Explicitly specify the initial values of all properties to be animated before the animation. + this.w = 80 + this.color = Color.Yellow + animateTo({ curve: Curve.Sharp, duration: 1000 }, () => { + this.w = (this.w === 80 ? 150 : 80); + }); + animateTo({ curve: Curve.Linear, duration: 2000 }, () => { + this.color = (this.color === Color.Yellow ? Color.Red : Color.Yellow); + }); + // Refresh non-animated properties after animation completes + this.h = 5 + }, 2000 * i) + } + }) + // [StartExclude update_multiple_properties2] + // [StartExclude update_multiple_properties3] + Button('Tap3') + .width('100%') + .margin({ top: 12 }) + .onClick(() => { + let doTimes = 5; + for (let i = 0; i < doTimes; i++) { + setTimeout(() => { + animateTo({ curve: Curve.Sharp, duration: 1000 }, () => { + this.w = (this.w === 80 ? 150 : 80); + }); + animateTo({ curve: Curve.Linear, duration: 2000 }, () => { + this.color = (this.color === Color.Yellow ? Color.Red : Color.Yellow); + }); + }, 2000 * i) + } + }) + // [EndExclude update_multiple_properties2] + // [EndExclude update_multiple_properties1] + } + .justifyContent(FlexAlign.End) + .height('25%') + } + .padding({ + left: 16, + right: 16, + bottom: 16 + }) + .width('100%') + .height('100%') + .justifyContent(FlexAlign.Start) + } +} +// [Start update_multiple_properties1] +// [Start update_multiple_properties2] +// [Start update_multiple_properties3] \ No newline at end of file diff --git a/animation/entry/src/main/module.json5 b/animation/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..ad219d733f6afa5ea07f85f580208b08cc3b9041 --- /dev/null +++ b/animation/entry/src/main/module.json5 @@ -0,0 +1,50 @@ +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "phone" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:layered_image", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "EntryBackupAbility", + "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets", + "type": "backup", + "exported": false, + "metadata": [ + { + "name": "ohos.extension.backup", + "resource": "$profile:backup_config" + } + ], + } + ] + } +} \ No newline at end of file diff --git a/animation/entry/src/main/resources/base/element/color.json b/animation/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/animation/entry/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/animation/entry/src/main/resources/base/element/float.json b/animation/entry/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..33ea22304f9b1485b5f22d811023701b5d4e35b6 --- /dev/null +++ b/animation/entry/src/main/resources/base/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} diff --git a/animation/entry/src/main/resources/base/element/string.json b/animation/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..f94595515a99e0c828807e243494f57f09251930 --- /dev/null +++ b/animation/entry/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/animation/entry/src/main/resources/base/media/background.png b/animation/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/animation/entry/src/main/resources/base/media/background.png differ diff --git a/animation/entry/src/main/resources/base/media/foreground.png b/animation/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/animation/entry/src/main/resources/base/media/foreground.png differ diff --git a/animation/entry/src/main/resources/base/media/layered_image.json b/animation/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/animation/entry/src/main/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/animation/entry/src/main/resources/base/media/startIcon.png b/animation/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/animation/entry/src/main/resources/base/media/startIcon.png differ diff --git a/animation/entry/src/main/resources/base/profile/backup_config.json b/animation/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a --- /dev/null +++ b/animation/entry/src/main/resources/base/profile/backup_config.json @@ -0,0 +1,3 @@ +{ + "allowToBackupRestore": true +} \ No newline at end of file diff --git a/animation/entry/src/main/resources/base/profile/main_pages.json b/animation/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce --- /dev/null +++ b/animation/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/animation/entry/src/main/resources/dark/element/color.json b/animation/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..79b11c2747aec33e710fd3a7b2b3c94dd9965499 --- /dev/null +++ b/animation/entry/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/animation/hvigor/hvigor-config.json5 b/animation/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..fe83c3e838abfb3629eed84f6c7092f306d818f9 --- /dev/null +++ b/animation/hvigor/hvigor-config.json5 @@ -0,0 +1,22 @@ +{ + "modelVersion": "5.0.2", + "dependencies": { + }, + "execution": { + // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */ + // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */ + // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */ + // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */ + // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */ + }, + "logging": { + // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ + }, + "debugging": { + // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */ + }, + "nodeOptions": { + // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/ + // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/ + } +} diff --git a/animation/hvigorfile.ts b/animation/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..f3cb9f1a87a81687554a76283af8df27d8bda775 --- /dev/null +++ b/animation/hvigorfile.ts @@ -0,0 +1,6 @@ +import { appTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/animation/oh-package.json5 b/animation/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..55a89782654b6f1883138381d8963a81c671baff --- /dev/null +++ b/animation/oh-package.json5 @@ -0,0 +1,10 @@ +{ + "modelVersion": "5.0.2", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.21", + "@ohos/hamock": "1.0.1-rc2" + } +}