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

Commit 851fc13

Browse files
rocketsrogerAlexandru2909
andauthored
For #12151 - Add support for empty step value in TimePicker (Uplift) (#12840)
* For #12151 - Add support for empty step value in TimePicker * For #12151 - Fix ktlint issues for GeckoPromptDelegate.kt Co-authored-by: Alexandru2909 <aputanu@mozilla.com>
1 parent df429ed commit 851fc13

3 files changed

Lines changed: 281 additions & 177 deletions

File tree

components/browser/engine-gecko/src/main/java/mozilla/components/browser/engine/gecko/prompt/GeckoPromptDelegate.kt

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -397,15 +397,20 @@ internal class GeckoPromptDelegate(private val geckoEngineSession: GeckoEngineSe
397397
onConfirm("")
398398
}
399399
val initialDateString = prompt.defaultValue ?: ""
400+
val stepValue = if (prompt.stepValue.isNullOrBlank()) {
401+
null
402+
} else {
403+
prompt.stepValue
404+
}
400405

401406
val format = when (prompt.type) {
402407
DATE -> "yyyy-MM-dd"
403408
MONTH -> "yyyy-MM"
404409
WEEK -> "yyyy-'W'ww"
405410
TIME -> {
406-
if (shouldShowMillisecondsPicker(prompt.stepValue?.toFloat())) {
411+
if (shouldShowMillisecondsPicker(stepValue?.toFloat())) {
407412
"HH:mm:ss.SSS"
408-
} else if (shouldShowSecondsPicker(prompt.stepValue?.toFloat())) {
413+
} else if (shouldShowSecondsPicker(stepValue?.toFloat())) {
409414
"HH:mm:ss"
410415
} else {
411416
"HH:mm"
@@ -422,19 +427,19 @@ internal class GeckoPromptDelegate(private val geckoEngineSession: GeckoEngineSe
422427
initialDateString,
423428
prompt.minValue,
424429
prompt.maxValue,
425-
prompt.stepValue,
430+
stepValue,
426431
onClear,
427432
format,
428433
onConfirm,
429-
onDismiss
434+
onDismiss,
430435
)
431436

432437
return geckoResult
433438
}
434439

435440
override fun onAuthPrompt(
436441
session: GeckoSession,
437-
geckoPrompt: PromptDelegate.AuthPrompt
442+
geckoPrompt: PromptDelegate.AuthPrompt,
438443
): GeckoResult<PromptResponse>? {
439444
val geckoResult = GeckoResult<PromptResponse>()
440445
val title = geckoPrompt.title ?: ""
@@ -477,16 +482,16 @@ internal class GeckoPromptDelegate(private val geckoEngineSession: GeckoEngineSe
477482
previousFailed,
478483
isCrossOrigin,
479484
onConfirm,
480-
onDismiss
481-
)
485+
onDismiss,
486+
),
482487
)
483488
}
484489
return geckoResult
485490
}
486491

487492
override fun onTextPrompt(
488493
session: GeckoSession,
489-
prompt: PromptDelegate.TextPrompt
494+
prompt: PromptDelegate.TextPrompt,
490495
): GeckoResult<PromptResponse>? {
491496
val geckoResult = GeckoResult<PromptResponse>()
492497
val title = prompt.title ?: ""
@@ -507,8 +512,8 @@ internal class GeckoPromptDelegate(private val geckoEngineSession: GeckoEngineSe
507512
inputValue,
508513
false,
509514
onConfirm,
510-
onDismiss
511-
)
515+
onDismiss,
516+
),
512517
)
513518
}
514519

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

