summaryrefslogtreecommitdiff
path: root/base/src/main/java/com/smartdevicelink/managers/screen/BaseScreenManager.java
blob: 297c114d3b9411f47909f25d16ae2104fb4c5772 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
/*
 * Copyright (c) 2019 Livio, Inc.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice, this
 * list of conditions and the following disclaimer.
 *
 * Redistributions in binary form must reproduce the above copyright notice,
 * this list of conditions and the following
 * disclaimer in the documentation and/or other materials provided with the
 * distribution.
 *
 * Neither the name of the Livio Inc. nor the names of its contributors
 * may be used to endorse or promote products derived from this software
 * without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */
package com.smartdevicelink.managers.screen;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;

import com.smartdevicelink.managers.BaseSubManager;
import com.smartdevicelink.managers.CompletionListener;
import com.smartdevicelink.managers.ISdl;
import com.smartdevicelink.managers.file.FileManager;
import com.smartdevicelink.managers.file.filetypes.SdlArtwork;
import com.smartdevicelink.managers.screen.choiceset.ChoiceCell;
import com.smartdevicelink.managers.screen.choiceset.ChoiceSet;
import com.smartdevicelink.managers.screen.choiceset.ChoiceSetManager;
import com.smartdevicelink.managers.screen.choiceset.KeyboardListener;
import com.smartdevicelink.managers.screen.menu.DynamicMenuUpdatesMode;
import com.smartdevicelink.managers.screen.menu.MenuCell;
import com.smartdevicelink.managers.screen.menu.MenuConfiguration;
import com.smartdevicelink.managers.screen.menu.MenuManager;
import com.smartdevicelink.managers.screen.menu.VoiceCommand;
import com.smartdevicelink.managers.screen.menu.VoiceCommandManager;
import com.smartdevicelink.proxy.rpc.KeyboardProperties;
import com.smartdevicelink.proxy.rpc.enums.ButtonName;
import com.smartdevicelink.proxy.rpc.enums.InteractionMode;
import com.smartdevicelink.proxy.rpc.enums.MetadataType;
import com.smartdevicelink.proxy.rpc.enums.TextAlignment;
import com.smartdevicelink.util.DebugTool;

import java.lang.ref.WeakReference;
import java.util.HashSet;
import java.util.List;

/**
 * <strong>ScreenManager</strong> <br>
 *
 * Note: This class must be accessed through the SdlManager. Do not instantiate it by itself. <br>
*/
abstract class BaseScreenManager extends BaseSubManager {

	private static final String TAG = "ScreenManager";
	private final WeakReference<FileManager> fileManager;
	private SoftButtonManager softButtonManager;
	private TextAndGraphicManager textAndGraphicManager;
	private VoiceCommandManager voiceCommandManager;
	private MenuManager menuManager;
	private ChoiceSetManager choiceSetManager;
	private SubscribeButtonManager subscribeButtonManager;

	// Sub manager listener
	private final CompletionListener subManagerListener = new CompletionListener() {

		@Override
		public synchronized void onComplete(boolean success) {
			if (softButtonManager != null && textAndGraphicManager != null && voiceCommandManager != null && menuManager != null && choiceSetManager != null && subscribeButtonManager != null) {
				if (softButtonManager.getState() == BaseSubManager.READY && textAndGraphicManager.getState() == BaseSubManager.READY && voiceCommandManager.getState() == BaseSubManager.READY && menuManager.getState() == BaseSubManager.READY
						&& subscribeButtonManager.getState() == BaseSubManager.READY) {
					DebugTool.logInfo(TAG, "Starting screen manager, all sub managers are in ready state");
					transitionToState(READY);
				} else if (softButtonManager.getState() == BaseSubManager.ERROR && textAndGraphicManager.getState() == BaseSubManager.ERROR && voiceCommandManager.getState() == BaseSubManager.ERROR && menuManager.getState() == BaseSubManager.ERROR
						&& choiceSetManager.getState() == BaseSubManager.ERROR && subscribeButtonManager.getState() == BaseSubManager.ERROR) {
					DebugTool.logError(TAG, "ERROR starting screen manager, all sub managers are in error state");
					transitionToState(ERROR);
				} else if (textAndGraphicManager.getState() == BaseSubManager.SETTING_UP || softButtonManager.getState() == BaseSubManager.SETTING_UP || voiceCommandManager.getState() == BaseSubManager.SETTING_UP || menuManager.getState() == BaseSubManager.SETTING_UP
						|| choiceSetManager.getState() == BaseSubManager.SETTING_UP || subscribeButtonManager.getState() == BaseSubManager.SETTING_UP) {
					DebugTool.logInfo(TAG, "SETTING UP screen manager, at least one sub manager is still setting up");
					transitionToState(SETTING_UP);
				} else {
					DebugTool.logWarning(TAG, "LIMITED starting screen manager, at least one sub manager is in error state and the others are ready");
					transitionToState(LIMITED);
				}
			} else {
				// We should never be here, but somehow one of the sub-sub managers is null
				DebugTool.logError(TAG, "ERROR one of the screen sub managers is null");
				transitionToState(ERROR);
			}
		}
	};

