Skip to content

Commit

Permalink
Merge pull request #142 from zhangruiyu/ohos
Browse files Browse the repository at this point in the history
Ohos支持
  • Loading branch information
gstory0404 authored Jan 6, 2025
2 parents 930612d + 2e375bf commit 22c4f6b
Show file tree
Hide file tree
Showing 51 changed files with 1,184 additions and 73 deletions.
27 changes: 25 additions & 2 deletions .metadata
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,30 @@
# This file should be version controlled and should not be manually edited.

version:
revision: bbfbf1770cca2da7c82e887e4e4af910034800b6
channel: stable
revision: "c44cfb3a15b27abcfd6056ff447d6256cde7bc19"
channel: "oh-3.22.0"

project_type: plugin

# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: c44cfb3a15b27abcfd6056ff447d6256cde7bc19
base_revision: c44cfb3a15b27abcfd6056ff447d6256cde7bc19
- platform: android
create_revision: c44cfb3a15b27abcfd6056ff447d6256cde7bc19
base_revision: c44cfb3a15b27abcfd6056ff447d6256cde7bc19
- platform: ios
create_revision: c44cfb3a15b27abcfd6056ff447d6256cde7bc19
base_revision: c44cfb3a15b27abcfd6056ff447d6256cde7bc19

# User provided section

# List of Local paths (relative to this file) that should be
# ignored by the migrate tool.
#
# Files that are not part of the templates will be ignored by default.
unmanaged_files:
- 'lib/main.dart'
- 'ios/Runner.xcodeproj/project.pbxproj'
42 changes: 40 additions & 2 deletions example/.metadata
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,45 @@
# This file should be version controlled and should not be manually edited.

version:
revision: bbfbf1770cca2da7c82e887e4e4af910034800b6
channel: stable
revision: "c44cfb3a15b27abcfd6056ff447d6256cde7bc19"
channel: "oh-3.22.0"

project_type: app

# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: c44cfb3a15b27abcfd6056ff447d6256cde7bc19
base_revision: c44cfb3a15b27abcfd6056ff447d6256cde7bc19
- platform: android
create_revision: c44cfb3a15b27abcfd6056ff447d6256cde7bc19
base_revision: c44cfb3a15b27abcfd6056ff447d6256cde7bc19
- platform: ios
create_revision: c44cfb3a15b27abcfd6056ff447d6256cde7bc19
base_revision: c44cfb3a15b27abcfd6056ff447d6256cde7bc19
- platform: linux
create_revision: c44cfb3a15b27abcfd6056ff447d6256cde7bc19
base_revision: c44cfb3a15b27abcfd6056ff447d6256cde7bc19
- platform: macos
create_revision: c44cfb3a15b27abcfd6056ff447d6256cde7bc19
base_revision: c44cfb3a15b27abcfd6056ff447d6256cde7bc19
- platform: web
create_revision: c44cfb3a15b27abcfd6056ff447d6256cde7bc19
base_revision: c44cfb3a15b27abcfd6056ff447d6256cde7bc19
- platform: windows
create_revision: c44cfb3a15b27abcfd6056ff447d6256cde7bc19
base_revision: c44cfb3a15b27abcfd6056ff447d6256cde7bc19
- platform: ohos
create_revision: c44cfb3a15b27abcfd6056ff447d6256cde7bc19
base_revision: c44cfb3a15b27abcfd6056ff447d6256cde7bc19

# User provided section

