From 2beb3777bf11ac3f3a6266aba23ab77b84184dd8 Mon Sep 17 00:00:00 2001 From: duqingquan Date: Fri, 9 Sep 2022 18:18:12 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E8=85=BE=E8=AE=AF=E5=AE=9A?= =?UTF-8?q?=E4=BD=8D=20=20libs=E6=89=93=E5=8C=85=E6=8A=A5=E9=94=99?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AndroidManifest.xml | 10 +++ manifest.json | 4 +- pages/advance/advance.vue | 27 +++++-- pages/index/index.vue | 14 +++- .../utssdk/app-android/config.json | 2 - .../uts-advance/utssdk/app-android/index.uts | 67 ++++++++++++++---- .../uts-advance/utssdk/app-android/utils.uts | 3 - .../utssdk/app-android/index.uts | 18 +++-- .../utssdk/app-android/AndroidManifest.xml | 6 +- .../utssdk/app-android/config.json | 5 -- .../utssdk/app-android/index.uts | 20 ++++-- ...7\346\227\266\347\247\273\351\231\244.jar" | Bin 12 files changed, 128 insertions(+), 48 deletions(-) create mode 100644 AndroidManifest.xml delete mode 100644 uni_modules/uts-advance/utssdk/app-android/config.json delete mode 100644 uni_modules/uts-advance/utssdk/app-android/utils.uts rename "uni_modules/uts-tencentgeolocation/utssdk/app-android/libs/androix-core-1.0.0-\350\207\252\345\256\232\344\271\211\345\237\272\345\272\247\351\234\200\347\247\273\351\231\244.jar" => "uni_modules/uts-tencentgeolocation/utssdk/app-android/libs/androix-core-1.0.0-\350\207\252\345\256\232\344\271\211\345\237\272\345\272\247\346\227\266\347\247\273\351\231\244.jar" (100%) diff --git a/AndroidManifest.xml b/AndroidManifest.xml new file mode 100644 index 0000000..81d2140 --- /dev/null +++ b/AndroidManifest.xml @@ -0,0 +1,10 @@ + + + + + + + + + diff --git a/manifest.json b/manifest.json index 0e88621..5511eae 100644 --- a/manifest.json +++ b/manifest.json @@ -2,8 +2,8 @@ "name" : "HelloUTS", "appid" : "__UNI__70BE9D0", "description" : "", - "versionName" : "1.0.8", - "versionCode" : "108", + "versionName" : "1.0.9", + "versionCode" : "109", "transformPx" : false, /* 5+App特有相关 */ "app-plus" : { diff --git a/pages/advance/advance.vue b/pages/advance/advance.vue index 69c3c4f..40f1a18 100644 --- a/pages/advance/advance.vue +++ b/pages/advance/advance.vue @@ -14,7 +14,7 @@ - + @@ -38,9 +38,11 @@ taskId:0 } }, - onUnload:function(){ - }, + methods: { + /** + * 测试延迟任务 + */ testTimer: function () { doTimerTask({ start:function(response){ @@ -57,6 +59,9 @@ }, }); }, + /** + * 测试周期任务 + */ testInterval: function () { var ret = doIntervalTask({ start:function(response){ @@ -74,21 +79,31 @@ }); this.taskId = ret.taskId; }, - + /** + * 取消周期任务 + */ testClearInterval: function () { console.log(this.taskId); clearIntervalTask(this.taskId); }, + /** + * 测试添加View实例至顶层容器 + */ testAddToDecorView: function () { addViewToDecorView(); }, - + /** + * 测试移除顶层容器的View实例 + */ testRemoveToDecorView: function () { removeViewToDecorView(); }, - testResource: function () { + /** + * 跳转至资源加载演示界面 + */ + gotoResourceDemo: function () { uni.navigateTo({ url:'/pages/resource/resource' }) diff --git a/pages/index/index.vue b/pages/index/index.vue index 2f33e23..1832e83 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -19,9 +19,12 @@ stringParam:"hello world", } }, - onUnload:function(){ - }, + methods: { + + /** + * 测试无参数调用 + */ testDoSthWithCallback: function () { UTSHello.callWithoutParam( @@ -33,7 +36,11 @@ } ); }, + /** + * 测试字符串参数回调 + */ testDoSthWithString: function () { + UTSHello.callWithStringParam( this.stringParam, function(response){ @@ -44,6 +51,9 @@ }, ); }, + /** + * 测试json参数回调 + */ testDoSthWithJSON: function () { var inputObject = { inputText:this.stringParam diff --git a/uni_modules/uts-advance/utssdk/app-android/config.json b/uni_modules/uts-advance/utssdk/app-android/config.json deleted file mode 100644 index 7a73a41..0000000 --- a/uni_modules/uts-advance/utssdk/app-android/config.json +++ /dev/null @@ -1,2 +0,0 @@ -{ -} \ No newline at end of file diff --git a/uni_modules/uts-advance/utssdk/app-android/index.uts b/uni_modules/uts-advance/utssdk/app-android/index.uts index 7b157b2..7ba747d 100644 --- a/uni_modules/uts-advance/utssdk/app-android/index.uts +++ b/uni_modules/uts-advance/utssdk/app-android/index.uts @@ -20,12 +20,21 @@ import { getAppContext } from "io.dcloud.uts.android"; + /** * 定时任务参数封装 */ type TimerOptions = { - start: (res: string) => void; - work: (res: string) => void; + /** + * 定时任务开始的回调 + * @res 回调参数 + */ + start: (res: string) => void; + /** + * 定时任务执行的回调 + * @res 回调参数 + */ + work: (res: string) => void; }; @@ -60,12 +69,14 @@ export function doIntervalTask(opts:TimerOptions) { export function clearIntervalTask(taskId:number) { clearInterval(taskId); - - return { name: "clearIntervalTask"}; + return { name: "clearIntervalTask"}; } - +/** + * 实现一个添加view的 Runnable类 + * 用法说明:https://uniapp.dcloud.net.cn/plugin/uts-plugin.html#%E5%8C%BF%E5%90%8D%E5%86%85%E9%83%A8%E7%B1%BB + */ class AddUIRunnable extends Runnable { override run():void { @@ -89,6 +100,10 @@ class AddUIRunnable extends Runnable { } }; +/** + * 实现一个移除view的 Runnable类 + * 用法说明:https://uniapp.dcloud.net.cn/plugin/uts-plugin.html#%E5%8C%BF%E5%90%8D%E5%86%85%E9%83%A8%E7%B1%BB + */ class RemoveUIRunnable extends Runnable { override run():void { @@ -102,27 +117,34 @@ class RemoveUIRunnable extends Runnable { } }; - +/** + * 实现添加view实例至decorview + * + */ export function addViewToDecorView() { let uiRunable = new AddUIRunnable(); getUniActivity()!.runOnUiThread(uiRunable) } - +/** + * 实现从decorview上移除指定view + */ export function removeViewToDecorView() { var uiRunable = new RemoveUIRunnable(); getUniActivity()!.runOnUiThread(uiRunable) } - - - +/** + * 引用资源路径 + */ export function getLogoPath(): string { return logo; } - +/** + * 播放asset资源中的音频 + */ export function playAssetAudio() { let assetManager = getAppContext()!.getAssets(); @@ -135,26 +157,43 @@ export function playAssetAudio() { } - - - +/** + * 初始化应用生命周期监听 + * + */ export function initAppLifecycle(onLifecycleChange: (event:string) => void) { + /** + * activity 销毁生命周期回调 + * 说明文档:https://uniapp.dcloud.net.cn/plugin/uts-plugin.html#onappactivitydestroy + */ onAppActivityDestroy(() => { let eventName = "onAppActivityDestroy - " + Date.now(); onLifecycleChange(eventName); console.log(eventName); }); + /** + * activity 失去焦点生命周期回调 + * 说明文档:https://uniapp.dcloud.net.cn/plugin/uts-plugin.html#onappactivitypause + */ onAppActivityPause(() => { let eventName = "onAppActivityPause - " + Date.now(); onLifecycleChange(eventName); console.log(eventName); }); + /** + * activity 得到焦点的周期回调 + * 说明文档:https://uniapp.dcloud.net.cn/plugin/uts-plugin.html#onappactivityresume + */ onAppActivityResume(() => { let eventName = "onAppActivityResume - " + Date.now(); onLifecycleChange(eventName); console.log(eventName); }); + /** + * activity 回退物理按键事件回调 + * 说明文档:https://uniapp.dcloud.net.cn/plugin/uts-plugin.html#onappactivityback + */ onAppActivityBack(() => { let eventName = "onAppActivityBack - " + Date.now(); onLifecycleChange(eventName); diff --git a/uni_modules/uts-advance/utssdk/app-android/utils.uts b/uni_modules/uts-advance/utssdk/app-android/utils.uts deleted file mode 100644 index 71050f5..0000000 --- a/uni_modules/uts-advance/utssdk/app-android/utils.uts +++ /dev/null @@ -1,3 +0,0 @@ -export function log(msg: string) { - console.log(msg); -} diff --git a/uni_modules/uts-helloworld/utssdk/app-android/index.uts b/uni_modules/uts-helloworld/utssdk/app-android/index.uts index e668100..e42147d 100644 --- a/uni_modules/uts-helloworld/utssdk/app-android/index.uts +++ b/uni_modules/uts-helloworld/utssdk/app-android/index.uts @@ -1,9 +1,13 @@ - +/** + * json参数格式定义 + */ type inputJSON = { inputText: string, errCode: number } - +/** + * json入参格式 + */ type JsonParamOptions = { input: inputJSON; success: (res: string) => void; @@ -13,7 +17,7 @@ type JsonParamOptions = { /** - * 导出一个带callback的同步方法 + * 导出无参的UTS函数 * @param opts */ export function callWithoutParam(success: () => void) { @@ -21,13 +25,17 @@ export function callWithoutParam(success: () => void) { return { name: "doSthWithCallback" }; } - +/** + * 导出一个字符串入参的UTS函数 + */ export function callWithStringParam(input: string, success: (res: string) => void) { success(input); return { name: "doSthWithCallback" }; } - +/** + * 导出一个JSON入参的UTS函数 + */ export function callWithJSONParam(opts: JsonParamOptions) { opts.input.errCode = 10; opts.success(opts.input); diff --git a/uni_modules/uts-tencentgeolocation/utssdk/app-android/AndroidManifest.xml b/uni_modules/uts-tencentgeolocation/utssdk/app-android/AndroidManifest.xml index 153ef60..bb21051 100644 --- a/uni_modules/uts-tencentgeolocation/utssdk/app-android/AndroidManifest.xml +++ b/uni_modules/uts-tencentgeolocation/utssdk/app-android/AndroidManifest.xml @@ -26,9 +26,5 @@ - - - - - + diff --git a/uni_modules/uts-tencentgeolocation/utssdk/app-android/config.json b/uni_modules/uts-tencentgeolocation/utssdk/app-android/config.json index ba5d885..47c8119 100644 --- a/uni_modules/uts-tencentgeolocation/utssdk/app-android/config.json +++ b/uni_modules/uts-tencentgeolocation/utssdk/app-android/config.json @@ -1,8 +1,3 @@ { - "dependencies": [ - { - "id": "com.tencent.map.geolocation:TencentLocationSdk-openplatform", - "source": "implementation 'com.tencent.map.geolocation:TencentLocationSdk-openplatform:7.4.9'" - }], "minSdkVersion": 21 } diff --git a/uni_modules/uts-tencentgeolocation/utssdk/app-android/index.uts b/uni_modules/uts-tencentgeolocation/utssdk/app-android/index.uts index bcc78cc..8115b87 100644 --- a/uni_modules/uts-tencentgeolocation/utssdk/app-android/index.uts +++ b/uni_modules/uts-tencentgeolocation/utssdk/app-android/index.uts @@ -16,6 +16,12 @@ import TencentLocationRequest from "com.tencent.map.geolocation.TencentLocationR export function requestPremission() { + /** + * 同意隐私协议。重要!! + * 说明文档:https://lbs.qq.com/mobile/androidLocationSDK/androidGeoGuide/agreePrivacy + */ + TencentLocationManager.setUserAgreePrivacy(true); + // 注册一个请求回调 onAppActivityRequestPermissionsResult((requestCode: number, permissions: MutableList, @@ -28,8 +34,8 @@ export function requestPremission() { console.log(permissions); console.log(requestCode); }); - // 发起权限申请 + // 发起权限申请 ActivityCompat.requestPermissions( getUniActivity()!, arrayOf(Manifest.permission.ACCESS_COARSE_LOCATION,Manifest.permission.ACCESS_FINE_LOCATION), 1001); @@ -57,6 +63,10 @@ type LocationResponse = { longitude?:number } + +/** + * 定位监听结果包装类 + */ class LocationOptionsWapper{ hostOption:LocationOptions; @@ -101,7 +111,7 @@ class SingleLocationListener extends TencentLocationListener { reason:string ):void{ console.log(error); console.log(reason); - console.log(location); + console.log(error); this.hostOptionWraper.onLocationChanged(location,error,reason); } @@ -118,6 +128,7 @@ class SingleLocationListener extends TencentLocationListener { */ export function getLocation(locationOptions: LocationOptions) { + let mLocationManager = TencentLocationManager.getInstance(getAppContext()); // 定位监听器封装 let locationOptionWrapper = new LocationOptionsWapper(locationOptions); @@ -130,7 +141,8 @@ export function getLocation(locationOptions: LocationOptions) { }else{ locationRequest.setRequestLevel(TencentLocationRequest.REQUEST_LEVEL_GEO); } -console.log(locationRequest); - mLocationManager.requestSingleFreshLocation(null, mLocationListener, Looper.getMainLooper()); + + mLocationManager.requestSingleFreshLocation(locationRequest, mLocationListener, Looper.getMainLooper()); + return { name: "getLocation"}; } \ No newline at end of file diff --git "a/uni_modules/uts-tencentgeolocation/utssdk/app-android/libs/androix-core-1.0.0-\350\207\252\345\256\232\344\271\211\345\237\272\345\272\247\351\234\200\347\247\273\351\231\244.jar" "b/uni_modules/uts-tencentgeolocation/utssdk/app-android/libs/androix-core-1.0.0-\350\207\252\345\256\232\344\271\211\345\237\272\345\272\247\346\227\266\347\247\273\351\231\244.jar" similarity index 100% rename from "uni_modules/uts-tencentgeolocation/utssdk/app-android/libs/androix-core-1.0.0-\350\207\252\345\256\232\344\271\211\345\237\272\345\272\247\351\234\200\347\247\273\351\231\244.jar" rename to "uni_modules/uts-tencentgeolocation/utssdk/app-android/libs/androix-core-1.0.0-\350\207\252\345\256\232\344\271\211\345\237\272\345\272\247\346\227\266\347\247\273\351\231\244.jar" -- GitLab