	BaseScreenManager(@NonNull ISdl internalInterface, @NonNull FileManager fileManager) {
		super(internalInterface);
		this.fileManager = new WeakReference<>(fileManager);
		initialize();
	}

	@Override
	@RestrictTo(RestrictTo.Scope.LIBRARY)
	public void start(CompletionListener listener) {
		super.start(listener);
		this.softButtonManager.start(subManagerListener);
		this.textAndGraphicManager.start(subManagerListener);
		this.voiceCommandManager.start(subManagerListener);
		this.menuManager.start(subManagerListener);
		this.choiceSetManager.start(subManagerListener);
		this.subscribeButtonManager.start(subManagerListener);
	}

	private void initialize(){
		if (fileManager.get() != null) {
			this.softButtonManager = new SoftButtonManager(internalInterface, fileManager.get());
			this.textAndGraphicManager = new TextAndGraphicManager(internalInterface, fileManager.get(), softButtonManager);
			this.menuManager = new MenuManager(internalInterface, fileManager.get());
			this.choiceSetManager = new ChoiceSetManager(internalInterface, fileManager.get());
		}
		this.subscribeButtonManager = new SubscribeButtonManager(internalInterface);
		this.voiceCommandManager = new VoiceCommandManager(internalInterface);
	}

	/**
	 * <p>Called when manager is being torn down</p>
	 */
	@Override
	@RestrictTo(RestrictTo.Scope.LIBRARY)
	public void dispose() {
		softButtonManager.dispose();
		textAndGraphicManager.dispose();
		voiceCommandManager.dispose();
		menuManager.dispose();
		choiceSetManager.dispose();
		subscribeButtonManager.dispose();
		super.dispose();
	}

	/**
	 * Set the textField1 on the head unit screen
	 * Sending an empty String "" will clear the field
	 * @param textField1 String value represents the textField1
	 */
	public void setTextField1(String textField1) {
		this.softButtonManager.setCurrentMainField1(textField1);
		this.textAndGraphicManager.setTextField1(textField1);
	}

	/**
	 * Get the current textField1 value
	 * @return a String value represents the current textField1 value
	 */
	public String getTextField1() {
		return this.textAndGraphicManager.getTextField1();
	}

	/**
	 * Set the textField2 on the head unit screen
	 * Sending an empty String "" will clear the field
	 * @param textField2 String value represents the textField1
	 */
	public void setTextField2(String textField2) {
		this.textAndGraphicManager.setTextField2(textField2);
	}

	/**
	 * Get the current textField2 value
	 * @return a String value represents the current textField2 value
	 */
	public String getTextField2() {
		return this.textAndGraphicManager.getTextField2();
	}

	/**
	 * Set the textField3 on the head unit screen
	 * Sending an empty String "" will clear the field
	 * @param textField3 String value represents the textField1
	 */
	public void setTextField3(String textField3) {
		this.textAndGraphicManager.setTextField3(textField3);
	}

	/**
	 * Get the current textField3 value
	 * @return a String value represents the current textField3 value
	 */
	public String getTextField3() {
		return this.textAndGraphicManager.getTextField3();
	}

	/**
	 * Set the textField4 on the head unit screen
	 * Sending an empty String "" will clear the field
	 * @param textField4 String value represents the textField1
	 */
	public void setTextField4(String textField4) {
		this.textAndGraphicManager.setTextField4(textField4);
	}

	/**
	 * Get the current textField4 value
	 * @return a String value represents the current textField4 value
	 */
	public String getTextField4() {
		return this.textAndGraphicManager.getTextField4();
	}

	/**
	 * Set the mediaTrackTextField on the head unit screen
	 * @param mediaTrackTextField String value represents the mediaTrackTextField
	 */
	public void setMediaTrackTextField(String mediaTrackTextField) {
		this.textAndGraphicManager.setMediaTrackTextField(mediaTrackTextField);
	}

	/**
	 * Get the current mediaTrackTextField value
	 * @return a String value represents the current mediaTrackTextField
	 */
	public String getMediaTrackTextField() {
		return this.textAndGraphicManager.getMediaTrackTextField();
	}