# List of Local paths (relative to this file) that should be
# ignored by the migrate tool.
#
# Files that are not part of the templates will be ignored by default.
unmanaged_files:
- 'lib/main.dart'
- 'ios/Runner.xcodeproj/project.pbxproj'
2 changes: 2 additions & 0 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ class _IndexPageState extends State<IndexPage> {
androidAppId: "5098580",
//穿山甲广告 ios appid 必填
iosAppId: "5098580",
ohosAppId: "5638354",
//appname 必填
appName: "unionad_test",
//使用聚合功能一定要打开此开关,否则不会请求聚合广告,默认这个值为false
Expand Down Expand Up @@ -345,6 +346,7 @@ class _IndexPageState extends State<IndexPage> {
androidCodeId: "102733764",
//Android 激励视频广告id 必填
iosCodeId: "102733764",
ohosCodeId: '962519282',
//ios 激励视频广告id 必填
rewardName: "200金币",
//奖励名称 选填
Expand Down
19 changes: 19 additions & 0 deletions example/ohos/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/node_modules
/oh_modules
/local.properties
/.idea
**/build
/.hvigor
.cxx
/.clangd
/.clang-format
/.clang-tidy
**/.test
*.har
**/BuildProfile.ets
**/oh-package-lock.json5

**/src/main/resources/rawfile/flutter_assets/
**/libs/arm64-v8a/libapp.so
**/libs/arm64-v8a/libflutter.so
**/libs/arm64-v8a/libvmservice_snapshot.so
1 change: 1 addition & 0 deletions example/ohos/.ohpmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
registry=https://ohpm.openharmony.cn/ohpm/,https://artifact.bytedance.com/repository/byted-ohpm/
10 changes: 10 additions & 0 deletions example/ohos/AppScope/app.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"app": {
"bundleName": "com.pure.woodenfish.next",
"vendor": "example",
"versionCode": 4,
"versionName": "1.0.4",
"icon": "$media:app_icon",
"label": "$string:app_name"
}
}
8 changes: 8 additions & 0 deletions example/ohos/AppScope/resources/base/element/string.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"string": [
{
"name": "app_name",
"value": "example"
}
]
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
58 changes: 58 additions & 0 deletions example/ohos/build-profile.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"app": {
"signingConfigs": [
{
"name": "default",
"type": "HarmonyOS",
"material": {
"certpath": "/Users/housemao/.ohos/config/default_ohos_nqAToKei4RqYzVE_W0Qrtmgpl2bZulOSs9f_TUqDO8o=.cer",
"storePassword": "0000001B6DA162590C5A9FC04251F74F7B849886605913978E14D4A617300CC2DC5380DDD0AF50CB93C5DA",
"keyAlias": "debugKey",
"keyPassword": "0000001B4BB625CF5EDA5D263BEDB85069F698A8A89D55B8A3F4E15F0AE3177C47F6FFF33FC2A31F138535",
"profile": "/Users/housemao/.ohos/config/default_ohos_nqAToKei4RqYzVE_W0Qrtmgpl2bZulOSs9f_TUqDO8o=.p7b",
"signAlg": "SHA256withECDSA",
"storeFile": "/Users/housemao/.ohos/config/default_ohos_nqAToKei4RqYzVE_W0Qrtmgpl2bZulOSs9f_TUqDO8o=.p12"
}
}
],
"products": [
{
"name": "default",
"signingConfig": "default",
"compatibleSdkVersion": "5.0.0(12)",
"runtimeOS": "HarmonyOS",
"buildOption": {
"strictMode": {
"useNormalizedOHMUrl": true
}
}
}
]
},
"modules": [
{
"name": "entry",
"srcPath": "./entry",
"targets": [
{
"name": "default",
"applyToProducts": [
"default"
]
}
]
},
{
"name": "flutter_unionad",
"srcPath": "../../ohos",
"targets": [
{
"name": "default",
"applyToProducts": [
"default"
]
}
]
}
]
}
7 changes: 7 additions & 0 deletions example/ohos/entry/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

/node_modules
/oh_modules
/.preview
/build
/.cxx
/.test
29 changes: 29 additions & 0 deletions example/ohos/entry/build-profile.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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": {
},
"targets": [
{
"name": "default",
"runtimeOS": "HarmonyOS"
},
{
"name": "ohosTest",
}
]
}
17 changes: 17 additions & 0 deletions example/ohos/entry/hvigorfile.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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.
*/

// 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';
11 changes: 11 additions & 0 deletions example/ohos/entry/oh-package.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "entry",
"version": "1.0.0",
"description": "Please describe the basic information.",
"main": "",
"author": "",
"license": "",
"dependencies": {
"flutter_unionad": "file:../har/flutter_unionad.har"
}
}
24 changes: 24 additions & 0 deletions example/ohos/entry/src/main/ets/entryability/EntryAbility.ets
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 { FlutterAbility, FlutterEngine } from '@ohos/flutter_ohos';
import { GeneratedPluginRegistrant } from '../plugins/GeneratedPluginRegistrant';

export default class EntryAbility extends FlutterAbility {
configureFlutterEngine(flutterEngine: FlutterEngine) {
super.configureFlutterEngine(flutterEngine)
GeneratedPluginRegistrant.registerWith(flutterEngine)
}
}
38 changes: 38 additions & 0 deletions example/ohos/entry/src/main/ets/pages/Index.ets
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 common from '@ohos.app.ability.common';
import { FlutterPage } from '@ohos/flutter_ohos'

let storage = LocalStorage.getShared()
const EVENT_BACK_PRESS = 'EVENT_BACK_PRESS'

@Entry(storage)
@Component
struct Index {
private context = getContext(this) as common.UIAbilityContext
@LocalStorageLink('viewId') viewId: string = "";

build() {
Column() {
FlutterPage({ viewId: this.viewId })
}
}

onBackPress(): boolean {
this.context.eventHub.emit(EVENT_BACK_PRESS)
return true
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { FlutterEngine, Log } from '@ohos/flutter_ohos';
import FlutterUnionadPlugin from 'flutter_unionad';

/**
* Generated file. Do not edit.
* This file is generated by the Flutter tool based on the
* plugins that support the Ohos platform.
*/

const TAG = "GeneratedPluginRegistrant";

export class GeneratedPluginRegistrant {

static registerWith(flutterEngine: FlutterEngine) {
try {
flutterEngine.getPlugins()?.add(new FlutterUnionadPlugin());
} catch (e) {
Log.e(
TAG,
"Tried to register plugins with FlutterEngine ("
+ flutterEngine
+ ") failed.");
Log.e(TAG, "Received exception while registering", e);
}
}
}
Loading

0 comments on commit 22c4f6b

Please sign in to comment.