1 2/** 3 * Copyright (c) 2023 Huawei Device Co., Ltd. 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17import AspectRatio from '../../../setting/settingitem/AspectRatio' 18import AssistiveGrid from '../../../setting/settingitem/AssistiveGrid' 19import SaveGeoLocation from '../../../setting/settingitem/SaveGeoLocation' 20import SelfMirror from '../../../setting/settingitem/SelfMirror' 21import Resolution from '../../../setting/settingitem/Resolution' 22import Timer from '../../../setting/settingitem/Timer' 23import VideoCodec from '../../../setting/settingitem/VideoCodec' 24import { Voice } from '../../../setting/settingitem/Voice' 25import type { RadioItem, SettingGroupItem, SettingItem } from './SettingData' 26 27/** 28 * app setting homepage service class 29 */ 30export class SettingListModel { 31 private settingsList: SettingGroupItem[] = [] 32 constructor() { 33 this.buildSettingsList() 34 } 35 36 getSettingList() { 37 return this.settingsList; 38 } 39 40 private buildSettingsList() { 41 this.settingsList[0] = this.buildPhotoModeSettings() 42 this.settingsList[1] = this.buildVideoModeSettings() 43 this.settingsList[2] = this.buildGeneralSettings() 44 } 45 46 private buildPhotoModeSettings() { 47 let result: SettingGroupItem = {} 48 result.settingTitle = $r('app.string.photo_mode') 49 result.settingChildren = [] 50 result.settingChildren[0] = this.buildPhotoResolutionSettingItem() 51 return result; 52 } 53 54 private buildPhotoResolutionSettingItem() { 55 let result: SettingItem = {} 56 result.imagePath = $r("app.media.ic_camera_setting_resolution_photo") 57 result.settingName = $r('app.string.aspect_ratio') 58 result.settingAlias = AspectRatio.ALIAS 59 result.selectType = "radio" 60 result.radio = this.buildPhotoResolutionRadio() 61 result.checkedName = result.radio[0].itemValue 62 return result; 63 } 64 65 private buildPhotoResolutionRadio() { 66 let result: RadioItem[] = [] 67 result[0] = { "itemValue": AspectRatio.RESOURCE_RATIO_4_3} 68 result[1] = { "itemValue": AspectRatio.RESOURCE_RATIO_1_1} 69 result[2] = { "itemValue": AspectRatio.RESOURCE_RATIO_16_9} 70 return result; 71 } 72 73 private buildVideoModeSettings() { 74 let result: SettingGroupItem = {} 75 result.settingTitle = $r('app.string.video_mode') 76 result.settingChildren = [] 77 result.settingChildren[0] = this.buildVideoResolutionSettingItem() 78// result.settingChildren[1] = this.buildVideoCodecSettingItem() 79 return result; 80 } 81 82 private buildVideoResolutionSettingItem() { 83 let result :SettingItem = {} 84 result.imagePath = $r("app.media.ic_camera_setting_resolution_video") 85 result.settingName = $r('app.string.video_resolution') 86 result.settingAlias = Resolution.ALIAS 87 result.selectType = "radio" 88 result.radio = this.buildVideoResolutionRadio() 89 result.checkedName = result.radio[0].itemValue 90 return result; 91 } 92 93 private buildVideoResolutionRadio() { 94 let result: RadioItem[] = [] 95 result[0] = { "itemValue": Resolution.RESOURCE_16_9_720P} 96 result[1] = { "itemValue": Resolution.RESOURCE_16_9_1080P} 97 return result; 98 } 99 100 private buildVideoCodecSettingItem() { 101 let result: SettingItem = {} 102 result.imagePath = $r("app.media.ic_camera_setting_efficient_video_format") 103 result.settingName = $r('app.string.video_codec') 104 result.description = $r("app.string.video_codec_desp") 105 result.settingAlias = VideoCodec.ALIAS 106 result.selectType = "toggle" 107 result.checkedName = false 108 result.toggle = true 109 return result; 110 } 111 112 private buildGeneralSettings() { 113 let result: SettingGroupItem = {} 114 result.settingTitle = $r('app.string.general') 115 result.settingChildren = [] 116 result.settingChildren[0] = this.buildAssistiveGridSettingItem() 117 result.settingChildren[1] = this.buildTimerSettingItem() 118 result.settingChildren[2] = this.buildSaveGeoLocationSettingItem() 119 result.settingChildren[3] = this.buildSoundMuteSettingItem() 120 result.settingChildren[4] = this.buildSelfMirrorSettingItem() 121 return result; 122 } 123 124 private buildAssistiveGridSettingItem() { 125 let result: SettingItem = {} 126 result.imagePath = $r("app.media.ic_camera_setting_assistive_grid") 127 result.settingName = $r('app.string.assistive_grid') 128 result.settingAlias = AssistiveGrid.ALIAS 129 result.selectType = "toggle" 130 result.checkedName = false 131 result.toggle = true 132 return result; 133 } 134 135 private buildTimerSettingItem() { 136 let result :SettingItem = {} 137 result.imagePath = $r("app.media.ic_camera_rersolution") 138 result.settingName = $r('app.string.timer') 139 result.settingAlias = Timer.ALIAS 140 result.selectType = "radio" 141 result.radio = this.buildTimerRadio() 142 result.checkedName = result.radio[0].itemValue 143 return result; 144 } 145 146 private buildTimerRadio() { 147 let result: RadioItem[] = [] 148 result[0] = { "itemValue": Timer.RESOURCE_OFF } 149 result[1] = { "itemValue": Timer.RESOURCE_TWO_SECONDS } 150 result[2] = { "itemValue": Timer.RESOURCE_FIVE_SECONDS } 151 result[3] = { "itemValue": Timer.RESOURCE_TEN_SECONDS } 152 return result; 153 } 154 155 private buildSaveGeoLocationSettingItem() { 156 let result: SettingItem = {} 157 result.imagePath = $r("app.media.ic_camera_setting_location") 158 result.settingName = $r('app.string.save_geo_location') 159 result.description = $r("app.string.geo_location_desp") 160 result.settingAlias = SaveGeoLocation.ALIAS 161 result.selectType = "toggle" 162 result.checkedName = false 163 result.toggle = true 164 return result; 165 } 166 167 private buildSoundMuteSettingItem() { 168 let result: SettingItem = {} 169 result.imagePath = $r("app.media.ic_camera_sound_mute") 170 result.settingName = $r('app.string.sound_mute') 171 result.settingAlias = Voice.ALIAS 172 result.selectType = "toggle" 173 result.checkedName = false 174 result.toggle = true 175 return result; 176 } 177 178 private buildSelfMirrorSettingItem() { 179 let result: SettingItem = {} 180 result.imagePath = $r("app.media.ic_camera_mirrow_reflection") 181 result.settingName = $r('app.string.self_mirror') 182 result.description = $r("app.string.self_mirror_desp") 183 result.settingAlias = SelfMirror.ALIAS 184 result.selectType = "toggle" 185 result.checkedName = false 186 result.toggle = false 187 return result; 188 } 189}