• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2023 Shenzhen Kaihong Digital Industry Development Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16import { Log } from '../utils/Log';
17import { MediaConstants } from '../constants/MediaConstants';
18import { getResourceString } from '../utils/ResourceUtils';
19
20const TAG = 'UserFileDataHelper';
21
22export class Rotatable {
23  rotatable: boolean;
24  orientation: number;
25}
26
27function getPropertyValidOrientation(orientation: number): string {
28  Log.info(TAG, 'getPropertyValidOrientation ' + orientation);
29  if (orientation === MediaConstants.ROTATE_NONE) {
30    return '1';
31  } else if (orientation === MediaConstants.ROTATE_THIRD) {
32    return '8';
33  } else if (orientation === MediaConstants.ROTATE_TWICE) {
34    return '3';
35  } else if (orientation === MediaConstants.ROTATE_ONCE) {
36    return '6';
37  }
38  return '';
39}
40
41export async function getAlbumDisplayName(name: string): Promise<string> {
42  if (name === MediaConstants.ALBUM_ID_ALL) {
43    return await getResourceString($r('app.string.album_all'));
44  } else if (name === MediaConstants.ALBUM_ID_VIDEO) {
45    return await getResourceString($r('app.string.album_video'));
46  } else if (name === MediaConstants.ALBUM_ID_RECYCLE) {
47    return await getResourceString($r('app.string.album_recycle'));
48  } else if (name === MediaConstants.ALBUM_ID_CAMERA) {
49    return await getResourceString($r('app.string.album_camera'));
50  } else if (name === MediaConstants.ALBUM_ID_FAVOR) {
51    return await getResourceString($r('app.string.album_favor'));
52  } else if (name === MediaConstants.ALBUM_ID_REMOTE) {
53    return await getResourceString($r('app.string.album_remote_device'));
54  } else if (name === MediaConstants.ALBUM_ID_SNAPSHOT) {
55    return await getResourceString($r('app.string.album_screen_shot'));
56  } else if (name === MediaConstants.ALBUM_ID_MOVING_PHOTO) {
57    return await getResourceString($r('app.string.album_moving_photo'));
58  }
59  return null;
60}
61
62export async function getSystemAlbumDisplayName(): Promise<string[]> {
63  let albumNames = [];
64  albumNames.push(await getResourceString($r('app.string.album_all')));
65  albumNames.push(await getResourceString($r('app.string.album_video')));
66  albumNames.push(await getResourceString($r('app.string.album_recycle')));
67  albumNames.push(await getResourceString($r('app.string.album_camera')));
68  albumNames.push(await getResourceString($r('app.string.album_favor')));
69  albumNames.push(await getResourceString($r('app.string.album_remote_device')));
70  albumNames.push(await getResourceString($r('app.string.album_screen_shot')));
71  albumNames.push(await getResourceString($r('app.string.album_moving_photo')));
72  return albumNames;
73}