|
| 1 | +package com.osfans.trime.data.theme.mapper |
| 2 | + |
| 3 | +import com.osfans.trime.data.theme.model.GeneralStyle |
| 4 | +import com.osfans.trime.ime.symbol.CandidateAdapter.CommentPosition |
| 5 | +import com.osfans.trime.util.config.ConfigItem |
| 6 | + |
| 7 | +class GeneralStyleMapper( |
| 8 | + style: Map<String, ConfigItem?>?, |
| 9 | +) : Mapper(style) { |
| 10 | + fun map(): GeneralStyle { |
| 11 | + val autoCaps = getString("auto_caps") |
| 12 | + |
| 13 | + val backgroundDimAmount = getFloat("background_dim_amount") |
| 14 | + |
| 15 | + val candidateBorder = getInt("candidate_border") |
| 16 | + val candidateBorderRound = getInt("candidate_border_round") |
| 17 | + |
| 18 | + val candidateFont = getStringList("candidate_font") |
| 19 | + |
| 20 | + val candidatePadding = getInt("candidate_padding") |
| 21 | + |
| 22 | + val candidateSpacing = getFloat("candidate_spacing") |
| 23 | + |
| 24 | + val candidateTextSize = getInt("candidate_text_size") |
| 25 | + |
| 26 | + val candidateUseCursor = getBoolean("candidate_use_cursor") |
| 27 | + |
| 28 | + val candidateViewHeight = getInt("candidate_view_height") |
| 29 | + |
| 30 | + val colorScheme = getString("color_scheme") |
| 31 | + |
| 32 | + val commentFont = getStringList("comment_font") |
| 33 | + |
| 34 | + val commentHeight = getInt("comment_height") |
| 35 | + |
| 36 | + val commentOnTop = getBoolean("comment_on_top") |
| 37 | + val commentPosition = |
| 38 | + runCatching { |
| 39 | + val s = getString("comment_position") |
| 40 | + CommentPosition.valueOf(s.uppercase()) |
| 41 | + }.getOrElse { |
| 42 | + CommentPosition.UNKNOWN |
| 43 | + } |
| 44 | + |
| 45 | + val commentTextSize = getInt("comment_text_size") |
| 46 | + |
| 47 | + val hanbFont = getStringList("hanb_font") |
| 48 | + |
| 49 | + val horizontal = getBoolean("horizontal") |
| 50 | + |
| 51 | + val horizontalGap = getInt("horizontal_gap") |
| 52 | + |
| 53 | + val keyboardPadding = getInt("keyboard_padding") |
| 54 | + |
| 55 | + val keyboardPaddingLeft = getInt("keyboard_padding_left") |
| 56 | + |
| 57 | + val keyboardPaddingRight = getInt("keyboard_padding_right") |
| 58 | + |
| 59 | + val keyboardPaddingBottom = getInt("keyboard_padding_bottom") |
| 60 | + |
| 61 | + val keyboardPaddingLand = getInt("keyboard_padding_land") |
| 62 | + |
| 63 | + val keyboardPaddingLandBottom = getInt("keyboard_padding_land_bottom") |
| 64 | + |
| 65 | + val layout = |
| 66 | + getObject("layout").let { |
| 67 | + LayoutStyleMapper(it).map() |
| 68 | + } |
| 69 | + |
| 70 | + val window = |
| 71 | + (getList("window")).map { |
| 72 | + val compositionWindowStyleMapper = CompositionWindowStyleMapper(it.configMap) |
| 73 | + compositionWindowStyleMapper.map() |
| 74 | + } |
| 75 | + val liquidKeyboardWindow = |
| 76 | + (getList("liquid_keyboard_window")).map { |
| 77 | + val mapper = CompositionWindowStyleMapper(it.configMap) |
| 78 | + mapper.map() |
| 79 | + } |
| 80 | + val keyFont = getStringList("key_font") |
| 81 | + val keyBorder = getInt("key_border") |
| 82 | + |
| 83 | + val keyHeight = getInt("key_height") |
| 84 | + |
| 85 | + val keyLongTextSize = getInt("key_long_text_size") |
| 86 | + |
| 87 | + val keyTextSize = getInt("key_text_size") |
| 88 | + |
| 89 | + val keyTextOffsetX = getInt("key_text_offset_x") |
| 90 | + val keyTextOffsetY = getInt("key_text_offset_y") |
| 91 | + val keySymbolOffsetX = getInt("key_symbol_offset_x") |
| 92 | + val keySymbolOffsetY = getInt("key_symbol_offset_y") |
| 93 | + val keyHintOffsetX = getInt("key_hint_offset_x") |
| 94 | + val keyHintOffsetY = getInt("key_hint_offset_y") |
| 95 | + val keyPressOffsetX = getInt("key_press_offset_x") |
| 96 | + val keyPressOffsetY = getInt("key_press_offset_y") |
| 97 | + |
| 98 | + val keyWidth = getFloat("key_width") |
| 99 | + |
| 100 | + val keyboards = getStringList("keyboards") |
| 101 | + |
| 102 | + val labelTextSize = getInt("label_text_size") |
| 103 | + |
| 104 | + val labelFont = getStringList("label_font") |
| 105 | + |
| 106 | + val latinFont = getStringList("latin_font") |
| 107 | + |
| 108 | + val latinLocale = getString("latin_locale") |
| 109 | + |
| 110 | + val locale = getString("locale") |
| 111 | + |
| 112 | + val keyboardHeight = getInt("keyboard_height") |
| 113 | + |
| 114 | + val keyboardHeightLand = getInt("keyboard_height_land") |
| 115 | + |
| 116 | + val previewFont = getStringList("preview_font") |
| 117 | + |
| 118 | + val previewHeight = getInt("preview_height") |
| 119 | + |
| 120 | + val previewOffset = getInt("preview_offset") |
| 121 | + |
| 122 | + val previewTextSize = getInt("preview_text_size") |
| 123 | + |
| 124 | + val proximityCorrection = getBoolean("proximity_correction") |
| 125 | + |
| 126 | + val resetASCIIMode = getBoolean("reset_ascii_mode") |
| 127 | + |
| 128 | + val roundCorner = getInt("round_corner") |
| 129 | + |
| 130 | + val shadowRadius = getFloat("shadow_radius") |
| 131 | + |
| 132 | + val speechOpenccConfig = getString("speech_opencc_config") |
| 133 | + |
| 134 | + val symbolFont = getStringList("symbol_font") |
| 135 | + |
| 136 | + val symbolTextSize = getInt("symbol_text_size") |
| 137 | + |
| 138 | + val textFont = getStringList("text_font") |
| 139 | + |
| 140 | + val textSize = getInt("text_size") |
| 141 | + |
| 142 | + val verticalCorrection = getInt("vertical_correction") |
| 143 | + |
| 144 | + val verticalGap = getInt("vertical_gap") |
| 145 | + |
| 146 | + val longTextFont = getStringList("long_text_font") |
| 147 | + |
| 148 | + val backgroundFolder = getString("background_folder") |
| 149 | + |
| 150 | + val keyIntTextBorder = getInt("key_long_text_border") |
| 151 | + |
| 152 | + val enterLabelMode = getInt("enter_label_mode") |
| 153 | + |
| 154 | + val enterLabels = EnterLabelStyleMapper((getObject("enter_labels")?.configMap)).map() |
| 155 | + |
| 156 | + return GeneralStyle( |
| 157 | + autoCaps, |
| 158 | + backgroundDimAmount, |
| 159 | + candidateBorder, |
| 160 | + candidateBorderRound, |
| 161 | + candidateFont, |
| 162 | + candidatePadding, |
| 163 | + candidateSpacing, |
| 164 | + candidateTextSize, |
| 165 | + candidateUseCursor, |
| 166 | + candidateViewHeight, |
| 167 | + colorScheme, |
| 168 | + commentFont, |
| 169 | + commentHeight, |
| 170 | + commentOnTop, |
| 171 | + commentPosition, |
| 172 | + commentTextSize, |
| 173 | + hanbFont, |
| 174 | + horizontal, |
| 175 | + horizontalGap, |
| 176 | + keyboardPadding, |
| 177 | + keyboardPaddingLeft, |
| 178 | + keyboardPaddingRight, |
| 179 | + keyboardPaddingBottom, |
| 180 | + keyboardPaddingLand, |
| 181 | + keyboardPaddingLandBottom, |
| 182 | + layout, |
| 183 | + window, |
| 184 | + liquidKeyboardWindow, |
| 185 | + keyFont, |
| 186 | + keyBorder, |
| 187 | + keyHeight, |
| 188 | + keyLongTextSize, |
| 189 | + keyTextSize, |
| 190 | + keyTextOffsetX, |
| 191 | + keyTextOffsetY, |
| 192 | + keySymbolOffsetX, |
| 193 | + keySymbolOffsetY, |
| 194 | + keyHintOffsetX, |
| 195 | + keyHintOffsetY, |
| 196 | + keyPressOffsetX, |
| 197 | + keyPressOffsetY, |
| 198 | + keyWidth, |
| 199 | + keyboards, |
| 200 | + labelTextSize, |
| 201 | + labelFont, |
| 202 | + latinFont, |
| 203 | + latinLocale, |
| 204 | + locale, |
| 205 | + keyboardHeight, |
| 206 | + keyboardHeightLand, |
| 207 | + previewFont, |
| 208 | + previewHeight, |
| 209 | + previewOffset, |
| 210 | + previewTextSize, |
| 211 | + proximityCorrection, |
| 212 | + resetASCIIMode, |
| 213 | + roundCorner, |
| 214 | + shadowRadius, |
| 215 | + speechOpenccConfig, |
| 216 | + symbolFont, |
| 217 | + symbolTextSize, |
| 218 | + textFont, |
| 219 | + textSize, |
| 220 | + verticalCorrection, |
| 221 | + verticalGap, |
| 222 | + longTextFont, |
| 223 | + backgroundFolder, |
| 224 | + keyIntTextBorder, |
| 225 | + enterLabelMode, |
| 226 | + enterLabels, |
| 227 | + ) |
| 228 | + } |
| 229 | +} |
0 commit comments