-
Notifications
You must be signed in to change notification settings - Fork 461
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for OHOS interfaces #2408
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/node_modules | ||
/oh_modules | ||
/local.properties | ||
/.idea | ||
**/build | ||
/.hvigor | ||
.cxx | ||
/.clangd | ||
/.clang-format | ||
/.clang-tidy | ||
**/.test | ||
/.appanalyzer |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"app": { | ||
"bundleName": "org.libpag.PAGViewer", | ||
"vendor": "example", | ||
"versionCode": 1000000, | ||
"versionName": "1.0.0", | ||
"icon": "$media:app_icon", | ||
"label": "$string:app_name" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"string": [ | ||
{ | ||
"name": "app_name", | ||
"value": "PAGViewer" | ||
} | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
{ | ||
"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" | ||
] | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "libpag", | ||
"srcPath": "./libpag", | ||
"targets": [ | ||
{ | ||
"name": "default", | ||
"applyToProducts": [ | ||
"default" | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/node_modules | ||
/oh_modules | ||
/.preview | ||
/build | ||
/.cxx | ||
/.test |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"apiType": "stageMode", | ||
"buildOption": { | ||
}, | ||
"buildOptionSet": [ | ||
{ | ||
"name": "release", | ||
"arkOptions": { | ||
"obfuscation": { | ||
"ruleOptions": { | ||
"enable": true, | ||
"files": [ | ||
"./obfuscation-rules.txt" | ||
] | ||
} | ||
} | ||
}, | ||
"nativeLib": { | ||
"debugSymbol": { | ||
"strip": true, | ||
"exclude": [] | ||
} | ||
} | ||
}, | ||
], | ||
"targets": [ | ||
{ | ||
"name": "default" | ||
}, | ||
{ | ||
"name": "ohosTest", | ||
} | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. | ||
export { hapTasks } from '@ohos/hvigor-ohos-plugin'; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"license": "", | ||
"devDependencies": {}, | ||
"author": "", | ||
"name": "entry", | ||
"description": "Please describe the basic information.", | ||
"main": "", | ||
"version": "1.0.0", | ||
"dependencies": { | ||
"libpag": "../libpag" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* 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. | ||
*/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. demo里这个协议去掉吧,或者更新成我们的。 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done,ets文件中license都更新了 |
||
|
||
import UIAbility from '@ohos.app.ability.UIAbility'; | ||
import hilog from '@ohos.hilog'; | ||
import window from '@ohos.window'; | ||
|
||
export default class EntryAbility extends UIAbility { | ||
onCreate(want, launchParam) { | ||
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); | ||
} | ||
|
||
onDestroy() { | ||
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); | ||
} | ||
|
||
onWindowStageCreate(windowStage: window.WindowStage) { | ||
// Main window is created, set main page for this ability | ||
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); | ||
|
||
windowStage.loadContent('pages/Index', (err, data) => { | ||
if (err.code) { | ||
hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); | ||
return; | ||
} | ||
hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); | ||
}); | ||
} | ||
|
||
onWindowStageDestroy() { | ||
// Main window is destroyed, release UI related resources | ||
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); | ||
} | ||
|
||
onForeground() { | ||
// Ability has brought to foreground | ||
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); | ||
} | ||
|
||
onBackground() { | ||
// Ability has back to background | ||
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); | ||
} | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import * as pag from 'libpag'; | ||
|
||
@Entry | ||
@Component | ||
struct Index { | ||
@State message: string = ""; | ||
@State @Watch("updateMessage") stateString: string = ""; | ||
@State composition: pag.PAGComposition | null = null; | ||
@State @Watch("updateMessage") progress: number = 0; | ||
@State isPlaying: boolean = false; | ||
@State repeatCount: number = 1; | ||
|
||
aboutToAppear(): void { | ||
let manager = getContext(this).resourceManager; | ||
let file = pag.PAGFile.LoadFromAssets(manager, "PAG_LOGO.pag"); | ||
this.composition = file as pag.PAGComposition; | ||
this.isPlaying = true; | ||
} | ||
|
||
onAnimationStart = (view: pag.PAGView) => { | ||
this.stateString = 'PAG start'; | ||
} | ||
onAnimationEnd = (view: pag.PAGView) => { | ||
this.stateString = `PAG end`; | ||
} | ||
onAnimationRepeat = (view: pag.PAGView) => { | ||
this.stateString = `PAG repeat`; | ||
} | ||
onAnimationCancel = (view: pag.PAGView) => { | ||
this.stateString = `PAG cancel`; | ||
} | ||
onAnimationUpdate = (view: pag.PAGView) => { | ||
} | ||
|
||
updateMessage() { | ||
this.message = this.stateString + ` progress ${this.progress.toFixed(2)}`; | ||
} | ||
|
||
build() { | ||
Row() { | ||
Column() { | ||
pag.PAGView({ | ||
composition: this.composition, | ||
progress: this.progress, | ||
isPlaying: this.isPlaying, | ||
repeatCount: this.repeatCount, | ||
listeners: [new WeakRef(this)] | ||
}) | ||
.height('50%') | ||
.onClick(() => { | ||
this.isPlaying = !this.isPlaying | ||
}) | ||
|
||
Text(this.message) | ||
.fontSize(50) | ||
.fontWeight(FontWeight.Bold) | ||
.onClick(() => { | ||
this.progress = 0.5; | ||
this.repeatCount = 0; | ||
}) | ||
.height('50%') | ||
} | ||
.width('100%') | ||
|
||
} | ||
.height('100%') | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright (c) 2023 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. | ||
*/ | ||
|
||
{ | ||
"module": { | ||
"name": "entry", | ||
"type": "entry", | ||
"description": "$string:module_desc", | ||
"mainElement": "EntryAbility", | ||
"deviceTypes": [ | ||
"default" | ||
], | ||
"deliveryWithInstall": true, | ||
"installationFree": false, | ||
"pages": "$profile:main_pages", | ||
"abilities": [ | ||
{ | ||
"name": "EntryAbility", | ||
"srcEntry": "./ets/entryability/EntryAbility.ts", | ||
"description": "$string:EntryAbility_desc", | ||
"icon": "$media:icon", | ||
"label": "$string:EntryAbility_label", | ||
"startWindowIcon": "$media:icon", | ||
"startWindowBackground": "$color:start_window_background", | ||
"exported": true, | ||
"skills": [ | ||
{ | ||
"entities": [ | ||
"entity.system.home" | ||
], | ||
"actions": [ | ||
"action.system.home" | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"color": [ | ||
{ | ||
"name": "start_window_background", | ||
"value": "#FFFFFF" | ||
} | ||
] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
换个正式的PAGViewer图标
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done