	/**
	 * Set the primaryGraphic on the head unit screen
	 * @param primaryGraphic an SdlArtwork object represents the primaryGraphic
	 */
	public void setPrimaryGraphic(SdlArtwork primaryGraphic) {
		if (primaryGraphic == null){
			primaryGraphic = textAndGraphicManager.getBlankArtwork();
		}
		this.textAndGraphicManager.setPrimaryGraphic(primaryGraphic);
	}

	/**
	 * Get the current primaryGraphic value
	 * @return an SdlArtwork object represents the current primaryGraphic
	 */
	public SdlArtwork getPrimaryGraphic() {
		if (this.textAndGraphicManager.getPrimaryGraphic() == null ||  textAndGraphicManager.getPrimaryGraphic().getName() == null || this.textAndGraphicManager.getPrimaryGraphic().getName().equals(textAndGraphicManager.getBlankArtwork().getName())) {
			return null;
		}
		return this.textAndGraphicManager.getPrimaryGraphic();
	}

	/**
	 * Set the secondaryGraphic on the head unit screen
	 * @param secondaryGraphic an SdlArtwork object represents the secondaryGraphic
	 */
	public void setSecondaryGraphic(SdlArtwork secondaryGraphic) {
		if (secondaryGraphic == null){
			secondaryGraphic = textAndGraphicManager.getBlankArtwork();
		}
		this.textAndGraphicManager.setSecondaryGraphic(secondaryGraphic);
	}

	/**
	 * Get the current secondaryGraphic value
	 * @return an SdlArtwork object represents the current secondaryGraphic
	 */
	public SdlArtwork getSecondaryGraphic() {
		if (this.textAndGraphicManager.getSecondaryGraphic() == null || textAndGraphicManager.getSecondaryGraphic().getName() == null || this.textAndGraphicManager.getSecondaryGraphic().getName().equals(textAndGraphicManager.getBlankArtwork().getName())) {
			return null;
		}
		return this.textAndGraphicManager.getSecondaryGraphic();
	}

	/**
	 * Set the alignment for the text fields
	 * @param textAlignment TextAlignment value represents the alignment for the text fields
	 */
	public void setTextAlignment(TextAlignment textAlignment) {
		this.textAndGraphicManager.setTextAlignment(textAlignment);
	}

	/**
	 * Get the alignment for the text fields
	 * @return a TextAlignment value represents the alignment for the text fields
	 */
	public TextAlignment getTextAlignment() {
		return this.textAndGraphicManager.getTextAlignment();
	}

	/**
	 * Set the metadata type for the textField1
	 * @param textField1Type a MetadataType value represents the metadata for textField1
	 */
	public void setTextField1Type(MetadataType textField1Type) {
		this.textAndGraphicManager.setTextField1Type(textField1Type);
	}

	/**
	 * Get the metadata type for textField1
	 * @return a MetadataType value represents the metadata for textField1
	 */
	public MetadataType getTextField1Type() {
		return this.textAndGraphicManager.getTextField1Type();
	}

	/**
	 * Set the metadata type for the textField2
	 * @param textField2Type a MetadataType value represents the metadata for textField2
	 */
	public void setTextField2Type(MetadataType textField2Type) {
		this.textAndGraphicManager.setTextField2Type(textField2Type);
	}

	/**
	 * Get the metadata type for textField2
	 * @return a MetadataType value represents the metadata for textField2
	 */
	public MetadataType getTextField2Type() {
		return this.textAndGraphicManager.getTextField2Type();
	}

	/**
	 * Set the metadata type for the textField3
	 * @param textField3Type a MetadataType value represents the metadata for textField3
	 */
	public void setTextField3Type(MetadataType textField3Type) {
		this.textAndGraphicManager.setTextField3Type(textField3Type);
	}

	/**
	 * Get the metadata type for textField3
	 * @return a MetadataType value represents the metadata for textField3
	 */
	public MetadataType getTextField3Type() {
		return this.textAndGraphicManager.getTextField3Type();
	}

	/**
	 * Set the metadata type for the textField4
	 * @param textField4Type a MetadataType value represents the metadata for textField4
	 */
	public void setTextField4Type(MetadataType textField4Type) {
		this.textAndGraphicManager.setTextField4Type(textField4Type);
	}

	/**
	 * Get the metadata type for textField4
	 * @return a MetadataType value represents the metadata for textField4
	 */
	public MetadataType getTextField4Type() {
		return this.textAndGraphicManager.getTextField4Type();
	}

