Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
Hello UTS
提交
35ad20ce
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看板
提交
35ad20ce
编写于
10月 27, 2022
作者:
杜庆泉
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
完善xtoast 使用示例
上级
6bb96332
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
179 addition
and
85 deletion
+179
-85
pages.json
pages.json
+18
-0
pages/SDKIntegration/SDKIntegration.vue
pages/SDKIntegration/SDKIntegration.vue
+14
-50
pages/SDKIntegration/TencentLocation/TencentLocation.vue
pages/SDKIntegration/TencentLocation/TencentLocation.vue
+74
-0
pages/SDKIntegration/XToast/XToast.vue
pages/SDKIntegration/XToast/XToast.vue
+27
-0
pages/resource/resource.vue
pages/resource/resource.vue
+1
-0
uni_modules/uts-advance/utssdk/app-android/index.uts
uni_modules/uts-advance/utssdk/app-android/index.uts
+27
-27
uni_modules/uts-toast/utssdk/app-android/index.uts
uni_modules/uts-toast/utssdk/app-android/index.uts
+18
-8
未找到文件。
pages.json
浏览文件 @
35ad20ce
...
...
@@ -35,6 +35,24 @@
"enablePullDownRefresh"
:
false
}
},
{
"path"
:
"pages/SDKIntegration/TencentLocation/TencentLocation"
,
"style"
:
{
"navigationBarTitleText"
:
""
,
"enablePullDownRefresh"
:
false
}
},
{
"path"
:
"pages/SDKIntegration/XToast/XToast"
,
"style"
:
{
"navigationBarTitleText"
:
""
,
"enablePullDownRefresh"
:
false
}
},
{
"path"
:
"pages/lifecycle/lifecycle"
,
...
...
pages/SDKIntegration/SDKIntegration.vue
浏览文件 @
35ad20ce
<
template
>
<view>
<page-head
:title=
"title"
></page-head>
<view
class=
"uni-padding-wrap uni-common-mt"
>
<view
class=
"uni-hello-text"
>
1. 腾讯定位sdk需在腾讯地图官网申请key。https://lbs.qq.com/mobile/androidMapSDK/
developerGuide/getKey。
</view>
<view
class=
"uni-hello-text"
>
2. 将key配置在uts插件uts-tencentgeolocation/utssdk/app-android/AndroidManifest.xml中。
</view>
<view
class=
"uni-hello-text"
>
3. 打包自定义基座,注意将uts-tencentgeolocation/utssdk/app-android/libs/androix-core-1.0.0.jar先移到其他目录。
</view>
<view
class=
"uni-hello-text"
>
4. 打包自定义基座后将androix-core-1.0.0.jar移回原位,然后真机运行自定义基座。这个临时的移出移入问题后续会升级解决,详见uts插件开发文档的临时注意。
</view>
</view>
<view
class=
"uni-btn-v uni-common-mt"
>
<button
type=
"primary"
@
tap=
"checkLocationPermission"
>
请求定位权限
</button>
<button
type=
"primary"
@
tap=
"testGetlocation"
>
腾讯地图获取定位(需自定义基座)
</button>
</view>
<uni-list>
<uni-list-item
@
tap=
"gotoTencentLocation"
title=
"腾讯定位sdk集成示例"
class=
"itemButton"
:clickable=
"true"
link
/>
<uni-list-item
@
tap=
"gotoXToast"
title=
"XToast集成示例"
class=
"itemButton"
:clickable=
"true"
link
/>
</uni-list>
</view>
</
template
>
<
script
>
import
{
requestPremission
,
getLocation
}
from
"
@/uni_modules/uts-tencentgeolocation
"
;
export
default
{
data
()
{
return
{
title
:
'
腾讯定位
SDK集成示例
'
,
title
:
'
SDK集成示例
'
,
}
},
methods
:
{
checkLocationPermission
:
function
(
e
){
requestPremission
();
},
testGetlocation
:
function
(
e
){
let
startRet
=
getLocation
({
geocode
:
true
,
success
:
function
(
response
){
console
.
log
(
response
);
var
addressDesc
=
response
.
name
+
'
-
'
+
response
.
address
uni
.
showToast
({
title
:
'
执行结果:
'
+
addressDesc
,
icon
:
'
none
'
});
},
fail
:
function
(
msg
)
{
uni
.
showToast
({
title
:
msg
,
icon
:
"
none
"
})
}
gotoXToast
:
function
(
e
){
uni
.
navigateTo
({
url
:
'
/pages/SDKIntegration/XToast/XToast
'
})
if
(
!
startRet
){
uni
.
showToast
({
title
:
'
定位启动失败,请检查配置
'
,
icon
:
'
none
'
});
}
},
gotoTencentLocation
:
function
(
e
){
uni
.
navigateTo
({
url
:
'
/pages/SDKIntegration/TencentLocation/TencentLocation
'
})
}
}
}
</
script
>
...
...
pages/SDKIntegration/TencentLocation/TencentLocation.vue
0 → 100644
浏览文件 @
35ad20ce
<
template
>
<view>
<page-head
:title=
"title"
></page-head>
<view
class=
"uni-padding-wrap uni-common-mt"
>
<view
class=
"uni-hello-text"
>
1. 腾讯定位sdk需在腾讯地图官网申请key。https://lbs.qq.com/mobile/androidMapSDK/
developerGuide/getKey。
</view>
<view
class=
"uni-hello-text"
>
2. 将key配置在uts插件uts-tencentgeolocation/utssdk/app-android/AndroidManifest.xml中。
</view>
<view
class=
"uni-hello-text"
>
3. 打包自定义基座,注意将uts-tencentgeolocation/utssdk/app-android/libs/androix-core-1.0.0.jar先移到其他目录。
</view>
<view
class=
"uni-hello-text"
>
4. 打包自定义基座后将androix-core-1.0.0.jar移回原位,然后真机运行自定义基座。这个临时的移出移入问题后续会升级解决,详见uts插件开发文档的临时注意。
</view>
</view>
<view
class=
"uni-btn-v uni-common-mt"
>
<button
type=
"primary"
@
tap=
"checkLocationPermission"
>
请求定位权限
</button>
<button
type=
"primary"
@
tap=
"testGetlocation"
>
腾讯地图获取定位(需自定义基座)
</button>
</view>
</view>
</
template
>
<
script
>
import
{
requestPremission
,
getLocation
}
from
"
@/uni_modules/uts-tencentgeolocation
"
;
export
default
{
data
()
{
return
{
title
:
'
腾讯定位SDK集成示例
'
,
}
},
methods
:
{
checkLocationPermission
:
function
(
e
){
requestPremission
();
},
testGetlocation
:
function
(
e
){
let
startRet
=
getLocation
({
geocode
:
true
,
success
:
function
(
response
){
console
.
log
(
response
);
var
addressDesc
=
response
.
name
+
'
-
'
+
response
.
address
uni
.
showToast
({
title
:
'
执行结果:
'
+
addressDesc
,
icon
:
'
none
'
});
},
fail
:
function
(
msg
)
{
uni
.
showToast
({
title
:
msg
,
icon
:
"
none
"
})
}
})
if
(
!
startRet
){
uni
.
showToast
({
title
:
'
定位启动失败,请检查配置
'
,
icon
:
'
none
'
});
}
},
}
}
</
script
>
<
style
>
</
style
>
pages/SDKIntegration/XToast/XToast.vue
0 → 100644
浏览文件 @
35ad20ce
<
template
>
<button
@
tap=
"testToastShow"
>
调用XToast弹窗
</button>
</
template
>
<
script
>
import
{
showToast
}
from
'
@/uni_modules/uts-toast
'
export
default
{
data
()
{
return
{
}
},
methods
:{
testToastShow
(){
showToast
();
}
}
}
</
script
>
<
style
>
</
style
>
\ No newline at end of file
pages/resource/resource.vue
浏览文件 @
35ad20ce
...
...
@@ -9,6 +9,7 @@
import
{
getLogoPath
}
from
'
../../uni_modules/uts-advance
'
export
default
{
data
()
{
...
...
uni_modules/uts-advance/utssdk/app-android/index.uts
浏览文件 @
35ad20ce
...
...
@@ -202,24 +202,24 @@ export function goOtherActivity(imageDone: (event:string) => void):boolean {
return false;
}
onAppActivityResult((requestCode: Int, resultCode: Int, data?: Intent) => {
let eventName = "onAppActivityResult - requestCode:" + requestCode + " -resultCode:"+resultCode + " -data:"+JSON.stringify(data);
console.log(eventName);
if ((requestCode == 1001) && (resultCode == Activity.RESULT_OK)) {
if (data != null) {
let bundle = data.getExtras();
let mImageBitmap = bundle!.get("data") as Bitmap;
let bitmapPath = getUniActivity()!.getExternalCacheDir()!.getPath() + "/photo.png"
console.log(bitmapPath);
try{
mImageBitmap.compress(Bitmap.CompressFormat.PNG,100,new FileOutputStream(bitmapPath))
}catch(e){
}
imageDone(bitmapPath);
//
onAppActivityResult((requestCode: Int, resultCode: Int, data?: Intent) => {
//
let eventName = "onAppActivityResult - requestCode:" + requestCode + " -resultCode:"+resultCode + " -data:"+JSON.stringify(data);
//
console.log(eventName);
//
if ((requestCode == 1001) && (resultCode == Activity.RESULT_OK)) {
//
if (data != null) {
//
let bundle = data.getExtras();
//
let mImageBitmap = bundle!.get("data") as Bitmap;
//
let bitmapPath = getUniActivity()!.getExternalCacheDir()!.getPath() + "/photo.png"
//
console.log(bitmapPath);
//
try{
//
mImageBitmap.compress(Bitmap.CompressFormat.PNG,100,new FileOutputStream(bitmapPath))
//
}catch(e){
//
}
//
imageDone(bitmapPath);
}
}
});
//
}
//
}
//
});
let takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
//resolveActivity 返回可处理 Intent 的第一个 Activity 组件
...
...
@@ -240,18 +240,18 @@ export function initAppLifecycle(onLifecycleChange: (event:string) => void) {
onAppTrimMemory((level:Number) => {
let eventName = "onAppTrimMemory - " + level;
onLifecycleChange(eventName);
console.log(eventName);
});
//
onAppTrimMemory((level:Number) => {
//
let eventName = "onAppTrimMemory - " + level;
//
onLifecycleChange(eventName);
//
console.log(eventName);
//
});
onAppConfigChange((ret:UTSJSONObject) => {
let eventName = "onAppConfigChange - " + JSON.stringify(ret);
onLifecycleChange(eventName);
console.log(eventName);
});
//
onAppConfigChange((ret:UTSJSONObject) => {
//
let eventName = "onAppConfigChange - " + JSON.stringify(ret);
//
onLifecycleChange(eventName);
//
console.log(eventName);
//
});
/**
...
...
uni_modules/uts-toast/utssdk/app-android/index.uts
浏览文件 @
35ad20ce
...
...
@@ -4,15 +4,25 @@ import {
import XToast from "com.hjq.xtoast.XToast";
import R from "io.dcloud.uni_modules.uts_toast.R";
import Runnable from 'java.lang.Runnable';
export function showToast():string{
class UIRunnable extends Runnable {
override run():void {
new XToast<XToast<unknown>>(getUniActivity())
.setDuration(1000)
.setContentView(R.layout.window_hint)
.setImageDrawable(android.R.id.icon, android.R.mipmap.sym_def_app_icon)
.setText(android.R.id.message, "一秒后自动消失")
.show()
}
};
export function showToast(){
new XToast<XToast<unknown>>(getUniActivity())
.setDuration(1000)
.setContentView(R.layout.window_hint)
.setImageDrawable(android.R.id.icon, android.R.mipmap.sym_def_app_icon)
.setText(android.R.id.message, "一秒后自动消失")
.show()
let toastRunable = new UIRunnable();
getUniActivity()!.runOnUiThread(toastRunable)
return ""
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录