Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
Hello UTS
提交
628a4a4a
H
Hello UTS
项目概览
DCloud
/
Hello UTS
通知
1598
Star
27
Fork
9
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
2
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
Hello UTS
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
2
Issue
2
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
628a4a4a
编写于
10月 09, 2022
作者:
杜庆泉
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修改uts插件 可能出现编译告警的源码
上级
531e8c82
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
87 addition
and
80 deletion
+87
-80
pages/SystemAPI/SystemAPI.vue
pages/SystemAPI/SystemAPI.vue
+2
-2
pages/advance/advance.vue
pages/advance/advance.vue
+45
-52
uni_modules/uts-advance/utssdk/app-android/index.uts
uni_modules/uts-advance/utssdk/app-android/index.uts
+0
-2
uni_modules/uts-nativepage/utssdk/app-android/index.uts
uni_modules/uts-nativepage/utssdk/app-android/index.uts
+2
-2
uni_modules/uts-nativepage/utssdk/app-android/libs/androix-core-1.0.0.jar
...nativepage/utssdk/app-android/libs/androix-core-1.0.0.jar
+0
-0
uni_modules/uts-screenshot-listener/utssdk/app-android/index.uts
...ules/uts-screenshot-listener/utssdk/app-android/index.uts
+38
-22
uni_modules/uts-screenshot-listener/utssdk/app-android/libs/androix-core-1.0.0.jar
...t-listener/utssdk/app-android/libs/androix-core-1.0.0.jar
+0
-0
uni_modules/uts-tencentgeolocation/utssdk/app-android/libs/androix-core-1.0.0.jar
...eolocation/utssdk/app-android/libs/androix-core-1.0.0.jar
+0
-0
uni_modules/uts-tencentgeolocation/utssdk/app-android/libs/armeabi-v7a/androix-core-1.0.0.jar
...tssdk/app-android/libs/armeabi-v7a/androix-core-1.0.0.jar
+0
-0
未找到文件。
pages/SystemAPI/SystemAPI.vue
浏览文件 @
628a4a4a
...
...
@@ -7,7 +7,7 @@
<button
type=
"primary"
@
tap=
"testScreenShotPremission"
>
准备截屏监听权限
</button>
<button
type=
"primary"
@
tap=
"testScreenShotListen"
>
监听截屏事件
</button>
<button
type=
"primary"
@
tap=
"testScreenShotOff"
>
关闭截屏监听
</button>
<image
:src=
"screenImage"
class=
"screenImage"
mode=
"aspectFit"
></image>
<image
:src=
"screenImage"
class=
"screenImage"
mode=
"aspectFit"
></image>
</view>
</view>
</
template
>
...
...
@@ -24,7 +24,7 @@
data
()
{
return
{
title
:
'
系统API示例
'
,
screenImage
:
"
../../static/logo.png
"
screenImage
:
""
}
},
onUnload
:
function
()
{},
...
...
pages/advance/advance.vue
浏览文件 @
628a4a4a
...
...
@@ -2,68 +2,57 @@
<view>
<page-head
:title=
"title"
></page-head>
<uni-section
title=
"任务"
type=
"line"
>
<uni-collapse>
<uni-collapse-item
title=
"延迟任务"
>
<button
type=
"primary"
@
tap=
"testTimer"
>
延迟任务
</button>
</uni-collapse-item>
<uni-collapse>
<uni-collapse-item
title=
"延迟任务"
>
<button
@
tap=
"testTimer"
class=
"itemButton"
>
开启
延迟任务
</button>
</uni-collapse-item>
<uni-collapse-item
title=
"定时任务"
>
<button
type=
"primary"
@
tap=
"testInterval"
>
定时任务
</button>
<button
type=
"primary"
@
tap=
"testClearInterval
"
>
关闭定时任务
</button>
</uni-collapse-item>
<uni-collapse-item
title=
"定时任务"
>
<button
@
tap=
"testInterval"
class=
"itemButton"
>
开启
定时任务
</button>
<button
@
tap=
"testClearInterval"
class=
"itemButton
"
>
关闭定时任务
</button>
</uni-collapse-item>
</uni-collapse>
</uni-collapse>
</uni-section>
<uni-collapse>
<uni-collapse-item
title=
"进阶语法示例"
>
<button
type=
"primary"
class=
"itemButton"
@
tap=
"testSyntax"
>
进阶语法示例
</button>
</uni-collapse-item>
</uni-collapse>
<uni-section
title=
"语法"
type=
"line"
>
<uni-collapse>
<uni-collapse-item
title=
"进阶语法示例"
>
<button
type=
"primary"
@
tap=
"testSyntax"
>
进阶语法示例
</button>
</uni-collapse-item>
</uni-collapse>
</uni-section>
<uni-section
title=
"资源"
type=
"line"
>
<uni-collapse>
<uni-collapse-item
title=
"资源加载"
>
<button
type=
"primary"
@
tap=
"gotoResourceDemo"
>
资源加载示例
</button>
</uni-collapse-item>
</uni-collapse>
</uni-section>
<uni-collapse>
<uni-collapse-item
title=
"图片加载示例"
>
<button
type=
"primary"
@
tap=
"gotoResourceDemo"
class=
"itemButton"
>
资源加载示例
</button>
</uni-collapse-item>
<uni-collapse-item
title=
"asset操作示例"
>
<button
type=
"primary"
class=
"itemButton"
>
播放asset音频(需自定义基座)
</button>
</uni-collapse-item>
<uni-section
title=
"内置函数"
type=
"line"
>
<uni-collapse>
<uni-collapse-item
title=
"生命周期"
>
<button
type=
"primary"
@
tap=
"testLifecyle"
>
activity生命周期监听
</button>
</uni-collapse-item>
</uni-collapse>
</uni-section>
<uni-section
title=
"原生UI"
type=
"line"
>
<uni-collapse>
<uni-collapse-item
title=
"DecorView操作示例"
>
<button
type=
"primary"
@
tap=
"testAddToDecorView"
>
添加TextView至视图顶层
</button>
<button
type=
"primary"
@
tap=
"testRemoveToDecorView"
>
移除视图顶层的TextView
</button>
</uni-collapse-item>
</uni-collapse>
</uni-section>
</uni-collapse>
<uni-collapse>
<uni-collapse-item
title=
"生命周期"
>
<button
type=
"primary"
@
tap=
"testLifecyle"
class=
"itemButton"
>
activity生命周期监听
</button>
</uni-collapse-item>
</uni-collapse>
<uni-collapse>
<uni-collapse-item
title=
"DecorView操作示例"
>
<button
type=
"primary"
@
tap=
"testAddToDecorView"
class=
"itemButton"
>
添加TextView至视图顶层
</button>
<button
type=
"primary"
@
tap=
"testRemoveToDecorView"
class=
"itemButton"
>
移除视图顶层的TextView
</button>
</uni-collapse-item>
</uni-collapse>
</view>
...
...
@@ -270,6 +259,10 @@
</
script
>
<
style
>
.itemButton
{
margin-top
:
5px
;
margin-bottom
:
5px
;
margin-left
:
10px
;
margin-right
:
10px
;
}
</
style
>
uni_modules/uts-advance/utssdk/app-android/index.uts
浏览文件 @
628a4a4a
import Rect from "android.graphics.Rect";
import Color from "android.graphics.Color";
import TextView from "android.widget.TextView";
import FrameLayout from "android.widget.FrameLayout";
import ViewGroup from "android.view.ViewGroup";
import Gravity from "android.view.Gravity";
import Runnable from 'java.lang.Runnable';
import Exception from 'java.lang.Exception';
import MediaPlayer from 'android.media.MediaPlayer';
import logo from "../../static/logo.png";
...
...
uni_modules/uts-nativepage/utssdk/app-android/index.uts
浏览文件 @
628a4a4a
...
...
@@ -46,14 +46,14 @@ class ForeService extends Service {
override onStartCommand(intent:Intent ,flags:Int ,startId:Int ):Int {
let mBuilder = new NotificationCompat.Builder(this);
let mBuilder = new NotificationCompat.Builder(this
,"uts-test"
);
mBuilder.setAutoCancel(true) // 点击后让通知将消失
mBuilder.setContentText("测试")
mBuilder.setContentTitle("测试")
mBuilder.setWhen(System.currentTimeMillis()) //通知产生的时间,会在通知信息里显示
mBuilder.setPriority(Notification
.PRIORITY
_DEFAULT) //设置该通知优先级
mBuilder.setPriority(Notification
Manager.IMPORTANCE
_DEFAULT) //设置该通知优先级
mBuilder.setOngoing(false) //ture,设置他为一个正在进行的通知。他们通常是用来表示一个后台任务,用户积极参与(如播放音乐)或以某种方式正在等待,因此占用设备(如一个文件下载,同步操作,主动网络连接)
mBuilder.setDefaults(Notification.DEFAULT_ALL) //向通知添加声音、闪灯和振动效果的最简单、最一致的方式是使用当前的用户默认设置,使用defaults属性,可以组合:
...
...
uni_modules/uts-nativepage/utssdk/app-android/libs/androix-core-1.0.0
-自定义基座时移除
.jar
→
uni_modules/uts-nativepage/utssdk/app-android/libs/androix-core-1.0.0.jar
浏览文件 @
628a4a4a
文件已移动
uni_modules/uts-screenshot-listener/utssdk/app-android/index.uts
浏览文件 @
628a4a4a
import {
onAppActivityDestroy,
onAppActivityPause,
onAppActivityResume,
onAppActivityBack,
getUniActivity,
getAppContext
getUniActivity
} from "io.dcloud.uts.android";
...
...
@@ -23,7 +18,6 @@ import Cursor from "android.database.Cursor";
import ContentObserver from "android.database.ContentObserver";
import Uri from "android.net.Uri";
import BitmapFactory from "android.graphics.BitmapFactory";
import Display from "android.view.Display";
import Locale from "java.util.Locale";
import WindowManager from "android.view.WindowManager";
import FileObserver from "android.os.FileObserver";
...
...
@@ -35,7 +29,7 @@ import Environment from "android.os.Environment";
* 读取媒体数据库时需要读取的列,其中 width、height 字段在 API 16 之后才有
*/
const MEDIA_PROJECTIONS_API_16 = arrayOf(
MediaStore.Images.ImageColumns.DATA
,
"_data"
,
MediaStore.Images.ImageColumns.DATE_TAKEN,
MediaStore.Images.ImageColumns.WIDTH,
MediaStore.Images.ImageColumns.HEIGHT
...
...
@@ -63,19 +57,24 @@ class ScreenFileObserver extends FileObserver {
constructor(screenFile: File) {
super(screenFile)
this.allScreen = screenFile;
console.log(allScreen);
}
override onEvent(event: Int, path?: String): void {
if (event == FileObserver.CREATE) {
var newPath: string = new File(allScreen, path
).path;
let newPath: string = new File(allScreen, path!
).path;
let currentTime = System.currentTimeMillis();
if ((currentTime - lastFileObserverTime) < 1000) {
// 本地截屏行为比上一次超过1000ms,才认为是一个有效的时间
return;
}
console.log(path);
lastFileObserverTime = System.currentTimeMillis()
listenOption
!
.onImageCatchChange(newPath)
listenOption.onImageCatchChange(newPath)
}
}
}
...
...
@@ -120,8 +119,7 @@ function handleMediaContentChange(contentUri: Uri) {
MEDIA_PROJECTIONS_API_16,
null, null,
MediaStore.Images.ImageColumns.DATE_ADDED + " desc limit 1"
)!
)
if (cursor == null) {
return
...
...
@@ -132,7 +130,7 @@ function handleMediaContentChange(contentUri: Uri) {
}
// 获取各列的索引
let dataIndex = cursor.getColumnIndex(
MediaStore.Images.ImageColumns.DATA
)
let dataIndex = cursor.getColumnIndex(
"_data"
)
let dateTakenIndex = cursor.getColumnIndex(MediaStore.Images.ImageColumns.DATE_TAKEN)
let widthIndex = cursor.getColumnIndex(MediaStore.Images.ImageColumns.WIDTH)
let heightIndex = cursor.getColumnIndex(MediaStore.Images.ImageColumns.HEIGHT)
...
...
@@ -140,8 +138,8 @@ function handleMediaContentChange(contentUri: Uri) {
// 获取行数据
let data = cursor.getString(dataIndex)
let dateTaken = cursor.getLong(dateTakenIndex)
let width
= 0
;
let height
= 0
;
let width
:number
;
let height
:number
;
if (widthIndex >= 0 && heightIndex >= 0) {
width = cursor.getInt(widthIndex)
height = cursor.getInt(heightIndex)
...
...
@@ -165,7 +163,7 @@ function handleMediaContentChange(contentUri: Uri) {
/**
* 获取媒体库内置图像的大小
*/
function getImageSize(imagePath: string): Point
{
function getImageSize(imagePath: string): Point{
let options = BitmapFactory.Options()
options.inJustDecodeBounds = true
BitmapFactory.decodeFile(imagePath, options)
...
...
@@ -179,7 +177,7 @@ function handleMediaRowData(data: String, dateTaken: Long, width: Int, height: I
if (checkScreenShot(data, dateTaken, width, height)) {
if (!checkCallback(data)) {
listenOption
!
.onImageCatchChange(data)
listenOption.onImageCatchChange(data)
}
} else {
// 如果在观察区间媒体数据库有数据改变,又不符合截屏规则
...
...
@@ -247,8 +245,13 @@ function getRealScreenSize(): Point | null {
let screenSize: Point = Point();
try {
let windowManager = getUniActivity()!.getSystemService(Context.WINDOW_SERVICE) as WindowManager
let defaultDisplay = windowManager.defaultDisplay
defaultDisplay.getRealSize(screenSize)
screenSize.x = windowManager.currentWindowMetrics.bounds.width();
screenSize.y = windowManager.currentWindowMetrics.bounds.height();
// let defaultDisplay = windowManager.defaultDisplay
// let defaultDisplay = getUniActivity()!.display
// defaultDisplay!.getRealSize(screenSize)
console.log(screenSize);
} catch (e) {
e.printStackTrace()
}
...
...
@@ -302,13 +305,25 @@ export function requestPremission() {
*/
export function onUserCaptureScreen(success: (res: string) => void) {
listenOption.onImageCatchChange = success;
console.log(Build.VERSION.SDK_INT);
console.log(Build.VERSION_CODES.Q);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
// android 10 以上版本,使用监听文件的方式,更加可靠
var
directory_screenshot: File;
let
directory_screenshot: File;
var directory_pictures = File(Environment.getExternalStorageDirectory(), Environment.DIRECTORY_PICTURES);
var directory_dcim = File(Environment.getExternalStorageDirectory(), Environment.DIRECTORY_DCIM);
// let directory_pictures = getUniActivity()!.getExternalFilesDir(Environment.DIRECTORY_PICTURES)
// let directory_dcim = getUniActivity()!.getExternalFilesDir(Environment.DIRECTORY_DCIM)
let directory_pictures = File(Environment.getExternalStorageDirectory(), Environment.DIRECTORY_PICTURES);
let directory_dcim = File(Environment.getExternalStorageDirectory(), Environment.DIRECTORY_DCIM);
console.log(directory_pictures);
console.log(directory_dcim);
// console.log(directory_pictures2);
// console.log(directory_dcim2);
if (Build.MANUFACTURER.equals("Xiaomi", true)) {
directory_screenshot = File(directory_dcim, "Screenshots");
...
...
@@ -349,6 +364,7 @@ export function onUserCaptureScreen(success: (res: string) => void) {
* 关闭截屏监听
*/
export function offUserCaptureScreen(success: (res: string) => void) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
// android 10以上,关闭监听通过移除文件监听器实现
if (screenOB != null) {
...
...
uni_modules/uts-screenshot-listener/utssdk/app-android/libs/androix-core-1.0.0
-自定义基座时移除
.jar
→
uni_modules/uts-screenshot-listener/utssdk/app-android/libs/androix-core-1.0.0.jar
浏览文件 @
628a4a4a
文件已移动
uni_modules/uts-tencentgeolocation/utssdk/app-android/libs/androix-core-1.0.0
-自定义基座时移除
.jar
→
uni_modules/uts-tencentgeolocation/utssdk/app-android/libs/androix-core-1.0.0.jar
浏览文件 @
628a4a4a
文件已移动
uni_modules/uts-tencentgeolocation/utssdk/app-android/libs/armeabi-v7a/androix-core-1.0.0.jar
0 → 100644
浏览文件 @
628a4a4a
文件已添加
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录