	/**
	 * Sets the title of the new template that will be displayed.
	 * Sending an empty String "" will clear the field
	 * @param title the title of the new template that will be displayed. MaxLength: 100.
	 */
	public void setTitle(String title){
		this.textAndGraphicManager.setTitle(title);
	}

	/**
	 * Gets the title of the new template that will be displayed
	 * @return title - String value that represents the title of the new template that will be displayed
	 */
	public String getTitle(){
		return this.textAndGraphicManager.getTitle();
	}

	/**
	 * Set softButtonObjects list and upload the images to the head unit
	 * @param softButtonObjects the list of the SoftButtonObject values that should be displayed on the head unit
	 */
	public void setSoftButtonObjects(@NonNull List<SoftButtonObject> softButtonObjects) {
		softButtonManager.setSoftButtonObjects(softButtonObjects);
	}

	/**
	 * Get the soft button objects list
	 * @return a List<SoftButtonObject>
	 */
	public List<SoftButtonObject> getSoftButtonObjects() {
		return softButtonManager.getSoftButtonObjects();
	}

	/**
	 * Get the SoftButtonObject that has the provided name
	 * @param name a String value that represents the name
	 * @return a SoftButtonObject
	 */
	public SoftButtonObject getSoftButtonObjectByName(@NonNull String name){
		return softButtonManager.getSoftButtonObjectByName(name);
	}

	/**
	 * Get the SoftButtonObject that has the provided buttonId
	 * @param buttonId a int value that represents the id of the button
	 * @return a SoftButtonObject
	 */
	public SoftButtonObject getSoftButtonObjectById(int buttonId){
		return softButtonManager.getSoftButtonObjectById(buttonId);
	}

	/**
	 * Get the currently set voice commands
	 * @return a List of Voice Command objects
	 */
	public List<VoiceCommand> getVoiceCommands(){
		return voiceCommandManager.getVoiceCommands();
	}

	/**
	 * Set voice commands
	 * @param voiceCommands the voice commands to be sent to the head unit
	 */
	public void setVoiceCommands(@NonNull List<VoiceCommand> voiceCommands){
		this.voiceCommandManager.setVoiceCommands(voiceCommands);
	}

	// MENUS

	/**
	 * The list of currently set menu cells
	 * @return a List of the currently set menu cells
	 */
	public List<MenuCell> getMenu(){
		return this.menuManager.getMenuCells();
	}

	/**
	 * Creates and sends all associated Menu RPCs
	 * Note: the manager will store a deep copy the menuCells internally to be able to handle future updates correctly
	 * @param menuCells - the menu cells that are to be sent to the head unit, including their sub-cells.
	 */
	public void setMenu(@NonNull List<MenuCell> menuCells){
		this.menuManager.setMenuCells(menuCells);
	}

	/**
	 * Sets the behavior of how menus are updated. For explanations of the differences, see {@link DynamicMenuUpdatesMode}
	 * @param value - the update mode
	 */
	public void setDynamicMenuUpdatesMode(@NonNull DynamicMenuUpdatesMode value){
		this.menuManager.setDynamicUpdatesMode(value);
	}

	/**
	 * @return The currently set DynamicMenuUpdatesMode. It defaults to ON_WITH_COMPAT_MODE if not set.
	 */
	public DynamicMenuUpdatesMode getDynamicMenuUpdatesMode(){
		return this.menuManager.getDynamicMenuUpdatesMode();
	}

	/**
	 * Requires SDL RPC Version 6.0.0 or greater
	 * Opens the Main Menu.
	 * @return boolean success / failure - whether the request was able to be sent
	 */
	public boolean openMenu(){
		return this.menuManager.openMenu();
	}

	/**
	 * Requires SDL RPC Version 6.0.0 or greater
	 * Opens a subMenu. The cell you pass in must be constructed with {@link MenuCell(String,SdlArtwork,List)}
	 * @param cell - A <Strong>SubMenu</Strong> cell whose sub menu you wish to open
	 * @return boolean success / failure - whether the request was able to be sent
	 */
	public boolean openSubMenu(@NonNull MenuCell cell){
		return this.menuManager.openSubMenu(cell);
  	}
  
  	/**
	 * The main menu layout. See available menu layouts on WindowCapability.menuLayoutsAvailable.
	 * @param menuConfiguration - The default menuConfiguration
	 */
	public void setMenuConfiguration(@NonNull MenuConfiguration menuConfiguration) {
		this.menuManager.setMenuConfiguration(menuConfiguration);
	}

	/**
	 * The main menu layout. See available menu layouts on WindowCapability.menuLayoutsAvailable.
	 * @return the currently set MenuConfiguration
	 */
	public MenuConfiguration getMenuConfiguration(){
		return this.menuManager.getMenuConfiguration();
	}

