修复MediaCollections应用因接口下架导致的音视频播放问题
Signed-off-by: 王鑫 <wangxin601@huawei.com>
53
OAT.xml
@ -150,8 +150,33 @@ Note:If the text contains special characters, please escape them according to th
|
||||
<filteritem type="filepath" name="code/Solutions/Media/MultiMedia/lib/CameraPage-1.0.0.tgz" desc="Provided by code/Solutions/Media/MultiMedia"/>
|
||||
<filteritem type="filepath" name="code/BasicFeature/Media/AVRecorder/lib/VideoRecorder-1.0.0.tgz" desc="Provided by code/BasicFeature/Media/AVRecorder"/>
|
||||
<filteritem type="filepath" name="code/BasicFeature/FileManagement/FileManager/lib/MyPhoneFilePage-1.0.0.tgz" desc="Provided by code/BasicFeature/FileManagement/FileManager"/>
|
||||
<filteritem type="filepath" name="code\BasicFeature/FileManagement/MediaCollections/screenshots/devices/drm_play_page.png" desc="Provided by code/BasicFeature/FileManagement/FileManager"/>
|
||||
<filteritem type="filepath" name="code\BasicFeature/FileManagement/MediaCollections/screenshots/devices/drm_playlist.png" desc="Provided by code/BasicFeature/FileManagement/FileManager"/>
|
||||
<filteritem type="filepath" name="code/SystemFeature/FileManagement/MediaCollections/screenshots/devices/drm_play_page.png" desc="Provided by code/SystemFeature/FileManagement/FileManager/MediaCollections"/>
|
||||
<filteritem type="filepath" name="code/SystemFeature/FileManagement/MediaCollections/screenshots/devices/drm_playlist.png" desc="Provided by code/SystemFeature/FileManagement/FileManager/MediaCollections"/>
|
||||
<filteritem type="filepath" name="code/SystemFeature/FileManagement/MediaCollections/screenshots/devices/video.png" desc="Provided by code/SystemFeature/FileManagement/FileManager/MediaCollections"/>
|
||||
<filteritem type="filepath" name="code/SystemFeature/FileManagement/MediaCollections/screenshots/devices/audio.png" desc="Provided by code/SystemFeature/FileManagement/FileManager/MediaCollections"/>
|
||||
<filteritem type="filepath" name="code/SystemFeature/FileManagement/MediaCollections/screenshots/devices/rename.png" desc="Provided by code/SystemFeature/FileManagement/FileManager/MediaCollections"/>
|
||||
<filteritem type="filepath" name="code/SystemFeature/FileManagement/MediaCollections/screenshots/devices/index.png" desc="Provided by code/SystemFeature/FileManagement/FileManager/MediaCollections"/>
|
||||
<filteritem type="filepath" name="code/SystemFeature/FileManagement/MediaCollections/entry/src/main/resources/base/media/icon_loading.png" desc="Provided by code/SystemFeature/FileManagement/FileManager/MediaCollections"/>
|
||||
<filteritem type="filepath" name="code/SystemFeature/FileManagement/MediaCollections/entry/src/main/resources/base/media/icon_seekStart.png" desc="Provided by code/SystemFeature/FileManagement/FileManager/MediaCollections"/>
|
||||
<filteritem type="filepath" name="code/SystemFeature/FileManagement/MediaCollections/screenshots/devices/rename.png" desc="Provided by code/SystemFeature/FileManagement/FileManager/MediaCollections"/>
|
||||
<filteritem type="filepath" name="code/SystemFeature/FileManagement/MediaCollections/screenshots/devices/index.png" desc="Provided by code/SystemFeature/FileManagement/FileManager/MediaCollections"/>
|
||||
<filteritem type="filepath" name="code/SystemFeature/FileManagement/MediaCollections/entry/src/main/resources/base/media/audioCover.png" desc="Provided by code/SystemFeature/FileManagement/FileManager/MediaCollections"/>
|
||||
<filteritem type="filepath" name="code/SystemFeature/FileManagement/MediaCollections/entry/src/main/resources/base/media/icon_forward.png" desc="Provided by code/SystemFeature/FileManagement/FileManager/MediaCollections"/>
|
||||
<filteritem type="filepath" name="code/SystemFeature/FileManagement/MediaCollections/entry/src/ohosTest/resources/base/media/icon.png" desc="Provided by code/SystemFeature/FileManagement/FileManager/MediaCollections"/>
|
||||
<filteritem type="filepath" name="code/SystemFeature/FileManagement/MediaCollections/entry/src/main/resources/base/media/key.png" desc="Provided by code/SystemFeature/FileManagement/FileManager/MediaCollections"/>
|
||||
<filteritem type="filepath" name="code/SystemFeature/FileManagement/MediaCollections/entry/src/main/resources/base/media/upward.png" desc="Provided by code/SystemFeature/FileManagement/FileManager/MediaCollections"/>
|
||||
<filteritem type="filepath" name="code/SystemFeature/FileManagement/MediaCollections/entry/src/main/resources/base/media/icon_backoff.png" desc="Provided by code/SystemFeature/FileManagement/FileManager/MediaCollections"/>
|
||||
<filteritem type="filepath" name="code/SystemFeature/FileManagement/MediaCollections/entry/src/main/resources/base/media/icon_seekEnd.png" desc="Provided by code/SystemFeature/FileManagement/FileManager/MediaCollections"/>
|
||||
<filteritem type="filepath" name="code/SystemFeature/FileManagement/MediaCollections/entry/src/main/resources/base/media/download.png" desc="Provided by code/SystemFeature/FileManagement/FileManager/MediaCollections"/>
|
||||
<filteritem type="filepath" name="code/SystemFeature/FileManagement/MediaCollections/entry/src/main/resources/base/media/icon_logo.png" desc="Provided by code/SystemFeature/FileManagement/FileManager/MediaCollections"/>
|
||||
<filteritem type="filepath" name="code/SystemFeature/FileManagement/MediaCollections/entry/src/main/resources/base/media/videoCover.png" desc="Provided by code/SystemFeature/FileManagement/FileManager/MediaCollections"/>
|
||||
<filteritem type="filepath" name="code/SystemFeature/FileManagement/MediaCollections/entry/src/main/resources/base/media/downward.png" desc="Provided by code/SystemFeature/FileManagement/FileManager/MediaCollections"/>
|
||||
<filteritem type="filepath" name="code/SystemFeature/FileManagement/MediaCollections/screenshots/devices/video.png" desc="Provided by code/SystemFeature/FileManagement/FileManager/MediaCollections"/>
|
||||
<filteritem type="filepath" name="code/SystemFeature/FileManagement/MediaCollections/AppScope/resources/base/media/app_icon.png" desc="Provided by code/SystemFeature/FileManagement/FileManager/MediaCollections"/>
|
||||
<filteritem type="filepath" name="code/SystemFeature/FileManagement/MediaCollections/screenshots/devices/audio.png" desc="Provided by code/SystemFeature/FileManagement/FileManager/MediaCollections"/>
|
||||
<filteritem type="filepath" name="code/SystemFeature/FileManagement/MediaCollections/entry/src/main/resources/base/media/key_blue.png" desc="Provided by code/SystemFeature/FileManagement/FileManager/MediaCollections"/>
|
||||
<filteritem type="filepath" name="code/SystemFeature/FileManagement/MediaCollections/entry/src/main/resources/base/media/delete.png" desc="Provided by code/SystemFeature/FileManagement/FileManager/MediaCollections"/>
|
||||
<filteritem type="filepath" name="code/SystemFeature/FileManagement/MediaCollections/entry/src/main/resources/base/media/icon.png" desc="Provided by code/SystemFeature/FileManagement/FileManager/MediaCollections"/>
|
||||
<filteritem type="filepath" name="code/BasicFeature/Connectivity/VPN/lib/VPNFoundation-1.0.0.tgz" desc="Provided by code/BasicFeature/Connectivity/VPN"/>
|
||||
<filteritem type="filepath" name="code/UI/ArkTsComponentCollection/ComponentCollection/lib/DragEvent-1.0.0.tgz" desc="Provided by code/UI/ArkTsComponentCollection/ComponentCollection"/>
|
||||
<filteritem type="filepath" name="code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary/lib/ProcessMessage-1.0.0.tgz" desc="Provided by code/LaunguageBaseClassLibrary/LanguageBaseClassLibrary"/>
|
||||
@ -682,6 +707,22 @@ Note:If the text contains special characters, please escape them according to th
|
||||
<filteritem type="filepath" name="code/SystemFeature/ApplicationModels/UIExtensionAbility/entry/src/ohosTest/resources/base/media/icon.png" desc="Provided by code/SystemFeature/ApplicationModels/UIExtensionAbility"/>
|
||||
<filteritem type="filepath" name="code/BasicFeature/Native/Audio/screenshots/device/AudioVivid.jpg" desc="Provided by code/BasicFeature/Native/Audio"/>
|
||||
<filteritem type="filepath" name="code/BasicFeature/Native/Audio/screenshots/device/index.jpg" desc="Provided by code/BasicFeature/Native/Audio"/>
|
||||
<filteritem type="filepath" name="code/DocsSample/Media/Audio/OHAudio/screenshots/device/record.jpeg" desc="Provided by code/DocsSample/Media/Audio/OHAudio"/>
|
||||
<filteritem type="filepath" name="code/DocsSample/Media/Audio/OHAudio/screenshots/device/play.jpeg" desc="Provided by code/DocsSample/Media/Audio/OHAudio"/>
|
||||
<filteritem type="filepath" name="code/DocsSample/Media/Audio/OHAudio/screenshots/device/AudioVivid.jpg" desc="Provided by code/DocsSample/Media/Audio/OHAudio"/>
|
||||
<filteritem type="filepath" name="code/DocsSample/Media/Audio/OHAudio/screenshots/device/index.jpg" desc="Provided by code/DocsSample/Media/Audio/OHAudio"/>
|
||||
<filteritem type="filepath" name="code/DocsSample/Media/Audio/OHAudio/AppScope/resources/base/media/app_icon.png" desc="Provided by code/DocsSample/Media/Audio/OHAudio"/>
|
||||
<filteritem type="filepath" name="code/DocsSample/Media/Audio/OHAudio/entry/src/main/resources/base/media/icon.png" desc="Provided by code/DocsSample/Media/Audio/OHAudio"/>
|
||||
<filteritem type="filepath" name="code/DocsSample/Media/Audio/OHAudio/entry/src/main/resources/base/media/pic_Audiovivid.png" desc="Provided by code/DocsSample/Media/Audio/OHAudio"/>
|
||||
<filteritem type="filepath" name="code/DocsSample/Media/Audio/OHAudio/entry/src/ohosTest/resources/base/media/icon.png" desc="Provided by code/DocsSample/Media/Audio/OHAudio"/>
|
||||
<filteritem type="filepath" name="code/DocsSample/ArkTSUtilsDocModule/entry/src/main/resources/base/media/icon.png" desc="Provided by code/DocsSample/ArkTSUtilsDocModule"/>
|
||||
<filteritem type="filepath" name="code/DocsSample/ArkTSUtilsDocModule/entry/src/main/resources/rawfile/startIcon.png" desc="Provided by code/DocsSample/ArkTSUtilsDocModule"/>
|
||||
<filteritem type="filepath" name="code/DocsSample/ArkTSUtilsDocModule/screenshots/device/image1.jpeg" desc="Provided by code/DocsSample/ArkTSUtilsDocModule"/>
|
||||
<filteritem type="filepath" name="code/DocsSample/ArkTSUtilsDocModule/screenshots/device/image2.jpeg" desc="Provided by code/DocsSample/ArkTSUtilsDocModule"/>
|
||||
<filteritem type="filepath" name="code/DocsSample/ArkTSUtilsDocModule/screenshots/device/image3.jpeg" desc="Provided by code/DocsSample/ArkTSUtilsDocModule"/>
|
||||
<filteritem type="filepath" name="code/DocsSample/ArkTSUtilsDocModule/AppScope/resources/base/media/app_icon.png" desc="Provided by code/DocsSample/ArkTSUtilsDocModule"/>
|
||||
<filteritem type="filepath" name="code/DocsSample/ArkTSUtilsDocModule/entry/src/ohosTest/resources/base/media/icon.png" desc="Provided by code/DocsSample/ArkTSUtilsDocModule"/>
|
||||
<filteritem type="filepath" name="code/DocsSample/ArkTSUtilsDocModule/entry/src/main/resources/base/media/startIcon.png" desc="Provided by code/DocsSample/ArkTSUtilsDocModule"/>
|
||||
<filteritem type="filepath" name="code/Project/HapBuild/compile-tool/tool/sign_tool/OpenHarmonyProfileDebug.pem" desc="Provided by code/Project/HapBuild"/>
|
||||
<filteritem type="filepath" name="code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/src/main/resources/base/media/icon.png" desc="Provided by code/BasicFeature/ApplicationModels/BundleManager/BundleManagement"/>
|
||||
<filteritem type="filepath" name="code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/sceenshots/device/snapshot_directory.png" desc="Provided by code/BasicFeature/ApplicationModels/BundleManager/BundleManagement"/>
|
||||
@ -768,6 +809,14 @@ Note:If the text contains special characters, please escape them according to th
|
||||
<filteritem type="filepath" name="code/BasicFeature/DataManagement/pasteboard/screenshots/first.png" desc="Provided by code/BasicFeature/DataManagement/pasteboard"/>
|
||||
<filteritem type="filepath" name="code/Solutions/InputMethod/KikaInputMethod/entry/src/main/resources/base/media/startIcon.png" desc="Provided by code/Solutions/InputMethod/KikaInputMethod"/>
|
||||
<filteritem type="filepath" name="code/Solutions/InputMethod/KikaInputMethod/screenshots/devices/preview.jpg" desc="Provided by code/Solutions/InputMethod/KikaInputMethod"/>
|
||||
<filteritem type="filepath" name="code/BasicFeature/DataManagement/UDMF/UDMFDemo/AppScope/resources/base/media/app_icon.png" desc="Provided by code/BasicFeature/DataManagement/UDMF/UDMFDemo"/>
|
||||
<filteritem type="filepath" name="code/BasicFeature/DataManagement/UDMF/UDMFDemo/entry/src/main/resources/base/media/ic_select_option_collection.png" desc="Provided by code/BasicFeature/DataManagement/UDMF/UDMFDemo"/>
|
||||
<filteritem type="filepath" name="code/BasicFeature/DataManagement/UDMF/UDMFDemo/entry/src/ohosTest/resources/base/media/icon.png" desc="Provided by code/BasicFeature/DataManagement/UDMF/UDMFDemo"/>
|
||||
<filteritem type="filepath" name="code/BasicFeature/DataManagement/UDMF/UDMFDemo/entry/src/main/resources/base/media/startIcon.png" desc="Provided by code/BasicFeature/DataManagement/UDMF/UDMFDemo"/>
|
||||
<filteritem type="filepath" name="code/BasicFeature/DataManagement/UDMF/UDMFDemo/screenshots/first.png" desc="Provided by code/BasicFeature/DataManagement/UDMF/UDMFDemo"/>
|
||||
<filteritem type="filepath" name="code/BasicFeature/DataManagement/UDMF/UDMFDemo/screenshots/select.png" desc="Provided by code/BasicFeature/DataManagement/UDMF/UDMFDemo"/>
|
||||
<filteritem type="filepath" name="code/BasicFeature/DataManagement/UDMF/UDMFDemo/screenshots/drag.png" desc="Provided by code/BasicFeature/DataManagement/UDMF/UDMFDemo"/>
|
||||
<filteritem type="filepath" name="code/BasicFeature/DataManagement/UDMF/UDMFDemo/entry/src/main/resources/base/media/icon.png" desc="Provided by code/BasicFeature/DataManagement/UDMF/UDMFDemo"/>
|
||||
<filteritem type="filepath" name="code/LaunguageBaseClassLibrary/ZipLib/screenshots/device/Screenshot_20231208091553194.jpeg" desc="Provided by code/LaunguageBaseClassLibrary/ZipLib"/>
|
||||
<filteritem type="filepath" name="code/LaunguageBaseClassLibrary/ZipLib/screenshots/device/Screenshot_20231208091619146.jpeg" desc="Provided by code/LaunguageBaseClassLibrary/ZipLib"/>
|
||||
<filteritem type="filepath" name="code/LaunguageBaseClassLibrary/ZipLib/screenshots/device/Screenshot_20231208091638669.jpeg" desc="Provided by code/LaunguageBaseClassLibrary/ZipLib"/>
|
||||
|
23
README_zh.md
@ -49,7 +49,7 @@
|
||||
<td ></td>
|
||||
</tr>
|
||||
<tr height="18" style='height:13.50pt;'>
|
||||
<td height="270" align="center" rowspan="29" style='height:202.50pt' x:str><strong>基础特性</strong></td>
|
||||
<td height="270" align="center" rowspan="28" style='height:202.50pt' x:str><strong>基础特性</strong></td>
|
||||
<td x:str><strong>能力增强</strong></td>
|
||||
<td x:str><a href="code/BasicFeature/Ability/AbilityFeature">基础能力增强</a></td>
|
||||
<td ></td>
|
||||
@ -146,7 +146,6 @@
|
||||
<td rowspan="1" x:str><strong>文件管理</strong></td>
|
||||
<td x:str><a href="code/BasicFeature/FileManagement/FileBackupExtension">应用接入数据备份恢复(API 11)</a></td>
|
||||
<td x:str><a href="code/BasicFeature/FileManagement/FileManager">文件管理(API 11)</a></td>
|
||||
<td x:str><a href="code/BasicFeature/FileManagement/MediaCollections">媒体管理合集</a></td>
|
||||
<td x:str><a href="code/BasicFeature/FileManagement/FileShare/SandboxShare">文件分享与访问</a></td>
|
||||
</tr>
|
||||
<tr height="18" style='height:13.50pt;'>
|
||||
@ -156,13 +155,6 @@
|
||||
<td ></td>
|
||||
<td ></td>
|
||||
</tr>
|
||||
<tr height="18" style='height:13.50pt;'>
|
||||
<td rowspan="1" x:str><strong>意图</strong></td>
|
||||
<td x:str><a href="code/BasicFeature/InsightIntent/IntentExecutor">意图执行</a></td>
|
||||
<td ></td>
|
||||
<td ></td>
|
||||
<td ></td>
|
||||
</tr>
|
||||
<tr height="18" style='height:13.50pt;'>
|
||||
<td rowspan="2" x:str><strong>设备管理</strong></td>
|
||||
<td x:str><a href="code/BasicFeature/DeviceManagement/Location">位置服务</a></td>
|
||||
@ -243,7 +235,7 @@
|
||||
<td ></td>
|
||||
</tr>
|
||||
<tr height="18" style='height:13.50pt;'>
|
||||
<td height="90" align="center" rowspan="25" style='height:67.50pt;' x:str><strong>系统特性(仅对系统应用开放)</strong></td>
|
||||
<td height="90" align="center" rowspan="24" style='height:67.50pt;' x:str><strong>系统特性(仅对系统应用开放)</strong></td>
|
||||
<td x:str><strong>能力增强</strong></td>
|
||||
<td x:str><a href="code/SystemFeature/Ability/AbilityFeatureSystem">基础能力增强</a></td>
|
||||
<td ></td>
|
||||
@ -369,7 +361,7 @@
|
||||
<td x:str><strong>文件管理</strong></td>
|
||||
<td x:str><a href="code/SystemFeature/FileManagement/FileShare/Picker">选择并查看文档与媒体文件(API 10)</a></td>
|
||||
<td x:str><a href="code/SystemFeature/FileManagement/Photos">相册(API 12)</a></td>
|
||||
<td ></td>
|
||||
<td x:str><a href="code/SystemFeature/FileManagement/MediaCollections">媒体管理合集</a></td>
|
||||
<td ></td>
|
||||
</tr>
|
||||
<tr height="18" style='height:13.50pt;'>
|
||||
@ -379,13 +371,6 @@
|
||||
<td ></td>
|
||||
<td ></td>
|
||||
</tr>
|
||||
<tr height="18" style='height:13.50pt;'>
|
||||
<td x:str><strong>意图</strong></td>
|
||||
<td x:str><a href="code/SystemFeature/InsightIntent/IntentDriver">意图执行</a></td>
|
||||
<td ></td>
|
||||
<td ></td>
|
||||
<td ></td>
|
||||
</tr>
|
||||
<tr height="18" style='height:13.50pt;'>
|
||||
<td x:str><strong>电话服务</strong></td>
|
||||
<td x:str><a href="code/SystemFeature/TaskManagement/Flybird">小鸟避障游戏</a></td>
|
||||
@ -586,7 +571,6 @@ code
|
||||
|---DeviceManagement # 设备管理
|
||||
|---FileManagement # 文件管理
|
||||
|---Graphics # 图像
|
||||
|---InsightIntent # 意图
|
||||
|---International # 国际化
|
||||
|---Media # 媒体
|
||||
|---Native # Native c++
|
||||
@ -609,7 +593,6 @@ code
|
||||
|---DistributedAppDev # 分布式
|
||||
|---FileManagement # 文件管理
|
||||
|---IDL # IDL
|
||||
|---InsightIntent # 意图
|
||||
|---Internationalnation # 国际化
|
||||
|---Media # 媒体
|
||||
|---Notification # 通知
|
||||
|
@ -47,8 +47,9 @@ entry/src/main/ets/
|
||||
* 获取当前应用的BundleInfo:bundleManager.getBundleInfoForSelf()
|
||||
* 获取BundleInfo(sync):bundleManager.getBundleInfoForSelfSync()
|
||||
* 获取配置json:bundleManager.getProfileByAbility()
|
||||
* 获取配置json(sync):bundleManager.getProfileByExtensionAbility()
|
||||
* 获取配置数组:bundleManager.getProfileByExtensionAbilitySync()
|
||||
* 获取配置json(sync):bundleManager.getProfileByAbilitySync()
|
||||
* 获取配置数组:bundleManager.getProfileByExtensionAbility()
|
||||
* 获取配置数组(sync):bundleManager.getProfileByExtensionAbilitySync()
|
||||
* 校验.abc文件:bundleManager.verifyAbc()
|
||||
* 删除.abc文件:bundleManager.deleteAbc()
|
||||
* 校验链接是否可打开:bundleManager.canOpenLink()
|
||||
|
@ -41,13 +41,38 @@ struct Index {
|
||||
{
|
||||
text: $r('app.string.GetBundleInfo'),
|
||||
callback: () => {
|
||||
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION;
|
||||
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_ABILITY |
|
||||
bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_HAP_MODULE;
|
||||
try {
|
||||
bundleManager.getBundleInfoForSelf(bundleFlags).then((data) => {
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'getBundleInfoForSelf success. Data: %{public}s',
|
||||
JSON.stringify(data));
|
||||
promptAction.showToast({
|
||||
message: JSON.stringify(data), duration: 3000
|
||||
message: JSON.stringify(data), duration: 5000
|
||||
});
|
||||
}).catch((err: BusinessError) => {
|
||||
hilog.error(DOMAIN_NUMBER, TAG, 'getBundleInfoForSelf failed. Cause: %{public}s', err.message);
|
||||
});
|
||||
} catch (err) {
|
||||
let message = (err as BusinessError).message;
|
||||
hilog.error(DOMAIN_NUMBER, TAG, 'getBundleInfoForSelf failed: %{public}s', message);
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
text: $r('app.string.GetBundleInfoCombination'),
|
||||
callback: () => {
|
||||
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_METADATA |
|
||||
bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION |
|
||||
bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_HAP_MODULE |
|
||||
bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_EXTENSION_ABILITY |
|
||||
bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_ABILITY;
|
||||
try {
|
||||
bundleManager.getBundleInfoForSelf(bundleFlags).then((data) => {
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'getBundleInfoForSelf success. Data: %{public}s',
|
||||
JSON.stringify(data));
|
||||
promptAction.showToast({
|
||||
message: JSON.stringify(data), duration: 5000
|
||||
});
|
||||
}).catch((err: BusinessError) => {
|
||||
hilog.error(DOMAIN_NUMBER, TAG, 'getBundleInfoForSelf failed. Cause: %{public}s', err.message);
|
||||
@ -66,7 +91,7 @@ struct Index {
|
||||
let data = bundleManager.getBundleInfoForSelfSync(bundleFlags);
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'getBundleInfoForSelfSync success: %{public}s', JSON.stringify(data));
|
||||
promptAction.showToast({
|
||||
message: JSON.stringify(data), duration: 3000
|
||||
message: JSON.stringify(data), duration: 5000
|
||||
});
|
||||
} catch (err) {
|
||||
let message = (err as BusinessError).message;
|
||||
@ -92,7 +117,7 @@ struct Index {
|
||||
} else {
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'getProfileByAbility success: %{public}s', JSON.stringify(data));
|
||||
promptAction.showToast({
|
||||
message: JSON.stringify(data), duration: 3000
|
||||
message: JSON.stringify(data), duration: 5000
|
||||
});
|
||||
}
|
||||
});
|
||||
@ -102,6 +127,24 @@ struct Index {
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
text: $r('app.string.GetConfigurationJsonSync'),
|
||||
callback: () => {
|
||||
let moduleName = 'entry';
|
||||
let abilityName = 'EntryAbility';
|
||||
let metadataName = 'ohos.ability.shortcuts';
|
||||
try {
|
||||
let data = bundleManager.getProfileByAbilitySync(moduleName, abilityName, metadataName);
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'getProfileByAbilitySync successfully: %{public}s', JSON.stringify(data));
|
||||
promptAction.showToast({
|
||||
message: JSON.stringify(data), duration: 5000
|
||||
});
|
||||
} catch (err) {
|
||||
let message = (err as BusinessError).message;
|
||||
hilog.error(DOMAIN_NUMBER, TAG, 'getProfileByAbilitySync failed. Cause: %{public}s', message);
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
text: $r('app.string.GetConfigurationArray'),
|
||||
callback: () => {
|
||||
@ -117,7 +160,7 @@ struct Index {
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'getProfileByExtensionAbility success: %{public}s',
|
||||
JSON.stringify(data));
|
||||
promptAction.showToast({
|
||||
message: JSON.stringify(data), duration: 3000
|
||||
message: JSON.stringify(data), duration: 5000
|
||||
});
|
||||
}
|
||||
});
|
||||
@ -128,27 +171,18 @@ struct Index {
|
||||
}
|
||||
},
|
||||
{
|
||||
text: $r('app.string.GetConfigurationJsonSync'),
|
||||
text: $r('app.string.GetConfigurationArraySync'),
|
||||
callback: () => {
|
||||
let moduleName = 'entry';
|
||||
let extensionAbilityName = 'NewUIExtAbility';
|
||||
let metadataName = 'ohos.ability.NewUIExtAbility';
|
||||
try {
|
||||
let data = bundleManager.getProfileByExtensionAbilitySync(moduleName, extensionAbilityName);
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'getProfileByExtensionAbilitySync successfully. Data: %{public}s',
|
||||
JSON.stringify(data));
|
||||
promptAction.showToast({
|
||||
message: JSON.stringify(data), duration: 3000
|
||||
});
|
||||
} catch (err) {
|
||||
let message = (err as BusinessError).message;
|
||||
hilog.error(DOMAIN_NUMBER, TAG, 'getProfileByExtensionAbilitySync failed. Cause: %{public}s', message);
|
||||
}
|
||||
|
||||
try {
|
||||
let data = bundleManager.getProfileByExtensionAbilitySync(moduleName, extensionAbilityName, metadataName);
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'getProfileByExtensionAbilitySync successfully. Data: %{public}s',
|
||||
JSON.stringify(data));
|
||||
promptAction.showToast({
|
||||
message: JSON.stringify(data), duration: 5000
|
||||
});
|
||||
} catch (err) {
|
||||
let message = (err as BusinessError).message;
|
||||
hilog.error(DOMAIN_NUMBER, TAG, 'getProfileByExtensionAbilitySync failed. Cause: %{public}s', message);
|
||||
@ -168,7 +202,7 @@ struct Index {
|
||||
bundleManager.verifyAbc(abcPaths, true).then((data) => {
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'verifyAbc successfully' + JSON.stringify(data));
|
||||
promptAction.showToast({
|
||||
message: 'success', duration: 3000
|
||||
message: 'success', duration: 5000
|
||||
});
|
||||
}).catch((err: BusinessError) => {
|
||||
hilog.error(DOMAIN_NUMBER, TAG, 'verifyAbc err: %{public}s', err.message);
|
||||
@ -187,7 +221,7 @@ struct Index {
|
||||
bundleManager.deleteAbc(abcPath).then(() => {
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'deleteAbc successfully');
|
||||
promptAction.showToast({
|
||||
message: 'success', duration: 3000
|
||||
message: 'success', duration: 5000
|
||||
});
|
||||
}).catch((err: BusinessError) => {
|
||||
hilog.error(DOMAIN_NUMBER, TAG, 'deleteAbc failed. err: %{public}s', err.message);
|
||||
@ -211,7 +245,7 @@ struct Index {
|
||||
let data = bundleManager.canOpenLink(link);
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'canOpenLink successfully: %{public}s', JSON.stringify(data));
|
||||
promptAction.showToast({
|
||||
message: JSON.stringify(data), duration: 3000
|
||||
message: JSON.stringify(data), duration: 5000
|
||||
});
|
||||
} catch (err) {
|
||||
let message = (err as BusinessError).message;
|
||||
@ -231,7 +265,7 @@ struct Index {
|
||||
.then((data) => {
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'Operation successful. IsDefaultApplication ? ' + JSON.stringify(data));
|
||||
promptAction.showToast({
|
||||
message: JSON.stringify(data), duration: 3000
|
||||
message: JSON.stringify(data), duration: 5000
|
||||
});
|
||||
}).catch((error: BusinessError) => {
|
||||
hilog.error(DOMAIN_NUMBER, TAG, 'Operation failed. Cause: ' + JSON.stringify(error));
|
||||
@ -246,7 +280,7 @@ struct Index {
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'Operation successful. IsDefaultApplicationSync ? ' +
|
||||
JSON.stringify(data));
|
||||
promptAction.showToast({
|
||||
message: JSON.stringify(data), duration: 3000
|
||||
message: JSON.stringify(data), duration: 5000
|
||||
});
|
||||
} catch (error) {
|
||||
hilog.error(DOMAIN_NUMBER, TAG, 'Operation failed. Cause: ' + JSON.stringify(error));
|
||||
@ -297,7 +331,7 @@ struct Index {
|
||||
let overlayModuleInfo = await overlay.getOverlayModuleInfo(moduleName);
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'overlayModuleInfo is ' + JSON.stringify(overlayModuleInfo));
|
||||
promptAction.showToast({
|
||||
message: JSON.stringify(overlayModuleInfo), duration: 3000
|
||||
message: JSON.stringify(overlayModuleInfo), duration: 5000
|
||||
});
|
||||
} catch (err) {
|
||||
let code = (err as BusinessError).code;
|
||||
@ -317,7 +351,7 @@ struct Index {
|
||||
let overlayModuleInfos = await overlay.getTargetOverlayModuleInfos(targetModuleName);
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'overlayModuleInfos are ' + JSON.stringify(overlayModuleInfos));
|
||||
promptAction.showToast({
|
||||
message: JSON.stringify(overlayModuleInfos), duration: 3000
|
||||
message: JSON.stringify(overlayModuleInfos), duration: 5000
|
||||
});
|
||||
} catch (err) {
|
||||
let code = (err as BusinessError).code;
|
||||
|
@ -56,6 +56,10 @@
|
||||
"name": "GetBundleInfo",
|
||||
"value": "获取BundleInfo"
|
||||
},
|
||||
{
|
||||
"name": "GetBundleInfoCombination",
|
||||
"value": "获取BundleInfo(组合参数)"
|
||||
},
|
||||
{
|
||||
"name": "GetBundleInfoSync",
|
||||
"value": "获取BundleInfo(sync)"
|
||||
@ -72,6 +76,10 @@
|
||||
"name": "GetConfigurationArray",
|
||||
"value": "获取配置数组"
|
||||
},
|
||||
{
|
||||
"name": "GetConfigurationArraySync",
|
||||
"value": "获取配置数组(sync)"
|
||||
},
|
||||
{
|
||||
"name": "GetConfigurationJsonSync",
|
||||
"value": "获取配置json(sync)"
|
||||
|
@ -56,6 +56,10 @@
|
||||
"name": "GetBundleInfo",
|
||||
"value": "GetBundleInfo"
|
||||
},
|
||||
{
|
||||
"name": "GetBundleInfoCombination",
|
||||
"value": "GetBundleInfoCombination"
|
||||
},
|
||||
{
|
||||
"name": "GetBundleInfoSync",
|
||||
"value": "GetBundleInfoSync"
|
||||
@ -72,6 +76,10 @@
|
||||
"name": "GetConfigurationArray",
|
||||
"value": "GetConfigurationArray"
|
||||
},
|
||||
{
|
||||
"name": "GetConfigurationArraySync",
|
||||
"value": "GetConfigurationArraySync"
|
||||
},
|
||||
{
|
||||
"name": "GetConfigurationJsonSync",
|
||||
"value": "GetConfigurationJsonSync"
|
||||
|
@ -56,6 +56,10 @@
|
||||
"name": "GetBundleInfo",
|
||||
"value": "获取BundleInfo"
|
||||
},
|
||||
{
|
||||
"name": "GetBundleInfoCombination",
|
||||
"value": "获取BundleInfo(组合参数)"
|
||||
},
|
||||
{
|
||||
"name": "GetBundleInfoSync",
|
||||
"value": "获取BundleInfo(sync)"
|
||||
@ -72,6 +76,10 @@
|
||||
"name": "GetConfigurationArray",
|
||||
"value": "获取配置数组"
|
||||
},
|
||||
{
|
||||
"name": "GetConfigurationArraySync",
|
||||
"value": "获取配置数组(sync)"
|
||||
},
|
||||
{
|
||||
"name": "GetConfigurationJsonSync",
|
||||
"value": "获取配置json(sync)"
|
||||
|
@ -41,11 +41,11 @@ function startAbility() {
|
||||
}
|
||||
|
||||
export default function abilityTest() {
|
||||
describe('AutoFillSampleTest', () => {
|
||||
describe('BundleManagerSampleTest', () => {
|
||||
/*
|
||||
* @tc.number: BundleManager_GetBundleInfoForSelf_001
|
||||
* @tc.name: By providing the sample code call interface
|
||||
* @tc.desc: Call the GetProfileByExtensionAbility API successfully
|
||||
* @tc.desc: Call the getBundleInfoForSelf API successfully
|
||||
* @tc.size: MediumTest
|
||||
* @tc.type: Function
|
||||
* @tc.level Level 1
|
||||
@ -70,7 +70,7 @@ export default function abilityTest() {
|
||||
/*
|
||||
* @tc.number: BundleManager_GetBundleInfoForSelfSync_002
|
||||
* @tc.name: By providing the sample code call interface
|
||||
* @tc.desc: Call the GetBundleInfoForSelfSync API successfully
|
||||
* @tc.desc: Call the getBundleInfoForSelf(parameterCombination) API successfully
|
||||
* @tc.size: MediumTest
|
||||
* @tc.type: Function
|
||||
* @tc.level Level 1
|
||||
@ -79,6 +79,27 @@ export default function abilityTest() {
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'BundleManager_GetBundleInfoForSelfSync_002 start');
|
||||
let driver = Driver.create();
|
||||
await sleep(1000);
|
||||
let registerBtn = await driver.findComponent(ON.text(
|
||||
await resourceManager.getStringValue($r('app.string.GetBundleInfoCombinationTest'))));
|
||||
await sleep(1000);
|
||||
await registerBtn.click();
|
||||
await sleep(1000);
|
||||
expect(registerBtn != null).assertTrue();
|
||||
done();
|
||||
})
|
||||
|
||||
/*
|
||||
* @tc.number: BundleManager_GetBundleInfoForSelfSync_003
|
||||
* @tc.name: By providing the sample code call interface
|
||||
* @tc.desc: Call the GetBundleInfoForSelfSync API successfully
|
||||
* @tc.size: MediumTest
|
||||
* @tc.type: Function
|
||||
* @tc.level Level 1
|
||||
*/
|
||||
it('BundleManager_GetBundleInfoForSelfSync_003', 0, async (done: Function) => {
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'BundleManager_GetBundleInfoForSelfSync_003 start');
|
||||
let driver = Driver.create();
|
||||
await sleep(1000);
|
||||
let registerBtn = await driver.findComponent(ON.text(
|
||||
await resourceManager.getStringValue($r('app.string.GetBundleInfoSyncTest'))));
|
||||
await sleep(1000);
|
||||
@ -110,15 +131,36 @@ export default function abilityTest() {
|
||||
})
|
||||
|
||||
/*
|
||||
* @tc.number: BundleManager_GetProfileByExtensionAbility_005
|
||||
* @tc.number: BundleManager_getProfileByAbilitySync_005
|
||||
* @tc.name: By providing the sample code call interface
|
||||
* @tc.desc: Call the GetProfileByExtensionAbility API successfully
|
||||
* @tc.size: MediumTest
|
||||
* @tc.type: Function
|
||||
* @tc.level Level 1
|
||||
*/
|
||||
it('BundleManager_GetProfileByExtensionAbility_005', 0, async (done: Function) => {
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'BundleManager_GetProfileByExtensionAbility_005 start');
|
||||
it('BundleManager_getProfileByAbilitySync_005', 0, async (done: Function) => {
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'BundleManager_getProfileByAbilitySync_005 start');
|
||||
let driver = Driver.create();
|
||||
await sleep(1000);
|
||||
let registerBtn = await driver.findComponent(ON.text(
|
||||
await resourceManager.getStringValue($r('app.string.GetConfigurationSyncTest'))));
|
||||
await sleep(1000);
|
||||
await registerBtn.click();
|
||||
await sleep(2000);
|
||||
expect(registerBtn != null).assertTrue();
|
||||
done();
|
||||
})
|
||||
|
||||
/*
|
||||
* @tc.number: BundleManager_GetProfileByExtensionAbility_006
|
||||
* @tc.name: By providing the sample code call interface
|
||||
* @tc.desc: Call the GetProfileByExtensionAbility API successfully
|
||||
* @tc.size: MediumTest
|
||||
* @tc.type: Function
|
||||
* @tc.level Level 1
|
||||
*/
|
||||
it('BundleManager_GetProfileByExtensionAbility_006', 0, async (done: Function) => {
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'BundleManager_GetProfileByExtensionAbility_006 start');
|
||||
let driver = Driver.create();
|
||||
await sleep(1000);
|
||||
let registerBtn = await driver.findComponent(ON.text(
|
||||
@ -131,19 +173,19 @@ export default function abilityTest() {
|
||||
})
|
||||
|
||||
/*
|
||||
* @tc.number: BundleManager_GetProfileByExtensionAbilitySync_006
|
||||
* @tc.number: BundleManager_GetProfileByExtensionAbilitySync_007
|
||||
* @tc.name: By providing the sample code call interface
|
||||
* @tc.desc: Call the GetProfileByExtensionAbilitySync API successfully
|
||||
* @tc.size: MediumTest
|
||||
* @tc.type: Function
|
||||
* @tc.level Level 1
|
||||
*/
|
||||
it('BundleManager_GetProfileByExtensionAbilitySync_006', 0, async (done: Function) => {
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'BundleManager_GetProfileByExtensionAbilitySync_006 start');
|
||||
it('BundleManager_GetProfileByExtensionAbilitySync_007', 0, async (done: Function) => {
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'BundleManager_GetProfileByExtensionAbilitySync_007 start');
|
||||
let driver = Driver.create();
|
||||
await sleep(2000);
|
||||
let registerBtn = await driver.findComponent(ON.text(
|
||||
await resourceManager.getStringValue($r('app.string.GetConfigurationJsonSyncTest'))));
|
||||
await resourceManager.getStringValue($r('app.string.GetConfigurationArraySyncTest'))));
|
||||
await sleep(1000);
|
||||
await registerBtn.click();
|
||||
await sleep(1000);
|
||||
@ -152,20 +194,21 @@ export default function abilityTest() {
|
||||
})
|
||||
|
||||
/*
|
||||
* @tc.number: BundleManager_CanOpenLink_007
|
||||
* @tc.number: BundleManager_CanOpenLink_008
|
||||
* @tc.name: By providing the sample code call interface
|
||||
* @tc.desc: Call the CanOpenLink API successfully
|
||||
* @tc.size: MediumTest
|
||||
* @tc.type: Function
|
||||
* @tc.level Level 1
|
||||
*/
|
||||
it('BundleManager_CanOpenLink_007', 0, async (done: Function) => {
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'BundleManager_CanOpenLink_007 start');
|
||||
it('BundleManager_CanOpenLink_008', 0, async (done: Function) => {
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'BundleManager_CanOpenLink_008 start');
|
||||
let driver = Driver.create();
|
||||
await sleep(1000);
|
||||
let registerBtn = await driver.findComponent(ON.text(
|
||||
await resourceManager.getStringValue($r('app.string.VerifyLinkOpenedTest'))));
|
||||
await sleep(1000);
|
||||
await driver.swipe(360, 1100, 360, 100);
|
||||
await registerBtn.click();
|
||||
await sleep(1000);
|
||||
expect(registerBtn != null).assertTrue();
|
||||
@ -173,18 +216,17 @@ export default function abilityTest() {
|
||||
})
|
||||
|
||||
/*
|
||||
* @tc.number: DefaultAppMgr_IsDefaultApplication_008
|
||||
* @tc.number: DefaultAppMgr_IsDefaultApplication_009
|
||||
* @tc.name: By providing the sample code call interface
|
||||
* @tc.desc: Call the IsDefaultApplication API successfully
|
||||
* @tc.size: MediumTest
|
||||
* @tc.type: Function
|
||||
* @tc.level Level 1
|
||||
*/
|
||||
it('DefaultAppMgr_IsDefaultApplication_008', 0, async (done: Function) => {
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'DefaultAppMgr_IsDefaultApplication_008 start');
|
||||
it('DefaultAppMgr_IsDefaultApplication_009', 0, async (done: Function) => {
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'DefaultAppMgr_IsDefaultApplication_009 start');
|
||||
let driver = Driver.create();
|
||||
await sleep(1000);
|
||||
await driver.swipe(360, 1070, 360, 600);
|
||||
let registerBtn = await driver.findComponent(ON.text(
|
||||
await resourceManager.getStringValue($r('app.string.DetermineDefaultApplicationTest'))));
|
||||
await sleep(1000);
|
||||
@ -195,15 +237,15 @@ export default function abilityTest() {
|
||||
})
|
||||
|
||||
/*
|
||||
* @tc.number: DefaultAppMgr_IsDefaultApplicationSync_009
|
||||
* @tc.number: DefaultAppMgr_IsDefaultApplicationSync_010
|
||||
* @tc.name: By providing the sample code call interface
|
||||
* @tc.desc: Call the IsDefaultApplicationSync API successfully
|
||||
* @tc.size: MediumTest
|
||||
* @tc.type: Function
|
||||
* @tc.level Level 1
|
||||
*/
|
||||
it('DefaultAppMgr_IsDefaultApplicationSync_009', 0, async (done: Function) => {
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'DefaultAppMgr_IsDefaultApplicationSync_009 start');
|
||||
it('DefaultAppMgr_IsDefaultApplicationSync_010', 0, async (done: Function) => {
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'DefaultAppMgr_IsDefaultApplicationSync_010 start');
|
||||
let driver = Driver.create();
|
||||
await sleep(1000);
|
||||
let registerBtn = await driver.findComponent(ON.text(
|
||||
@ -216,15 +258,15 @@ export default function abilityTest() {
|
||||
})
|
||||
|
||||
/*
|
||||
* @tc.number: Overlay_SetOverlayEnabled_010
|
||||
* @tc.number: Overlay_SetOverlayEnabled_011
|
||||
* @tc.name: By providing the sample code call interface
|
||||
* @tc.desc: Call the SetOverlayEnabled API successfully
|
||||
* @tc.size: MediumTest
|
||||
* @tc.type: Function
|
||||
* @tc.level Level 1
|
||||
*/
|
||||
it('Overlay_SetOverlayEnabled_010', 0, async (done: Function) => {
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'Overlay_SetOverlayEnabled_010 start');
|
||||
it('Overlay_SetOverlayEnabled_011', 0, async (done: Function) => {
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'Overlay_SetOverlayEnabled_011 start');
|
||||
let driver = Driver.create();
|
||||
await sleep(1000);
|
||||
let registerBtn = await driver.findComponent(ON.text(
|
||||
@ -237,15 +279,15 @@ export default function abilityTest() {
|
||||
})
|
||||
|
||||
/*
|
||||
* @tc.number: Overlay_GetOverlayModuleInfo_011
|
||||
* @tc.number: Overlay_GetOverlayModuleInfo_012
|
||||
* @tc.name: By providing the sample code call interface
|
||||
* @tc.desc: Call the GetOverlayModuleInfo API successfully
|
||||
* @tc.size: MediumTest
|
||||
* @tc.type: Function
|
||||
* @tc.level Level 1
|
||||
*/
|
||||
it('Overlay_GetOverlayModuleInfo_011', 0, async (done: Function) => {
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'Overlay_GetOverlayModuleInfo_011 start');
|
||||
it('Overlay_GetOverlayModuleInfo_012', 0, async (done: Function) => {
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'Overlay_GetOverlayModuleInfo_012 start');
|
||||
let driver = Driver.create();
|
||||
await sleep(1000);
|
||||
let registerBtn = await driver.findComponent(ON.text(
|
||||
@ -258,15 +300,15 @@ export default function abilityTest() {
|
||||
})
|
||||
|
||||
/*
|
||||
* @tc.number: Overlay_GetTargetOverlayModuleInfos_012
|
||||
* @tc.number: Overlay_GetTargetOverlayModuleInfos_013
|
||||
* @tc.name: By providing the sample code call interface
|
||||
* @tc.desc: Call the GetTargetOverlayModuleInfos API successfully
|
||||
* @tc.size: MediumTest
|
||||
* @tc.type: Function
|
||||
* @tc.level Level 1
|
||||
*/
|
||||
it('Overlay_GetTargetOverlayModuleInfos_012', 0, async (done: Function) => {
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'Overlay_GetTargetOverlayModuleInfos_012 start');
|
||||
it('Overlay_GetTargetOverlayModuleInfos_013', 0, async (done: Function) => {
|
||||
hilog.info(DOMAIN_NUMBER, TAG, 'Overlay_GetTargetOverlayModuleInfos_013 start');
|
||||
let driver = Driver.create();
|
||||
await sleep(1000);
|
||||
let registerBtn = await driver.findComponent(ON.text(
|
||||
|
@ -16,6 +16,10 @@
|
||||
"name": "GetBundleInfoTest",
|
||||
"value": "获取BundleInfo"
|
||||
},
|
||||
{
|
||||
"name": "GetBundleInfoCombinationTest",
|
||||
"value": "获取BundleInfo(组合参数)"
|
||||
},
|
||||
{
|
||||
"name": "GetBundleInfoSyncTest",
|
||||
"value": "获取BundleInfo(sync)"
|
||||
@ -29,7 +33,11 @@
|
||||
"value": "获取配置数组"
|
||||
},
|
||||
{
|
||||
"name": "GetConfigurationJsonSyncTest",
|
||||
"name": "GetConfigurationArraySyncTest",
|
||||
"value": "获取配置数组(sync)"
|
||||
},
|
||||
{
|
||||
"name": "GetConfigurationSyncTest",
|
||||
"value": "获取配置json(sync)"
|
||||
},
|
||||
{
|
||||
|
@ -16,6 +16,10 @@
|
||||
"name": "GetBundleInfoTest",
|
||||
"value": "GetBundleInfo"
|
||||
},
|
||||
{
|
||||
"name": "GetBundleInfoCombinationTest",
|
||||
"value": "GetBundleInfoCombinationTest"
|
||||
},
|
||||
{
|
||||
"name": "GetBundleInfoSyncTest",
|
||||
"value": "GetBundleInfoSync"
|
||||
@ -29,8 +33,12 @@
|
||||
"value": "GetConfigurationArray"
|
||||
},
|
||||
{
|
||||
"name": "GetConfigurationJsonSyncTest",
|
||||
"value": "GetConfigurationJsonSync"
|
||||
"name": "GetConfigurationArraySyncTest",
|
||||
"value": "GetConfigurationArraySyncTest"
|
||||
},
|
||||
{
|
||||
"name": "GetConfigurationSyncTest",
|
||||
"value": "GetConfigurationSyncTest"
|
||||
},
|
||||
{
|
||||
"name": "VerifyFileTest",
|
||||
|
@ -16,6 +16,10 @@
|
||||
"name": "GetBundleInfoTest",
|
||||
"value": "获取BundleInfo"
|
||||
},
|
||||
{
|
||||
"name": "GetBundleInfoCombinationTest",
|
||||
"value": "获取BundleInfo(组合参数)"
|
||||
},
|
||||
{
|
||||
"name": "GetBundleInfoSyncTest",
|
||||
"value": "获取BundleInfo(sync)"
|
||||
@ -29,7 +33,11 @@
|
||||
"value": "获取配置数组"
|
||||
},
|
||||
{
|
||||
"name": "GetConfigurationJsonSyncTest",
|
||||
"name": "GetConfigurationArraySyncTest",
|
||||
"value": "获取配置数组(sync)"
|
||||
},
|
||||
{
|
||||
"name": "GetConfigurationSyncTest",
|
||||
"value": "获取配置json(sync)"
|
||||
},
|
||||
{
|
||||
|
@ -1,15 +1,16 @@
|
||||
|测试功能|预置条件|输入|预期输出|测试结果|
|
||||
|--------------------------------|--------------------------------|--------------------------------|--------------------------------|--------------------------------|
|
||||
|进入主页| 1.拉起资源API示例页面 |不涉及|调用GetProfileByExtensionAbility接口成功,页面正常展示字符串文本|Pass|
|
||||
|进入主页| 1.拉起资源API示例页面 |不涉及|调用GetBundleInfoForSelfSync接口成功,页面正常展示字符串文本|Pass|
|
||||
|进入主页| 1.拉起资源API示例页面 |不涉及|调用GetProfileByAbility接口成功,页面正常展示字符串文本|Pass|
|
||||
|进入主页| 1.拉起资源API示例页面 |不涉及|调用GetProfileByExtensionAbility接口成功,页面正常展示字符串文本|Pass|
|
||||
|进入主页| 1.拉起资源API示例页面 |不涉及|调用GetProfileByExtensionAbilitySync接口成功,页面正常展示字符串文本|Pass|
|
||||
|进入主页| 1.将.abc文件放到/data/app/el1/bundle/public/com.samples.bundlemanagement/目录下 2.拉起资源API示例页面 |不涉及|调用verifyAbc接口成功,页面正常展示字符串文本|Pass|
|
||||
|进入主页| 1.将.abc文件放到/data/app/el1/bundle/public/com.samples.bundlemanagement/目录下 2.拉起资源API示例页面 |不涉及|调用deleteAbc接口成功,页面正常展示字符串文本|Pass|
|
||||
|进入主页| 1.拉起资源API示例页面 |不涉及|调用CanOpenLink接口成功,页面正常展示字符串文本|Pass|
|
||||
|进入主页| 1.拉起资源API示例页面 |不涉及|调用IsDefaultApplication接口成功,页面正常展示字符串文本|Pass|
|
||||
|进入主页| 1.拉起资源API示例页面 |不涉及|调用IsDefaultApplicationSync接口成功,页面正常展示字符串文本|Pass|
|
||||
|进入主页| 1.拉起Overlay示例页面,根据静态overlay脚本安装共享hsp包 |不涉及|调用SetOverlayEnabled接口成功,页面正常展示字符串文本|Pass|
|
||||
|进入主页| 1.拉起OverlayModuleInfo示例页面 |不涉及|调用GetOverlayModuleInfo接口成功,页面正常展示字符串文本|Pass|
|
||||
|进入主页| 1.拉起OverlayModuleInfo示例页面 |不涉及|调用GetTargetOverlayModuleInfos接口成功,页面正常展示字符串文本|Pass|
|
||||
|测试功能|预置条件|输入|预期输出|是否自动|测试结果|
|
||||
|--------------------------------|--------------------------------|--------------------------------|--------------------------------|--------------------------------|--------------------------------|
|
||||
|进入主页| 1.拉起资源API示例页面 |不涉及|调用getBundleInfoForSelf接口成功,页面正常展示字符串文本|是|Pass|
|
||||
|进入主页| 1.拉起资源API示例页面 |不涉及|调用getBundleInfoForSelfSync接口成功,页面正常展示字符串文本|是|Pass|
|
||||
|进入主页| 1.拉起资源API示例页面 |不涉及|调用getProfileByAbility接口成功,页面正常展示字符串文本|是|Pass|
|
||||
|进入主页| 1.拉起资源API示例页面 |不涉及|调用getProfileByAbilitySync接口成功,页面正常展示字符串文本|是|Pass|
|
||||
|进入主页| 1.拉起资源API示例页面 |不涉及|调用GetProfileByExtensionAbility接口成功,页面正常展示字符串文本|是|Pass|
|
||||
|进入主页| 1.拉起资源API示例页面 |不涉及|调用GetProfileByExtensionAbilitySync接口成功,页面正常展示字符串文本|是|Pass|
|
||||
|进入主页| 1.将.abc文件放到/data/app/el1/bundle/public/com.samples.bundlemanagement/目录下<br />2.拉起资源API示例页面 |不涉及|调用verifyAbc接口成功,页面正常展示字符串文本|否|Pass|
|
||||
|进入主页| 1.将.abc文件放到/data/app/el1/bundle/public/com.samples.bundlemanagement/目录下 <br />2.拉起资源API示例页面 |不涉及|调用deleteAbc接口成功,页面正常展示字符串文本|否|Pass|
|
||||
|进入主页| 1.拉起资源API示例页面 |不涉及|调用CanOpenLink接口成功,页面正常展示字符串文本|是|Pass|
|
||||
|进入主页| 1.拉起资源API示例页面 |不涉及|调用IsDefaultApplication接口成功,页面正常展示字符串文本|是|Pass|
|
||||
|进入主页| 1.拉起资源API示例页面 |不涉及|调用IsDefaultApplicationSync接口成功,页面正常展示字符串文本|是|Pass|
|
||||
|进入主页| 1.拉起Overlay示例页面,根据静态overlay脚本安装共享hsp包 |不涉及|调用SetOverlayEnabled接口成功,页面正常展示字符串文本|是|Pass|
|
||||
|进入主页| 1.拉起OverlayModuleInfo示例页面 |不涉及|调用GetOverlayModuleInfo接口成功,页面正常展示字符串文本|是|Pass|
|
||||
|进入主页| 1.拉起OverlayModuleInfo示例页面 |不涉及|调用GetTargetOverlayModuleInfos接口成功,页面正常展示字符串文本|是|Pass|
|
@ -7,7 +7,7 @@
|
||||
|
||||
| 主页 | 上传 | 片段上传 | 下载 | 证书锁定 |
|
||||
| :---------------------------------------: | :---------------------------------------: | :--------------------------------------: | :--------------------------------------: | ---------------------------------------- |
|
||||
| ![home](screenshots/devices/zh/home.jpg) | ![util](screenshots/devices/zh/upload.jpg) | ![util](screenshots/devices/zh/uploadchunk.jpg) | ![convertxml](screenshots/devices/zh/download.jpg) | ![](D:\01Code\sample\PR\applications_app_samples\code\BasicFeature\Connectivity\UploadAndDownLoad\screenshots\devices\zh\cert_lock.jpg) |
|
||||
| ![home](screenshots/devices/zh/home.jpg) | ![util](screenshots/devices/zh/upload.jpg) | ![util](screenshots/devices/zh/uploadchunk.jpg) | ![convertxml](screenshots/devices/zh/download.jpg) | ![cert_lock](screenshots/devices/zh/cert_lock.jpg) |
|
||||
|
||||
使用说明
|
||||
|
||||
@ -120,7 +120,7 @@ UploadAndDownload
|
||||
|
||||
2.本示例为Stage模型,支持API12版本SDK,SDK版本号(API Version 12),镜像版本号(5.0)
|
||||
|
||||
3.本示例需要使用DevEco Studio 版本号(4.0 Release)及以上版本才可编译运行。
|
||||
3.本示例需要使用DevEco Studio 版本号(4.1 Release)及以上版本才可编译运行。
|
||||
|
||||
4.运行本示例需全程联网。
|
||||
|
||||
|
@ -48,7 +48,6 @@ export default class EntryAbility extends UIAbility {
|
||||
onWindowStageCreate(windowStage: window.WindowStage): void {
|
||||
// Main window is created, set main page for this ability
|
||||
logger.info(TAG, 'Ability onWindowStageCreate');
|
||||
urlUtils.subscribe(this.context);
|
||||
windowStage.loadContent('pages/Index', (err, data) => {
|
||||
if (err.code) {
|
||||
logger.error(TAG, `Failed to load the content. Cause:${JSON.stringify(err) ?? ''}`);
|
||||
|
@ -16,6 +16,8 @@
|
||||
import notificationManager from '@ohos.notificationManager';
|
||||
import router from '@ohos.router';
|
||||
import common from '@ohos.app.ability.common';
|
||||
import { urlUtils } from '@ohos/uploaddownload';
|
||||
import util from '@ohos.util';
|
||||
|
||||
@Styles
|
||||
function itemStyle() {
|
||||
@ -61,7 +63,21 @@ struct Index {
|
||||
})
|
||||
}
|
||||
.itemStyle()
|
||||
.margin({ top: 0 })
|
||||
.margin({ top: 20 })
|
||||
|
||||
Row() {
|
||||
Text($r('app.string.HFS_tips'))
|
||||
.textStyle()
|
||||
Blank()
|
||||
TextInput()
|
||||
.width(250)
|
||||
.height(40)
|
||||
.margin({left : 20})
|
||||
.onChange((val) => urlUtils.saveUrl(getContext(this) as common.UIAbilityContext,val))
|
||||
}
|
||||
|
||||
.itemStyle()
|
||||
.margin({ top: 15 })
|
||||
|
||||
this.CapabilityView($r('app.media.ic_upload'), $r('app.string.upload'), 'btn_upload', () => {
|
||||
router.pushUrl({
|
||||
@ -80,8 +96,9 @@ struct Index {
|
||||
})
|
||||
}
|
||||
.width('100%')
|
||||
.margin({ left:-12 })
|
||||
}
|
||||
.padding({ left: 12, right: 12 })
|
||||
.padding({ left: 12, right: 6 })
|
||||
.height('100%')
|
||||
.align(Alignment.Top)
|
||||
}
|
||||
@ -94,7 +111,7 @@ struct Index {
|
||||
main: this.getResourceString($r('app.string.EntryAbility_label')),
|
||||
sub: this.getResourceString($r('app.string.home_tips'))
|
||||
})
|
||||
.margin({ top: 10 })
|
||||
.padding({ top:5 })
|
||||
}
|
||||
|
||||
@Builder
|
||||
|
@ -108,6 +108,10 @@
|
||||
"name": "background_tips",
|
||||
"value": "Whether to start background tasks"
|
||||
},
|
||||
{
|
||||
"name": "HFS_tips",
|
||||
"value": "HFS Address"
|
||||
},
|
||||
{
|
||||
"name": "home_tips",
|
||||
"value": "Demonstrate foreground and background upload and download tasks"
|
||||
|
@ -108,6 +108,10 @@
|
||||
"name": "background_tips",
|
||||
"value": "Whether to start background tasks"
|
||||
},
|
||||
{
|
||||
"name": "HFS_tips",
|
||||
"value": "HFS Address"
|
||||
},
|
||||
{
|
||||
"name": "home_tips",
|
||||
"value": "Demonstrate foreground and background upload and download tasks"
|
||||
|
@ -108,6 +108,10 @@
|
||||
"name": "background_tips",
|
||||
"value": "是否开启后台任务"
|
||||
},
|
||||
{
|
||||
"name": "HFS_tips",
|
||||
"value": "HFS 地址"
|
||||
},
|
||||
{
|
||||
"name": "home_tips",
|
||||
"value": "演示前台和后台上传和下载任务"
|
||||
|
@ -16,11 +16,11 @@ https://nchc.dl.sourceforge.net/project/hfs/HFS/2.3m/hfs.exe
|
||||
| ------------------------------------------------------------ | ------------------------ | ------------------------------------ |
|
||||
| ![bind](src/bind.png) | ![bind](src/prop.png) | ![bind](src/permission.png) |
|
||||
|
||||
4.**手机端打开应用后**,查看打开客户端的url,修改[setURL.bat](./setURL.bat)中的url为hfs客户端的url后双击运行[setURL.bat](./setURL.bat)。
|
||||
4.**手机端打开应用后**,查看打开客户端的url,修改HFS地址中的url为hfs客户端的url。
|
||||
|
||||
| 获取url | 修改url |
|
||||
| :-----------------------: | :-----------------------: |
|
||||
| ![copy](src/copy_url.png) | ![copy](src/past_url.png) |
|
||||
| ![copy](src/copy_url.png) | ![copy](src/past_url.jpg) |
|
||||
|
||||
5、按照顺序操作1-4步骤后,即可测试上传下载任务。
|
||||
|
||||
|
@ -1,17 +0,0 @@
|
||||
:: Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
:: Licensed under the Apache License, Version 2.0 (the "License");
|
||||
:: you may not use this file except in compliance with the License.
|
||||
:: You may obtain a copy of the License at
|
||||
::
|
||||
:: http://www.apache.org/licenses/LICENSE-2.0
|
||||
::
|
||||
:: Unless required by applicable law or agreed to in writing, software
|
||||
:: distributed under the License is distributed on an "AS IS" BASIS,
|
||||
:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
:: See the License for the specific language governing permissions and
|
||||
:: limitations under the License.
|
||||
|
||||
@echo off
|
||||
set url=http://192.168.8.183/
|
||||
hdc shell cem publish -e "uploaddownload.event.SET_URL" -c 100 -d %url%
|
||||
pause
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 12 KiB |
@ -21,29 +21,11 @@ import { CommonEventSubscriber } from './commonEvent/commonEventSubscriber';
|
||||
import { logger } from './Logger';
|
||||
|
||||
const TAG: string = 'UrlUtils';
|
||||
const SUBSCRIBER_EVENT: string = 'uploaddownload.event.SET_URL';
|
||||
const URL_KEY: string = 'url';
|
||||
const STORE_NAME: string = 'server_url';
|
||||
const DEFAULT_SERVER_URL: string = 'http://192.168.1.1/';
|
||||
|
||||
class UrlUtil {
|
||||
private subscriber: CommonEventSubscriber | undefined = undefined;
|
||||
|
||||
async subscribe(context: common.UIAbilityContext): Promise<void> {
|
||||
logger.info(TAG, `subscribe`)
|
||||
this.subscriber = await commonEventManager.createSubscriber({ events: [SUBSCRIBER_EVENT] });
|
||||
commonEventManager.subscribe(this.subscriber, (err: Error, data: CommonEventData) => {
|
||||
if (err) {
|
||||
logger.error(TAG, `subscribeCallBack, failed: ${JSON.stringify(err)}`);
|
||||
return;
|
||||
}
|
||||
logger.info(TAG, `subscribeCallBack, ${JSON.stringify(data)}`);
|
||||
if (data.event === 'uploaddownload.event.SET_URL' && data.data) {
|
||||
urlUtils.saveUrl(context, data.data);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async getUrl(context: common.UIAbilityContext): Promise<string> {
|
||||
let preference = await preferences.getPreferences(context, STORE_NAME);
|
||||
let url = await preference.get(URL_KEY, '') as string;
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"hvigorVersion": "3.0.2",
|
||||
"hvigorVersion": "3.2.4",
|
||||
"dependencies": {
|
||||
"@ohos/hvigor-ohos-plugin": "3.0.2"
|
||||
"@ohos/hvigor-ohos-plugin": "3.2.4"
|
||||
}
|
||||
}
|
Before Width: | Height: | Size: 7.1 KiB After Width: | Height: | Size: 11 KiB |
@ -9,4 +9,3 @@
|
||||
/.clang-format
|
||||
/.clang-tidy
|
||||
**/.test
|
||||
/oh-package-lock.json5
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@ -15,8 +15,8 @@
|
||||
|
||||
{
|
||||
"app": {
|
||||
"bundleName": "com.samples.intentdriver",
|
||||
"vendor": "samples",
|
||||
"bundleName": "com.example.udmfdemo",
|
||||
"vendor": "example",
|
||||
"versionCode": 1000000,
|
||||
"versionName": "1.0.0",
|
||||
"icon": "$media:app_icon",
|
@ -2,7 +2,7 @@
|
||||
"string": [
|
||||
{
|
||||
"name": "app_name",
|
||||
"value": "IntentExecute"
|
||||
"value": "UDMFDemo"
|
||||
}
|
||||
]
|
||||
}
|
After Width: | Height: | Size: 2.0 KiB |
72
code/BasicFeature/DataManagement/UDMF/UDMFDemo/README_zh.md
Normal file
@ -0,0 +1,72 @@
|
||||
# UDMF Demo
|
||||
|
||||
### 介绍
|
||||
|
||||
本示例主要使用[@ohos.data.uniformTypeDescriptor](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkdata/js-apis-data-uniformTypeDescriptor.md)
|
||||
[@ohos.data.unifiedDataChannel](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/@ohos.data.unifiedDataChannel.d.ts)展示了标准化数据定义与描述的功能,在新增预置文件后,对文件的utd标准类型获取、utd类型归属类型查询、获取文件对应的utd类型的默认图标等功能。 实现过程中还使用到[@ohos.file.fs](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-core-file-kit/js-apis-file-fs.md) 等接口。
|
||||
另外,展示了ArkTS控件[拖拽事件](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/arkui-ts/ts-universal-events-drag-drop.md)中使用UDMF数据结构相关实现。
|
||||
|
||||
|
||||
|
||||
### 效果预览
|
||||
|
||||
|首页|文件过滤| 文本拖拽结果 |
|
||||
|--------------------------------|--------------------------------|--------------------------------|
|
||||
|![image](screenshots/first.png)|![image](screenshots/select.png)| ![image](screenshots/drag.png) |
|
||||
|
||||
|
||||
使用说明
|
||||
1. 在主界面,类型过滤下拉框中,选择某一文件类型后,文件呈现区域展示对应类型的所有文件;
|
||||
2. 在主界面,点击txt后缀的文件,文本呈现区域可展示文件内容;
|
||||
3. 在主界面,对于txt后缀的文件,长按拖拽到右上角的文本控件区域,被拖拽的文件会被另存为新的文件,新生成的文件名会在组件内显示,如果文件名过长会在组件内滚动显示;
|
||||
4. 在主界面,在“文本呈现区域”右边长按拖拽到右上角的文本控件区域,被拖拽的文本会被另存为新的文件,新生成的文件名会在组件内显示,如果文件名过长会在组件内滚动显示;
|
||||
|
||||
### 工程目录
|
||||
|
||||
```
|
||||
entry/src/main/ets/
|
||||
|---entryAbility
|
||||
|---fileFs
|
||||
| |---fileFs.ets
|
||||
|---util
|
||||
| |---Common.ets
|
||||
| |---Logger.ets
|
||||
|---pages|
|
||||
| |---Index.ets // 首页
|
||||
```
|
||||
|
||||
### 具体实现
|
||||
|
||||
#### 场景一:下拉列表选择不同数据类型可以进行过滤文件
|
||||
* 预置条件:应用中设置不同类型的文件数据到沙箱内
|
||||
* 输入:指定文件类型
|
||||
* 输出:筛选出指定文件类型,过滤后的文件图标排列到文件呈现区域。
|
||||
|
||||
|
||||
#### 场景二:实现选择出来的文件/文本信息能够被拖拽到另一个设备的应用内落为文件
|
||||
* 输入:选定文件/文本
|
||||
|
||||
* 输出:
|
||||
1.拖拽文件/数据到落入框后, 落入文件/数据另存为文件;
|
||||
|
||||
### 相关权限
|
||||
无
|
||||
### 依赖
|
||||
|
||||
不涉及
|
||||
|
||||
### 约束与限制
|
||||
|
||||
1. 本示例仅支持标准系统上运行,支持设备:RK3568。
|
||||
2. 本示例为Stage模型,仅支持API12版本SDK,SDK版本号(API Version 12 Release),镜像版本号(OpenHarmony 5.0.0.25及更高版本)。
|
||||
3. 本示例需要使用DevEco Studio 版本号(4.1Release)及以上版本才可编译运行。
|
||||
|
||||
### 下载
|
||||
|
||||
如需单独下载本工程,执行如下命令:
|
||||
|
||||
git init
|
||||
git config core.sparsecheckout true
|
||||
echo code/BasicFeature/DataManagement/UDMF/UDMFDemo/ > .git/info/sparse-checkout
|
||||
git remote add origin https://gitee.com/openharmony/applications_app_samples.git
|
||||
git pull origin master
|
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
{
|
||||
"app": {
|
||||
"signingConfigs": [
|
||||
],
|
||||
"products": [
|
||||
{
|
||||
"name": "default",
|
||||
"signingConfig": "default",
|
||||
"compileSdkVersion": 12,
|
||||
"compatibleSdkVersion": 12
|
||||
}
|
||||
],
|
||||
"buildModeSet": [
|
||||
{
|
||||
"name": "debug",
|
||||
},
|
||||
{
|
||||
"name": "release"
|
||||
}
|
||||
]
|
||||
},
|
||||
"modules": [
|
||||
{
|
||||
"name": "entry",
|
||||
"srcPath": "./entry",
|
||||
"targets": [
|
||||
{
|
||||
"name": "default",
|
||||
"applyToProducts": [
|
||||
"default"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@ -14,7 +14,7 @@
|
||||
*/
|
||||
|
||||
{
|
||||
"apiType": 'stageMode',
|
||||
"apiType": "stageMode",
|
||||
"buildOption": {
|
||||
},
|
||||
"targets": [
|
@ -0,0 +1,6 @@
|
||||
import { hapTasks } from '@ohos/hvigor-ohos-plugin';
|
||||
|
||||
export default {
|
||||
system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
|
||||
plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
{
|
||||
"name": "entry",
|
||||
"version": "1.0.0",
|
||||
"description": "Please describe the basic information.",
|
||||
"main": "",
|
||||
"author": "",
|
||||
"license": "",
|
||||
"dependencies": {}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@ -8,52 +8,51 @@
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF InputStyle KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import AbilityConstant from '@ohos.app.ability.AbilityConstant';
|
||||
import Base from '@ohos.base';
|
||||
import hilog from '@ohos.hilog';
|
||||
import UIAbility from '@ohos.app.ability.UIAbility';
|
||||
import Want from '@ohos.app.ability.Want';
|
||||
import window from '@ohos.window';
|
||||
import { logger } from '../util/Logger';
|
||||
|
||||
const TAG: string = '[EntryAbility]';
|
||||
|
||||
export default class EntryAbility extends UIAbility {
|
||||
onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) {
|
||||
logger.info(TAG, `Ability onCreate want: ${JSON.stringify(want)}, launchParam: ${JSON.stringify(launchParam)}`);
|
||||
onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
|
||||
}
|
||||
|
||||
onDestroy() {
|
||||
logger.info(TAG, 'Ability onDestroy');
|
||||
onDestroy(): void {
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
|
||||
}
|
||||
|
||||
onWindowStageCreate(windowStage: window.WindowStage) {
|
||||
onWindowStageCreate(windowStage: window.WindowStage): void {
|
||||
// Main window is created, set main page for this ability
|
||||
logger.info(TAG, 'Ability onWindowStageCreate');
|
||||
windowStage.loadContent('pages/Index', (err: Base.BusinessError) => {
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
|
||||
|
||||
windowStage.loadContent('pages/Index', (err) => {
|
||||
if (err.code) {
|
||||
logger.info(TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
|
||||
hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
|
||||
return;
|
||||
}
|
||||
hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.');
|
||||
});
|
||||
}
|
||||
|
||||
onWindowStageDestroy() {
|
||||
onWindowStageDestroy(): void {
|
||||
// Main window is destroyed, release UI related resources
|
||||
logger.info(TAG, 'Ability onWindowStageDestroy');
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
|
||||
}
|
||||
|
||||
onForeground() {
|
||||
onForeground(): void {
|
||||
// Ability has brought to foreground
|
||||
logger.info(TAG, 'Ability onForeground');
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
|
||||
}
|
||||
|
||||
onBackground() {
|
||||
onBackground(): void {
|
||||
// Ability has back to background
|
||||
logger.info(TAG, 'Ability onBackground');
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
|
||||
}
|
||||
}
|
@ -0,0 +1,131 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { bufferToString } from '../util/Common';
|
||||
import { logger } from '../util/Logger';
|
||||
import fs from '@ohos.file.fs';
|
||||
import fileUri from '@ohos.file.fileuri';
|
||||
import wantConstant from '@ohos.ability.wantConstant';
|
||||
|
||||
import Want from '@ohos.app.ability.Want';
|
||||
|
||||
let fileContent = '';
|
||||
const BUFFER_SIZE = 4096; // 读写文件缓冲区大小
|
||||
const FILE_NUM = 3; // 沙箱目录预制文件个数
|
||||
const DIR_FILE_NUM = 10; // 沙箱目录文件夹中预制文件个数
|
||||
const TAG: string = '[File].[SandboxShare]';
|
||||
|
||||
export default class FileFs {
|
||||
public fileSize: number = 0;
|
||||
private baseDir: string = '';
|
||||
private dmClass: Object = null;
|
||||
public log: string[] = [];
|
||||
public fileInfo = {
|
||||
path: [],
|
||||
size: 0
|
||||
};
|
||||
|
||||
constructor() {
|
||||
let content1: string = AppStorage.Get('fileContent1');
|
||||
let content2: string = AppStorage.Get('fileContent2');
|
||||
let content3: string = AppStorage.Get('fileContent3');
|
||||
let content4: string = AppStorage.Get('fileContent4');
|
||||
fileContent = content1 + '\r\n\n' + content2 + '\r\n\n' + content3 + '\r\n\n' + content4;
|
||||
}
|
||||
|
||||
readyFilesToTestDir(filesDir: string): void {
|
||||
let content = fileContent;
|
||||
this.baseDir = filesDir + '/TestDir';
|
||||
|
||||
try {
|
||||
let flag = TAG;
|
||||
if (!fs.accessSync(this.baseDir)) {
|
||||
fs.mkdirSync(this.baseDir);
|
||||
}
|
||||
let dpath = this.baseDir;
|
||||
|
||||
|
||||
logger.info(TAG, 'readyFileToWatcher dpath = ' + dpath);
|
||||
for (let i = 0; i < DIR_FILE_NUM; i++) {
|
||||
let myFile = dpath + `/testFile_${i}.txt`;
|
||||
logger.info(TAG, 'readyFileToWatcher myFile = ' + myFile);
|
||||
let file = fs.openSync(myFile, fs.OpenMode.CREATE | fs.OpenMode.READ_WRITE);
|
||||
fs.writeSync(file.fd, content);
|
||||
fs.closeSync(file);
|
||||
}
|
||||
logger.info(TAG, 'readyFileToWatcher successful');
|
||||
} catch (e) {
|
||||
logger.error(TAG, `readyFileToWatcher has failed for: {message: ${e.message}, code: ${e.code}}`);
|
||||
}
|
||||
}
|
||||
|
||||
readyFilesToCurDir(filesDir: string): void {
|
||||
let content = fileContent;
|
||||
this.baseDir = filesDir;
|
||||
|
||||
try {
|
||||
let flag = TAG;
|
||||
if (!fs.accessSync(this.baseDir)) {
|
||||
fs.mkdirSync(this.baseDir);
|
||||
}
|
||||
let dpath = this.baseDir;
|
||||
|
||||
logger.info(TAG, 'readyFileToWatcher dpath = ' + dpath);
|
||||
for (let i = 0; i < FILE_NUM; i++) {
|
||||
let myFile = dpath + `/myFile_${i}.txt`;
|
||||
logger.info(TAG, 'readyFileToWatcher myFile = ' + myFile);
|
||||
let file = fs.openSync(myFile, fs.OpenMode.CREATE | fs.OpenMode.READ_WRITE);
|
||||
fs.writeSync(file.fd, content);
|
||||
fs.closeSync(file);
|
||||
}
|
||||
logger.info(TAG, 'readyFileToWatcher successful');
|
||||
} catch (e) {
|
||||
logger.error(TAG, `readyFileToWatcher has failed for: {message: ${e.message}, code: ${e.code}}`);
|
||||
}
|
||||
}
|
||||
|
||||
getFileContentBuffer(path: string): ArrayBuffer {
|
||||
let buf = new ArrayBuffer(BUFFER_SIZE);
|
||||
try {
|
||||
logger.info(TAG, 'modifyFileToWatcher getFileContent filePath = ' + path);
|
||||
let file = fs.openSync(path, fs.OpenMode.READ_WRITE);
|
||||
let num = fs.readSync(file.fd, buf);
|
||||
logger.info(TAG, 'modifyFileToWatcher getFileContent read num = ' + num);
|
||||
fs.closeSync(file);
|
||||
return buf;
|
||||
} catch (e) {
|
||||
logger.error(TAG, `modifyFileToWatcher getFileContent has failed for: {message: ${e.message}, code: ${e.code}}`);
|
||||
return buf;
|
||||
}
|
||||
}
|
||||
|
||||
getFileContent(path: string): string {
|
||||
let resultPut = '';
|
||||
try {
|
||||
logger.info(TAG, 'modifyFileToWatcher getFileContent filePath = ' + path);
|
||||
let file = fs.openSync(path, fs.OpenMode.READ_WRITE);
|
||||
let buf = new ArrayBuffer(BUFFER_SIZE);
|
||||
let num = fs.readSync(file.fd, buf);
|
||||
logger.info(TAG, 'modifyFileToWatcher getFileContent read num = ' + num);
|
||||
resultPut = bufferToString(buf);
|
||||
logger.info(TAG, 'modifyFileToWatcher getFileContent read resultPut = ' + resultPut);
|
||||
fs.closeSync(file);
|
||||
return resultPut;
|
||||
} catch (e) {
|
||||
logger.error(TAG, `modifyFileToWatcher getFileContent has failed for: {message: ${e.message}, code: ${e.code}}`);
|
||||
return resultPut;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,599 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF InputStyle KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import fs from '@ohos.file.fs';
|
||||
import fileUri from '@ohos.file.fileuri';
|
||||
import common from '@ohos.app.ability.common';
|
||||
import utdDesc from '@ohos.data.uniformTypeDescriptor';
|
||||
import { BusinessError } from '@ohos.base';
|
||||
import { logger } from '../util/Logger';
|
||||
import UDC from '@ohos.data.unifiedDataChannel';
|
||||
import UTD from '@ohos.data.uniformTypeDescriptor';
|
||||
import FileFs from '../fileFs/fileFs'
|
||||
import { randomString } from '../util/Common';
|
||||
import systemDateTime from '@ohos.systemDateTime';
|
||||
|
||||
const TAG: string = 'UDMF_Demo';
|
||||
|
||||
// 获取应用文件路径
|
||||
let context = getContext(this) as common.UIAbilityContext;
|
||||
let baseDir = context.filesDir;
|
||||
let filesDir = baseDir + '/udmf_demo_test';
|
||||
|
||||
let class2UTD = new Map([
|
||||
["All", "All"],
|
||||
["Images", "general.image"],
|
||||
["Audios", "general.audio"],
|
||||
["Videos", "general.video"],
|
||||
["Text", "general.text"],
|
||||
["Archive", "general.archive"],
|
||||
["Calendar", "general.calendar"],
|
||||
["ComObject", "general.composite-object"],
|
||||
["Exe", "general.executable"],
|
||||
["OpenXml", "org.openxmlformats.openxml"],
|
||||
|
||||
]);
|
||||
|
||||
class FileInfo {
|
||||
filename: string;
|
||||
iconFile: string;
|
||||
|
||||
constructor(fileName: string, iconFile: string) {
|
||||
this.filename = fileName;
|
||||
this.iconFile = iconFile;
|
||||
}
|
||||
}
|
||||
|
||||
let precastFiles: string[] = [
|
||||
"test1.txt",
|
||||
"testx.xhtml",
|
||||
"testc.css",
|
||||
"testm.md",
|
||||
"testRtf.rtf",
|
||||
"testCsv.csv",
|
||||
|
||||
"imagePng1.png",
|
||||
"imageJpg2.jpg",
|
||||
"imageTiff1.tiff",
|
||||
"imageTiff2.tiff",
|
||||
"imageMyImage1.myImage",
|
||||
"imageMyImage2.myImage",
|
||||
"imageXbm.xbm",
|
||||
"imageFpx.fpx",
|
||||
"imageGif.gif",
|
||||
|
||||
"myPsd.psd",
|
||||
"audioMp32.mp3",
|
||||
"audioAu.au",
|
||||
"audioAif.aif",
|
||||
"audioM4a.m4a",
|
||||
"audioMp2.mp2",
|
||||
"audioMpga.mpga",
|
||||
|
||||
"audioAu.au",
|
||||
"audioSd2.sd2",
|
||||
"audioRa.ra",
|
||||
"audioMka.mka",
|
||||
|
||||
"audioWav1.wav",
|
||||
"audioWav2.wav",
|
||||
"myBz2.bz2",
|
||||
"myZip.zip",
|
||||
"audioMyAudio1.myAudio",
|
||||
"audioMyAudio2.myAudio",
|
||||
|
||||
"myHtml.html",
|
||||
"myXml.xml",
|
||||
"myIcs.ics",
|
||||
"videoMpeg2.mpeg",
|
||||
"myVcs.vcs",
|
||||
"videoAvi2.avi",
|
||||
"myTar.tar",
|
||||
"videoMyVideo2.myVideo",
|
||||
"videoMxu.mxu",
|
||||
"videoRm.rm",
|
||||
"videoMkv.mkv",
|
||||
"videoSwf.swf",
|
||||
|
||||
"myArchiveOpg.opg",
|
||||
"myArchiveIso.iso",
|
||||
|
||||
|
||||
// api 12新增
|
||||
"myComObjectPps.pps",
|
||||
"myComObjectXlt.xlt",
|
||||
"myComObjectVsd.vsd",
|
||||
|
||||
"myComObjectVsdx.vsdx",
|
||||
"myComObjectDocm.docm",
|
||||
"myComObjectXlsm.xlsm",
|
||||
"myComObjectPptm.pptm",
|
||||
"myComObjectVsdx.vsdx",
|
||||
"myComObjectVstx.vstx",
|
||||
|
||||
|
||||
"myExe.exe",
|
||||
"myClass.class",
|
||||
|
||||
"myOfd.ofd",
|
||||
"myRar.rar",
|
||||
"My7z.7z"
|
||||
];
|
||||
|
||||
// 预制文件
|
||||
function CreatePrecastFile(): void {
|
||||
try {
|
||||
let res = fs.accessSync(filesDir);
|
||||
if (res) {
|
||||
logger.info(TAG, `file path: ${filesDir} exists`);
|
||||
} else {
|
||||
logger.info(TAG, `file path: ${filesDir} not exists`);
|
||||
fs.mkdirSync(filesDir);
|
||||
}
|
||||
} catch (error) {
|
||||
let err: BusinessError = error as BusinessError;
|
||||
logger.error(TAG, 'accessSync failed with error message: ' + err.message + ', error code: ' + err.code);
|
||||
}
|
||||
|
||||
for (let i = 0; i < precastFiles.length; i++) {
|
||||
let fileName = filesDir + '/' + precastFiles[i];
|
||||
logger.info(TAG, `The file name: ${fileName}`);
|
||||
try {
|
||||
let res = fs.accessSync(fileName);
|
||||
if (res) {
|
||||
logger.info(TAG, `file: ${fileName} exists!.`);
|
||||
} else {
|
||||
logger.info(TAG, `file: ${fileName} not exists, will create it!.`);
|
||||
let file = fs.openSync(fileName, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE);
|
||||
logger.info(TAG, 'file fd: ' + file.fd);
|
||||
|
||||
if (fileName.includes('.txt')) {
|
||||
logger.info(TAG, 'txt file write sync ');
|
||||
fs.writeSync(file.fd, 'test content 1 test content 2');
|
||||
}
|
||||
fs.closeSync(file);
|
||||
}
|
||||
} catch (error) {
|
||||
let err: BusinessError = error as BusinessError;
|
||||
logger.error(TAG, 'accessSync failed with error message: ' + err.message + ', error code: ' + err.code);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function saveAsFileContent(fileName: string, content: ArrayBuffer | string) {
|
||||
logger.info(TAG, `The file name: ${fileName}`);
|
||||
try {
|
||||
let res = fs.accessSync(fileName);
|
||||
if (res) {
|
||||
logger.info(TAG, `file: ${fileName} exists!.`);
|
||||
} else {
|
||||
logger.info(TAG, `file: ${fileName} not exists, will create it!.`);
|
||||
let file = fs.openSync(fileName, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE);
|
||||
logger.info(TAG, 'file fd: ' + file.fd);
|
||||
|
||||
if (fileName.includes('.txt')) {
|
||||
logger.info(TAG, 'txt file write sync ');
|
||||
fs.writeSync(file.fd, content);
|
||||
}
|
||||
fs.closeSync(file);
|
||||
}
|
||||
} catch (error) {
|
||||
let err: BusinessError = error as BusinessError;
|
||||
logger.error(TAG, 'accessSync failed with error message: ' + err.message + ', error code: ' + err.code);
|
||||
}
|
||||
}
|
||||
|
||||
function getIconByType(fileName: string) {
|
||||
let index = fileName.lastIndexOf('.');
|
||||
let fileExtension = fileName.substring(index);
|
||||
logger.info(TAG, `getIconByType fileExtension: ${fileExtension}`);
|
||||
|
||||
let utd = utdDesc.getUniformDataTypeByFilenameExtension(fileExtension);
|
||||
let typeObj: utdDesc.TypeDescriptor = utdDesc.getTypeDescriptor(utd);
|
||||
logger.info(TAG, `getIconByType typeObj.iconFile: ${typeObj.iconFile}`);
|
||||
if (typeObj.iconFile == '') {
|
||||
logger.info(TAG, `getIconByType typeObj.iconFile is null`);
|
||||
let iconFile: string = 'app.media.ic_select_option_collection';
|
||||
return iconFile;
|
||||
}
|
||||
return typeObj.iconFile;
|
||||
}
|
||||
|
||||
async function convertResourceToString(resource: Resource) {
|
||||
let value: string = await context.resourceManager.getStringValue($r('app.string.text_target_tips').id);
|
||||
logger.info(TAG, 'getStringValue value: ' + value);
|
||||
return value;
|
||||
}
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
struct Index {
|
||||
@State textContentTarget: string = '';
|
||||
@StorageLink('filesDir') filesDir: string = '';
|
||||
|
||||
fileFs: FileFs = new FileFs();
|
||||
@State text: string = 'All';
|
||||
@State index: number = 1;
|
||||
@State space: number = 12;
|
||||
@State arrowPosition: ArrowPosition = ArrowPosition.END;
|
||||
@State fileNames: string[] = [];
|
||||
@State selectedFilesInfos: FileInfo[] = [];
|
||||
@State textContent: string = '';
|
||||
@State backGroundColor: Color = Color.Transparent;
|
||||
controller: TextAreaController = new TextAreaController()
|
||||
controllerTarget: TextAreaController = new TextAreaController()
|
||||
|
||||
getListFile(): string[] {
|
||||
let files = fs.listFileSync(filesDir);
|
||||
return files;
|
||||
}
|
||||
|
||||
UpdateSelectedFiles(): void {
|
||||
this.fileNames = this.getListFile();
|
||||
for (let i = this.selectedFilesInfos.length - 1; i >= 0; i--) {
|
||||
this.selectedFilesInfos.pop();
|
||||
}
|
||||
this.selectedFilesInfos = [];
|
||||
logger.info(TAG, 'selectText: ' + this.text);
|
||||
for (let i = 0; i < this.fileNames.length; i++) {
|
||||
let fileName = this.fileNames[i];
|
||||
let index = fileName.lastIndexOf('.');
|
||||
if (index < 0) {
|
||||
logger.info(TAG, `fileNames file: ${fileName}`);
|
||||
if (this.text == 'All') {
|
||||
let fileInfo = new FileInfo(fileName, '');
|
||||
this.selectedFilesInfos.push(fileInfo);
|
||||
}
|
||||
continue;
|
||||
} else {
|
||||
let fileExtension = fileName.substring(index);
|
||||
logger.info(TAG, `fileExtension: ${fileExtension}`);
|
||||
let utd = utdDesc.getUniformDataTypeByFilenameExtension(fileExtension);
|
||||
logger.info(TAG, `fileNames file: ${fileName}, extension: ${fileExtension}, utd: ${utd}`);
|
||||
try {
|
||||
if (utd != null) {
|
||||
let typeObj: utdDesc.TypeDescriptor = utdDesc.getTypeDescriptor(utd);
|
||||
|
||||
if (class2UTD.get(this.text) == 'All') {
|
||||
let fileInfo = new FileInfo(fileName, typeObj.iconFile);
|
||||
this.selectedFilesInfos.push(fileInfo);
|
||||
logger.info(TAG, `All type: ${fileInfo.filename}, utd: ${utd}, iconFile: ${fileInfo.iconFile}`);
|
||||
} else {
|
||||
let ret = typeObj.belongsTo(class2UTD.get(this.text));
|
||||
logger.info(TAG, `typeObj.belongsTo: ${fileName}, utd: ${class2UTD.get(this.text)}, ret: ${ret} iconFile: ${typeObj.iconFile}`);
|
||||
if (ret) {
|
||||
let fileInfo = new FileInfo(fileName, typeObj.iconFile);
|
||||
this.selectedFilesInfos.push(fileInfo);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (class2UTD.get(this.text) == 'All') {
|
||||
let fileInfo = new FileInfo(fileName, '');
|
||||
this.selectedFilesInfos.push(fileInfo);
|
||||
logger.info(TAG, `utd null All type: ${fileInfo.filename}, utd: ${utd}, iconFile: ${fileInfo.iconFile}`);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
let error: BusinessError = e as BusinessError;
|
||||
logger.error(TAG, `belongsTo throws an exception. code is ${error.code}, message is ${error.message}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
logger.info(TAG, `all files ${JSON.stringify(this.selectedFilesInfos)}}`);
|
||||
}
|
||||
|
||||
aboutToAppear() {
|
||||
logger.info(TAG, 'filesDir: ' + filesDir);
|
||||
convertResourceToString($r('app.string.text_target_tips')).then((val) => {
|
||||
this.textContentTarget = val;
|
||||
})
|
||||
CreatePrecastFile();
|
||||
this.UpdateSelectedFiles();
|
||||
}
|
||||
|
||||
aboutToDisappear() {
|
||||
for (let i = this.selectedFilesInfos.length - 1; i >= 0; i--) {
|
||||
this.selectedFilesInfos.pop();
|
||||
}
|
||||
}
|
||||
|
||||
getDataFromUdmfRetry(event: DragEvent, callback: (data: DragEvent) => void) {
|
||||
try {
|
||||
let data: UnifiedData = event.getData();
|
||||
if (!data) {
|
||||
return false;
|
||||
}
|
||||
let records: UDC.UnifiedRecord[] = data.getRecords();
|
||||
if (!records || records.length <= 0) {
|
||||
return false;
|
||||
}
|
||||
callback(event);
|
||||
return true;
|
||||
} catch (e) {
|
||||
console.log('getData failed, code = ' + (e as BusinessError).code + ', message = ' + (e as BusinessError).message);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
getDataFromUdmf(event: DragEvent, callback: (data: DragEvent) => void) {
|
||||
if (this.getDataFromUdmfRetry(event, callback)) {
|
||||
return;
|
||||
}
|
||||
setTimeout(() => {
|
||||
this.getDataFromUdmfRetry(event, callback);
|
||||
}, 1500);
|
||||
}
|
||||
|
||||
build() {
|
||||
Row() {
|
||||
Column() {
|
||||
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start, justifyContent: FlexAlign.Start }) {
|
||||
Text($r('app.string.UDMF_demo'))
|
||||
.fontStyle(FontStyle.Normal)
|
||||
.fontSize(20)
|
||||
.fontWeight(700)
|
||||
.textAlign(TextAlign.Start)
|
||||
.id('titleText')
|
||||
}
|
||||
.width('30%')
|
||||
.height('5%')
|
||||
.margin({ left: 12 })
|
||||
|
||||
// 下拉选择框
|
||||
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Start, justifyContent: FlexAlign.SpaceBetween }) {
|
||||
Select([{ value: 'All', icon: $r('app.media.ic_select_option_collection') },
|
||||
{ value: 'Images', icon: $r(getIconByType('test.png')) },
|
||||
{ value: 'Audios', icon: $r(getIconByType('test.mp3')) },
|
||||
{ value: 'Videos', icon: $r(getIconByType('test.avi')) },
|
||||
{ value: 'Text', icon: $r(getIconByType('test.txt')) },
|
||||
{ value: 'Archive', icon: $r(getIconByType('test.zip')) },
|
||||
{ value: 'Calendar', icon: $r(getIconByType('test.ics')) },
|
||||
{ value: 'ComObject', icon: $r(getIconByType('test.ofd')) },
|
||||
{ value: 'Exe', icon: $r(getIconByType('test.exe')) },
|
||||
{ value: 'OpenXml', icon: $r(getIconByType('test.xls')) }
|
||||
])
|
||||
.selected(this.index)
|
||||
.value(this.text)
|
||||
.id('SelectTypeList')
|
||||
.font({ size: 16, weight: 500 })
|
||||
.fontColor('#182431')
|
||||
.selectedOptionFont({ size: 16, weight: 500 })
|
||||
.optionFont({ size: 16, weight: 500 })
|
||||
.space(this.space)
|
||||
.arrowPosition(this.arrowPosition)
|
||||
.menuAlign(MenuAlignType.START, { dx: 0, dy: 0 })
|
||||
.backgroundColor($r('app.color.bottom_title_divider'))
|
||||
.width('30%')
|
||||
.height('30%')
|
||||
.onSelect((index: number, text?: string | undefined) => {
|
||||
this.index = index;
|
||||
if (text) {
|
||||
this.text = text;
|
||||
logger.info(TAG, 'Select type:' + text);
|
||||
this.UpdateSelectedFiles();
|
||||
}
|
||||
})
|
||||
|
||||
Text(this.textContentTarget)
|
||||
.backgroundColor($r('app.color.bottom_title_divider'))
|
||||
.width('70%')
|
||||
.height(42)
|
||||
.margin({ left: 12, right: 12 })
|
||||
.fontSize(16)
|
||||
.maxLines(1)
|
||||
.fontColor('#182431')
|
||||
.id('targetText')
|
||||
.borderRadius(24)
|
||||
.textOverflow({ overflow: TextOverflow.MARQUEE })
|
||||
.maxLines(1)
|
||||
.padding({left: 12})
|
||||
.allowDrop([UTD.UniformDataType.PLAIN_TEXT, UTD.UniformDataType.FILE])
|
||||
.onDrop((dragEvent?: DragEvent) => {
|
||||
logger.info(TAG, `textContentTarget onDrop this.textContentTarget:` + this.textContentTarget);
|
||||
this.getDataFromUdmf((dragEvent as DragEvent), (event: DragEvent) => {
|
||||
let records: Array<UDC.UnifiedRecord> = event.getData().getRecords();
|
||||
let type: string = records[0].getType();
|
||||
let time = 0;
|
||||
try {
|
||||
time = systemDateTime.getUptime(systemDateTime.TimeType.ACTIVE, false);
|
||||
logger.info(TAG, 'getUptime: ' + time);
|
||||
} catch(e) {
|
||||
let error = e as BusinessError;
|
||||
logger.info(TAG, `Failed to get uptime. message: ${error.message}, code: ${error.code}`);
|
||||
}
|
||||
|
||||
if(type == UTD.UniformDataType.FILE) {
|
||||
logger.info(TAG, 'general.file is true!');
|
||||
let file: UDC.File = records[0] as UDC.File;
|
||||
let name: string = randomString(6, 'UDMFDemo');
|
||||
|
||||
let details: Record<string, string> | undefined = file.details
|
||||
if (details == undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
let fileNewName: string = 'copy' + '_' + time.toString() + '_' + details.name;
|
||||
let fileTestDirPathNew: string = filesDir + "/" + fileNewName;
|
||||
logger.info(TAG, 'fileTestDirPathNew: ' + fileTestDirPathNew);
|
||||
|
||||
let content: ArrayBuffer = this.fileFs.getFileContentBuffer(file.uri);
|
||||
saveAsFileContent(fileTestDirPathNew, content);
|
||||
this.UpdateSelectedFiles();
|
||||
this.textContentTarget = 'Save as ' + fileNewName;
|
||||
} else if (type == UTD.UniformDataType.PLAIN_TEXT) {
|
||||
logger.info(TAG, 'general.plain-text is true!');
|
||||
let plainText: UDC.PlainText = records[0] as UDC.PlainText;
|
||||
|
||||
let name: string = randomString(6, 'UDMFDemo') + '.txt';
|
||||
let fileNewName: string = time.toString() + '_' + name;
|
||||
let fileTestDirPathNew = filesDir + "/" + fileNewName;
|
||||
|
||||
logger.info(TAG, `textContentTarget onDrop fileTestDirPathNew:` + fileTestDirPathNew);
|
||||
logger.info(TAG, `textContentTarget onDrop plainText.textContent:` + plainText.textContent);
|
||||
|
||||
saveAsFileContent(fileTestDirPathNew, plainText.textContent);
|
||||
this.UpdateSelectedFiles();
|
||||
this.textContentTarget = 'Content save as ' + fileNewName;
|
||||
logger.info(TAG, `textContentTarget onDrop this.textContentTarget:` + this.textContentTarget);
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
.margin({ left: 12, right: 12 })
|
||||
.height('5%')
|
||||
|
||||
// 文件列表
|
||||
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start, justifyContent: FlexAlign.Start }) {
|
||||
Text($r('app.string.file_list'))
|
||||
.fontStyle(FontStyle.Normal)
|
||||
.fontSize(16)
|
||||
.fontWeight(700)
|
||||
.textAlign(TextAlign.Start)
|
||||
.margin({ left: 12, top: 24, bottom: 12 })
|
||||
.height('10%')
|
||||
.copyOption(CopyOptions.InApp)
|
||||
.draggable(true)
|
||||
|
||||
List({ space: 2, initialIndex: 0 }) {
|
||||
ForEach(this.selectedFilesInfos, (item: FileInfo, no: Number) => {
|
||||
ListItem() {
|
||||
Row() {
|
||||
Column() {
|
||||
Row() {
|
||||
Image($r(getIconByType(item.filename)))
|
||||
.objectFit(ImageFit.Contain)
|
||||
.width('10%')
|
||||
.height('60%');
|
||||
Text(item.filename)
|
||||
.fontSize(16)
|
||||
.height(46)
|
||||
.textAlign(TextAlign.Start)
|
||||
.margin({ left: 12, right: 12 })
|
||||
.fontWeight(500)
|
||||
.id('textFilename_' + no)
|
||||
.visibility(Visibility.Visible)
|
||||
.onClick(() => {
|
||||
logger.info(TAG, `selected file:` + item.filename + `and clicked`);
|
||||
logger.info(TAG, `selected file:` + item.filename + `and clicked row`);
|
||||
let fileTestDirPath = filesDir + '/' + item.filename;
|
||||
if (item.filename.includes('.txt')) {
|
||||
this.textContent = this.fileFs.getFileContent(fileTestDirPath);
|
||||
if (this.textContent == '') {
|
||||
this.textContent = item.filename + 'content is empty!'
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Divider()
|
||||
.vertical(false)
|
||||
.height(2)
|
||||
.color($r('app.color.background_shallow_grey'))
|
||||
.opacity(0.6)
|
||||
.margin({ left: 12, right: 12 })
|
||||
}
|
||||
.width('100%')
|
||||
.height(48)
|
||||
.justifyContent(FlexAlign.Center)
|
||||
.alignItems(HorizontalAlign.Start)
|
||||
.onDragStart((event) => {
|
||||
this.textContentTarget = '';
|
||||
let fileTestDirPath = filesDir + '/' + item.filename;
|
||||
logger.info(TAG, 'onDragStart begin!')
|
||||
|
||||
let file = new UDC.File();
|
||||
file.details = {
|
||||
name: item.filename,
|
||||
};
|
||||
file.uri = fileUri.getUriFromPath(fileTestDirPath);
|
||||
this.backGroundColor = Color.Transparent;
|
||||
(event as DragEvent).setData(new UDC.UnifiedData(file));
|
||||
})
|
||||
}
|
||||
.width('100%')
|
||||
.height(48)
|
||||
.alignItems(VerticalAlign.Center)
|
||||
}
|
||||
.id('listItem_'+ no)
|
||||
})
|
||||
}
|
||||
.listDirection(Axis.Vertical)
|
||||
.scrollBar(BarState.Auto)
|
||||
.friction(0.6)
|
||||
.margin({ left: 12, right: 12 })
|
||||
.borderRadius(24)
|
||||
.edgeEffect(EdgeEffect.Spring) // 边缘效果设置为Spring
|
||||
.onScrollIndex((firstIndex: number, lastIndex: number, centerIndex: number) => {
|
||||
logger.info(TAG, 'onScrollIndex')
|
||||
})
|
||||
.onDidScroll((scrollOffset: number, scrollState: ScrollState) => {
|
||||
logger.info(TAG, 'onDidScroll')
|
||||
})
|
||||
.onScrollStop(()=> {
|
||||
logger.info(TAG, 'onScrollStop')
|
||||
})
|
||||
.backgroundColor(0xFFFFFF)
|
||||
}
|
||||
.height('40%')
|
||||
|
||||
// 文件内容
|
||||
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start, justifyContent: FlexAlign.Start }) {
|
||||
Text($r('app.string.text_content'))
|
||||
.fontStyle(FontStyle.Normal)
|
||||
.fontSize(16)
|
||||
.fontWeight(700)
|
||||
.textAlign(TextAlign.Start)
|
||||
.margin({ left: 12, top: 12, bottom: 6 })
|
||||
.height('10%')
|
||||
.copyOption(CopyOptions.InApp)
|
||||
.draggable(true)
|
||||
TextArea({
|
||||
text: this.textContent,
|
||||
controller: this.controller
|
||||
})
|
||||
.placeholderFont({ size: 16, weight: 400 })
|
||||
.backgroundColor('#FFFFFF')
|
||||
.border({ width: 1, color: Color.Gray, radius: 16 })
|
||||
.height('80%')
|
||||
.margin({ left: 12, right: 12 })
|
||||
.fontSize(16)
|
||||
.maxLines(4)
|
||||
.fontColor('#182431')
|
||||
.copyOption(CopyOptions.InApp)
|
||||
.draggable(true)
|
||||
.id('textContent')
|
||||
.onChange((value: string) => {
|
||||
this.textContent = value
|
||||
})
|
||||
}
|
||||
.margin({ top: 12 })
|
||||
.onDragStart((event) => {
|
||||
this.textContentTarget = '';
|
||||
this.backGroundColor = Color.Transparent;
|
||||
let data: UDC.PlainText = new UDC.PlainText();
|
||||
data.abstract = 'this is abstract';
|
||||
data.textContent = this.textContent;
|
||||
(event as DragEvent).setData(new UDC.UnifiedData(data));
|
||||
})
|
||||
.height('45%')
|
||||
}
|
||||
.margin({ left: 12, right: 12 })
|
||||
.alignItems(HorizontalAlign.Start)
|
||||
}
|
||||
.height('100%')
|
||||
.width('100%')
|
||||
.backgroundColor($r('app.color.background_shallow_grey'))
|
||||
}
|
||||
}
|
@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import util from '@ohos.util';
|
||||
|
||||
const INDEX: number = 2; // 序号
|
||||
const SLEEP_TIME: number = 10; // 睡眠时间
|
||||
const RADIX: number = 16; // parInt第二个参数值
|
||||
|
||||
export function strToUtf8Bytes(content: string | number | boolean): Array<number> {
|
||||
const code = encodeURIComponent(content);
|
||||
let bytes = [];
|
||||
for (let i = 0; i < code.length; i++) {
|
||||
const char = code.charAt(i);
|
||||
if (char === '%') {
|
||||
const hex = code.charAt(i + 1) + code.charAt(i + INDEX);
|
||||
const hexValue = parseInt(hex, RADIX);
|
||||
bytes.push(hexValue);
|
||||
i += INDEX;
|
||||
} else {
|
||||
bytes.push(char.charCodeAt(0));
|
||||
}
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
|
||||
export function strToArrayBuffer(text: string): ArrayBuffer {
|
||||
const bytes = this.strToUtf8Bytes(text);
|
||||
const buffer = new ArrayBuffer(bytes.length);
|
||||
const bufView = new DataView(buffer);
|
||||
for (let i = 0; i < bytes.length; i++) {
|
||||
bufView.setUint8(i, bytes[i]);
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
|
||||
export async function sleep(times: number): Promise<void> {
|
||||
if (!times) {
|
||||
times = SLEEP_TIME;
|
||||
}
|
||||
await new Promise((res) => setTimeout(res, times));
|
||||
}
|
||||
|
||||
export function randomString(num: number, chars: string): string {
|
||||
let len = num;
|
||||
let maxPos = chars.length;
|
||||
let pwd = '';
|
||||
for (let i = 0; i < len; i++) {
|
||||
pwd += chars.charAt(Math.floor(Math.random() * maxPos));
|
||||
}
|
||||
return pwd;
|
||||
}
|
||||
|
||||
export function bufferToString(buffer: ArrayBuffer): string {
|
||||
let textDecoder = util.TextDecoder.create('utf-8', {
|
||||
ignoreBOM: true
|
||||
});
|
||||
let resultPut = textDecoder.decodeWithStream(new Uint8Array(buffer), {
|
||||
stream: true
|
||||
});
|
||||
return resultPut;
|
||||
}
|
||||
|
||||
export function stringToBuffer(content: string): Uint8Array {
|
||||
let textEncoder = new util.TextEncoder('utf-8');
|
||||
let resultBuf = textEncoder.encodeInto(content);
|
||||
return resultBuf;
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@ -18,36 +18,28 @@ import hilog from '@ohos.hilog';
|
||||
class Logger {
|
||||
private domain: number;
|
||||
private prefix: string;
|
||||
private format: string = '%{public}s';
|
||||
private format: string = '%{public}s, %{public}s';
|
||||
|
||||
constructor(prefix: string) {
|
||||
this.prefix = prefix;
|
||||
this.domain = 0xF811;
|
||||
}
|
||||
|
||||
makeFormat(args_length: number): string {
|
||||
let format: string = this.format;
|
||||
for (let i = 0; i < args_length - 1; i++) {
|
||||
format += ', ' + this.format;
|
||||
}
|
||||
return format;
|
||||
}
|
||||
|
||||
debug(...args: string[]): void {
|
||||
hilog.debug(this.domain, this.prefix, this.makeFormat(args.length), args);
|
||||
hilog.debug(this.domain, this.prefix, this.format, args);
|
||||
}
|
||||
|
||||
info(...args: string[]): void {
|
||||
hilog.info(this.domain, this.prefix, this.makeFormat(args.length), args);
|
||||
hilog.info(this.domain, this.prefix, this.format, args);
|
||||
}
|
||||
|
||||
warn(...args: string[]): void {
|
||||
hilog.warn(this.domain, this.prefix, this.makeFormat(args.length), args);
|
||||
hilog.warn(this.domain, this.prefix, this.format, args);
|
||||
}
|
||||
|
||||
error(...args: string[]): void {
|
||||
hilog.error(this.domain, this.prefix, this.makeFormat(args.length), args);
|
||||
hilog.error(this.domain, this.prefix, this.format, args);
|
||||
}
|
||||
}
|
||||
|
||||
export const logger = new Logger('Sample_IntentDriver_Test');
|
||||
export const logger = new Logger('Sample_UDMFDemo');
|
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
{
|
||||
"module": {
|
||||
"name": "entry",
|
||||
"type": "entry",
|
||||
"description": "$string:module_desc",
|
||||
"mainElement": "EntryAbility",
|
||||
"deviceTypes": [
|
||||
"default",
|
||||
"tablet"
|
||||
],
|
||||
"deliveryWithInstall": true,
|
||||
"installationFree": false,
|
||||
"pages": "$profile:main_pages",
|
||||
"abilities": [
|
||||
{
|
||||
"name": "EntryAbility",
|
||||
"srcEntry": "./ets/entryability/EntryAbility.ts",
|
||||
"description": "$string:EntryAbility_desc",
|
||||
"icon": "$media:icon",
|
||||
"label": "$string:EntryAbility_label",
|
||||
"startWindowIcon": "$media:startIcon",
|
||||
"startWindowBackground": "$color:start_window_background",
|
||||
"exported": true,
|
||||
"skills": [
|
||||
{
|
||||
"entities": [
|
||||
"entity.system.home"
|
||||
],
|
||||
"actions": [
|
||||
"action.system.home"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
@ -0,0 +1,409 @@
|
||||
{
|
||||
"color": [
|
||||
{
|
||||
"name": "white",
|
||||
"value": "#FFFFFF"
|
||||
},
|
||||
{
|
||||
"name": "white_pressed",
|
||||
"value": "#FFE3E3E3"
|
||||
},
|
||||
{
|
||||
"name": "item_pressed",
|
||||
"value": "#4DE3E3E3"
|
||||
},
|
||||
{
|
||||
"name": "black",
|
||||
"value": "#000000"
|
||||
},
|
||||
{
|
||||
"name": "font_gray",
|
||||
"value": "#FF838383"
|
||||
},
|
||||
{
|
||||
"name": "background",
|
||||
"value": "#F1F3F5"
|
||||
},
|
||||
{
|
||||
"name": "divider",
|
||||
"value": "#FFCBCBCB"
|
||||
},
|
||||
{
|
||||
"name": "text_color",
|
||||
"value": "#5aabf9"
|
||||
},
|
||||
{
|
||||
"name": "color_333333_grey",
|
||||
"value": "#333333"
|
||||
},
|
||||
{
|
||||
"name": "color_666666_grey",
|
||||
"value": "#666666"
|
||||
},
|
||||
{
|
||||
"name": "color_999999_grey",
|
||||
"value": "#999999"
|
||||
},
|
||||
{
|
||||
"name": "color_E3E3E3_grey",
|
||||
"value": "#E3E3E3"
|
||||
},
|
||||
{
|
||||
"name": "color_D8D8D8_grey",
|
||||
"value": "#D8D8D8"
|
||||
},
|
||||
{
|
||||
"name": "color_button_grey",
|
||||
"value": "#1824310D"
|
||||
},
|
||||
{
|
||||
"name": "color_00000000_transparent",
|
||||
"value": "#00000000"
|
||||
},
|
||||
{
|
||||
"name": "volume_bg_color",
|
||||
"value": "#CCFFFFFF"
|
||||
},
|
||||
{
|
||||
"name": "white_bg_color",
|
||||
"value": "#FFFFFF"
|
||||
},
|
||||
{
|
||||
"name": "font_color_182431",
|
||||
"value": "#182431"
|
||||
},
|
||||
{
|
||||
"name": "font_color_007DFF",
|
||||
"value": "#007DFF"
|
||||
},
|
||||
{
|
||||
"name": "search_no_result_text_color",
|
||||
"value": "$color:font_color_182431"
|
||||
},
|
||||
{
|
||||
"name": "search_result_text_color",
|
||||
"value": "$color:font_color_182431"
|
||||
},
|
||||
{
|
||||
"name": "search_result_text_color_highlight",
|
||||
"value": "$color:font_color_007DFF"
|
||||
},
|
||||
{
|
||||
"name": "FAFAFA",
|
||||
"value": "#FAFAFA"
|
||||
},
|
||||
{
|
||||
"name": "DCEAF9",
|
||||
"value": "#DCEAF9"
|
||||
},
|
||||
{
|
||||
"name": "ab274f",
|
||||
"value": "#ab274f"
|
||||
},
|
||||
{
|
||||
"name": "66ccff",
|
||||
"value": "#66ccff"
|
||||
},
|
||||
{
|
||||
"name": "blue",
|
||||
"value": "#87CEFA"
|
||||
},
|
||||
{
|
||||
"name": "cyan",
|
||||
"value": "#E1FFFF"
|
||||
},
|
||||
{
|
||||
"name": "spring",
|
||||
"value": "#F5FFFA"
|
||||
},
|
||||
{
|
||||
"name": "red",
|
||||
"value": "#DC143C"
|
||||
},
|
||||
{
|
||||
"name": "yellow",
|
||||
"value": "#D9B612"
|
||||
},
|
||||
{
|
||||
"name": "lightyellow",
|
||||
"value": "#F3F143"
|
||||
},
|
||||
{
|
||||
"name": "green",
|
||||
"value": "#549688"
|
||||
},
|
||||
{
|
||||
"name": "moon",
|
||||
"value": "#D7ECF1"
|
||||
},
|
||||
{
|
||||
"name": "frost",
|
||||
"value": "#E9F0F6"
|
||||
},
|
||||
{
|
||||
"name": "water",
|
||||
"value": "#D4F2E8"
|
||||
},
|
||||
{
|
||||
"name": "lead",
|
||||
"value": "#F0EFF4"
|
||||
},
|
||||
{
|
||||
"name": "index_background",
|
||||
"value": "#F1F3F5"
|
||||
},
|
||||
{
|
||||
"name": "title_black_color",
|
||||
"value": "#182431"
|
||||
},
|
||||
{
|
||||
"name": "main_blue",
|
||||
"value": "#007DFF"
|
||||
},
|
||||
{
|
||||
"name": "main_red",
|
||||
"value": "#E84026"
|
||||
},
|
||||
{
|
||||
"name": "button_background",
|
||||
"value": "#0D182431"
|
||||
},
|
||||
{
|
||||
"name": "edit_blue",
|
||||
"value": "#1A007DFF"
|
||||
},
|
||||
{
|
||||
"name": "dialog_progress",
|
||||
"value": "#4D4D4D"
|
||||
},
|
||||
{
|
||||
"name": "start_window_background",
|
||||
"value": "#FFFFFF"
|
||||
},
|
||||
{
|
||||
"name": "custom_button_color",
|
||||
"value": "#E8E7EB"
|
||||
},
|
||||
{
|
||||
"name": "input_background",
|
||||
"value": "#0D182431"
|
||||
},
|
||||
{
|
||||
"name": "bottom_title_divider",
|
||||
"value": "#99838388"
|
||||
},
|
||||
{
|
||||
"name": "tab_bar_divider",
|
||||
"value": "#33182431"
|
||||
},
|
||||
{
|
||||
"name": "font_color_shallow",
|
||||
"value": "#182431"
|
||||
},
|
||||
{
|
||||
"name": "font_color_dark",
|
||||
"value": "#000000"
|
||||
},
|
||||
{
|
||||
"name": "font_color_red",
|
||||
"value": "#FFD22C2C"
|
||||
},
|
||||
{
|
||||
"name": "tab_bar_select",
|
||||
"value": "#007DFF"
|
||||
},
|
||||
{
|
||||
"name": "tab_bar_unselect",
|
||||
"value": "#66182431"
|
||||
},
|
||||
{
|
||||
"name": "background_shallow_grey",
|
||||
"value": "#F1F3F5"
|
||||
},
|
||||
{
|
||||
"name": "background_dark",
|
||||
"value": "#FF000000"
|
||||
},
|
||||
{
|
||||
"name": "background_grey",
|
||||
"value": "#0d000000"
|
||||
},
|
||||
{
|
||||
"name": "background_orange",
|
||||
"value": "#E6A23C"
|
||||
},
|
||||
{
|
||||
"name": "background_pink",
|
||||
"value": "#F56C6C"
|
||||
},
|
||||
{
|
||||
"name": "background_blue",
|
||||
"value": "#409EFF"
|
||||
},
|
||||
{
|
||||
"name": "background_green",
|
||||
"value": "#67C23A"
|
||||
},
|
||||
{
|
||||
"name": "pop_up_background",
|
||||
"value": "#0D182431"
|
||||
},
|
||||
{
|
||||
"name": "button_custom_color",
|
||||
"value": "#80FF7500"
|
||||
},
|
||||
{
|
||||
"name": "button_default_bg_color",
|
||||
"value": "#007DFF"
|
||||
},
|
||||
{
|
||||
"name": "divider_block_color",
|
||||
"value": "#1A838388"
|
||||
},
|
||||
{
|
||||
"name": "curve_normal",
|
||||
"value": "#3F56EA"
|
||||
},
|
||||
{
|
||||
"name": "curve_bezier",
|
||||
"value": "#00BFC9"
|
||||
},
|
||||
{
|
||||
"name": "curve_spring",
|
||||
"value": "#BCD600"
|
||||
},
|
||||
{
|
||||
"name": "curve_init",
|
||||
"value": "#E40078"
|
||||
},
|
||||
{
|
||||
"name": "curve_steps",
|
||||
"value": "#FF7500"
|
||||
},
|
||||
{
|
||||
"name": "radio_response_region_color",
|
||||
"value": "#66ffc0cb"
|
||||
},
|
||||
{
|
||||
"name": "select_option_bg_color",
|
||||
"value": "#33007DFF"
|
||||
},
|
||||
{
|
||||
"name": "select_option_font_color",
|
||||
"value": "#FF007DFF"
|
||||
},
|
||||
{
|
||||
"name": "toggle_selected_color",
|
||||
"value": "#4D00BFC9"
|
||||
},
|
||||
{
|
||||
"name": "background_light_gray",
|
||||
"value": "#f1f3f5"
|
||||
},
|
||||
{
|
||||
"name": "sub_title_color",
|
||||
"value": "#182431"
|
||||
},
|
||||
{
|
||||
"name": "title_colorone",
|
||||
"value": "#0A59F7"
|
||||
},
|
||||
{
|
||||
"name": "title_colortwo",
|
||||
"value": "#000000"
|
||||
},
|
||||
{
|
||||
"name": "scrollbar_background_color",
|
||||
"value": "#ededed"
|
||||
},
|
||||
{
|
||||
"name": "contentArea_background_color",
|
||||
"value": "#C0C0C0"
|
||||
},
|
||||
{
|
||||
"name": "normal_bg_color",
|
||||
"value": "#0A59F7"
|
||||
},
|
||||
{
|
||||
"name": "btn_border_color",
|
||||
"value": "#33000000"
|
||||
},
|
||||
{
|
||||
"name": "3D_background_color",
|
||||
"value": "#F9BC64"
|
||||
},
|
||||
{
|
||||
"name": "3D_top_left_color",
|
||||
"value": "#FED599"
|
||||
},
|
||||
{
|
||||
"name": "3D_right_buttom_color",
|
||||
"value": "#D69942"
|
||||
},
|
||||
{
|
||||
"name": "btn_one_color",
|
||||
"value": "#FFC0CB"
|
||||
},
|
||||
{
|
||||
"name": "btn_two_color",
|
||||
"value": "#87CEFA"
|
||||
},
|
||||
{
|
||||
"name": "btn_three_color",
|
||||
"value": "#90EE90"
|
||||
},
|
||||
{
|
||||
"name": "btn_onFocus_color",
|
||||
"value": "#FF0000"
|
||||
},
|
||||
{
|
||||
"name": "focus_on_background",
|
||||
"value": "#007DFE"
|
||||
},
|
||||
{
|
||||
"name": "COLOR_80000000",
|
||||
"value": "#80000000"
|
||||
},
|
||||
{
|
||||
"name": "COLOR_FFFFFF",
|
||||
"value": "#FFFFFF"
|
||||
},
|
||||
{
|
||||
"name": "COLOR_8C9BA2",
|
||||
"value": "#8C9BA2"
|
||||
},
|
||||
{
|
||||
"name": "COLOR_99FFFFFF",
|
||||
"value": "#99ffffff"
|
||||
},
|
||||
{
|
||||
"name": "canvas_background",
|
||||
"value": "#ffff00"
|
||||
},
|
||||
{
|
||||
"name": "canvas_normal_button_bg",
|
||||
"value": "#317aff"
|
||||
},
|
||||
{
|
||||
"name": "canvas_clear_button_bg",
|
||||
"value": "#ffff7300"
|
||||
},
|
||||
{
|
||||
"name": "canvas_bg_color",
|
||||
"value": "#00ffff"
|
||||
},
|
||||
{
|
||||
"name": "scroll_to_button_color",
|
||||
"value": "#ff55c6f5"
|
||||
},
|
||||
{
|
||||
"name": "scroll_item_color",
|
||||
"value": "#ff2a78db"
|
||||
},
|
||||
{
|
||||
"name": "scroll_grid_item_color",
|
||||
"value": "#F9CF93"
|
||||
}
|
||||
|
||||
]
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name": "module_desc",
|
||||
"value": "module description"
|
||||
},
|
||||
{
|
||||
"name": "EntryAbility_desc",
|
||||
"value": "description"
|
||||
},
|
||||
{
|
||||
"name": "EntryAbility_label",
|
||||
"value": "UDMFDemo"
|
||||
},
|
||||
{
|
||||
"name": "text_content",
|
||||
"value": "text Content"
|
||||
},
|
||||
{
|
||||
"name": "UDMF_demo",
|
||||
"value": "UDMF"
|
||||
},
|
||||
{
|
||||
"name": "text_target_content",
|
||||
"value": "text target content"
|
||||
},
|
||||
{
|
||||
"name": "text_target_tips",
|
||||
"value": "Drag files/text here"
|
||||
},
|
||||
{
|
||||
"name": "file_list",
|
||||
"value": "file list"
|
||||
}
|
||||
]
|
||||
}
|
After Width: | Height: | Size: 3.0 KiB |
After Width: | Height: | Size: 2.0 KiB |
After Width: | Height: | Size: 4.2 KiB |
@ -0,0 +1,36 @@
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name": "module_desc",
|
||||
"value": "module description"
|
||||
},
|
||||
{
|
||||
"name": "EntryAbility_desc",
|
||||
"value": "description"
|
||||
},
|
||||
{
|
||||
"name": "EntryAbility_label",
|
||||
"value": "UDMFDemo"
|
||||
},
|
||||
{
|
||||
"name": "text_content",
|
||||
"value": "text Content"
|
||||
},
|
||||
{
|
||||
"name": "UDMF_demo",
|
||||
"value": "UDMF"
|
||||
},
|
||||
{
|
||||
"name": "text_target_content",
|
||||
"value": "text target content"
|
||||
},
|
||||
{
|
||||
"name": "text_target_tips",
|
||||
"value": "Drag files/text here"
|
||||
},
|
||||
{
|
||||
"name": "file_list",
|
||||
"value": "file list"
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name": "module_desc",
|
||||
"value": "模块描述"
|
||||
},
|
||||
{
|
||||
"name": "EntryAbility_desc",
|
||||
"value": "description"
|
||||
},
|
||||
{
|
||||
"name": "EntryAbility_label",
|
||||
"value": "UDMFDemo"
|
||||
},
|
||||
{
|
||||
"name": "text_content",
|
||||
"value": "文本呈现区域"
|
||||
},
|
||||
{
|
||||
"name": "file_list",
|
||||
"value": "文件呈现区域"
|
||||
},
|
||||
{
|
||||
"name": "UDMF_demo",
|
||||
"value": "UDMF"
|
||||
},
|
||||
{
|
||||
"name": "text_target_content",
|
||||
"value": "目的文本"
|
||||
},
|
||||
{
|
||||
"name": "text_target_tips",
|
||||
"value": "将文件/文本拖入此处"
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,184 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import hilog from '@ohos.hilog';
|
||||
import { describe, it, expect } from '@ohos/hypium';
|
||||
import { Driver, ON, MatchPattern } from '@ohos.UiTest';
|
||||
import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
|
||||
import { logger } from '../../../main/ets/util/Logger';
|
||||
|
||||
const TAG = '[Sample_UDMFDemo]';
|
||||
const DOMAIN = 0xF811;
|
||||
const BUNDLE = 'UDMFDemo_';
|
||||
|
||||
export default function abilityTest() {
|
||||
describe('UDMFDemo', () => {
|
||||
/**
|
||||
* @tc.number UDMFDemo_StartAbilityFunction_001
|
||||
* @tc.name UDMFDemo_StartAbilityFunction_001
|
||||
* @tc.desc Test start ability.
|
||||
* @tc.size MEDIUM
|
||||
* @tc.type Function
|
||||
* @tc.level Level 0
|
||||
* @tc.require
|
||||
*/
|
||||
it('UDMFDemo_StartAbilityFunction_001', 0, async () => {
|
||||
hilog.info(DOMAIN, TAG, BUNDLE + 'StartAbilityFunction_001 begin');
|
||||
let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
|
||||
try {
|
||||
await abilityDelegator.startAbility({
|
||||
bundleName: "com.example.udmfdemo",
|
||||
abilityName: "EntryAbility"
|
||||
});
|
||||
} catch (err) {
|
||||
expect(err.code).assertEqual(0);
|
||||
}
|
||||
hilog.info(DOMAIN, TAG, BUNDLE + 'StartAbilityFunction_001 end');
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number UDMF_Select_001
|
||||
* @tc.name UDMF_Select_001
|
||||
* @tc.desc Test file select.
|
||||
* @tc.size MEDIUM
|
||||
* @tc.type Function
|
||||
* @tc.level Level 0
|
||||
* @tc.require
|
||||
*/
|
||||
it('UDMF_Select_001', 0, async () => {
|
||||
logger.info(TAG, 'UDMF_Select_001 begin');
|
||||
let driver = Driver.create();
|
||||
await driver.delayMs(1000);
|
||||
await driver.assertComponentExist(ON.id('SelectTypeList'));
|
||||
let btnStart = await driver.findComponent(ON.id('SelectTypeList'));
|
||||
await btnStart.click();
|
||||
await driver.delayMs(500);
|
||||
await driver.click(190, 550);
|
||||
await driver.delayMs(1000);
|
||||
|
||||
await driver.assertComponentExist(ON.text('test1.txt' , MatchPattern.CONTAINS));
|
||||
let ics = await driver.findComponent(ON.text('test1.txt' , MatchPattern.CONTAINS));
|
||||
await ics.click();
|
||||
await driver.delayMs(500);
|
||||
|
||||
await driver.assertComponentExist(ON.id('textContent'));
|
||||
let textContent = await driver.findComponent(ON.id('textContent'));
|
||||
let inputString = await textContent.getText();
|
||||
logger.info(TAG, 'UDMF_Select_001 inputString: ' + inputString);
|
||||
|
||||
expect(inputString.includes('test content 1 test content 2')).assertTrue();
|
||||
|
||||
await driver.assertComponentExist(ON.id('SelectTypeList'));
|
||||
let selectStart = await driver.findComponent(ON.id('SelectTypeList'));
|
||||
await selectStart.click();
|
||||
await driver.delayMs(500);
|
||||
await driver.click(170, 260);
|
||||
await driver.delayMs(1000);
|
||||
|
||||
logger.info(TAG, 'UDMF_Select_001 end');
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number UDMF_Select_002
|
||||
* @tc.name UDMF_Select_002
|
||||
* @tc.desc Test file select.
|
||||
* @tc.size MEDIUM
|
||||
* @tc.type Function
|
||||
* @tc.level Level 0
|
||||
* @tc.require
|
||||
*/
|
||||
it('UDMF_Select_002', 0, async () => {
|
||||
logger.info(TAG, 'UDMF_Select_002 begin');
|
||||
let driver = Driver.create();
|
||||
await driver.delayMs(1000);
|
||||
await driver.assertComponentExist(ON.id('SelectTypeList'));
|
||||
let btnStart = await driver.findComponent(ON.id('SelectTypeList'));
|
||||
await btnStart.click();
|
||||
await driver.delayMs(500);
|
||||
await driver.click(250, 700);
|
||||
await driver.delayMs(1000);
|
||||
|
||||
await driver.assertComponentExist(ON.text('ics' , MatchPattern.CONTAINS));
|
||||
let ics = await driver.findComponent(ON.text('ics' , MatchPattern.CONTAINS));
|
||||
expect(ics != null ).assertTrue();
|
||||
|
||||
await driver.assertComponentExist(ON.id('SelectTypeList'));
|
||||
let selectStart = await driver.findComponent(ON.id('SelectTypeList'));
|
||||
await selectStart.click();
|
||||
await driver.delayMs(500);
|
||||
await driver.click(170, 260);
|
||||
await driver.delayMs(1000);
|
||||
logger.info(TAG, 'UDMF_Select_002 end');
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number UDMF_Drag_001
|
||||
* @tc.name UDMF_Drag_001
|
||||
* @tc.desc Test file drag.
|
||||
* @tc.size MEDIUM
|
||||
* @tc.type Function
|
||||
* @tc.level Level 0
|
||||
* @tc.require
|
||||
*/
|
||||
it('UDMF_Drag_001', 0, async () => {
|
||||
logger.info(TAG, 'UDMF_Drag_001 begin');
|
||||
let driver = Driver.create();
|
||||
await driver.delayMs(1000);
|
||||
|
||||
await driver.assertComponentExist(ON.id('targetText'));
|
||||
let textTarget = await driver.findComponent(ON.id('targetText'));
|
||||
await driver.delayMs(500);
|
||||
|
||||
await driver.drag(100, 320, 430, 180);
|
||||
await driver.delayMs(1000);
|
||||
|
||||
let result = await textTarget.getText();
|
||||
expect(result.includes('Save as')).assertTrue();
|
||||
logger.info(TAG, 'UDMF_Drag_001 end');
|
||||
})
|
||||
|
||||
/**
|
||||
* @tc.number UDMF_Drag_002
|
||||
* @tc.name UDMF_Drag_002
|
||||
* @tc.desc Test text Drag.
|
||||
* @tc.size MEDIUM
|
||||
* @tc.type Function
|
||||
* @tc.level Level 0
|
||||
* @tc.require
|
||||
*/
|
||||
it('UDMF_Drag_002', 0, async () => {
|
||||
logger.info(TAG, 'UDMF_Drag_002 begin');
|
||||
let driver = Driver.create();
|
||||
await driver.delayMs(1000);
|
||||
|
||||
logger.info(TAG, 'UDMF_Drag_002 aa');
|
||||
await driver.assertComponentExist(ON.id('targetText'));
|
||||
let textTarget = await driver.findComponent(ON.id('targetText'));
|
||||
|
||||
logger.info(TAG, 'UDMF_Drag_002 bb');
|
||||
await driver.delayMs(500);
|
||||
|
||||
await driver.click(100, 320);
|
||||
await driver.delayMs(500);
|
||||
|
||||
await driver.drag(350, 740, 430, 180);
|
||||
await driver.delayMs(1000);
|
||||
|
||||
let result = await textTarget.getText();
|
||||
expect(result.includes('Content save as')).assertTrue();
|
||||
logger.info(TAG, 'UDMF_Drag_002 end');
|
||||
})
|
||||
})
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
import abilityTest from './Ability.test';
|
||||
|
||||
export default function testsuite() {
|
||||
abilityTest();
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import UIAbility from '@ohos.app.ability.UIAbility';
|
||||
import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
|
||||
import hilog from '@ohos.hilog';
|
||||
import { Hypium } from '@ohos/hypium';
|
||||
import testsuite from '../test/List.test';
|
||||
import window from '@ohos.window';
|
||||
import Want from '@ohos.app.ability.Want';
|
||||
import AbilityConstant from '@ohos.app.ability.AbilityConstant';
|
||||
|
||||
export default class TestAbility extends UIAbility {
|
||||
onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) {
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onCreate');
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'want param:' + JSON.stringify(want) ?? '');
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'launchParam:' + JSON.stringify(launchParam) ?? '');
|
||||
let abilityDelegator: AbilityDelegatorRegistry.AbilityDelegator;
|
||||
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
|
||||
let abilityDelegatorArguments: AbilityDelegatorRegistry.AbilityDelegatorArgs;
|
||||
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments();
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'start run testcase!!!');
|
||||
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite);
|
||||
}
|
||||
|
||||
onDestroy() {
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onDestroy');
|
||||
}
|
||||
|
||||
onWindowStageCreate(windowStage: window.WindowStage) {
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageCreate');
|
||||
windowStage.loadContent('testability/pages/Index', (err) => {
|
||||
if (err.code) {
|
||||
hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
|
||||
return;
|
||||
}
|
||||
hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.');
|
||||
});
|
||||
}
|
||||
|
||||
onWindowStageDestroy() {
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageDestroy');
|
||||
}
|
||||
|
||||
onForeground() {
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onForeground');
|
||||
}
|
||||
|
||||
onBackground() {
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onBackground');
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
@Entry
|
||||
@Component
|
||||
struct Index {
|
||||
@State message: string = 'Hello World';
|
||||
|
||||
build() {
|
||||
Row() {
|
||||
Column() {
|
||||
Text(this.message)
|
||||
.fontSize(50)
|
||||
.fontWeight(FontWeight.Bold)
|
||||
}
|
||||
.width('100%')
|
||||
}
|
||||
.height('100%')
|
||||
}
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import hilog from '@ohos.hilog';
|
||||
import TestRunner from '@ohos.application.testRunner';
|
||||
import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
|
||||
import Want from '@ohos.app.ability.Want';
|
||||
|
||||
let abilityDelegator: AbilityDelegatorRegistry.AbilityDelegator | undefined = undefined
|
||||
let abilityDelegatorArguments: AbilityDelegatorRegistry.AbilityDelegatorArgs | undefined = undefined
|
||||
|
||||
async function onAbilityCreateCallback() {
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'onAbilityCreateCallback');
|
||||
}
|
||||
|
||||
async function addAbilityMonitorCallback(err : Error) {
|
||||
hilog.info(0x0000, 'testTag', 'addAbilityMonitorCallback : %{public}s', JSON.stringify(err) ?? '');
|
||||
}
|
||||
|
||||
export default class OpenHarmonyTestRunner implements TestRunner {
|
||||
constructor() {
|
||||
}
|
||||
|
||||
onPrepare() {
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner OnPrepare ');
|
||||
}
|
||||
|
||||
async onRun() {
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun run');
|
||||
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
|
||||
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
|
||||
const bundleName = abilityDelegatorArguments.bundleName;
|
||||
const testAbilityName = 'TestAbility';
|
||||
const moduleName = abilityDelegatorArguments.parameters['-m'];
|
||||
let lMonitor: AbilityDelegatorRegistry.AbilityMonitor = {
|
||||
abilityName: testAbilityName,
|
||||
onAbilityCreate: onAbilityCreateCallback,
|
||||
moduleName: moduleName
|
||||
};
|
||||
abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback)
|
||||
const want: Want = {
|
||||
bundleName: bundleName,
|
||||
abilityName: testAbilityName,
|
||||
moduleName: moduleName
|
||||
};
|
||||
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
|
||||
abilityDelegator.startAbility(want, (err, data) => {
|
||||
hilog.info(0x0000, 'testTag', 'startAbility : err : %{public}s', JSON.stringify(err) ?? '');
|
||||
hilog.info(0x0000, 'testTag', 'startAbility : data : %{public}s',JSON.stringify(data) ?? '');
|
||||
})
|
||||
hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun end');
|
||||
}
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
{
|
||||
"module": {
|
||||
"name": "entry_test",
|
||||
"type": "feature",
|
||||
"description": "$string:module_test_desc",
|
||||
"mainElement": "TestAbility",
|
||||
"deviceTypes": [
|
||||
"default",
|
||||
"tablet"
|
||||
],
|
||||
"deliveryWithInstall": true,
|
||||
"installationFree": false,
|
||||
"pages": "$profile:test_pages",
|
||||
"abilities": [
|
||||
{
|
||||
"name": "TestAbility",
|
||||
"srcEntry": "./ets/testability/TestAbility.ets",
|
||||
"description": "$string:TestAbility_desc",
|
||||
"icon": "$media:icon",
|
||||
"label": "$string:TestAbility_label",
|
||||
"exported": true,
|
||||
"startWindowIcon": "$media:icon",
|
||||
"startWindowBackground": "$color:start_window_background",
|
||||
"skills": [
|
||||
{
|
||||
"actions": [
|
||||
"action.system.home"
|
||||
],
|
||||
"entities": [
|
||||
"entity.system.home"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 2.0 KiB |
@ -0,0 +1,22 @@
|
||||
{
|
||||
"hvigorVersion": "3.2.4",
|
||||
"dependencies": {
|
||||
"@ohos/hvigor-ohos-plugin": "3.2.4"
|
||||
},
|
||||
"execution": {
|
||||
// "analyze": "default", /* Define the build analyze mode. Value: [ "default" | "verbose" | false ]. Default: "default" */
|
||||
// "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */
|
||||
// "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */
|
||||
// "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */
|
||||
// "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */
|
||||
},
|
||||
"logging": {
|
||||
// "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */
|
||||
},
|
||||
"debugging": {
|
||||
// "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */
|
||||
},
|
||||
"nodeOptions": {
|
||||
// "maxOldSpaceSize": 4096 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process */
|
||||
}
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
import { appTasks } from '@ohos/hvigor-ohos-plugin';
|
||||
|
||||
export default {
|
||||
system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
|
||||
plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
|
||||
}
|
54
code/BasicFeature/DataManagement/UDMF/UDMFDemo/hvigorw
Normal file
@ -0,0 +1,54 @@
|
||||
#!/bin/bash
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Hvigor startup script, version 1.0.0
|
||||
#
|
||||
# Required ENV vars:
|
||||
# ------------------
|
||||
# NODE_HOME - location of a Node home dir
|
||||
# or
|
||||
# Add /usr/local/nodejs/bin to the PATH environment variable
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
HVIGOR_APP_HOME="`pwd -P`"
|
||||
HVIGOR_WRAPPER_SCRIPT=${HVIGOR_APP_HOME}/hvigor/hvigor-wrapper.js
|
||||
#NODE_OPTS="--max-old-space-size=4096"
|
||||
|
||||
fail() {
|
||||
echo "$*"
|
||||
exit 1
|
||||
}
|
||||
|
||||
set_executable_node() {
|
||||
EXECUTABLE_NODE="${NODE_HOME}/bin/node"
|
||||
if [ -x "$EXECUTABLE_NODE" ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
EXECUTABLE_NODE="${NODE_HOME}/node"
|
||||
if [ -x "$EXECUTABLE_NODE" ]; then
|
||||
return
|
||||
fi
|
||||
fail "ERROR: NODE_HOME is set to an invalid directory,check $NODE_HOME\n\nPlease set NODE_HOME in your environment to the location where your nodejs installed"
|
||||
}
|
||||
|
||||
# Determine node to start hvigor wrapper script
|
||||
if [ -n "${NODE_HOME}" ]; then
|
||||
set_executable_node
|
||||
else
|
||||
EXECUTABLE_NODE="node"
|
||||
command -v ${EXECUTABLE_NODE} &> /dev/null || fail "ERROR: NODE_HOME not set and 'node' command not found"
|
||||
fi
|
||||
|
||||
# Check hvigor wrapper script
|
||||
if [ ! -r "$HVIGOR_WRAPPER_SCRIPT" ]; then
|
||||
fail "ERROR: Couldn't find hvigor/hvigor-wrapper.js in ${HVIGOR_APP_HOME}"
|
||||
fi
|
||||
|
||||
if [ -z "${NODE_OPTS}" ]; then
|
||||
NODE_OPTS="--"
|
||||
fi
|
||||
|
||||
# start hvigor-wrapper script
|
||||
exec "${EXECUTABLE_NODE}" "${NODE_OPTS}" \
|
||||
"${HVIGOR_WRAPPER_SCRIPT}" "$@"
|
54
code/BasicFeature/DataManagement/UDMF/UDMFDemo/hvigorw.bat
Normal file
@ -0,0 +1,54 @@
|
||||
@rem
|
||||
@rem ----------------------------------------------------------------------------
|
||||
@rem Hvigor startup script for Windows, version 1.0.0
|
||||
@rem
|
||||
@rem Required ENV vars:
|
||||
@rem ------------------
|
||||
@rem NODE_HOME - location of a Node home dir
|
||||
@rem or
|
||||
@rem Add %NODE_HOME%/bin to the PATH environment variable
|
||||
@rem ----------------------------------------------------------------------------
|
||||
@rem
|
||||
@echo off
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
set WRAPPER_MODULE_PATH=%APP_HOME%\hvigor\hvigor-wrapper.js
|
||||
set NODE_EXE=node.exe
|
||||
@rem set NODE_OPTS="--max-old-space-size=4096"
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
if not defined NODE_OPTS set NODE_OPTS="--"
|
||||
|
||||
@rem Find node.exe
|
||||
if defined NODE_HOME (
|
||||
set NODE_HOME=%NODE_HOME:"=%
|
||||
set NODE_EXE_PATH=%NODE_HOME%/%NODE_EXE%
|
||||
)
|
||||
|
||||
%NODE_EXE% --version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" (
|
||||
"%NODE_EXE%" "%NODE_OPTS%" "%WRAPPER_MODULE_PATH%" %*
|
||||
) else if exist "%NODE_EXE_PATH%" (
|
||||
"%NODE_EXE%" "%NODE_OPTS%" "%WRAPPER_MODULE_PATH%" %*
|
||||
) else (
|
||||
echo.
|
||||
echo ERROR: NODE_HOME is not set and no 'node' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the NODE_HOME variable in your environment to match the
|
||||
echo location of your NodeJs installation.
|
||||
)
|
||||
|
||||
if "%ERRORLEVEL%" == "0" (
|
||||
if "%OS%" == "Windows_NT" endlocal
|
||||
) else (
|
||||
exit /b %ERRORLEVEL%
|
||||
)
|
@ -0,0 +1,13 @@
|
||||
{
|
||||
"name": "udmfdemo",
|
||||
"version": "1.0.0",
|
||||
"description": "Please describe the basic information.",
|
||||
"main": "",
|
||||
"author": "",
|
||||
"license": "",
|
||||
"dependencies": {
|
||||
},
|
||||
"devDependencies": {
|
||||
"@ohos/hypium": "1.0.13"
|
||||
}
|
||||
}
|
11
code/BasicFeature/DataManagement/UDMF/UDMFDemo/ohosTest.md
Normal file
@ -0,0 +1,11 @@
|
||||
# UDMF Demo 测试用例归档
|
||||
|
||||
## 用例表
|
||||
|
||||
| 测试功能 | 预置条件 | 输入 | 预期输出 |测试结果|
|
||||
|-------------|------------------------|---------------------------|---------------------|--------------------------------|
|
||||
| 打开应用 | 设备中存在主题应用 | 拉起应用 | 应用启动成功 |Pass|
|
||||
| 筛选日历数据类型 | 应用启动成功 | 下拉框选择'Calendar' | 文件呈现区域显示应用沙箱内所有日历文件 |Pass|
|
||||
| 筛选文本数据类型并展示 | 应用启动成功 | 下拉框选择'Text',点击文件呈现区域的文本文件 | 文本呈现区域显示过滤出的文本内容 |Pass|
|
||||
| 拖拽文件 | 应用启动成功 | 拖拽文件列表中的txt类型文件到右上角的文本控件区域 | 被拖拽的文件会被另存为新的文件 |Pass|
|
||||
| 拖拽文本 | 打开txt后缀的文件,内容显示在文本呈现区域 | 在“文本呈现区域”右边长按拖拽到右上角的文本控件区域 | 被拖拽的文本会被另存为新的文件 |Pass|
|
After Width: | Height: | Size: 45 KiB |
After Width: | Height: | Size: 42 KiB |
After Width: | Height: | Size: 62 KiB |
@ -179,10 +179,9 @@ struct Index {
|
||||
.onClick(() => {
|
||||
// 粘贴类型过滤,仅跨设备文本
|
||||
let systemPasteboard: pasteboard.SystemPasteboard = pasteboard.getSystemPasteboard();
|
||||
systemPasteboard.getUnifiedData().then((data) => {
|
||||
let result: boolean = systemPasteboard.isRemoteData();
|
||||
if (result) {
|
||||
let systemPasteboard: pasteboard.SystemPasteboard = pasteboard.getSystemPasteboard();
|
||||
systemPasteboard.getUnifiedData().then((data) => {
|
||||
let records = data.getRecords();
|
||||
for (let j = 0; j < records.length; j++) {
|
||||
if (records[j].getType() === uniformTypeDescriptor.UniformDataType.PLAIN_TEXT) {
|
||||
@ -191,12 +190,13 @@ struct Index {
|
||||
this.addLog('Button_device_paste' + `${j + 1}.${text.textContent}`);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.addLog('Check isRemoteData DataType fail!');
|
||||
return;
|
||||
}
|
||||
}).catch((err: BusinessError) => {
|
||||
this.addLog('Failed to get UnifiedData. Cause: ' + err.message);
|
||||
});
|
||||
} else {
|
||||
this.addLog('Check isRemoteData DataType fail!');
|
||||
}
|
||||
})
|
||||
}
|
||||
.margin({left:12, right:12})
|
||||
|
@ -67,17 +67,12 @@ export default function abilityTest() {
|
||||
hilog.info(DOMAIN, TAG, BUNDLE + 'copy_001 begin');
|
||||
let driver = await Driver.create();
|
||||
await driver.delayMs(1000);
|
||||
await driver.assertComponentExist(ON.id('pasteText'));
|
||||
let inputTextArea = await driver.findComponent(ON.id('pasteText'));
|
||||
await driver.assertComponentExist(ON.id('copyText'));
|
||||
let inputTextArea = await driver.findComponent(ON.id('copyText'));
|
||||
await inputTextArea.click();
|
||||
await inputTextArea.clearText();
|
||||
|
||||
await driver.delayMs(1000);
|
||||
await driver.assertComponentExist(ON.text('a', MatchPattern.CONTAINS));
|
||||
let inputTextA = await driver.findComponent(ON.text('a', MatchPattern.CONTAINS));
|
||||
await inputTextA.click();
|
||||
|
||||
await driver.delayMs(1000);
|
||||
await driver.delayMs(2000);
|
||||
await driver.assertComponentExist(ON.text('b', MatchPattern.CONTAINS));
|
||||
let inputTextB = await driver.findComponent(ON.text('b', MatchPattern.CONTAINS));
|
||||
await inputTextB.click();
|
||||
@ -114,7 +109,7 @@ export default function abilityTest() {
|
||||
await driver.assertComponentExist(ON.id('pasteText'));
|
||||
let inputTextArea = await driver.findComponent(ON.id('pasteText'));
|
||||
let inputString = await inputTextArea.getText();
|
||||
expect(inputString === 'abc').assertTrue();
|
||||
expect(inputString === 'bc').assertTrue();
|
||||
|
||||
await driver.delayMs(200);
|
||||
hilog.info(DOMAIN, TAG, BUNDLE + 'paste_001 end');
|
||||
@ -135,7 +130,7 @@ export default function abilityTest() {
|
||||
let inputTextArea = await driver.findComponent(ON.id('pasteText'));
|
||||
let inputString = await inputTextArea.getText();
|
||||
hilog.info(DOMAIN, TAG, BUNDLE + 'paste_text_001 inputString: ' + inputString);
|
||||
expect(inputString === 'abc').assertTrue();
|
||||
expect(inputString === 'bc').assertTrue();
|
||||
|
||||
await driver.delayMs(200);
|
||||
hilog.info(DOMAIN, TAG, BUNDLE + 'paste_security_text_001 end');
|
||||
@ -156,7 +151,7 @@ export default function abilityTest() {
|
||||
let inputTextArea = await driver.findComponent(ON.id('pasteText'));
|
||||
let inputString = await inputTextArea.getText();
|
||||
hilog.info(DOMAIN, TAG, BUNDLE + 'paste_text_001 inputString: ' + inputString);
|
||||
expect(inputString === 'abc').assertTrue();
|
||||
expect(inputString === 'bc').assertTrue();
|
||||
|
||||
await driver.delayMs(200);
|
||||
hilog.info(DOMAIN, TAG, BUNDLE + 'paste_text_001 end');
|
||||
|
@ -1,75 +0,0 @@
|
||||
# 意图执行
|
||||
|
||||
### 介绍
|
||||
|
||||
本示例使用[@ohos.app.ability.InsightIntentExecutor](https://docs.openharmony.cn/pages/v4.1/zh-cn/application-dev/reference/apis-ability-kit/js-apis-app-ability-insightIntentExecutor.md)、[@ohos.app.ability.insightIntent](https://docs.openharmony.cn/pages/v4.1/zh-cn/application-dev/reference/apis-ability-kit/js-apis-app-ability-insightIntent.md)等接口,展示了意图绑定到UIAbility前台执行,主要包括构造意图配置文件、响应绑定到UIAbility前台执行的意图调用等。
|
||||
|
||||
### 效果预览:
|
||||
|
||||
| 主页(参照系统应用[IntentDriver](../../../SystemFeature/InsightIntent/IntentDriver)) | 意图绑定到UIAbility前台执行迁移页面 | 意图绑定到UIAbility前台执行结果 |
|
||||
| ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ |
|
||||
| <img alt="home" height="640" src="screenshots/zh/home.png" width="360"/> | <img alt="UIAbility" height="640" src="screenshots/zh/executeInUIAbility2.png" width="360"/> | <img alt="UIAbility" height="640" src="screenshots/zh/executeInUIAbility.png" width="360"/> |
|
||||
|
||||
使用说明
|
||||
|
||||
1.启动系统应用[IntentDriver](../../../SystemFeature/InsightIntent/IntentDriver)应用后,主页面上显示两个按钮:意图绑定到UIAbility前台、意图绑定到ServiceExtension;
|
||||
|
||||
2.点击按钮“意图绑定到UIAbility前台”,触发本应用的意图执行,并加载新的页面,返回意图调用结果通过promptAction.showToast显示在IntentDriver应用;
|
||||
|
||||
### 工程目录
|
||||
|
||||
```
|
||||
entry/src/main/
|
||||
├─ets
|
||||
│ ├─entryability
|
||||
│ │ └─EntryAbility.ets // UIAbility,意图绑定到该UIAbility前台执行
|
||||
│ ├─intents
|
||||
│ │ └─PlayMusicIntentExecutorImpl.ets // 通过意图调用执行基类对接端侧意图框架,实现响应意图调用的业务逻辑
|
||||
│ ├─pages
|
||||
│ │ ├─Index.ets // 主页面
|
||||
│ │ └─IntentPage.ets // 意图绑定到该UIAbility前台执行时加载的页面
|
||||
│ └─util
|
||||
│ └─Logger.ets // 日志工具
|
||||
└─resources
|
||||
└─base
|
||||
└─profile
|
||||
└─insight_intent.json // 意图配置文件
|
||||
```
|
||||
|
||||
### 具体实现
|
||||
|
||||
* 实现意图调用业务逻辑的功能接口封装在PlayMusicIntentExecutorImpl,源码参考:[PlayMusicIntentExecutorImpl.ets](entry/src/main/ets/intents/PlayMusicIntentExecutorImpl.ets)
|
||||
* 意图绑定到UIAbility前台运行的业务逻辑:
|
||||
实现意图调用执行基类InsightIntentExecutor的onExecuteInUIAbilityForegroundMode()回调函数;
|
||||
* 在意图配置文件[insight_intent.json](entry/src/main/resources/base/profile/insight_intent.json)中配置应用支持的意图API列表
|
||||
* 配置内容包括:
|
||||
意图API名称、意图API所属的垂域、意图API版本号、代码相对路径入口、执行模式等;
|
||||
* 页面[IntentPage.ets](entry/src/main/ets/pages/IntentPage.ets)是绑定到UIAbility前台运行的意图拉起的页面
|
||||
|
||||
### 相关权限
|
||||
|
||||
不涉及。
|
||||
|
||||
### 依赖
|
||||
|
||||
本应用的运行依赖系统应用[IntentDriver](../../../SystemFeature/InsightIntent/IntentDriver)。
|
||||
|
||||
### 约束与限制
|
||||
|
||||
1.本示例仅支持标准系统上运行,支持设备:RK3568;
|
||||
|
||||
2.本示例为Stage模型,支持API11版本SDK,版本号:4.1.3.1;
|
||||
|
||||
3.本示例需要使用DevEco Studio 3.1.1 Release (Build Version: 3.1.0.501, built on June 20, 2023)才可编译运行;
|
||||
|
||||
### 下载
|
||||
|
||||
如需单独下载本工程,执行如下命令:
|
||||
|
||||
```
|
||||
git init
|
||||
git config core.sparsecheckout true
|
||||
echo code/BasicFeature/InsightIntent/IntentExecutor/ > .git/info/sparse-checkout
|
||||
git remote add origin https://gitee.com/openharmony/applications_app_samples.git
|
||||
git pull origin master
|
||||
```
|
@ -1,17 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the 'License');
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an 'AS IS' BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently.
|
||||
export { hapTasks } from '@ohos/hvigor-ohos-plugin';
|
@ -1,63 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import IntentExecutor from '@ohos.app.ability.InsightIntentExecutor';
|
||||
import insightIntent from '@ohos.app.ability.insightIntent';
|
||||
import window from '@ohos.window';
|
||||
import { logger } from '../util/Logger';
|
||||
import router from '@ohos.router';
|
||||
|
||||
const TAG: string = '[PlayMusicIntentExecutorImpl]';
|
||||
|
||||
export default class PlayMusicIntentExecutorImpl extends IntentExecutor {
|
||||
onExecuteInUIAbilityForegroundMode(name: string, param: Record<string, Object>,
|
||||
pageLoader: window.WindowStage): insightIntent.ExecuteResult {
|
||||
let result: insightIntent.ExecuteResult;
|
||||
let msg: Record<string, Object>;
|
||||
if (name !== 'PlayMusic') {
|
||||
logger.info(TAG, `onExecuteInUIAbilityForegroundMode unsupported insight intent ${name}`);
|
||||
msg = {
|
||||
'message': `onExecuteInUIAbilityForegroundMode unsupported insight intent ${name}`
|
||||
};
|
||||
result = {
|
||||
// decided by developer
|
||||
code: 404,
|
||||
result: msg
|
||||
};
|
||||
return result;
|
||||
}
|
||||
|
||||
// if developer need load content
|
||||
try {
|
||||
router.pushUrl({
|
||||
url: 'pages/IntentPage'
|
||||
});
|
||||
} catch (err) {
|
||||
logger.error(TAG, `pushUrl failed,code:${JSON.stringify(err.code)},message:${JSON.stringify(err.message)}`)
|
||||
}
|
||||
|
||||
|
||||
msg = {
|
||||
'message': 'onExecuteInUIAbilityForegroundMode execute insight intent succeed.',
|
||||
'name': name,
|
||||
'param': JSON.stringify(param)
|
||||
};
|
||||
result = {
|
||||
code: 0,
|
||||
result: msg
|
||||
};
|
||||
return result;
|
||||
}
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
struct Index {
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
Text($r('app.string.intent_executor_title'))
|
||||
.fontColor('#182431')
|
||||
.fontSize(32)
|
||||
.fontWeight(700)
|
||||
.margin({ left: 72, top: 32 })
|
||||
.textAlign(TextAlign.Start)
|
||||
.width('100%')
|
||||
}
|
||||
.width('100%')
|
||||
.height('100%')
|
||||
.backgroundColor($r('sys.color.ohos_id_color_text_field_sub_bg'))
|
||||
}
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import router from '@ohos.router';
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
struct IntentPage {
|
||||
@State message: string = 'Loaded by IntentExecutor';
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
Row() {
|
||||
Image($r('app.media.ic_back'))
|
||||
.width(32)
|
||||
.height(32)
|
||||
.margin({ left: 32, top: 32 })
|
||||
Text(this.message)
|
||||
.fontColor('#182431')
|
||||
.fontSize(30)
|
||||
.fontWeight(700)
|
||||
.margin({ left: 12, top: 32 })
|
||||
.textAlign(TextAlign.Start)
|
||||
}
|
||||
.width('100%')
|
||||
.onClick(() => {
|
||||
router.back();
|
||||
})
|
||||
}
|
||||
.width('100%')
|
||||
.height('100%')
|
||||
.backgroundColor($r('sys.color.ohos_id_color_text_field_sub_bg'))
|
||||
}
|
||||
}
|
@ -1,57 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import hilog from '@ohos.hilog'
|
||||
|
||||
class Logger {
|
||||
private domain: number;
|
||||
private prefix: string;
|
||||
private format: string = '%{public}s';
|
||||
|
||||
constructor(prefix: string) {
|
||||
this.prefix = prefix;
|
||||
this.domain = 0xFF00;
|
||||
hilog.isLoggable(this.domain, prefix, hilog.LogLevel.INFO);
|
||||
hilog.isLoggable(this.domain, prefix, hilog.LogLevel.DEBUG);
|
||||
hilog.isLoggable(this.domain, prefix, hilog.LogLevel.WARN);
|
||||
hilog.isLoggable(this.domain, prefix, hilog.LogLevel.ERROR);
|
||||
}
|
||||
|
||||
makeFormat(args_length: number): string {
|
||||
let format: string = this.format;
|
||||
for (let i = 0; i < args_length - 1; i++) {
|
||||
format += ', ' + this.format;
|
||||
}
|
||||
return format;
|
||||
}
|
||||
|
||||
debug(...args: string[]) {
|
||||
hilog.debug(this.domain, this.prefix, this.makeFormat(args.length), args);
|
||||
}
|
||||
|
||||
info(...args: string[]) {
|
||||
hilog.info(this.domain, this.prefix, this.makeFormat(args.length), args);
|
||||
}
|
||||
|
||||
warn(...args: string[]) {
|
||||
hilog.warn(this.domain, this.prefix, this.makeFormat(args.length), args);
|
||||
}
|
||||
|
||||
error(...args: string[]) {
|
||||
hilog.error(this.domain, this.prefix, this.makeFormat(args.length), args);
|
||||
}
|
||||
}
|
||||
|
||||
export let logger = new Logger('[Sample_IntentExecutor]');
|
@ -1,32 +0,0 @@
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name": "module_desc",
|
||||
"value": "execute insight intent"
|
||||
},
|
||||
{
|
||||
"name": "EntryAbility_desc",
|
||||
"value": "EntryAbility"
|
||||
},
|
||||
{
|
||||
"name": "EntryAbility_label",
|
||||
"value": "EntryAbility"
|
||||
},
|
||||
{
|
||||
"name": "ServiceExtAbility_desc",
|
||||
"value": "ServiceExtAbility"
|
||||
},
|
||||
{
|
||||
"name": "ServiceExtAbility_label",
|
||||
"value": "ServiceExtAbility"
|
||||
},
|
||||
{
|
||||
"name": "intent_executor_title",
|
||||
"value": "Intent Executor"
|
||||
},
|
||||
{
|
||||
"name": "Back",
|
||||
"value": "Back"
|
||||
}
|
||||
]
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="24px" height="24px" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<title>ic_back</title>
|
||||
<defs>
|
||||
<path d="M5.56079777,13.7499686 L11.5303301,19.7196699 L11.5640714,19.7556673 C11.8227547,20.0502619 11.8115076,20.4991526 11.5303301,20.7803301 C11.2491526,21.0615076 10.8002619,21.0727547 10.5056673,20.8140714 L10.4696699,20.7803301 L3.43929777,13.7499686 L5.56079777,13.7499686 Z M10.4696699,3.21966991 C10.7625631,2.9267767 11.2374369,2.9267767 11.5303301,3.21966991 C11.8115076,3.5008474 11.8227547,3.94973814 11.5640714,4.24433269 L11.5303301,4.28033009 L4.5605,11.25 L21.25,11.25 C21.6494202,11.25 21.9759152,11.56223 21.9987268,11.9559318 L22,12 C22,12.3994202 21.68777,12.7259152 21.2940682,12.7487268 L21.25,12.75 L2.75,12.75 C2.09603793,12.75 1.76158663,11.9761547 2.19060357,11.5002723 L2.21966991,11.4696699 L10.4696699,3.21966991 Z" id="path-1"></path>
|
||||
</defs>
|
||||
<g id="ic_back" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<mask id="mask-2" fill="white">
|
||||
<use xlink:href="#path-1"></use>
|
||||
</mask>
|
||||
<use id="形状结合" fill="#182431" fill-rule="nonzero" xlink:href="#path-1"></use>
|
||||
</g>
|
||||
</svg>
|
Before Width: | Height: | Size: 1.3 KiB |
@ -1,17 +0,0 @@
|
||||
{
|
||||
"insightIntents": [
|
||||
{
|
||||
"intentName": "PlayMusic",
|
||||
"domain": "MusicDomain",
|
||||
"intentVersion": "1.0.1",
|
||||
"srcEntry": "./ets/intents/PlayMusicIntentExecutorImpl.ets",
|
||||
"uiAbility": {
|
||||
"ability": "EntryAbility",
|
||||
"executeMode": [
|
||||
"background",
|
||||
"foreground"
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
{
|
||||
"src": [
|
||||
"pages/Index",
|
||||
"pages/IntentPage"
|
||||
]
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name": "module_desc",
|
||||
"value": "module description"
|
||||
},
|
||||
{
|
||||
"name": "EntryAbility_desc",
|
||||
"value": "description"
|
||||
},
|
||||
{
|
||||
"name": "EntryAbility_label",
|
||||
"value": "label"
|
||||
},
|
||||
{
|
||||
"name": "ServiceExtAbility_desc",
|
||||
"value": "description"
|
||||
},
|
||||
{
|
||||
"name": "ServiceExtAbility_label",
|
||||
"value": "label"
|
||||
},
|
||||
{
|
||||
"name": "intent_executor_title",
|
||||
"value": "Intent Executor"
|
||||
},
|
||||
{
|
||||
"name": "Back",
|
||||
"value": "Back"
|
||||
}
|
||||
]
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name": "module_desc",
|
||||
"value": "模块描述"
|
||||
},
|
||||
{
|
||||
"name": "EntryAbility_desc",
|
||||
"value": "EntryAbility"
|
||||
},
|
||||
{
|
||||
"name": "EntryAbility_label",
|
||||
"value": "EntryAbility"
|
||||
},
|
||||
{
|
||||
"name": "ServiceExtAbility_desc",
|
||||
"value": "ServiceExtAbility"
|
||||
},
|
||||
{
|
||||
"name": "ServiceExtAbility_label",
|
||||
"value": "ServiceExtAbility"
|
||||
},
|
||||
{
|
||||
"name": "intent_executor_title",
|
||||
"value": "意图执行"
|
||||
},
|
||||
{
|
||||
"name": "Back",
|
||||
"value": "返回"
|
||||
}
|
||||
]
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
{
|
||||
"hvigorVersion": "4.0.2",
|
||||
"dependencies": {
|
||||
"@ohos/hvigor-ohos-plugin": "4.0.2"
|
||||
}
|
||||
}
|
Before Width: | Height: | Size: 52 KiB |
Before Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 36 KiB |
@ -2,7 +2,7 @@
|
||||
|
||||
### 介绍
|
||||
|
||||
该示例通过[@ohos.multimedia.image](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-image-kit/js-apis-image.md)和[@ohos.multimedia.mediaLibrary](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-media-library-kit/js-apis-medialibrary.md)接口实现获取图片,以及图片裁剪分割的功能。
|
||||
该示例通过[@ohos.multimedia.image](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-image-kit/js-apis-image.md)和[@ohos.file.photoAccessHelper](https://docs.openharmony.cn/pages/v4.1/zh-cn/application-dev/reference/apis-media-library-kit/js-apis-photoAccessHelper.md)接口实现获取图片,以及图片裁剪分割的功能。
|
||||
|
||||
### 效果预览
|
||||
|首页|运行|
|
||||
@ -38,8 +38,11 @@ VideoComponent/src/main/ets/components
|
||||
|
||||
[ohos.permission.READ_MEDIA](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissionread_media)
|
||||
|
||||
[ohos.permission.WRITE_MEDIA](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissionwrite_media)
|
||||
|
||||
[ohos.permission.MEDIA_LOCATION](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissionmedia_location)
|
||||
|
||||
[ohos.permission.READ_IMAGEVIDEO](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md#ohospermissionread_imagevideo)
|
||||
### 依赖
|
||||
|
||||
不涉及。
|
||||
@ -47,7 +50,7 @@ VideoComponent/src/main/ets/components
|
||||
### 约束与限制
|
||||
|
||||
1. 本示例仅支持标准系统上运行;
|
||||
2. 本示例已适配API version 9版本SDK,版本号:3.2.11.9;
|
||||
2. 本示例已适配API version 10版本SDK,版本号:4.0.10.18;
|
||||
3. 本示例需要使用DevEco Studio 3.1 Beta2 (Build Version: 3.1.0.400, built on April 7, 2023)才可编译运行。
|
||||
|
||||
### 下载
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2022-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@ -15,9 +15,9 @@
|
||||
|
||||
{
|
||||
"app": {
|
||||
"compileSdkVersion": 10,
|
||||
"compatibleSdkVersion": 10,
|
||||
"signingConfigs": [],
|
||||
"compileSdkVersion": 9,
|
||||
"compatibleSdkVersion": 9,
|
||||
"products": [
|
||||
{
|
||||
"name": "default",
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022-2023 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2022-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@ -12,11 +12,11 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import mediaLibrary from '@ohos.multimedia.mediaLibrary'
|
||||
import photoAccessHelper from '@ohos.file.photoAccessHelper';
|
||||
|
||||
@CustomDialog
|
||||
export default struct ImagePicker {
|
||||
private imageDatas: Array<mediaLibrary.FileAsset> = []
|
||||
private imageDatas: photoAccessHelper.PhotoAsset[] = [];
|
||||
@State selected: number = 0
|
||||
public controller: CustomDialogController
|
||||
@Link index: number
|
||||
@ -28,7 +28,7 @@ export default struct ImagePicker {
|
||||
build() {
|
||||
Column() {
|
||||
List({ space: 5 }) {
|
||||
ForEach(this.imageDatas, (item, index) => {
|
||||
ForEach(this.imageDatas, (item: photoAccessHelper.PhotoAsset, index: number) => {
|
||||
ListItem() {
|
||||
Stack({ alignContent: Alignment.TopEnd }) {
|
||||
Image(item.uri)
|
||||
|
@ -13,37 +13,40 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
import image from '@ohos.multimedia.image'
|
||||
import mediaLibrary from '@ohos.multimedia.mediaLibrary'
|
||||
import photoAccessHelper from '@ohos.file.photoAccessHelper';
|
||||
import Logger from './Logger'
|
||||
import PictureItem from '../model/PictureItem'
|
||||
import { Context } from '@ohos.abilityAccessCtrl';
|
||||
import dataSharePredicates from '@ohos.data.dataSharePredicates';
|
||||
|
||||
const TAG = '[ImageModel]'
|
||||
const SPLIT_COUNT: number = 3 // 图片横竖切割的份数
|
||||
export default class ImageModel {
|
||||
private media: mediaLibrary.MediaLibrary = undefined
|
||||
private phAccessHelper: photoAccessHelper.PhotoAccessHelper;
|
||||
|
||||
constructor(context: any) {
|
||||
this.media = mediaLibrary.getMediaLibrary(context)
|
||||
constructor(context: Context) {
|
||||
this.phAccessHelper = photoAccessHelper.getPhotoAccessHelper(context);
|
||||
}
|
||||
|
||||
async getAllImg() {
|
||||
let fileKeyObj = mediaLibrary.FileKey
|
||||
let fetchOp = {
|
||||
selections: fileKeyObj.MEDIA_TYPE + '=?',
|
||||
selectionArgs: [`${mediaLibrary.MediaType.IMAGE}`],
|
||||
let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
|
||||
let fetchOptions: photoAccessHelper.FetchOptions = {
|
||||
fetchColumns: [],
|
||||
predicates: predicates
|
||||
};
|
||||
|
||||
let mediaList: photoAccessHelper.PhotoAsset[] = [];
|
||||
const fetchResult = await this.phAccessHelper.getAssets(fetchOptions);
|
||||
if (fetchResult.getCount() > 0) {
|
||||
mediaList = await fetchResult.getAllObjects();
|
||||
Logger.info(TAG, 'fetchResult success' + JSON.stringify(mediaList));
|
||||
}
|
||||
let mediaList: Array<mediaLibrary.FileAsset> = []
|
||||
const fetchFileResult = await this.media.getFileAssets(fetchOp)
|
||||
Logger.info(TAG, `queryFile getFileAssetsFromType fetchFileResult.count = ${fetchFileResult.getCount()}`)
|
||||
if (fetchFileResult.getCount() > 0) {
|
||||
mediaList = await fetchFileResult.getAllObject()
|
||||
}
|
||||
return mediaList
|
||||
return mediaList;
|
||||
}
|
||||
|
||||
async splitPic(index: number) {
|
||||
let imagePixelMap: PictureItem[] = []
|
||||
let imgDatas: Array<mediaLibrary.FileAsset> = await this.getAllImg()
|
||||
let imgDatas: photoAccessHelper.PhotoAsset[] = await this.getAllImg();
|
||||
let imagePackerApi = image.createImagePacker()
|
||||
let fd = await imgDatas[index].open('r')
|
||||
let imageSource = image.createImageSource(fd)
|
||||
@ -52,7 +55,7 @@ export default class ImageModel {
|
||||
let height = imageInfo.size.height / SPLIT_COUNT
|
||||
for (let i = 0; i < SPLIT_COUNT; i++) {
|
||||
for (let j = 0; j < SPLIT_COUNT; j++) {
|
||||
let picItem
|
||||
let picItem: PictureItem | PixelMap | undefined = undefined;
|
||||
if (i === SPLIT_COUNT - 1 && j === SPLIT_COUNT - 1) {
|
||||
picItem = new PictureItem(9, undefined)
|
||||
imagePixelMap.push(picItem)
|
@ -18,7 +18,7 @@ export default class PictureItem {
|
||||
public index: number
|
||||
public pixelMap: image.PixelMap
|
||||
|
||||
constructor(index: number, pixelMap: image.PixelMap) {
|
||||
constructor(index: number, pixelMap: image.PixelMap | undefined) {
|
||||
this.index = index
|
||||
this.pixelMap = pixelMap
|
||||
}
|
||||
|
@ -14,7 +14,6 @@
|
||||
*/
|
||||
|
||||
import mediaQuery from '@ohos.mediaquery'
|
||||
import mediaLibrary from '@ohos.multimedia.mediaLibrary'
|
||||
import GameRules from "../model/GameRules"
|
||||
import ImageModel from "../model/ImageModel"
|
||||
import ImagePicker from '../common/ImagePicker'
|
||||
@ -22,9 +21,11 @@ import Logger from '../model/Logger'
|
||||
import PictureItem from '../model/PictureItem'
|
||||
import abilityAccessCtrl, { Permissions } from '@ohos.abilityAccessCtrl'
|
||||
import emitter from '@ohos.events.emitter';
|
||||
import mediaquery from '@ohos.mediaquery';
|
||||
import photoAccessHelper from '@ohos.file.photoAccessHelper';
|
||||
|
||||
const PERMISSIONS: Array<Permissions> = ['ohos.permission.READ_MEDIA', 'ohos.permission.WRITE_MEDIA',
|
||||
'ohos.permission.MEDIA_LOCATION','ohos.permission.MANAGE_MISSIONS'];
|
||||
const PERMISSIONS: Permissions[] = ['ohos.permission.READ_MEDIA', 'ohos.permission.WRITE_MEDIA',
|
||||
'ohos.permission.MEDIA_LOCATION', 'ohos.permission.MANAGE_MISSIONS', 'ohos.permission.READ_IMAGEVIDEO'];
|
||||
const IMAGE_SIZE: number = px2vp(640)
|
||||
const GAME_TIME: number = 300 // 游戏时长
|
||||
const TAG: string = 'Index'
|
||||
@ -39,12 +40,12 @@ struct Index {
|
||||
private timer: number = -1
|
||||
private isRefresh: boolean = false
|
||||
@State numArray: PictureItem[] = []
|
||||
@State imgDatas: Array<mediaLibrary.FileAsset> = []
|
||||
@State imgDatas: photoAccessHelper.PhotoAsset[] = [];
|
||||
@State @Watch("onTimeOver") gameTime: number = GAME_TIME
|
||||
@State @Watch("onImageChange") index: number = 0
|
||||
@State isLand: boolean = false
|
||||
onLand = (mediaQueryResult) => {
|
||||
console.info(`[eTSMediaQuery.Index]onLand: mediaQueryResult.matches=${mediaQueryResult.matches}`)
|
||||
onLand = (mediaQueryResult: mediaquery.MediaQueryResult) => {
|
||||
Logger.info(TAG, `[eTSMediaQuery.Index]onLand: mediaQueryResult.matches=${mediaQueryResult.matches}`)
|
||||
this.isLand = mediaQueryResult.matches
|
||||
}
|
||||
|
||||
@ -147,7 +148,7 @@ struct Index {
|
||||
@Builder
|
||||
ImageGrid(leftMargin: number, topMargin: number) {
|
||||
Grid() {
|
||||
ForEach(this.numArray, (item, index) => {
|
||||
ForEach(this.numArray, (item: PictureItem, index: number) => {
|
||||
GridItem() {
|
||||
Image(item.pixelMap)
|
||||
.width('99%')
|
||||
|
@ -58,13 +58,32 @@
|
||||
],
|
||||
"requestPermissions": [
|
||||
{
|
||||
"name": "ohos.permission.READ_MEDIA"
|
||||
"name": "ohos.permission.READ_MEDIA",
|
||||
"reason": "$string:app_name",
|
||||
"usedScene": {
|
||||
"when": "always"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "ohos.permission.WRITE_MEDIA"
|
||||
"name": "ohos.permission.WRITE_MEDIA",
|
||||
"reason": "$string:app_name",
|
||||
"usedScene": {
|
||||
"when": "always"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "ohos.permission.MEDIA_LOCATION"
|
||||
"name": "ohos.permission.MEDIA_LOCATION",
|
||||
"reason": "$string:app_name",
|
||||
"usedScene": {
|
||||
"when": "always"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "ohos.permission.READ_IMAGEVIDEO",
|
||||
"reason": "$string:app_name",
|
||||
"usedScene": {
|
||||
"when": "always"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@ -12,9 +12,10 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
{
|
||||
"hvigorVersion": "2.0.0",
|
||||
"hvigorVersion": "2.4.2",
|
||||
"dependencies": {
|
||||
"@ohos/hvigor-ohos-plugin": "2.0.0"
|
||||
"@ohos/hvigor-ohos-plugin": "2.4.2"
|
||||
}
|
||||
}
|
@ -38,6 +38,7 @@ const TAG: string = '[Sample_EditImage]';
|
||||
export struct EditImage {
|
||||
@State mediaUris: string = (router.getParams() as Record<string, Object>)['mediaUris'] as string;
|
||||
@State pixelMap: PixelMap | undefined | null = undefined;
|
||||
@State isPixelMapChange: boolean = false;
|
||||
@State adjustMarkJudg: boolean = false;
|
||||
@State currentTask: number = Tasks.ADJUST;
|
||||
@State currentCropTask: number = CropTasks.NONE;
|
||||
@ -547,9 +548,11 @@ export struct EditImage {
|
||||
.onClick(async () => {
|
||||
if (this.canClick) {
|
||||
this.canClick = false;
|
||||
this.isPixelMapChange = true;
|
||||
await this.pixelMap?.rotate(90);
|
||||
setTimeout(() => {
|
||||
this.canClick = true;
|
||||
this.isPixelMapChange = false;
|
||||
this.flushPage();
|
||||
}, 300)
|
||||
}
|
||||
@ -568,9 +571,11 @@ export struct EditImage {
|
||||
.onClick(async () => {
|
||||
if (this.canClick) {
|
||||
this.canClick = false;
|
||||
this.isPixelMapChange = true;
|
||||
await this.pixelMap?.rotate(-90);
|
||||
setTimeout(() => {
|
||||
this.canClick = true;
|
||||
this.isPixelMapChange = false;
|
||||
this.flushPage();
|
||||
}, 300);
|
||||
}
|
||||
@ -838,6 +843,7 @@ export struct EditImage {
|
||||
}.layoutWeight(1)
|
||||
} else {
|
||||
Stack({ alignContent: Alignment.Center }) {
|
||||
if (this.isPixelMapChange) {
|
||||
Image(this.pixelMap)
|
||||
.objectFit(ImageFit.Contain)
|
||||
.width('90%')
|
||||
@ -851,6 +857,21 @@ export struct EditImage {
|
||||
}
|
||||
)
|
||||
.id('image')
|
||||
} else {
|
||||
Image(this.pixelMap)
|
||||
.objectFit(ImageFit.Contain)
|
||||
.width('90%')
|
||||
.height('90%')
|
||||
.dynamicRangeMode(DynamicRangeMode.HIGH)
|
||||
.backgroundColor($r('app.color.edit_image_stack_image'))
|
||||
.alignRules(
|
||||
{
|
||||
middle: { anchor: '__container__', align: HorizontalAlign.Center },
|
||||
center: { anchor: '__container__', align: VerticalAlign.Center }
|
||||
}
|
||||
)
|
||||
.id('image')
|
||||
}
|
||||
|
||||
if (this.currentTask === Tasks.SCALE) {
|
||||
Stack() {
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
import fileio from '@ohos.fileio'
|
||||
import image from '@ohos.multimedia.image'
|
||||
import mediaLibrary from '@ohos.multimedia.mediaLibrary'
|
||||
import photoAccessHelper from '@ohos.file.photoAccessHelper'
|
||||
import common from '@ohos.app.ability.common'
|
||||
import prompt from '@ohos.promptAction';
|
||||
import {
|
||||
@ -35,8 +35,10 @@ import { CameraService } from './CameraService'
|
||||
import { QRCodeScanConst, ImageAttribute, DecodeResultAttribute } from './QRCodeScanConst';
|
||||
import Logger from '../utils/Logger'
|
||||
import Want from '@ohos.app.ability.Want'
|
||||
import dataSharePredicates from '@ohos.data.dataSharePredicates'
|
||||
|
||||
const TAG: string = 'QRCodeParser'
|
||||
let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
|
||||
|
||||
/**
|
||||
* 二维码解析器
|
||||
@ -75,8 +77,7 @@ class QRCodeParser {
|
||||
// 给每次接收的image资源赋予随机文件名
|
||||
let fileName = this.getRandomFileName(QRCodeScanConst.IMG_FILE_PREFIX, QRCodeScanConst.IMG_SUFFIX_JPG)
|
||||
// 将image的ArrayBuffer写入指定文件中,返回文件uri
|
||||
let imageUri = await this.createPublicDirFileAsset(fileName, mediaLibrary.MediaType.IMAGE,
|
||||
mediaLibrary.DirectoryType.DIR_IMAGE, imageComponent.byteBuffer);
|
||||
let imageUri = await this.createPublicDirFileAsset(fileName, imageComponent.byteBuffer);
|
||||
// 释放已读取的image资源,以便处理下一个资源
|
||||
await targetImage.release()
|
||||
|
||||
@ -102,14 +103,13 @@ class QRCodeParser {
|
||||
*/
|
||||
async parseImageQRCode(imageSrc: string): Promise<DecodeResultAttribute> {
|
||||
Logger.info(`parseImageQRCode start`);
|
||||
let media = mediaLibrary.getMediaLibrary(AppStorage.Get<common.UIAbilityContext>('context'));
|
||||
let imagesIdFetchOp: mediaLibrary.MediaFetchOptions = {
|
||||
selections: ``,
|
||||
selectionArgs: [],
|
||||
uri: imageSrc
|
||||
};
|
||||
let media = photoAccessHelper.getPhotoAccessHelper(AppStorage.get<common.UIAbilityContext>('context'));
|
||||
let imagesIdFetchOp: photoAccessHelper.FetchOptions = {
|
||||
fetchColumns: [],
|
||||
predicates: predicates.equalTo('uri', imageSrc)
|
||||
}
|
||||
// 获取图片文件资源
|
||||
let fetchIdFileResult = await media.getFileAssets(imagesIdFetchOp);
|
||||
let fetchIdFileResult = await media.getAssets(imagesIdFetchOp);
|
||||
let fileIdAsset = await fetchIdFileResult.getFirstObject();
|
||||
// 获取文件描述符
|
||||
let fd = await fileIdAsset.open('RW');
|
||||
@ -155,20 +155,19 @@ class QRCodeParser {
|
||||
*/
|
||||
async getImageSource(imageSrc: string): Promise<ImageAttribute> {
|
||||
Logger.info(`getImageSource start`);
|
||||
let media = mediaLibrary.getMediaLibrary(AppStorage.Get<common.UIAbilityContext>('context'));
|
||||
let imagesIdFetchOp: mediaLibrary.MediaFetchOptions = {
|
||||
selections: ``,
|
||||
selectionArgs: [],
|
||||
uri: imageSrc
|
||||
};
|
||||
let media = photoAccessHelper.getPhotoAccessHelper(AppStorage.get<common.UIAbilityContext>('context'));
|
||||
let imagesIdFetchOp: photoAccessHelper.FetchOptions = {
|
||||
fetchColumns: ['width', 'height'],
|
||||
predicates: predicates.equalTo('uri', imageSrc)
|
||||
}
|
||||
// 获取图片文件资源
|
||||
let fetchIdFileResult = await media.getFileAssets(imagesIdFetchOp);
|
||||
let fetchIdFileResult = await media.getAssets(imagesIdFetchOp);
|
||||
let fileIdAsset = await fetchIdFileResult.getFirstObject();
|
||||
// 将字符串分割,下标为1的数据即为图片类型
|
||||
let imgType = fileIdAsset.displayName.split('.')[1];
|
||||
// 获取文件描述符
|
||||
let fd = await fileIdAsset.open('RW');
|
||||
let context = AppStorage.Get<common.UIAbilityContext>('context');
|
||||
let context = AppStorage.get<common.UIAbilityContext>('context');
|
||||
// 获取当前时间
|
||||
let time = new Date().getTime();
|
||||
// 拼接路径
|
||||
@ -181,22 +180,21 @@ class QRCodeParser {
|
||||
let pixelMap = await imageSource.createPixelMap();
|
||||
// 4、关闭安fd,Asset
|
||||
await fileIdAsset.close(fd);
|
||||
return { width: fileIdAsset.width, height: fileIdAsset.height, pixelMap: pixelMap };
|
||||
return {
|
||||
width: fileIdAsset.get('width') as number,
|
||||
height: fileIdAsset.get('height') as number,
|
||||
pixelMap: pixelMap
|
||||
};
|
||||
}
|
||||
/**
|
||||
* 在媒体公共资源目录下的创建指定类型的资源对象
|
||||
*/
|
||||
async createPublicDirFileAsset(fileDisplayName: string,
|
||||
mediaType: mediaLibrary.MediaType,
|
||||
directoryType: mediaLibrary.DirectoryType,
|
||||
fileByteBuffer: ArrayBuffer): Promise<string> {
|
||||
Logger.info("createPublicDirFileAsset start")
|
||||
// 获取mediaLibrary对象
|
||||
let mediaLibraryObj = mediaLibrary.getMediaLibrary(AppStorage.Get('context'))
|
||||
// 获取媒体公共资源目录
|
||||
let publicDir = await mediaLibraryObj.getPublicDirectory(directoryType)
|
||||
// 使用资源类型、资源名称、和公共资源路径创建FileAccess对象
|
||||
let fileAsset = await mediaLibraryObj.createAsset(mediaType, fileDisplayName, publicDir)
|
||||
let mediaLibraryObj = photoAccessHelper.getPhotoAccessHelper(AppStorage.get('context'))
|
||||
let fileAsset = await mediaLibraryObj.createAsset(fileDisplayName)
|
||||
// 拿到fileAccess资源对应的uri
|
||||
let fileUri = fileAsset.uri
|
||||
// 调用open方法打开这个资源对象 // TODO 为啥要打开?
|
||||
|
@ -28,7 +28,7 @@ export default class MainAbility extends UIAbility {
|
||||
Logger.info(TAG, 'MainAbility onCreate')
|
||||
let atManager: abilityAccessCtrl.AtManager = abilityAccessCtrl.createAtManager()
|
||||
try {
|
||||
await atManager.requestPermissionsFromUser(this.context, ['ohos.permission.CAMERA', 'ohos.permission.READ_MEDIA', 'ohos.permission.WRITE_MEDIA', 'ohos.permission.MEDIA_LOCATION']).then((data) => {
|
||||
await atManager.requestPermissionsFromUser(this.context, ['ohos.permission.CAMERA', 'ohos.permission.READ_IMAGEVIDEO', 'ohos.permission.WRITE_IMAGEVIDEO', 'ohos.permission.MEDIA_LOCATION']).then((data) => {
|
||||
Logger.info(TAG, `data: ${JSON.stringify(data)}`)
|
||||
// 如果权限列表中有-1,说明用户拒绝了授权
|
||||
if (data.authResults[0] === 0) {
|
||||
|
@ -39,6 +39,14 @@
|
||||
},
|
||||
{
|
||||
"name": "ohos.permission.READ_MEDIA"
|
||||
},
|
||||
{
|
||||
"name": "ohos.permission.READ_IMAGEVIDEO",
|
||||
"reason": "$string:read_image_video_permission"
|
||||
},
|
||||
{
|
||||
"name": "ohos.permission.WRITE_IMAGEVIDEO",
|
||||
"reason": "$string:write_image_video_permission"
|
||||
}
|
||||
],
|
||||
"abilities": [
|
||||
|
@ -11,6 +11,14 @@
|
||||
{
|
||||
"name": "MainAbility_label",
|
||||
"value": "二维码扫描"
|
||||
},
|
||||
{
|
||||
"name": "read_image_video_permission",
|
||||
"value": "读取用户公共目录的图片或视频文件"
|
||||
},
|
||||
{
|
||||
"name": "write_image_video_permission",
|
||||
"value": "修改用户公共目录的图片或视频文件"
|
||||
}
|
||||
]
|
||||
}
|