Skip to content

Commit

Permalink
feat: Update plugin structure for OpenHarmony (#301)
Browse files Browse the repository at this point in the history
  • Loading branch information
zmtzawqlp committed May 14, 2024
1 parent 2aa67cb commit 5e999c4
Show file tree
Hide file tree
Showing 44 changed files with 52 additions and 781 deletions.
2 changes: 1 addition & 1 deletion packages/flutter_image_compress/example/ohos/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ entry/libs/arm64-v8a/libapp.so
entry/libs/arm64-v8a/libflutter.so
entry/libs/arm64-v8a/libvmservice_snapshot.so
entry/src/main/resources/rawfile/flutter_assets/
har/flutter.har
har/*.har
oh-package-lock.json5
dta
17 changes: 1 addition & 16 deletions packages/flutter_image_compress/example/ohos/build-profile.json5
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
/*
* 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.
*/

{
"app": {
"signingConfigs": [],
Expand All @@ -22,7 +7,7 @@
"signingConfig": "default",
"compileSdkVersion": "4.1.0(11)",
"compatibleSdkVersion": "4.1.0(11)",
"runtimeOS": "HarmonyOS",
"runtimeOS": "HarmonyOS"
}
]
},
Expand Down
20 changes: 10 additions & 10 deletions packages/flutter_image_compress/example/ohos/entry/oh-package.json5
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
name: 'entry',
version: '1.0.0',
description: 'Please describe the basic information.',
main: '',
author: '',
license: '',
dependencies: {
'@ohos/path_provider_ohos': 'file:./har/path_provider_ohos.har',
'@ohos/flutter_image_compress_ohos': 'file:./har/flutter_image_compress_ohos.har',
},
"name": "entry",
"version": "1.0.0",
"description": "Please describe the basic information.",
"main": "",
"author": "",
"license": "",
"dependencies": {
"path_provider_ohos": "file:../har/path_provider_ohos.har",
"flutter_image_compress_ohos": "file:../har/flutter_image_compress_ohos.har"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,12 @@
*/

import { FlutterAbility } from '@ohos/flutter_ohos'
import { FlutterPlugin } from '@ohos/flutter_ohos/src/main/ets/embedding/engine/plugins/FlutterPlugin';
import { GeneratedPluginRegistrant } from '../plugins/GeneratedPluginRegistrant';
import List from '@ohos.util.List';
import FlutterEngine from '@ohos/flutter_ohos/src/main/ets/embedding/engine/FlutterEngine';

export default class EntryAbility extends FlutterAbility {
configureFlutterEngine(flutterEngine: FlutterEngine) {
super.configureFlutterEngine(flutterEngine)
let plugins = GeneratedPluginRegistrant.getPlugins() as List<FlutterPlugin>;
plugins.forEach((plugin) => {
this.addPlugin(plugin);
})
GeneratedPluginRegistrant.registerWith(flutterEngine)
}
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@
import { FlutterPlugin } from '@ohos/flutter_ohos/src/main/ets/embedding/engine/plugins/FlutterPlugin';
import List from '@ohos.util.List';
import FlutterImageCompressOhosPlugin from '@ohos/flutter_image_compress_ohos'
import PathProviderPlugin from '@ohos/path_provider_ohos'
import { FlutterEngine, Log } from '@ohos/flutter_ohos';
import FlutterImageCompressOhosPlugin from 'flutter_image_compress_ohos';
import PathProviderPlugin from 'path_provider_ohos';

/**
* 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 getPlugins(): List<FlutterPlugin> {
let pluginList : List<FlutterPlugin> = new List();
pluginList.add(new FlutterImageCompressOhosPlugin());
pluginList.add(new PathProviderPlugin());
return pluginList;

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

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit 5e999c4

Please sign in to comment.