	// CHOICE SETS

	/**
	 * Deletes choices that were sent previously
	 * @param choices - A list of ChoiceCell objects
	 */
	public void deleteChoices(@NonNull List<ChoiceCell> choices){
		this.choiceSetManager.deleteChoices(choices);
	}

	/**
	 * Preload choices to improve performance while presenting a choice set at a later time
	 * @param choices - a list of ChoiceCell objects that will be part of a choice set later
	 * @param listener - a completion listener to inform when the operation is complete
	 */
	public void preloadChoices(@NonNull List<ChoiceCell> choices, CompletionListener listener){
		this.choiceSetManager.preloadChoices(choices, listener);
	}

	/**
	 * Presents a searchable choice set
	 * @param choiceSet - The choice set to be presented. This can include Choice Cells that were preloaded or not
	 * @param mode - The intended interaction mode
	 * @param keyboardListener - A keyboard listener to capture user input
	 */
	public void presentSearchableChoiceSet(@NonNull ChoiceSet choiceSet, @Nullable InteractionMode mode, @NonNull KeyboardListener keyboardListener){
		this.choiceSetManager.presentChoiceSet(choiceSet, mode, keyboardListener);
	}

	/**
	 * Presents a choice set
	 * @param choiceSet - The choice set to be presented. This can include Choice Cells that were preloaded or not
	 * @param mode - The intended interaction mode
	 */
	public void presentChoiceSet(@NonNull ChoiceSet choiceSet, @Nullable InteractionMode mode){
		this.choiceSetManager.presentChoiceSet(choiceSet, mode, null);
	}

	/**
	 * Presents a keyboard on the Head unit to capture user input
	 * @param initialText - The initial text that is used as a placeholder text. It might not work on some head units.
	 * @param customKeyboardProperties - the custom keyboard configuration to be used when the keyboard is displayed
	 * @param keyboardListener - A keyboard listener to capture user input
	 * @return A unique cancelID that can be used to cancel this keyboard. If `null`, no keyboard was created.
	 */
	public Integer presentKeyboard(@NonNull String initialText, @Nullable KeyboardProperties customKeyboardProperties, @NonNull KeyboardListener keyboardListener){
		return this.choiceSetManager.presentKeyboard(initialText, customKeyboardProperties, keyboardListener);
	}

	/**
	 * Set a custom keyboard configuration for this session. If set to null, it will reset to default keyboard configuration.
	 * @param keyboardConfiguration - the custom keyboard configuration to be used when the keyboard is displayed
	 */
	public void setKeyboardConfiguration(@Nullable KeyboardProperties keyboardConfiguration){
		this.choiceSetManager.setKeyboardConfiguration(keyboardConfiguration);
	}

	/**
	 * @return A set of choice cells that have been preloaded to the head unit
	 */
	public HashSet<ChoiceCell> getPreloadedChoices(){
		return this.choiceSetManager.getPreloadedChoices();
	}

	/**
	 * Dismisses a currently presented keyboard with the associated ID. Canceling a keyboard only works when connected to SDL Core v.6.0+. When connected to older versions of SDL Core the keyboard will not be dismissed.
	 * @param cancelID The unique ID assigned to the keyboard
	 */
	public void dismissKeyboard(@NonNull Integer cancelID) {
		this.choiceSetManager.dismissKeyboard(cancelID);
	}

	// END CHOICE SETS

	/**
	 * Begin a multiple updates transaction. The updates will be applied when commit() is called<br>
	 * Note: if we don't use beginTransaction & commit, every update will be sent individually.
	 */
	public void beginTransaction(){
		softButtonManager.setBatchUpdates(true);
		textAndGraphicManager.setBatchUpdates(true);
	}

	/**
	 * Send the updates that were started after beginning the transaction
	 * @param listener a CompletionListener that has a callback that will be called when the updates are finished
	 */
	public void commit(final CompletionListener listener){
		softButtonManager.setBatchUpdates(false);
		textAndGraphicManager.setBatchUpdates(false);
		textAndGraphicManager.update(new CompletionListener() {
			@Override
			public void onComplete(boolean success) {
				if (listener != null) {
					listener.onComplete(success);
				}
			}
		});
	}

	public void addButtonListener(@NonNull ButtonName buttonName, @NonNull OnButtonListener listener){
		subscribeButtonManager.addButtonListener(buttonName,listener);
	}
	public void removeButtonListener(@NonNull ButtonName buttonName, @NonNull OnButtonListener listener){
		subscribeButtonManager.removeButtonListener(buttonName, listener);
	}
}