diff --git a/AndroidManifest.xml b/AndroidManifest.xml index a50775628701806e5d973e24ccd30423dabdaf83..85e0d2c8df3ded51a4f2f07b826c2584b1091478 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -2,9 +2,19 @@ - + - + + + + diff --git a/main.uts b/main.uts index f0074dad9eea4b5c5c77983f2edc82d904b21eb7..5065eb1cafd497cc8ea60fc50071d072e3211b22 100644 --- a/main.uts +++ b/main.uts @@ -1,4 +1,4 @@ -import App from './App' +import App from './App.vue' import { createSSRApp } from 'vue' export function createApp() { @@ -7,4 +7,4 @@ export function createApp() { return { app } -} \ No newline at end of file +} diff --git a/pages/advance/advance.vue b/pages/advance/advance.vue index 3f37c4e97369db72ec0ae844f824e6d9fd58a389..b8e961bfd5deb81fb1725ff03f565a6a41b03dc0 100644 --- a/pages/advance/advance.vue +++ b/pages/advance/advance.vue @@ -27,6 +27,8 @@ quitApp, arrayConvert } from "../../uni_modules/uts-advance"; + + import {openFileWithProvider} from '../../uni_modules/uts-nativepage' export default { data() { @@ -81,7 +83,12 @@ }, { name: "播放asset音频(需自定义基座)", url: "advance/android/assetaudio" - }, { + }, + { + name: "使用三方应用打开项目文件(需自定义基座)", + function: "testOpenFileWithProvider" + }, + { name: "操作DecorView", url: "advance/android/decorview" }, { @@ -215,6 +222,9 @@ }, testQuitApp() { quitApp() + }, + testOpenFileWithProvider() { + openFileWithProvider("apps/__UNI__70BE9D0/www/static/logo.png") }, testArrayConvert() { let convertRet = arrayConvert() diff --git a/uni_modules/uts-nativepage/utssdk/app-android/index.uts b/uni_modules/uts-nativepage/utssdk/app-android/index.uts index 887564ae1a97105adf348dcfc3f498d1d41ccd59..4191d8f290a3e208984d3a85a7d0a7950c1765d8 100644 --- a/uni_modules/uts-nativepage/utssdk/app-android/index.uts +++ b/uni_modules/uts-nativepage/utssdk/app-android/index.uts @@ -27,6 +27,23 @@ import ViewGroup from 'android.view.ViewGroup'; import LayoutInflater from 'android.view.LayoutInflater'; import LinearLayoutManager from 'androidx.recyclerview.widget.LinearLayoutManager'; export {DoAppWidget} from "./DoAppWidget.uts" +import Application from 'android.app.Application'; +import File from 'java.io.File'; +import Uri from 'android.net.Uri'; + + +export class AppHookProxy implements UTSAndroidHookProxy { + override onCreate(application: Application) { + //当前应用是否 取得用户同意隐私协议 + android.util.Log.d("AppHookProxy", "AppHookProxy--onCreate---") + if(UTSAndroid.isPrivacyAgree()) { + //onCreate 初始化三方SDK + android.util.Log.d("AppHookProxy", "AppHookProxy--onCreate---isPrivacyAgree") + } + } +} + + class ForeService extends Service { @@ -294,3 +311,15 @@ export function gotoDemoActivity():boolean { } + +export function openFileWithProvider(url:String){ + let file = new File(UTSAndroid.getResourcePath("static/logo.png")) + // 这里的 io.dcloud.hellouts.uts_nativepage.fileprovider 应该是你唯一的fileprovider 标识 + const uri = androidx.core.content.FileProvider.getUriForFile(UTSAndroid.getUniActivity()!,"io.dcloud.hellouts.uts_nativepage.fileprovider",file) + console.log("uri",uri.toString()) + const intent = new Intent(Intent.ACTION_VIEW, uri) + intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION) // 添加权限标志 + const context = UTSAndroid.getUniActivity()!; + context.startActivity(intent); +} + diff --git a/uni_modules/uts-nativepage/utssdk/app-android/res/xml/custom_network_security_config.xml b/uni_modules/uts-nativepage/utssdk/app-android/res/xml/custom_network_security_config.xml new file mode 100644 index 0000000000000000000000000000000000000000..4db231d85c144ae427aaed0515c92c845444ac05 --- /dev/null +++ b/uni_modules/uts-nativepage/utssdk/app-android/res/xml/custom_network_security_config.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/uni_modules/uts-nativepage/utssdk/app-android/res/xml/filepaths.xml b/uni_modules/uts-nativepage/utssdk/app-android/res/xml/filepaths.xml new file mode 100644 index 0000000000000000000000000000000000000000..56d22266ec97f29aa4caffecbe466d36285e3d36 --- /dev/null +++ b/uni_modules/uts-nativepage/utssdk/app-android/res/xml/filepaths.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/uni_modules/uts-platform-api/utssdk/app-android/index.uts b/uni_modules/uts-platform-api/utssdk/app-android/index.uts index 2b5db4b6ea045e0def5fdb06514aa0f831ea45e6..11b6663316b848b4b5ef9244b3e5967210a264fb 100644 --- a/uni_modules/uts-platform-api/utssdk/app-android/index.uts +++ b/uni_modules/uts-platform-api/utssdk/app-android/index.uts @@ -119,7 +119,7 @@ export function gotoSystemPermissionActivityTest() { */ export function gotoCameraTake(imageDone : (event : string) => void) : boolean { - let permissionNeed = utsArrayOf("android.permission.CAMERA") + let permissionNeed = ["android.permission.CAMERA"] UTSAndroid.requestSystemPermission(UTSAndroid.getUniActivity()!, permissionNeed, function (allRight : boolean, _grantedList : string[]) { if (allRight) { @@ -282,7 +282,7 @@ export function arrayPermissionFlowTest(callback : (ret : boolean, desc : string /** * 同时申请日历和联系人权限 */ - let permissionNeed = utsArrayOf("android.permission.WRITE_EXTERNAL_STORAGE", "android.permission.ACCESS_FINE_LOCATION", "android.permission.READ_PHONE_STATE") + let permissionNeed = ["android.permission.WRITE_EXTERNAL_STORAGE", "android.permission.ACCESS_FINE_LOCATION", "android.permission.READ_PHONE_STATE"] if (UTSAndroid.getSystemPermissionDenied(UTSAndroid.getUniActivity()!, permissionNeed).isEmpty()) { callback(false, "已具备请求权限") @@ -429,7 +429,7 @@ export function singlePermissionFlowTest(callback : (ret : boolean, desc : strin return } - let permissionNeed = utsArrayOf("android.permission.READ_PHONE_STATE") + let permissionNeed = ["android.permission.READ_PHONE_STATE"] if (UTSAndroid.getSystemPermissionDenied(UTSAndroid.getUniActivity()!, permissionNeed).isEmpty()) { callback(false, "已具备权限") return; diff --git a/uni_modules/uts-tests/utssdk/Number.uts b/uni_modules/uts-tests/utssdk/Number.uts index a487b7506c35eef505c9c1eca0e7663471a0bcc5..ca405a9095ff95646f28e770fd94e95438a280ce 100644 --- a/uni_modules/uts-tests/utssdk/Number.uts +++ b/uni_modules/uts-tests/utssdk/Number.uts @@ -22,12 +22,13 @@ export function testNumber(): Result { console.log(JSON.stringify(obj)) + + // #ifndef APP-IOS + // android 专有数据类型 expect(123456.789.toFixed(2)).toEqual("123456.79"); expect(12345600123.789123.toFixed(2)).toEqual("12345600123.79"); expect((-123456.789).toFixed(5)).toEqual("-123456.78900"); expect(parseFloat("16688995566.369").toFixed(3)).toEqual("16688995566.369"); - // #ifndef APP-IOS - // android 专有数据类型 let a1 = 56 let a2 = -122 expect(a1.toByte().toFixed(2)).toEqual("56.00");