1/** 2 * Copyright (c) 2021-2022 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 16/** 17 * Setting item configuration class, read-only 18 */ 19export class SettingItemsConfig { 20 /** 21 * layout options: grid or list 22 */ 23 static readonly SETTING_ITEM_LAYOUT_OPTIONS = 'LayoutOptions'; 24 25 /** 26 * Setting options name 27 */ 28 static readonly SETTING_ITEM_PHONE_GRID_LAYOUT_OPTIONS = 'PhoneGridLayOutOptions'; 29 30 /** 31 * Setting options name 32 */ 33 static readonly SETTING_ITEM_PAD_GRID_LAYOUT_OPTIONS = 'PadGridLayOutOptions'; 34 35 /** 36 * Index: Layout settings 37 */ 38 static readonly SETTINGS_INDEX_LAYOUT: number = 0; 39 40 /** 41 * Index: grid layout 42 */ 43 static readonly SETTINGS_INDEX_GRID_LAYOUT: number = 1; 44 45 /** 46 * Applicable equipment: Not supported on all devices 47 */ 48 static readonly DEVICE_TYPE_NULL: number = 0; 49 50 /** 51 * Applicable equipment: phone support 52 */ 53 static readonly DEVICE_TYPE_PHONE: number = 1; 54 55 /** 56 * Applicable equipment: pad support 57 */ 58 static readonly DEVICE_TYPE_PAD: number = 1 << 1; 59 60 /** 61 * Applicable conditions: no restrictions 62 */ 63 static readonly CONDITION_ALL: number = 0xffffffff; 64 65 /** 66 * Applicable conditions: Valid for list layout 67 */ 68 static readonly CONDITION_LIST_LAYOUT_ENABLE: number = 1; 69 70 /** 71 * Applicable conditions: Valid for grid layout 72 */ 73 static readonly CONDITION_GRID_LAYOUT_ENABLE: number = 1 << 1; 74 75 /** 76 * setting type: Single box 77 */ 78 static readonly SETTING_TYPE_RADIO = 1; 79 80 /** 81 * setting type: switch 82 */ 83 static readonly SETTING_TYPE_SWITCH = 2; 84 85 /** 86 * hide options 87 */ 88 static readonly HIDE_OPTIONS: boolean = false; 89 90 /** 91 * show options 92 */ 93 static readonly SHOW_OPTIONS: boolean = true; 94 95 /** 96 * setting options info 97 */ 98 static readonly sSettingsMap = { 99 // LayoutOptions 100 'LayoutOptions': { 101 index: SettingItemsConfig.SETTINGS_INDEX_LAYOUT, 102 description: $r('app.string.layout_style'), 103 settingType: SettingItemsConfig.SETTING_TYPE_RADIO, 104 deviceType: SettingItemsConfig.DEVICE_TYPE_PHONE, 105 condition: SettingItemsConfig.CONDITION_ALL, 106 optionList: [ 107 { name: 'List'}, 108 { name: 'Grid'} 109 ], 110 isShowOptions: SettingItemsConfig.HIDE_OPTIONS 111 }, 112 113 // PhoneGridLayOutOptions 114 'PhoneGridLayOutOptions': { 115 index: SettingItemsConfig.SETTINGS_INDEX_GRID_LAYOUT, 116 description: $r('app.string.launcher_layout'), 117 settingType: SettingItemsConfig.SETTING_TYPE_RADIO, 118 deviceType: SettingItemsConfig.DEVICE_TYPE_PHONE, 119 condition: SettingItemsConfig.CONDITION_GRID_LAYOUT_ENABLE, 120 optionList: [ 121 { name: '4X4', params:{row:4, column:4}}, 122 { name: '5X4', params:{row:5, column:4}}, 123 { name: '6X4', params:{row:6, column:4}} 124 ], 125 isShowOptions: SettingItemsConfig.HIDE_OPTIONS 126 }, 127 128 // PadGridLayOutOptions 129 'PadGridLayOutOptions': { 130 index: SettingItemsConfig.SETTINGS_INDEX_GRID_LAYOUT, 131 description: $r('app.string.launcher_layout'), 132 settingType: SettingItemsConfig.SETTING_TYPE_RADIO, 133 deviceType: SettingItemsConfig.DEVICE_TYPE_PAD, 134 condition: SettingItemsConfig.CONDITION_GRID_LAYOUT_ENABLE, 135 optionList: [ 136 { name: '5X11', params:{row:5, column:11}}, 137 { name: '4X10', params:{row:4, column:10}}, 138 { name: '4X9', params:{row:4, column:9}} 139 ], 140 isShowOptions: SettingItemsConfig.HIDE_OPTIONS 141 }, 142 143 // PhoneGestureNavigationOptions 144 'PhoneGestureNavigationOptions': { 145 index: 2, 146 description: $r('app.string.gesture_navigation_options'), 147 settingType: SettingItemsConfig.SETTING_TYPE_SWITCH, 148 deviceType: SettingItemsConfig.DEVICE_TYPE_PHONE, 149 condition: SettingItemsConfig.CONDITION_GRID_LAYOUT_ENABLE, 150 isShowOptions: SettingItemsConfig.SHOW_OPTIONS 151 }, 152 153 // PadGestureNavigationOptions 154 'PadGestureNavigationOptions': { 155 index: 2, 156 description: $r('app.string.gesture_navigation_options'), 157 settingType: SettingItemsConfig.SETTING_TYPE_SWITCH, 158 deviceType: SettingItemsConfig.DEVICE_TYPE_PAD, 159 condition: SettingItemsConfig.CONDITION_GRID_LAYOUT_ENABLE, 160 isShowOptions: SettingItemsConfig.SHOW_OPTIONS 161 }, 162 }; 163}