mirror of
https://github.com/openharmony/applications_filepicker.git
synced 2026-07-01 00:17:55 -04:00
[TicketNo:]AR000JP17R
[Description:]音乐XX项目开发-音频管理--Audio Picker界面 [Binary Source:]NA Signed-off-by: nWX1290789 <niuyuanyuan6@h-partners.com>
This commit is contained in:
@@ -36,6 +36,7 @@
|
||||
<filteritem type="filepath" name="figures/.*.png" desc="self developed image"/>
|
||||
<filteritem type="filepath" name="doc/images/.*.png" desc="self developed image"/>
|
||||
<filteritem type="filepath" name="AppScope/resources/base/media/.*.png" desc="self developed image"/>
|
||||
<filteritem type="filepath" name="audiopicker/src/main/resources/base/media/.*.webp" desc="self developed image"/>
|
||||
</filefilter>
|
||||
|
||||
|
||||
|
||||
@@ -17,9 +17,6 @@
|
||||
}
|
||||
},
|
||||
],
|
||||
"entryModules": [
|
||||
"audiopicker"
|
||||
],
|
||||
"targets": [
|
||||
{
|
||||
"name": "default"
|
||||
|
||||
@@ -7,7 +7,7 @@ import { MusicApp } from '../common/global/globalmodel/GlobalModel';
|
||||
import { createOrGet, globalKeys } from '../common/global/GlobalThisHelper'
|
||||
import { PreferenceManager } from '../common/preference/PreferenceManager'
|
||||
|
||||
const key_Permission_TipLog = 'Key_Permission_TipLog'
|
||||
const keyPermissionTipLog = 'Key_Permission_TipLog'
|
||||
const logger: Logger = new Logger('AudioPickerPreference')
|
||||
const app: MusicApp = createOrGet(MusicApp, globalKeys.app, ['phone']);
|
||||
|
||||
@@ -20,7 +20,7 @@ export class AudioPickerPreference {
|
||||
* @param isFirstStartUp
|
||||
*/
|
||||
public saveSafetyTipStatus(isFirstStartUp: boolean): void {
|
||||
this.preferenceManager.put(key_Permission_TipLog, isFirstStartUp, true,
|
||||
this.preferenceManager.put(keyPermissionTipLog, isFirstStartUp, true,
|
||||
this.preferenceManager.preferKeys.audioPicker).then((res) => {
|
||||
logger.info(`saveSafetyTipStatus Success ? : ${res}`)
|
||||
}).catch((err: BusinessError) => {
|
||||
@@ -35,7 +35,7 @@ export class AudioPickerPreference {
|
||||
*/
|
||||
public getSafetyTipStatus(): Promise<boolean> {
|
||||
return new Promise((resolve) => {
|
||||
this.preferenceManager.get(key_Permission_TipLog, false,
|
||||
this.preferenceManager.get(keyPermissionTipLog, false,
|
||||
this.preferenceManager.preferKeys.audioPicker).then((res) => {
|
||||
resolve(res as boolean)
|
||||
}).catch((err: BusinessError) => {
|
||||
|
||||
@@ -13,15 +13,15 @@ export class Constants {
|
||||
/**
|
||||
* Bundle name of audioPicker
|
||||
*/
|
||||
static readonly AUDIO_PICKER_BUNDLE = 'com.ohos.filepicker';
|
||||
public static readonly AUDIO_PICKER_BUNDLE = 'com.ohos.filepicker';
|
||||
|
||||
/**
|
||||
* AudioPicker每页请求数量
|
||||
*/
|
||||
static readonly PICKER_PAGE_SIZE: number = 100
|
||||
public static readonly PICKER_PAGE_SIZE: number = 100
|
||||
|
||||
/**
|
||||
* 每次请求参数
|
||||
*/
|
||||
static readonly PAGE_COUNT: number = 1
|
||||
public static readonly PAGE_COUNT: number = 1
|
||||
}
|
||||
@@ -31,7 +31,7 @@ export class LocalResourceManager {
|
||||
public terminateSelfWithResult(localAudioFile: Array<LocalAudioFile>): Promise<Array<string>> {
|
||||
//赋予权限就放在audiopicker模块,直接调系统接口
|
||||
return new Promise(async (resolve) => {
|
||||
let uriList: Array<string> = []
|
||||
let uriList: string[] = []
|
||||
for(let item of localAudioFile) {
|
||||
try {
|
||||
await fileShare.grantUriPermission(item.uri, Constants.AUDIO_PICKER_BUNDLE, wantConstant
|
||||
|
||||
@@ -5,17 +5,17 @@ import { image } from '@kit.ImageKit';
|
||||
|
||||
export class LocalAudioFile {
|
||||
// 文件uri
|
||||
uri: string = ''
|
||||
public uri: string = ''
|
||||
// 名称
|
||||
name: string = ''
|
||||
public name: string = ''
|
||||
// 歌手
|
||||
artist: string = ''
|
||||
public artist: string = ''
|
||||
// 专辑
|
||||
album: string = ''
|
||||
public album: string = ''
|
||||
// 显示名字
|
||||
displayName: string = ''
|
||||
public displayName: string = ''
|
||||
// 缩略图
|
||||
getThumbnail?: image.PixelMap | Resource
|
||||
public getThumbnail?: image.PixelMap | Resource
|
||||
|
||||
constructor(uri: string, name: string, artist: string, album: string,
|
||||
displayName: string, getThumbnail?: image.PixelMap | Resource) {
|
||||
|
||||
@@ -59,7 +59,7 @@ export class LocalAudioManager {
|
||||
* 将FileAsset转换为LocalAudioFile
|
||||
*/
|
||||
transferFileAssetsToLocalAudioFiles(): Promise<Array<LocalAudioFile>> {
|
||||
let localAudioFile: Array<LocalAudioFile> = []
|
||||
let localAudioFile: LocalAudioFile[] = []
|
||||
return new Promise(async (resolve) => {
|
||||
if (this.fileAssets) {
|
||||
logger.info('fileAsset.length :' + this.fileAssets.length);
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
* Copyright (c) Huawei Technologies Co., Ltd. 2024-2024. All rights reserved.
|
||||
*/
|
||||
import UIExtensionContentSession from '@ohos.app.ability.UIExtensionContentSession'
|
||||
import { image } from '@kit.ImageKit';
|
||||
import { CustomContentDialog } from '@ohos.arkui.advanced.Dialog';
|
||||
import { ability, Context, Want } from '@kit.AbilityKit';
|
||||
|
||||
import { Logger } from '../../common/util/HiLogger'
|
||||
import { createOrGet, globalKeys } from '../../common/global/GlobalThisHelper'
|
||||
@@ -31,14 +31,14 @@ export struct AudioPickerView {
|
||||
// 是否展示加载更多
|
||||
@State showLoadMore: boolean = false
|
||||
@State requestCounts: number = 0
|
||||
@State thumbnail: Array<image.PixelMap | Resource> = []
|
||||
@State uriArr: Array<string> = []
|
||||
@State isSelect: boolean = false
|
||||
// load more 提前的条目数量
|
||||
private loadMoreAdvance: number = 3
|
||||
private pageNo: number = 0;
|
||||
// 设备信息
|
||||
private globalDeviceInfo: DeviceInfo = createOrGet(DeviceInfo, globalKeys.deviceInfo)
|
||||
session: UIExtensionContentSession | undefined
|
||||
want: Want | undefined
|
||||
scroller: Scroller = new Scroller()
|
||||
context: Context = getContext(this)
|
||||
// 弹窗知道了按钮回调
|
||||
@@ -154,16 +154,20 @@ export struct AudioPickerView {
|
||||
* 返回赋予临时权限的uri列表回调
|
||||
*/
|
||||
async settingTerminateSelfWithResult() {
|
||||
this.uriArr = await this.localResourceManager.terminateSelfWithResult(this.isSelectedAudioPickerList)
|
||||
logger.info('uriArr length: ' + this.uriArr.length)
|
||||
let uriArr = await this.localResourceManager.terminateSelfWithResult(this.isSelectedAudioPickerList)
|
||||
logger.info('uriArr length: ' + uriArr.length)
|
||||
if (this.session) {
|
||||
this.session?.terminateSelfWithResult({
|
||||
resultCode: this.uriArr ? 0 : -1,
|
||||
let abilityResult: ability.AbilityResult = {
|
||||
resultCode: (uriArr === undefined) ? -1 : 0,
|
||||
want: {
|
||||
parameters: {
|
||||
'uriArr': this.uriArr
|
||||
'ability.params.stream': uriArr,
|
||||
'uriArr': uriArr
|
||||
}
|
||||
}
|
||||
}
|
||||
this.session?.terminateSelfWithResult(abilityResult, (err) => {
|
||||
logger.error('terminateSelfWithResult is called: ' + err)
|
||||
})
|
||||
} else {
|
||||
logger.error(`oncancel session: ${this.session}`)
|
||||
@@ -238,6 +242,14 @@ export struct AudioPickerView {
|
||||
} else {
|
||||
this.isSelectedAudioPickerList = this.isSelectedAudioPickerList.filter(val => val != item)
|
||||
}
|
||||
let key_pick_num = this.want?.parameters?.key_pick_num
|
||||
if (key_pick_num) {
|
||||
if (this.isSelectedAudioPickerList.length < key_pick_num) {
|
||||
this.isSelect = true
|
||||
} else {
|
||||
this.isSelect = false
|
||||
}
|
||||
}
|
||||
})
|
||||
.unselectedColor($r('sys.color.ohos_id_color_switch_outline_off'))
|
||||
.width(20)
|
||||
|
||||
@@ -11,13 +11,13 @@ import { BaseState, ViewState } from '../../basemvvm/ViewState'
|
||||
@Observed
|
||||
export class AudioPickerViewData extends AbsBaseViewData<ViewState, LocalAudioFile> {
|
||||
// 页面加载状态
|
||||
viewState: ViewState = new ViewState(BaseState.DEFAULT)
|
||||
public viewState: ViewState = new ViewState(BaseState.DEFAULT)
|
||||
// 页面错误码
|
||||
errCode: number = -2
|
||||
public errCode: number = -2
|
||||
// 是否加载更多
|
||||
hasMoreData: boolean = false
|
||||
public hasMoreData: boolean = false
|
||||
// 是否正在加载更多
|
||||
isLoadMore: boolean = false
|
||||
public isLoadMore: boolean = false
|
||||
|
||||
constructor() {
|
||||
super()
|
||||
|
||||
Reference in New Issue
Block a user