提交 7568a738 编写于 作者: 杜庆泉's avatar 杜庆泉

android 适配3.7.7 新的编译校验规则

上级 40663c1e
......@@ -56,7 +56,8 @@
*/
testDoSthWithJSON: function () {
var inputObject = {
inputText:this.stringParam
inputText:this.stringParam,
errCode:0
}
UTSHello.callWithJSONParam({
......
......@@ -9,90 +9,87 @@ import DialogInterface from 'android.content.DialogInterface';
import EditText from 'android.widget.EditText';
@Suppress("UNUSED_PARAMETER")
export function showAlert(_title: string|null, _message: string|null, _result: (index: Number) => void) {
// todo
let uiRunable = new DialogUIRunnable(null,_title!,_message!,"",false);
export function showAlert(_title : string | null, _message : string | null, _result : (index : Number) => void) {
let uiRunable = new DialogUIRunnable(null, _title!, _message!, "", false);
UTSAndroid.getUniActivity()!.runOnUiThread(uiRunable)
}
@Suppress("UNUSED_PARAMETER")
export function showPrompt(_title: string|null,_message: string|null,_placeholder: string|null, success: (content: string)=>void) {
let uiRunable = new DialogUIRunnable(success,_title!,_message!,_placeholder!,true);
export function showPrompt(_title : string | null, _message : string | null, _placeholder : string | null, success : (content : string) => void) {
let uiRunable = new DialogUIRunnable(success, _title!, _message!, _placeholder!, true);
UTSAndroid.getUniActivity()!.runOnUiThread(uiRunable)
}
/**
* 用户输入对话框监听器
*/
class DialogListener extends DialogInterface.OnClickListener{
inputET:EditText
callback:UTSCallback
constructor(et:EditText,cb:UTSCallback){
* 用户输入对话框监听器
*/
class DialogListener extends DialogInterface.OnClickListener {
inputET : EditText
callback : (content : string) => void
constructor(et : EditText, cb : (content : string) => void) {
super();
this.callback = cb;
this.inputET = et;
}
override onClick(_dialog:DialogInterface,_arg1:Int ):void {
override onClick(_dialog : DialogInterface, _arg1 : Int) : void {
//数据获取
let input = this.inputET.getText().toString()
this.callback(input);
Toast.makeText(UTSAndroid.getUniActivity(),input,
Toast.LENGTH_LONG).show();
Toast.makeText(UTSAndroid.getUniActivity(), input,
Toast.LENGTH_LONG).show();
}
}
/**
* Dialog ui任务封装
*/
* Dialog ui任务封装
*/
class DialogUIRunnable extends Runnable {
callback:UTSCallback|null = null
title: string
message: string
placeholder: string
needInput:boolean
constructor(success?:UTSCallback,title: string,message: string,placeholder: string,needInput:boolean){
callback ?: (content : string) => void = null
title : string
message : string
placeholder : string
needInput : boolean
constructor(success ?: (content : string) => void, title : string, message : string, placeholder : string, needInput : boolean) {
super();
if(success != null){
if (success != null) {
this.callback = success
}
this.title = title
this.message = message
this.placeholder = placeholder
this.needInput = needInput
}
override run():void {
if(this.needInput){
override run() : void {
if (this.needInput) {
let et = new EditText(UTSAndroid.getUniActivity());
et.setText(this.placeholder);
new AlertDialog.Builder(UTSAndroid.getUniActivity())
.setTitle(this.title)
.setMessage(this.message)
.setIcon(android.R.drawable.ic_dialog_info).setView(et)
.setPositiveButton("确定", new DialogListener(et,this.callback!))
.setNegativeButton("取消", null).show();
}else{
.setTitle(this.title)
.setMessage(this.message)
.setIcon(android.R.drawable.ic_dialog_info).setView(et)
.setPositiveButton("确定", new DialogListener(et, this.callback!))
.setNegativeButton("取消", null).show();
} else {
new AlertDialog.Builder(UTSAndroid.getUniActivity())
.setTitle(this.title)
.setMessage(this.message)
.setIcon(android.R.drawable.ic_dialog_info)
.setNegativeButton("取消", null).show();
.setTitle(this.title)
.setMessage(this.message)
.setIcon(android.R.drawable.ic_dialog_info)
.setNegativeButton("取消", null).show();
}
}
};
}
};
\ No newline at end of file
......@@ -15,7 +15,6 @@ type JsonParamOptions = {
complete: (res: string) => void;
};
/**
* 导出无参的UTS函数
* @param opts
......
......@@ -4,6 +4,8 @@ import {
UTSAndroid
} from "io.dcloud.uts";
import { OnUserCaptureScreen, OffUserCaptureScreen, UserCaptureScreenCallback, OnUserCaptureScreenResult } from "../interface.uts"
import ActivityCompat from "androidx.core.app.ActivityCompat";
import Manifest from "android.Manifest";
......@@ -27,7 +29,7 @@ let lastFileObserverTime: number = 0;
/**
* 图片被捕获的实现
*/
let imageChange: UTSCallback | null = null;
let imageChange: UserCaptureScreenCallback | null = null;
......@@ -64,11 +66,13 @@ class ScreenFileObserver extends FileObserver {
}
lastFileObserverTime = System.currentTimeMillis()
let ret = {
errCode:1,
const ret: OnUserCaptureScreenResult = {
errCode: 0,
errSubject: "uni-usercapturescreen",
errMsg: "onUserCaptureScreen:ok",
image:newPath
}
imageChange!(ret);
}
}
......@@ -77,15 +81,11 @@ class ScreenFileObserver extends FileObserver {
/**
* 开启截图监听
*/
@Suppress("DEPRECATION")
export function onUserCaptureScreen(callback: (res:object) => void) {
export function onUserCaptureScreen(callback: UserCaptureScreenCallback) {
// 检查相关权限是否已经具备
if (ActivityCompat.checkSelfPermission(UTSAndroid.getUniActivity()!, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
......@@ -93,8 +93,11 @@ export function onUserCaptureScreen(callback: (res:object) => void) {
ActivityCompat.requestPermissions(UTSAndroid.getUniActivity()!, arrayOf(Manifest.permission.READ_EXTERNAL_STORAGE), 1001)
// 因权限缺失导致监听失败
let ret = {
errCode:-1
const ret: OnUserCaptureScreenResult = {
errCode: -1,
errSubject: "uni-usercapturescreen",
errMsg: "onUserCaptureScreen:fail",
image: null
}
callback(ret);
return ;
......@@ -121,8 +124,11 @@ export function onUserCaptureScreen(callback: (res:object) => void) {
screenOB!.startWatching()
// 监听成功
let ret = {
errCode:0
const ret: OnUserCaptureScreenResult = {
errCode: 0,
errSubject: "uni-usercapturescreen",
errMsg: "onUserCaptureScreen:ok",
image: null
}
callback(ret);
......
......@@ -26,7 +26,7 @@ class CaptureScreenTool {
errCode: 0,
errSubject: "uni-usercapturescreen",
errMsg: "onUserCaptureScreen:ok",
path: null
image: null
}
this.listener?.(res)
}
......@@ -39,7 +39,7 @@ class CaptureScreenTool {
errCode: 0,
errSubject: "uni-usercapturescreen",
errMsg: "offUserCaptureScreen:ok",
path: null
image: null
}
callback?.(res)
}
......
......@@ -16,7 +16,7 @@ export type OnUserCaptureScreenResult = {
/**
* 截屏文件路径(仅Android返回)
*/
path : string | null
image : string | null
}
export type UserCaptureScreenCallback = (res: OnUserCaptureScreenResult) => void
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册