Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

For #12151 - Add support for empty step value in TimePicker (Uplift) #12840

Merged
merged 2 commits into from
Sep 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -397,15 +397,20 @@ internal class GeckoPromptDelegate(private val geckoEngineSession: GeckoEngineSe
onConfirm("")
}
val initialDateString = prompt.defaultValue ?: ""
val stepValue = if (prompt.stepValue.isNullOrBlank()) {
null
} else {
prompt.stepValue
}

val format = when (prompt.type) {
DATE -> "yyyy-MM-dd"
MONTH -> "yyyy-MM"
WEEK -> "yyyy-'W'ww"
TIME -> {
if (shouldShowMillisecondsPicker(prompt.stepValue?.toFloat())) {
if (shouldShowMillisecondsPicker(stepValue?.toFloat())) {
"HH:mm:ss.SSS"
} else if (shouldShowSecondsPicker(prompt.stepValue?.toFloat())) {
} else if (shouldShowSecondsPicker(stepValue?.toFloat())) {
"HH:mm:ss"
} else {
"HH:mm"
Expand All @@ -422,19 +427,19 @@ internal class GeckoPromptDelegate(private val geckoEngineSession: GeckoEngineSe
initialDateString,
prompt.minValue,
prompt.maxValue,
prompt.stepValue,
stepValue,
onClear,
format,
onConfirm,
onDismiss
onDismiss,
)

return geckoResult
}

override fun onAuthPrompt(
session: GeckoSession,
geckoPrompt: PromptDelegate.AuthPrompt
geckoPrompt: PromptDelegate.AuthPrompt,
): GeckoResult<PromptResponse>? {
val geckoResult = GeckoResult<PromptResponse>()
val title = geckoPrompt.title ?: ""
Expand Down Expand Up @@ -477,16 +482,16 @@ internal class GeckoPromptDelegate(private val geckoEngineSession: GeckoEngineSe
previousFailed,
isCrossOrigin,
onConfirm,
onDismiss
)
onDismiss,
),
)
}
return geckoResult
}

override fun onTextPrompt(
session: GeckoSession,
prompt: PromptDelegate.TextPrompt
prompt: PromptDelegate.TextPrompt,
): GeckoResult<PromptResponse>? {
val geckoResult = GeckoResult<PromptResponse>()
val title = prompt.title ?: ""
Expand All @@ -507,8 +512,8 @@ internal class GeckoPromptDelegate(private val geckoEngineSession: GeckoEngineSe
inputValue,
false,
onConfirm,
onDismiss
)
onDismiss,
),
)
}

Expand All @@ -517,7 +522,7 @@ internal class GeckoPromptDelegate(private val geckoEngineSession: GeckoEngineSe

override fun onColorPrompt(
session: GeckoSession,
prompt: PromptDelegate.ColorPrompt
prompt: PromptDelegate.ColorPrompt,
): GeckoResult<PromptResponse>? {
val geckoResult = GeckoResult<PromptResponse>()
val onConfirm: (String) -> Unit = {
Expand All @@ -531,15 +536,15 @@ internal class GeckoPromptDelegate(private val geckoEngineSession: GeckoEngineSe

geckoEngineSession.notifyObservers {
onPromptRequest(
PromptRequest.Color(defaultColor, onConfirm, onDismiss)
PromptRequest.Color(defaultColor, onConfirm, onDismiss),
)
}
return geckoResult
}

override fun onPopupPrompt(
session: GeckoSession,
prompt: PromptDelegate.PopupPrompt
prompt: PromptDelegate.PopupPrompt,
): GeckoResult<PromptResponse> {
val geckoResult = GeckoResult<PromptResponse>()
val onAllow: () -> Unit = {
Expand All @@ -555,15 +560,15 @@ internal class GeckoPromptDelegate(private val geckoEngineSession: GeckoEngineSe

geckoEngineSession.notifyObservers {
onPromptRequest(
PromptRequest.Popup(prompt.targetUri ?: "", onAllow, onDeny)
PromptRequest.Popup(prompt.targetUri ?: "", onAllow, onDeny),
)
}
return geckoResult
}

override fun onBeforeUnloadPrompt(
session: GeckoSession,
geckoPrompt: BeforeUnloadPrompt
geckoPrompt: BeforeUnloadPrompt,
): GeckoResult<PromptResponse>? {
val geckoResult = GeckoResult<PromptResponse>()
val title = geckoPrompt.title ?: ""
Expand All @@ -588,7 +593,7 @@ internal class GeckoPromptDelegate(private val geckoEngineSession: GeckoEngineSe

override fun onSharePrompt(
session: GeckoSession,
prompt: PromptDelegate.SharePrompt
prompt: PromptDelegate.SharePrompt,
): GeckoResult<PromptResponse> {
val geckoResult = GeckoResult<PromptResponse>()
val onSuccess = {
Expand All @@ -609,20 +614,20 @@ internal class GeckoPromptDelegate(private val geckoEngineSession: GeckoEngineSe
ShareData(
title = prompt.title,
text = prompt.text,
url = prompt.uri
url = prompt.uri,
),
onSuccess,
onFailure,
onDismiss
)
onDismiss,
),
)
}
return geckoResult
}

override fun onButtonPrompt(
session: GeckoSession,
prompt: PromptDelegate.ButtonPrompt
prompt: PromptDelegate.ButtonPrompt,
): GeckoResult<PromptResponse>? {
val geckoResult = GeckoResult<PromptResponse>()
val title = prompt.title ?: ""
Expand Down Expand Up @@ -652,18 +657,18 @@ internal class GeckoPromptDelegate(private val geckoEngineSession: GeckoEngineSe
"",
onConfirmPositiveButton,
onConfirmNegativeButton,
onDismiss
onDismiss,
) {
onDismiss(false)
}
},
)
}
return geckoResult
}

override fun onRepostConfirmPrompt(
session: GeckoSession,
prompt: PromptDelegate.RepostConfirmPrompt
prompt: PromptDelegate.RepostConfirmPrompt,
): GeckoResult<PromptResponse>? {
val geckoResult = GeckoResult<PromptResponse>()

Expand All @@ -683,8 +688,8 @@ internal class GeckoPromptDelegate(private val geckoEngineSession: GeckoEngineSe
onPromptRequest(
PromptRequest.Repost(
onConfirm,
onCancel
)
onCancel,
),
)
}
return geckoResult
Expand All @@ -700,7 +705,7 @@ internal class GeckoPromptDelegate(private val geckoEngineSession: GeckoEngineSe
onClear: () -> Unit,
format: String,
onConfirm: (String) -> Unit,
onDismiss: () -> Unit
onDismiss: () -> Unit,
) {
val initialDate = initialDateString.toDate(format)
val minDate = if (minDateString.isNullOrEmpty()) null else minDateString.toDate()
Expand Down Expand Up @@ -728,8 +733,8 @@ internal class GeckoPromptDelegate(private val geckoEngineSession: GeckoEngineSe
selectionType,
onSelect,
onClear,
onDismiss
)
onDismiss,
),
)
}
}
Expand Down
Loading