提交 60420c7d 编写于 作者: 杜庆泉's avatar 杜庆泉

Merge branch 'dev' of gitcode.net:dcloud/hello-uts into dev

## 1.0.13
* update 4.17.2024051110-alpha
## 1.0.12
* update 4.16.2024051009-alpha
## 1.0.11
* update 4.14.2024042905-alpha
## 1.0.10
* update 4.13.2024042321-alpha
## 1.0.9
* update 4.12.2024041009-alpha
## 1.0.8
* update 4.06.2024032403-alpha
## 1.0.7
* update 4.05.2024032021-alpha
## 1.0.6
* update 4.04.2024031519-alpha
## 1.0.5
* update 4.03.2024031101-alpha
## 1.0.4
* update 4.02.2024030621-alpha
## 1.0.3
* update 4.01.2024020211-alpha
## 1.0.2
* update 4.0.2024012711-alpha
## 1.0.1(2023-12-19)
更多详情查看:[https://gitcode.net/dcloud/hello-uts/-/commits/alpha](https://gitcode.net/dcloud/hello-uts/-/commits/alpha)
{
"id": "hello-uts-alpha",
"name": "hello-uts-alpha",
"displayName": "hello-uts-alpha",
"version": "1.0.13",
"description": "UTS插件示例项目",
"repository": "https://gitcode.net/dcloud/hello-uts",
"keywords": [
"uts",
"示例工程"
],
"author": "",
"license": "MIT",
"dependencies": {},
"engines": {
"HBuilderX": "^3.99"
},
"dcloudext": {
"sale": {
"regular": {
"price": "0.00"
},
"sourcecode": {
"price": "0.00"
}
},
"contact": {
"qq": ""
},
"declaration": {
"ads": "无",
"data": "不采集任何数据",
"permissions": "- android.permission.INTERNET \n- android.permission.READ_EXTERNAL_STORAGE \n- android.permission.WRITE_EXTERNAL_STORAGE \n- android.permission.ACCESS_FINE_LOCATION \n- android.permission.ACCESS_COARSE_LOCATION \n- android.permission.ACCESS_NETWORK_STATE \n- android.permission.READ_MEDIA_IMAGES \n- android.permission.READ_MEDIA_VIDEO"
},
"npmurl": "",
"type": "uniapp-template-project"
},
"uni_modules": {
"dependencies": [],
"encrypt": [],
"platforms": {
"cloud": {
"tcb": "y",
"aliyun": "y"
},
"client": {
"App": {
"app-vue": "y",
"app-nvue": "n",
"app-uvue": "n"
},
"H5-mobile": {
"Safari": "n",
"Android Browser": "n",
"微信浏览器(Android)": "n",
"QQ浏览器(Android)": "n"
},
"H5-pc": {
"Chrome": "n",
"IE": "n",
"Edge": "n",
"Firefox": "n",
"Safari": "n"
},
"小程序": {
"微信": "n",
"阿里": "n",
"百度": "n",
"字节跳动": "n",
"QQ": "n",
"京东": "n",
"钉钉": "n",
"快手": "n",
"飞书": "n"
},
"快应用": {
"华为": "n",
"联盟": "n"
},
"Vue": {
"vue2": "y",
"vue3": "y"
}
}
}
}
}
\ No newline at end of file
......@@ -8,7 +8,7 @@
<button @tap="changeAction(1)">测试action play</button>
<button @tap="changeAction(2)">测试action pause</button>
<button @tap="changeAction(3)">测试action stop</button>
<uts-animation-view ref="animView" :path="animUrl" :autoplay="autoplay" :loop="loop" :action="action"
<uts-animation-view ref="animView" :path="animUrl" :autoplay="autoplay" :loop="loop" :action="action"
:hidden="hidden" @bindended="testAnimEnd" @click="lottieClickTest" @longpress="lottieLongpressTest"
:style="{width:widthNum+'rpx',height:heightNum+'px',background:yanse}">
</uts-animation-view>
......
<template>
<!-- #ifdef APP-ANDROID -->
<!-- #ifdef APP -->
<scroll-view style="flex: 1">
<!-- #endif -->
<view>
<view class="uni-padding-wrap uni-common-mt">
<view class="uni-hello-text"> 逐一点击执行,观察测试反馈 </view>
......@@ -19,7 +17,6 @@
<button @click="pathTestClick">路径转换测试</button>
<button @click="privacyStateClick">隐私协议状态测试</button>
<button @click="privacyStateCallBackClick">隐私协议回调测试</button>
<button @click="privacyStateCallBackClick">隐私协议回调测试</button>
<view class="uni-padding-wrap uni-common-mt">
<view class="uni-hello-text">
1. 当前页面已通过initAppLifecycle函数注册了生命周期监听。
......@@ -44,299 +41,346 @@
</view>
<button @tap="getDeviceInfoClick">获取设备基础信息</button>
<button @tap="getFileProviderUriClick">使用外部应用访问私有文件</button>
<!-- #ifdef APP-ANDROID -->
<button @tap="activityCallback">注册activity 回调方法</button>
<view class="uni-padding-wrap uni-common-mt">
<view class="uni-hello-text">
点击注册activity 回调方法后,可以手动切换其他APP再返回,可在控制台和界面观察事件日志
</view>
<button @tap="activityCallback">注册activity 回调方法</button>
<view class="uni-padding-wrap uni-common-mt">
<view class="uni-hello-text">
点击注册activity 回调方法后,可以手动切换其他APP再返回,可在控制台和界面观察事件日志
</view>
<view class="uni-padding-wrap uni-common-mt">
<view class="text-box" scroll-y="true">
<text>{{ cbText }}</text>
</view>
</view>
<view class="uni-padding-wrap uni-common-mt">
<view class="text-box" scroll-y="true">
<text>{{ cbText }}</text>
</view>
<button @tap="unRegActivityCallback">取消注册activity 回调方法</button>
<!-- #endif -->
</view>
<button @tap="unRegActivityCallback">取消注册activity 回调方法</button>
</view>
<!-- #ifdef APP -->
</scroll-view>
<!-- #endif -->
<!-- #endif -->
</template>
<script>
<!-- #ifdef APP-ANDROID -->
import {
getAppContextTest,
getUniActivityTest,
getJavaClassTest,
getAppTempPathTest,
typeofClickTest,
gotoSystemPermissionActivityTest,
arrayPermissionFlowTest,
singlePermissionFlowTest,
dispatchAsyncTest,
convert2AbsFullPathTest,
unRegLifecycle,
initAppLifecycle,
gotoCameraTake,
getDeviceInfoTest,
privacyStateTest,
privacyStateCallBackTest
} from '@/uni_modules/uts-platform-api'
// #ifdef APP-ANDROID
import {
import {
getAppContextTest,
getUniActivityTest,
getJavaClassTest,
getAppTempPathTest,
typeofClickTest,
gotoSystemPermissionActivityTest,
arrayPermissionFlowTest,
singlePermissionFlowTest,
dispatchAsyncTest,
convert2AbsFullPathTest,
unRegLifecycle,
initAppLifecycle,
gotoCameraTake,
getDeviceInfoTest,
privacyStateTest
} from '@/uni_modules/uts-platform-api'
// #ifdef APP-ANDROID
import {
UTSAcvitiyLifeCycleCallback,
UTSAcvitiyKeyEventCallback,
UTSActivityWindowCallback,
UTSActivityCallback,
UTSActivityComponentCallback,
onCallbackChange,
registerCallbacks,
unRegisterCallbacks
} from '@/uni_modules/uts-syntaxcase'
// #endif
onCallbackChange
} from '@/uni_modules/uts-syntaxcase'
// #endif
import File from 'java.io.File';
import Intent from 'android.content.Intent';
/**
* 测试在页面生命周期之外,使用api
*/
export default {
data() {
return {
text: '',
cbText: '',
selectImage: '',
callback: [] as Any[]
}
},
unmounted() {
// #ifdef APP-ANDROID
this.unRegActivityCallback()
// #endif
import File from 'java.io.File';
import Intent from 'android.content.Intent';
},
onLoad: function () {
let that = this
initAppLifecycle(function (eventLog) {
// 展示捕捉到的声明周期日志
let nextLine = that.text + eventLog
that.text = nextLine
let nextLineFlag = that.text + '\n'
that.text = nextLineFlag
})
},
methods: {
privacyStateClick() {
privacyStateTest(function (ret, desc) {
if (ret) {
uni.showToast({
title: '测试通过',
})
} else {
uni.showToast({
icon: 'none',
title: '失败:' + desc,
})
}
})
},
privacyStateCallBackClick() {
/**
* 测试在页面生命周期之外,使用api
*/
export default {
data() {
return {
text: '',
cbText:'',
selectImage: '',
callbackIds: [] as string[]
}
},
unmounted() {
// #ifdef APP-ANDROID
this.unRegActivityCallback()
// #endif
},
onLoad: function () {
let that = this
initAppLifecycle(function (eventLog) {
// 展示捕捉到的声明周期日志
let nextLine = that.text + eventLog
that.text = nextLine
let nextLineFlag = that.text + '\n'
that.text = nextLineFlag
})
},
methods: {
privacyStateClick() {
privacyStateTest(function (ret, desc) {
if (ret) {
let isAgree : boolean = true
const cb = (ret : PrivacyOption) => {
console.log('privacyStateCallBackTest->' + ret.isAgree)
if (ret.isAgree == isAgree) {
uni.showToast({
title: '测试通过'
})
} else {
uni.showToast({
icon: 'none',
title: '失败'
})
}
}
// 先重置用户同意状态
UTSAndroid.onPrivacyAgreeChange(cb)
UTSAndroid.setPrivacyAgree(isAgree)
UTSAndroid.offPrivacyAgreeChange(cb)
setTimeout(function () {
console.log('privacyStateCallBackTest->false')
UTSAndroid.setPrivacyAgree(false)
}, 5000);
},
getDeviceInfoClick() {
this.text = getDeviceInfoTest()
},
testGoOtherActivity() {
var that = this
let ret = gotoCameraTake(function (file) {
// 展示捕捉到的声明周期日志
console.log(file)
that.selectImage = 'file://' + file
})
if (!ret) {
uni.showToast({
title: '测试通过',
icon: 'none',
title: '测试失败',
})
}
},
testUnRegLifecycle() {
// 取消注册生命周期
unRegLifecycle()
},
getJavaClassClick() {
if (getJavaClassTest()) {
uni.showToast({
title: '测试通过'
})
} else {
uni.showToast({
icon: 'none',
title: '失败:' + desc,
icon: 'error',
title: '测试失败'
})
}
})
},
privacyStateCallBackClick() {
privacyStateCallBackTest(function(ret, desc) {
if (ret) {
},
getAppContextClick() {
if (getAppContextTest()) {
uni.showToast({
title: '测试通过'
title: '测试通过',
})
} else {
uni.showToast({
icon: 'none',
title: '失败:' + desc
icon: 'error',
title: '测试失败',
})
}
})
},
getDeviceInfoClick() {
this.text = getDeviceInfoTest()
},
testGoOtherActivity() {
var that = this
let ret = gotoCameraTake(function (file) {
// 展示捕捉到的声明周期日志
console.log(file)
that.selectImage = 'file://' + file
})
if (!ret) {
uni.showToast({
icon: 'none',
title: '测试失败',
})
}
},
testUnRegLifecycle() {
// 取消注册生命周期
unRegLifecycle()
},
getJavaClassClick() {
if (getJavaClassTest()) {
uni.showToast({
title: '测试通过'
})
} else {
uni.showToast({
icon: 'error',
title: '测试失败'
})
}
},
getAppContextClick() {
if (getAppContextTest()) {
uni.showToast({
title: '测试通过',
})
} else {
uni.showToast({
icon: 'error',
title: '测试失败',
})
}
},
},
getUniActivityClick() {
if (getUniActivityTest()) {
uni.showToast({
title: '测试通过',
})
} else {
uni.showToast({
icon: 'error',
title: '测试失败',
})
}
},
pathTestClick() {
if (convert2AbsFullPathTest()) {
uni.showToast({
title: '测试通过',
})
} else {
uni.showToast({
icon: 'error',
title: '测试失败',
})
}
},
getFileProviderUriClick() {
let file = new File(UTSAndroid.getResourcePath("static/logo.png"))
const uri = UTSAndroid.getFileProviderUri(file)
console.log("uri",uri.toString())
const intent = new Intent(Intent.ACTION_VIEW, uri)
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION) // 添加权限标志
const context = UTSAndroid.getUniActivity()!;
context.startActivity(intent);
},
getAppTempPathClick() {
if (getAppTempPathTest()) {
uni.showToast({
title: '测试通过',
})
} else {
uni.showToast({
icon: 'error',
title: '测试失败',
})
}
},
dispatchAsyncClick() {
dispatchAsyncTest(function (ret, desc) {
if (ret) {
getUniActivityClick() {
if (getUniActivityTest()) {
uni.showToast({
title: '测试通过',
})
} else {
uni.showToast({
icon: 'none',
title: '失败:' + desc,
icon: 'error',
title: '测试失败',
})
}
})
},
typeofClick() {
if (typeofClickTest()) {
uni.showToast({
title: '测试通过',
})
} else {
uni.showToast({
icon: 'error',
title: '测试失败',
})
}
},
gotoSystemPermissionActivityClick() {
gotoSystemPermissionActivityTest()
},
arrayPermissionFlowClick() {
arrayPermissionFlowTest(function (ret, desc) {
if (ret) {
},
pathTestClick() {
if (convert2AbsFullPathTest()) {
uni.showToast({
icon: 'none',
title: '测试通过',
})
} else {
uni.showToast({
icon: 'none',
title: '失败:' + desc,
icon: 'error',
title: '测试失败',
})
}
})
},
singlePermissionFlowClick() {
singlePermissionFlowTest(function (ret, desc) {
if (ret) {
},
getFileProviderUriClick() {
let file = new File(UTSAndroid.getResourcePath("static/logo.png"))
const uri = UTSAndroid.getFileProviderUri(file)
console.log("uri", uri.toString())
const intent = new Intent(Intent.ACTION_VIEW, uri)
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION) // 添加权限标志
const context = UTSAndroid.getUniActivity()!;
context.startActivity(intent);
},
getAppTempPathClick() {
if (getAppTempPathTest()) {
uni.showToast({
icon: 'none',
title: '测试通过',
})
} else {
uni.showToast({
icon: 'none',
title: '失败:' + desc,
icon: 'error',
title: '测试失败',
})
}
})
},
// #ifdef APP-ANDROID
activityCallback(){
var that = this
onCallbackChange(function (eventLog:string) {
// 展示捕捉到的声明周期日志
let nextLine = that.cbText + eventLog
that.cbText = nextLine
let nextLineFlag = that.cbText + '\n'
that.cbText = nextLineFlag
})
registerCallbacks()
},
unRegActivityCallback(){
unRegisterCallbacks()
}
// #endif
},
dispatchAsyncClick() {
dispatchAsyncTest(function (ret, desc) {
if (ret) {
uni.showToast({
title: '测试通过',
})
} else {
uni.showToast({
icon: 'none',
title: '失败:' + desc,
})
}
})
},
typeofClick() {
if (typeofClickTest()) {
uni.showToast({
title: '测试通过',
})
} else {
uni.showToast({
icon: 'error',
title: '测试失败',
})
}
},
gotoSystemPermissionActivityClick() {
gotoSystemPermissionActivityTest()
},
arrayPermissionFlowClick() {
arrayPermissionFlowTest(function (ret, desc) {
if (ret) {
uni.showToast({
icon: 'none',
title: '测试通过',
})
} else {
uni.showToast({
icon: 'none',
title: '失败:' + desc,
})
}
})
},
singlePermissionFlowClick() {
singlePermissionFlowTest(function (ret, desc) {
if (ret) {
uni.showToast({
icon: 'none',
title: '测试通过',
})
} else {
uni.showToast({
icon: 'none',
title: '失败:' + desc,
})
}
})
},
// #ifdef APP-ANDROID
// #ifdef UNI-APP-X
activityCallback() {
var that = this
onCallbackChange(function (eventLog : string) {
// 展示捕捉到的声明周期日志
let nextLine = that.cbText + eventLog
that.cbText = nextLine
let nextLineFlag = that.cbText + '\n'
that.cbText = nextLineFlag
})
let index = getCurrentPages().length - 1
let page = getCurrentPages()[index]
console.log('page route=' + page.route)
this.callback.push(new UTSAcvitiyLifeCycleCallback())
this.callback.push(new UTSActivityWindowCallback())
this.callback.push(new UTSAcvitiyKeyEventCallback())
this.callback.push(new UTSActivityCallback(), page.route)
this.callback.push(new UTSActivityComponentCallback())
this.callback.forEach((value) => {
if (value instanceof UTSAcvitiyLifeCycleCallback) {
UTSAndroid.onActivityCallback(value,page.route)
}
if (value instanceof UTSActivityWindowCallback) {
UTSAndroid.onActivityCallback(value)
}
if (value instanceof UTSAcvitiyKeyEventCallback) {
UTSAndroid.onActivityCallback(value)
}
if (value instanceof UTSActivityCallback) {
UTSAndroid.onActivityCallback(value)
}
if (value instanceof UTSActivityComponentCallback) {
UTSAndroid.onActivityCallback(value)
}
},
}
<!-- #endif -->
})
},
unRegActivityCallback() {
this.callback.forEach((value) => {
if (value instanceof UTSAcvitiyLifeCycleCallback) {
UTSAndroid.offActivityCallback(value)
}
if (value instanceof UTSActivityWindowCallback) {
UTSAndroid.offActivityCallback(value)
}
if (value instanceof UTSAcvitiyKeyEventCallback) {
UTSAndroid.offActivityCallback(value)
}
if (value instanceof UTSActivityCallback) {
UTSAndroid.offActivityCallback(value)
}
if (value instanceof UTSActivityComponentCallback) {
UTSAndroid.offActivityCallback(value)
}
})
}
// #endif
// #endif
},
}
</script>
<style>
.testButton {
width: 100%;
}
</style>
.testButton {
width: 100%;
}
</style>
\ No newline at end of file
......@@ -22,11 +22,11 @@ import AlertDialog from 'android.app.AlertDialog';
import DialogInterface from 'android.content.DialogInterface';
import EditText from 'android.widget.EditText';
import array from 'android.R.array';
import File from 'java.io.File';
/**
* 定时任务参数封装
*/
......
import { UIImageView , UIImage , UIScreen } from 'UIKit';
import { DispatchQueue } from 'Dispatch';
import { UTSiOS } from "DCloudUTSFoundation";
export function addViewToDecorView() { }
......
......@@ -227,6 +227,7 @@
}
}
</script>
<style>
/* 定义默认样式值, 组件使用者没有配置时使用 */
.defaultStyles {
......
......@@ -83,18 +83,23 @@ export function privacyStateTest(callback : (ret : boolean, desc : string) => vo
export function privacyStateCallBackTest(callback : (ret : boolean, desc : string) => void) {
let isAgree : boolean = true
const cb = (ret : boolean) => {
console.log('privacyStateCallBackTest->' + ret)
if (ret == isAgree) {
const cb = (ret : PrivacyOption) => {
console.log('privacyStateCallBackTest->' + ret.isAgree)
if (ret.isAgree == isAgree) {
callback(true, "pass")
} else {
callback(false, "callback error")
}
}
// 先重置用户同意状态
const callBackId=UTSAndroid.registerPrivacyAgreeListener(cb)
UTSAndroid.onPrivacyAgreeChange(cb)
UTSAndroid.setPrivacyAgree(isAgree)
UTSAndroid.unRegisterPrivacyAgreeListener(callBackId)
UTSAndroid.offPrivacyAgreeChange(cb)
setTimeout(function () {
console.log('privacyStateCallBackTest->false')
UTSAndroid.setPrivacyAgree(false)
}, 5000);
}
/**
......
......@@ -178,32 +178,10 @@ import ActionMode from 'android.view.ActionMode';
// export let onCallBackChange: (event: string) => void = (res) => {};
let callback : (eventLog : string) => void = (res) => { };
let callbackIds : string[] = [];
export function onCallbackChange(fn : (eventLog : string) => void) {
callback = fn
}
export function registerCallbacks() {
let reg1 = UTSAndroid.registerActivityCallback(new UTSAcvitiyLifeCycleCallback())
let reg2 = UTSAndroid.registerActivityCallback(new UTSActivityWindowCallback())
let reg3 = UTSAndroid.registerActivityCallback(new UTSAcvitiyKeyEventCallback())
let reg4 = UTSAndroid.registerActivityCallback(new UTSActivityCallback())
let reg5 = UTSAndroid.registerActivityCallback(new UTSActivityComponentCallback())
callbackIds.push(reg1)
callbackIds.push(reg2)
callbackIds.push(reg3)
callbackIds.push(reg4)
callbackIds.push(reg5)
}
export function unRegisterCallbacks() {
callbackIds.forEach((value) => {
console.log(value)
UTSAndroid.unRegisterActivityCallback(value)
})
}
export class UTSAcvitiyLifeCycleCallback extends UniActivityLifeCycleCallback {
constructor() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册