518523
override fun onColorPrompt(
519524
session: GeckoSession,
520-
prompt: PromptDelegate.ColorPrompt
525+
prompt: PromptDelegate.ColorPrompt,
521526
): GeckoResult<PromptResponse>? {
522527
val geckoResult = GeckoResult<PromptResponse>()
523528
val onConfirm: (String) -> Unit = {
@@ -531,15 +536,15 @@ internal class GeckoPromptDelegate(private val geckoEngineSession: GeckoEngineSe
531536

532537
geckoEngineSession.notifyObservers {
533538
onPromptRequest(
534-
PromptRequest.Color(defaultColor, onConfirm, onDismiss)
539+
PromptRequest.Color(defaultColor, onConfirm, onDismiss),
535540
)
536541
}
537542
return geckoResult
538543
}
539544

540545
override fun onPopupPrompt(
541546
session: GeckoSession,
542-
prompt: PromptDelegate.PopupPrompt
547+
prompt: PromptDelegate.PopupPrompt,
543548
): GeckoResult<PromptResponse> {
544549
val geckoResult = GeckoResult<PromptResponse>()
545550
val onAllow: () -> Unit = {
@@ -555,15 +560,15 @@ internal class GeckoPromptDelegate(private val geckoEngineSession: GeckoEngineSe
555560

556561
geckoEngineSession.notifyObservers {
557562
onPromptRequest(
558-
PromptRequest.Popup(prompt.targetUri ?: "", onAllow, onDeny)
563+
PromptRequest.Popup(prompt.targetUri ?: "", onAllow, onDeny),
559564
)
560565
}
561566
return geckoResult
562567
}
563568

564569
override fun onBeforeUnloadPrompt(
565570
session: GeckoSession,
566-
geckoPrompt: BeforeUnloadPrompt
571+
geckoPrompt: BeforeUnloadPrompt,
567572
): GeckoResult<PromptResponse>? {
568573
val geckoResult = GeckoResult<PromptResponse>()
569574
val title = geckoPrompt.title ?: ""
@@ -588,7 +593,7 @@ internal class GeckoPromptDelegate(private val geckoEngineSession: GeckoEngineSe
588593

589594
override fun onSharePrompt(
590595
session: GeckoSession,
591-
prompt: PromptDelegate.SharePrompt
596+
prompt: PromptDelegate.SharePrompt,
592597
): GeckoResult<PromptResponse> {
593598
val geckoResult = GeckoResult<PromptResponse>()
594599
val onSuccess = {
@@ -609,20 +614,20 @@ internal class GeckoPromptDelegate(private val geckoEngineSession: GeckoEngineSe
609614
ShareData(
610615
title = prompt.title,
611616
text = prompt.text,
612-
url = prompt.uri
617+
url = prompt.uri,
613618
),
614619
onSuccess,
615620
onFailure,
616-
onDismiss
617-
)
621+
onDismiss,
622+
),
618623
)
619624
}
620625
return geckoResult
621626
}
622627

623628
override fun onButtonPrompt(
624629
session: GeckoSession,
625-
prompt: PromptDelegate.ButtonPrompt
630+
prompt: PromptDelegate.ButtonPrompt,
626631
): GeckoResult<PromptResponse>? {
627632
val geckoResult = GeckoResult<PromptResponse>()
628633
val title = prompt.title ?: ""
@@ -652,18 +657,18 @@ internal class GeckoPromptDelegate(private val geckoEngineSession: GeckoEngineSe
652657
"",
653658
onConfirmPositiveButton,
654659
onConfirmNegativeButton,
655-
onDismiss
660+
onDismiss,
656661
) {
657662
onDismiss(false)
658-
}
663+
},
659664
)
660665
}
661666
return geckoResult
662667
}
663668

664669
override fun onRepostConfirmPrompt(
665670
session: GeckoSession,
666-
prompt: PromptDelegate.RepostConfirmPrompt
671+
prompt: PromptDelegate.RepostConfirmPrompt,
667672
): GeckoResult<PromptResponse>? {
668673
val geckoResult = GeckoResult<PromptResponse>()
669674

@@ -683,8 +688,8 @@ internal class GeckoPromptDelegate(private val geckoEngineSession: GeckoEngineSe
683688
onPromptRequest(
684689
PromptRequest.Repost(
685690
onConfirm,
686-
onCancel
687-
)
691+
onCancel,
692+
),
688693
)
689694
}
690695
return geckoResult
@@ -700,7 +705,7 @@ internal class GeckoPromptDelegate(private val geckoEngineSession: GeckoEngineSe
700705
onClear: () -> Unit,
701706
format: String,
702707
onConfirm: (String) -> Unit,
703-
onDismiss: () -> Unit
708+
onDismiss: () -> Unit,
704709
) {
705710
val initialDate = initialDateString.toDate(format)
706711
val minDate = if (minDateString.isNullOrEmpty()) null else minDateString.toDate()
@@ -728,8 +733,8 @@ internal class GeckoPromptDelegate(private val geckoEngineSession: GeckoEngineSe
728733
selectionType,
729734
onSelect,
730735
onClear,
731-
onDismiss
732-
)
736+
onDismiss,
737+
),
733738
)
734739
}
735740
}

0 commit comments

Comments
 (0)