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

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

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