From b061d3b472b89b655cad61e65a4a46650da7dd28 Mon Sep 17 00:00:00 2001 From: duqingquan Date: Tue, 31 Oct 2023 15:24:40 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=8B=E5=8A=A8=E7=A7=BB=E9=99=A4=E5=85=A8?= =?UTF-8?q?=E9=83=A8=E6=97=A0=E6=95=88=E7=9A=84=20UTSAndroid=20=E5=BC=95?= =?UTF-8?q?=E7=94=A8=EF=BC=8C=E9=81=BF=E5=85=8D=E5=91=8A=E8=AD=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../uts-alert/utssdk/app-android/index.uts | 5 - .../utssdk/app-android/index.vue | 1 - .../utssdk/app-android/index.uts | 5 +- .../utssdk/app-android/index.uts | 1 - .../utssdk/app-android/index.vue | 131 +++++++++++++++--- .../utssdk/app-android/DoAppWidget.uts | 2 - .../utssdk/app-android/index.uts | 5 - .../utssdk/app-android/index.uts | 1 - .../utssdk/app-android/index.uts | 7 +- .../utssdk/app-android/index.uts | 6 - .../uts-toast/utssdk/app-android/index.uts | 7 +- 11 files changed, 117 insertions(+), 54 deletions(-) diff --git a/uni_modules/uts-alert/utssdk/app-android/index.uts b/uni_modules/uts-alert/utssdk/app-android/index.uts index e221cc8..6a74a20 100644 --- a/uni_modules/uts-alert/utssdk/app-android/index.uts +++ b/uni_modules/uts-alert/utssdk/app-android/index.uts @@ -1,8 +1,3 @@ - -import { - UTSAndroid -} from "io.dcloud.uts"; - import Toast from 'android.widget.Toast'; import AlertDialog from 'android.app.AlertDialog'; import DialogInterface from 'android.content.DialogInterface'; diff --git a/uni_modules/uts-animation-view/utssdk/app-android/index.vue b/uni_modules/uts-animation-view/utssdk/app-android/index.vue index d47fe88..a298254 100644 --- a/uni_modules/uts-animation-view/utssdk/app-android/index.vue +++ b/uni_modules/uts-animation-view/utssdk/app-android/index.vue @@ -10,7 +10,6 @@ import LottieAnimationView from 'com.airbnb.lottie.LottieAnimationView' import LottieDrawable from 'com.airbnb.lottie.LottieDrawable' import FileInputStream from 'java.io.FileInputStream' - import { UTSAndroid } from "io.dcloud.uts"; class CustomAnimListener extends Animator.AnimatorListener { diff --git a/uni_modules/uts-file-manager/utssdk/app-android/index.uts b/uni_modules/uts-file-manager/utssdk/app-android/index.uts index d92f48f..1d0c5ce 100644 --- a/uni_modules/uts-file-manager/utssdk/app-android/index.uts +++ b/uni_modules/uts-file-manager/utssdk/app-android/index.uts @@ -1,10 +1,9 @@ -import { ReadFileSuccessResult, ReadFile,ReadFileOptions } from "../interface.uts" -import { WriteFileSuccessResult, WriteFile,WriteFileOptions } from "../interface.uts" +import { ReadFileSuccessResult, ReadFileOptions } from "../interface.uts" +import { WriteFileSuccessResult, WriteFileOptions } from "../interface.uts" import { GetFileSystemManager,FileSystemManager} from "../interface.uts" import { UniErrorSubject, UniErrors } from "../unierror.uts" import File from "java.io.File" -import UTSAndroid from 'io.dcloud.uts.UTSAndroid'; import Base64 from "android.util.Base64" export { ReadFileOptions, WriteFileOptions } from "../interface.uts" diff --git a/uni_modules/uts-getbatteryinfo/utssdk/app-android/index.uts b/uni_modules/uts-getbatteryinfo/utssdk/app-android/index.uts index 4207108..ab4dac1 100644 --- a/uni_modules/uts-getbatteryinfo/utssdk/app-android/index.uts +++ b/uni_modules/uts-getbatteryinfo/utssdk/app-android/index.uts @@ -1,6 +1,5 @@ import Context from "android.content.Context"; import BatteryManager from "android.os.BatteryManager"; -import { UTSAndroid } from "io.dcloud.uts"; import IntentFilter from 'android.content.IntentFilter'; import Intent from 'android.content.Intent'; diff --git a/uni_modules/uts-hello-component/utssdk/app-android/index.vue b/uni_modules/uts-hello-component/utssdk/app-android/index.vue index 47fb09f..2af7805 100644 --- a/uni_modules/uts-hello-component/utssdk/app-android/index.vue +++ b/uni_modules/uts-hello-component/utssdk/app-android/index.vue @@ -1,5 +1,6 @@ + @@ -7,11 +8,12 @@ import TextUtils from 'android.text.TextUtils' import Button from 'android.widget.Button' import LinearLayout from 'android.widget.LinearLayout' - import Color from 'android.graphics.Color' import View from 'android.view.View' class ButtonClickListsner extends View.OnClickListener { - constructor() {} + constructor() { + super() + } override onClick(v ? : View) { console.log(v) } @@ -19,21 +21,35 @@ //原生提供以下属性或方法的实现 export default { - + /** + * 组件名称,也就是开发者使用的标签 + */ name: "uts-hello-view", - + /** + * 组件涉及的事件声明,只有声明过的事件,才能被正常发送 + */ + emits: ['buttonClick'], + /** + * 属性声明,组件的使用者会传递这些属性值到组件 + */ props: { - + /** + * 字符串类型 属性:buttonText 需要设置默认值 + */ "buttonText": { type: String, default: "点击触发" } }, - + /** + * 组件内部变量声明 + */ data() { return {} }, - + /** + * 属性变化监听器实现 + */ watch: { "buttonText": { /** @@ -47,26 +63,105 @@ } } }, - immediate: false + immediate: false //创建时是否通过此方法更新属性,默认值为false + }, + }, + /** + * 规则:如果没有配置expose,则methods中的方法均对外暴露,如果配置了expose,则以expose的配置为准向外暴露 + * ['publicMethod'] 含义为:只有 `publicMethod` 在实例上可用 + */ + expose: ['doSth'], + methods: { + /** + * 对外公开的组件方法 + */ + doSth(paramA: string) { + // 这是组件的自定义方法 + console.log("paramA",paramA) }, + /** + * 内部使用的组件方法 + */ + privateMethod() { + + } + }, + + /** + * 组件被创建,组件第一个生命周期, + * 在内存中被占用的时候被调用,开发者可以在这里执行一些需要提前执行的初始化逻辑 + * [可选实现] + */ + created() { + }, + /** + * 对应平台的view载体即将被创建,对应前端beforeMount + * [可选实现] + */ + NVBeforeLoad() { + }, + /** + * 创建原生View,必须定义返回值类型 + * 开发者需要重点实现这个函数,声明原生组件被创建出来的过程,以及最终生成的原生组件类型 + * (Android需要明确知道View类型,需特殊校验) + * todo 补充IOS平台限制 + * [必须实现] + */ NVLoad(): LinearLayout { //必须实现 - let contentLayout = new LinearLayout($androidContext) - let button = new Button($androidContext) + let contentLayout = new LinearLayout(this.$androidContext) + let button = new Button(this.$androidContext) button.setText("点击触发"); button.setTag("centerButton"); - contentLayout.addView(button, LinearLayout.LayoutParams(500, 500)); + contentLayout.addView(button, new LinearLayout.LayoutParams(500, 500)); button.setOnClickListener(new ButtonClickListsner()) return contentLayout + }, + + /** + * 原生View已创建 + * [可选实现] + */ + NVLoaded() { + + }, + /** + * 原生View布局完成 + * [可选实现] + */ + NVLayouted() { + + }, + /** + * 原生View将释放 + * [可选实现] + */ + NVBeforeUnload() {}, + /** + * 原生View已释放,这里可以做释放View之后的操作 + * [可选实现] + */ + NVUnloaded() { + + }, + /** + * 组件销毁 + * [可选实现] + */ + unmounted() {}, + /** + * 自定组件布局尺寸 + * [可选实现] + */ + NVMeasure(size: UTSSize): UTSSize { + size.width = 120.0.toFloat() + size.height = 800.0.toFloat() + return size } } + + \ No newline at end of file diff --git a/uni_modules/uts-nativepage/utssdk/app-android/DoAppWidget.uts b/uni_modules/uts-nativepage/utssdk/app-android/DoAppWidget.uts index 446dc71..29ec6e3 100644 --- a/uni_modules/uts-nativepage/utssdk/app-android/DoAppWidget.uts +++ b/uni_modules/uts-nativepage/utssdk/app-android/DoAppWidget.uts @@ -2,8 +2,6 @@ import AppWidgetProvider from 'android.appwidget.AppWidgetProvider'; import Context from 'android.content.Context'; import AppWidgetManager from 'android.appwidget.AppWidgetManager'; import RemoteViews from 'android.widget.RemoteViews'; -import Handler from 'android.os.Handler'; -import UTSAndroid from 'io.dcloud.uts.UTSAndroid'; import R from 'io.dcloud.uni_modules.uts_nativepage.R'; export class DoAppWidget extends AppWidgetProvider { diff --git a/uni_modules/uts-nativepage/utssdk/app-android/index.uts b/uni_modules/uts-nativepage/utssdk/app-android/index.uts index c218484..9912b0b 100644 --- a/uni_modules/uts-nativepage/utssdk/app-android/index.uts +++ b/uni_modules/uts-nativepage/utssdk/app-android/index.uts @@ -17,14 +17,9 @@ import IBinder from 'android.os.IBinder'; import Toast from 'android.widget.Toast'; -import { - UTSAndroid -} from "io.dcloud.uts"; - import Service from 'android.app.Service'; import System from 'java.lang.System'; import Exception from 'java.lang.Exception'; -import ResolveInfo from 'android.content.pm.ResolveInfo'; import RecyclerView from 'androidx.recyclerview.widget.RecyclerView'; import TextView from 'android.widget.TextView'; import ViewGroup from 'android.view.ViewGroup'; diff --git a/uni_modules/uts-platform-api/utssdk/app-android/index.uts b/uni_modules/uts-platform-api/utssdk/app-android/index.uts index 11b6663..7ea5c1b 100644 --- a/uni_modules/uts-platform-api/utssdk/app-android/index.uts +++ b/uni_modules/uts-platform-api/utssdk/app-android/index.uts @@ -2,7 +2,6 @@ import MediaStore from "android.provider.MediaStore"; import Activity from "android.app.Activity"; import Bitmap from "android.graphics.Bitmap"; import FileOutputStream from "java.io.FileOutputStream"; -import File from "java.io.File"; import Intent from 'android.content.Intent'; /** diff --git a/uni_modules/uts-screenshot-listener/utssdk/app-android/index.uts b/uni_modules/uts-screenshot-listener/utssdk/app-android/index.uts index db836a2..37f4a56 100644 --- a/uni_modules/uts-screenshot-listener/utssdk/app-android/index.uts +++ b/uni_modules/uts-screenshot-listener/utssdk/app-android/index.uts @@ -1,10 +1,6 @@ -import { - UTSAndroid -} from "io.dcloud.uts"; - -import { OnUserCaptureScreen, OffUserCaptureScreen, UserCaptureScreenCallback, OnUserCaptureScreenResult } from "../interface.uts" +import { UserCaptureScreenCallback, OnUserCaptureScreenResult } from "../interface.uts" import ActivityCompat from "androidx.core.app.ActivityCompat"; @@ -14,7 +10,6 @@ import Build from "android.os.Build"; import FileObserver from "android.os.FileObserver"; import File from "java.io.File"; import Environment from "android.os.Environment"; -import System from 'java.lang.System'; diff --git a/uni_modules/uts-tencentgeolocation/utssdk/app-android/index.uts b/uni_modules/uts-tencentgeolocation/utssdk/app-android/index.uts index c446df3..17b5d63 100644 --- a/uni_modules/uts-tencentgeolocation/utssdk/app-android/index.uts +++ b/uni_modules/uts-tencentgeolocation/utssdk/app-android/index.uts @@ -1,8 +1,4 @@ -import { - UTSAndroid -} from "io.dcloud.uts"; -import ActivityCompat from "androidx.core.app.ActivityCompat"; import Manifest from "android.Manifest"; import Looper from "android.os.Looper"; import TencentLocationManager from "com.tencent.map.geolocation.TencentLocationManager"; @@ -10,8 +6,6 @@ import TencentLocationListener from "com.tencent.map.geolocation.TencentLocation import TencentLocation from "com.tencent.map.geolocation.TencentLocation"; import TencentLocationRequest from "com.tencent.map.geolocation.TencentLocationRequest"; import PackageManager from "android.content.pm.PackageManager"; -import Class from 'java.lang.Class'; -import Exception from 'java.lang.Exception'; diff --git a/uni_modules/uts-toast/utssdk/app-android/index.uts b/uni_modules/uts-toast/utssdk/app-android/index.uts index 847a27f..217fafa 100644 --- a/uni_modules/uts-toast/utssdk/app-android/index.uts +++ b/uni_modules/uts-toast/utssdk/app-android/index.uts @@ -1,12 +1,7 @@ -import { - UTSAndroid -} from "io.dcloud.uts"; import XToast from "com.hjq.xtoast.XToast"; import R from "io.dcloud.uni_modules.uts_toast.R"; -import Runnable from 'java.lang.Runnable'; -import Class from 'java.lang.Class'; -import Exception from 'java.lang.Exception'; + class UIRunnable extends Runnable { -- GitLab