|
14 | 14 | import javax.annotation.Nullable; |
15 | 15 |
|
16 | 16 | import io.channel.plugin.android.enumerate.BubblePosition; |
| 17 | +import io.channel.plugin.android.open.enumerate.ChannelButtonIcon; |
17 | 18 | import io.channel.plugin.android.open.model.Appearance; |
18 | 19 | import io.channel.plugin.android.open.option.BubbleOption; |
19 | 20 |
|
@@ -195,24 +196,77 @@ public static List<Object> toArrayList(ReadableArray readableArray) { |
195 | 196 |
|
196 | 197 | public static ChannelButtonOption toChannelButtonOption(ReadableMap channelButtonOptionMap) { |
197 | 198 | if (channelButtonOptionMap != null) { |
| 199 | + String iconString = Utils.getString(channelButtonOptionMap, Const.KEY_ICON).getValue(); |
198 | 200 | String positionString = Utils.getString(channelButtonOptionMap, Const.KEY_POSITION).getValue(); |
199 | 201 | Double xPosition = Utils.getDouble(channelButtonOptionMap, Const.KEY_X_MARGIN).getValue(); |
200 | 202 | Double yPosition = Utils.getDouble(channelButtonOptionMap, Const.KEY_Y_MARGIN).getValue(); |
201 | 203 |
|
202 | | - if (positionString != null && xPosition != null && yPosition != null) { |
203 | | - switch (positionString) { |
204 | | - case Const.KEY_LAUNCHER_POSITION_LEFT: |
205 | | - return new ChannelButtonOption(ChannelButtonPosition.LEFT, xPosition.floatValue(), yPosition.floatValue()); |
206 | | - |
207 | | - case Const.KEY_LAUNCHER_POSITION_RIGHT: |
208 | | - return new ChannelButtonOption(ChannelButtonPosition.RIGHT, xPosition.floatValue(), yPosition.floatValue()); |
209 | | - } |
| 204 | + if (iconString != null && positionString != null && xPosition != null && yPosition != null) { |
| 205 | + return new ChannelButtonOption( |
| 206 | + toChannelButtonIcon(iconString), |
| 207 | + toChannelButtonPosition(positionString), |
| 208 | + xPosition.floatValue(), |
| 209 | + yPosition.floatValue() |
| 210 | + ); |
| 211 | + } else if (iconString != null) { |
| 212 | + return new ChannelButtonOption(toChannelButtonIcon(iconString)); |
| 213 | + } else if (positionString != null && xPosition != null && yPosition != null) { |
| 214 | + return new ChannelButtonOption(toChannelButtonPosition(positionString), xPosition.floatValue(), yPosition.floatValue()); |
210 | 215 | } |
211 | 216 | } |
212 | 217 |
|
213 | 218 | return null; |
214 | 219 | } |
215 | 220 |
|
| 221 | + private static ChannelButtonPosition toChannelButtonPosition(String positionString) { |
| 222 | + if (positionString.equals(Const.KEY_CHANNEL_BUTTON_OPTION_POSITION_LEFT)) { |
| 223 | + return ChannelButtonPosition.LEFT; |
| 224 | + } else { |
| 225 | + return ChannelButtonPosition.RIGHT; |
| 226 | + } |
| 227 | + } |
| 228 | + |
| 229 | + private static ChannelButtonIcon toChannelButtonIcon(String iconString) { |
| 230 | + switch (iconString) { |
| 231 | + case Const.KEY_CHANNEL_BUTTON_OPTION_ICON_CHAT_BUBBLE_FILLED: |
| 232 | + return ChannelButtonIcon.ChatBubbleFilled; |
| 233 | + case Const.KEY_CHANNEL_BUTTON_OPTION_ICON_CHAT_PROGRESS_FILLED: |
| 234 | + return ChannelButtonIcon.ChatProgressFilled; |
| 235 | + case Const.KEY_CHANNEL_BUTTON_OPTION_ICON_CHAT_QUESTION_FILLED: |
| 236 | + return ChannelButtonIcon.ChatQuestionFilled; |
| 237 | + case Const.KEY_CHANNEL_BUTTON_OPTION_ICON_CHAT_LIGHTNING_FILLED: |
| 238 | + return ChannelButtonIcon.ChatLightningFilled; |
| 239 | + case Const.KEY_CHANNEL_BUTTON_OPTION_ICON_CHAT_BUBBLE_ALT_FILLED: |
| 240 | + return ChannelButtonIcon.ChatBubbleAltFilled; |
| 241 | + case Const.KEY_CHANNEL_BUTTON_OPTION_ICON_SMS_FILLED: |
| 242 | + return ChannelButtonIcon.SmsFilled; |
| 243 | + case Const.KEY_CHANNEL_BUTTON_OPTION_ICON_COMMENT_FILLED: |
| 244 | + return ChannelButtonIcon.CommentFilled; |
| 245 | + case Const.KEY_CHANNEL_BUTTON_OPTION_ICON_SEND_FORWARD_FILLED: |
| 246 | + return ChannelButtonIcon.SendForwardFilled; |
| 247 | + case Const.KEY_CHANNEL_BUTTON_OPTION_ICON_HELP_FILLED: |
| 248 | + return ChannelButtonIcon.HelpFilled; |
| 249 | + case Const.KEY_CHANNEL_BUTTON_OPTION_ICON_CHAT_PROGRESS: |
| 250 | + return ChannelButtonIcon.ChatProgress; |
| 251 | + case Const.KEY_CHANNEL_BUTTON_OPTION_ICON_CHAT_QUESTION: |
| 252 | + return ChannelButtonIcon.ChatQuestion; |
| 253 | + case Const.KEY_CHANNEL_BUTTON_OPTION_ICON_CHAT_BUBBLE_ALT: |
| 254 | + return ChannelButtonIcon.ChatBubbleAlt; |
| 255 | + case Const.KEY_CHANNEL_BUTTON_OPTION_ICON_SMS: |
| 256 | + return ChannelButtonIcon.Sms; |
| 257 | + case Const.KEY_CHANNEL_BUTTON_OPTION_ICON_COMMENT: |
| 258 | + return ChannelButtonIcon.Comment; |
| 259 | + case Const.KEY_CHANNEL_BUTTON_OPTION_ICON_SEND_FORWARD: |
| 260 | + return ChannelButtonIcon.SendForward; |
| 261 | + case Const.KEY_CHANNEL_BUTTON_OPTION_ICON_COMMUNICATION: |
| 262 | + return ChannelButtonIcon.Communication; |
| 263 | + case Const.KEY_CHANNEL_BUTTON_OPTION_ICON_HEADSET: |
| 264 | + return ChannelButtonIcon.Headset; |
| 265 | + default: |
| 266 | + return ChannelButtonIcon.Channel; |
| 267 | + } |
| 268 | + } |
| 269 | + |
216 | 270 | public static BubbleOption toBubbleOption(ReadableMap bubbleOptionMap) { |
217 | 271 | if (bubbleOptionMap != null) { |
218 | 272 | String positionString = Utils.getString(bubbleOptionMap, Const.KEY_POSITION).getValue(); |
|
0 commit comments