• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/**
2 * Copyright (c) 2023 Huawei Device 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 AspectRatio from '../../../setting/settingitem/AspectRatio';
17import AssistiveGrid from '../../../setting/settingitem/AssistiveGrid';
18import SaveGeoLocation from '../../../setting/settingitem/SaveGeoLocation';
19import SelfMirror from '../../../setting/settingitem/SelfMirror';
20import Resolution from '../../../setting/settingitem/Resolution';
21import Timer from '../../../setting/settingitem/Timer';
22import VideoCodec from '../../../setting/settingitem/VideoCodec';
23import { Voice } from '../../../setting/settingitem/Voice';
24import type { RadioItem, SettingGroupItem, SettingItem } from './SettingData';
25
26/**
27 * app setting homepage service class
28 */
29export class SettingListModel {
30  private static readonly ARRAY_INDEX_2 = 2;
31  private static readonly ARRAY_INDEX_3 = 2;
32  private static readonly ARRAY_INDEX_4 = 2;
33
34  private settingsList: SettingGroupItem[] = [];
35
36  constructor() {
37    this.buildSettingsList();
38  }
39
40  getSettingList(): SettingGroupItem[] {
41    return this.settingsList;
42  }
43
44  private buildSettingsList(): void {
45    this.settingsList[0] = this.buildPhotoModeSettings();
46    this.settingsList[1] = this.buildVideoModeSettings();
47    this.settingsList[SettingListModel.ARRAY_INDEX_2] = this.buildGeneralSettings();
48  }
49
50  private buildPhotoModeSettings(): SettingGroupItem {
51    let result: SettingGroupItem = {};
52    result.settingTitle = $r('app.string.photo_mode');
53    result.settingChildren = [];
54    result.settingChildren[0] = this.buildPhotoResolutionSettingItem();
55    return result;
56  }
57
58  private buildPhotoResolutionSettingItem(): SettingItem {
59    let result: SettingItem = {};
60    result.imagePath = $r('app.media.ic_camera_setting_resolution_photo');
61    result.settingName = $r('app.string.aspect_ratio');
62    result.settingAlias = AspectRatio.ALIAS;
63    result.selectType = 'radio';
64    result.radio = this.buildPhotoResolutionRadio();
65    result.checkedName = result.radio[0].itemValue;
66    return result;
67  }
68
69  private buildPhotoResolutionRadio(): RadioItem[] {
70    let result: RadioItem[] = [];
71    result[0] = { 'itemValue': AspectRatio.RESOURCE_RATIO_4_3 };
72    result[1] = { 'itemValue': AspectRatio.RESOURCE_RATIO_1_1 };
73    result[SettingListModel.ARRAY_INDEX_2] = { 'itemValue': AspectRatio.RESOURCE_RATIO_16_9 };
74    return result;
75  }
76
77  private buildVideoModeSettings(): SettingGroupItem {
78    let result: SettingGroupItem = {};
79    result.settingTitle = $r('app.string.video_mode');
80    result.settingChildren = [];
81    result.settingChildren[0] = this.buildVideoResolutionSettingItem();
82    return result;
83  }
84
85  private buildVideoResolutionSettingItem(): SettingItem {
86    let result: SettingItem = {};
87    result.imagePath = $r('app.media.ic_camera_setting_resolution_video');
88    result.settingName = $r('app.string.video_resolution');
89    result.settingAlias = Resolution.ALIAS;
90    result.selectType = 'radio';
91    result.radio = this.buildVideoResolutionRadio();
92    result.checkedName = result.radio[0].itemValue;
93    return result;
94  }
95
96  private buildVideoResolutionRadio(): RadioItem[] {
97    let result: RadioItem[] = [];
98    result[0] = { 'itemValue': Resolution.RESOURCE_16_9_720P };
99    result[1] = { 'itemValue': Resolution.RESOURCE_16_9_1080P };
100    return result;
101  }
102
103  private buildVideoCodecSettingItem(): SettingItem {
104    let result: SettingItem = {};
105    result.imagePath = $r('app.media.ic_camera_setting_efficient_video_format');
106    result.settingName = $r('app.string.video_codec');
107    result.description = $r('app.string.video_codec_desp');
108    result.settingAlias = VideoCodec.ALIAS;
109    result.selectType = 'toggle';
110    result.checkedName = false;
111    result.toggle = true;
112    return result;
113  }
114
115  private buildGeneralSettings(): SettingGroupItem {
116    let result: SettingGroupItem = {};
117    result.settingTitle = $r('app.string.general');
118    result.settingChildren = [];
119    result.settingChildren[0] = this.buildAssistiveGridSettingItem();
120    result.settingChildren[1] = this.buildTimerSettingItem();
121    result.settingChildren[SettingListModel.ARRAY_INDEX_2] = this.buildSaveGeoLocationSettingItem();
122    result.settingChildren[SettingListModel.ARRAY_INDEX_3] = this.buildSoundMuteSettingItem();
123    result.settingChildren[SettingListModel.ARRAY_INDEX_4] = this.buildSelfMirrorSettingItem();
124    return result;
125  }
126
127  private buildAssistiveGridSettingItem(): SettingItem {
128    let result: SettingItem = {};
129    result.imagePath = $r('app.media.ic_camera_setting_assistive_grid');
130    result.settingName = $r('app.string.assistive_grid');
131    result.settingAlias = AssistiveGrid.ALIAS;
132    result.selectType = 'toggle';
133    result.checkedName = false;
134    result.toggle = true;
135    return result;
136  }
137
138  private buildTimerSettingItem(): SettingItem {
139    let result: SettingItem = {};
140    result.imagePath = $r('app.media.ic_camera_rersolution');
141    result.settingName = $r('app.string.timer');
142    result.settingAlias = Timer.ALIAS;
143    result.selectType = 'radio';
144    result.radio = this.buildTimerRadio();
145    result.checkedName = result.radio[0].itemValue;
146    return result;
147  }
148
149  private buildTimerRadio(): RadioItem[] {
150    let result: RadioItem[] = [];
151    result[0] = { 'itemValue': Timer.RESOURCE_OFF };
152    result[1] = { 'itemValue': Timer.RESOURCE_TWO_SECONDS };
153    result[SettingListModel.ARRAY_INDEX_2] = { 'itemValue': Timer.RESOURCE_FIVE_SECONDS };
154    result[SettingListModel.ARRAY_INDEX_3] = { 'itemValue': Timer.RESOURCE_TEN_SECONDS };
155    return result;
156  }
157
158  private buildSaveGeoLocationSettingItem(): SettingItem {
159    let result: SettingItem = {};
160    result.imagePath = $r('app.media.ic_camera_setting_location');
161    result.settingName = $r('app.string.save_geo_location');
162    result.description = $r('app.string.geo_location_desp');
163    result.settingAlias = SaveGeoLocation.ALIAS;
164    result.selectType = 'toggle';
165    result.checkedName = false;
166    result.toggle = true;
167    return result;
168  }
169
170  private buildSoundMuteSettingItem(): SettingItem {
171    let result: SettingItem = {};
172    result.imagePath = $r('app.media.ic_camera_sound_mute');
173    result.settingName = $r('app.string.sound_mute');
174    result.settingAlias = Voice.ALIAS;
175    result.selectType = 'toggle';
176    result.checkedName = false;
177    result.toggle = true;
178    return result;
179  }
180
181  private buildSelfMirrorSettingItem(): SettingItem {
182    let result: SettingItem = {};
183    result.imagePath = $r('app.media.ic_camera_mirrow_reflection');
184    result.settingName = $r('app.string.self_mirror');
185    result.description = $r('app.string.self_mirror_desp');
186    result.settingAlias = SelfMirror.ALIAS;
187    result.selectType = 'toggle';
188    result.checkedName = false;
189    result.toggle = false;
190    return result;
191  }
192}