diff --git a/pages/SystemAPI/SystemAPI.vue b/pages/SystemAPI/SystemAPI.vue index b39f94bfe19adf078277e7ca1e640c1849213d56..8185475af594c221c3a094dc3a4b8a1dc75c100b 100644 --- a/pages/SystemAPI/SystemAPI.vue +++ b/pages/SystemAPI/SystemAPI.vue @@ -7,7 +7,7 @@ - + @@ -24,7 +24,7 @@ data() { return { title: '系统API示例', - screenImage:"../../static/logo.png" + screenImage:"" } }, onUnload: function() {}, diff --git a/pages/advance/advance.vue b/pages/advance/advance.vue index 1fd4739db1ef8d12907d2f620f89b15aa5711016..cb7ffe1f732a4c4f21eaa2219dafcec2f874fbc1 100644 --- a/pages/advance/advance.vue +++ b/pages/advance/advance.vue @@ -2,68 +2,57 @@ - - - - - + + + + - - - - + + + + - + - + + + + + - - - - - - - - - - - - - - - - - - + + + + + + + - - - - - - - - - - - - - - - - - - - - + - + + + + + + + + + + + + + + + + + @@ -270,6 +259,10 @@ diff --git a/uni_modules/uts-advance/utssdk/app-android/index.uts b/uni_modules/uts-advance/utssdk/app-android/index.uts index f580459e5dbf66bd62029bcea0256db0236d4683..ae52cb01e3280e9e8632903f840eda57f2784a7e 100644 --- a/uni_modules/uts-advance/utssdk/app-android/index.uts +++ b/uni_modules/uts-advance/utssdk/app-android/index.uts @@ -1,11 +1,9 @@ -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"; diff --git a/uni_modules/uts-nativepage/utssdk/app-android/index.uts b/uni_modules/uts-nativepage/utssdk/app-android/index.uts index 5e264bdf26657579ac3c7897c3d7b4460e56f625..c2a5ac1d69d1f152a57dfba75ce2839fe72d4ce5 100644 --- a/uni_modules/uts-nativepage/utssdk/app-android/index.uts +++ b/uni_modules/uts-nativepage/utssdk/app-android/index.uts @@ -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(NotificationManager.IMPORTANCE_DEFAULT) //设置该通知优先级 mBuilder.setOngoing(false) //ture,设置他为一个正在进行的通知。他们通常是用来表示一个后台任务,用户积极参与(如播放音乐)或以某种方式正在等待,因此占用设备(如一个文件下载,同步操作,主动网络连接) mBuilder.setDefaults(Notification.DEFAULT_ALL) //向通知添加声音、闪灯和振动效果的最简单、最一致的方式是使用当前的用户默认设置,使用defaults属性,可以组合: diff --git "a/uni_modules/uts-nativepage/utssdk/app-android/libs/androix-core-1.0.0-\350\207\252\345\256\232\344\271\211\345\237\272\345\272\247\346\227\266\347\247\273\351\231\244.jar" b/uni_modules/uts-nativepage/utssdk/app-android/libs/androix-core-1.0.0.jar similarity index 100% rename from "uni_modules/uts-nativepage/utssdk/app-android/libs/androix-core-1.0.0-\350\207\252\345\256\232\344\271\211\345\237\272\345\272\247\346\227\266\347\247\273\351\231\244.jar" rename to uni_modules/uts-nativepage/utssdk/app-android/libs/androix-core-1.0.0.jar diff --git a/uni_modules/uts-screenshot-listener/utssdk/app-android/index.uts b/uni_modules/uts-screenshot-listener/utssdk/app-android/index.uts index 6954b01aa117229b17701db7570fa89d0a88d175..06a0a6de610aa48ac2a762444ca13953a1a52d2d 100644 --- a/uni_modules/uts-screenshot-listener/utssdk/app-android/index.uts +++ b/uni_modules/uts-screenshot-listener/utssdk/app-android/index.uts @@ -1,12 +1,7 @@ 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) { diff --git "a/uni_modules/uts-screenshot-listener/utssdk/app-android/libs/androix-core-1.0.0-\350\207\252\345\256\232\344\271\211\345\237\272\345\272\247\346\227\266\347\247\273\351\231\244.jar" b/uni_modules/uts-screenshot-listener/utssdk/app-android/libs/androix-core-1.0.0.jar similarity index 100% rename from "uni_modules/uts-screenshot-listener/utssdk/app-android/libs/androix-core-1.0.0-\350\207\252\345\256\232\344\271\211\345\237\272\345\272\247\346\227\266\347\247\273\351\231\244.jar" rename to uni_modules/uts-screenshot-listener/utssdk/app-android/libs/androix-core-1.0.0.jar diff --git "a/uni_modules/uts-tencentgeolocation/utssdk/app-android/libs/androix-core-1.0.0-\350\207\252\345\256\232\344\271\211\345\237\272\345\272\247\346\227\266\347\247\273\351\231\244.jar" b/uni_modules/uts-tencentgeolocation/utssdk/app-android/libs/androix-core-1.0.0.jar similarity index 100% rename from "uni_modules/uts-tencentgeolocation/utssdk/app-android/libs/androix-core-1.0.0-\350\207\252\345\256\232\344\271\211\345\237\272\345\272\247\346\227\266\347\247\273\351\231\244.jar" rename to uni_modules/uts-tencentgeolocation/utssdk/app-android/libs/androix-core-1.0.0.jar diff --git a/uni_modules/uts-tencentgeolocation/utssdk/app-android/libs/armeabi-v7a/androix-core-1.0.0.jar b/uni_modules/uts-tencentgeolocation/utssdk/app-android/libs/armeabi-v7a/androix-core-1.0.0.jar new file mode 100644 index 0000000000000000000000000000000000000000..f1f7e720871192c61a9faa138c03ea78bb8efb8b Binary files /dev/null and b/uni_modules/uts-tencentgeolocation/utssdk/app-android/libs/armeabi-v7a/androix-core-1.0.0.jar differ