Skip to content

Commit abbc455

Browse files
author
Julian Kast
committed
Align with IOS and JS on timeout logic
1 parent 4d8fb85 commit abbc455

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

base/src/main/java/com/smartdevicelink/managers/screen/AlertView.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,11 @@
3939
import java.util.List;
4040

4141
public class AlertView implements Cloneable {
42-
43-
private static Integer defaultTimeout = 5;
42+
43+
private static final int TIMEOUT_DEFAULT = 0;
4444
private static final int TIMEOUT_MIN = 3;
4545
private static final int TIMEOUT_MAX = 10;
46+
private static Integer defaultTimeout = 5;
4647
private String text, secondaryText, tertiaryText;
4748
private Integer timeout;
4849
private AlertAudioData audio;
@@ -61,14 +62,17 @@ public static class Builder {
6162

6263
public Builder() {
6364
alertView = new AlertView();
65+
if (alertView.timeout == null) {
66+
alertView.timeout = TIMEOUT_DEFAULT;
67+
}
6468
}
6569

6670
/**
6771
* The primary line of text for display on the alert. If fewer than three alert lines are available
6872
* on the head unit, the screen manager will automatically concatenate some of the lines together.
6973
*/
7074
public Builder setText(String text) {
71-
this.alertView.text = text;
75+
alertView.text = text;
7276
return this;
7377
}
7478

@@ -164,7 +168,7 @@ public void cancel() {
164168
}
165169

166170
public Integer getTimeout() {
167-
if (timeout == null) {
171+
if (timeout == TIMEOUT_DEFAULT) {
168172
timeout = getDefaultTimeout();
169173
} else if (timeout < TIMEOUT_MIN) {
170174
return TIMEOUT_MIN;

base/src/main/java/com/smartdevicelink/managers/screen/choiceset/ChoiceSet.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,10 @@ public class ChoiceSet {
5959
ChoiceSetCanceledListener canceledListener;
6060

6161
// defaults
62-
private static Integer defaultTimeout = 10;
62+
private static final int TIMEOUT_DEFAULT = 0;
6363
private static final int TIMEOUT_MIN = 5;
6464
private static final int TIMEOUT_MAX = 100;
65+
private static Integer defaultTimeout = 10;
6566
private final ChoiceSetLayout defaultLayout = ChoiceSetLayout.CHOICE_SET_LAYOUT_LIST;
6667

6768
/**
@@ -81,6 +82,7 @@ public ChoiceSet(@NonNull String title, @NonNull List<ChoiceCell> choices, @NonN
8182
setTitle(title);
8283
setChoiceSetSelectionListener(listener);
8384
setChoices(choices);
85+
setTimeout(TIMEOUT_DEFAULT);
8486

8587
// defaults
8688
setLayout(defaultLayout);
@@ -302,7 +304,7 @@ public void setLayout(ChoiceSetLayout layout) {
302304
* @return The Timeout
303305
*/
304306
public Integer getTimeout() {
305-
if (timeout == null) {
307+
if (timeout == TIMEOUT_DEFAULT) {
306308
timeout = getDefaultTimeout();
307309
} else if (timeout < TIMEOUT_MIN) {
308310
return TIMEOUT_MIN;

0 commit comments

Comments
 (0)