提交 6fe36ca3 编写于 作者: dcloud_wdl's avatar dcloud_wdl

Merge remote-tracking branch 'origin/alpha'

......@@ -16,5 +16,14 @@
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<!--meta-data-->
<activity android:name="io.dcloud.uniapp.UniLaunchProxyActivity" android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="appuniappx"/>
</intent-filter>
</activity>
</application>
</manifest>
## 1.0.19
* update 4.23.2024070309-alpha
## 1.0.17
* update 4.22.2024062415-alpha
## 1.0.16
* update 4.21.2024061818-alpha
......
......@@ -2,8 +2,8 @@
"name" : "HelloUTS",
"appid" : "__UNI__70BE9D0",
"description" : "",
"versionName" : "1.0.9",
"versionCode" : "109",
"versionName" : "1.1.0",
"versionCode" : "110",
"transformPx" : false,
"uni-app-x" : {},
/* 5+App特有相关 */
......
......@@ -2,7 +2,7 @@
"id": "hello-uts-alpha",
"name": "hello-uts-alpha",
"displayName": "hello-uts-alpha",
"version": "1.0.16",
"version": "1.0.19",
"description": "UTS插件示例项目",
"repository": "https://gitcode.net/dcloud/hello-uts",
"keywords": [
......
......@@ -158,7 +158,7 @@
}
// #endif
// #ifdef APP-Android
// #ifdef APP
,
{
"path": "pages/SyntaxCase/utsAndroid",
......@@ -168,8 +168,6 @@
}
}
// #endif
// #ifdef APP-iOS
,
{
"path": "pages/SyntaxCase/utsiOS",
......
<template>
<!-- #ifdef APP-ANDROID -->
<!-- #ifdef APP-ANDROID -->
<scroll-view style="flex: 1">
<view>
<view class="uni-padding-wrap uni-common-mt">
......@@ -60,6 +60,7 @@
</template>
<script>
// #ifdef APP-ANDROID
import {
getAppContextTest,
getUniActivityTest,
......@@ -77,6 +78,8 @@
getDeviceInfoTest,
privacyStateTest
} from '@/uni_modules/uts-platform-api'
// #endif
// #ifdef APP-ANDROID
import {
UTSAcvitiyLifeCycleCallback,
......@@ -86,15 +89,15 @@
UTSActivityComponentCallback,
onCallbackChange
} from '@/uni_modules/uts-syntaxcase'
// #endif
import File from 'java.io.File';
import Intent from 'android.content.Intent';
// #endif
/**
* 测试在页面生命周期之外,使用api
*/
*/
export default {
data() {
return {
......@@ -111,6 +114,7 @@
},
onLoad: function () {
// #ifdef APP-ANDROID
let that = this
initAppLifecycle(function (eventLog) {
// 展示捕捉到的声明周期日志
......@@ -119,8 +123,10 @@
let nextLineFlag = that.text + '\n'
that.text = nextLineFlag
})
// #endif
},
methods: {
// #ifdef APP-ANDROID
privacyStateClick() {
privacyStateTest(function (ret, desc) {
if (ret) {
......@@ -314,6 +320,7 @@
}
})
},
// #endif
// #ifdef APP-ANDROID
// #ifdef UNI-APP-X
activityCallback() {
......
......@@ -4,15 +4,39 @@
</view>
</template>
<script lang="uts">
import LinearLayout from 'android.widget.LinearLayout'
import Context from 'android.content.Context'
import View from 'android.view.View'
/**
* 自定义android布局组件,可以实现监听显示状态等复杂的功能
*/
class CustomLinearLayout extends LinearLayout{
constructor(context: Context) {
super(context)
}
override onWindowVisibilityChanged(visibility:kotlin.Int){
if (visibility == View.VISIBLE){
console.log("可见状态",visibility)
}else if(visibility == INVISIBLE || visibility == GONE){
console.log("不可见状态",visibility)
}
}
}
//原生提供以下属性或方法的实现
export default {
name: "uts-hello-container",
NVLoad(): LinearLayout {
let contentLayout = new LinearLayout($androidContext)
let contentLayout = new CustomLinearLayout($androidContext!)
contentLayout.orientation = LinearLayout.VERTICAL;
return contentLayout
}
......
......@@ -125,7 +125,10 @@
* [可选实现]
*/
NVLoaded() {
// 组件内可以调用 UTSAndroid 内置方法
console.log("UTSAndroid.devicePX2px(1080) : ",UTSAndroid.devicePX2px(1080))
console.log("UTSAndroid.rpx2px(1080) : ",UTSAndroid.rpx2px(1080))
console.log("UTSAndroid.appJSBundleUrl() : ",UTSAndroid.appJSBundleUrl())
},
/**
* 原生View布局完成
......
......@@ -15,13 +15,10 @@ export class CustomAccessibilityService extends AccessibilityService {
override onAccessibilityEvent(event:AccessibilityEvent ):void {
if(event == null){
return ;
}
console.log("packagename",event!.getPackageName())
if("io.dcloud.uniappx" == event!.getPackageName()){
console.log("packagename",event.getPackageName())
if("io.dcloud.uniappx" == event.getPackageName()){
console.log("辅助服务消息:uniappx 基座打开")
}else if("io.dcloud.HBuilder" == event!.getPackageName()){
}else if("io.dcloud.HBuilder" == event.getPackageName()){
console.log("辅助服务消息:HBuilder 基座被打开")
}
}
......
......@@ -382,7 +382,8 @@ function initShortCut() {
shortcutBuilder2.setIcon(IconCompat.createWithResource(UTSAndroid.getAppContext()!, R.drawable.icon_short))
shortcutBuilder2.setIntent(
new Intent(
"uts.sdk.modules.demo"
Intent.ACTION_VIEW,
Uri.parse("appuniappx://market/111")
)
)
let shortcut2 = shortcutBuilder2.build()
......
......@@ -319,6 +319,13 @@ export function testJSON() : Result {
a: 1
}.toMap()
expect(map.get('a')).toEqual(1)
const json = `{"result":true, "count":42}`;
const obj = JSON.parse(json) as UTSJSONObject;
let retStr = JSON.stringify(obj)
// #ifdef APP-ANDROID
expect(retStr).toEqual('{"result":true,"count":42}')
// #endif
})
test('parse Map', () => {
......
......@@ -59,7 +59,63 @@ export function testNumber() : Result {
expect(isFinite(1000 / 1)).toEqual(true);
expect(isFinite(910)).toEqual(true);
expect(isFinite(0)).toEqual(true);
// #ifdef APP-ANDROID
let aj2 = JSON.parse('{"a":1}') as UTSJSONObject;
let aNumber = aj2['a'] as UTSNumber
expect(isFinite(aNumber)).toEqual(true);
expect(UTSNumber.isFinite(aNumber)).toEqual(true);
expect(UTSNumber.isFinite(11.00)).toEqual(true);
expect(UTSNumber.isFinite(Double.POSITIVE_INFINITY)).toEqual(false);
// #endif
})
test('number-from-json-parse', () => {
type A = {
a:number
}
let aj = JSON.parse<A>('{"a":1}');
expect(aj?.a == 1).toEqual(true);
expect(aj?.a == 1 as number).toEqual(true);
expect(aj?.a == 1.0).toEqual(true);
expect(aj?.a == 1.0 as number).toEqual(true);
// #ifdef APP-ANDROID
expect(aj?.a === 1).toEqual(true);
expect(aj?.a === 1 as number).toEqual(true);
expect(aj?.a === 1.0).toEqual(true);
expect(aj?.a === 1.0 as number).toEqual(true);
let ki:Int = 1;
let kd:Double = 1.0;
let kf:Float = (1.0).toFloat();
expect(aj?.a == ki).toEqual(true);
expect(aj?.a == kd).toEqual(true);
expect(aj?.a == kf).toEqual(true);
expect(aj?.a === ki).toEqual(true);
expect(aj?.a === kd).toEqual(true);
expect(aj?.a === kf).toEqual(true);
// 对比JSON.parse 和 new 得到的对象属性
let newA = A(1)
expect(aj?.a == newA.a).toEqual(true);
expect(aj?.a === newA.a).toEqual(true);
newA.a = 1.0
expect(aj?.a == newA.a).toEqual(true);
expect(aj?.a === newA.a).toEqual(true);
newA.a = 1.1
expect(aj?.a == newA.a).toEqual(false);
expect(aj?.a === newA.a).toEqual(false);
let a10 = JSON.parse("10")
let b10 = JSON.parse("10")
let c10 = JSON.parse("10.0")
expect(a10 == b10).toEqual(true);
expect(a10 == c10).toEqual(true);
let aj2 = JSON.parse<A>('{"a":1}');
expect(aj?.a == aj2?.a).toEqual(true);
// #endif
})
test('isInteger', () => {
expect(Number.isInteger(12)).toEqual(true);
expect(Number.isInteger(12.01)).toEqual(false);
......@@ -69,6 +125,15 @@ export function testNumber() : Result {
test('isNaN', () => {
expect(isNaN(0)).toEqual(false);
// #ifdef APP-ANDROID
let aj2 = JSON.parse('{"a":1}') as UTSJSONObject;
let aNumber = aj2['a'] as UTSNumber
expect(isNaN(aNumber)).toEqual(false);
expect(UTSNumber.isNaN(aNumber)).toEqual(false);
expect(UTSNumber.isNaN(11)).toEqual(false);
expect(UTSNumber.isNaN(null)).toEqual(false);
expect(UTSNumber.isNaN(1 / 0)).toEqual(false);
// #endif
})
test('toPrecision', () => {
......
......@@ -26,6 +26,24 @@ export function testUTSJSONObject() : Result {
// #endif
})
test('setvalue-after-get', () => {
// #ifdef APP-ANDROID
let obj = {
"cars":[
{
name:"car1",
value:100
}
]
}
let cars = obj.getArray<UTSJSONObject>("cars")
cars![0].set("value",20)
let firstCar = obj.getJSON("cars[0]")
expect(firstCar!['value']).toEqual(20);
// #endif
})
test('assign-withtype', () => {
// #ifdef APP-ANDROID
type User = {
......
import { describe, test, expect, expectNumber, Result } from './tests.uts'
function obtainInnerObject(obj:Any | null):UTSJSONObject{
let jsonStr = console.getLogV2(obj).slice(19,-17)
let a = JSON.parseArray(jsonStr)![0]
......@@ -14,8 +13,29 @@ export function testConsole() : Result {
expect(obtainInnerObject(0.9).get("type")).toEqual("Double");
expect(obtainInnerObject(0.9).get("subType")).toEqual("number");
expect(obtainInnerObject(0.9).get("value")).toEqual("0.9");
// #endif
// #ifdef UNI-APP-X && APP-ANDROID
let pageInstance = new io.dcloud.uniapp.vue.ComponentInternalInstance()
expect(obtainInnerObject(pageInstance).get("className")).toEqual("io.dcloud.uniapp.vue.ComponentInternalInstance");
expect(obtainInnerObject(pageInstance).get("type")).toEqual("object");
// #endif
})
test('console-number-from-JSON-parse', () => {
// #ifdef APP-ANDROID
let aj2 = JSON.parse('{"a":1}') as UTSJSONObject;
console.log(aj2!['a'])
expect(obtainInnerObject(aj2!['a']).get("type")).toEqual("number");
expect(obtainInnerObject(aj2!['a']).get("subType")).toEqual("number");
// #endif
}
)
})
})
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册