Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
Hello UTS
提交
d6e9787d
H
Hello UTS
项目概览
DCloud
/
Hello UTS
通知
1595
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看板
提交
d6e9787d
编写于
10月 18, 2022
作者:
杜庆泉
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
消除大部分 uts 警告
上级
595ffcd2
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
51 addition
and
43 deletion
+51
-43
uni_modules/uts-nativepage/utssdk/app-android/index.uts
uni_modules/uts-nativepage/utssdk/app-android/index.uts
+25
-14
uni_modules/uts-nativepage/utssdk/app-android/libs/R.jar
uni_modules/uts-nativepage/utssdk/app-android/libs/R.jar
+0
-0
uni_modules/uts-nativepage/utssdk/app-android/res/layout/demo_activity.xml
...ativepage/utssdk/app-android/res/layout/demo_activity.xml
+1
-1
uni_modules/uts-screenshot-listener/utssdk/app-android/index.uts
...ules/uts-screenshot-listener/utssdk/app-android/index.uts
+16
-16
uni_modules/uts-syntaxcase/index.uts
uni_modules/uts-syntaxcase/index.uts
+0
-2
uni_modules/uts-tencentgeolocation/utssdk/app-android/index.uts
...dules/uts-tencentgeolocation/utssdk/app-android/index.uts
+9
-10
未找到文件。
uni_modules/uts-nativepage/utssdk/app-android/index.uts
浏览文件 @
d6e9787d
...
...
@@ -5,7 +5,6 @@ import Bundle from 'android.os.Bundle';
import R from 'io.dcloud.uni_modules.uts_nativepage.R';
import Intent from 'android.content.Intent';
import IntentFilter from 'android.content.IntentFilter';
import NotificationCompat from 'androidx.core.app.NotificationCompat';
import NotificationManager from 'android.app.NotificationManager';
import NotificationChannel from 'android.app.NotificationChannel';
...
...
@@ -25,6 +24,8 @@ import {
import Service from 'android.app.Service';
import System from 'java.lang.System';
class ForeService extends Service {
...
...
@@ -47,14 +48,18 @@ class ForeService extends Service {
let mBuilder = new NotificationCompat.Builder(this,"uts-test");
mBuilder.setAutoCancel(true) // 点击后让通知将消失
// 点击后让通知将消失
mBuilder.setAutoCancel(true)
mBuilder.setContentText("测试")
mBuilder.setContentTitle("测试")
mBuilder.setWhen(System.currentTimeMillis()) //通知产生的时间,会在通知信息里显示
mBuilder.setPriority(NotificationManager.IMPORTANCE_DEFAULT) //设置该通知优先级
mBuilder.setOngoing(false) //ture,设置他为一个正在进行的通知。他们通常是用来表示一个后台任务,用户积极参与(如播放音乐)或以某种方式正在等待,因此占用设备(如一个文件下载,同步操作,主动网络连接)
mBuilder.setDefaults(Notification.DEFAULT_ALL) //向通知添加声音、闪灯和振动效果的最简单、最一致的方式是使用当前的用户默认设置,使用defaults属性,可以组合:
//通知产生的时间,会在通知信息里显示
mBuilder.setWhen(System.currentTimeMillis())
//设置该通知优先级
mBuilder.setPriority(NotificationManager.IMPORTANCE_DEFAULT)
//ture,设置他为一个正在进行的通知。他们通常是用来表示一个后台任务,用户积极参与(如播放音乐)或以某种方式正在等待,因此占用设备(如一个文件下载,同步操作,主动网络连接)
mBuilder.setOngoing(false)
//向通知添加声音、闪灯和振动效果的最简单、最一致的方式是使用当前的用户默认设置,使用defaults属性,可以组合:
mBuilder.setDefaults(Notification.DEFAULT_ALL)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
...
...
@@ -72,7 +77,7 @@ class ForeService extends Service {
}
mBuilder.setContentIntent(null)
this.startForeground(
22
2, mBuilder.build())
this.startForeground(
10
2, mBuilder.build())
return super.onStartCommand(intent, flags, startId);
}
...
...
@@ -87,7 +92,11 @@ class ForeService extends Service {
class ScreenReceiver extends BroadcastReceiver() {
class ScreenReceiver extends BroadcastReceiver{
constructor (){
super();
}
override onReceive(context: Context, intent: Intent):void {
if (Intent.ACTION_SCREEN_OFF == intent.action) {
...
...
@@ -104,7 +113,7 @@ class StartServiceListener extends OnClickListener{
override onClick(v?: View):void{
var intent = Intent(getUniActivity(), ForeService().javaClass);
var intent =
new
Intent(getUniActivity(), ForeService().javaClass);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
getAppContext()!.startForegroundService(intent);
}
...
...
@@ -135,13 +144,15 @@ class StartBroadcastListener extends OnClickListener{
class DemoActivity extends Activity
()
{
class DemoActivity extends Activity{
constructor (){
super();
}
override onCreate(savedInstanceState?: Bundle):void {
super.onCreate(savedInstanceState)
setContentView(R.layout.demo_activity);
this.setContentView(R.layout.demo_activity);
let btn_start_service_front = findViewById<Button>(R.id.btn_start_service_front);
btn_start_service_front.setOnClickListener(new StartServiceListener());
...
...
uni_modules/uts-nativepage/utssdk/app-android/libs/R.jar
0 → 100644
浏览文件 @
d6e9787d
文件已添加
uni_modules/uts-nativepage/utssdk/app-android/res/layout/demo_activity.xml
浏览文件 @
d6e9787d
...
...
@@ -6,5 +6,5 @@
<TextView
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:text=
"demo text"
/>
<Button
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:text=
"开启前台服务(应用包活)"
android:id=
"@+id/btn_start_service_front"
/>
<Button
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:text=
"注册
网络
状态广播监听"
android:id=
"@+id/btn_start_screen_listen"
/>
<Button
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:text=
"注册
屏幕
状态广播监听"
android:id=
"@+id/btn_start_screen_listen"
/>
</LinearLayout>
\ No newline at end of file
uni_modules/uts-screenshot-listener/utssdk/app-android/index.uts
浏览文件 @
d6e9787d
...
...
@@ -12,6 +12,7 @@ import Build from "android.os.Build";
import FileObserver from "android.os.FileObserver";
import File from "java.io.File";
import Environment from "android.os.Environment";
import System from 'java.lang.System';
...
...
@@ -24,15 +25,10 @@ let screenOB: ScreenFileObserver | null = null;
*/
let lastFileObserverTime: number = 0;
/**
* 图片
捕捉定义
* 图片
被捕获的实现
*/
type OnImageCatchOptions = {
onImageCatchChange: (res: any) => void;
};
/**
* 图片捕捉监听变量
*/
let listenOption = new OnImageCatchOptions();
let imageChange: UTSCallback | null = null;
...
...
@@ -54,12 +50,12 @@ class ScreenFileObserver extends FileObserver {
}
override onEvent(event: Int, path?:
S
tring): void {
override onEvent(event: Int, path?:
s
tring): void {
// 只监听文件新增事件
if (event == FileObserver.CREATE) {
let newPath: string = new File(this.allScreen, path!).
path
;
let newPath: string = new File(this.allScreen, path!).
getPath()
;
let currentTime = System.currentTimeMillis();
if ((currentTime - lastFileObserverTime) < 1000) {
...
...
@@ -71,7 +67,8 @@ class ScreenFileObserver extends FileObserver {
let ret = {
image:newPath
}
listenOption.onImageCatchChange(ret)
imageChange!(ret);
}
}
}
...
...
@@ -99,20 +96,22 @@ export function requestPremission() {
/**
* 开启截图监听
*/
export function onUserCaptureScreen(
success: (res: any
) => void) {
export function onUserCaptureScreen(
callback: (res:UTSJSONObject
) => void) {
listenOption.onImageCatchChange = success;
// android 10 以上版本,使用监听文件的方式,更加可靠
let directory_screenshot: File;
imageChange = callback;
let directory_screenshot: File;
// 找到设备存放截屏文件的目录
let directory_pictures = new File(Environment.getExternalStorageDirectory(), Environment.DIRECTORY_PICTURES);
let directory_dcim = new File(Environment.getExternalStorageDirectory(), Environment.DIRECTORY_DCIM);
if (Build.MANUFACTURER.
equals("Xiaomi", true)
) {
if (Build.MANUFACTURER.
lowercase() === "xiaomi"
) {
directory_screenshot = new File(directory_dcim, "Screenshots");
} else {
directory_screenshot = new File(directory_pictures, "Screenshots");
...
...
@@ -121,6 +120,7 @@ export function onUserCaptureScreen(success: (res: any) => void) {
if (screenOB != null) {
screenOB!.stopWatching()
}
//开始监听
screenOB = new ScreenFileObserver(directory_screenshot.path)
screenOB!.startWatching()
...
...
uni_modules/uts-syntaxcase/index.uts
浏览文件 @
d6e9787d
import
{
log
}
from
"./utils.uts"
;
type
AsyncOptions
=
{
type
:
string
;
success
:
(
res
:
string
)
=>
void
;
...
...
@@ -16,7 +15,6 @@ export const MAX = 100;
*/
export
function
testSync
(
msg
:
string
)
{
console
.
log
(
"log test"
);
log
(
"log test1"
);
return
{
msg
:
`hello ${msg}`
,
};
...
...
uni_modules/uts-tencentgeolocation/utssdk/app-android/index.uts
浏览文件 @
d6e9787d
import {
onAppActivityPause,
onAppActivityRequestPermissionsResult,
getUniActivity,
getAppContext
...
...
@@ -76,21 +75,21 @@ class LocationOptionsWapper{
this.hostOption = option
}
onLocationChanged(location:TencentLocation , error:Int ,
reason:string){
onLocationChanged(location:TencentLocation ,
_
error:Int ,
_
reason:string){
let response = new LocationResponse();
response.name = location.name;
response.address = location.address;
response.latitude = location.latitude;
response.longitude = location.longitude;
let response = {
name:location.name,
address:location.address,
latitude:location.latitude,
longitude:location.longitude
};
this.hostOption.success(response);
}
onStatusUpdate(
name:string, status:Int,
desc:string){
onStatusUpdate(
_name:string, _status:Int, _
desc:string){
// 定位状态发生变化
//hostOption.onStatusUpdate(name,status,desc);
}
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录